diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-includes/js/dist/element.js
--- a/wp/wp-includes/js/dist/element.js Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-includes/js/dist/element.js Fri Sep 05 18:40:08 2025 +0200
@@ -1,90 +1,155 @@
-/******/ (function() { // webpackBootstrap
+/******/ (() => { // webpackBootstrap
/******/ "use strict";
-/******/ // The require scope
-/******/ var __webpack_require__ = {};
+/******/ var __webpack_modules__ = ({
+
+/***/ 4140:
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+
+
+var m = __webpack_require__(5795);
+if (true) {
+ exports.H = m.createRoot;
+ exports.c = m.hydrateRoot;
+} else { var i; }
+
+
+/***/ }),
+
+/***/ 5795:
+/***/ ((module) => {
+
+module.exports = window["ReactDOM"];
+
+/***/ })
+
+/******/ });
+/************************************************************************/
+/******/ // The module cache
+/******/ var __webpack_module_cache__ = {};
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/ // Check if module is in cache
+/******/ var cachedModule = __webpack_module_cache__[moduleId];
+/******/ if (cachedModule !== undefined) {
+/******/ return cachedModule.exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = __webpack_module_cache__[moduleId] = {
+/******/ // no module.id needed
+/******/ // no module.loaded needed
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
-/******/ !function() {
+/******/ (() => {
/******/ // define getter functions for harmony exports
-/******/ __webpack_require__.d = function(exports, definition) {
+/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
-/******/ }();
+/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
-/******/ !function() {
-/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
-/******/ }();
+/******/ (() => {
+/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
+/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
-/******/ !function() {
+/******/ (() => {
/******/ // define __esModule on exports
-/******/ __webpack_require__.r = function(exports) {
+/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
-/******/ }();
+/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
+// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
+(() => {
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
- "Children": function() { return /* reexport */ external_React_namespaceObject.Children; },
- "Component": function() { return /* reexport */ external_React_namespaceObject.Component; },
- "Fragment": function() { return /* reexport */ external_React_namespaceObject.Fragment; },
- "Platform": function() { return /* reexport */ platform; },
- "RawHTML": function() { return /* reexport */ RawHTML; },
- "StrictMode": function() { return /* reexport */ external_React_namespaceObject.StrictMode; },
- "Suspense": function() { return /* reexport */ external_React_namespaceObject.Suspense; },
- "cloneElement": function() { return /* reexport */ external_React_namespaceObject.cloneElement; },
- "concatChildren": function() { return /* reexport */ concatChildren; },
- "createContext": function() { return /* reexport */ external_React_namespaceObject.createContext; },
- "createElement": function() { return /* reexport */ external_React_namespaceObject.createElement; },
- "createInterpolateElement": function() { return /* reexport */ create_interpolate_element; },
- "createPortal": function() { return /* reexport */ external_ReactDOM_namespaceObject.createPortal; },
- "createRef": function() { return /* reexport */ external_React_namespaceObject.createRef; },
- "findDOMNode": function() { return /* reexport */ external_ReactDOM_namespaceObject.findDOMNode; },
- "forwardRef": function() { return /* reexport */ external_React_namespaceObject.forwardRef; },
- "isEmptyElement": function() { return /* reexport */ isEmptyElement; },
- "isValidElement": function() { return /* reexport */ external_React_namespaceObject.isValidElement; },
- "lazy": function() { return /* reexport */ external_React_namespaceObject.lazy; },
- "memo": function() { return /* reexport */ external_React_namespaceObject.memo; },
- "render": function() { return /* reexport */ external_ReactDOM_namespaceObject.render; },
- "renderToString": function() { return /* reexport */ serialize; },
- "switchChildrenNodeName": function() { return /* reexport */ switchChildrenNodeName; },
- "unmountComponentAtNode": function() { return /* reexport */ external_ReactDOM_namespaceObject.unmountComponentAtNode; },
- "useCallback": function() { return /* reexport */ external_React_namespaceObject.useCallback; },
- "useContext": function() { return /* reexport */ external_React_namespaceObject.useContext; },
- "useDebugValue": function() { return /* reexport */ external_React_namespaceObject.useDebugValue; },
- "useEffect": function() { return /* reexport */ external_React_namespaceObject.useEffect; },
- "useImperativeHandle": function() { return /* reexport */ external_React_namespaceObject.useImperativeHandle; },
- "useLayoutEffect": function() { return /* reexport */ external_React_namespaceObject.useLayoutEffect; },
- "useMemo": function() { return /* reexport */ external_React_namespaceObject.useMemo; },
- "useReducer": function() { return /* reexport */ external_React_namespaceObject.useReducer; },
- "useRef": function() { return /* reexport */ external_React_namespaceObject.useRef; },
- "useState": function() { return /* reexport */ external_React_namespaceObject.useState; }
+ Children: () => (/* reexport */ external_React_namespaceObject.Children),
+ Component: () => (/* reexport */ external_React_namespaceObject.Component),
+ Fragment: () => (/* reexport */ external_React_namespaceObject.Fragment),
+ Platform: () => (/* reexport */ platform),
+ PureComponent: () => (/* reexport */ external_React_namespaceObject.PureComponent),
+ RawHTML: () => (/* reexport */ RawHTML),
+ StrictMode: () => (/* reexport */ external_React_namespaceObject.StrictMode),
+ Suspense: () => (/* reexport */ external_React_namespaceObject.Suspense),
+ cloneElement: () => (/* reexport */ external_React_namespaceObject.cloneElement),
+ concatChildren: () => (/* reexport */ concatChildren),
+ createContext: () => (/* reexport */ external_React_namespaceObject.createContext),
+ createElement: () => (/* reexport */ external_React_namespaceObject.createElement),
+ createInterpolateElement: () => (/* reexport */ create_interpolate_element),
+ createPortal: () => (/* reexport */ external_ReactDOM_.createPortal),
+ createRef: () => (/* reexport */ external_React_namespaceObject.createRef),
+ createRoot: () => (/* reexport */ client/* createRoot */.H),
+ findDOMNode: () => (/* reexport */ external_ReactDOM_.findDOMNode),
+ flushSync: () => (/* reexport */ external_ReactDOM_.flushSync),
+ forwardRef: () => (/* reexport */ external_React_namespaceObject.forwardRef),
+ hydrate: () => (/* reexport */ external_ReactDOM_.hydrate),
+ hydrateRoot: () => (/* reexport */ client/* hydrateRoot */.c),
+ isEmptyElement: () => (/* reexport */ isEmptyElement),
+ isValidElement: () => (/* reexport */ external_React_namespaceObject.isValidElement),
+ lazy: () => (/* reexport */ external_React_namespaceObject.lazy),
+ memo: () => (/* reexport */ external_React_namespaceObject.memo),
+ render: () => (/* reexport */ external_ReactDOM_.render),
+ renderToString: () => (/* reexport */ serialize),
+ startTransition: () => (/* reexport */ external_React_namespaceObject.startTransition),
+ switchChildrenNodeName: () => (/* reexport */ switchChildrenNodeName),
+ unmountComponentAtNode: () => (/* reexport */ external_ReactDOM_.unmountComponentAtNode),
+ useCallback: () => (/* reexport */ external_React_namespaceObject.useCallback),
+ useContext: () => (/* reexport */ external_React_namespaceObject.useContext),
+ useDebugValue: () => (/* reexport */ external_React_namespaceObject.useDebugValue),
+ useDeferredValue: () => (/* reexport */ external_React_namespaceObject.useDeferredValue),
+ useEffect: () => (/* reexport */ external_React_namespaceObject.useEffect),
+ useId: () => (/* reexport */ external_React_namespaceObject.useId),
+ useImperativeHandle: () => (/* reexport */ external_React_namespaceObject.useImperativeHandle),
+ useInsertionEffect: () => (/* reexport */ external_React_namespaceObject.useInsertionEffect),
+ useLayoutEffect: () => (/* reexport */ external_React_namespaceObject.useLayoutEffect),
+ useMemo: () => (/* reexport */ external_React_namespaceObject.useMemo),
+ useReducer: () => (/* reexport */ external_React_namespaceObject.useReducer),
+ useRef: () => (/* reexport */ external_React_namespaceObject.useRef),
+ useState: () => (/* reexport */ external_React_namespaceObject.useState),
+ useSyncExternalStore: () => (/* reexport */ external_React_namespaceObject.useSyncExternalStore),
+ useTransition: () => (/* reexport */ external_React_namespaceObject.useTransition)
});
;// CONCATENATED MODULE: external "React"
-var external_React_namespaceObject = window["React"];
+const external_React_namespaceObject = window["React"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/create-interpolate-element.js
/**
* Internal dependencies
*/
-/** @typedef {import('./react').WPElement} WPElement */
+
+/**
+ * Object containing a React element.
+ *
+ * @typedef {import('react').ReactElement} Element
+ */
let indoc, offset, output, stack;
+
/**
* Matches tags in the localized string
*
@@ -94,30 +159,30 @@
* There are four references extracted using this tokenizer:
*
* match: Full match of the tag (i.e. , ,
)
- * isClosing: The closing slash, it it exists.
+ * isClosing: The closing slash, if it exists.
* name: The name portion of the tag (strong, br) (if )
* isSelfClosed: The slash on a self closing tag, if it exists.
*
* @type {RegExp}
*/
+const tokenizer = /<(\/)?(\w+)\s*(\/)?>/g;
-const tokenizer = /<(\/)?(\w+)\s*(\/)?>/g;
/**
* The stack frame tracking parse progress.
*
* @typedef Frame
*
- * @property {WPElement} element A parent element which may still have
- * @property {number} tokenStart Offset at which parent element first
- * appears.
- * @property {number} tokenLength Length of string marking start of parent
- * element.
- * @property {number} [prevOffset] Running offset at which parsing should
- * continue.
- * @property {number} [leadingTextStart] Offset at which last closing element
- * finished, used for finding text between
- * elements.
- * @property {WPElement[]} children Children.
+ * @property {Element} element A parent element which may still have
+ * @property {number} tokenStart Offset at which parent element first
+ * appears.
+ * @property {number} tokenLength Length of string marking start of parent
+ * element.
+ * @property {number} [prevOffset] Running offset at which parsing should
+ * continue.
+ * @property {number} [leadingTextStart] Offset at which last closing element
+ * finished, used for finding text between
+ * elements.
+ * @property {Element[]} children Children.
*/
/**
@@ -127,21 +192,20 @@
* parsed.
*
* @private
- * @param {WPElement} element A parent element which may still have
- * nested children not yet parsed.
- * @param {number} tokenStart Offset at which parent element first
- * appears.
- * @param {number} tokenLength Length of string marking start of parent
- * element.
- * @param {number} [prevOffset] Running offset at which parsing should
- * continue.
- * @param {number} [leadingTextStart] Offset at which last closing element
- * finished, used for finding text between
- * elements.
+ * @param {Element} element A parent element which may still have
+ * nested children not yet parsed.
+ * @param {number} tokenStart Offset at which parent element first
+ * appears.
+ * @param {number} tokenLength Length of string marking start of parent
+ * element.
+ * @param {number} [prevOffset] Running offset at which parsing should
+ * continue.
+ * @param {number} [leadingTextStart] Offset at which last closing element
+ * finished, used for finding text between
+ * elements.
*
* @return {Frame} The stack frame tracking parse progress.
*/
-
function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) {
return {
element,
@@ -152,6 +216,7 @@
children: []
};
}
+
/**
* This function creates an interpolated element from a passed in string with
* specific tags matching how the string should be converted to an element via
@@ -173,35 +238,32 @@
* }
* ```
*
- * @param {string} interpolatedString The interpolation string to be parsed.
- * @param {Object} conversionMap The map used to convert the string to
- * a react element.
+ * @param {string} interpolatedString The interpolation string to be parsed.
+ * @param {Record} conversionMap The map used to convert the string to
+ * a react element.
* @throws {TypeError}
- * @return {WPElement} A wp element.
+ * @return {Element} A wp element.
*/
-
-
const createInterpolateElement = (interpolatedString, conversionMap) => {
indoc = interpolatedString;
offset = 0;
output = [];
stack = [];
tokenizer.lastIndex = 0;
-
if (!isValidConversionMap(conversionMap)) {
- throw new TypeError('The conversionMap provided is not valid. It must be an object with values that are WPElements');
+ throw new TypeError('The conversionMap provided is not valid. It must be an object with values that are React Elements');
}
-
- do {// twiddle our thumbs
+ do {
+ // twiddle our thumbs
} while (proceed(conversionMap));
-
return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, ...output);
};
+
/**
* Validate conversion map.
*
* A map is considered valid if it's an object and every value in the object
- * is a WPElement
+ * is a React Element
*
* @private
*
@@ -209,13 +271,12 @@
*
* @return {boolean} True means the map is valid.
*/
-
-
const isValidConversionMap = conversionMap => {
const isObject = typeof conversionMap === 'object';
const values = isObject && Object.values(conversionMap);
return isObject && values.length && values.every(element => (0,external_React_namespaceObject.isValidElement)(element));
};
+
/**
* This is the iterator over the matches in the string.
*
@@ -225,19 +286,15 @@
*
* @return {boolean} true for continuing to iterate, false for finished.
*/
-
-
function proceed(conversionMap) {
const next = nextToken();
const [tokenType, name, startOffset, tokenLength] = next;
const stackDepth = stack.length;
const leadingTextStart = startOffset > offset ? offset : null;
-
if (!conversionMap[name]) {
addText();
return false;
}
-
switch (tokenType) {
case 'no-more-tokens':
if (stackDepth !== 0) {
@@ -247,41 +304,36 @@
} = stack.pop();
output.push(indoc.substr(stackLeadingText, tokenStart));
}
-
addText();
return false;
-
case 'self-closed':
if (0 === stackDepth) {
if (null !== leadingTextStart) {
output.push(indoc.substr(leadingTextStart, startOffset - leadingTextStart));
}
-
output.push(conversionMap[name]);
offset = startOffset + tokenLength;
return true;
- } // Otherwise we found an inner element.
+ }
-
+ // Otherwise we found an inner element.
addChild(createFrame(conversionMap[name], startOffset, tokenLength));
offset = startOffset + tokenLength;
return true;
-
case 'opener':
stack.push(createFrame(conversionMap[name], startOffset, tokenLength, startOffset + tokenLength, leadingTextStart));
offset = startOffset + tokenLength;
return true;
-
case 'closer':
// If we're not nesting then this is easy - close the block.
if (1 === stackDepth) {
closeOuterElement(startOffset);
offset = startOffset + tokenLength;
return true;
- } // Otherwise we're nested and we have to close out the current
+ }
+
+ // Otherwise we're nested and we have to close out the current
// block and add it as a innerBlock to the parent.
-
-
const stackTop = stack.pop();
const text = indoc.substr(stackTop.prevOffset, startOffset - stackTop.prevOffset);
stackTop.children.push(text);
@@ -291,12 +343,12 @@
addChild(frame);
offset = startOffset + tokenLength;
return true;
-
default:
addText();
return false;
}
}
+
/**
* Grabs the next token match in the string and returns it's details.
*
@@ -304,29 +356,24 @@
*
* @return {Array} An array of details for the token matched.
*/
-
-
function nextToken() {
- const matches = tokenizer.exec(indoc); // We have no more tokens.
-
+ const matches = tokenizer.exec(indoc);
+ // We have no more tokens.
if (null === matches) {
return ['no-more-tokens'];
}
-
const startedAt = matches.index;
const [match, isClosing, name, isSelfClosed] = matches;
const length = match.length;
-
if (isSelfClosed) {
return ['self-closed', name, startedAt, length];
}
-
if (isClosing) {
return ['closer', name, startedAt, length];
}
-
return ['opener', name, startedAt, length];
}
+
/**
* Pushes text extracted from the indoc string to the output stack given the
* current rawLength value and offset (if rawLength is provided ) or the
@@ -334,17 +381,14 @@
*
* @private
*/
-
-
function addText() {
const length = indoc.length - offset;
-
if (0 === length) {
return;
}
-
output.push(indoc.substr(offset, length));
}
+
/**
* Pushes a child element to the associated parent element's children for the
* parent currently active in the stack.
@@ -354,8 +398,6 @@
* @param {Frame} frame The Frame containing the child element and it's
* token information.
*/
-
-
function addChild(frame) {
const {
element,
@@ -366,14 +408,13 @@
} = frame;
const parent = stack[stack.length - 1];
const text = indoc.substr(parent.prevOffset, tokenStart - parent.prevOffset);
-
if (text) {
parent.children.push(text);
}
-
parent.children.push((0,external_React_namespaceObject.cloneElement)(element, null, ...children));
parent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;
}
+
/**
* This is called for closing tags. It creates the element currently active in
* the stack.
@@ -386,8 +427,6 @@
* helps capture any remaining nested text nodes in
* the element.
*/
-
-
function closeOuterElement(endOffset) {
const {
element,
@@ -397,22 +436,16 @@
children
} = stack.pop();
const text = endOffset ? indoc.substr(prevOffset, endOffset - prevOffset) : indoc.substr(prevOffset);
-
if (text) {
children.push(text);
}
-
if (null !== leadingTextStart) {
output.push(indoc.substr(leadingTextStart, tokenStart - leadingTextStart));
}
-
output.push((0,external_React_namespaceObject.cloneElement)(element, null, ...children));
}
-
-/* harmony default export */ var create_interpolate_element = (createInterpolateElement);
+/* harmony default export */ const create_interpolate_element = (createInterpolateElement);
-;// CONCATENATED MODULE: external "lodash"
-var external_lodash_namespaceObject = window["lodash"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/react.js
/**
* External dependencies
@@ -423,19 +456,26 @@
/**
* Object containing a React element.
*
- * @typedef {import('react').ReactElement} WPElement
+ * @typedef {import('react').ReactElement} Element
*/
/**
* Object containing a React component.
*
- * @typedef {import('react').ComponentType} WPComponent
+ * @typedef {import('react').ComponentType} ComponentType
*/
/**
* Object containing a React synthetic event.
*
- * @typedef {import('react').SyntheticEvent} WPSyntheticEvent
+ * @typedef {import('react').SyntheticEvent} SyntheticEvent
+ */
+
+/**
+ * Object containing a React synthetic event.
+ *
+ * @template T
+ * @typedef {import('react').RefObject} RefObject
*/
/**
@@ -446,10 +486,10 @@
/**
* Creates a copy of an element with extended props.
*
- * @param {WPElement} element Element
- * @param {?Object} props Props to apply to cloned element
+ * @param {Element} element Element
+ * @param {?Object} props Props to apply to cloned element
*
- * @return {WPElement} Cloned element.
+ * @return {Element} Cloned element.
*/
@@ -475,9 +515,9 @@
* @param {Object} props Element properties, either attribute
* set to apply to DOM node or values to
* pass through to element creator
- * @param {...WPElement} children Descendant elements
+ * @param {...Element} children Descendant elements
*
- * @return {WPElement} Element.
+ * @return {Element} Element.
*/
@@ -499,7 +539,7 @@
* @param {Function} forwarder Function passed `props` and `ref`, expected to
* return an element.
*
- * @return {WPComponent} Enhanced component.
+ * @return {Component} Enhanced component.
*/
@@ -509,11 +549,11 @@
/**
- * Checks if an object is a valid WPElement.
+ * Checks if an object is a valid React Element.
*
* @param {Object} objectToCheck The object to be checked.
*
- * @return {boolean} true if objectToTest is a valid WPElement and false otherwise.
+ * @return {boolean} true if objectToTest is a valid React Element and false otherwise.
*/
@@ -543,16 +583,31 @@
/**
+ * @see https://reactjs.org/docs/hooks-reference.html#usedeferredvalue
+ */
+
+
+/**
* @see https://reactjs.org/docs/hooks-reference.html#useeffect
*/
/**
+ * @see https://reactjs.org/docs/hooks-reference.html#useid
+ */
+
+
+/**
* @see https://reactjs.org/docs/hooks-reference.html#useimperativehandle
*/
/**
+ * @see https://reactjs.org/docs/hooks-reference.html#useinsertioneffect
+ */
+
+
+/**
* @see https://reactjs.org/docs/hooks-reference.html#uselayouteffect
*/
@@ -578,6 +633,21 @@
/**
+ * @see https://reactjs.org/docs/hooks-reference.html#usesyncexternalstore
+ */
+
+
+/**
+ * @see https://reactjs.org/docs/hooks-reference.html#usetransition
+ */
+
+
+/**
+ * @see https://reactjs.org/docs/react-api.html#starttransition
+ */
+
+
+/**
* @see https://reactjs.org/docs/react-api.html#reactlazy
*/
@@ -588,18 +658,18 @@
/**
+ * @see https://reactjs.org/docs/react-api.html#reactpurecomponent
+ */
+
+
+/**
* Concatenate two or more React children objects.
*
* @param {...?Object} childrenArguments Array of children arguments (array of arrays/strings/objects) to concatenate.
*
* @return {Array} The concatenated value.
*/
-
-function concatChildren() {
- for (var _len = arguments.length, childrenArguments = new Array(_len), _key = 0; _key < _len; _key++) {
- childrenArguments[_key] = arguments[_key];
- }
-
+function concatChildren(...childrenArguments) {
return childrenArguments.reduce((accumulator, children, i) => {
external_React_namespaceObject.Children.forEach(children, (child, j) => {
if (child && 'string' !== typeof child) {
@@ -607,12 +677,12 @@
key: [i, j].join()
});
}
-
accumulator.push(child);
});
return accumulator;
}, []);
}
+
/**
* Switches the nodeName of all the elements in the children object.
*
@@ -621,15 +691,13 @@
*
* @return {?Object} The updated children object.
*/
-
function switchChildrenNodeName(children, nodeName) {
return children && external_React_namespaceObject.Children.map(children, (elt, index) => {
- if ((0,external_lodash_namespaceObject.isString)(elt)) {
+ if (typeof elt?.valueOf() === 'string') {
return (0,external_React_namespaceObject.createElement)(nodeName, {
key: index
}, elt);
}
-
const {
children: childrenProp,
...props
@@ -641,68 +709,96 @@
});
}
-;// CONCATENATED MODULE: external "ReactDOM"
-var external_ReactDOM_namespaceObject = window["ReactDOM"];
+// EXTERNAL MODULE: external "ReactDOM"
+var external_ReactDOM_ = __webpack_require__(5795);
+// EXTERNAL MODULE: ./node_modules/react-dom/client.js
+var client = __webpack_require__(4140);
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/react-platform.js
/**
* External dependencies
*/
+
+
/**
* Creates a portal into which a component can be rendered.
*
* @see https://github.com/facebook/react/issues/10309#issuecomment-318433235
*
- * @param {import('./react').WPElement} child Any renderable child, such as an element,
- * string, or fragment.
- * @param {HTMLElement} container DOM node into which element should be rendered.
+ * @param {import('react').ReactElement} child Any renderable child, such as an element,
+ * string, or fragment.
+ * @param {HTMLElement} container DOM node into which element should be rendered.
*/
/**
* Finds the dom node of a React component.
*
- * @param {import('./react').WPComponent} component Component's instance.
+ * @param {import('react').ComponentType} component Component's instance.
+ */
+
+
+/**
+ * Forces React to flush any updates inside the provided callback synchronously.
+ *
+ * @param {Function} callback Callback to run synchronously.
*/
/**
* Renders a given element into the target DOM node.
*
- * @param {import('./react').WPElement} element Element to render.
- * @param {HTMLElement} target DOM node into which element should be rendered.
+ * @deprecated since WordPress 6.2.0. Use `createRoot` instead.
+ * @see https://react.dev/reference/react-dom/render
+ */
+
+
+/**
+ * Hydrates a given element into the target DOM node.
+ *
+ * @deprecated since WordPress 6.2.0. Use `hydrateRoot` instead.
+ * @see https://react.dev/reference/react-dom/hydrate
+ */
+
+
+/**
+ * Creates a new React root for the target DOM node.
+ *
+ * @since 6.2.0 Introduced in WordPress core.
+ * @see https://react.dev/reference/react-dom/client/createRoot
+ */
+
+
+/**
+ * Creates a new React root for the target DOM node and hydrates it with a pre-generated markup.
+ *
+ * @since 6.2.0 Introduced in WordPress core.
+ * @see https://react.dev/reference/react-dom/client/hydrateRoot
*/
/**
* Removes any mounted element from the target DOM node.
*
- * @param {Element} target DOM node in which element is to be removed
+ * @deprecated since WordPress 6.2.0. Use `root.unmount()` instead.
+ * @see https://react.dev/reference/react-dom/unmountComponentAtNode
*/
-
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/utils.js
/**
- * External dependencies
- */
-
-/**
* Checks if the provided WP element is empty.
*
* @param {*} element WP element to check.
* @return {boolean} True when an element is considered empty.
*/
-
const isEmptyElement = element => {
- if ((0,external_lodash_namespaceObject.isNumber)(element)) {
+ if (typeof element === 'number') {
return false;
}
-
- if ((0,external_lodash_namespaceObject.isString)(element) || (0,external_lodash_namespaceObject.isArray)(element)) {
+ if (typeof element?.valueOf() === 'string' || Array.isArray(element)) {
return !element.length;
}
-
return !element;
};
@@ -726,7 +822,7 @@
*
* This is the same concept as the React Native implementation.
*
- * @see https://facebook.github.io/react-native/docs/platform-specific-code#platform-module
+ * @see https://reactnative.dev/docs/platform-specific-code#platform-module
*
* Here is an example of how to use the select method:
* @example
@@ -739,16 +835,520 @@
* } );
* ```
*/
+/* harmony default export */ const platform = (Platform);
-/* harmony default export */ var platform = (Platform);
+;// CONCATENATED MODULE: ./node_modules/is-plain-object/dist/is-plain-object.mjs
+/*!
+ * is-plain-object
+ *
+ * Copyright (c) 2014-2017, Jon Schlinkert.
+ * Released under the MIT License.
+ */
+
+function isObject(o) {
+ return Object.prototype.toString.call(o) === '[object Object]';
+}
+
+function isPlainObject(o) {
+ var ctor,prot;
+
+ if (isObject(o) === false) return false;
+
+ // If has modified constructor
+ ctor = o.constructor;
+ if (ctor === undefined) return true;
+
+ // If has modified prototype
+ prot = ctor.prototype;
+ if (isObject(prot) === false) return false;
+
+ // If constructor does not have an Object-specific method
+ if (prot.hasOwnProperty('isPrototypeOf') === false) {
+ return false;
+ }
+
+ // Most likely a plain Object
+ return true;
+}
+
+
+
+;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
+/******************************************************************************
+Copyright (c) Microsoft Corporation.
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+***************************************************************************** */
+/* global Reflect, Promise, SuppressedError, Symbol */
+
+var extendStatics = function(d, b) {
+ extendStatics = Object.setPrototypeOf ||
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
+ return extendStatics(d, b);
+};
+
+function __extends(d, b) {
+ if (typeof b !== "function" && b !== null)
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
+ extendStatics(d, b);
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+}
+
+var __assign = function() {
+ __assign = Object.assign || function __assign(t) {
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
+ s = arguments[i];
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
+ }
+ return t;
+ }
+ return __assign.apply(this, arguments);
+}
+
+function __rest(s, e) {
+ var t = {};
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
+ t[p] = s[p];
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
+ t[p[i]] = s[p[i]];
+ }
+ return t;
+}
+
+function __decorate(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ 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;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+}
+
+function __param(paramIndex, decorator) {
+ return function (target, key) { decorator(target, key, paramIndex); }
+}
+
+function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
+ var _, done = false;
+ for (var i = decorators.length - 1; i >= 0; i--) {
+ var context = {};
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
+ if (kind === "accessor") {
+ if (result === void 0) continue;
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
+ if (_ = accept(result.get)) descriptor.get = _;
+ if (_ = accept(result.set)) descriptor.set = _;
+ if (_ = accept(result.init)) initializers.unshift(_);
+ }
+ else if (_ = accept(result)) {
+ if (kind === "field") initializers.unshift(_);
+ else descriptor[key] = _;
+ }
+ }
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
+ done = true;
+};
+
+function __runInitializers(thisArg, initializers, value) {
+ var useValue = arguments.length > 2;
+ for (var i = 0; i < initializers.length; i++) {
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
+ }
+ return useValue ? value : void 0;
+};
+
+function __propKey(x) {
+ return typeof x === "symbol" ? x : "".concat(x);
+};
+
+function __setFunctionName(f, name, prefix) {
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
+};
+
+function __metadata(metadataKey, metadataValue) {
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
+}
+
+function __awaiter(thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+}
+
+function __generator(thisArg, body) {
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
+ function verb(n) { return function (v) { return step([n, v]); }; }
+ function step(op) {
+ if (f) throw new TypeError("Generator is already executing.");
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
+ 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;
+ if (y = 0, t) op = [op[0] & 2, t.value];
+ switch (op[0]) {
+ case 0: case 1: t = op; break;
+ case 4: _.label++; return { value: op[1], done: false };
+ case 5: _.label++; y = op[1]; op = [0]; continue;
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
+ default:
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
+ if (t[2]) _.ops.pop();
+ _.trys.pop(); continue;
+ }
+ op = body.call(thisArg, _);
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
+ }
+}
+
+var __createBinding = Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+});
+
+function __exportStar(m, o) {
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
+}
+
+function __values(o) {
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
+ if (m) return m.call(o);
+ if (o && typeof o.length === "number") return {
+ next: function () {
+ if (o && i >= o.length) o = void 0;
+ return { value: o && o[i++], done: !o };
+ }
+ };
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
+}
+
+function __read(o, n) {
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
+ if (!m) return o;
+ var i = m.call(o), r, ar = [], e;
+ try {
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
+ }
+ catch (error) { e = { error: error }; }
+ finally {
+ try {
+ if (r && !r.done && (m = i["return"])) m.call(i);
+ }
+ finally { if (e) throw e.error; }
+ }
+ return ar;
+}
+
+/** @deprecated */
+function __spread() {
+ for (var ar = [], i = 0; i < arguments.length; i++)
+ ar = ar.concat(__read(arguments[i]));
+ return ar;
+}
+
+/** @deprecated */
+function __spreadArrays() {
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
+ r[k] = a[j];
+ return r;
+}
+
+function __spreadArray(to, from, pack) {
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
+ if (ar || !(i in from)) {
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
+ ar[i] = from[i];
+ }
+ }
+ return to.concat(ar || Array.prototype.slice.call(from));
+}
+
+function __await(v) {
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
+}
+
+function __asyncGenerator(thisArg, _arguments, generator) {
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
+ function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
+ function fulfill(value) { resume("next", value); }
+ function reject(value) { resume("throw", value); }
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
+}
+
+function __asyncDelegator(o) {
+ var i, p;
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
+ 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; }
+}
+
+function __asyncValues(o) {
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
+ var m = o[Symbol.asyncIterator], i;
+ 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);
+ 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); }); }; }
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
+}
+
+function __makeTemplateObject(cooked, raw) {
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
+ return cooked;
+};
+
+var __setModuleDefault = Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+};
+
+function __importStar(mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+}
+
+function __importDefault(mod) {
+ return (mod && mod.__esModule) ? mod : { default: mod };
+}
+
+function __classPrivateFieldGet(receiver, state, kind, f) {
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
+ 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");
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
+}
+
+function __classPrivateFieldSet(receiver, state, value, kind, f) {
+ if (kind === "m") throw new TypeError("Private method is not writable");
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
+ 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");
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
+}
+
+function __classPrivateFieldIn(state, receiver) {
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
+ return typeof state === "function" ? receiver === state : state.has(receiver);
+}
+
+function __addDisposableResource(env, value, async) {
+ if (value !== null && value !== void 0) {
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
+ var dispose;
+ if (async) {
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
+ dispose = value[Symbol.asyncDispose];
+ }
+ if (dispose === void 0) {
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
+ dispose = value[Symbol.dispose];
+ }
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
+ env.stack.push({ value: value, dispose: dispose, async: async });
+ }
+ else if (async) {
+ env.stack.push({ async: true });
+ }
+ return value;
+}
+
+var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
+ var e = new Error(message);
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
+};
+
+function __disposeResources(env) {
+ function fail(e) {
+ env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
+ env.hasError = true;
+ }
+ function next() {
+ while (env.stack.length) {
+ var rec = env.stack.pop();
+ try {
+ var result = rec.dispose && rec.dispose.call(rec.value);
+ if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
+ }
+ catch (e) {
+ fail(e);
+ }
+ }
+ if (env.hasError) throw env.error;
+ }
+ return next();
+}
+
+/* harmony default export */ const tslib_es6 = ({
+ __extends,
+ __assign,
+ __rest,
+ __decorate,
+ __param,
+ __metadata,
+ __awaiter,
+ __generator,
+ __createBinding,
+ __exportStar,
+ __values,
+ __read,
+ __spread,
+ __spreadArrays,
+ __spreadArray,
+ __await,
+ __asyncGenerator,
+ __asyncDelegator,
+ __asyncValues,
+ __makeTemplateObject,
+ __importStar,
+ __importDefault,
+ __classPrivateFieldGet,
+ __classPrivateFieldSet,
+ __classPrivateFieldIn,
+ __addDisposableResource,
+ __disposeResources,
+});
+
+;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
+/**
+ * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
+ */
+var SUPPORTED_LOCALE = {
+ tr: {
+ regexp: /\u0130|\u0049|\u0049\u0307/g,
+ map: {
+ İ: "\u0069",
+ I: "\u0131",
+ İ: "\u0069",
+ },
+ },
+ az: {
+ regexp: /\u0130/g,
+ map: {
+ İ: "\u0069",
+ I: "\u0131",
+ İ: "\u0069",
+ },
+ },
+ lt: {
+ regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
+ map: {
+ I: "\u0069\u0307",
+ J: "\u006A\u0307",
+ Į: "\u012F\u0307",
+ Ì: "\u0069\u0307\u0300",
+ Í: "\u0069\u0307\u0301",
+ Ĩ: "\u0069\u0307\u0303",
+ },
+ },
+};
+/**
+ * Localized lower case.
+ */
+function localeLowerCase(str, locale) {
+ var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
+ if (lang)
+ return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
+ return lowerCase(str);
+}
+/**
+ * Lower case as a function.
+ */
+function lowerCase(str) {
+ return str.toLowerCase();
+}
+
+;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
+
+// Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
+var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
+// Remove all non-word characters.
+var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
+/**
+ * Normalize the string into something other libraries can manipulate easier.
+ */
+function noCase(input, options) {
+ if (options === void 0) { options = {}; }
+ 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;
+ var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
+ var start = 0;
+ var end = result.length;
+ // Trim the delimiter from around the output string.
+ while (result.charAt(start) === "\0")
+ start++;
+ while (result.charAt(end - 1) === "\0")
+ end--;
+ // Transform each token independently.
+ return result.slice(start, end).split("\0").map(transform).join(delimiter);
+}
+/**
+ * Replace `re` in the input string with the replacement value.
+ */
+function replace(input, re, value) {
+ if (re instanceof RegExp)
+ return input.replace(re, value);
+ return re.reduce(function (input, re) { return input.replace(re, value); }, input);
+}
+
+;// CONCATENATED MODULE: ./node_modules/dot-case/dist.es2015/index.js
+
+
+function dotCase(input, options) {
+ if (options === void 0) { options = {}; }
+ return noCase(input, __assign({ delimiter: "." }, options));
+}
+
+;// CONCATENATED MODULE: ./node_modules/param-case/dist.es2015/index.js
+
+
+function paramCase(input, options) {
+ if (options === void 0) { options = {}; }
+ return dotCase(input, __assign({ delimiter: "-" }, options));
+}
;// CONCATENATED MODULE: external ["wp","escapeHtml"]
-var external_wp_escapeHtml_namespaceObject = window["wp"]["escapeHtml"];
+const external_wp_escapeHtml_namespaceObject = window["wp"]["escapeHtml"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/raw-html.js
/**
* Internal dependencies
*/
- // Disable reason: JSDoc linter doesn't seem to parse the union (`&`) correctly.
+
/** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */
@@ -764,21 +1364,21 @@
*
* @return {JSX.Element} Dangerously-rendering component.
*/
+function RawHTML({
+ children,
+ ...props
+}) {
+ let rawHtml = '';
-function RawHTML(_ref) {
- let {
- children,
- ...props
- } = _ref;
- let rawHtml = ''; // Cast children as an array, and concatenate each element if it is a string.
-
+ // Cast children as an array, and concatenate each element if it is a string.
external_React_namespaceObject.Children.toArray(children).forEach(child => {
if (typeof child === 'string' && child.trim() !== '') {
rawHtml += child;
}
- }); // The `div` wrapper will be stripped by the `renderElement` serializer in
+ });
+
+ // The `div` wrapper will be stripped by the `renderElement` serializer in
// `./serialize.js` unless there are non-children props present.
-
return (0,external_React_namespaceObject.createElement)('div', {
dangerouslySetInnerHTML: {
__html: rawHtml
@@ -819,6 +1419,8 @@
* External dependencies
*/
+
+
/**
* WordPress dependencies
*/
@@ -830,7 +1432,7 @@
-/** @typedef {import('./react').WPElement} WPElement */
+/** @typedef {import('react').ReactElement} ReactElement */
const {
Provider,
@@ -839,20 +1441,21 @@
const ForwardRef = (0,external_React_namespaceObject.forwardRef)(() => {
return null;
});
+
/**
* Valid attribute types.
*
* @type {Set}
*/
+const ATTRIBUTES_TYPES = new Set(['string', 'boolean', 'number']);
-const ATTRIBUTES_TYPES = new Set(['string', 'boolean', 'number']);
/**
* Element tags which can be self-closing.
*
* @type {Set}
*/
+const SELF_CLOSING_TAGS = new Set(['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']);
-const SELF_CLOSING_TAGS = new Set(['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']);
/**
* Boolean attributes are attributes whose presence as being assigned is
* meaningful, even if only empty.
@@ -868,8 +1471,8 @@
*
* @type {Set}
*/
+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']);
-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']);
/**
* Enumerated attributes are attributes which must be of a specific value form.
* Like boolean attributes, these are meaningful if specified, even if not of a
@@ -890,8 +1493,8 @@
*
* @type {Set}
*/
+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']);
-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']);
/**
* Set of CSS style properties which support assignment of unitless numbers.
* Used in rendering of style properties, where `px` unit is assumed unless
@@ -910,8 +1513,8 @@
*
* @type {Set}
*/
+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']);
-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']);
/**
* Returns true if the specified string is prefixed by one of an array of
* possible prefixes.
@@ -921,10 +1524,10 @@
*
* @return {boolean} Whether string has prefix.
*/
-
function hasPrefix(string, prefixes) {
return prefixes.some(prefix => string.indexOf(prefix) === 0);
}
+
/**
* Returns true if the given prop name should be ignored in attributes
* serialization, or false otherwise.
@@ -933,10 +1536,10 @@
*
* @return {boolean} Whether attribute should be ignored.
*/
-
function isInternalAttribute(attribute) {
return 'key' === attribute || 'children' === attribute;
}
+
/**
* Returns the normal form of the element's attribute value for HTML.
*
@@ -945,14 +1548,11 @@
*
* @return {*} Normalized attribute value.
*/
-
-
function getNormalAttributeValue(attribute, value) {
switch (attribute) {
case 'style':
return renderStyle(value);
}
-
return value;
}
/**
@@ -961,34 +1561,33 @@
*
* List from: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute.
*/
-
-
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) => {
// The keys are lower-cased for more robust lookup.
map[attribute.toLowerCase()] = attribute;
return map;
}, {});
+
/**
* This is a map of all case-sensitive SVG attributes. Map(lowercase key => proper case attribute).
* The keys are lower-cased for more robust lookup.
* Note that this list only contains attributes that contain at least one capital letter.
* Lowercase attributes don't need mapping, since we lowercase all attributes by default.
*/
-
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) => {
// The keys are lower-cased for more robust lookup.
map[attribute.toLowerCase()] = attribute;
return map;
}, {});
+
/**
* This is a map of all SVG attributes that have colons.
* Keys are lower-cased and stripped of their colons for more robust lookup.
*/
-
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) => {
map[attribute.replace(':', '').toLowerCase()] = attribute;
return map;
}, {});
+
/**
* Returns the normal form of the element's attribute name for HTML.
*
@@ -996,28 +1595,24 @@
*
* @return {string} Normalized attribute name.
*/
-
function getNormalAttributeName(attribute) {
switch (attribute) {
case 'htmlFor':
return 'for';
-
case 'className':
return 'class';
}
-
const attributeLowerCase = attribute.toLowerCase();
-
if (CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]) {
return CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase];
} else if (SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]) {
- return (0,external_lodash_namespaceObject.kebabCase)(SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]);
+ return paramCase(SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]);
} else if (SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]) {
return SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase];
}
-
return attributeLowerCase;
}
+
/**
* Returns the normal form of the style property name for HTML.
*
@@ -1029,19 +1624,16 @@
*
* @return {string} Normalized property name.
*/
-
-
function getNormalStylePropertyName(property) {
- if ((0,external_lodash_namespaceObject.startsWith)(property, '--')) {
+ if (property.startsWith('--')) {
return property;
}
-
if (hasPrefix(property, ['ms', 'O', 'Moz', 'Webkit'])) {
- return '-' + (0,external_lodash_namespaceObject.kebabCase)(property);
+ return '-' + paramCase(property);
}
+ return paramCase(property);
+}
- return (0,external_lodash_namespaceObject.kebabCase)(property);
-}
/**
* Returns the normal form of the style property value for HTML. Appends a
* default pixel unit if numeric, not a unitless property, and not zero.
@@ -1051,15 +1643,13 @@
*
* @return {*} Normalized property value.
*/
-
-
function getNormalStylePropertyValue(property, value) {
if (typeof value === 'number' && 0 !== value && !CSS_PROPERTIES_SUPPORTS_UNITLESS.has(property)) {
return value + 'px';
}
-
return value;
}
+
/**
* Serializes a React element to string.
*
@@ -1069,76 +1659,60 @@
*
* @return {string} Serialized element.
*/
-
-
-function renderElement(element, context) {
- let legacyContext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
-
+function renderElement(element, context, legacyContext = {}) {
if (null === element || undefined === element || false === element) {
return '';
}
-
if (Array.isArray(element)) {
return renderChildren(element, context, legacyContext);
}
-
switch (typeof element) {
case 'string':
return (0,external_wp_escapeHtml_namespaceObject.escapeHTML)(element);
-
case 'number':
return element.toString();
}
-
const {
type,
props
- } =
- /** @type {{type?: any, props?: any}} */
+ } = /** @type {{type?: any, props?: any}} */
element;
-
switch (type) {
case external_React_namespaceObject.StrictMode:
case external_React_namespaceObject.Fragment:
return renderChildren(props.children, context, legacyContext);
-
case RawHTML:
const {
children,
...wrapperProps
} = props;
- return renderNativeComponent((0,external_lodash_namespaceObject.isEmpty)(wrapperProps) ? null : 'div', { ...wrapperProps,
+ return renderNativeComponent(!Object.keys(wrapperProps).length ? null : 'div', {
+ ...wrapperProps,
dangerouslySetInnerHTML: {
__html: children
}
}, context, legacyContext);
}
-
switch (typeof type) {
case 'string':
return renderNativeComponent(type, props, context, legacyContext);
-
case 'function':
if (type.prototype && typeof type.prototype.render === 'function') {
return renderComponent(type, props, context, legacyContext);
}
-
return renderElement(type(props, legacyContext), context, legacyContext);
}
-
switch (type && type.$$typeof) {
case Provider.$$typeof:
return renderChildren(props.children, props.value, legacyContext);
-
case Consumer.$$typeof:
return renderElement(props.children(context || type._currentValue), context, legacyContext);
-
case ForwardRef.$$typeof:
return renderElement(type.render(props), context, legacyContext);
}
-
return '';
}
+
/**
* Serializes a native component type to string.
*
@@ -1150,68 +1724,60 @@
*
* @return {string} Serialized element.
*/
-
-function renderNativeComponent(type, props, context) {
- let legacyContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
+function renderNativeComponent(type, props, context, legacyContext = {}) {
let content = '';
-
if (type === 'textarea' && props.hasOwnProperty('value')) {
// Textarea children can be assigned as value prop. If it is, render in
// place of children. Ensure to omit so it is not assigned as attribute
// as well.
content = renderChildren(props.value, context, legacyContext);
- props = (0,external_lodash_namespaceObject.omit)(props, 'value');
+ const {
+ value,
+ ...restProps
+ } = props;
+ props = restProps;
} else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html === 'string') {
// Dangerous content is left unescaped.
content = props.dangerouslySetInnerHTML.__html;
} else if (typeof props.children !== 'undefined') {
content = renderChildren(props.children, context, legacyContext);
}
-
if (!type) {
return content;
}
-
const attributes = renderAttributes(props);
-
if (SELF_CLOSING_TAGS.has(type)) {
return '<' + type + attributes + '/>';
}
-
return '<' + type + attributes + '>' + content + '' + type + '>';
}
-/** @typedef {import('./react').WPComponent} WPComponent */
+
+/** @typedef {import('react').ComponentType} ComponentType */
/**
* Serializes a non-native component type to string.
*
- * @param {WPComponent} Component Component type to serialize.
- * @param {Object} props Props object.
- * @param {Object} [context] Context object.
- * @param {Object} [legacyContext] Legacy context object.
+ * @param {ComponentType} Component Component type to serialize.
+ * @param {Object} props Props object.
+ * @param {Object} [context] Context object.
+ * @param {Object} [legacyContext] Legacy context object.
*
* @return {string} Serialized element
*/
-
-function renderComponent(Component, props, context) {
- let legacyContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
- const instance = new
- /** @type {import('react').ComponentClass} */
- Component(props, legacyContext);
-
- if (typeof // Ignore reason: Current prettier reformats parens and mangles type assertion
+function renderComponent(Component, props, context, legacyContext = {}) {
+ const instance = new ( /** @type {import('react').ComponentClass} */
+ Component)(props, legacyContext);
+ if (typeof
+ // Ignore reason: Current prettier reformats parens and mangles type assertion
// prettier-ignore
-
/** @type {{getChildContext?: () => unknown}} */
instance.getChildContext === 'function') {
- Object.assign(legacyContext,
- /** @type {{getChildContext?: () => unknown}} */
- instance.getChildContext());
+ Object.assign(legacyContext, /** @type {{getChildContext?: () => unknown}} */instance.getChildContext());
}
-
const html = renderElement(instance.render(), context, legacyContext);
return html;
}
+
/**
* Serializes an array of children to string.
*
@@ -1221,19 +1787,16 @@
*
* @return {string} Serialized children.
*/
-
-function renderChildren(children, context) {
- let legacyContext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
+function renderChildren(children, context, legacyContext = {}) {
let result = '';
- children = (0,external_lodash_namespaceObject.castArray)(children);
-
+ children = Array.isArray(children) ? children : [children];
for (let i = 0; i < children.length; i++) {
const child = children[i];
result += renderElement(child, context, legacyContext);
}
-
return result;
}
+
/**
* Renders a props object as a string of HTML attributes.
*
@@ -1241,57 +1804,51 @@
*
* @return {string} Attributes string.
*/
-
-
function renderAttributes(props) {
let result = '';
-
for (const key in props) {
const attribute = getNormalAttributeName(key);
-
if (!(0,external_wp_escapeHtml_namespaceObject.isValidAttributeName)(attribute)) {
continue;
}
+ let value = getNormalAttributeValue(key, props[key]);
- let value = getNormalAttributeValue(key, props[key]); // If value is not of serializeable type, skip.
-
+ // If value is not of serializable type, skip.
if (!ATTRIBUTES_TYPES.has(typeof value)) {
continue;
- } // Don't render internal attribute names.
-
-
- if (isInternalAttribute(key)) {
- continue;
}
- const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has(attribute); // Boolean attribute should be omitted outright if its value is false.
+ // Don't render internal attribute names.
+ if (isInternalAttribute(key)) {
+ continue;
+ }
+ const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has(attribute);
+ // Boolean attribute should be omitted outright if its value is false.
if (isBooleanAttribute && value === false) {
continue;
}
+ const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ['data-', 'aria-']) || ENUMERATED_ATTRIBUTES.has(attribute);
- const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ['data-', 'aria-']) || ENUMERATED_ATTRIBUTES.has(attribute); // Only write boolean value as attribute if meaningful.
-
+ // Only write boolean value as attribute if meaningful.
if (typeof value === 'boolean' && !isMeaningfulAttribute) {
continue;
}
+ result += ' ' + attribute;
- result += ' ' + attribute; // Boolean attributes should write attribute name, but without value.
+ // Boolean attributes should write attribute name, but without value.
// Mere presence of attribute name is effective truthiness.
-
if (isBooleanAttribute) {
continue;
}
-
if (typeof value === 'string') {
value = (0,external_wp_escapeHtml_namespaceObject.escapeAttribute)(value);
}
-
result += '="' + value + '"';
}
-
return result;
}
+
/**
* Renders a style object as a string attribute value.
*
@@ -1299,36 +1856,29 @@
*
* @return {string} Style attribute value.
*/
-
function renderStyle(style) {
// Only generate from object, e.g. tolerate string value.
- if (!(0,external_lodash_namespaceObject.isPlainObject)(style)) {
+ if (!isPlainObject(style)) {
return style;
}
-
let result;
-
for (const property in style) {
const value = style[property];
-
if (null === value || undefined === value) {
continue;
}
-
if (result) {
result += ';';
} else {
result = '';
}
-
const normalName = getNormalStylePropertyName(property);
const normalValue = getNormalStylePropertyValue(property, value);
result += normalName + ':' + normalValue;
}
-
return result;
}
-/* harmony default export */ var serialize = (renderElement);
+/* harmony default export */ const serialize = (renderElement);
;// CONCATENATED MODULE: ./node_modules/@wordpress/element/build-module/index.js
@@ -1339,6 +1889,8 @@
+})();
+
(window.wp = window.wp || {}).element = __webpack_exports__;
/******/ })()
;
\ No newline at end of file