woocommerce/1397.7925f1d4.iframe.bundle...

915 lines
32 KiB
JavaScript

"use strict";
(self["webpackChunk_woocommerce_storybook"] = self["webpackChunk_woocommerce_storybook"] || []).push([[1397],{
/***/ "../../node_modules/.pnpm/@wordpress+components@19.8.5_@types+react@17.0.71_react-dom@17.0.2_react@17.0.2__react-with-d_oli5xz3n7pc4ztqokra47llglu/node_modules/@wordpress/components/build-module/notice/index.js":
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
A: () => (/* binding */ notice)
});
// EXTERNAL MODULE: ../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js
var react = __webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js");
// EXTERNAL MODULE: ../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js
var lodash = __webpack_require__("../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js");
// EXTERNAL MODULE: ../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js
var classnames = __webpack_require__("../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js");
var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
// EXTERNAL MODULE: ../../node_modules/.pnpm/@wordpress+i18n@4.6.1/node_modules/@wordpress/i18n/build-module/index.js + 3 modules
var build_module = __webpack_require__("../../node_modules/.pnpm/@wordpress+i18n@4.6.1/node_modules/@wordpress/i18n/build-module/index.js");
// EXTERNAL MODULE: ../../node_modules/.pnpm/@wordpress+escape-html@2.47.0/node_modules/@wordpress/escape-html/build-module/index.js + 1 modules
var escape_html_build_module = __webpack_require__("../../node_modules/.pnpm/@wordpress+escape-html@2.47.0/node_modules/@wordpress/escape-html/build-module/index.js");
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+element@4.4.1/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 */
/**
* 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(_ref) {
let {
children,
...props
} = _ref;
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
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+element@4.4.1/node_modules/@wordpress/element/build-module/serialize.js
/**
* 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').WPElement} WPElement */
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,lodash.kebabCase)(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 ((0,lodash.startsWith)(property, '--')) {
return property;
}
if (hasPrefix(property, ['ms', 'O', 'Moz', 'Webkit'])) {
return '-' + (0,lodash.kebabCase)(property);
}
return (0,lodash.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.
*
* @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) {
let legacyContext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (null === element || undefined === element || false === element) {
return '';
}
if (Array.isArray(element)) {
return renderChildren(element, context, legacyContext);
}
switch (typeof element) {
case 'string':
return (0,escape_html_build_module/* escapeHTML */.Zn)(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:
const {
children,
...wrapperProps
} = props;
return renderNativeComponent((0,lodash.isEmpty)(wrapperProps) ? 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) {
let legacyContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
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,lodash.omit)(props, 'value');
} 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 */
/**
* 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.
*
* @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
// 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) {
let legacyContext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
let result = '';
children = (0,lodash.castArray)(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,escape_html_build_module/* isValidAttributeName */.i8)(attribute)) {
continue;
}
let value = getNormalAttributeValue(key, props[key]); // If value is not of serializeable 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,escape_html_build_module/* escapeAttribute */.Gj)(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,lodash.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 */ const serialize = (renderElement);
//# sourceMappingURL=serialize.js.map
// EXTERNAL MODULE: ../../node_modules/.pnpm/@wordpress+a11y@3.6.1/node_modules/@wordpress/a11y/build-module/index.js + 5 modules
var a11y_build_module = __webpack_require__("../../node_modules/.pnpm/@wordpress+a11y@3.6.1/node_modules/@wordpress/a11y/build-module/index.js");
// EXTERNAL MODULE: ../../node_modules/.pnpm/@wordpress+icons@8.4.0/node_modules/@wordpress/icons/build-module/library/close.js
var library_close = __webpack_require__("../../node_modules/.pnpm/@wordpress+icons@8.4.0/node_modules/@wordpress/icons/build-module/library/close.js");
// EXTERNAL MODULE: ../../node_modules/.pnpm/@wordpress+components@19.8.5_@types+react@17.0.71_react-dom@17.0.2_react@17.0.2__react-with-d_oli5xz3n7pc4ztqokra47llglu/node_modules/@wordpress/components/build-module/button/index.js
var build_module_button = __webpack_require__("../../node_modules/.pnpm/@wordpress+components@19.8.5_@types+react@17.0.71_react-dom@17.0.2_react@17.0.2__react-with-d_oli5xz3n7pc4ztqokra47llglu/node_modules/@wordpress/components/build-module/button/index.js");
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+components@19.8.5_@types+react@17.0.71_react-dom@17.0.2_react@17.0.2__react-with-d_oli5xz3n7pc4ztqokra47llglu/node_modules/@wordpress/components/build-module/notice/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('@wordpress/element').WPElement} WPElement */
/**
* Custom hook which announces the message with the given politeness, if a
* valid message is provided.
*
* @param {string|WPElement} [message] Message to announce.
* @param {'polite'|'assertive'} politeness Politeness to announce.
*/
function useSpokenMessage(message, politeness) {
const spokenMessage = typeof message === 'string' ? message : serialize(message);
(0,react.useEffect)(() => {
if (spokenMessage) {
(0,a11y_build_module/* speak */.L)(spokenMessage, politeness);
}
}, [spokenMessage, politeness]);
}
/**
* Given a notice status, returns an assumed default politeness for the status.
* Defaults to 'assertive'.
*
* @param {string} [status] Notice status.
*
* @return {'polite'|'assertive'} Notice politeness.
*/
function getDefaultPoliteness(status) {
switch (status) {
case 'success':
case 'warning':
case 'info':
return 'polite';
case 'error':
default:
return 'assertive';
}
}
function Notice(_ref) {
let {
className,
status = 'info',
children,
spokenMessage = children,
onRemove = lodash.noop,
isDismissible = true,
actions = [],
politeness = getDefaultPoliteness(status),
__unstableHTML,
// onDismiss is a callback executed when the notice is dismissed.
// It is distinct from onRemove, which _looks_ like a callback but is
// actually the function to call to remove the notice from the UI.
onDismiss = lodash.noop
} = _ref;
useSpokenMessage(spokenMessage, politeness);
const classes = classnames_default()(className, 'components-notice', 'is-' + status, {
'is-dismissible': isDismissible
});
if (__unstableHTML) {
children = (0,react.createElement)(RawHTML, null, children);
}
const onDismissNotice = event => {
var _event$preventDefault;
event === null || event === void 0 ? void 0 : (_event$preventDefault = event.preventDefault) === null || _event$preventDefault === void 0 ? void 0 : _event$preventDefault.call(event);
onDismiss();
onRemove();
};
return (0,react.createElement)("div", {
className: classes
}, (0,react.createElement)("div", {
className: "components-notice__content"
}, children, (0,react.createElement)("div", {
className: "components-notice__actions"
}, actions.map((_ref2, index) => {
let {
className: buttonCustomClasses,
label,
isPrimary,
variant,
noDefaultClasses = false,
onClick,
url
} = _ref2;
let computedVariant = variant;
if (variant !== 'primary' && !noDefaultClasses) {
computedVariant = !url ? 'secondary' : 'link';
}
if (typeof computedVariant === 'undefined' && isPrimary) {
computedVariant = 'primary';
}
return (0,react.createElement)(build_module_button/* default */.A, {
key: index,
href: url,
variant: computedVariant,
onClick: url ? undefined : onClick,
className: classnames_default()('components-notice__action', buttonCustomClasses)
}, label);
}))), isDismissible && (0,react.createElement)(build_module_button/* default */.A, {
className: "components-notice__dismiss",
icon: library_close/* default */.A,
label: (0,build_module.__)('Dismiss this notice'),
onClick: onDismissNotice,
showTooltip: false
}));
}
/* harmony default export */ const notice = (Notice);
//# sourceMappingURL=index.js.map
/***/ }),
/***/ "../../node_modules/.pnpm/@wordpress+escape-html@2.47.0/node_modules/@wordpress/escape-html/build-module/index.js":
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
Gj: () => (/* binding */ escapeAttribute),
jG: () => (/* binding */ escapeEditableHTML),
Zn: () => (/* binding */ escapeHTML),
i8: () => (/* binding */ isValidAttributeName)
});
// UNUSED EXPORTS: escapeAmpersand, escapeLessThan, escapeQuotationMark
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+escape-html@2.47.0/node_modules/@wordpress/escape-html/build-module/escape-greater.js
/**
* Returns a string with greater-than sign replaced.
*
* Note that if a resolution for Trac#45387 comes to fruition, it is no longer
* necessary for `__unstableEscapeGreaterThan` to exist.
*
* See: https://core.trac.wordpress.org/ticket/45387
*
* @param {string} value Original string.
*
* @return {string} Escaped string.
*/
function __unstableEscapeGreaterThan(value) {
return value.replace(/>/g, '&gt;');
}
//# sourceMappingURL=escape-greater.js.map
;// CONCATENATED MODULE: ../../node_modules/.pnpm/@wordpress+escape-html@2.47.0/node_modules/@wordpress/escape-html/build-module/index.js
/**
* Internal dependencies
*/
/**
* Regular expression matching invalid attribute names.
*
* "Attribute names must consist of one or more characters other than controls,
* U+0020 SPACE, U+0022 ("), U+0027 ('), U+003E (>), U+002F (/), U+003D (=),
* and noncharacters."
*
* @see https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
*
* @type {RegExp}
*/
const REGEXP_INVALID_ATTRIBUTE_NAME = /[\u007F-\u009F "'>/="\uFDD0-\uFDEF]/;
/**
* Returns a string with ampersands escaped. Note that this is an imperfect
* implementation, where only ampersands which do not appear as a pattern of
* named, decimal, or hexadecimal character references are escaped. Invalid
* named references (i.e. ambiguous ampersand) are still permitted.
*
* @see https://w3c.github.io/html/syntax.html#character-references
* @see https://w3c.github.io/html/syntax.html#ambiguous-ampersand
* @see https://w3c.github.io/html/syntax.html#named-character-references
*
* @param {string} value Original string.
*
* @return {string} Escaped string.
*/
function escapeAmpersand(value) {
return value.replace(/&(?!([a-z0-9]+|#[0-9]+|#x[a-f0-9]+);)/gi, '&amp;');
}
/**
* Returns a string with quotation marks replaced.
*
* @param {string} value Original string.
*
* @return {string} Escaped string.
*/
function escapeQuotationMark(value) {
return value.replace(/"/g, '&quot;');
}
/**
* Returns a string with less-than sign replaced.
*
* @param {string} value Original string.
*
* @return {string} Escaped string.
*/
function escapeLessThan(value) {
return value.replace(/</g, '&lt;');
}
/**
* Returns an escaped attribute value.
*
* @see https://w3c.github.io/html/syntax.html#elements-attributes
*
* "[...] the text cannot contain an ambiguous ampersand [...] must not contain
* any literal U+0022 QUOTATION MARK characters (")"
*
* Note we also escape the greater than symbol, as this is used by wptexturize to
* split HTML strings. This is a WordPress specific fix
*
* Note that if a resolution for Trac#45387 comes to fruition, it is no longer
* necessary for `__unstableEscapeGreaterThan` to be used.
*
* See: https://core.trac.wordpress.org/ticket/45387
*
* @param {string} value Attribute value.
*
* @return {string} Escaped attribute value.
*/
function escapeAttribute(value) {
return __unstableEscapeGreaterThan(escapeQuotationMark(escapeAmpersand(value)));
}
/**
* Returns an escaped HTML element value.
*
* @see https://w3c.github.io/html/syntax.html#writing-html-documents-elements
*
* "the text must not contain the character U+003C LESS-THAN SIGN (<) or an
* ambiguous ampersand."
*
* @param {string} value Element value.
*
* @return {string} Escaped HTML element value.
*/
function escapeHTML(value) {
return escapeLessThan(escapeAmpersand(value));
}
/**
* Returns an escaped Editable HTML element value. This is different from
* `escapeHTML`, because for editable HTML, ALL ampersands must be escaped in
* order to render the content correctly on the page.
*
* @param {string} value Element value.
*
* @return {string} Escaped HTML element value.
*/
function escapeEditableHTML(value) {
return escapeLessThan(value.replace(/&/g, '&amp;'));
}
/**
* Returns true if the given attribute name is valid, or false otherwise.
*
* @param {string} name Attribute name to test.
*
* @return {boolean} Whether attribute is valid.
*/
function isValidAttributeName(name) {
return !REGEXP_INVALID_ATTRIBUTE_NAME.test(name);
}
//# sourceMappingURL=index.js.map
/***/ })
}]);