@wordpress/components 37.0.0 → 38.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -2
- package/CHANGELOG.md +46 -0
- package/build/autocomplete/index.cjs +3 -1
- package/build/autocomplete/index.cjs.map +2 -2
- package/build/color-picker/component.cjs +14 -5
- package/build/color-picker/component.cjs.map +2 -2
- package/build/color-picker/picker.cjs +95 -23
- package/build/color-picker/picker.cjs.map +2 -2
- package/build/confirm-dialog/component.cjs +86 -4
- package/build/confirm-dialog/component.cjs.map +3 -3
- package/build/content-editable-control/index.cjs +19 -9
- package/build/content-editable-control/index.cjs.map +3 -3
- package/build/custom-select-control/index.cjs +1 -2
- package/build/custom-select-control/index.cjs.map +2 -2
- package/build/disabled/index.cjs +87 -4
- package/build/disabled/index.cjs.map +4 -4
- package/build/form-token-field/index.cjs +87 -2
- package/build/form-token-field/index.cjs.map +3 -3
- package/build/gradient-picker/index.cjs +26 -20
- package/build/gradient-picker/index.cjs.map +2 -2
- package/build/input-control/index.cjs +0 -1
- package/build/input-control/index.cjs.map +2 -2
- package/build/input-control/styles/input-control-styles.cjs +23 -31
- package/build/input-control/styles/input-control-styles.cjs.map +2 -2
- package/build/private-apis.cjs +0 -2
- package/build/private-apis.cjs.map +3 -3
- package/build/range-control/index.cjs +0 -1
- package/build/range-control/index.cjs.map +2 -2
- package/build/sandbox/index.cjs +23 -4
- package/build/sandbox/index.cjs.map +3 -3
- package/build/search-control/index.cjs +93 -10
- package/build/search-control/index.cjs.map +4 -4
- package/build/select-control/index.cjs +0 -1
- package/build/select-control/index.cjs.map +2 -2
- package/build/select-control/styles/select-control-styles.cjs +9 -16
- package/build/select-control/styles/select-control-styles.cjs.map +2 -2
- package/build/slot-fill/fill.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control/component.cjs +91 -8
- package/build/toggle-group-control/toggle-group-control/component.cjs.map +4 -4
- package/build/toggle-group-control/toggle-group-control-option-base/component.cjs +98 -17
- package/build/toggle-group-control/toggle-group-control-option-base/component.cjs.map +4 -4
- package/build/tools-panel/tools-panel/component.cjs +6 -0
- package/build/tools-panel/tools-panel/component.cjs.map +2 -2
- package/build/tools-panel/tools-panel/hook.cjs +87 -11
- package/build/tools-panel/tools-panel/hook.cjs.map +4 -4
- package/build/tools-panel/tools-panel-header/component.cjs +87 -2
- package/build/tools-panel/tools-panel-header/component.cjs.map +3 -3
- package/build/tools-panel/tools-panel-header/hook.cjs +90 -20
- package/build/tools-panel/tools-panel-header/hook.cjs.map +4 -4
- package/build/tools-panel/tools-panel-item/hook.cjs +88 -9
- package/build/tools-panel/tools-panel-item/hook.cjs.map +4 -4
- package/build/validated-form-controls/control-with-error.cjs +3 -0
- package/build/validated-form-controls/control-with-error.cjs.map +2 -2
- package/build-module/autocomplete/index.mjs +3 -1
- package/build-module/autocomplete/index.mjs.map +2 -2
- package/build-module/color-picker/component.mjs +14 -5
- package/build-module/color-picker/component.mjs.map +2 -2
- package/build-module/color-picker/picker.mjs +96 -24
- package/build-module/color-picker/picker.mjs.map +2 -2
- package/build-module/confirm-dialog/component.mjs +86 -4
- package/build-module/confirm-dialog/component.mjs.map +3 -3
- package/build-module/content-editable-control/index.mjs +21 -11
- package/build-module/content-editable-control/index.mjs.map +2 -2
- package/build-module/custom-select-control/index.mjs +1 -2
- package/build-module/custom-select-control/index.mjs.map +2 -2
- package/build-module/disabled/index.mjs +87 -4
- package/build-module/disabled/index.mjs.map +3 -3
- package/build-module/form-token-field/index.mjs +88 -3
- package/build-module/form-token-field/index.mjs.map +3 -3
- package/build-module/gradient-picker/index.mjs +26 -20
- package/build-module/gradient-picker/index.mjs.map +2 -2
- package/build-module/input-control/index.mjs +0 -1
- package/build-module/input-control/index.mjs.map +2 -2
- package/build-module/input-control/styles/input-control-styles.mjs +23 -31
- package/build-module/input-control/styles/input-control-styles.mjs.map +2 -2
- package/build-module/private-apis.mjs +0 -2
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/range-control/index.mjs +0 -1
- package/build-module/range-control/index.mjs.map +2 -2
- package/build-module/sandbox/index.mjs +13 -4
- package/build-module/sandbox/index.mjs.map +2 -2
- package/build-module/search-control/index.mjs +93 -10
- package/build-module/search-control/index.mjs.map +3 -3
- package/build-module/select-control/index.mjs +0 -1
- package/build-module/select-control/index.mjs.map +2 -2
- package/build-module/select-control/styles/select-control-styles.mjs +9 -16
- package/build-module/select-control/styles/select-control-styles.mjs.map +2 -2
- package/build-module/slot-fill/fill.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control/component.mjs +92 -9
- package/build-module/toggle-group-control/toggle-group-control/component.mjs.map +3 -3
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.mjs +99 -18
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.mjs.map +3 -3
- package/build-module/tools-panel/tools-panel/component.mjs +6 -0
- package/build-module/tools-panel/tools-panel/component.mjs.map +2 -2
- package/build-module/tools-panel/tools-panel/hook.mjs +87 -11
- package/build-module/tools-panel/tools-panel/hook.mjs.map +3 -3
- package/build-module/tools-panel/tools-panel-header/component.mjs +87 -2
- package/build-module/tools-panel/tools-panel-header/component.mjs.map +3 -3
- package/build-module/tools-panel/tools-panel-header/hook.mjs +90 -20
- package/build-module/tools-panel/tools-panel-header/hook.mjs.map +3 -3
- package/build-module/tools-panel/tools-panel-item/hook.mjs +89 -10
- package/build-module/tools-panel/tools-panel-item/hook.mjs.map +3 -3
- package/build-module/validated-form-controls/control-with-error.mjs +3 -0
- package/build-module/validated-form-controls/control-with-error.mjs.map +2 -2
- package/build-style/style-rtl.css +20 -24
- package/build-style/style.css +20 -24
- package/build-types/autocomplete/index.d.ts +7 -3
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/component.d.ts +1 -3
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/stories/index.story.d.ts +1 -3
- package/build-types/border-box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/border-box-control/types.d.ts +1 -15
- package/build-types/border-box-control/types.d.ts.map +1 -1
- package/build-types/box-control/input-control.d.ts +3 -0
- package/build-types/box-control/input-control.d.ts.map +1 -0
- package/build-types/box-control/styles/box-control-styles.d.ts +4 -8
- package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
- package/build-types/box-control/types.d.ts +1 -8
- package/build-types/box-control/types.d.ts.map +1 -1
- package/build-types/card/context.d.ts +3 -0
- package/build-types/card/context.d.ts.map +1 -0
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/picker.d.ts +17 -1
- package/build-types/color-picker/picker.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +4 -8
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/color-picker/types.d.ts +2 -0
- package/build-types/color-picker/types.d.ts.map +1 -1
- package/build-types/confirm-dialog/component.d.ts.map +1 -1
- package/build-types/content-editable-control/index.d.ts.map +1 -1
- package/build-types/context/wordpress-component.d.ts +2 -1
- package/build-types/context/wordpress-component.d.ts.map +1 -1
- package/build-types/custom-select-control/index.d.ts.map +1 -1
- package/build-types/custom-select-control/types.d.ts +1 -8
- package/build-types/custom-select-control/types.d.ts.map +1 -1
- package/build-types/date-time/date/index.d.ts +23 -0
- package/build-types/date-time/date/index.d.ts.map +1 -0
- package/build-types/date-time/date/styles.d.ts +45 -0
- package/build-types/date-time/date/styles.d.ts.map +1 -0
- package/build-types/date-time/date/test/index.d.ts +2 -0
- package/build-types/date-time/date/test/index.d.ts.map +1 -0
- package/build-types/date-time/date/test/use-lilius.d.ts +2 -0
- package/build-types/date-time/date/test/use-lilius.d.ts.map +1 -0
- package/build-types/date-time/date/use-lilius/index.d.ts +169 -0
- package/build-types/date-time/date/use-lilius/index.d.ts.map +1 -0
- package/build-types/date-time/time/index.d.ts +27 -0
- package/build-types/date-time/time/index.d.ts.map +1 -0
- package/build-types/date-time/time/styles.d.ts +93 -0
- package/build-types/date-time/time/styles.d.ts.map +1 -0
- package/build-types/date-time/time/test/index.d.ts +2 -0
- package/build-types/date-time/time/test/index.d.ts.map +1 -0
- package/build-types/date-time/time/time-input/index.d.ts +4 -0
- package/build-types/date-time/time/time-input/index.d.ts.map +1 -0
- package/build-types/date-time/time/time-input/test/index.d.ts +2 -0
- package/build-types/date-time/time/time-input/test/index.d.ts.map +1 -0
- package/build-types/date-time/time/timezone.d.ts +7 -0
- package/build-types/date-time/time/timezone.d.ts.map +1 -0
- package/build-types/date-time/time-picker/styles.d.ts +8 -16
- package/build-types/date-time/time-picker/styles.d.ts.map +1 -1
- package/build-types/disabled/index.d.ts.map +1 -1
- package/build-types/divider/styles.d.ts +10 -0
- package/build-types/divider/styles.d.ts.map +1 -0
- package/build-types/flex/styles.d.ts +17 -0
- package/build-types/flex/styles.d.ts.map +1 -0
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +2 -4
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts.map +1 -1
- package/build-types/font-size-picker/index.d.ts +12 -2
- package/build-types/font-size-picker/index.d.ts.map +1 -1
- package/build-types/font-size-picker/stories/e2e/index.story.d.ts +12 -1
- package/build-types/font-size-picker/stories/e2e/index.story.d.ts.map +1 -1
- package/build-types/font-size-picker/types.d.ts +2 -15
- package/build-types/font-size-picker/types.d.ts.map +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/gradient-picker/index.d.ts.map +1 -1
- package/build-types/gradient-picker/stories/index.story.d.ts +1 -0
- package/build-types/gradient-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/gradient-picker/test/index.d.ts +2 -0
- package/build-types/gradient-picker/test/index.d.ts.map +1 -0
- package/build-types/gradient-picker/types.d.ts +19 -4
- package/build-types/gradient-picker/types.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts +0 -6
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +1 -8
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/mobile/image/constants.d.ts +5 -0
- package/build-types/mobile/image/constants.d.ts.map +1 -0
- package/build-types/navigation/back-button/index.d.ts +7 -0
- package/build-types/navigation/back-button/index.d.ts.map +1 -0
- package/build-types/navigation/constants.d.ts +3 -0
- package/build-types/navigation/constants.d.ts.map +1 -0
- package/build-types/navigation/context.d.ts +4 -0
- package/build-types/navigation/context.d.ts.map +1 -0
- package/build-types/navigation/group/context.d.ts +7 -0
- package/build-types/navigation/group/context.d.ts.map +1 -0
- package/build-types/navigation/group/index.d.ts +7 -0
- package/build-types/navigation/group/index.d.ts.map +1 -0
- package/build-types/navigation/index.d.ts +46 -0
- package/build-types/navigation/index.d.ts.map +1 -0
- package/build-types/navigation/item/base-content.d.ts +3 -0
- package/build-types/navigation/item/base-content.d.ts.map +1 -0
- package/build-types/navigation/item/base.d.ts +3 -0
- package/build-types/navigation/item/base.d.ts.map +1 -0
- package/build-types/navigation/item/index.d.ts +7 -0
- package/build-types/navigation/item/index.d.ts.map +1 -0
- package/build-types/navigation/item/use-navigation-tree-item.d.ts +3 -0
- package/build-types/navigation/item/use-navigation-tree-item.d.ts.map +1 -0
- package/build-types/navigation/menu/context.d.ts +7 -0
- package/build-types/navigation/menu/context.d.ts.map +1 -0
- package/build-types/navigation/menu/index.d.ts +7 -0
- package/build-types/navigation/menu/index.d.ts.map +1 -0
- package/build-types/navigation/menu/menu-title-search.d.ts +3 -0
- package/build-types/navigation/menu/menu-title-search.d.ts.map +1 -0
- package/build-types/navigation/menu/menu-title.d.ts +3 -0
- package/build-types/navigation/menu/menu-title.d.ts.map +1 -0
- package/build-types/navigation/menu/search-no-results-found.d.ts +3 -0
- package/build-types/navigation/menu/search-no-results-found.d.ts.map +1 -0
- package/build-types/navigation/menu/use-navigation-tree-menu.d.ts +3 -0
- package/build-types/navigation/menu/use-navigation-tree-menu.d.ts.map +1 -0
- package/build-types/navigation/stories/index.story.d.ts +23 -0
- package/build-types/navigation/stories/index.story.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/controlled-state.d.ts +7 -0
- package/build-types/navigation/stories/utils/controlled-state.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/default.d.ts +10 -0
- package/build-types/navigation/stories/utils/default.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/group.d.ts +10 -0
- package/build-types/navigation/stories/utils/group.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/hide-if-empty.d.ts +10 -0
- package/build-types/navigation/stories/utils/hide-if-empty.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/more-examples.d.ts +10 -0
- package/build-types/navigation/stories/utils/more-examples.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/search.d.ts +10 -0
- package/build-types/navigation/stories/utils/search.d.ts.map +1 -0
- package/build-types/navigation/styles/navigation-styles.d.ts +55 -0
- package/build-types/navigation/styles/navigation-styles.d.ts.map +1 -0
- package/build-types/navigation/test/index.d.ts +2 -0
- package/build-types/navigation/test/index.d.ts.map +1 -0
- package/build-types/navigation/types.d.ts +266 -0
- package/build-types/navigation/types.d.ts.map +1 -0
- package/build-types/navigation/use-create-navigation-tree.d.ts +15 -0
- package/build-types/navigation/use-create-navigation-tree.d.ts.map +1 -0
- package/build-types/navigation/use-navigation-tree-nodes.d.ts +10 -0
- package/build-types/navigation/use-navigation-tree-nodes.d.ts.map +1 -0
- package/build-types/navigation/utils.d.ts +3 -0
- package/build-types/navigation/utils.d.ts.map +1 -0
- package/build-types/number-control/index.d.ts +2 -4
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/stories/index.story.d.ts +2 -4
- package/build-types/number-control/stories/index.story.d.ts.map +1 -1
- package/build-types/number-control/types.d.ts +1 -15
- package/build-types/number-control/types.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +2 -4
- package/build-types/range-control/index.d.ts.map +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +2 -4
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/range-control/types.d.ts +2 -16
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/sandbox/index.d.ts.map +1 -1
- package/build-types/sandbox/types.d.ts +11 -0
- package/build-types/sandbox/types.d.ts.map +1 -1
- package/build-types/search-control/index.d.ts.map +1 -1
- package/build-types/search-control/types.d.ts +1 -1
- package/build-types/search-control/types.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/select-control/types.d.ts +0 -7
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/slot-fill/fill.d.ts.map +1 -1
- package/build-types/slot-fill/stories/index.story.d.ts +1 -6
- package/build-types/slot-fill/stories/index.story.d.ts.map +1 -1
- package/build-types/surface/styles.d.ts +11 -0
- package/build-types/surface/styles.d.ts.map +1 -0
- package/build-types/theme/styles.d.ts +10 -0
- package/build-types/theme/styles.d.ts.map +1 -0
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts +0 -1
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/types.d.ts +0 -7
- package/build-types/toggle-group-control/types.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/tree-select/types.d.ts +1 -8
- package/build-types/tree-select/types.d.ts.map +1 -1
- package/build-types/truncate/styles.d.ts +2 -0
- package/build-types/truncate/styles.d.ts.map +1 -0
- package/build-types/unit-control/index.d.ts +2 -4
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +2 -4
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/types.d.ts +1 -15
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/utils/deprecated-36px-size.d.ts +7 -0
- package/build-types/utils/deprecated-36px-size.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/number-control.d.ts +2 -4
- package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/range-control.d.ts +2 -4
- package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/overview.story.d.ts +5 -0
- package/build-types/validated-form-controls/components/stories/overview.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/toggle-group-control.d.ts +1 -2
- package/build-types/validated-form-controls/components/toggle-group-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
- package/build-types/visually-hidden/test/index.d.ts +2 -0
- package/build-types/visually-hidden/test/index.d.ts.map +1 -0
- package/package.json +27 -27
- package/src/autocomplete/index.tsx +16 -3
- package/src/base-control/README.md +2 -2
- package/src/border-box-control/types.ts +4 -15
- package/src/box-control/types.ts +4 -8
- package/src/card/test/__snapshots__/index.tsx.snap +1 -1
- package/src/checkbox-control/test/__snapshots__/index.tsx.snap +1 -1
- package/src/color-indicator/test/__snapshots__/index.tsx.snap +1 -1
- package/src/color-picker/component.tsx +23 -19
- package/src/color-picker/picker.tsx +144 -21
- package/src/color-picker/test/index.tsx +502 -0
- package/src/color-picker/types.ts +2 -0
- package/src/combobox-control/style.scss +2 -2
- package/src/confirm-dialog/component.tsx +2 -4
- package/src/confirm-dialog/style.module.scss +7 -0
- package/src/confirm-dialog/test/index.tsx +5 -0
- package/src/content-editable-control/index.tsx +24 -5
- package/src/content-editable-control/style.module.scss +1 -1
- package/src/content-editable-control/test/index.tsx +20 -8
- package/src/context/test/__snapshots__/context-system-provider.js.snap +1 -1
- package/src/context/wordpress-component.ts +7 -2
- package/src/custom-gradient-picker/test/index.tsx +111 -1
- package/src/custom-select-control/index.tsx +1 -2
- package/src/custom-select-control/test/__snapshots__/index.tsx.snap +6 -0
- package/src/custom-select-control/test/index.tsx +23 -0
- package/src/custom-select-control/types.ts +1 -8
- package/src/disabled/index.tsx +7 -5
- package/src/disabled/style.module.scss +15 -0
- package/src/disabled/test/index.tsx +6 -4
- package/src/elevation/test/__snapshots__/index.tsx.snap +1 -1
- package/src/external-link/style.scss +6 -12
- package/src/flex/test/__snapshots__/index.tsx.snap +1 -1
- package/src/font-size-picker/types.ts +6 -15
- package/src/form-toggle/test/__snapshots__/index.tsx.snap +1 -1
- package/src/form-token-field/index.tsx +5 -4
- package/src/form-token-field/style.module.scss +6 -0
- package/src/form-token-field/style.scss +2 -2
- package/src/gradient-picker/README.md +21 -3
- package/src/gradient-picker/index.tsx +43 -28
- package/src/gradient-picker/stories/index.story.tsx +41 -5
- package/src/gradient-picker/test/index.tsx +148 -0
- package/src/gradient-picker/types.ts +24 -4
- package/src/h-stack/test/__snapshots__/index.tsx.snap +1 -1
- package/src/heading/test/__snapshots__/index.tsx.snap +1 -1
- package/src/higher-order/with-filters/test/__snapshots__/index.tsx.snap +1 -1
- package/src/input-control/index.tsx +0 -1
- package/src/input-control/styles/input-control-styles.tsx +0 -8
- package/src/input-control/test/__snapshots__/index.js.snap +11 -0
- package/src/input-control/test/index.js +28 -0
- package/src/input-control/types.ts +1 -8
- package/src/item-group/test/__snapshots__/index.js.snap +1 -1
- package/src/menu/README.md +2 -2
- package/src/menu-item/test/__snapshots__/index.js.snap +1 -1
- package/src/modal/test/index.tsx +42 -0
- package/src/notice/test/__snapshots__/index.tsx.snap +1 -1
- package/src/number-control/types.ts +1 -22
- package/src/panel/test/__snapshots__/body.tsx.snap +1 -1
- package/src/panel/test/__snapshots__/header.tsx.snap +1 -1
- package/src/panel/test/__snapshots__/index.tsx.snap +1 -1
- package/src/panel/test/__snapshots__/row.tsx.snap +1 -1
- package/src/private-apis.ts +0 -2
- package/src/range-control/index.tsx +0 -1
- package/src/range-control/types.ts +2 -15
- package/src/sandbox/index.tsx +22 -2
- package/src/sandbox/test/index.tsx +21 -0
- package/src/sandbox/types.ts +11 -0
- package/src/scrollable/test/__snapshots__/index.tsx.snap +1 -1
- package/src/search-control/index.tsx +23 -20
- package/src/search-control/style.module.scss +16 -0
- package/src/search-control/test/index.tsx +8 -0
- package/src/search-control/types.ts +1 -1
- package/src/select-control/index.tsx +0 -1
- package/src/select-control/styles/select-control-styles.ts +0 -7
- package/src/select-control/test/__snapshots__/select-control.tsx.snap +11 -0
- package/src/select-control/test/select-control.tsx +37 -0
- package/src/select-control/types.ts +0 -7
- package/src/shortcut/test/__snapshots__/index.tsx.snap +1 -1
- package/src/slot-fill/fill.tsx +3 -9
- package/src/slot-fill/stories/index.story.tsx +52 -10
- package/src/slot-fill/test/__snapshots__/slot.js.snap +1 -1
- package/src/slot-fill/test/slot.js +53 -11
- package/src/spacer/test/__snapshots__/index.tsx.snap +1 -1
- package/src/text/test/__snapshots__/index.tsx.snap +1 -1
- package/src/text-control/style.scss +1 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +29 -707
- package/src/toggle-group-control/test/index.tsx +33 -3
- package/src/toggle-group-control/toggle-group-control/component.tsx +11 -16
- package/src/toggle-group-control/toggle-group-control/style.module.scss +63 -0
- package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +22 -24
- package/src/toggle-group-control/toggle-group-control-option-base/style.module.scss +88 -0
- package/src/toggle-group-control/types.ts +0 -7
- package/src/tools-panel/style.module.scss +117 -0
- package/src/tools-panel/test/index.tsx +105 -39
- package/src/tools-panel/tools-panel/component.tsx +12 -1
- package/src/tools-panel/tools-panel/hook.ts +13 -15
- package/src/tools-panel/tools-panel-header/component.tsx +6 -2
- package/src/tools-panel/tools-panel-header/hook.ts +7 -25
- package/src/tools-panel/tools-panel-item/hook.ts +16 -34
- package/src/tooltip/test/index.tsx +1 -1
- package/src/tree-grid/test/__snapshots__/cell.tsx.snap +1 -1
- package/src/tree-grid/test/__snapshots__/index.tsx.snap +1 -1
- package/src/tree-grid/test/__snapshots__/roving-tab-index-item.tsx.snap +1 -1
- package/src/tree-grid/test/__snapshots__/roving-tab-index.tsx.snap +1 -1
- package/src/tree-grid/test/__snapshots__/row.tsx.snap +1 -1
- package/src/tree-select/README.md +1 -1
- package/src/tree-select/types.ts +1 -8
- package/src/unit-control/types.ts +1 -18
- package/src/utils/theme-variables.scss +1 -0
- package/src/v-stack/test/__snapshots__/index.tsx.snap +1 -1
- package/src/validated-form-controls/components/stories/overview.story.tsx +51 -0
- package/src/validated-form-controls/control-with-error.tsx +9 -0
- package/src/validated-form-controls/style.scss +3 -3
- package/src/validated-form-controls/test/control-with-error.tsx +42 -0
- package/src/view/test/__snapshots__/index.js.snap +1 -1
- package/build/confirm-dialog/styles.cjs +0 -42
- package/build/confirm-dialog/styles.cjs.map +0 -7
- package/build/disabled/styles/disabled-styles.cjs +0 -42
- package/build/disabled/styles/disabled-styles.cjs.map +0 -7
- package/build/form-token-field/styles.cjs +0 -49
- package/build/form-token-field/styles.cjs.map +0 -7
- package/build/search-control/styles.cjs +0 -74
- package/build/search-control/styles.cjs.map +0 -7
- package/build/theme/color-algorithms.cjs +0 -131
- package/build/theme/color-algorithms.cjs.map +0 -7
- package/build/theme/index.cjs +0 -160
- package/build/theme/index.cjs.map +0 -7
- package/build/theme/types.cjs +0 -19
- package/build/theme/types.cjs.map +0 -7
- package/build/toggle-group-control/toggle-group-control/styles.cjs +0 -53
- package/build/toggle-group-control/toggle-group-control/styles.cjs.map +0 -7
- package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs +0 -94
- package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs.map +0 -7
- package/build/tools-panel/styles.cjs +0 -129
- package/build/tools-panel/styles.cjs.map +0 -7
- package/build/utils/use-deprecated-props.cjs +0 -41
- package/build/utils/use-deprecated-props.cjs.map +0 -7
- package/build-module/confirm-dialog/styles.mjs +0 -17
- package/build-module/confirm-dialog/styles.mjs.map +0 -7
- package/build-module/disabled/styles/disabled-styles.mjs +0 -17
- package/build-module/disabled/styles/disabled-styles.mjs.map +0 -7
- package/build-module/form-token-field/styles.mjs +0 -14
- package/build-module/form-token-field/styles.mjs.map +0 -7
- package/build-module/search-control/styles.mjs +0 -38
- package/build-module/search-control/styles.mjs.map +0 -7
- package/build-module/theme/color-algorithms.mjs +0 -94
- package/build-module/theme/color-algorithms.mjs.map +0 -7
- package/build-module/theme/index.mjs +0 -129
- package/build-module/theme/index.mjs.map +0 -7
- package/build-module/theme/types.mjs +0 -1
- package/build-module/theme/types.mjs.map +0 -7
- package/build-module/toggle-group-control/toggle-group-control/styles.mjs +0 -27
- package/build-module/toggle-group-control/toggle-group-control/styles.mjs.map +0 -7
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs +0 -56
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs.map +0 -7
- package/build-module/tools-panel/styles.mjs +0 -84
- package/build-module/tools-panel/styles.mjs.map +0 -7
- package/build-module/utils/use-deprecated-props.mjs +0 -16
- package/build-module/utils/use-deprecated-props.mjs.map +0 -7
- package/src/confirm-dialog/styles.ts +0 -18
- package/src/disabled/styles/disabled-styles.tsx +0 -23
- package/src/form-token-field/styles.ts +0 -15
- package/src/search-control/styles.ts +0 -27
- package/src/theme/README.md +0 -47
- package/src/theme/color-algorithms.ts +0 -142
- package/src/theme/index.tsx +0 -80
- package/src/theme/stories/index.story.tsx +0 -127
- package/src/theme/style.module.scss +0 -4
- package/src/theme/test/color-algorithms.ts +0 -100
- package/src/theme/test/index.tsx +0 -151
- package/src/theme/types.ts +0 -61
- package/src/toggle-group-control/toggle-group-control/styles.ts +0 -84
- package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +0 -109
- package/src/tools-panel/styles.ts +0 -176
- package/src/utils/use-deprecated-props.ts +0 -14
package/AGENTS.md
CHANGED
|
@@ -4,7 +4,7 @@ This package contains UI components that are intended to be used anywhere in a g
|
|
|
4
4
|
|
|
5
5
|
We are currently in the process of rewriting the global components to be in the new `@wordpress/ui` package. Refer to the [`use-recommended-components` ESLint rule](../eslint-plugin/rules/use-recommended-components.js) for guidance on which components to use.
|
|
6
6
|
|
|
7
|
-
For components not explicitly listed in the `use-recommended-components` rule,
|
|
7
|
+
For components not explicitly listed in the `use-recommended-components` rule, locate the component's Storybook source within this package and use its status guidance. This guidance is more authoritative than the `experimental` tag or component prefix.
|
|
8
8
|
|
|
9
9
|
## Forms
|
|
10
10
|
|
|
@@ -14,4 +14,4 @@ For adding validation, consider using the [Validated Form Components](./src/vali
|
|
|
14
14
|
|
|
15
15
|
## Storybook
|
|
16
16
|
|
|
17
|
-
Don't forget to check a
|
|
17
|
+
Don't forget to check a component's Storybook documentation for additional usage guidance. The Storybook links ([public base URL](https://wordpress.github.io/gutenberg/)) are also useful to present to a human when they are asking for help with a component.
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 38.0.0 (2026-07-29)
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
- Components that compose Emotion style fragments with `cx()` should pass source-order-dependent fragments in a single `css()` call. Passing separate fragments can change override order after the following components stopped rendering styles through Emotion:
|
|
10
|
+
- `ToggleGroupControl` ([#80381](https://github.com/WordPress/gutenberg/pull/80381))
|
|
11
|
+
- `Disabled` ([#80643](https://github.com/WordPress/gutenberg/pull/80643))
|
|
12
|
+
- `ToolsPanel` ([#80445](https://github.com/WordPress/gutenberg/pull/80445))
|
|
13
|
+
- Remove the private `Theme` component ([#80691](https://github.com/WordPress/gutenberg/pull/80691)).
|
|
14
|
+
|
|
15
|
+
### Enhancements
|
|
16
|
+
|
|
17
|
+
- `GradientPicker`: Add `selectedSlug` prop for slug-based selection and pass the selected preset's slug to `onChange`, so two presets sharing a gradient keep their identity ([#80554](https://github.com/WordPress/gutenberg/pull/80554)).
|
|
18
|
+
- `SandBox`: Add `allowPopups` prop to opt into `allow-popups` in the iframe's sandbox attribute ([#69617](https://github.com/WordPress/gutenberg/pull/69617)).
|
|
19
|
+
- Validated form controls: Only move focus to the invalid control for trusted `invalid` events (form submission, `reportValidity()`). Consumers can now dispatch a synthetic `invalid` event to reveal a control's error message without disturbing the user's place in the form ([#80685](https://github.com/WordPress/gutenberg/pull/80685)).
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
- `ToolsPanel`: Migrate styles from Emotion to an SCSS Module and restore the header heading typography after the `View` migration. ([#80445](https://github.com/WordPress/gutenberg/pull/80445)).
|
|
24
|
+
- `Autocomplete`: Expose the suggestions list to assistive technology with `aria-controls` and `aria-haspopup`, both required alongside `aria-autocomplete="list"` ([#80403](https://github.com/WordPress/gutenberg/pull/80403)).
|
|
25
|
+
- `Autocomplete`: Omit `aria-activedescendant` while no suggestion is highlighted, instead of returning `null` for it ([#80403](https://github.com/WordPress/gutenberg/pull/80403)).
|
|
26
|
+
- `ContentEditableControl`: Associate the label with the `contentEditable` field via `aria-labelledby` instead of an invalid `label[for]`, which triggered Chrome console errors ([#80344](https://github.com/WordPress/gutenberg/pull/80344)).
|
|
27
|
+
- `SearchControl`: Render suffix only if there is one. ([#80356](https://github.com/WordPress/gutenberg/pull/80356), [#80406](https://github.com/WordPress/gutenberg/pull/80406)).
|
|
28
|
+
- `ColorPicker`: Keep the visual picker in native HSVA so gradient/controlled HSLA echoes no longer jitter the saturation pointer, and preserve the black-edge saturation coordinate without leaving white at a chromatic position ([#80205](https://github.com/WordPress/gutenberg/pull/80205)).
|
|
29
|
+
|
|
30
|
+
### TypeScript
|
|
31
|
+
|
|
32
|
+
- Update Jest type definitions to v30 ([#80767](https://github.com/WordPress/gutenberg/pull/80767)).
|
|
33
|
+
- `Autocomplete`: `__unstableUseAutocompleteProps` now narrows its returned ARIA props and no longer asks for a `contentRef` it never used, so callers can spread its return value onto an element without a placeholder ref, normalizing, or casting ([#80403](https://github.com/WordPress/gutenberg/pull/80403)).
|
|
34
|
+
- Improved performance of TypeScript types for internal polymorphic `WordPressComponent` component type ([#80364](https://github.com/WordPress/gutenberg/pull/80364)).
|
|
35
|
+
|
|
36
|
+
### Internal
|
|
37
|
+
|
|
38
|
+
- Update `date-fns` to 4.4.0 ([#80763](https://github.com/WordPress/gutenberg/pull/80763)).
|
|
39
|
+
- Update `memize` to 2.1.1 ([#80764](https://github.com/WordPress/gutenberg/pull/80764)).
|
|
40
|
+
- `TextControl`, `ComboboxControl`, `FormTokenField`, `ContentEditableControl`: Replace `--wp-components-color-accent` with `--wp-admin-theme-color` for focus ring color ([#80595](https://github.com/WordPress/gutenberg/pull/80595)).
|
|
41
|
+
- `ConfirmDialog`: Migrate styles from Emotion to an SCSS Module ([#80394](https://github.com/WordPress/gutenberg/pull/80394)).
|
|
42
|
+
- `ExternalLink`: Use the shared `outset-ring__focus` mixin for the focus ring ([#80573](https://github.com/WordPress/gutenberg/pull/80573)).
|
|
43
|
+
- `SearchControl`: Migrate styles from Emotion to an SCSS Module ([#80474](https://github.com/WordPress/gutenberg/pull/80474)).
|
|
44
|
+
- `FormTokenField`: Migrate styles from Emotion to an SCSS Module ([#80472](https://github.com/WordPress/gutenberg/pull/80472)).
|
|
45
|
+
- `InputControl`, `SelectControl`, `CustomSelectControl`, `ToggleGroupControl`, and `RangeControl`: Remove obsolete internal `__shouldNotWarnDeprecated36pxSize` prop ([#80323](https://github.com/WordPress/gutenberg/pull/80323)).
|
|
46
|
+
- `InputControl`, `SelectControl`, `CustomSelectControl`: Remove obsolete `__unstable-large` from the public `size` type. The value continues to work at runtime, and is equivalent to the `default` size. ([#80081](https://github.com/WordPress/gutenberg/pull/80081)).
|
|
47
|
+
- `ToggleGroupControl`: Migrate styles from Emotion to SCSS Modules and use WPDS tokens for migrated visual values ([#80381](https://github.com/WordPress/gutenberg/pull/80381)).
|
|
48
|
+
- `Disabled`: Migrate styles from Emotion to an SCSS Module ([#80643](https://github.com/WordPress/gutenberg/pull/80643)).
|
|
49
|
+
- Update `exports` to use subpath patterns instead of deprecated trailing `/` folder mappings ([#80270](https://github.com/WordPress/gutenberg/pull/80270)).
|
|
50
|
+
|
|
5
51
|
## 37.0.0 (2026-07-14)
|
|
6
52
|
|
|
7
53
|
### Enhancements
|
|
@@ -327,8 +327,10 @@ function useAutocompleteProps(options) {
|
|
|
327
327
|
ref: mergedRefs,
|
|
328
328
|
children: popover,
|
|
329
329
|
"aria-autocomplete": listBoxId ? "list" : void 0,
|
|
330
|
+
"aria-haspopup": listBoxId ? "listbox" : void 0,
|
|
331
|
+
"aria-controls": listBoxId,
|
|
330
332
|
"aria-owns": listBoxId,
|
|
331
|
-
"aria-activedescendant": activeId
|
|
333
|
+
"aria-activedescendant": activeId ?? void 0
|
|
332
334
|
};
|
|
333
335
|
}
|
|
334
336
|
function Autocomplete({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/autocomplete/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { renderToString, useEffect, useMemo, useReducer, useRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { create, slice, insert, isCollapsed, getTextContent, privateApis as richTextPrivateApis } from '@wordpress/rich-text';\nimport { speak } from '@wordpress/a11y';\nimport { isAppleOS } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { AutocompleterUI } from './autocompleter-ui';\nimport { getAutocompleteMatch } from './get-autocomplete-match';\nimport { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';\nimport getNodeText from '../utils/get-node-text';\nimport { unlock } from '../lock-unlock';\nimport { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst {\n subscribeOwnedListener\n} = unlock(richTextPrivateApis);\nconst EMPTY_FILTERED_OPTIONS = [];\n\n// Used for generating the instance ID\nconst AUTOCOMPLETE_HOOK_REFERENCE = {};\nfunction getCompletionObject(completion) {\n if (completion !== null && typeof completion === 'object' && 'action' in completion && completion.action !== undefined && 'value' in completion && completion.value !== undefined) {\n return completion;\n }\n return {\n action: 'insert-at-caret',\n value: completion\n };\n}\nconst initialState = {\n selectedIndex: 0,\n filteredOptions: EMPTY_FILTERED_OPTIONS,\n filterValue: '',\n autocompleter: null\n};\nfunction autocompleteReducer(state, action) {\n switch (action.type) {\n case 'RESET':\n return initialState;\n case 'SELECT':\n return {\n ...state,\n selectedIndex: action.index\n };\n case 'OPTIONS':\n return {\n ...state,\n filteredOptions: action.options,\n selectedIndex: action.options.length === state.filteredOptions.length ? state.selectedIndex : 0\n };\n case 'MATCH':\n return {\n ...state,\n autocompleter: action.completer,\n filterValue: action.query\n };\n }\n}\nexport function useAutocomplete({\n record,\n onChange,\n onReplace,\n completers,\n contentRef\n}) {\n const instanceId = useInstanceId(AUTOCOMPLETE_HOOK_REFERENCE);\n const [state, dispatch] = useReducer(autocompleteReducer, initialState);\n const {\n selectedIndex,\n filteredOptions,\n filterValue,\n autocompleter\n } = state;\n const backspacingRef = useRef(false);\n const prevRecordTextRef = useRef('');\n const lastCompletionRef = useRef(null);\n function insertCompletion(replacement) {\n if (autocompleter === null) {\n return '';\n }\n const end = record.start;\n const start = end - autocompleter.triggerPrefix.length - filterValue.length;\n const toInsert = create({\n html: renderToString(replacement)\n });\n onChange(insert(record, toInsert, start, end));\n return getTextContent(toInsert);\n }\n function select(option) {\n if (option.isDisabled || !autocompleter) {\n return;\n }\n const {\n getOptionCompletion\n } = autocompleter;\n if (!getOptionCompletion) {\n dispatch({\n type: 'RESET'\n });\n contentRef.current?.focus();\n return;\n }\n const completionObject = getCompletionObject(getOptionCompletion(option.value, filterValue));\n if ('replace' === completionObject.action) {\n onReplace([completionObject.value]);\n // When replacing, the component will unmount, so don't reset\n // state (below) on an unmounted component.\n return;\n }\n if ('insert-at-caret' === completionObject.action) {\n const completionText = insertCompletion(completionObject.value);\n // When the completion value starts with the trigger prefix\n // (e.g. @username), the trigger stays in the text and would\n // re-activate the autocompleter. Store the completed text so\n // the effect can suppress the stale re-match.\n if (completionText.startsWith(autocompleter.triggerPrefix)) {\n const afterPrefix = completionText.slice(autocompleter.triggerPrefix.length);\n if (afterPrefix) {\n lastCompletionRef.current = {\n name: autocompleter.name,\n value: afterPrefix\n };\n }\n }\n }\n\n // Reset autocomplete state after insertion rather than before\n // so insertion events don't cause the completion menu to redisplay.\n dispatch({\n type: 'RESET'\n });\n\n // Make sure that the content remains focused after making a selection\n // and that the text cursor position is not lost.\n contentRef.current?.focus();\n }\n function onChangeOptions(options) {\n dispatch({\n type: 'OPTIONS',\n options\n });\n }\n function handleKeyDown(event) {\n backspacingRef.current = event.key === 'Backspace';\n if (!autocompleter) {\n return;\n }\n if (filteredOptions.length === 0) {\n return;\n }\n if (event.defaultPrevented) {\n return;\n }\n switch (event.key) {\n case 'ArrowUp':\n case 'ArrowDown':\n {\n const offset = event.key === 'ArrowUp' ? -1 : 1;\n const newIndex = (selectedIndex + offset + filteredOptions.length) % filteredOptions.length;\n dispatch({\n type: 'SELECT',\n index: newIndex\n });\n // See the related PR as to why this is necessary: https://github.com/WordPress/gutenberg/pull/54902.\n if (isAppleOS()) {\n speak(getNodeText(filteredOptions[newIndex].label), 'assertive');\n }\n break;\n }\n case 'Escape':\n dispatch({\n type: 'RESET'\n });\n event.preventDefault();\n break;\n case 'Enter':\n select(filteredOptions[selectedIndex]);\n break;\n case 'ArrowLeft':\n case 'ArrowRight':\n dispatch({\n type: 'RESET'\n });\n return;\n default:\n return;\n }\n\n // Any handled key should prevent original behavior. This relies on\n // the early return in the default case.\n event.preventDefault();\n }\n\n // textContent is a primitive (string), memoizing is not strictly necessary\n // but this is a preemptive performance improvement, since the autocompleter\n // is a potential bottleneck for the editor type metric.\n const textContent = useMemo(() => {\n if (isCollapsed(record)) {\n return getTextContent(slice(record, 0));\n }\n return '';\n }, [record]);\n useEffect(() => {\n const isTextChange = record.text !== prevRecordTextRef.current;\n prevRecordTextRef.current = record.text;\n function getTextAfterSelection() {\n return textContent ? getTextContent(slice(record, undefined, getTextContent(record).length)) : '';\n }\n const match = getAutocompleteMatch(textContent, completers, {\n matchCount: filteredOptions.length,\n isBackspacing: backspacingRef.current,\n getTextAfterSelection,\n lastCompletion: lastCompletionRef.current\n });\n if (!match) {\n if (autocompleter) {\n dispatch({\n type: 'RESET'\n });\n }\n return;\n }\n const {\n completer,\n filterValue: query\n } = match;\n\n // Don't re-activate a dismissed autocompleter on cursor-only\n // movement. `textContent` (text before cursor) changes with the\n // caret, so the effect re-runs, but `record.text` does not.\n // Complements the render-time `didUserInput` gate in\n // `useAutocompleteProps` for callers using this hook directly.\n if (!autocompleter && !isTextChange) {\n return;\n }\n\n // Clear stale completion ref when the user types a new trigger\n // for the same completer (the previous completion is no longer\n // relevant). Must be after the cursor-only check so that mere\n // cursor movement doesn't discard the suppression state.\n if (lastCompletionRef.current && lastCompletionRef.current.name === completer.name) {\n lastCompletionRef.current = null;\n }\n dispatch({\n type: 'MATCH',\n completer,\n query\n });\n // We want to avoid introducing unexpected side effects.\n // See https://github.com/WordPress/gutenberg/pull/41820\n }, [textContent]);\n const {\n key: selectedKey = ''\n } = filteredOptions[selectedIndex] || {};\n const {\n className\n } = autocompleter || {};\n const isExpanded = !!autocompleter && filteredOptions.length > 0;\n const listBoxId = isExpanded ? `components-autocomplete-listbox-${instanceId}` : undefined;\n const activeId = isExpanded ? `components-autocomplete-item-${instanceId}-${selectedKey}` : null;\n const hasSelection = record.start !== undefined;\n const showPopover = !!textContent && hasSelection && !!autocompleter;\n return {\n listBoxId,\n activeId,\n onKeyDown: withIgnoreIMEEvents(handleKeyDown),\n popover: showPopover && /*#__PURE__*/_jsx(AutocompleterUI, {\n autocompleter: autocompleter,\n className: className,\n filterValue: filterValue,\n instanceId: instanceId,\n listBoxId: listBoxId,\n selectedIndex: selectedIndex,\n onChangeOptions: onChangeOptions,\n onSelect: select,\n contentRef: contentRef,\n reset: () => dispatch({\n type: 'RESET'\n })\n }, autocompleter.name + autocompleter.triggerPrefix)\n };\n}\n\n/**\n * Checks whether two records represent the same user-visible state\n * (same text content and cursor position).\n */\nfunction recordValuesMatch(a, b) {\n return a.text === b.text && a.start === b.start && a.end === b.end;\n}\n\n/**\n * Tracks the last record whose value differed from the current one.\n * Used to determine whether the user has actually typed something\n */\nexport function useLastDifferentValue(value) {\n const history = useRef([]);\n const lastEntry = history.current[history.current.length - 1];\n\n // Only add to history if the value is meaningfully different from\n // the most recent entry (analogous to Set.add being a no-op for\n // duplicate references in the original implementation).\n if (!lastEntry || !recordValuesMatch(value, lastEntry)) {\n history.current.push(value);\n }\n\n // Keep the history size to 2.\n if (history.current.length > 2) {\n history.current.shift();\n }\n return history.current[0];\n}\nexport function useAutocompleteProps(options) {\n const ref = useRef(null);\n const onKeyDownRef = useRef(undefined);\n const {\n record\n } = options;\n const previousRecord = useLastDifferentValue(record);\n const {\n popover,\n listBoxId,\n activeId,\n onKeyDown\n } = useAutocomplete({\n ...options,\n contentRef: ref\n });\n onKeyDownRef.current = onKeyDown;\n const mergedRefs = useMergeRefs([ref, useRefEffect(element => {\n function _onKeyDown(event) {\n onKeyDownRef.current?.(event);\n }\n // Capture phase. When the autocomplete popover is open,\n // Up/Down/Enter/Escape must navigate the completion list —\n // they shouldn't be consumed by ancestor handlers (e.g.\n // block-editor's writing-flow) for block navigation, block\n // splitting, or \"move out of parent\" actions. Those handlers\n // fire at bubble phase and gate on `event.defaultPrevented`,\n // so firing in capture lets us preventDefault first when the\n // popover is active.\n return subscribeOwnedListener(element, 'keydown', _onKeyDown, true);\n }, [])]);\n\n // We only want to show the popover if the user has typed something.\n const didUserInput = record.text !== previousRecord?.text;\n if (!didUserInput) {\n return {\n ref: mergedRefs\n };\n }\n return {\n ref: mergedRefs,\n children: popover,\n 'aria-autocomplete': listBoxId ? 'list' : undefined,\n 'aria-owns': listBoxId,\n 'aria-activedescendant': activeId\n };\n}\nexport default function Autocomplete({\n children,\n isSelected,\n ...options\n}) {\n const {\n popover,\n ...props\n } = useAutocomplete(options);\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [children(props), isSelected && popover]\n });\n}"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAuE;AACvE,qBAA0D;AAC1D,uBAAuG;AACvG,kBAAsB;AACtB,sBAA0B;AAK1B,8BAAgC;AAChC,oCAAqC;AACrC,oCAAoC;AACpC,2BAAwB;AACxB,yBAAuB;AACvB,yBAAkE;AAClE,IAAM;AAAA,EACJ;AACF,QAAI,2BAAO,iBAAAA,WAAmB;AAC9B,IAAM,yBAAyB,CAAC;AAGhC,IAAM,8BAA8B,CAAC;AACrC,SAAS,oBAAoB,YAAY;AACvC,MAAI,eAAe,QAAQ,OAAO,eAAe,YAAY,YAAY,cAAc,WAAW,WAAW,UAAa,WAAW,cAAc,WAAW,UAAU,QAAW;AACjL,WAAO;AAAA,EACT;AACA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;AACA,IAAM,eAAe;AAAA,EACnB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,eAAe;AACjB;AACA,SAAS,oBAAoB,OAAO,QAAQ;AAC1C,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,eAAe,OAAO;AAAA,MACxB;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,iBAAiB,OAAO;AAAA,QACxB,eAAe,OAAO,QAAQ,WAAW,MAAM,gBAAgB,SAAS,MAAM,gBAAgB;AAAA,MAChG;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,eAAe,OAAO;A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gB,CAAC,CAAC;AACvD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,eAAW,mDAAoB,aAAa;AAAA,IAC5C,SAAS,eAA4B,uCAAAC,KAAK,yCAAiB;AAAA,MACzD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA,OAAO,MAAM,SAAS;AAAA,QACpB,MAAM;AAAA,MACR,CAAC;AAAA,IACH,GAAG,cAAc,OAAO,cAAc,aAAa;AAAA,EACrD;AACF;AAMA,SAAS,kBAAkB,GAAG,GAAG;AAC/B,SAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE;AACjE;AAMO,SAAS,sBAAsB,OAAO;AAC3C,QAAM,cAAU,uBAAO,CAAC,CAAC;AACzB,QAAM,YAAY,QAAQ,QAAQ,QAAQ,QAAQ,SAAS,CAAC;AAK5D,MAAI,CAAC,aAAa,CAAC,kBAAkB,OAAO,SAAS,GAAG;AACtD,YAAQ,QAAQ,KAAK,KAAK;AAAA,EAC5B;AAGA,MAAI,QAAQ,QAAQ,SAAS,GAAG;AAC9B,YAAQ,QAAQ,MAAM;AAAA,EACxB;AACA,SAAO,QAAQ,QAAQ,CAAC;AAC1B;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { renderToString, useEffect, useMemo, useReducer, useRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { create, slice, insert, isCollapsed, getTextContent, privateApis as richTextPrivateApis } from '@wordpress/rich-text';\nimport { speak } from '@wordpress/a11y';\nimport { isAppleOS } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { AutocompleterUI } from './autocompleter-ui';\nimport { getAutocompleteMatch } from './get-autocomplete-match';\nimport { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';\nimport getNodeText from '../utils/get-node-text';\nimport { unlock } from '../lock-unlock';\nimport { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst {\n subscribeOwnedListener\n} = unlock(richTextPrivateApis);\nconst EMPTY_FILTERED_OPTIONS = [];\n\n// Used for generating the instance ID\nconst AUTOCOMPLETE_HOOK_REFERENCE = {};\nfunction getCompletionObject(completion) {\n if (completion !== null && typeof completion === 'object' && 'action' in completion && completion.action !== undefined && 'value' in completion && completion.value !== undefined) {\n return completion;\n }\n return {\n action: 'insert-at-caret',\n value: completion\n };\n}\nconst initialState = {\n selectedIndex: 0,\n filteredOptions: EMPTY_FILTERED_OPTIONS,\n filterValue: '',\n autocompleter: null\n};\nfunction autocompleteReducer(state, action) {\n switch (action.type) {\n case 'RESET':\n return initialState;\n case 'SELECT':\n return {\n ...state,\n selectedIndex: action.index\n };\n case 'OPTIONS':\n return {\n ...state,\n filteredOptions: action.options,\n selectedIndex: action.options.length === state.filteredOptions.length ? state.selectedIndex : 0\n };\n case 'MATCH':\n return {\n ...state,\n autocompleter: action.completer,\n filterValue: action.query\n };\n }\n}\nexport function useAutocomplete({\n record,\n onChange,\n onReplace,\n completers,\n contentRef\n}) {\n const instanceId = useInstanceId(AUTOCOMPLETE_HOOK_REFERENCE);\n const [state, dispatch] = useReducer(autocompleteReducer, initialState);\n const {\n selectedIndex,\n filteredOptions,\n filterValue,\n autocompleter\n } = state;\n const backspacingRef = useRef(false);\n const prevRecordTextRef = useRef('');\n const lastCompletionRef = useRef(null);\n function insertCompletion(replacement) {\n if (autocompleter === null) {\n return '';\n }\n const end = record.start;\n const start = end - autocompleter.triggerPrefix.length - filterValue.length;\n const toInsert = create({\n html: renderToString(replacement)\n });\n onChange(insert(record, toInsert, start, end));\n return getTextContent(toInsert);\n }\n function select(option) {\n if (option.isDisabled || !autocompleter) {\n return;\n }\n const {\n getOptionCompletion\n } = autocompleter;\n if (!getOptionCompletion) {\n dispatch({\n type: 'RESET'\n });\n contentRef.current?.focus();\n return;\n }\n const completionObject = getCompletionObject(getOptionCompletion(option.value, filterValue));\n if ('replace' === completionObject.action) {\n onReplace([completionObject.value]);\n // When replacing, the component will unmount, so don't reset\n // state (below) on an unmounted component.\n return;\n }\n if ('insert-at-caret' === completionObject.action) {\n const completionText = insertCompletion(completionObject.value);\n // When the completion value starts with the trigger prefix\n // (e.g. @username), the trigger stays in the text and would\n // re-activate the autocompleter. Store the completed text so\n // the effect can suppress the stale re-match.\n if (completionText.startsWith(autocompleter.triggerPrefix)) {\n const afterPrefix = completionText.slice(autocompleter.triggerPrefix.length);\n if (afterPrefix) {\n lastCompletionRef.current = {\n name: autocompleter.name,\n value: afterPrefix\n };\n }\n }\n }\n\n // Reset autocomplete state after insertion rather than before\n // so insertion events don't cause the completion menu to redisplay.\n dispatch({\n type: 'RESET'\n });\n\n // Make sure that the content remains focused after making a selection\n // and that the text cursor position is not lost.\n contentRef.current?.focus();\n }\n function onChangeOptions(options) {\n dispatch({\n type: 'OPTIONS',\n options\n });\n }\n function handleKeyDown(event) {\n backspacingRef.current = event.key === 'Backspace';\n if (!autocompleter) {\n return;\n }\n if (filteredOptions.length === 0) {\n return;\n }\n if (event.defaultPrevented) {\n return;\n }\n switch (event.key) {\n case 'ArrowUp':\n case 'ArrowDown':\n {\n const offset = event.key === 'ArrowUp' ? -1 : 1;\n const newIndex = (selectedIndex + offset + filteredOptions.length) % filteredOptions.length;\n dispatch({\n type: 'SELECT',\n index: newIndex\n });\n // See the related PR as to why this is necessary: https://github.com/WordPress/gutenberg/pull/54902.\n if (isAppleOS()) {\n speak(getNodeText(filteredOptions[newIndex].label), 'assertive');\n }\n break;\n }\n case 'Escape':\n dispatch({\n type: 'RESET'\n });\n event.preventDefault();\n break;\n case 'Enter':\n select(filteredOptions[selectedIndex]);\n break;\n case 'ArrowLeft':\n case 'ArrowRight':\n dispatch({\n type: 'RESET'\n });\n return;\n default:\n return;\n }\n\n // Any handled key should prevent original behavior. This relies on\n // the early return in the default case.\n event.preventDefault();\n }\n\n // textContent is a primitive (string), memoizing is not strictly necessary\n // but this is a preemptive performance improvement, since the autocompleter\n // is a potential bottleneck for the editor type metric.\n const textContent = useMemo(() => {\n if (isCollapsed(record)) {\n return getTextContent(slice(record, 0));\n }\n return '';\n }, [record]);\n useEffect(() => {\n const isTextChange = record.text !== prevRecordTextRef.current;\n prevRecordTextRef.current = record.text;\n function getTextAfterSelection() {\n return textContent ? getTextContent(slice(record, undefined, getTextContent(record).length)) : '';\n }\n const match = getAutocompleteMatch(textContent, completers, {\n matchCount: filteredOptions.length,\n isBackspacing: backspacingRef.current,\n getTextAfterSelection,\n lastCompletion: lastCompletionRef.current\n });\n if (!match) {\n if (autocompleter) {\n dispatch({\n type: 'RESET'\n });\n }\n return;\n }\n const {\n completer,\n filterValue: query\n } = match;\n\n // Don't re-activate a dismissed autocompleter on cursor-only\n // movement. `textContent` (text before cursor) changes with the\n // caret, so the effect re-runs, but `record.text` does not.\n // Complements the render-time `didUserInput` gate in\n // `useAutocompleteProps` for callers using this hook directly.\n if (!autocompleter && !isTextChange) {\n return;\n }\n\n // Clear stale completion ref when the user types a new trigger\n // for the same completer (the previous completion is no longer\n // relevant). Must be after the cursor-only check so that mere\n // cursor movement doesn't discard the suppression state.\n if (lastCompletionRef.current && lastCompletionRef.current.name === completer.name) {\n lastCompletionRef.current = null;\n }\n dispatch({\n type: 'MATCH',\n completer,\n query\n });\n // We want to avoid introducing unexpected side effects.\n // See https://github.com/WordPress/gutenberg/pull/41820\n }, [textContent]);\n const {\n key: selectedKey = ''\n } = filteredOptions[selectedIndex] || {};\n const {\n className\n } = autocompleter || {};\n const isExpanded = !!autocompleter && filteredOptions.length > 0;\n const listBoxId = isExpanded ? `components-autocomplete-listbox-${instanceId}` : undefined;\n const activeId = isExpanded ? `components-autocomplete-item-${instanceId}-${selectedKey}` : null;\n const hasSelection = record.start !== undefined;\n const showPopover = !!textContent && hasSelection && !!autocompleter;\n return {\n listBoxId,\n activeId,\n onKeyDown: withIgnoreIMEEvents(handleKeyDown),\n popover: showPopover && /*#__PURE__*/_jsx(AutocompleterUI, {\n autocompleter: autocompleter,\n className: className,\n filterValue: filterValue,\n instanceId: instanceId,\n listBoxId: listBoxId,\n selectedIndex: selectedIndex,\n onChangeOptions: onChangeOptions,\n onSelect: select,\n contentRef: contentRef,\n reset: () => dispatch({\n type: 'RESET'\n })\n }, autocompleter.name + autocompleter.triggerPrefix)\n };\n}\n\n/**\n * Checks whether two records represent the same user-visible state\n * (same text content and cursor position).\n */\nfunction recordValuesMatch(a, b) {\n return a.text === b.text && a.start === b.start && a.end === b.end;\n}\n\n/**\n * Tracks the last record whose value differed from the current one.\n * Used to determine whether the user has actually typed something\n */\nexport function useLastDifferentValue(value) {\n const history = useRef([]);\n const lastEntry = history.current[history.current.length - 1];\n\n // Only add to history if the value is meaningfully different from\n // the most recent entry (analogous to Set.add being a no-op for\n // duplicate references in the original implementation).\n if (!lastEntry || !recordValuesMatch(value, lastEntry)) {\n history.current.push(value);\n }\n\n // Keep the history size to 2.\n if (history.current.length > 2) {\n history.current.shift();\n }\n return history.current[0];\n}\n\n// The popover is anchored to the element this hook's own `ref` lands on, so it\n// owns `contentRef` and callers don't provide one.\nexport function useAutocompleteProps(options) {\n const ref = useRef(null);\n const onKeyDownRef = useRef(undefined);\n const {\n record\n } = options;\n const previousRecord = useLastDifferentValue(record);\n const {\n popover,\n listBoxId,\n activeId,\n onKeyDown\n } = useAutocomplete({\n ...options,\n contentRef: ref\n });\n onKeyDownRef.current = onKeyDown;\n const mergedRefs = useMergeRefs([ref, useRefEffect(element => {\n function _onKeyDown(event) {\n onKeyDownRef.current?.(event);\n }\n // Capture phase. When the autocomplete popover is open,\n // Up/Down/Enter/Escape must navigate the completion list —\n // they shouldn't be consumed by ancestor handlers (e.g.\n // block-editor's writing-flow) for block navigation, block\n // splitting, or \"move out of parent\" actions. Those handlers\n // fire at bubble phase and gate on `event.defaultPrevented`,\n // so firing in capture lets us preventDefault first when the\n // popover is active.\n return subscribeOwnedListener(element, 'keydown', _onKeyDown, true);\n }, [])]);\n\n // We only want to show the popover if the user has typed something.\n const didUserInput = record.text !== previousRecord?.text;\n if (!didUserInput) {\n return {\n ref: mergedRefs\n };\n }\n\n // `aria-owns` and `aria-controls` point at the same list: either one lets\n // `aria-activedescendant` resolve to an option rendered outside this\n // element, and assistive technology support differs between them.\n //\n // No `aria-expanded`: consumers are `textbox` elements, which don't\n // support it; that would mean `role=\"combobox\"`, which in turn doesn't\n // support the `aria-multiline` these fields set.\n return {\n ref: mergedRefs,\n children: popover,\n 'aria-autocomplete': listBoxId ? 'list' : undefined,\n 'aria-haspopup': listBoxId ? 'listbox' : undefined,\n 'aria-controls': listBoxId,\n 'aria-owns': listBoxId,\n 'aria-activedescendant': activeId ?? undefined\n };\n}\nexport default function Autocomplete({\n children,\n isSelected,\n ...options\n}) {\n const {\n popover,\n ...props\n } = useAutocomplete(options);\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [children(props), isSelected && popover]\n });\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAuE;AACvE,qBAA0D;AAC1D,uBAAuG;AACvG,kBAAsB;AACtB,sBAA0B;AAK1B,8BAAgC;AAChC,oCAAqC;AACrC,oCAAoC;AACpC,2BAAwB;AACxB,yBAAuB;AACvB,yBAAkE;AAClE,IAAM;AAAA,EACJ;AACF,QAAI,2BAAO,iBAAAA,WAAmB;AAC9B,IAAM,yBAAyB,CAAC;AAGhC,IAAM,8BAA8B,CAAC;AACrC,SAAS,oBAAoB,YAAY;AACvC,MAAI,eAAe,QAAQ,OAAO,eAAe,YAAY,YAAY,cAAc,WAAW,WAAW,UAAa,WAAW,cAAc,WAAW,UAAU,QAAW;AACjL,WAAO;AAAA,EACT;AACA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;AACA,IAAM,eAAe;AAAA,E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 @@ var UnconnectedColorPicker = (props, forwardedRef) => {
|
|
|
95
95
|
...safeColordColor.toHsl()
|
|
96
96
|
}));
|
|
97
97
|
const lastProducedHexRef = (0, import_element.useRef)(safeColordColor.toHex());
|
|
98
|
+
const isPickerInteractingRef = (0, import_element.useRef)(false);
|
|
98
99
|
(0, import_element.useEffect)(() => {
|
|
99
|
-
|
|
100
|
-
if (incomingHex === lastProducedHexRef.current) {
|
|
100
|
+
if (isPickerInteractingRef.current) {
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
|
-
lastProducedHexRef.current
|
|
103
|
+
if (safeColordColor.isEqual(lastProducedHexRef.current)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
lastProducedHexRef.current = safeColordColor.toHex();
|
|
104
107
|
const externalHSLA = safeColordColor.toHsl();
|
|
105
108
|
setInternalHSLA((prev) => mergeHSLA(externalHSLA, prev));
|
|
106
109
|
}, [safeColordColor]);
|
|
@@ -108,7 +111,7 @@ var UnconnectedColorPicker = (props, forwardedRef) => {
|
|
|
108
111
|
setInternalHSLA(nextHSLA);
|
|
109
112
|
const previousHex = lastProducedHexRef.current;
|
|
110
113
|
const nextHex = (0, import_colord.colord)(nextHSLA).toHex();
|
|
111
|
-
if (nextHex
|
|
114
|
+
if (!(0, import_colord.colord)(nextHex).isEqual(previousHex)) {
|
|
112
115
|
lastProducedHexRef.current = nextHex;
|
|
113
116
|
setColor(nextHex);
|
|
114
117
|
}
|
|
@@ -151,7 +154,13 @@ var UnconnectedColorPicker = (props, forwardedRef) => {
|
|
|
151
154
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_picker.Picker, {
|
|
152
155
|
onChange: handleHSLAChange,
|
|
153
156
|
hsla: internalHSLA,
|
|
154
|
-
enableAlpha
|
|
157
|
+
enableAlpha,
|
|
158
|
+
onInteractionStart: () => {
|
|
159
|
+
isPickerInteractingRef.current = true;
|
|
160
|
+
},
|
|
161
|
+
onInteractionEnd: () => {
|
|
162
|
+
isPickerInteractingRef.current = false;
|
|
163
|
+
}
|
|
155
164
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.AuxiliaryColorArtefactWrapper, {
|
|
156
165
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.AuxiliaryColorArtefactHStackHeader, {
|
|
157
166
|
justify: "space-between",
|
|
@@ -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, getFormat } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef, 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]);\n\n/**\n * Merges incoming HSLA with previous state, preserving hue for achromatic\n * colors and saturation only at lightness extremes (black/white) where\n * it has no visual effect.\n */\nfunction mergeHSLA(nextHSLA, prevHSLA) {\n if (nextHSLA.s === 0) {\n if (nextHSLA.l === 0 || nextHSLA.l === 100) {\n return {\n ...nextHSLA,\n h: prevHSLA.h,\n s: prevHSLA.s\n };\n }\n return {\n ...nextHSLA,\n h: prevHSLA.h\n };\n }\n return nextHSLA;\n}\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\n // Internal HSLA state preserves hue and saturation values that\n // would otherwise be lost when converting to/from hex at achromatic\n // colors (e.g. pure black or white where any H/S maps to the same hex).\n const [internalHSLA, setInternalHSLA] = useState(() => ({\n ...safeColordColor.toHsl()\n }));\n\n // Track the last hex we produced so the sync effect can\n // distinguish our own updates from external prop changes.\n const lastProducedHexRef = useRef(safeColordColor.toHex());\n\n // Sync internalHSLA when the color prop changes externally (e.g.\n // parent passes a new color that wasn't produced by our onChange).\n useEffect(() => {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAA0C;AAC1C,mBAAwB;AAKxB,qBAAkE;AAClE,qBAA4B;AAC5B,kBAAmB;AAKnB,qBAAiD;AACjD,oBAAqI;AACrI,+BAAgC;AAChC,yBAA2B;AAC3B,oBAAuB;AACvB,mBAAmC;AACnC,yBAA2C;AAAA,IAC3C,sBAAO,CAAC,aAAAA,OAAW,CAAC;AAOpB,SAAS,UAAU,UAAU,UAAU;AACrC,MAAI,SAAS,MAAM,GAAG;AACpB,QAAI,SAAS,MAAM,KAAK,SAAS,MAAM,KAAK;AAC1C,aAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG,SAAS;AAAA,QACZ,GAAG,SAAS;AAAA,MACd;AAAA,IACF;AACA,WAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAG,SAAS;AAAA,IACd;AAAA,EACF;AACA,SAAO;AACT;AACA,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;AACD,QAAM,sBAAkB,wBAAQ,MAAM;AACpC,eAAO,sBAAO,SAAS,EAAE;AAAA,EAC3B,GAAG,CAAC,KAAK,CAAC;AACV,QAAM,wBAAoB,4BAAY,QAAQ;AAK9C,QAAM,CAAC,cAAc,eAAe,QAAI,yBAAS,OAAO;AAAA,IACtD,GAAG,gBAAgB,MAAM;AAAA,EAC3B,EAAE;AAIF,QAAM,yBAAqB,uBAAO,gBAAgB,MAAM,CAAC;AAIzD,gCAAU,MAAM;AACd,
|
|
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, useEffect, useRef, 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]);\n\n/**\n * Merges incoming HSLA with previous state, preserving hue for achromatic\n * colors and saturation only at lightness extremes (black/white) where\n * it has no visual effect.\n */\nfunction mergeHSLA(nextHSLA, prevHSLA) {\n if (nextHSLA.s === 0) {\n if (nextHSLA.l === 0 || nextHSLA.l === 100) {\n return {\n ...nextHSLA,\n h: prevHSLA.h,\n s: prevHSLA.s\n };\n }\n return {\n ...nextHSLA,\n h: prevHSLA.h\n };\n }\n return nextHSLA;\n}\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\n // Internal HSLA state preserves hue and saturation values that\n // would otherwise be lost when converting to/from hex at achromatic\n // colors (e.g. pure black or white where any H/S maps to the same hex).\n const [internalHSLA, setInternalHSLA] = useState(() => ({\n ...safeColordColor.toHsl()\n }));\n\n // Track the last hex we produced so the sync effect can\n // distinguish our own updates from external prop changes.\n const lastProducedHexRef = useRef(safeColordColor.toHex());\n\n // While the user is dragging the visual picker, ignore color-prop sync\n // so delayed/stale controlled echoes cannot overwrite internalHSLA mid-drag.\n const isPickerInteractingRef = useRef(false);\n\n // Sync internalHSLA when the color prop changes externally (e.g.\n // parent passes a new color that wasn't produced by our onChange).\n useEffect(() => {\n if (isPickerInteractingRef.current) {\n return;\n }\n\n // Compare by color equality, not hex string — rgb()/rgba()\n // round-trips can differ in string form for the same color.\n if (safeColordColor.isEqual(lastProducedHexRef.current)) {\n return;\n }\n\n // Genuinely external change — sync internalHSLA.\n lastProducedHexRef.current = safeColordColor.toHex();\n const externalHSLA = safeColordColor.toHsl();\n setInternalHSLA(prev => mergeHSLA(externalHSLA, prev));\n }, [safeColordColor]);\n\n // Handler for HSL inputs (and the HSVA picker after it converts to HSLA).\n // Apply the user's HSLA, then notify the parent only when the color\n // actually changes. setColor must not run inside setInternalHSLA\n // (state updaters must be pure). Uses direct setColor (not debounced)\n // to avoid races with hex/RGB's debouncedSetColor.\n const handleHSLAChange = useCallback(nextHSLA => {\n setInternalHSLA(nextHSLA);\n const previousHex = lastProducedHexRef.current;\n const nextHex = colord(nextHSLA).toHex();\n if (!colord(nextHex).isEqual(previousHex)) {\n lastProducedHexRef.current = nextHex;\n setColor(nextHex);\n }\n }, [setColor]);\n\n // Handler for components that provide Colord values (RGB, Hex inputs).\n // Uses debouncedSetColor since the hex input fires per keystroke.\n const handleChange = useCallback(nextValue => {\n const nextHSLA = nextValue.toHsl();\n setInternalHSLA(prev => mergeHSLA(nextHSLA, prev));\n const nextHex = nextValue.toHex();\n lastProducedHexRef.current = nextHex;\n debouncedSetColor(nextHex);\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: handleHSLAChange,\n hsla: internalHSLA,\n enableAlpha: enableAlpha,\n onInteractionStart: () => {\n isPickerInteractingRef.current = true;\n },\n onInteractionEnd: () => {\n isPickerInteractingRef.current = false;\n }\n }), /*#__PURE__*/_jsxs(AuxiliaryColorArtefactWrapper, {\n children: [/*#__PURE__*/_jsxs(AuxiliaryColorArtefactHStackHeader, {\n justify: \"space-between\",\n children: [/*#__PURE__*/_jsx(SelectControl, {\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 hsla: internalHSLA,\n onChange: handleChange,\n onHSLChange: handleHSLAChange,\n enableAlpha: enableAlpha\n })\n })]\n })]\n });\n};\n\n/**\n * `ColorPicker` lets users select a color from a visual color surface, or by\n * editing its hex, RGB, or HSL values.\n */\nexport const ColorPicker = contextConnect(UnconnectedColorPicker, 'ColorPicker');\nexport default ColorPicker;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAA0C;AAC1C,mBAAwB;AAKxB,qBAAkE;AAClE,qBAA4B;AAC5B,kBAAmB;AAKnB,qBAAiD;AACjD,oBAAqI;AACrI,+BAAgC;AAChC,yBAA2B;AAC3B,oBAAuB;AACvB,mBAAmC;A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
});
|
|
25
25
|
module.exports = __toCommonJS(picker_exports);
|
|
26
|
+
var import_element = require("@wordpress/element");
|
|
26
27
|
var import_react_colorful = require("react-colorful");
|
|
28
|
+
var import_colord = require("colord");
|
|
27
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
function toHsva(hsla) {
|
|
31
|
+
return {
|
|
32
|
+
...(0, import_colord.colord)(hsla).toHsv(),
|
|
33
|
+
// HSL and HSV share the hue angle. Color conversion collapses achromatic
|
|
34
|
+
// hue to 0, but HSLA retains the user's latent hue.
|
|
35
|
+
h: hsla.h,
|
|
36
|
+
a: hsla.a
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function isSameHsla(a, b) {
|
|
40
|
+
return a.h === b.h && a.s === b.s && a.l === b.l && a.a === b.a;
|
|
41
|
+
}
|
|
42
|
+
function toHsvaFromHsla(hsla, prevHsva, prevHsla) {
|
|
43
|
+
const converted = toHsva(hsla);
|
|
44
|
+
if (hsla.l !== 0) {
|
|
45
|
+
return converted;
|
|
40
46
|
}
|
|
41
|
-
|
|
47
|
+
const saturationChanged = prevHsla !== null && prevHsla.s !== hsla.s;
|
|
48
|
+
return {
|
|
49
|
+
h: hsla.h,
|
|
50
|
+
s: saturationChanged ? hsla.s : prevHsva.s,
|
|
51
|
+
v: 0,
|
|
52
|
+
a: hsla.a
|
|
53
|
+
};
|
|
54
|
+
}
|
|
42
55
|
var Picker = ({
|
|
43
56
|
hsla,
|
|
44
57
|
enableAlpha,
|
|
45
|
-
onChange
|
|
58
|
+
onChange,
|
|
59
|
+
onInteractionStart,
|
|
60
|
+
onInteractionEnd
|
|
46
61
|
}) => {
|
|
62
|
+
const [hsva, setHsva] = (0, import_element.useState)(() => toHsva(hsla));
|
|
63
|
+
const pickerOriginHslaRef = (0, import_element.useRef)(null);
|
|
64
|
+
const prevHslaRef = (0, import_element.useRef)(hsla);
|
|
65
|
+
const isPointerInteractingRef = (0, import_element.useRef)(false);
|
|
66
|
+
(0, import_element.useEffect)(() => {
|
|
67
|
+
if (isPointerInteractingRef.current) {
|
|
68
|
+
prevHslaRef.current = hsla;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (pickerOriginHslaRef.current && isSameHsla(pickerOriginHslaRef.current, hsla)) {
|
|
72
|
+
prevHslaRef.current = hsla;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
pickerOriginHslaRef.current = null;
|
|
76
|
+
setHsva((prev) => toHsvaFromHsla(hsla, prev, prevHslaRef.current));
|
|
77
|
+
prevHslaRef.current = hsla;
|
|
78
|
+
}, [hsla]);
|
|
79
|
+
const pointerCaptureProps = {
|
|
80
|
+
onPointerDown({
|
|
81
|
+
currentTarget,
|
|
82
|
+
pointerId
|
|
83
|
+
}) {
|
|
84
|
+
isPointerInteractingRef.current = true;
|
|
85
|
+
onInteractionStart?.();
|
|
86
|
+
currentTarget.setPointerCapture(pointerId);
|
|
87
|
+
},
|
|
88
|
+
onPointerUp({
|
|
89
|
+
currentTarget,
|
|
90
|
+
pointerId
|
|
91
|
+
}) {
|
|
92
|
+
currentTarget.releasePointerCapture(pointerId);
|
|
93
|
+
isPointerInteractingRef.current = false;
|
|
94
|
+
onInteractionEnd?.();
|
|
95
|
+
},
|
|
96
|
+
onPointerCancel({
|
|
97
|
+
currentTarget,
|
|
98
|
+
pointerId
|
|
99
|
+
}) {
|
|
100
|
+
currentTarget.releasePointerCapture(pointerId);
|
|
101
|
+
isPointerInteractingRef.current = false;
|
|
102
|
+
onInteractionEnd?.();
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const handleChange = (next) => {
|
|
106
|
+
setHsva(next);
|
|
107
|
+
const nextHsla = {
|
|
108
|
+
...(0, import_colord.colord)(next).toHsl(),
|
|
109
|
+
a: next.a
|
|
110
|
+
};
|
|
111
|
+
pickerOriginHslaRef.current = nextHsla;
|
|
112
|
+
onChange(nextHsla);
|
|
113
|
+
};
|
|
47
114
|
if (enableAlpha) {
|
|
48
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_colorful.
|
|
49
|
-
color:
|
|
50
|
-
onChange,
|
|
115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_colorful.HsvaColorPicker, {
|
|
116
|
+
color: hsva,
|
|
117
|
+
onChange: handleChange,
|
|
51
118
|
...pointerCaptureProps
|
|
52
119
|
});
|
|
53
120
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
121
|
+
const hsv = {
|
|
122
|
+
h: hsva.h,
|
|
123
|
+
s: hsva.s,
|
|
124
|
+
v: hsva.v
|
|
125
|
+
};
|
|
126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_colorful.HsvColorPicker, {
|
|
127
|
+
color: hsv,
|
|
128
|
+
onChange: (next) => {
|
|
129
|
+
handleChange({
|
|
130
|
+
...next,
|
|
131
|
+
a: hsva.a
|
|
60
132
|
});
|
|
61
133
|
},
|
|
62
134
|
...pointerCaptureProps
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/color-picker/picker.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\n\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { HsvColorPicker, HsvaColorPicker } from 'react-colorful';\nimport { colord } from 'colord';\n\n/**\n * Internal dependencies\n */\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction toHsva(hsla) {\n return {\n ...colord(hsla).toHsv(),\n // HSL and HSV share the hue angle. Color conversion collapses achromatic\n // hue to 0, but HSLA retains the user's latent hue.\n h: hsla.h,\n a: hsla.a\n };\n}\nfunction isSameHsla(a, b) {\n return a.h === b.h && a.s === b.s && a.l === b.l && a.a === b.a;\n}\n\n/**\n * Convert parent HSLA into HSVA for prop sync.\n *\n * At black, RGB round-trips collapse saturation to 0. Preserve the native\n * HSVA saturation coordinate unless the HSL saturation channel itself\n * changed (sibling hue/alpha edits must not snap the pointer).\n *\n * At white, only `v: 100, s: 0` is visually white — preserving a prior\n * chromatic saturation would leave the pointer at the top-right and make\n * the first keyboard step jump from white to a saturated color.\n */\nfunction toHsvaFromHsla(hsla, prevHsva, prevHsla) {\n const converted = toHsva(hsla);\n\n // White and chromatic colors use the converted value as-is.\n if (hsla.l !== 0) {\n return converted;\n }\n const saturationChanged = prevHsla !== null && prevHsla.s !== hsla.s;\n return {\n h: hsla.h,\n s: saturationChanged ? hsla.s : prevHsva.s,\n v: 0,\n a: hsla.a\n };\n}\n\n/**\n * Visual color surface.\n *\n * Uses HSVA (react-colorful's native model) and keeps that value in local\n * state so HSLA↔hex round-trips cannot move the pointer\n * Parent ColorPicker still speaks HSLA for\n * inputs and controlled value sync; conversion happens only at the boundary.\n *\n * Prop sync from parent HSLA is suppressed for:\n * - pointer/touch drags (interaction flag), and\n * - any picker-originated update including keyboard (HSLA origin token).\n *\n * Achromatic HSL sibling edits (hue/alpha while at black) preserve native\n * HSVA saturation unless saturation itself changed. White always syncs to\n * the converted `s: 0` visual coordinate.\n */\nexport const Picker = ({\n hsla,\n enableAlpha,\n onChange,\n onInteractionStart,\n onInteractionEnd\n}) => {\n const [hsva, setHsva] = useState(() => toHsva(hsla));\n // Last HSLA emitted by this picker — skip echoing it back into HSVA.\n const pickerOriginHslaRef = useRef(null);\n // Previous parent HSLA — detect which channel changed on achromatic sync.\n const prevHslaRef = useRef(hsla);\n // Pointer/touch drag: never sync from HSLA mid-gesture (origin match alone\n // can fail across rapid frames when parent gradient state re-renders).\n const isPointerInteractingRef = useRef(false);\n useEffect(() => {\n if (isPointerInteractingRef.current) {\n // Keep prevHsla in lockstep with parent updates during the gesture\n // so a post-drag HSL sibling edit is not compared against pre-drag\n // HSLA and mistaken for a saturation change.\n prevHslaRef.current = hsla;\n return;\n }\n if (pickerOriginHslaRef.current && isSameHsla(pickerOriginHslaRef.current, hsla)) {\n prevHslaRef.current = hsla;\n return;\n }\n pickerOriginHslaRef.current = null;\n setHsva(prev => toHsvaFromHsla(hsla, prev, prevHslaRef.current));\n prevHslaRef.current = hsla;\n }, [hsla]);\n\n // Inline handlers so refs are not passed into a helper during render\n // (react-hooks/refs). Pointer capture also keeps drag working over iframes.\n const pointerCaptureProps = {\n onPointerDown({\n currentTarget,\n pointerId\n }) {\n isPointerInteractingRef.current = true;\n onInteractionStart?.();\n currentTarget.setPointerCapture(pointerId);\n },\n onPointerUp({\n currentTarget,\n pointerId\n }) {\n currentTarget.releasePointerCapture(pointerId);\n isPointerInteractingRef.current = false;\n onInteractionEnd?.();\n },\n onPointerCancel({\n currentTarget,\n pointerId\n }) {\n currentTarget.releasePointerCapture(pointerId);\n isPointerInteractingRef.current = false;\n onInteractionEnd?.();\n }\n };\n const handleChange = next => {\n setHsva(next);\n const nextHsla = {\n ...colord(next).toHsl(),\n a: next.a\n };\n pickerOriginHslaRef.current = nextHsla;\n onChange(nextHsla);\n };\n if (enableAlpha) {\n return /*#__PURE__*/_jsx(HsvaColorPicker, {\n color: hsva,\n onChange: handleChange,\n ...pointerCaptureProps\n });\n }\n\n // HsvColorPicker's equality checks enumerate own keys — never pass `a`,\n // or every parent re-render looks like an external color change and the\n // pointer jitters while dragging.\n const hsv = {\n h: hsva.h,\n s: hsva.s,\n v: hsva.v\n };\n return /*#__PURE__*/_jsx(HsvColorPicker, {\n color: hsv,\n onChange: next => {\n handleChange({\n ...next,\n a: hsva.a\n });\n },\n ...pointerCaptureProps\n });\n};"],
|
|
5
|
+
"mappings": ";;;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BAAY,UAAU;AAAA,EACxB,GAAG,CAAC,IAAI,CAAC;AAIT,QAAM,sBAAsB;AAAA,IAC1B,cAAc;AAAA,MACZ;AAAA,MACA;AAAA,IACF,GAAG;AACD,8BAAwB,UAAU;AAClC,2BAAqB;AACrB,oBAAc,kBAAkB,SAAS;AAAA,IAC3C;AAAA,IACA,YAAY;AAAA,MACV;AAAA,MACA;AAAA,IACF,GAAG;AACD,oBAAc,sBAAsB,SAAS;AAC7C,8BAAwB,UAAU;AAClC,yBAAmB;AAAA,IACrB;AAAA,IACA,gBAAgB;AAAA,MACd;AAAA,MACA;AAAA,IACF,GAAG;AACD,oBAAc,sBAAsB,SAAS;AAC7C,8BAAwB,UAAU;AAClC,yBAAmB;AAAA,IACrB;AAAA,EACF;AACA,QAAM,eAAe,UAAQ;AAC3B,YAAQ,IAAI;AACZ,UAAM,WAAW;AAAA,MACf,OAAG,sBAAO,IAAI,EAAE,MAAM;AAAA,MACtB,GAAG,KAAK;AAAA,IACV;AACA,wBAAoB,UAAU;AAC9B,aAAS,QAAQ;AAAA,EACnB;AACA,MAAI,aAAa;AACf,WAAoB,uCAAAA,KAAK,uCAAiB;AAAA,MACxC,OAAO;AAAA,MACP,UAAU;AAAA,MACV,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAKA,QAAM,MAAM;AAAA,IACV,GAAG,KAAK;AAAA,IACR,GAAG,KAAK;AAAA,IACR,GAAG,KAAK;AAAA,EACV;AACA,SAAoB,uCAAAA,KAAK,sCAAgB;AAAA,IACvC,OAAO;AAAA,IACP,UAAU,UAAQ;AAChB,mBAAa;AAAA,QACX,GAAG;AAAA,QACH,GAAG,KAAK;AAAA,MACV,CAAC;AAAA,IACH;AAAA,IACA,GAAG;AAAA,EACL,CAAC;AACH;",
|
|
6
6
|
"names": ["_jsx"]
|
|
7
7
|
}
|
|
@@ -42,8 +42,91 @@ var import_flex = require("../flex/index.cjs");
|
|
|
42
42
|
var import_button = __toESM(require("../button/index.cjs"));
|
|
43
43
|
var import_text = require("../text/index.cjs");
|
|
44
44
|
var import_v_stack = require("../v-stack/index.cjs");
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
|
|
46
|
+
// packages/style-runtime/src/index.ts
|
|
47
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
48
|
+
function getRuntime() {
|
|
49
|
+
const globalScope = globalThis;
|
|
50
|
+
if (globalScope.__wpStyleRuntime) {
|
|
51
|
+
return globalScope.__wpStyleRuntime;
|
|
52
|
+
}
|
|
53
|
+
globalScope.__wpStyleRuntime = {
|
|
54
|
+
documents: /* @__PURE__ */ new Map(),
|
|
55
|
+
styles: /* @__PURE__ */ new Map(),
|
|
56
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
57
|
+
};
|
|
58
|
+
if (typeof document !== "undefined") {
|
|
59
|
+
registerDocument(document);
|
|
60
|
+
}
|
|
61
|
+
return globalScope.__wpStyleRuntime;
|
|
62
|
+
}
|
|
63
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
64
|
+
if (!targetDocument.head) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {
|
|
68
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
function injectStyle(targetDocument, hash, css) {
|
|
75
|
+
if (!targetDocument.head) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const runtime = getRuntime();
|
|
79
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
80
|
+
if (!injectedStyles) {
|
|
81
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
82
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
83
|
+
}
|
|
84
|
+
if (injectedStyles.has(hash)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
88
|
+
injectedStyles.add(hash);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const style = targetDocument.createElement("style");
|
|
92
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
93
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
94
|
+
targetDocument.head.appendChild(style);
|
|
95
|
+
injectedStyles.add(hash);
|
|
96
|
+
}
|
|
97
|
+
function registerDocument(targetDocument) {
|
|
98
|
+
const runtime = getRuntime();
|
|
99
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
100
|
+
for (const [hash, css] of runtime.styles) {
|
|
101
|
+
injectStyle(targetDocument, hash, css);
|
|
102
|
+
}
|
|
103
|
+
return () => {
|
|
104
|
+
const count = runtime.documents.get(targetDocument);
|
|
105
|
+
if (count === void 0) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (count <= 1) {
|
|
109
|
+
runtime.documents.delete(targetDocument);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function registerStyle(hash, css) {
|
|
116
|
+
const runtime = getRuntime();
|
|
117
|
+
runtime.styles.set(hash, css);
|
|
118
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
119
|
+
injectStyle(targetDocument, hash, css);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// packages/components/src/confirm-dialog/style.module.scss
|
|
124
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
125
|
+
registerStyle("af7a0f28df", ".f8c6ba0dd016e6c1__wrapper.f8c6ba0dd016e6c1__wrapper{z-index:1000001}");
|
|
126
|
+
}
|
|
127
|
+
var style_module_default = { "wrapper": "f8c6ba0dd016e6c1__wrapper" };
|
|
128
|
+
|
|
129
|
+
// packages/components/src/confirm-dialog/component.tsx
|
|
47
130
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
131
|
var UnconnectedConfirmDialog = (props, forwardedRef) => {
|
|
49
132
|
const {
|
|
@@ -56,8 +139,7 @@ var UnconnectedConfirmDialog = (props, forwardedRef) => {
|
|
|
56
139
|
isBusy,
|
|
57
140
|
...otherProps
|
|
58
141
|
} = (0, import_context.useContextSystem)(props, "ConfirmDialog");
|
|
59
|
-
const
|
|
60
|
-
const wrapperClassName = cx(styles.wrapper);
|
|
142
|
+
const wrapperClassName = style_module_default.wrapper;
|
|
61
143
|
const cancelButtonRef = (0, import_element.useRef)(null);
|
|
62
144
|
const confirmButtonRef = (0, import_element.useRef)(null);
|
|
63
145
|
const [isOpen, setIsOpen] = (0, import_element.useState)();
|