@wordpress/components 32.5.0 → 32.5.2-next.v.202604091042.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -2
- package/CHANGELOG.md +20 -0
- package/README.md +18 -4
- package/build/autocomplete/autocompleter-ui.cjs +75 -79
- package/build/autocomplete/autocompleter-ui.cjs.map +2 -2
- package/build/autocomplete/get-autocomplete-match.cjs +91 -0
- package/build/autocomplete/get-autocomplete-match.cjs.map +7 -0
- package/build/autocomplete/index.cjs +104 -107
- package/build/autocomplete/index.cjs.map +3 -3
- package/build/box-control/index.cjs +0 -8
- package/build/box-control/index.cjs.map +2 -2
- package/build/box-control/utils.cjs +1 -10
- package/build/box-control/utils.cjs.map +2 -2
- package/build/calendar/utils/use-localization-props.cjs +3 -2
- package/build/calendar/utils/use-localization-props.cjs.map +2 -2
- package/build/custom-select-control/index.cjs.map +3 -3
- package/build/custom-select-control-v2/custom-select.cjs +2 -2
- package/build/custom-select-control-v2/custom-select.cjs.map +2 -2
- package/build/custom-select-control-v2/index.cjs.map +3 -3
- package/build/sandbox/index.cjs +2 -2
- package/build/sandbox/index.cjs.map +2 -2
- package/build/validated-form-controls/control-with-error.cjs +12 -8
- package/build/validated-form-controls/control-with-error.cjs.map +2 -2
- package/build-module/autocomplete/autocompleter-ui.mjs +74 -78
- package/build-module/autocomplete/autocompleter-ui.mjs.map +2 -2
- package/build-module/autocomplete/get-autocomplete-match.mjs +56 -0
- package/build-module/autocomplete/get-autocomplete-match.mjs.map +7 -0
- package/build-module/autocomplete/index.mjs +103 -107
- package/build-module/autocomplete/index.mjs.map +3 -3
- package/build-module/box-control/index.mjs +1 -9
- package/build-module/box-control/index.mjs.map +2 -2
- package/build-module/box-control/utils.mjs +1 -9
- package/build-module/box-control/utils.mjs.map +2 -2
- package/build-module/calendar/utils/use-localization-props.mjs +3 -2
- package/build-module/calendar/utils/use-localization-props.mjs.map +2 -2
- package/build-module/custom-select-control/index.mjs +2 -2
- package/build-module/custom-select-control/index.mjs.map +2 -2
- package/build-module/custom-select-control-v2/custom-select.mjs +2 -2
- package/build-module/custom-select-control-v2/custom-select.mjs.map +2 -2
- package/build-module/custom-select-control-v2/index.mjs +2 -2
- package/build-module/custom-select-control-v2/index.mjs.map +2 -2
- package/build-module/sandbox/index.mjs +2 -2
- package/build-module/sandbox/index.mjs.map +2 -2
- package/build-module/validated-form-controls/control-with-error.mjs +12 -8
- package/build-module/validated-form-controls/control-with-error.mjs.map +2 -2
- package/build-style/style-rtl.css +0 -3
- package/build-style/style.css +0 -3
- package/build-types/autocomplete/autocompleter-ui.d.ts +2 -2
- package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
- package/build-types/autocomplete/get-autocomplete-match.d.ts +11 -0
- package/build-types/autocomplete/get-autocomplete-match.d.ts.map +1 -0
- package/build-types/autocomplete/index.d.ts +8 -0
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/autocomplete/test/get-autocomplete-match.d.ts +2 -0
- package/build-types/autocomplete/test/get-autocomplete-match.d.ts.map +1 -0
- package/build-types/autocomplete/types.d.ts +23 -9
- package/build-types/autocomplete/types.d.ts.map +1 -1
- package/build-types/box-control/index.d.ts.map +1 -1
- package/build-types/box-control/utils.d.ts +7 -16
- package/build-types/box-control/utils.d.ts.map +1 -1
- package/build-types/button/stories/index.story.d.ts +0 -1
- package/build-types/button/stories/index.story.d.ts.map +1 -1
- package/build-types/calendar/utils/use-localization-props.d.ts +3 -3
- package/build-types/calendar/utils/use-localization-props.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/constants.d.ts +2 -2
- package/build-types/custom-select-control-v2/custom-select.d.ts +3 -3
- package/build-types/custom-select-control-v2/custom-select.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/types.d.ts +1 -1
- package/build-types/custom-select-control-v2/types.d.ts.map +1 -1
- package/build-types/font-size-picker/constants.d.ts +2 -2
- package/build-types/font-size-picker/constants.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts +1 -1
- package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/alignment-matrix-control/README.md +1 -1
- package/src/angle-picker-control/style.module.scss +1 -0
- package/src/autocomplete/README.md +2 -2
- package/src/autocomplete/autocompleter-ui.native.js +166 -173
- package/src/autocomplete/autocompleter-ui.tsx +114 -116
- package/src/autocomplete/get-autocomplete-match.ts +115 -0
- package/src/autocomplete/index.tsx +129 -208
- package/src/autocomplete/test/get-autocomplete-match.ts +338 -0
- package/src/autocomplete/test/index.tsx +112 -4
- package/src/autocomplete/types.ts +17 -10
- package/src/box-control/index.tsx +1 -19
- package/src/box-control/utils.ts +1 -19
- package/src/button/README.md +1 -1
- package/src/button/stories/index.story.tsx +0 -1
- package/src/button/style.scss +0 -6
- package/src/calendar/utils/use-localization-props.ts +3 -4
- package/src/custom-select-control/index.tsx +3 -3
- package/src/custom-select-control-v2/custom-select.tsx +4 -4
- package/src/custom-select-control-v2/index.tsx +2 -2
- package/src/custom-select-control-v2/types.ts +1 -1
- package/src/divider/README.md +5 -6
- package/src/flex/stories/index.story.tsx +1 -1
- package/src/form-file-upload/README.md +3 -3
- package/src/gradient-picker/README.md +2 -2
- package/src/h-stack/README.md +10 -15
- package/src/h-stack/stories/index.story.tsx +2 -2
- package/src/heading/stories/index.story.tsx +1 -1
- package/src/higher-order/with-focus-outside/index.native.js +21 -20
- package/src/icon/README.md +1 -1
- package/src/menu/README.md +2 -2
- package/src/mobile/utils/get-px-from-css-unit.native.js +1 -1
- package/src/sandbox/index.native.js +2 -2
- package/src/sandbox/index.tsx +2 -2
- package/src/tabs/README.md +6 -6
- package/src/text/stories/index.story.tsx +1 -1
- package/src/toolbar/toolbar-button/toolbar-button-container.native.js +3 -1
- package/src/tree-select/README.md +1 -1
- package/src/v-stack/README.md +10 -15
- package/src/v-stack/stories/index.story.tsx +2 -2
- package/src/validated-form-controls/control-with-error.tsx +17 -12
- package/src/validated-form-controls/test/control-with-error.tsx +28 -1
- package/src/view/README.md +2 -5
- package/src/button/stories/style.css +0 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/box-control/utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\n\
|
|
5
|
-
"mappings": ";AAGA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\n\nexport const CUSTOM_VALUE_SETTINGS = {\n px: {\n max: 300,\n step: 1\n },\n '%': {\n max: 100,\n step: 1\n },\n vw: {\n max: 100,\n step: 1\n },\n vh: {\n max: 100,\n step: 1\n },\n em: {\n max: 10,\n step: 0.1\n },\n rm: {\n max: 10,\n step: 0.1\n },\n svw: {\n max: 100,\n step: 1\n },\n lvw: {\n max: 100,\n step: 1\n },\n dvw: {\n max: 100,\n step: 1\n },\n svh: {\n max: 100,\n step: 1\n },\n lvh: {\n max: 100,\n step: 1\n },\n dvh: {\n max: 100,\n step: 1\n },\n vi: {\n max: 100,\n step: 1\n },\n svi: {\n max: 100,\n step: 1\n },\n lvi: {\n max: 100,\n step: 1\n },\n dvi: {\n max: 100,\n step: 1\n },\n vb: {\n max: 100,\n step: 1\n },\n svb: {\n max: 100,\n step: 1\n },\n lvb: {\n max: 100,\n step: 1\n },\n dvb: {\n max: 100,\n step: 1\n },\n vmin: {\n max: 100,\n step: 1\n },\n svmin: {\n max: 100,\n step: 1\n },\n lvmin: {\n max: 100,\n step: 1\n },\n dvmin: {\n max: 100,\n step: 1\n },\n vmax: {\n max: 100,\n step: 1\n },\n svmax: {\n max: 100,\n step: 1\n },\n lvmax: {\n max: 100,\n step: 1\n },\n dvmax: {\n max: 100,\n step: 1\n }\n};\nexport const LABELS = {\n all: __('All sides'),\n top: __('Top side'),\n bottom: __('Bottom side'),\n left: __('Left side'),\n right: __('Right side'),\n vertical: __('Top and bottom sides'),\n horizontal: __('Left and right sides')\n};\nexport const DEFAULT_VALUES = {\n top: undefined,\n right: undefined,\n bottom: undefined,\n left: undefined\n};\nexport const ALL_SIDES = ['top', 'right', 'bottom', 'left'];\n\n/**\n * Gets an items with the most occurrence within an array\n * https://stackoverflow.com/a/20762713\n *\n * @param arr Array of items to check.\n * @return The item with the most occurrences.\n */\nfunction mode(arr) {\n return arr.sort((a, b) => arr.filter(v => v === a).length - arr.filter(v => v === b).length).pop();\n}\n\n/**\n * Gets the merged input value and unit from values data.\n *\n * @param values Box values.\n * @param availableSides Available box sides to evaluate.\n *\n * @return A value + unit for the 'all' input.\n */\nexport function getMergedValue(values = {}, availableSides = ALL_SIDES) {\n const sides = normalizeSides(availableSides);\n if (sides.every(side => values[side] === values[sides[0]])) {\n return values[sides[0]];\n }\n return undefined;\n}\n\n/**\n * Checks if the values are mixed.\n *\n * @param values Box values.\n * @param availableSides Available box sides to evaluate.\n * @return Whether the values are mixed.\n */\nexport function isValueMixed(values = {}, availableSides = ALL_SIDES) {\n const sides = normalizeSides(availableSides);\n return sides.some(side => values[side] !== values[sides[0]]);\n}\n\n/**\n * Determine the most common unit selection to use as a fallback option.\n *\n * @param selectedUnits Current unit selections for individual sides.\n * @return Most common unit selection.\n */\nexport function getAllUnitFallback(selectedUnits) {\n if (!selectedUnits || typeof selectedUnits !== 'object') {\n return undefined;\n }\n const filteredUnits = Object.values(selectedUnits).filter(Boolean);\n return mode(filteredUnits);\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param values Box values.\n *\n * @return Whether values are mixed.\n */\nexport function isValuesDefined(values) {\n return values && Object.values(values).filter(\n // Switching units when input is empty causes values only\n // containing units. This gives false positive on mixed values\n // unless filtered.\n value => !!value && /\\d/.test(value)).length > 0;\n}\n\n/**\n * Normalizes provided sides configuration to an array containing only top,\n * right, bottom and left. This essentially just maps `horizontal` or `vertical`\n * to their appropriate sides to facilitate correctly determining value for\n * all input control.\n *\n * @param sides Available sides for box control.\n * @return Normalized sides configuration.\n */\nexport function normalizeSides(sides) {\n const filteredSides = [];\n if (!sides?.length) {\n return ALL_SIDES;\n }\n if (sides.includes('vertical')) {\n filteredSides.push(...['top', 'bottom']);\n } else if (sides.includes('horizontal')) {\n filteredSides.push(...['left', 'right']);\n } else {\n const newSides = ALL_SIDES.filter(side => sides.includes(side));\n filteredSides.push(...newSides);\n }\n return filteredSides;\n}\n\n/**\n * Applies a value to an object representing top, right, bottom and left sides\n * while taking into account any custom side configuration.\n *\n * @deprecated\n *\n * @param currentValues The current values for each side.\n * @param newValue The value to apply to the sides object.\n * @param sides Array defining valid sides.\n *\n * @return Object containing the updated values for each side.\n */\nexport function applyValueToSides(currentValues, newValue, sides) {\n deprecated('applyValueToSides', {\n since: '6.8',\n version: '7.0'\n });\n const newValues = {\n ...currentValues\n };\n if (sides?.length) {\n sides.forEach(side => {\n if (side === 'vertical') {\n newValues.top = newValue;\n newValues.bottom = newValue;\n } else if (side === 'horizontal') {\n newValues.left = newValue;\n newValues.right = newValue;\n } else {\n newValues[side] = newValue;\n }\n });\n } else {\n ALL_SIDES.forEach(side => newValues[side] = newValue);\n }\n return newValues;\n}\n\n/**\n * Return the allowed sides based on the sides configuration.\n *\n * @param sides Sides configuration.\n * @return Allowed sides.\n */\nexport function getAllowedSides(sides) {\n const allowedSides = new Set(!sides ? ALL_SIDES : []);\n sides?.forEach(allowedSide => {\n if (allowedSide === 'vertical') {\n allowedSides.add('top');\n allowedSides.add('bottom');\n } else if (allowedSide === 'horizontal') {\n allowedSides.add('right');\n allowedSides.add('left');\n } else {\n allowedSides.add(allowedSide);\n }\n });\n return allowedSides;\n}\n\n/**\n * Checks if a value is a preset value.\n *\n * @param value The value to check.\n * @param presetKey The preset key to check against.\n * @return Whether the value is a preset value.\n */\nexport function isValuePreset(value, presetKey) {\n return value.startsWith(`var:preset|${presetKey}|`);\n}\n\n/**\n * Returns the index of the preset value in the presets array.\n *\n * @param value The value to check.\n * @param presetKey The preset key to check against.\n * @param presets The array of presets to search.\n * @return The index of the preset value in the presets array.\n */\nexport function getPresetIndexFromValue(value, presetKey, presets) {\n if (!isValuePreset(value, presetKey)) {\n return undefined;\n }\n const match = value.match(new RegExp(`^var:preset\\\\|${presetKey}\\\\|(.+)$`));\n if (!match) {\n return undefined;\n }\n const slug = match[1];\n const index = presets.findIndex(preset => {\n return preset.slug === slug;\n });\n return index !== -1 ? index : undefined;\n}\n\n/**\n * Returns the preset value from the index.\n *\n * @param index The index of the preset value in the presets array.\n * @param presetKey The preset key to check against.\n * @param presets The array of presets to search.\n * @return The preset value from the index.\n */\nexport function getPresetValueFromIndex(index, presetKey, presets) {\n const preset = presets[index];\n return `var:preset|${presetKey}|${preset.slug}`;\n}"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,gBAAgB;AACvB,SAAS,UAAU;AAMZ,IAAM,wBAAwB;AAAA,EACnC,IAAI;AAAA,IACF,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,K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S,cAAc,OAAO,WAAW;AAC9C,SAAO,MAAM,WAAW,cAAc,SAAS,GAAG;AACpD;AAUO,SAAS,wBAAwB,OAAO,WAAW,SAAS;AACjE,MAAI,CAAC,cAAc,OAAO,SAAS,GAAG;AACpC,WAAO;AAAA,EACT;AACA,QAAM,QAAQ,MAAM,MAAM,IAAI,OAAO,iBAAiB,SAAS,UAAU,CAAC;AAC1E,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AACA,QAAM,OAAO,MAAM,CAAC;AACpB,QAAM,QAAQ,QAAQ,UAAU,YAAU;AACxC,WAAO,OAAO,SAAS;AAAA,EACzB,CAAC;AACD,SAAO,UAAU,KAAK,QAAQ;AAChC;AAUO,SAAS,wBAAwB,OAAO,WAAW,SAAS;AACjE,QAAM,SAAS,QAAQ,KAAK;AAC5B,SAAO,cAAc,SAAS,IAAI,OAAO,IAAI;AAC/C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,8 +3,9 @@ import { __, sprintf } from "@wordpress/i18n";
|
|
|
3
3
|
import { useMemo } from "@wordpress/element";
|
|
4
4
|
function isLocaleRTL(localeCode) {
|
|
5
5
|
const localeObj = new Intl.Locale(localeCode);
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const direction = localeObj.getTextInfo?.().direction;
|
|
7
|
+
if (direction) {
|
|
8
|
+
return direction === "rtl";
|
|
8
9
|
}
|
|
9
10
|
return [
|
|
10
11
|
"ar",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/calendar/utils/use-localization-props.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\n/**\n * Internal dependencies\n */\n\nfunction isLocaleRTL(localeCode) {\n const localeObj = new Intl.Locale(localeCode);\n
|
|
5
|
-
"mappings": ";AAGA,SAAS,IAAI,eAAe;AAC5B,SAAS,eAAe;AAKxB,SAAS,YAAY,YAAY;AAC/B,QAAM,YAAY,IAAI,KAAK,OAAO,UAAU;AAC5C,MAAI,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\n/**\n * Internal dependencies\n */\n\nfunction isLocaleRTL(localeCode) {\n const localeObj = new Intl.Locale(localeCode);\n const direction = localeObj.getTextInfo?.().direction;\n if (direction) {\n return direction === 'rtl';\n }\n return ['ar',\n // Arabic\n 'he',\n // Hebrew\n 'fa',\n // Persian (Farsi)\n 'ur',\n // Urdu\n 'ps',\n // Pashto\n 'syr',\n // Syriac\n 'dv',\n // Divehi\n 'ku',\n // Kurdish (Sorani)\n 'yi' // Yiddish\n ].includes(localeObj.language);\n}\n\n/**\n * Returns localization props for the calendar components.\n *\n * Notes:\n * - the following props should be intended as defaults, and should\n * be overridden by consumer props if listed as public props.\n * - It is possible for the translated strings to use a different locale\n * than the formatted dates and the computed `dir`. This is because the\n * translation function doesn't expose the locale used for the translated\n * strings, meaning that the dates are formatted using the `locale` prop.\n * For a correct localized experience, consumers should make sure that\n * translation context and `locale` prop are consistent.\n * @param props\n * @param props.locale\n * @param props.timeZone\n * @param props.mode\n */\nexport const useLocalizationProps = ({\n locale,\n timeZone,\n mode\n}) => {\n return useMemo(() => {\n // ie. April 2025\n const monthNameFormatter = new Intl.DateTimeFormat(locale.code, {\n year: 'numeric',\n month: 'long',\n timeZone\n });\n // ie. M, T, W, T, F, S, S\n const weekdayNarrowFormatter = new Intl.DateTimeFormat(locale.code, {\n weekday: 'narrow',\n timeZone\n });\n // ie. Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday\n const weekdayLongFormatter = new Intl.DateTimeFormat(locale.code, {\n weekday: 'long',\n timeZone\n });\n // ie. Monday, April 29, 2025\n const fullDateFormatter = new Intl.DateTimeFormat(locale.code, {\n weekday: 'long',\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n timeZone\n });\n\n // Note: the following props should be intended as defaults, and should\n // be overridden by consumer props if listed as public props.\n return {\n 'aria-label': mode === 'single' ? __('Date calendar') : __('Date range calendar'),\n labels: {\n /**\n * The label for the month grid.\n * @param date\n */\n labelGrid: date => monthNameFormatter.format(date),\n /**\n * The label for the gridcell, when the calendar is not interactive.\n * @param date\n * @param modifiers\n */\n labelGridcell: (date, modifiers) => {\n const formattedDate = fullDateFormatter.format(date);\n let label = formattedDate;\n if (modifiers?.today) {\n label = sprintf(\n // translators: %s is the full date (e.g. \"Monday, April 29, 2025\")\n __('Today, %s'), formattedDate);\n }\n return label;\n },\n /** The label for the \"next month\" button. */\n labelNext: () => __('Go to the Next Month'),\n /** The label for the \"previous month\" button. */\n labelPrevious: () => __('Go to the Previous Month'),\n /**\n * The label for the day button.\n * @param date\n * @param modifiers\n */\n labelDayButton: (date, modifiers) => {\n const formattedDate = fullDateFormatter.format(date);\n let label = formattedDate;\n if (modifiers?.today) {\n label = sprintf(\n // translators: %s is the full date (e.g. \"Monday, April 29, 2025\")\n __('Today, %s'), formattedDate);\n }\n if (modifiers?.selected) {\n label = sprintf(\n // translators: %s is the full date (e.g. \"Monday, April 29, 2025\")\n __('%s, selected'), formattedDate);\n }\n return label;\n },\n /**\n * The label for the weekday.\n * @param date\n */\n labelWeekday: date => weekdayLongFormatter.format(date)\n },\n locale,\n dir: isLocaleRTL(locale.code) ? 'rtl' : 'ltr',\n formatters: {\n formatWeekdayName: date => {\n return weekdayNarrowFormatter.format(date);\n },\n formatCaption: date => {\n return monthNameFormatter.format(date);\n }\n },\n timeZone\n };\n }, [locale, timeZone, mode]);\n};"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,IAAI,eAAe;AAC5B,SAAS,eAAe;AAKxB,SAAS,YAAY,YAAY;AAC/B,QAAM,YAAY,IAAI,KAAK,OAAO,UAAU;AAC5C,QAAM,YAAY,UAAU,cAAc,EAAE;AAC5C,MAAI,WAAW;AACb,WAAO,cAAc;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AAsB;AAAA;AAAA,QAE1C,eAAe,MAAM,GAAG,0BAA0B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMlD,gBAAgB,CAAC,MAAM,cAAc;AACnC,gBAAM,gBAAgB,kBAAkB,OAAO,IAAI;AACnD,cAAI,QAAQ;AACZ,cAAI,WAAW,OAAO;AACpB,oBAAQ;AAAA;AAAA,cAER,GAAG,WAAW;AAAA,cAAG;AAAA,YAAa;AAAA,UAChC;AACA,cAAI,WAAW,UAAU;AACvB,oBAAQ;AAAA;AAAA,cAER,GAAG,cAAc;AAAA,cAAG;AAAA,YAAa;AAAA,UACnC;AACA,iBAAO;AAAA,QACT;AAAA;AAAA;AAAA;AAAA;AAAA,QAKA,cAAc,UAAQ,qBAAqB,OAAO,IAAI;AAAA,MACxD;AAAA,MACA;AAAA,MACA,KAAK,YAAY,OAAO,IAAI,IAAI,QAAQ;AAAA,MACxC,YAAY;AAAA,QACV,mBAAmB,UAAQ;AACzB,iBAAO,uBAAuB,OAAO,IAAI;AAAA,QAC3C;AAAA,QACA,eAAe,UAAQ;AACrB,iBAAO,mBAAmB,OAAO,IAAI;AAAA,QACvC;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACF,GAAG,CAAC,QAAQ,UAAU,IAAI,CAAC;AAC7B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,7 +3,7 @@ import * as Ariakit from "@ariakit/react";
|
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { useInstanceId } from "@wordpress/compose";
|
|
5
5
|
import { __, sprintf } from "@wordpress/i18n";
|
|
6
|
-
import
|
|
6
|
+
import CustomSelect from "../custom-select-control-v2/custom-select.mjs";
|
|
7
7
|
import CustomSelectItem from "../custom-select-control-v2/item.mjs";
|
|
8
8
|
import * as Styled from "../custom-select-control-v2/styles.mjs";
|
|
9
9
|
import { VisuallyHidden } from "../visually-hidden/index.mjs";
|
|
@@ -133,7 +133,7 @@ function CustomSelectControl(props) {
|
|
|
133
133
|
return size;
|
|
134
134
|
})();
|
|
135
135
|
return /* @__PURE__ */ _jsxs(_Fragment, {
|
|
136
|
-
children: [/* @__PURE__ */ _jsx(
|
|
136
|
+
children: [/* @__PURE__ */ _jsx(CustomSelect, {
|
|
137
137
|
"aria-describedby": descriptionId,
|
|
138
138
|
renderSelectedValue,
|
|
139
139
|
size: translatedSize,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/custom-select-control/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport
|
|
5
|
-
"mappings": ";AAGA,YAAY,aAAa;AACzB,OAAO,UAAU;AAKjB,SAAS,qBAAqB;AAC9B,SAAS,IAAI,eAAe;AAK5B,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport CustomSelect from '../custom-select-control-v2/custom-select';\nimport CustomSelectItem from '../custom-select-control-v2/item';\nimport * as Styled from '../custom-select-control-v2/styles';\nimport { VisuallyHidden } from '../visually-hidden';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nfunction useDeprecatedProps({\n __experimentalShowSelectedHint,\n ...otherProps\n}) {\n return {\n showSelectedHint: __experimentalShowSelectedHint,\n ...otherProps\n };\n}\n\n// The removal of `__experimentalHint` in favour of `hint` doesn't happen in\n// the `useDeprecatedProps` hook in order not to break consumers that rely\n// on object identity (see https://github.com/WordPress/gutenberg/pull/63248#discussion_r1672213131)\nfunction applyOptionDeprecations({\n __experimentalHint,\n ...rest\n}) {\n return {\n hint: __experimentalHint,\n ...rest\n };\n}\nfunction getDescribedBy(currentName, describedBy) {\n if (describedBy) {\n return describedBy;\n }\n\n // translators: %s: The selected option.\n return sprintf(__('Currently selected: %s'), currentName);\n}\nfunction CustomSelectControl(props) {\n const {\n __next40pxDefaultSize = false,\n __shouldNotWarnDeprecated36pxSize,\n describedBy,\n options,\n onChange,\n size = 'default',\n value,\n className: classNameProp,\n showSelectedHint = false,\n ...restProps\n } = useDeprecatedProps(props);\n maybeWarnDeprecated36pxSize({\n componentName: 'CustomSelectControl',\n __next40pxDefaultSize,\n size,\n __shouldNotWarnDeprecated36pxSize\n });\n const descriptionId = useInstanceId(CustomSelectControl, 'custom-select-control__description');\n\n // Forward props + store from v2 implementation\n const store = Ariakit.useSelectStore({\n async setValue(nextValue) {\n const nextOption = options.find(item => item.key === nextValue);\n if (!onChange || !nextOption) {\n return;\n }\n\n // Executes the logic in a microtask after the popup is closed.\n // This is simply to ensure the isOpen state matches the one from the\n // previous legacy implementation.\n await Promise.resolve();\n const state = store.getState();\n const changeObject = {\n highlightedIndex: state.renderedItems.findIndex(item => item.value === nextValue),\n inputValue: '',\n isOpen: state.open,\n selectedItem: nextOption,\n type: ''\n };\n onChange(changeObject);\n },\n value: value?.key,\n // Setting the first option as a default value when no value is provided\n // is already done natively by the underlying Ariakit component,\n // but doing this explicitly avoids the `onChange` callback from firing\n // on initial render, thus making this implementation closer to the v1.\n defaultValue: options[0]?.key\n });\n const children = options.map(applyOptionDeprecations).map(({\n name,\n key,\n hint,\n style,\n className\n }) => {\n const withHint = /*#__PURE__*/_jsxs(Styled.WithHintItemWrapper, {\n children: [/*#__PURE__*/_jsx(\"span\", {\n children: name\n }), /*#__PURE__*/_jsx(Styled.WithHintItemHint, {\n // Keeping the classname for legacy reasons\n className: \"components-custom-select-control__item-hint\",\n children: hint\n })]\n });\n return /*#__PURE__*/_jsx(CustomSelectItem, {\n value: key,\n children: hint ? withHint : name,\n style: style,\n className: clsx(className,\n // Keeping the classnames for legacy reasons\n 'components-custom-select-control__item', {\n 'has-hint': hint\n })\n }, key);\n });\n const currentValue = Ariakit.useStoreState(store, 'value');\n const selectedOption = options?.map(applyOptionDeprecations)?.find(({\n key\n }) => currentValue === key) ?? options[0];\n const renderSelectedValue = () => {\n if (!showSelectedHint || !selectedOption.hint) {\n return selectedOption?.name;\n }\n return /*#__PURE__*/_jsxs(Styled.SelectedExperimentalHintWrapper, {\n children: [selectedOption?.name, /*#__PURE__*/_jsx(Styled.SelectedExperimentalHintItem, {\n // Keeping the classname for legacy reasons\n className: \"components-custom-select-control__hint\",\n children: selectedOption?.hint\n })]\n });\n };\n const translatedSize = (() => {\n if (__next40pxDefaultSize && size === 'default' || size === '__unstable-large') {\n return 'default';\n }\n if (!__next40pxDefaultSize && size === 'default') {\n return 'compact';\n }\n return size;\n })();\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(CustomSelect, {\n \"aria-describedby\": descriptionId,\n renderSelectedValue: renderSelectedValue,\n size: translatedSize,\n store: store,\n className: clsx(\n // Keeping the classname for legacy reasons\n 'components-custom-select-control', classNameProp),\n isLegacy: true,\n ...restProps,\n children: children\n }), /*#__PURE__*/_jsx(VisuallyHidden, {\n children: /*#__PURE__*/_jsx(\"span\", {\n id: descriptionId,\n children: getDescribedBy(selectedOption?.name, describedBy)\n })\n })]\n });\n}\nexport default CustomSelectControl;"],
|
|
5
|
+
"mappings": ";AAGA,YAAY,aAAa;AACzB,OAAO,UAAU;AAKjB,SAAS,qBAAqB;AAC9B,SAAS,IAAI,eAAe;AAK5B,OAAO,kBAAkB;AACzB,OAAO,sBAAsB;AAC7B,YAAY,YAAY;AACxB,SAAS,sBAAsB;AAC/B,SAAS,mCAAmC;AAC5C,SAAS,OAAO,MAAM,QAAQ,OAAO,YAAY,iBAAiB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oB,sBAAM,WAAW;AAAA,IACnC,UAAU,CAAc,qBAAK,cAAc;AAAA,MACzC,oBAAoB;AAAA,MACpB;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA,WAAW;AAAA;AAAA,QAEX;AAAA,QAAoC;AAAA,MAAa;AAAA,MACjD,UAAU;AAAA,MACV,GAAG;AAAA,MACH;AAAA,IACF,CAAC,GAAgB,qBAAK,gBAAgB;AAAA,MACpC,UAAuB,qBAAK,QAAQ;AAAA,QAClC,IAAI;AAAA,QACJ,UAAU,eAAe,gBAAgB,MAAM,WAAW;AAAA,MAC5D,CAAC;AAAA,IACH,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACA,IAAO,gCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -42,7 +42,7 @@ var CustomSelectButton = ({
|
|
|
42
42
|
children: computedRenderSelectedValue(currentValue)
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
|
-
function
|
|
45
|
+
function CustomSelect(props) {
|
|
46
46
|
const {
|
|
47
47
|
children,
|
|
48
48
|
hideLabelFromVision = false,
|
|
@@ -103,7 +103,7 @@ function _CustomSelect(props) {
|
|
|
103
103
|
})
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
|
-
var custom_select_default =
|
|
106
|
+
var custom_select_default = CustomSelect;
|
|
107
107
|
export {
|
|
108
108
|
CustomSelectContext,
|
|
109
109
|
custom_select_default as default
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/custom-select-control-v2/custom-select.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport { createContext, useCallback, useMemo } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { VisuallyHidden } from '../visually-hidden';\nimport * as Styled from './styles';\nimport InputBase from '../input-control/input-base';\nimport SelectControlChevronDown from '../select-control/chevron-down';\nimport BaseControl from '../base-control';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport const CustomSelectContext = createContext(undefined);\nCustomSelectContext.displayName = 'CustomSelectContext';\nfunction defaultRenderSelectedValue(value) {\n const isValueEmpty = Array.isArray(value) ? value.length === 0 : value === undefined || value === null;\n if (isValueEmpty) {\n return __('Select an item');\n }\n if (Array.isArray(value)) {\n return value.length === 1 ? value[0] : sprintf(\n // translators: %d: number of items selected (it will always be 2 or more items)\n _n('%d item selected', '%d items selected', value.length), value.length);\n }\n return value;\n}\nconst CustomSelectButton = ({\n renderSelectedValue,\n size = 'default',\n store,\n ...restProps\n}) => {\n const {\n value: currentValue\n } = Ariakit.useStoreState(store);\n const computedRenderSelectedValue = useMemo(() => renderSelectedValue ?? defaultRenderSelectedValue, [renderSelectedValue]);\n return /*#__PURE__*/_jsx(Styled.Select, {\n ...restProps,\n size: size,\n hasCustomRenderProp: !!renderSelectedValue,\n store: store,\n children: computedRenderSelectedValue(currentValue)\n });\n};\nfunction
|
|
5
|
-
"mappings": ";AAGA,YAAY,aAAa;AAKzB,SAAS,eAAe,aAAa,eAAe;AACpD,SAAS,IAAI,IAAI,eAAe;AAKhC,SAAS,sBAAsB;AAC/B,YAAY,YAAY;AACxB,OAAO,eAAe;AACtB,OAAO,8BAA8B;AACrC,OAAO,iBAAiB;AACxB,SAAS,OAAO,MAAM,QAAQ,aAAa;AACpC,IAAM,sBAAsB,cAAc,MAAS;AAC1D,oBAAoB,cAAc;AAClC,SAAS,2BAA2B,OAAO;AACzC,QAAM,eAAe,MAAM,QAAQ,KAAK,IAAI,MAAM,WAAW,IAAI,UAAU,UAAa,UAAU;AAClG,MAAI,cAAc;AAChB,WAAO,GAAG,gBAAgB;AAAA,EAC5B;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI;AAAA;AAAA,MAEvC,GAAG,oBAAoB,qBAAqB,MAAM,MAAM;AAAA,MAAG,MAAM;AAAA,IAAM;AAAA,EACzE;AACA,SAAO;AACT;AACA,IAAM,qBAAqB,CAAC;AAAA,EAC1B;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM;AAAA,IACJ,OAAO;AAAA,EACT,IAAY,sBAAc,KAAK;AAC/B,QAAM,8BAA8B,QAAQ,MAAM,uBAAuB,4BAA4B,CAAC,mBAAmB,CAAC;AAC1H,SAAoB,qBAAY,eAAQ;AAAA,IACtC,GAAG;AAAA,IACH;AAAA,IACA,qBAAqB,CAAC,CAAC;AAAA,IACvB;AAAA,IACA,UAAU,4BAA4B,YAAY;AAAA,EACpD,CAAC;AACH;AACA,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport { createContext, useCallback, useMemo } from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { VisuallyHidden } from '../visually-hidden';\nimport * as Styled from './styles';\nimport InputBase from '../input-control/input-base';\nimport SelectControlChevronDown from '../select-control/chevron-down';\nimport BaseControl from '../base-control';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport const CustomSelectContext = createContext(undefined);\nCustomSelectContext.displayName = 'CustomSelectContext';\nfunction defaultRenderSelectedValue(value) {\n const isValueEmpty = Array.isArray(value) ? value.length === 0 : value === undefined || value === null;\n if (isValueEmpty) {\n return __('Select an item');\n }\n if (Array.isArray(value)) {\n return value.length === 1 ? value[0] : sprintf(\n // translators: %d: number of items selected (it will always be 2 or more items)\n _n('%d item selected', '%d items selected', value.length), value.length);\n }\n return value;\n}\nconst CustomSelectButton = ({\n renderSelectedValue,\n size = 'default',\n store,\n ...restProps\n}) => {\n const {\n value: currentValue\n } = Ariakit.useStoreState(store);\n const computedRenderSelectedValue = useMemo(() => renderSelectedValue ?? defaultRenderSelectedValue, [renderSelectedValue]);\n return /*#__PURE__*/_jsx(Styled.Select, {\n ...restProps,\n size: size,\n hasCustomRenderProp: !!renderSelectedValue,\n store: store,\n children: computedRenderSelectedValue(currentValue)\n });\n};\nfunction CustomSelect(props) {\n const {\n children,\n hideLabelFromVision = false,\n label,\n size,\n store,\n className,\n isLegacy = false,\n ...restProps\n } = props;\n const onSelectPopoverKeyDown = useCallback(e => {\n if (isLegacy) {\n e.stopPropagation();\n }\n }, [isLegacy]);\n const contextValue = useMemo(() => ({\n store,\n size\n }), [store, size]);\n return (\n /*#__PURE__*/\n // Where should `restProps` be forwarded to?\n _jsxs(\"div\", {\n className: className,\n children: [/*#__PURE__*/_jsx(Ariakit.SelectLabel, {\n store: store,\n render: hideLabelFromVision ?\n /*#__PURE__*/\n // @ts-expect-error `children` are passed via the render prop\n _jsx(VisuallyHidden, {}) :\n /*#__PURE__*/\n // @ts-expect-error `children` are passed via the render prop\n _jsx(BaseControl.VisualLabel, {\n as: \"div\"\n }),\n children: label\n }), /*#__PURE__*/_jsxs(InputBase, {\n __next40pxDefaultSize: true,\n size: size,\n suffix: /*#__PURE__*/_jsx(SelectControlChevronDown, {}),\n children: [/*#__PURE__*/_jsx(CustomSelectButton, {\n ...restProps,\n size: size,\n store: store\n // Match legacy behavior (move selection rather than open the popover)\n ,\n showOnKeyDown: !isLegacy\n }), /*#__PURE__*/_jsx(Styled.SelectPopover, {\n gutter: 12,\n store: store,\n sameWidth: true,\n slide: false,\n onKeyDown: onSelectPopoverKeyDown\n // Match legacy behavior\n ,\n flip: !isLegacy,\n children: /*#__PURE__*/_jsx(CustomSelectContext.Provider, {\n value: contextValue,\n children: children\n })\n })]\n })]\n })\n );\n}\nexport default CustomSelect;"],
|
|
5
|
+
"mappings": ";AAGA,YAAY,aAAa;AAKzB,SAAS,eAAe,aAAa,eAAe;AACpD,SAAS,IAAI,IAAI,eAAe;AAKhC,SAAS,sBAAsB;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ClC;AAAA,IACA;AAAA,EACF,IAAI,CAAC,OAAO,IAAI,CAAC;AACjB;AAAA;AAAA,IAGE,sBAAM,OAAO;AAAA,MACX;AAAA,MACA,UAAU,CAAc,qBAAa,qBAAa;AAAA,QAChD;AAAA,QACA,QAAQ;AAAA;AAAA,UAGR,qBAAK,gBAAgB,CAAC,CAAC;AAAA;AAAA;AAAA,UAGvB,qBAAK,YAAY,aAAa;AAAA,YAC5B,IAAI;AAAA,UACN,CAAC;AAAA;AAAA,QACD,UAAU;AAAA,MACZ,CAAC,GAAgB,sBAAM,WAAW;AAAA,QAChC,uBAAuB;AAAA,QACvB;AAAA,QACA,QAAqB,qBAAK,0BAA0B,CAAC,CAAC;AAAA,QACtD,UAAU,CAAc,qBAAK,oBAAoB;AAAA,UAC/C,GAAG;AAAA,UACH;AAAA,UACA;AAAA,UAGA,eAAe,CAAC;AAAA,QAClB,CAAC,GAAgB,qBAAY,sBAAe;AAAA,UAC1C,QAAQ;AAAA,UACR;AAAA,UACA,WAAW;AAAA,UACX,OAAO;AAAA,UACP,WAAW;AAAA,UAGX,MAAM,CAAC;AAAA,UACP,UAAuB,qBAAK,oBAAoB,UAAU;AAAA,YACxD,OAAO;AAAA,YACP;AAAA,UACF,CAAC;AAAA,QACH,CAAC,CAAC;AAAA,MACJ,CAAC,CAAC;AAAA,IACJ,CAAC;AAAA;AAEL;AACA,IAAO,wBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/components/src/custom-select-control-v2/index.tsx
|
|
2
2
|
import * as Ariakit from "@ariakit/react";
|
|
3
|
-
import
|
|
3
|
+
import CustomSelect from "./custom-select.mjs";
|
|
4
4
|
import Item from "./item.mjs";
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
function CustomSelectControlV2(props) {
|
|
@@ -15,7 +15,7 @@ function CustomSelectControlV2(props) {
|
|
|
15
15
|
defaultValue,
|
|
16
16
|
value
|
|
17
17
|
});
|
|
18
|
-
return /* @__PURE__ */ _jsx(
|
|
18
|
+
return /* @__PURE__ */ _jsx(CustomSelect, {
|
|
19
19
|
...restProps,
|
|
20
20
|
store
|
|
21
21
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/custom-select-control-v2/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\n/**\n * Internal dependencies\n */\nimport
|
|
5
|
-
"mappings": ";AAGA,YAAY,aAAa;AAIzB,OAAO,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\n/**\n * Internal dependencies\n */\nimport CustomSelect from './custom-select';\nimport Item from './item';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction CustomSelectControlV2(props) {\n const {\n defaultValue,\n onChange,\n value,\n ...restProps\n } = props;\n // Forward props + store from v2 implementation\n const store = Ariakit.useSelectStore({\n setValue: nextValue => onChange?.(nextValue),\n defaultValue,\n value\n });\n return /*#__PURE__*/_jsx(CustomSelect, {\n ...restProps,\n store: store\n });\n}\nCustomSelectControlV2.Item = Item;\nexport default CustomSelectControlV2;"],
|
|
5
|
+
"mappings": ";AAGA,YAAY,aAAa;AAIzB,OAAO,kBAAkB;AACzB,OAAO,UAAU;AACjB,SAAS,OAAO,YAAY;AAC5B,SAAS,sBAAsB,OAAO;AACpC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,QAAgB,uBAAe;AAAA,IACnC,UAAU,eAAa,WAAW,SAAS;AAAA,IAC3C;AAAA,IACA;AAAA,EACF,CAAC;AACD,SAAoB,qBAAK,cAAc;AAAA,IACrC,GAAG;AAAA,IACH;AAAA,EACF,CAAC;AACH;AACA,sBAAsB,OAAO;AAC7B,IAAO,mCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -83,7 +83,7 @@ function SandBox({
|
|
|
83
83
|
function isFrameAccessible() {
|
|
84
84
|
try {
|
|
85
85
|
return !!ref.current?.contentDocument?.body;
|
|
86
|
-
} catch
|
|
86
|
+
} catch {
|
|
87
87
|
return false;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -148,7 +148,7 @@ function SandBox({
|
|
|
148
148
|
if ("string" === typeof data) {
|
|
149
149
|
try {
|
|
150
150
|
data = JSON.parse(data);
|
|
151
|
-
} catch
|
|
151
|
+
} catch {
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
if ("resize" !== data.action) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/sandbox/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { renderToString, useRef, useState, useEffect } from '@wordpress/element';\nimport { useFocusableIframe, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst observeAndResizeJS = function () {\n const {\n MutationObserver\n } = window;\n if (!MutationObserver || !document.body || !window.parent) {\n return;\n }\n function sendResize() {\n const clientBoundingRect = document.body.getBoundingClientRect();\n window.parent.postMessage({\n action: 'resize',\n width: clientBoundingRect.width,\n height: clientBoundingRect.height\n }, '*');\n }\n const observer = new MutationObserver(sendResize);\n observer.observe(document.body, {\n attributes: true,\n attributeOldValue: false,\n characterData: true,\n characterDataOldValue: false,\n childList: true,\n subtree: true\n });\n window.addEventListener('load', sendResize, true);\n\n // Hack: Remove viewport unit styles, as these are relative\n // the iframe root and interfere with our mechanism for\n // determining the unconstrained page bounds.\n function removeViewportStyles(ruleOrNode) {\n if (ruleOrNode.style) {\n ['width', 'height', 'minHeight', 'maxHeight'].forEach(function (style) {\n if (/^\\\\d+(vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/.test(ruleOrNode.style[style])) {\n ruleOrNode.style[style] = '';\n }\n });\n }\n }\n Array.prototype.forEach.call(document.querySelectorAll('[style]'), removeViewportStyles);\n Array.prototype.forEach.call(document.styleSheets, function (stylesheet) {\n Array.prototype.forEach.call(stylesheet.cssRules || stylesheet.rules, removeViewportStyles);\n });\n document.body.style.position = 'absolute';\n document.body.style.width = '100%';\n document.body.setAttribute('data-resizable-iframe-connected', '');\n sendResize();\n\n // Resize events can change the width of elements with 100% width, but we don't\n // get an DOM mutations for that, so do the resize when the window is resized, too.\n window.addEventListener('resize', sendResize, true);\n};\n\n// TODO: These styles shouldn't be coupled with WordPress.\nconst style = `\n\tbody {\n\t\tmargin: 0;\n\t}\n\thtml,\n\tbody,\n\tbody > div {\n\t\twidth: 100%;\n\t}\n\thtml.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio > div,\n\tbody.wp-has-aspect-ratio > div iframe {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */\n\t}\n\tbody > div > * {\n\t\tmargin-top: 0 !important; /* Has to have !important to override inline styles. */\n\t\tmargin-bottom: 0 !important;\n\t}\n`;\n\n/**\n * This component provides an isolated environment for arbitrary HTML via iframes.\n *\n * ```jsx\n * import { SandBox } from '@wordpress/components';\n *\n * const MySandBox = () => (\n * \t<SandBox html=\"<p>Content</p>\" title=\"SandBox\" type=\"embed\" />\n * );\n * ```\n */\nfunction SandBox({\n html = '',\n title = '',\n type,\n styles = [],\n scripts = [],\n onFocus,\n tabIndex\n}) {\n const ref = useRef(null);\n const [width, setWidth] = useState(0);\n const [height, setHeight] = useState(0);\n function isFrameAccessible() {\n try {\n return !!ref.current?.contentDocument?.body;\n } catch
|
|
5
|
-
"mappings": ";AAGA,SAAS,gBA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AE;AAChE,aAAW;AAIX,SAAO,iBAAiB,UAAU,YAAY,IAAI;AACpD;AAGA,IAAM,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkCd,SAAS,QAAQ;AAAA,EACf,OAAO;AAAA,EACP,QAAQ;AAAA,EACR;AAAA,EACA,SAAS,CAAC;AAAA,EACV,UAAU,CAAC;AAAA,EACX;AAAA,EACA;AACF,GAAG;AACD,QAAM,MAAM,OAAO,IAAI;AACvB,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,CAAC;AACpC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,CAAC;AACtC,WAAS,oBAAoB;AAC3B,QAAI;AACF,aAAO,CAAC,CAAC,IAAI,SAAS,iBAAiB;AAAA,IACzC,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { renderToString, useRef, useState, useEffect } from '@wordpress/element';\nimport { useFocusableIframe, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst observeAndResizeJS = function () {\n const {\n MutationObserver\n } = window;\n if (!MutationObserver || !document.body || !window.parent) {\n return;\n }\n function sendResize() {\n const clientBoundingRect = document.body.getBoundingClientRect();\n window.parent.postMessage({\n action: 'resize',\n width: clientBoundingRect.width,\n height: clientBoundingRect.height\n }, '*');\n }\n const observer = new MutationObserver(sendResize);\n observer.observe(document.body, {\n attributes: true,\n attributeOldValue: false,\n characterData: true,\n characterDataOldValue: false,\n childList: true,\n subtree: true\n });\n window.addEventListener('load', sendResize, true);\n\n // Hack: Remove viewport unit styles, as these are relative\n // the iframe root and interfere with our mechanism for\n // determining the unconstrained page bounds.\n function removeViewportStyles(ruleOrNode) {\n if (ruleOrNode.style) {\n ['width', 'height', 'minHeight', 'maxHeight'].forEach(function (style) {\n if (/^\\\\d+(vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/.test(ruleOrNode.style[style])) {\n ruleOrNode.style[style] = '';\n }\n });\n }\n }\n Array.prototype.forEach.call(document.querySelectorAll('[style]'), removeViewportStyles);\n Array.prototype.forEach.call(document.styleSheets, function (stylesheet) {\n Array.prototype.forEach.call(stylesheet.cssRules || stylesheet.rules, removeViewportStyles);\n });\n document.body.style.position = 'absolute';\n document.body.style.width = '100%';\n document.body.setAttribute('data-resizable-iframe-connected', '');\n sendResize();\n\n // Resize events can change the width of elements with 100% width, but we don't\n // get an DOM mutations for that, so do the resize when the window is resized, too.\n window.addEventListener('resize', sendResize, true);\n};\n\n// TODO: These styles shouldn't be coupled with WordPress.\nconst style = `\n\tbody {\n\t\tmargin: 0;\n\t}\n\thtml,\n\tbody,\n\tbody > div {\n\t\twidth: 100%;\n\t}\n\thtml.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio > div,\n\tbody.wp-has-aspect-ratio > div iframe {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */\n\t}\n\tbody > div > * {\n\t\tmargin-top: 0 !important; /* Has to have !important to override inline styles. */\n\t\tmargin-bottom: 0 !important;\n\t}\n`;\n\n/**\n * This component provides an isolated environment for arbitrary HTML via iframes.\n *\n * ```jsx\n * import { SandBox } from '@wordpress/components';\n *\n * const MySandBox = () => (\n * \t<SandBox html=\"<p>Content</p>\" title=\"SandBox\" type=\"embed\" />\n * );\n * ```\n */\nfunction SandBox({\n html = '',\n title = '',\n type,\n styles = [],\n scripts = [],\n onFocus,\n tabIndex\n}) {\n const ref = useRef(null);\n const [width, setWidth] = useState(0);\n const [height, setHeight] = useState(0);\n function isFrameAccessible() {\n try {\n return !!ref.current?.contentDocument?.body;\n } catch {\n return false;\n }\n }\n function trySandBox(forceRerender = false) {\n if (!isFrameAccessible()) {\n return;\n }\n const {\n contentDocument,\n ownerDocument\n } = ref.current;\n if (!forceRerender && null !== contentDocument?.body.getAttribute('data-resizable-iframe-connected')) {\n return;\n }\n\n // Put the html snippet into a html document, and then write it to the iframe's document\n // we can use this in the future to inject custom styles or scripts.\n // Scripts go into the body rather than the head, to support embedded content such as Instagram\n // that expect the scripts to be part of the body.\n const htmlDoc = /*#__PURE__*/_jsxs(\"html\", {\n lang: ownerDocument.documentElement.lang,\n className: type,\n children: [/*#__PURE__*/_jsxs(\"head\", {\n children: [/*#__PURE__*/_jsx(\"title\", {\n children: title\n }), /*#__PURE__*/_jsx(\"style\", {\n dangerouslySetInnerHTML: {\n __html: style\n }\n }), styles.map((rules, i) => /*#__PURE__*/_jsx(\"style\", {\n dangerouslySetInnerHTML: {\n __html: rules\n }\n }, i))]\n }), /*#__PURE__*/_jsxs(\"body\", {\n \"data-resizable-iframe-connected\": \"data-resizable-iframe-connected\",\n className: type,\n children: [/*#__PURE__*/_jsx(\"div\", {\n dangerouslySetInnerHTML: {\n __html: html\n }\n }), /*#__PURE__*/_jsx(\"script\", {\n type: \"text/javascript\",\n dangerouslySetInnerHTML: {\n __html: `(${observeAndResizeJS.toString()})();`\n }\n }), scripts.map(src => /*#__PURE__*/_jsx(\"script\", {\n src: src\n }, src))]\n })]\n });\n\n // Writing the document like this makes it act in the same way as if it was\n // loaded over the network, so DOM creation and mutation, script execution, etc.\n // all work as expected.\n contentDocument.open();\n contentDocument.write('<!DOCTYPE html>' + renderToString(htmlDoc));\n contentDocument.close();\n }\n useEffect(() => {\n trySandBox();\n function tryNoForceSandBox() {\n trySandBox(false);\n }\n function checkMessageForResize(event) {\n const iframe = ref.current;\n\n // Verify that the mounted element is the source of the message.\n if (!iframe || iframe.contentWindow !== event.source) {\n return;\n }\n\n // Attempt to parse the message data as JSON if passed as string.\n let data = event.data || {};\n if ('string' === typeof data) {\n try {\n data = JSON.parse(data);\n } catch {}\n }\n\n // Update the state only if the message is formatted as we expect,\n // i.e. as an object with a 'resize' action.\n if ('resize' !== data.action) {\n return;\n }\n setWidth(data.width);\n setHeight(data.height);\n }\n const iframe = ref.current;\n const defaultView = iframe?.ownerDocument?.defaultView;\n\n // This used to be registered using <iframe onLoad={} />, but it made the iframe blank\n // after reordering the containing block. See these two issues for more details:\n // https://github.com/WordPress/gutenberg/issues/6146\n // https://github.com/facebook/react/issues/18752\n iframe?.addEventListener('load', tryNoForceSandBox, false);\n defaultView?.addEventListener('message', checkMessageForResize);\n return () => {\n iframe?.removeEventListener('load', tryNoForceSandBox, false);\n defaultView?.removeEventListener('message', checkMessageForResize);\n };\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, []);\n useEffect(() => {\n trySandBox();\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, [title, styles, scripts]);\n useEffect(() => {\n trySandBox(true);\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, [html, type]);\n return /*#__PURE__*/_jsx(\"iframe\", {\n ref: useMergeRefs([ref, useFocusableIframe()]),\n title: title,\n tabIndex: tabIndex,\n className: \"components-sandbox\",\n sandbox: \"allow-scripts allow-same-origin allow-presentation\",\n onFocus: onFocus,\n width: Math.ceil(width),\n height: Math.ceil(height)\n });\n}\nexport default SandBox;"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,gBAAgB,QAAQ,UAAU,iBAAiB;AAC5D,SAAS,oBAAoB,oBAAoB;AAKjD,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,qBAAqB,WAAY;AACrC,QAAM;AAAA,IACJ;AAAA,EACF,IAAI;AACJ,MAAI,CAAC,oBAAoB,CAAC,SAAS,QAAQ,CAAC,OAAO,QAAQ;AACzD;AAAA,EACF;AACA,WAAS,aAAa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AAK,aAAa,CAAC,KAAK,mBAAmB,CAAC,CAAC;AAAA,IAC7C;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,SAAS;AAAA,IACT;AAAA,IACA,OAAO,KAAK,KAAK,KAAK;AAAA,IACtB,QAAQ,KAAK,KAAK,MAAM;AAAA,EAC1B,CAAC;AACH;AACA,IAAO,kBAAQ;",
|
|
6
6
|
"names": ["style", "iframe"]
|
|
7
7
|
}
|
|
@@ -4,17 +4,21 @@ import { cloneElement, forwardRef, useEffect, useId, useState } from "@wordpress
|
|
|
4
4
|
import { ValidityIndicator } from "./validity-indicator.mjs";
|
|
5
5
|
import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
function appendRequiredIndicator(label, required, markWhenOptional) {
|
|
7
|
+
let suffix;
|
|
7
8
|
if (required && !markWhenOptional) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})
|
|
9
|
+
suffix = `(${__("Required")})`;
|
|
10
|
+
} else if (!required && markWhenOptional) {
|
|
11
|
+
suffix = `(${__("Optional")})`;
|
|
11
12
|
}
|
|
12
|
-
if (!
|
|
13
|
-
return
|
|
14
|
-
children: [label, " ", `(${__("Optional")})`]
|
|
15
|
-
});
|
|
13
|
+
if (!suffix) {
|
|
14
|
+
return label;
|
|
16
15
|
}
|
|
17
|
-
|
|
16
|
+
if (typeof label === "string") {
|
|
17
|
+
return `${label} ${suffix}`;
|
|
18
|
+
}
|
|
19
|
+
return /* @__PURE__ */ _jsxs(_Fragment, {
|
|
20
|
+
children: [label, " ", suffix]
|
|
21
|
+
});
|
|
18
22
|
}
|
|
19
23
|
var VALIDITY_VISIBLE_ATTRIBUTE = "data-validity-visible";
|
|
20
24
|
var className = "components-validated-control";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/validated-form-controls/control-with-error.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { cloneElement, forwardRef, useEffect, useId, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\n\nimport { ValidityIndicator } from './validity-indicator';\nimport { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from \"react/jsx-runtime\";\nfunction appendRequiredIndicator(label, required, markWhenOptional) {\n if (required && !markWhenOptional) {\n
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,cAAc,YAAY,WAAW,OAAO,gBAAgB;AAMrE,SAAS,yBAAyB;AAClC,SAAS,YAAY,WAAW,QAAQ,OAAO,OAAO,YAAY;AAClE,SAAS,wBAAwB,OAAO,UAAU,kBAAkB;AAClE,MAAI,YAAY,CAAC,kBAAkB;AACjC,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { cloneElement, forwardRef, useEffect, useId, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\n\nimport { ValidityIndicator } from './validity-indicator';\nimport { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from \"react/jsx-runtime\";\nfunction appendRequiredIndicator(label, required, markWhenOptional) {\n let suffix;\n if (required && !markWhenOptional) {\n suffix = `(${__('Required')})`;\n } else if (!required && markWhenOptional) {\n suffix = `(${__('Optional')})`;\n }\n if (!suffix) {\n return label;\n }\n if (typeof label === 'string') {\n return `${label} ${suffix}`;\n }\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [label, \" \", suffix]\n });\n}\nconst VALIDITY_VISIBLE_ATTRIBUTE = 'data-validity-visible';\nconst className = 'components-validated-control';\n\n/**\n * HTML elements that support the Constraint Validation API.\n *\n * Here, we exclude HTMLButtonElement because although it does technically support the API,\n * normal buttons are actually exempted from any validation.\n * @see https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Form_validation\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/willValidate\n */\n\nfunction UnforwardedControlWithError({\n required,\n markWhenOptional,\n customValidity,\n getValidityTarget,\n children\n}, forwardedRef) {\n const [errorMessage, setErrorMessage] = useState();\n const [statusMessage, setStatusMessage] = useState();\n const [showMessage, setShowMessage] = useState(false);\n const [isTouched, setIsTouched] = useState(false);\n\n // Ensure that error messages are visible when an `invalid` event is triggered,\n // e.g. when a form is submitted or reportValidity() is called.\n useEffect(() => {\n const validityTarget = getValidityTarget();\n const handler = () => {\n setShowMessage(true);\n validityTarget?.setAttribute(VALIDITY_VISIBLE_ATTRIBUTE, '');\n };\n validityTarget?.addEventListener('invalid', handler);\n return () => validityTarget?.removeEventListener('invalid', handler);\n }, [getValidityTarget]);\n\n // Suppress the native error popover, while keeping the focus behavior intact.\n useEffect(() => {\n const validityTarget = getValidityTarget();\n const suppressNativePopover = event => {\n event.preventDefault();\n const target = event.target;\n const firstErrorInForm = Array.from(target.form?.elements ?? []).find(el => !el.validity.valid);\n if (!target.form || firstErrorInForm === target) {\n target.focus();\n }\n };\n\n // Radio inputs need special handling because all radio inputs with the\n // same `name` will be marked as invalid. Without this handling, the last radio option\n // will be focused with an unsuppressed native popover.\n const radioSibilings = validityTarget?.type === 'radio' && validityTarget?.name ? Array.from(validityTarget?.closest(`.${className}`)?.querySelectorAll(`input[type=\"radio\"][name=\"${validityTarget?.name}\"]`) ?? []).filter(sibling => sibling !== validityTarget) : [];\n validityTarget?.addEventListener('invalid', suppressNativePopover);\n radioSibilings.forEach(sibling => sibling.addEventListener('invalid', suppressNativePopover));\n return () => {\n validityTarget?.removeEventListener('invalid', suppressNativePopover);\n radioSibilings.forEach(sibling => sibling.removeEventListener('invalid', suppressNativePopover));\n };\n }, [getValidityTarget]);\n\n // Handle validity messages.\n useEffect(() => {\n const validityTarget = getValidityTarget();\n if (!customValidity?.type) {\n validityTarget?.setCustomValidity('');\n setErrorMessage(validityTarget?.validationMessage);\n setStatusMessage(undefined);\n return;\n }\n switch (customValidity.type) {\n case 'validating':\n {\n validityTarget?.setCustomValidity('');\n setErrorMessage(undefined);\n setStatusMessage({\n type: 'validating',\n message: customValidity.message\n });\n break;\n }\n case 'valid':\n {\n validityTarget?.setCustomValidity('');\n setErrorMessage(validityTarget?.validationMessage);\n setStatusMessage({\n type: 'valid',\n message: customValidity.message\n });\n break;\n }\n case 'invalid':\n {\n validityTarget?.setCustomValidity(customValidity.message ?? '');\n setErrorMessage(validityTarget?.validationMessage);\n setStatusMessage(undefined);\n break;\n }\n }\n }, [customValidity, getValidityTarget]);\n\n // Show messages if field has been touched (i.e. has blurred at least once),\n // or validation has been triggered by the consumer/user.\n useEffect(() => {\n if (!isTouched || showMessage) {\n return;\n }\n if (customValidity?.type === 'validating') {\n // Don't show validating indicators for quick calls that take less than 1 sec.\n const timer = setTimeout(() => {\n setShowMessage(true);\n }, 1000);\n return () => clearTimeout(timer);\n }\n setShowMessage(true);\n }, [isTouched, customValidity?.type, showMessage]);\n\n // Mark blurred fields as touched.\n const onBlur = event => {\n if (isTouched) {\n return;\n }\n\n // Only consider \"blurred from the component\" if focus has fully left the wrapping div.\n // This prevents unnecessary blurs from components with multiple focusable elements.\n if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {\n setIsTouched(true);\n getValidityTarget()?.setAttribute(VALIDITY_VISIBLE_ATTRIBUTE, '');\n }\n };\n const messageId = useId();\n const message = (() => {\n if (errorMessage) {\n return /*#__PURE__*/_jsx(ValidityIndicator, {\n id: messageId,\n type: \"invalid\",\n message: errorMessage\n });\n }\n if (statusMessage?.type) {\n return /*#__PURE__*/_jsx(ValidityIndicator, {\n id: messageId,\n type: statusMessage.type,\n message: statusMessage.message\n });\n }\n return null;\n })();\n const visibleMessage = showMessage ? message : null;\n\n // Imperatively manage `aria-describedby` on the validity target so we\n // merge with any value the child control sets internally (e.g. from a\n // `help` prop), rather than competing with it at the props level.\n useEffect(() => {\n const target = getValidityTarget();\n if (!target) {\n return;\n }\n function setDescribedBy(el, shouldAdd) {\n const ids = (el.getAttribute('aria-describedby') ?? '').split(' ').filter(id => id && id !== messageId);\n if (shouldAdd) {\n ids.push(messageId);\n }\n if (ids.length) {\n el.setAttribute('aria-describedby', ids.join(' '));\n } else {\n el.removeAttribute('aria-describedby');\n }\n }\n setDescribedBy(target, !!visibleMessage);\n return () => setDescribedBy(target, false);\n }, [visibleMessage, messageId, getValidityTarget]);\n return /*#__PURE__*/_jsxs(\"div\", {\n className: className,\n ref: forwardedRef,\n onBlur: onBlur,\n children: [cloneElement(children, {\n label: appendRequiredIndicator(children.props.label, required, markWhenOptional),\n required\n }), /*#__PURE__*/_jsx(\"div\", {\n \"aria-live\": \"polite\",\n children: visibleMessage\n })]\n });\n}\nexport const ControlWithError = forwardRef(UnforwardedControlWithError);\nControlWithError.displayName = 'ControlWithError';"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,cAAc,YAAY,WAAW,OAAO,gBAAgB;AAMrE,SAAS,yBAAyB;AAClC,SAAS,YAAY,WAAW,QAAQ,OAAO,OAAO,YAAY;AAClE,SAAS,wBAAwB,OAAO,UAAU,kBAAkB;AAClE,MAAI;AACJ,MAAI,YAAY,CAAC,kBAAkB;AACjC,aAAS,IAAI,GAAG,UAAU,CAAC;AAAA,EAC7B,WAAW,CAAC,YAAY,kBAAkB;AACxC,aAAS,IAAI,GAAG,UAAU,CAAC;AAAA,EAC7B;AACA,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,GAAG,KAAK,IAAI,MAAM;AAAA,EAC3B;AACA,SAAoB,sBAAM,WAAW;AAAA,IACnC,UAAU,CAAC,OAAO,KAAK,MAAM;AAAA,EAC/B,CAAC;AACH;AACA,IAAM,6BAA6B;AACnC,IAAM,YAAY;AAWlB,SAAS,4BAA4B;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAG,cAAc;AACf,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS;AAC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|
|
7
7
|
}
|
package/build-style/style.css
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AutocompleterUIProps
|
|
2
|
-
export declare function
|
|
1
|
+
import type { AutocompleterUIProps } from './types';
|
|
2
|
+
export declare function AutocompleterUI({ autocompleter, filterValue, instanceId, listBoxId, className, selectedIndex, onChangeOptions, onSelect, reset, contentRef, }: AutocompleterUIProps): import("react").JSX.Element | null;
|
|
3
3
|
//# sourceMappingURL=autocompleter-ui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocompleter-ui.d.ts","sourceRoot":"","sources":["../../src/autocomplete/autocompleter-ui.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,oBAAoB,EAAe,
|
|
1
|
+
{"version":3,"file":"autocompleter-ui.d.ts","sourceRoot":"","sources":["../../src/autocomplete/autocompleter-ui.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,oBAAoB,EAAe,MAAM,SAAS,CAAC;AAsDjE,wBAAgB,eAAe,CAAE,EAChC,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,eAAe,EACf,QAAQ,EACR,KAAK,EACL,UAAU,GACV,EAAE,oBAAoB,sCAyHtB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { WPCompleter } from './types';
|
|
5
|
+
type AutocompleteMatch = {
|
|
6
|
+
completer: WPCompleter;
|
|
7
|
+
filterValue: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function getAutocompleteMatch(textContent: string, completers: WPCompleter[], filteredOptionsLength: number, isBackspacing: boolean, getTextAfterSelection: () => string): AutocompleteMatch | null;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=get-autocomplete-match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-autocomplete-match.d.ts","sourceRoot":"","sources":["../../src/autocomplete/get-autocomplete-match.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,KAAK,iBAAiB,GAAG;IACxB,SAAS,EAAE,WAAW,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,WAAW,EAAE,EACzB,qBAAqB,EAAE,MAAM,EAC7B,aAAa,EAAE,OAAO,EACtB,qBAAqB,EAAE,MAAM,MAAM,GACjC,iBAAiB,GAAG,IAAI,CA6F1B"}
|
|
@@ -5,6 +5,14 @@ export declare function useAutocomplete({ record, onChange, onReplace, completer
|
|
|
5
5
|
onKeyDown: (event: KeyboardEvent) => void;
|
|
6
6
|
popover: false | import("react").JSX.Element;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Tracks the last record whose value differed from the current one.
|
|
10
|
+
* Used to determine whether the user has actually typed something
|
|
11
|
+
*/
|
|
12
|
+
export declare function useLastDifferentValue(value: UseAutocompleteProps['record']): import("@wordpress/rich-text").RichTextValue & {
|
|
13
|
+
start: NonNullable<import("@wordpress/rich-text").RichTextValue["start"]>;
|
|
14
|
+
end: NonNullable<import("@wordpress/rich-text").RichTextValue["end"]>;
|
|
15
|
+
};
|
|
8
16
|
export declare function useAutocompleteProps(options: UseAutocompleteProps): {
|
|
9
17
|
ref: import("react").RefCallback<HTMLElement>;
|
|
10
18
|
children?: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/autocomplete/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/autocomplete/index.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAEX,iBAAiB,EAMjB,oBAAoB,EACpB,MAAM,SAAS,CAAC;AA6DjB,wBAAgB,eAAe,CAAE,EAChC,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,EACV,UAAU,GACV,EAAE,oBAAoB;;;;;EA2LtB;AAaD;;;GAGG;AACH,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,oBAAoB,CAAE,QAAQ,CAAE;;;EAmBvC;AAED,wBAAgB,oBAAoB,CAAE,OAAO,EAAE,oBAAoB;;;;;;;;;;;;EAuClE;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,EACrC,QAAQ,EACR,UAAU,EACV,GAAG,OAAO,EACV,EAAE,iBAAiB,+BAQnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-autocomplete-match.d.ts","sourceRoot":"","sources":["../../../src/autocomplete/test/get-autocomplete-match.ts"],"names":[],"mappings":""}
|