| 1 |
/******/ (() => { // webpackBootstrap |
| 2 |
/******/ "use strict"; |
| 3 |
/******/ var __webpack_modules__ = ({ |
| 4 |
|
| 5 |
/***/ 4140: |
| 6 |
/***/ ((__unused_webpack_module, exports, __webpack_require__) => { |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
var m = __webpack_require__(5795); |
| 11 |
if (true) { |
| 12 |
exports.H = m.createRoot; |
| 13 |
exports.c = m.hydrateRoot; |
| 14 |
} else { var i; } |
| 15 |
|
| 16 |
|
| 17 |
/***/ }), |
| 18 |
|
| 19 |
/***/ 5795: |
| 20 |
/***/ ((module) => { |
| 21 |
|
| 22 |
module.exports = window["ReactDOM"]; |
| 23 |
|
| 24 |
/***/ }) |
| 25 |
|
| 26 |
/******/ }); |
| 27 |
/************************************************************************/ |
| 28 |
/******/ // The module cache |
| 29 |
/******/ var __webpack_module_cache__ = {}; |
| 30 |
/******/ |
| 31 |
/******/ // The require function |
| 32 |
/******/ function __webpack_require__(moduleId) { |
| 33 |
/******/ // Check if module is in cache |
| 34 |
/******/ var cachedModule = __webpack_module_cache__[moduleId]; |
| 35 |
/******/ if (cachedModule !== undefined) { |
| 36 |
/******/ return cachedModule.exports; |
| 37 |
/******/ } |
| 38 |
/******/ // Create a new module (and put it into the cache) |
| 39 |
/******/ var module = __webpack_module_cache__[moduleId] = { |
| 40 |
/******/ // no module.id needed |
| 41 |
/******/ // no module.loaded needed |
| 42 |
/******/ exports: {} |
| 43 |
/******/ }; |
| 44 |
/******/ |
| 45 |
/******/ // Execute the module function |
| 46 |
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
| 47 |
/******/ |
| 48 |
/******/ // Return the exports of the module |
| 49 |
/******/ return module.exports; |
| 50 |
/******/ } |
| 51 |
/******/ |
| 52 |
/************************************************************************/ |
| 53 |
/******/ /* webpack/runtime/define property getters */ |
| 54 |
/******/ (() => { |
| 55 |
/******/ // define getter functions for harmony exports |
| 56 |
/******/ __webpack_require__.d = (exports, definition) => { |
| 57 |
/******/ for(var key in definition) { |
| 58 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
| 59 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 60 |
/******/ } |
| 61 |
/******/ } |
| 62 |
/******/ }; |
| 63 |
/******/ })(); |
| 64 |
/******/ |
| 65 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 66 |
/******/ (() => { |
| 67 |
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
| 68 |
/******/ })(); |
| 69 |
/******/ |
| 70 |
/******/ /* webpack/runtime/make namespace object */ |
| 71 |
/******/ (() => { |
| 72 |
/******/ // define __esModule on exports |
| 73 |
/******/ __webpack_require__.r = (exports) => { |
| 74 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 75 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 76 |
/******/ } |
| 77 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 78 |
/******/ }; |
| 79 |
/******/ })(); |
| 80 |
/******/ |
| 81 |
/************************************************************************/ |
| 82 |
var __webpack_exports__ = {}; |
| 83 |
// ESM COMPAT FLAG |
| 84 |
__webpack_require__.r(__webpack_exports__); |
| 85 |
|
| 86 |
// EXPORTS |
| 87 |
__webpack_require__.d(__webpack_exports__, { |
| 88 |
Children: () => (/* reexport */ external_React_namespaceObject.Children), |
| 89 |
Component: () => (/* reexport */ external_React_namespaceObject.Component), |
| 90 |
Fragment: () => (/* reexport */ external_React_namespaceObject.Fragment), |
| 91 |
Platform: () => (/* reexport */ platform), |
| 92 |
PureComponent: () => (/* reexport */ external_React_namespaceObject.PureComponent), |
| 93 |
RawHTML: () => (/* reexport */ RawHTML), |
| 94 |
StrictMode: () => (/* reexport */ external_React_namespaceObject.StrictMode), |
| 95 |
Suspense: () => (/* reexport */ external_React_namespaceObject.Suspense), |
| 96 |
cloneElement: () => (/* reexport */ external_React_namespaceObject.cloneElement), |
| 97 |
concatChildren: () => (/* reexport */ concatChildren), |
| 98 |
createContext: () => (/* reexport */ external_React_namespaceObject.createContext), |
| 99 |
createElement: () => (/* reexport */ external_React_namespaceObject.createElement), |
| 100 |
createInterpolateElement: () => (/* reexport */ create_interpolate_element), |
| 101 |
createPortal: () => (/* reexport */ external_ReactDOM_.createPortal), |
| 102 |
createRef: () => (/* reexport */ external_React_namespaceObject.createRef), |
| 103 |
createRoot: () => (/* reexport */ client/* createRoot */.H), |
| 104 |
findDOMNode: () => (/* reexport */ external_ReactDOM_.findDOMNode), |
| 105 |
flushSync: () => (/* reexport */ external_ReactDOM_.flushSync), |
| 106 |
forwardRef: () => (/* reexport */ external_React_namespaceObject.forwardRef), |
| 107 |
hydrate: () => (/* reexport */ external_ReactDOM_.hydrate), |
| 108 |
hydrateRoot: () => (/* reexport */ client/* hydrateRoot */.c), |
| 109 |
isEmptyElement: () => (/* reexport */ isEmptyElement), |
| 110 |
isValidElement: () => (/* reexport */ external_React_namespaceObject.isValidElement), |
| 111 |
lazy: () => (/* reexport */ external_React_namespaceObject.lazy), |
| 112 |
memo: () => (/* reexport */ external_React_namespaceObject.memo), |
| 113 |
render: () => (/* reexport */ external_ReactDOM_.render), |
| 114 |
renderToString: () => (/* reexport */ serialize), |
| 115 |
startTransition: () => (/* reexport */ external_React_namespaceObject.startTransition), |
| 116 |
switchChildrenNodeName: () => (/* reexport */ switchChildrenNodeName), |
| 117 |
unmountComponentAtNode: () => (/* reexport */ external_ReactDOM_.unmountComponentAtNode), |
| 118 |
useCallback: () => (/* reexport */ external_React_namespaceObject.useCallback), |
| 119 |
useContext: () => (/* reexport */ external_React_namespaceObject.useContext), |
| 120 |
useDebugValue: () => (/* reexport */ external_React_namespaceObject.useDebugValue), |
| 121 |
useDeferredValue: () => (/* reexport */ external_React_namespaceObject.useDeferredValue), |
| 122 |
useEffect: () => (/* reexport */ external_React_namespaceObject.useEffect), |
| 123 |
useId: () => (/* reexport */ external_React_namespaceObject.useId), |
| 124 |
useImperativeHandle: () => (/* reexport */ external_React_namespaceObject.useImperativeHandle), |
| 125 |
useInsertionEffect: () => (/* reexport */ external_React_namespaceObject.useInsertionEffect), |
| 126 |
useLayoutEffect: () => (/* reexport */ external_React_namespaceObject.useLayoutEffect), |
| 127 |
useMemo: () => (/* reexport */ external_React_namespaceObject.useMemo), |
| 128 |
useReducer: () => (/* reexport */ external_React_namespaceObject.useReducer), |
| 129 |
useRef: () => (/* reexport */ external_React_namespaceObject.useRef), |
| 130 |
useState: () => (/* reexport */ external_React_namespaceObject.useState), |
| 131 |
useSyncExternalStore: () => (/* reexport */ external_React_namespaceObject.useSyncExternalStore), |
| 132 |
useTransition: () => (/* reexport */ external_React_namespaceObject.useTransition) |
| 133 |
}); |
| 134 |
|
| 135 |
;// external "React" |
| 136 |
const external_React_namespaceObject = window["React"]; |
| 137 |
;// ./packages/element/build-module/create-interpolate-element.js |
| 138 |
/* wp:polyfill */ |
| 139 |
/** |
| 140 |
* Internal dependencies |
| 141 |
*/ |
| 142 |
|
| 143 |
|
| 144 |
/** |
| 145 |
* Object containing a React element. |
| 146 |
* |
| 147 |
* @typedef {import('react').ReactElement} Element |
| 148 |
*/ |
| 149 |
|
| 150 |
let indoc, offset, output, stack; |
| 151 |
|
| 152 |
/** |
| 153 |
* Matches tags in the localized string |
| 154 |
* |
| 155 |
* This is used for extracting the tag pattern groups for parsing the localized |
| 156 |
* string and along with the map converting it to a react element. |
| 157 |
* |
| 158 |
* There are four references extracted using this tokenizer: |
| 159 |
* |
| 160 |
* match: Full match of the tag (i.e. <strong>, </strong>, <br/>) |
| 161 |
* isClosing: The closing slash, if it exists. |
| 162 |
* name: The name portion of the tag (strong, br) (if ) |
| 163 |
* isSelfClosed: The slash on a self closing tag, if it exists. |
| 164 |
* |
| 165 |
* @type {RegExp} |
| 166 |
*/ |
| 167 |
const tokenizer = /<(\/)?(\w+)\s*(\/)?>/g; |
| 168 |
|
| 169 |
/** |
| 170 |
* The stack frame tracking parse progress. |
| 171 |
* |
| 172 |
* @typedef Frame |
| 173 |
* |
| 174 |
* @property {Element} element A parent element which may still have |
| 175 |
* @property {number} tokenStart Offset at which parent element first |
| 176 |
* appears. |
| 177 |
* @property {number} tokenLength Length of string marking start of parent |
| 178 |
* element. |
| 179 |
* @property {number} [prevOffset] Running offset at which parsing should |
| 180 |
* continue. |
| 181 |
* @property {number} [leadingTextStart] Offset at which last closing element |
| 182 |
* finished, used for finding text between |
| 183 |
* elements. |
| 184 |
* @property {Element[]} children Children. |
| 185 |
*/ |
| 186 |
|
| 187 |
/** |
| 188 |
* Tracks recursive-descent parse state. |
| 189 |
* |
| 190 |
* This is a Stack frame holding parent elements until all children have been |
| 191 |
* parsed. |
| 192 |
* |
| 193 |
* @private |
| 194 |
* @param {Element} element A parent element which may still have |
| 195 |
* nested children not yet parsed. |
| 196 |
* @param {number} tokenStart Offset at which parent element first |
| 197 |
* appears. |
| 198 |
* @param {number} tokenLength Length of string marking start of parent |
| 199 |
* element. |
| 200 |
* @param {number} [prevOffset] Running offset at which parsing should |
| 201 |
* continue. |
| 202 |
* @param {number} [leadingTextStart] Offset at which last closing element |
| 203 |
* finished, used for finding text between |
| 204 |
* elements. |
| 205 |
* |
| 206 |
* @return {Frame} The stack frame tracking parse progress. |
| 207 |
*/ |
| 208 |
function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) { |
| 209 |
return { |
| 210 |
element, |
| 211 |
tokenStart, |
| 212 |
tokenLength, |
| 213 |
prevOffset, |
| 214 |
leadingTextStart, |
| 215 |
children: [] |
| 216 |
}; |
| 217 |
} |
| 218 |
|
| 219 |
/** |
| 220 |
* This function creates an interpolated element from a passed in string with |
| 221 |
* specific tags matching how the string should be converted to an element via |
| 222 |
* the conversion map value. |
| 223 |
* |
| 224 |
* @example |
| 225 |
* For example, for the given string: |
| 226 |
* |
| 227 |
* "This is a <span>string</span> with <a>a link</a> and a self-closing |
| 228 |
* <CustomComponentB/> tag" |
| 229 |
* |
| 230 |
* You would have something like this as the conversionMap value: |
| 231 |
* |
| 232 |
* ```js |
| 233 |
* { |
| 234 |
* span: <span />, |
| 235 |
* a: <a href={ 'https://github.com' } />, |
| 236 |
* CustomComponentB: <CustomComponent />, |
| 237 |
* } |
| 238 |
* ``` |
| 239 |
* |
| 240 |
* @param {string} interpolatedString The interpolation string to be parsed. |
| 241 |
* @param {Record<string, Element>} conversionMap The map used to convert the string to |
| 242 |
* a react element. |
| 243 |
* @throws {TypeError} |
| 244 |
* @return {Element} A wp element. |
| 245 |
*/ |
| 246 |
const createInterpolateElement = (interpolatedString, conversionMap) => { |
| 247 |
indoc = interpolatedString; |
| 248 |
offset = 0; |
| 249 |
output = []; |
| 250 |
stack = []; |
| 251 |
tokenizer.lastIndex = 0; |
| 252 |
if (!isValidConversionMap(conversionMap)) { |
| 253 |
throw new TypeError('The conversionMap provided is not valid. It must be an object with values that are React Elements'); |
| 254 |
} |
| 255 |
do { |
| 256 |
// twiddle our thumbs |
| 257 |
} while (proceed(conversionMap)); |
| 258 |
return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, ...output); |
| 259 |
}; |
| 260 |
|
| 261 |
/** |
| 262 |
* Validate conversion map. |
| 263 |
* |
| 264 |
* A map is considered valid if it's an object and every value in the object |
| 265 |
* is a React Element |
| 266 |
* |
| 267 |
* @private |
| 268 |
* |
| 269 |
* @param {Object} conversionMap The map being validated. |
| 270 |
* |
| 271 |
* @return {boolean} True means the map is valid. |
| 272 |
*/ |
| 273 |
const isValidConversionMap = conversionMap => { |
| 274 |
const isObject = typeof conversionMap === 'object'; |
| 275 |
const values = isObject && Object.values(conversionMap); |
| 276 |
return isObject && values.length && values.every(element => (0,external_React_namespaceObject.isValidElement)(element)); |
| 277 |
}; |
| 278 |
|
| 279 |
/** |
| 280 |
* This is the iterator over the matches in the string. |
| 281 |
* |
| 282 |
* @private |
| 283 |
* |
| 284 |
* @param {Object} conversionMap The conversion map for the string. |
| 285 |
* |
| 286 |
* @return {boolean} true for continuing to iterate, false for finished. |
| 287 |
*/ |
| 288 |
function proceed(conversionMap) { |
| 289 |
const next = nextToken(); |
| 290 |
const [tokenType, name, startOffset, tokenLength] = next; |
| 291 |
const stackDepth = stack.length; |
| 292 |
const leadingTextStart = startOffset > offset ? offset : null; |
| 293 |
if (!conversionMap[name]) { |
| 294 |
addText(); |
| 295 |
return false; |
| 296 |
} |
| 297 |
switch (tokenType) { |
| 298 |
case 'no-more-tokens': |
| 299 |
if (stackDepth !== 0) { |
| 300 |
const { |
| 301 |
leadingTextStart: stackLeadingText, |
| 302 |
tokenStart |
| 303 |
} = stack.pop(); |
| 304 |
output.push(indoc.substr(stackLeadingText, tokenStart)); |
| 305 |
} |
| 306 |
addText(); |
| 307 |
return false; |
| 308 |
case 'self-closed': |
| 309 |
if (0 === stackDepth) { |
| 310 |
if (null !== leadingTextStart) { |
| 311 |
output.push(indoc.substr(leadingTextStart, startOffset - leadingTextStart)); |
| 312 |
} |
| 313 |
output.push(conversionMap[name]); |
| 314 |
offset = startOffset + tokenLength; |
| 315 |
return true; |
| 316 |
} |
| 317 |
|
| 318 |
// Otherwise we found an inner element. |
| 319 |
addChild(createFrame(conversionMap[name], startOffset, tokenLength)); |
| 320 |
offset = startOffset + tokenLength; |
| 321 |
return true; |
| 322 |
case 'opener': |
| 323 |
stack.push(createFrame(conversionMap[name], startOffset, tokenLength, startOffset + tokenLength, leadingTextStart)); |
| 324 |
offset = startOffset + tokenLength; |
| 325 |
return true; |
| 326 |
case 'closer': |
| 327 |
// If we're not nesting then this is easy - close the block. |
| 328 |
if (1 === stackDepth) { |
| 329 |
closeOuterElement(startOffset); |
| 330 |
offset = startOffset + tokenLength; |
| 331 |
return true; |
| 332 |
} |
| 333 |
|
| 334 |
// Otherwise we're nested and we have to close out the current |
| 335 |
// block and add it as a innerBlock to the parent. |
| 336 |
const stackTop = stack.pop(); |
| 337 |
const text = indoc.substr(stackTop.prevOffset, startOffset - stackTop.prevOffset); |
| 338 |
stackTop.children.push(text); |
| 339 |
stackTop.prevOffset = startOffset + tokenLength; |
| 340 |
const frame = createFrame(stackTop.element, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength); |
| 341 |
frame.children = stackTop.children; |
| 342 |
addChild(frame); |
| 343 |
offset = startOffset + tokenLength; |
| 344 |
return true; |
| 345 |
default: |
| 346 |
addText(); |
| 347 |
return false; |
| 348 |
} |
| 349 |
} |
| 350 |
|
| 351 |
/** |
| 352 |
* Grabs the next token match in the string and returns it's details. |
| 353 |
* |
| 354 |
* @private |
| 355 |
* |
| 356 |
* @return {Array} An array of details for the token matched. |
| 357 |
*/ |
| 358 |
function nextToken() { |
| 359 |
const matches = tokenizer.exec(indoc); |
| 360 |
// We have no more tokens. |
| 361 |
if (null === matches) { |
| 362 |
return ['no-more-tokens']; |
| 363 |
} |
| 364 |
const startedAt = matches.index; |
| 365 |
const [match, isClosing, name, isSelfClosed] = matches; |
| 366 |
const length = match.length; |
| 367 |
if (isSelfClosed) { |
| 368 |
return ['self-closed', name, startedAt, length]; |
| 369 |
} |
| 370 |
if (isClosing) { |
| 371 |
return ['closer', name, startedAt, length]; |
| 372 |
} |
| 373 |
return ['opener', name, startedAt, length]; |
| 374 |
} |
| 375 |
|
| 376 |
/** |
| 377 |
* Pushes text extracted from the indoc string to the output stack given the |
| 378 |
* current rawLength value and offset (if rawLength is provided ) or the |
| 379 |
* indoc.length and offset. |
| 380 |
* |
| 381 |
* @private |
| 382 |
*/ |
| 383 |
function addText() { |
| 384 |
const length = indoc.length - offset; |
| 385 |
if (0 === length) { |
| 386 |
return; |
| 387 |
} |
| 388 |
output.push(indoc.substr(offset, length)); |
| 389 |
} |
| 390 |
|
| 391 |
/** |
| 392 |
* Pushes a child element to the associated parent element's children for the |
| 393 |
* parent currently active in the stack. |
| 394 |
* |
| 395 |
* @private |
| 396 |
* |
| 397 |
* @param {Frame} frame The Frame containing the child element and it's |
| 398 |
* token information. |
| 399 |
*/ |
| 400 |
function addChild(frame) { |
| 401 |
const { |
| 402 |
element, |
| 403 |
tokenStart, |
| 404 |
tokenLength, |
| 405 |
prevOffset, |
| 406 |
children |
| 407 |
} = frame; |
| 408 |
const parent = stack[stack.length - 1]; |
| 409 |
const text = indoc.substr(parent.prevOffset, tokenStart - parent.prevOffset); |
| 410 |
if (text) { |
| 411 |
parent.children.push(text); |
| 412 |
} |
| 413 |
parent.children.push((0,external_React_namespaceObject.cloneElement)(element, null, ...children)); |
| 414 |
parent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength; |
| 415 |
} |
| 416 |
|
| 417 |
/** |
| 418 |
* This is called for closing tags. It creates the element currently active in |
| 419 |
* the stack. |
| 420 |
* |
| 421 |
* @private |
| 422 |
* |
| 423 |
* @param {number} endOffset Offset at which the closing tag for the element |
| 424 |
* begins in the string. If this is greater than the |
| 425 |
* prevOffset attached to the element, then this |
| 426 |
* helps capture any remaining nested text nodes in |
| 427 |
* the element. |
| 428 |
*/ |
| 429 |
function closeOuterElement(endOffset) { |
| 430 |
const { |
| 431 |
element, |
| 432 |
leadingTextStart, |
| 433 |
prevOffset, |
| 434 |
tokenStart, |
| 435 |
children |
| 436 |
} = stack.pop(); |
| 437 |
const text = endOffset ? indoc.substr(prevOffset, endOffset - prevOffset) : indoc.substr(prevOffset); |
| 438 |
if (text) { |
| 439 |
children.push(text); |
| 440 |
} |
| 441 |
if (null !== leadingTextStart) { |
| 442 |
output.push(indoc.substr(leadingTextStart, tokenStart - leadingTextStart)); |
| 443 |
} |
| 444 |
output.push((0,external_React_namespaceObject.cloneElement)(element, null, ...children)); |
| 445 |
} |
| 446 |
/* harmony default export */ const create_interpolate_element = (createInterpolateElement); |
| 447 |
|
| 448 |
;// ./packages/element/build-module/react.js |
| 449 |
/* wp:polyfill */ |
| 450 |
/** |
| 451 |
* External dependencies |
| 452 |
*/ |
| 453 |
// eslint-disable-next-line @typescript-eslint/no-restricted-imports |
| 454 |
|
| 455 |
|
| 456 |
/** |
| 457 |
* Object containing a React element. |
| 458 |
* |
| 459 |
* @typedef {import('react').ReactElement} Element |
| 460 |
*/ |
| 461 |
|
| 462 |
/** |
| 463 |
* Object containing a React component. |
| 464 |
* |
| 465 |
* @typedef {import('react').ComponentType} ComponentType |
| 466 |
*/ |
| 467 |
|
| 468 |
/** |
| 469 |
* Object containing a React synthetic event. |
| 470 |
* |
| 471 |
* @typedef {import('react').SyntheticEvent} SyntheticEvent |
| 472 |
*/ |
| 473 |
|
| 474 |
/** |
| 475 |
* Object containing a React ref object. |
| 476 |
* |
| 477 |
* @template T |
| 478 |
* @typedef {import('react').RefObject<T>} RefObject<T> |
| 479 |
*/ |
| 480 |
|
| 481 |
/** |
| 482 |
* Object containing a React ref callback. |
| 483 |
* |
| 484 |
* @template T |
| 485 |
* @typedef {import('react').RefCallback<T>} RefCallback<T> |
| 486 |
*/ |
| 487 |
|
| 488 |
/** |
| 489 |
* Object containing a React ref. |
| 490 |
* |
| 491 |
* @template T |
| 492 |
* @typedef {import('react').Ref<T>} Ref<T> |
| 493 |
*/ |
| 494 |
|
| 495 |
/** |
| 496 |
* Object that provides utilities for dealing with React children. |
| 497 |
*/ |
| 498 |
|
| 499 |
|
| 500 |
/** |
| 501 |
* Creates a copy of an element with extended props. |
| 502 |
* |
| 503 |
* @param {Element} element Element |
| 504 |
* @param {?Object} props Props to apply to cloned element |
| 505 |
* |
| 506 |
* @return {Element} Cloned element. |
| 507 |
*/ |
| 508 |
|
| 509 |
|
| 510 |
/** |
| 511 |
* A base class to create WordPress Components (Refs, state and lifecycle hooks) |
| 512 |
*/ |
| 513 |
|
| 514 |
|
| 515 |
/** |
| 516 |
* Creates a context object containing two components: a provider and consumer. |
| 517 |
* |
| 518 |
* @param {Object} defaultValue A default data stored in the context. |
| 519 |
* |
| 520 |
* @return {Object} Context object. |
| 521 |
*/ |
| 522 |
|
| 523 |
|
| 524 |
/** |
| 525 |
* Returns a new element of given type. Type can be either a string tag name or |
| 526 |
* another function which itself returns an element. |
| 527 |
* |
| 528 |
* @param {?(string|Function)} type Tag name or element creator |
| 529 |
* @param {Object} props Element properties, either attribute |
| 530 |
* set to apply to DOM node or values to |
| 531 |
* pass through to element creator |
| 532 |
* @param {...Element} children Descendant elements |
| 533 |
* |
| 534 |
* @return {Element} Element. |
| 535 |
*/ |
| 536 |
|
| 537 |
|
| 538 |
/** |
| 539 |
* Returns an object tracking a reference to a rendered element via its |
| 540 |
* `current` property as either a DOMElement or Element, dependent upon the |
| 541 |
* type of element rendered with the ref attribute. |
| 542 |
* |
| 543 |
* @return {Object} Ref object. |
| 544 |
*/ |
| 545 |
|
| 546 |
|
| 547 |
/** |
| 548 |
* Component enhancer used to enable passing a ref to its wrapped component. |
| 549 |
* Pass a function argument which receives `props` and `ref` as its arguments, |
| 550 |
* returning an element using the forwarded ref. The return value is a new |
| 551 |
* component which forwards its ref. |
| 552 |
* |
| 553 |
* @param {Function} forwarder Function passed `props` and `ref`, expected to |
| 554 |
* return an element. |
| 555 |
* |
| 556 |
* @return {Component} Enhanced component. |
| 557 |
*/ |
| 558 |
|
| 559 |
|
| 560 |
/** |
| 561 |
* A component which renders its children without any wrapping element. |
| 562 |
*/ |
| 563 |
|
| 564 |
|
| 565 |
/** |
| 566 |
* Checks if an object is a valid React Element. |
| 567 |
* |
| 568 |
* @param {Object} objectToCheck The object to be checked. |
| 569 |
* |
| 570 |
* @return {boolean} true if objectToTest is a valid React Element and false otherwise. |
| 571 |
*/ |
| 572 |
|
| 573 |
|
| 574 |
/** |
| 575 |
* @see https://react.dev/reference/react/memo |
| 576 |
*/ |
| 577 |
|
| 578 |
|
| 579 |
/** |
| 580 |
* Component that activates additional checks and warnings for its descendants. |
| 581 |
*/ |
| 582 |
|
| 583 |
|
| 584 |
/** |
| 585 |
* @see https://react.dev/reference/react/useCallback |
| 586 |
*/ |
| 587 |
|
| 588 |
|
| 589 |
/** |
| 590 |
* @see https://react.dev/reference/react/useContext |
| 591 |
*/ |
| 592 |
|
| 593 |
|
| 594 |
/** |
| 595 |
* @see https://react.dev/reference/react/useDebugValue |
| 596 |
*/ |
| 597 |
|
| 598 |
|
| 599 |
/** |
| 600 |
* @see https://react.dev/reference/react/useDeferredValue |
| 601 |
*/ |
| 602 |
|
| 603 |
|
| 604 |
/** |
| 605 |
* @see https://react.dev/reference/react/useEffect |
| 606 |
*/ |
| 607 |
|
| 608 |
|
| 609 |
/** |
| 610 |
* @see https://react.dev/reference/react/useId |
| 611 |
*/ |
| 612 |
|
| 613 |
|
| 614 |
/** |
| 615 |
* @see https://react.dev/reference/react/useImperativeHandle |
| 616 |
*/ |
| 617 |
|
| 618 |
|
| 619 |
/** |
| 620 |
* @see https://react.dev/reference/react/useInsertionEffect |
| 621 |
*/ |
| 622 |
|
| 623 |
|
| 624 |
/** |
| 625 |
* @see https://react.dev/reference/react/useLayoutEffect |
| 626 |
*/ |
| 627 |
|
| 628 |
|
| 629 |
/** |
| 630 |
* @see https://react.dev/reference/react/useMemo |
| 631 |
*/ |
| 632 |
|
| 633 |
|
| 634 |
/** |
| 635 |
* @see https://react.dev/reference/react/useReducer |
| 636 |
*/ |
| 637 |
|
| 638 |
|
| 639 |
/** |
| 640 |
* @see https://react.dev/reference/react/useRef |
| 641 |
*/ |
| 642 |
|
| 643 |
|
| 644 |
/** |
| 645 |
* @see https://react.dev/reference/react/useState |
| 646 |
*/ |
| 647 |
|
| 648 |
|
| 649 |
/** |
| 650 |
* @see https://react.dev/reference/react/useSyncExternalStore |
| 651 |
*/ |
| 652 |
|
| 653 |
|
| 654 |
/** |
| 655 |
* @see https://react.dev/reference/react/useTransition |
| 656 |
*/ |
| 657 |
|
| 658 |
|
| 659 |
/** |
| 660 |
* @see https://react.dev/reference/react/startTransition |
| 661 |
*/ |
| 662 |
|
| 663 |
|
| 664 |
/** |
| 665 |
* @see https://react.dev/reference/react/lazy |
| 666 |
*/ |
| 667 |
|
| 668 |
|
| 669 |
/** |
| 670 |
* @see https://react.dev/reference/react/Suspense |
| 671 |
*/ |
| 672 |
|
| 673 |
|
| 674 |
/** |
| 675 |
* @see https://react.dev/reference/react/PureComponent |
| 676 |
*/ |
| 677 |
|
| 678 |
|
| 679 |
/** |
| 680 |
* Concatenate two or more React children objects. |
| 681 |
* |
| 682 |
* @param {...?Object} childrenArguments Array of children arguments (array of arrays/strings/objects) to concatenate. |
| 683 |
* |
| 684 |
* @return {Array} The concatenated value. |
| 685 |
*/ |
| 686 |
function concatChildren(...childrenArguments) { |
| 687 |
return childrenArguments.reduce((accumulator, children, i) => { |
| 688 |
external_React_namespaceObject.Children.forEach(children, (child, j) => { |
| 689 |
if (child && 'string' !== typeof child) { |
| 690 |
child = (0,external_React_namespaceObject.cloneElement)(child, { |
| 691 |
key: [i, j].join() |
| 692 |
}); |
| 693 |
} |
| 694 |
accumulator.push(child); |
| 695 |
}); |
| 696 |
return accumulator; |
| 697 |
}, []); |
| 698 |
} |
| 699 |
|
| 700 |
/** |
| 701 |
* Switches the nodeName of all the elements in the children object. |
| 702 |
* |
| 703 |
* @param {?Object} children Children object. |
| 704 |
* @param {string} nodeName Node name. |
| 705 |
* |
| 706 |
* @return {?Object} The updated children object. |
| 707 |
*/ |
| 708 |
function switchChildrenNodeName(children, nodeName) { |
| 709 |
return children && external_React_namespaceObject.Children.map(children, (elt, index) => { |
| 710 |
if (typeof elt?.valueOf() === 'string') { |
| 711 |
return (0,external_React_namespaceObject.createElement)(nodeName, { |
| 712 |
key: index |
| 713 |
}, elt); |
| 714 |
} |
| 715 |
const { |
| 716 |
children: childrenProp, |
| 717 |
...props |
| 718 |
} = elt.props; |
| 719 |
return (0,external_React_namespaceObject.createElement)(nodeName, { |
| 720 |
key: index, |
| 721 |
...props |
| 722 |
}, childrenProp); |
| 723 |
}); |
| 724 |
} |
| 725 |
|
| 726 |
// EXTERNAL MODULE: external "ReactDOM" |
| 727 |
var external_ReactDOM_ = __webpack_require__(5795); |
| 728 |
// EXTERNAL MODULE: ./node_modules/react-dom/client.js |
| 729 |
var client = __webpack_require__(4140); |
| 730 |
;// ./packages/element/build-module/react-platform.js |
| 731 |
/** |
| 732 |
* External dependencies |
| 733 |
*/ |
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
/** |
| 738 |
* Creates a portal into which a component can be rendered. |
| 739 |
* |
| 740 |
* @see https://github.com/facebook/react/issues/10309#issuecomment-318433235 |
| 741 |
* |
| 742 |
* @param {import('react').ReactElement} child Any renderable child, such as an element, |
| 743 |
* string, or fragment. |
| 744 |
* @param {HTMLElement} container DOM node into which element should be rendered. |
| 745 |
*/ |
| 746 |
|
| 747 |
|
| 748 |
/** |
| 749 |
* Finds the dom node of a React component. |
| 750 |
* |
| 751 |
* @param {import('react').ComponentType} component Component's instance. |
| 752 |
*/ |
| 753 |
|
| 754 |
|
| 755 |
/** |
| 756 |
* Forces React to flush any updates inside the provided callback synchronously. |
| 757 |
* |
| 758 |
* @param {Function} callback Callback to run synchronously. |
| 759 |
*/ |
| 760 |
|
| 761 |
|
| 762 |
/** |
| 763 |
* Renders a given element into the target DOM node. |
| 764 |
* |
| 765 |
* @deprecated since WordPress 6.2.0. Use `createRoot` instead. |
| 766 |
* @see https://react.dev/reference/react-dom/render |
| 767 |
*/ |
| 768 |
|
| 769 |
|
| 770 |
/** |
| 771 |
* Hydrates a given element into the target DOM node. |
| 772 |
* |
| 773 |
* @deprecated since WordPress 6.2.0. Use `hydrateRoot` instead. |
| 774 |
* @see https://react.dev/reference/react-dom/hydrate |
| 775 |
*/ |
| 776 |
|
| 777 |
|
| 778 |
/** |
| 779 |
* Creates a new React root for the target DOM node. |
| 780 |
* |
| 781 |
* @since 6.2.0 Introduced in WordPress core. |
| 782 |
* @see https://react.dev/reference/react-dom/client/createRoot |
| 783 |
*/ |
| 784 |
|
| 785 |
|
| 786 |
/** |
| 787 |
* Creates a new React root for the target DOM node and hydrates it with a pre-generated markup. |
| 788 |
* |
| 789 |
* @since 6.2.0 Introduced in WordPress core. |
| 790 |
* @see https://react.dev/reference/react-dom/client/hydrateRoot |
| 791 |
*/ |
| 792 |
|
| 793 |
|
| 794 |
/** |
| 795 |
* Removes any mounted element from the target DOM node. |
| 796 |
* |
| 797 |
* @deprecated since WordPress 6.2.0. Use `root.unmount()` instead. |
| 798 |
* @see https://react.dev/reference/react-dom/unmountComponentAtNode |
| 799 |
*/ |
| 800 |
|
| 801 |
|
| 802 |
;// ./packages/element/build-module/utils.js |
| 803 |
/** |
| 804 |
* Checks if the provided WP element is empty. |
| 805 |
* |
| 806 |
* @param {*} element WP element to check. |
| 807 |
* @return {boolean} True when an element is considered empty. |
| 808 |
*/ |
| 809 |
const isEmptyElement = element => { |
| 810 |
if (typeof element === 'number') { |
| 811 |
return false; |
| 812 |
} |
| 813 |
if (typeof element?.valueOf() === 'string' || Array.isArray(element)) { |
| 814 |
return !element.length; |
| 815 |
} |
| 816 |
return !element; |
| 817 |
}; |
| 818 |
|
| 819 |
;// ./packages/element/build-module/platform.js |
| 820 |
/** |
| 821 |
* Parts of this source were derived and modified from react-native-web, |
| 822 |
* released under the MIT license. |
| 823 |
* |
| 824 |
* Copyright (c) 2016-present, Nicolas Gallagher. |
| 825 |
* Copyright (c) 2015-present, Facebook, Inc. |
| 826 |
* |
| 827 |
*/ |
| 828 |
const Platform = { |
| 829 |
OS: 'web', |
| 830 |
select: spec => 'web' in spec ? spec.web : spec.default, |
| 831 |
isWeb: true |
| 832 |
}; |
| 833 |
/** |
| 834 |
* Component used to detect the current Platform being used. |
| 835 |
* Use Platform.OS === 'web' to detect if running on web enviroment. |
| 836 |
* |
| 837 |
* This is the same concept as the React Native implementation. |
| 838 |
* |
| 839 |
* @see https://reactnative.dev/docs/platform-specific-code#platform-module |
| 840 |
* |
| 841 |
* Here is an example of how to use the select method: |
| 842 |
* @example |
| 843 |
* ```js |
| 844 |
* import { Platform } from '@wordpress/element'; |
| 845 |
* |
| 846 |
* const placeholderLabel = Platform.select( { |
| 847 |
* native: __( 'Add media' ), |
| 848 |
* web: __( 'Drag images, upload new ones or select files from your library.' ), |
| 849 |
* } ); |
| 850 |
* ``` |
| 851 |
*/ |
| 852 |
/* harmony default export */ const platform = (Platform); |
| 853 |
|
| 854 |
;// ./node_modules/is-plain-object/dist/is-plain-object.mjs |
| 855 |
/*! |
| 856 |
* is-plain-object <https://github.com/jonschlinkert/is-plain-object> |
| 857 |
* |
| 858 |
* Copyright (c) 2014-2017, Jon Schlinkert. |
| 859 |
* Released under the MIT License. |
| 860 |
*/ |
| 861 |
|
| 862 |
function isObject(o) { |
| 863 |
return Object.prototype.toString.call(o) === '[object Object]'; |
| 864 |
} |
| 865 |
|
| 866 |
function isPlainObject(o) { |
| 867 |
var ctor,prot; |
| 868 |
|
| 869 |
if (isObject(o) === false) return false; |
| 870 |
|
| 871 |
// If has modified constructor |
| 872 |
ctor = o.constructor; |
| 873 |
if (ctor === undefined) return true; |
| 874 |
|
| 875 |
// If has modified prototype |
| 876 |
prot = ctor.prototype; |
| 877 |
if (isObject(prot) === false) return false; |
| 878 |
|
| 879 |
// If constructor does not have an Object-specific method |
| 880 |
if (prot.hasOwnProperty('isPrototypeOf') === false) { |
| 881 |
return false; |
| 882 |
} |
| 883 |
|
| 884 |
// Most likely a plain Object |
| 885 |
return true; |
| 886 |
} |
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
;// ./node_modules/tslib/tslib.es6.mjs |
| 891 |
/****************************************************************************** |
| 892 |
Copyright (c) Microsoft Corporation. |
| 893 |
|
| 894 |
Permission to use, copy, modify, and/or distribute this software for any |
| 895 |
purpose with or without fee is hereby granted. |
| 896 |
|
| 897 |
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
| 898 |
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 899 |
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
| 900 |
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
| 901 |
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
| 902 |
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 903 |
PERFORMANCE OF THIS SOFTWARE. |
| 904 |
***************************************************************************** */ |
| 905 |
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */ |
| 906 |
|
| 907 |
var extendStatics = function(d, b) { |
| 908 |
extendStatics = Object.setPrototypeOf || |
| 909 |
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
| 910 |
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
| 911 |
return extendStatics(d, b); |
| 912 |
}; |
| 913 |
|
| 914 |
function __extends(d, b) { |
| 915 |
if (typeof b !== "function" && b !== null) |
| 916 |
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); |
| 917 |
extendStatics(d, b); |
| 918 |
function __() { this.constructor = d; } |
| 919 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| 920 |
} |
| 921 |
|
| 922 |
var __assign = function() { |
| 923 |
__assign = Object.assign || function __assign(t) { |
| 924 |
for (var s, i = 1, n = arguments.length; i < n; i++) { |
| 925 |
s = arguments[i]; |
| 926 |
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; |
| 927 |
} |
| 928 |
return t; |
| 929 |
} |
| 930 |
return __assign.apply(this, arguments); |
| 931 |
} |
| 932 |
|
| 933 |
function __rest(s, e) { |
| 934 |
var t = {}; |
| 935 |
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) |
| 936 |
t[p] = s[p]; |
| 937 |
if (s != null && typeof Object.getOwnPropertySymbols === "function") |
| 938 |
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { |
| 939 |
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) |
| 940 |
t[p[i]] = s[p[i]]; |
| 941 |
} |
| 942 |
return t; |
| 943 |
} |
| 944 |
|
| 945 |
function __decorate(decorators, target, key, desc) { |
| 946 |
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; |
| 947 |
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); |
| 948 |
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; |
| 949 |
return c > 3 && r && Object.defineProperty(target, key, r), r; |
| 950 |
} |
| 951 |
|
| 952 |
function __param(paramIndex, decorator) { |
| 953 |
return function (target, key) { decorator(target, key, paramIndex); } |
| 954 |
} |
| 955 |
|
| 956 |
function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { |
| 957 |
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } |
| 958 |
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; |
| 959 |
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; |
| 960 |
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); |
| 961 |
var _, done = false; |
| 962 |
for (var i = decorators.length - 1; i >= 0; i--) { |
| 963 |
var context = {}; |
| 964 |
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; |
| 965 |
for (var p in contextIn.access) context.access[p] = contextIn.access[p]; |
| 966 |
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; |
| 967 |
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); |
| 968 |
if (kind === "accessor") { |
| 969 |
if (result === void 0) continue; |
| 970 |
if (result === null || typeof result !== "object") throw new TypeError("Object expected"); |
| 971 |
if (_ = accept(result.get)) descriptor.get = _; |
| 972 |
if (_ = accept(result.set)) descriptor.set = _; |
| 973 |
if (_ = accept(result.init)) initializers.unshift(_); |
| 974 |
} |
| 975 |
else if (_ = accept(result)) { |
| 976 |
if (kind === "field") initializers.unshift(_); |
| 977 |
else descriptor[key] = _; |
| 978 |
} |
| 979 |
} |
| 980 |
if (target) Object.defineProperty(target, contextIn.name, descriptor); |
| 981 |
done = true; |
| 982 |
}; |
| 983 |
|
| 984 |
function __runInitializers(thisArg, initializers, value) { |
| 985 |
var useValue = arguments.length > 2; |
| 986 |
for (var i = 0; i < initializers.length; i++) { |
| 987 |
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); |
| 988 |
} |
| 989 |
return useValue ? value : void 0; |
| 990 |
}; |
| 991 |
|
| 992 |
function __propKey(x) { |
| 993 |
return typeof x === "symbol" ? x : "".concat(x); |
| 994 |
}; |
| 995 |
|
| 996 |
function __setFunctionName(f, name, prefix) { |
| 997 |
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; |
| 998 |
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); |
| 999 |
}; |
| 1000 |
|
| 1001 |
function __metadata(metadataKey, metadataValue) { |
| 1002 |
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); |
| 1003 |
} |
| 1004 |
|
| 1005 |
function __awaiter(thisArg, _arguments, P, generator) { |
| 1006 |
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
| 1007 |
return new (P || (P = Promise))(function (resolve, reject) { |
| 1008 |
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
| 1009 |
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
| 1010 |
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
| 1011 |
step((generator = generator.apply(thisArg, _arguments || [])).next()); |
| 1012 |
}); |
| 1013 |
} |
| 1014 |
|
| 1015 |
function __generator(thisArg, body) { |
| 1016 |
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); |
| 1017 |
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; |
| 1018 |
function verb(n) { return function (v) { return step([n, v]); }; } |
| 1019 |
function step(op) { |
| 1020 |
if (f) throw new TypeError("Generator is already executing."); |
| 1021 |
while (g && (g = 0, op[0] && (_ = 0)), _) try { |
| 1022 |
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; |
| 1023 |
if (y = 0, t) op = [op[0] & 2, t.value]; |
| 1024 |
switch (op[0]) { |
| 1025 |
case 0: case 1: t = op; break; |
| 1026 |
case 4: _.label++; return { value: op[1], done: false }; |
| 1027 |
case 5: _.label++; y = op[1]; op = [0]; continue; |
| 1028 |
case 7: op = _.ops.pop(); _.trys.pop(); continue; |
| 1029 |
default: |
| 1030 |
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } |
| 1031 |
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } |
| 1032 |
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } |
| 1033 |
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } |
| 1034 |
if (t[2]) _.ops.pop(); |
| 1035 |
_.trys.pop(); continue; |
| 1036 |
} |
| 1037 |
op = body.call(thisArg, _); |
| 1038 |
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } |
| 1039 |
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; |
| 1040 |
} |
| 1041 |
} |
| 1042 |
|
| 1043 |
var __createBinding = Object.create ? (function(o, m, k, k2) { |
| 1044 |
if (k2 === undefined) k2 = k; |
| 1045 |
var desc = Object.getOwnPropertyDescriptor(m, k); |
| 1046 |
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { |
| 1047 |
desc = { enumerable: true, get: function() { return m[k]; } }; |
| 1048 |
} |
| 1049 |
Object.defineProperty(o, k2, desc); |
| 1050 |
}) : (function(o, m, k, k2) { |
| 1051 |
if (k2 === undefined) k2 = k; |
| 1052 |
o[k2] = m[k]; |
| 1053 |
}); |
| 1054 |
|
| 1055 |
function __exportStar(m, o) { |
| 1056 |
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); |
| 1057 |
} |
| 1058 |
|
| 1059 |
function __values(o) { |
| 1060 |
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; |
| 1061 |
if (m) return m.call(o); |
| 1062 |
if (o && typeof o.length === "number") return { |
| 1063 |
next: function () { |
| 1064 |
if (o && i >= o.length) o = void 0; |
| 1065 |
return { value: o && o[i++], done: !o }; |
| 1066 |
} |
| 1067 |
}; |
| 1068 |
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); |
| 1069 |
} |
| 1070 |
|
| 1071 |
function __read(o, n) { |
| 1072 |
var m = typeof Symbol === "function" && o[Symbol.iterator]; |
| 1073 |
if (!m) return o; |
| 1074 |
var i = m.call(o), r, ar = [], e; |
| 1075 |
try { |
| 1076 |
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); |
| 1077 |
} |
| 1078 |
catch (error) { e = { error: error }; } |
| 1079 |
finally { |
| 1080 |
try { |
| 1081 |
if (r && !r.done && (m = i["return"])) m.call(i); |
| 1082 |
} |
| 1083 |
finally { if (e) throw e.error; } |
| 1084 |
} |
| 1085 |
return ar; |
| 1086 |
} |
| 1087 |
|
| 1088 |
/** @deprecated */ |
| 1089 |
function __spread() { |
| 1090 |
for (var ar = [], i = 0; i < arguments.length; i++) |
| 1091 |
ar = ar.concat(__read(arguments[i])); |
| 1092 |
return ar; |
| 1093 |
} |
| 1094 |
|
| 1095 |
/** @deprecated */ |
| 1096 |
function __spreadArrays() { |
| 1097 |
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; |
| 1098 |
for (var r = Array(s), k = 0, i = 0; i < il; i++) |
| 1099 |
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) |
| 1100 |
r[k] = a[j]; |
| 1101 |
return r; |
| 1102 |
} |
| 1103 |
|
| 1104 |
function __spreadArray(to, from, pack) { |
| 1105 |
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { |
| 1106 |
if (ar || !(i in from)) { |
| 1107 |
if (!ar) ar = Array.prototype.slice.call(from, 0, i); |
| 1108 |
ar[i] = from[i]; |
| 1109 |
} |
| 1110 |
} |
| 1111 |
return to.concat(ar || Array.prototype.slice.call(from)); |
| 1112 |
} |
| 1113 |
|
| 1114 |
function __await(v) { |
| 1115 |
return this instanceof __await ? (this.v = v, this) : new __await(v); |
| 1116 |
} |
| 1117 |
|
| 1118 |
function __asyncGenerator(thisArg, _arguments, generator) { |
| 1119 |
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
| 1120 |
var g = generator.apply(thisArg, _arguments || []), i, q = []; |
| 1121 |
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i; |
| 1122 |
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; } |
| 1123 |
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } } |
| 1124 |
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } |
| 1125 |
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } |
| 1126 |
function fulfill(value) { resume("next", value); } |
| 1127 |
function reject(value) { resume("throw", value); } |
| 1128 |
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } |
| 1129 |
} |
| 1130 |
|
| 1131 |
function __asyncDelegator(o) { |
| 1132 |
var i, p; |
| 1133 |
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; |
| 1134 |
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } |
| 1135 |
} |
| 1136 |
|
| 1137 |
function __asyncValues(o) { |
| 1138 |
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
| 1139 |
var m = o[Symbol.asyncIterator], i; |
| 1140 |
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); |
| 1141 |
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } |
| 1142 |
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } |
| 1143 |
} |
| 1144 |
|
| 1145 |
function __makeTemplateObject(cooked, raw) { |
| 1146 |
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } |
| 1147 |
return cooked; |
| 1148 |
}; |
| 1149 |
|
| 1150 |
var __setModuleDefault = Object.create ? (function(o, v) { |
| 1151 |
Object.defineProperty(o, "default", { enumerable: true, value: v }); |
| 1152 |
}) : function(o, v) { |
| 1153 |
o["default"] = v; |
| 1154 |
}; |
| 1155 |
|
| 1156 |
function __importStar(mod) { |
| 1157 |
if (mod && mod.__esModule) return mod; |
| 1158 |
var result = {}; |
| 1159 |
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); |
| 1160 |
__setModuleDefault(result, mod); |
| 1161 |
return result; |
| 1162 |
} |
| 1163 |
|
| 1164 |
function __importDefault(mod) { |
| 1165 |
return (mod && mod.__esModule) ? mod : { default: mod }; |
| 1166 |
} |
| 1167 |
|
| 1168 |
function __classPrivateFieldGet(receiver, state, kind, f) { |
| 1169 |
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); |
| 1170 |
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); |
| 1171 |
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); |
| 1172 |
} |
| 1173 |
|
| 1174 |
function __classPrivateFieldSet(receiver, state, value, kind, f) { |
| 1175 |
if (kind === "m") throw new TypeError("Private method is not writable"); |
| 1176 |
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); |
| 1177 |
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); |
| 1178 |
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; |
| 1179 |
} |
| 1180 |
|
| 1181 |
function __classPrivateFieldIn(state, receiver) { |
| 1182 |
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); |
| 1183 |
return typeof state === "function" ? receiver === state : state.has(receiver); |
| 1184 |
} |
| 1185 |
|
| 1186 |
function __addDisposableResource(env, value, async) { |
| 1187 |
if (value !== null && value !== void 0) { |
| 1188 |
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); |
| 1189 |
var dispose, inner; |
| 1190 |
if (async) { |
| 1191 |
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); |
| 1192 |
dispose = value[Symbol.asyncDispose]; |
| 1193 |
} |
| 1194 |
if (dispose === void 0) { |
| 1195 |
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); |
| 1196 |
dispose = value[Symbol.dispose]; |
| 1197 |
if (async) inner = dispose; |
| 1198 |
} |
| 1199 |
if (typeof dispose !== "function") throw new TypeError("Object not disposable."); |
| 1200 |
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } }; |
| 1201 |
env.stack.push({ value: value, dispose: dispose, async: async }); |
| 1202 |
} |
| 1203 |
else if (async) { |
| 1204 |
env.stack.push({ async: true }); |
| 1205 |
} |
| 1206 |
return value; |
| 1207 |
} |
| 1208 |
|
| 1209 |
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { |
| 1210 |
var e = new Error(message); |
| 1211 |
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; |
| 1212 |
}; |
| 1213 |
|
| 1214 |
function __disposeResources(env) { |
| 1215 |
function fail(e) { |
| 1216 |
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; |
| 1217 |
env.hasError = true; |
| 1218 |
} |
| 1219 |
var r, s = 0; |
| 1220 |
function next() { |
| 1221 |
while (r = env.stack.pop()) { |
| 1222 |
try { |
| 1223 |
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next); |
| 1224 |
if (r.dispose) { |
| 1225 |
var result = r.dispose.call(r.value); |
| 1226 |
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); |
| 1227 |
} |
| 1228 |
else s |= 1; |
| 1229 |
} |
| 1230 |
catch (e) { |
| 1231 |
fail(e); |
| 1232 |
} |
| 1233 |
} |
| 1234 |
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve(); |
| 1235 |
if (env.hasError) throw env.error; |
| 1236 |
} |
| 1237 |
return next(); |
| 1238 |
} |
| 1239 |
|
| 1240 |
function __rewriteRelativeImportExtension(path, preserveJsx) { |
| 1241 |
if (typeof path === "string" && /^\.\.?\//.test(path)) { |
| 1242 |
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) { |
| 1243 |
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js"); |
| 1244 |
}); |
| 1245 |
} |
| 1246 |
return path; |
| 1247 |
} |
| 1248 |
|
| 1249 |
/* harmony default export */ const tslib_es6 = ({ |
| 1250 |
__extends, |
| 1251 |
__assign, |
| 1252 |
__rest, |
| 1253 |
__decorate, |
| 1254 |
__param, |
| 1255 |
__esDecorate, |
| 1256 |
__runInitializers, |
| 1257 |
__propKey, |
| 1258 |
__setFunctionName, |
| 1259 |
__metadata, |
| 1260 |
__awaiter, |
| 1261 |
__generator, |
| 1262 |
__createBinding, |
| 1263 |
__exportStar, |
| 1264 |
__values, |
| 1265 |
__read, |
| 1266 |
__spread, |
| 1267 |
__spreadArrays, |
| 1268 |
__spreadArray, |
| 1269 |
__await, |
| 1270 |
__asyncGenerator, |
| 1271 |
__asyncDelegator, |
| 1272 |
__asyncValues, |
| 1273 |
__makeTemplateObject, |
| 1274 |
__importStar, |
| 1275 |
__importDefault, |
| 1276 |
__classPrivateFieldGet, |
| 1277 |
__classPrivateFieldSet, |
| 1278 |
__classPrivateFieldIn, |
| 1279 |
__addDisposableResource, |
| 1280 |
__disposeResources, |
| 1281 |
__rewriteRelativeImportExtension, |
| 1282 |
}); |
| 1283 |
|
| 1284 |
;// ./node_modules/lower-case/dist.es2015/index.js |
| 1285 |
/** |
| 1286 |
* Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt |
| 1287 |
*/ |
| 1288 |
var SUPPORTED_LOCALE = { |
| 1289 |
tr: { |
| 1290 |
regexp: /\u0130|\u0049|\u0049\u0307/g, |
| 1291 |
map: { |
| 1292 |
İ: "\u0069", |
| 1293 |
I: "\u0131", |
| 1294 |
İ: "\u0069", |
| 1295 |
}, |
| 1296 |
}, |
| 1297 |
az: { |
| 1298 |
regexp: /\u0130/g, |
| 1299 |
map: { |
| 1300 |
İ: "\u0069", |
| 1301 |
I: "\u0131", |
| 1302 |
İ: "\u0069", |
| 1303 |
}, |
| 1304 |
}, |
| 1305 |
lt: { |
| 1306 |
regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g, |
| 1307 |
map: { |
| 1308 |
I: "\u0069\u0307", |
| 1309 |
J: "\u006A\u0307", |
| 1310 |
Į: "\u012F\u0307", |
| 1311 |
Ì: "\u0069\u0307\u0300", |
| 1312 |
Í: "\u0069\u0307\u0301", |
| 1313 |
Ĩ: "\u0069\u0307\u0303", |
| 1314 |
}, |
| 1315 |
}, |
| 1316 |
}; |
| 1317 |
/** |
| 1318 |
* Localized lower case. |
| 1319 |
*/ |
| 1320 |
function localeLowerCase(str, locale) { |
| 1321 |
var lang = SUPPORTED_LOCALE[locale.toLowerCase()]; |
| 1322 |
if (lang) |
| 1323 |
return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; })); |
| 1324 |
return lowerCase(str); |
| 1325 |
} |
| 1326 |
/** |
| 1327 |
* Lower case as a function. |
| 1328 |
*/ |
| 1329 |
function lowerCase(str) { |
| 1330 |
return str.toLowerCase(); |
| 1331 |
} |
| 1332 |
|
| 1333 |
;// ./node_modules/no-case/dist.es2015/index.js |
| 1334 |
|
| 1335 |
// Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case"). |
| 1336 |
var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; |
| 1337 |
// Remove all non-word characters. |
| 1338 |
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; |
| 1339 |
/** |
| 1340 |
* Normalize the string into something other libraries can manipulate easier. |
| 1341 |
*/ |
| 1342 |
function noCase(input, options) { |
| 1343 |
if (options === void 0) { options = {}; } |
| 1344 |
var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d; |
| 1345 |
var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); |
| 1346 |
var start = 0; |
| 1347 |
var end = result.length; |
| 1348 |
// Trim the delimiter from around the output string. |
| 1349 |
while (result.charAt(start) === "\0") |
| 1350 |
start++; |
| 1351 |
while (result.charAt(end - 1) === "\0") |
| 1352 |
end--; |
| 1353 |
// Transform each token independently. |
| 1354 |
return result.slice(start, end).split("\0").map(transform).join(delimiter); |
| 1355 |
} |
| 1356 |
/** |
| 1357 |
* Replace `re` in the input string with the replacement value. |
| 1358 |
*/ |
| 1359 |
function replace(input, re, value) { |
| 1360 |
if (re instanceof RegExp) |
| 1361 |
return input.replace(re, value); |
| 1362 |
return re.reduce(function (input, re) { return input.replace(re, value); }, input); |
| 1363 |
} |
| 1364 |
|
| 1365 |
;// ./node_modules/dot-case/dist.es2015/index.js |
| 1366 |
|
| 1367 |
|
| 1368 |
function dotCase(input, options) { |
| 1369 |
if (options === void 0) { options = {}; } |
| 1370 |
return noCase(input, __assign({ delimiter: "." }, options)); |
| 1371 |
} |
| 1372 |
|
| 1373 |
;// ./node_modules/param-case/dist.es2015/index.js |
| 1374 |
|
| 1375 |
|
| 1376 |
function paramCase(input, options) { |
| 1377 |
if (options === void 0) { options = {}; } |
| 1378 |
return dotCase(input, __assign({ delimiter: "-" }, options)); |
| 1379 |
} |
| 1380 |
|
| 1381 |
;// external ["wp","escapeHtml"] |
| 1382 |
const external_wp_escapeHtml_namespaceObject = window["wp"]["escapeHtml"]; |
| 1383 |
;// ./packages/element/build-module/raw-html.js |
| 1384 |
/* wp:polyfill */ |
| 1385 |
/** |
| 1386 |
* Internal dependencies |
| 1387 |
*/ |
| 1388 |
|
| 1389 |
|
| 1390 |
/** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */ |
| 1391 |
|
| 1392 |
/** |
| 1393 |
* Component used as equivalent of Fragment with unescaped HTML, in cases where |
| 1394 |
* it is desirable to render dangerous HTML without needing a wrapper element. |
| 1395 |
* To preserve additional props, a `div` wrapper _will_ be created if any props |
| 1396 |
* aside from `children` are passed. |
| 1397 |
* |
| 1398 |
* @param {RawHTMLProps} props Children should be a string of HTML or an array |
| 1399 |
* of strings. Other props will be passed through |
| 1400 |
* to the div wrapper. |
| 1401 |
* |
| 1402 |
* @return {JSX.Element} Dangerously-rendering component. |
| 1403 |
*/ |
| 1404 |
function RawHTML({ |
| 1405 |
children, |
| 1406 |
...props |
| 1407 |
}) { |
| 1408 |
let rawHtml = ''; |
| 1409 |
|
| 1410 |
// Cast children as an array, and concatenate each element if it is a string. |
| 1411 |
external_React_namespaceObject.Children.toArray(children).forEach(child => { |
| 1412 |
if (typeof child === 'string' && child.trim() !== '') { |
| 1413 |
rawHtml += child; |
| 1414 |
} |
| 1415 |
}); |
| 1416 |
|
| 1417 |
// The `div` wrapper will be stripped by the `renderElement` serializer in |
| 1418 |
// `./serialize.js` unless there are non-children props present. |
| 1419 |
return (0,external_React_namespaceObject.createElement)('div', { |
| 1420 |
dangerouslySetInnerHTML: { |
| 1421 |
__html: rawHtml |
| 1422 |
}, |
| 1423 |
...props |
| 1424 |
}); |
| 1425 |
} |
| 1426 |
|
| 1427 |
;// ./packages/element/build-module/serialize.js |
| 1428 |
/* wp:polyfill */ |
| 1429 |
/** |
| 1430 |
* Parts of this source were derived and modified from fast-react-render, |
| 1431 |
* released under the MIT license. |
| 1432 |
* |
| 1433 |
* https://github.com/alt-j/fast-react-render |
| 1434 |
* |
| 1435 |
* Copyright (c) 2016 Andrey Morozov |
| 1436 |
* |
| 1437 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
| 1438 |
* of this software and associated documentation files (the "Software"), to deal |
| 1439 |
* in the Software without restriction, including without limitation the rights |
| 1440 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 1441 |
* copies of the Software, and to permit persons to whom the Software is |
| 1442 |
* furnished to do so, subject to the following conditions: |
| 1443 |
* |
| 1444 |
* The above copyright notice and this permission notice shall be included in |
| 1445 |
* all copies or substantial portions of the Software. |
| 1446 |
* |
| 1447 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 1448 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 1449 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 1450 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 1451 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 1452 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 1453 |
* THE SOFTWARE. |
| 1454 |
*/ |
| 1455 |
|
| 1456 |
/** |
| 1457 |
* External dependencies |
| 1458 |
*/ |
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
/** |
| 1463 |
* WordPress dependencies |
| 1464 |
*/ |
| 1465 |
|
| 1466 |
|
| 1467 |
/** |
| 1468 |
* Internal dependencies |
| 1469 |
*/ |
| 1470 |
|
| 1471 |
|
| 1472 |
|
| 1473 |
/** @typedef {import('react').ReactElement} ReactElement */ |
| 1474 |
|
| 1475 |
const { |
| 1476 |
Provider, |
| 1477 |
Consumer |
| 1478 |
} = (0,external_React_namespaceObject.createContext)(undefined); |
| 1479 |
const ForwardRef = (0,external_React_namespaceObject.forwardRef)(() => { |
| 1480 |
return null; |
| 1481 |
}); |
| 1482 |
|
| 1483 |
/** |
| 1484 |
* Valid attribute types. |
| 1485 |
* |
| 1486 |
* @type {Set<string>} |
| 1487 |
*/ |
| 1488 |
const ATTRIBUTES_TYPES = new Set(['string', 'boolean', 'number']); |
| 1489 |
|
| 1490 |
/** |
| 1491 |
* Element tags which can be self-closing. |
| 1492 |
* |
| 1493 |
* @type {Set<string>} |
| 1494 |
*/ |
| 1495 |
const SELF_CLOSING_TAGS = new Set(['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']); |
| 1496 |
|
| 1497 |
/** |
| 1498 |
* Boolean attributes are attributes whose presence as being assigned is |
| 1499 |
* meaningful, even if only empty. |
| 1500 |
* |
| 1501 |
* See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes |
| 1502 |
* Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 |
| 1503 |
* |
| 1504 |
* Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ] |
| 1505 |
* .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 ) |
| 1506 |
* .reduce( ( result, tr ) => Object.assign( result, { |
| 1507 |
* [ tr.firstChild.textContent.trim() ]: true |
| 1508 |
* } ), {} ) ).sort(); |
| 1509 |
* |
| 1510 |
* @type {Set<string>} |
| 1511 |
*/ |
| 1512 |
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']); |
| 1513 |
|
| 1514 |
/** |
| 1515 |
* Enumerated attributes are attributes which must be of a specific value form. |
| 1516 |
* Like boolean attributes, these are meaningful if specified, even if not of a |
| 1517 |
* valid enumerated value. |
| 1518 |
* |
| 1519 |
* See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute |
| 1520 |
* Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 |
| 1521 |
* |
| 1522 |
* Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ] |
| 1523 |
* .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) ) |
| 1524 |
* .reduce( ( result, tr ) => Object.assign( result, { |
| 1525 |
* [ tr.firstChild.textContent.trim() ]: true |
| 1526 |
* } ), {} ) ).sort(); |
| 1527 |
* |
| 1528 |
* Some notable omissions: |
| 1529 |
* |
| 1530 |
* - `alt`: https://blog.whatwg.org/omit-alt |
| 1531 |
* |
| 1532 |
* @type {Set<string>} |
| 1533 |
*/ |
| 1534 |
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']); |
| 1535 |
|
| 1536 |
/** |
| 1537 |
* Set of CSS style properties which support assignment of unitless numbers. |
| 1538 |
* Used in rendering of style properties, where `px` unit is assumed unless |
| 1539 |
* property is included in this set or value is zero. |
| 1540 |
* |
| 1541 |
* Generated via: |
| 1542 |
* |
| 1543 |
* Object.entries( document.createElement( 'div' ).style ) |
| 1544 |
* .filter( ( [ key ] ) => ( |
| 1545 |
* ! /^(webkit|ms|moz)/.test( key ) && |
| 1546 |
* ( e.style[ key ] = 10 ) && |
| 1547 |
* e.style[ key ] === '10' |
| 1548 |
* ) ) |
| 1549 |
* .map( ( [ key ] ) => key ) |
| 1550 |
* .sort(); |
| 1551 |
* |
| 1552 |
* @type {Set<string>} |
| 1553 |
*/ |
| 1554 |
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']); |
| 1555 |
|
| 1556 |
/** |
| 1557 |
* Returns true if the specified string is prefixed by one of an array of |
| 1558 |
* possible prefixes. |
| 1559 |
* |
| 1560 |
* @param {string} string String to check. |
| 1561 |
* @param {string[]} prefixes Possible prefixes. |
| 1562 |
* |
| 1563 |
* @return {boolean} Whether string has prefix. |
| 1564 |
*/ |
| 1565 |
function hasPrefix(string, prefixes) { |
| 1566 |
return prefixes.some(prefix => string.indexOf(prefix) === 0); |
| 1567 |
} |
| 1568 |
|
| 1569 |
/** |
| 1570 |
* Returns true if the given prop name should be ignored in attributes |
| 1571 |
* serialization, or false otherwise. |
| 1572 |
* |
| 1573 |
* @param {string} attribute Attribute to check. |
| 1574 |
* |
| 1575 |
* @return {boolean} Whether attribute should be ignored. |
| 1576 |
*/ |
| 1577 |
function isInternalAttribute(attribute) { |
| 1578 |
return 'key' === attribute || 'children' === attribute; |
| 1579 |
} |
| 1580 |
|
| 1581 |
/** |
| 1582 |
* Returns the normal form of the element's attribute value for HTML. |
| 1583 |
* |
| 1584 |
* @param {string} attribute Attribute name. |
| 1585 |
* @param {*} value Non-normalized attribute value. |
| 1586 |
* |
| 1587 |
* @return {*} Normalized attribute value. |
| 1588 |
*/ |
| 1589 |
function getNormalAttributeValue(attribute, value) { |
| 1590 |
switch (attribute) { |
| 1591 |
case 'style': |
| 1592 |
return renderStyle(value); |
| 1593 |
} |
| 1594 |
return value; |
| 1595 |
} |
| 1596 |
/** |
| 1597 |
* This is a map of all SVG attributes that have dashes. Map(lower case prop => dashed lower case attribute). |
| 1598 |
* We need this to render e.g strokeWidth as stroke-width. |
| 1599 |
* |
| 1600 |
* List from: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute. |
| 1601 |
*/ |
| 1602 |
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) => { |
| 1603 |
// The keys are lower-cased for more robust lookup. |
| 1604 |
map[attribute.toLowerCase()] = attribute; |
| 1605 |
return map; |
| 1606 |
}, {}); |
| 1607 |
|
| 1608 |
/** |
| 1609 |
* This is a map of all case-sensitive SVG attributes. Map(lowercase key => proper case attribute). |
| 1610 |
* The keys are lower-cased for more robust lookup. |
| 1611 |
* Note that this list only contains attributes that contain at least one capital letter. |
| 1612 |
* Lowercase attributes don't need mapping, since we lowercase all attributes by default. |
| 1613 |
*/ |
| 1614 |
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) => { |
| 1615 |
// The keys are lower-cased for more robust lookup. |
| 1616 |
map[attribute.toLowerCase()] = attribute; |
| 1617 |
return map; |
| 1618 |
}, {}); |
| 1619 |
|
| 1620 |
/** |
| 1621 |
* This is a map of all SVG attributes that have colons. |
| 1622 |
* Keys are lower-cased and stripped of their colons for more robust lookup. |
| 1623 |
*/ |
| 1624 |
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) => { |
| 1625 |
map[attribute.replace(':', '').toLowerCase()] = attribute; |
| 1626 |
return map; |
| 1627 |
}, {}); |
| 1628 |
|
| 1629 |
/** |
| 1630 |
* Returns the normal form of the element's attribute name for HTML. |
| 1631 |
* |
| 1632 |
* @param {string} attribute Non-normalized attribute name. |
| 1633 |
* |
| 1634 |
* @return {string} Normalized attribute name. |
| 1635 |
*/ |
| 1636 |
function getNormalAttributeName(attribute) { |
| 1637 |
switch (attribute) { |
| 1638 |
case 'htmlFor': |
| 1639 |
return 'for'; |
| 1640 |
case 'className': |
| 1641 |
return 'class'; |
| 1642 |
} |
| 1643 |
const attributeLowerCase = attribute.toLowerCase(); |
| 1644 |
if (CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]) { |
| 1645 |
return CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]; |
| 1646 |
} else if (SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]) { |
| 1647 |
return paramCase(SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]); |
| 1648 |
} else if (SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]) { |
| 1649 |
return SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]; |
| 1650 |
} |
| 1651 |
return attributeLowerCase; |
| 1652 |
} |
| 1653 |
|
| 1654 |
/** |
| 1655 |
* Returns the normal form of the style property name for HTML. |
| 1656 |
* |
| 1657 |
* - Converts property names to kebab-case, e.g. 'backgroundColor' → 'background-color' |
| 1658 |
* - Leaves custom attributes alone, e.g. '--myBackgroundColor' → '--myBackgroundColor' |
| 1659 |
* - Converts vendor-prefixed property names to -kebab-case, e.g. 'MozTransform' → '-moz-transform' |
| 1660 |
* |
| 1661 |
* @param {string} property Property name. |
| 1662 |
* |
| 1663 |
* @return {string} Normalized property name. |
| 1664 |
*/ |
| 1665 |
function getNormalStylePropertyName(property) { |
| 1666 |
if (property.startsWith('--')) { |
| 1667 |
return property; |
| 1668 |
} |
| 1669 |
if (hasPrefix(property, ['ms', 'O', 'Moz', 'Webkit'])) { |
| 1670 |
return '-' + paramCase(property); |
| 1671 |
} |
| 1672 |
return paramCase(property); |
| 1673 |
} |
| 1674 |
|
| 1675 |
/** |
| 1676 |
* Returns the normal form of the style property value for HTML. Appends a |
| 1677 |
* default pixel unit if numeric, not a unitless property, and not zero. |
| 1678 |
* |
| 1679 |
* @param {string} property Property name. |
| 1680 |
* @param {*} value Non-normalized property value. |
| 1681 |
* |
| 1682 |
* @return {*} Normalized property value. |
| 1683 |
*/ |
| 1684 |
function getNormalStylePropertyValue(property, value) { |
| 1685 |
if (typeof value === 'number' && 0 !== value && !CSS_PROPERTIES_SUPPORTS_UNITLESS.has(property)) { |
| 1686 |
return value + 'px'; |
| 1687 |
} |
| 1688 |
return value; |
| 1689 |
} |
| 1690 |
|
| 1691 |
/** |
| 1692 |
* Serializes a React element to string. |
| 1693 |
* |
| 1694 |
* @param {import('react').ReactNode} element Element to serialize. |
| 1695 |
* @param {Object} [context] Context object. |
| 1696 |
* @param {Object} [legacyContext] Legacy context object. |
| 1697 |
* |
| 1698 |
* @return {string} Serialized element. |
| 1699 |
*/ |
| 1700 |
function renderElement(element, context, legacyContext = {}) { |
| 1701 |
if (null === element || undefined === element || false === element) { |
| 1702 |
return ''; |
| 1703 |
} |
| 1704 |
if (Array.isArray(element)) { |
| 1705 |
return renderChildren(element, context, legacyContext); |
| 1706 |
} |
| 1707 |
switch (typeof element) { |
| 1708 |
case 'string': |
| 1709 |
return (0,external_wp_escapeHtml_namespaceObject.escapeHTML)(element); |
| 1710 |
case 'number': |
| 1711 |
return element.toString(); |
| 1712 |
} |
| 1713 |
const { |
| 1714 |
type, |
| 1715 |
props |
| 1716 |
} = /** @type {{type?: any, props?: any}} */ |
| 1717 |
element; |
| 1718 |
switch (type) { |
| 1719 |
case external_React_namespaceObject.StrictMode: |
| 1720 |
case external_React_namespaceObject.Fragment: |
| 1721 |
return renderChildren(props.children, context, legacyContext); |
| 1722 |
case RawHTML: |
| 1723 |
const { |
| 1724 |
children, |
| 1725 |
...wrapperProps |
| 1726 |
} = props; |
| 1727 |
return renderNativeComponent(!Object.keys(wrapperProps).length ? null : 'div', { |
| 1728 |
...wrapperProps, |
| 1729 |
dangerouslySetInnerHTML: { |
| 1730 |
__html: children |
| 1731 |
} |
| 1732 |
}, context, legacyContext); |
| 1733 |
} |
| 1734 |
switch (typeof type) { |
| 1735 |
case 'string': |
| 1736 |
return renderNativeComponent(type, props, context, legacyContext); |
| 1737 |
case 'function': |
| 1738 |
if (type.prototype && typeof type.prototype.render === 'function') { |
| 1739 |
return renderComponent(type, props, context, legacyContext); |
| 1740 |
} |
| 1741 |
return renderElement(type(props, legacyContext), context, legacyContext); |
| 1742 |
} |
| 1743 |
switch (type && type.$$typeof) { |
| 1744 |
case Provider.$$typeof: |
| 1745 |
return renderChildren(props.children, props.value, legacyContext); |
| 1746 |
case Consumer.$$typeof: |
| 1747 |
return renderElement(props.children(context || type._currentValue), context, legacyContext); |
| 1748 |
case ForwardRef.$$typeof: |
| 1749 |
return renderElement(type.render(props), context, legacyContext); |
| 1750 |
} |
| 1751 |
return ''; |
| 1752 |
} |
| 1753 |
|
| 1754 |
/** |
| 1755 |
* Serializes a native component type to string. |
| 1756 |
* |
| 1757 |
* @param {?string} type Native component type to serialize, or null if |
| 1758 |
* rendering as fragment of children content. |
| 1759 |
* @param {Object} props Props object. |
| 1760 |
* @param {Object} [context] Context object. |
| 1761 |
* @param {Object} [legacyContext] Legacy context object. |
| 1762 |
* |
| 1763 |
* @return {string} Serialized element. |
| 1764 |
*/ |
| 1765 |
function renderNativeComponent(type, props, context, legacyContext = {}) { |
| 1766 |
let content = ''; |
| 1767 |
if (type === 'textarea' && props.hasOwnProperty('value')) { |
| 1768 |
// Textarea children can be assigned as value prop. If it is, render in |
| 1769 |
// place of children. Ensure to omit so it is not assigned as attribute |
| 1770 |
// as well. |
| 1771 |
content = renderChildren(props.value, context, legacyContext); |
| 1772 |
const { |
| 1773 |
value, |
| 1774 |
...restProps |
| 1775 |
} = props; |
| 1776 |
props = restProps; |
| 1777 |
} else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html === 'string') { |
| 1778 |
// Dangerous content is left unescaped. |
| 1779 |
content = props.dangerouslySetInnerHTML.__html; |
| 1780 |
} else if (typeof props.children !== 'undefined') { |
| 1781 |
content = renderChildren(props.children, context, legacyContext); |
| 1782 |
} |
| 1783 |
if (!type) { |
| 1784 |
return content; |
| 1785 |
} |
| 1786 |
const attributes = renderAttributes(props); |
| 1787 |
if (SELF_CLOSING_TAGS.has(type)) { |
| 1788 |
return '<' + type + attributes + '/>'; |
| 1789 |
} |
| 1790 |
return '<' + type + attributes + '>' + content + '</' + type + '>'; |
| 1791 |
} |
| 1792 |
|
| 1793 |
/** @typedef {import('react').ComponentType} ComponentType */ |
| 1794 |
|
| 1795 |
/** |
| 1796 |
* Serializes a non-native component type to string. |
| 1797 |
* |
| 1798 |
* @param {ComponentType} Component Component type to serialize. |
| 1799 |
* @param {Object} props Props object. |
| 1800 |
* @param {Object} [context] Context object. |
| 1801 |
* @param {Object} [legacyContext] Legacy context object. |
| 1802 |
* |
| 1803 |
* @return {string} Serialized element |
| 1804 |
*/ |
| 1805 |
function renderComponent(Component, props, context, legacyContext = {}) { |
| 1806 |
const instance = new (/** @type {import('react').ComponentClass} */ |
| 1807 |
Component)(props, legacyContext); |
| 1808 |
if (typeof |
| 1809 |
// Ignore reason: Current prettier reformats parens and mangles type assertion |
| 1810 |
// prettier-ignore |
| 1811 |
/** @type {{getChildContext?: () => unknown}} */ |
| 1812 |
instance.getChildContext === 'function') { |
| 1813 |
Object.assign(legacyContext, /** @type {{getChildContext?: () => unknown}} */instance.getChildContext()); |
| 1814 |
} |
| 1815 |
const html = renderElement(instance.render(), context, legacyContext); |
| 1816 |
return html; |
| 1817 |
} |
| 1818 |
|
| 1819 |
/** |
| 1820 |
* Serializes an array of children to string. |
| 1821 |
* |
| 1822 |
* @param {import('react').ReactNodeArray} children Children to serialize. |
| 1823 |
* @param {Object} [context] Context object. |
| 1824 |
* @param {Object} [legacyContext] Legacy context object. |
| 1825 |
* |
| 1826 |
* @return {string} Serialized children. |
| 1827 |
*/ |
| 1828 |
function renderChildren(children, context, legacyContext = {}) { |
| 1829 |
let result = ''; |
| 1830 |
children = Array.isArray(children) ? children : [children]; |
| 1831 |
for (let i = 0; i < children.length; i++) { |
| 1832 |
const child = children[i]; |
| 1833 |
result += renderElement(child, context, legacyContext); |
| 1834 |
} |
| 1835 |
return result; |
| 1836 |
} |
| 1837 |
|
| 1838 |
/** |
| 1839 |
* Renders a props object as a string of HTML attributes. |
| 1840 |
* |
| 1841 |
* @param {Object} props Props object. |
| 1842 |
* |
| 1843 |
* @return {string} Attributes string. |
| 1844 |
*/ |
| 1845 |
function renderAttributes(props) { |
| 1846 |
let result = ''; |
| 1847 |
for (const key in props) { |
| 1848 |
const attribute = getNormalAttributeName(key); |
| 1849 |
if (!(0,external_wp_escapeHtml_namespaceObject.isValidAttributeName)(attribute)) { |
| 1850 |
continue; |
| 1851 |
} |
| 1852 |
let value = getNormalAttributeValue(key, props[key]); |
| 1853 |
|
| 1854 |
// If value is not of serializable type, skip. |
| 1855 |
if (!ATTRIBUTES_TYPES.has(typeof value)) { |
| 1856 |
continue; |
| 1857 |
} |
| 1858 |
|
| 1859 |
// Don't render internal attribute names. |
| 1860 |
if (isInternalAttribute(key)) { |
| 1861 |
continue; |
| 1862 |
} |
| 1863 |
const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has(attribute); |
| 1864 |
|
| 1865 |
// Boolean attribute should be omitted outright if its value is false. |
| 1866 |
if (isBooleanAttribute && value === false) { |
| 1867 |
continue; |
| 1868 |
} |
| 1869 |
const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ['data-', 'aria-']) || ENUMERATED_ATTRIBUTES.has(attribute); |
| 1870 |
|
| 1871 |
// Only write boolean value as attribute if meaningful. |
| 1872 |
if (typeof value === 'boolean' && !isMeaningfulAttribute) { |
| 1873 |
continue; |
| 1874 |
} |
| 1875 |
result += ' ' + attribute; |
| 1876 |
|
| 1877 |
// Boolean attributes should write attribute name, but without value. |
| 1878 |
// Mere presence of attribute name is effective truthiness. |
| 1879 |
if (isBooleanAttribute) { |
| 1880 |
continue; |
| 1881 |
} |
| 1882 |
if (typeof value === 'string') { |
| 1883 |
value = (0,external_wp_escapeHtml_namespaceObject.escapeAttribute)(value); |
| 1884 |
} |
| 1885 |
result += '="' + value + '"'; |
| 1886 |
} |
| 1887 |
return result; |
| 1888 |
} |
| 1889 |
|
| 1890 |
/** |
| 1891 |
* Renders a style object as a string attribute value. |
| 1892 |
* |
| 1893 |
* @param {Object} style Style object. |
| 1894 |
* |
| 1895 |
* @return {string} Style attribute value. |
| 1896 |
*/ |
| 1897 |
function renderStyle(style) { |
| 1898 |
// Only generate from object, e.g. tolerate string value. |
| 1899 |
if (!isPlainObject(style)) { |
| 1900 |
return style; |
| 1901 |
} |
| 1902 |
let result; |
| 1903 |
for (const property in style) { |
| 1904 |
const value = style[property]; |
| 1905 |
if (null === value || undefined === value) { |
| 1906 |
continue; |
| 1907 |
} |
| 1908 |
if (result) { |
| 1909 |
result += ';'; |
| 1910 |
} else { |
| 1911 |
result = ''; |
| 1912 |
} |
| 1913 |
const normalName = getNormalStylePropertyName(property); |
| 1914 |
const normalValue = getNormalStylePropertyValue(property, value); |
| 1915 |
result += normalName + ':' + normalValue; |
| 1916 |
} |
| 1917 |
return result; |
| 1918 |
} |
| 1919 |
/* harmony default export */ const serialize = (renderElement); |
| 1920 |
|
| 1921 |
;// ./packages/element/build-module/index.js |
| 1922 |
|
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
|
| 1927 |
|
| 1928 |
|
| 1929 |
|
| 1930 |
(window.wp = window.wp || {}).element = __webpack_exports__; |
| 1931 |
/******/ })() |
| 1932 |
; |