@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
|
@@ -7,8 +7,91 @@ import { Flex } from "../flex/index.mjs";
|
|
|
7
7
|
import Button from "../button/index.mjs";
|
|
8
8
|
import { Text } from "../text/index.mjs";
|
|
9
9
|
import { VStack } from "../v-stack/index.mjs";
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
// packages/style-runtime/src/index.ts
|
|
12
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
13
|
+
function getRuntime() {
|
|
14
|
+
const globalScope = globalThis;
|
|
15
|
+
if (globalScope.__wpStyleRuntime) {
|
|
16
|
+
return globalScope.__wpStyleRuntime;
|
|
17
|
+
}
|
|
18
|
+
globalScope.__wpStyleRuntime = {
|
|
19
|
+
documents: /* @__PURE__ */ new Map(),
|
|
20
|
+
styles: /* @__PURE__ */ new Map(),
|
|
21
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
22
|
+
};
|
|
23
|
+
if (typeof document !== "undefined") {
|
|
24
|
+
registerDocument(document);
|
|
25
|
+
}
|
|
26
|
+
return globalScope.__wpStyleRuntime;
|
|
27
|
+
}
|
|
28
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
29
|
+
if (!targetDocument.head) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {
|
|
33
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
function injectStyle(targetDocument, hash, css) {
|
|
40
|
+
if (!targetDocument.head) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const runtime = getRuntime();
|
|
44
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
45
|
+
if (!injectedStyles) {
|
|
46
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
47
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
48
|
+
}
|
|
49
|
+
if (injectedStyles.has(hash)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
53
|
+
injectedStyles.add(hash);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const style = targetDocument.createElement("style");
|
|
57
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
58
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
59
|
+
targetDocument.head.appendChild(style);
|
|
60
|
+
injectedStyles.add(hash);
|
|
61
|
+
}
|
|
62
|
+
function registerDocument(targetDocument) {
|
|
63
|
+
const runtime = getRuntime();
|
|
64
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
65
|
+
for (const [hash, css] of runtime.styles) {
|
|
66
|
+
injectStyle(targetDocument, hash, css);
|
|
67
|
+
}
|
|
68
|
+
return () => {
|
|
69
|
+
const count = runtime.documents.get(targetDocument);
|
|
70
|
+
if (count === void 0) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (count <= 1) {
|
|
74
|
+
runtime.documents.delete(targetDocument);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function registerStyle(hash, css) {
|
|
81
|
+
const runtime = getRuntime();
|
|
82
|
+
runtime.styles.set(hash, css);
|
|
83
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
84
|
+
injectStyle(targetDocument, hash, css);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// packages/components/src/confirm-dialog/style.module.scss
|
|
89
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
90
|
+
registerStyle("af7a0f28df", ".f8c6ba0dd016e6c1__wrapper.f8c6ba0dd016e6c1__wrapper{z-index:1000001}");
|
|
91
|
+
}
|
|
92
|
+
var style_module_default = { "wrapper": "f8c6ba0dd016e6c1__wrapper" };
|
|
93
|
+
|
|
94
|
+
// packages/components/src/confirm-dialog/component.tsx
|
|
12
95
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
96
|
var UnconnectedConfirmDialog = (props, forwardedRef) => {
|
|
14
97
|
const {
|
|
@@ -21,8 +104,7 @@ var UnconnectedConfirmDialog = (props, forwardedRef) => {
|
|
|
21
104
|
isBusy,
|
|
22
105
|
...otherProps
|
|
23
106
|
} = useContextSystem(props, "ConfirmDialog");
|
|
24
|
-
const
|
|
25
|
-
const wrapperClassName = cx(styles.wrapper);
|
|
107
|
+
const wrapperClassName = style_module_default.wrapper;
|
|
26
108
|
const cancelButtonRef = useRef(null);
|
|
27
109
|
const confirmButtonRef = useRef(null);
|
|
28
110
|
const [isOpen, setIsOpen] = useState();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 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 isBusy,\n ...otherProps\n } = useContextSystem(props, 'ConfirmDialog');\n const cx = useCx();\n const wrapperClassName = cx(styles.wrapper);\n const cancelButtonRef = useRef(null);\n const confirmButtonRef = useRef(null);\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 ?? __('Cancel');\n const confirmLabel = 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": ";AAGA,SAAS,UAAU;AACnB,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAKzD,OAAO,WAAW;AAClB,SAAS,kBAAkB,sBAAsB;AACjD,SAAS,YAAY;AACrB,OAAO,YAAY;AACnB,SAAS,YAAY;AACrB,SAAS,cAAc;
|
|
3
|
+
"sources": ["../../src/confirm-dialog/component.tsx", "../../../style-runtime/src/index.ts", "../../src/confirm-dialog/style.module.scss"],
|
|
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 styles from './style.module.scss';\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 wrapperClassName = styles.wrapper;\n const cancelButtonRef = useRef(null);\n const confirmButtonRef = useRef(null);\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 ?? __('Cancel');\n const confirmLabel = 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;", "const STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n const globalScope = globalThis;\n if (globalScope.__wpStyleRuntime) {\n return globalScope.__wpStyleRuntime;\n }\n globalScope.__wpStyleRuntime = {\n documents: new Map(),\n styles: new Map(),\n injectedStyles: new WeakMap()\n };\n if (typeof document !== 'undefined') {\n registerDocument(document);\n }\n return globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(targetDocument, hash) {\n if (!targetDocument.head) {\n return false;\n }\n for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {\n if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle(targetDocument, hash, css) {\n if (!targetDocument.head) {\n return;\n }\n const runtime = getRuntime();\n let injectedStyles = runtime.injectedStyles.get(targetDocument);\n if (!injectedStyles) {\n injectedStyles = new Set();\n runtime.injectedStyles.set(targetDocument, injectedStyles);\n }\n if (injectedStyles.has(hash)) {\n return;\n }\n\n // Older generated CSS module output can still inject matching style tags\n // after this document's cache is created, so keep the DOM as the fallback\n // source of truth on cache misses.\n if (documentContainsStyleHash(targetDocument, hash)) {\n injectedStyles.add(hash);\n return;\n }\n const style = targetDocument.createElement('style');\n style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);\n style.appendChild(targetDocument.createTextNode(css));\n targetDocument.head.appendChild(style);\n injectedStyles.add(hash);\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument(targetDocument) {\n const runtime = getRuntime();\n runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);\n for (const [hash, css] of runtime.styles) {\n injectStyle(targetDocument, hash, css);\n }\n return () => {\n const count = runtime.documents.get(targetDocument);\n if (count === undefined) {\n return;\n }\n if (count <= 1) {\n runtime.documents.delete(targetDocument);\n return;\n }\n runtime.documents.set(targetDocument, count - 1);\n };\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle(hash, css) {\n const runtime = getRuntime();\n runtime.styles.set(hash, css);\n for (const targetDocument of runtime.documents.keys()) {\n injectStyle(targetDocument, hash, css);\n }\n}", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\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,WAAW;AAAA,UACX,SAAS;AAAA,UACT,UAAU,CAAc,qBAAK,QAAQ;AAAA,YACnC,uBAAuB;AAAA,YACvB,KAAK;AAAA,YACL,SAAS;AAAA,YACT,SAAS,YAAY,QAAQ;AAAA,YAC7B,wBAAwB;AAAA,YACxB,UAAU;AAAA,YACV,UAAU;AAAA,UACZ,CAAC,GAAgB,qBAAK,QAAQ;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,gBAAgB,eAAe,0BAA0B,eAAe;AACrF,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// packages/components/src/content-editable-control/index.tsx
|
|
2
|
-
import {
|
|
2
|
+
import { useMergeRefs } from "@wordpress/compose";
|
|
3
|
+
import { forwardRef, useRef } from "@wordpress/element";
|
|
3
4
|
import BaseControl from "../base-control/index.mjs";
|
|
4
5
|
import { useBaseControlProps } from "../base-control/hooks.mjs";
|
|
6
|
+
import { VisuallyHidden } from "../visually-hidden/index.mjs";
|
|
5
7
|
|
|
6
8
|
// packages/style-runtime/src/index.ts
|
|
7
9
|
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
@@ -82,12 +84,12 @@ function registerStyle(hash, css) {
|
|
|
82
84
|
|
|
83
85
|
// packages/components/src/content-editable-control/style.module.scss
|
|
84
86
|
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
85
|
-
registerStyle("
|
|
87
|
+
registerStyle("87e5397cb4", "._0f130cee1a924516__editable{background:var(--wp-components-color-background,var(--wpds-color-background-surface-neutral-strong,#fff));border:1px solid #949494;border-radius:2px;box-shadow:0 0 0 transparent;color:var(--wp-components-color-foreground,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-family:-apple-system,system-ui,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:16px;line-height:normal;padding:6px 8px;width:100%}@media not (prefers-reduced-motion){._0f130cee1a924516__editable{transition:box-shadow .1s linear}}@media (min-width:600px){._0f130cee1a924516__editable{font-size:13px;line-height:normal}}._0f130cee1a924516__editable:focus{border-color:var(--wp-admin-theme-color);box-shadow:0 0 0 .5px var(--wp-admin-theme-color);outline:2px solid transparent}._0f130cee1a924516__editable::placeholder{color:rgba(30,30,30,.62)}._0f130cee1a924516__editable{border-color:var(--wp-components-color-gray-600,var(--wpds-color-stroke-interactive-neutral,#8d8d8d))}._0f130cee1a924516__editable[aria-placeholder]:empty:before{color:color-mix(in srgb,var(--wp-components-color-foreground,var(--wpds-color-foreground-content-neutral,#1e1e1e)),transparent 38%);content:attr(aria-placeholder)}._0f130cee1a924516__editable{min-height:40px;padding:12px}._0f130cee1a924516__editable[aria-disabled=true]{background:var(--wp-components-color-gray-100,var(--wpds-color-background-surface-neutral,#fcfcfc));border-color:var(--wp-components-color-gray-300,var(--wpds-color-stroke-surface-neutral,#dbdbdb));color:var(--wp-components-color-gray-700,var(--wpds-color-foreground-content-neutral-weak,#707070));cursor:default}");
|
|
86
88
|
}
|
|
87
89
|
var style_module_default = { "editable": "_0f130cee1a924516__editable" };
|
|
88
90
|
|
|
89
91
|
// packages/components/src/content-editable-control/index.tsx
|
|
90
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
92
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
91
93
|
function UnforwardedContentEditableControl({
|
|
92
94
|
label,
|
|
93
95
|
id,
|
|
@@ -105,26 +107,34 @@ function UnforwardedContentEditableControl({
|
|
|
105
107
|
} = useBaseControlProps({
|
|
106
108
|
id,
|
|
107
109
|
className,
|
|
108
|
-
help
|
|
109
|
-
hideLabelFromVision,
|
|
110
|
-
label
|
|
110
|
+
help
|
|
111
111
|
});
|
|
112
|
-
|
|
112
|
+
const labelId = `${controlProps.id}__label`;
|
|
113
|
+
const editableRef = useRef(null);
|
|
114
|
+
const mergedRefs = useMergeRefs([editableRef, forwardedRef]);
|
|
115
|
+
return /* @__PURE__ */ _jsxs(BaseControl, {
|
|
113
116
|
...baseControlProps,
|
|
114
|
-
children: /* @__PURE__ */ _jsx(
|
|
117
|
+
children: [hideLabelFromVision ? /* @__PURE__ */ _jsx(VisuallyHidden, {
|
|
118
|
+
id: labelId,
|
|
119
|
+
children: label
|
|
120
|
+
}) : /* @__PURE__ */ _jsx(BaseControl.VisualLabel, {
|
|
121
|
+
id: labelId,
|
|
122
|
+
onClick: () => editableRef.current?.focus(),
|
|
123
|
+
children: label
|
|
124
|
+
}), /* @__PURE__ */ _jsx("div", {
|
|
115
125
|
className: style_module_default.editable,
|
|
116
126
|
role: "textbox",
|
|
117
127
|
"aria-multiline": true,
|
|
118
|
-
"aria-
|
|
128
|
+
"aria-labelledby": labelId,
|
|
119
129
|
"aria-placeholder": placeholder || void 0,
|
|
120
130
|
"aria-disabled": disabled || void 0,
|
|
121
131
|
"aria-required": required || void 0,
|
|
122
|
-
ref:
|
|
132
|
+
ref: mergedRefs,
|
|
123
133
|
contentEditable: !disabled,
|
|
124
134
|
suppressContentEditableWarning: true,
|
|
125
135
|
...additionalProps,
|
|
126
136
|
...controlProps
|
|
127
|
-
})
|
|
137
|
+
})]
|
|
128
138
|
});
|
|
129
139
|
}
|
|
130
140
|
var ContentEditableControl = forwardRef(UnforwardedContentEditableControl);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/content-editable-control/index.tsx", "../../../style-runtime/src/index.ts", "../../src/content-editable-control/style.module.scss"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport { useBaseControlProps } from '../base-control/hooks';\nimport styles from './style.module.scss';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnforwardedContentEditableControl({\n label,\n id,\n className,\n help,\n hideLabelFromVision,\n disabled,\n required,\n placeholder,\n ...additionalProps\n}, forwardedRef) {\n const {\n baseControlProps,\n controlProps\n } = useBaseControlProps({\n id,\n className,\n help
|
|
5
|
-
"mappings": ";AAOA,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport { useBaseControlProps } from '../base-control/hooks';\nimport { VisuallyHidden } from '../visually-hidden';\nimport styles from './style.module.scss';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nfunction UnforwardedContentEditableControl({\n label,\n id,\n className,\n help,\n hideLabelFromVision,\n disabled,\n required,\n placeholder,\n ...additionalProps\n}, forwardedRef) {\n // The label is not passed through to `BaseControl`: it would render a\n // `<label for>` pointing at the `contentEditable` `div`, which is not a\n // labelable element, making the association invalid. The label is instead\n // rendered here without `for` and wired up via `aria-labelledby`.\n const {\n baseControlProps,\n controlProps\n } = useBaseControlProps({\n id,\n className,\n help\n });\n const labelId = `${controlProps.id}__label`;\n const editableRef = useRef(null);\n const mergedRefs = useMergeRefs([editableRef, forwardedRef]);\n return /*#__PURE__*/_jsxs(BaseControl, {\n ...baseControlProps,\n children: [hideLabelFromVision ? /*#__PURE__*/_jsx(VisuallyHidden, {\n id: labelId,\n children: label\n }) : /*#__PURE__*/_jsx(BaseControl.VisualLabel, {\n id: labelId\n // Focus the field on label click, like `<label for>` would.\n ,\n onClick: () => editableRef.current?.focus(),\n children: label\n }), /*#__PURE__*/_jsx(\"div\", {\n className: styles.editable,\n role: \"textbox\",\n \"aria-multiline\": true,\n \"aria-labelledby\": labelId,\n \"aria-placeholder\": placeholder || undefined,\n \"aria-disabled\": disabled || undefined,\n \"aria-required\": required || undefined,\n ref: mergedRefs\n // A disabled field is not `contentEditable`, which also\n // removes it from the tab order.\n ,\n contentEditable: !disabled,\n suppressContentEditableWarning: true,\n ...additionalProps,\n ...controlProps\n })]\n });\n}\n\n/**\n * A presentational `contentEditable` form control: a labeled editable element\n * rendered with the chrome (`BaseControl` + label) shared by the other form\n * controls in the package.\n *\n * Unlike the in-canvas `RichText` from `@wordpress/block-editor`, this control\n * is intended for standalone form fields (DataForms, sidebar inputs, etc.).\n * It is deliberately **presentational only** and has no `@wordpress/rich-text`\n * dependency: the editable behavior (value, formatting, keyboard shortcuts)\n * and any focus/selection tracking are owned by the consumer, which wires them\n * through the forwarded ref and native event props (see the richtext DataForm\n * control in `@wordpress/dataviews` for the canonical assembly).\n *\n * ```jsx\n * // The rich-text \"assembly\" lives in the consumer.\n * <ContentEditableControl\n * label=\"Caption\"\n * ref={ mergedRef }\n * onFocus={ onEditableFocus }\n * onBlur={ onEditableBlur }\n * />\n * ```\n */\nexport const ContentEditableControl = forwardRef(UnforwardedContentEditableControl);\nexport default ContentEditableControl;", "const STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n const globalScope = globalThis;\n if (globalScope.__wpStyleRuntime) {\n return globalScope.__wpStyleRuntime;\n }\n globalScope.__wpStyleRuntime = {\n documents: new Map(),\n styles: new Map(),\n injectedStyles: new WeakMap()\n };\n if (typeof document !== 'undefined') {\n registerDocument(document);\n }\n return globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(targetDocument, hash) {\n if (!targetDocument.head) {\n return false;\n }\n for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {\n if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle(targetDocument, hash, css) {\n if (!targetDocument.head) {\n return;\n }\n const runtime = getRuntime();\n let injectedStyles = runtime.injectedStyles.get(targetDocument);\n if (!injectedStyles) {\n injectedStyles = new Set();\n runtime.injectedStyles.set(targetDocument, injectedStyles);\n }\n if (injectedStyles.has(hash)) {\n return;\n }\n\n // Older generated CSS module output can still inject matching style tags\n // after this document's cache is created, so keep the DOM as the fallback\n // source of truth on cache misses.\n if (documentContainsStyleHash(targetDocument, hash)) {\n injectedStyles.add(hash);\n return;\n }\n const style = targetDocument.createElement('style');\n style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);\n style.appendChild(targetDocument.createTextNode(css));\n targetDocument.head.appendChild(style);\n injectedStyles.add(hash);\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument(targetDocument) {\n const runtime = getRuntime();\n runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);\n for (const [hash, css] of runtime.styles) {\n injectStyle(targetDocument, hash, css);\n }\n return () => {\n const count = runtime.documents.get(targetDocument);\n if (count === undefined) {\n return;\n }\n if (count <= 1) {\n runtime.documents.delete(targetDocument);\n return;\n }\n runtime.documents.set(targetDocument, count - 1);\n };\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle(hash, css) {\n const runtime = getRuntime();\n runtime.styles.set(hash, css);\n for (const targetDocument of runtime.documents.keys()) {\n injectStyle(targetDocument, hash, css);\n }\n}", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"87e5397cb4\", \"._0f130cee1a924516__editable{background:var(--wp-components-color-background,var(--wpds-color-background-surface-neutral-strong,#fff));border:1px solid #949494;border-radius:2px;box-shadow:0 0 0 transparent;color:var(--wp-components-color-foreground,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-family:-apple-system,system-ui,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:16px;line-height:normal;padding:6px 8px;width:100%}@media not (prefers-reduced-motion){._0f130cee1a924516__editable{transition:box-shadow .1s linear}}@media (min-width:600px){._0f130cee1a924516__editable{font-size:13px;line-height:normal}}._0f130cee1a924516__editable:focus{border-color:var(--wp-admin-theme-color);box-shadow:0 0 0 .5px var(--wp-admin-theme-color);outline:2px solid transparent}._0f130cee1a924516__editable::placeholder{color:rgba(30,30,30,.62)}._0f130cee1a924516__editable{border-color:var(--wp-components-color-gray-600,var(--wpds-color-stroke-interactive-neutral,#8d8d8d))}._0f130cee1a924516__editable[aria-placeholder]:empty:before{color:color-mix(in srgb,var(--wp-components-color-foreground,var(--wpds-color-foreground-content-neutral,#1e1e1e)),transparent 38%);content:attr(aria-placeholder)}._0f130cee1a924516__editable{min-height:40px;padding:12px}._0f130cee1a924516__editable[aria-disabled=true]{background:var(--wp-components-color-gray-100,var(--wpds-color-background-surface-neutral,#fcfcfc));border-color:var(--wp-components-color-gray-300,var(--wpds-color-stroke-surface-neutral,#dbdbdb));color:var(--wp-components-color-gray-700,var(--wpds-color-foreground-content-neutral-weak,#707070));cursor:default}\");\n}\nexport default {\"editable\":\"_0f130cee1a924516__editable\"};\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,cAAc;AAKnC,OAAO,iBAAiB;AACxB,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;;;ACf/B,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACpB,QAAM,cAAc;AACpB,MAAI,YAAY,kBAAkB;AAChC,WAAO,YAAY;AAAA,EACrB;AACA,cAAY,mBAAmB;AAAA,IAC7B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC9B;AACA,MAAI,OAAO,aAAa,aAAa;AACnC,qBAAiB,QAAQ;AAAA,EAC3B;AACA,SAAO,YAAY;AACrB;AAUA,SAAS,0BAA0B,gBAAgB,MAAM;AACvD,MAAI,CAAC,eAAe,MAAM;AACxB,WAAO;AAAA,EACT;AACA,aAAW,SAAS,eAAe,KAAK,iBAAiB,SAAS,oBAAoB,GAAG,GAAG;AAC1F,QAAI,MAAM,aAAa,oBAAoB,MAAM,MAAM;AACrD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAUA,SAAS,YAAY,gBAAgB,MAAM,KAAK;AAC9C,MAAI,CAAC,eAAe,MAAM;AACxB;AAAA,EACF;AACA,QAAM,UAAU,WAAW;AAC3B,MAAI,iBAAiB,QAAQ,eAAe,IAAI,cAAc;AAC9D,MAAI,CAAC,gBAAgB;AACnB,qBAAiB,oBAAI,IAAI;AACzB,YAAQ,eAAe,IAAI,gBAAgB,cAAc;AAAA,EAC3D;AACA,MAAI,eAAe,IAAI,IAAI,GAAG;AAC5B;AAAA,EACF;AAKA,MAAI,0BAA0B,gBAAgB,IAAI,GAAG;AACnD,m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,oBAAoB;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,UAAU,GAAG,aAAa,EAAE;AAClC,QAAM,cAAc,OAAO,IAAI;AAC/B,QAAM,aAAa,aAAa,CAAC,aAAa,YAAY,CAAC;AAC3D,SAAoB,sBAAM,aAAa;AAAA,IACrC,GAAG;AAAA,IACH,UAAU,CAAC,sBAAmC,qBAAK,gBAAgB;AAAA,MACjE,IAAI;AAAA,MACJ,UAAU;AAAA,IACZ,CAAC,IAAiB,qBAAK,YAAY,aAAa;AAAA,MAC9C,IAAI;AAAA,MAGJ,SAAS,MAAM,YAAY,SAAS,MAAM;AAAA,MAC1C,UAAU;AAAA,IACZ,CAAC,GAAgB,qBAAK,OAAO;AAAA,MAC3B,WAAW,qBAAO;AAAA,MAClB,MAAM;AAAA,MACN,kBAAkB;AAAA,MAClB,mBAAmB;AAAA,MACnB,oBAAoB,eAAe;AAAA,MACnC,iBAAiB,YAAY;AAAA,MAC7B,iBAAiB,YAAY;AAAA,MAC7B,KAAK;AAAA,MAIL,iBAAiB,CAAC;AAAA,MAClB,gCAAgC;AAAA,MAChC,GAAG;AAAA,MACH,GAAG;AAAA,IACL,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AAyBO,IAAM,yBAAyB,WAAW,iCAAiC;AAClF,IAAO,mCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -36,7 +36,6 @@ function CustomSelectControl(props) {
|
|
|
36
36
|
const {
|
|
37
37
|
// Prevent passing legacy props to internal component.
|
|
38
38
|
__next40pxDefaultSize: _next40pxDefaultSize,
|
|
39
|
-
__shouldNotWarnDeprecated36pxSize: _shouldNotWarnDeprecated36pxSize,
|
|
40
39
|
describedBy,
|
|
41
40
|
options,
|
|
42
41
|
onChange,
|
|
@@ -121,7 +120,7 @@ function CustomSelectControl(props) {
|
|
|
121
120
|
children: [/* @__PURE__ */ _jsx(CustomSelect, {
|
|
122
121
|
"aria-describedby": descriptionId,
|
|
123
122
|
renderSelectedValue,
|
|
124
|
-
size
|
|
123
|
+
size,
|
|
125
124
|
store,
|
|
126
125
|
className: clsx(
|
|
127
126
|
// Keeping the classname for legacy reasons
|
|
@@ -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 { 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}\n\n/**\n * `CustomSelectControl` is a dropdown for selecting a single option from a\n * list, with support for custom styling. Use it instead of the `SelectControl`\n * when options need richer markup (e.g. per-option styles or hints).\n */\nfunction CustomSelectControl(props) {\n const {\n // Prevent passing legacy props to internal component.\n __next40pxDefaultSize: _next40pxDefaultSize,\n
|
|
5
|
-
"mappings": ";AAGA,YAAY,aAAa;AACzB,OAAO,UAAU;AAKjB,SAAS,qBAAqB;AAC9B,SAAS,IAAI,eAAe;AAK5B,OAAO,kBAAkB;AACzB,OAAO,sBAAsB;AAC7B,YAAY,YAAY;AACxB,SAAS,sBAAsB;AAC/B,SAAS,OAAO,MAAM,QAAQ,OAAO,YAAY,iBAAiB;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;AACf,WAAO;AAAA,EACT;AAGA,SAAO,QAAQ,GAAG,wBAAwB,GAAG,WAAW;AAC1D;AAOA,SAAS,oBAAoB,OAAO;AAClC,QAAM;AAAA;AAAA,IAEJ,uBAAuB;AAAA,IACvB
|
|
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 { 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}\n\n/**\n * `CustomSelectControl` is a dropdown for selecting a single option from a\n * list, with support for custom styling. Use it instead of the `SelectControl`\n * when options need richer markup (e.g. per-option styles or hints).\n */\nfunction CustomSelectControl(props) {\n const {\n // Prevent passing legacy props to internal component.\n __next40pxDefaultSize: _next40pxDefaultSize,\n describedBy,\n options,\n onChange,\n size = 'default',\n value,\n className: classNameProp,\n showSelectedHint = false,\n ...restProps\n } = useDeprecatedProps(props);\n const descriptionId = useInstanceId(CustomSelectControl, 'custom-select-control__description');\n\n // Forward props + store from v2 implementation\n const store = Ariakit.useSelectStore({\n async setValue(nextValue) {\n const nextOption = options.find(item => item.key === nextValue);\n if (!onChange || !nextOption) {\n return;\n }\n\n // Executes the logic in a microtask after the popup is closed.\n // This is simply to ensure the isOpen state matches the one from the\n // previous legacy implementation.\n await Promise.resolve();\n const state = store.getState();\n const changeObject = {\n highlightedIndex: state.renderedItems.findIndex(item => item.value === nextValue),\n inputValue: '',\n isOpen: state.open,\n selectedItem: nextOption,\n type: ''\n };\n onChange(changeObject);\n },\n value: value?.key,\n // Setting the first option as a default value when no value is provided\n // is already done natively by the underlying Ariakit component,\n // but doing this explicitly avoids the `onChange` callback from firing\n // on initial render, thus making this implementation closer to the v1.\n defaultValue: options[0]?.key\n });\n const children = options.map(applyOptionDeprecations).map(({\n name,\n key,\n hint,\n style,\n className\n }) => {\n const withHint = /*#__PURE__*/_jsxs(Styled.WithHintItemWrapper, {\n children: [/*#__PURE__*/_jsx(\"span\", {\n children: name\n }), /*#__PURE__*/_jsx(Styled.WithHintItemHint, {\n // Keeping the classname for legacy reasons\n className: \"components-custom-select-control__item-hint\",\n children: hint\n })]\n });\n return /*#__PURE__*/_jsx(CustomSelectItem, {\n value: key,\n children: hint ? withHint : name,\n style: style,\n className: clsx(className,\n // Keeping the classnames for legacy reasons\n 'components-custom-select-control__item', {\n 'has-hint': hint\n })\n }, key);\n });\n const currentValue = Ariakit.useStoreState(store, 'value');\n const selectedOption = options?.map(applyOptionDeprecations)?.find(({\n key\n }) => currentValue === key) ?? options[0];\n const renderSelectedValue = () => {\n if (!showSelectedHint || !selectedOption.hint) {\n return selectedOption?.name;\n }\n return /*#__PURE__*/_jsxs(Styled.SelectedExperimentalHintWrapper, {\n children: [selectedOption?.name, /*#__PURE__*/_jsx(Styled.SelectedExperimentalHintItem, {\n // Keeping the classname for legacy reasons\n className: \"components-custom-select-control__hint\",\n children: selectedOption?.hint\n })]\n });\n };\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(CustomSelect, {\n \"aria-describedby\": descriptionId,\n renderSelectedValue: renderSelectedValue,\n size: size,\n store: store,\n className: clsx(\n // Keeping the classname for legacy reasons\n 'components-custom-select-control', classNameProp),\n isLegacy: true,\n ...restProps,\n children: children\n }), /*#__PURE__*/_jsx(VisuallyHidden, {\n children: /*#__PURE__*/_jsx(\"span\", {\n id: descriptionId,\n children: getDescribedBy(selectedOption?.name, describedBy)\n })\n })]\n });\n}\nexport default CustomSelectControl;"],
|
|
5
|
+
"mappings": ";AAGA,YAAY,aAAa;AACzB,OAAO,UAAU;AAKjB,SAAS,qBAAqB;AAC9B,SAAS,IAAI,eAAe;AAK5B,OAAO,kBAAkB;AACzB,OAAO,sBAAsB;AAC7B,YAAY,YAAY;AACxB,SAAS,sBAAsB;AAC/B,SAAS,OAAO,MAAM,QAAQ,OAAO,YAAY,iBAAiB;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,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
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,91 @@
|
|
|
1
1
|
// packages/components/src/disabled/index.tsx
|
|
2
|
-
import
|
|
3
|
-
import { useCx } from "../utils/index.mjs";
|
|
2
|
+
import clsx from "clsx";
|
|
4
3
|
import Context from "./context.mjs";
|
|
4
|
+
|
|
5
|
+
// packages/style-runtime/src/index.ts
|
|
6
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
7
|
+
function getRuntime() {
|
|
8
|
+
const globalScope = globalThis;
|
|
9
|
+
if (globalScope.__wpStyleRuntime) {
|
|
10
|
+
return globalScope.__wpStyleRuntime;
|
|
11
|
+
}
|
|
12
|
+
globalScope.__wpStyleRuntime = {
|
|
13
|
+
documents: /* @__PURE__ */ new Map(),
|
|
14
|
+
styles: /* @__PURE__ */ new Map(),
|
|
15
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
16
|
+
};
|
|
17
|
+
if (typeof document !== "undefined") {
|
|
18
|
+
registerDocument(document);
|
|
19
|
+
}
|
|
20
|
+
return globalScope.__wpStyleRuntime;
|
|
21
|
+
}
|
|
22
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
23
|
+
if (!targetDocument.head) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {
|
|
27
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
function injectStyle(targetDocument, hash, css) {
|
|
34
|
+
if (!targetDocument.head) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const runtime = getRuntime();
|
|
38
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
39
|
+
if (!injectedStyles) {
|
|
40
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
41
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
42
|
+
}
|
|
43
|
+
if (injectedStyles.has(hash)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
47
|
+
injectedStyles.add(hash);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const style = targetDocument.createElement("style");
|
|
51
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
52
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
53
|
+
targetDocument.head.appendChild(style);
|
|
54
|
+
injectedStyles.add(hash);
|
|
55
|
+
}
|
|
56
|
+
function registerDocument(targetDocument) {
|
|
57
|
+
const runtime = getRuntime();
|
|
58
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
59
|
+
for (const [hash, css] of runtime.styles) {
|
|
60
|
+
injectStyle(targetDocument, hash, css);
|
|
61
|
+
}
|
|
62
|
+
return () => {
|
|
63
|
+
const count = runtime.documents.get(targetDocument);
|
|
64
|
+
if (count === void 0) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (count <= 1) {
|
|
68
|
+
runtime.documents.delete(targetDocument);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function registerStyle(hash, css) {
|
|
75
|
+
const runtime = getRuntime();
|
|
76
|
+
runtime.styles.set(hash, css);
|
|
77
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
78
|
+
injectStyle(targetDocument, hash, css);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// packages/components/src/disabled/style.module.scss
|
|
83
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
84
|
+
registerStyle("bacc423d2b", '._556ae8be2a7ddc8e__disabled{pointer-events:none;position:relative}._556ae8be2a7ddc8e__disabled:after{content:"";inset:0;position:absolute}._556ae8be2a7ddc8e__disabled *{pointer-events:none}');
|
|
85
|
+
}
|
|
86
|
+
var style_module_default = { "disabled": "_556ae8be2a7ddc8e__disabled" };
|
|
87
|
+
|
|
88
|
+
// packages/components/src/disabled/index.tsx
|
|
5
89
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
90
|
var {
|
|
7
91
|
Consumer,
|
|
@@ -13,13 +97,12 @@ function Disabled({
|
|
|
13
97
|
isDisabled = true,
|
|
14
98
|
...props
|
|
15
99
|
}) {
|
|
16
|
-
const cx = useCx();
|
|
17
100
|
return /* @__PURE__ */ _jsx(Provider, {
|
|
18
101
|
value: isDisabled,
|
|
19
102
|
children: /* @__PURE__ */ _jsx("div", {
|
|
20
103
|
// @ts-ignore Reason: inert is a recent HTML attribute
|
|
21
104
|
inert: isDisabled ? "true" : void 0,
|
|
22
|
-
className: isDisabled ?
|
|
105
|
+
className: isDisabled ? clsx(style_module_default.disabled, className, "components-disabled") : void 0,
|
|
23
106
|
...props,
|
|
24
107
|
children
|
|
25
108
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/disabled/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";AAAA,SAAS,sBAAsB;AAC/
|
|
3
|
+
"sources": ["../../src/disabled/index.tsx", "../../../style-runtime/src/index.ts", "../../src/disabled/style.module.scss"],
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport Context from './context';\nimport styles from './style.module.scss';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst {\n Consumer,\n Provider\n} = Context;\n\n/**\n * `Disabled` is a component which disables descendant tabbable elements and\n * prevents pointer interaction.\n *\n * _Note: this component may not behave as expected in browsers that don't\n * support the `inert` HTML attribute. We recommend adding the official WICG\n * polyfill when using this component in your project._\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n *\n * ```jsx\n * import { Button, Disabled, TextControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDisabled = () => {\n * \tconst [ isDisabled, setIsDisabled ] = useState( true );\n *\n *\tlet input = (\n *\t\t<TextControl\n *\t\t\tlabel=\"Input\"\n *\t\t\tonChange={ () => {} }\n *\t\t/>\n *\t);\n * \tif ( isDisabled ) {\n * \t\tinput = <Disabled>{ input }</Disabled>;\n * \t}\n *\n * \tconst toggleDisabled = () => {\n * \t\tsetIsDisabled( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<div>\n * \t\t\t{ input }\n * \t\t\t<Button variant=\"primary\" onClick={ toggleDisabled }>\n * \t\t\t\tToggle Disabled\n * \t\t\t</Button>\n * \t\t</div>\n * \t);\n * };\n * ```\n */\nfunction Disabled({\n className,\n children,\n isDisabled = true,\n ...props\n}) {\n return /*#__PURE__*/_jsx(Provider, {\n value: isDisabled,\n children: /*#__PURE__*/_jsx(\"div\", {\n // @ts-ignore Reason: inert is a recent HTML attribute\n inert: isDisabled ? 'true' : undefined,\n className: isDisabled ? clsx(styles.disabled, className, 'components-disabled') : undefined,\n ...props,\n children: children\n })\n });\n}\nDisabled.Context = Context;\nDisabled.Consumer = Consumer;\nexport default Disabled;", "const STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n const globalScope = globalThis;\n if (globalScope.__wpStyleRuntime) {\n return globalScope.__wpStyleRuntime;\n }\n globalScope.__wpStyleRuntime = {\n documents: new Map(),\n styles: new Map(),\n injectedStyles: new WeakMap()\n };\n if (typeof document !== 'undefined') {\n registerDocument(document);\n }\n return globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(targetDocument, hash) {\n if (!targetDocument.head) {\n return false;\n }\n for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {\n if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle(targetDocument, hash, css) {\n if (!targetDocument.head) {\n return;\n }\n const runtime = getRuntime();\n let injectedStyles = runtime.injectedStyles.get(targetDocument);\n if (!injectedStyles) {\n injectedStyles = new Set();\n runtime.injectedStyles.set(targetDocument, injectedStyles);\n }\n if (injectedStyles.has(hash)) {\n return;\n }\n\n // Older generated CSS module output can still inject matching style tags\n // after this document's cache is created, so keep the DOM as the fallback\n // source of truth on cache misses.\n if (documentContainsStyleHash(targetDocument, hash)) {\n injectedStyles.add(hash);\n return;\n }\n const style = targetDocument.createElement('style');\n style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);\n style.appendChild(targetDocument.createTextNode(css));\n targetDocument.head.appendChild(style);\n injectedStyles.add(hash);\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument(targetDocument) {\n const runtime = getRuntime();\n runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);\n for (const [hash, css] of runtime.styles) {\n injectStyle(targetDocument, hash, css);\n }\n return () => {\n const count = runtime.documents.get(targetDocument);\n if (count === undefined) {\n return;\n }\n if (count <= 1) {\n runtime.documents.delete(targetDocument);\n return;\n }\n runtime.documents.set(targetDocument, count - 1);\n };\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle(hash, css) {\n const runtime = getRuntime();\n runtime.styles.set(hash, css);\n for (const targetDocument of runtime.documents.keys()) {\n injectStyle(targetDocument, hash, css);\n }\n}", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"bacc423d2b\", \"._556ae8be2a7ddc8e__disabled{pointer-events:none;position:relative}._556ae8be2a7ddc8e__disabled:after{content:\\\"\\\";inset:0;position:absolute}._556ae8be2a7ddc8e__disabled *{pointer-events:none}\");\n}\nexport default {\"disabled\":\"_556ae8be2a7ddc8e__disabled\"};\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,UAAU;AACjB,OAAO,aAAa;;;ACDpB,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACpB,QAAM,cAAc;AACpB,MAAI,YAAY,kBAAkB;AAChC,WAAO,YAAY;AAAA,EACrB;AACA,cAAY,mBAAmB;AAAA,IAC7B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC9B;AACA,MAAI,OAAO,aAAa,aAAa;AACnC,qBAAiB,QAAQ;AAAA,EAC3B;AACA,SAAO,YAAY;AACrB;AAUA,SAAS,0BAA0B,gBAAgB,MAAM;AACvD,MAAI,CAAC,eAAe,MAAM;AACxB,WAAO;AAAA,EACT;AACA,aAAW,SAAS,eAAe,KAAK,iBAAiB,SAAS,oBAAoB,GAAG,GAAG;AAC1F,QAAI,MAAM,aAAa,oBAAoB,MAAM,MAAM;AACrD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;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IA,IAAI,OAAO,YAAY,eAAe,QAAQ,IAAI,aAAa,QAAQ;AACtE,gBAAc,cAAc,gMAAkM;AAC/N;AACA,IAAO,uBAAQ,EAAC,YAAW,8BAA6B;;;AFDxD,SAAS,OAAO,YAAY;AAC5B,IAAM;AAAA,EACJ;AAAA,EACA;AACF,IAAI;AA4CJ,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,GAAG;AACL,GAAG;AACD,SAAoB,qBAAK,UAAU;AAAA,IACjC,OAAO;AAAA,IACP,UAAuB,qBAAK,OAAO;AAAA;AAAA,MAEjC,OAAO,aAAa,SAAS;AAAA,MAC7B,WAAW,aAAa,KAAK,qBAAO,UAAU,WAAW,qBAAqB,IAAI;AAAA,MAClF,GAAG;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;AACA,SAAS,UAAU;AACnB,SAAS,WAAW;AACpB,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,9 +8,93 @@ import { isShallowEqual } from "@wordpress/is-shallow-equal";
|
|
|
8
8
|
import deprecated from "@wordpress/deprecated";
|
|
9
9
|
import Token from "./token.mjs";
|
|
10
10
|
import TokenInput from "./token-input.mjs";
|
|
11
|
-
import { TokensAndInputWrapperFlex } from "./styles.mjs";
|
|
12
11
|
import SuggestionsList from "./suggestions-list.mjs";
|
|
13
|
-
import { FlexItem } from "../flex/index.mjs";
|
|
12
|
+
import { Flex, FlexItem } from "../flex/index.mjs";
|
|
13
|
+
|
|
14
|
+
// packages/style-runtime/src/index.ts
|
|
15
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
16
|
+
function getRuntime() {
|
|
17
|
+
const globalScope = globalThis;
|
|
18
|
+
if (globalScope.__wpStyleRuntime) {
|
|
19
|
+
return globalScope.__wpStyleRuntime;
|
|
20
|
+
}
|
|
21
|
+
globalScope.__wpStyleRuntime = {
|
|
22
|
+
documents: /* @__PURE__ */ new Map(),
|
|
23
|
+
styles: /* @__PURE__ */ new Map(),
|
|
24
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
25
|
+
};
|
|
26
|
+
if (typeof document !== "undefined") {
|
|
27
|
+
registerDocument(document);
|
|
28
|
+
}
|
|
29
|
+
return globalScope.__wpStyleRuntime;
|
|
30
|
+
}
|
|
31
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
32
|
+
if (!targetDocument.head) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {
|
|
36
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
function injectStyle(targetDocument, hash, css) {
|
|
43
|
+
if (!targetDocument.head) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const runtime = getRuntime();
|
|
47
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
48
|
+
if (!injectedStyles) {
|
|
49
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
50
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
51
|
+
}
|
|
52
|
+
if (injectedStyles.has(hash)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
56
|
+
injectedStyles.add(hash);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const style = targetDocument.createElement("style");
|
|
60
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
61
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
62
|
+
targetDocument.head.appendChild(style);
|
|
63
|
+
injectedStyles.add(hash);
|
|
64
|
+
}
|
|
65
|
+
function registerDocument(targetDocument) {
|
|
66
|
+
const runtime = getRuntime();
|
|
67
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
68
|
+
for (const [hash, css] of runtime.styles) {
|
|
69
|
+
injectStyle(targetDocument, hash, css);
|
|
70
|
+
}
|
|
71
|
+
return () => {
|
|
72
|
+
const count = runtime.documents.get(targetDocument);
|
|
73
|
+
if (count === void 0) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (count <= 1) {
|
|
77
|
+
runtime.documents.delete(targetDocument);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function registerStyle(hash, css) {
|
|
84
|
+
const runtime = getRuntime();
|
|
85
|
+
runtime.styles.set(hash, css);
|
|
86
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
87
|
+
injectStyle(targetDocument, hash, css);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// packages/components/src/form-token-field/style.module.scss
|
|
92
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
93
|
+
registerStyle("f9ae5dc19e", ".df878b202c3b3cb7__tokens-and-input{box-sizing:border-box;padding:7px}.df878b202c3b3cb7__tokens-and-input *,.df878b202c3b3cb7__tokens-and-input :after,.df878b202c3b3cb7__tokens-and-input :before{box-sizing:inherit}");
|
|
94
|
+
}
|
|
95
|
+
var style_module_default = { "tokens-and-input": "df878b202c3b3cb7__tokens-and-input" };
|
|
96
|
+
|
|
97
|
+
// packages/components/src/form-token-field/index.tsx
|
|
14
98
|
import { StyledHelp, StyledLabel } from "../base-control/styles/base-control-styles.mjs";
|
|
15
99
|
import { withIgnoreIMEEvents } from "../utils/with-ignore-ime-events.mjs";
|
|
16
100
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -535,7 +619,8 @@ function FormTokenField(props) {
|
|
|
535
619
|
tabIndex: -1,
|
|
536
620
|
onMouseDown: onContainerTouched,
|
|
537
621
|
onTouchStart: onContainerTouched,
|
|
538
|
-
children: [/* @__PURE__ */ _jsx(
|
|
622
|
+
children: [/* @__PURE__ */ _jsx(Flex, {
|
|
623
|
+
className: style_module_default["tokens-and-input"],
|
|
539
624
|
justify: "flex-start",
|
|
540
625
|
align: "center",
|
|
541
626
|
gap: 1,
|