@wordpress/components 40.0.0 → 40.1.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/CHANGELOG.md +40 -0
- package/CONTRIBUTING.md +2 -0
- package/build/border-box-control/border-box-control/component.cjs +37 -5
- package/build/border-box-control/border-box-control/component.cjs.map +3 -3
- package/build/border-box-control/border-box-control/hook.cjs +24 -3
- package/build/border-box-control/border-box-control/hook.cjs.map +3 -3
- package/build/border-box-control/border-box-control-linked-button/hook.cjs +2 -2
- package/build/border-box-control/border-box-control-linked-button/hook.cjs.map +2 -2
- package/build/border-box-control/border-box-control-split-controls/hook.cjs +2 -2
- package/build/border-box-control/border-box-control-split-controls/hook.cjs.map +2 -2
- package/build/border-box-control/border-box-control-visualizer/hook.cjs +2 -2
- package/build/border-box-control/border-box-control-visualizer/hook.cjs.map +2 -2
- package/build/color-palette/index.cjs +1 -1
- package/build/color-palette/index.cjs.map +2 -2
- package/build/composite/context.cjs +9 -2
- package/build/composite/context.cjs.map +2 -2
- package/build/composite/group-label.cjs +4 -0
- package/build/composite/group-label.cjs.map +2 -2
- package/build/composite/group.cjs +10 -2
- package/build/composite/group.cjs.map +2 -2
- package/build/composite/item.cjs +4 -0
- package/build/composite/item.cjs.map +3 -3
- package/build/context/context-system-provider.cjs +2 -5
- package/build/context/context-system-provider.cjs.map +3 -3
- package/build/context/use-context-system.cjs +7 -2
- package/build/context/use-context-system.cjs.map +2 -2
- package/build/disabled/index.cjs +1 -1
- package/build/disabled/index.cjs.map +2 -2
- package/build/draggable/index.cjs.map +1 -1
- package/build/form-token-field/index.cjs +1 -1
- package/build/form-token-field/index.cjs.map +2 -2
- package/build/icon/index.cjs +30 -12
- package/build/icon/index.cjs.map +2 -2
- package/build/input-control/styles/input-control-styles.cjs +42 -27
- package/build/input-control/styles/input-control-styles.cjs.map +2 -2
- package/build/item-group/context.cjs +1 -0
- package/build/item-group/context.cjs.map +2 -2
- package/build/item-group/item/component.cjs +12 -0
- package/build/item-group/item/component.cjs.map +3 -3
- package/build/item-group/item/hook.cjs +7 -6
- package/build/item-group/item/hook.cjs.map +2 -2
- package/build/item-group/item-group/component.cjs +1 -0
- package/build/item-group/item-group/component.cjs.map +2 -2
- package/build/item-group/item-group/hook.cjs +1 -1
- package/build/item-group/item-group/hook.cjs.map +2 -2
- package/build/progress-bar/index.cjs +1 -1
- package/build/progress-bar/index.cjs.map +2 -2
- package/build/resizable-box/index.cjs.map +1 -1
- package/build/snackbar/index.cjs +8 -5
- package/build/snackbar/index.cjs.map +2 -2
- package/build/textarea-control/index.cjs +1 -1
- package/build/textarea-control/index.cjs.map +2 -2
- package/build/toggle-group-control/context.cjs +8 -2
- package/build/toggle-group-control/context.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control/as-button-group.cjs +5 -2
- package/build/toggle-group-control/toggle-group-control/as-button-group.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control/as-radio-group.cjs +5 -2
- package/build/toggle-group-control/toggle-group-control/as-radio-group.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control/component.cjs +3 -1
- package/build/toggle-group-control/toggle-group-control/component.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control-option/component.cjs +2 -0
- package/build/toggle-group-control/toggle-group-control-option/component.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control-option-base/component.cjs +2 -1
- package/build/toggle-group-control/toggle-group-control-option-base/component.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control-option-icon/component.cjs +2 -0
- package/build/toggle-group-control/toggle-group-control-option-icon/component.cjs.map +2 -2
- package/build/tools-panel/tools-panel/hook.cjs +102 -106
- package/build/tools-panel/tools-panel/hook.cjs.map +2 -2
- package/build/tools-panel/tools-panel-item/hook.cjs +33 -33
- package/build/tools-panel/tools-panel-item/hook.cjs.map +2 -2
- package/build/tree-grid/cell.cjs +4 -0
- package/build/tree-grid/cell.cjs.map +2 -2
- package/build/tree-grid/roving-tab-index-item.cjs +5 -1
- package/build/tree-grid/roving-tab-index-item.cjs.map +2 -2
- package/build/tree-grid/row.cjs +6 -1
- package/build/tree-grid/row.cjs.map +2 -2
- package/build/tree-grid/use-validate-tree-grid-structure.cjs +81 -0
- package/build/tree-grid/use-validate-tree-grid-structure.cjs.map +7 -0
- package/build/utils/colors-values.cjs +3 -2
- package/build/utils/colors-values.cjs.map +2 -2
- package/build-module/border-box-control/border-box-control/component.mjs +38 -6
- package/build-module/border-box-control/border-box-control/component.mjs.map +2 -2
- package/build-module/border-box-control/border-box-control/hook.mjs +14 -3
- package/build-module/border-box-control/border-box-control/hook.mjs.map +2 -2
- package/build-module/border-box-control/border-box-control-linked-button/hook.mjs +2 -2
- package/build-module/border-box-control/border-box-control-linked-button/hook.mjs.map +2 -2
- package/build-module/border-box-control/border-box-control-split-controls/hook.mjs +2 -2
- package/build-module/border-box-control/border-box-control-split-controls/hook.mjs.map +2 -2
- package/build-module/border-box-control/border-box-control-visualizer/hook.mjs +2 -2
- package/build-module/border-box-control/border-box-control-visualizer/hook.mjs.map +2 -2
- package/build-module/color-palette/index.mjs +1 -1
- package/build-module/color-palette/index.mjs.map +2 -2
- package/build-module/composite/context.mjs +6 -1
- package/build-module/composite/context.mjs.map +2 -2
- package/build-module/composite/group-label.mjs +5 -1
- package/build-module/composite/group-label.mjs.map +2 -2
- package/build-module/composite/group.mjs +11 -3
- package/build-module/composite/group.mjs.map +2 -2
- package/build-module/composite/item.mjs +4 -0
- package/build-module/composite/item.mjs.map +2 -2
- package/build-module/context/context-system-provider.mjs +2 -5
- package/build-module/context/context-system-provider.mjs.map +3 -3
- package/build-module/context/use-context-system.mjs +7 -2
- package/build-module/context/use-context-system.mjs.map +2 -2
- package/build-module/disabled/index.mjs +1 -1
- package/build-module/disabled/index.mjs.map +2 -2
- package/build-module/draggable/index.mjs.map +1 -1
- package/build-module/form-token-field/index.mjs +1 -1
- package/build-module/form-token-field/index.mjs.map +2 -2
- package/build-module/icon/index.mjs +30 -12
- package/build-module/icon/index.mjs.map +2 -2
- package/build-module/input-control/styles/input-control-styles.mjs +42 -27
- package/build-module/input-control/styles/input-control-styles.mjs.map +2 -2
- package/build-module/item-group/context.mjs +1 -0
- package/build-module/item-group/context.mjs.map +2 -2
- package/build-module/item-group/item/component.mjs +12 -0
- package/build-module/item-group/item/component.mjs.map +2 -2
- package/build-module/item-group/item/hook.mjs +7 -6
- package/build-module/item-group/item/hook.mjs.map +2 -2
- package/build-module/item-group/item-group/component.mjs +1 -0
- package/build-module/item-group/item-group/component.mjs.map +2 -2
- package/build-module/item-group/item-group/hook.mjs +1 -1
- package/build-module/item-group/item-group/hook.mjs.map +2 -2
- package/build-module/progress-bar/index.mjs +1 -1
- package/build-module/progress-bar/index.mjs.map +2 -2
- package/build-module/resizable-box/index.mjs.map +1 -1
- package/build-module/snackbar/index.mjs +8 -5
- package/build-module/snackbar/index.mjs.map +2 -2
- package/build-module/textarea-control/index.mjs +1 -1
- package/build-module/textarea-control/index.mjs.map +2 -2
- package/build-module/toggle-group-control/context.mjs +8 -2
- package/build-module/toggle-group-control/context.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control/as-button-group.mjs +5 -2
- package/build-module/toggle-group-control/toggle-group-control/as-button-group.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.mjs +5 -2
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control/component.mjs +3 -1
- package/build-module/toggle-group-control/toggle-group-control/component.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control-option/component.mjs +2 -0
- package/build-module/toggle-group-control/toggle-group-control-option/component.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.mjs +2 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.mjs +2 -0
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.mjs.map +2 -2
- package/build-module/tools-panel/tools-panel/hook.mjs +103 -107
- package/build-module/tools-panel/tools-panel/hook.mjs.map +2 -2
- package/build-module/tools-panel/tools-panel-item/hook.mjs +35 -35
- package/build-module/tools-panel/tools-panel-item/hook.mjs.map +2 -2
- package/build-module/tree-grid/cell.mjs +5 -1
- package/build-module/tree-grid/cell.mjs.map +2 -2
- package/build-module/tree-grid/roving-tab-index-item.mjs +5 -1
- package/build-module/tree-grid/roving-tab-index-item.mjs.map +2 -2
- package/build-module/tree-grid/row.mjs +7 -2
- package/build-module/tree-grid/row.mjs.map +2 -2
- package/build-module/tree-grid/use-validate-tree-grid-structure.mjs +56 -0
- package/build-module/tree-grid/use-validate-tree-grid-structure.mjs.map +7 -0
- package/build-module/utils/colors-values.mjs +3 -2
- package/build-module/utils/colors-values.mjs.map +2 -2
- package/build-style/style-rtl.css +27 -85
- package/build-style/style.css +27 -85
- package/build-types/border-box-control/border-box-control/component.d.ts +4 -0
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +4 -2
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-box-control/types.d.ts +6 -2
- package/build-types/border-box-control/types.d.ts.map +1 -1
- package/build-types/composite/context.d.ts +2 -0
- package/build-types/composite/context.d.ts.map +1 -1
- package/build-types/composite/group-label.d.ts.map +1 -1
- package/build-types/composite/group.d.ts.map +1 -1
- package/build-types/composite/item.d.ts.map +1 -1
- package/build-types/composite/types.d.ts +1 -1
- package/build-types/context/context-system-provider.d.ts +8 -6
- package/build-types/context/context-system-provider.d.ts.map +1 -1
- package/build-types/context/use-context-system.d.ts.map +1 -1
- package/build-types/icon/index.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/item-group/context.d.ts.map +1 -1
- package/build-types/item-group/item/component.d.ts.map +1 -1
- package/build-types/item-group/item/hook.d.ts +1 -1
- package/build-types/item-group/item/hook.d.ts.map +1 -1
- package/build-types/item-group/item-group/component.d.ts.map +1 -1
- package/build-types/item-group/types.d.ts +4 -0
- package/build-types/item-group/types.d.ts.map +1 -1
- package/build-types/popover/types.d.ts +6 -2
- package/build-types/popover/types.d.ts.map +1 -1
- package/build-types/snackbar/index.d.ts.map +1 -1
- package/build-types/toggle-group-control/context.d.ts +2 -2
- package/build-types/toggle-group-control/context.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts.map +1 -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/component.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control-option/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/toggle-group-control-option-icon/component.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/types.d.ts +12 -3
- package/build-types/toggle-group-control/types.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +4 -4
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +52 -9
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/tree-grid/cell.d.ts.map +1 -1
- package/build-types/tree-grid/roving-tab-index-item.d.ts.map +1 -1
- package/build-types/tree-grid/row.d.ts.map +1 -1
- package/build-types/tree-grid/use-validate-tree-grid-structure.d.ts +2 -0
- package/build-types/tree-grid/use-validate-tree-grid-structure.d.ts.map +1 -0
- package/build-types/utils/colors-values.d.ts.map +1 -1
- package/emotion-to-scss-modules.md +149 -0
- package/package.json +28 -27
- package/src/alignment-matrix-control/test/{index.tsx → index.jsdom.test.tsx} +5 -4
- package/src/angle-picker-control/style.module.scss +1 -1
- package/src/autocomplete/test/get-autocomplete-match.ts +2 -1
- package/src/autocomplete/test/{index.tsx → index.jsdom.test.tsx} +2 -1
- package/src/badge/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/base-control/stories/index.story.tsx +2 -2
- package/src/base-control/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/border-box-control/border-box-control/README.md +5 -3
- package/src/border-box-control/border-box-control/component.tsx +83 -15
- package/src/border-box-control/border-box-control/hook.ts +19 -1
- package/src/border-box-control/stories/index.story.tsx +10 -0
- package/src/border-box-control/style.module.scss +34 -3
- package/src/border-box-control/test/{index.tsx → index.jsdom.test.tsx} +138 -2
- package/src/border-box-control/test/utils.ts +11 -0
- package/src/border-box-control/types.ts +6 -2
- package/src/border-control/test/{index.js → index.jsdom.test.tsx} +44 -24
- package/src/box-control/test/{index.tsx → index.jsdom.test.tsx} +6 -3
- package/src/button/style.scss +0 -6
- package/src/button/test/{index.tsx → index.jsdom.test.tsx} +6 -2
- package/src/checkbox-control/stories/index.story.tsx +1 -1
- package/src/checkbox-control/style.scss +2 -2
- package/src/checkbox-control/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +10 -7
- package/src/checkbox-control/test/{index.tsx → index.jsdom.test.tsx} +4 -1
- package/src/circular-option-picker/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/color-indicator/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +2 -2
- package/src/color-indicator/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/color-palette/index.tsx +1 -1
- package/src/color-palette/test/{index.tsx → index.jsdom.test.tsx} +25 -22
- package/src/color-palette/test/{utils.ts → utils.jsdom.test.ts} +1 -0
- package/src/combobox-control/test/{index.tsx → index.jsdom.test.tsx} +12 -7
- package/src/composite/README.md +1 -1
- package/src/composite/context.tsx +6 -0
- package/src/composite/group-label.tsx +8 -1
- package/src/composite/group.tsx +9 -2
- package/src/composite/item.tsx +6 -0
- package/src/composite/legacy/test/{index.tsx → index.jsdom.test.tsx} +6 -13
- package/src/composite/test/{index.tsx → index.jsdom.test.tsx} +60 -17
- package/src/composite/types.ts +1 -1
- package/src/confirm-dialog/test/{index.tsx → index.jsdom.test.tsx} +16 -14
- package/src/content-editable-control/test/{index.tsx → index.jsdom.test.tsx} +4 -3
- package/src/context/{context-system-provider.js → context-system-provider.tsx} +19 -5
- package/src/context/stories/{ComponentsProvider.stories.jsx → ComponentsProvider.stories.tsx} +2 -2
- package/src/context/test/context-connect.tsx +1 -2
- package/src/context/test/{context-system-provider.js → context-system-provider.jsdom.test.tsx} +93 -51
- package/src/context/test/wordpress-component.tsx +1 -2
- package/src/context/use-context-system.js +13 -4
- package/src/custom-gradient-picker/gradient-bar/test/{utils.ts → utils.jsdom.test.ts} +6 -5
- package/src/custom-gradient-picker/test/serializer.ts +1 -0
- package/src/custom-select-control-v2/test/{index.tsx → index.jsdom.test.tsx} +4 -1
- package/src/date-time/date-picker/test/{index.tsx → index.jsdom.test.tsx} +6 -3
- package/src/date-time/date-picker/test/{use-lilius.ts → use-lilius.jsdom.test.ts} +1 -0
- package/src/date-time/date-time/test/{index.tsx → index.jsdom.test.tsx} +20 -11
- package/src/date-time/test/utils.test.ts +9 -0
- package/src/date-time/time-picker/test/{index.tsx → index.jsdom.test.tsx} +37 -27
- package/src/date-time/time-picker/time-input/test/{index.tsx → index.jsdom.test.tsx} +8 -3
- package/src/disabled/index.tsx +7 -7
- package/src/disabled/test/{index.tsx → index.jsdom.test.tsx} +26 -0
- package/src/draggable/index.tsx +1 -1
- package/src/draggable/style.module.scss +1 -1
- package/src/dropdown/style.module.scss +2 -2
- package/src/dropdown/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/dropdown-menu/test/{index.tsx → index.jsdom.test.tsx} +5 -4
- package/src/duotone-picker/test/{custom-duotone-bar.tsx → custom-duotone-bar.jsdom.test.tsx} +11 -8
- package/src/duotone-picker/test/{index.tsx → index.jsdom.test.tsx} +11 -10
- package/src/external-link/test/{index.tsx → index.jsdom.test.tsx} +5 -4
- package/src/focal-point-picker/test/{index.tsx → index.jsdom.test.tsx} +12 -9
- package/src/focal-point-picker/test/{media.tsx → media.jsdom.test.tsx} +1 -0
- package/src/font-size-picker/test/{font-size-picker-select.tsx → font-size-picker-select.jsdom.test.tsx} +19 -16
- package/src/font-size-picker/test/{font-size-picker-toggle-group.tsx → font-size-picker-toggle-group.jsdom.test.tsx} +13 -11
- package/src/font-size-picker/test/{index.tsx → index.jsdom.test.tsx} +19 -14
- package/src/font-size-picker/test/utils.ts +1 -0
- package/src/form-toggle/style.scss +1 -1
- package/src/form-toggle/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +4 -4
- package/src/form-toggle/test/{index.tsx → index.jsdom.test.tsx} +2 -1
- package/src/form-token-field/index.tsx +1 -1
- package/src/form-token-field/test/{index.tsx → index.jsdom.test.tsx} +86 -44
- package/src/gradient-picker/test/{index.tsx → index.jsdom.test.tsx} +12 -9
- package/src/guide/test/{index.tsx → index.jsdom.test.tsx} +4 -2
- package/src/h-stack/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +4 -4
- package/src/h-stack/test/{index.tsx → index.jsdom.test.tsx} +3 -0
- package/src/higher-order/with-fallback-styles/test/{index.tsx → index.jsdom.test.tsx} +3 -2
- package/src/higher-order/with-filters/test/__snapshots__/index.jsdom.test.tsx.snap +87 -0
- package/src/higher-order/with-filters/test/{index.tsx → index.jsdom.test.tsx} +6 -5
- package/src/higher-order/with-focus-outside/test/{index.tsx → index.jsdom.test.tsx} +2 -1
- package/src/higher-order/with-focus-return/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/higher-order/with-notices/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/higher-order/with-spoken-messages/test/{index.tsx → index.jsdom.test.tsx} +3 -2
- package/src/icon/index.tsx +28 -12
- package/src/icon/test/{index.tsx → index.jsdom.test.tsx} +66 -0
- package/src/input-control/styles/input-control-styles.tsx +38 -7
- package/src/input-control/test/{index.js → index.jsdom.test.tsx} +16 -10
- package/src/isolated-event-container/test/{index.tsx → index.jsdom.test.tsx} +4 -3
- package/src/item-group/context.ts +1 -0
- package/src/item-group/item/component.tsx +19 -1
- package/src/item-group/item/hook.ts +2 -3
- package/src/item-group/item-group/component.tsx +1 -0
- package/src/item-group/style.module.scss +1 -2
- package/src/item-group/test/__snapshots__/{index.js.snap → index.jsdom.test.tsx.snap} +9 -9
- package/src/item-group/test/{index.js → index.jsdom.test.tsx} +99 -2
- package/src/item-group/types.ts +4 -0
- package/src/keyboard-shortcuts/test/{index.tsx → index.jsdom.test.tsx} +5 -4
- package/src/menu/test/{index.tsx → index.jsdom.test.tsx} +67 -23
- package/src/menu-group/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/menu-item/test/__snapshots__/{index.js.snap → index.jsdom.test.tsx.snap} +5 -5
- package/src/menu-item/test/{index.js → index.jsdom.test.tsx} +1 -0
- package/src/modal/test/{aria-helper.ts → aria-helper.jsdom.test.ts} +1 -0
- package/src/modal/test/{index.tsx → index.jsdom.test.tsx} +9 -5
- package/src/navigable-container/test/{navigable-menu.tsx → navigable-menu.jsdom.test.tsx} +7 -5
- package/src/navigable-container/test/{tababble-container.tsx → tababble-container.jsdom.test.tsx} +5 -3
- package/src/navigator/test/{index.tsx → index.jsdom.test.tsx} +5 -2
- package/src/navigator/test/router.ts +1 -0
- package/src/notice/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +7 -4
- package/src/notice/test/{index.tsx → index.jsdom.test.tsx} +8 -4
- package/src/notice/test/{list.tsx → list.jsdom.test.tsx} +1 -0
- package/src/number-control/test/{index.tsx → index.jsdom.test.tsx} +9 -6
- package/src/palette-edit/test/{index.tsx → index.jsdom.test.tsx} +16 -13
- package/src/panel/test/__snapshots__/body.jsdom.test.tsx.snap +9 -0
- package/src/panel/test/__snapshots__/header.jsdom.test.tsx.snap +9 -0
- package/src/panel/test/__snapshots__/index.jsdom.test.tsx.snap +17 -0
- package/src/panel/test/__snapshots__/row.jsdom.test.tsx.snap +17 -0
- package/src/panel/test/{body.tsx → body.jsdom.test.tsx} +2 -1
- package/src/panel/test/{header.tsx → header.jsdom.test.tsx} +1 -0
- package/src/panel/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/panel/test/{row.tsx → row.jsdom.test.tsx} +1 -0
- package/src/placeholder/style.scss +0 -5
- package/src/placeholder/test/{index.tsx → index.jsdom.test.tsx} +19 -14
- package/src/popover/README.md +2 -2
- package/src/popover/test/{index.tsx → index.jsdom.test.tsx} +23 -0
- package/src/popover/types.ts +9 -3
- package/src/progress-bar/style.module.scss +9 -1
- package/src/query-controls/test/terms.ts +1 -0
- package/src/radio-control/test/{index.tsx → index.jsdom.test.tsx} +14 -11
- package/src/range-control/test/{index.tsx → index.jsdom.test.tsx} +10 -7
- package/src/resizable-box/index.tsx +1 -1
- package/src/sandbox/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/scroll-lock/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/shortcut/test/__snapshots__/index.jsdom.test.tsx.snap +15 -0
- package/src/shortcut/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/slot-fill/test/{index.js → index.jsdom.test.tsx} +4 -3
- package/src/slot-fill/test/{slot.js → slot.jsdom.test.tsx} +17 -9
- package/src/snackbar/index.tsx +10 -6
- package/src/snackbar/test/{index.tsx → index.jsdom.test.tsx} +41 -11
- package/src/snackbar/test/list.jsdom.test.tsx +100 -0
- package/src/style-provider/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/surface/style.module.scss +2 -2
- package/src/surface/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/tab-panel/style.scss +4 -23
- package/src/tab-panel/test/{index.tsx → index.jsdom.test.tsx} +22 -21
- package/src/tabs/test/{index.tsx → index.jsdom.test.tsx} +21 -19
- package/src/text-control/test/{text-control.tsx → text-control.jsdom.test.tsx} +1 -0
- package/src/text-highlight/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/textarea-control/style.module.scss +9 -4
- package/src/tip/style.scss +1 -1
- package/src/toggle-control/test/{index.tsx → index.jsdom.test.tsx} +4 -1
- package/src/toggle-group-control/context.ts +14 -5
- package/src/toggle-group-control/stories/index.story.tsx +15 -2
- package/src/toggle-group-control/test/{index.tsx → index.jsdom.test.tsx} +283 -9
- package/src/toggle-group-control/toggle-group-control/README.md +8 -5
- package/src/toggle-group-control/toggle-group-control/as-button-group.tsx +4 -0
- package/src/toggle-group-control/toggle-group-control/as-radio-group.tsx +4 -0
- package/src/toggle-group-control/toggle-group-control/component.tsx +2 -0
- package/src/toggle-group-control/toggle-group-control/style.module.scss +8 -2
- package/src/toggle-group-control/toggle-group-control-option/README.md +8 -5
- package/src/toggle-group-control/toggle-group-control-option/component.tsx +2 -0
- package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +4 -1
- package/src/toggle-group-control/toggle-group-control-option-icon/README.md +7 -0
- package/src/toggle-group-control/toggle-group-control-option-icon/component.tsx +2 -0
- package/src/toggle-group-control/types.ts +12 -3
- package/src/toolbar/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/toolbar/test/{toolbar-group.tsx → toolbar-group.jsdom.test.tsx} +2 -1
- package/src/tools-panel/test/{index.tsx → index.jsdom.test.tsx} +595 -47
- package/src/tools-panel/tools-panel/hook.ts +195 -180
- package/src/tools-panel/tools-panel-item/README.md +42 -1
- package/src/tools-panel/tools-panel-item/hook.ts +97 -69
- package/src/tools-panel/types.ts +54 -9
- package/src/tooltip/test/{index.tsx → index.jsdom.test.tsx} +5 -3
- package/src/tree-grid/cell.tsx +6 -2
- package/src/tree-grid/roving-tab-index-item.tsx +7 -3
- package/src/tree-grid/row.tsx +8 -2
- package/src/tree-grid/test/__snapshots__/{cell.tsx.snap → cell.jsdom.test.tsx.snap} +2 -2
- package/src/tree-grid/test/__snapshots__/index.jsdom.test.tsx.snap +3 -0
- package/src/tree-grid/test/__snapshots__/roving-tab-index-item.jsdom.test.tsx.snap +27 -0
- package/src/tree-grid/test/__snapshots__/roving-tab-index.jsdom.test.tsx.snap +9 -0
- package/src/tree-grid/test/__snapshots__/{row.tsx.snap → row.jsdom.test.tsx.snap} +9 -5
- package/src/tree-grid/test/cell.jsdom.test.tsx +149 -0
- package/src/tree-grid/test/{index.tsx → index.jsdom.test.tsx} +9 -7
- package/src/tree-grid/test/{roving-tab-index-item.tsx → roving-tab-index-item.jsdom.test.tsx} +4 -1
- package/src/tree-grid/test/{roving-tab-index.tsx → roving-tab-index.jsdom.test.tsx} +1 -0
- package/src/tree-grid/test/row.jsdom.test.tsx +132 -0
- package/src/tree-grid/use-validate-tree-grid-structure.ts +104 -0
- package/src/truncate/style.module.scss +0 -1
- package/src/truncate/test/{index.tsx → index.jsdom.test.tsx} +1 -0
- package/src/unit-control/test/{index.tsx → index.jsdom.test.tsx} +22 -19
- package/src/unit-control/test/utils.ts +1 -0
- package/src/utils/colors-values.js +5 -4
- package/src/utils/hooks/test/{use-controlled-state.js → use-controlled-state.jsdom.test.tsx} +22 -7
- package/src/utils/hooks/test/{use-controlled-value.js → use-controlled-value.jsdom.test.tsx} +6 -3
- package/src/utils/hooks/test/{use-cx.js → use-cx.jsdom.test.tsx} +8 -5
- package/src/utils/test/colors.js +1 -0
- package/src/utils/test/{get-node-text.js → get-node-text.tsx} +1 -0
- package/src/utils/test/math.js +1 -0
- package/src/utils/test/rtl.js +1 -0
- package/src/utils/test/space.js +1 -0
- package/src/utils/test/strings.js +1 -0
- package/src/utils/test/unit-values.js +1 -0
- package/src/v-stack/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +4 -4
- package/src/v-stack/test/{index.tsx → index.jsdom.test.tsx} +3 -0
- package/src/validated-form-controls/style.scss +11 -15
- package/src/validated-form-controls/test/{content-editable-control.tsx → content-editable-control.jsdom.test.tsx} +1 -1
- package/src/validated-form-controls/test/{custom-select-control.tsx → custom-select-control.jsdom.test.tsx} +3 -0
- package/src/validated-form-controls/test/{input-control.tsx → input-control.jsdom.test.tsx} +3 -0
- package/src/validated-form-controls/test/{range-control.tsx → range-control.jsdom.test.tsx} +3 -0
- package/src/validated-form-controls/test/{textarea-control.tsx → textarea-control.jsdom.test.tsx} +1 -0
- package/src/view/test/__snapshots__/{index.js.snap → index.jsdom.test.tsx.snap} +7 -7
- package/src/view/test/{index.js → index.jsdom.test.tsx} +7 -2
- package/src/context/test/__snapshots__/context-system-provider.js.snap +0 -35
- package/src/higher-order/with-filters/test/__snapshots__/index.tsx.snap +0 -87
- package/src/panel/test/__snapshots__/body.tsx.snap +0 -9
- package/src/panel/test/__snapshots__/header.tsx.snap +0 -9
- package/src/panel/test/__snapshots__/index.tsx.snap +0 -17
- package/src/panel/test/__snapshots__/row.tsx.snap +0 -17
- package/src/shortcut/test/__snapshots__/index.tsx.snap +0 -15
- package/src/snackbar/test/list.tsx +0 -39
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +0 -359
- package/src/tree-grid/test/__snapshots__/index.tsx.snap +0 -3
- package/src/tree-grid/test/__snapshots__/roving-tab-index-item.tsx.snap +0 -27
- package/src/tree-grid/test/__snapshots__/roving-tab-index.tsx.snap +0 -9
- package/src/tree-grid/test/cell.tsx +0 -46
- package/src/tree-grid/test/row.tsx +0 -37
- /package/src/card/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/card/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/color-picker/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/custom-gradient-picker/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/custom-select-control/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/custom-select-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/divider/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/elevation/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/elevation/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/flex/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/flex/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/form-file-upload/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/grid/test/{grid.tsx → grid.jsdom.test.tsx} +0 -0
- /package/src/heading/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/heading/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/input-control/test/__snapshots__/{index.js.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/progress-bar/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/resizable-box/resize-tooltip/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/resizable-box/resize-tooltip/test/{label.tsx → label.jsdom.test.tsx} +0 -0
- /package/src/scrollable/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/search-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/select-control/test/__snapshots__/{select-control.tsx.snap → select-control.jsdom.test.tsx.snap} +0 -0
- /package/src/select-control/test/{select-control.tsx → select-control.jsdom.test.tsx} +0 -0
- /package/src/slot-fill/test/__snapshots__/{slot.js.snap → slot.jsdom.test.tsx.snap} +0 -0
- /package/src/spacer/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/spacer/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/text/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/text/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/utils/test/{polymorphic-element.tsx → polymorphic-element.jsdom.test.tsx} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/tools-panel/tools-panel-item/hook.ts", "../../../../style-runtime/src/index.ts", "../../../src/tools-panel/style.module.scss"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { usePrevious } from '@wordpress/compose';\nimport { useCallback, useEffect, useLayoutEffect } from '@wordpress/element';\nimport styles from '../style.module.scss';\nimport { useToolsPanelContext } from '../context';\nimport { useContextSystem } from '../../context';\nconst noop = () => {};\nexport function useToolsPanelItem(props) {\n const {\n className,\n hasValue,\n isShownByDefault = false,\n label,\n panelId,\n resetAllFilter = noop,\n onDeselect,\n onSelect,\n ...otherProps\n } = useContextSystem(props, 'ToolsPanelItem');\n const {\n panelId: currentPanelId,\n menuItems,\n registerResetAllFilter,\n deregisterResetAllFilter,\n registerPanelItem,\n deregisterPanelItem,\n flagItemCustomization,\n isResetting,\n shouldRenderPlaceholderItems: shouldRenderPlaceholder,\n firstDisplayedItem,\n lastDisplayedItem,\n __experimentalFirstVisibleItemClass,\n __experimentalLastVisibleItemClass\n } = useToolsPanelContext();\n\n // hasValue is a new function on every render, so do not add it as a\n // dependency to the useCallback hook! If needed, we should use a ref.\n const hasValueCallback = useCallback(hasValue, [panelId]);\n // resetAllFilter is a new function on every render, so do not add it as a\n // dependency to the useCallback hook! If needed, we should use a ref.\n const resetAllFilterCallback = useCallback(resetAllFilter, [panelId]);\n const previousPanelId = usePrevious(currentPanelId);\n const hasMatchingPanel = currentPanelId === panelId || currentPanelId === null;\n\n // Registering the panel item allows the panel to include it in its\n // automatically generated menu and determine its initial checked status.\n //\n // This is performed in a layout effect to ensure that the panel item\n // is registered before it is rendered preventing a rendering glitch.\n // See: https://github.com/WordPress/gutenberg/issues/56470\n useLayoutEffect(() => {\n if (hasMatchingPanel && previousPanelId !== null) {\n registerPanelItem({\n hasValue: hasValueCallback,\n isShownByDefault,\n label,\n panelId\n });\n }\n return () => {\n if (previousPanelId === null && !!currentPanelId || currentPanelId === panelId) {\n deregisterPanelItem(label);\n }\n };\n }, [currentPanelId, hasMatchingPanel, isShownByDefault, label, hasValueCallback, panelId, previousPanelId, registerPanelItem, deregisterPanelItem]);\n useEffect(() => {\n if (hasMatchingPanel) {\n registerResetAllFilter(resetAllFilterCallback);\n }\n return () => {\n if (hasMatchingPanel) {\n deregisterResetAllFilter(resetAllFilterCallback);\n }\n };\n }, [registerResetAllFilter, deregisterResetAllFilter, resetAllFilterCallback, hasMatchingPanel]);\n\n // Note: `label` is used as a key when building menu item state in\n // `ToolsPanel`.\n const menuGroup = isShownByDefault ? 'default' : 'optional';\n const isMenuItemChecked = menuItems?.[menuGroup]?.[label];\n const wasMenuItemChecked = usePrevious(isMenuItemChecked);\n const isRegistered = menuItems?.[menuGroup]?.[label] !== undefined;\n const isValueSet = hasValue();\n // Notify the panel when an item's value has changed except for optional\n // items without value because the item should not cause itself to hide.\n useEffect(() => {\n if (!isShownByDefault && !isValueSet) {\n return;\n }\n flagItemCustomization(isValueSet, label, menuGroup);\n }, [isValueSet, menuGroup, label, flagItemCustomization, isShownByDefault]);\n\n // Determine if the panel item's corresponding menu is being toggled and\n // trigger appropriate callback if it is.\n useEffect(() => {\n // We check whether this item is currently registered as items rendered\n // via fills can persist through the parent panel being remounted.\n // See: https://github.com/WordPress/gutenberg/pull/45673\n if (!isRegistered || isResetting || !hasMatchingPanel) {\n return;\n }\n if (isMenuItemChecked && !isValueSet && !wasMenuItemChecked) {\n onSelect?.();\n }\n if (!isMenuItemChecked && isValueSet && wasMenuItemChecked) {\n onDeselect?.();\n }\n }, [hasMatchingPanel, isMenuItemChecked, isRegistered, isResetting, isValueSet, wasMenuItemChecked, onSelect, onDeselect]);\n\n // The item is shown if it is a default control regardless of whether it\n // has a value. Optional items are shown when they are checked or have\n // a value.\n const isShown = isShownByDefault ? menuItems?.[menuGroup]?.[label] !== undefined : isMenuItemChecked;\n const shouldApplyPlaceholderStyles = shouldRenderPlaceholder && !isShown;\n const classes = clsx(styles['tools-panel-item'], shouldApplyPlaceholderStyles && styles['tools-panel-item-placeholder'], !shouldApplyPlaceholderStyles && className, firstDisplayedItem === label && __experimentalFirstVisibleItemClass, lastDisplayedItem === label && __experimentalLastVisibleItemClass);\n return {\n ...otherProps,\n isShown,\n shouldRenderPlaceholder,\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\":\"f135b96aa96ca6bb__reset-label\",\"default-controls-item\":\"_69b138dfa5570d9c__default-controls-item\"};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { useEvent } from '@wordpress/compose';\nimport { useCallback, useEffect, useLayoutEffect, useRef } from '@wordpress/element';\nimport styles from '../style.module.scss';\nimport { useToolsPanelContext } from '../context';\nimport { useContextSystem } from '../../context';\nconst noop = () => {};\nexport function useToolsPanelItem(props) {\n const {\n className,\n defaultShown,\n hasValue,\n isShownByDefault = false,\n label,\n panelId,\n resetAllFilter = noop,\n onDeselect,\n onSelect,\n onShownChange,\n ...otherProps\n } = useContextSystem(props, 'ToolsPanelItem');\n const {\n panelId: currentPanelId,\n menuItems,\n registerPanelItem,\n deregisterPanelItem,\n flagItemCustomization,\n isResetting,\n shouldRenderPlaceholderItems: shouldRenderPlaceholder,\n firstDisplayedItem,\n lastDisplayedItem,\n __experimentalFirstVisibleItemClass,\n __experimentalLastVisibleItemClass\n } = useToolsPanelContext();\n\n // `hasValue` is a new function every render. It can't use `useEvent`\n // because the panel calls it while deriving the menu during render, which\n // `useEvent` forbids, so it stays keyed on the panel it was captured for.\n const hasValueCallback = useCallback(hasValue, [panelId]);\n // `resetAllFilter` only runs from the reset handler, so a stable identity\n // that always sees the latest props is both safe and more correct than\n // freezing it per panel.\n const resetAllFilterCallback = useEvent(resetAllFilter);\n\n // `defaultShown` seeds an item's visibility when it registers, and is\n // deliberately not reactive. Holding it in a ref keeps it out of the\n // registration effect below, so a change on its own cannot deregister and\n // re-register the item, which would discard the visibility the user chose\n // from the menu.\n //\n // The ref still tracks the latest value, so that a re-registration caused\n // by something else, such as `panelId` changing, seeds from the current\n // preference rather than a stale one.\n const defaultShownRef = useRef(defaultShown);\n // Declared before the registration effect below so that it has already\n // run by the time that effect reads the ref in the same commit.\n useLayoutEffect(() => {\n defaultShownRef.current = defaultShown;\n });\n\n // `onShownChange` is a new function every render. `useEvent` gives the item\n // a stable callback to register, while the panel still invokes the latest.\n const onShownChangeCallback = useEvent(onShownChange);\n\n // A panel spanning a multi-selection has no id of its own, so every item\n // belongs to it.\n const hasMatchingPanel = currentPanelId === panelId || currentPanelId === null;\n\n // A layout effect so the item is registered before it renders, avoiding a\n // glitch, and so a whole panel's worth of registrations land in one commit\n // for React to batch.\n // See: https://github.com/WordPress/gutenberg/issues/56470\n useLayoutEffect(() => {\n if (!hasMatchingPanel) {\n return;\n }\n const item = {\n defaultShown: defaultShownRef.current,\n hasValue: hasValueCallback,\n isShownByDefault,\n label,\n onShownChange: onShownChangeCallback,\n panelId,\n resetAllFilter: resetAllFilterCallback\n };\n registerPanelItem(item);\n\n // Passing the registration back lets the panel ignore this cleanup if\n // a replacement has already claimed the label, which happens when a\n // panel switches while its items arrive through a Slot.\n return () => {\n deregisterPanelItem(label, item);\n };\n }, [deregisterPanelItem, hasMatchingPanel, hasValueCallback, isShownByDefault, label, onShownChangeCallback, panelId, registerPanelItem, resetAllFilterCallback]);\n const menuGroup = isShownByDefault ? 'default' : 'optional';\n const isMenuItemChecked = menuItems?.[menuGroup]?.[label];\n const isRegistered = isMenuItemChecked !== undefined;\n // Tracks the effect below rather than the render, so renders that leave\n // the checked state alone can't desync it.\n const wasMenuItemCheckedRef = useRef(undefined);\n const isValueSet = hasValue();\n\n // An optional item losing its value must not hide itself, so only default\n // items report a value going away. Items belonging to another panel stay\n // silent or they would leave an orphaned entry in this panel's menu.\n //\n // Shares the layout phase with registration above so it runs against an\n // already registered item and batches with it.\n useLayoutEffect(() => {\n if (!hasMatchingPanel || !isShownByDefault && !isValueSet) {\n return;\n }\n flagItemCustomization(isValueSet, label);\n }, [hasMatchingPanel, isValueSet, label, flagItemCustomization, isShownByDefault]);\n\n // Passive so consumer callbacks don't run before the browser has painted.\n useEffect(() => {\n const wasMenuItemChecked = wasMenuItemCheckedRef.current;\n wasMenuItemCheckedRef.current = isMenuItemChecked;\n\n // An item has no menu entry until it registers, so the first time\n // through there is no previous checked state. Items that register\n // already shown, because they have a value or `defaultShown` was set,\n // must not look as though the user just selected them.\n const wasRegistered = wasMenuItemChecked !== undefined;\n\n // Items rendered via fills can outlive a remount of the panel they\n // belong to, leaving them unregistered.\n // See: https://github.com/WordPress/gutenberg/pull/45673\n if (!isRegistered || !wasRegistered || isResetting || !hasMatchingPanel) {\n return;\n }\n if (isMenuItemChecked && !isValueSet && !wasMenuItemChecked) {\n onSelect?.();\n }\n if (!isMenuItemChecked && isValueSet && wasMenuItemChecked) {\n onDeselect?.();\n }\n }, [hasMatchingPanel, isMenuItemChecked, isRegistered, isResetting, isValueSet, onSelect, onDeselect]);\n\n // A default control shows whether or not it has a value; an optional one\n // shows once checked.\n const isShown = isShownByDefault ? isRegistered : isMenuItemChecked;\n const shouldApplyPlaceholderStyles = shouldRenderPlaceholder && !isShown;\n const classes = clsx(styles['tools-panel-item'], shouldApplyPlaceholderStyles && styles['tools-panel-item-placeholder'], !shouldApplyPlaceholderStyles && className, firstDisplayedItem === label && __experimentalFirstVisibleItemClass, lastDisplayedItem === label && __experimentalLastVisibleItemClass);\n return {\n ...otherProps,\n isShown,\n shouldRenderPlaceholder,\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\":\"f135b96aa96ca6bb__reset-label\",\"default-controls-item\":\"_69b138dfa5570d9c__default-controls-item\"};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,qBAAyB;AACzB,qBAAgE;;;ACFhE,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACpB,QAAM,cAAc;AACpB,MAAI,YAAY,kBAAkB;AAChC,WAAO,YAAY;AAAA,EACrB;AACA,cAAY,mBAAmB;AAAA,IAC7B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC9B;AACA,MAAI,OAAO,aAAa,aAAa;AACnC,qBAAiB,QAAQ;AAAA,EAC3B;AACA,SAAO,YAAY;AACrB;AAUA,SAAS,0BAA0B,gBAAgB,MAAM;AACvD,MAAI,CAAC,eAAe,MAAM;AACxB,WAAO;AAAA,EACT;AACA,aAAW,SAAS,eAAe,KAAK,iBAAiB,SAAS,oBAAoB,GAAG,GAAG;AAC1F,QAAI,MAAM,aAAa,oBAAoB,MAAM,MAAM;AACrD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAUA,SAAS,YAAY,gBAAgB,MAAM,KAAK;AAC9C,MAAI,CAAC,eAAe,MAAM;AACxB;AAAA,EACF;AACA,QAAM,UAAU,WAAW;AAC3B,MAAI,iBAAiB,QAAQ,eAAe,IAAI,cAAc;AAC9D,MAAI,CAAC,gBAAgB;AACnB,qBAAiB,oBAAI,IAAI;AACzB,YAAQ,eAAe,IAAI,gBAAgB,cAAc;AAAA,EAC3D;AACA,MAAI,eAAe,IAAI,IAAI,GAAG;AAC5B;AAAA,EACF;AAKA,MAAI,0BAA0B,gBAAgB,IAAI,GAAG;AACnD,mBAAe,IAAI,IAAI;AACvB;AAAA,EACF;AACA,QAAM,QAAQ,eAAe,cAAc,OAAO;AAClD,QAAM,aAAa,sBAAsB,IAAI;AAC7C,QAAM,YAAY,eAAe,eAAe,GAAG,CAAC;AACpD,iBAAe,KAAK,YAAY,KAAK;AACrC,iBAAe,IAAI,IAAI;AACzB;AAaO,SAAS,iBAAiB,gBAAgB;AAC/C,QAAM,UAAU,WAAW;AAC3B,UAAQ,UAAU,IAAI,iBAAiB,QAAQ,UAAU,IAAI,cAAc,KAAK,KAAK,CAAC;AACtF,aAAW,CAAC,MAAM,GAAG,KAAK,QAAQ,QAAQ;AACxC,gBAAY,gBAAgB,MAAM,GAAG;AAAA,EACvC;AACA,SAAO,MAAM;AACX,UAAM,QAAQ,QAAQ,UAAU,IAAI,cAAc;AAClD,QAAI,UAAU,QAAW;AACvB;AAAA,IACF;AACA,QAAI,SAAS,GAAG;AACd,cAAQ,UAAU,OAAO,cAAc;AACvC;AAAA,IACF;AACA,YAAQ,UAAU,IAAI,gBAAgB,QAAQ,CAAC;AAAA,EACjD;AACF;AAaO,SAAS,cAAc,MAAM,KAAK;AACvC,QAAM,UAAU,WAAW;AAC3B,UAAQ,OAAO,IAAI,MAAM,GAAG;AAC5B,aAAW,kBAAkB,QAAQ,UAAU,KAAK,GAAG;AACrD,gBAAY,gBAAgB,MAAM,GAAG;AAAA,EACvC;AACF;;;AChIA,IAAI,OAAO,YAAY,eAAe,QAAQ,IAAI,aAAa,QAAQ;AACtE,gBAAc,cAAc,qrEAAqrE;AACltE;AACA,IAAO,uBAAQ,EAAC,eAAc,kCAAiC,kCAAiC,qDAAoD,oCAAmC,uDAAsD,sBAAqB,yCAAwC,uBAAsB,yCAAwC,oBAAmB,uCAAsC,gCAA+B,mDAAkD,iBAAgB,mCAAkC,eAAc,iCAAgC,yBAAwB,2CAA0C;;;AFAppB,qBAAqC;AACrC,IAAAA,kBAAiC;AACjC,IAAM,OAAO,MAAM;AAAC;AACb,SAAS,kBAAkB,OAAO;AACvC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,IACnB;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,QAAI,kCAAiB,OAAO,gBAAgB;AAC5C,QAAM;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,8BAA8B;AAAA,IAC9B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,qCAAqB;AAKzB,QAAM,uBAAmB,4BAAY,UAAU,CAAC,OAAO,CAAC;AAIxD,QAAM,6BAAyB,yBAAS,cAAc;AAWtD,QAAM,sBAAkB,uBAAO,YAAY;AAG3C,sCAAgB,MAAM;AACpB,oBAAgB,UAAU;AAAA,EAC5B,CAAC;AAID,QAAM,4BAAwB,yBAAS,aAAa;AAIpD,QAAM,mBAAmB,mBAAmB,WAAW,mBAAmB;AAM1E,sCAAgB,MAAM;AACpB,QAAI,CAAC,kBAAkB;AACrB;AAAA,IACF;AACA,UAAM,OAAO;AAAA,MACX,cAAc,gBAAgB;AAAA,MAC9B,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA,eAAe;AAAA,MACf;AAAA,MACA,gBAAgB;AAAA,IAClB;AACA,sBAAkB,IAAI;AAKtB,WAAO,MAAM;AACX,0BAAoB,OAAO,IAAI;AAAA,IACjC;AAAA,EACF,GAAG,CAAC,qBAAqB,kBAAkB,kBAAkB,kBAAkB,OAAO,uBAAuB,SAAS,mBAAmB,sBAAsB,CAAC;AAChK,QAAM,YAAY,mBAAmB,YAAY;AACjD,QAAM,oBAAoB,YAAY,SAAS,IAAI,KAAK;AACxD,QAAM,eAAe,sBAAsB;AAG3C,QAAM,4BAAwB,uBAAO,MAAS;AAC9C,QAAM,aAAa,SAAS;AAQ5B,sCAAgB,MAAM;AACpB,QAAI,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,YAAY;AACzD;AAAA,IACF;AACA,0BAAsB,YAAY,KAAK;AAAA,EACzC,GAAG,CAAC,kBAAkB,YAAY,OAAO,uBAAuB,gBAAgB,CAAC;AAGjF,gCAAU,MAAM;AACd,UAAM,qBAAqB,sBAAsB;AACjD,0BAAsB,UAAU;AAMhC,UAAM,gBAAgB,uBAAuB;AAK7C,QAAI,CAAC,gBAAgB,CAAC,iBAAiB,eAAe,CAAC,kBAAkB;AACvE;AAAA,IACF;AACA,QAAI,qBAAqB,CAAC,cAAc,CAAC,oBAAoB;AAC3D,iBAAW;AAAA,IACb;AACA,QAAI,CAAC,qBAAqB,cAAc,oBAAoB;AAC1D,mBAAa;AAAA,IACf;AAAA,EACF,GAAG,CAAC,kBAAkB,mBAAmB,cAAc,aAAa,YAAY,UAAU,UAAU,CAAC;AAIrG,QAAM,UAAU,mBAAmB,eAAe;AAClD,QAAM,+BAA+B,2BAA2B,CAAC;AACjE,QAAM,cAAU,YAAAC,SAAK,qBAAO,kBAAkB,GAAG,gCAAgC,qBAAO,8BAA8B,GAAG,CAAC,gCAAgC,WAAW,uBAAuB,SAAS,qCAAqC,sBAAsB,SAAS,kCAAkC;AAC3S,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA,WAAW;AAAA,EACb;AACF;",
|
|
6
6
|
"names": ["import_context", "clsx"]
|
|
7
7
|
}
|
package/build/tree-grid/cell.cjs
CHANGED
|
@@ -36,13 +36,17 @@ __export(cell_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(cell_exports);
|
|
37
37
|
var import_element = require("@wordpress/element");
|
|
38
38
|
var import_item = __toESM(require("./item.cjs"));
|
|
39
|
+
var import_use_validate_tree_grid_structure = require("./use-validate-tree-grid-structure.cjs");
|
|
39
40
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
41
|
function UnforwardedTreeGridCell({
|
|
41
42
|
children,
|
|
42
43
|
withoutGridItem = false,
|
|
43
44
|
...props
|
|
44
45
|
}, ref) {
|
|
46
|
+
const cellRef = (0, import_element.useRef)(null);
|
|
47
|
+
(0, import_use_validate_tree_grid_structure.useValidateTreeGridStructure)("TreeGridCell", cellRef);
|
|
45
48
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
|
|
49
|
+
ref: cellRef,
|
|
46
50
|
...props,
|
|
47
51
|
role: "gridcell",
|
|
48
52
|
children: withoutGridItem ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tree-grid/cell.tsx"],
|
|
4
|
-
"sourcesContent": ["import { forwardRef } from '@wordpress/element';\nimport TreeGridItem from './item';\nimport { Fragment as _Fragment, jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnforwardedTreeGridCell({\n children,\n withoutGridItem = false,\n ...props\n}, ref) {\n return /*#__PURE__*/_jsx(\"td\", {\n ...props,\n role: \"gridcell\",\n children: withoutGridItem ? /*#__PURE__*/_jsx(_Fragment, {\n children: typeof children === 'function' ? children({\n ...props,\n ref\n }) : children\n }) : /*#__PURE__*/_jsx(TreeGridItem, {\n ref: ref,\n children: children\n })\n });\n}\n\n/**\n * `TreeGridCell` is used to create a tree hierarchy.\n * It is not a visually styled component, but instead helps with adding\n * keyboard navigation and roving tab index behaviors to tree grid structures.\n *\n * @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html}\n */\nexport const TreeGridCell = forwardRef(UnforwardedTreeGridCell);\nTreeGridCell.displayName = 'TreeGridCell';\nexport default TreeGridCell;"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { forwardRef, useRef } from '@wordpress/element';\nimport TreeGridItem from './item';\nimport { useValidateTreeGridStructure } from './use-validate-tree-grid-structure';\nimport { Fragment as _Fragment, jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnforwardedTreeGridCell({\n children,\n withoutGridItem = false,\n ...props\n}, ref) {\n const cellRef = useRef(null);\n useValidateTreeGridStructure('TreeGridCell', cellRef);\n return /*#__PURE__*/_jsx(\"td\", {\n ref: cellRef,\n ...props,\n role: \"gridcell\",\n children: withoutGridItem ? /*#__PURE__*/_jsx(_Fragment, {\n children: typeof children === 'function' ? children({\n ...props,\n ref\n }) : children\n }) : /*#__PURE__*/_jsx(TreeGridItem, {\n ref: ref,\n children: children\n })\n });\n}\n\n/**\n * `TreeGridCell` is used to create a tree hierarchy.\n * It is not a visually styled component, but instead helps with adding\n * keyboard navigation and roving tab index behaviors to tree grid structures.\n *\n * @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html}\n */\nexport const TreeGridCell = forwardRef(UnforwardedTreeGridCell);\nTreeGridCell.displayName = 'TreeGridCell';\nexport default TreeGridCell;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAmC;AACnC,kBAAyB;AACzB,8CAA6C;AAC7C,yBAAmD;AACnD,SAAS,wBAAwB;AAAA,EAC/B;AAAA,EACA,kBAAkB;AAAA,EAClB,GAAG;AACL,GAAG,KAAK;AACN,QAAM,cAAU,uBAAO,IAAI;AAC3B,4EAA6B,gBAAgB,OAAO;AACpD,SAAoB,uCAAAA,KAAK,MAAM;AAAA,IAC7B,KAAK;AAAA,IACL,GAAG;AAAA,IACH,MAAM;AAAA,IACN,UAAU,kBAA+B,uCAAAA,KAAK,mBAAAC,UAAW;AAAA,MACvD,UAAU,OAAO,aAAa,aAAa,SAAS;AAAA,QAClD,GAAG;AAAA,QACH;AAAA,MACF,CAAC,IAAI;AAAA,IACP,CAAC,IAAiB,uCAAAD,KAAK,YAAAE,SAAc;AAAA,MACnC;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;AASO,IAAM,mBAAe,2BAAW,uBAAuB;AAC9D,aAAa,cAAc;AAC3B,IAAO,eAAQ;",
|
|
6
6
|
"names": ["_jsx", "_Fragment", "TreeGridItem"]
|
|
7
7
|
}
|
|
@@ -34,10 +34,14 @@ var RovingTabIndexItem = (0, import_element.forwardRef)(function UnforwardedRovi
|
|
|
34
34
|
}, forwardedRef) {
|
|
35
35
|
const localRef = (0, import_element.useRef)(null);
|
|
36
36
|
const ref = forwardedRef || localRef;
|
|
37
|
+
const context = (0, import_roving_tab_index_context.useRovingTabIndexContext)();
|
|
38
|
+
if (!context) {
|
|
39
|
+
throw new Error("TreeGridItem can only be rendered inside a TreeGrid component.");
|
|
40
|
+
}
|
|
37
41
|
const {
|
|
38
42
|
lastFocusedElement,
|
|
39
43
|
setLastFocusedElement
|
|
40
|
-
} =
|
|
44
|
+
} = context;
|
|
41
45
|
let tabIndex;
|
|
42
46
|
if (lastFocusedElement) {
|
|
43
47
|
tabIndex = lastFocusedElement === // TODO: The original implementation simply used `ref.current` here, assuming
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tree-grid/roving-tab-index-item.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useRef, forwardRef } from '@wordpress/element';\nimport { useRovingTabIndexContext } from './roving-tab-index-context';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport const RovingTabIndexItem = forwardRef(function UnforwardedRovingTabIndexItem({\n children,\n as: Component,\n ...props\n}, forwardedRef) {\n const localRef = useRef(null);\n const ref = forwardedRef || localRef;\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAmC;AACnC,sCAAyC;AACzC,yBAA4B;AACrB,IAAM,yBAAqB,2BAAW,SAAS,8BAA8B;AAAA,EAClF;AAAA,EACA,IAAI;AAAA,EACJ,GAAG;AACL,GAAG,cAAc;AACf,QAAM,eAAW,uBAAO,IAAI;AAC5B,QAAM,MAAM,gBAAgB;
|
|
4
|
+
"sourcesContent": ["import { useRef, forwardRef } from '@wordpress/element';\nimport { useRovingTabIndexContext } from './roving-tab-index-context';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport const RovingTabIndexItem = forwardRef(function UnforwardedRovingTabIndexItem({\n children,\n as: Component,\n ...props\n}, forwardedRef) {\n const localRef = useRef(null);\n const ref = forwardedRef || localRef;\n const context = useRovingTabIndexContext();\n if (!context) {\n throw new Error('TreeGridItem can only be rendered inside a TreeGrid component.');\n }\n const {\n lastFocusedElement,\n setLastFocusedElement\n } = context;\n let tabIndex;\n if (lastFocusedElement) {\n tabIndex = lastFocusedElement === (\n // TODO: The original implementation simply used `ref.current` here, assuming\n // that a forwarded ref would always be an object, which is not necessarily true.\n // This workaround maintains the original runtime behavior in a type-safe way,\n // but should be revisited.\n 'current' in ref ? ref.current : undefined) ? 0 : -1;\n }\n const onFocus = event => setLastFocusedElement?.(event.target);\n const allProps = {\n ref,\n tabIndex,\n onFocus,\n ...props\n };\n if (typeof children === 'function') {\n return children(allProps);\n }\n if (!Component) {\n return null;\n }\n return /*#__PURE__*/_jsx(Component, {\n ...allProps,\n children: children\n });\n});\nRovingTabIndexItem.displayName = 'RovingTabIndexItem';\nexport default RovingTabIndexItem;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAmC;AACnC,sCAAyC;AACzC,yBAA4B;AACrB,IAAM,yBAAqB,2BAAW,SAAS,8BAA8B;AAAA,EAClF;AAAA,EACA,IAAI;AAAA,EACJ,GAAG;AACL,GAAG,cAAc;AACf,QAAM,eAAW,uBAAO,IAAI;AAC5B,QAAM,MAAM,gBAAgB;AAC5B,QAAM,cAAU,0DAAyB;AACzC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,gEAAgE;AAAA,EAClF;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACF,IAAI;AACJ,MAAI;AACJ,MAAI,oBAAoB;AACtB,eAAW;AAAA;AAAA;AAAA;AAAA,KAKX,aAAa,MAAM,IAAI,UAAU,UAAa,IAAI;AAAA,EACpD;AACA,QAAM,UAAU,WAAS,wBAAwB,MAAM,MAAM;AAC7D,QAAM,WAAW;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AACA,MAAI,OAAO,aAAa,YAAY;AAClC,WAAO,SAAS,QAAQ;AAAA,EAC1B;AACA,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AACA,SAAoB,uCAAAA,KAAK,WAAW;AAAA,IAClC,GAAG;AAAA,IACH;AAAA,EACF,CAAC;AACH,CAAC;AACD,mBAAmB,cAAc;AACjC,IAAO,gCAAQ;",
|
|
6
6
|
"names": ["_jsx"]
|
|
7
7
|
}
|
package/build/tree-grid/row.cjs
CHANGED
|
@@ -24,7 +24,9 @@ __export(row_exports, {
|
|
|
24
24
|
default: () => row_default
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(row_exports);
|
|
27
|
+
var import_compose = require("@wordpress/compose");
|
|
27
28
|
var import_element = require("@wordpress/element");
|
|
29
|
+
var import_use_validate_tree_grid_structure = require("./use-validate-tree-grid-structure.cjs");
|
|
28
30
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
31
|
function UnforwardedTreeGridRow({
|
|
30
32
|
children,
|
|
@@ -34,9 +36,12 @@ function UnforwardedTreeGridRow({
|
|
|
34
36
|
isExpanded,
|
|
35
37
|
...props
|
|
36
38
|
}, ref) {
|
|
39
|
+
const rowRef = (0, import_element.useRef)(null);
|
|
40
|
+
const refs = (0, import_compose.useMergeRefs)([rowRef, ref]);
|
|
41
|
+
(0, import_use_validate_tree_grid_structure.useValidateTreeGridStructure)("TreeGridRow", rowRef);
|
|
37
42
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", {
|
|
38
43
|
...props,
|
|
39
|
-
ref,
|
|
44
|
+
ref: refs,
|
|
40
45
|
role: "row",
|
|
41
46
|
"aria-level": level,
|
|
42
47
|
"aria-posinset": positionInSet,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tree-grid/row.tsx"],
|
|
4
|
-
"sourcesContent": ["import { forwardRef } from '@wordpress/element';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnforwardedTreeGridRow({\n children,\n level,\n positionInSet,\n setSize,\n isExpanded,\n ...props\n}, ref) {\n return /*#__PURE__*/_jsx(\"tr\", {\n ...props,\n ref:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useRef } from '@wordpress/element';\nimport { useValidateTreeGridStructure } from './use-validate-tree-grid-structure';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnforwardedTreeGridRow({\n children,\n level,\n positionInSet,\n setSize,\n isExpanded,\n ...props\n}, ref) {\n const rowRef = useRef(null);\n const refs = useMergeRefs([rowRef, ref]);\n useValidateTreeGridStructure('TreeGridRow', rowRef);\n return /*#__PURE__*/_jsx(\"tr\", {\n ...props,\n ref: refs,\n role: \"row\",\n \"aria-level\": level,\n \"aria-posinset\": positionInSet,\n \"aria-setsize\": setSize,\n \"aria-expanded\": isExpanded,\n children: children\n });\n}\n\n/**\n * `TreeGridRow` is used to create a tree hierarchy.\n * It is not a visually styled component, but instead helps with adding\n * keyboard navigation and roving tab index behaviors to tree grid structures.\n *\n * @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html}\n */\nexport const TreeGridRow = forwardRef(UnforwardedTreeGridRow);\nTreeGridRow.displayName = 'TreeGridRow';\nexport default TreeGridRow;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA6B;AAC7B,qBAAmC;AACnC,8CAA6C;AAC7C,yBAA4B;AAC5B,SAAS,uBAAuB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,KAAK;AACN,QAAM,aAAS,uBAAO,IAAI;AAC1B,QAAM,WAAO,6BAAa,CAAC,QAAQ,GAAG,CAAC;AACvC,4EAA6B,eAAe,MAAM;AAClD,SAAoB,uCAAAA,KAAK,MAAM;AAAA,IAC7B,GAAG;AAAA,IACH,KAAK;AAAA,IACL,MAAM;AAAA,IACN,cAAc;AAAA,IACd,iBAAiB;AAAA,IACjB,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB;AAAA,EACF,CAAC;AACH;AASO,IAAM,kBAAc,2BAAW,sBAAsB;AAC5D,YAAY,cAAc;AAC1B,IAAO,cAAQ;",
|
|
6
6
|
"names": ["_jsx"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/components/src/tree-grid/use-validate-tree-grid-structure.ts
|
|
21
|
+
var use_validate_tree_grid_structure_exports = {};
|
|
22
|
+
__export(use_validate_tree_grid_structure_exports, {
|
|
23
|
+
useValidateTreeGridStructure: () => useValidateTreeGridStructure
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(use_validate_tree_grid_structure_exports);
|
|
26
|
+
var import_element = require("@wordpress/element");
|
|
27
|
+
var ROW_SELECTOR = 'tr:not([role]), [role="row"]';
|
|
28
|
+
var TREE_GRID_SELECTOR = '[role="treegrid"]';
|
|
29
|
+
function getAriaOwners(element) {
|
|
30
|
+
if (!element.id) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const escapedId = element.id.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
34
|
+
return Array.from(element.ownerDocument.querySelectorAll(`[aria-owns~="${escapedId}"]`));
|
|
35
|
+
}
|
|
36
|
+
function isContainedInOrOwnedBy(element, selector, visited = /* @__PURE__ */ new Set()) {
|
|
37
|
+
if (visited.has(element)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
visited.add(element);
|
|
41
|
+
if (element.parentElement?.closest(selector)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
const hasValidOwner = getAriaOwners(element).some((owner) => owner.matches(selector) || isContainedInOrOwnedBy(owner, selector, visited));
|
|
45
|
+
if (hasValidOwner) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return element.parentElement ? isContainedInOrOwnedBy(element.parentElement, selector, visited) : false;
|
|
49
|
+
}
|
|
50
|
+
function isOwnedByRowInTreeGrid(element, visited = /* @__PURE__ */ new Set()) {
|
|
51
|
+
if (visited.has(element)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
visited.add(element);
|
|
55
|
+
const hasValidOwner = getAriaOwners(element).some((owner) => {
|
|
56
|
+
const row = owner.matches(ROW_SELECTOR) ? owner : owner.closest(ROW_SELECTOR);
|
|
57
|
+
return row ? isContainedInOrOwnedBy(row, TREE_GRID_SELECTOR) : isOwnedByRowInTreeGrid(owner, visited);
|
|
58
|
+
});
|
|
59
|
+
if (hasValidOwner) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return element.parentElement ? isOwnedByRowInTreeGrid(element.parentElement, visited) : false;
|
|
63
|
+
}
|
|
64
|
+
function useValidateTreeGridStructure(componentName, elementRef) {
|
|
65
|
+
(0, import_element.useEffect)(() => {
|
|
66
|
+
const element = elementRef.current;
|
|
67
|
+
if (!element) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const row = element.parentElement?.closest(ROW_SELECTOR);
|
|
71
|
+
const hasValidStructure = componentName === "TreeGridRow" ? isContainedInOrOwnedBy(element, TREE_GRID_SELECTOR) : row && isContainedInOrOwnedBy(row, TREE_GRID_SELECTOR) || isOwnedByRowInTreeGrid(element);
|
|
72
|
+
if (!hasValidStructure) {
|
|
73
|
+
throw new Error(componentName === "TreeGridRow" ? 'TreeGridRow must be rendered inside an element with role="treegrid".' : 'TreeGridCell must be rendered as a cell in a row that belongs to an element with role="treegrid".');
|
|
74
|
+
}
|
|
75
|
+
}, [componentName, elementRef]);
|
|
76
|
+
}
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
useValidateTreeGridStructure
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=use-validate-tree-grid-structure.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/tree-grid/use-validate-tree-grid-structure.ts"],
|
|
4
|
+
"sourcesContent": ["import { useEffect } from '@wordpress/element';\nconst ROW_SELECTOR = 'tr:not([role]), [role=\"row\"]';\nconst TREE_GRID_SELECTOR = '[role=\"treegrid\"]';\nfunction getAriaOwners(element) {\n if (!element.id) {\n return [];\n }\n const escapedId = element.id.replaceAll('\\\\', '\\\\\\\\').replaceAll('\"', '\\\\\"');\n return Array.from(element.ownerDocument.querySelectorAll(`[aria-owns~=\"${escapedId}\"]`));\n}\nfunction isContainedInOrOwnedBy(element, selector, visited = new Set()) {\n if (visited.has(element)) {\n return false;\n }\n visited.add(element);\n if (element.parentElement?.closest(selector)) {\n return true;\n }\n const hasValidOwner = getAriaOwners(element).some(owner => owner.matches(selector) || isContainedInOrOwnedBy(owner, selector, visited));\n if (hasValidOwner) {\n return true;\n }\n return element.parentElement ? isContainedInOrOwnedBy(element.parentElement, selector, visited) : false;\n}\nfunction isOwnedByRowInTreeGrid(element, visited = new Set()) {\n if (visited.has(element)) {\n return false;\n }\n visited.add(element);\n const hasValidOwner = getAriaOwners(element).some(owner => {\n const row = owner.matches(ROW_SELECTOR) ? owner : owner.closest(ROW_SELECTOR);\n return row ? isContainedInOrOwnedBy(row, TREE_GRID_SELECTOR) : isOwnedByRowInTreeGrid(owner, visited);\n });\n if (hasValidOwner) {\n return true;\n }\n return element.parentElement ? isOwnedByRowInTreeGrid(element.parentElement, visited) : false;\n}\nexport function useValidateTreeGridStructure(componentName, elementRef) {\n useEffect(() => {\n const element = elementRef.current;\n if (!element) {\n return;\n }\n const row = element.parentElement?.closest(ROW_SELECTOR);\n const hasValidStructure = componentName === 'TreeGridRow' ? isContainedInOrOwnedBy(element, TREE_GRID_SELECTOR) : row && isContainedInOrOwnedBy(row, TREE_GRID_SELECTOR) || isOwnedByRowInTreeGrid(element);\n if (!hasValidStructure) {\n throw new Error(componentName === 'TreeGridRow' ? 'TreeGridRow must be rendered inside an element with role=\"treegrid\".' : 'TreeGridCell must be rendered as a cell in a row that belongs to an element with role=\"treegrid\".');\n }\n }, [componentName, elementRef]);\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0B;AAC1B,IAAM,eAAe;AACrB,IAAM,qBAAqB;AAC3B,SAAS,cAAc,SAAS;AAC9B,MAAI,CAAC,QAAQ,IAAI;AACf,WAAO,CAAC;AAAA,EACV;AACA,QAAM,YAAY,QAAQ,GAAG,WAAW,MAAM,MAAM,EAAE,WAAW,KAAK,KAAK;AAC3E,SAAO,MAAM,KAAK,QAAQ,cAAc,iBAAiB,gBAAgB,SAAS,IAAI,CAAC;AACzF;AACA,SAAS,uBAAuB,SAAS,UAAU,UAAU,oBAAI,IAAI,GAAG;AACtE,MAAI,QAAQ,IAAI,OAAO,GAAG;AACxB,WAAO;AAAA,EACT;AACA,UAAQ,IAAI,OAAO;AACnB,MAAI,QAAQ,eAAe,QAAQ,QAAQ,GAAG;AAC5C,WAAO;AAAA,EACT;AACA,QAAM,gBAAgB,cAAc,OAAO,EAAE,KAAK,WAAS,MAAM,QAAQ,QAAQ,KAAK,uBAAuB,OAAO,UAAU,OAAO,CAAC;AACtI,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AACA,SAAO,QAAQ,gBAAgB,uBAAuB,QAAQ,eAAe,UAAU,OAAO,IAAI;AACpG;AACA,SAAS,uBAAuB,SAAS,UAAU,oBAAI,IAAI,GAAG;AAC5D,MAAI,QAAQ,IAAI,OAAO,GAAG;AACxB,WAAO;AAAA,EACT;AACA,UAAQ,IAAI,OAAO;AACnB,QAAM,gBAAgB,cAAc,OAAO,EAAE,KAAK,WAAS;AACzD,UAAM,MAAM,MAAM,QAAQ,YAAY,IAAI,QAAQ,MAAM,QAAQ,YAAY;AAC5E,WAAO,MAAM,uBAAuB,KAAK,kBAAkB,IAAI,uBAAuB,OAAO,OAAO;AAAA,EACtG,CAAC;AACD,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AACA,SAAO,QAAQ,gBAAgB,uBAAuB,QAAQ,eAAe,OAAO,IAAI;AAC1F;AACO,SAAS,6BAA6B,eAAe,YAAY;AACtE,gCAAU,MAAM;AACd,UAAM,UAAU,WAAW;AAC3B,QAAI,CAAC,SAAS;AACZ;AAAA,IACF;AACA,UAAM,MAAM,QAAQ,eAAe,QAAQ,YAAY;AACvD,UAAM,oBAAoB,kBAAkB,gBAAgB,uBAAuB,SAAS,kBAAkB,IAAI,OAAO,uBAAuB,KAAK,kBAAkB,KAAK,uBAAuB,OAAO;AAC1M,QAAI,CAAC,mBAAmB;AACtB,YAAM,IAAI,MAAM,kBAAkB,gBAAgB,yEAAyE,mGAAmG;AAAA,IAChO;AAAA,EACF,GAAG,CAAC,eAAe,UAAU,CAAC;AAChC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -73,8 +73,9 @@ var UI = {
|
|
|
73
73
|
border: THEME.gray[600],
|
|
74
74
|
borderHover: THEME.gray[700],
|
|
75
75
|
borderFocus: THEME.accent,
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
// The gray ramp above has no disabled step to map these through.
|
|
77
|
+
borderDisabled: `var(--wpds-color-stroke-interactive-neutral-disabled, #dbdbdb)`,
|
|
78
|
+
textDisabled: `var(--wpds-color-foreground-interactive-neutral-disabled, #8d8d8d)`,
|
|
78
79
|
// Matches @wordpress/base-styles
|
|
79
80
|
darkGrayPlaceholder: `color-mix(in srgb, ${THEME.foreground}, transparent 38%)`,
|
|
80
81
|
lightGrayPlaceholder: `color-mix(in srgb, ${THEME.background}, transparent 35%)`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/colors-values.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @wordpress/no-ds-tokens -- This file is the JS counterpart of\n theme-variables.scss and the package's single mapping to the design system.\n The rule guards against bare `--wpds-*` references, which the build can't\n inject fallbacks into for Emotion/JS files; here every reference carries an\n explicit fallback, so that concern doesn't apply.\n\n IMPORTANT: because this file's source contains `--wpds-` text, the\n design-system fallback build plugin claims it (it matches any file whose\n source includes `--wpds-`, comments included) and, in doing so, displaces\n the Emotion transform for this file. That is harmless ONLY because this file\n holds plain value constants and no Emotion `css`/styled component selectors.\n Do not add any here: a co-located component selector would silently fail to\n compile and break the build, with no lint signal (see #79245). Keep this\n file selector-free — define styles elsewhere and consume these constants. */\n\nconst white = '#fff';\n\n// Matches the grays in @wordpress/base-styles\nconst GRAY = {\n\t900: '#1e1e1e',\n\t800: '#2f2f2f',\n\t/** Meets 4.6:1 text contrast against white. */\n\t700: '#757575',\n\t/** Meets 3:1 UI or large text contrast against white. */\n\t600: '#949494',\n\t400: '#ccc',\n\t/** Used for most borders. */\n\t300: '#ddd',\n\t/** Used sparingly for light borders. */\n\t200: '#e0e0e0',\n\t/** Used for light gray backgrounds. */\n\t100: '#f0f0f0',\n};\n\n// Matches @wordpress/base-styles\nconst ALERT = {\n\tyellow: '#f0b849',\n\tred: '#d94f4f',\n\tgreen: '#4ab866',\n};\n\n// Should match packages/components/src/utils/theme-variables.scss.\n//\n// Mirrors the Sass structure: each non-accent value resolves through a design\n// system (`--wpds-*`) token, then a hardcoded fallback. The hardcoded values\n// match what the design-system fallback plugin injects into the Sass version,\n// so JS behaves consistently with the Sass variables. Keep both the token\n// references and the fallbacks in sync with the Sass version.\nconst THEME = {\n\taccent: `var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9))`,\n\taccentDarker10: `var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #2145e6))`,\n\taccentDarker20: `var(--wp-components-color-accent-darker-20, var(--wp-admin-theme-color-darker-20, #183ad6))`,\n\t/** Used when placing text on the accent color. */\n\taccentInverted: `var(--wp-components-color-accent-inverted, var(--wpds-color-foreground-interactive-brand-strong, #fff))`,\n\n\tbackground: `var(--wp-components-color-background, var(--wpds-color-background-surface-neutral-strong, #fff))`,\n\n\tforeground: `var(--wp-components-color-foreground, var(--wpds-color-foreground-content-neutral, #1e1e1e))`,\n\t/** Used when placing text on the foreground color. */\n\tforegroundInverted: `var(--wp-components-color-foreground-inverted, var(--wpds-color-background-surface-neutral, #fcfcfc))`,\n\n\tgray: {\n\t\t/** @deprecated Use `COLORS.theme.foreground` instead. */\n\t\t900: `var(--wp-components-color-foreground, var(--wpds-color-foreground-content-neutral, #1e1e1e))`,\n\t\t800: `var(--wp-components-color-gray-800, var(--wpds-color-foreground-content-neutral, #1e1e1e))`,\n\t\t700: `var(--wp-components-color-gray-700, var(--wpds-color-foreground-content-neutral-weak, #707070))`,\n\t\t600: `var(--wp-components-color-gray-600, var(--wpds-color-stroke-interactive-neutral, #8d8d8d))`,\n\t\t400: `var(--wp-components-color-gray-400, var(--wpds-color-stroke-interactive-neutral, #8d8d8d))`,\n\t\t300: `var(--wp-components-color-gray-300, var(--wpds-color-stroke-surface-neutral, #dbdbdb))`,\n\t\t200: `var(--wp-components-color-gray-200, var(--wpds-color-stroke-surface-neutral, #dbdbdb))`,\n\t\t100: `var(--wp-components-color-gray-100, var(--wpds-color-background-surface-neutral, #fcfcfc))`,\n\t},\n};\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,IAAM,QAAQ;AAGd,IAAM,OAAO;AAAA,EACZ,KAAK;AAAA,EACL,KAAK;AAAA;AAAA,EAEL,KAAK;AAAA;AAAA,EAEL,KAAK;AAAA,EACL,KAAK;AAAA;AAAA,EAEL,KAAK;AAAA;AAAA,EAEL,KAAK;AAAA;AAAA,EAEL,KAAK;AACN;AAGA,IAAM,QAAQ;AAAA,EACb,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,OAAO;AACR;AASA,IAAM,QAAQ;AAAA,EACb,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,gBAAgB;AAAA;AAAA,EAEhB,gBAAgB;AAAA,EAEhB,YAAY;AAAA,EAEZ,YAAY;AAAA;AAAA,EAEZ,oBAAoB;AAAA,EAEpB,MAAM;AAAA;AAAA,IAEL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,EACN;AACD;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @wordpress/no-ds-tokens -- This file is the JS counterpart of\n theme-variables.scss and the package's single mapping to the design system.\n The rule guards against bare `--wpds-*` references, which the build can't\n inject fallbacks into for Emotion/JS files; here every reference carries an\n explicit fallback, so that concern doesn't apply.\n\n IMPORTANT: because this file's source contains `--wpds-` text, the\n design-system fallback build plugin claims it (it matches any file whose\n source includes `--wpds-`, comments included) and, in doing so, displaces\n the Emotion transform for this file. That is harmless ONLY because this file\n holds plain value constants and no Emotion `css`/styled component selectors.\n Do not add any here: a co-located component selector would silently fail to\n compile and break the build, with no lint signal (see #79245). Keep this\n file selector-free — define styles elsewhere and consume these constants. */\n\nconst white = '#fff';\n\n// Matches the grays in @wordpress/base-styles\nconst GRAY = {\n\t900: '#1e1e1e',\n\t800: '#2f2f2f',\n\t/** Meets 4.6:1 text contrast against white. */\n\t700: '#757575',\n\t/** Meets 3:1 UI or large text contrast against white. */\n\t600: '#949494',\n\t400: '#ccc',\n\t/** Used for most borders. */\n\t300: '#ddd',\n\t/** Used sparingly for light borders. */\n\t200: '#e0e0e0',\n\t/** Used for light gray backgrounds. */\n\t100: '#f0f0f0',\n};\n\n// Matches @wordpress/base-styles\nconst ALERT = {\n\tyellow: '#f0b849',\n\tred: '#d94f4f',\n\tgreen: '#4ab866',\n};\n\n// Should match packages/components/src/utils/theme-variables.scss.\n//\n// Mirrors the Sass structure: each non-accent value resolves through a design\n// system (`--wpds-*`) token, then a hardcoded fallback. The hardcoded values\n// match what the design-system fallback plugin injects into the Sass version,\n// so JS behaves consistently with the Sass variables. Keep both the token\n// references and the fallbacks in sync with the Sass version.\nconst THEME = {\n\taccent: `var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9))`,\n\taccentDarker10: `var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #2145e6))`,\n\taccentDarker20: `var(--wp-components-color-accent-darker-20, var(--wp-admin-theme-color-darker-20, #183ad6))`,\n\t/** Used when placing text on the accent color. */\n\taccentInverted: `var(--wp-components-color-accent-inverted, var(--wpds-color-foreground-interactive-brand-strong, #fff))`,\n\n\tbackground: `var(--wp-components-color-background, var(--wpds-color-background-surface-neutral-strong, #fff))`,\n\n\tforeground: `var(--wp-components-color-foreground, var(--wpds-color-foreground-content-neutral, #1e1e1e))`,\n\t/** Used when placing text on the foreground color. */\n\tforegroundInverted: `var(--wp-components-color-foreground-inverted, var(--wpds-color-background-surface-neutral, #fcfcfc))`,\n\n\tgray: {\n\t\t/** @deprecated Use `COLORS.theme.foreground` instead. */\n\t\t900: `var(--wp-components-color-foreground, var(--wpds-color-foreground-content-neutral, #1e1e1e))`,\n\t\t800: `var(--wp-components-color-gray-800, var(--wpds-color-foreground-content-neutral, #1e1e1e))`,\n\t\t700: `var(--wp-components-color-gray-700, var(--wpds-color-foreground-content-neutral-weak, #707070))`,\n\t\t600: `var(--wp-components-color-gray-600, var(--wpds-color-stroke-interactive-neutral, #8d8d8d))`,\n\t\t400: `var(--wp-components-color-gray-400, var(--wpds-color-stroke-interactive-neutral, #8d8d8d))`,\n\t\t300: `var(--wp-components-color-gray-300, var(--wpds-color-stroke-surface-neutral, #dbdbdb))`,\n\t\t200: `var(--wp-components-color-gray-200, var(--wpds-color-stroke-surface-neutral, #dbdbdb))`,\n\t\t100: `var(--wp-components-color-gray-100, var(--wpds-color-background-surface-neutral, #fcfcfc))`,\n\t},\n};\n\nconst UI = {\n\tbackground: THEME.background,\n\tbackgroundDisabled: THEME.gray[ 100 ],\n\tborder: THEME.gray[ 600 ],\n\tborderHover: THEME.gray[ 700 ],\n\tborderFocus: THEME.accent,\n\t// The gray ramp above has no disabled step to map these through.\n\tborderDisabled: `var(--wpds-color-stroke-interactive-neutral-disabled, #dbdbdb)`,\n\ttextDisabled: `var(--wpds-color-foreground-interactive-neutral-disabled, #8d8d8d)`,\n\n\t// Matches @wordpress/base-styles\n\tdarkGrayPlaceholder: `color-mix(in srgb, ${ THEME.foreground }, transparent 38%)`,\n\tlightGrayPlaceholder: `color-mix(in srgb, ${ THEME.background }, transparent 35%)`,\n};\n\n/* eslint-enable @wordpress/no-ds-tokens */\n\nexport const COLORS = Object.freeze( {\n\t/**\n\t * The main gray color object.\n\t *\n\t * @deprecated Use semantic aliases in `COLORS.ui` or theme-ready variables in `COLORS.theme.gray`.\n\t */\n\tgray: GRAY, // TODO: Stop exporting this when everything is migrated to `theme` or `ui`\n\t/**\n\t * @deprecated Prefer theme-ready variables in `COLORS.theme`.\n\t */\n\twhite,\n\talert: ALERT,\n\t/**\n\t * Theme-ready variables with fallbacks.\n\t *\n\t * Prefer semantic aliases in `COLORS.ui` when applicable.\n\t */\n\ttheme: THEME,\n\t/**\n\t * Semantic aliases (prefer these over raw variables when applicable).\n\t */\n\tui: UI,\n} );\n\nexport default COLORS;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,IAAM,QAAQ;AAGd,IAAM,OAAO;AAAA,EACZ,KAAK;AAAA,EACL,KAAK;AAAA;AAAA,EAEL,KAAK;AAAA;AAAA,EAEL,KAAK;AAAA,EACL,KAAK;AAAA;AAAA,EAEL,KAAK;AAAA;AAAA,EAEL,KAAK;AAAA;AAAA,EAEL,KAAK;AACN;AAGA,IAAM,QAAQ;AAAA,EACb,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,OAAO;AACR;AASA,IAAM,QAAQ;AAAA,EACb,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,gBAAgB;AAAA;AAAA,EAEhB,gBAAgB;AAAA,EAEhB,YAAY;AAAA,EAEZ,YAAY;AAAA;AAAA,EAEZ,oBAAoB;AAAA,EAEpB,MAAM;AAAA;AAAA,IAEL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,EACN;AACD;AAEA,IAAM,KAAK;AAAA,EACV,YAAY,MAAM;AAAA,EAClB,oBAAoB,MAAM,KAAM,GAAI;AAAA,EACpC,QAAQ,MAAM,KAAM,GAAI;AAAA,EACxB,aAAa,MAAM,KAAM,GAAI;AAAA,EAC7B,aAAa,MAAM;AAAA;AAAA,EAEnB,gBAAgB;AAAA,EAChB,cAAc;AAAA;AAAA,EAGd,qBAAqB,sBAAuB,MAAM,UAAW;AAAA,EAC7D,sBAAsB,sBAAuB,MAAM,UAAW;AAC/D;AAIO,IAAM,SAAS,OAAO,OAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpC,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAIN;AAAA,EACA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMP,OAAO;AAAA;AAAA;AAAA;AAAA,EAIP,IAAI;AACL,CAAE;AAEF,IAAO,wBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// packages/components/src/border-box-control/border-box-control/component.tsx
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
3
|
import { useMemo, useState } from "@wordpress/element";
|
|
4
|
-
import { useMergeRefs } from "@wordpress/compose";
|
|
4
|
+
import { useInstanceId, useMergeRefs } from "@wordpress/compose";
|
|
5
5
|
import BorderBoxControlLinkedButton from "../border-box-control-linked-button/index.mjs";
|
|
6
6
|
import BorderBoxControlSplitControls from "../border-box-control-split-controls/index.mjs";
|
|
7
7
|
import { BorderControl } from "../../border-control/index.mjs";
|
|
8
|
-
import
|
|
8
|
+
import BaseControl from "../../base-control/index.mjs";
|
|
9
|
+
import { Grid } from "../../grid/index.mjs";
|
|
9
10
|
import { View } from "../../view/index.mjs";
|
|
10
11
|
import { VisuallyHidden } from "../../visually-hidden/index.mjs";
|
|
11
12
|
import { contextConnect } from "../../context/index.mjs";
|
|
@@ -13,6 +14,7 @@ import { useBorderBoxControl } from "./hook.mjs";
|
|
|
13
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
15
|
var BorderLabel = (props) => {
|
|
15
16
|
const {
|
|
17
|
+
id,
|
|
16
18
|
label,
|
|
17
19
|
hideLabelFromVision
|
|
18
20
|
} = props;
|
|
@@ -20,9 +22,11 @@ var BorderLabel = (props) => {
|
|
|
20
22
|
return null;
|
|
21
23
|
}
|
|
22
24
|
return hideLabelFromVision ? /* @__PURE__ */ _jsx(VisuallyHidden, {
|
|
23
|
-
as: "
|
|
25
|
+
as: "span",
|
|
26
|
+
id,
|
|
24
27
|
children: label
|
|
25
|
-
}) : /* @__PURE__ */ _jsx(
|
|
28
|
+
}) : /* @__PURE__ */ _jsx(BaseControl.VisualLabel, {
|
|
29
|
+
id,
|
|
26
30
|
children: label
|
|
27
31
|
});
|
|
28
32
|
};
|
|
@@ -35,6 +39,8 @@ var UnconnectedBorderBoxControl = (props, forwardedRef) => {
|
|
|
35
39
|
enableAlpha,
|
|
36
40
|
enableStyle,
|
|
37
41
|
hasMixedBorders,
|
|
42
|
+
hasVisibleLabel,
|
|
43
|
+
headerClassName,
|
|
38
44
|
hideLabelFromVision,
|
|
39
45
|
isLinked,
|
|
40
46
|
label,
|
|
@@ -48,8 +54,12 @@ var UnconnectedBorderBoxControl = (props, forwardedRef) => {
|
|
|
48
54
|
toggleLinked,
|
|
49
55
|
wrapperClassName,
|
|
50
56
|
__experimentalIsRenderedInSidebar,
|
|
57
|
+
"aria-label": ariaLabel,
|
|
58
|
+
"aria-labelledby": ariaLabelledBy,
|
|
51
59
|
...otherProps
|
|
52
60
|
} = useBorderBoxControl(props);
|
|
61
|
+
const generatedLabelId = useInstanceId(BorderBoxControl, "border-box-control-label");
|
|
62
|
+
const labelId = label && !ariaLabel && !ariaLabelledBy ? generatedLabelId : void 0;
|
|
53
63
|
const [popoverAnchor, setPopoverAnchor] = useState(null);
|
|
54
64
|
const popoverProps = useMemo(() => popoverPlacement ? {
|
|
55
65
|
placement: popoverPlacement,
|
|
@@ -60,9 +70,31 @@ var UnconnectedBorderBoxControl = (props, forwardedRef) => {
|
|
|
60
70
|
const mergedRef = useMergeRefs([setPopoverAnchor, forwardedRef]);
|
|
61
71
|
return /* @__PURE__ */ _jsxs(View, {
|
|
62
72
|
className,
|
|
73
|
+
role: label || ariaLabel || ariaLabelledBy ? "group" : void 0,
|
|
74
|
+
"aria-label": ariaLabel,
|
|
75
|
+
"aria-labelledby": ariaLabelledBy ?? labelId,
|
|
63
76
|
...otherProps,
|
|
64
77
|
ref: mergedRef,
|
|
65
|
-
children: [
|
|
78
|
+
children: [hasVisibleLabel ? (
|
|
79
|
+
// The toggle shares the label's row so that it lines up with
|
|
80
|
+
// the equivalent toggle on sibling controls, e.g. the border
|
|
81
|
+
// radius one.
|
|
82
|
+
/* @__PURE__ */ _jsxs(Grid, {
|
|
83
|
+
className: headerClassName,
|
|
84
|
+
columns: 2,
|
|
85
|
+
templateColumns: "1fr min-content",
|
|
86
|
+
alignment: "center",
|
|
87
|
+
children: [/* @__PURE__ */ _jsx(BorderLabel, {
|
|
88
|
+
id: labelId,
|
|
89
|
+
label,
|
|
90
|
+
hideLabelFromVision
|
|
91
|
+
}), /* @__PURE__ */ _jsx(BorderBoxControlLinkedButton, {
|
|
92
|
+
onClick: toggleLinked,
|
|
93
|
+
isLinked
|
|
94
|
+
})]
|
|
95
|
+
})
|
|
96
|
+
) : /* @__PURE__ */ _jsx(BorderLabel, {
|
|
97
|
+
id: labelId,
|
|
66
98
|
label,
|
|
67
99
|
hideLabelFromVision
|
|
68
100
|
}), /* @__PURE__ */ _jsxs(View, {
|
|
@@ -92,7 +124,7 @@ var UnconnectedBorderBoxControl = (props, forwardedRef) => {
|
|
|
92
124
|
popoverOffset,
|
|
93
125
|
value: splitValue,
|
|
94
126
|
__experimentalIsRenderedInSidebar
|
|
95
|
-
}), /* @__PURE__ */ _jsx(BorderBoxControlLinkedButton, {
|
|
127
|
+
}), !hasVisibleLabel && /* @__PURE__ */ _jsx(BorderBoxControlLinkedButton, {
|
|
96
128
|
onClick: toggleLinked,
|
|
97
129
|
isLinked
|
|
98
130
|
})]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/border-box-control/border-box-control/component.tsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\nimport BorderBoxControlLinkedButton from '../border-box-control-linked-button';\nimport BorderBoxControlSplitControls from '../border-box-control-split-controls';\nimport { BorderControl } from '../../border-control';\nimport {
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,SAAS,gBAAgB;AAClC,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport BorderBoxControlLinkedButton from '../border-box-control-linked-button';\nimport BorderBoxControlSplitControls from '../border-box-control-split-controls';\nimport { BorderControl } from '../../border-control';\nimport BaseControl from '../../base-control';\nimport { Grid } from '../../grid';\nimport { View } from '../../view';\nimport { VisuallyHidden } from '../../visually-hidden';\nimport { contextConnect } from '../../context';\nimport { useBorderBoxControl } from './hook';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst BorderLabel = props => {\n const {\n id,\n label,\n hideLabelFromVision\n } = props;\n if (!label) {\n return null;\n }\n\n // The visible label is rendered as `BaseControl.VisualLabel` so it carries\n // the stable `.components-base-control__label` className consumers style\n // against; `StyledLabel` is an emotion component with a generated one.\n return hideLabelFromVision ? /*#__PURE__*/_jsx(VisuallyHidden, {\n as: \"span\",\n id: id,\n children: label\n }) : /*#__PURE__*/_jsx(BaseControl.VisualLabel, {\n id: id,\n children: label\n });\n};\nconst UnconnectedBorderBoxControl = (props, forwardedRef) => {\n const {\n className,\n colors,\n disableCustomColors,\n disableUnits,\n enableAlpha,\n enableStyle,\n hasMixedBorders,\n hasVisibleLabel,\n headerClassName,\n hideLabelFromVision,\n isLinked,\n label,\n linkedControlClassName,\n linkedValue,\n onLinkedChange,\n onSplitChange,\n popoverPlacement,\n popoverOffset,\n splitValue,\n toggleLinked,\n wrapperClassName,\n __experimentalIsRenderedInSidebar,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ...otherProps\n } = useBorderBoxControl(props);\n\n // The label names the group of border controls rather than a single input,\n // so it is associated via `aria-labelledby` instead of `htmlFor`.\n const generatedLabelId = useInstanceId(BorderBoxControl, 'border-box-control-label');\n\n // A consumer-provided accessible name takes precedence, so the generated\n // relationship is only used as a fallback. Where an external name wins,\n // the unused ID is left off the internal label. Empty values are treated\n // as absent, matching the accessible name computation, which skips an\n // empty `aria-label` or `aria-labelledby` rather than resolving a name\n // from it.\n const labelId = label && !ariaLabel && !ariaLabelledBy ? generatedLabelId : undefined;\n\n // Use internal state instead of a ref to make sure that the component\n // re-renders when the popover's anchor updates.\n const [popoverAnchor, setPopoverAnchor] = useState(null);\n\n // Memoize popoverProps to avoid returning a new object every time.\n const popoverProps = useMemo(() => popoverPlacement ? {\n placement: popoverPlacement,\n offset: popoverOffset,\n anchor: popoverAnchor,\n shift: true\n } : undefined, [popoverPlacement, popoverOffset, popoverAnchor]);\n const mergedRef = useMergeRefs([setPopoverAnchor, forwardedRef]);\n return /*#__PURE__*/_jsxs(View, {\n className: className\n // Whichever naming source wins, it describes the border controls\n // as a whole, so the wrapper needs a role for that accessible\n // name to attach to. Without a name there is no group to expose.\n ,\n role: label || ariaLabel || ariaLabelledBy ? 'group' : undefined,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy ?? labelId,\n ...otherProps,\n ref: mergedRef,\n children: [hasVisibleLabel ?\n /*#__PURE__*/\n // The toggle shares the label's row so that it lines up with\n // the equivalent toggle on sibling controls, e.g. the border\n // radius one.\n _jsxs(Grid, {\n className: headerClassName,\n columns: 2,\n templateColumns: \"1fr min-content\",\n alignment: \"center\",\n children: [/*#__PURE__*/_jsx(BorderLabel, {\n id: labelId,\n label: label,\n hideLabelFromVision: hideLabelFromVision\n }), /*#__PURE__*/_jsx(BorderBoxControlLinkedButton, {\n onClick: toggleLinked,\n isLinked: isLinked\n })]\n }) : /*#__PURE__*/_jsx(BorderLabel, {\n id: labelId,\n label: label,\n hideLabelFromVision: hideLabelFromVision\n }), /*#__PURE__*/_jsxs(View, {\n className: wrapperClassName,\n children: [isLinked ? /*#__PURE__*/_jsx(BorderControl, {\n className: linkedControlClassName,\n colors: colors,\n disableUnits: disableUnits,\n disableCustomColors: disableCustomColors,\n enableAlpha: enableAlpha,\n enableStyle: enableStyle,\n onChange: onLinkedChange,\n placeholder: hasMixedBorders ? __('Mixed') : undefined,\n __unstablePopoverProps: popoverProps,\n shouldSanitizeBorder: false // This component will handle that.\n ,\n value: linkedValue,\n withSlider: true,\n width: \"116px\",\n __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar\n }) : /*#__PURE__*/_jsx(BorderBoxControlSplitControls, {\n colors: colors,\n disableCustomColors: disableCustomColors,\n enableAlpha: enableAlpha,\n enableStyle: enableStyle,\n onChange: onSplitChange,\n popoverPlacement: popoverPlacement,\n popoverOffset: popoverOffset,\n value: splitValue,\n __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar\n }), !hasVisibleLabel && /*#__PURE__*/_jsx(BorderBoxControlLinkedButton, {\n onClick: toggleLinked,\n isLinked: isLinked\n })]\n })]\n });\n};\n\n/**\n * An input control for the color, style, and width of the border of a box. The\n * border can be customized as a whole, or individually for each side of the box.\n *\n * The controls are exposed as a group named by the `label` prop. Passing\n * `aria-labelledby` or `aria-label` names the group instead, taking precedence\n * over `label`; with none of the three, the wrapper is not exposed as a group.\n *\n * ```jsx\n * import { BorderBoxControl } from '@wordpress/components';\n * import { __ } from '@wordpress/i18n';\n *\n * const colors = [\n * \t{ name: 'Blue 20', color: '#72aee6' },\n * \t// ...\n * ];\n *\n * const MyBorderBoxControl = () => {\n * \tconst defaultBorder = {\n * \t\tcolor: '#72aee6',\n * \t\tstyle: 'dashed',\n * \t\twidth: '1px',\n * \t};\n * \tconst [ borders, setBorders ] = useState( {\n * \t\ttop: defaultBorder,\n * \t\tright: defaultBorder,\n * \t\tbottom: defaultBorder,\n * \t\tleft: defaultBorder,\n * \t} );\n * \tconst onChange = ( newBorders ) => setBorders( newBorders );\n *\n * \treturn (\n * \t\t<BorderBoxControl\n * \t\t\tcolors={ colors }\n * \t\t\tlabel={ __( 'Borders' ) }\n * \t\t\tonChange={ onChange }\n * \t\t\tvalue={ borders }\n * \t\t/>\n * \t);\n * };\n * ```\n */\nexport const BorderBoxControl = contextConnect(UnconnectedBorderBoxControl, 'BorderBoxControl');\nexport default BorderBoxControl;"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// packages/components/src/border-box-control/border-box-control/hook.ts
|
|
2
|
+
import clsx from "clsx";
|
|
2
3
|
import { useState } from "@wordpress/element";
|
|
3
4
|
|
|
4
5
|
// packages/style-runtime/src/index.ts
|
|
@@ -80,9 +81,9 @@ function registerStyle(hash, css) {
|
|
|
80
81
|
|
|
81
82
|
// packages/components/src/border-box-control/style.module.scss
|
|
82
83
|
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
83
|
-
registerStyle("
|
|
84
|
+
registerStyle("2eee37fabd", ".fa6e6c2331986855__linked-border-control.fa6e6c2331986855__linked-border-control{flex:1;margin-inline-end:24px}._6a6edeeb175d724f__linked-border-control-full-width._6a6edeeb175d724f__linked-border-control-full-width{margin-inline-end:0}.f5104488f80fa50f__header{margin-bottom:4px}.f5104488f80fa50f__header>span{margin-bottom:0}._48f63719b9dc7e1a__wrapper{position:relative}._48f63719b9dc7e1a__wrapper ._902e774d37b6698b__linked-button{inset-inline-end:0;position:absolute;top:8px}._902e774d37b6698b__linked-button{line-height:0}._5978f65e1d08de6c__visualizer{border-bottom:var(--wp-components-border-box-visualizer-bottom);border-inline-end:var(--wp-components-border-box-visualizer-end);border-inline-start:var(--wp-components-border-box-visualizer-start);border-top:var(--wp-components-border-box-visualizer-top);bottom:20px;position:absolute;top:20px;inset-inline:39px}.afa8e78cec6a9f62__split-controls{flex:1;position:relative}.ec002fcdf4036950__centered-border-control{grid-column:span 2;margin:0 auto}.f9ea07d7127ab067__right-border-control{margin-inline-start:auto}");
|
|
84
85
|
}
|
|
85
|
-
var style_module_default = { "linked-border-control": "fa6e6c2331986855__linked-border-control", "wrapper": "_48f63719b9dc7e1a__wrapper", "linked-button": "_902e774d37b6698b__linked-button", "visualizer": "_5978f65e1d08de6c__visualizer", "split-controls": "afa8e78cec6a9f62__split-controls", "centered-border-control": "ec002fcdf4036950__centered-border-control", "right-border-control": "f9ea07d7127ab067__right-border-control" };
|
|
86
|
+
var style_module_default = { "linked-border-control": "fa6e6c2331986855__linked-border-control", "linked-border-control-full-width": "_6a6edeeb175d724f__linked-border-control-full-width", "header": "f5104488f80fa50f__header", "wrapper": "_48f63719b9dc7e1a__wrapper", "linked-button": "_902e774d37b6698b__linked-button", "visualizer": "_5978f65e1d08de6c__visualizer", "split-controls": "afa8e78cec6a9f62__split-controls", "centered-border-control": "ec002fcdf4036950__centered-border-control", "right-border-control": "f9ea07d7127ab067__right-border-control" };
|
|
86
87
|
|
|
87
88
|
// packages/components/src/border-box-control/border-box-control/hook.ts
|
|
88
89
|
import { getBorderDiff, getCommonBorder, getSplitBorders, hasMixedBorders, hasSplitBorders, isCompleteBorder, isEmptyBorder } from "../utils.mjs";
|
|
@@ -94,6 +95,8 @@ function useBorderBoxControl(props) {
|
|
|
94
95
|
onChange,
|
|
95
96
|
enableAlpha = false,
|
|
96
97
|
enableStyle = true,
|
|
98
|
+
hideLabelFromVision,
|
|
99
|
+
label,
|
|
97
100
|
value,
|
|
98
101
|
__experimentalIsRenderedInSidebar = false,
|
|
99
102
|
// Deprecated props, no longer used.
|
|
@@ -101,6 +104,7 @@ function useBorderBoxControl(props) {
|
|
|
101
104
|
__next40pxDefaultSize: _next40pxDefaultSize,
|
|
102
105
|
...otherProps
|
|
103
106
|
} = useContextSystem(props, "BorderBoxControl");
|
|
107
|
+
const hasVisibleLabel = !!label && !hideLabelFromVision;
|
|
104
108
|
const mixedBorders = hasMixedBorders(value);
|
|
105
109
|
const splitBorders = hasSplitBorders(value);
|
|
106
110
|
const linkedValue = splitBorders ? getCommonBorder(value) : value;
|
|
@@ -151,12 +155,19 @@ function useBorderBoxControl(props) {
|
|
|
151
155
|
onChange(newBorder);
|
|
152
156
|
}
|
|
153
157
|
};
|
|
154
|
-
const linkedControlClassName = style_module_default["linked-border-control"]
|
|
158
|
+
const linkedControlClassName = clsx(style_module_default["linked-border-control"], {
|
|
159
|
+
[style_module_default["linked-border-control-full-width"]]: hasVisibleLabel
|
|
160
|
+
});
|
|
155
161
|
const wrapperClassName = style_module_default.wrapper;
|
|
162
|
+
const headerClassName = style_module_default.header;
|
|
156
163
|
return {
|
|
157
164
|
...otherProps,
|
|
158
165
|
className,
|
|
159
166
|
colors,
|
|
167
|
+
hasVisibleLabel,
|
|
168
|
+
headerClassName,
|
|
169
|
+
hideLabelFromVision,
|
|
170
|
+
label,
|
|
160
171
|
disableUnits: mixedBorders && !hasWidthValue,
|
|
161
172
|
enableAlpha,
|
|
162
173
|
enableStyle,
|