@wordpress/components 40.0.0 → 40.1.1-next.v.202609031004.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 +26 -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/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/icon/index.cjs +30 -12
- package/build/icon/index.cjs.map +2 -2
- package/build/item-group/item/hook.cjs +1 -1
- package/build/item-group/item/hook.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/resizable-box/index.cjs.map +1 -1
- package/build/snackbar/index.cjs +8 -5
- package/build/snackbar/index.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-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/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/icon/index.mjs +30 -12
- package/build-module/icon/index.mjs.map +2 -2
- package/build-module/item-group/item/hook.mjs +1 -1
- package/build-module/item-group/item/hook.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/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/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-style/style-rtl.css +7 -35
- package/build-style/style.css +7 -35
- 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/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/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/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/package.json +26 -25
- package/src/angle-picker-control/style.module.scss +1 -1
- package/src/autocomplete/test/get-autocomplete-match.ts +2 -1
- package/src/base-control/stories/index.story.tsx +2 -2
- 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} +133 -0
- 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} +20 -13
- package/src/checkbox-control/style.scss +2 -2
- package/src/checkbox-control/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +8 -5
- package/src/color-palette/index.tsx +1 -1
- package/src/composite/README.md +1 -1
- package/src/composite/types.ts +1 -1
- 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/__snapshots__/{context-system-provider.js.snap → context-system-provider.jsdom.test.tsx.snap} +3 -3
- package/src/context/test/context-connect.tsx +1 -2
- package/src/context/test/{context-system-provider.js → context-system-provider.jsdom.test.tsx} +81 -43
- package/src/context/test/wordpress-component.tsx +1 -2
- package/src/context/use-context-system.js +13 -4
- package/src/custom-gradient-picker/test/serializer.ts +1 -0
- package/src/date-time/test/utils.test.ts +9 -0
- package/src/draggable/style.module.scss +1 -1
- package/src/dropdown/style.module.scss +2 -2
- package/src/font-size-picker/test/utils.ts +1 -0
- package/src/icon/index.tsx +28 -12
- package/src/icon/test/{index.tsx → index.jsdom.test.tsx} +66 -0
- package/src/input-control/test/{index.js → index.jsdom.test.tsx} +16 -10
- package/src/item-group/style.module.scss +1 -2
- package/src/navigator/test/router.ts +1 -0
- package/src/notice/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +5 -2
- 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/query-controls/test/terms.ts +1 -0
- package/src/resizable-box/index.tsx +1 -1
- package/src/slot-fill/test/{index.js → index.jsdom.test.tsx} +3 -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} +28 -2
- package/src/snackbar/test/list.jsdom.test.tsx +99 -0
- package/src/surface/style.module.scss +2 -2
- package/src/textarea-control/style.module.scss +1 -1
- package/src/tip/style.scss +1 -1
- package/src/toggle-group-control/toggle-group-control/style.module.scss +1 -1
- package/src/tools-panel/test/{index.tsx → index.jsdom.test.tsx} +528 -9
- 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/truncate/style.module.scss +0 -1
- package/src/unit-control/test/utils.ts +1 -0
- package/src/utils/hooks/test/{use-controlled-state.js → use-controlled-state.jsdom.test.tsx} +17 -3
- package/src/utils/hooks/test/{use-controlled-value.js → use-controlled-value.jsdom.test.tsx} +3 -1
- package/src/utils/hooks/test/{use-cx.js → use-cx.jsdom.test.tsx} +3 -1
- 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/view/test/{index.js → index.jsdom.test.tsx} +5 -1
- package/src/snackbar/test/list.tsx +0 -39
- /package/src/alignment-matrix-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/autocomplete/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/badge/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/base-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/box-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/button/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /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/checkbox-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/circular-option-picker/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/color-indicator/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/color-indicator/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/color-palette/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/color-palette/test/{utils.ts → utils.jsdom.test.ts} +0 -0
- /package/src/color-picker/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/combobox-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/composite/legacy/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/composite/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/confirm-dialog/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/content-editable-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/custom-gradient-picker/gradient-bar/test/{utils.ts → utils.jsdom.test.ts} +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/custom-select-control-v2/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/date-time/date-picker/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/date-time/date-picker/test/{use-lilius.ts → use-lilius.jsdom.test.ts} +0 -0
- /package/src/date-time/date-time/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/date-time/time-picker/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/date-time/time-picker/time-input/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/disabled/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/divider/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/dropdown/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/dropdown-menu/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/duotone-picker/test/{custom-duotone-bar.tsx → custom-duotone-bar.jsdom.test.tsx} +0 -0
- /package/src/duotone-picker/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/external-link/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/focal-point-picker/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/focal-point-picker/test/{media.tsx → media.jsdom.test.tsx} +0 -0
- /package/src/font-size-picker/test/{font-size-picker-select.tsx → font-size-picker-select.jsdom.test.tsx} +0 -0
- /package/src/font-size-picker/test/{font-size-picker-toggle-group.tsx → font-size-picker-toggle-group.jsdom.test.tsx} +0 -0
- /package/src/font-size-picker/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/form-toggle/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/form-toggle/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/form-token-field/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/gradient-picker/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/grid/test/{grid.tsx → grid.jsdom.test.tsx} +0 -0
- /package/src/guide/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/h-stack/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/h-stack/test/{index.tsx → index.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/higher-order/with-fallback-styles/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/higher-order/with-filters/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/higher-order/with-filters/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/higher-order/with-focus-outside/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/higher-order/with-focus-return/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/higher-order/with-notices/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/higher-order/with-spoken-messages/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/isolated-event-container/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/item-group/test/__snapshots__/{index.js.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/item-group/test/{index.js → index.jsdom.test.tsx} +0 -0
- /package/src/keyboard-shortcuts/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/menu/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/menu-group/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/menu-item/test/__snapshots__/{index.js.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/menu-item/test/{index.js → index.jsdom.test.tsx} +0 -0
- /package/src/modal/test/{aria-helper.ts → aria-helper.jsdom.test.ts} +0 -0
- /package/src/modal/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/navigable-container/test/{navigable-menu.tsx → navigable-menu.jsdom.test.tsx} +0 -0
- /package/src/navigable-container/test/{tababble-container.tsx → tababble-container.jsdom.test.tsx} +0 -0
- /package/src/navigator/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/notice/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/notice/test/{list.tsx → list.jsdom.test.tsx} +0 -0
- /package/src/number-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/palette-edit/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/panel/test/__snapshots__/{body.tsx.snap → body.jsdom.test.tsx.snap} +0 -0
- /package/src/panel/test/__snapshots__/{header.tsx.snap → header.jsdom.test.tsx.snap} +0 -0
- /package/src/panel/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/panel/test/__snapshots__/{row.tsx.snap → row.jsdom.test.tsx.snap} +0 -0
- /package/src/panel/test/{body.tsx → body.jsdom.test.tsx} +0 -0
- /package/src/panel/test/{header.tsx → header.jsdom.test.tsx} +0 -0
- /package/src/panel/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/panel/test/{row.tsx → row.jsdom.test.tsx} +0 -0
- /package/src/placeholder/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/progress-bar/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/radio-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/range-control/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/sandbox/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/scroll-lock/test/{index.tsx → index.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/shortcut/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/shortcut/test/{index.tsx → index.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/style-provider/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/surface/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/tab-panel/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/tabs/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/text-control/test/{text-control.tsx → text-control.jsdom.test.tsx} +0 -0
- /package/src/text-highlight/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/toggle-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/toggle-group-control/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/toggle-group-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/toolbar/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/toolbar/test/{toolbar-group.tsx → toolbar-group.jsdom.test.tsx} +0 -0
- /package/src/tooltip/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/tree-grid/test/__snapshots__/{cell.tsx.snap → cell.jsdom.test.tsx.snap} +0 -0
- /package/src/tree-grid/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/tree-grid/test/__snapshots__/{roving-tab-index-item.tsx.snap → roving-tab-index-item.jsdom.test.tsx.snap} +0 -0
- /package/src/tree-grid/test/__snapshots__/{roving-tab-index.tsx.snap → roving-tab-index.jsdom.test.tsx.snap} +0 -0
- /package/src/tree-grid/test/__snapshots__/{row.tsx.snap → row.jsdom.test.tsx.snap} +0 -0
- /package/src/tree-grid/test/{cell.tsx → cell.jsdom.test.tsx} +0 -0
- /package/src/tree-grid/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/tree-grid/test/{roving-tab-index-item.tsx → roving-tab-index-item.jsdom.test.tsx} +0 -0
- /package/src/tree-grid/test/{roving-tab-index.tsx → roving-tab-index.jsdom.test.tsx} +0 -0
- /package/src/tree-grid/test/{row.tsx → row.jsdom.test.tsx} +0 -0
- /package/src/truncate/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/unit-control/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/utils/test/{polymorphic-element.tsx → polymorphic-element.jsdom.test.tsx} +0 -0
- /package/src/v-stack/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap} +0 -0
- /package/src/v-stack/test/{index.tsx → index.jsdom.test.tsx} +0 -0
- /package/src/validated-form-controls/test/{content-editable-control.tsx → content-editable-control.jsdom.test.tsx} +0 -0
- /package/src/validated-form-controls/test/{custom-select-control.tsx → custom-select-control.jsdom.test.tsx} +0 -0
- /package/src/validated-form-controls/test/{input-control.tsx → input-control.jsdom.test.tsx} +0 -0
- /package/src/validated-form-controls/test/{range-control.tsx → range-control.jsdom.test.tsx} +0 -0
- /package/src/validated-form-controls/test/{textarea-control.tsx → textarea-control.jsdom.test.tsx} +0 -0
- /package/src/view/test/__snapshots__/{index.js.snap → index.jsdom.test.tsx.snap} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ComponentProps } from 'react';
|
|
2
2
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { useId } from '@wordpress/element';
|
|
4
5
|
import { BorderBoxControl } from '..';
|
|
5
6
|
|
|
6
7
|
const colors = [
|
|
@@ -50,6 +51,102 @@ function TestBorderBoxControl(
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
describe( 'BorderBoxControl', () => {
|
|
54
|
+
describe( 'Labelling', () => {
|
|
55
|
+
it( 'should give the group of controls an accessible name from the label', () => {
|
|
56
|
+
render( <TestBorderBoxControl { ...props } /> );
|
|
57
|
+
|
|
58
|
+
expect(
|
|
59
|
+
screen.getByRole( 'group', { name: props.label } )
|
|
60
|
+
).toBeInTheDocument();
|
|
61
|
+
} );
|
|
62
|
+
|
|
63
|
+
it( 'should name the group of controls even when the label is hidden', () => {
|
|
64
|
+
render( <TestBorderBoxControl { ...props } hideLabelFromVision /> );
|
|
65
|
+
|
|
66
|
+
expect(
|
|
67
|
+
screen.getByRole( 'group', { name: props.label } )
|
|
68
|
+
).toBeInTheDocument();
|
|
69
|
+
} );
|
|
70
|
+
|
|
71
|
+
it( 'should let a consumer-provided `aria-label` take precedence over the label', () => {
|
|
72
|
+
render(
|
|
73
|
+
<TestBorderBoxControl { ...props } aria-label="Outer borders" />
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
expect(
|
|
77
|
+
screen.getByRole( 'group', { name: 'Outer borders' } )
|
|
78
|
+
).toBeInTheDocument();
|
|
79
|
+
} );
|
|
80
|
+
|
|
81
|
+
it( 'should let a consumer-provided `aria-labelledby` take precedence over the label', () => {
|
|
82
|
+
const ExternallyLabelledControl = () => {
|
|
83
|
+
const id = useId();
|
|
84
|
+
return (
|
|
85
|
+
<>
|
|
86
|
+
<span id={ id }>Outer borders</span>
|
|
87
|
+
<TestBorderBoxControl
|
|
88
|
+
{ ...props }
|
|
89
|
+
aria-labelledby={ id }
|
|
90
|
+
/>
|
|
91
|
+
</>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
render( <ExternallyLabelledControl /> );
|
|
96
|
+
|
|
97
|
+
expect(
|
|
98
|
+
screen.getByRole( 'group', { name: 'Outer borders' } )
|
|
99
|
+
).toBeInTheDocument();
|
|
100
|
+
|
|
101
|
+
// With an external name in play, the internal label is no longer
|
|
102
|
+
// referenced, so it shouldn't carry a generated ID either.
|
|
103
|
+
expect( screen.getByText( props.label ) ).not.toHaveAttribute(
|
|
104
|
+
'id'
|
|
105
|
+
);
|
|
106
|
+
} );
|
|
107
|
+
|
|
108
|
+
it( 'should form a group when named only by `aria-label`', () => {
|
|
109
|
+
render(
|
|
110
|
+
<TestBorderBoxControl
|
|
111
|
+
{ ...props }
|
|
112
|
+
label={ undefined }
|
|
113
|
+
aria-label="Outer borders"
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
expect(
|
|
118
|
+
screen.getByRole( 'group', { name: 'Outer borders' } )
|
|
119
|
+
).toBeInTheDocument();
|
|
120
|
+
} );
|
|
121
|
+
|
|
122
|
+
it( 'should fall back to the label when an ARIA naming prop is empty', () => {
|
|
123
|
+
// An empty `aria-label` is skipped by the accessible name
|
|
124
|
+
// computation, so it shouldn't suppress the label association and
|
|
125
|
+
// leave the group unnamed.
|
|
126
|
+
render( <TestBorderBoxControl { ...props } aria-label="" /> );
|
|
127
|
+
|
|
128
|
+
expect(
|
|
129
|
+
screen.getByRole( 'group', { name: props.label } )
|
|
130
|
+
).toBeInTheDocument();
|
|
131
|
+
} );
|
|
132
|
+
|
|
133
|
+
it( 'should give each instance its own label association', () => {
|
|
134
|
+
render(
|
|
135
|
+
<>
|
|
136
|
+
<TestBorderBoxControl { ...props } label="First" />
|
|
137
|
+
<TestBorderBoxControl { ...props } label="Second" />
|
|
138
|
+
</>
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
expect(
|
|
142
|
+
screen.getByRole( 'group', { name: 'First' } )
|
|
143
|
+
).toBeInTheDocument();
|
|
144
|
+
expect(
|
|
145
|
+
screen.getByRole( 'group', { name: 'Second' } )
|
|
146
|
+
).toBeInTheDocument();
|
|
147
|
+
} );
|
|
148
|
+
} );
|
|
149
|
+
|
|
53
150
|
describe( 'Linked view rendering', () => {
|
|
54
151
|
it( 'should render correctly when no value provided', () => {
|
|
55
152
|
render( <TestBorderBoxControl { ...props } /> );
|
|
@@ -76,6 +173,42 @@ describe( 'BorderBoxControl', () => {
|
|
|
76
173
|
expect( linkedButton ).toBeInTheDocument();
|
|
77
174
|
} );
|
|
78
175
|
|
|
176
|
+
// `getAllByRole` returns document order, so the sign of this offset is
|
|
177
|
+
// which side of the border inputs the linked button sits on. The color
|
|
178
|
+
// button is the first of those inputs.
|
|
179
|
+
const getLinkedButtonOffsetFromColorButton = () => {
|
|
180
|
+
const buttons = screen.getAllByRole( 'button' );
|
|
181
|
+
const linkedButtonIndex = buttons.indexOf(
|
|
182
|
+
screen.getByLabelText( 'Unlink sides' )
|
|
183
|
+
);
|
|
184
|
+
const colorButtonIndex = buttons.indexOf(
|
|
185
|
+
screen.getByLabelText( toggleLabelRegex )
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
// Both queries throw when absent, and `indexOf` gives -1 for a
|
|
189
|
+
// button outside the list, which would read as "earlier than".
|
|
190
|
+
expect( linkedButtonIndex ).toBeGreaterThanOrEqual( 0 );
|
|
191
|
+
expect( colorButtonIndex ).toBeGreaterThanOrEqual( 0 );
|
|
192
|
+
|
|
193
|
+
return linkedButtonIndex - colorButtonIndex;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
it( 'should place the linked button before the border inputs when the label is visible', () => {
|
|
197
|
+
render( <TestBorderBoxControl { ...props } /> );
|
|
198
|
+
|
|
199
|
+
// Sharing the label's row is what lines it up with the equivalent
|
|
200
|
+
// button on sibling controls such as border radius.
|
|
201
|
+
expect( getLinkedButtonOffsetFromColorButton() ).toBeLessThan( 0 );
|
|
202
|
+
} );
|
|
203
|
+
|
|
204
|
+
it( 'should place the linked button after the border inputs when the label is hidden', () => {
|
|
205
|
+
render( <TestBorderBoxControl { ...props } hideLabelFromVision /> );
|
|
206
|
+
|
|
207
|
+
expect( getLinkedButtonOffsetFromColorButton() ).toBeGreaterThan(
|
|
208
|
+
0
|
|
209
|
+
);
|
|
210
|
+
} );
|
|
211
|
+
|
|
79
212
|
it( 'should hide label', () => {
|
|
80
213
|
render( <TestBorderBoxControl { ...props } hideLabelFromVision /> );
|
|
81
214
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
1
2
|
import {
|
|
2
3
|
getBorderDiff,
|
|
3
4
|
getCommonBorder,
|
|
@@ -44,12 +45,14 @@ describe( 'BorderBoxControl Utils', () => {
|
|
|
44
45
|
describe( 'isEmptyBorder', () => {
|
|
45
46
|
it( 'should determine a undefined, null, and {} to be empty', () => {
|
|
46
47
|
expect( isEmptyBorder( undefined ) ).toBe( true );
|
|
48
|
+
// Checking for extra resilience, even if not a valid type.
|
|
47
49
|
// @ts-expect-error `null` is outside the declared `Border | undefined` input; resilience is tested.
|
|
48
50
|
expect( isEmptyBorder( null ) ).toBe( true );
|
|
49
51
|
expect( isEmptyBorder( {} ) ).toBe( true );
|
|
50
52
|
} );
|
|
51
53
|
|
|
52
54
|
it( 'should determine object missing all border props to be empty', () => {
|
|
55
|
+
// Checking for extra resilience, even if not a valid type.
|
|
53
56
|
// @ts-expect-error `nonBorder` has no properties in common with `Border`; resilience is tested.
|
|
54
57
|
expect( isEmptyBorder( nonBorder ) ).toBe( true );
|
|
55
58
|
} );
|
|
@@ -109,12 +112,14 @@ describe( 'BorderBoxControl Utils', () => {
|
|
|
109
112
|
describe( 'isCompleteBorder', () => {
|
|
110
113
|
it( 'should determine a undefined, null, and {} to be incomplete', () => {
|
|
111
114
|
expect( isCompleteBorder( undefined ) ).toBe( false );
|
|
115
|
+
// Checking for extra resilience, even if not a valid type.
|
|
112
116
|
// @ts-expect-error `null` is outside the declared `Border | undefined` input; resilience is tested.
|
|
113
117
|
expect( isCompleteBorder( null ) ).toBe( false );
|
|
114
118
|
expect( isCompleteBorder( {} ) ).toBe( false );
|
|
115
119
|
} );
|
|
116
120
|
|
|
117
121
|
it( 'should determine objects missing border props to be incomplete', () => {
|
|
122
|
+
// Checking for extra resilience, even if not a valid type.
|
|
118
123
|
// @ts-expect-error `nonBorder` has no properties in common with `Border`; resilience is tested.
|
|
119
124
|
expect( isCompleteBorder( nonBorder ) ).toBe( false );
|
|
120
125
|
expect( isCompleteBorder( partialBorder ) ).toBe( false );
|
|
@@ -150,6 +155,7 @@ describe( 'BorderBoxControl Utils', () => {
|
|
|
150
155
|
it( 'should determine undefined, non-border or empty object as not being mixed', () => {
|
|
151
156
|
expect( hasMixedBorders( undefined ) ).toBe( false );
|
|
152
157
|
expect( hasMixedBorders( {} ) ).toBe( false );
|
|
158
|
+
// Checking for extra resilience, even if not a valid type.
|
|
153
159
|
// @ts-expect-error `nonBorder` is not assignable to `AnyBorder`; resilience is tested.
|
|
154
160
|
expect( hasMixedBorders( nonBorder ) ).toBe( false );
|
|
155
161
|
} );
|
|
@@ -170,12 +176,14 @@ describe( 'BorderBoxControl Utils', () => {
|
|
|
170
176
|
describe( 'getSplitBorders', () => {
|
|
171
177
|
it( 'should return undefined when no border provided', () => {
|
|
172
178
|
expect( getSplitBorders( undefined ) ).toEqual( undefined );
|
|
179
|
+
// Checking for extra resilience, even if not a valid type.
|
|
173
180
|
// @ts-expect-error `null` is outside the declared `Border | undefined` input; resilience is tested.
|
|
174
181
|
expect( getSplitBorders( null ) ).toEqual( undefined );
|
|
175
182
|
} );
|
|
176
183
|
|
|
177
184
|
it( 'should return undefined when supplied border is empty', () => {
|
|
178
185
|
expect( getSplitBorders( {} ) ).toEqual( undefined );
|
|
186
|
+
// Checking for extra resilience, even if not a valid type.
|
|
179
187
|
// @ts-expect-error `nonBorder` has no properties in common with `Border`; resilience is tested.
|
|
180
188
|
expect( getSplitBorders( nonBorder ) ).toEqual( undefined );
|
|
181
189
|
} );
|
|
@@ -197,6 +205,7 @@ describe( 'BorderBoxControl Utils', () => {
|
|
|
197
205
|
} );
|
|
198
206
|
|
|
199
207
|
it( 'should only return differences for border related properties', () => {
|
|
208
|
+
// Checking for extra resilience, even if not a valid type.
|
|
200
209
|
// @ts-expect-error `nonBorder` has no properties in common with `Border`; resilience is tested.
|
|
201
210
|
const diff = getBorderDiff( nonBorder, { caffeine: 'coffee' } );
|
|
202
211
|
expect( diff ).toEqual( {} );
|
|
@@ -206,6 +215,7 @@ describe( 'BorderBoxControl Utils', () => {
|
|
|
206
215
|
const diff = getBorderDiff( completeBorder, {
|
|
207
216
|
...completeBorder,
|
|
208
217
|
color: '#21759b',
|
|
218
|
+
// Checking for extra resilience, even if not a valid type.
|
|
209
219
|
// @ts-expect-error `caffeine` is not a declared `Border` property; the test checks it is ignored.
|
|
210
220
|
caffeine: 'cola',
|
|
211
221
|
} );
|
|
@@ -304,6 +314,7 @@ describe( 'BorderBoxControl Utils', () => {
|
|
|
304
314
|
it( 'should return undefined when no border provided', () => {
|
|
305
315
|
expect( getShorthandBorderStyle( undefined ) ).toEqual( undefined );
|
|
306
316
|
expect( getShorthandBorderStyle( {} ) ).toEqual( undefined );
|
|
317
|
+
// Checking for extra resilience, even if not a valid type.
|
|
307
318
|
// @ts-expect-error `nonBorder` has no properties in common with `Border`; resilience is tested.
|
|
308
319
|
expect( getShorthandBorderStyle( nonBorder ) ).toEqual( undefined );
|
|
309
320
|
} );
|
|
@@ -34,7 +34,9 @@ export type BorderBoxControlProps = ColorProps &
|
|
|
34
34
|
*/
|
|
35
35
|
popoverPlacement?: PopoverProps[ 'placement' ];
|
|
36
36
|
/**
|
|
37
|
-
* The space between the popover and the control wrapper.
|
|
37
|
+
* The space between the popover and the control wrapper. A number
|
|
38
|
+
* displaces the popover along its main axis; pass an object to also
|
|
39
|
+
* displace it along its cross axis.
|
|
38
40
|
*/
|
|
39
41
|
popoverOffset?: PopoverProps[ 'offset' ];
|
|
40
42
|
/**
|
|
@@ -83,7 +85,9 @@ export type SplitControlsProps = ColorProps &
|
|
|
83
85
|
*/
|
|
84
86
|
popoverPlacement?: PopoverProps[ 'placement' ];
|
|
85
87
|
/**
|
|
86
|
-
* The space between the popover and the control wrapper.
|
|
88
|
+
* The space between the popover and the control wrapper. A number
|
|
89
|
+
* displaces the popover along its main axis; pass an object to also
|
|
90
|
+
* displace it along its cross axis.
|
|
87
91
|
*/
|
|
88
92
|
popoverOffset?: PopoverProps[ 'offset' ];
|
|
89
93
|
/**
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from '@testing-library/react';
|
|
8
8
|
import userEvent from '@testing-library/user-event';
|
|
9
9
|
import { BorderControl } from '../';
|
|
10
|
+
import type { Border, BorderControlProps } from '../types';
|
|
10
11
|
import { COLORS } from '../../utils';
|
|
11
12
|
|
|
12
13
|
const colors = [
|
|
@@ -23,11 +24,13 @@ const defaultBorder = {
|
|
|
23
24
|
width: '1px',
|
|
24
25
|
};
|
|
25
26
|
|
|
26
|
-
function createProps(
|
|
27
|
-
|
|
27
|
+
function createProps(
|
|
28
|
+
customProps: Partial< BorderControlProps > = {}
|
|
29
|
+
): BorderControlProps {
|
|
30
|
+
const props: BorderControlProps = {
|
|
28
31
|
colors,
|
|
29
32
|
label: 'Border',
|
|
30
|
-
onChange: jest.fn().mockImplementation( ( newValue ) => {
|
|
33
|
+
onChange: jest.fn().mockImplementation( ( newValue?: Border ) => {
|
|
31
34
|
props.value = newValue;
|
|
32
35
|
} ),
|
|
33
36
|
value: defaultBorder,
|
|
@@ -38,7 +41,7 @@ function createProps( customProps ) {
|
|
|
38
41
|
|
|
39
42
|
const toggleLabelRegex = /Border color( and style)* picker/;
|
|
40
43
|
|
|
41
|
-
const openPopover = async ( user ) => {
|
|
44
|
+
const openPopover = async ( user: ReturnType< typeof userEvent.setup > ) => {
|
|
42
45
|
const toggleButton = screen.getByLabelText( toggleLabelRegex );
|
|
43
46
|
await user.click( toggleButton );
|
|
44
47
|
|
|
@@ -50,27 +53,31 @@ const openPopover = async ( user ) => {
|
|
|
50
53
|
await waitFor( () => expect( pickerButton ).toBePositionedPopover() );
|
|
51
54
|
};
|
|
52
55
|
|
|
53
|
-
const getButton = ( name ) => {
|
|
56
|
+
const getButton = ( name: string | RegExp ) => {
|
|
54
57
|
return screen.getByRole( 'button', { name } );
|
|
55
58
|
};
|
|
56
59
|
|
|
57
|
-
const getColorOption = ( color ) => {
|
|
60
|
+
const getColorOption = ( color: string ) => {
|
|
58
61
|
return screen.getByRole( 'option', { name: `${ color }` } );
|
|
59
62
|
};
|
|
60
63
|
|
|
61
|
-
const queryButton = ( name ) => {
|
|
64
|
+
const queryButton = ( name: string | RegExp ) => {
|
|
62
65
|
return screen.queryByRole( 'button', { name } );
|
|
63
66
|
};
|
|
64
67
|
|
|
65
68
|
const getSliderInput = () => {
|
|
66
|
-
return screen.getByRole( 'slider', {
|
|
69
|
+
return screen.getByRole< HTMLInputElement >( 'slider', {
|
|
70
|
+
name: 'Border width',
|
|
71
|
+
} );
|
|
67
72
|
};
|
|
68
73
|
|
|
69
74
|
const getWidthInput = () => {
|
|
70
|
-
return screen.getByRole( 'spinbutton', {
|
|
75
|
+
return screen.getByRole< HTMLInputElement >( 'spinbutton', {
|
|
76
|
+
name: 'Border width',
|
|
77
|
+
} );
|
|
71
78
|
};
|
|
72
79
|
|
|
73
|
-
function TestBorderControl( restProps ) {
|
|
80
|
+
function TestBorderControl( restProps: BorderControlProps ) {
|
|
74
81
|
return <BorderControl { ...restProps } />;
|
|
75
82
|
}
|
|
76
83
|
|
|
@@ -80,7 +87,7 @@ describe( 'BorderControl', () => {
|
|
|
80
87
|
const props = createProps();
|
|
81
88
|
render( <TestBorderControl { ...props } /> );
|
|
82
89
|
|
|
83
|
-
const label = screen.getByText( props.label );
|
|
90
|
+
const label = screen.getByText( props.label! );
|
|
84
91
|
const colorButton = screen.getByLabelText( toggleLabelRegex );
|
|
85
92
|
const widthInput = getWidthInput();
|
|
86
93
|
const unitSelect = screen.getByRole( 'combobox', {
|
|
@@ -100,7 +107,7 @@ describe( 'BorderControl', () => {
|
|
|
100
107
|
it( 'should hide label', () => {
|
|
101
108
|
const props = createProps( { hideLabelFromVision: true } );
|
|
102
109
|
render( <TestBorderControl { ...props } /> );
|
|
103
|
-
const label = screen.getByText( props.label );
|
|
110
|
+
const label = screen.getByText( props.label! );
|
|
104
111
|
|
|
105
112
|
// As visually hidden labels are still included in the document
|
|
106
113
|
// and do not have `display: none` styling, we can't rely on
|
|
@@ -128,7 +135,7 @@ describe( 'BorderControl', () => {
|
|
|
128
135
|
} );
|
|
129
136
|
|
|
130
137
|
describe( 'color indicator inline styles', () => {
|
|
131
|
-
const getIndicatorWrapper = ( border ) => {
|
|
138
|
+
const getIndicatorWrapper = ( border: Border ) => {
|
|
132
139
|
render(
|
|
133
140
|
<TestBorderControl
|
|
134
141
|
{ ...createProps( { value: border } ) }
|
|
@@ -77,7 +77,7 @@ svg.components-checkbox-control__checked,
|
|
|
77
77
|
svg.components-checkbox-control__indeterminate {
|
|
78
78
|
--checkmark-size: var(--checkbox-input-size);
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
color: $white;
|
|
81
81
|
cursor: var(--wpds-cursor-control);
|
|
82
82
|
position: absolute;
|
|
83
83
|
left: 50%;
|
|
@@ -96,7 +96,7 @@ svg.components-checkbox-control__indeterminate {
|
|
|
96
96
|
.components-checkbox-control:has(:disabled) {
|
|
97
97
|
svg.components-checkbox-control__checked,
|
|
98
98
|
svg.components-checkbox-control__indeterminate {
|
|
99
|
-
|
|
99
|
+
color: $components-color-gray-400;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
package/src/checkbox-control/test/__snapshots__/{index.tsx.snap → index.jsdom.test.tsx.snap}
RENAMED
|
@@ -5,7 +5,7 @@ Snapshot Diff:
|
|
|
5
5
|
- First value
|
|
6
6
|
+ Second value
|
|
7
7
|
|
|
8
|
-
@@ -14,14 +14,
|
|
8
|
+
@@ -14,14 +14,32 @@
|
|
9
9
|
<span
|
|
10
10
|
class="components-checkbox-control__input-container"
|
|
11
11
|
>
|
|
@@ -15,21 +15,24 @@ Snapshot Diff:
|
|
|
15
15
|
+ id="inspector-checkbox-control-7"
|
|
16
16
|
type="checkbox"
|
|
17
17
|
value="1"
|
|
18
|
-
|
|
18
|
+
+ />
|
|
19
19
|
+ <svg
|
|
20
20
|
+ aria-hidden="true"
|
|
21
21
|
+ class="components-checkbox-control__indeterminate"
|
|
22
|
-
+ fill="currentColor"
|
|
23
22
|
+ focusable="false"
|
|
24
23
|
+ height="24"
|
|
25
24
|
+ role="presentation"
|
|
25
|
+
+ stroke="currentColor"
|
|
26
|
+
+ stroke-width="1.5"
|
|
27
|
+
+ style="fill: none;"
|
|
26
28
|
+ viewBox="0 0 24 24"
|
|
27
29
|
+ width="24"
|
|
28
30
|
+ xmlns="http://www.w3.org/2000/svg"
|
|
29
31
|
+ >
|
|
30
32
|
+ <path
|
|
31
|
-
+ d="M7
|
|
32
|
-
+
|
|
33
|
+
+ d="M7 12H17"
|
|
34
|
+
+ vector-effect="non-scaling-stroke"
|
|
35
|
+
/>
|
|
33
36
|
+ </svg>
|
|
34
37
|
</span>
|
|
35
38
|
</div>
|
package/src/composite/README.md
CHANGED
|
@@ -136,7 +136,7 @@ Allows the component to be rendered as a different HTML element or React compone
|
|
|
136
136
|
|
|
137
137
|
Makes the component a focusable element. When this element gains keyboard focus, it gets a `data-focus-visible` attribute and triggers the `onFocusVisible` prop.
|
|
138
138
|
|
|
139
|
-
The component supports the `disabled` prop even for those elements not supporting the native `disabled` attribute. Disabled elements may be still accessible via keyboard by using the
|
|
139
|
+
The component supports the `disabled` prop even for those elements not supporting the native `disabled` attribute. Disabled elements may be still accessible via keyboard by using the `accessibleWhenDisabled` prop.
|
|
140
140
|
|
|
141
141
|
Non-native focusable elements will lose their focusability entirely. However, native focusable elements will retain their inherent focusability.
|
|
142
142
|
|
package/src/composite/types.ts
CHANGED
|
@@ -141,7 +141,7 @@ export type CompositeProps = CompositeStoreProps & {
|
|
|
141
141
|
* `onFocusVisible` prop.
|
|
142
142
|
* The component supports the `disabled` prop even for those elements not
|
|
143
143
|
* supporting the native `disabled` attribute. Disabled elements may be
|
|
144
|
-
* still accessible via keyboard by using the
|
|
144
|
+
* still accessible via keyboard by using the `accessibleWhenDisabled`
|
|
145
145
|
* prop.
|
|
146
146
|
* Non-native focusable elements will lose their focusability entirely.
|
|
147
147
|
* However, native focusable elements will retain their inherent focusability.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import deepmerge from 'deepmerge';
|
|
2
2
|
import fastDeepEqual from 'fast-deep-equal/es6/index.js';
|
|
3
3
|
import { isPlainObject } from 'is-plain-object';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
4
5
|
import {
|
|
5
6
|
createContext,
|
|
6
7
|
useContext,
|
|
@@ -11,9 +12,12 @@ import {
|
|
|
11
12
|
import warn from '@wordpress/warning';
|
|
12
13
|
import { useUpdateEffect } from '../utils';
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
type ContextSystemValue = Record<
|
|
16
|
+
string,
|
|
17
|
+
Record< string, unknown > | undefined
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
export const ComponentsContext = createContext< ContextSystemValue >( {} );
|
|
17
21
|
ComponentsContext.displayName = 'ComponentsContext';
|
|
18
22
|
|
|
19
23
|
export const useComponentsContext = () => useContext( ComponentsContext );
|
|
@@ -27,7 +31,11 @@ export const useComponentsContext = () => useContext( ComponentsContext );
|
|
|
27
31
|
* @param {Record<string, any>} props.value
|
|
28
32
|
* @return {Record<string, any>} The consolidated value.
|
|
29
33
|
*/
|
|
30
|
-
function useContextSystemBridge( {
|
|
34
|
+
function useContextSystemBridge( {
|
|
35
|
+
value,
|
|
36
|
+
}: {
|
|
37
|
+
value?: ContextSystemValue;
|
|
38
|
+
} ): ContextSystemValue {
|
|
31
39
|
const parentContext = useComponentsContext();
|
|
32
40
|
|
|
33
41
|
const valueRef = useRef( value );
|
|
@@ -82,7 +90,13 @@ function useContextSystemBridge( { value } ) {
|
|
|
82
90
|
* @param {T} options.value Props to render into connected components.
|
|
83
91
|
* @return {React.JSX.Element} A Provider wrapped component.
|
|
84
92
|
*/
|
|
85
|
-
const BaseContextSystemProvider = ( {
|
|
93
|
+
const BaseContextSystemProvider = ( {
|
|
94
|
+
children,
|
|
95
|
+
value,
|
|
96
|
+
}: {
|
|
97
|
+
children: ReactNode;
|
|
98
|
+
value?: ContextSystemValue;
|
|
99
|
+
} ) => {
|
|
86
100
|
const contextValue = useContextSystemBridge( { value } );
|
|
87
101
|
|
|
88
102
|
return (
|
package/src/context/stories/{ComponentsProvider.stories.jsx → ComponentsProvider.stories.tsx}
RENAMED
|
@@ -4,7 +4,7 @@ import { View } from '../../view';
|
|
|
4
4
|
import { Text } from '../../text';
|
|
5
5
|
import { ContextSystemProvider } from '../index';
|
|
6
6
|
|
|
7
|
-
const SomeContext = createContext();
|
|
7
|
+
const SomeContext = createContext< number | undefined >( undefined );
|
|
8
8
|
const useSomeContext = () => useContext( SomeContext );
|
|
9
9
|
|
|
10
10
|
export default {
|
|
@@ -39,7 +39,7 @@ const innerContext = {
|
|
|
39
39
|
|
|
40
40
|
const InnerContent = memo( () => {
|
|
41
41
|
const state = useSomeContext();
|
|
42
|
-
const isEven = state % 2 === 0;
|
|
42
|
+
const isEven = state !== undefined && state % 2 === 0;
|
|
43
43
|
return (
|
|
44
44
|
<View style={ { background: isEven ? 'red' : 'initial' } }>
|
|
45
45
|
<Text>Card (inside innerContext)</Text>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`props should render _override props 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<div
|
|
6
|
-
class="components-component test-component css-
|
|
6
|
+
class="components-component test-component css-1j9m8ga-View emotion-0"
|
|
7
7
|
data-wp-c16t="true"
|
|
8
8
|
data-wp-component="Component"
|
|
9
9
|
>
|
|
@@ -15,7 +15,7 @@ exports[`props should render _override props 1`] = `
|
|
|
15
15
|
exports[`props should render context props 1`] = `
|
|
16
16
|
<div>
|
|
17
17
|
<div
|
|
18
|
-
class="components-component css-
|
|
18
|
+
class="components-component css-1j9m8ga-View emotion-0"
|
|
19
19
|
data-wp-c16t="true"
|
|
20
20
|
data-wp-component="Component"
|
|
21
21
|
>
|
|
@@ -27,7 +27,7 @@ exports[`props should render context props 1`] = `
|
|
|
27
27
|
exports[`props should render correctly 1`] = `
|
|
28
28
|
<div>
|
|
29
29
|
<div
|
|
30
|
-
class="components-component css-
|
|
30
|
+
class="components-component css-1j9m8ga-View emotion-0"
|
|
31
31
|
data-wp-c16t="true"
|
|
32
32
|
data-wp-component="Component"
|
|
33
33
|
/>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { describe, it } from 'vitest';
|
|
1
2
|
import type { ForwardedRef } from 'react';
|
|
2
3
|
import { contextConnect, contextConnectWithoutRef } from '../context-connect';
|
|
3
4
|
import type { WordPressComponentProps } from '../wordpress-component';
|
|
4
5
|
|
|
5
6
|
// Static TypeScript tests
|
|
6
|
-
/* eslint-disable jest/expect-expect */
|
|
7
7
|
describe( 'ref forwarding', () => {
|
|
8
8
|
const ComponentWithRef = (
|
|
9
9
|
props: WordPressComponentProps< {}, 'div' >,
|
|
@@ -47,4 +47,3 @@ describe( 'ref forwarding', () => {
|
|
|
47
47
|
<NoRef foo={ null } />;
|
|
48
48
|
} );
|
|
49
49
|
} );
|
|
50
|
-
/* eslint-enable jest/expect-expect */
|