@wordpress/element 6.32.0 → 6.32.1-next.b8c8708f3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/build/create-interpolate-element.js +79 -183
  2. package/build/create-interpolate-element.js.map +7 -1
  3. package/build/index.js +52 -74
  4. package/build/index.js.map +7 -1
  5. package/build/platform.android.js +29 -16
  6. package/build/platform.android.js.map +7 -1
  7. package/build/platform.ios.js +29 -16
  8. package/build/platform.ios.js.map +7 -1
  9. package/build/platform.js +25 -40
  10. package/build/platform.js.map +7 -1
  11. package/build/raw-html.js +28 -47
  12. package/build/raw-html.js.map +7 -1
  13. package/build/react-platform.js +43 -55
  14. package/build/react-platform.js.map +7 -1
  15. package/build/react.js +114 -411
  16. package/build/react.js.map +7 -1
  17. package/build/serialize.js +418 -325
  18. package/build/serialize.js.map +7 -1
  19. package/build/utils.js +29 -15
  20. package/build/utils.js.map +7 -1
  21. package/build-module/create-interpolate-element.js +63 -175
  22. package/build-module/create-interpolate-element.js.map +7 -1
  23. package/build-module/index.js +14 -8
  24. package/build-module/index.js.map +7 -1
  25. package/build-module/platform.android.js +10 -10
  26. package/build-module/platform.android.js.map +7 -1
  27. package/build-module/platform.ios.js +10 -10
  28. package/build-module/platform.ios.js.map +7 -1
  29. package/build-module/platform.js +7 -36
  30. package/build-module/platform.js.map +7 -1
  31. package/build-module/raw-html.js +11 -44
  32. package/build-module/raw-html.js.map +7 -1
  33. package/build-module/react-platform.js +20 -71
  34. package/build-module/react-platform.js.map +7 -1
  35. package/build-module/react.js +91 -255
  36. package/build-module/react.js.map +7 -1
  37. package/build-module/serialize.js +382 -311
  38. package/build-module/serialize.js.map +7 -1
  39. package/build-module/utils.js +7 -10
  40. package/build-module/utils.js.map +7 -1
  41. package/package.json +11 -4
  42. package/build/react-platform.native.js +0 -22
  43. package/build/react-platform.native.js.map +0 -1
  44. package/build-module/react-platform.native.js +0 -15
  45. package/build-module/react-platform.native.js.map +0 -1
@@ -1 +1,7 @@
1
- {"version":3,"names":["createElement","cloneElement","Fragment","isValidElement","indoc","offset","output","stack","tokenizer","createFrame","element","tokenStart","tokenLength","prevOffset","leadingTextStart","children","createInterpolateElement","interpolatedString","conversionMap","lastIndex","isValidConversionMap","TypeError","proceed","isObject","values","Object","length","every","next","nextToken","tokenType","name","startOffset","stackDepth","addText","stackLeadingText","pop","push","substr","addChild","closeOuterElement","stackTop","text","frame","matches","exec","startedAt","index","match","isClosing","isSelfClosed","parent","endOffset"],"sources":["@wordpress/element/src/create-interpolate-element.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateElement,\n\tcloneElement,\n\tFragment,\n\tisValidElement,\n\ttype Element as ReactElement,\n} from './react';\n\nlet indoc: string;\nlet offset: number;\nlet output: ( string | ReactElement )[];\nlet stack: Frame[];\n\n/**\n * Matches tags in the localized string\n *\n * This is used for extracting the tag pattern groups for parsing the localized\n * string and along with the map converting it to a react element.\n *\n * There are four references extracted using this tokenizer:\n *\n * match: Full match of the tag (i.e. <strong>, </strong>, <br/>)\n * isClosing: The closing slash, if it exists.\n * name: The name portion of the tag (strong, br) (if )\n * isSelfClosed: The slash on a self closing tag, if it exists.\n */\nconst tokenizer = /<(\\/)?(\\w+)\\s*(\\/)?>/g;\n\ninterface Frame {\n\t/**\n\t * A parent element which may still have nested children not yet parsed.\n\t */\n\telement: ReactElement;\n\n\t/**\n\t * Offset at which parent element first appears.\n\t */\n\ttokenStart: number;\n\n\t/**\n\t * Length of string marking start of parent element.\n\t */\n\ttokenLength: number;\n\n\t/**\n\t * Running offset at which parsing should continue.\n\t */\n\tprevOffset?: number;\n\n\t/**\n\t * Offset at which last closing element finished, used for finding text between elements.\n\t */\n\tleadingTextStart?: number | null;\n\n\t/**\n\t * Children.\n\t */\n\tchildren: ( string | ReactElement )[];\n}\n\n/**\n * Tracks recursive-descent parse state.\n *\n * This is a Stack frame holding parent elements until all children have been\n * parsed.\n *\n * @private\n * @param element A parent element which may still have\n * nested children not yet parsed.\n * @param tokenStart Offset at which parent element first\n * appears.\n * @param tokenLength Length of string marking start of parent\n * element.\n * @param prevOffset Running offset at which parsing should\n * continue.\n * @param leadingTextStart Offset at which last closing element\n * finished, used for finding text between\n * elements.\n *\n * @return The stack frame tracking parse progress.\n */\nfunction createFrame(\n\telement: ReactElement,\n\ttokenStart: number,\n\ttokenLength: number,\n\tprevOffset?: number,\n\tleadingTextStart?: number | null\n): Frame {\n\treturn {\n\t\telement,\n\t\ttokenStart,\n\t\ttokenLength,\n\t\tprevOffset,\n\t\tleadingTextStart,\n\t\tchildren: [],\n\t};\n}\n\n/**\n * This function creates an interpolated element from a passed in string with\n * specific tags matching how the string should be converted to an element via\n * the conversion map value.\n *\n * @example\n * For example, for the given string:\n *\n * \"This is a <span>string</span> with <a>a link</a> and a self-closing\n * <CustomComponentB/> tag\"\n *\n * You would have something like this as the conversionMap value:\n *\n * ```js\n * {\n * span: <span />,\n * a: <a href={ 'https://github.com' } />,\n * CustomComponentB: <CustomComponent />,\n * }\n * ```\n *\n * @param interpolatedString The interpolation string to be parsed.\n * @param conversionMap The map used to convert the string to\n * a react element.\n * @throws {TypeError}\n * @return A wp element.\n */\nconst createInterpolateElement = (\n\tinterpolatedString: string,\n\tconversionMap: Record< string, ReactElement >\n): ReactElement => {\n\tindoc = interpolatedString;\n\toffset = 0;\n\toutput = [];\n\tstack = [];\n\ttokenizer.lastIndex = 0;\n\n\tif ( ! isValidConversionMap( conversionMap ) ) {\n\t\tthrow new TypeError(\n\t\t\t'The conversionMap provided is not valid. It must be an object with values that are React Elements'\n\t\t);\n\t}\n\n\tdo {\n\t\t// twiddle our thumbs\n\t} while ( proceed( conversionMap ) );\n\treturn createElement( Fragment, null, ...output );\n};\n\n/**\n * Validate conversion map.\n *\n * A map is considered valid if it's an object and every value in the object\n * is a React Element\n *\n * @private\n *\n * @param conversionMap The map being validated.\n *\n * @return True means the map is valid.\n */\nconst isValidConversionMap = (\n\tconversionMap: Record< string, ReactElement >\n): boolean => {\n\tconst isObject =\n\t\ttypeof conversionMap === 'object' && conversionMap !== null;\n\tconst values = isObject && Object.values( conversionMap );\n\treturn (\n\t\tisObject &&\n\t\tvalues.length > 0 &&\n\t\tvalues.every( ( element ) => isValidElement( element ) )\n\t);\n};\n\ntype TokenType = 'no-more-tokens' | 'self-closed' | 'opener' | 'closer';\ntype TokenResult =\n\t| [ TokenType & 'no-more-tokens' ]\n\t| [\n\t\t\tTokenType & ( 'self-closed' | 'opener' | 'closer' ),\n\t\t\tstring,\n\t\t\tnumber,\n\t\t\tnumber,\n\t ];\n\n/**\n * This is the iterator over the matches in the string.\n *\n * @private\n *\n * @param conversionMap The conversion map for the string.\n *\n * @return true for continuing to iterate, false for finished.\n */\nfunction proceed( conversionMap: Record< string, ReactElement > ): boolean {\n\tconst next = nextToken();\n\tconst [ tokenType, name, startOffset, tokenLength ] = next;\n\tconst stackDepth = stack.length;\n\tconst leadingTextStart = startOffset > offset ? offset : null;\n\tif ( name && ! conversionMap[ name ] ) {\n\t\taddText();\n\t\treturn false;\n\t}\n\tswitch ( tokenType ) {\n\t\tcase 'no-more-tokens':\n\t\t\tif ( stackDepth !== 0 ) {\n\t\t\t\tconst { leadingTextStart: stackLeadingText, tokenStart } =\n\t\t\t\t\tstack.pop();\n\t\t\t\toutput.push( indoc.substr( stackLeadingText, tokenStart ) );\n\t\t\t}\n\t\t\taddText();\n\t\t\treturn false;\n\n\t\tcase 'self-closed':\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\tif ( null !== leadingTextStart ) {\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tindoc.substr(\n\t\t\t\t\t\t\tleadingTextStart,\n\t\t\t\t\t\t\tstartOffset - leadingTextStart\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\toutput.push( conversionMap[ name ] );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we found an inner element.\n\t\t\taddChild(\n\t\t\t\tcreateFrame( conversionMap[ name ], startOffset, tokenLength )\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'opener':\n\t\t\tstack.push(\n\t\t\t\tcreateFrame(\n\t\t\t\t\tconversionMap[ name ],\n\t\t\t\t\tstartOffset,\n\t\t\t\t\ttokenLength,\n\t\t\t\t\tstartOffset + tokenLength,\n\t\t\t\t\tleadingTextStart\n\t\t\t\t)\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'closer':\n\t\t\t// If we're not nesting then this is easy - close the block.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\tcloseOuterElement( startOffset );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we're nested and we have to close out the current\n\t\t\t// block and add it as a innerBlock to the parent.\n\t\t\tconst stackTop = stack.pop();\n\t\t\tconst text = indoc.substr(\n\t\t\t\tstackTop.prevOffset,\n\t\t\t\tstartOffset - stackTop.prevOffset\n\t\t\t);\n\t\t\tstackTop.children.push( text );\n\t\t\tstackTop.prevOffset = startOffset + tokenLength;\n\t\t\tconst frame = createFrame(\n\t\t\t\tstackTop.element,\n\t\t\t\tstackTop.tokenStart,\n\t\t\t\tstackTop.tokenLength,\n\t\t\t\tstartOffset + tokenLength\n\t\t\t);\n\t\t\tframe.children = stackTop.children;\n\t\t\taddChild( frame );\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tdefault:\n\t\t\taddText();\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Grabs the next token match in the string and returns it's details.\n *\n * @private\n *\n * @return An array of details for the token matched.\n */\nfunction nextToken(): TokenResult {\n\tconst matches = tokenizer.exec( indoc );\n\t// We have no more tokens.\n\tif ( null === matches ) {\n\t\treturn [ 'no-more-tokens' ];\n\t}\n\tconst startedAt = matches.index;\n\tconst [ match, isClosing, name, isSelfClosed ] = matches;\n\tconst length = match.length;\n\tif ( isSelfClosed ) {\n\t\treturn [ 'self-closed', name, startedAt, length ];\n\t}\n\tif ( isClosing ) {\n\t\treturn [ 'closer', name, startedAt, length ];\n\t}\n\treturn [ 'opener', name, startedAt, length ];\n}\n\n/**\n * Pushes text extracted from the indoc string to the output stack given the\n * current rawLength value and offset (if rawLength is provided ) or the\n * indoc.length and offset.\n *\n * @private\n */\nfunction addText(): void {\n\tconst length = indoc.length - offset;\n\tif ( 0 === length ) {\n\t\treturn;\n\t}\n\toutput.push( indoc.substr( offset, length ) );\n}\n\n/**\n * Pushes a child element to the associated parent element's children for the\n * parent currently active in the stack.\n *\n * @private\n *\n * @param {Frame} frame The Frame containing the child element and it's\n * token information.\n */\nfunction addChild( frame: Frame ): void {\n\tconst { element, tokenStart, tokenLength, prevOffset, children } = frame;\n\tconst parent = stack[ stack.length - 1 ];\n\tconst text = indoc.substr(\n\t\tparent.prevOffset,\n\t\ttokenStart - parent.prevOffset\n\t);\n\n\tif ( text ) {\n\t\tparent.children.push( text );\n\t}\n\n\tparent.children.push( cloneElement( element, null, ...children ) );\n\tparent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;\n}\n\n/**\n * This is called for closing tags. It creates the element currently active in\n * the stack.\n *\n * @private\n *\n * @param {number} endOffset Offset at which the closing tag for the element\n * begins in the string. If this is greater than the\n * prevOffset attached to the element, then this\n * helps capture any remaining nested text nodes in\n * the element.\n */\nfunction closeOuterElement( endOffset: number ): void {\n\tconst { element, leadingTextStart, prevOffset, tokenStart, children } =\n\t\tstack.pop();\n\n\tconst text = endOffset\n\t\t? indoc.substr( prevOffset, endOffset - prevOffset )\n\t\t: indoc.substr( prevOffset );\n\n\tif ( text ) {\n\t\tchildren.push( text );\n\t}\n\n\tif ( null !== leadingTextStart ) {\n\t\toutput.push(\n\t\t\tindoc.substr( leadingTextStart, tokenStart - leadingTextStart )\n\t\t);\n\t}\n\n\toutput.push( cloneElement( element, null, ...children ) );\n}\n\nexport default createInterpolateElement;\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,YAAY,EACZC,QAAQ,EACRC,cAAc,QAER,SAAS;AAEhB,IAAIC,KAAa;AACjB,IAAIC,MAAc;AAClB,IAAIC,MAAmC;AACvC,IAAIC,KAAc;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,SAAS,GAAG,uBAAuB;AAkCzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,WAAWA,CACnBC,OAAqB,EACrBC,UAAkB,EAClBC,WAAmB,EACnBC,UAAmB,EACnBC,gBAAgC,EACxB;EACR,OAAO;IACNJ,OAAO;IACPC,UAAU;IACVC,WAAW;IACXC,UAAU;IACVC,gBAAgB;IAChBC,QAAQ,EAAE;EACX,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,wBAAwB,GAAGA,CAChCC,kBAA0B,EAC1BC,aAA6C,KAC3B;EAClBd,KAAK,GAAGa,kBAAkB;EAC1BZ,MAAM,GAAG,CAAC;EACVC,MAAM,GAAG,EAAE;EACXC,KAAK,GAAG,EAAE;EACVC,SAAS,CAACW,SAAS,GAAG,CAAC;EAEvB,IAAK,CAAEC,oBAAoB,CAAEF,aAAc,CAAC,EAAG;IAC9C,MAAM,IAAIG,SAAS,CAClB,mGACD,CAAC;EACF;EAEA,GAAG;IACF;EAAA,CACA,QAASC,OAAO,CAAEJ,aAAc,CAAC;EAClC,OAAOlB,aAAa,CAAEE,QAAQ,EAAE,IAAI,EAAE,GAAGI,MAAO,CAAC;AAClD,CAAC;;AAED;AACA;AACA;AACA;AACA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IAAI,CACVjC,KAAK,CAACkC,MAAM,CAAExB,gBAAgB,EAAEH,UAAU,GAAGG,gBAAiB,CAC/D,CAAC;EACF;EAEAR,MAAM,CAAC+B,IAAI,CAAEpC,YAAY,CAAES,OAAO,EAAE,IAAI,EAAE,GAAGK,QAAS,CAAE,CAAC;AAC1D;AAEA,eAAeC,wBAAwB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/create-interpolate-element.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport {\n\tcreateElement,\n\tcloneElement,\n\tFragment,\n\tisValidElement,\n\ttype Element as ReactElement,\n} from './react';\n\nlet indoc: string;\nlet offset: number;\nlet output: ( string | ReactElement )[];\nlet stack: Frame[];\n\n/**\n * Matches tags in the localized string\n *\n * This is used for extracting the tag pattern groups for parsing the localized\n * string and along with the map converting it to a react element.\n *\n * There are four references extracted using this tokenizer:\n *\n * match: Full match of the tag (i.e. <strong>, </strong>, <br/>)\n * isClosing: The closing slash, if it exists.\n * name: The name portion of the tag (strong, br) (if )\n * isSelfClosed: The slash on a self closing tag, if it exists.\n */\nconst tokenizer = /<(\\/)?(\\w+)\\s*(\\/)?>/g;\n\ninterface Frame {\n\t/**\n\t * A parent element which may still have nested children not yet parsed.\n\t */\n\telement: ReactElement;\n\n\t/**\n\t * Offset at which parent element first appears.\n\t */\n\ttokenStart: number;\n\n\t/**\n\t * Length of string marking start of parent element.\n\t */\n\ttokenLength: number;\n\n\t/**\n\t * Running offset at which parsing should continue.\n\t */\n\tprevOffset?: number;\n\n\t/**\n\t * Offset at which last closing element finished, used for finding text between elements.\n\t */\n\tleadingTextStart?: number | null;\n\n\t/**\n\t * Children.\n\t */\n\tchildren: ( string | ReactElement )[];\n}\n\n/**\n * Tracks recursive-descent parse state.\n *\n * This is a Stack frame holding parent elements until all children have been\n * parsed.\n *\n * @private\n * @param element A parent element which may still have\n * nested children not yet parsed.\n * @param tokenStart Offset at which parent element first\n * appears.\n * @param tokenLength Length of string marking start of parent\n * element.\n * @param prevOffset Running offset at which parsing should\n * continue.\n * @param leadingTextStart Offset at which last closing element\n * finished, used for finding text between\n * elements.\n *\n * @return The stack frame tracking parse progress.\n */\nfunction createFrame(\n\telement: ReactElement,\n\ttokenStart: number,\n\ttokenLength: number,\n\tprevOffset?: number,\n\tleadingTextStart?: number | null\n): Frame {\n\treturn {\n\t\telement,\n\t\ttokenStart,\n\t\ttokenLength,\n\t\tprevOffset,\n\t\tleadingTextStart,\n\t\tchildren: [],\n\t};\n}\n\n/**\n * This function creates an interpolated element from a passed in string with\n * specific tags matching how the string should be converted to an element via\n * the conversion map value.\n *\n * @example\n * For example, for the given string:\n *\n * \"This is a <span>string</span> with <a>a link</a> and a self-closing\n * <CustomComponentB/> tag\"\n *\n * You would have something like this as the conversionMap value:\n *\n * ```js\n * {\n * span: <span />,\n * a: <a href={ 'https://github.com' } />,\n * CustomComponentB: <CustomComponent />,\n * }\n * ```\n *\n * @param interpolatedString The interpolation string to be parsed.\n * @param conversionMap The map used to convert the string to\n * a react element.\n * @throws {TypeError}\n * @return A wp element.\n */\nconst createInterpolateElement = (\n\tinterpolatedString: string,\n\tconversionMap: Record< string, ReactElement >\n): ReactElement => {\n\tindoc = interpolatedString;\n\toffset = 0;\n\toutput = [];\n\tstack = [];\n\ttokenizer.lastIndex = 0;\n\n\tif ( ! isValidConversionMap( conversionMap ) ) {\n\t\tthrow new TypeError(\n\t\t\t'The conversionMap provided is not valid. It must be an object with values that are React Elements'\n\t\t);\n\t}\n\n\tdo {\n\t\t// twiddle our thumbs\n\t} while ( proceed( conversionMap ) );\n\treturn createElement( Fragment, null, ...output );\n};\n\n/**\n * Validate conversion map.\n *\n * A map is considered valid if it's an object and every value in the object\n * is a React Element\n *\n * @private\n *\n * @param conversionMap The map being validated.\n *\n * @return True means the map is valid.\n */\nconst isValidConversionMap = (\n\tconversionMap: Record< string, ReactElement >\n): boolean => {\n\tconst isObject =\n\t\ttypeof conversionMap === 'object' && conversionMap !== null;\n\tconst values = isObject && Object.values( conversionMap );\n\treturn (\n\t\tisObject &&\n\t\tvalues.length > 0 &&\n\t\tvalues.every( ( element ) => isValidElement( element ) )\n\t);\n};\n\ntype TokenType = 'no-more-tokens' | 'self-closed' | 'opener' | 'closer';\ntype TokenResult =\n\t| [ TokenType & 'no-more-tokens' ]\n\t| [\n\t\t\tTokenType & ( 'self-closed' | 'opener' | 'closer' ),\n\t\t\tstring,\n\t\t\tnumber,\n\t\t\tnumber,\n\t ];\n\n/**\n * This is the iterator over the matches in the string.\n *\n * @private\n *\n * @param conversionMap The conversion map for the string.\n *\n * @return true for continuing to iterate, false for finished.\n */\nfunction proceed( conversionMap: Record< string, ReactElement > ): boolean {\n\tconst next = nextToken();\n\tconst [ tokenType, name, startOffset, tokenLength ] = next;\n\tconst stackDepth = stack.length;\n\tconst leadingTextStart = startOffset > offset ? offset : null;\n\tif ( name && ! conversionMap[ name ] ) {\n\t\taddText();\n\t\treturn false;\n\t}\n\tswitch ( tokenType ) {\n\t\tcase 'no-more-tokens':\n\t\t\tif ( stackDepth !== 0 ) {\n\t\t\t\tconst { leadingTextStart: stackLeadingText, tokenStart } =\n\t\t\t\t\tstack.pop();\n\t\t\t\toutput.push( indoc.substr( stackLeadingText, tokenStart ) );\n\t\t\t}\n\t\t\taddText();\n\t\t\treturn false;\n\n\t\tcase 'self-closed':\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\tif ( null !== leadingTextStart ) {\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tindoc.substr(\n\t\t\t\t\t\t\tleadingTextStart,\n\t\t\t\t\t\t\tstartOffset - leadingTextStart\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\toutput.push( conversionMap[ name ] );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we found an inner element.\n\t\t\taddChild(\n\t\t\t\tcreateFrame( conversionMap[ name ], startOffset, tokenLength )\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'opener':\n\t\t\tstack.push(\n\t\t\t\tcreateFrame(\n\t\t\t\t\tconversionMap[ name ],\n\t\t\t\t\tstartOffset,\n\t\t\t\t\ttokenLength,\n\t\t\t\t\tstartOffset + tokenLength,\n\t\t\t\t\tleadingTextStart\n\t\t\t\t)\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'closer':\n\t\t\t// If we're not nesting then this is easy - close the block.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\tcloseOuterElement( startOffset );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we're nested and we have to close out the current\n\t\t\t// block and add it as a innerBlock to the parent.\n\t\t\tconst stackTop = stack.pop();\n\t\t\tconst text = indoc.substr(\n\t\t\t\tstackTop.prevOffset,\n\t\t\t\tstartOffset - stackTop.prevOffset\n\t\t\t);\n\t\t\tstackTop.children.push( text );\n\t\t\tstackTop.prevOffset = startOffset + tokenLength;\n\t\t\tconst frame = createFrame(\n\t\t\t\tstackTop.element,\n\t\t\t\tstackTop.tokenStart,\n\t\t\t\tstackTop.tokenLength,\n\t\t\t\tstartOffset + tokenLength\n\t\t\t);\n\t\t\tframe.children = stackTop.children;\n\t\t\taddChild( frame );\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tdefault:\n\t\t\taddText();\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Grabs the next token match in the string and returns it's details.\n *\n * @private\n *\n * @return An array of details for the token matched.\n */\nfunction nextToken(): TokenResult {\n\tconst matches = tokenizer.exec( indoc );\n\t// We have no more tokens.\n\tif ( null === matches ) {\n\t\treturn [ 'no-more-tokens' ];\n\t}\n\tconst startedAt = matches.index;\n\tconst [ match, isClosing, name, isSelfClosed ] = matches;\n\tconst length = match.length;\n\tif ( isSelfClosed ) {\n\t\treturn [ 'self-closed', name, startedAt, length ];\n\t}\n\tif ( isClosing ) {\n\t\treturn [ 'closer', name, startedAt, length ];\n\t}\n\treturn [ 'opener', name, startedAt, length ];\n}\n\n/**\n * Pushes text extracted from the indoc string to the output stack given the\n * current rawLength value and offset (if rawLength is provided ) or the\n * indoc.length and offset.\n *\n * @private\n */\nfunction addText(): void {\n\tconst length = indoc.length - offset;\n\tif ( 0 === length ) {\n\t\treturn;\n\t}\n\toutput.push( indoc.substr( offset, length ) );\n}\n\n/**\n * Pushes a child element to the associated parent element's children for the\n * parent currently active in the stack.\n *\n * @private\n *\n * @param {Frame} frame The Frame containing the child element and it's\n * token information.\n */\nfunction addChild( frame: Frame ): void {\n\tconst { element, tokenStart, tokenLength, prevOffset, children } = frame;\n\tconst parent = stack[ stack.length - 1 ];\n\tconst text = indoc.substr(\n\t\tparent.prevOffset,\n\t\ttokenStart - parent.prevOffset\n\t);\n\n\tif ( text ) {\n\t\tparent.children.push( text );\n\t}\n\n\tparent.children.push( cloneElement( element, null, ...children ) );\n\tparent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;\n}\n\n/**\n * This is called for closing tags. It creates the element currently active in\n * the stack.\n *\n * @private\n *\n * @param {number} endOffset Offset at which the closing tag for the element\n * begins in the string. If this is greater than the\n * prevOffset attached to the element, then this\n * helps capture any remaining nested text nodes in\n * the element.\n */\nfunction closeOuterElement( endOffset: number ): void {\n\tconst { element, leadingTextStart, prevOffset, tokenStart, children } =\n\t\tstack.pop();\n\n\tconst text = endOffset\n\t\t? indoc.substr( prevOffset, endOffset - prevOffset )\n\t\t: indoc.substr( prevOffset );\n\n\tif ( text ) {\n\t\tchildren.push( text );\n\t}\n\n\tif ( null !== leadingTextStart ) {\n\t\toutput.push(\n\t\t\tindoc.substr( leadingTextStart, tokenStart - leadingTextStart )\n\t\t);\n\t}\n\n\toutput.push( cloneElement( element, null, ...children ) );\n}\n\nexport default createInterpolateElement;\n"],
5
+ "mappings": "AAGA;AAAA,EACC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,MAAO;AAAA,EACjD;AACA,MAAK,WAAY;AAChB,WAAO,CAAE,UAAU,MAAM,WAAW,MAAO;AAAA,EAC5C;AACA,SAAO,CAAE,UAAU,MAAM,WAAW,MAAO;AAC5C;AASA,SAAS,UAAgB;AACxB,QAAM,SAAS,MAAM,SAAS;AAC9B,MAAK,MAAM,QAAS;AACnB;AAAA,EACD;AACA,SAAO,KAAM,MAAM,OAAQ,QAAQ,MAAO,CAAE;AAC7C;AAWA,SAAS,SAAU,OAAqB;AACvC,QAAM,EAAE,SAAS,YAAY,aAAa,YAAY,SAAS,IAAI;AACnE,QAAM,SAAS,MAAO,MAAM,SAAS,CAAE;AACvC,QAAM,OAAO,MAAM;AAAA,IAClB,OAAO;AAAA,IACP,aAAa,OAAO;AAAA,EACrB;AAEA,MAAK,MAAO;AACX,WAAO,SAAS,KAAM,IAAK;AAAA,EAC5B;AAEA,SAAO,SAAS,KAAM,aAAc,SAAS,MAAM,GAAG,QAAS,CAAE;AACjE,SAAO,aAAa,aAAa,aAAa,aAAa;AAC5D;AAcA,SAAS,kBAAmB,WAA0B;AACrD,QAAM,EAAE,SAAS,kBAAkB,YAAY,YAAY,SAAS,IACnE,MAAM,IAAI;AAEX,QAAM,OAAO,YACV,MAAM,OAAQ,YAAY,YAAY,UAAW,IACjD,MAAM,OAAQ,UAAW;AAE5B,MAAK,MAAO;AACX,aAAS,KAAM,IAAK;AAAA,EACrB;AAEA,MAAK,SAAS,kBAAmB;AAChC,WAAO;AAAA,MACN,MAAM,OAAQ,kBAAkB,aAAa,gBAAiB;AAAA,IAC/D;AAAA,EACD;AAEA,SAAO,KAAM,aAAc,SAAS,MAAM,GAAG,QAAS,CAAE;AACzD;AAEA,IAAO,qCAAQ;",
6
+ "names": []
7
+ }
@@ -1,8 +1,14 @@
1
- export { default as createInterpolateElement } from './create-interpolate-element';
2
- export * from './react';
3
- export * from './react-platform';
4
- export * from './utils';
5
- export { default as Platform } from './platform';
6
- export { default as renderToString } from './serialize';
7
- export { default as RawHTML } from './raw-html';
8
- //# sourceMappingURL=index.js.map
1
+ import { default as default2 } from "./create-interpolate-element";
2
+ export * from "./react";
3
+ export * from "./react-platform";
4
+ export * from "./utils";
5
+ import { default as default3 } from "./platform";
6
+ import { default as default4 } from "./serialize";
7
+ import { default as default5 } from "./raw-html";
8
+ export {
9
+ default3 as Platform,
10
+ default5 as RawHTML,
11
+ default2 as createInterpolateElement,
12
+ default4 as renderToString
13
+ };
14
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["default","createInterpolateElement","Platform","renderToString","RawHTML"],"sources":["@wordpress/element/src/index.ts"],"sourcesContent":["export { default as createInterpolateElement } from './create-interpolate-element';\nexport * from './react';\nexport * from './react-platform';\nexport * from './utils';\nexport { default as Platform } from './platform';\nexport { default as renderToString } from './serialize';\nexport { default as RawHTML } from './raw-html';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,wBAAwB,QAAQ,8BAA8B;AAClF,cAAc,SAAS;AACvB,cAAc,kBAAkB;AAChC,cAAc,SAAS;AACvB,SAASD,OAAO,IAAIE,QAAQ,QAAQ,YAAY;AAChD,SAASF,OAAO,IAAIG,cAAc,QAAQ,aAAa;AACvD,SAASH,OAAO,IAAII,OAAO,QAAQ,YAAY","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["export { default as createInterpolateElement } from './create-interpolate-element';\nexport * from './react';\nexport * from './react-platform';\nexport * from './utils';\nexport { default as Platform } from './platform';\nexport { default as renderToString } from './serialize';\nexport { default as RawHTML } from './raw-html';\n"],
5
+ "mappings": "AAAA,SAAoB,WAAXA,gBAA2C;AACpD,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAoB,WAAXA,gBAA2B;AACpC,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,gBAA0B;",
6
+ "names": ["default"]
7
+ }
@@ -1,14 +1,11 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { Platform as OriginalPlatform } from 'react-native';
1
+ import { Platform as OriginalPlatform } from "react-native";
5
2
  const Platform = {
6
3
  ...OriginalPlatform,
7
- OS: 'native',
8
- select: spec => {
9
- if ('android' in spec) {
4
+ OS: "native",
5
+ select: (spec) => {
6
+ if ("android" in spec) {
10
7
  return spec.android;
11
- } else if ('native' in spec) {
8
+ } else if ("native" in spec) {
12
9
  return spec.native;
13
10
  }
14
11
  return spec.default;
@@ -16,5 +13,8 @@ const Platform = {
16
13
  isNative: true,
17
14
  isAndroid: true
18
15
  };
19
- export default Platform;
20
- //# sourceMappingURL=platform.android.js.map
16
+ var platform_android_default = Platform;
17
+ export {
18
+ platform_android_default as default
19
+ };
20
+ //# sourceMappingURL=platform.android.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["Platform","OriginalPlatform","OS","select","spec","android","native","default","isNative","isAndroid"],"sources":["@wordpress/element/src/platform.android.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Platform as OriginalPlatform } from 'react-native';\n\nconst Platform = {\n\t...OriginalPlatform,\n\tOS: 'native',\n\tselect: ( spec ) => {\n\t\tif ( 'android' in spec ) {\n\t\t\treturn spec.android;\n\t\t} else if ( 'native' in spec ) {\n\t\t\treturn spec.native;\n\t\t}\n\t\treturn spec.default;\n\t},\n\tisNative: true,\n\tisAndroid: true,\n};\n\nexport default Platform;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,IAAIC,gBAAgB,QAAQ,cAAc;AAE3D,MAAMD,QAAQ,GAAG;EAChB,GAAGC,gBAAgB;EACnBC,EAAE,EAAE,QAAQ;EACZC,MAAM,EAAIC,IAAI,IAAM;IACnB,IAAK,SAAS,IAAIA,IAAI,EAAG;MACxB,OAAOA,IAAI,CAACC,OAAO;IACpB,CAAC,MAAM,IAAK,QAAQ,IAAID,IAAI,EAAG;MAC9B,OAAOA,IAAI,CAACE,MAAM;IACnB;IACA,OAAOF,IAAI,CAACG,OAAO;EACpB,CAAC;EACDC,QAAQ,EAAE,IAAI;EACdC,SAAS,EAAE;AACZ,CAAC;AAED,eAAeT,QAAQ","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/platform.android.js"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { Platform as OriginalPlatform } from 'react-native';\n\nconst Platform = {\n\t...OriginalPlatform,\n\tOS: 'native',\n\tselect: ( spec ) => {\n\t\tif ( 'android' in spec ) {\n\t\t\treturn spec.android;\n\t\t} else if ( 'native' in spec ) {\n\t\t\treturn spec.native;\n\t\t}\n\t\treturn spec.default;\n\t},\n\tisNative: true,\n\tisAndroid: true,\n};\n\nexport default Platform;\n"],
5
+ "mappings": "AAGA,SAAS,YAAY,wBAAwB;AAE7C,MAAM,WAAW;AAAA,EAChB,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,QAAQ,CAAE,SAAU;AACnB,QAAK,aAAa,MAAO;AACxB,aAAO,KAAK;AAAA,IACb,WAAY,YAAY,MAAO;AAC9B,aAAO,KAAK;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACb;AAAA,EACA,UAAU;AAAA,EACV,WAAW;AACZ;AAEA,IAAO,2BAAQ;",
6
+ "names": []
7
+ }
@@ -1,14 +1,11 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { Platform as OriginalPlatform } from 'react-native';
1
+ import { Platform as OriginalPlatform } from "react-native";
5
2
  const Platform = {
6
3
  ...OriginalPlatform,
7
- OS: 'native',
8
- select: spec => {
9
- if ('ios' in spec) {
4
+ OS: "native",
5
+ select: (spec) => {
6
+ if ("ios" in spec) {
10
7
  return spec.ios;
11
- } else if ('native' in spec) {
8
+ } else if ("native" in spec) {
12
9
  return spec.native;
13
10
  }
14
11
  return spec.default;
@@ -16,5 +13,8 @@ const Platform = {
16
13
  isNative: true,
17
14
  isIOS: true
18
15
  };
19
- export default Platform;
20
- //# sourceMappingURL=platform.ios.js.map
16
+ var platform_ios_default = Platform;
17
+ export {
18
+ platform_ios_default as default
19
+ };
20
+ //# sourceMappingURL=platform.ios.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["Platform","OriginalPlatform","OS","select","spec","ios","native","default","isNative","isIOS"],"sources":["@wordpress/element/src/platform.ios.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Platform as OriginalPlatform } from 'react-native';\n\nconst Platform = {\n\t...OriginalPlatform,\n\tOS: 'native',\n\tselect: ( spec ) => {\n\t\tif ( 'ios' in spec ) {\n\t\t\treturn spec.ios;\n\t\t} else if ( 'native' in spec ) {\n\t\t\treturn spec.native;\n\t\t}\n\t\treturn spec.default;\n\t},\n\tisNative: true,\n\tisIOS: true,\n};\n\nexport default Platform;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,IAAIC,gBAAgB,QAAQ,cAAc;AAE3D,MAAMD,QAAQ,GAAG;EAChB,GAAGC,gBAAgB;EACnBC,EAAE,EAAE,QAAQ;EACZC,MAAM,EAAIC,IAAI,IAAM;IACnB,IAAK,KAAK,IAAIA,IAAI,EAAG;MACpB,OAAOA,IAAI,CAACC,GAAG;IAChB,CAAC,MAAM,IAAK,QAAQ,IAAID,IAAI,EAAG;MAC9B,OAAOA,IAAI,CAACE,MAAM;IACnB;IACA,OAAOF,IAAI,CAACG,OAAO;EACpB,CAAC;EACDC,QAAQ,EAAE,IAAI;EACdC,KAAK,EAAE;AACR,CAAC;AAED,eAAeT,QAAQ","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/platform.ios.js"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { Platform as OriginalPlatform } from 'react-native';\n\nconst Platform = {\n\t...OriginalPlatform,\n\tOS: 'native',\n\tselect: ( spec ) => {\n\t\tif ( 'ios' in spec ) {\n\t\t\treturn spec.ios;\n\t\t} else if ( 'native' in spec ) {\n\t\t\treturn spec.native;\n\t\t}\n\t\treturn spec.default;\n\t},\n\tisNative: true,\n\tisIOS: true,\n};\n\nexport default Platform;\n"],
5
+ "mappings": "AAGA,SAAS,YAAY,wBAAwB;AAE7C,MAAM,WAAW;AAAA,EAChB,GAAG;AAAA,EACH,IAAI;AAAA,EACJ,QAAQ,CAAE,SAAU;AACnB,QAAK,SAAS,MAAO;AACpB,aAAO,KAAK;AAAA,IACb,WAAY,YAAY,MAAO;AAC9B,aAAO,KAAK;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACb;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AACR;AAEA,IAAO,uBAAQ;",
6
+ "names": []
7
+ }
@@ -1,38 +1,6 @@
1
- /**
2
- * Parts of this source were derived and modified from react-native-web,
3
- * released under the MIT license.
4
- *
5
- * Copyright (c) 2016-present, Nicolas Gallagher.
6
- * Copyright (c) 2015-present, Facebook, Inc.
7
- *
8
- */
9
-
10
- /**
11
- * Specification for platform-specific value selection.
12
- */
13
-
14
- /**
15
- * Component used to detect the current Platform being used.
16
- * Use Platform.OS === 'web' to detect if running on web environment.
17
- *
18
- * This is the same concept as the React Native implementation.
19
- *
20
- * @see https://reactnative.dev/docs/platform-specific-code#platform-module
21
- *
22
- * Here is an example of how to use the select method:
23
- * @example
24
- * ```js
25
- * import { Platform } from '@wordpress/element';
26
- *
27
- * const placeholderLabel = Platform.select( {
28
- * native: __( 'Add media' ),
29
- * web: __( 'Drag images, upload new ones or select files from your library.' ),
30
- * } );
31
- * ```
32
- */
33
1
  const Platform = {
34
2
  /** Platform identifier. Will always be `'web'` in this module. */
35
- OS: 'web',
3
+ OS: "web",
36
4
  /**
37
5
  * Select a value based on the platform.
38
6
  *
@@ -41,10 +9,13 @@ const Platform = {
41
9
  * @return The selected value.
42
10
  */
43
11
  select(spec) {
44
- return 'web' in spec ? spec.web : spec.default;
12
+ return "web" in spec ? spec.web : spec.default;
45
13
  },
46
14
  /** Whether the platform is web */
47
15
  isWeb: true
48
16
  };
49
- export default Platform;
50
- //# sourceMappingURL=platform.js.map
17
+ var platform_default = Platform;
18
+ export {
19
+ platform_default as default
20
+ };
21
+ //# sourceMappingURL=platform.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["Platform","OS","select","spec","web","default","isWeb"],"sources":["@wordpress/element/src/platform.ts"],"sourcesContent":["/**\n * Parts of this source were derived and modified from react-native-web,\n * released under the MIT license.\n *\n * Copyright (c) 2016-present, Nicolas Gallagher.\n * Copyright (c) 2015-present, Facebook, Inc.\n *\n */\n\n/**\n * Specification for platform-specific value selection.\n */\ntype PlatformSelectSpec< T > = {\n\tweb?: T;\n\tdefault?: T;\n};\n\n/**\n * Component used to detect the current Platform being used.\n * Use Platform.OS === 'web' to detect if running on web environment.\n *\n * This is the same concept as the React Native implementation.\n *\n * @see https://reactnative.dev/docs/platform-specific-code#platform-module\n *\n * Here is an example of how to use the select method:\n * @example\n * ```js\n * import { Platform } from '@wordpress/element';\n *\n * const placeholderLabel = Platform.select( {\n * native: __( 'Add media' ),\n * web: __( 'Drag images, upload new ones or select files from your library.' ),\n * } );\n * ```\n */\nconst Platform = {\n\t/** Platform identifier. Will always be `'web'` in this module. */\n\tOS: 'web' as const,\n\n\t/**\n\t * Select a value based on the platform.\n\t *\n\t * @template T\n\t * @param spec - Object with optional platform-specific values.\n\t * @return The selected value.\n\t */\n\tselect< T >( spec: PlatformSelectSpec< T > ): T | undefined {\n\t\treturn 'web' in spec ? spec.web : spec.default;\n\t},\n\n\t/** Whether the platform is web */\n\tisWeb: true,\n};\n\nexport default Platform;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAQ,GAAG;EAChB;EACAC,EAAE,EAAE,KAAc;EAElB;AACD;AACA;AACA;AACA;AACA;AACA;EACCC,MAAMA,CAAOC,IAA6B,EAAkB;IAC3D,OAAO,KAAK,IAAIA,IAAI,GAAGA,IAAI,CAACC,GAAG,GAAGD,IAAI,CAACE,OAAO;EAC/C,CAAC;EAED;EACAC,KAAK,EAAE;AACR,CAAC;AAED,eAAeN,QAAQ","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/platform.ts"],
4
+ "sourcesContent": ["/**\n * Parts of this source were derived and modified from react-native-web,\n * released under the MIT license.\n *\n * Copyright (c) 2016-present, Nicolas Gallagher.\n * Copyright (c) 2015-present, Facebook, Inc.\n *\n */\n\n/**\n * Specification for platform-specific value selection.\n */\ntype PlatformSelectSpec< T > = {\n\tweb?: T;\n\tdefault?: T;\n};\n\n/**\n * Component used to detect the current Platform being used.\n * Use Platform.OS === 'web' to detect if running on web environment.\n *\n * This is the same concept as the React Native implementation.\n *\n * @see https://reactnative.dev/docs/platform-specific-code#platform-module\n *\n * Here is an example of how to use the select method:\n * @example\n * ```js\n * import { Platform } from '@wordpress/element';\n *\n * const placeholderLabel = Platform.select( {\n * native: __( 'Add media' ),\n * web: __( 'Drag images, upload new ones or select files from your library.' ),\n * } );\n * ```\n */\nconst Platform = {\n\t/** Platform identifier. Will always be `'web'` in this module. */\n\tOS: 'web' as const,\n\n\t/**\n\t * Select a value based on the platform.\n\t *\n\t * @template T\n\t * @param spec - Object with optional platform-specific values.\n\t * @return The selected value.\n\t */\n\tselect< T >( spec: PlatformSelectSpec< T > ): T | undefined {\n\t\treturn 'web' in spec ? spec.web : spec.default;\n\t},\n\n\t/** Whether the platform is web */\n\tisWeb: true,\n};\n\nexport default Platform;\n"],
5
+ "mappings": "AAoCA,MAAM,WAAW;AAAA;AAAA,EAEhB,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASJ,OAAa,MAA+C;AAC3D,WAAO,SAAS,OAAO,KAAK,MAAM,KAAK;AAAA,EACxC;AAAA;AAAA,EAGA,OAAO;AACR;AAEA,IAAO,mBAAQ;",
6
+ "names": []
7
+ }
@@ -1,53 +1,20 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { Children, createElement } from './react';
5
-
6
- /**
7
- * Props for the RawHTML component.
8
- */
9
-
10
- /**
11
- * Component used to render unescaped HTML.
12
- *
13
- * Note: The `renderElement` serializer will remove the `div` wrapper
14
- * unless non-children props are present; typically when preparing a block for saving.
15
- *
16
- * @example
17
- * ```jsx
18
- * import { RawHTML } from '@wordpress/element';
19
- *
20
- * const Component = () => <RawHTML><h3>Hello world</h3></RawHTML>;
21
- * // Edit: <div><h3>Hello world</h3></div>
22
- * // save: <h3>Hello world</h3>
23
- * ```
24
- *
25
- * @param {RawHTMLProps} props Children should be a string of HTML or an array
26
- * of strings. Other props will be passed through
27
- * to the div wrapper.
28
- *
29
- * @return Dangerously-rendering component.
30
- */
31
- export default function RawHTML({
1
+ import { Children, createElement } from "./react";
2
+ function RawHTML({
32
3
  children,
33
4
  ...props
34
5
  }) {
35
- let rawHtml = '';
36
-
37
- // Cast children as an array, and concatenate each element if it is a string.
38
- Children.toArray(children).forEach(child => {
39
- if (typeof child === 'string' && child.trim() !== '') {
6
+ let rawHtml = "";
7
+ Children.toArray(children).forEach((child) => {
8
+ if (typeof child === "string" && child.trim() !== "") {
40
9
  rawHtml += child;
41
10
  }
42
11
  });
43
-
44
- // The `div` wrapper will be stripped by the `renderElement` serializer in
45
- // `./serialize.js` unless there are non-children props present.
46
- return createElement('div', {
47
- dangerouslySetInnerHTML: {
48
- __html: rawHtml
49
- },
12
+ return createElement("div", {
13
+ dangerouslySetInnerHTML: { __html: rawHtml },
50
14
  ...props
51
15
  });
52
16
  }
53
- //# sourceMappingURL=raw-html.js.map
17
+ export {
18
+ RawHTML as default
19
+ };
20
+ //# sourceMappingURL=raw-html.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["Children","createElement","RawHTML","children","props","rawHtml","toArray","forEach","child","trim","dangerouslySetInnerHTML","__html"],"sources":["@wordpress/element/src/raw-html.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { Children, createElement } from './react';\n\n/**\n * Props for the RawHTML component.\n */\nexport type RawHTMLProps = {\n\tchildren: string | string[];\n} & React.ComponentPropsWithoutRef< 'div' >;\n\n/**\n * Component used to render unescaped HTML.\n *\n * Note: The `renderElement` serializer will remove the `div` wrapper\n * unless non-children props are present; typically when preparing a block for saving.\n *\n * @example\n * ```jsx\n * import { RawHTML } from '@wordpress/element';\n *\n * const Component = () => <RawHTML><h3>Hello world</h3></RawHTML>;\n * // Edit: <div><h3>Hello world</h3></div>\n * // save: <h3>Hello world</h3>\n * ```\n *\n * @param {RawHTMLProps} props Children should be a string of HTML or an array\n * of strings. Other props will be passed through\n * to the div wrapper.\n *\n * @return Dangerously-rendering component.\n */\nexport default function RawHTML( {\n\tchildren,\n\t...props\n}: RawHTMLProps ): JSX.Element {\n\tlet rawHtml = '';\n\n\t// Cast children as an array, and concatenate each element if it is a string.\n\tChildren.toArray( children ).forEach( ( child ) => {\n\t\tif ( typeof child === 'string' && child.trim() !== '' ) {\n\t\t\trawHtml += child;\n\t\t}\n\t} );\n\n\t// The `div` wrapper will be stripped by the `renderElement` serializer in\n\t// `./serialize.js` unless there are non-children props present.\n\treturn createElement( 'div', {\n\t\tdangerouslySetInnerHTML: { __html: rawHtml },\n\t\t...props,\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,aAAa,QAAQ,SAAS;;AAEjD;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,OAAOA,CAAE;EAChCC,QAAQ;EACR,GAAGC;AACU,CAAC,EAAgB;EAC9B,IAAIC,OAAO,GAAG,EAAE;;EAEhB;EACAL,QAAQ,CAACM,OAAO,CAAEH,QAAS,CAAC,CAACI,OAAO,CAAIC,KAAK,IAAM;IAClD,IAAK,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAG;MACvDJ,OAAO,IAAIG,KAAK;IACjB;EACD,CAAE,CAAC;;EAEH;EACA;EACA,OAAOP,aAAa,CAAE,KAAK,EAAE;IAC5BS,uBAAuB,EAAE;MAAEC,MAAM,EAAEN;IAAQ,CAAC;IAC5C,GAAGD;EACJ,CAAE,CAAC;AACJ","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/raw-html.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { Children, createElement } from './react';\n\n/**\n * Props for the RawHTML component.\n */\nexport type RawHTMLProps = {\n\tchildren: string | string[];\n} & React.ComponentPropsWithoutRef< 'div' >;\n\n/**\n * Component used to render unescaped HTML.\n *\n * Note: The `renderElement` serializer will remove the `div` wrapper\n * unless non-children props are present; typically when preparing a block for saving.\n *\n * @example\n * ```jsx\n * import { RawHTML } from '@wordpress/element';\n *\n * const Component = () => <RawHTML><h3>Hello world</h3></RawHTML>;\n * // Edit: <div><h3>Hello world</h3></div>\n * // save: <h3>Hello world</h3>\n * ```\n *\n * @param {RawHTMLProps} props Children should be a string of HTML or an array\n * of strings. Other props will be passed through\n * to the div wrapper.\n *\n * @return Dangerously-rendering component.\n */\nexport default function RawHTML( {\n\tchildren,\n\t...props\n}: RawHTMLProps ): JSX.Element {\n\tlet rawHtml = '';\n\n\t// Cast children as an array, and concatenate each element if it is a string.\n\tChildren.toArray( children ).forEach( ( child ) => {\n\t\tif ( typeof child === 'string' && child.trim() !== '' ) {\n\t\t\trawHtml += child;\n\t\t}\n\t} );\n\n\t// The `div` wrapper will be stripped by the `renderElement` serializer in\n\t// `./serialize.js` unless there are non-children props present.\n\treturn createElement( 'div', {\n\t\tdangerouslySetInnerHTML: { __html: rawHtml },\n\t\t...props,\n\t} );\n}\n"],
5
+ "mappings": "AAGA,SAAS,UAAU,qBAAqB;AA8BzB,SAAR,QAA0B;AAAA,EAChC;AAAA,EACA,GAAG;AACJ,GAA+B;AAC9B,MAAI,UAAU;AAGd,WAAS,QAAS,QAAS,EAAE,QAAS,CAAE,UAAW;AAClD,QAAK,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,IAAK;AACvD,iBAAW;AAAA,IACZ;AAAA,EACD,CAAE;AAIF,SAAO,cAAe,OAAO;AAAA,IAC5B,yBAAyB,EAAE,QAAQ,QAAQ;AAAA,IAC3C,GAAG;AAAA,EACJ,CAAE;AACH;",
6
+ "names": []
7
+ }
@@ -1,71 +1,20 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { createPortal, findDOMNode, flushSync, render, hydrate, unmountComponentAtNode } from 'react-dom';
5
- import { createRoot, hydrateRoot } from 'react-dom/client';
6
-
7
- /**
8
- * Creates a portal into which a component can be rendered.
9
- *
10
- * @see https://github.com/facebook/react/issues/10309#issuecomment-318433235
11
- *
12
- * @param {import('react').ReactElement} child Any renderable child, such as an element,
13
- * string, or fragment.
14
- * @param {HTMLElement} container DOM node into which element should be rendered.
15
- */
16
- export { createPortal };
17
-
18
- /**
19
- * Finds the dom node of a React component.
20
- *
21
- * @param {import('react').ComponentType} component Component's instance.
22
- */
23
- export { findDOMNode };
24
-
25
- /**
26
- * Forces React to flush any updates inside the provided callback synchronously.
27
- *
28
- * @param {Function} callback Callback to run synchronously.
29
- */
30
- export { flushSync };
31
-
32
- /**
33
- * Renders a given element into the target DOM node.
34
- *
35
- * @deprecated since WordPress 6.2.0. Use `createRoot` instead.
36
- * @see https://react.dev/reference/react-dom/render
37
- */
38
- export { render };
39
-
40
- /**
41
- * Hydrates a given element into the target DOM node.
42
- *
43
- * @deprecated since WordPress 6.2.0. Use `hydrateRoot` instead.
44
- * @see https://react.dev/reference/react-dom/hydrate
45
- */
46
- export { hydrate };
47
-
48
- /**
49
- * Creates a new React root for the target DOM node.
50
- *
51
- * @since 6.2.0 Introduced in WordPress core.
52
- * @see https://react.dev/reference/react-dom/client/createRoot
53
- */
54
- export { createRoot };
55
-
56
- /**
57
- * Creates a new React root for the target DOM node and hydrates it with a pre-generated markup.
58
- *
59
- * @since 6.2.0 Introduced in WordPress core.
60
- * @see https://react.dev/reference/react-dom/client/hydrateRoot
61
- */
62
- export { hydrateRoot };
63
-
64
- /**
65
- * Removes any mounted element from the target DOM node.
66
- *
67
- * @deprecated since WordPress 6.2.0. Use `root.unmount()` instead.
68
- * @see https://react.dev/reference/react-dom/unmountComponentAtNode
69
- */
70
- export { unmountComponentAtNode };
71
- //# sourceMappingURL=react-platform.js.map
1
+ import {
2
+ createPortal,
3
+ findDOMNode,
4
+ flushSync,
5
+ render,
6
+ hydrate,
7
+ unmountComponentAtNode
8
+ } from "react-dom";
9
+ import { createRoot, hydrateRoot } from "react-dom/client";
10
+ export {
11
+ createPortal,
12
+ createRoot,
13
+ findDOMNode,
14
+ flushSync,
15
+ hydrate,
16
+ hydrateRoot,
17
+ render,
18
+ unmountComponentAtNode
19
+ };
20
+ //# sourceMappingURL=react-platform.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createPortal","findDOMNode","flushSync","render","hydrate","unmountComponentAtNode","createRoot","hydrateRoot"],"sources":["@wordpress/element/src/react-platform.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tcreatePortal,\n\tfindDOMNode,\n\tflushSync,\n\trender,\n\thydrate,\n\tunmountComponentAtNode,\n} from 'react-dom';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\n\n/**\n * Creates a portal into which a component can be rendered.\n *\n * @see https://github.com/facebook/react/issues/10309#issuecomment-318433235\n *\n * @param {import('react').ReactElement} child Any renderable child, such as an element,\n * string, or fragment.\n * @param {HTMLElement} container DOM node into which element should be rendered.\n */\nexport { createPortal };\n\n/**\n * Finds the dom node of a React component.\n *\n * @param {import('react').ComponentType} component Component's instance.\n */\nexport { findDOMNode };\n\n/**\n * Forces React to flush any updates inside the provided callback synchronously.\n *\n * @param {Function} callback Callback to run synchronously.\n */\nexport { flushSync };\n\n/**\n * Renders a given element into the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `createRoot` instead.\n * @see https://react.dev/reference/react-dom/render\n */\nexport { render };\n\n/**\n * Hydrates a given element into the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `hydrateRoot` instead.\n * @see https://react.dev/reference/react-dom/hydrate\n */\nexport { hydrate };\n\n/**\n * Creates a new React root for the target DOM node.\n *\n * @since 6.2.0 Introduced in WordPress core.\n * @see https://react.dev/reference/react-dom/client/createRoot\n */\nexport { createRoot };\n\n/**\n * Creates a new React root for the target DOM node and hydrates it with a pre-generated markup.\n *\n * @since 6.2.0 Introduced in WordPress core.\n * @see https://react.dev/reference/react-dom/client/hydrateRoot\n */\nexport { hydrateRoot };\n\n/**\n * Removes any mounted element from the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `root.unmount()` instead.\n * @see https://react.dev/reference/react-dom/unmountComponentAtNode\n */\nexport { unmountComponentAtNode };\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,YAAY,EACZC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,OAAO,EACPC,sBAAsB,QAChB,WAAW;AAClB,SAASC,UAAU,EAAEC,WAAW,QAAQ,kBAAkB;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASP,YAAY;;AAErB;AACA;AACA;AACA;AACA;AACA,SAASC,WAAW;;AAEpB;AACA;AACA;AACA;AACA;AACA,SAASC,SAAS;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,MAAM;;AAEf;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,OAAO;;AAEhB;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,UAAU;;AAEnB;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,WAAW;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA,SAASF,sBAAsB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/react-platform.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport {\n\tcreatePortal,\n\tfindDOMNode,\n\tflushSync,\n\trender,\n\thydrate,\n\tunmountComponentAtNode,\n} from 'react-dom';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\n\n/**\n * Creates a portal into which a component can be rendered.\n *\n * @see https://github.com/facebook/react/issues/10309#issuecomment-318433235\n *\n * @param {import('react').ReactElement} child Any renderable child, such as an element,\n * string, or fragment.\n * @param {HTMLElement} container DOM node into which element should be rendered.\n */\nexport { createPortal };\n\n/**\n * Finds the dom node of a React component.\n *\n * @param {import('react').ComponentType} component Component's instance.\n */\nexport { findDOMNode };\n\n/**\n * Forces React to flush any updates inside the provided callback synchronously.\n *\n * @param {Function} callback Callback to run synchronously.\n */\nexport { flushSync };\n\n/**\n * Renders a given element into the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `createRoot` instead.\n * @see https://react.dev/reference/react-dom/render\n */\nexport { render };\n\n/**\n * Hydrates a given element into the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `hydrateRoot` instead.\n * @see https://react.dev/reference/react-dom/hydrate\n */\nexport { hydrate };\n\n/**\n * Creates a new React root for the target DOM node.\n *\n * @since 6.2.0 Introduced in WordPress core.\n * @see https://react.dev/reference/react-dom/client/createRoot\n */\nexport { createRoot };\n\n/**\n * Creates a new React root for the target DOM node and hydrates it with a pre-generated markup.\n *\n * @since 6.2.0 Introduced in WordPress core.\n * @see https://react.dev/reference/react-dom/client/hydrateRoot\n */\nexport { hydrateRoot };\n\n/**\n * Removes any mounted element from the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `root.unmount()` instead.\n * @see https://react.dev/reference/react-dom/unmountComponentAtNode\n */\nexport { unmountComponentAtNode };\n"],
5
+ "mappings": "AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,YAAY,mBAAmB;",
6
+ "names": []
7
+ }