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