@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/tools-panel/tools-panel/hook.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useMemo, useReducer, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\nconst DEFAULT_COLUMNS = 2;\nfunction emptyMenuItems() {\n return {\n default: {},\n optional: {}\n };\n}\nfunction emptyState() {\n return {\n panelItems: [],\n menuItemOrder: [],\n menuItems: emptyMenuItems()\n };\n}\nconst generateMenuItems = ({\n panelItems,\n shouldReset,\n currentMenuItems,\n menuItemOrder\n}) => {\n const newMenuItems = emptyMenuItems();\n const menuItems = emptyMenuItems();\n panelItems.forEach(({\n hasValue,\n isShownByDefault,\n label\n }) => {\n const group = isShownByDefault ? 'default' : 'optional';\n\n // If a menu item for this label has already been flagged as customized\n // (for default controls), or toggled on (for optional controls), do not\n // overwrite its value as those controls would lose that state.\n const existingItemValue = currentMenuItems?.[group]?.[label];\n const value = existingItemValue ? existingItemValue : hasValue();\n newMenuItems[group][label] = shouldReset ? false : value;\n });\n\n // Loop the known, previously registered items first to maintain menu order.\n menuItemOrder.forEach(key => {\n if (newMenuItems.default.hasOwnProperty(key)) {\n menuItems.default[key] = newMenuItems.default[key];\n }\n if (newMenuItems.optional.hasOwnProperty(key)) {\n menuItems.optional[key] = newMenuItems.optional[key];\n }\n });\n\n // Loop newMenuItems object adding any that aren't in the known items order.\n Object.keys(newMenuItems.default).forEach(key => {\n if (!menuItems.default.hasOwnProperty(key)) {\n menuItems.default[key] = newMenuItems.default[key];\n }\n });\n Object.keys(newMenuItems.optional).forEach(key => {\n if (!menuItems.optional.hasOwnProperty(key)) {\n menuItems.optional[key] = newMenuItems.optional[key];\n }\n });\n return menuItems;\n};\nfunction panelItemsReducer(panelItems, action) {\n switch (action.type) {\n case 'REGISTER_PANEL':\n {\n const newItems = [...panelItems];\n // If an item with this label has already been registered, remove it\n // first. This can happen when an item is moved between the default\n // and optional groups.\n const existingIndex = newItems.findIndex(oldItem => oldItem.label === action.item.label);\n if (existingIndex !== -1) {\n newItems.splice(existingIndex, 1);\n }\n newItems.push(action.item);\n return newItems;\n }\n case 'UNREGISTER_PANEL':\n {\n const index = panelItems.findIndex(item => item.label === action.label);\n if (index !== -1) {\n const newItems = [...panelItems];\n newItems.splice(index, 1);\n return newItems;\n }\n return panelItems;\n }\n default:\n return panelItems;\n }\n}\nfunction menuItemOrderReducer(menuItemOrder, action) {\n switch (action.type) {\n case 'REGISTER_PANEL':\n {\n // Track the initial order of item registration. This is used for\n // maintaining menu item order later.\n if (menuItemOrder.includes(action.item.label)) {\n return menuItemOrder;\n }\n return [...menuItemOrder, action.item.label];\n }\n default:\n return menuItemOrder;\n }\n}\nfunction menuItemsReducer(state, action) {\n switch (action.type) {\n case 'REGISTER_PANEL':\n case 'UNREGISTER_PANEL':\n // generate new menu items from original `menuItems` and updated `panelItems` and `menuItemOrder`\n return generateMenuItems({\n currentMenuItems: state.menuItems,\n panelItems: state.panelItems,\n menuItemOrder: state.menuItemOrder,\n shouldReset: false\n });\n case 'RESET_ALL':\n return generateMenuItems({\n panelItems: state.panelItems,\n menuItemOrder: state.menuItemOrder,\n shouldReset: true\n });\n case 'UPDATE_VALUE':\n {\n const oldValue = state.menuItems[action.group][action.label];\n if (action.value === oldValue) {\n return state.menuItems;\n }\n return {\n ...state.menuItems,\n [action.group]: {\n ...state.menuItems[action.group],\n [action.label]: action.value\n }\n };\n }\n case 'TOGGLE_VALUE':\n {\n const currentItem = state.panelItems.find(item => item.label === action.label);\n if (!currentItem) {\n return state.menuItems;\n }\n const menuGroup = currentItem.isShownByDefault ? 'default' : 'optional';\n const newMenuItems = {\n ...state.menuItems,\n [menuGroup]: {\n ...state.menuItems[menuGroup],\n [action.label]: !state.menuItems[menuGroup][action.label]\n }\n };\n return newMenuItems;\n }\n default:\n return state.menuItems;\n }\n}\nfunction panelReducer(state, action) {\n const panelItems = panelItemsReducer(state.panelItems, action);\n const menuItemOrder = menuItemOrderReducer(state.menuItemOrder, action);\n // `menuItemsReducer` is a bit unusual because it generates new state from original `menuItems`\n // and the updated `panelItems` and `menuItemOrder`.\n const menuItems = menuItemsReducer({\n panelItems,\n menuItemOrder,\n menuItems: state.menuItems\n }, action);\n return {\n panelItems,\n menuItemOrder,\n menuItems\n };\n}\nfunction resetAllFiltersReducer(filters, action) {\n switch (action.type) {\n case 'REGISTER':\n return [...filters, action.filter];\n case 'UNREGISTER':\n return filters.filter(f => f !== action.filter);\n default:\n return filters;\n }\n}\nconst isMenuItemTypeEmpty = obj => Object.keys(obj).length === 0;\nexport function useToolsPanel(props) {\n const {\n className,\n headingLevel = 2,\n resetAll,\n panelId,\n hasInnerWrapper = false,\n shouldRenderPlaceholderItems = false,\n __experimentalFirstVisibleItemClass,\n __experimentalLastVisibleItemClass,\n ...otherProps\n } = useContextSystem(props, 'ToolsPanel');\n const isResettingRef = useRef(false);\n const wasResetting = isResettingRef.current;\n\n // `isResettingRef` is cleared via this hook to effectively batch together\n // the resetAll task. Without this, the flag is cleared after the first\n // control updates and forces a rerender with subsequent controls then\n // believing they need to reset, unfortunately using stale data.\n useEffect(() => {\n if (wasResetting) {\n isResettingRef.current = false;\n }\n }, [wasResetting]);\n\n // Allow panel items to register themselves.\n const [{\n panelItems,\n menuItems\n }, panelDispatch] = useReducer(panelReducer, undefined, emptyState);\n const [resetAllFilters, dispatchResetAllFilters] = useReducer(resetAllFiltersReducer, []);\n const registerPanelItem = useCallback(item => {\n // Add item to panel items.\n panelDispatch({\n type: 'REGISTER_PANEL',\n item\n });\n }, []);\n\n // Panels need to deregister on unmount to avoid orphans in menu state.\n // This is an issue when panel items are being injected via SlotFills.\n const deregisterPanelItem = useCallback(label => {\n // When switching selections between components injecting matching\n // controls, e.g. both panels have a \"padding\" control, the\n // deregistration of the first panel doesn't occur until after the\n // registration of the next.\n panelDispatch({\n type: 'UNREGISTER_PANEL',\n label\n });\n }, []);\n const registerResetAllFilter = useCallback(filter => {\n dispatchResetAllFilters({\n type: 'REGISTER',\n filter\n });\n }, []);\n const deregisterResetAllFilter = useCallback(filter => {\n dispatchResetAllFilters({\n type: 'UNREGISTER',\n filter\n });\n }, []);\n\n // Updates the status of the panel’s menu items. For default items the\n // value represents whether it differs from the default and for optional\n // items whether the item is shown.\n const flagItemCustomization = useCallback((value, label, group = 'default') => {\n panelDispatch({\n type: 'UPDATE_VALUE',\n group,\n label,\n value\n });\n }, []);\n\n // Whether all optional menu items are hidden or not must be tracked\n // in order to later determine if the panel display is empty and handle\n // conditional display of a plus icon to indicate the presence of further\n // menu items.\n const areAllOptionalControlsHidden = useMemo(() => {\n return isMenuItemTypeEmpty(menuItems.default) && !isMenuItemTypeEmpty(menuItems.optional) && Object.values(menuItems.optional).every(isSelected => !isSelected);\n }, [menuItems]);\n const cx = useCx();\n const classes = useMemo(() => {\n return cx(styles.getToolsPanelStyles({\n columns: DEFAULT_COLUMNS,\n hasInnerWrapper,\n areAllOptionalControlsHidden\n }), className);\n }, [areAllOptionalControlsHidden, className, cx, hasInnerWrapper]);\n\n // Toggle the checked state of a menu item which is then used to determine\n // display of the item within the panel.\n const toggleItem = useCallback(label => {\n panelDispatch({\n type: 'TOGGLE_VALUE',\n label\n });\n }, []);\n\n // Resets display of children and executes resetAll callback if available.\n const resetAllItems = useCallback(() => {\n if (typeof resetAll === 'function') {\n isResettingRef.current = true;\n resetAll(resetAllFilters);\n }\n\n // Turn off display of all non-default items.\n panelDispatch({\n type: 'RESET_ALL'\n });\n }, [resetAllFilters, resetAll]);\n\n // Assist ItemGroup styling when there are potentially hidden placeholder\n // items by identifying first & last items that are toggled on for display.\n const getFirstVisibleItemLabel = items => {\n const optionalItems = menuItems.optional || {};\n const firstItem = items.find(item => item.isShownByDefault || optionalItems[item.label]);\n return firstItem?.label;\n };\n const firstDisplayedItem = getFirstVisibleItemLabel(panelItems);\n const lastDisplayedItem = getFirstVisibleItemLabel([...panelItems].reverse());\n const hasMenuItems = panelItems.length > 0;\n const panelContext = useMemo(() => ({\n areAllOptionalControlsHidden,\n deregisterPanelItem,\n deregisterResetAllFilter,\n firstDisplayedItem,\n flagItemCustomization,\n hasMenuItems,\n isResetting: isResettingRef.current,\n lastDisplayedItem,\n menuItems,\n panelId,\n registerPanelItem,\n registerResetAllFilter,\n shouldRenderPlaceholderItems,\n __experimentalFirstVisibleItemClass,\n __experimentalLastVisibleItemClass\n }), [areAllOptionalControlsHidden, deregisterPanelItem, deregisterResetAllFilter, firstDisplayedItem, flagItemCustomization, lastDisplayedItem, menuItems, panelId, hasMenuItems, registerResetAllFilter, registerPanelItem, shouldRenderPlaceholderItems, __experimentalFirstVisibleItemClass, __experimentalLastVisibleItemClass]);\n return {\n ...otherProps,\n headingLevel,\n panelContext,\n resetAllItems,\n toggleItem,\n className: classes\n };\n}"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,aAAa,WAAW,SAAS,YAAY,cAAc;
|
|
3
|
+
"sources": ["../../../src/tools-panel/tools-panel/hook.ts", "../../../../style-runtime/src/index.ts", "../../../src/tools-panel/style.module.scss"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useMemo, useReducer, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport styles from '../style.module.scss';\nimport { useContextSystem } from '../../context';\nfunction emptyMenuItems() {\n return {\n default: {},\n optional: {}\n };\n}\nfunction emptyState() {\n return {\n panelItems: [],\n menuItemOrder: [],\n menuItems: emptyMenuItems()\n };\n}\nconst generateMenuItems = ({\n panelItems,\n shouldReset,\n currentMenuItems,\n menuItemOrder\n}) => {\n const newMenuItems = emptyMenuItems();\n const menuItems = emptyMenuItems();\n panelItems.forEach(({\n hasValue,\n isShownByDefault,\n label\n }) => {\n const group = isShownByDefault ? 'default' : 'optional';\n\n // If a menu item for this label has already been flagged as customized\n // (for default controls), or toggled on (for optional controls), do not\n // overwrite its value as those controls would lose that state.\n const existingItemValue = currentMenuItems?.[group]?.[label];\n const value = existingItemValue ? existingItemValue : hasValue();\n newMenuItems[group][label] = shouldReset ? false : value;\n });\n\n // Loop the known, previously registered items first to maintain menu order.\n menuItemOrder.forEach(key => {\n if (newMenuItems.default.hasOwnProperty(key)) {\n menuItems.default[key] = newMenuItems.default[key];\n }\n if (newMenuItems.optional.hasOwnProperty(key)) {\n menuItems.optional[key] = newMenuItems.optional[key];\n }\n });\n\n // Loop newMenuItems object adding any that aren't in the known items order.\n Object.keys(newMenuItems.default).forEach(key => {\n if (!menuItems.default.hasOwnProperty(key)) {\n menuItems.default[key] = newMenuItems.default[key];\n }\n });\n Object.keys(newMenuItems.optional).forEach(key => {\n if (!menuItems.optional.hasOwnProperty(key)) {\n menuItems.optional[key] = newMenuItems.optional[key];\n }\n });\n return menuItems;\n};\nfunction panelItemsReducer(panelItems, action) {\n switch (action.type) {\n case 'REGISTER_PANEL':\n {\n const newItems = [...panelItems];\n // If an item with this label has already been registered, remove it\n // first. This can happen when an item is moved between the default\n // and optional groups.\n const existingIndex = newItems.findIndex(oldItem => oldItem.label === action.item.label);\n if (existingIndex !== -1) {\n newItems.splice(existingIndex, 1);\n }\n newItems.push(action.item);\n return newItems;\n }\n case 'UNREGISTER_PANEL':\n {\n const index = panelItems.findIndex(item => item.label === action.label);\n if (index !== -1) {\n const newItems = [...panelItems];\n newItems.splice(index, 1);\n return newItems;\n }\n return panelItems;\n }\n default:\n return panelItems;\n }\n}\nfunction menuItemOrderReducer(menuItemOrder, action) {\n switch (action.type) {\n case 'REGISTER_PANEL':\n {\n // Track the initial order of item registration. This is used for\n // maintaining menu item order later.\n if (menuItemOrder.includes(action.item.label)) {\n return menuItemOrder;\n }\n return [...menuItemOrder, action.item.label];\n }\n default:\n return menuItemOrder;\n }\n}\nfunction menuItemsReducer(state, action) {\n switch (action.type) {\n case 'REGISTER_PANEL':\n case 'UNREGISTER_PANEL':\n // generate new menu items from original `menuItems` and updated `panelItems` and `menuItemOrder`\n return generateMenuItems({\n currentMenuItems: state.menuItems,\n panelItems: state.panelItems,\n menuItemOrder: state.menuItemOrder,\n shouldReset: false\n });\n case 'RESET_ALL':\n return generateMenuItems({\n panelItems: state.panelItems,\n menuItemOrder: state.menuItemOrder,\n shouldReset: true\n });\n case 'UPDATE_VALUE':\n {\n const oldValue = state.menuItems[action.group][action.label];\n if (action.value === oldValue) {\n return state.menuItems;\n }\n return {\n ...state.menuItems,\n [action.group]: {\n ...state.menuItems[action.group],\n [action.label]: action.value\n }\n };\n }\n case 'TOGGLE_VALUE':\n {\n const currentItem = state.panelItems.find(item => item.label === action.label);\n if (!currentItem) {\n return state.menuItems;\n }\n const menuGroup = currentItem.isShownByDefault ? 'default' : 'optional';\n const newMenuItems = {\n ...state.menuItems,\n [menuGroup]: {\n ...state.menuItems[menuGroup],\n [action.label]: !state.menuItems[menuGroup][action.label]\n }\n };\n return newMenuItems;\n }\n default:\n return state.menuItems;\n }\n}\nfunction panelReducer(state, action) {\n const panelItems = panelItemsReducer(state.panelItems, action);\n const menuItemOrder = menuItemOrderReducer(state.menuItemOrder, action);\n // `menuItemsReducer` is a bit unusual because it generates new state from original `menuItems`\n // and the updated `panelItems` and `menuItemOrder`.\n const menuItems = menuItemsReducer({\n panelItems,\n menuItemOrder,\n menuItems: state.menuItems\n }, action);\n return {\n panelItems,\n menuItemOrder,\n menuItems\n };\n}\nfunction resetAllFiltersReducer(filters, action) {\n switch (action.type) {\n case 'REGISTER':\n return [...filters, action.filter];\n case 'UNREGISTER':\n return filters.filter(f => f !== action.filter);\n default:\n return filters;\n }\n}\nconst isMenuItemTypeEmpty = obj => Object.keys(obj).length === 0;\nexport function useToolsPanel(props) {\n const {\n className,\n headingLevel = 2,\n resetAll,\n panelId,\n hasInnerWrapper = false,\n shouldRenderPlaceholderItems = false,\n __experimentalFirstVisibleItemClass,\n __experimentalLastVisibleItemClass,\n ...otherProps\n } = useContextSystem(props, 'ToolsPanel');\n const isResettingRef = useRef(false);\n const wasResetting = isResettingRef.current;\n\n // `isResettingRef` is cleared via this hook to effectively batch together\n // the resetAll task. Without this, the flag is cleared after the first\n // control updates and forces a rerender with subsequent controls then\n // believing they need to reset, unfortunately using stale data.\n useEffect(() => {\n if (wasResetting) {\n isResettingRef.current = false;\n }\n }, [wasResetting]);\n\n // Allow panel items to register themselves.\n const [{\n panelItems,\n menuItems\n }, panelDispatch] = useReducer(panelReducer, undefined, emptyState);\n const [resetAllFilters, dispatchResetAllFilters] = useReducer(resetAllFiltersReducer, []);\n const registerPanelItem = useCallback(item => {\n // Add item to panel items.\n panelDispatch({\n type: 'REGISTER_PANEL',\n item\n });\n }, []);\n\n // Panels need to deregister on unmount to avoid orphans in menu state.\n // This is an issue when panel items are being injected via SlotFills.\n const deregisterPanelItem = useCallback(label => {\n // When switching selections between components injecting matching\n // controls, e.g. both panels have a \"padding\" control, the\n // deregistration of the first panel doesn't occur until after the\n // registration of the next.\n panelDispatch({\n type: 'UNREGISTER_PANEL',\n label\n });\n }, []);\n const registerResetAllFilter = useCallback(filter => {\n dispatchResetAllFilters({\n type: 'REGISTER',\n filter\n });\n }, []);\n const deregisterResetAllFilter = useCallback(filter => {\n dispatchResetAllFilters({\n type: 'UNREGISTER',\n filter\n });\n }, []);\n\n // Updates the status of the panel’s menu items. For default items the\n // value represents whether it differs from the default and for optional\n // items whether the item is shown.\n const flagItemCustomization = useCallback((value, label, group = 'default') => {\n panelDispatch({\n type: 'UPDATE_VALUE',\n group,\n label,\n value\n });\n }, []);\n\n // Whether all optional menu items are hidden or not must be tracked\n // in order to later determine if the panel display is empty and handle\n // conditional display of a plus icon to indicate the presence of further\n // menu items.\n const areAllOptionalControlsHidden = useMemo(() => {\n return isMenuItemTypeEmpty(menuItems.default) && !isMenuItemTypeEmpty(menuItems.optional) && Object.values(menuItems.optional).every(isSelected => !isSelected);\n }, [menuItems]);\n const classes = clsx(styles['tools-panel'], hasInnerWrapper && styles['tools-panel-with-inner-wrapper'], areAllOptionalControlsHidden && styles['tools-panel-hidden-inner-wrapper'], className);\n\n // Toggle the checked state of a menu item which is then used to determine\n // display of the item within the panel.\n const toggleItem = useCallback(label => {\n panelDispatch({\n type: 'TOGGLE_VALUE',\n label\n });\n }, []);\n\n // Resets display of children and executes resetAll callback if available.\n const resetAllItems = useCallback(() => {\n if (typeof resetAll === 'function') {\n isResettingRef.current = true;\n resetAll(resetAllFilters);\n }\n\n // Turn off display of all non-default items.\n panelDispatch({\n type: 'RESET_ALL'\n });\n }, [resetAllFilters, resetAll]);\n\n // Assist ItemGroup styling when there are potentially hidden placeholder\n // items by identifying first & last items that are toggled on for display.\n const getFirstVisibleItemLabel = items => {\n const optionalItems = menuItems.optional || {};\n const firstItem = items.find(item => item.isShownByDefault || optionalItems[item.label]);\n return firstItem?.label;\n };\n const firstDisplayedItem = getFirstVisibleItemLabel(panelItems);\n const lastDisplayedItem = getFirstVisibleItemLabel([...panelItems].reverse());\n const hasMenuItems = panelItems.length > 0;\n const panelContext = useMemo(() => ({\n areAllOptionalControlsHidden,\n deregisterPanelItem,\n deregisterResetAllFilter,\n firstDisplayedItem,\n flagItemCustomization,\n hasMenuItems,\n isResetting: isResettingRef.current,\n lastDisplayedItem,\n menuItems,\n panelId,\n registerPanelItem,\n registerResetAllFilter,\n shouldRenderPlaceholderItems,\n __experimentalFirstVisibleItemClass,\n __experimentalLastVisibleItemClass\n }), [areAllOptionalControlsHidden, deregisterPanelItem, deregisterResetAllFilter, firstDisplayedItem, flagItemCustomization, lastDisplayedItem, menuItems, panelId, hasMenuItems, registerResetAllFilter, registerPanelItem, shouldRenderPlaceholderItems, __experimentalFirstVisibleItemClass, __experimentalLastVisibleItemClass]);\n return {\n ...otherProps,\n headingLevel,\n panelContext,\n resetAllItems,\n toggleItem,\n className: classes\n };\n}", "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(\"29b739f451\", \"._62d714739f4dc308__tools-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}._40db7f4f897b683d__tools-panel-with-inner-wrapper>div:not(:first-of-type){column-gap:16px;display:grid;grid-column:1/-1;grid-template-columns:repeat(2,minmax(0,1fr));row-gap:16px}._95a15674966f30a3__tools-panel-hidden-inner-wrapper>div:not(:first-of-type){display:none}._322a049b9b7d8674__tools-panel-header{gap:8px;grid-column:1/-1}._322a049b9b7d8674__tools-panel-header .components-dropdown-menu{line-height:0;margin:-4px 0}._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header .components-dropdown-menu__toggle{min-width:24px;padding:0}.b92a382d3b30104d__tools-panel-heading.b92a382d3b30104d__tools-panel-heading{font-size:inherit;line-height:normal;margin:0}._8005d68fffa9db91__tools-panel-item{grid-column:1/-1}._8005d68fffa9db91__tools-panel-item>div,._8005d68fffa9db91__tools-panel-item>fieldset{margin-bottom:0;max-width:100%;padding-bottom:0}._8005d68fffa9db91__tools-panel-item .components-base-control__help,._8005d68fffa9db91__tools-panel-item._8005d68fffa9db91__tools-panel-item .components-base-control,._8005d68fffa9db91__tools-panel-item._8005d68fffa9db91__tools-panel-item .components-base-control .components-base-control__field:last-child{margin-bottom:0}._4f55e1a6e373746e__tools-panel-item-placeholder{display:none}.d40032517bff9e12__dropdown-menu{min-width:200px}.f135b96aa96ca6bb__reset-label{color:var(--wp-components-color-accent-darker-10,var(--wp-admin-theme-color-darker-10,#2145e6));font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:1.4;margin-inline-start:12px;text-transform:uppercase}._69b138dfa5570d9c__default-controls-item{color:#1e1e1e}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true]{color:#757575;opacity:1}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true]:hover{color:#757575}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true] .f135b96aa96ca6bb__reset-label{opacity:.3}\");\n}\nexport default {\"tools-panel\":\"_62d714739f4dc308__tools-panel\",\"tools-panel-with-inner-wrapper\":\"_40db7f4f897b683d__tools-panel-with-inner-wrapper\",\"tools-panel-hidden-inner-wrapper\":\"_95a15674966f30a3__tools-panel-hidden-inner-wrapper\",\"tools-panel-header\":\"_322a049b9b7d8674__tools-panel-header\",\"tools-panel-heading\":\"b92a382d3b30104d__tools-panel-heading\",\"tools-panel-item\":\"_8005d68fffa9db91__tools-panel-item\",\"tools-panel-item-placeholder\":\"_4f55e1a6e373746e__tools-panel-item-placeholder\",\"dropdown-menu\":\"d40032517bff9e12__dropdown-menu\",\"reset-label\":\"f135b96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-8,8 +8,92 @@ import MenuItem from "../../menu-item/index.mjs";
|
|
|
8
8
|
import { HStack } from "../../h-stack/index.mjs";
|
|
9
9
|
import { Heading } from "../../heading/index.mjs";
|
|
10
10
|
import { useToolsPanelHeader } from "./hook.mjs";
|
|
11
|
+
|
|
12
|
+
// packages/style-runtime/src/index.ts
|
|
13
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
14
|
+
function getRuntime() {
|
|
15
|
+
const globalScope = globalThis;
|
|
16
|
+
if (globalScope.__wpStyleRuntime) {
|
|
17
|
+
return globalScope.__wpStyleRuntime;
|
|
18
|
+
}
|
|
19
|
+
globalScope.__wpStyleRuntime = {
|
|
20
|
+
documents: /* @__PURE__ */ new Map(),
|
|
21
|
+
styles: /* @__PURE__ */ new Map(),
|
|
22
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
23
|
+
};
|
|
24
|
+
if (typeof document !== "undefined") {
|
|
25
|
+
registerDocument(document);
|
|
26
|
+
}
|
|
27
|
+
return globalScope.__wpStyleRuntime;
|
|
28
|
+
}
|
|
29
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
30
|
+
if (!targetDocument.head) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {
|
|
34
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
function injectStyle(targetDocument, hash, css) {
|
|
41
|
+
if (!targetDocument.head) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const runtime = getRuntime();
|
|
45
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
46
|
+
if (!injectedStyles) {
|
|
47
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
48
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
49
|
+
}
|
|
50
|
+
if (injectedStyles.has(hash)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
54
|
+
injectedStyles.add(hash);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const style = targetDocument.createElement("style");
|
|
58
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
59
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
60
|
+
targetDocument.head.appendChild(style);
|
|
61
|
+
injectedStyles.add(hash);
|
|
62
|
+
}
|
|
63
|
+
function registerDocument(targetDocument) {
|
|
64
|
+
const runtime = getRuntime();
|
|
65
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
66
|
+
for (const [hash, css] of runtime.styles) {
|
|
67
|
+
injectStyle(targetDocument, hash, css);
|
|
68
|
+
}
|
|
69
|
+
return () => {
|
|
70
|
+
const count = runtime.documents.get(targetDocument);
|
|
71
|
+
if (count === void 0) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (count <= 1) {
|
|
75
|
+
runtime.documents.delete(targetDocument);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function registerStyle(hash, css) {
|
|
82
|
+
const runtime = getRuntime();
|
|
83
|
+
runtime.styles.set(hash, css);
|
|
84
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
85
|
+
injectStyle(targetDocument, hash, css);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// packages/components/src/tools-panel/style.module.scss
|
|
90
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
91
|
+
registerStyle("29b739f451", "._62d714739f4dc308__tools-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}._40db7f4f897b683d__tools-panel-with-inner-wrapper>div:not(:first-of-type){column-gap:16px;display:grid;grid-column:1/-1;grid-template-columns:repeat(2,minmax(0,1fr));row-gap:16px}._95a15674966f30a3__tools-panel-hidden-inner-wrapper>div:not(:first-of-type){display:none}._322a049b9b7d8674__tools-panel-header{gap:8px;grid-column:1/-1}._322a049b9b7d8674__tools-panel-header .components-dropdown-menu{line-height:0;margin:-4px 0}._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header .components-dropdown-menu__toggle{min-width:24px;padding:0}.b92a382d3b30104d__tools-panel-heading.b92a382d3b30104d__tools-panel-heading{font-size:inherit;line-height:normal;margin:0}._8005d68fffa9db91__tools-panel-item{grid-column:1/-1}._8005d68fffa9db91__tools-panel-item>div,._8005d68fffa9db91__tools-panel-item>fieldset{margin-bottom:0;max-width:100%;padding-bottom:0}._8005d68fffa9db91__tools-panel-item .components-base-control__help,._8005d68fffa9db91__tools-panel-item._8005d68fffa9db91__tools-panel-item .components-base-control,._8005d68fffa9db91__tools-panel-item._8005d68fffa9db91__tools-panel-item .components-base-control .components-base-control__field:last-child{margin-bottom:0}._4f55e1a6e373746e__tools-panel-item-placeholder{display:none}.d40032517bff9e12__dropdown-menu{min-width:200px}.f135b96aa96ca6bb__reset-label{color:var(--wp-components-color-accent-darker-10,var(--wp-admin-theme-color-darker-10,#2145e6));font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:1.4;margin-inline-start:12px;text-transform:uppercase}._69b138dfa5570d9c__default-controls-item{color:#1e1e1e}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true]{color:#757575;opacity:1}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true]:hover{color:#757575}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true] .f135b96aa96ca6bb__reset-label{opacity:.3}");
|
|
92
|
+
}
|
|
93
|
+
var style_module_default = { "tools-panel": "_62d714739f4dc308__tools-panel", "tools-panel-with-inner-wrapper": "_40db7f4f897b683d__tools-panel-with-inner-wrapper", "tools-panel-hidden-inner-wrapper": "_95a15674966f30a3__tools-panel-hidden-inner-wrapper", "tools-panel-header": "_322a049b9b7d8674__tools-panel-header", "tools-panel-heading": "b92a382d3b30104d__tools-panel-heading", "tools-panel-item": "_8005d68fffa9db91__tools-panel-item", "tools-panel-item-placeholder": "_4f55e1a6e373746e__tools-panel-item-placeholder", "dropdown-menu": "d40032517bff9e12__dropdown-menu", "reset-label": "f135b96aa96ca6bb__reset-label", "default-controls-item": "_69b138dfa5570d9c__default-controls-item" };
|
|
94
|
+
|
|
95
|
+
// packages/components/src/tools-panel/tools-panel-header/component.tsx
|
|
11
96
|
import { contextConnect } from "../../context/index.mjs";
|
|
12
|
-
import { ResetLabel } from "../styles.mjs";
|
|
13
97
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
98
|
var DefaultControlsGroup = ({
|
|
15
99
|
itemClassName,
|
|
@@ -19,8 +103,9 @@ var DefaultControlsGroup = ({
|
|
|
19
103
|
if (!items.length) {
|
|
20
104
|
return null;
|
|
21
105
|
}
|
|
22
|
-
const resetSuffix = /* @__PURE__ */ _jsx(
|
|
106
|
+
const resetSuffix = /* @__PURE__ */ _jsx("span", {
|
|
23
107
|
"aria-hidden": true,
|
|
108
|
+
className: style_module_default["reset-label"],
|
|
24
109
|
children: __("Reset")
|
|
25
110
|
});
|
|
26
111
|
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/tools-panel/tools-panel-header/component.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { check, moreVertical, plus } from '@wordpress/icons';\nimport { __, _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport MenuGroup from '../../menu-group';\nimport MenuItem from '../../menu-item';\nimport { HStack } from '../../h-stack';\nimport { Heading } from '../../heading';\nimport { useToolsPanelHeader } from './hook';\nimport { contextConnect } from '../../context';\nimport { ResetLabel } from '../styles';\nimport { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst DefaultControlsGroup = ({\n itemClassName,\n items,\n toggleItem\n}) => {\n if (!items.length) {\n return null;\n }\n const resetSuffix = /*#__PURE__*/_jsx(ResetLabel, {\n \"aria-hidden\": true,\n children: __('Reset')\n });\n return /*#__PURE__*/_jsx(_Fragment, {\n children: items.map(([label, hasValue]) => {\n if (hasValue) {\n return /*#__PURE__*/_jsx(MenuItem, {\n className: itemClassName,\n role: \"menuitem\",\n label: sprintf(\n // translators: %s: The name of the control being reset e.g. \"Padding\".\n __('Reset %s'), label),\n onClick: () => {\n toggleItem(label);\n speak(sprintf(\n // translators: %s: The name of the control being reset e.g. \"Padding\".\n __('%s reset to default'), label), 'assertive');\n },\n suffix: resetSuffix,\n children: label\n }, label);\n }\n return /*#__PURE__*/_jsx(MenuItem, {\n icon: check,\n className: itemClassName,\n role: \"menuitemcheckbox\",\n isSelected: true,\n \"aria-disabled\": true,\n children: label\n }, label);\n })\n });\n};\nconst OptionalControlsGroup = ({\n items,\n toggleItem\n}) => {\n if (!items.length) {\n return null;\n }\n return /*#__PURE__*/_jsx(_Fragment, {\n children: items.map(([label, isSelected]) => {\n const itemLabel = isSelected ? sprintf(\n // translators: %s: The name of the control being hidden and reset e.g. \"Padding\".\n __('Hide and reset %s'), label) : sprintf(\n // translators: %s: The name of the control to display e.g. \"Padding\".\n _x('Show %s', 'input control'), label);\n return /*#__PURE__*/_jsx(MenuItem, {\n icon: isSelected ? check : null,\n isSelected: isSelected,\n label: itemLabel,\n onClick: () => {\n if (isSelected) {\n speak(sprintf(\n // translators: %s: The name of the control being reset e.g. \"Padding\".\n __('%s hidden and reset to default'), label), 'assertive');\n } else {\n speak(sprintf(\n // translators: %s: The name of the control being reset e.g. \"Padding\".\n __('%s is now visible'), label), 'assertive');\n }\n toggleItem(label);\n },\n role: \"menuitemcheckbox\",\n children: label\n }, label);\n })\n });\n};\nconst ToolsPanelHeader = (props, forwardedRef) => {\n const {\n areAllOptionalControlsHidden,\n defaultControlsItemClassName,\n dropdownMenuClassName,\n hasMenuItems,\n headingClassName,\n headingLevel = 2,\n label: labelText,\n menuItems,\n resetAll,\n toggleItem,\n dropdownMenuProps,\n ...headerProps\n } = useToolsPanelHeader(props);\n if (!labelText) {\n return null;\n }\n const defaultItems = Object.entries(menuItems?.default || {});\n const optionalItems = Object.entries(menuItems?.optional || {});\n const dropDownMenuIcon = areAllOptionalControlsHidden ? plus : moreVertical;\n const dropDownMenuLabelText = sprintf(\n // translators: %s: The name of the tool e.g. \"Color\" or \"Typography\".\n _x('%s options', 'Button label to reveal tool panel options'), labelText);\n const dropdownMenuDescriptionText = areAllOptionalControlsHidden ? __('All options are currently hidden') : undefined;\n const canResetAll = [...defaultItems, ...optionalItems].some(([, isSelected]) => isSelected);\n return /*#__PURE__*/_jsxs(HStack, {\n ...headerProps,\n ref: forwardedRef,\n children: [/*#__PURE__*/_jsx(Heading, {\n level: headingLevel,\n className: headingClassName,\n children: labelText\n }), hasMenuItems && /*#__PURE__*/_jsx(DropdownMenu, {\n ...dropdownMenuProps,\n icon: dropDownMenuIcon,\n label: dropDownMenuLabelText,\n menuProps: {\n className: dropdownMenuClassName\n },\n toggleProps: {\n size: 'small',\n description: dropdownMenuDescriptionText\n },\n children: () => /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsxs(MenuGroup, {\n label: labelText,\n children: [/*#__PURE__*/_jsx(DefaultControlsGroup, {\n items: defaultItems,\n toggleItem: toggleItem,\n itemClassName: defaultControlsItemClassName\n }), /*#__PURE__*/_jsx(OptionalControlsGroup, {\n items: optionalItems,\n toggleItem: toggleItem\n })]\n }), /*#__PURE__*/_jsx(MenuGroup, {\n children: /*#__PURE__*/_jsx(MenuItem, {\n \"aria-disabled\": !canResetAll\n // @ts-expect-error - TODO: If this \"tertiary\" style is something we really want to allow on MenuItem,\n // we should rename it and explicitly allow it as an official API. All the other Button variants\n // don't make sense in a MenuItem context, and should be disallowed.\n ,\n variant: \"tertiary\",\n onClick: () => {\n if (canResetAll) {\n resetAll();\n speak(__('All options reset'), 'assertive');\n }\n },\n children: __('Reset all')\n })\n })]\n })\n })]\n });\n};\nconst ConnectedToolsPanelHeader = contextConnect(ToolsPanelHeader, 'ToolsPanelHeader');\nexport default ConnectedToolsPanelHeader;"],
|
|
5
|
-
"mappings": ";AAOA,SAAS,aAAa;AACtB,SAAS,OAAO,cAAc,YAAY;AAC1C,SAAS,IAAI,IAAI,eAAe;AAKhC,OAAO,kBAAkB;AACzB,OAAO,eAAe;AACtB,OAAO,cAAc;AACrB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,2BAA2B;
|
|
3
|
+
"sources": ["../../../src/tools-panel/tools-panel-header/component.tsx", "../../../../style-runtime/src/index.ts", "../../../src/tools-panel/style.module.scss"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { check, moreVertical, plus } from '@wordpress/icons';\nimport { __, _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport MenuGroup from '../../menu-group';\nimport MenuItem from '../../menu-item';\nimport { HStack } from '../../h-stack';\nimport { Heading } from '../../heading';\nimport { useToolsPanelHeader } from './hook';\nimport styles from '../style.module.scss';\nimport { contextConnect } from '../../context';\nimport { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst DefaultControlsGroup = ({\n itemClassName,\n items,\n toggleItem\n}) => {\n if (!items.length) {\n return null;\n }\n const resetSuffix = /*#__PURE__*/_jsx(\"span\", {\n \"aria-hidden\": true,\n className: styles['reset-label'],\n children: __('Reset')\n });\n return /*#__PURE__*/_jsx(_Fragment, {\n children: items.map(([label, hasValue]) => {\n if (hasValue) {\n return /*#__PURE__*/_jsx(MenuItem, {\n className: itemClassName,\n role: \"menuitem\",\n label: sprintf(\n // translators: %s: The name of the control being reset e.g. \"Padding\".\n __('Reset %s'), label),\n onClick: () => {\n toggleItem(label);\n speak(sprintf(\n // translators: %s: The name of the control being reset e.g. \"Padding\".\n __('%s reset to default'), label), 'assertive');\n },\n suffix: resetSuffix,\n children: label\n }, label);\n }\n return /*#__PURE__*/_jsx(MenuItem, {\n icon: check,\n className: itemClassName,\n role: \"menuitemcheckbox\",\n isSelected: true,\n \"aria-disabled\": true,\n children: label\n }, label);\n })\n });\n};\nconst OptionalControlsGroup = ({\n items,\n toggleItem\n}) => {\n if (!items.length) {\n return null;\n }\n return /*#__PURE__*/_jsx(_Fragment, {\n children: items.map(([label, isSelected]) => {\n const itemLabel = isSelected ? sprintf(\n // translators: %s: The name of the control being hidden and reset e.g. \"Padding\".\n __('Hide and reset %s'), label) : sprintf(\n // translators: %s: The name of the control to display e.g. \"Padding\".\n _x('Show %s', 'input control'), label);\n return /*#__PURE__*/_jsx(MenuItem, {\n icon: isSelected ? check : null,\n isSelected: isSelected,\n label: itemLabel,\n onClick: () => {\n if (isSelected) {\n speak(sprintf(\n // translators: %s: The name of the control being reset e.g. \"Padding\".\n __('%s hidden and reset to default'), label), 'assertive');\n } else {\n speak(sprintf(\n // translators: %s: The name of the control being reset e.g. \"Padding\".\n __('%s is now visible'), label), 'assertive');\n }\n toggleItem(label);\n },\n role: \"menuitemcheckbox\",\n children: label\n }, label);\n })\n });\n};\nconst ToolsPanelHeader = (props, forwardedRef) => {\n const {\n areAllOptionalControlsHidden,\n defaultControlsItemClassName,\n dropdownMenuClassName,\n hasMenuItems,\n headingClassName,\n headingLevel = 2,\n label: labelText,\n menuItems,\n resetAll,\n toggleItem,\n dropdownMenuProps,\n ...headerProps\n } = useToolsPanelHeader(props);\n if (!labelText) {\n return null;\n }\n const defaultItems = Object.entries(menuItems?.default || {});\n const optionalItems = Object.entries(menuItems?.optional || {});\n const dropDownMenuIcon = areAllOptionalControlsHidden ? plus : moreVertical;\n const dropDownMenuLabelText = sprintf(\n // translators: %s: The name of the tool e.g. \"Color\" or \"Typography\".\n _x('%s options', 'Button label to reveal tool panel options'), labelText);\n const dropdownMenuDescriptionText = areAllOptionalControlsHidden ? __('All options are currently hidden') : undefined;\n const canResetAll = [...defaultItems, ...optionalItems].some(([, isSelected]) => isSelected);\n return /*#__PURE__*/_jsxs(HStack, {\n ...headerProps,\n ref: forwardedRef,\n children: [/*#__PURE__*/_jsx(Heading, {\n level: headingLevel,\n className: headingClassName,\n children: labelText\n }), hasMenuItems && /*#__PURE__*/_jsx(DropdownMenu, {\n ...dropdownMenuProps,\n icon: dropDownMenuIcon,\n label: dropDownMenuLabelText,\n menuProps: {\n className: dropdownMenuClassName\n },\n toggleProps: {\n size: 'small',\n description: dropdownMenuDescriptionText\n },\n children: () => /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsxs(MenuGroup, {\n label: labelText,\n children: [/*#__PURE__*/_jsx(DefaultControlsGroup, {\n items: defaultItems,\n toggleItem: toggleItem,\n itemClassName: defaultControlsItemClassName\n }), /*#__PURE__*/_jsx(OptionalControlsGroup, {\n items: optionalItems,\n toggleItem: toggleItem\n })]\n }), /*#__PURE__*/_jsx(MenuGroup, {\n children: /*#__PURE__*/_jsx(MenuItem, {\n \"aria-disabled\": !canResetAll\n // @ts-expect-error - TODO: If this \"tertiary\" style is something we really want to allow on MenuItem,\n // we should rename it and explicitly allow it as an official API. All the other Button variants\n // don't make sense in a MenuItem context, and should be disallowed.\n ,\n variant: \"tertiary\",\n onClick: () => {\n if (canResetAll) {\n resetAll();\n speak(__('All options reset'), 'assertive');\n }\n },\n children: __('Reset all')\n })\n })]\n })\n })]\n });\n};\nconst ConnectedToolsPanelHeader = contextConnect(ToolsPanelHeader, 'ToolsPanelHeader');\nexport default ConnectedToolsPanelHeader;", "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(\"29b739f451\", \"._62d714739f4dc308__tools-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}._40db7f4f897b683d__tools-panel-with-inner-wrapper>div:not(:first-of-type){column-gap:16px;display:grid;grid-column:1/-1;grid-template-columns:repeat(2,minmax(0,1fr));row-gap:16px}._95a15674966f30a3__tools-panel-hidden-inner-wrapper>div:not(:first-of-type){display:none}._322a049b9b7d8674__tools-panel-header{gap:8px;grid-column:1/-1}._322a049b9b7d8674__tools-panel-header .components-dropdown-menu{line-height:0;margin:-4px 0}._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header .components-dropdown-menu__toggle{min-width:24px;padding:0}.b92a382d3b30104d__tools-panel-heading.b92a382d3b30104d__tools-panel-heading{font-size:inherit;line-height:normal;margin:0}._8005d68fffa9db91__tools-panel-item{grid-column:1/-1}._8005d68fffa9db91__tools-panel-item>div,._8005d68fffa9db91__tools-panel-item>fieldset{margin-bottom:0;max-width:100%;padding-bottom:0}._8005d68fffa9db91__tools-panel-item .components-base-control__help,._8005d68fffa9db91__tools-panel-item._8005d68fffa9db91__tools-panel-item .components-base-control,._8005d68fffa9db91__tools-panel-item._8005d68fffa9db91__tools-panel-item .components-base-control .components-base-control__field:last-child{margin-bottom:0}._4f55e1a6e373746e__tools-panel-item-placeholder{display:none}.d40032517bff9e12__dropdown-menu{min-width:200px}.f135b96aa96ca6bb__reset-label{color:var(--wp-components-color-accent-darker-10,var(--wp-admin-theme-color-darker-10,#2145e6));font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:1.4;margin-inline-start:12px;text-transform:uppercase}._69b138dfa5570d9c__default-controls-item{color:#1e1e1e}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true]{color:#757575;opacity:1}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true]:hover{color:#757575}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true] .f135b96aa96ca6bb__reset-label{opacity:.3}\");\n}\nexport default {\"tools-panel\":\"_62d714739f4dc308__tools-panel\",\"tools-panel-with-inner-wrapper\":\"_40db7f4f897b683d__tools-panel-with-inner-wrapper\",\"tools-panel-hidden-inner-wrapper\":\"_95a15674966f30a3__tools-panel-hidden-inner-wrapper\",\"tools-panel-header\":\"_322a049b9b7d8674__tools-panel-header\",\"tools-panel-heading\":\"b92a382d3b30104d__tools-panel-heading\",\"tools-panel-item\":\"_8005d68fffa9db91__tools-panel-item\",\"tools-panel-item-placeholder\":\"_4f55e1a6e373746e__tools-panel-item-placeholder\",\"dropdown-menu\":\"d40032517bff9e12__dropdown-menu\",\"reset-label\":\"f135b96aa96ca6bb__reset-label\",\"default-controls-item\":\"_69b138dfa5570d9c__default-controls-item\"};\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,aAAa;AACtB,SAAS,OAAO,cAAc,YAAY;AAC1C,SAAS,IAAI,IAAI,eAAe;AAKhC,OAAO,kBAAkB;AACzB,OAAO,eAAe;AACtB,OAAO,cAAc;AACrB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,2BAA2B;;;ACnBpC,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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1
|
// packages/components/src/tools-panel/tools-panel-header/hook.ts
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
|
|
4
|
+
// packages/style-runtime/src/index.ts
|
|
5
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
6
|
+
function getRuntime() {
|
|
7
|
+
const globalScope = globalThis;
|
|
8
|
+
if (globalScope.__wpStyleRuntime) {
|
|
9
|
+
return globalScope.__wpStyleRuntime;
|
|
10
|
+
}
|
|
11
|
+
globalScope.__wpStyleRuntime = {
|
|
12
|
+
documents: /* @__PURE__ */ new Map(),
|
|
13
|
+
styles: /* @__PURE__ */ new Map(),
|
|
14
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
15
|
+
};
|
|
16
|
+
if (typeof document !== "undefined") {
|
|
17
|
+
registerDocument(document);
|
|
18
|
+
}
|
|
19
|
+
return globalScope.__wpStyleRuntime;
|
|
20
|
+
}
|
|
21
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
22
|
+
if (!targetDocument.head) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {
|
|
26
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
function injectStyle(targetDocument, hash, css) {
|
|
33
|
+
if (!targetDocument.head) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const runtime = getRuntime();
|
|
37
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
38
|
+
if (!injectedStyles) {
|
|
39
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
40
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
41
|
+
}
|
|
42
|
+
if (injectedStyles.has(hash)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
46
|
+
injectedStyles.add(hash);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const style = targetDocument.createElement("style");
|
|
50
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
51
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
52
|
+
targetDocument.head.appendChild(style);
|
|
53
|
+
injectedStyles.add(hash);
|
|
54
|
+
}
|
|
55
|
+
function registerDocument(targetDocument) {
|
|
56
|
+
const runtime = getRuntime();
|
|
57
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
58
|
+
for (const [hash, css] of runtime.styles) {
|
|
59
|
+
injectStyle(targetDocument, hash, css);
|
|
60
|
+
}
|
|
61
|
+
return () => {
|
|
62
|
+
const count = runtime.documents.get(targetDocument);
|
|
63
|
+
if (count === void 0) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (count <= 1) {
|
|
67
|
+
runtime.documents.delete(targetDocument);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function registerStyle(hash, css) {
|
|
74
|
+
const runtime = getRuntime();
|
|
75
|
+
runtime.styles.set(hash, css);
|
|
76
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
77
|
+
injectStyle(targetDocument, hash, css);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// packages/components/src/tools-panel/style.module.scss
|
|
82
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
83
|
+
registerStyle("29b739f451", "._62d714739f4dc308__tools-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}._40db7f4f897b683d__tools-panel-with-inner-wrapper>div:not(:first-of-type){column-gap:16px;display:grid;grid-column:1/-1;grid-template-columns:repeat(2,minmax(0,1fr));row-gap:16px}._95a15674966f30a3__tools-panel-hidden-inner-wrapper>div:not(:first-of-type){display:none}._322a049b9b7d8674__tools-panel-header{gap:8px;grid-column:1/-1}._322a049b9b7d8674__tools-panel-header .components-dropdown-menu{line-height:0;margin:-4px 0}._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header .components-dropdown-menu__toggle{min-width:24px;padding:0}.b92a382d3b30104d__tools-panel-heading.b92a382d3b30104d__tools-panel-heading{font-size:inherit;line-height:normal;margin:0}._8005d68fffa9db91__tools-panel-item{grid-column:1/-1}._8005d68fffa9db91__tools-panel-item>div,._8005d68fffa9db91__tools-panel-item>fieldset{margin-bottom:0;max-width:100%;padding-bottom:0}._8005d68fffa9db91__tools-panel-item .components-base-control__help,._8005d68fffa9db91__tools-panel-item._8005d68fffa9db91__tools-panel-item .components-base-control,._8005d68fffa9db91__tools-panel-item._8005d68fffa9db91__tools-panel-item .components-base-control .components-base-control__field:last-child{margin-bottom:0}._4f55e1a6e373746e__tools-panel-item-placeholder{display:none}.d40032517bff9e12__dropdown-menu{min-width:200px}.f135b96aa96ca6bb__reset-label{color:var(--wp-components-color-accent-darker-10,var(--wp-admin-theme-color-darker-10,#2145e6));font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:1.4;margin-inline-start:12px;text-transform:uppercase}._69b138dfa5570d9c__default-controls-item{color:#1e1e1e}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true]{color:#757575;opacity:1}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true]:hover{color:#757575}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true] .f135b96aa96ca6bb__reset-label{opacity:.3}");
|
|
84
|
+
}
|
|
85
|
+
var style_module_default = { "tools-panel": "_62d714739f4dc308__tools-panel", "tools-panel-with-inner-wrapper": "_40db7f4f897b683d__tools-panel-with-inner-wrapper", "tools-panel-hidden-inner-wrapper": "_95a15674966f30a3__tools-panel-hidden-inner-wrapper", "tools-panel-header": "_322a049b9b7d8674__tools-panel-header", "tools-panel-heading": "b92a382d3b30104d__tools-panel-heading", "tools-panel-item": "_8005d68fffa9db91__tools-panel-item", "tools-panel-item-placeholder": "_4f55e1a6e373746e__tools-panel-item-placeholder", "dropdown-menu": "d40032517bff9e12__dropdown-menu", "reset-label": "f135b96aa96ca6bb__reset-label", "default-controls-item": "_69b138dfa5570d9c__default-controls-item" };
|
|
86
|
+
|
|
87
|
+
// packages/components/src/tools-panel/tools-panel-header/hook.ts
|
|
4
88
|
import { useToolsPanelContext } from "../context.mjs";
|
|
5
89
|
import { useContextSystem } from "../../context/index.mjs";
|
|
6
|
-
import { useCx } from "../../utils/hooks/use-cx.mjs";
|
|
7
90
|
function useToolsPanelHeader(props) {
|
|
8
91
|
const {
|
|
9
92
|
className,
|
|
10
93
|
headingLevel = 2,
|
|
11
94
|
...otherProps
|
|
12
95
|
} = useContextSystem(props, "ToolsPanelHeader");
|
|
13
|
-
const cx = useCx();
|
|
14
|
-
const classes = useMemo(() => {
|
|
15
|
-
return cx(styles.ToolsPanelHeader, className);
|
|
16
|
-
}, [className, cx]);
|
|
17
|
-
const dropdownMenuClassName = useMemo(() => {
|
|
18
|
-
return cx(styles.DropdownMenu);
|
|
19
|
-
}, [cx]);
|
|
20
|
-
const headingClassName = useMemo(() => {
|
|
21
|
-
return cx(styles.ToolsPanelHeading);
|
|
22
|
-
}, [cx]);
|
|
23
|
-
const defaultControlsItemClassName = useMemo(() => {
|
|
24
|
-
return cx(styles.DefaultControlsItem);
|
|
25
|
-
}, [cx]);
|
|
26
96
|
const {
|
|
27
97
|
menuItems,
|
|
28
98
|
hasMenuItems,
|
|
@@ -31,13 +101,13 @@ function useToolsPanelHeader(props) {
|
|
|
31
101
|
return {
|
|
32
102
|
...otherProps,
|
|
33
103
|
areAllOptionalControlsHidden,
|
|
34
|
-
defaultControlsItemClassName,
|
|
35
|
-
dropdownMenuClassName,
|
|
104
|
+
defaultControlsItemClassName: style_module_default["default-controls-item"],
|
|
105
|
+
dropdownMenuClassName: style_module_default["dropdown-menu"],
|
|
36
106
|
hasMenuItems,
|
|
37
|
-
headingClassName,
|
|
107
|
+
headingClassName: style_module_default["tools-panel-heading"],
|
|
38
108
|
headingLevel,
|
|
39
109
|
menuItems,
|
|
40
|
-
className:
|
|
110
|
+
className: clsx(style_module_default["tools-panel-header"], className)
|
|
41
111
|
};
|
|
42
112
|
}
|
|
43
113
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/tools-panel/tools-panel-header/hook.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n *
|
|
5
|
-
"mappings": ";AAGA,SAAS,
|
|
3
|
+
"sources": ["../../../src/tools-panel/tools-panel-header/hook.ts", "../../../../style-runtime/src/index.ts", "../../../src/tools-panel/style.module.scss"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * Internal dependencies\n */\nimport styles from '../style.module.scss';\nimport { useToolsPanelContext } from '../context';\nimport { useContextSystem } from '../../context';\nexport function useToolsPanelHeader(props) {\n const {\n className,\n headingLevel = 2,\n ...otherProps\n } = useContextSystem(props, 'ToolsPanelHeader');\n const {\n menuItems,\n hasMenuItems,\n areAllOptionalControlsHidden\n } = useToolsPanelContext();\n return {\n ...otherProps,\n areAllOptionalControlsHidden,\n defaultControlsItemClassName: styles['default-controls-item'],\n dropdownMenuClassName: styles['dropdown-menu'],\n hasMenuItems,\n headingClassName: styles['tools-panel-heading'],\n headingLevel,\n menuItems,\n className: clsx(styles['tools-panel-header'], className)\n };\n}", "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(\"29b739f451\", \"._62d714739f4dc308__tools-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}._40db7f4f897b683d__tools-panel-with-inner-wrapper>div:not(:first-of-type){column-gap:16px;display:grid;grid-column:1/-1;grid-template-columns:repeat(2,minmax(0,1fr));row-gap:16px}._95a15674966f30a3__tools-panel-hidden-inner-wrapper>div:not(:first-of-type){display:none}._322a049b9b7d8674__tools-panel-header{gap:8px;grid-column:1/-1}._322a049b9b7d8674__tools-panel-header .components-dropdown-menu{line-height:0;margin:-4px 0}._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header .components-dropdown-menu__toggle{min-width:24px;padding:0}.b92a382d3b30104d__tools-panel-heading.b92a382d3b30104d__tools-panel-heading{font-size:inherit;line-height:normal;margin:0}._8005d68fffa9db91__tools-panel-item{grid-column:1/-1}._8005d68fffa9db91__tools-panel-item>div,._8005d68fffa9db91__tools-panel-item>fieldset{margin-bottom:0;max-width:100%;padding-bottom:0}._8005d68fffa9db91__tools-panel-item .components-base-control__help,._8005d68fffa9db91__tools-panel-item._8005d68fffa9db91__tools-panel-item .components-base-control,._8005d68fffa9db91__tools-panel-item._8005d68fffa9db91__tools-panel-item .components-base-control .components-base-control__field:last-child{margin-bottom:0}._4f55e1a6e373746e__tools-panel-item-placeholder{display:none}.d40032517bff9e12__dropdown-menu{min-width:200px}.f135b96aa96ca6bb__reset-label{color:var(--wp-components-color-accent-darker-10,var(--wp-admin-theme-color-darker-10,#2145e6));font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:1.4;margin-inline-start:12px;text-transform:uppercase}._69b138dfa5570d9c__default-controls-item{color:#1e1e1e}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true]{color:#757575;opacity:1}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true]:hover{color:#757575}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true] .f135b96aa96ca6bb__reset-label{opacity:.3}\");\n}\nexport default {\"tools-panel\":\"_62d714739f4dc308__tools-panel\",\"tools-panel-with-inner-wrapper\":\"_40db7f4f897b683d__tools-panel-with-inner-wrapper\",\"tools-panel-hidden-inner-wrapper\":\"_95a15674966f30a3__tools-panel-hidden-inner-wrapper\",\"tools-panel-header\":\"_322a049b9b7d8674__tools-panel-header\",\"tools-panel-heading\":\"b92a382d3b30104d__tools-panel-heading\",\"tools-panel-item\":\"_8005d68fffa9db91__tools-panel-item\",\"tools-panel-item-placeholder\":\"_4f55e1a6e373746e__tools-panel-item-placeholder\",\"dropdown-menu\":\"d40032517bff9e12__dropdown-menu\",\"reset-label\":\"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ACL,GAAG;AAAA,IACH;AAAA,IACA,8BAA8B,qBAAO,uBAAuB;AAAA,IAC5D,uBAAuB,qBAAO,eAAe;AAAA,IAC7C;AAAA,IACA,kBAAkB,qBAAO,qBAAqB;AAAA,IAC9C;AAAA,IACA;AAAA,IACA,WAAW,KAAK,qBAAO,oBAAoB,GAAG,SAAS;AAAA,EACzD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,94 @@
|
|
|
1
1
|
// packages/components/src/tools-panel/tools-panel-item/hook.ts
|
|
2
|
+
import clsx from "clsx";
|
|
2
3
|
import { usePrevious } from "@wordpress/compose";
|
|
3
|
-
import { useCallback, useEffect, useLayoutEffect
|
|
4
|
-
|
|
4
|
+
import { useCallback, useEffect, useLayoutEffect } from "@wordpress/element";
|
|
5
|
+
|
|
6
|
+
// packages/style-runtime/src/index.ts
|
|
7
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
8
|
+
function getRuntime() {
|
|
9
|
+
const globalScope = globalThis;
|
|
10
|
+
if (globalScope.__wpStyleRuntime) {
|
|
11
|
+
return globalScope.__wpStyleRuntime;
|
|
12
|
+
}
|
|
13
|
+
globalScope.__wpStyleRuntime = {
|
|
14
|
+
documents: /* @__PURE__ */ new Map(),
|
|
15
|
+
styles: /* @__PURE__ */ new Map(),
|
|
16
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
17
|
+
};
|
|
18
|
+
if (typeof document !== "undefined") {
|
|
19
|
+
registerDocument(document);
|
|
20
|
+
}
|
|
21
|
+
return globalScope.__wpStyleRuntime;
|
|
22
|
+
}
|
|
23
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
24
|
+
if (!targetDocument.head) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {
|
|
28
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
function injectStyle(targetDocument, hash, css) {
|
|
35
|
+
if (!targetDocument.head) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const runtime = getRuntime();
|
|
39
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
40
|
+
if (!injectedStyles) {
|
|
41
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
42
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
43
|
+
}
|
|
44
|
+
if (injectedStyles.has(hash)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
48
|
+
injectedStyles.add(hash);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const style = targetDocument.createElement("style");
|
|
52
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
53
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
54
|
+
targetDocument.head.appendChild(style);
|
|
55
|
+
injectedStyles.add(hash);
|
|
56
|
+
}
|
|
57
|
+
function registerDocument(targetDocument) {
|
|
58
|
+
const runtime = getRuntime();
|
|
59
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
60
|
+
for (const [hash, css] of runtime.styles) {
|
|
61
|
+
injectStyle(targetDocument, hash, css);
|
|
62
|
+
}
|
|
63
|
+
return () => {
|
|
64
|
+
const count = runtime.documents.get(targetDocument);
|
|
65
|
+
if (count === void 0) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (count <= 1) {
|
|
69
|
+
runtime.documents.delete(targetDocument);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function registerStyle(hash, css) {
|
|
76
|
+
const runtime = getRuntime();
|
|
77
|
+
runtime.styles.set(hash, css);
|
|
78
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
79
|
+
injectStyle(targetDocument, hash, css);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// packages/components/src/tools-panel/style.module.scss
|
|
84
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
85
|
+
registerStyle("29b739f451", "._62d714739f4dc308__tools-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}._40db7f4f897b683d__tools-panel-with-inner-wrapper>div:not(:first-of-type){column-gap:16px;display:grid;grid-column:1/-1;grid-template-columns:repeat(2,minmax(0,1fr));row-gap:16px}._95a15674966f30a3__tools-panel-hidden-inner-wrapper>div:not(:first-of-type){display:none}._322a049b9b7d8674__tools-panel-header{gap:8px;grid-column:1/-1}._322a049b9b7d8674__tools-panel-header .components-dropdown-menu{line-height:0;margin:-4px 0}._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header._322a049b9b7d8674__tools-panel-header .components-dropdown-menu__toggle{min-width:24px;padding:0}.b92a382d3b30104d__tools-panel-heading.b92a382d3b30104d__tools-panel-heading{font-size:inherit;line-height:normal;margin:0}._8005d68fffa9db91__tools-panel-item{grid-column:1/-1}._8005d68fffa9db91__tools-panel-item>div,._8005d68fffa9db91__tools-panel-item>fieldset{margin-bottom:0;max-width:100%;padding-bottom:0}._8005d68fffa9db91__tools-panel-item .components-base-control__help,._8005d68fffa9db91__tools-panel-item._8005d68fffa9db91__tools-panel-item .components-base-control,._8005d68fffa9db91__tools-panel-item._8005d68fffa9db91__tools-panel-item .components-base-control .components-base-control__field:last-child{margin-bottom:0}._4f55e1a6e373746e__tools-panel-item-placeholder{display:none}.d40032517bff9e12__dropdown-menu{min-width:200px}.f135b96aa96ca6bb__reset-label{color:var(--wp-components-color-accent-darker-10,var(--wp-admin-theme-color-darker-10,#2145e6));font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:1.4;margin-inline-start:12px;text-transform:uppercase}._69b138dfa5570d9c__default-controls-item{color:#1e1e1e}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true]{color:#757575;opacity:1}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true]:hover{color:#757575}._69b138dfa5570d9c__default-controls-item._69b138dfa5570d9c__default-controls-item[aria-disabled=true] .f135b96aa96ca6bb__reset-label{opacity:.3}");
|
|
86
|
+
}
|
|
87
|
+
var style_module_default = { "tools-panel": "_62d714739f4dc308__tools-panel", "tools-panel-with-inner-wrapper": "_40db7f4f897b683d__tools-panel-with-inner-wrapper", "tools-panel-hidden-inner-wrapper": "_95a15674966f30a3__tools-panel-hidden-inner-wrapper", "tools-panel-header": "_322a049b9b7d8674__tools-panel-header", "tools-panel-heading": "b92a382d3b30104d__tools-panel-heading", "tools-panel-item": "_8005d68fffa9db91__tools-panel-item", "tools-panel-item-placeholder": "_4f55e1a6e373746e__tools-panel-item-placeholder", "dropdown-menu": "d40032517bff9e12__dropdown-menu", "reset-label": "f135b96aa96ca6bb__reset-label", "default-controls-item": "_69b138dfa5570d9c__default-controls-item" };
|
|
88
|
+
|
|
89
|
+
// packages/components/src/tools-panel/tools-panel-item/hook.ts
|
|
5
90
|
import { useToolsPanelContext } from "../context.mjs";
|
|
6
91
|
import { useContextSystem } from "../../context/index.mjs";
|
|
7
|
-
import { useCx } from "../../utils/hooks/use-cx.mjs";
|
|
8
92
|
var noop = () => {
|
|
9
93
|
};
|
|
10
94
|
function useToolsPanelItem(props) {
|
|
@@ -86,13 +170,8 @@ function useToolsPanelItem(props) {
|
|
|
86
170
|
}
|
|
87
171
|
}, [hasMatchingPanel, isMenuItemChecked, isRegistered, isResetting, isValueSet, wasMenuItemChecked, onSelect, onDeselect]);
|
|
88
172
|
const isShown = isShownByDefault ? menuItems?.[menuGroup]?.[label] !== void 0 : isMenuItemChecked;
|
|
89
|
-
const
|
|
90
|
-
const classes =
|
|
91
|
-
const shouldApplyPlaceholderStyles = shouldRenderPlaceholder && !isShown;
|
|
92
|
-
const firstItemStyle = firstDisplayedItem === label && __experimentalFirstVisibleItemClass;
|
|
93
|
-
const lastItemStyle = lastDisplayedItem === label && __experimentalLastVisibleItemClass;
|
|
94
|
-
return cx(styles.ToolsPanelItem, shouldApplyPlaceholderStyles && styles.ToolsPanelItemPlaceholder, !shouldApplyPlaceholderStyles && className, firstItemStyle, lastItemStyle);
|
|
95
|
-
}, [isShown, shouldRenderPlaceholder, className, cx, firstDisplayedItem, lastDisplayedItem, __experimentalFirstVisibleItemClass, __experimentalLastVisibleItemClass, label]);
|
|
173
|
+
const shouldApplyPlaceholderStyles = shouldRenderPlaceholder && !isShown;
|
|
174
|
+
const classes = clsx(style_module_default["tools-panel-item"], shouldApplyPlaceholderStyles && style_module_default["tools-panel-item-placeholder"], !shouldApplyPlaceholderStyles && className, firstDisplayedItem === label && __experimentalFirstVisibleItemClass, lastDisplayedItem === label && __experimentalLastVisibleItemClass);
|
|
96
175
|
return {
|
|
97
176
|
...otherProps,
|
|
98
177
|
isShown,
|