@wordpress/element 6.30.0 → 6.30.1-next.6f42e1382.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 (55) hide show
  1. package/README.md +10 -14
  2. package/build/create-interpolate-element.js +28 -53
  3. package/build/create-interpolate-element.js.map +1 -1
  4. package/build/index.js.map +1 -1
  5. package/build/platform.js +21 -5
  6. package/build/platform.js.map +1 -1
  7. package/build/raw-html.js +4 -2
  8. package/build/raw-html.js.map +1 -1
  9. package/build/react-platform.js.map +1 -1
  10. package/build/react.js +9 -22
  11. package/build/react.js.map +1 -1
  12. package/build/serialize.js +36 -89
  13. package/build/serialize.js.map +1 -1
  14. package/build/utils.js +2 -2
  15. package/build/utils.js.map +1 -1
  16. package/build-module/create-interpolate-element.js +28 -54
  17. package/build-module/create-interpolate-element.js.map +1 -1
  18. package/build-module/index.js.map +1 -1
  19. package/build-module/platform.js +21 -5
  20. package/build-module/platform.js.map +1 -1
  21. package/build-module/raw-html.js +4 -2
  22. package/build-module/raw-html.js.map +1 -1
  23. package/build-module/react-platform.js.map +1 -1
  24. package/build-module/react.js +9 -22
  25. package/build-module/react.js.map +1 -1
  26. package/build-module/serialize.js +36 -89
  27. package/build-module/serialize.js.map +1 -1
  28. package/build-module/utils.js +2 -2
  29. package/build-module/utils.js.map +1 -1
  30. package/build-types/create-interpolate-element.d.ts +8 -42
  31. package/build-types/create-interpolate-element.d.ts.map +1 -1
  32. package/build-types/index.d.ts +7 -7
  33. package/build-types/index.d.ts.map +1 -1
  34. package/build-types/platform.d.ts +48 -5
  35. package/build-types/platform.d.ts.map +1 -1
  36. package/build-types/raw-html.d.ts +7 -5
  37. package/build-types/raw-html.d.ts.map +1 -1
  38. package/build-types/react-platform.d.ts +62 -9
  39. package/build-types/react-platform.d.ts.map +1 -1
  40. package/build-types/react.d.ts +185 -58
  41. package/build-types/react.d.ts.map +1 -1
  42. package/build-types/serialize.d.ts +61 -43
  43. package/build-types/serialize.d.ts.map +1 -1
  44. package/build-types/utils.d.ts +7 -1
  45. package/build-types/utils.d.ts.map +1 -1
  46. package/package.json +3 -3
  47. package/src/{create-interpolate-element.js → create-interpolate-element.ts} +95 -64
  48. package/src/{platform.js → platform.ts} +27 -4
  49. package/src/{raw-html.js → raw-html.ts} +11 -3
  50. package/src/{react.js → react.ts} +40 -37
  51. package/src/{serialize.js → serialize.ts} +131 -144
  52. package/src/{utils.js → utils.ts} +4 -4
  53. package/tsconfig.tsbuildinfo +1 -1
  54. /package/src/{index.js → index.ts} +0 -0
  55. /package/src/{react-platform.js → react-platform.ts} +0 -0
package/README.md CHANGED
@@ -54,11 +54,11 @@ Concatenate two or more React children objects.
54
54
 
55
55
  _Parameters_
56
56
 
57
- - _childrenArguments_ `...?Object`: Array of children arguments (array of arrays/strings/objects) to concatenate.
57
+ - _childrenArguments_ `ReactNode[][]`: - Array of children arguments (array of arrays/strings/objects) to concatenate.
58
58
 
59
59
  _Returns_
60
60
 
61
- - `Array`: The concatenated value.
61
+ - `ReactNode[]`: The concatenated value.
62
62
 
63
63
  ### createContext
64
64
 
@@ -110,11 +110,11 @@ You would have something like this as the conversionMap value:
110
110
  _Parameters_
111
111
 
112
112
  - _interpolatedString_ `string`: The interpolation string to be parsed.
113
- - _conversionMap_ `Record<string, Element>`: The map used to convert the string to a react element.
113
+ - _conversionMap_ `Record< string, ReactElement >`: The map used to convert the string to a react element.
114
114
 
115
115
  _Returns_
116
116
 
117
- - `Element`: A wp element.
117
+ - `ReactElement`: A wp element.
118
118
 
119
119
  ### createPortal
120
120
 
@@ -209,7 +209,7 @@ Checks if the provided WP element is empty.
209
209
 
210
210
  _Parameters_
211
211
 
212
- - _element_ `*`: WP element to check.
212
+ - _element_ `unknown`: WP element to check.
213
213
 
214
214
  _Returns_
215
215
 
@@ -312,13 +312,9 @@ Serializes a React element to string.
312
312
 
313
313
  _Parameters_
314
314
 
315
- - _element_ `import('react').ReactNode`: Element to serialize.
316
- - _context_ `[Object]`: Context object.
317
- - _legacyContext_ `[Object]`: Legacy context object.
318
-
319
- _Returns_
320
-
321
- - `string`: Serialized element.
315
+ - _element_ `React.ReactNode`:
316
+ - _context_ `any`:
317
+ - _legacyContext_ `Record< string, any >`:
322
318
 
323
319
  ### startTransition
324
320
 
@@ -342,12 +338,12 @@ Switches the nodeName of all the elements in the children object.
342
338
 
343
339
  _Parameters_
344
340
 
345
- - _children_ `?Object`: Children object.
341
+ - _children_ `ReactNode`: Children object.
346
342
  - _nodeName_ `string`: Node name.
347
343
 
348
344
  _Returns_
349
345
 
350
- - `?Object`: The updated children object.
346
+ - `ReactNode`: The updated children object.
351
347
 
352
348
  ### unmountComponentAtNode
353
349
 
@@ -9,13 +9,10 @@ var _react = require("./react");
9
9
  * Internal dependencies
10
10
  */
11
11
 
12
- /**
13
- * Object containing a React element.
14
- *
15
- * @typedef {import('react').ReactElement} Element
16
- */
17
-
18
- let indoc, offset, output, stack;
12
+ let indoc;
13
+ let offset;
14
+ let output;
15
+ let stack;
19
16
 
20
17
  /**
21
18
  * Matches tags in the localized string
@@ -29,29 +26,8 @@ let indoc, offset, output, stack;
29
26
  * isClosing: The closing slash, if it exists.
30
27
  * name: The name portion of the tag (strong, br) (if )
31
28
  * isSelfClosed: The slash on a self closing tag, if it exists.
32
- *
33
- * @type {RegExp}
34
29
  */
35
30
  const tokenizer = /<(\/)?(\w+)\s*(\/)?>/g;
36
-
37
- /**
38
- * The stack frame tracking parse progress.
39
- *
40
- * @typedef Frame
41
- *
42
- * @property {Element} element A parent element which may still have
43
- * @property {number} tokenStart Offset at which parent element first
44
- * appears.
45
- * @property {number} tokenLength Length of string marking start of parent
46
- * element.
47
- * @property {number} [prevOffset] Running offset at which parsing should
48
- * continue.
49
- * @property {number} [leadingTextStart] Offset at which last closing element
50
- * finished, used for finding text between
51
- * elements.
52
- * @property {Element[]} children Children.
53
- */
54
-
55
31
  /**
56
32
  * Tracks recursive-descent parse state.
57
33
  *
@@ -59,19 +35,19 @@ const tokenizer = /<(\/)?(\w+)\s*(\/)?>/g;
59
35
  * parsed.
60
36
  *
61
37
  * @private
62
- * @param {Element} element A parent element which may still have
63
- * nested children not yet parsed.
64
- * @param {number} tokenStart Offset at which parent element first
65
- * appears.
66
- * @param {number} tokenLength Length of string marking start of parent
67
- * element.
68
- * @param {number} [prevOffset] Running offset at which parsing should
69
- * continue.
70
- * @param {number} [leadingTextStart] Offset at which last closing element
71
- * finished, used for finding text between
72
- * elements.
38
+ * @param element A parent element which may still have
39
+ * nested children not yet parsed.
40
+ * @param tokenStart Offset at which parent element first
41
+ * appears.
42
+ * @param tokenLength Length of string marking start of parent
43
+ * element.
44
+ * @param prevOffset Running offset at which parsing should
45
+ * continue.
46
+ * @param leadingTextStart Offset at which last closing element
47
+ * finished, used for finding text between
48
+ * elements.
73
49
  *
74
- * @return {Frame} The stack frame tracking parse progress.
50
+ * @return The stack frame tracking parse progress.
75
51
  */
76
52
  function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) {
77
53
  return {
@@ -105,11 +81,11 @@ function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextSt
105
81
  * }
106
82
  * ```
107
83
  *
108
- * @param {string} interpolatedString The interpolation string to be parsed.
109
- * @param {Record<string, Element>} conversionMap The map used to convert the string to
110
- * a react element.
84
+ * @param interpolatedString The interpolation string to be parsed.
85
+ * @param conversionMap The map used to convert the string to
86
+ * a react element.
111
87
  * @throws {TypeError}
112
- * @return {Element} A wp element.
88
+ * @return A wp element.
113
89
  */
114
90
  const createInterpolateElement = (interpolatedString, conversionMap) => {
115
91
  indoc = interpolatedString;
@@ -134,31 +110,30 @@ const createInterpolateElement = (interpolatedString, conversionMap) => {
134
110
  *
135
111
  * @private
136
112
  *
137
- * @param {Object} conversionMap The map being validated.
113
+ * @param conversionMap The map being validated.
138
114
  *
139
- * @return {boolean} True means the map is valid.
115
+ * @return True means the map is valid.
140
116
  */
141
117
  const isValidConversionMap = conversionMap => {
142
- const isObject = typeof conversionMap === 'object';
118
+ const isObject = typeof conversionMap === 'object' && conversionMap !== null;
143
119
  const values = isObject && Object.values(conversionMap);
144
- return isObject && values.length && values.every(element => (0, _react.isValidElement)(element));
120
+ return isObject && values.length > 0 && values.every(element => (0, _react.isValidElement)(element));
145
121
  };
146
-
147
122
  /**
148
123
  * This is the iterator over the matches in the string.
149
124
  *
150
125
  * @private
151
126
  *
152
- * @param {Object} conversionMap The conversion map for the string.
127
+ * @param conversionMap The conversion map for the string.
153
128
  *
154
- * @return {boolean} true for continuing to iterate, false for finished.
129
+ * @return true for continuing to iterate, false for finished.
155
130
  */
156
131
  function proceed(conversionMap) {
157
132
  const next = nextToken();
158
133
  const [tokenType, name, startOffset, tokenLength] = next;
159
134
  const stackDepth = stack.length;
160
135
  const leadingTextStart = startOffset > offset ? offset : null;
161
- if (!conversionMap[name]) {
136
+ if (name && !conversionMap[name]) {
162
137
  addText();
163
138
  return false;
164
139
  }
@@ -221,7 +196,7 @@ function proceed(conversionMap) {
221
196
  *
222
197
  * @private
223
198
  *
224
- * @return {Array} An array of details for the token matched.
199
+ * @return An array of details for the token matched.
225
200
  */
226
201
  function nextToken() {
227
202
  const matches = tokenizer.exec(indoc);
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","indoc","offset","output","stack","tokenizer","createFrame","element","tokenStart","tokenLength","prevOffset","leadingTextStart","children","createInterpolateElement","interpolatedString","conversionMap","lastIndex","isValidConversionMap","TypeError","proceed","createElement","Fragment","isObject","values","Object","length","every","isValidElement","next","nextToken","tokenType","name","startOffset","stackDepth","addText","stackLeadingText","pop","push","substr","addChild","closeOuterElement","stackTop","text","frame","matches","exec","startedAt","index","match","isClosing","isSelfClosed","parent","cloneElement","endOffset","_default","exports","default"],"sources":["@wordpress/element/src/create-interpolate-element.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { createElement, cloneElement, Fragment, isValidElement } from './react';\n\n/**\n * Object containing a React element.\n *\n * @typedef {import('react').ReactElement} Element\n */\n\nlet indoc, offset, output, stack;\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 *\n * @type {RegExp}\n */\nconst tokenizer = /<(\\/)?(\\w+)\\s*(\\/)?>/g;\n\n/**\n * The stack frame tracking parse progress.\n *\n * @typedef Frame\n *\n * @property {Element} element A parent element which may still have\n * @property {number} tokenStart Offset at which parent element first\n * appears.\n * @property {number} tokenLength Length of string marking start of parent\n * element.\n * @property {number} [prevOffset] Running offset at which parsing should\n * continue.\n * @property {number} [leadingTextStart] Offset at which last closing element\n * finished, used for finding text between\n * elements.\n * @property {Element[]} children Children.\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} element A parent element which may still have\n * nested children not yet parsed.\n * @param {number} tokenStart Offset at which parent element first\n * appears.\n * @param {number} tokenLength Length of string marking start of parent\n * element.\n * @param {number} [prevOffset] Running offset at which parsing should\n * continue.\n * @param {number} [leadingTextStart] Offset at which last closing element\n * finished, used for finding text between\n * elements.\n *\n * @return {Frame} The stack frame tracking parse progress.\n */\nfunction createFrame(\n\telement,\n\ttokenStart,\n\ttokenLength,\n\tprevOffset,\n\tleadingTextStart\n) {\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 {string} interpolatedString The interpolation string to be parsed.\n * @param {Record<string, Element>} conversionMap The map used to convert the string to\n * a react element.\n * @throws {TypeError}\n * @return {Element} A wp element.\n */\nconst createInterpolateElement = ( interpolatedString, conversionMap ) => {\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 {Object} conversionMap The map being validated.\n *\n * @return {boolean} True means the map is valid.\n */\nconst isValidConversionMap = ( conversionMap ) => {\n\tconst isObject = typeof conversionMap === 'object';\n\tconst values = isObject && Object.values( conversionMap );\n\treturn (\n\t\tisObject &&\n\t\tvalues.length &&\n\t\tvalues.every( ( element ) => isValidElement( element ) )\n\t);\n};\n\n/**\n * This is the iterator over the matches in the string.\n *\n * @private\n *\n * @param {Object} conversionMap The conversion map for the string.\n *\n * @return {boolean} true for continuing to iterate, false for finished.\n */\nfunction proceed( conversionMap ) {\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 ( ! 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 {Array} An array of details for the token matched.\n */\nfunction nextToken() {\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() {\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 ) {\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 ) {\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":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAEA,IAAIC,KAAK,EAAEC,MAAM,EAAEC,MAAM,EAAEC,KAAK;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,SAAS,GAAG,uBAAuB;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,WAAWA,CACnBC,OAAO,EACPC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,gBAAgB,EACf;EACD,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,CAAEC,kBAAkB,EAAEC,aAA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,UAAU;IAAEF,UAAU;IAAEI;EAAS,CAAC,GACpER,KAAK,CAACgC,GAAG,CAAC,CAAC;EAEZ,MAAMM,IAAI,GAAGW,SAAS,GACnBpD,KAAK,CAACqC,MAAM,CAAE5B,UAAU,EAAE2C,SAAS,GAAG3C,UAAW,CAAC,GAClDT,KAAK,CAACqC,MAAM,CAAE5B,UAAW,CAAC;EAE7B,IAAKgC,IAAI,EAAG;IACX9B,QAAQ,CAACyB,IAAI,CAAEK,IAAK,CAAC;EACtB;EAEA,IAAK,IAAI,KAAK/B,gBAAgB,EAAG;IAChCR,MAAM,CAACkC,IAAI,CACVpC,KAAK,CAACqC,MAAM,CAAE3B,gBAAgB,EAAEH,UAAU,GAAGG,gBAAiB,CAC/D,CAAC;EACF;EAEAR,MAAM,CAACkC,IAAI,CAAE,IAAAe,mBAAY,EAAE7C,OAAO,EAAE,IAAI,EAAE,GAAGK,QAAS,CAAE,CAAC;AAC1D;AAAC,IAAA0C,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc3C,wBAAwB","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","indoc","offset","output","stack","tokenizer","createFrame","element","tokenStart","tokenLength","prevOffset","leadingTextStart","children","createInterpolateElement","interpolatedString","conversionMap","lastIndex","isValidConversionMap","TypeError","proceed","createElement","Fragment","isObject","values","Object","length","every","isValidElement","next","nextToken","tokenType","name","startOffset","stackDepth","addText","stackLeadingText","pop","push","substr","addChild","closeOuterElement","stackTop","text","frame","matches","exec","startedAt","index","match","isClosing","isSelfClosed","parent","cloneElement","endOffset","_default","exports","default"],"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":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AASA,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,CAA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AAS,CAAE,CAAC;EAClEuC,MAAM,CAACzC,UAAU,GAAGA,UAAU,GAAGA,UAAU,GAAGF,UAAU,GAAGC,WAAW;AACvE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS+B,iBAAiBA,CAAEa,SAAiB,EAAS;EACrD,MAAM;IAAE9C,OAAO;IAAEI,gBAAgB;IAAED,UAAU;IAAEF,UAAU;IAAEI;EAAS,CAAC,GACpER,KAAK,CAACgC,GAAG,CAAC,CAAC;EAEZ,MAAMM,IAAI,GAAGW,SAAS,GACnBpD,KAAK,CAACqC,MAAM,CAAE5B,UAAU,EAAE2C,SAAS,GAAG3C,UAAW,CAAC,GAClDT,KAAK,CAACqC,MAAM,CAAE5B,UAAW,CAAC;EAE7B,IAAKgC,IAAI,EAAG;IACX9B,QAAQ,CAACyB,IAAI,CAAEK,IAAK,CAAC;EACtB;EAEA,IAAK,IAAI,KAAK/B,gBAAgB,EAAG;IAChCR,MAAM,CAACkC,IAAI,CACVpC,KAAK,CAACqC,MAAM,CAAE3B,gBAAgB,EAAEH,UAAU,GAAGG,gBAAiB,CAC/D,CAAC;EACF;EAEAR,MAAM,CAACkC,IAAI,CAAE,IAAAe,mBAAY,EAAE7C,OAAO,EAAE,IAAI,EAAE,GAAGK,QAAS,CAAE,CAAC;AAC1D;AAAC,IAAA0C,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc3C,wBAAwB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_createInterpolateElement","_interopRequireDefault","require","_react","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_reactPlatform","_utils","_platform","_serialize","_rawHtml"],"sources":["@wordpress/element/src/index.js"],"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-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AAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAU,MAAA,CAAAV,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,MAAA,CAAAV,GAAA;IAAA;EAAA;AAAA;AACA,IAAAW,SAAA,GAAAjB,sBAAA,CAAAC,OAAA;AACA,IAAAiB,UAAA,GAAAlB,sBAAA,CAAAC,OAAA;AACA,IAAAkB,QAAA,GAAAnB,sBAAA,CAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_createInterpolateElement","_interopRequireDefault","require","_react","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_reactPlatform","_utils","_platform","_serialize","_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,IAAAA,yBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,cAAA,GAAAd,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAW,cAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,cAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,cAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AACA,IAAAU,MAAA,GAAAf,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAY,MAAA,EAAAX,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAU,MAAA,CAAAV,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,MAAA,CAAAV,GAAA;IAAA;EAAA;AAAA;AACA,IAAAW,SAAA,GAAAjB,sBAAA,CAAAC,OAAA;AACA,IAAAiB,UAAA,GAAAlB,sBAAA,CAAAC,OAAA;AACA,IAAAkB,QAAA,GAAAnB,sBAAA,CAAAC,OAAA","ignoreList":[]}
package/build/platform.js CHANGED
@@ -12,11 +12,11 @@ exports.default = void 0;
12
12
  * Copyright (c) 2015-present, Facebook, Inc.
13
13
  *
14
14
  */
15
- const Platform = {
16
- OS: 'web',
17
- select: spec => 'web' in spec ? spec.web : spec.default,
18
- isWeb: true
19
- };
15
+
16
+ /**
17
+ * Specification for platform-specific value selection.
18
+ */
19
+
20
20
  /**
21
21
  * Component used to detect the current Platform being used.
22
22
  * Use Platform.OS === 'web' to detect if running on web environment.
@@ -36,5 +36,21 @@ const Platform = {
36
36
  * } );
37
37
  * ```
38
38
  */
39
+ const Platform = {
40
+ /** Platform identifier. Will always be `'web'` in this module. */
41
+ OS: 'web',
42
+ /**
43
+ * Select a value based on the platform.
44
+ *
45
+ * @template T
46
+ * @param spec - Object with optional platform-specific values.
47
+ * @return The selected value.
48
+ */
49
+ select(spec) {
50
+ return 'web' in spec ? spec.web : spec.default;
51
+ },
52
+ /** Whether the platform is web */
53
+ isWeb: true
54
+ };
39
55
  var _default = exports.default = Platform;
40
56
  //# sourceMappingURL=platform.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","OS","select","spec","web","default","isWeb","_default","exports"],"sources":["@wordpress/element/src/platform.js"],"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 */\nconst Platform = {\n\tOS: 'web',\n\tselect: ( spec ) => ( 'web' in spec ? spec.web : spec.default ),\n\tisWeb: true,\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 */\nexport default Platform;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAQ,GAAG;EAChBC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAIC,IAAI,IAAQ,KAAK,IAAIA,IAAI,GAAGA,IAAI,CAACC,GAAG,GAAGD,IAAI,CAACE,OAAS;EAC/DC,KAAK,EAAE;AACR,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAlBA,IAAAC,QAAA,GAAAC,OAAA,CAAAH,OAAA,GAmBeL,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":["Platform","OS","select","spec","web","default","isWeb","_default","exports"],"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;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAH,OAAA,GAEaL,QAAQ","ignoreList":[]}
package/build/raw-html.js CHANGED
@@ -9,7 +9,9 @@ var _react = require("./react");
9
9
  * Internal dependencies
10
10
  */
11
11
 
12
- /** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */
12
+ /**
13
+ * Props for the RawHTML component.
14
+ */
13
15
 
14
16
  /**
15
17
  * Component used to render unescaped HTML.
@@ -30,7 +32,7 @@ var _react = require("./react");
30
32
  * of strings. Other props will be passed through
31
33
  * to the div wrapper.
32
34
  *
33
- * @return {JSX.Element} Dangerously-rendering component.
35
+ * @return Dangerously-rendering component.
34
36
  */
35
37
  function RawHTML({
36
38
  children,
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","RawHTML","children","props","rawHtml","Children","toArray","forEach","child","trim","createElement","dangerouslySetInnerHTML","__html"],"sources":["@wordpress/element/src/raw-html.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { Children, createElement } from './react';\n\n/** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */\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 {JSX.Element} Dangerously-rendering component.\n */\nexport default function RawHTML( { children, ...props } ) {\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":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,OAAOA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAG;EACzD,IAAIC,OAAO,GAAG,EAAE;;EAEhB;EACAC,eAAQ,CAACC,OAAO,CAAEJ,QAAS,CAAC,CAACK,OAAO,CAAIC,KAAK,IAAM;IAClD,IAAK,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAG;MACvDL,OAAO,IAAII,KAAK;IACjB;EACD,CAAE,CAAC;;EAEH;EACA;EACA,OAAO,IAAAE,oBAAa,EAAE,KAAK,EAAE;IAC5BC,uBAAuB,EAAE;MAAEC,MAAM,EAAER;IAAQ,CAAC;IAC5C,GAAGD;EACJ,CAAE,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","RawHTML","children","props","rawHtml","Children","toArray","forEach","child","trim","createElement","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":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,OAAOA,CAAE;EAChCC,QAAQ;EACR,GAAGC;AACU,CAAC,EAAgB;EAC9B,IAAIC,OAAO,GAAG,EAAE;;EAEhB;EACAC,eAAQ,CAACC,OAAO,CAAEJ,QAAS,CAAC,CAACK,OAAO,CAAIC,KAAK,IAAM;IAClD,IAAK,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAG;MACvDL,OAAO,IAAII,KAAK;IACjB;EACD,CAAE,CAAC;;EAEH;EACA;EACA,OAAO,IAAAE,oBAAa,EAAE,KAAK,EAAE;IAC5BC,uBAAuB,EAAE;MAAEC,MAAM,EAAER;IAAQ,CAAC;IAC5C,GAAGD;EACJ,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_reactDom","require","_client"],"sources":["@wordpress/element/src/react-platform.js"],"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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAQA,IAAAC,OAAA,GAAAD,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_reactDom","require","_client"],"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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAQA,IAAAC,OAAA,GAAAD,OAAA","ignoreList":[]}
package/build/react.js CHANGED
@@ -193,41 +193,26 @@ var _react = require("react");
193
193
 
194
194
  /**
195
195
  * Object containing a React element.
196
- *
197
- * @typedef {import('react').ReactElement} Element
198
196
  */
199
197
 
200
198
  /**
201
199
  * Object containing a React component.
202
- *
203
- * @typedef {import('react').ComponentType} ComponentType
204
200
  */
205
201
 
206
202
  /**
207
203
  * Object containing a React synthetic event.
208
- *
209
- * @typedef {import('react').SyntheticEvent} SyntheticEvent
210
204
  */
211
205
 
212
206
  /**
213
207
  * Object containing a React ref object.
214
- *
215
- * @template T
216
- * @typedef {import('react').RefObject<T>} RefObject<T>
217
208
  */
218
209
 
219
210
  /**
220
211
  * Object containing a React ref callback.
221
- *
222
- * @template T
223
- * @typedef {import('react').RefCallback<T>} RefCallback<T>
224
212
  */
225
213
 
226
214
  /**
227
215
  * Object containing a React ref.
228
- *
229
- * @template T
230
- * @typedef {import('react').Ref<T>} Ref<T>
231
216
  */
232
217
 
233
218
  /**
@@ -387,14 +372,13 @@ var _react = require("react");
387
372
  /**
388
373
  * Concatenate two or more React children objects.
389
374
  *
390
- * @param {...?Object} childrenArguments Array of children arguments (array of arrays/strings/objects) to concatenate.
391
- *
392
- * @return {Array} The concatenated value.
375
+ * @param childrenArguments - Array of children arguments (array of arrays/strings/objects) to concatenate.
376
+ * @return The concatenated value.
393
377
  */
394
378
  function concatChildren(...childrenArguments) {
395
379
  return childrenArguments.reduce((accumulator, children, i) => {
396
380
  _react.Children.forEach(children, (child, j) => {
397
- if (child && 'string' !== typeof child) {
381
+ if ((0, _react.isValidElement)(child) && typeof child !== 'string') {
398
382
  child = (0, _react.cloneElement)(child, {
399
383
  key: [i, j].join()
400
384
  });
@@ -408,10 +392,10 @@ function concatChildren(...childrenArguments) {
408
392
  /**
409
393
  * Switches the nodeName of all the elements in the children object.
410
394
  *
411
- * @param {?Object} children Children object.
412
- * @param {string} nodeName Node name.
395
+ * @param children Children object.
396
+ * @param nodeName Node name.
413
397
  *
414
- * @return {?Object} The updated children object.
398
+ * @return The updated children object.
415
399
  */
416
400
  function switchChildrenNodeName(children, nodeName) {
417
401
  return children && _react.Children.map(children, (elt, index) => {
@@ -420,6 +404,9 @@ function switchChildrenNodeName(children, nodeName) {
420
404
  key: index
421
405
  }, elt);
422
406
  }
407
+ if (!(0, _react.isValidElement)(elt)) {
408
+ return elt;
409
+ }
423
410
  const {
424
411
  children: childrenProp,
425
412
  ...props
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","concatChildren","childrenArguments","reduce","accumulator","children","i","Children","forEach","child","j","cloneElement","key","join","push","switchChildrenNodeName","nodeName","map","elt","index","valueOf","createElement","childrenProp","props"],"sources":["@wordpress/element/src/react.js"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport {\n\tChildren,\n\tcloneElement,\n\tComponent,\n\tcreateContext,\n\tcreateElement,\n\tcreateRef,\n\tforwardRef,\n\tFragment,\n\tisValidElement,\n\tmemo,\n\tPureComponent,\n\tStrictMode,\n\tuseCallback,\n\tuseContext,\n\tuseDebugValue,\n\tuseDeferredValue,\n\tuseEffect,\n\tuseId,\n\tuseMemo,\n\tuseImperativeHandle,\n\tuseInsertionEffect,\n\tuseLayoutEffect,\n\tuseReducer,\n\tuseRef,\n\tuseState,\n\tuseSyncExternalStore,\n\tuseTransition,\n\tstartTransition,\n\tlazy,\n\tSuspense,\n} from 'react';\n\n/**\n * Object containing a React element.\n *\n * @typedef {import('react').ReactElement} Element\n */\n\n/**\n * Object containing a React component.\n *\n * @typedef {import('react').ComponentType} ComponentType\n */\n\n/**\n * Object containing a React synthetic event.\n *\n * @typedef {import('react').SyntheticEvent} SyntheticEvent\n */\n\n/**\n * Object containing a React ref object.\n *\n * @template T\n * @typedef {import('react').RefObject<T>} RefObject<T>\n */\n\n/**\n * Object containing a React ref callback.\n *\n * @template T\n * @typedef {import('react').RefCallback<T>} RefCallback<T>\n */\n\n/**\n * Object containing a React ref.\n *\n * @template T\n * @typedef {import('react').Ref<T>} Ref<T>\n */\n\n/**\n * Object that provides utilities for dealing with React children.\n */\nexport { Children };\n\n/**\n * Creates a copy of an element with extended props.\n *\n * @param {Element} element Element\n * @param {?Object} props Props to apply to cloned element\n *\n * @return {Element} Cloned element.\n */\nexport { cloneElement };\n\n/**\n * A base class to create WordPress Components (Refs, state and lifecycle hooks)\n */\nexport { Component };\n\n/**\n * Creates a context object containing two components: a provider and consumer.\n *\n * @param {Object} defaultValue A default data stored in the context.\n *\n * @return {Object} Context object.\n */\nexport { createContext };\n\n/**\n * Returns a new element of given type. Type can be either a string tag name or\n * another function which itself returns an element.\n *\n * @param {?(string|Function)} type Tag name or element creator\n * @param {Object} props Element properties, either attribute\n * set to apply to DOM node or values to\n * pass through to element creator\n * @param {...Element} children Descendant elements\n *\n * @return {Element} Element.\n */\nexport { createElement };\n\n/**\n * Returns an object tracking a reference to a rendered element via its\n * `current` property as either a DOMElement or Element, dependent upon the\n * type of element rendered with the ref attribute.\n *\n * @return {Object} Ref object.\n */\nexport { createRef };\n\n/**\n * Component enhancer used to enable passing a ref to its wrapped component.\n * Pass a function argument which receives `props` and `ref` as its arguments,\n * returning an element using the forwarded ref. The return value is a new\n * component which forwards its ref.\n *\n * @param {Function} forwarder Function passed `props` and `ref`, expected to\n * return an element.\n *\n * @return {Component} Enhanced component.\n */\nexport { forwardRef };\n\n/**\n * A component which renders its children without any wrapping element.\n */\nexport { Fragment };\n\n/**\n * Checks if an object is a valid React Element.\n *\n * @param {Object} objectToCheck The object to be checked.\n *\n * @return {boolean} true if objectToTest is a valid React Element and false otherwise.\n */\nexport { isValidElement };\n\n/**\n * @see https://react.dev/reference/react/memo\n */\nexport { memo };\n\n/**\n * Component that activates additional checks and warnings for its descendants.\n */\nexport { StrictMode };\n\n/**\n * @see https://react.dev/reference/react/useCallback\n */\nexport { useCallback };\n\n/**\n * @see https://react.dev/reference/react/useContext\n */\nexport { useContext };\n\n/**\n * @see https://react.dev/reference/react/useDebugValue\n */\nexport { useDebugValue };\n\n/**\n * @see https://react.dev/reference/react/useDeferredValue\n */\nexport { useDeferredValue };\n\n/**\n * @see https://react.dev/reference/react/useEffect\n */\nexport { useEffect };\n\n/**\n * @see https://react.dev/reference/react/useId\n */\nexport { useId };\n\n/**\n * @see https://react.dev/reference/react/useImperativeHandle\n */\nexport { useImperativeHandle };\n\n/**\n * @see https://react.dev/reference/react/useInsertionEffect\n */\nexport { useInsertionEffect };\n\n/**\n * @see https://react.dev/reference/react/useLayoutEffect\n */\nexport { useLayoutEffect };\n\n/**\n * @see https://react.dev/reference/react/useMemo\n */\nexport { useMemo };\n\n/**\n * @see https://react.dev/reference/react/useReducer\n */\nexport { useReducer };\n\n/**\n * @see https://react.dev/reference/react/useRef\n */\nexport { useRef };\n\n/**\n * @see https://react.dev/reference/react/useState\n */\nexport { useState };\n\n/**\n * @see https://react.dev/reference/react/useSyncExternalStore\n */\nexport { useSyncExternalStore };\n\n/**\n * @see https://react.dev/reference/react/useTransition\n */\nexport { useTransition };\n\n/**\n * @see https://react.dev/reference/react/startTransition\n */\nexport { startTransition };\n\n/**\n * @see https://react.dev/reference/react/lazy\n */\nexport { lazy };\n\n/**\n * @see https://react.dev/reference/react/Suspense\n */\nexport { Suspense };\n\n/**\n * @see https://react.dev/reference/react/PureComponent\n */\nexport { PureComponent };\n\n/**\n * Concatenate two or more React children objects.\n *\n * @param {...?Object} childrenArguments Array of children arguments (array of arrays/strings/objects) to concatenate.\n *\n * @return {Array} The concatenated value.\n */\nexport function concatChildren( ...childrenArguments ) {\n\treturn childrenArguments.reduce( ( accumulator, children, i ) => {\n\t\tChildren.forEach( children, ( child, j ) => {\n\t\t\tif ( child && 'string' !== typeof child ) {\n\t\t\t\tchild = cloneElement( child, {\n\t\t\t\t\tkey: [ i, j ].join(),\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\taccumulator.push( child );\n\t\t} );\n\n\t\treturn accumulator;\n\t}, [] );\n}\n\n/**\n * Switches the nodeName of all the elements in the children object.\n *\n * @param {?Object} children Children object.\n * @param {string} nodeName Node name.\n *\n * @return {?Object} The updated children object.\n */\nexport function switchChildrenNodeName( children, nodeName ) {\n\treturn (\n\t\tchildren &&\n\t\tChildren.map( children, ( elt, index ) => {\n\t\t\tif ( typeof elt?.valueOf() === 'string' ) {\n\t\t\t\treturn createElement( nodeName, { key: index }, elt );\n\t\t\t}\n\t\t\tconst { children: childrenProp, ...props } = elt.props;\n\t\t\treturn createElement(\n\t\t\t\tnodeName,\n\t\t\t\t{ key: index, ...props },\n\t\t\t\tchildrenProp\n\t\t\t);\n\t\t} )\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAJA;AACA;AACA;AACA;;AAkCA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAAE,GAAGC,iBAAiB,EAAG;EACtD,OAAOA,iBAAiB,CAACC,MAAM,CAAE,CAAEC,WAAW,EAAEC,QAAQ,EAAEC,CAAC,KAAM;IAChEC,eAAQ,CAACC,OAAO,CAAEH,QAAQ,EAAE,CAAEI,KAAK,EAAEC,CAAC,KAAM;MAC3C,IAAKD,KAAK,IAAI,QAAQ,KAAK,OAAOA,KAAK,EAAG;QACzCA,KAAK,GAAG,IAAAE,mBAAY,EAAEF,KAAK,EAAE;UAC5BG,GAAG,EAAE,CAAEN,CAAC,EAAEI,CAAC,CAAE,CAACG,IAAI,CAAC;QACpB,CAAE,CAAC;MACJ;MAEAT,WAAW,CAACU,IAAI,CAAEL,KAAM,CAAC;IAC1B,CAAE,CAAC;IAEH,OAAOL,WAAW;EACnB,CAAC,EAAE,EAAG,CAAC;AACR;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASW,sBAAsBA,CAAEV,QAAQ,EAAEW,QAAQ,EAAG;EAC5D,OACCX,QAAQ,IACRE,eAAQ,CAACU,GAAG,CAAEZ,QAAQ,EAAE,CAAEa,GAAG,EAAEC,KAAK,KAAM;IACzC,IAAK,OAAOD,GAAG,EAAEE,OAAO,CAAC,CAAC,KAAK,QAAQ,EAAG;MACzC,OAAO,IAAAC,oBAAa,EAAEL,QAAQ,EAAE;QAAEJ,GAAG,EAAEO;MAAM,CAAC,EAAED,GAAI,CAAC;IACtD;IACA,MAAM;MAAEb,QAAQ,EAAEiB,YAAY;MAAE,GAAGC;IAAM,CAAC,GAAGL,GAAG,CAACK,KAAK;IACtD,OAAO,IAAAF,oBAAa,EACnBL,QAAQ,EACR;MAAEJ,GAAG,EAAEO,KAAK;MAAE,GAAGI;IAAM,CAAC,EACxBD,YACD,CAAC;EACF,CAAE,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","concatChildren","childrenArguments","reduce","accumulator","children","i","Children","forEach","child","j","isValidElement","cloneElement","key","join","push","switchChildrenNodeName","nodeName","map","elt","index","valueOf","createElement","childrenProp","props"],"sources":["@wordpress/element/src/react.ts"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport {\n\tChildren,\n\tcloneElement,\n\tComponent,\n\tcreateContext,\n\tcreateElement,\n\tcreateRef,\n\tforwardRef,\n\tFragment,\n\tisValidElement,\n\tmemo,\n\tPureComponent,\n\tStrictMode,\n\tuseCallback,\n\tuseContext,\n\tuseDebugValue,\n\tuseDeferredValue,\n\tuseEffect,\n\tuseId,\n\tuseMemo,\n\tuseImperativeHandle,\n\tuseInsertionEffect,\n\tuseLayoutEffect,\n\tuseReducer,\n\tuseRef,\n\tuseState,\n\tuseSyncExternalStore,\n\tuseTransition,\n\tstartTransition,\n\tlazy,\n\tSuspense,\n} from 'react';\nimport type { ReactNode } from 'react';\n\n/**\n * Object containing a React element.\n */\nexport type Element = React.ReactElement;\n\n/**\n * Object containing a React component.\n */\nexport type ComponentType< T = any > = React.ComponentType< T >;\n\n/**\n * Object containing a React synthetic event.\n */\nexport type SyntheticEvent< T = Element > = React.SyntheticEvent< T >;\n\n/**\n * Object containing a React ref object.\n */\nexport type RefObject< T > = React.RefObject< T >;\n\n/**\n * Object containing a React ref callback.\n */\nexport type RefCallback< T > = React.RefCallback< T >;\n\n/**\n * Object containing a React ref.\n */\nexport type Ref< T > = React.Ref< T >;\n\n/**\n * Object that provides utilities for dealing with React children.\n */\nexport { Children };\n\n/**\n * Creates a copy of an element with extended props.\n *\n * @param {Element} element Element\n * @param {?Object} props Props to apply to cloned element\n *\n * @return {Element} Cloned element.\n */\nexport { cloneElement };\n\n/**\n * A base class to create WordPress Components (Refs, state and lifecycle hooks)\n */\nexport { Component };\n\n/**\n * Creates a context object containing two components: a provider and consumer.\n *\n * @param {Object} defaultValue A default data stored in the context.\n *\n * @return {Object} Context object.\n */\nexport { createContext };\n\n/**\n * Returns a new element of given type. Type can be either a string tag name or\n * another function which itself returns an element.\n *\n * @param {?(string|Function)} type Tag name or element creator\n * @param {Object} props Element properties, either attribute\n * set to apply to DOM node or values to\n * pass through to element creator\n * @param {...Element} children Descendant elements\n *\n * @return {Element} Element.\n */\nexport { createElement };\n\n/**\n * Returns an object tracking a reference to a rendered element via its\n * `current` property as either a DOMElement or Element, dependent upon the\n * type of element rendered with the ref attribute.\n *\n * @return {Object} Ref object.\n */\nexport { createRef };\n\n/**\n * Component enhancer used to enable passing a ref to its wrapped component.\n * Pass a function argument which receives `props` and `ref` as its arguments,\n * returning an element using the forwarded ref. The return value is a new\n * component which forwards its ref.\n *\n * @param {Function} forwarder Function passed `props` and `ref`, expected to\n * return an element.\n *\n * @return {Component} Enhanced component.\n */\nexport { forwardRef };\n\n/**\n * A component which renders its children without any wrapping element.\n */\nexport { Fragment };\n\n/**\n * Checks if an object is a valid React Element.\n *\n * @param {Object} objectToCheck The object to be checked.\n *\n * @return {boolean} true if objectToTest is a valid React Element and false otherwise.\n */\nexport { isValidElement };\n\n/**\n * @see https://react.dev/reference/react/memo\n */\nexport { memo };\n\n/**\n * Component that activates additional checks and warnings for its descendants.\n */\nexport { StrictMode };\n\n/**\n * @see https://react.dev/reference/react/useCallback\n */\nexport { useCallback };\n\n/**\n * @see https://react.dev/reference/react/useContext\n */\nexport { useContext };\n\n/**\n * @see https://react.dev/reference/react/useDebugValue\n */\nexport { useDebugValue };\n\n/**\n * @see https://react.dev/reference/react/useDeferredValue\n */\nexport { useDeferredValue };\n\n/**\n * @see https://react.dev/reference/react/useEffect\n */\nexport { useEffect };\n\n/**\n * @see https://react.dev/reference/react/useId\n */\nexport { useId };\n\n/**\n * @see https://react.dev/reference/react/useImperativeHandle\n */\nexport { useImperativeHandle };\n\n/**\n * @see https://react.dev/reference/react/useInsertionEffect\n */\nexport { useInsertionEffect };\n\n/**\n * @see https://react.dev/reference/react/useLayoutEffect\n */\nexport { useLayoutEffect };\n\n/**\n * @see https://react.dev/reference/react/useMemo\n */\nexport { useMemo };\n\n/**\n * @see https://react.dev/reference/react/useReducer\n */\nexport { useReducer };\n\n/**\n * @see https://react.dev/reference/react/useRef\n */\nexport { useRef };\n\n/**\n * @see https://react.dev/reference/react/useState\n */\nexport { useState };\n\n/**\n * @see https://react.dev/reference/react/useSyncExternalStore\n */\nexport { useSyncExternalStore };\n\n/**\n * @see https://react.dev/reference/react/useTransition\n */\nexport { useTransition };\n\n/**\n * @see https://react.dev/reference/react/startTransition\n */\nexport { startTransition };\n\n/**\n * @see https://react.dev/reference/react/lazy\n */\nexport { lazy };\n\n/**\n * @see https://react.dev/reference/react/Suspense\n */\nexport { Suspense };\n\n/**\n * @see https://react.dev/reference/react/PureComponent\n */\nexport { PureComponent };\n\n/**\n * Concatenate two or more React children objects.\n *\n * @param childrenArguments - Array of children arguments (array of arrays/strings/objects) to concatenate.\n * @return The concatenated value.\n */\nexport function concatChildren(\n\t...childrenArguments: ReactNode[][]\n): ReactNode[] {\n\treturn childrenArguments.reduce< ReactNode[] >(\n\t\t( accumulator, children, i ) => {\n\t\t\tChildren.forEach( children, ( child, j ) => {\n\t\t\t\tif ( isValidElement( child ) && typeof child !== 'string' ) {\n\t\t\t\t\tchild = cloneElement( child, {\n\t\t\t\t\t\tkey: [ i, j ].join(),\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\taccumulator.push( child );\n\t\t\t} );\n\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n}\n\n/**\n * Switches the nodeName of all the elements in the children object.\n *\n * @param children Children object.\n * @param nodeName Node name.\n *\n * @return The updated children object.\n */\nexport function switchChildrenNodeName(\n\tchildren: ReactNode,\n\tnodeName: string\n): ReactNode {\n\treturn (\n\t\tchildren &&\n\t\tChildren.map( children, ( elt, index ) => {\n\t\t\tif ( typeof elt?.valueOf() === 'string' ) {\n\t\t\t\treturn createElement( nodeName, { key: index }, elt );\n\t\t\t}\n\t\t\tif ( ! isValidElement( elt ) ) {\n\t\t\t\treturn elt;\n\t\t\t}\n\n\t\t\tconst { children: childrenProp, ...props } = elt.props;\n\t\t\treturn createElement(\n\t\t\t\tnodeName,\n\t\t\t\t{ key: index, ...props },\n\t\t\t\tchildrenProp\n\t\t\t);\n\t\t} )\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAJA;AACA;AACA;AACA;;AAmCA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAC7B,GAAGC,iBAAgC,EACrB;EACd,OAAOA,iBAAiB,CAACC,MAAM,CAC9B,CAAEC,WAAW,EAAEC,QAAQ,EAAEC,CAAC,KAAM;IAC/BC,eAAQ,CAACC,OAAO,CAAEH,QAAQ,EAAE,CAAEI,KAAK,EAAEC,CAAC,KAAM;MAC3C,IAAK,IAAAC,qBAAc,EAAEF,KAAM,CAAC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAG;QAC3DA,KAAK,GAAG,IAAAG,mBAAY,EAAEH,KAAK,EAAE;UAC5BI,GAAG,EAAE,CAAEP,CAAC,EAAEI,CAAC,CAAE,CAACI,IAAI,CAAC;QACpB,CAAE,CAAC;MACJ;MAEAV,WAAW,CAACW,IAAI,CAAEN,KAAM,CAAC;IAC1B,CAAE,CAAC;IAEH,OAAOL,WAAW;EACnB,CAAC,EACD,EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;A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