fix: prevent asset conflicts between React and Grid.js versions

Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

View File

@@ -0,0 +1,315 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = require("./react");
/**
* Internal dependencies
*/
/**
* Object containing a React element.
*
* @typedef {import('react').ReactElement} Element
*/
let indoc, offset, output, stack;
/**
* Matches tags in the localized string
*
* This is used for extracting the tag pattern groups for parsing the localized
* string and along with the map converting it to a react element.
*
* There are four references extracted using this tokenizer:
*
* match: Full match of the tag (i.e. <strong>, </strong>, <br/>)
* 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;
/**
* The stack frame tracking parse progress.
*
* @typedef Frame
*
* @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.
*/
/**
* Tracks recursive-descent parse state.
*
* This is a Stack frame holding parent elements until all children have been
* parsed.
*
* @private
* @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,
tokenStart,
tokenLength,
prevOffset,
leadingTextStart,
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
* the conversion map value.
*
* @example
* For example, for the given string:
*
* "This is a <span>string</span> with <a>a link</a> and a self-closing
* <CustomComponentB/> tag"
*
* You would have something like this as the conversionMap value:
*
* ```js
* {
* span: <span />,
* a: <a href={ 'https://github.com' } />,
* CustomComponentB: <CustomComponent />,
* }
* ```
*
* @param {string} interpolatedString The interpolation string to be parsed.
* @param {Record<string, Element>} conversionMap The map used to convert the string to
* a react element.
* @throws {TypeError}
* @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 React Elements');
}
do {
// twiddle our thumbs
} while (proceed(conversionMap));
return (0, _react.createElement)(_react.Fragment, null, ...output);
};
/**
* Validate conversion map.
*
* A map is considered valid if it's an object and every value in the object
* is a React Element
*
* @private
*
* @param {Object} conversionMap The map being validated.
*
* @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, _react.isValidElement)(element));
};
/**
* This is the iterator over the matches in the string.
*
* @private
*
* @param {Object} conversionMap The conversion map for the string.
*
* @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) {
const {
leadingTextStart: stackLeadingText,
tokenStart
} = 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.
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
// 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);
stackTop.prevOffset = startOffset + tokenLength;
const frame = createFrame(stackTop.element, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength);
frame.children = stackTop.children;
addChild(frame);
offset = startOffset + tokenLength;
return true;
default:
addText();
return false;
}
}
/**
* Grabs the next token match in the string and returns it's details.
*
* @private
*
* @return {Array} An array of details for the token matched.
*/
function nextToken() {
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
* indoc.length and offset.
*
* @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.
*
* @private
*
* @param {Frame} frame The Frame containing the child element and it's
* token information.
*/
function addChild(frame) {
const {
element,
tokenStart,
tokenLength,
prevOffset,
children
} = 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, _react.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.
*
* @private
*
* @param {number} endOffset Offset at which the closing tag for the element
* begins in the string. If this is greater than the
* prevOffset attached to the element, then this
* helps capture any remaining nested text nodes in
* the element.
*/
function closeOuterElement(endOffset) {
const {
element,
leadingTextStart,
prevOffset,
tokenStart,
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, _react.cloneElement)(element, null, ...children));
}
var _default = exports.default = createInterpolateElement;
//# sourceMappingURL=create-interpolate-element.js.map

File diff suppressed because one or more lines are too long

77
node_modules/@wordpress/element/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,77 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {
createInterpolateElement: true,
Platform: true,
renderToString: true,
RawHTML: true
};
Object.defineProperty(exports, "Platform", {
enumerable: true,
get: function () {
return _platform.default;
}
});
Object.defineProperty(exports, "RawHTML", {
enumerable: true,
get: function () {
return _rawHtml.default;
}
});
Object.defineProperty(exports, "createInterpolateElement", {
enumerable: true,
get: function () {
return _createInterpolateElement.default;
}
});
Object.defineProperty(exports, "renderToString", {
enumerable: true,
get: function () {
return _serialize.default;
}
});
var _createInterpolateElement = _interopRequireDefault(require("./create-interpolate-element"));
var _react = require("./react");
Object.keys(_react).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _react[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _react[key];
}
});
});
var _reactPlatform = require("./react-platform");
Object.keys(_reactPlatform).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _reactPlatform[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _reactPlatform[key];
}
});
});
var _utils = require("./utils");
Object.keys(_utils).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _utils[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _utils[key];
}
});
});
var _platform = _interopRequireDefault(require("./platform"));
var _serialize = _interopRequireDefault(require("./serialize"));
var _rawHtml = _interopRequireDefault(require("./raw-html"));
//# sourceMappingURL=index.js.map

1
node_modules/@wordpress/element/build/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"names":["_createInterpolateElement","_interopRequireDefault","require","_react","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_reactPlatform","_utils","_platform","_serialize","_rawHtml"],"sources":["@wordpress/element/src/index.js"],"sourcesContent":["export { default as createInterpolateElement } from './create-interpolate-element';\nexport * from './react';\nexport * from './react-platform';\nexport * from './utils';\nexport { default as Platform } from './platform';\nexport { default as renderToString } from './serialize';\nexport { default as RawHTML } from './raw-html';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,yBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,cAAA,GAAAd,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAW,cAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,cAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,cAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AACA,IAAAU,MAAA,GAAAf,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAY,MAAA,EAAAX,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAU,MAAA,CAAAV,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,MAAA,CAAAV,GAAA;IAAA;EAAA;AAAA;AACA,IAAAW,SAAA,GAAAjB,sBAAA,CAAAC,OAAA;AACA,IAAAiB,UAAA,GAAAlB,sBAAA,CAAAC,OAAA;AACA,IAAAkB,QAAA,GAAAnB,sBAAA,CAAAC,OAAA","ignoreList":[]}

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
/**
* External dependencies
*/
const Platform = {
..._reactNative.Platform,
OS: 'native',
select: spec => {
if ('android' in spec) {
return spec.android;
} else if ('native' in spec) {
return spec.native;
}
return spec.default;
},
isNative: true,
isAndroid: true
};
var _default = exports.default = Platform;
//# sourceMappingURL=platform.android.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_reactNative","require","Platform","OriginalPlatform","OS","select","spec","android","native","default","isNative","isAndroid","_default","exports"],"sources":["@wordpress/element/src/platform.android.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Platform as OriginalPlatform } from 'react-native';\n\nconst Platform = {\n\t...OriginalPlatform,\n\tOS: 'native',\n\tselect: ( spec ) => {\n\t\tif ( 'android' in spec ) {\n\t\t\treturn spec.android;\n\t\t} else if ( 'native' in spec ) {\n\t\t\treturn spec.native;\n\t\t}\n\t\treturn spec.default;\n\t},\n\tisNative: true,\n\tisAndroid: true,\n};\n\nexport default Platform;\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,QAAQ,GAAG;EAChB,GAAGC,qBAAgB;EACnBC,EAAE,EAAE,QAAQ;EACZC,MAAM,EAAIC,IAAI,IAAM;IACnB,IAAK,SAAS,IAAIA,IAAI,EAAG;MACxB,OAAOA,IAAI,CAACC,OAAO;IACpB,CAAC,MAAM,IAAK,QAAQ,IAAID,IAAI,EAAG;MAC9B,OAAOA,IAAI,CAACE,MAAM;IACnB;IACA,OAAOF,IAAI,CAACG,OAAO;EACpB,CAAC;EACDC,QAAQ,EAAE,IAAI;EACdC,SAAS,EAAE;AACZ,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAJ,OAAA,GAEaP,QAAQ","ignoreList":[]}

27
node_modules/@wordpress/element/build/platform.ios.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
/**
* External dependencies
*/
const Platform = {
..._reactNative.Platform,
OS: 'native',
select: spec => {
if ('ios' in spec) {
return spec.ios;
} else if ('native' in spec) {
return spec.native;
}
return spec.default;
},
isNative: true,
isIOS: true
};
var _default = exports.default = Platform;
//# sourceMappingURL=platform.ios.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_reactNative","require","Platform","OriginalPlatform","OS","select","spec","ios","native","default","isNative","isIOS","_default","exports"],"sources":["@wordpress/element/src/platform.ios.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { Platform as OriginalPlatform } from 'react-native';\n\nconst Platform = {\n\t...OriginalPlatform,\n\tOS: 'native',\n\tselect: ( spec ) => {\n\t\tif ( 'ios' in spec ) {\n\t\t\treturn spec.ios;\n\t\t} else if ( 'native' in spec ) {\n\t\t\treturn spec.native;\n\t\t}\n\t\treturn spec.default;\n\t},\n\tisNative: true,\n\tisIOS: true,\n};\n\nexport default Platform;\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,QAAQ,GAAG;EAChB,GAAGC,qBAAgB;EACnBC,EAAE,EAAE,QAAQ;EACZC,MAAM,EAAIC,IAAI,IAAM;IACnB,IAAK,KAAK,IAAIA,IAAI,EAAG;MACpB,OAAOA,IAAI,CAACC,GAAG;IAChB,CAAC,MAAM,IAAK,QAAQ,IAAID,IAAI,EAAG;MAC9B,OAAOA,IAAI,CAACE,MAAM;IACnB;IACA,OAAOF,IAAI,CAACG,OAAO;EACpB,CAAC;EACDC,QAAQ,EAAE,IAAI;EACdC,KAAK,EAAE;AACR,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAJ,OAAA,GAEaP,QAAQ","ignoreList":[]}

40
node_modules/@wordpress/element/build/platform.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* Parts of this source were derived and modified from react-native-web,
* released under the MIT license.
*
* Copyright (c) 2016-present, Nicolas Gallagher.
* Copyright (c) 2015-present, Facebook, Inc.
*
*/
const Platform = {
OS: 'web',
select: spec => 'web' in spec ? spec.web : spec.default,
isWeb: true
};
/**
* Component used to detect the current Platform being used.
* Use Platform.OS === 'web' to detect if running on web enviroment.
*
* This is the same concept as the React Native implementation.
*
* @see https://reactnative.dev/docs/platform-specific-code#platform-module
*
* Here is an example of how to use the select method:
* @example
* ```js
* import { Platform } from '@wordpress/element';
*
* const placeholderLabel = Platform.select( {
* native: __( 'Add media' ),
* web: __( 'Drag images, upload new ones or select files from your library.' ),
* } );
* ```
*/
var _default = exports.default = Platform;
//# sourceMappingURL=platform.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["Platform","OS","select","spec","web","default","isWeb","_default","exports"],"sources":["@wordpress/element/src/platform.js"],"sourcesContent":["/**\n * Parts of this source were derived and modified from react-native-web,\n * released under the MIT license.\n *\n * Copyright (c) 2016-present, Nicolas Gallagher.\n * Copyright (c) 2015-present, Facebook, Inc.\n *\n */\nconst Platform = {\n\tOS: 'web',\n\tselect: ( spec ) => ( 'web' in spec ? spec.web : spec.default ),\n\tisWeb: true,\n};\n/**\n * Component used to detect the current Platform being used.\n * Use Platform.OS === 'web' to detect if running on web enviroment.\n *\n * This is the same concept as the React Native implementation.\n *\n * @see https://reactnative.dev/docs/platform-specific-code#platform-module\n *\n * Here is an example of how to use the select method:\n * @example\n * ```js\n * import { Platform } from '@wordpress/element';\n *\n * const placeholderLabel = Platform.select( {\n * native: __( 'Add media' ),\n * web: __( 'Drag images, upload new ones or select files from your library.' ),\n * } );\n * ```\n */\nexport default Platform;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAQ,GAAG;EAChBC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAIC,IAAI,IAAQ,KAAK,IAAIA,IAAI,GAAGA,IAAI,CAACC,GAAG,GAAGD,IAAI,CAACE,OAAS;EAC/DC,KAAK,EAAE;AACR,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAlBA,IAAAC,QAAA,GAAAC,OAAA,CAAAH,OAAA,GAmBeL,QAAQ","ignoreList":[]}

48
node_modules/@wordpress/element/build/raw-html.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = RawHTML;
var _react = require("./react");
/**
* Internal dependencies
*/
/** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */
/**
* Component used as equivalent of Fragment with unescaped HTML, in cases where
* it is desirable to render dangerous HTML without needing a wrapper element.
* To preserve additional props, a `div` wrapper _will_ be created if any props
* aside from `children` are passed.
*
* @param {RawHTMLProps} props Children should be a string of HTML or an array
* of strings. Other props will be passed through
* to the div wrapper.
*
* @return {JSX.Element} Dangerously-rendering component.
*/
function RawHTML({
children,
...props
}) {
let rawHtml = '';
// Cast children as an array, and concatenate each element if it is a string.
_react.Children.toArray(children).forEach(child => {
if (typeof child === 'string' && child.trim() !== '') {
rawHtml += child;
}
});
// The `div` wrapper will be stripped by the `renderElement` serializer in
// `./serialize.js` unless there are non-children props present.
return (0, _react.createElement)('div', {
dangerouslySetInnerHTML: {
__html: rawHtml
},
...props
});
}
//# sourceMappingURL=raw-html.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_react","require","RawHTML","children","props","rawHtml","Children","toArray","forEach","child","trim","createElement","dangerouslySetInnerHTML","__html"],"sources":["@wordpress/element/src/raw-html.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { Children, createElement } from './react';\n\n/** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */\n\n/**\n * Component used as equivalent of Fragment with unescaped HTML, in cases where\n * it is desirable to render dangerous HTML without needing a wrapper element.\n * To preserve additional props, a `div` wrapper _will_ be created if any props\n * aside from `children` are passed.\n *\n * @param {RawHTMLProps} props Children should be a string of HTML or an array\n * of strings. Other props will be passed through\n * to the div wrapper.\n *\n * @return {JSX.Element} Dangerously-rendering component.\n */\nexport default function RawHTML( { children, ...props } ) {\n\tlet rawHtml = '';\n\n\t// Cast children as an array, and concatenate each element if it is a string.\n\tChildren.toArray( children ).forEach( ( child ) => {\n\t\tif ( typeof child === 'string' && child.trim() !== '' ) {\n\t\t\trawHtml += child;\n\t\t}\n\t} );\n\n\t// The `div` wrapper will be stripped by the `renderElement` serializer in\n\t// `./serialize.js` unless there are non-children props present.\n\treturn createElement( 'div', {\n\t\tdangerouslySetInnerHTML: { __html: rawHtml },\n\t\t...props,\n\t} );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,OAAOA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAG;EACzD,IAAIC,OAAO,GAAG,EAAE;;EAEhB;EACAC,eAAQ,CAACC,OAAO,CAAEJ,QAAS,CAAC,CAACK,OAAO,CAAIC,KAAK,IAAM;IAClD,IAAK,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAG;MACvDL,OAAO,IAAII,KAAK;IACjB;EACD,CAAE,CAAC;;EAEH;EACA;EACA,OAAO,IAAAE,oBAAa,EAAE,KAAK,EAAE;IAC5BC,uBAAuB,EAAE;MAAEC,MAAM,EAAER;IAAQ,CAAC;IAC5C,GAAGD;EACJ,CAAE,CAAC;AACJ","ignoreList":[]}

View File

@@ -0,0 +1,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "createPortal", {
enumerable: true,
get: function () {
return _reactDom.createPortal;
}
});
Object.defineProperty(exports, "createRoot", {
enumerable: true,
get: function () {
return _client.createRoot;
}
});
Object.defineProperty(exports, "findDOMNode", {
enumerable: true,
get: function () {
return _reactDom.findDOMNode;
}
});
Object.defineProperty(exports, "flushSync", {
enumerable: true,
get: function () {
return _reactDom.flushSync;
}
});
Object.defineProperty(exports, "hydrate", {
enumerable: true,
get: function () {
return _reactDom.hydrate;
}
});
Object.defineProperty(exports, "hydrateRoot", {
enumerable: true,
get: function () {
return _client.hydrateRoot;
}
});
Object.defineProperty(exports, "render", {
enumerable: true,
get: function () {
return _reactDom.render;
}
});
Object.defineProperty(exports, "unmountComponentAtNode", {
enumerable: true,
get: function () {
return _reactDom.unmountComponentAtNode;
}
});
var _reactDom = require("react-dom");
var _client = require("react-dom/client");
//# sourceMappingURL=react-platform.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_reactDom","require","_client"],"sources":["@wordpress/element/src/react-platform.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tcreatePortal,\n\tfindDOMNode,\n\tflushSync,\n\trender,\n\thydrate,\n\tunmountComponentAtNode,\n} from 'react-dom';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\n\n/**\n * Creates a portal into which a component can be rendered.\n *\n * @see https://github.com/facebook/react/issues/10309#issuecomment-318433235\n *\n * @param {import('react').ReactElement} child Any renderable child, such as an element,\n * string, or fragment.\n * @param {HTMLElement} container DOM node into which element should be rendered.\n */\nexport { createPortal };\n\n/**\n * Finds the dom node of a React component.\n *\n * @param {import('react').ComponentType} component Component's instance.\n */\nexport { findDOMNode };\n\n/**\n * Forces React to flush any updates inside the provided callback synchronously.\n *\n * @param {Function} callback Callback to run synchronously.\n */\nexport { flushSync };\n\n/**\n * Renders a given element into the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `createRoot` instead.\n * @see https://react.dev/reference/react-dom/render\n */\nexport { render };\n\n/**\n * Hydrates a given element into the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `hydrateRoot` instead.\n * @see https://react.dev/reference/react-dom/hydrate\n */\nexport { hydrate };\n\n/**\n * Creates a new React root for the target DOM node.\n *\n * @since 6.2.0 Introduced in WordPress core.\n * @see https://react.dev/reference/react-dom/client/createRoot\n */\nexport { createRoot };\n\n/**\n * Creates a new React root for the target DOM node and hydrates it with a pre-generated markup.\n *\n * @since 6.2.0 Introduced in WordPress core.\n * @see https://react.dev/reference/react-dom/client/hydrateRoot\n */\nexport { hydrateRoot };\n\n/**\n * Removes any mounted element from the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `root.unmount()` instead.\n * @see https://react.dev/reference/react-dom/unmountComponentAtNode\n */\nexport { unmountComponentAtNode };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAQA,IAAAC,OAAA,GAAAD,OAAA","ignoreList":[]}

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.registerComponent = void 0;
var _reactNative = require("react-native");
/**
* External dependencies
*/
/**
* Registers an app root component allowing the native system to run the app.
*
* @param {string} appKey Unique app name identifier.
* @param {Function} componentProvider Function returning the app root React component.
*/
const registerComponent = (appKey, componentProvider) => {
_reactNative.AppRegistry.registerComponent(appKey, componentProvider);
};
exports.registerComponent = registerComponent;
//# sourceMappingURL=react-platform.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_reactNative","require","registerComponent","appKey","componentProvider","AppRegistry","exports"],"sources":["@wordpress/element/src/react-platform.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { AppRegistry } from 'react-native';\n\n/**\n * Registers an app root component allowing the native system to run the app.\n *\n * @param {string} appKey Unique app name identifier.\n * @param {Function} componentProvider Function returning the app root React component.\n */\nexport const registerComponent = ( appKey, componentProvider ) => {\n\tAppRegistry.registerComponent( appKey, componentProvider );\n};\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,iBAAiB,GAAGA,CAAEC,MAAM,EAAEC,iBAAiB,KAAM;EACjEC,wBAAW,CAACH,iBAAiB,CAAEC,MAAM,EAAEC,iBAAkB,CAAC;AAC3D,CAAC;AAACE,OAAA,CAAAJ,iBAAA,GAAAA,iBAAA","ignoreList":[]}

419
node_modules/@wordpress/element/build/react.js generated vendored Normal file
View File

@@ -0,0 +1,419 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Children", {
enumerable: true,
get: function () {
return _react.Children;
}
});
Object.defineProperty(exports, "Component", {
enumerable: true,
get: function () {
return _react.Component;
}
});
Object.defineProperty(exports, "Fragment", {
enumerable: true,
get: function () {
return _react.Fragment;
}
});
Object.defineProperty(exports, "PureComponent", {
enumerable: true,
get: function () {
return _react.PureComponent;
}
});
Object.defineProperty(exports, "StrictMode", {
enumerable: true,
get: function () {
return _react.StrictMode;
}
});
Object.defineProperty(exports, "Suspense", {
enumerable: true,
get: function () {
return _react.Suspense;
}
});
Object.defineProperty(exports, "cloneElement", {
enumerable: true,
get: function () {
return _react.cloneElement;
}
});
exports.concatChildren = concatChildren;
Object.defineProperty(exports, "createContext", {
enumerable: true,
get: function () {
return _react.createContext;
}
});
Object.defineProperty(exports, "createElement", {
enumerable: true,
get: function () {
return _react.createElement;
}
});
Object.defineProperty(exports, "createRef", {
enumerable: true,
get: function () {
return _react.createRef;
}
});
Object.defineProperty(exports, "forwardRef", {
enumerable: true,
get: function () {
return _react.forwardRef;
}
});
Object.defineProperty(exports, "isValidElement", {
enumerable: true,
get: function () {
return _react.isValidElement;
}
});
Object.defineProperty(exports, "lazy", {
enumerable: true,
get: function () {
return _react.lazy;
}
});
Object.defineProperty(exports, "memo", {
enumerable: true,
get: function () {
return _react.memo;
}
});
Object.defineProperty(exports, "startTransition", {
enumerable: true,
get: function () {
return _react.startTransition;
}
});
exports.switchChildrenNodeName = switchChildrenNodeName;
Object.defineProperty(exports, "useCallback", {
enumerable: true,
get: function () {
return _react.useCallback;
}
});
Object.defineProperty(exports, "useContext", {
enumerable: true,
get: function () {
return _react.useContext;
}
});
Object.defineProperty(exports, "useDebugValue", {
enumerable: true,
get: function () {
return _react.useDebugValue;
}
});
Object.defineProperty(exports, "useDeferredValue", {
enumerable: true,
get: function () {
return _react.useDeferredValue;
}
});
Object.defineProperty(exports, "useEffect", {
enumerable: true,
get: function () {
return _react.useEffect;
}
});
Object.defineProperty(exports, "useId", {
enumerable: true,
get: function () {
return _react.useId;
}
});
Object.defineProperty(exports, "useImperativeHandle", {
enumerable: true,
get: function () {
return _react.useImperativeHandle;
}
});
Object.defineProperty(exports, "useInsertionEffect", {
enumerable: true,
get: function () {
return _react.useInsertionEffect;
}
});
Object.defineProperty(exports, "useLayoutEffect", {
enumerable: true,
get: function () {
return _react.useLayoutEffect;
}
});
Object.defineProperty(exports, "useMemo", {
enumerable: true,
get: function () {
return _react.useMemo;
}
});
Object.defineProperty(exports, "useReducer", {
enumerable: true,
get: function () {
return _react.useReducer;
}
});
Object.defineProperty(exports, "useRef", {
enumerable: true,
get: function () {
return _react.useRef;
}
});
Object.defineProperty(exports, "useState", {
enumerable: true,
get: function () {
return _react.useState;
}
});
Object.defineProperty(exports, "useSyncExternalStore", {
enumerable: true,
get: function () {
return _react.useSyncExternalStore;
}
});
Object.defineProperty(exports, "useTransition", {
enumerable: true,
get: function () {
return _react.useTransition;
}
});
var _react = require("react");
/**
* External dependencies
*/
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
/**
* Object containing a React element.
*
* @typedef {import('react').ReactElement} Element
*/
/**
* Object containing a React component.
*
* @typedef {import('react').ComponentType} ComponentType
*/
/**
* Object containing a React synthetic event.
*
* @typedef {import('react').SyntheticEvent} SyntheticEvent
*/
/**
* Object containing a React synthetic event.
*
* @template T
* @typedef {import('react').RefObject<T>} RefObject<T>
*/
/**
* Object that provides utilities for dealing with React children.
*/
/**
* Creates a copy of an element with extended props.
*
* @param {Element} element Element
* @param {?Object} props Props to apply to cloned element
*
* @return {Element} Cloned element.
*/
/**
* A base class to create WordPress Components (Refs, state and lifecycle hooks)
*/
/**
* Creates a context object containing two components: a provider and consumer.
*
* @param {Object} defaultValue A default data stored in the context.
*
* @return {Object} Context object.
*/
/**
* Returns a new element of given type. Type can be either a string tag name or
* another function which itself returns an element.
*
* @param {?(string|Function)} type Tag name or element creator
* @param {Object} props Element properties, either attribute
* set to apply to DOM node or values to
* pass through to element creator
* @param {...Element} children Descendant elements
*
* @return {Element} Element.
*/
/**
* Returns an object tracking a reference to a rendered element via its
* `current` property as either a DOMElement or Element, dependent upon the
* type of element rendered with the ref attribute.
*
* @return {Object} Ref object.
*/
/**
* Component enhancer used to enable passing a ref to its wrapped component.
* Pass a function argument which receives `props` and `ref` as its arguments,
* returning an element using the forwarded ref. The return value is a new
* component which forwards its ref.
*
* @param {Function} forwarder Function passed `props` and `ref`, expected to
* return an element.
*
* @return {Component} Enhanced component.
*/
/**
* A component which renders its children without any wrapping element.
*/
/**
* 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 React Element and false otherwise.
*/
/**
* @see https://reactjs.org/docs/react-api.html#reactmemo
*/
/**
* Component that activates additional checks and warnings for its descendants.
*/
/**
* @see https://reactjs.org/docs/hooks-reference.html#usecallback
*/
/**
* @see https://reactjs.org/docs/hooks-reference.html#usecontext
*/
/**
* @see https://reactjs.org/docs/hooks-reference.html#usedebugvalue
*/
/**
* @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
*/
/**
* @see https://reactjs.org/docs/hooks-reference.html#usememo
*/
/**
* @see https://reactjs.org/docs/hooks-reference.html#usereducer
*/
/**
* @see https://reactjs.org/docs/hooks-reference.html#useref
*/
/**
* @see https://reactjs.org/docs/hooks-reference.html#usestate
*/
/**
* @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
*/
/**
* @see https://reactjs.org/docs/react-api.html#reactsuspense
*/
/**
* @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(...childrenArguments) {
return childrenArguments.reduce((accumulator, children, i) => {
_react.Children.forEach(children, (child, j) => {
if (child && 'string' !== typeof child) {
child = (0, _react.cloneElement)(child, {
key: [i, j].join()
});
}
accumulator.push(child);
});
return accumulator;
}, []);
}
/**
* Switches the nodeName of all the elements in the children object.
*
* @param {?Object} children Children object.
* @param {string} nodeName Node name.
*
* @return {?Object} The updated children object.
*/
function switchChildrenNodeName(children, nodeName) {
return children && _react.Children.map(children, (elt, index) => {
if (typeof elt?.valueOf() === 'string') {
return (0, _react.createElement)(nodeName, {
key: index
}, elt);
}
const {
children: childrenProp,
...props
} = elt.props;
return (0, _react.createElement)(nodeName, {
key: index,
...props
}, childrenProp);
});
}
//# sourceMappingURL=react.js.map

1
node_modules/@wordpress/element/build/react.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

505
node_modules/@wordpress/element/build/serialize.js generated vendored Normal file
View File

@@ -0,0 +1,505 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports.hasPrefix = hasPrefix;
exports.renderAttributes = renderAttributes;
exports.renderComponent = renderComponent;
exports.renderElement = renderElement;
exports.renderNativeComponent = renderNativeComponent;
exports.renderStyle = renderStyle;
var _isPlainObject = require("is-plain-object");
var _changeCase = require("change-case");
var _escapeHtml = require("@wordpress/escape-html");
var _react = require("./react");
var _rawHtml = _interopRequireDefault(require("./raw-html"));
/**
* Parts of this source were derived and modified from fast-react-render,
* released under the MIT license.
*
* https://github.com/alt-j/fast-react-render
*
* Copyright (c) 2016 Andrey Morozov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('react').ReactElement} ReactElement */
const {
Provider,
Consumer
} = (0, _react.createContext)(undefined);
const ForwardRef = (0, _react.forwardRef)(() => {
return null;
});
/**
* Valid attribute types.
*
* @type {Set<string>}
*/
const ATTRIBUTES_TYPES = new Set(['string', 'boolean', 'number']);
/**
* Element tags which can be self-closing.
*
* @type {Set<string>}
*/
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.
*
* See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
* Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
*
* Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
* .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )
* .reduce( ( result, tr ) => Object.assign( result, {
* [ tr.firstChild.textContent.trim() ]: true
* } ), {} ) ).sort();
*
* @type {Set<string>}
*/
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
* valid enumerated value.
*
* See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute
* Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
*
* Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
* .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) )
* .reduce( ( result, tr ) => Object.assign( result, {
* [ tr.firstChild.textContent.trim() ]: true
* } ), {} ) ).sort();
*
* Some notable omissions:
*
* - `alt`: https://blog.whatwg.org/omit-alt
*
* @type {Set<string>}
*/
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
* property is included in this set or value is zero.
*
* Generated via:
*
* Object.entries( document.createElement( 'div' ).style )
* .filter( ( [ key ] ) => (
* ! /^(webkit|ms|moz)/.test( key ) &&
* ( e.style[ key ] = 10 ) &&
* e.style[ key ] === '10'
* ) )
* .map( ( [ key ] ) => key )
* .sort();
*
* @type {Set<string>}
*/
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.
*
* @param {string} string String to check.
* @param {string[]} prefixes Possible prefixes.
*
* @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.
*
* @param {string} attribute Attribute to check.
*
* @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.
*
* @param {string} attribute Attribute name.
* @param {*} value Non-normalized attribute value.
*
* @return {*} Normalized attribute value.
*/
function getNormalAttributeValue(attribute, value) {
switch (attribute) {
case 'style':
return renderStyle(value);
}
return value;
}
/**
* This is a map of all SVG attributes that have dashes. Map(lower case prop => dashed lower case attribute).
* We need this to render e.g strokeWidth as stroke-width.
*
* 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.
*
* @param {string} attribute Non-normalized attribute name.
*
* @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, _changeCase.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.
*
* - Converts property names to kebab-case, e.g. 'backgroundColor' → 'background-color'
* - Leaves custom attributes alone, e.g. '--myBackgroundColor' → '--myBackgroundColor'
* - Converts vendor-prefixed property names to -kebab-case, e.g. 'MozTransform' → '-moz-transform'
*
* @param {string} property Property name.
*
* @return {string} Normalized property name.
*/
function getNormalStylePropertyName(property) {
if (property.startsWith('--')) {
return property;
}
if (hasPrefix(property, ['ms', 'O', 'Moz', 'Webkit'])) {
return '-' + (0, _changeCase.paramCase)(property);
}
return (0, _changeCase.paramCase)(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.
*
* @param {string} property Property name.
* @param {*} value Non-normalized property value.
*
* @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.
*
* @param {import('react').ReactNode} element Element to serialize.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*
* @return {string} Serialized element.
*/
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, _escapeHtml.escapeHTML)(element);
case 'number':
return element.toString();
}
const {
type,
props
} = /** @type {{type?: any, props?: any}} */
element;
switch (type) {
case _react.StrictMode:
case _react.Fragment:
return renderChildren(props.children, context, legacyContext);
case _rawHtml.default:
const {
children,
...wrapperProps
} = props;
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.
*
* @param {?string} type Native component type to serialize, or null if
* rendering as fragment of children content.
* @param {Object} props Props object.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*
* @return {string} Serialized element.
*/
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);
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').ComponentType} ComponentType */
/**
* Serializes a non-native component type to string.
*
* @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, 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());
}
const html = renderElement(instance.render(), context, legacyContext);
return html;
}
/**
* Serializes an array of children to string.
*
* @param {import('react').ReactNodeArray} children Children to serialize.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*
* @return {string} Serialized children.
*/
function renderChildren(children, context, legacyContext = {}) {
let result = '';
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.
*
* @param {Object} props Props object.
*
* @return {string} Attributes string.
*/
function renderAttributes(props) {
let result = '';
for (const key in props) {
const attribute = getNormalAttributeName(key);
if (!(0, _escapeHtml.isValidAttributeName)(attribute)) {
continue;
}
let value = getNormalAttributeValue(key, props[key]);
// 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.
if (isBooleanAttribute && value === false) {
continue;
}
const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ['data-', 'aria-']) || ENUMERATED_ATTRIBUTES.has(attribute);
// Only write boolean value as attribute if meaningful.
if (typeof value === 'boolean' && !isMeaningfulAttribute) {
continue;
}
result += ' ' + attribute;
// 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, _escapeHtml.escapeAttribute)(value);
}
result += '="' + value + '"';
}
return result;
}
/**
* Renders a style object as a string attribute value.
*
* @param {Object} style Style object.
*
* @return {string} Style attribute value.
*/
function renderStyle(style) {
// Only generate from object, e.g. tolerate string value.
if (!(0, _isPlainObject.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;
}
var _default = exports.default = renderElement;
//# sourceMappingURL=serialize.js.map

File diff suppressed because one or more lines are too long

23
node_modules/@wordpress/element/build/utils.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isEmptyElement = void 0;
/**
* 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 (typeof element === 'number') {
return false;
}
if (typeof element?.valueOf() === 'string' || Array.isArray(element)) {
return !element.length;
}
return !element;
};
exports.isEmptyElement = isEmptyElement;
//# sourceMappingURL=utils.js.map

1
node_modules/@wordpress/element/build/utils.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"names":["isEmptyElement","element","valueOf","Array","isArray","length","exports"],"sources":["@wordpress/element/src/utils.js"],"sourcesContent":["/**\n * Checks if the provided WP element is empty.\n *\n * @param {*} element WP element to check.\n * @return {boolean} True when an element is considered empty.\n */\nexport const isEmptyElement = ( element ) => {\n\tif ( typeof element === 'number' ) {\n\t\treturn false;\n\t}\n\n\tif ( typeof element?.valueOf() === 'string' || Array.isArray( element ) ) {\n\t\treturn ! element.length;\n\t}\n\n\treturn ! element;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,GAAKC,OAAO,IAAM;EAC5C,IAAK,OAAOA,OAAO,KAAK,QAAQ,EAAG;IAClC,OAAO,KAAK;EACb;EAEA,IAAK,OAAOA,OAAO,EAAEC,OAAO,CAAC,CAAC,KAAK,QAAQ,IAAIC,KAAK,CAACC,OAAO,CAAEH,OAAQ,CAAC,EAAG;IACzE,OAAO,CAAEA,OAAO,CAACI,MAAM;EACxB;EAEA,OAAO,CAAEJ,OAAO;AACjB,CAAC;AAACK,OAAA,CAAAN,cAAA,GAAAA,cAAA","ignoreList":[]}