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IAAI,CAACE,OAAN,iDAAiB,EAAjB,EAAqBD,WAArB,EAAtB,CAAR,CACH,CAHuB,CAIxBG,WAAW,CAAEf,sBAAsB,CAAC0B,kBAJZ,CAA5B,EAOA,MAAOnB,CAAAA,sBAAP,CACH,CAED,+DAAe,CAAET,wBAAwB,CAAxBA,wBAAF,CAA4BH,UAAU,CAAVA,UAA5B,CAAf","sources":["webpack://giveeasy.cloud/./wwwroot/jsx/utils/root-utils.jsx"],"sourcesContent":["import React from 'react';\r\nimport ReactIs from 'react-is';\r\n\r\nfunction parseKey(key) {\r\n // react attribute names use camelcase with no hyphens.\r\n const parts = key.split('-');\r\n if (parts.length > 1) {\r\n const newKeyParts = parts.map((c, index) => {\r\n if (index > 0) {\r\n return c.charAt(0).toUpperCase() + c.slice(1);\r\n }\r\n return c;\r\n });\r\n\r\n return newKeyParts.join('');\r\n }\r\n\r\n return key;\r\n}\r\n\r\nfunction convertStyleAttr(attr) {\r\n // NB: This will break if urls or data-uris are passed through the style attribute.\r\n // e.g.content: \"data:image/svg+xml,data:text/plain;charset=utf-8,...\"\r\n const styles = attr.split(';');\r\n\r\n const styleObject = {};\r\n if (Array.isArray(styles)) {\r\n styles.forEach((s) => {\r\n if (s) {\r\n const kv = s.split(':');\r\n const key = parseKey(kv[0]);\r\n const value = kv[1];\r\n\r\n styleObject[key] = value;\r\n }\r\n });\r\n }\r\n\r\n return styleObject;\r\n}\r\n\r\nfunction attr2Props(attributes) {\r\n const props = attributes.reduce((o, kv) => {\r\n const x = o;\r\n let n = kv.name;\r\n let v = kv.value;\r\n if (n === 'style') {\r\n v = convertStyleAttr(v);\r\n }\r\n if (n === 'class') {\r\n n = 'className';\r\n }\r\n // See https://reactjs.org/docs/uncontrolled-components.html#default-values\r\n if (n === 'value' && x.type === 'checkbox') {\r\n n = 'defaultChecked';\r\n }\r\n if (n === 'value' && x.type !== 'submit') {\r\n n = 'defaultValue';\r\n }\r\n if (n === 'checked') {\r\n n = 'defaultChecked';\r\n }\r\n if (n === 'readonly') {\r\n n = 'readOnly';\r\n }\r\n if (v === 'true') {\r\n v = true;\r\n }\r\n if (v === 'false') {\r\n v = false;\r\n }\r\n // defaultChecked and checked are bool values.\r\n // The only way to get an unchecked checkbox is by omitting these properties\r\n // Allow only 'checked' value as the 'value' attribute doesn't seem to change\r\n if (!(n === 'defaultChecked' && kv.value !== 'checked')) {\r\n x[n] = v;\r\n }\r\n\r\n return x;\r\n }, {});\r\n return props;\r\n}\r\n\r\nconst HtmlToReact = require('html-to-react');\r\n\r\n// Resolves and loads module content\r\nexport function requireAll(requireContext) {\r\n return requireContext.keys().map(requireContext);\r\n}\r\n\r\n// Important! This allows us to nest JSX components and HTML components inside each other\r\n// Everything inside a element will be converted into React\r\nexport function setProcessingInstuctions(modules) {\r\n const processNodeDefinitions = new HtmlToReact.ProcessNodeDefinitions(React);\r\n\r\n const components = [];\r\n for (const m of modules) {\r\n if (m.default) { // default is the module export class\r\n const c = m.default;\r\n\r\n // https://www.npmjs.com/package/react-is\r\n if (ReactIs.isValidElementType(c)) {\r\n components.push(m.default);\r\n }\r\n }\r\n }\r\n\r\n // Order matters. Instructions are processed in\r\n // the order they're defined\r\n const processingInstructions = [];\r\n const doNotProcess = [];\r\n\r\n // Instruct the parser to replace JSX classes with their appropriate components\r\n for (const c of components) {\r\n const type = { component: c }; // This is needed to trick JSX into using the component type\r\n\r\n processingInstructions.push(\r\n {\r\n shouldProcessNode(node) {\r\n try {\r\n c.name.toLowerCase();\r\n } catch {\r\n return false;\r\n }\r\n return (node.tagName ?? '').toLowerCase() === c.name.toLowerCase() && !doNotProcess.includes(c.name.toLowerCase());\r\n },\r\n processNode(node, children, index) {\r\n const props = attr2Props(node?.attributes ?? []);\r\n\r\n // filter out any whitespace children\r\n const filteredChildren = React.Children\r\n .toArray(children)\r\n .filter((child) => {\r\n if (child.type || child.replace(/\\s/g, '').length > 0) {\r\n return child;\r\n }\r\n return undefined;\r\n });\r\n\r\n const r = (\r\n \r\n {filteredChildren}\r\n \r\n );\r\n return r;\r\n },\r\n // replaceChildren: true// NB: replaceChildren: true tells React to own the child nodes\r\n },\r\n );\r\n }\r\n\r\n // Add an uncontrolled state handler for pure elements\r\n // See https://reactjs.org/docs/uncontrolled-components.html\r\n processingInstructions.push({\r\n shouldProcessNode(node) {\r\n return (node.tagName ?? '').toLowerCase().includes('input') && !doNotProcess.includes((node.tagName ?? '').toLowerCase());\r\n },\r\n processNode(node, children, index) {\r\n // eslint-disable-next-line react/destructuring-assignment\r\n const reactProps = attr2Props(node.attributes);\r\n return (\r\n \r\n );\r\n },\r\n });\r\n\r\n // Add the default case handler for a plain HTML node\r\n processingInstructions.push({\r\n shouldProcessNode(node) {\r\n return !doNotProcess.includes((node.tagName ?? '').toLowerCase());\r\n },\r\n processNode: processNodeDefinitions.processDefaultNode,\r\n });\r\n\r\n return processingInstructions;\r\n}\r\n\r\nexport default { setProcessingInstuctions, requireAll };\r\n"],"names":["React","ReactIs","parseKey","key","parts","split","length","newKeyParts","map","c","index","charAt","toUpperCase","slice","join","convertStyleAttr","attr","styles","styleObject","Array","isArray","forEach","s","kv","value","attr2Props","attributes","props","reduce","o","x","n","name","v","type","HtmlToReact","require","requireAll","requireContext","keys","setProcessingInstuctions","modules","processNodeDefinitions","ProcessNodeDefinitions","components","m","default","isValidElementType","push","processingInstructions","doNotProcess","component","shouldProcessNode","node","toLowerCase","tagName","includes","processNode","children","filteredChildren","Children","toArray","filter","child","replace","undefined","r","reactProps","processDefaultNode"],"sourceRoot":""}