@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,OAAO,UAAU;AACjB,SAAS,
|
|
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": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// packages/components/src/tree-grid/cell.tsx
|
|
2
|
-
import { forwardRef } from "@wordpress/element";
|
|
2
|
+
import { forwardRef, useRef } from "@wordpress/element";
|
|
3
3
|
import TreeGridItem from "./item.mjs";
|
|
4
|
+
import { useValidateTreeGridStructure } from "./use-validate-tree-grid-structure.mjs";
|
|
4
5
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
function UnforwardedTreeGridCell({
|
|
6
7
|
children,
|
|
7
8
|
withoutGridItem = false,
|
|
8
9
|
...props
|
|
9
10
|
}, ref) {
|
|
11
|
+
const cellRef = useRef(null);
|
|
12
|
+
useValidateTreeGridStructure("TreeGridCell", cellRef);
|
|
10
13
|
return /* @__PURE__ */ _jsx("td", {
|
|
14
|
+
ref: cellRef,
|
|
11
15
|
...props,
|
|
12
16
|
role: "gridcell",
|
|
13
17
|
children: withoutGridItem ? /* @__PURE__ */ _jsx(_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,SAAS,
|
|
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,SAAS,YAAY,cAAc;AACnC,OAAO,kBAAkB;AACzB,SAAS,oCAAoC;AAC7C,SAAS,YAAY,WAAW,OAAO,YAAY;AACnD,SAAS,wBAAwB;AAAA,EAC/B;AAAA,EACA,kBAAkB;AAAA,EAClB,GAAG;AACL,GAAG,KAAK;AACN,QAAM,UAAU,OAAO,IAAI;AAC3B,+BAA6B,gBAAgB,OAAO;AACpD,SAAoB,qBAAK,MAAM;AAAA,IAC7B,KAAK;AAAA,IACL,GAAG;AAAA,IACH,MAAM;AAAA,IACN,UAAU,kBAA+B,qBAAK,WAAW;AAAA,MACvD,UAAU,OAAO,aAAa,aAAa,SAAS;AAAA,QAClD,GAAG;AAAA,QACH;AAAA,MACF,CAAC,IAAI;AAAA,IACP,CAAC,IAAiB,qBAAK,cAAc;AAAA,MACnC;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;AASO,IAAM,eAAe,WAAW,uBAAuB;AAC9D,aAAa,cAAc;AAC3B,IAAO,eAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,10 +9,14 @@ var RovingTabIndexItem = forwardRef(function UnforwardedRovingTabIndexItem({
|
|
|
9
9
|
}, forwardedRef) {
|
|
10
10
|
const localRef = useRef(null);
|
|
11
11
|
const ref = forwardedRef || localRef;
|
|
12
|
+
const context = useRovingTabIndexContext();
|
|
13
|
+
if (!context) {
|
|
14
|
+
throw new Error("TreeGridItem can only be rendered inside a TreeGrid component.");
|
|
15
|
+
}
|
|
12
16
|
const {
|
|
13
17
|
lastFocusedElement,
|
|
14
18
|
setLastFocusedElement
|
|
15
|
-
} =
|
|
19
|
+
} = context;
|
|
16
20
|
let tabIndex;
|
|
17
21
|
if (lastFocusedElement) {
|
|
18
22
|
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,SAAS,QAAQ,kBAAkB;AACnC,SAAS,gCAAgC;AACzC,SAAS,OAAO,YAAY;AACrB,IAAM,qBAAqB,WAAW,SAAS,8BAA8B;AAAA,EAClF;AAAA,EACA,IAAI;AAAA,EACJ,GAAG;AACL,GAAG,cAAc;AACf,QAAM,WAAW,OAAO,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,SAAS,QAAQ,kBAAkB;AACnC,SAAS,gCAAgC;AACzC,SAAS,OAAO,YAAY;AACrB,IAAM,qBAAqB,WAAW,SAAS,8BAA8B;AAAA,EAClF;AAAA,EACA,IAAI;AAAA,EACJ,GAAG;AACL,GAAG,cAAc;AACf,QAAM,WAAW,OAAO,IAAI;AAC5B,QAAM,MAAM,gBAAgB;AAC5B,QAAM,UAAU,yBAAyB;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,qBAAK,WAAW;AAAA,IAClC,GAAG;AAAA,IACH;AAAA,EACF,CAAC;AACH,CAAC;AACD,mBAAmB,cAAc;AACjC,IAAO,gCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// packages/components/src/tree-grid/row.tsx
|
|
2
|
-
import {
|
|
2
|
+
import { useMergeRefs } from "@wordpress/compose";
|
|
3
|
+
import { forwardRef, useRef } from "@wordpress/element";
|
|
4
|
+
import { useValidateTreeGridStructure } from "./use-validate-tree-grid-structure.mjs";
|
|
3
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
6
|
function UnforwardedTreeGridRow({
|
|
5
7
|
children,
|
|
@@ -9,9 +11,12 @@ function UnforwardedTreeGridRow({
|
|
|
9
11
|
isExpanded,
|
|
10
12
|
...props
|
|
11
13
|
}, ref) {
|
|
14
|
+
const rowRef = useRef(null);
|
|
15
|
+
const refs = useMergeRefs([rowRef, ref]);
|
|
16
|
+
useValidateTreeGridStructure("TreeGridRow", rowRef);
|
|
12
17
|
return /* @__PURE__ */ _jsx("tr", {
|
|
13
18
|
...props,
|
|
14
|
-
ref,
|
|
19
|
+
ref: refs,
|
|
15
20
|
role: "row",
|
|
16
21
|
"aria-level": level,
|
|
17
22
|
"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,SAAS,
|
|
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,SAAS,oBAAoB;AAC7B,SAAS,YAAY,cAAc;AACnC,SAAS,oCAAoC;AAC7C,SAAS,OAAO,YAAY;AAC5B,SAAS,uBAAuB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,KAAK;AACN,QAAM,SAAS,OAAO,IAAI;AAC1B,QAAM,OAAO,aAAa,CAAC,QAAQ,GAAG,CAAC;AACvC,+BAA6B,eAAe,MAAM;AAClD,SAAoB,qBAAK,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,cAAc,WAAW,sBAAsB;AAC5D,YAAY,cAAc;AAC1B,IAAO,cAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// packages/components/src/tree-grid/use-validate-tree-grid-structure.ts
|
|
2
|
+
import { useEffect } from "@wordpress/element";
|
|
3
|
+
var ROW_SELECTOR = 'tr:not([role]), [role="row"]';
|
|
4
|
+
var TREE_GRID_SELECTOR = '[role="treegrid"]';
|
|
5
|
+
function getAriaOwners(element) {
|
|
6
|
+
if (!element.id) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
const escapedId = element.id.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
|
|
10
|
+
return Array.from(element.ownerDocument.querySelectorAll(`[aria-owns~="${escapedId}"]`));
|
|
11
|
+
}
|
|
12
|
+
function isContainedInOrOwnedBy(element, selector, visited = /* @__PURE__ */ new Set()) {
|
|
13
|
+
if (visited.has(element)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
visited.add(element);
|
|
17
|
+
if (element.parentElement?.closest(selector)) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
const hasValidOwner = getAriaOwners(element).some((owner) => owner.matches(selector) || isContainedInOrOwnedBy(owner, selector, visited));
|
|
21
|
+
if (hasValidOwner) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return element.parentElement ? isContainedInOrOwnedBy(element.parentElement, selector, visited) : false;
|
|
25
|
+
}
|
|
26
|
+
function isOwnedByRowInTreeGrid(element, visited = /* @__PURE__ */ new Set()) {
|
|
27
|
+
if (visited.has(element)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
visited.add(element);
|
|
31
|
+
const hasValidOwner = getAriaOwners(element).some((owner) => {
|
|
32
|
+
const row = owner.matches(ROW_SELECTOR) ? owner : owner.closest(ROW_SELECTOR);
|
|
33
|
+
return row ? isContainedInOrOwnedBy(row, TREE_GRID_SELECTOR) : isOwnedByRowInTreeGrid(owner, visited);
|
|
34
|
+
});
|
|
35
|
+
if (hasValidOwner) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return element.parentElement ? isOwnedByRowInTreeGrid(element.parentElement, visited) : false;
|
|
39
|
+
}
|
|
40
|
+
function useValidateTreeGridStructure(componentName, elementRef) {
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const element = elementRef.current;
|
|
43
|
+
if (!element) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const row = element.parentElement?.closest(ROW_SELECTOR);
|
|
47
|
+
const hasValidStructure = componentName === "TreeGridRow" ? isContainedInOrOwnedBy(element, TREE_GRID_SELECTOR) : row && isContainedInOrOwnedBy(row, TREE_GRID_SELECTOR) || isOwnedByRowInTreeGrid(element);
|
|
48
|
+
if (!hasValidStructure) {
|
|
49
|
+
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".');
|
|
50
|
+
}
|
|
51
|
+
}, [componentName, elementRef]);
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
useValidateTreeGridStructure
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=use-validate-tree-grid-structure.mjs.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,SAAS,iBAAiB;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,YAAU,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
|
+
}
|
|
@@ -48,8 +48,9 @@ var UI = {
|
|
|
48
48
|
border: THEME.gray[600],
|
|
49
49
|
borderHover: THEME.gray[700],
|
|
50
50
|
borderFocus: THEME.accent,
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
// The gray ramp above has no disabled step to map these through.
|
|
52
|
+
borderDisabled: `var(--wpds-color-stroke-interactive-neutral-disabled, #dbdbdb)`,
|
|
53
|
+
textDisabled: `var(--wpds-color-foreground-interactive-neutral-disabled, #8d8d8d)`,
|
|
53
54
|
// Matches @wordpress/base-styles
|
|
54
55
|
darkGrayPlaceholder: `color-mix(in srgb, ${THEME.foreground}, transparent 38%)`,
|
|
55
56
|
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": ";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": ";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
|
}
|