@wordpress/components 28.2.0 → 28.3.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 +48 -0
- package/build/animation/index.js.map +1 -1
- package/build/autocomplete/autocompleter-ui.js +1 -0
- package/build/autocomplete/autocompleter-ui.js.map +1 -1
- package/build/autocomplete/index.js.map +1 -1
- package/build/base-control/index.js +14 -7
- package/build/base-control/index.js.map +1 -1
- package/build/border-box-control/border-box-control-visualizer/component.js +0 -4
- package/build/border-box-control/border-box-control-visualizer/component.js.map +1 -1
- package/build/button/index.js +5 -3
- package/build/button/index.js.map +1 -1
- package/build/button/types.js.map +1 -1
- package/build/combobox-control/index.js +4 -1
- package/build/combobox-control/index.js.map +1 -1
- package/build/composite/current/index.js.map +1 -1
- package/build/custom-select-control-v2/custom-select.js +57 -33
- package/build/custom-select-control-v2/custom-select.js.map +1 -1
- package/build/custom-select-control-v2/default-component/index.js +0 -1
- package/build/custom-select-control-v2/default-component/index.js.map +1 -1
- package/build/custom-select-control-v2/item.js +2 -0
- package/build/custom-select-control-v2/item.js.map +1 -1
- package/build/custom-select-control-v2/legacy-component/index.js +18 -6
- package/build/custom-select-control-v2/legacy-component/index.js.map +1 -1
- package/build/custom-select-control-v2/styles.js +90 -78
- package/build/custom-select-control-v2/styles.js.map +1 -1
- package/build/custom-select-control-v2/types.js.map +1 -1
- package/build/date-time/date-time/index.js +3 -1
- package/build/date-time/date-time/index.js.map +1 -1
- package/build/date-time/index.js +7 -0
- package/build/date-time/index.js.map +1 -1
- package/build/date-time/time/index.js +62 -145
- package/build/date-time/time/index.js.map +1 -1
- package/build/date-time/time-input/index.js +159 -0
- package/build/date-time/time-input/index.js.map +1 -0
- package/build/date-time/types.js.map +1 -1
- package/build/date-time/utils.js +64 -0
- package/build/date-time/utils.js.map +1 -1
- package/build/disclosure/index.js +0 -1
- package/build/disclosure/index.js.map +1 -1
- package/build/divider/component.js +0 -1
- package/build/divider/component.js.map +1 -1
- package/build/divider/types.js.map +1 -1
- package/build/dropdown-menu/index.js +1 -0
- package/build/dropdown-menu/index.js.map +1 -1
- package/build/dropdown-menu-v2/index.js +0 -1
- package/build/dropdown-menu-v2/index.js.map +1 -1
- package/build/dropdown-menu-v2/styles.js +15 -16
- package/build/dropdown-menu-v2/styles.js.map +1 -1
- package/build/dropdown-menu-v2/types.js.map +1 -1
- package/build/font-size-picker/font-size-picker-select.js +2 -2
- package/build/font-size-picker/font-size-picker-select.js.map +1 -1
- package/build/font-size-picker/index.js +1 -1
- package/build/font-size-picker/index.js.map +1 -1
- package/build/font-size-picker/utils.js +0 -4
- package/build/font-size-picker/utils.js.map +1 -1
- package/build/form-token-field/token.js +4 -1
- package/build/form-token-field/token.js.map +1 -1
- package/build/higher-order/with-spoken-messages/index.js +1 -2
- package/build/higher-order/with-spoken-messages/index.js.map +1 -1
- package/build/menu-items-choice/types.js.map +1 -1
- package/build/popover/index.js +0 -4
- package/build/popover/index.js.map +1 -1
- package/build/popover/utils.js +0 -1
- package/build/popover/utils.js.map +1 -1
- package/build/private-apis.js +2 -4
- package/build/private-apis.js.map +1 -1
- package/build/progress-bar/styles.js +19 -13
- package/build/progress-bar/styles.js.map +1 -1
- package/build/radio-group/context.js +0 -1
- package/build/radio-group/context.js.map +1 -1
- package/build/radio-group/index.js +0 -1
- package/build/radio-group/index.js.map +1 -1
- package/build/radio-group/radio.js +0 -1
- package/build/radio-group/radio.js.map +1 -1
- package/build/range-control/index.js +4 -1
- package/build/range-control/index.js.map +1 -1
- package/build/range-control/styles/range-control-styles.js +34 -28
- package/build/range-control/styles/range-control-styles.js.map +1 -1
- package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build/select-control/index.js +1 -2
- package/build/select-control/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +13 -8
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/tab-panel/index.js +0 -1
- package/build/tab-panel/index.js.map +1 -1
- package/build/tabs/index.js +0 -1
- package/build/tabs/index.js.map +1 -1
- package/build/tabs/styles.js +3 -5
- package/build/tabs/styles.js.map +1 -1
- package/build/tabs/tablist.js +148 -37
- package/build/tabs/tablist.js.map +1 -1
- package/build/tabs/types.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/as-radio-group.js +0 -2
- package/build/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +0 -2
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/component.js +0 -4
- package/build/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
- package/build/toolbar/toolbar/toolbar-container.js +0 -1
- package/build/toolbar/toolbar/toolbar-container.js.map +1 -1
- package/build/toolbar/toolbar/types.js.map +1 -1
- package/build/toolbar/toolbar-button/index.js +27 -19
- package/build/toolbar/toolbar-button/index.js.map +1 -1
- package/build/toolbar/toolbar-button/types.js.map +1 -1
- package/build/toolbar/toolbar-context/index.js +0 -1
- package/build/toolbar/toolbar-context/index.js.map +1 -1
- package/build/toolbar/toolbar-item/index.js +1 -1
- package/build/toolbar/toolbar-item/index.js.map +1 -1
- package/build/tooltip/index.js +3 -2
- package/build/tooltip/index.js.map +1 -1
- package/build/tooltip/types.js.map +1 -1
- package/build/unit-control/index.js +3 -3
- package/build/unit-control/index.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +7 -7
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/utils/hooks/use-update-effect.js +4 -1
- package/build/utils/hooks/use-update-effect.js.map +1 -1
- package/build-module/animation/index.js +0 -1
- package/build-module/animation/index.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.js +1 -0
- package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/base-control/index.js +13 -6
- package/build-module/base-control/index.js.map +1 -1
- package/build-module/border-box-control/border-box-control-visualizer/component.js +0 -4
- package/build-module/border-box-control/border-box-control-visualizer/component.js.map +1 -1
- package/build-module/button/index.js +5 -3
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/types.js.map +1 -1
- package/build-module/combobox-control/index.js +4 -1
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/composite/current/index.js +0 -3
- package/build-module/composite/current/index.js.map +1 -1
- package/build-module/custom-select-control-v2/custom-select.js +58 -35
- package/build-module/custom-select-control-v2/custom-select.js.map +1 -1
- package/build-module/custom-select-control-v2/default-component/index.js +0 -1
- package/build-module/custom-select-control-v2/default-component/index.js.map +1 -1
- package/build-module/custom-select-control-v2/item.js +2 -0
- package/build-module/custom-select-control-v2/item.js.map +1 -1
- package/build-module/custom-select-control-v2/legacy-component/index.js +18 -6
- package/build-module/custom-select-control-v2/legacy-component/index.js.map +1 -1
- package/build-module/custom-select-control-v2/styles.js +88 -76
- package/build-module/custom-select-control-v2/styles.js.map +1 -1
- package/build-module/custom-select-control-v2/types.js.map +1 -1
- package/build-module/date-time/date-time/index.js +4 -1
- package/build-module/date-time/date-time/index.js.map +1 -1
- package/build-module/date-time/index.js +2 -1
- package/build-module/date-time/index.js.map +1 -1
- package/build-module/date-time/time/index.js +65 -149
- package/build-module/date-time/time/index.js.map +1 -1
- package/build-module/date-time/time-input/index.js +151 -0
- package/build-module/date-time/time-input/index.js.map +1 -0
- package/build-module/date-time/types.js.map +1 -1
- package/build-module/date-time/utils.js +61 -0
- package/build-module/date-time/utils.js.map +1 -1
- package/build-module/disclosure/index.js +0 -1
- package/build-module/disclosure/index.js.map +1 -1
- package/build-module/divider/component.js +0 -1
- package/build-module/divider/component.js.map +1 -1
- package/build-module/divider/types.js.map +1 -1
- package/build-module/dropdown-menu/index.js +1 -0
- package/build-module/dropdown-menu/index.js.map +1 -1
- package/build-module/dropdown-menu-v2/index.js +0 -1
- package/build-module/dropdown-menu-v2/index.js.map +1 -1
- package/build-module/dropdown-menu-v2/styles.js +14 -15
- package/build-module/dropdown-menu-v2/styles.js.map +1 -1
- package/build-module/dropdown-menu-v2/types.js.map +1 -1
- package/build-module/font-size-picker/font-size-picker-select.js +1 -1
- package/build-module/font-size-picker/font-size-picker-select.js.map +1 -1
- package/build-module/font-size-picker/index.js +1 -1
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/font-size-picker/utils.js +0 -4
- package/build-module/font-size-picker/utils.js.map +1 -1
- package/build-module/form-token-field/token.js +4 -1
- package/build-module/form-token-field/token.js.map +1 -1
- package/build-module/higher-order/with-spoken-messages/index.js +1 -2
- package/build-module/higher-order/with-spoken-messages/index.js.map +1 -1
- package/build-module/menu-items-choice/types.js.map +1 -1
- package/build-module/popover/index.js +0 -3
- package/build-module/popover/index.js.map +1 -1
- package/build-module/popover/utils.js +0 -1
- package/build-module/popover/utils.js.map +1 -1
- package/build-module/private-apis.js +2 -4
- package/build-module/private-apis.js.map +1 -1
- package/build-module/progress-bar/styles.js +21 -13
- package/build-module/progress-bar/styles.js.map +1 -1
- package/build-module/radio-group/context.js +0 -1
- package/build-module/radio-group/context.js.map +1 -1
- package/build-module/radio-group/index.js +0 -1
- package/build-module/radio-group/index.js.map +1 -1
- package/build-module/radio-group/radio.js +0 -1
- package/build-module/radio-group/radio.js.map +1 -1
- package/build-module/range-control/index.js +4 -1
- package/build-module/range-control/index.js.map +1 -1
- package/build-module/range-control/styles/range-control-styles.js +34 -28
- package/build-module/range-control/styles/range-control-styles.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build-module/select-control/index.js +2 -3
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +12 -7
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/tab-panel/index.js +0 -1
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/tabs/index.js +0 -1
- package/build-module/tabs/index.js.map +1 -1
- package/build-module/tabs/styles.js +3 -4
- package/build-module/tabs/styles.js.map +1 -1
- package/build-module/tabs/tablist.js +149 -38
- package/build-module/tabs/tablist.js.map +1 -1
- package/build-module/tabs/types.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js +0 -1
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +0 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.js +0 -2
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
- package/build-module/toolbar/toolbar/toolbar-container.js +0 -1
- package/build-module/toolbar/toolbar/toolbar-container.js.map +1 -1
- package/build-module/toolbar/toolbar/types.js.map +1 -1
- package/build-module/toolbar/toolbar-button/index.js +27 -19
- package/build-module/toolbar/toolbar-button/index.js.map +1 -1
- package/build-module/toolbar/toolbar-button/types.js.map +1 -1
- package/build-module/toolbar/toolbar-context/index.js +0 -1
- package/build-module/toolbar/toolbar-context/index.js.map +1 -1
- package/build-module/toolbar/toolbar-item/index.js +1 -1
- package/build-module/toolbar/toolbar-item/index.js.map +1 -1
- package/build-module/tooltip/index.js +3 -2
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tooltip/types.js.map +1 -1
- package/build-module/unit-control/index.js +3 -3
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +7 -7
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/utils/hooks/use-update-effect.js +4 -1
- package/build-module/utils/hooks/use-update-effect.js.map +1 -1
- package/build-style/style-rtl.css +18 -0
- package/build-style/style.css +18 -0
- package/build-types/animation/index.d.ts.map +1 -1
- package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/base-control/index.d.ts +6 -20
- package/build-types/base-control/index.d.ts.map +1 -1
- package/build-types/base-control/stories/index.story.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-visualizer/component.d.ts.map +1 -1
- package/build-types/button/deprecated.d.ts +4 -4
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/button/stories/e2e/index.story.d.ts.map +1 -1
- package/build-types/button/types.d.ts +27 -10
- package/build-types/button/types.d.ts.map +1 -1
- package/build-types/combobox-control/index.d.ts.map +1 -1
- package/build-types/composite/current/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/custom-select.d.ts +2 -2
- package/build-types/custom-select-control-v2/custom-select.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/default-component/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/item.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/legacy-component/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/stories/default.story.d.ts +6 -3
- package/build-types/custom-select-control-v2/stories/default.story.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/styles.d.ts +18 -26
- package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/types.d.ts +12 -2
- package/build-types/custom-select-control-v2/types.d.ts.map +1 -1
- package/build-types/date-time/date-time/index.d.ts.map +1 -1
- package/build-types/date-time/index.d.ts +2 -1
- package/build-types/date-time/index.d.ts.map +1 -1
- package/build-types/date-time/stories/time-input.story.d.ts +12 -0
- package/build-types/date-time/stories/time-input.story.d.ts.map +1 -0
- package/build-types/date-time/time/index.d.ts +1 -1
- package/build-types/date-time/time/index.d.ts.map +1 -1
- package/build-types/date-time/time-input/index.d.ts +5 -0
- package/build-types/date-time/time-input/index.d.ts.map +1 -0
- package/build-types/date-time/time-input/test/index.d.ts +2 -0
- package/build-types/date-time/time-input/test/index.d.ts.map +1 -0
- package/build-types/date-time/types.d.ts +54 -0
- package/build-types/date-time/types.d.ts.map +1 -1
- package/build-types/date-time/utils.d.ts +40 -0
- package/build-types/date-time/utils.d.ts.map +1 -1
- package/build-types/disclosure/index.d.ts.map +1 -1
- package/build-types/divider/component.d.ts.map +1 -1
- package/build-types/divider/types.d.ts.map +1 -1
- package/build-types/dropdown-menu/index.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/index.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/types.d.ts.map +1 -1
- package/build-types/font-size-picker/styles.d.ts +1 -1
- package/build-types/font-size-picker/utils.d.ts.map +1 -1
- package/build-types/form-token-field/token.d.ts.map +1 -1
- package/build-types/higher-order/with-spoken-messages/index.d.ts +1 -2
- package/build-types/higher-order/with-spoken-messages/index.d.ts.map +1 -1
- package/build-types/menu-items-choice/types.d.ts +1 -1
- package/build-types/menu-items-choice/types.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/component.d.ts +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +1 -1
- package/build-types/navigator/navigator-button/component.d.ts +1 -1
- package/build-types/navigator/navigator-button/hook.d.ts +1 -1
- package/build-types/navigator/navigator-to-parent-button/component.d.ts +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/utils.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/progress-bar/styles.d.ts.map +1 -1
- package/build-types/radio-group/context.d.ts.map +1 -1
- package/build-types/radio-group/index.d.ts.map +1 -1
- package/build-types/radio-group/radio.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts.map +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts +2 -2
- package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/styles/select-control-styles.d.ts +5 -0
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/tabs/index.d.ts.map +1 -1
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/tabs/tablist.d.ts.map +1 -1
- package/build-types/tabs/types.d.ts.map +1 -1
- package/build-types/theme/stories/index.story.d.ts.map +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-base/component.d.ts.map +1 -1
- package/build-types/toolbar/toolbar/toolbar-container.d.ts.map +1 -1
- package/build-types/toolbar/toolbar/types.d.ts +6 -0
- package/build-types/toolbar/toolbar/types.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-button/index.d.ts +3 -96
- package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-button/types.d.ts +18 -0
- package/build-types/toolbar/toolbar-button/types.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-context/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-item/index.d.ts +1 -3
- package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/tooltip/types.d.ts +4 -0
- package/build-types/tooltip/types.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/utils/hooks/use-update-effect.d.ts +1 -1
- package/build-types/utils/hooks/use-update-effect.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/animation/index.tsx +0 -1
- package/src/autocomplete/autocompleter-ui.tsx +1 -0
- package/src/autocomplete/index.tsx +0 -1
- package/src/base-control/index.tsx +16 -6
- package/src/base-control/stories/index.story.tsx +0 -1
- package/src/border-box-control/border-box-control-visualizer/component.tsx +0 -5
- package/src/button/README.md +13 -0
- package/src/button/index.tsx +6 -4
- package/src/button/stories/e2e/index.story.tsx +2 -1
- package/src/button/test/index.tsx +17 -2
- package/src/button/types.ts +27 -10
- package/src/combobox-control/index.tsx +2 -0
- package/src/composite/current/index.ts +0 -2
- package/src/custom-select-control/test/index.js +42 -6
- package/src/custom-select-control-v2/custom-select.tsx +57 -22
- package/src/custom-select-control-v2/default-component/index.tsx +0 -1
- package/src/custom-select-control-v2/item.tsx +5 -1
- package/src/custom-select-control-v2/legacy-component/index.tsx +28 -7
- package/src/custom-select-control-v2/legacy-component/test/index.tsx +44 -8
- package/src/custom-select-control-v2/styles.ts +153 -83
- package/src/custom-select-control-v2/test/index.tsx +35 -5
- package/src/custom-select-control-v2/types.ts +18 -6
- package/src/date-time/README.md +8 -0
- package/src/date-time/date-time/index.tsx +2 -1
- package/src/date-time/index.ts +2 -1
- package/src/date-time/stories/time-input.story.tsx +36 -0
- package/src/date-time/time/index.tsx +77 -194
- package/src/date-time/time/test/index.tsx +61 -0
- package/src/date-time/time-input/index.tsx +196 -0
- package/src/date-time/time-input/test/index.tsx +171 -0
- package/src/date-time/types.ts +63 -0
- package/src/date-time/utils.ts +69 -0
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +116 -96
- package/src/disclosure/index.tsx +0 -1
- package/src/divider/component.tsx +0 -1
- package/src/divider/types.ts +0 -1
- package/src/dropdown-menu/index.tsx +1 -0
- package/src/dropdown-menu-v2/index.tsx +0 -1
- package/src/dropdown-menu-v2/styles.ts +0 -1
- package/src/dropdown-menu-v2/types.ts +0 -1
- package/src/font-size-picker/font-size-picker-select.tsx +1 -1
- package/src/font-size-picker/index.tsx +1 -1
- package/src/font-size-picker/test/index.tsx +6 -6
- package/src/font-size-picker/utils.ts +0 -5
- package/src/form-token-field/token.tsx +2 -0
- package/src/higher-order/navigate-regions/style.scss +25 -13
- package/src/higher-order/with-spoken-messages/index.tsx +1 -2
- package/src/menu-items-choice/types.ts +2 -1
- package/src/palette-edit/test/index.tsx +1 -0
- package/src/popover/index.tsx +0 -2
- package/src/popover/utils.ts +0 -1
- package/src/private-apis.ts +2 -5
- package/src/progress-bar/styles.ts +18 -9
- package/src/radio-group/context.tsx +0 -1
- package/src/radio-group/index.tsx +0 -1
- package/src/radio-group/radio.tsx +0 -1
- package/src/range-control/index.tsx +2 -0
- package/src/range-control/styles/range-control-styles.ts +6 -2
- package/src/resizable-box/resize-tooltip/utils.ts +1 -1
- package/src/select-control/index.tsx +3 -4
- package/src/select-control/styles/select-control-styles.ts +17 -6
- package/src/tab-panel/index.tsx +0 -1
- package/src/tabs/index.tsx +0 -1
- package/src/tabs/stories/index.story.tsx +25 -18
- package/src/tabs/styles.ts +18 -14
- package/src/tabs/tablist.tsx +187 -43
- package/src/tabs/types.ts +0 -1
- package/src/theme/stories/index.story.tsx +2 -0
- package/src/toggle-group-control/toggle-group-control/as-radio-group.tsx +0 -1
- package/src/toggle-group-control/toggle-group-control/component.tsx +0 -2
- package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +0 -2
- package/src/toolbar/toolbar/README.md +9 -0
- package/src/toolbar/toolbar/style.scss +7 -0
- package/src/toolbar/toolbar/toolbar-container.tsx +0 -1
- package/src/toolbar/toolbar/types.ts +6 -0
- package/src/toolbar/toolbar-button/index.tsx +30 -17
- package/src/toolbar/toolbar-button/types.ts +19 -0
- package/src/toolbar/toolbar-context/index.ts +0 -1
- package/src/toolbar/toolbar-item/index.tsx +1 -1
- package/src/tooltip/index.tsx +3 -2
- package/src/tooltip/test/index.tsx +18 -0
- package/src/tooltip/types.ts +4 -0
- package/src/unit-control/index.tsx +3 -2
- package/src/unit-control/styles/unit-control-styles.ts +10 -4
- package/src/utils/hooks/use-update-effect.js +8 -1
- package/tsconfig.tsbuildinfo +1 -1
package/src/tabs/tablist.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
// eslint-disable-next-line no-restricted-imports
|
|
5
4
|
import * as Ariakit from '@ariakit/react';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -10,8 +9,9 @@ import * as Ariakit from '@ariakit/react';
|
|
|
10
9
|
import warning from '@wordpress/warning';
|
|
11
10
|
import {
|
|
12
11
|
forwardRef,
|
|
12
|
+
useCallback,
|
|
13
13
|
useEffect,
|
|
14
|
-
|
|
14
|
+
useInsertionEffect,
|
|
15
15
|
useRef,
|
|
16
16
|
useState,
|
|
17
17
|
} from '@wordpress/element';
|
|
@@ -25,49 +25,111 @@ import { TabListWrapper } from './styles';
|
|
|
25
25
|
import type { WordPressComponentProps } from '../context';
|
|
26
26
|
import clsx from 'clsx';
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
onUpdate?: () => void
|
|
31
|
-
) {
|
|
32
|
-
const [ indicatorPosition, setIndicatorPosition ] = useState( {
|
|
33
|
-
left: 0,
|
|
34
|
-
top: 0,
|
|
35
|
-
width: 0,
|
|
36
|
-
height: 0,
|
|
37
|
-
} );
|
|
28
|
+
// TODO: move these into a separate utility file, for use in other components
|
|
29
|
+
// such as ToggleGroupControl.
|
|
38
30
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Any function.
|
|
33
|
+
*/
|
|
34
|
+
type AnyFunction = ( ...args: any ) => any;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates a stable callback function that has access to the latest state and
|
|
38
|
+
* can be used within event handlers and effect callbacks. Throws when used in
|
|
39
|
+
* the render phase.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
*
|
|
43
|
+
* ```tsx
|
|
44
|
+
* function Component(props) {
|
|
45
|
+
* const onClick = useEvent(props.onClick);
|
|
46
|
+
* React.useEffect(() => {}, [onClick]);
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
function useEvent< T extends AnyFunction >( callback?: T ) {
|
|
51
|
+
const ref = useRef< AnyFunction | undefined >( () => {
|
|
52
|
+
throw new Error( 'Cannot call an event handler while rendering.' );
|
|
43
53
|
} );
|
|
54
|
+
useInsertionEffect( () => {
|
|
55
|
+
ref.current = callback;
|
|
56
|
+
} );
|
|
57
|
+
return useCallback< AnyFunction >(
|
|
58
|
+
( ...args ) => ref.current?.( ...args ),
|
|
59
|
+
[]
|
|
60
|
+
) as T;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* `useResizeObserver` options.
|
|
65
|
+
*/
|
|
66
|
+
type UseResizeObserverOptions = {
|
|
67
|
+
/**
|
|
68
|
+
* Whether to trigger the callback when an element's ResizeObserver is
|
|
69
|
+
* first set up.
|
|
70
|
+
*
|
|
71
|
+
* @default true
|
|
72
|
+
*/
|
|
73
|
+
fireOnObserve?: boolean;
|
|
74
|
+
};
|
|
44
75
|
|
|
45
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Fires `onResize` when the target element is resized.
|
|
78
|
+
*
|
|
79
|
+
* **The element must not be stored in a ref**, else it won't be observed
|
|
80
|
+
* or updated. Instead, it should be stored in a React state or equivalent.
|
|
81
|
+
*
|
|
82
|
+
* It sets up a `ResizeObserver` that tracks the element under the hood. The
|
|
83
|
+
* target element can be changed dynamically, and the observer will be
|
|
84
|
+
* updated accordingly.
|
|
85
|
+
*
|
|
86
|
+
* By default, `onResize` is called when the observer is set up, in addition
|
|
87
|
+
* to when the element is resized. This behavior can be disabled with the
|
|
88
|
+
* `fireOnObserve` option.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
*
|
|
92
|
+
* ```tsx
|
|
93
|
+
* const [ targetElement, setTargetElement ] = useState< HTMLElement | null >();
|
|
94
|
+
*
|
|
95
|
+
* useResizeObserver( targetElement, ( element ) => {
|
|
96
|
+
* console.log( 'Element resized:', element );
|
|
97
|
+
* } );
|
|
98
|
+
*
|
|
99
|
+
* <div ref={ setTargetElement } />;
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
function useResizeObserver(
|
|
103
|
+
/**
|
|
104
|
+
* The target element to observe. It can be changed dynamically.
|
|
105
|
+
*/
|
|
106
|
+
targetElement: HTMLElement | undefined | null,
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Callback to fire when the element is resized. It will also be
|
|
110
|
+
* called when the observer is set up, unless `fireOnObserve` is
|
|
111
|
+
* set to `false`.
|
|
112
|
+
*/
|
|
113
|
+
onResize: ( element: HTMLElement ) => void,
|
|
114
|
+
{ fireOnObserve = true }: UseResizeObserverOptions = {}
|
|
115
|
+
) {
|
|
116
|
+
const onResizeEvent = useEvent( onResize );
|
|
117
|
+
|
|
118
|
+
const observedElementRef = useRef< HTMLElement | null >();
|
|
46
119
|
const resizeObserverRef = useRef< ResizeObserver >();
|
|
120
|
+
|
|
47
121
|
useEffect( () => {
|
|
48
122
|
if ( targetElement === observedElementRef.current ) {
|
|
49
123
|
return;
|
|
50
124
|
}
|
|
51
125
|
|
|
52
|
-
observedElementRef.current = targetElement
|
|
53
|
-
|
|
54
|
-
function updateIndicator( element: HTMLElement ) {
|
|
55
|
-
setIndicatorPosition( {
|
|
56
|
-
// Workaround to prevent unwanted scrollbars, see:
|
|
57
|
-
// https://github.com/WordPress/gutenberg/pull/61979
|
|
58
|
-
left: Math.max( element.offsetLeft - 1, 0 ),
|
|
59
|
-
top: Math.max( element.offsetTop - 1, 0 ),
|
|
60
|
-
width: parseFloat( getComputedStyle( element ).width ),
|
|
61
|
-
height: parseFloat( getComputedStyle( element ).height ),
|
|
62
|
-
} );
|
|
63
|
-
updateCallbackRef.current?.();
|
|
64
|
-
}
|
|
126
|
+
observedElementRef.current = targetElement;
|
|
65
127
|
|
|
66
128
|
// Set up a ResizeObserver.
|
|
67
129
|
if ( ! resizeObserverRef.current ) {
|
|
68
130
|
resizeObserverRef.current = new ResizeObserver( () => {
|
|
69
131
|
if ( observedElementRef.current ) {
|
|
70
|
-
|
|
132
|
+
onResizeEvent( observedElementRef.current );
|
|
71
133
|
}
|
|
72
134
|
} );
|
|
73
135
|
}
|
|
@@ -75,7 +137,9 @@ function useTrackElementOffset(
|
|
|
75
137
|
|
|
76
138
|
// Observe new element.
|
|
77
139
|
if ( targetElement ) {
|
|
78
|
-
|
|
140
|
+
if ( fireOnObserve ) {
|
|
141
|
+
onResizeEvent( targetElement );
|
|
142
|
+
}
|
|
79
143
|
resizeObserver.observe( targetElement );
|
|
80
144
|
}
|
|
81
145
|
|
|
@@ -85,35 +149,115 @@ function useTrackElementOffset(
|
|
|
85
149
|
resizeObserver.unobserve( observedElementRef.current );
|
|
86
150
|
}
|
|
87
151
|
};
|
|
88
|
-
}, [ targetElement ] );
|
|
152
|
+
}, [ fireOnObserve, onResizeEvent, targetElement ] );
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The position and dimensions of an element, relative to its offset parent.
|
|
157
|
+
*/
|
|
158
|
+
type ElementOffsetRect = {
|
|
159
|
+
/**
|
|
160
|
+
* The distance from the left edge of the offset parent to the left edge of
|
|
161
|
+
* the element.
|
|
162
|
+
*/
|
|
163
|
+
left: number;
|
|
164
|
+
/**
|
|
165
|
+
* The distance from the top edge of the offset parent to the top edge of
|
|
166
|
+
* the element.
|
|
167
|
+
*/
|
|
168
|
+
top: number;
|
|
169
|
+
/**
|
|
170
|
+
* The width of the element.
|
|
171
|
+
*/
|
|
172
|
+
width: number;
|
|
173
|
+
/**
|
|
174
|
+
* The height of the element.
|
|
175
|
+
*/
|
|
176
|
+
height: number;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* An `ElementOffsetRect` object with all values set to zero.
|
|
181
|
+
*/
|
|
182
|
+
const NULL_ELEMENT_OFFSET_RECT = {
|
|
183
|
+
left: 0,
|
|
184
|
+
top: 0,
|
|
185
|
+
width: 0,
|
|
186
|
+
height: 0,
|
|
187
|
+
} satisfies ElementOffsetRect;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Returns the position and dimensions of an element, relative to its offset
|
|
191
|
+
* parent. This is useful in contexts where `getBoundingClientRect` is not
|
|
192
|
+
* suitable, such as when the element is transformed.
|
|
193
|
+
*
|
|
194
|
+
* **Note:** the `left` and `right` values are adjusted due to a limitation
|
|
195
|
+
* in the way the browser calculates the offset position of the element,
|
|
196
|
+
* which can cause unwanted scrollbars to appear. This adjustment makes the
|
|
197
|
+
* values potentially inaccurate within a range of 1 pixel.
|
|
198
|
+
*/
|
|
199
|
+
function getElementOffsetRect( element: HTMLElement ): ElementOffsetRect {
|
|
200
|
+
return {
|
|
201
|
+
// The adjustments mentioned in the documentation above are necessary
|
|
202
|
+
// because `offsetLeft` and `offsetTop` are rounded to the nearest pixel,
|
|
203
|
+
// which can result in a position mismatch that causes unwanted overflow.
|
|
204
|
+
// For context, see: https://github.com/WordPress/gutenberg/pull/61979
|
|
205
|
+
left: Math.max( element.offsetLeft - 1, 0 ),
|
|
206
|
+
top: Math.max( element.offsetTop - 1, 0 ),
|
|
207
|
+
// This is a workaround to obtain these values with a sub-pixel precision,
|
|
208
|
+
// since `offsetWidth` and `offsetHeight` are rounded to the nearest pixel.
|
|
209
|
+
width: parseFloat( getComputedStyle( element ).width ),
|
|
210
|
+
height: parseFloat( getComputedStyle( element ).height ),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Tracks the position and dimensions of an element, relative to its offset
|
|
216
|
+
* parent. The element can be changed dynamically.
|
|
217
|
+
*/
|
|
218
|
+
function useTrackElementOffsetRect(
|
|
219
|
+
targetElement: HTMLElement | undefined | null
|
|
220
|
+
) {
|
|
221
|
+
const [ indicatorPosition, setIndicatorPosition ] =
|
|
222
|
+
useState< ElementOffsetRect >( NULL_ELEMENT_OFFSET_RECT );
|
|
223
|
+
|
|
224
|
+
useResizeObserver( targetElement, ( element ) =>
|
|
225
|
+
setIndicatorPosition( getElementOffsetRect( element ) )
|
|
226
|
+
);
|
|
89
227
|
|
|
90
228
|
return indicatorPosition;
|
|
91
229
|
}
|
|
92
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Context object for the `onUpdate` callback of `useOnValueUpdate`.
|
|
233
|
+
*/
|
|
93
234
|
type ValueUpdateContext< T > = {
|
|
94
235
|
previousValue: T;
|
|
95
236
|
};
|
|
96
237
|
|
|
238
|
+
/**
|
|
239
|
+
* Calls the `onUpdate` callback when the `value` changes.
|
|
240
|
+
*/
|
|
97
241
|
function useOnValueUpdate< T >(
|
|
242
|
+
/**
|
|
243
|
+
* The value to watch for changes.
|
|
244
|
+
*/
|
|
98
245
|
value: T,
|
|
246
|
+
/**
|
|
247
|
+
* Callback to fire when the value changes.
|
|
248
|
+
*/
|
|
99
249
|
onUpdate: ( context: ValueUpdateContext< T > ) => void
|
|
100
250
|
) {
|
|
101
251
|
const previousValueRef = useRef( value );
|
|
102
|
-
|
|
103
|
-
// TODO: replace with useEventCallback or similar when officially available.
|
|
104
|
-
const updateCallbackRef = useRef( onUpdate );
|
|
105
|
-
useLayoutEffect( () => {
|
|
106
|
-
updateCallbackRef.current = onUpdate;
|
|
107
|
-
} );
|
|
108
|
-
|
|
252
|
+
const updateCallbackEvent = useEvent( onUpdate );
|
|
109
253
|
useEffect( () => {
|
|
110
254
|
if ( previousValueRef.current !== value ) {
|
|
111
|
-
|
|
255
|
+
updateCallbackEvent( {
|
|
112
256
|
previousValue: previousValueRef.current,
|
|
113
257
|
} );
|
|
114
258
|
previousValueRef.current = value;
|
|
115
259
|
}
|
|
116
|
-
}, [ value ] );
|
|
260
|
+
}, [ updateCallbackEvent, value ] );
|
|
117
261
|
}
|
|
118
262
|
|
|
119
263
|
export const TabList = forwardRef<
|
|
@@ -123,7 +267,7 @@ export const TabList = forwardRef<
|
|
|
123
267
|
const context = useTabsContext();
|
|
124
268
|
|
|
125
269
|
const selectedId = context?.store.useState( 'selectedId' );
|
|
126
|
-
const indicatorPosition =
|
|
270
|
+
const indicatorPosition = useTrackElementOffsetRect(
|
|
127
271
|
context?.store.item( selectedId )?.element
|
|
128
272
|
);
|
|
129
273
|
|
package/src/tabs/types.ts
CHANGED
|
@@ -59,9 +59,11 @@ export const ColorScheme: StoryFn< typeof Theme > = ( {
|
|
|
59
59
|
} ) => {
|
|
60
60
|
const { colors } = generateThemeVariables( { accent, background } );
|
|
61
61
|
const { gray, ...otherColors } = colors;
|
|
62
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
62
63
|
const contrastIssues = Object.entries(
|
|
63
64
|
checkContrasts( { accent, background }, colors )
|
|
64
65
|
).filter( ( [ _, error ] ) => !! error );
|
|
66
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
65
67
|
|
|
66
68
|
const Chip = ( { color, name }: { color: string; name: string } ) => (
|
|
67
69
|
<HStack justify="flex-start">
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { ForwardedRef } from 'react';
|
|
5
|
-
// eslint-disable-next-line no-restricted-imports
|
|
6
5
|
import { LayoutGroup } from 'framer-motion';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* WordPress dependencies
|
|
10
9
|
*/
|
|
11
10
|
import { useInstanceId } from '@wordpress/compose';
|
|
12
|
-
import { __ } from '@wordpress/i18n';
|
|
13
11
|
import { useMemo } from '@wordpress/element';
|
|
14
12
|
|
|
15
13
|
/**
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { ForwardedRef } from 'react';
|
|
5
|
-
// eslint-disable-next-line no-restricted-imports
|
|
6
5
|
import * as Ariakit from '@ariakit/react';
|
|
7
|
-
// eslint-disable-next-line no-restricted-imports
|
|
8
6
|
import { motion } from 'framer-motion';
|
|
9
7
|
|
|
10
8
|
/**
|
|
@@ -74,6 +74,15 @@ Leave undefined for the default style. Or `'unstyled'` which removes the border
|
|
|
74
74
|
- Required: No
|
|
75
75
|
- Default: `undefined`
|
|
76
76
|
|
|
77
|
+
#### `orientation`: `'horizontal' | 'vertical'`
|
|
78
|
+
|
|
79
|
+
Specifies the toolbar's orientation.
|
|
80
|
+
|
|
81
|
+
Leave undefined or 'horizontal' for horizontal orientation keyboard interactions, choose 'vertical' for the alternative.
|
|
82
|
+
|
|
83
|
+
- Required: No
|
|
84
|
+
- Default: `horizontal`
|
|
85
|
+
|
|
77
86
|
## Related components
|
|
78
87
|
|
|
79
88
|
- Toolbar may contain [ToolbarGroup](/packages/components/src/toolbar-group/README.md), [ToolbarButton](/packages/components/src/toolbar-button/README.md) and [ToolbarItem](/packages/components/src/toolbar-Item/README.md) as children.
|
|
@@ -20,6 +20,13 @@
|
|
|
20
20
|
|
|
21
21
|
.components-accessible-toolbar,
|
|
22
22
|
.components-toolbar {
|
|
23
|
+
|
|
24
|
+
&[aria-orientation="vertical"] {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
align-items: center;
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
.components-button {
|
|
24
31
|
position: relative;
|
|
25
32
|
height: $block-toolbar-height;
|
|
@@ -16,22 +16,36 @@ import Button from '../../button';
|
|
|
16
16
|
import ToolbarItem from '../toolbar-item';
|
|
17
17
|
import ToolbarContext from '../toolbar-context';
|
|
18
18
|
import ToolbarButtonContainer from './toolbar-button-container';
|
|
19
|
-
import type { ToolbarButtonProps } from './types';
|
|
19
|
+
import type { ToolbarButtonOverriddenProps, ToolbarButtonProps } from './types';
|
|
20
20
|
import type { WordPressComponentProps } from '../../context';
|
|
21
21
|
|
|
22
|
+
function useDeprecatedProps( {
|
|
23
|
+
isDisabled,
|
|
24
|
+
...otherProps
|
|
25
|
+
}: React.ComponentProps< typeof ToolbarButton > ) {
|
|
26
|
+
return {
|
|
27
|
+
disabled: isDisabled,
|
|
28
|
+
...otherProps,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
function UnforwardedToolbarButton(
|
|
23
|
-
|
|
33
|
+
props: Omit<
|
|
34
|
+
WordPressComponentProps< ToolbarButtonProps, typeof Button, false >,
|
|
35
|
+
'accessibleWhenDisabled' // By default, ToolbarButton will be focusable when disabled.
|
|
36
|
+
> &
|
|
37
|
+
ToolbarButtonOverriddenProps,
|
|
38
|
+
ref: ForwardedRef< any >
|
|
39
|
+
) {
|
|
40
|
+
const {
|
|
24
41
|
children,
|
|
25
42
|
className,
|
|
26
43
|
containerClassName,
|
|
27
44
|
extraProps,
|
|
28
45
|
isActive,
|
|
29
|
-
isDisabled,
|
|
30
46
|
title,
|
|
31
|
-
...
|
|
32
|
-
}
|
|
33
|
-
ref: ForwardedRef< any >
|
|
34
|
-
) {
|
|
47
|
+
...restProps
|
|
48
|
+
} = useDeprecatedProps( props );
|
|
35
49
|
const accessibleToolbarState = useContext( ToolbarContext );
|
|
36
50
|
|
|
37
51
|
if ( ! accessibleToolbarState ) {
|
|
@@ -39,10 +53,10 @@ function UnforwardedToolbarButton(
|
|
|
39
53
|
<ToolbarButtonContainer className={ containerClassName }>
|
|
40
54
|
<Button
|
|
41
55
|
ref={ ref }
|
|
42
|
-
icon={
|
|
56
|
+
icon={ restProps.icon }
|
|
43
57
|
label={ title }
|
|
44
|
-
shortcut={
|
|
45
|
-
data-subscript={
|
|
58
|
+
shortcut={ restProps.shortcut }
|
|
59
|
+
data-subscript={ restProps.subscript }
|
|
46
60
|
onClick={ (
|
|
47
61
|
event: ReactMouseEvent<
|
|
48
62
|
HTMLButtonElement & HTMLAnchorElement,
|
|
@@ -50,9 +64,9 @@ function UnforwardedToolbarButton(
|
|
|
50
64
|
>
|
|
51
65
|
) => {
|
|
52
66
|
event.stopPropagation();
|
|
53
|
-
// TODO: Possible bug; maybe use onClick instead of
|
|
54
|
-
if (
|
|
55
|
-
|
|
67
|
+
// TODO: Possible bug; maybe use onClick instead of restProps.onClick.
|
|
68
|
+
if ( restProps.onClick ) {
|
|
69
|
+
restProps.onClick( event );
|
|
56
70
|
}
|
|
57
71
|
} }
|
|
58
72
|
className={ clsx(
|
|
@@ -60,10 +74,10 @@ function UnforwardedToolbarButton(
|
|
|
60
74
|
className
|
|
61
75
|
) }
|
|
62
76
|
isPressed={ isActive }
|
|
63
|
-
|
|
77
|
+
accessibleWhenDisabled
|
|
64
78
|
data-toolbar-item
|
|
65
79
|
{ ...extraProps }
|
|
66
|
-
{ ...
|
|
80
|
+
{ ...restProps }
|
|
67
81
|
>
|
|
68
82
|
{ children }
|
|
69
83
|
</Button>
|
|
@@ -78,14 +92,13 @@ function UnforwardedToolbarButton(
|
|
|
78
92
|
<ToolbarItem
|
|
79
93
|
className={ clsx( 'components-toolbar-button', className ) }
|
|
80
94
|
{ ...extraProps }
|
|
81
|
-
{ ...
|
|
95
|
+
{ ...restProps }
|
|
82
96
|
ref={ ref }
|
|
83
97
|
>
|
|
84
98
|
{ ( toolbarItemProps ) => (
|
|
85
99
|
<Button
|
|
86
100
|
label={ title }
|
|
87
101
|
isPressed={ isActive }
|
|
88
|
-
disabled={ isDisabled }
|
|
89
102
|
{ ...toolbarItemProps }
|
|
90
103
|
>
|
|
91
104
|
{ children }
|
|
@@ -22,6 +22,9 @@ export type ToolbarButtonProps = {
|
|
|
22
22
|
isActive?: boolean;
|
|
23
23
|
/**
|
|
24
24
|
* Indicates if the button is disabled.
|
|
25
|
+
*
|
|
26
|
+
* @deprecated Use `disabled` instead.
|
|
27
|
+
* @ignore
|
|
25
28
|
*/
|
|
26
29
|
isDisabled?: boolean;
|
|
27
30
|
/**
|
|
@@ -34,6 +37,22 @@ export type ToolbarButtonProps = {
|
|
|
34
37
|
title?: string;
|
|
35
38
|
};
|
|
36
39
|
|
|
40
|
+
export type ToolbarButtonOverriddenProps = {
|
|
41
|
+
/**
|
|
42
|
+
* Whether to keep the button focusable when disabled.
|
|
43
|
+
*
|
|
44
|
+
* In most cases, it is recommended to set this to `true`. Disabling a control without maintaining focusability
|
|
45
|
+
* can cause accessibility issues, by hiding their presence from screen reader users,
|
|
46
|
+
* or by preventing focus from returning to a trigger element.
|
|
47
|
+
*
|
|
48
|
+
* Learn more about the [focusability of disabled controls](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#focusabilityofdisabledcontrols)
|
|
49
|
+
* in the WAI-ARIA Authoring Practices Guide.
|
|
50
|
+
*
|
|
51
|
+
* @default true
|
|
52
|
+
*/
|
|
53
|
+
accessibleWhenDisabled?: boolean;
|
|
54
|
+
};
|
|
55
|
+
|
|
37
56
|
export type ToolbarButtonContainerProps = {
|
|
38
57
|
/**
|
|
39
58
|
* Children to be rendered inside the button container.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
// eslint-disable-next-line no-restricted-imports
|
|
5
4
|
import * as Ariakit from '@ariakit/react';
|
|
6
5
|
import type { ForwardedRef } from 'react';
|
|
7
6
|
|
|
@@ -50,6 +49,7 @@ function ToolbarItem(
|
|
|
50
49
|
|
|
51
50
|
return (
|
|
52
51
|
<Ariakit.ToolbarItem
|
|
52
|
+
accessibleWhenDisabled
|
|
53
53
|
{ ...allProps }
|
|
54
54
|
store={ accessibleToolbarStore }
|
|
55
55
|
render={ render }
|
package/src/tooltip/index.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
// eslint-disable-next-line no-restricted-imports
|
|
5
4
|
import * as Ariakit from '@ariakit/react';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
@@ -45,6 +45,7 @@ function UnforwardedTooltip(
|
|
|
45
45
|
) {
|
|
46
46
|
const {
|
|
47
47
|
children,
|
|
48
|
+
className,
|
|
48
49
|
delay = TOOLTIP_DELAY,
|
|
49
50
|
hideOnClick = true,
|
|
50
51
|
placement,
|
|
@@ -113,7 +114,7 @@ function UnforwardedTooltip(
|
|
|
113
114
|
{ isOnlyChild && ( text || shortcut ) && (
|
|
114
115
|
<Ariakit.Tooltip
|
|
115
116
|
{ ...restProps }
|
|
116
|
-
className=
|
|
117
|
+
className={ clsx( 'components-tooltip', className ) }
|
|
117
118
|
unmountOnHide
|
|
118
119
|
gutter={ 4 }
|
|
119
120
|
id={ describedById }
|
|
@@ -105,6 +105,24 @@ describe( 'Tooltip', () => {
|
|
|
105
105
|
screen.getByRole( 'button', { name: 'Anchor' } )
|
|
106
106
|
).not.toHaveAttribute( 'data-foo' );
|
|
107
107
|
} );
|
|
108
|
+
|
|
109
|
+
it( 'should add default and custom class names to the tooltip', async () => {
|
|
110
|
+
render( <Tooltip { ...props } className="foo" /> );
|
|
111
|
+
|
|
112
|
+
// Hover over the anchor, tooltip should show
|
|
113
|
+
await hover(
|
|
114
|
+
screen.getByRole( 'button', { name: 'Tooltip anchor' } )
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
// Check default and custom classnames
|
|
118
|
+
await waitFor( () =>
|
|
119
|
+
expect(
|
|
120
|
+
screen.getByRole( 'tooltip', {
|
|
121
|
+
name: 'tooltip text',
|
|
122
|
+
} )
|
|
123
|
+
).toHaveClass( 'components-tooltip', 'foo' )
|
|
124
|
+
);
|
|
125
|
+
} );
|
|
108
126
|
} );
|
|
109
127
|
|
|
110
128
|
describe( 'keyboard focus', () => {
|
package/src/tooltip/types.ts
CHANGED
|
@@ -16,6 +16,10 @@ export type TooltipProps = {
|
|
|
16
16
|
* **Note**: Accepts only one child element.
|
|
17
17
|
*/
|
|
18
18
|
children: React.ReactElement;
|
|
19
|
+
/**
|
|
20
|
+
* Custom class name for the tooltip.
|
|
21
|
+
*/
|
|
22
|
+
className?: string;
|
|
19
23
|
/**
|
|
20
24
|
* Option to hide the tooltip when the anchor is clicked.
|
|
21
25
|
*
|
|
@@ -167,11 +167,12 @@ function UnforwardedUnitControl(
|
|
|
167
167
|
if ( ! disableUnits && isUnitSelectTabbable && units.length ) {
|
|
168
168
|
handleOnKeyDown = ( event: KeyboardEvent< HTMLInputElement > ) => {
|
|
169
169
|
props.onKeyDown?.( event );
|
|
170
|
-
// Unless the meta key was pressed (to avoid interfering with
|
|
171
|
-
// shortcuts, e.g. pastes),
|
|
170
|
+
// Unless the meta or ctrl key was pressed (to avoid interfering with
|
|
171
|
+
// shortcuts, e.g. pastes), move focus to the unit select if a key
|
|
172
172
|
// matches the first character of a unit.
|
|
173
173
|
if (
|
|
174
174
|
! event.metaKey &&
|
|
175
|
+
! event.ctrlKey &&
|
|
175
176
|
reFirstCharacterOfUnits.test( event.key )
|
|
176
177
|
) {
|
|
177
178
|
refInputSuffix.current?.focus();
|