19
|
1 |
/******/ (function() { // webpackBootstrap |
|
2 |
/******/ "use strict"; |
|
3 |
/******/ // The require scope |
|
4 |
/******/ var __webpack_require__ = {}; |
|
5 |
/******/ |
|
6 |
/************************************************************************/ |
|
7 |
/******/ /* webpack/runtime/define property getters */ |
|
8 |
/******/ !function() { |
|
9 |
/******/ // define getter functions for harmony exports |
|
10 |
/******/ __webpack_require__.d = function(exports, definition) { |
|
11 |
/******/ for(var key in definition) { |
|
12 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
|
13 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
|
14 |
/******/ } |
|
15 |
/******/ } |
9
|
16 |
/******/ }; |
19
|
17 |
/******/ }(); |
|
18 |
/******/ |
|
19 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
|
20 |
/******/ !function() { |
|
21 |
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
|
22 |
/******/ }(); |
|
23 |
/******/ |
|
24 |
/******/ /* webpack/runtime/make namespace object */ |
|
25 |
/******/ !function() { |
|
26 |
/******/ // define __esModule on exports |
|
27 |
/******/ __webpack_require__.r = function(exports) { |
|
28 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
29 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
30 |
/******/ } |
|
31 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
32 |
/******/ }; |
|
33 |
/******/ }(); |
|
34 |
/******/ |
9
|
35 |
/************************************************************************/ |
19
|
36 |
var __webpack_exports__ = {}; |
16
|
37 |
// ESM COMPAT FLAG |
9
|
38 |
__webpack_require__.r(__webpack_exports__); |
|
39 |
|
16
|
40 |
// EXPORTS |
19
|
41 |
__webpack_require__.d(__webpack_exports__, { |
|
42 |
"Children": function() { return /* reexport */ external_React_namespaceObject.Children; }, |
|
43 |
"Component": function() { return /* reexport */ external_React_namespaceObject.Component; }, |
|
44 |
"Fragment": function() { return /* reexport */ external_React_namespaceObject.Fragment; }, |
|
45 |
"Platform": function() { return /* reexport */ platform; }, |
|
46 |
"RawHTML": function() { return /* reexport */ RawHTML; }, |
|
47 |
"StrictMode": function() { return /* reexport */ external_React_namespaceObject.StrictMode; }, |
|
48 |
"Suspense": function() { return /* reexport */ external_React_namespaceObject.Suspense; }, |
|
49 |
"cloneElement": function() { return /* reexport */ external_React_namespaceObject.cloneElement; }, |
|
50 |
"concatChildren": function() { return /* reexport */ concatChildren; }, |
|
51 |
"createContext": function() { return /* reexport */ external_React_namespaceObject.createContext; }, |
|
52 |
"createElement": function() { return /* reexport */ external_React_namespaceObject.createElement; }, |
|
53 |
"createInterpolateElement": function() { return /* reexport */ create_interpolate_element; }, |
|
54 |
"createPortal": function() { return /* reexport */ external_ReactDOM_namespaceObject.createPortal; }, |
|
55 |
"createRef": function() { return /* reexport */ external_React_namespaceObject.createRef; }, |
|
56 |
"findDOMNode": function() { return /* reexport */ external_ReactDOM_namespaceObject.findDOMNode; }, |
|
57 |
"forwardRef": function() { return /* reexport */ external_React_namespaceObject.forwardRef; }, |
|
58 |
"isEmptyElement": function() { return /* reexport */ isEmptyElement; }, |
|
59 |
"isValidElement": function() { return /* reexport */ external_React_namespaceObject.isValidElement; }, |
|
60 |
"lazy": function() { return /* reexport */ external_React_namespaceObject.lazy; }, |
|
61 |
"memo": function() { return /* reexport */ external_React_namespaceObject.memo; }, |
|
62 |
"render": function() { return /* reexport */ external_ReactDOM_namespaceObject.render; }, |
|
63 |
"renderToString": function() { return /* reexport */ serialize; }, |
|
64 |
"switchChildrenNodeName": function() { return /* reexport */ switchChildrenNodeName; }, |
|
65 |
"unmountComponentAtNode": function() { return /* reexport */ external_ReactDOM_namespaceObject.unmountComponentAtNode; }, |
|
66 |
"useCallback": function() { return /* reexport */ external_React_namespaceObject.useCallback; }, |
|
67 |
"useContext": function() { return /* reexport */ external_React_namespaceObject.useContext; }, |
|
68 |
"useDebugValue": function() { return /* reexport */ external_React_namespaceObject.useDebugValue; }, |
|
69 |
"useEffect": function() { return /* reexport */ external_React_namespaceObject.useEffect; }, |
|
70 |
"useImperativeHandle": function() { return /* reexport */ external_React_namespaceObject.useImperativeHandle; }, |
|
71 |
"useLayoutEffect": function() { return /* reexport */ external_React_namespaceObject.useLayoutEffect; }, |
|
72 |
"useMemo": function() { return /* reexport */ external_React_namespaceObject.useMemo; }, |
|
73 |
"useReducer": function() { return /* reexport */ external_React_namespaceObject.useReducer; }, |
|
74 |
"useRef": function() { return /* reexport */ external_React_namespaceObject.useRef; }, |
|
75 |
"useState": function() { return /* reexport */ external_React_namespaceObject.useState; } |
|
76 |
}); |
9
|
77 |
|
19
|
78 |
;// CONCATENATED MODULE: external "React" |
|
79 |
var external_React_namespaceObject = window["React"]; |
|
80 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/create-interpolate-element.js |
9
|
81 |
/** |
18
|
82 |
* Internal dependencies |
9
|
83 |
*/ |
|
84 |
|
16
|
85 |
/** @typedef {import('./react').WPElement} WPElement */ |
|
86 |
|
18
|
87 |
let indoc, offset, output, stack; |
16
|
88 |
/** |
|
89 |
* Matches tags in the localized string |
|
90 |
* |
|
91 |
* This is used for extracting the tag pattern groups for parsing the localized |
|
92 |
* string and along with the map converting it to a react element. |
|
93 |
* |
|
94 |
* There are four references extracted using this tokenizer: |
|
95 |
* |
|
96 |
* match: Full match of the tag (i.e. <strong>, </strong>, <br/>) |
|
97 |
* isClosing: The closing slash, it it exists. |
|
98 |
* name: The name portion of the tag (strong, br) (if ) |
|
99 |
* isSelfClosed: The slash on a self closing tag, if it exists. |
|
100 |
* |
|
101 |
* @type {RegExp} |
|
102 |
*/ |
|
103 |
|
18
|
104 |
const tokenizer = /<(\/)?(\w+)\s*(\/)?>/g; |
16
|
105 |
/** |
|
106 |
* The stack frame tracking parse progress. |
|
107 |
* |
|
108 |
* @typedef Frame |
|
109 |
* |
19
|
110 |
* @property {WPElement} element A parent element which may still have |
|
111 |
* @property {number} tokenStart Offset at which parent element first |
|
112 |
* appears. |
|
113 |
* @property {number} tokenLength Length of string marking start of parent |
|
114 |
* element. |
|
115 |
* @property {number} [prevOffset] Running offset at which parsing should |
|
116 |
* continue. |
|
117 |
* @property {number} [leadingTextStart] Offset at which last closing element |
|
118 |
* finished, used for finding text between |
|
119 |
* elements. |
|
120 |
* @property {WPElement[]} children Children. |
16
|
121 |
*/ |
|
122 |
|
|
123 |
/** |
|
124 |
* Tracks recursive-descent parse state. |
|
125 |
* |
|
126 |
* This is a Stack frame holding parent elements until all children have been |
|
127 |
* parsed. |
|
128 |
* |
|
129 |
* @private |
|
130 |
* @param {WPElement} element A parent element which may still have |
|
131 |
* nested children not yet parsed. |
|
132 |
* @param {number} tokenStart Offset at which parent element first |
|
133 |
* appears. |
|
134 |
* @param {number} tokenLength Length of string marking start of parent |
|
135 |
* element. |
|
136 |
* @param {number} [prevOffset] Running offset at which parsing should |
|
137 |
* continue. |
|
138 |
* @param {number} [leadingTextStart] Offset at which last closing element |
|
139 |
* finished, used for finding text between |
|
140 |
* elements. |
|
141 |
* |
|
142 |
* @return {Frame} The stack frame tracking parse progress. |
|
143 |
*/ |
|
144 |
|
|
145 |
function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) { |
|
146 |
return { |
18
|
147 |
element, |
|
148 |
tokenStart, |
|
149 |
tokenLength, |
|
150 |
prevOffset, |
|
151 |
leadingTextStart, |
16
|
152 |
children: [] |
|
153 |
}; |
|
154 |
} |
|
155 |
/** |
|
156 |
* This function creates an interpolated element from a passed in string with |
|
157 |
* specific tags matching how the string should be converted to an element via |
|
158 |
* the conversion map value. |
|
159 |
* |
|
160 |
* @example |
|
161 |
* For example, for the given string: |
|
162 |
* |
|
163 |
* "This is a <span>string</span> with <a>a link</a> and a self-closing |
|
164 |
* <CustomComponentB/> tag" |
|
165 |
* |
|
166 |
* You would have something like this as the conversionMap value: |
|
167 |
* |
|
168 |
* ```js |
|
169 |
* { |
|
170 |
* span: <span />, |
|
171 |
* a: <a href={ 'https://github.com' } />, |
|
172 |
* CustomComponentB: <CustomComponent />, |
|
173 |
* } |
|
174 |
* ``` |
|
175 |
* |
19
|
176 |
* @param {string} interpolatedString The interpolation string to be parsed. |
|
177 |
* @param {Object} conversionMap The map used to convert the string to |
|
178 |
* a react element. |
16
|
179 |
* @throws {TypeError} |
|
180 |
* @return {WPElement} A wp element. |
|
181 |
*/ |
|
182 |
|
|
183 |
|
18
|
184 |
const createInterpolateElement = (interpolatedString, conversionMap) => { |
16
|
185 |
indoc = interpolatedString; |
|
186 |
offset = 0; |
|
187 |
output = []; |
|
188 |
stack = []; |
|
189 |
tokenizer.lastIndex = 0; |
|
190 |
|
18
|
191 |
if (!isValidConversionMap(conversionMap)) { |
16
|
192 |
throw new TypeError('The conversionMap provided is not valid. It must be an object with values that are WPElements'); |
|
193 |
} |
|
194 |
|
|
195 |
do {// twiddle our thumbs |
|
196 |
} while (proceed(conversionMap)); |
|
197 |
|
19
|
198 |
return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, ...output); |
16
|
199 |
}; |
|
200 |
/** |
|
201 |
* Validate conversion map. |
|
202 |
* |
|
203 |
* A map is considered valid if it's an object and every value in the object |
|
204 |
* is a WPElement |
|
205 |
* |
|
206 |
* @private |
|
207 |
* |
19
|
208 |
* @param {Object} conversionMap The map being validated. |
16
|
209 |
* |
|
210 |
* @return {boolean} True means the map is valid. |
|
211 |
*/ |
|
212 |
|
|
213 |
|
18
|
214 |
const isValidConversionMap = conversionMap => { |
|
215 |
const isObject = typeof conversionMap === 'object'; |
|
216 |
const values = isObject && Object.values(conversionMap); |
19
|
217 |
return isObject && values.length && values.every(element => (0,external_React_namespaceObject.isValidElement)(element)); |
16
|
218 |
}; |
|
219 |
/** |
|
220 |
* This is the iterator over the matches in the string. |
|
221 |
* |
|
222 |
* @private |
|
223 |
* |
|
224 |
* @param {Object} conversionMap The conversion map for the string. |
|
225 |
* |
|
226 |
* @return {boolean} true for continuing to iterate, false for finished. |
|
227 |
*/ |
|
228 |
|
|
229 |
|
|
230 |
function proceed(conversionMap) { |
18
|
231 |
const next = nextToken(); |
|
232 |
const [tokenType, name, startOffset, tokenLength] = next; |
|
233 |
const stackDepth = stack.length; |
|
234 |
const leadingTextStart = startOffset > offset ? offset : null; |
16
|
235 |
|
|
236 |
if (!conversionMap[name]) { |
|
237 |
addText(); |
|
238 |
return false; |
|
239 |
} |
|
240 |
|
|
241 |
switch (tokenType) { |
|
242 |
case 'no-more-tokens': |
|
243 |
if (stackDepth !== 0) { |
18
|
244 |
const { |
|
245 |
leadingTextStart: stackLeadingText, |
|
246 |
tokenStart |
|
247 |
} = stack.pop(); |
16
|
248 |
output.push(indoc.substr(stackLeadingText, tokenStart)); |
|
249 |
} |
|
250 |
|
|
251 |
addText(); |
|
252 |
return false; |
|
253 |
|
|
254 |
case 'self-closed': |
|
255 |
if (0 === stackDepth) { |
|
256 |
if (null !== leadingTextStart) { |
|
257 |
output.push(indoc.substr(leadingTextStart, startOffset - leadingTextStart)); |
|
258 |
} |
|
259 |
|
|
260 |
output.push(conversionMap[name]); |
|
261 |
offset = startOffset + tokenLength; |
|
262 |
return true; |
19
|
263 |
} // Otherwise we found an inner element. |
16
|
264 |
|
|
265 |
|
|
266 |
addChild(createFrame(conversionMap[name], startOffset, tokenLength)); |
|
267 |
offset = startOffset + tokenLength; |
|
268 |
return true; |
|
269 |
|
|
270 |
case 'opener': |
|
271 |
stack.push(createFrame(conversionMap[name], startOffset, tokenLength, startOffset + tokenLength, leadingTextStart)); |
|
272 |
offset = startOffset + tokenLength; |
|
273 |
return true; |
|
274 |
|
|
275 |
case 'closer': |
19
|
276 |
// If we're not nesting then this is easy - close the block. |
16
|
277 |
if (1 === stackDepth) { |
|
278 |
closeOuterElement(startOffset); |
|
279 |
offset = startOffset + tokenLength; |
|
280 |
return true; |
19
|
281 |
} // Otherwise we're nested and we have to close out the current |
|
282 |
// block and add it as a innerBlock to the parent. |
16
|
283 |
|
|
284 |
|
18
|
285 |
const stackTop = stack.pop(); |
|
286 |
const text = indoc.substr(stackTop.prevOffset, startOffset - stackTop.prevOffset); |
16
|
287 |
stackTop.children.push(text); |
|
288 |
stackTop.prevOffset = startOffset + tokenLength; |
18
|
289 |
const frame = createFrame(stackTop.element, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength); |
16
|
290 |
frame.children = stackTop.children; |
|
291 |
addChild(frame); |
|
292 |
offset = startOffset + tokenLength; |
|
293 |
return true; |
|
294 |
|
|
295 |
default: |
|
296 |
addText(); |
|
297 |
return false; |
|
298 |
} |
|
299 |
} |
|
300 |
/** |
|
301 |
* Grabs the next token match in the string and returns it's details. |
|
302 |
* |
|
303 |
* @private |
|
304 |
* |
|
305 |
* @return {Array} An array of details for the token matched. |
|
306 |
*/ |
|
307 |
|
|
308 |
|
|
309 |
function nextToken() { |
19
|
310 |
const matches = tokenizer.exec(indoc); // We have no more tokens. |
16
|
311 |
|
|
312 |
if (null === matches) { |
|
313 |
return ['no-more-tokens']; |
|
314 |
} |
|
315 |
|
18
|
316 |
const startedAt = matches.index; |
|
317 |
const [match, isClosing, name, isSelfClosed] = matches; |
|
318 |
const length = match.length; |
16
|
319 |
|
|
320 |
if (isSelfClosed) { |
|
321 |
return ['self-closed', name, startedAt, length]; |
|
322 |
} |
|
323 |
|
|
324 |
if (isClosing) { |
|
325 |
return ['closer', name, startedAt, length]; |
|
326 |
} |
|
327 |
|
|
328 |
return ['opener', name, startedAt, length]; |
|
329 |
} |
|
330 |
/** |
|
331 |
* Pushes text extracted from the indoc string to the output stack given the |
|
332 |
* current rawLength value and offset (if rawLength is provided ) or the |
|
333 |
* indoc.length and offset. |
|
334 |
* |
|
335 |
* @private |
|
336 |
*/ |
|
337 |
|
|
338 |
|
|
339 |
function addText() { |
18
|
340 |
const length = indoc.length - offset; |
16
|
341 |
|
|
342 |
if (0 === length) { |
|
343 |
return; |
|
344 |
} |
|
345 |
|
|
346 |
output.push(indoc.substr(offset, length)); |
|
347 |
} |
|
348 |
/** |
|
349 |
* Pushes a child element to the associated parent element's children for the |
|
350 |
* parent currently active in the stack. |
|
351 |
* |
|
352 |
* @private |
|
353 |
* |
19
|
354 |
* @param {Frame} frame The Frame containing the child element and it's |
|
355 |
* token information. |
16
|
356 |
*/ |
|
357 |
|
|
358 |
|
|
359 |
function addChild(frame) { |
18
|
360 |
const { |
|
361 |
element, |
|
362 |
tokenStart, |
|
363 |
tokenLength, |
|
364 |
prevOffset, |
|
365 |
children |
|
366 |
} = frame; |
|
367 |
const parent = stack[stack.length - 1]; |
|
368 |
const text = indoc.substr(parent.prevOffset, tokenStart - parent.prevOffset); |
16
|
369 |
|
|
370 |
if (text) { |
|
371 |
parent.children.push(text); |
|
372 |
} |
|
373 |
|
19
|
374 |
parent.children.push((0,external_React_namespaceObject.cloneElement)(element, null, ...children)); |
16
|
375 |
parent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength; |
|
376 |
} |
|
377 |
/** |
|
378 |
* This is called for closing tags. It creates the element currently active in |
|
379 |
* the stack. |
|
380 |
* |
|
381 |
* @private |
|
382 |
* |
|
383 |
* @param {number} endOffset Offset at which the closing tag for the element |
|
384 |
* begins in the string. If this is greater than the |
|
385 |
* prevOffset attached to the element, then this |
|
386 |
* helps capture any remaining nested text nodes in |
|
387 |
* the element. |
|
388 |
*/ |
|
389 |
|
|
390 |
|
|
391 |
function closeOuterElement(endOffset) { |
18
|
392 |
const { |
|
393 |
element, |
|
394 |
leadingTextStart, |
|
395 |
prevOffset, |
|
396 |
tokenStart, |
|
397 |
children |
|
398 |
} = stack.pop(); |
|
399 |
const text = endOffset ? indoc.substr(prevOffset, endOffset - prevOffset) : indoc.substr(prevOffset); |
16
|
400 |
|
|
401 |
if (text) { |
|
402 |
children.push(text); |
|
403 |
} |
|
404 |
|
|
405 |
if (null !== leadingTextStart) { |
|
406 |
output.push(indoc.substr(leadingTextStart, tokenStart - leadingTextStart)); |
|
407 |
} |
|
408 |
|
19
|
409 |
output.push((0,external_React_namespaceObject.cloneElement)(element, null, ...children)); |
16
|
410 |
} |
|
411 |
|
18
|
412 |
/* harmony default export */ var create_interpolate_element = (createInterpolateElement); |
16
|
413 |
|
19
|
414 |
;// CONCATENATED MODULE: external "lodash" |
|
415 |
var external_lodash_namespaceObject = window["lodash"]; |
|
416 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/react.js |
16
|
417 |
/** |
|
418 |
* External dependencies |
|
419 |
*/ |
19
|
420 |
// eslint-disable-next-line @typescript-eslint/no-restricted-imports |
16
|
421 |
|
|
422 |
|
|
423 |
/** |
|
424 |
* Object containing a React element. |
|
425 |
* |
|
426 |
* @typedef {import('react').ReactElement} WPElement |
|
427 |
*/ |
|
428 |
|
|
429 |
/** |
|
430 |
* Object containing a React component. |
|
431 |
* |
|
432 |
* @typedef {import('react').ComponentType} WPComponent |
|
433 |
*/ |
|
434 |
|
|
435 |
/** |
|
436 |
* Object containing a React synthetic event. |
|
437 |
* |
|
438 |
* @typedef {import('react').SyntheticEvent} WPSyntheticEvent |
|
439 |
*/ |
9
|
440 |
|
|
441 |
/** |
|
442 |
* Object that provides utilities for dealing with React children. |
|
443 |
*/ |
|
444 |
|
|
445 |
|
|
446 |
/** |
|
447 |
* Creates a copy of an element with extended props. |
|
448 |
* |
|
449 |
* @param {WPElement} element Element |
|
450 |
* @param {?Object} props Props to apply to cloned element |
|
451 |
* |
|
452 |
* @return {WPElement} Cloned element. |
|
453 |
*/ |
|
454 |
|
|
455 |
|
|
456 |
/** |
|
457 |
* A base class to create WordPress Components (Refs, state and lifecycle hooks) |
|
458 |
*/ |
|
459 |
|
|
460 |
|
|
461 |
/** |
|
462 |
* Creates a context object containing two components: a provider and consumer. |
|
463 |
* |
|
464 |
* @param {Object} defaultValue A default data stored in the context. |
|
465 |
* |
|
466 |
* @return {Object} Context object. |
|
467 |
*/ |
|
468 |
|
|
469 |
|
|
470 |
/** |
|
471 |
* Returns a new element of given type. Type can be either a string tag name or |
|
472 |
* another function which itself returns an element. |
|
473 |
* |
|
474 |
* @param {?(string|Function)} type Tag name or element creator |
|
475 |
* @param {Object} props Element properties, either attribute |
16
|
476 |
* set to apply to DOM node or values to |
|
477 |
* pass through to element creator |
9
|
478 |
* @param {...WPElement} children Descendant elements |
|
479 |
* |
|
480 |
* @return {WPElement} Element. |
|
481 |
*/ |
|
482 |
|
|
483 |
|
|
484 |
/** |
|
485 |
* Returns an object tracking a reference to a rendered element via its |
|
486 |
* `current` property as either a DOMElement or Element, dependent upon the |
|
487 |
* type of element rendered with the ref attribute. |
|
488 |
* |
|
489 |
* @return {Object} Ref object. |
|
490 |
*/ |
|
491 |
|
|
492 |
|
|
493 |
/** |
|
494 |
* Component enhancer used to enable passing a ref to its wrapped component. |
|
495 |
* Pass a function argument which receives `props` and `ref` as its arguments, |
|
496 |
* returning an element using the forwarded ref. The return value is a new |
|
497 |
* component which forwards its ref. |
|
498 |
* |
|
499 |
* @param {Function} forwarder Function passed `props` and `ref`, expected to |
|
500 |
* return an element. |
|
501 |
* |
|
502 |
* @return {WPComponent} Enhanced component. |
|
503 |
*/ |
|
504 |
|
|
505 |
|
|
506 |
/** |
|
507 |
* A component which renders its children without any wrapping element. |
|
508 |
*/ |
|
509 |
|
|
510 |
|
|
511 |
/** |
16
|
512 |
* Checks if an object is a valid WPElement. |
9
|
513 |
* |
|
514 |
* @param {Object} objectToCheck The object to be checked. |
|
515 |
* |
|
516 |
* @return {boolean} true if objectToTest is a valid WPElement and false otherwise. |
|
517 |
*/ |
|
518 |
|
|
519 |
|
|
520 |
/** |
16
|
521 |
* @see https://reactjs.org/docs/react-api.html#reactmemo |
|
522 |
*/ |
|
523 |
|
|
524 |
|
|
525 |
/** |
9
|
526 |
* Component that activates additional checks and warnings for its descendants. |
|
527 |
*/ |
|
528 |
|
|
529 |
|
|
530 |
/** |
|
531 |
* @see https://reactjs.org/docs/hooks-reference.html#usecallback |
|
532 |
*/ |
|
533 |
|
|
534 |
|
|
535 |
/** |
|
536 |
* @see https://reactjs.org/docs/hooks-reference.html#usecontext |
|
537 |
*/ |
|
538 |
|
|
539 |
|
|
540 |
/** |
|
541 |
* @see https://reactjs.org/docs/hooks-reference.html#usedebugvalue |
|
542 |
*/ |
|
543 |
|
|
544 |
|
|
545 |
/** |
|
546 |
* @see https://reactjs.org/docs/hooks-reference.html#useeffect |
|
547 |
*/ |
|
548 |
|
|
549 |
|
|
550 |
/** |
|
551 |
* @see https://reactjs.org/docs/hooks-reference.html#useimperativehandle |
|
552 |
*/ |
|
553 |
|
|
554 |
|
|
555 |
/** |
|
556 |
* @see https://reactjs.org/docs/hooks-reference.html#uselayouteffect |
|
557 |
*/ |
|
558 |
|
|
559 |
|
|
560 |
/** |
|
561 |
* @see https://reactjs.org/docs/hooks-reference.html#usememo |
|
562 |
*/ |
|
563 |
|
|
564 |
|
|
565 |
/** |
|
566 |
* @see https://reactjs.org/docs/hooks-reference.html#usereducer |
|
567 |
*/ |
|
568 |
|
|
569 |
|
|
570 |
/** |
|
571 |
* @see https://reactjs.org/docs/hooks-reference.html#useref |
|
572 |
*/ |
|
573 |
|
|
574 |
|
|
575 |
/** |
|
576 |
* @see https://reactjs.org/docs/hooks-reference.html#usestate |
|
577 |
*/ |
|
578 |
|
|
579 |
|
|
580 |
/** |
16
|
581 |
* @see https://reactjs.org/docs/react-api.html#reactlazy |
|
582 |
*/ |
|
583 |
|
|
584 |
|
|
585 |
/** |
|
586 |
* @see https://reactjs.org/docs/react-api.html#reactsuspense |
|
587 |
*/ |
|
588 |
|
|
589 |
|
|
590 |
/** |
9
|
591 |
* Concatenate two or more React children objects. |
|
592 |
* |
|
593 |
* @param {...?Object} childrenArguments Array of children arguments (array of arrays/strings/objects) to concatenate. |
|
594 |
* |
|
595 |
* @return {Array} The concatenated value. |
|
596 |
*/ |
|
597 |
|
19
|
598 |
function concatChildren() { |
|
599 |
for (var _len = arguments.length, childrenArguments = new Array(_len), _key = 0; _key < _len; _key++) { |
|
600 |
childrenArguments[_key] = arguments[_key]; |
|
601 |
} |
|
602 |
|
18
|
603 |
return childrenArguments.reduce((accumulator, children, i) => { |
19
|
604 |
external_React_namespaceObject.Children.forEach(children, (child, j) => { |
9
|
605 |
if (child && 'string' !== typeof child) { |
19
|
606 |
child = (0,external_React_namespaceObject.cloneElement)(child, { |
9
|
607 |
key: [i, j].join() |
|
608 |
}); |
|
609 |
} |
|
610 |
|
16
|
611 |
accumulator.push(child); |
9
|
612 |
}); |
16
|
613 |
return accumulator; |
9
|
614 |
}, []); |
|
615 |
} |
|
616 |
/** |
|
617 |
* Switches the nodeName of all the elements in the children object. |
|
618 |
* |
|
619 |
* @param {?Object} children Children object. |
|
620 |
* @param {string} nodeName Node name. |
|
621 |
* |
|
622 |
* @return {?Object} The updated children object. |
|
623 |
*/ |
|
624 |
|
|
625 |
function switchChildrenNodeName(children, nodeName) { |
19
|
626 |
return children && external_React_namespaceObject.Children.map(children, (elt, index) => { |
|
627 |
if ((0,external_lodash_namespaceObject.isString)(elt)) { |
|
628 |
return (0,external_React_namespaceObject.createElement)(nodeName, { |
9
|
629 |
key: index |
|
630 |
}, elt); |
|
631 |
} |
|
632 |
|
18
|
633 |
const { |
|
634 |
children: childrenProp, |
|
635 |
...props |
|
636 |
} = elt.props; |
19
|
637 |
return (0,external_React_namespaceObject.createElement)(nodeName, { |
18
|
638 |
key: index, |
|
639 |
...props |
|
640 |
}, childrenProp); |
9
|
641 |
}); |
|
642 |
} |
|
643 |
|
19
|
644 |
;// CONCATENATED MODULE: external "ReactDOM" |
|
645 |
var external_ReactDOM_namespaceObject = window["ReactDOM"]; |
|
646 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/react-platform.js |
9
|
647 |
/** |
|
648 |
* External dependencies |
|
649 |
*/ |
|
650 |
|
|
651 |
/** |
|
652 |
* Creates a portal into which a component can be rendered. |
|
653 |
* |
|
654 |
* @see https://github.com/facebook/react/issues/10309#issuecomment-318433235 |
|
655 |
* |
19
|
656 |
* @param {import('./react').WPElement} child Any renderable child, such as an element, |
|
657 |
* string, or fragment. |
|
658 |
* @param {HTMLElement} container DOM node into which element should be rendered. |
9
|
659 |
*/ |
|
660 |
|
|
661 |
|
|
662 |
/** |
16
|
663 |
* Finds the dom node of a React component. |
9
|
664 |
* |
16
|
665 |
* @param {import('./react').WPComponent} component Component's instance. |
9
|
666 |
*/ |
|
667 |
|
|
668 |
|
|
669 |
/** |
|
670 |
* Renders a given element into the target DOM node. |
|
671 |
* |
19
|
672 |
* @param {import('./react').WPElement} element Element to render. |
|
673 |
* @param {HTMLElement} target DOM node into which element should be rendered. |
9
|
674 |
*/ |
|
675 |
|
|
676 |
|
|
677 |
/** |
|
678 |
* Removes any mounted element from the target DOM node. |
|
679 |
* |
|
680 |
* @param {Element} target DOM node in which element is to be removed |
|
681 |
*/ |
|
682 |
|
|
683 |
|
|
684 |
|
19
|
685 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/utils.js |
9
|
686 |
/** |
|
687 |
* External dependencies |
|
688 |
*/ |
|
689 |
|
|
690 |
/** |
|
691 |
* Checks if the provided WP element is empty. |
|
692 |
* |
|
693 |
* @param {*} element WP element to check. |
|
694 |
* @return {boolean} True when an element is considered empty. |
|
695 |
*/ |
|
696 |
|
18
|
697 |
const isEmptyElement = element => { |
19
|
698 |
if ((0,external_lodash_namespaceObject.isNumber)(element)) { |
9
|
699 |
return false; |
|
700 |
} |
|
701 |
|
19
|
702 |
if ((0,external_lodash_namespaceObject.isString)(element) || (0,external_lodash_namespaceObject.isArray)(element)) { |
9
|
703 |
return !element.length; |
|
704 |
} |
|
705 |
|
|
706 |
return !element; |
|
707 |
}; |
|
708 |
|
19
|
709 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/platform.js |
16
|
710 |
/** |
|
711 |
* Parts of this source were derived and modified from react-native-web, |
|
712 |
* released under the MIT license. |
|
713 |
* |
|
714 |
* Copyright (c) 2016-present, Nicolas Gallagher. |
|
715 |
* Copyright (c) 2015-present, Facebook, Inc. |
|
716 |
* |
|
717 |
*/ |
18
|
718 |
const Platform = { |
16
|
719 |
OS: 'web', |
19
|
720 |
select: spec => 'web' in spec ? spec.web : spec.default, |
|
721 |
isWeb: true |
16
|
722 |
}; |
|
723 |
/** |
|
724 |
* Component used to detect the current Platform being used. |
|
725 |
* Use Platform.OS === 'web' to detect if running on web enviroment. |
|
726 |
* |
|
727 |
* This is the same concept as the React Native implementation. |
|
728 |
* |
|
729 |
* @see https://facebook.github.io/react-native/docs/platform-specific-code#platform-module |
|
730 |
* |
|
731 |
* Here is an example of how to use the select method: |
|
732 |
* @example |
|
733 |
* ```js |
|
734 |
* import { Platform } from '@wordpress/element'; |
|
735 |
* |
|
736 |
* const placeholderLabel = Platform.select( { |
|
737 |
* native: __( 'Add media' ), |
|
738 |
* web: __( 'Drag images, upload new ones or select files from your library.' ), |
|
739 |
* } ); |
|
740 |
* ``` |
|
741 |
*/ |
|
742 |
|
|
743 |
/* harmony default export */ var platform = (Platform); |
9
|
744 |
|
19
|
745 |
;// CONCATENATED MODULE: external ["wp","escapeHtml"] |
|
746 |
var external_wp_escapeHtml_namespaceObject = window["wp"]["escapeHtml"]; |
|
747 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/raw-html.js |
9
|
748 |
/** |
|
749 |
* Internal dependencies |
|
750 |
*/ |
16
|
751 |
// Disable reason: JSDoc linter doesn't seem to parse the union (`&`) correctly. |
|
752 |
|
|
753 |
/** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */ |
|
754 |
|
9
|
755 |
/** |
|
756 |
* Component used as equivalent of Fragment with unescaped HTML, in cases where |
|
757 |
* it is desirable to render dangerous HTML without needing a wrapper element. |
|
758 |
* To preserve additional props, a `div` wrapper _will_ be created if any props |
|
759 |
* aside from `children` are passed. |
|
760 |
* |
19
|
761 |
* @param {RawHTMLProps} props Children should be a string of HTML or an array |
|
762 |
* of strings. Other props will be passed through |
|
763 |
* to the div wrapper. |
9
|
764 |
* |
16
|
765 |
* @return {JSX.Element} Dangerously-rendering component. |
9
|
766 |
*/ |
|
767 |
|
19
|
768 |
function RawHTML(_ref) { |
|
769 |
let { |
|
770 |
children, |
|
771 |
...props |
|
772 |
} = _ref; |
|
773 |
let rawHtml = ''; // Cast children as an array, and concatenate each element if it is a string. |
|
774 |
|
|
775 |
external_React_namespaceObject.Children.toArray(children).forEach(child => { |
|
776 |
if (typeof child === 'string' && child.trim() !== '') { |
|
777 |
rawHtml += child; |
|
778 |
} |
|
779 |
}); // The `div` wrapper will be stripped by the `renderElement` serializer in |
|
780 |
// `./serialize.js` unless there are non-children props present. |
|
781 |
|
|
782 |
return (0,external_React_namespaceObject.createElement)('div', { |
9
|
783 |
dangerouslySetInnerHTML: { |
19
|
784 |
__html: rawHtml |
18
|
785 |
}, |
|
786 |
...props |
|
787 |
}); |
9
|
788 |
} |
|
789 |
|
19
|
790 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/serialize.js |
9
|
791 |
/** |
|
792 |
* Parts of this source were derived and modified from fast-react-render, |
|
793 |
* released under the MIT license. |
|
794 |
* |
|
795 |
* https://github.com/alt-j/fast-react-render |
|
796 |
* |
|
797 |
* Copyright (c) 2016 Andrey Morozov |
|
798 |
* |
|
799 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
800 |
* of this software and associated documentation files (the "Software"), to deal |
|
801 |
* in the Software without restriction, including without limitation the rights |
|
802 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
803 |
* copies of the Software, and to permit persons to whom the Software is |
|
804 |
* furnished to do so, subject to the following conditions: |
|
805 |
* |
|
806 |
* The above copyright notice and this permission notice shall be included in |
|
807 |
* all copies or substantial portions of the Software. |
|
808 |
* |
|
809 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
810 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
811 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
812 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
813 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
814 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
815 |
* THE SOFTWARE. |
|
816 |
*/ |
|
817 |
|
|
818 |
/** |
|
819 |
* External dependencies |
|
820 |
*/ |
|
821 |
|
|
822 |
/** |
|
823 |
* WordPress dependencies |
|
824 |
*/ |
|
825 |
|
|
826 |
|
|
827 |
/** |
|
828 |
* Internal dependencies |
|
829 |
*/ |
|
830 |
|
|
831 |
|
|
832 |
|
16
|
833 |
/** @typedef {import('./react').WPElement} WPElement */ |
9
|
834 |
|
18
|
835 |
const { |
|
836 |
Provider, |
|
837 |
Consumer |
19
|
838 |
} = (0,external_React_namespaceObject.createContext)(undefined); |
|
839 |
const ForwardRef = (0,external_React_namespaceObject.forwardRef)(() => { |
16
|
840 |
return null; |
|
841 |
}); |
9
|
842 |
/** |
|
843 |
* Valid attribute types. |
|
844 |
* |
16
|
845 |
* @type {Set<string>} |
9
|
846 |
*/ |
|
847 |
|
18
|
848 |
const ATTRIBUTES_TYPES = new Set(['string', 'boolean', 'number']); |
9
|
849 |
/** |
|
850 |
* Element tags which can be self-closing. |
|
851 |
* |
16
|
852 |
* @type {Set<string>} |
9
|
853 |
*/ |
|
854 |
|
18
|
855 |
const SELF_CLOSING_TAGS = new Set(['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']); |
9
|
856 |
/** |
|
857 |
* Boolean attributes are attributes whose presence as being assigned is |
|
858 |
* meaningful, even if only empty. |
|
859 |
* |
|
860 |
* See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes |
|
861 |
* Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 |
|
862 |
* |
|
863 |
* Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ] |
|
864 |
* .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 ) |
|
865 |
* .reduce( ( result, tr ) => Object.assign( result, { |
|
866 |
* [ tr.firstChild.textContent.trim() ]: true |
|
867 |
* } ), {} ) ).sort(); |
|
868 |
* |
16
|
869 |
* @type {Set<string>} |
9
|
870 |
*/ |
|
871 |
|
18
|
872 |
const BOOLEAN_ATTRIBUTES = new Set(['allowfullscreen', 'allowpaymentrequest', 'allowusermedia', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'download', 'formnovalidate', 'hidden', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected', 'typemustmatch']); |
9
|
873 |
/** |
|
874 |
* Enumerated attributes are attributes which must be of a specific value form. |
|
875 |
* Like boolean attributes, these are meaningful if specified, even if not of a |
|
876 |
* valid enumerated value. |
|
877 |
* |
|
878 |
* See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute |
|
879 |
* Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 |
|
880 |
* |
|
881 |
* Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ] |
|
882 |
* .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) ) |
|
883 |
* .reduce( ( result, tr ) => Object.assign( result, { |
|
884 |
* [ tr.firstChild.textContent.trim() ]: true |
|
885 |
* } ), {} ) ).sort(); |
|
886 |
* |
|
887 |
* Some notable omissions: |
|
888 |
* |
|
889 |
* - `alt`: https://blog.whatwg.org/omit-alt |
|
890 |
* |
16
|
891 |
* @type {Set<string>} |
9
|
892 |
*/ |
|
893 |
|
18
|
894 |
const ENUMERATED_ATTRIBUTES = new Set(['autocapitalize', 'autocomplete', 'charset', 'contenteditable', 'crossorigin', 'decoding', 'dir', 'draggable', 'enctype', 'formenctype', 'formmethod', 'http-equiv', 'inputmode', 'kind', 'method', 'preload', 'scope', 'shape', 'spellcheck', 'translate', 'type', 'wrap']); |
9
|
895 |
/** |
|
896 |
* Set of CSS style properties which support assignment of unitless numbers. |
|
897 |
* Used in rendering of style properties, where `px` unit is assumed unless |
|
898 |
* property is included in this set or value is zero. |
|
899 |
* |
|
900 |
* Generated via: |
|
901 |
* |
|
902 |
* Object.entries( document.createElement( 'div' ).style ) |
|
903 |
* .filter( ( [ key ] ) => ( |
|
904 |
* ! /^(webkit|ms|moz)/.test( key ) && |
|
905 |
* ( e.style[ key ] = 10 ) && |
|
906 |
* e.style[ key ] === '10' |
|
907 |
* ) ) |
|
908 |
* .map( ( [ key ] ) => key ) |
|
909 |
* .sort(); |
|
910 |
* |
16
|
911 |
* @type {Set<string>} |
9
|
912 |
*/ |
|
913 |
|
18
|
914 |
const CSS_PROPERTIES_SUPPORTS_UNITLESS = new Set(['animation', 'animationIterationCount', 'baselineShift', 'borderImageOutset', 'borderImageSlice', 'borderImageWidth', 'columnCount', 'cx', 'cy', 'fillOpacity', 'flexGrow', 'flexShrink', 'floodOpacity', 'fontWeight', 'gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart', 'lineHeight', 'opacity', 'order', 'orphans', 'r', 'rx', 'ry', 'shapeImageThreshold', 'stopOpacity', 'strokeDasharray', 'strokeDashoffset', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'tabSize', 'widows', 'x', 'y', 'zIndex', 'zoom']); |
9
|
915 |
/** |
|
916 |
* Returns true if the specified string is prefixed by one of an array of |
|
917 |
* possible prefixes. |
|
918 |
* |
|
919 |
* @param {string} string String to check. |
|
920 |
* @param {string[]} prefixes Possible prefixes. |
|
921 |
* |
|
922 |
* @return {boolean} Whether string has prefix. |
|
923 |
*/ |
|
924 |
|
|
925 |
function hasPrefix(string, prefixes) { |
18
|
926 |
return prefixes.some(prefix => string.indexOf(prefix) === 0); |
9
|
927 |
} |
|
928 |
/** |
|
929 |
* Returns true if the given prop name should be ignored in attributes |
|
930 |
* serialization, or false otherwise. |
|
931 |
* |
|
932 |
* @param {string} attribute Attribute to check. |
|
933 |
* |
|
934 |
* @return {boolean} Whether attribute should be ignored. |
|
935 |
*/ |
|
936 |
|
|
937 |
function isInternalAttribute(attribute) { |
|
938 |
return 'key' === attribute || 'children' === attribute; |
|
939 |
} |
|
940 |
/** |
|
941 |
* Returns the normal form of the element's attribute value for HTML. |
|
942 |
* |
|
943 |
* @param {string} attribute Attribute name. |
|
944 |
* @param {*} value Non-normalized attribute value. |
|
945 |
* |
16
|
946 |
* @return {*} Normalized attribute value. |
9
|
947 |
*/ |
|
948 |
|
|
949 |
|
|
950 |
function getNormalAttributeValue(attribute, value) { |
|
951 |
switch (attribute) { |
|
952 |
case 'style': |
|
953 |
return renderStyle(value); |
|
954 |
} |
|
955 |
|
|
956 |
return value; |
|
957 |
} |
|
958 |
/** |
19
|
959 |
* This is a map of all SVG attributes that have dashes. Map(lower case prop => dashed lower case attribute). |
|
960 |
* We need this to render e.g strokeWidth as stroke-width. |
|
961 |
* |
|
962 |
* List from: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute. |
|
963 |
*/ |
|
964 |
|
|
965 |
|
|
966 |
const SVG_ATTRIBUTE_WITH_DASHES_LIST = ['accentHeight', 'alignmentBaseline', 'arabicForm', 'baselineShift', 'capHeight', 'clipPath', 'clipRule', 'colorInterpolation', 'colorInterpolationFilters', 'colorProfile', 'colorRendering', 'dominantBaseline', 'enableBackground', 'fillOpacity', 'fillRule', 'floodColor', 'floodOpacity', 'fontFamily', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontWeight', 'glyphName', 'glyphOrientationHorizontal', 'glyphOrientationVertical', 'horizAdvX', 'horizOriginX', 'imageRendering', 'letterSpacing', 'lightingColor', 'markerEnd', 'markerMid', 'markerStart', 'overlinePosition', 'overlineThickness', 'paintOrder', 'panose1', 'pointerEvents', 'renderingIntent', 'shapeRendering', 'stopColor', 'stopOpacity', 'strikethroughPosition', 'strikethroughThickness', 'strokeDasharray', 'strokeDashoffset', 'strokeLinecap', 'strokeLinejoin', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'textAnchor', 'textDecoration', 'textRendering', 'underlinePosition', 'underlineThickness', 'unicodeBidi', 'unicodeRange', 'unitsPerEm', 'vAlphabetic', 'vHanging', 'vIdeographic', 'vMathematical', 'vectorEffect', 'vertAdvY', 'vertOriginX', 'vertOriginY', 'wordSpacing', 'writingMode', 'xmlnsXlink', 'xHeight'].reduce((map, attribute) => { |
|
967 |
// The keys are lower-cased for more robust lookup. |
|
968 |
map[attribute.toLowerCase()] = attribute; |
|
969 |
return map; |
|
970 |
}, {}); |
|
971 |
/** |
|
972 |
* This is a map of all case-sensitive SVG attributes. Map(lowercase key => proper case attribute). |
|
973 |
* The keys are lower-cased for more robust lookup. |
|
974 |
* Note that this list only contains attributes that contain at least one capital letter. |
|
975 |
* Lowercase attributes don't need mapping, since we lowercase all attributes by default. |
|
976 |
*/ |
|
977 |
|
|
978 |
const CASE_SENSITIVE_SVG_ATTRIBUTES = ['allowReorder', 'attributeName', 'attributeType', 'autoReverse', 'baseFrequency', 'baseProfile', 'calcMode', 'clipPathUnits', 'contentScriptType', 'contentStyleType', 'diffuseConstant', 'edgeMode', 'externalResourcesRequired', 'filterRes', 'filterUnits', 'glyphRef', 'gradientTransform', 'gradientUnits', 'kernelMatrix', 'kernelUnitLength', 'keyPoints', 'keySplines', 'keyTimes', 'lengthAdjust', 'limitingConeAngle', 'markerHeight', 'markerUnits', 'markerWidth', 'maskContentUnits', 'maskUnits', 'numOctaves', 'pathLength', 'patternContentUnits', 'patternTransform', 'patternUnits', 'pointsAtX', 'pointsAtY', 'pointsAtZ', 'preserveAlpha', 'preserveAspectRatio', 'primitiveUnits', 'refX', 'refY', 'repeatCount', 'repeatDur', 'requiredExtensions', 'requiredFeatures', 'specularConstant', 'specularExponent', 'spreadMethod', 'startOffset', 'stdDeviation', 'stitchTiles', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'surfaceScale', 'systemLanguage', 'tableValues', 'targetX', 'targetY', 'textLength', 'viewBox', 'viewTarget', 'xChannelSelector', 'yChannelSelector'].reduce((map, attribute) => { |
|
979 |
// The keys are lower-cased for more robust lookup. |
|
980 |
map[attribute.toLowerCase()] = attribute; |
|
981 |
return map; |
|
982 |
}, {}); |
|
983 |
/** |
|
984 |
* This is a map of all SVG attributes that have colons. |
|
985 |
* Keys are lower-cased and stripped of their colons for more robust lookup. |
|
986 |
*/ |
|
987 |
|
|
988 |
const SVG_ATTRIBUTES_WITH_COLONS = ['xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'xmlns:xlink'].reduce((map, attribute) => { |
|
989 |
map[attribute.replace(':', '').toLowerCase()] = attribute; |
|
990 |
return map; |
|
991 |
}, {}); |
|
992 |
/** |
9
|
993 |
* Returns the normal form of the element's attribute name for HTML. |
|
994 |
* |
|
995 |
* @param {string} attribute Non-normalized attribute name. |
|
996 |
* |
|
997 |
* @return {string} Normalized attribute name. |
|
998 |
*/ |
|
999 |
|
|
1000 |
function getNormalAttributeName(attribute) { |
|
1001 |
switch (attribute) { |
|
1002 |
case 'htmlFor': |
|
1003 |
return 'for'; |
|
1004 |
|
|
1005 |
case 'className': |
|
1006 |
return 'class'; |
|
1007 |
} |
|
1008 |
|
19
|
1009 |
const attributeLowerCase = attribute.toLowerCase(); |
|
1010 |
|
|
1011 |
if (CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]) { |
|
1012 |
return CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]; |
|
1013 |
} else if (SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]) { |
|
1014 |
return (0,external_lodash_namespaceObject.kebabCase)(SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]); |
|
1015 |
} else if (SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]) { |
|
1016 |
return SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]; |
|
1017 |
} |
|
1018 |
|
|
1019 |
return attributeLowerCase; |
9
|
1020 |
} |
|
1021 |
/** |
|
1022 |
* Returns the normal form of the style property name for HTML. |
|
1023 |
* |
|
1024 |
* - Converts property names to kebab-case, e.g. 'backgroundColor' → 'background-color' |
|
1025 |
* - Leaves custom attributes alone, e.g. '--myBackgroundColor' → '--myBackgroundColor' |
|
1026 |
* - Converts vendor-prefixed property names to -kebab-case, e.g. 'MozTransform' → '-moz-transform' |
|
1027 |
* |
|
1028 |
* @param {string} property Property name. |
|
1029 |
* |
|
1030 |
* @return {string} Normalized property name. |
|
1031 |
*/ |
|
1032 |
|
|
1033 |
|
|
1034 |
function getNormalStylePropertyName(property) { |
19
|
1035 |
if ((0,external_lodash_namespaceObject.startsWith)(property, '--')) { |
9
|
1036 |
return property; |
|
1037 |
} |
|
1038 |
|
|
1039 |
if (hasPrefix(property, ['ms', 'O', 'Moz', 'Webkit'])) { |
19
|
1040 |
return '-' + (0,external_lodash_namespaceObject.kebabCase)(property); |
9
|
1041 |
} |
|
1042 |
|
19
|
1043 |
return (0,external_lodash_namespaceObject.kebabCase)(property); |
9
|
1044 |
} |
|
1045 |
/** |
|
1046 |
* Returns the normal form of the style property value for HTML. Appends a |
|
1047 |
* default pixel unit if numeric, not a unitless property, and not zero. |
|
1048 |
* |
|
1049 |
* @param {string} property Property name. |
|
1050 |
* @param {*} value Non-normalized property value. |
|
1051 |
* |
|
1052 |
* @return {*} Normalized property value. |
|
1053 |
*/ |
|
1054 |
|
|
1055 |
|
|
1056 |
function getNormalStylePropertyValue(property, value) { |
|
1057 |
if (typeof value === 'number' && 0 !== value && !CSS_PROPERTIES_SUPPORTS_UNITLESS.has(property)) { |
|
1058 |
return value + 'px'; |
|
1059 |
} |
|
1060 |
|
|
1061 |
return value; |
|
1062 |
} |
|
1063 |
/** |
|
1064 |
* Serializes a React element to string. |
|
1065 |
* |
16
|
1066 |
* @param {import('react').ReactNode} element Element to serialize. |
|
1067 |
* @param {Object} [context] Context object. |
|
1068 |
* @param {Object} [legacyContext] Legacy context object. |
9
|
1069 |
* |
|
1070 |
* @return {string} Serialized element. |
|
1071 |
*/ |
|
1072 |
|
|
1073 |
|
19
|
1074 |
function renderElement(element, context) { |
|
1075 |
let legacyContext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
|
1076 |
|
9
|
1077 |
if (null === element || undefined === element || false === element) { |
|
1078 |
return ''; |
|
1079 |
} |
|
1080 |
|
|
1081 |
if (Array.isArray(element)) { |
|
1082 |
return renderChildren(element, context, legacyContext); |
|
1083 |
} |
|
1084 |
|
18
|
1085 |
switch (typeof element) { |
9
|
1086 |
case 'string': |
19
|
1087 |
return (0,external_wp_escapeHtml_namespaceObject.escapeHTML)(element); |
9
|
1088 |
|
|
1089 |
case 'number': |
|
1090 |
return element.toString(); |
|
1091 |
} |
|
1092 |
|
18
|
1093 |
const { |
|
1094 |
type, |
|
1095 |
props |
|
1096 |
} = |
16
|
1097 |
/** @type {{type?: any, props?: any}} */ |
18
|
1098 |
element; |
9
|
1099 |
|
|
1100 |
switch (type) { |
19
|
1101 |
case external_React_namespaceObject.StrictMode: |
|
1102 |
case external_React_namespaceObject.Fragment: |
9
|
1103 |
return renderChildren(props.children, context, legacyContext); |
|
1104 |
|
|
1105 |
case RawHTML: |
18
|
1106 |
const { |
|
1107 |
children, |
|
1108 |
...wrapperProps |
|
1109 |
} = props; |
19
|
1110 |
return renderNativeComponent((0,external_lodash_namespaceObject.isEmpty)(wrapperProps) ? null : 'div', { ...wrapperProps, |
9
|
1111 |
dangerouslySetInnerHTML: { |
|
1112 |
__html: children |
|
1113 |
} |
18
|
1114 |
}, context, legacyContext); |
9
|
1115 |
} |
|
1116 |
|
18
|
1117 |
switch (typeof type) { |
9
|
1118 |
case 'string': |
|
1119 |
return renderNativeComponent(type, props, context, legacyContext); |
|
1120 |
|
|
1121 |
case 'function': |
|
1122 |
if (type.prototype && typeof type.prototype.render === 'function') { |
|
1123 |
return renderComponent(type, props, context, legacyContext); |
|
1124 |
} |
|
1125 |
|
|
1126 |
return renderElement(type(props, legacyContext), context, legacyContext); |
|
1127 |
} |
|
1128 |
|
|
1129 |
switch (type && type.$$typeof) { |
|
1130 |
case Provider.$$typeof: |
|
1131 |
return renderChildren(props.children, props.value, legacyContext); |
|
1132 |
|
|
1133 |
case Consumer.$$typeof: |
|
1134 |
return renderElement(props.children(context || type._currentValue), context, legacyContext); |
16
|
1135 |
|
|
1136 |
case ForwardRef.$$typeof: |
|
1137 |
return renderElement(type.render(props), context, legacyContext); |
9
|
1138 |
} |
|
1139 |
|
|
1140 |
return ''; |
|
1141 |
} |
|
1142 |
/** |
|
1143 |
* Serializes a native component type to string. |
|
1144 |
* |
16
|
1145 |
* @param {?string} type Native component type to serialize, or null if |
|
1146 |
* rendering as fragment of children content. |
|
1147 |
* @param {Object} props Props object. |
|
1148 |
* @param {Object} [context] Context object. |
|
1149 |
* @param {Object} [legacyContext] Legacy context object. |
9
|
1150 |
* |
|
1151 |
* @return {string} Serialized element. |
|
1152 |
*/ |
|
1153 |
|
19
|
1154 |
function renderNativeComponent(type, props, context) { |
|
1155 |
let legacyContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; |
18
|
1156 |
let content = ''; |
9
|
1157 |
|
|
1158 |
if (type === 'textarea' && props.hasOwnProperty('value')) { |
|
1159 |
// Textarea children can be assigned as value prop. If it is, render in |
|
1160 |
// place of children. Ensure to omit so it is not assigned as attribute |
|
1161 |
// as well. |
|
1162 |
content = renderChildren(props.value, context, legacyContext); |
19
|
1163 |
props = (0,external_lodash_namespaceObject.omit)(props, 'value'); |
9
|
1164 |
} else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html === 'string') { |
|
1165 |
// Dangerous content is left unescaped. |
|
1166 |
content = props.dangerouslySetInnerHTML.__html; |
|
1167 |
} else if (typeof props.children !== 'undefined') { |
|
1168 |
content = renderChildren(props.children, context, legacyContext); |
|
1169 |
} |
|
1170 |
|
|
1171 |
if (!type) { |
|
1172 |
return content; |
|
1173 |
} |
|
1174 |
|
18
|
1175 |
const attributes = renderAttributes(props); |
9
|
1176 |
|
|
1177 |
if (SELF_CLOSING_TAGS.has(type)) { |
|
1178 |
return '<' + type + attributes + '/>'; |
|
1179 |
} |
|
1180 |
|
|
1181 |
return '<' + type + attributes + '>' + content + '</' + type + '>'; |
|
1182 |
} |
16
|
1183 |
/** @typedef {import('./react').WPComponent} WPComponent */ |
|
1184 |
|
9
|
1185 |
/** |
|
1186 |
* Serializes a non-native component type to string. |
|
1187 |
* |
16
|
1188 |
* @param {WPComponent} Component Component type to serialize. |
|
1189 |
* @param {Object} props Props object. |
|
1190 |
* @param {Object} [context] Context object. |
|
1191 |
* @param {Object} [legacyContext] Legacy context object. |
9
|
1192 |
* |
|
1193 |
* @return {string} Serialized element |
|
1194 |
*/ |
|
1195 |
|
19
|
1196 |
function renderComponent(Component, props, context) { |
|
1197 |
let legacyContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; |
18
|
1198 |
const instance = new |
16
|
1199 |
/** @type {import('react').ComponentClass} */ |
|
1200 |
Component(props, legacyContext); |
9
|
1201 |
|
16
|
1202 |
if (typeof // Ignore reason: Current prettier reformats parens and mangles type assertion |
|
1203 |
// prettier-ignore |
|
1204 |
|
|
1205 |
/** @type {{getChildContext?: () => unknown}} */ |
|
1206 |
instance.getChildContext === 'function') { |
|
1207 |
Object.assign(legacyContext, |
|
1208 |
/** @type {{getChildContext?: () => unknown}} */ |
|
1209 |
instance.getChildContext()); |
9
|
1210 |
} |
|
1211 |
|
18
|
1212 |
const html = renderElement(instance.render(), context, legacyContext); |
9
|
1213 |
return html; |
|
1214 |
} |
|
1215 |
/** |
|
1216 |
* Serializes an array of children to string. |
|
1217 |
* |
16
|
1218 |
* @param {import('react').ReactNodeArray} children Children to serialize. |
|
1219 |
* @param {Object} [context] Context object. |
|
1220 |
* @param {Object} [legacyContext] Legacy context object. |
9
|
1221 |
* |
|
1222 |
* @return {string} Serialized children. |
|
1223 |
*/ |
|
1224 |
|
19
|
1225 |
function renderChildren(children, context) { |
|
1226 |
let legacyContext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
18
|
1227 |
let result = ''; |
19
|
1228 |
children = (0,external_lodash_namespaceObject.castArray)(children); |
9
|
1229 |
|
18
|
1230 |
for (let i = 0; i < children.length; i++) { |
|
1231 |
const child = children[i]; |
9
|
1232 |
result += renderElement(child, context, legacyContext); |
|
1233 |
} |
|
1234 |
|
|
1235 |
return result; |
|
1236 |
} |
|
1237 |
/** |
|
1238 |
* Renders a props object as a string of HTML attributes. |
|
1239 |
* |
|
1240 |
* @param {Object} props Props object. |
|
1241 |
* |
|
1242 |
* @return {string} Attributes string. |
|
1243 |
*/ |
|
1244 |
|
|
1245 |
|
|
1246 |
function renderAttributes(props) { |
18
|
1247 |
let result = ''; |
9
|
1248 |
|
18
|
1249 |
for (const key in props) { |
|
1250 |
const attribute = getNormalAttributeName(key); |
9
|
1251 |
|
19
|
1252 |
if (!(0,external_wp_escapeHtml_namespaceObject.isValidAttributeName)(attribute)) { |
9
|
1253 |
continue; |
|
1254 |
} |
|
1255 |
|
18
|
1256 |
let value = getNormalAttributeValue(key, props[key]); // If value is not of serializeable type, skip. |
9
|
1257 |
|
18
|
1258 |
if (!ATTRIBUTES_TYPES.has(typeof value)) { |
9
|
1259 |
continue; |
|
1260 |
} // Don't render internal attribute names. |
|
1261 |
|
|
1262 |
|
|
1263 |
if (isInternalAttribute(key)) { |
|
1264 |
continue; |
|
1265 |
} |
|
1266 |
|
18
|
1267 |
const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has(attribute); // Boolean attribute should be omitted outright if its value is false. |
9
|
1268 |
|
|
1269 |
if (isBooleanAttribute && value === false) { |
|
1270 |
continue; |
|
1271 |
} |
|
1272 |
|
18
|
1273 |
const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ['data-', 'aria-']) || ENUMERATED_ATTRIBUTES.has(attribute); // Only write boolean value as attribute if meaningful. |
9
|
1274 |
|
|
1275 |
if (typeof value === 'boolean' && !isMeaningfulAttribute) { |
|
1276 |
continue; |
|
1277 |
} |
|
1278 |
|
|
1279 |
result += ' ' + attribute; // Boolean attributes should write attribute name, but without value. |
|
1280 |
// Mere presence of attribute name is effective truthiness. |
|
1281 |
|
|
1282 |
if (isBooleanAttribute) { |
|
1283 |
continue; |
|
1284 |
} |
|
1285 |
|
|
1286 |
if (typeof value === 'string') { |
19
|
1287 |
value = (0,external_wp_escapeHtml_namespaceObject.escapeAttribute)(value); |
9
|
1288 |
} |
|
1289 |
|
|
1290 |
result += '="' + value + '"'; |
|
1291 |
} |
|
1292 |
|
|
1293 |
return result; |
|
1294 |
} |
|
1295 |
/** |
|
1296 |
* Renders a style object as a string attribute value. |
|
1297 |
* |
|
1298 |
* @param {Object} style Style object. |
|
1299 |
* |
|
1300 |
* @return {string} Style attribute value. |
|
1301 |
*/ |
|
1302 |
|
|
1303 |
function renderStyle(style) { |
|
1304 |
// Only generate from object, e.g. tolerate string value. |
19
|
1305 |
if (!(0,external_lodash_namespaceObject.isPlainObject)(style)) { |
9
|
1306 |
return style; |
|
1307 |
} |
|
1308 |
|
18
|
1309 |
let result; |
9
|
1310 |
|
18
|
1311 |
for (const property in style) { |
|
1312 |
const value = style[property]; |
9
|
1313 |
|
|
1314 |
if (null === value || undefined === value) { |
|
1315 |
continue; |
|
1316 |
} |
|
1317 |
|
|
1318 |
if (result) { |
|
1319 |
result += ';'; |
|
1320 |
} else { |
|
1321 |
result = ''; |
|
1322 |
} |
|
1323 |
|
18
|
1324 |
const normalName = getNormalStylePropertyName(property); |
|
1325 |
const normalValue = getNormalStylePropertyValue(property, value); |
9
|
1326 |
result += normalName + ':' + normalValue; |
|
1327 |
} |
|
1328 |
|
|
1329 |
return result; |
|
1330 |
} |
|
1331 |
/* harmony default export */ var serialize = (renderElement); |
|
1332 |
|
19
|
1333 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/index.js |
16
|
1334 |
|
|
1335 |
|
9
|
1336 |
|
|
1337 |
|
|
1338 |
|
|
1339 |
|
|
1340 |
|
|
1341 |
|
19
|
1342 |
(window.wp = window.wp || {}).element = __webpack_exports__; |
|
1343 |
/******/ })() |
|
1344 |
; |