@wordpress/components 30.7.2-next.2f1c7c01b.0 → 30.8.1-next.16d95556a.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.
Files changed (136) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/build/color-picker/component.js +24 -0
  3. package/build/color-picker/component.js.map +2 -2
  4. package/build/confirm-dialog/component.js +6 -0
  5. package/build/confirm-dialog/component.js.map +2 -2
  6. package/build/custom-select-control/index.js +18 -14
  7. package/build/custom-select-control/index.js.map +2 -2
  8. package/build/modal/index.js +1 -0
  9. package/build/modal/index.js.map +2 -2
  10. package/build/utils/math.js +2 -2
  11. package/build/utils/math.js.map +2 -2
  12. package/build-module/color-picker/component.js +25 -1
  13. package/build-module/color-picker/component.js.map +2 -2
  14. package/build-module/confirm-dialog/component.js +6 -0
  15. package/build-module/confirm-dialog/component.js.map +2 -2
  16. package/build-module/custom-select-control/index.js +18 -14
  17. package/build-module/custom-select-control/index.js.map +2 -2
  18. package/build-module/modal/index.js +1 -0
  19. package/build-module/modal/index.js.map +2 -2
  20. package/build-module/utils/math.js +2 -2
  21. package/build-module/utils/math.js.map +2 -2
  22. package/build-style/style-rtl.css +3 -3
  23. package/build-style/style.css +3 -3
  24. package/build-types/alignment-matrix-control/styles.d.ts.map +1 -1
  25. package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +1 -1
  26. package/build-types/autocomplete/get-default-use-items.d.ts.map +1 -1
  27. package/build-types/base-control/styles/base-control-styles.d.ts.map +1 -1
  28. package/build-types/border-box-control/styles.d.ts.map +1 -1
  29. package/build-types/border-box-control/utils.d.ts.map +1 -1
  30. package/build-types/border-control/styles.d.ts.map +1 -1
  31. package/build-types/box-control/styles/box-control-icon-styles.d.ts.map +1 -1
  32. package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
  33. package/build-types/calendar/date-calendar/index.d.ts.map +1 -1
  34. package/build-types/calendar/date-range-calendar/index.d.ts.map +1 -1
  35. package/build-types/calendar/test/__utils__/index.d.ts.map +1 -1
  36. package/build-types/calendar/utils/use-localization-props.d.ts.map +1 -1
  37. package/build-types/card/card/hook.d.ts.map +1 -1
  38. package/build-types/card/card-body/component.d.ts.map +1 -1
  39. package/build-types/card/card-body/hook.d.ts.map +1 -1
  40. package/build-types/card/card-footer/component.d.ts.map +1 -1
  41. package/build-types/card/card-footer/hook.d.ts.map +1 -1
  42. package/build-types/card/card-header/component.d.ts.map +1 -1
  43. package/build-types/card/card-header/hook.d.ts.map +1 -1
  44. package/build-types/card/card-media/hook.d.ts.map +1 -1
  45. package/build-types/card/get-padding-by-size.d.ts.map +1 -1
  46. package/build-types/color-palette/utils.d.ts.map +1 -1
  47. package/build-types/color-picker/color-copy-button.d.ts.map +1 -1
  48. package/build-types/color-picker/color-input.d.ts.map +1 -1
  49. package/build-types/color-picker/component.d.ts.map +1 -1
  50. package/build-types/color-picker/hex-input.d.ts.map +1 -1
  51. package/build-types/color-picker/hsl-input.d.ts.map +1 -1
  52. package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
  53. package/build-types/color-picker/legacy-adapter.d.ts.map +1 -1
  54. package/build-types/color-picker/picker.d.ts.map +1 -1
  55. package/build-types/color-picker/rgb-input.d.ts.map +1 -1
  56. package/build-types/color-picker/styles.d.ts.map +1 -1
  57. package/build-types/combobox-control/stories/index.story.d.ts.map +1 -1
  58. package/build-types/composite/index.d.ts.map +1 -1
  59. package/build-types/confirm-dialog/component.d.ts.map +1 -1
  60. package/build-types/confirm-dialog/types.d.ts +6 -0
  61. package/build-types/confirm-dialog/types.d.ts.map +1 -1
  62. package/build-types/custom-select-control/index.d.ts.map +1 -1
  63. package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -1
  64. package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
  65. package/build-types/date-time/date/styles.d.ts.map +1 -1
  66. package/build-types/date-time/date/use-lilius/index.d.ts.map +1 -1
  67. package/build-types/date-time/time/styles.d.ts.map +1 -1
  68. package/build-types/date-time/utils.d.ts.map +1 -1
  69. package/build-types/dimension-control/sizes.d.ts.map +1 -1
  70. package/build-types/divider/styles.d.ts.map +1 -1
  71. package/build-types/dropdown/styles.d.ts.map +1 -1
  72. package/build-types/focal-point-picker/stories/index.story.d.ts.map +1 -1
  73. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts.map +1 -1
  74. package/build-types/focal-point-picker/styles/focal-point-style.d.ts.map +1 -1
  75. package/build-types/font-size-picker/font-size-picker-select.d.ts.map +1 -1
  76. package/build-types/font-size-picker/font-size-picker-toggle-group.d.ts.map +1 -1
  77. package/build-types/font-size-picker/styles.d.ts.map +1 -1
  78. package/build-types/higher-order/with-fallback-styles/index.d.ts.map +1 -1
  79. package/build-types/higher-order/with-focus-return/index.d.ts.map +1 -1
  80. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  81. package/build-types/item-group/item/hook.d.ts.map +1 -1
  82. package/build-types/item-group/item-group/hook.d.ts.map +1 -1
  83. package/build-types/item-group/styles.d.ts.map +1 -1
  84. package/build-types/menu/index.d.ts.map +1 -1
  85. package/build-types/menu/styles.d.ts.map +1 -1
  86. package/build-types/menu-item/index.d.ts.map +1 -1
  87. package/build-types/menu-item/stories/index.story.d.ts.map +1 -1
  88. package/build-types/modal/index.d.ts.map +1 -1
  89. package/build-types/navigation/item/use-navigation-tree-item.d.ts.map +1 -1
  90. package/build-types/navigation/menu/use-navigation-tree-menu.d.ts.map +1 -1
  91. package/build-types/navigation/styles/navigation-styles.d.ts.map +1 -1
  92. package/build-types/navigation/utils.d.ts.map +1 -1
  93. package/build-types/palette-edit/styles.d.ts.map +1 -1
  94. package/build-types/popover/test/utils/index.d.ts.map +1 -1
  95. package/build-types/popover/utils.d.ts.map +1 -1
  96. package/build-types/progress-bar/styles.d.ts.map +1 -1
  97. package/build-types/radio-group/radio.d.ts.map +1 -1
  98. package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
  99. package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts.map +1 -1
  100. package/build-types/resizable-box/stories/index.story.d.ts.map +1 -1
  101. package/build-types/select-control/stories/index.story.d.ts.map +1 -1
  102. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  103. package/build-types/spinner/styles.d.ts.map +1 -1
  104. package/build-types/surface/hook.d.ts.map +1 -1
  105. package/build-types/surface/styles.d.ts.map +1 -1
  106. package/build-types/tabs/styles.d.ts.map +1 -1
  107. package/build-types/text-highlight/index.d.ts.map +1 -1
  108. package/build-types/textarea-control/styles/textarea-control-styles.d.ts.map +1 -1
  109. package/build-types/theme/styles.d.ts.map +1 -1
  110. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
  111. package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
  112. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts.map +1 -1
  113. package/build-types/toolbar/toolbar-button/toolbar-button-container.d.ts.map +1 -1
  114. package/build-types/toolbar/toolbar-group/toolbar-group-container.d.ts.map +1 -1
  115. package/build-types/tools-panel/styles.d.ts.map +1 -1
  116. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  117. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  118. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  119. package/build-types/unit-control/utils.d.ts.map +1 -1
  120. package/build-types/utils/get-node-text.d.ts.map +1 -1
  121. package/build-types/utils/strings.d.ts.map +1 -1
  122. package/build-types/utils/use-responsive-value.d.ts.map +1 -1
  123. package/build-types/utils/with-ignore-ime-events.d.ts.map +1 -1
  124. package/build-types/validated-form-controls/components/combobox-control.d.ts.map +1 -1
  125. package/build-types/validated-form-controls/components/select-control.d.ts.map +1 -1
  126. package/build-types/z-stack/styles.d.ts.map +1 -1
  127. package/package.json +20 -20
  128. package/src/button/style.scss +3 -3
  129. package/src/color-picker/component.tsx +52 -3
  130. package/src/confirm-dialog/component.tsx +6 -0
  131. package/src/confirm-dialog/test/index.tsx +66 -0
  132. package/src/confirm-dialog/types.ts +6 -0
  133. package/src/custom-select-control/index.tsx +23 -22
  134. package/src/modal/index.tsx +1 -0
  135. package/src/utils/math.js +2 -2
  136. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,12 +2,24 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- ## 30.7.1-next.0 (2025-11-05)
5
+ ## 30.8.0 (2025-11-12)
6
6
 
7
7
  ### Bug Fixes
8
8
 
9
+ - `Button`: Revert disabled primary button state to its previous one ([#73037](https://github.com/WordPress/gutenberg/pull/73037)).
9
10
  - `TextareaControl`: Add `min-height` to the textarea element ([#72867](https://github.com/WordPress/gutenberg/pull/72867)).
10
11
  - `Card`, `CardHeader`, `CardBody` and `CardFooter`: Add support for directional padding through object-based size prop, allowing independent control of padding for each side ([#72511](https://github.com/WordPress/gutenberg/pull/72511)).
12
+ - `CustomSelectControl`: Fix the options with the same name are shown as the selected option ([#72189](https://github.com/WordPress/gutenberg/pull/72189)).
13
+ - `NumberControl`: Fix crash when min prop is string and step prop contains decimal ([#73107](https://github.com/WordPress/gutenberg/pull/73107)).
14
+
15
+ ### Internal
16
+
17
+ - `Modal`: Add a classname to simplify full height content modal styling ([#73108](https://github.com/WordPress/gutenberg/pull/73108)).
18
+
19
+ ### Enhancements
20
+
21
+ - `ConfirmDialog`: Add `isBusy` prop to component. ([#73041](https://github.com/WordPress/gutenberg/pull/73041)).
22
+ - `ColorPicker`: Support pasting whole color values. ([#73166](https://github.com/WordPress/gutenberg/pull/73166)).
11
23
 
12
24
  ## 30.7.0 (2025-10-29)
13
25
 
@@ -79,9 +79,33 @@ var UnconnectedColorPicker = (props, forwardedRef) => {
79
79
  debouncedSetColor(nextValue.toHex());
80
80
  }, [debouncedSetColor]);
81
81
  const [colorType, setColorType] = (0, import_element.useState)(copyFormat || "hex");
82
+ const maybeHandlePaste = (0, import_element.useCallback)((event) => {
83
+ const pastedText = event.clipboardData?.getData("text")?.trim();
84
+ if (!pastedText) {
85
+ return;
86
+ }
87
+ const parsedColor = (0, import_colord.colord)(pastedText);
88
+ if (!parsedColor.isValid()) {
89
+ return;
90
+ }
91
+ handleChange(parsedColor);
92
+ const supportedFormats = {
93
+ hex: "hex",
94
+ rgb: "rgb",
95
+ hsl: "hsl"
96
+ };
97
+ const detectedFormat = String((0, import_colord.getFormat)(pastedText));
98
+ const newColorType = supportedFormats[detectedFormat];
99
+ if (newColorType) {
100
+ setColorType(newColorType);
101
+ }
102
+ event.stopPropagation();
103
+ event.preventDefault();
104
+ }, [handleChange, setColorType]);
82
105
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.ColorfulWrapper, {
83
106
  ref: forwardedRef,
84
107
  ...divProps,
108
+ onPasteCapture: maybeHandlePaste,
85
109
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_picker.Picker, {
86
110
  onChange: handleChange,
87
111
  color: safeColordColor,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/color-picker/component.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\n\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useState, useMemo } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useContextSystem, contextConnect } from '../context';\nimport { ColorfulWrapper, SelectControl, AuxiliaryColorArtefactWrapper, AuxiliaryColorArtefactHStackHeader, ColorInputWrapper } from './styles';\nimport { ColorCopyButton } from './color-copy-button';\nimport { ColorInput } from './color-input';\nimport { Picker } from './picker';\nimport { useControlledValue } from '../utils/hooks';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nextend([namesPlugin]);\nconst options = [{\n label: 'RGB',\n value: 'rgb'\n}, {\n label: 'HSL',\n value: 'hsl'\n}, {\n label: 'Hex',\n value: 'hex'\n}];\nconst UnconnectedColorPicker = (props, forwardedRef) => {\n const {\n enableAlpha = false,\n color: colorProp,\n onChange,\n defaultValue = '#fff',\n copyFormat,\n ...divProps\n } = useContextSystem(props, 'ColorPicker');\n\n // Use a safe default value for the color and remove the possibility of `undefined`.\n const [color, setColor] = useControlledValue({\n onChange,\n value: colorProp,\n defaultValue\n });\n const safeColordColor = useMemo(() => {\n return colord(color || '');\n }, [color]);\n const debouncedSetColor = useDebounce(setColor);\n const handleChange = useCallback(nextValue => {\n debouncedSetColor(nextValue.toHex());\n }, [debouncedSetColor]);\n const [colorType, setColorType] = useState(copyFormat || 'hex');\n return /*#__PURE__*/_jsxs(ColorfulWrapper, {\n ref: forwardedRef,\n ...divProps,\n children: [/*#__PURE__*/_jsx(Picker, {\n onChange: handleChange,\n color: safeColordColor,\n enableAlpha: enableAlpha\n }), /*#__PURE__*/_jsxs(AuxiliaryColorArtefactWrapper, {\n children: [/*#__PURE__*/_jsxs(AuxiliaryColorArtefactHStackHeader, {\n justify: \"space-between\",\n children: [/*#__PURE__*/_jsx(SelectControl, {\n __nextHasNoMarginBottom: true,\n size: \"compact\",\n options: options,\n value: colorType,\n onChange: nextColorType => setColorType(nextColorType),\n label: __('Color format'),\n hideLabelFromVision: true,\n variant: \"minimal\"\n }), /*#__PURE__*/_jsx(ColorCopyButton, {\n color: safeColordColor,\n colorType: copyFormat || colorType\n })]\n }), /*#__PURE__*/_jsx(ColorInputWrapper, {\n direction: \"column\",\n gap: 2,\n children: /*#__PURE__*/_jsx(ColorInput, {\n colorType: colorType,\n color: safeColordColor,\n onChange: handleChange,\n enableAlpha: enableAlpha\n })\n })]\n })]\n });\n};\nexport const ColorPicker = contextConnect(UnconnectedColorPicker, 'ColorPicker');\nexport default ColorPicker;"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAA+B;AAC/B,mBAAwB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c,uCAAAC,KAAK,6BAAe;AAAA,UAC1C,yBAAyB;AAAA,UACzB,MAAM;AAAA,UACN;AAAA,UACA,OAAO;AAAA,UACP,UAAU,mBAAiB,aAAa,aAAa;AAAA,UACrD,WAAO,gBAAG,cAAc;AAAA,UACxB,qBAAqB;AAAA,UACrB,SAAS;AAAA,QACX,CAAC,GAAgB,uCAAAA,KAAK,0CAAiB;AAAA,UACrC,OAAO;AAAA,UACP,WAAW,cAAc;AAAA,QAC3B,CAAC,CAAC;AAAA,MACJ,CAAC,GAAgB,uCAAAA,KAAK,iCAAmB;AAAA,QACvC,WAAW;AAAA,QACX,KAAK;AAAA,QACL,UAAuB,uCAAAA,KAAK,+BAAY;AAAA,UACtC;AAAA,UACA,OAAO;AAAA,UACP,UAAU;AAAA,UACV;AAAA,QACF,CAAC;AAAA,MACH,CAAC,CAAC;AAAA,IACJ,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACO,IAAM,kBAAc,+BAAe,wBAAwB,aAAa;AAC/E,IAAO,oBAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\n\nimport { colord, extend, getFormat } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useState, useMemo } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useContextSystem, contextConnect } from '../context';\nimport { ColorfulWrapper, SelectControl, AuxiliaryColorArtefactWrapper, AuxiliaryColorArtefactHStackHeader, ColorInputWrapper } from './styles';\nimport { ColorCopyButton } from './color-copy-button';\nimport { ColorInput } from './color-input';\nimport { Picker } from './picker';\nimport { useControlledValue } from '../utils/hooks';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nextend([namesPlugin]);\nconst options = [{\n label: 'RGB',\n value: 'rgb'\n}, {\n label: 'HSL',\n value: 'hsl'\n}, {\n label: 'Hex',\n value: 'hex'\n}];\nconst UnconnectedColorPicker = (props, forwardedRef) => {\n const {\n enableAlpha = false,\n color: colorProp,\n onChange,\n defaultValue = '#fff',\n copyFormat,\n ...divProps\n } = useContextSystem(props, 'ColorPicker');\n\n // Use a safe default value for the color and remove the possibility of `undefined`.\n const [color, setColor] = useControlledValue({\n onChange,\n value: colorProp,\n defaultValue\n });\n const safeColordColor = useMemo(() => {\n return colord(color || '');\n }, [color]);\n const debouncedSetColor = useDebounce(setColor);\n const handleChange = useCallback(nextValue => {\n debouncedSetColor(nextValue.toHex());\n }, [debouncedSetColor]);\n const [colorType, setColorType] = useState(copyFormat || 'hex');\n\n /*\n * ! Listener intended for the CAPTURE phase\n *\n * Capture paste events over the entire color picker, looking for clipboard\n * data that could be parsed as a color. If not, let the paste event\n * propagate normally, so that individual input controls within the\n * component have a chance to handle it.\n */\n const maybeHandlePaste = useCallback(event => {\n const pastedText = event.clipboardData?.getData('text')?.trim();\n if (!pastedText) {\n return;\n }\n const parsedColor = colord(pastedText);\n if (!parsedColor.isValid()) {\n return;\n }\n\n // Apply all valid colors, even if the format isn't supported in\n // the UI (e.g. names like \"cyan\" or, in the future color spaces\n // like \"lch\" if we add the right colord plugins)\n handleChange(parsedColor);\n\n // This redundancy helps TypeScript and is safer than assertions\n const supportedFormats = {\n hex: 'hex',\n rgb: 'rgb',\n hsl: 'hsl'\n };\n const detectedFormat = String(getFormat(pastedText));\n const newColorType = supportedFormats[detectedFormat];\n if (newColorType) {\n setColorType(newColorType);\n }\n\n // Stop at capture phase; no bubbling\n event.stopPropagation();\n event.preventDefault();\n }, [handleChange, setColorType]);\n return /*#__PURE__*/_jsxs(ColorfulWrapper, {\n ref: forwardedRef,\n ...divProps,\n onPasteCapture: maybeHandlePaste,\n children: [/*#__PURE__*/_jsx(Picker, {\n onChange: handleChange,\n color: safeColordColor,\n enableAlpha: enableAlpha\n }), /*#__PURE__*/_jsxs(AuxiliaryColorArtefactWrapper, {\n children: [/*#__PURE__*/_jsxs(AuxiliaryColorArtefactHStackHeader, {\n justify: \"space-between\",\n children: [/*#__PURE__*/_jsx(SelectControl, {\n __nextHasNoMarginBottom: true,\n size: \"compact\",\n options: options,\n value: colorType,\n onChange: nextColorType => setColorType(nextColorType),\n label: __('Color format'),\n hideLabelFromVision: true,\n variant: \"minimal\"\n }), /*#__PURE__*/_jsx(ColorCopyButton, {\n color: safeColordColor,\n colorType: copyFormat || colorType\n })]\n }), /*#__PURE__*/_jsx(ColorInputWrapper, {\n direction: \"column\",\n gap: 2,\n children: /*#__PURE__*/_jsx(ColorInput, {\n colorType: colorType,\n color: safeColordColor,\n onChange: handleChange,\n enableAlpha: enableAlpha\n })\n })]\n })]\n });\n};\nexport const ColorPicker = contextConnect(UnconnectedColorPicker, 'ColorPicker');\nexport default ColorPicker;"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAA0C;AAC1C,mBAAwB;AAKxB,qBAA+C;AAC/C,qBAA4B;AAC5B,kBAAmB;AAKnB,qBAAiD;AACjD,oBAAqI;AACrI,+BAAgC;AAChC,yBAA2B;AAC3B,oBAAuB;AACvB,mBAAmC;AACnC,yBAA2C;AAAA,IAC3C,sBAAO,CAAC,aAAAA,OAAW,CAAC;AACpB,IAAM,UAAU,CAAC;AAAA,EACf,OAAO;AAAA,EACP,OAAO;AACT,GAAG;AAAA,EACD,OAAO;AAAA,EACP,OAAO;AACT,GAAG;AAAA,EACD,OAAO;AAAA,EACP,OAAO;AACT,CAAC;AACD,IAAM,yBAAyB,CAAC,OAAO,iBAAiB;AACtD,QAAM;AAAA,IACJ,cAAc;AAAA,IACd,OAAO;AAAA,IACP;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA,GAAG;AAAA,EACL,QAAI,iCAAiB,OAAO,aAAa;AAGzC,QAAM,CAAC,OAAO,QAAQ,QAAI,iCAAmB;AAAA,IAC3C;AAAA,IACA,OAAO;AAAA,IACP;AAAA,EACF,CAAC;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AO;AAAA,UACP,UAAU,mBAAiB,aAAa,aAAa;AAAA,UACrD,WAAO,gBAAG,cAAc;AAAA,UACxB,qBAAqB;AAAA,UACrB,SAAS;AAAA,QACX,CAAC,GAAgB,uCAAAA,KAAK,0CAAiB;AAAA,UACrC,OAAO;AAAA,UACP,WAAW,cAAc;AAAA,QAC3B,CAAC,CAAC;AAAA,MACJ,CAAC,GAAgB,uCAAAA,KAAK,iCAAmB;AAAA,QACvC,WAAW;AAAA,QACX,KAAK;AAAA,QACL,UAAuB,uCAAAA,KAAK,+BAAY;AAAA,UACtC;AAAA,UACA,OAAO;AAAA,UACP,UAAU;AAAA,UACV;AAAA,QACF,CAAC;AAAA,MACH,CAAC,CAAC;AAAA,IACJ,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACO,IAAM,kBAAc,+BAAe,wBAAwB,aAAa;AAC/E,IAAO,oBAAQ;",
6
6
  "names": ["namesPlugin", "_jsxs", "_jsx"]
7
7
  }
@@ -53,6 +53,7 @@ var UnconnectedConfirmDialog = (props, forwardedRef) => {
53
53
  children,
54
54
  confirmButtonText,
55
55
  cancelButtonText,
56
+ isBusy,
56
57
  ...otherProps
57
58
  } = (0, import_context.useContextSystem)(props, "ConfirmDialog");
58
59
  const cx = (0, import_use_cx.useCx)();
@@ -102,12 +103,17 @@ var UnconnectedConfirmDialog = (props, forwardedRef) => {
102
103
  ref: cancelButtonRef,
103
104
  variant: "tertiary",
104
105
  onClick: handleEvent(onCancel),
106
+ accessibleWhenDisabled: true,
107
+ disabled: isBusy,
105
108
  children: cancelLabel
106
109
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.default, {
107
110
  __next40pxDefaultSize: true,
108
111
  ref: confirmButtonRef,
109
112
  variant: "primary",
110
113
  onClick: handleEvent(onConfirm),
114
+ accessibleWhenDisabled: true,
115
+ disabled: isBusy,
116
+ isBusy,
111
117
  children: confirmLabel
112
118
  })]
113
119
  })]
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/confirm-dialog/component.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useEffect, useRef, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Modal from '../modal';\nimport { useContextSystem, contextConnect } from '../context';\nimport { Flex } from '../flex';\nimport Button from '../button';\nimport { Text } from '../text';\nimport { VStack } from '../v-stack';\nimport * as styles from './styles';\nimport { useCx } from '../utils/hooks/use-cx';\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nconst UnconnectedConfirmDialog = (props, forwardedRef) => {\n const {\n isOpen: isOpenProp,\n onConfirm,\n onCancel,\n children,\n confirmButtonText,\n cancelButtonText,\n ...otherProps\n } = useContextSystem(props, 'ConfirmDialog');\n const cx = useCx();\n const wrapperClassName = cx(styles.wrapper);\n const cancelButtonRef = useRef();\n const confirmButtonRef = useRef();\n const [isOpen, setIsOpen] = useState();\n const [shouldSelfClose, setShouldSelfClose] = useState();\n useEffect(() => {\n // We only allow the dialog to close itself if `isOpenProp` is *not* set.\n // If `isOpenProp` is set, then it (probably) means it's controlled by a\n // parent component. In that case, `shouldSelfClose` might do more harm than\n // good, so we disable it.\n const isIsOpenSet = typeof isOpenProp !== 'undefined';\n setIsOpen(isIsOpenSet ? isOpenProp : true);\n setShouldSelfClose(!isIsOpenSet);\n }, [isOpenProp]);\n const handleEvent = useCallback(callback => event => {\n callback?.(event);\n if (shouldSelfClose) {\n setIsOpen(false);\n }\n }, [shouldSelfClose, setIsOpen]);\n const handleEnter = useCallback(event => {\n // Avoid triggering the 'confirm' action when a button is focused,\n // as this can cause a double submission.\n const isConfirmOrCancelButton = event.target === cancelButtonRef.current || event.target === confirmButtonRef.current;\n if (!isConfirmOrCancelButton && event.key === 'Enter') {\n handleEvent(onConfirm)(event);\n }\n }, [handleEvent, onConfirm]);\n const cancelLabel = cancelButtonText !== null && cancelButtonText !== void 0 ? cancelButtonText : __('Cancel');\n const confirmLabel = confirmButtonText !== null && confirmButtonText !== void 0 ? confirmButtonText : __('OK');\n return /*#__PURE__*/_jsx(_Fragment, {\n children: isOpen && /*#__PURE__*/_jsx(Modal, {\n onRequestClose: handleEvent(onCancel),\n onKeyDown: handleEnter,\n closeButtonLabel: cancelLabel,\n isDismissible: true,\n ref: forwardedRef,\n overlayClassName: wrapperClassName,\n __experimentalHideHeader: true,\n ...otherProps,\n children: /*#__PURE__*/_jsxs(VStack, {\n spacing: 8,\n children: [/*#__PURE__*/_jsx(Text, {\n children: children\n }), /*#__PURE__*/_jsxs(Flex, {\n direction: \"row\",\n justify: \"flex-end\",\n children: [/*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n ref: cancelButtonRef,\n variant: \"tertiary\",\n onClick: handleEvent(onCancel),\n children: cancelLabel\n }), /*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n ref: confirmButtonRef,\n variant: \"primary\",\n onClick: handleEvent(onConfirm),\n children: confirmLabel\n })]\n })]\n })\n })\n });\n};\n\n/**\n * `ConfirmDialog` is built of top of [`Modal`](/packages/components/src/modal/README.md)\n * and displays a confirmation dialog, with _confirm_ and _cancel_ buttons.\n * The dialog is confirmed by clicking the _confirm_ button or by pressing the `Enter` key.\n * It is cancelled (closed) by clicking the _cancel_ button, by pressing the `ESC` key, or by\n * clicking outside the dialog focus (i.e, the overlay).\n *\n * `ConfirmDialog` has two main implicit modes: controlled and uncontrolled.\n *\n * UnControlled:\n *\n * Allows the component to be used standalone, just by declaring it as part of another React's component render method:\n * - It will be automatically open (displayed) upon mounting;\n * - It will be automatically closed when clicking the _cancel_ button, by pressing the `ESC` key, or by clicking outside the dialog focus (i.e, the overlay);\n * - `onCancel` is not mandatory but can be passed. Even if passed, the dialog will still be able to close itself.\n *\n * Activating this mode is as simple as omitting the `isOpen` prop. The only mandatory prop, in this case, is the `onConfirm` callback. The message is passed as the `children`. You can pass any JSX you'd like, which allows to further format the message or include sub-component if you'd like:\n *\n * ```jsx\n * import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n *\n * function Example() {\n * \treturn (\n * \t\t<ConfirmDialog onConfirm={ () => console.debug( ' Confirmed! ' ) }>\n * \t\t\tAre you sure? <strong>This action cannot be undone!</strong>\n * \t\t</ConfirmDialog>\n * \t);\n * }\n * ```\n *\n *\n * Controlled mode:\n * Let the parent component control when the dialog is open/closed. It's activated when a\n * boolean value is passed to `isOpen`:\n * - It will not be automatically closed. You need to let it know when to open/close by updating the value of the `isOpen` prop;\n * - Both `onConfirm` and the `onCancel` callbacks are mandatory props in this mode;\n * - You'll want to update the state that controls `isOpen` by updating it from the `onCancel` and `onConfirm` callbacks.\n *\n *```jsx\n * import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * function Example() {\n * \tconst [ isOpen, setIsOpen ] = useState( true );\n *\n * \tconst handleConfirm = () => {\n * \t\tconsole.debug( 'Confirmed!' );\n * \t\tsetIsOpen( false );\n * \t};\n *\n * \tconst handleCancel = () => {\n * \t\tconsole.debug( 'Cancelled!' );\n * \t\tsetIsOpen( false );\n * \t};\n *\n * \treturn (\n * \t\t<ConfirmDialog\n * \t\t\tisOpen={ isOpen }\n * \t\t\tonConfirm={ handleConfirm }\n * \t\t\tonCancel={ handleCancel }\n * \t\t>\n * \t\t\tAre you sure? <strong>This action cannot be undone!</strong>\n * \t\t</ConfirmDialog>\n * \t);\n * }\n * ```\n */\nexport const ConfirmDialog = contextConnect(UnconnectedConfirmDialog, 'ConfirmDialog');\nexport default ConfirmDialog;"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,qBAAyD;AAKzD,mBAAkB;AAClB,qBAAiD;AACjD,kBAAqB;AACrB,oBAAmB;AACnB,kBAAqB;AACrB,qBAAuB;AACvB,aAAwB;AACxB,oB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AAA,MACX,kBAAkB;AAAA,MAClB,eAAe;AAAA,MACf,KAAK;AAAA,MACL,kBAAkB;AAAA,MAClB,0BAA0B;AAAA,MAC1B,GAAG;AAAA,MACH,UAAuB,uCAAAC,MAAM,uBAAQ;AAAA,QACnC,SAAS;AAAA,QACT,UAAU,CAAc,uCAAAH,KAAK,kBAAM;AAAA,UACjC;AAAA,QACF,CAAC,GAAgB,uCAAAG,MAAM,kBAAM;AAAA,UAC3B,WAAW;AAAA,UACX,SAAS;AAAA,UACT,UAAU,CAAc,uCAAAH,KAAK,cAAAI,SAAQ;AAAA,YACnC,uBAAuB;AAAA,YACvB,KAAK;AAAA,YACL,SAAS;AAAA,YACT,SAAS,YAAY,QAAQ;AAAA,YAC7B,UAAU;AAAA,UACZ,CAAC,GAAgB,uCAAAJ,KAAK,cAAAI,SAAQ;AAAA,YAC5B,uBAAuB;AAAA,YACvB,KAAK;AAAA,YACL,SAAS;AAAA,YACT,SAAS,YAAY,SAAS;AAAA,YAC9B,UAAU;AAAA,UACZ,CAAC,CAAC;AAAA,QACJ,CAAC,CAAC;AAAA,MACJ,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;AAqEO,IAAM,oBAAgB,+BAAe,0BAA0B,eAAe;AACrF,IAAO,oBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useEffect, useRef, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Modal from '../modal';\nimport { useContextSystem, contextConnect } from '../context';\nimport { Flex } from '../flex';\nimport Button from '../button';\nimport { Text } from '../text';\nimport { VStack } from '../v-stack';\nimport * as styles from './styles';\nimport { useCx } from '../utils/hooks/use-cx';\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nconst UnconnectedConfirmDialog = (props, forwardedRef) => {\n const {\n isOpen: isOpenProp,\n onConfirm,\n onCancel,\n children,\n confirmButtonText,\n cancelButtonText,\n isBusy,\n ...otherProps\n } = useContextSystem(props, 'ConfirmDialog');\n const cx = useCx();\n const wrapperClassName = cx(styles.wrapper);\n const cancelButtonRef = useRef();\n const confirmButtonRef = useRef();\n const [isOpen, setIsOpen] = useState();\n const [shouldSelfClose, setShouldSelfClose] = useState();\n useEffect(() => {\n // We only allow the dialog to close itself if `isOpenProp` is *not* set.\n // If `isOpenProp` is set, then it (probably) means it's controlled by a\n // parent component. In that case, `shouldSelfClose` might do more harm than\n // good, so we disable it.\n const isIsOpenSet = typeof isOpenProp !== 'undefined';\n setIsOpen(isIsOpenSet ? isOpenProp : true);\n setShouldSelfClose(!isIsOpenSet);\n }, [isOpenProp]);\n const handleEvent = useCallback(callback => event => {\n callback?.(event);\n if (shouldSelfClose) {\n setIsOpen(false);\n }\n }, [shouldSelfClose, setIsOpen]);\n const handleEnter = useCallback(event => {\n // Avoid triggering the 'confirm' action when a button is focused,\n // as this can cause a double submission.\n const isConfirmOrCancelButton = event.target === cancelButtonRef.current || event.target === confirmButtonRef.current;\n if (!isConfirmOrCancelButton && event.key === 'Enter') {\n handleEvent(onConfirm)(event);\n }\n }, [handleEvent, onConfirm]);\n const cancelLabel = cancelButtonText !== null && cancelButtonText !== void 0 ? cancelButtonText : __('Cancel');\n const confirmLabel = confirmButtonText !== null && confirmButtonText !== void 0 ? confirmButtonText : __('OK');\n return /*#__PURE__*/_jsx(_Fragment, {\n children: isOpen && /*#__PURE__*/_jsx(Modal, {\n onRequestClose: handleEvent(onCancel),\n onKeyDown: handleEnter,\n closeButtonLabel: cancelLabel,\n isDismissible: true,\n ref: forwardedRef,\n overlayClassName: wrapperClassName,\n __experimentalHideHeader: true,\n ...otherProps,\n children: /*#__PURE__*/_jsxs(VStack, {\n spacing: 8,\n children: [/*#__PURE__*/_jsx(Text, {\n children: children\n }), /*#__PURE__*/_jsxs(Flex, {\n direction: \"row\",\n justify: \"flex-end\",\n children: [/*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n ref: cancelButtonRef,\n variant: \"tertiary\",\n onClick: handleEvent(onCancel),\n accessibleWhenDisabled: true,\n disabled: isBusy,\n children: cancelLabel\n }), /*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n ref: confirmButtonRef,\n variant: \"primary\",\n onClick: handleEvent(onConfirm),\n accessibleWhenDisabled: true,\n disabled: isBusy,\n isBusy: isBusy,\n children: confirmLabel\n })]\n })]\n })\n })\n });\n};\n\n/**\n * `ConfirmDialog` is built of top of [`Modal`](/packages/components/src/modal/README.md)\n * and displays a confirmation dialog, with _confirm_ and _cancel_ buttons.\n * The dialog is confirmed by clicking the _confirm_ button or by pressing the `Enter` key.\n * It is cancelled (closed) by clicking the _cancel_ button, by pressing the `ESC` key, or by\n * clicking outside the dialog focus (i.e, the overlay).\n *\n * `ConfirmDialog` has two main implicit modes: controlled and uncontrolled.\n *\n * UnControlled:\n *\n * Allows the component to be used standalone, just by declaring it as part of another React's component render method:\n * - It will be automatically open (displayed) upon mounting;\n * - It will be automatically closed when clicking the _cancel_ button, by pressing the `ESC` key, or by clicking outside the dialog focus (i.e, the overlay);\n * - `onCancel` is not mandatory but can be passed. Even if passed, the dialog will still be able to close itself.\n *\n * Activating this mode is as simple as omitting the `isOpen` prop. The only mandatory prop, in this case, is the `onConfirm` callback. The message is passed as the `children`. You can pass any JSX you'd like, which allows to further format the message or include sub-component if you'd like:\n *\n * ```jsx\n * import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n *\n * function Example() {\n * \treturn (\n * \t\t<ConfirmDialog onConfirm={ () => console.debug( ' Confirmed! ' ) }>\n * \t\t\tAre you sure? <strong>This action cannot be undone!</strong>\n * \t\t</ConfirmDialog>\n * \t);\n * }\n * ```\n *\n *\n * Controlled mode:\n * Let the parent component control when the dialog is open/closed. It's activated when a\n * boolean value is passed to `isOpen`:\n * - It will not be automatically closed. You need to let it know when to open/close by updating the value of the `isOpen` prop;\n * - Both `onConfirm` and the `onCancel` callbacks are mandatory props in this mode;\n * - You'll want to update the state that controls `isOpen` by updating it from the `onCancel` and `onConfirm` callbacks.\n *\n *```jsx\n * import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * function Example() {\n * \tconst [ isOpen, setIsOpen ] = useState( true );\n *\n * \tconst handleConfirm = () => {\n * \t\tconsole.debug( 'Confirmed!' );\n * \t\tsetIsOpen( false );\n * \t};\n *\n * \tconst handleCancel = () => {\n * \t\tconsole.debug( 'Cancelled!' );\n * \t\tsetIsOpen( false );\n * \t};\n *\n * \treturn (\n * \t\t<ConfirmDialog\n * \t\t\tisOpen={ isOpen }\n * \t\t\tonConfirm={ handleConfirm }\n * \t\t\tonCancel={ handleCancel }\n * \t\t>\n * \t\t\tAre you sure? <strong>This action cannot be undone!</strong>\n * \t\t</ConfirmDialog>\n * \t);\n * }\n * ```\n */\nexport const ConfirmDialog = contextConnect(UnconnectedConfirmDialog, 'ConfirmDialog');\nexport default ConfirmDialog;"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,qBAAyD;AAKzD,mBAAkB;AAClB,qBAAiD;AACjD,kBAAqB;AACrB,oBAAmB;AACnB,kBAAqB;AACrB,qBAAuB;AACvB,aAAwB;AACxB,oBAAsB;AACtB,yBAAkE;AAClE,IAAM,2BAA2B,CAAC,OAAO,iBAAiB;AACxD,QAAM;AAAA,IACJ,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,QAAI,iCAAiB,OAAO,eAAe;AAC3C,QAAM,SAAK,qBAAM;AACjB,QAAM,mBAAmB,GAAU,cAAO;AAC1C,QAAM,sBAAkB,uBAAO;AAC/B,QAAM,uBAAmB,uBAAO;AAChC,QAAM,CAAC,QAAQ,SAAS,QAAI,yBAAS;AACrC,QAAM,CAAC,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;AAAA,YACvB,KAAK;AAAA,YACL,SAAS;AAAA,YACT,SAAS,YAAY,QAAQ;AAAA,YAC7B,wBAAwB;AAAA,YACxB,UAAU;AAAA,YACV,UAAU;AAAA,UACZ,CAAC,GAAgB,uCAAAJ,KAAK,cAAAI,SAAQ;AAAA,YAC5B,uBAAuB;AAAA,YACvB,KAAK;AAAA,YACL,SAAS;AAAA,YACT,SAAS,YAAY,SAAS;AAAA,YAC9B,wBAAwB;AAAA,YACxB,UAAU;AAAA,YACV;AAAA,YACA,UAAU;AAAA,UACZ,CAAC,CAAC;AAAA,QACJ,CAAC,CAAC;AAAA,MACJ,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;AAqEO,IAAM,oBAAgB,+BAAe,0BAA0B,eAAe;AACrF,IAAO,oBAAQ;",
6
6
  "names": ["_jsx", "_Fragment", "Modal", "_jsxs", "Button"]
7
7
  }
@@ -61,13 +61,14 @@ function applyOptionDeprecations({
61
61
  ...rest
62
62
  };
63
63
  }
64
- function getDescribedBy(currentValue, describedBy) {
64
+ function getDescribedBy(currentName, describedBy) {
65
65
  if (describedBy) {
66
66
  return describedBy;
67
67
  }
68
- return (0, import_i18n.sprintf)((0, import_i18n.__)("Currently selected: %s"), currentValue);
68
+ return (0, import_i18n.sprintf)((0, import_i18n.__)("Currently selected: %s"), currentName);
69
69
  }
70
70
  function CustomSelectControl(props) {
71
+ var _options$map$find;
71
72
  const {
72
73
  __next40pxDefaultSize = false,
73
74
  __shouldNotWarnDeprecated36pxSize,
@@ -89,7 +90,7 @@ function CustomSelectControl(props) {
89
90
  const descriptionId = (0, import_compose.useInstanceId)(CustomSelectControl, "custom-select-control__description");
90
91
  const store = Ariakit.useSelectStore({
91
92
  async setValue(nextValue) {
92
- const nextOption = options.find((item) => item.name === nextValue);
93
+ const nextOption = options.find((item) => item.key === nextValue);
93
94
  if (!onChange || !nextOption) {
94
95
  return;
95
96
  }
@@ -104,12 +105,12 @@ function CustomSelectControl(props) {
104
105
  };
105
106
  onChange(changeObject);
106
107
  },
107
- value: value?.name,
108
+ value: value?.key,
108
109
  // Setting the first option as a default value when no value is provided
109
110
  // is already done natively by the underlying Ariakit component,
110
111
  // but doing this explicitly avoids the `onChange` callback from firing
111
112
  // on initial render, thus making this implementation closer to the v1.
112
- defaultValue: options[0]?.name
113
+ defaultValue: options[0]?.key
113
114
  });
114
115
  const children = options.map(applyOptionDeprecations).map(({
115
116
  name,
@@ -128,7 +129,7 @@ function CustomSelectControl(props) {
128
129
  })]
129
130
  });
130
131
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_item.default, {
131
- value: name,
132
+ value: key,
132
133
  children: hint ? withHint : name,
133
134
  style,
134
135
  className: (0, import_clsx.default)(
@@ -142,15 +143,18 @@ function CustomSelectControl(props) {
142
143
  }, key);
143
144
  });
144
145
  const currentValue = Ariakit.useStoreState(store, "value");
145
- const renderSelectedValueHint = () => {
146
- const selectedOptionHint = options?.map(applyOptionDeprecations)?.find(({
147
- name
148
- }) => currentValue === name)?.hint;
146
+ const selectedOption = (_options$map$find = options?.map(applyOptionDeprecations)?.find(({
147
+ key
148
+ }) => currentValue === key)) !== null && _options$map$find !== void 0 ? _options$map$find : options[0];
149
+ const renderSelectedValue = () => {
150
+ if (!showSelectedHint || !selectedOption.hint) {
151
+ return selectedOption?.name;
152
+ }
149
153
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Styled.SelectedExperimentalHintWrapper, {
150
- children: [currentValue, selectedOptionHint && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Styled.SelectedExperimentalHintItem, {
154
+ children: [selectedOption?.name, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Styled.SelectedExperimentalHintItem, {
151
155
  // Keeping the classname for legacy reasons
152
156
  className: "components-custom-select-control__hint",
153
- children: selectedOptionHint
157
+ children: selectedOption?.hint
154
158
  })]
155
159
  });
156
160
  };
@@ -166,7 +170,7 @@ function CustomSelectControl(props) {
166
170
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
167
171
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_custom_select.default, {
168
172
  "aria-describedby": descriptionId,
169
- renderSelectedValue: showSelectedHint ? renderSelectedValueHint : void 0,
173
+ renderSelectedValue,
170
174
  size: translatedSize,
171
175
  store,
172
176
  className: (0, import_clsx.default)(
@@ -180,7 +184,7 @@ function CustomSelectControl(props) {
180
184
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_visually_hidden.VisuallyHidden, {
181
185
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
182
186
  id: descriptionId,
183
- children: getDescribedBy(currentValue, describedBy)
187
+ children: getDescribedBy(selectedOption?.name, describedBy)
184
188
  })
185
189
  })]
186
190
  });
@@ -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 _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(currentValue, describedBy) {\n if (describedBy) {\n return describedBy;\n }\n\n // translators: %s: The selected option.\n return sprintf(__('Currently selected: %s'), currentValue);\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.name === 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?.name,\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]?.name\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: name,\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 renderSelectedValueHint = () => {\n const selectedOptionHint = options?.map(applyOptionDeprecations)?.find(({\n name\n }) => currentValue === name)?.hint;\n return /*#__PURE__*/_jsxs(Styled.SelectedExperimentalHintWrapper, {\n children: [currentValue, selectedOptionHint && /*#__PURE__*/_jsx(Styled.SelectedExperimentalHintItem, {\n // Keeping the classname for legacy reasons\n className: \"components-custom-select-control__hint\",\n children: selectedOptionHint\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: showSelectedHint ? renderSelectedValueHint : undefined,\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(currentValue, describedBy)\n })\n })]\n });\n}\nexport default CustomSelectControl;"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,cAAyB;AACzB,kBAAiB;AAKjB,qBAA8B;AAC9B,kBAA4B;AAK5B,2BAA0B;AAC1B,kBAA6B;AAC7B,aAAwB;AACxB,6BAA+B;AAC/B,kCAA4C;AAC5C,yBAAkE;AAClE,SAAS,mBAAmB;AAAA,EAC1B;AAAA,EACA,GAAG;AACL,GAAG;AACD,SAAO;AAAA,IACL,kBAAkB;AAAA,IAClB,GAAG;AAAA,EACL;AACF;AAKA,SAA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A,MACA,eAAW,YAAAF;AAAA;AAAA,QAEX;AAAA,QAAoC;AAAA,MAAa;AAAA,MACjD,UAAU;AAAA,MACV,GAAG;AAAA,MACH;AAAA,IACF,CAAC,GAAgB,uCAAAF,KAAK,uCAAgB;AAAA,MACpC,UAAuB,uCAAAA,KAAK,QAAQ;AAAA,QAClC,IAAI;AAAA,QACJ,UAAU,eAAe,cAAc,WAAW;AAAA,MACpD,CAAC;AAAA,IACH,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACA,IAAO,gCAAQ;",
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 var _options$map$find;\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$find = options?.map(applyOptionDeprecations)?.find(({\n key\n }) => currentValue === key)) !== null && _options$map$find !== void 0 ? _options$map$find : 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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,cAAyB;AACzB,kBAAiB;AAKjB,qBAA8B;AAC9B,kBAA4B;AAK5B,2BAA0B;AAC1B,kBAA6B;AAC7B,aAAwB;AACxB,6BAA+B;AAC/B,kCAA4C;AAC5C,yBAAkE;AAClE,SAAS,mBAAmB;AAAA,EAC1B;AAAA,EACA,GAAG;AACL,GAAG;AACD,SAAO;AAAA,IACL,kBAAkB;AAAA,IAClB,GAAG;AAAA,EACL;AACF;AAKA,SAAS,wBAAwB;AAAA,EAC/B;AAAA,EACA,GAAG;AACL,GAAG;AACD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,GAAG;AAAA,EACL;AACF;AACA,SAAS,eAAe,aAAa,aAAa;AAChD,MAAI,aAAa;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AEX;AAAA,QAAoC;AAAA,MAAa;AAAA,MACjD,UAAU;AAAA,MACV,GAAG;AAAA,MACH;AAAA,IACF,CAAC,GAAgB,uCAAAF,KAAK,uCAAgB;AAAA,MACpC,UAAuB,uCAAAA,KAAK,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": ["_jsxs", "_jsx", "CustomSelectItem", "clsx", "_Fragment", "_CustomSelect"]
7
7
  }
@@ -261,6 +261,7 @@ function UnforwardedModal(props, forwardedRef) {
261
261
  })]
262
262
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
263
263
  ref: (0, import_compose.useMergeRefs)([childrenContainerRef, focusOnMount === "firstContentElement" ? focusOnMountRef : null]),
264
+ className: "components-modal__children-container",
264
265
  children
265
266
  })]
266
267
  })
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/modal/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createPortal, useCallback, useEffect, useRef, useState, forwardRef, useLayoutEffect, createContext, useContext } from '@wordpress/element';\nimport { useInstanceId, useFocusReturn, useFocusOnMount, useConstrainedTabbing, useMergeRefs } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport * as ariaHelper from './aria-helper';\nimport Button from '../button';\nimport StyleProvider from '../style-provider';\nimport { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';\nimport { Spacer } from '../spacer';\nimport { useModalExitAnimation } from './use-modal-exit-animation';\n\n// Used to track and dismiss the prior modal when another opens unless nested.\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nconst ModalContext = createContext(new Set());\nModalContext.displayName = 'ModalContext';\n\n// Used to track body class names applied while modals are open.\nconst bodyOpenClasses = new Map();\nfunction UnforwardedModal(props, forwardedRef) {\n const {\n bodyOpenClassName = 'modal-open',\n role = 'dialog',\n title = null,\n focusOnMount = true,\n shouldCloseOnEsc = true,\n shouldCloseOnClickOutside = true,\n isDismissible = true,\n /* Accessibility. */\n aria = {\n labelledby: undefined,\n describedby: undefined\n },\n onRequestClose,\n icon,\n closeButtonLabel,\n children,\n style,\n overlayClassName: overlayClassnameProp,\n className,\n contentLabel,\n onKeyDown,\n isFullScreen = false,\n size,\n headerActions = null,\n __experimentalHideHeader = false\n } = props;\n const ref = useRef();\n const instanceId = useInstanceId(Modal);\n const headingId = title ? `components-modal-header-${instanceId}` : aria.labelledby;\n\n // The focus hook does not support 'firstContentElement' but this is a valid\n // value for the Modal's focusOnMount prop. The following code ensures the focus\n // hook will focus the first focusable node within the element to which it is applied.\n // When `firstContentElement` is passed as the value of the focusOnMount prop,\n // the focus hook is applied to the Modal's content element.\n // Otherwise, the focus hook is applied to the Modal's ref. This ensures that the\n // focus hook will focus the first element in the Modal's **content** when\n // `firstContentElement` is passed.\n const focusOnMountRef = useFocusOnMount(focusOnMount === 'firstContentElement' ? 'firstElement' : focusOnMount);\n const constrainedTabbingRef = useConstrainedTabbing();\n const focusReturnRef = useFocusReturn();\n const contentRef = useRef(null);\n const childrenContainerRef = useRef(null);\n const [hasScrolledContent, setHasScrolledContent] = useState(false);\n const [hasScrollableContent, setHasScrollableContent] = useState(false);\n let sizeClass;\n if (isFullScreen || size === 'fill') {\n sizeClass = 'is-full-screen';\n } else if (size) {\n sizeClass = `has-size-${size}`;\n }\n\n // Determines whether the Modal content is scrollable and updates the state.\n const isContentScrollable = useCallback(() => {\n if (!contentRef.current) {\n return;\n }\n const closestScrollContainer = getScrollContainer(contentRef.current);\n if (contentRef.current === closestScrollContainer) {\n setHasScrollableContent(true);\n } else {\n setHasScrollableContent(false);\n }\n }, [contentRef]);\n\n // Accessibly isolates/unisolates the modal.\n useEffect(() => {\n ariaHelper.modalize(ref.current);\n return () => ariaHelper.unmodalize();\n }, []);\n\n // Keeps a fresh ref for the subsequent effect.\n const onRequestCloseRef = useRef();\n useEffect(() => {\n onRequestCloseRef.current = onRequestClose;\n }, [onRequestClose]);\n\n // The list of `onRequestClose` callbacks of open (non-nested) Modals. Only\n // one should remain open at a time and the list enables closing prior ones.\n const dismissers = useContext(ModalContext);\n // Used for the tracking and dismissing any nested modals.\n const [nestedDismissers] = useState(() => new Set());\n\n // Updates the stack tracking open modals at this level and calls\n // onRequestClose for any prior and/or nested modals as applicable.\n useEffect(() => {\n // add this modal instance to the dismissers set\n dismissers.add(onRequestCloseRef);\n // request that all the other modals close themselves\n for (const dismisser of dismissers) {\n if (dismisser !== onRequestCloseRef) {\n dismisser.current?.();\n }\n }\n return () => {\n // request that all the nested modals close themselves\n for (const dismisser of nestedDismissers) {\n dismisser.current?.();\n }\n // remove this modal instance from the dismissers set\n dismissers.delete(onRequestCloseRef);\n };\n }, [dismissers, nestedDismissers]);\n\n // Adds/removes the value of bodyOpenClassName to body element.\n useEffect(() => {\n var _bodyOpenClasses$get;\n const theClass = bodyOpenClassName;\n const oneMore = 1 + ((_bodyOpenClasses$get = bodyOpenClasses.get(theClass)) !== null && _bodyOpenClasses$get !== void 0 ? _bodyOpenClasses$get : 0);\n bodyOpenClasses.set(theClass, oneMore);\n document.body.classList.add(bodyOpenClassName);\n return () => {\n const oneLess = bodyOpenClasses.get(theClass) - 1;\n if (oneLess === 0) {\n document.body.classList.remove(theClass);\n bodyOpenClasses.delete(theClass);\n } else {\n bodyOpenClasses.set(theClass, oneLess);\n }\n };\n }, [bodyOpenClassName]);\n const {\n closeModal,\n frameRef,\n frameStyle,\n overlayClassname\n } = useModalExitAnimation();\n\n // Calls the isContentScrollable callback when the Modal children container resizes.\n useLayoutEffect(() => {\n if (!window.ResizeObserver || !childrenContainerRef.current) {\n return;\n }\n const resizeObserver = new ResizeObserver(isContentScrollable);\n resizeObserver.observe(childrenContainerRef.current);\n isContentScrollable();\n return () => {\n resizeObserver.disconnect();\n };\n }, [isContentScrollable, childrenContainerRef]);\n function handleEscapeKeyDown(event) {\n if (shouldCloseOnEsc && (event.code === 'Escape' || event.key === 'Escape') && !event.defaultPrevented) {\n event.preventDefault();\n closeModal().then(() => onRequestClose(event));\n }\n }\n const onContentContainerScroll = useCallback(e => {\n var _e$currentTarget$scro;\n const scrollY = (_e$currentTarget$scro = e?.currentTarget?.scrollTop) !== null && _e$currentTarget$scro !== void 0 ? _e$currentTarget$scro : -1;\n if (!hasScrolledContent && scrollY > 0) {\n setHasScrolledContent(true);\n } else if (hasScrolledContent && scrollY <= 0) {\n setHasScrolledContent(false);\n }\n }, [hasScrolledContent]);\n let pressTarget = null;\n const overlayPressHandlers = {\n onPointerDown: event => {\n if (event.target === event.currentTarget) {\n pressTarget = event.target;\n // Avoids focus changing so that focus return works as expected.\n event.preventDefault();\n }\n },\n // Closes the modal with two exceptions. 1. Opening the context menu on\n // the overlay. 2. Pressing on the overlay then dragging the pointer\n // over the modal and releasing. Due to the modal being a child of the\n // overlay, such a gesture is a `click` on the overlay and cannot be\n // excepted by a `click` handler. Thus the tactic of handling\n // `pointerup` and comparing its target to that of the `pointerdown`.\n onPointerUp: ({\n target,\n button\n }) => {\n const isSameTarget = target === pressTarget;\n pressTarget = null;\n if (button === 0 && isSameTarget) {\n closeModal().then(() => onRequestClose());\n }\n }\n };\n const modal =\n /*#__PURE__*/\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n _jsx(\"div\", {\n ref: useMergeRefs([ref, forwardedRef]),\n className: clsx('components-modal__screen-overlay', overlayClassname, overlayClassnameProp),\n onKeyDown: withIgnoreIMEEvents(handleEscapeKeyDown),\n ...(shouldCloseOnClickOutside ? overlayPressHandlers : {}),\n children: /*#__PURE__*/_jsx(StyleProvider, {\n document: document,\n children: /*#__PURE__*/_jsx(\"div\", {\n className: clsx('components-modal__frame', sizeClass, className),\n style: {\n ...frameStyle,\n ...style\n },\n ref: useMergeRefs([frameRef, constrainedTabbingRef, focusReturnRef, focusOnMount !== 'firstContentElement' ? focusOnMountRef : null]),\n role: role,\n \"aria-label\": contentLabel,\n \"aria-labelledby\": contentLabel ? undefined : headingId,\n \"aria-describedby\": aria.describedby,\n tabIndex: -1,\n onKeyDown: onKeyDown,\n children: /*#__PURE__*/_jsxs(\"div\", {\n className: clsx('components-modal__content', {\n 'hide-header': __experimentalHideHeader,\n 'is-scrollable': hasScrollableContent,\n 'has-scrolled-content': hasScrolledContent\n }),\n role: \"document\",\n onScroll: onContentContainerScroll,\n ref: contentRef,\n \"aria-label\": hasScrollableContent ? __('Scrollable section') : undefined,\n tabIndex: hasScrollableContent ? 0 : undefined,\n children: [!__experimentalHideHeader && /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-modal__header\",\n children: [/*#__PURE__*/_jsxs(\"div\", {\n className: \"components-modal__header-heading-container\",\n children: [icon && /*#__PURE__*/_jsx(\"span\", {\n className: \"components-modal__icon-container\",\n \"aria-hidden\": true,\n children: icon\n }), title && /*#__PURE__*/_jsx(\"h1\", {\n id: headingId,\n className: \"components-modal__header-heading\",\n children: title\n })]\n }), headerActions, isDismissible && /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(Spacer, {\n marginBottom: 0,\n marginLeft: 2\n }), /*#__PURE__*/_jsx(Button, {\n size: \"compact\",\n onClick: event => closeModal().then(() => onRequestClose(event)),\n icon: close,\n label: closeButtonLabel || __('Close')\n })]\n })]\n }), /*#__PURE__*/_jsx(\"div\", {\n ref: useMergeRefs([childrenContainerRef, focusOnMount === 'firstContentElement' ? focusOnMountRef : null]),\n children: children\n })]\n })\n })\n })\n });\n return createPortal(/*#__PURE__*/_jsx(ModalContext.Provider, {\n value: nestedDismissers,\n children: modal\n }), document.body);\n}\n\n/**\n * Modals give users information and choices related to a task they\u2019re trying to\n * accomplish. They can contain critical information, require decisions, or\n * involve multiple tasks.\n *\n * ```jsx\n * import { Button, Modal } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyModal = () => {\n * const [ isOpen, setOpen ] = useState( false );\n * const openModal = () => setOpen( true );\n * const closeModal = () => setOpen( false );\n *\n * return (\n * <>\n * <Button variant=\"secondary\" onClick={ openModal }>\n * Open Modal\n * </Button>\n * { isOpen && (\n * <Modal title=\"This is my modal\" onRequestClose={ closeModal }>\n * <Button variant=\"secondary\" onClick={ closeModal }>\n * My custom close button\n * </Button>\n * </Modal>\n * ) }\n * </>\n * );\n * };\n * ```\n */\nexport const Modal = forwardRef(UnforwardedModal);\nexport default Modal;"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,qBAA+H;AAC/H,qBAAoG;AACpG,kBAAmB;AACnB,mBAAsB;AACtB,iBAAmC;AAKnC,iBAA4B;AAC5B,oBAAmB;AACnB,4BAA0B;AAC1B,oCAAoC;AACpC,oBAAuB;AACvB,sCAAsC;AAGtC,yBAAkE;AAClE,IAAM,mBAAe,8BAAc,oBAAI,IAAI,CAAC;AAC5C,aAAa,cAAc;AAG3B,IAAM,kBAAkB,oBAAI,IAAI;AAChC,SAAS,iBAAiB,OAAO,cAAc;AAC7C,QAAM;AAAA,IACJ,oBAAoB;AAAA,IACpB,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,4BAA4B;AAAA,IAC5B,gBAAgB;AAAA;AAAA,IAEhB,OAAO;AAAA,MACL,YAAY;AAAA,MACZ,aAAa;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA,gBAAgB;AAAA,IAChB,2BAA2B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AAK,6BAAa,CAAC,sBAAsB,iBAAiB,wBAAwB,kBAAkB,IAAI,CAAC;AAAA,cACzG;AAAA,YACF,CAAC,CAAC;AAAA,UACJ,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA;AACD,aAAO,6BAA0B,uCAAAA,KAAK,aAAa,UAAU;AAAA,IAC3D,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC,GAAG,SAAS,IAAI;AACnB;AAiCO,IAAM,YAAQ,2BAAW,gBAAgB;AAChD,IAAO,gBAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createPortal, useCallback, useEffect, useRef, useState, forwardRef, useLayoutEffect, createContext, useContext } from '@wordpress/element';\nimport { useInstanceId, useFocusReturn, useFocusOnMount, useConstrainedTabbing, useMergeRefs } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport * as ariaHelper from './aria-helper';\nimport Button from '../button';\nimport StyleProvider from '../style-provider';\nimport { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';\nimport { Spacer } from '../spacer';\nimport { useModalExitAnimation } from './use-modal-exit-animation';\n\n// Used to track and dismiss the prior modal when another opens unless nested.\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nconst ModalContext = createContext(new Set());\nModalContext.displayName = 'ModalContext';\n\n// Used to track body class names applied while modals are open.\nconst bodyOpenClasses = new Map();\nfunction UnforwardedModal(props, forwardedRef) {\n const {\n bodyOpenClassName = 'modal-open',\n role = 'dialog',\n title = null,\n focusOnMount = true,\n shouldCloseOnEsc = true,\n shouldCloseOnClickOutside = true,\n isDismissible = true,\n /* Accessibility. */\n aria = {\n labelledby: undefined,\n describedby: undefined\n },\n onRequestClose,\n icon,\n closeButtonLabel,\n children,\n style,\n overlayClassName: overlayClassnameProp,\n className,\n contentLabel,\n onKeyDown,\n isFullScreen = false,\n size,\n headerActions = null,\n __experimentalHideHeader = false\n } = props;\n const ref = useRef();\n const instanceId = useInstanceId(Modal);\n const headingId = title ? `components-modal-header-${instanceId}` : aria.labelledby;\n\n // The focus hook does not support 'firstContentElement' but this is a valid\n // value for the Modal's focusOnMount prop. The following code ensures the focus\n // hook will focus the first focusable node within the element to which it is applied.\n // When `firstContentElement` is passed as the value of the focusOnMount prop,\n // the focus hook is applied to the Modal's content element.\n // Otherwise, the focus hook is applied to the Modal's ref. This ensures that the\n // focus hook will focus the first element in the Modal's **content** when\n // `firstContentElement` is passed.\n const focusOnMountRef = useFocusOnMount(focusOnMount === 'firstContentElement' ? 'firstElement' : focusOnMount);\n const constrainedTabbingRef = useConstrainedTabbing();\n const focusReturnRef = useFocusReturn();\n const contentRef = useRef(null);\n const childrenContainerRef = useRef(null);\n const [hasScrolledContent, setHasScrolledContent] = useState(false);\n const [hasScrollableContent, setHasScrollableContent] = useState(false);\n let sizeClass;\n if (isFullScreen || size === 'fill') {\n sizeClass = 'is-full-screen';\n } else if (size) {\n sizeClass = `has-size-${size}`;\n }\n\n // Determines whether the Modal content is scrollable and updates the state.\n const isContentScrollable = useCallback(() => {\n if (!contentRef.current) {\n return;\n }\n const closestScrollContainer = getScrollContainer(contentRef.current);\n if (contentRef.current === closestScrollContainer) {\n setHasScrollableContent(true);\n } else {\n setHasScrollableContent(false);\n }\n }, [contentRef]);\n\n // Accessibly isolates/unisolates the modal.\n useEffect(() => {\n ariaHelper.modalize(ref.current);\n return () => ariaHelper.unmodalize();\n }, []);\n\n // Keeps a fresh ref for the subsequent effect.\n const onRequestCloseRef = useRef();\n useEffect(() => {\n onRequestCloseRef.current = onRequestClose;\n }, [onRequestClose]);\n\n // The list of `onRequestClose` callbacks of open (non-nested) Modals. Only\n // one should remain open at a time and the list enables closing prior ones.\n const dismissers = useContext(ModalContext);\n // Used for the tracking and dismissing any nested modals.\n const [nestedDismissers] = useState(() => new Set());\n\n // Updates the stack tracking open modals at this level and calls\n // onRequestClose for any prior and/or nested modals as applicable.\n useEffect(() => {\n // add this modal instance to the dismissers set\n dismissers.add(onRequestCloseRef);\n // request that all the other modals close themselves\n for (const dismisser of dismissers) {\n if (dismisser !== onRequestCloseRef) {\n dismisser.current?.();\n }\n }\n return () => {\n // request that all the nested modals close themselves\n for (const dismisser of nestedDismissers) {\n dismisser.current?.();\n }\n // remove this modal instance from the dismissers set\n dismissers.delete(onRequestCloseRef);\n };\n }, [dismissers, nestedDismissers]);\n\n // Adds/removes the value of bodyOpenClassName to body element.\n useEffect(() => {\n var _bodyOpenClasses$get;\n const theClass = bodyOpenClassName;\n const oneMore = 1 + ((_bodyOpenClasses$get = bodyOpenClasses.get(theClass)) !== null && _bodyOpenClasses$get !== void 0 ? _bodyOpenClasses$get : 0);\n bodyOpenClasses.set(theClass, oneMore);\n document.body.classList.add(bodyOpenClassName);\n return () => {\n const oneLess = bodyOpenClasses.get(theClass) - 1;\n if (oneLess === 0) {\n document.body.classList.remove(theClass);\n bodyOpenClasses.delete(theClass);\n } else {\n bodyOpenClasses.set(theClass, oneLess);\n }\n };\n }, [bodyOpenClassName]);\n const {\n closeModal,\n frameRef,\n frameStyle,\n overlayClassname\n } = useModalExitAnimation();\n\n // Calls the isContentScrollable callback when the Modal children container resizes.\n useLayoutEffect(() => {\n if (!window.ResizeObserver || !childrenContainerRef.current) {\n return;\n }\n const resizeObserver = new ResizeObserver(isContentScrollable);\n resizeObserver.observe(childrenContainerRef.current);\n isContentScrollable();\n return () => {\n resizeObserver.disconnect();\n };\n }, [isContentScrollable, childrenContainerRef]);\n function handleEscapeKeyDown(event) {\n if (shouldCloseOnEsc && (event.code === 'Escape' || event.key === 'Escape') && !event.defaultPrevented) {\n event.preventDefault();\n closeModal().then(() => onRequestClose(event));\n }\n }\n const onContentContainerScroll = useCallback(e => {\n var _e$currentTarget$scro;\n const scrollY = (_e$currentTarget$scro = e?.currentTarget?.scrollTop) !== null && _e$currentTarget$scro !== void 0 ? _e$currentTarget$scro : -1;\n if (!hasScrolledContent && scrollY > 0) {\n setHasScrolledContent(true);\n } else if (hasScrolledContent && scrollY <= 0) {\n setHasScrolledContent(false);\n }\n }, [hasScrolledContent]);\n let pressTarget = null;\n const overlayPressHandlers = {\n onPointerDown: event => {\n if (event.target === event.currentTarget) {\n pressTarget = event.target;\n // Avoids focus changing so that focus return works as expected.\n event.preventDefault();\n }\n },\n // Closes the modal with two exceptions. 1. Opening the context menu on\n // the overlay. 2. Pressing on the overlay then dragging the pointer\n // over the modal and releasing. Due to the modal being a child of the\n // overlay, such a gesture is a `click` on the overlay and cannot be\n // excepted by a `click` handler. Thus the tactic of handling\n // `pointerup` and comparing its target to that of the `pointerdown`.\n onPointerUp: ({\n target,\n button\n }) => {\n const isSameTarget = target === pressTarget;\n pressTarget = null;\n if (button === 0 && isSameTarget) {\n closeModal().then(() => onRequestClose());\n }\n }\n };\n const modal =\n /*#__PURE__*/\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n _jsx(\"div\", {\n ref: useMergeRefs([ref, forwardedRef]),\n className: clsx('components-modal__screen-overlay', overlayClassname, overlayClassnameProp),\n onKeyDown: withIgnoreIMEEvents(handleEscapeKeyDown),\n ...(shouldCloseOnClickOutside ? overlayPressHandlers : {}),\n children: /*#__PURE__*/_jsx(StyleProvider, {\n document: document,\n children: /*#__PURE__*/_jsx(\"div\", {\n className: clsx('components-modal__frame', sizeClass, className),\n style: {\n ...frameStyle,\n ...style\n },\n ref: useMergeRefs([frameRef, constrainedTabbingRef, focusReturnRef, focusOnMount !== 'firstContentElement' ? focusOnMountRef : null]),\n role: role,\n \"aria-label\": contentLabel,\n \"aria-labelledby\": contentLabel ? undefined : headingId,\n \"aria-describedby\": aria.describedby,\n tabIndex: -1,\n onKeyDown: onKeyDown,\n children: /*#__PURE__*/_jsxs(\"div\", {\n className: clsx('components-modal__content', {\n 'hide-header': __experimentalHideHeader,\n 'is-scrollable': hasScrollableContent,\n 'has-scrolled-content': hasScrolledContent\n }),\n role: \"document\",\n onScroll: onContentContainerScroll,\n ref: contentRef,\n \"aria-label\": hasScrollableContent ? __('Scrollable section') : undefined,\n tabIndex: hasScrollableContent ? 0 : undefined,\n children: [!__experimentalHideHeader && /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-modal__header\",\n children: [/*#__PURE__*/_jsxs(\"div\", {\n className: \"components-modal__header-heading-container\",\n children: [icon && /*#__PURE__*/_jsx(\"span\", {\n className: \"components-modal__icon-container\",\n \"aria-hidden\": true,\n children: icon\n }), title && /*#__PURE__*/_jsx(\"h1\", {\n id: headingId,\n className: \"components-modal__header-heading\",\n children: title\n })]\n }), headerActions, isDismissible && /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(Spacer, {\n marginBottom: 0,\n marginLeft: 2\n }), /*#__PURE__*/_jsx(Button, {\n size: \"compact\",\n onClick: event => closeModal().then(() => onRequestClose(event)),\n icon: close,\n label: closeButtonLabel || __('Close')\n })]\n })]\n }), /*#__PURE__*/_jsx(\"div\", {\n ref: useMergeRefs([childrenContainerRef, focusOnMount === 'firstContentElement' ? focusOnMountRef : null]),\n className: \"components-modal__children-container\",\n children: children\n })]\n })\n })\n })\n });\n return createPortal(/*#__PURE__*/_jsx(ModalContext.Provider, {\n value: nestedDismissers,\n children: modal\n }), document.body);\n}\n\n/**\n * Modals give users information and choices related to a task they\u2019re trying to\n * accomplish. They can contain critical information, require decisions, or\n * involve multiple tasks.\n *\n * ```jsx\n * import { Button, Modal } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyModal = () => {\n * const [ isOpen, setOpen ] = useState( false );\n * const openModal = () => setOpen( true );\n * const closeModal = () => setOpen( false );\n *\n * return (\n * <>\n * <Button variant=\"secondary\" onClick={ openModal }>\n * Open Modal\n * </Button>\n * { isOpen && (\n * <Modal title=\"This is my modal\" onRequestClose={ closeModal }>\n * <Button variant=\"secondary\" onClick={ closeModal }>\n * My custom close button\n * </Button>\n * </Modal>\n * ) }\n * </>\n * );\n * };\n * ```\n */\nexport const Modal = forwardRef(UnforwardedModal);\nexport default Modal;"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,qBAA+H;AAC/H,qBAAoG;AACpG,kBAAmB;AACnB,mBAAsB;AACtB,iBAAmC;AAKnC,iBAA4B;AAC5B,oBAAmB;AACnB,4BAA0B;AAC1B,oCAAoC;AACpC,oBAAuB;AACvB,sCAAsC;AAGtC,yBAAkE;AAClE,IAAM,mBAAe,8BAAc,oBAAI,IAAI,CAAC;AAC5C,aAAa,cAAc;AAG3B,IAAM,kBAAkB,oBAAI,IAAI;AAChC,SAAS,iBAAiB,OAAO,cAAc;AAC7C,QAAM;AAAA,IACJ,oBAAoB;AAAA,IACpB,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,4BAA4B;AAAA,IAC5B,gBAAgB;AAAA;AAAA,IAEhB,OAAO;AAAA,MACL,YAAY;AAAA,MACZ,aAAa;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA,gBAAgB;AAAA,IAChB,2BAA2B;AAAA,EAC7B,IAAI;AACJ,QAAM,UAAM,uBAAO;AACnB,QAAM,iBAAa,8BAAc,KAAK;AACtC,QAAM,YAAY,QAAQ,2BAA2B,UAAU,KAAK,KAAK;AAUzE,QAAM,sBAAkB,gCAAgB,iBAAiB,wBAAwB,iBAAiB,YAAY;AAC9G,QAAM,4BAAwB,sCAAsB;AACpD,QAAM,qBAAiB,+BAAe;AACtC,QAAM,iBAAa,uBAAO,IAAI;AAC9B,QAAM,2BAAuB,uBAAO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ACnB;AAiCO,IAAM,YAAQ,2BAAW,gBAAgB;AAChD,IAAO,gBAAQ;",
6
6
  "names": ["_jsx", "clsx", "StyleProvider", "_jsxs", "_Fragment", "Button"]
7
7
  }
@@ -58,10 +58,10 @@ function clamp(value, min, max) {
58
58
  }
59
59
  function ensureValidStep(value, min, step) {
60
60
  const baseValue = getNumber(value);
61
+ const minValue = getNumber(min);
61
62
  const stepValue = getNumber(step);
62
63
  const precision = Math.max(getPrecision(step), getPrecision(min));
63
- const realMin = Math.abs(min) === Infinity ? 0 : min;
64
- const tare = realMin % stepValue ? realMin : 0;
64
+ const tare = minValue % stepValue ? minValue : 0;
65
65
  const rounded = Math.round((baseValue - tare) / stepValue) * stepValue;
66
66
  const fromMin = rounded + tare;
67
67
  return precision ? getNumber(fromMin.toFixed(precision)) : fromMin;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/math.js"],
4
- "sourcesContent": ["/**\n * Parses and retrieves a number value.\n *\n * @param {unknown} value The incoming value.\n *\n * @return {number} The parsed number value.\n */\nexport function getNumber(value) {\n const number = Number(value);\n return isNaN(number) ? 0 : number;\n}\n\n/**\n * Safely adds 2 values.\n *\n * @param {Array<number|string>} args Values to add together.\n *\n * @return {number} The sum of values.\n */\nexport function add(...args) {\n return args.reduce(/** @type {(sum:number, arg: number|string) => number} */\n (sum, arg) => sum + getNumber(arg), 0);\n}\n\n/**\n * Safely subtracts 2 values.\n *\n * @param {Array<number|string>} args Values to subtract together.\n *\n * @return {number} The difference of the values.\n */\nexport function subtract(...args) {\n return args.reduce(/** @type {(diff:number, arg: number|string, index:number) => number} */\n (diff, arg, index) => {\n const value = getNumber(arg);\n return index === 0 ? value : diff - value;\n }, 0);\n}\n\n/**\n * Determines the decimal position of a number value.\n *\n * @param {number} value The number to evaluate.\n *\n * @return {number} The number of decimal places.\n */\nfunction getPrecision(value) {\n const split = (value + '').split('.');\n return split[1] !== undefined ? split[1].length : 0;\n}\n\n/**\n * Clamps a value based on a min/max range.\n *\n * @param {number|string} value The value.\n * @param {number} min The minimum range.\n * @param {number} max The maximum range.\n *\n * @return {number} The clamped value.\n */\nexport function clamp(value, min, max) {\n const baseValue = getNumber(value);\n return Math.max(min, Math.min(baseValue, max));\n}\n\n/**\n * Rounds a value to the nearest step offset by a minimum.\n *\n * @param {number|string} value The value.\n * @param {number} min The minimum range.\n * @param {number} step The increment for the value.\n *\n * @return {number} The value as a valid step.\n */\nexport function ensureValidStep(value, min, step) {\n const baseValue = getNumber(value);\n const stepValue = getNumber(step);\n const precision = Math.max(getPrecision(step), getPrecision(min));\n const realMin = Math.abs(min) === Infinity ? 0 : min;\n // If the step is not a factor of the minimum then the step must be\n // offset by the minimum.\n const tare = realMin % stepValue ? realMin : 0;\n const rounded = Math.round((baseValue - tare) / stepValue) * stepValue;\n const fromMin = rounded + tare;\n return precision ? getNumber(fromMin.toFixed(precision)) : fromMin;\n}"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,UAAU,OAAO;AAC/B,QAAM,SAAS,OAAO,KAAK;AAC3B,SAAO,MAAM,MAAM,IAAI,IAAI;AAC7B;AASO,SAAS,OAAO,MAAM;AAC3B,SAAO,KAAK;AAAA;AAAA,IACZ,CAAC,KAAK,QAAQ,MAAM,UAAU,GAAG;AAAA,IAAG;AAAA,EAAC;AACvC;AASO,SAAS,YAAY,MAAM;AAChC,SAAO,KAAK;AAAA;AAAA,IACZ,CAAC,MAAM,KAAK,UAAU;AACpB,YAAM,QAAQ,UAAU,GAAG;AAC3B,aAAO,UAAU,IAAI,QAAQ,OAAO;AAAA,IACtC;AAAA,IAAG;AAAA,EAAC;AACN;AASA,SAAS,aAAa,OAAO;AAC3B,QAAM,SAAS,QAAQ,IAAI,MAAM,GAAG;AACpC,SAAO,MAAM,CAAC,MAAM,SAAY,MAAM,CAAC,EAAE,SAAS;AACpD;AAWO,SAAS,MAAM,OAAO,KAAK,KAAK;AACrC,QAAM,YAAY,UAAU,KAAK;AACjC,SAAO,KAAK,IAAI,KAAK,KAAK,IAAI,WAAW,GAAG,CAAC;AAC/C;AAWO,SAAS,gBAAgB,OAAO,KAAK,MAAM;AAChD,QAAM,YAAY,UAAU,KAAK;AACjC,QAAM,YAAY,UAAU,IAAI;AAChC,QAAM,YAAY,KAAK,IAAI,aAAa,IAAI,GAAG,aAAa,GAAG,CAAC;AAChE,QAAM,UAAU,KAAK,IAAI,GAAG,MAAM,WAAW,IAAI;AAGjD,QAAM,OAAO,UAAU,YAAY,UAAU;AAC7C,QAAM,UAAU,KAAK,OAAO,YAAY,QAAQ,SAAS,IAAI;AAC7D,QAAM,UAAU,UAAU;AAC1B,SAAO,YAAY,UAAU,QAAQ,QAAQ,SAAS,CAAC,IAAI;AAC7D;",
4
+ "sourcesContent": ["/**\n * Parses and retrieves a number value.\n *\n * @param {unknown} value The incoming value.\n *\n * @return {number} The parsed number value.\n */\nexport function getNumber(value) {\n const number = Number(value);\n return isNaN(number) ? 0 : number;\n}\n\n/**\n * Safely adds 2 values.\n *\n * @param {Array<number|string>} args Values to add together.\n *\n * @return {number} The sum of values.\n */\nexport function add(...args) {\n return args.reduce(/** @type {(sum:number, arg: number|string) => number} */\n (sum, arg) => sum + getNumber(arg), 0);\n}\n\n/**\n * Safely subtracts 2 values.\n *\n * @param {Array<number|string>} args Values to subtract together.\n *\n * @return {number} The difference of the values.\n */\nexport function subtract(...args) {\n return args.reduce(/** @type {(diff:number, arg: number|string, index:number) => number} */\n (diff, arg, index) => {\n const value = getNumber(arg);\n return index === 0 ? value : diff - value;\n }, 0);\n}\n\n/**\n * Determines the decimal position of a number value.\n *\n * @param {number} value The number to evaluate.\n *\n * @return {number} The number of decimal places.\n */\nfunction getPrecision(value) {\n const split = (value + '').split('.');\n return split[1] !== undefined ? split[1].length : 0;\n}\n\n/**\n * Clamps a value based on a min/max range.\n *\n * @param {number|string} value The value.\n * @param {number} min The minimum range.\n * @param {number} max The maximum range.\n *\n * @return {number} The clamped value.\n */\nexport function clamp(value, min, max) {\n const baseValue = getNumber(value);\n return Math.max(min, Math.min(baseValue, max));\n}\n\n/**\n * Rounds a value to the nearest step offset by a minimum.\n *\n * @param {number|string} value The value.\n * @param {number} min The minimum range.\n * @param {number} step The increment for the value.\n *\n * @return {number} The value as a valid step.\n */\nexport function ensureValidStep(value, min, step) {\n const baseValue = getNumber(value);\n const minValue = getNumber(min);\n const stepValue = getNumber(step);\n const precision = Math.max(getPrecision(step), getPrecision(min));\n // If the step is not a factor of the minimum then the step must be\n // offset by the minimum.\n const tare = minValue % stepValue ? minValue : 0;\n const rounded = Math.round((baseValue - tare) / stepValue) * stepValue;\n const fromMin = rounded + tare;\n return precision ? getNumber(fromMin.toFixed(precision)) : fromMin;\n}"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,UAAU,OAAO;AAC/B,QAAM,SAAS,OAAO,KAAK;AAC3B,SAAO,MAAM,MAAM,IAAI,IAAI;AAC7B;AASO,SAAS,OAAO,MAAM;AAC3B,SAAO,KAAK;AAAA;AAAA,IACZ,CAAC,KAAK,QAAQ,MAAM,UAAU,GAAG;AAAA,IAAG;AAAA,EAAC;AACvC;AASO,SAAS,YAAY,MAAM;AAChC,SAAO,KAAK;AAAA;AAAA,IACZ,CAAC,MAAM,KAAK,UAAU;AACpB,YAAM,QAAQ,UAAU,GAAG;AAC3B,aAAO,UAAU,IAAI,QAAQ,OAAO;AAAA,IACtC;AAAA,IAAG;AAAA,EAAC;AACN;AASA,SAAS,aAAa,OAAO;AAC3B,QAAM,SAAS,QAAQ,IAAI,MAAM,GAAG;AACpC,SAAO,MAAM,CAAC,MAAM,SAAY,MAAM,CAAC,EAAE,SAAS;AACpD;AAWO,SAAS,MAAM,OAAO,KAAK,KAAK;AACrC,QAAM,YAAY,UAAU,KAAK;AACjC,SAAO,KAAK,IAAI,KAAK,KAAK,IAAI,WAAW,GAAG,CAAC;AAC/C;AAWO,SAAS,gBAAgB,OAAO,KAAK,MAAM;AAChD,QAAM,YAAY,UAAU,KAAK;AACjC,QAAM,WAAW,UAAU,GAAG;AAC9B,QAAM,YAAY,UAAU,IAAI;AAChC,QAAM,YAAY,KAAK,IAAI,aAAa,IAAI,GAAG,aAAa,GAAG,CAAC;AAGhE,QAAM,OAAO,WAAW,YAAY,WAAW;AAC/C,QAAM,UAAU,KAAK,OAAO,YAAY,QAAQ,SAAS,IAAI;AAC7D,QAAM,UAAU,UAAU;AAC1B,SAAO,YAAY,UAAU,QAAQ,QAAQ,SAAS,CAAC,IAAI;AAC7D;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,5 @@
1
1
  // packages/components/src/color-picker/component.tsx
2
- import { colord, extend } from "colord";
2
+ import { colord, extend, getFormat } from "colord";
3
3
  import namesPlugin from "colord/plugins/names";
4
4
  import { useCallback, useState, useMemo } from "@wordpress/element";
5
5
  import { useDebounce } from "@wordpress/compose";
@@ -44,9 +44,33 @@ var UnconnectedColorPicker = (props, forwardedRef) => {
44
44
  debouncedSetColor(nextValue.toHex());
45
45
  }, [debouncedSetColor]);
46
46
  const [colorType, setColorType] = useState(copyFormat || "hex");
47
+ const maybeHandlePaste = useCallback((event) => {
48
+ const pastedText = event.clipboardData?.getData("text")?.trim();
49
+ if (!pastedText) {
50
+ return;
51
+ }
52
+ const parsedColor = colord(pastedText);
53
+ if (!parsedColor.isValid()) {
54
+ return;
55
+ }
56
+ handleChange(parsedColor);
57
+ const supportedFormats = {
58
+ hex: "hex",
59
+ rgb: "rgb",
60
+ hsl: "hsl"
61
+ };
62
+ const detectedFormat = String(getFormat(pastedText));
63
+ const newColorType = supportedFormats[detectedFormat];
64
+ if (newColorType) {
65
+ setColorType(newColorType);
66
+ }
67
+ event.stopPropagation();
68
+ event.preventDefault();
69
+ }, [handleChange, setColorType]);
47
70
  return /* @__PURE__ */ _jsxs(ColorfulWrapper, {
48
71
  ref: forwardedRef,
49
72
  ...divProps,
73
+ onPasteCapture: maybeHandlePaste,
50
74
  children: [/* @__PURE__ */ _jsx(Picker, {
51
75
  onChange: handleChange,
52
76
  color: safeColordColor,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/color-picker/component.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\n\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useState, useMemo } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useContextSystem, contextConnect } from '../context';\nimport { ColorfulWrapper, SelectControl, AuxiliaryColorArtefactWrapper, AuxiliaryColorArtefactHStackHeader, ColorInputWrapper } from './styles';\nimport { ColorCopyButton } from './color-copy-button';\nimport { ColorInput } from './color-input';\nimport { Picker } from './picker';\nimport { useControlledValue } from '../utils/hooks';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nextend([namesPlugin]);\nconst options = [{\n label: 'RGB',\n value: 'rgb'\n}, {\n label: 'HSL',\n value: 'hsl'\n}, {\n label: 'Hex',\n value: 'hex'\n}];\nconst UnconnectedColorPicker = (props, forwardedRef) => {\n const {\n enableAlpha = false,\n color: colorProp,\n onChange,\n defaultValue = '#fff',\n copyFormat,\n ...divProps\n } = useContextSystem(props, 'ColorPicker');\n\n // Use a safe default value for the color and remove the possibility of `undefined`.\n const [color, setColor] = useControlledValue({\n onChange,\n value: colorProp,\n defaultValue\n });\n const safeColordColor = useMemo(() => {\n return colord(color || '');\n }, [color]);\n const debouncedSetColor = useDebounce(setColor);\n const handleChange = useCallback(nextValue => {\n debouncedSetColor(nextValue.toHex());\n }, [debouncedSetColor]);\n const [colorType, setColorType] = useState(copyFormat || 'hex');\n return /*#__PURE__*/_jsxs(ColorfulWrapper, {\n ref: forwardedRef,\n ...divProps,\n children: [/*#__PURE__*/_jsx(Picker, {\n onChange: handleChange,\n color: safeColordColor,\n enableAlpha: enableAlpha\n }), /*#__PURE__*/_jsxs(AuxiliaryColorArtefactWrapper, {\n children: [/*#__PURE__*/_jsxs(AuxiliaryColorArtefactHStackHeader, {\n justify: \"space-between\",\n children: [/*#__PURE__*/_jsx(SelectControl, {\n __nextHasNoMarginBottom: true,\n size: \"compact\",\n options: options,\n value: colorType,\n onChange: nextColorType => setColorType(nextColorType),\n label: __('Color format'),\n hideLabelFromVision: true,\n variant: \"minimal\"\n }), /*#__PURE__*/_jsx(ColorCopyButton, {\n color: safeColordColor,\n colorType: copyFormat || colorType\n })]\n }), /*#__PURE__*/_jsx(ColorInputWrapper, {\n direction: \"column\",\n gap: 2,\n children: /*#__PURE__*/_jsx(ColorInput, {\n colorType: colorType,\n color: safeColordColor,\n onChange: handleChange,\n enableAlpha: enableAlpha\n })\n })]\n })]\n });\n};\nexport const ColorPicker = contextConnect(UnconnectedColorPicker, 'ColorPicker');\nexport default ColorPicker;"],
5
- "mappings": ";AAIA,SAAS,QAAQ,cAAc;AAC/B,OAAO,iBAAiB;AAKxB,SAAS,aAAa,UAAU,eAAe;AAC/C,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AAKnB,SAAS,kBAAkB,sBAAsB;AACjD,SAAS,iBAAiB,eAAe,+BAA+B,oCAAoC,yBAAyB;AACrI,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,0BAA0B;AACnC,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,OAAO,CAAC,WAAW,CAAC;AACpB,IAAM,UAAU,CAAC;AAAA,EACf,OAAO;AAAA,EACP,OAAO;AACT,GAAG;AAAA,EACD,OAAO;AAAA,EACP,OAAO;AACT,GAAG;AAAA,EACD,OAAO;AAAA,EACP,OAAO;AACT,CAAC;AACD,IAAM,yBAAyB,CAAC,OAAO,iBAAiB;AACtD,QA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,UAAU;AAAA,UACV;AAAA,QACF,CAAC;AAAA,MACH,CAAC,CAAC;AAAA,IACJ,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACO,IAAM,cAAc,eAAe,wBAAwB,aAAa;AAC/E,IAAO,oBAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\n\nimport { colord, extend, getFormat } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useState, useMemo } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useContextSystem, contextConnect } from '../context';\nimport { ColorfulWrapper, SelectControl, AuxiliaryColorArtefactWrapper, AuxiliaryColorArtefactHStackHeader, ColorInputWrapper } from './styles';\nimport { ColorCopyButton } from './color-copy-button';\nimport { ColorInput } from './color-input';\nimport { Picker } from './picker';\nimport { useControlledValue } from '../utils/hooks';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nextend([namesPlugin]);\nconst options = [{\n label: 'RGB',\n value: 'rgb'\n}, {\n label: 'HSL',\n value: 'hsl'\n}, {\n label: 'Hex',\n value: 'hex'\n}];\nconst UnconnectedColorPicker = (props, forwardedRef) => {\n const {\n enableAlpha = false,\n color: colorProp,\n onChange,\n defaultValue = '#fff',\n copyFormat,\n ...divProps\n } = useContextSystem(props, 'ColorPicker');\n\n // Use a safe default value for the color and remove the possibility of `undefined`.\n const [color, setColor] = useControlledValue({\n onChange,\n value: colorProp,\n defaultValue\n });\n const safeColordColor = useMemo(() => {\n return colord(color || '');\n }, [color]);\n const debouncedSetColor = useDebounce(setColor);\n const handleChange = useCallback(nextValue => {\n debouncedSetColor(nextValue.toHex());\n }, [debouncedSetColor]);\n const [colorType, setColorType] = useState(copyFormat || 'hex');\n\n /*\n * ! Listener intended for the CAPTURE phase\n *\n * Capture paste events over the entire color picker, looking for clipboard\n * data that could be parsed as a color. If not, let the paste event\n * propagate normally, so that individual input controls within the\n * component have a chance to handle it.\n */\n const maybeHandlePaste = useCallback(event => {\n const pastedText = event.clipboardData?.getData('text')?.trim();\n if (!pastedText) {\n return;\n }\n const parsedColor = colord(pastedText);\n if (!parsedColor.isValid()) {\n return;\n }\n\n // Apply all valid colors, even if the format isn't supported in\n // the UI (e.g. names like \"cyan\" or, in the future color spaces\n // like \"lch\" if we add the right colord plugins)\n handleChange(parsedColor);\n\n // This redundancy helps TypeScript and is safer than assertions\n const supportedFormats = {\n hex: 'hex',\n rgb: 'rgb',\n hsl: 'hsl'\n };\n const detectedFormat = String(getFormat(pastedText));\n const newColorType = supportedFormats[detectedFormat];\n if (newColorType) {\n setColorType(newColorType);\n }\n\n // Stop at capture phase; no bubbling\n event.stopPropagation();\n event.preventDefault();\n }, [handleChange, setColorType]);\n return /*#__PURE__*/_jsxs(ColorfulWrapper, {\n ref: forwardedRef,\n ...divProps,\n onPasteCapture: maybeHandlePaste,\n children: [/*#__PURE__*/_jsx(Picker, {\n onChange: handleChange,\n color: safeColordColor,\n enableAlpha: enableAlpha\n }), /*#__PURE__*/_jsxs(AuxiliaryColorArtefactWrapper, {\n children: [/*#__PURE__*/_jsxs(AuxiliaryColorArtefactHStackHeader, {\n justify: \"space-between\",\n children: [/*#__PURE__*/_jsx(SelectControl, {\n __nextHasNoMarginBottom: true,\n size: \"compact\",\n options: options,\n value: colorType,\n onChange: nextColorType => setColorType(nextColorType),\n label: __('Color format'),\n hideLabelFromVision: true,\n variant: \"minimal\"\n }), /*#__PURE__*/_jsx(ColorCopyButton, {\n color: safeColordColor,\n colorType: copyFormat || colorType\n })]\n }), /*#__PURE__*/_jsx(ColorInputWrapper, {\n direction: \"column\",\n gap: 2,\n children: /*#__PURE__*/_jsx(ColorInput, {\n colorType: colorType,\n color: safeColordColor,\n onChange: handleChange,\n enableAlpha: enableAlpha\n })\n })]\n })]\n });\n};\nexport const ColorPicker = contextConnect(UnconnectedColorPicker, 'ColorPicker');\nexport default ColorPicker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H;AACO,IAAM,cAAc,eAAe,wBAAwB,aAAa;AAC/E,IAAO,oBAAQ;",
6
6
  "names": []
7
7
  }
@@ -18,6 +18,7 @@ var UnconnectedConfirmDialog = (props, forwardedRef) => {
18
18
  children,
19
19
  confirmButtonText,
20
20
  cancelButtonText,
21
+ isBusy,
21
22
  ...otherProps
22
23
  } = useContextSystem(props, "ConfirmDialog");
23
24
  const cx = useCx();
@@ -67,12 +68,17 @@ var UnconnectedConfirmDialog = (props, forwardedRef) => {
67
68
  ref: cancelButtonRef,
68
69
  variant: "tertiary",
69
70
  onClick: handleEvent(onCancel),
71
+ accessibleWhenDisabled: true,
72
+ disabled: isBusy,
70
73
  children: cancelLabel
71
74
  }), /* @__PURE__ */ _jsx(Button, {
72
75
  __next40pxDefaultSize: true,
73
76
  ref: confirmButtonRef,
74
77
  variant: "primary",
75
78
  onClick: handleEvent(onConfirm),
79
+ accessibleWhenDisabled: true,
80
+ disabled: isBusy,
81
+ isBusy,
76
82
  children: confirmLabel
77
83
  })]
78
84
  })]