@wordpress/components 28.1.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 +179 -120
- 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 +58 -36
- 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 +33 -15
- package/build/custom-select-control-v2/legacy-component/index.js.map +1 -1
- package/build/custom-select-control-v2/styles.js +92 -65
- 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/drop-zone/index.js +16 -79
- package/build/drop-zone/index.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/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/menu-items-choice/types.js.map +1 -1
- package/build/palette-edit/index.js +30 -38
- package/build/palette-edit/index.js.map +1 -1
- package/build/palette-edit/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 +59 -38
- 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 +33 -16
- package/build-module/custom-select-control-v2/legacy-component/index.js.map +1 -1
- package/build-module/custom-select-control-v2/styles.js +90 -63
- 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/drop-zone/index.js +17 -80
- package/build-module/drop-zone/index.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/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/menu-items-choice/types.js.map +1 -1
- package/build-module/palette-edit/index.js +31 -39
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/palette-edit/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 +46 -6
- package/build-style/style.css +46 -6
- 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/stories/index.story.d.ts +15 -0
- package/build-types/custom-select-control/stories/index.story.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 -22
- package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/types.d.ts +13 -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/drop-zone/index.d.ts +3 -0
- package/build-types/drop-zone/index.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/palette-edit/index.d.ts.map +1 -1
- package/build-types/palette-edit/types.d.ts +1 -3
- package/build-types/palette-edit/types.d.ts.map +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/stories/index.story.tsx +32 -3
- package/src/custom-select-control/test/index.js +247 -28
- package/src/custom-select-control-v2/custom-select.tsx +58 -23
- 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 +45 -16
- package/src/custom-select-control-v2/legacy-component/test/index.tsx +261 -43
- package/src/custom-select-control-v2/styles.ts +156 -74
- package/src/custom-select-control-v2/test/index.tsx +35 -5
- package/src/custom-select-control-v2/types.ts +19 -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/drop-zone/index.tsx +17 -76
- package/src/drop-zone/style.scss +51 -16
- 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/lock-unlock.js +1 -1
- package/src/menu-items-choice/types.ts +2 -1
- package/src/palette-edit/index.tsx +33 -45
- package/src/palette-edit/test/index.tsx +3 -4
- package/src/palette-edit/types.ts +1 -3
- 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
|
@@ -14,7 +14,11 @@ import { useState } from '@wordpress/element';
|
|
|
14
14
|
*/
|
|
15
15
|
import UncontrolledCustomSelectControl from '..';
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const customClassName = 'amber-skies';
|
|
18
|
+
const customStyles = {
|
|
19
|
+
backgroundColor: 'rgb(127, 255, 212)',
|
|
20
|
+
rotate: '13deg',
|
|
21
|
+
};
|
|
18
22
|
|
|
19
23
|
const props = {
|
|
20
24
|
label: 'label!',
|
|
@@ -26,7 +30,7 @@ const props = {
|
|
|
26
30
|
{
|
|
27
31
|
key: 'flower2',
|
|
28
32
|
name: 'crimson clover',
|
|
29
|
-
className:
|
|
33
|
+
className: customClassName,
|
|
30
34
|
},
|
|
31
35
|
{
|
|
32
36
|
key: 'flower3',
|
|
@@ -35,37 +39,114 @@ const props = {
|
|
|
35
39
|
{
|
|
36
40
|
key: 'color1',
|
|
37
41
|
name: 'amber',
|
|
38
|
-
className:
|
|
42
|
+
className: customClassName,
|
|
39
43
|
},
|
|
40
44
|
{
|
|
41
45
|
key: 'color2',
|
|
42
46
|
name: 'aquamarine',
|
|
43
|
-
style:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
style: customStyles,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
key: 'color3',
|
|
51
|
+
name: 'tomato (with custom props)',
|
|
52
|
+
className: customClassName,
|
|
53
|
+
style: customStyles,
|
|
54
|
+
// try passing a valid HTML attribute
|
|
55
|
+
'aria-label': 'test label',
|
|
56
|
+
// try adding a custom prop
|
|
57
|
+
customPropFoo: 'foo',
|
|
47
58
|
},
|
|
48
59
|
],
|
|
49
60
|
};
|
|
50
61
|
|
|
51
|
-
const ControlledCustomSelectControl = ( {
|
|
52
|
-
|
|
62
|
+
const ControlledCustomSelectControl = ( {
|
|
63
|
+
options,
|
|
64
|
+
onChange: onChangeProp,
|
|
65
|
+
...restProps
|
|
66
|
+
} ) => {
|
|
67
|
+
const [ value, setValue ] = useState( restProps.value ?? options[ 0 ] );
|
|
68
|
+
|
|
69
|
+
const onChange = ( changeObject ) => {
|
|
70
|
+
onChangeProp?.( changeObject );
|
|
71
|
+
setValue( changeObject.selectedItem );
|
|
72
|
+
};
|
|
73
|
+
|
|
53
74
|
return (
|
|
54
75
|
<UncontrolledCustomSelectControl
|
|
55
76
|
{ ...restProps }
|
|
56
77
|
options={ options }
|
|
57
|
-
onChange={
|
|
78
|
+
onChange={ onChange }
|
|
58
79
|
value={ options.find( ( option ) => option.key === value.key ) }
|
|
59
80
|
/>
|
|
60
81
|
);
|
|
61
82
|
};
|
|
62
83
|
|
|
84
|
+
it( 'Should apply external controlled updates', async () => {
|
|
85
|
+
const mockOnChange = jest.fn();
|
|
86
|
+
const { rerender } = render(
|
|
87
|
+
<UncontrolledCustomSelectControl
|
|
88
|
+
{ ...props }
|
|
89
|
+
value={ props.options[ 0 ] }
|
|
90
|
+
onChange={ mockOnChange }
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const currentSelectedItem = screen.getByRole( 'button', {
|
|
95
|
+
expanded: false,
|
|
96
|
+
} );
|
|
97
|
+
|
|
98
|
+
expect( currentSelectedItem ).toHaveTextContent( props.options[ 0 ].name );
|
|
99
|
+
|
|
100
|
+
rerender(
|
|
101
|
+
<UncontrolledCustomSelectControl
|
|
102
|
+
{ ...props }
|
|
103
|
+
value={ props.options[ 1 ] }
|
|
104
|
+
/>
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
expect( currentSelectedItem ).toHaveTextContent( props.options[ 1 ].name );
|
|
108
|
+
|
|
109
|
+
expect( mockOnChange ).not.toHaveBeenCalled();
|
|
110
|
+
} );
|
|
111
|
+
|
|
63
112
|
describe.each( [
|
|
64
|
-
[ '
|
|
65
|
-
[ '
|
|
113
|
+
[ 'Uncontrolled', UncontrolledCustomSelectControl ],
|
|
114
|
+
[ 'Controlled', ControlledCustomSelectControl ],
|
|
66
115
|
] )( 'CustomSelectControl %s', ( ...modeAndComponent ) => {
|
|
67
116
|
const [ , Component ] = modeAndComponent;
|
|
68
117
|
|
|
118
|
+
it( 'Should select the first option when no explicit initial value is passed without firing onChange', () => {
|
|
119
|
+
const mockOnChange = jest.fn();
|
|
120
|
+
render( <Component { ...props } onChange={ mockOnChange } /> );
|
|
121
|
+
|
|
122
|
+
expect(
|
|
123
|
+
screen.getByRole( 'button', {
|
|
124
|
+
expanded: false,
|
|
125
|
+
} )
|
|
126
|
+
).toHaveTextContent( props.options[ 0 ].name );
|
|
127
|
+
|
|
128
|
+
expect( mockOnChange ).not.toHaveBeenCalled();
|
|
129
|
+
} );
|
|
130
|
+
|
|
131
|
+
it( 'Should pick the initially selected option if the value prop is passed without firing onChange', async () => {
|
|
132
|
+
const mockOnChange = jest.fn();
|
|
133
|
+
render(
|
|
134
|
+
<Component
|
|
135
|
+
{ ...props }
|
|
136
|
+
onChange={ mockOnChange }
|
|
137
|
+
value={ props.options[ 3 ] }
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
expect(
|
|
142
|
+
screen.getByRole( 'button', {
|
|
143
|
+
expanded: false,
|
|
144
|
+
} )
|
|
145
|
+
).toHaveTextContent( props.options[ 3 ].name );
|
|
146
|
+
|
|
147
|
+
expect( mockOnChange ).not.toHaveBeenCalled();
|
|
148
|
+
} );
|
|
149
|
+
|
|
69
150
|
it( 'Should replace the initial selection when a new item is selected', async () => {
|
|
70
151
|
const user = userEvent.setup();
|
|
71
152
|
|
|
@@ -109,14 +190,14 @@ describe.each( [
|
|
|
109
190
|
await user.keyboard( '{enter}' );
|
|
110
191
|
expect(
|
|
111
192
|
screen.getByRole( 'listbox', {
|
|
112
|
-
name:
|
|
193
|
+
name: props.label,
|
|
113
194
|
} )
|
|
114
195
|
).toBeVisible();
|
|
115
196
|
|
|
116
197
|
await user.keyboard( '{escape}' );
|
|
117
198
|
expect(
|
|
118
199
|
screen.queryByRole( 'listbox', {
|
|
119
|
-
name:
|
|
200
|
+
name: props.label,
|
|
120
201
|
} )
|
|
121
202
|
).not.toBeInTheDocument();
|
|
122
203
|
|
|
@@ -144,7 +225,7 @@ describe.each( [
|
|
|
144
225
|
// assert against filtered array
|
|
145
226
|
itemsWithClass.map( ( { name } ) =>
|
|
146
227
|
expect( screen.getByRole( 'option', { name } ) ).toHaveClass(
|
|
147
|
-
|
|
228
|
+
customClassName
|
|
148
229
|
)
|
|
149
230
|
);
|
|
150
231
|
|
|
@@ -156,15 +237,13 @@ describe.each( [
|
|
|
156
237
|
// assert against filtered array
|
|
157
238
|
itemsWithoutClass.map( ( { name } ) =>
|
|
158
239
|
expect( screen.getByRole( 'option', { name } ) ).not.toHaveClass(
|
|
159
|
-
|
|
240
|
+
customClassName
|
|
160
241
|
)
|
|
161
242
|
);
|
|
162
243
|
} );
|
|
163
244
|
|
|
164
245
|
it( 'Should apply styles only to options that have styles defined', async () => {
|
|
165
246
|
const user = userEvent.setup();
|
|
166
|
-
const customStyles =
|
|
167
|
-
'background-color: rgb(127, 255, 212); rotate: 13deg;';
|
|
168
247
|
|
|
169
248
|
render( <Component { ...props } /> );
|
|
170
249
|
|
|
@@ -262,6 +341,115 @@ describe.each( [
|
|
|
262
341
|
expect( screen.getByRole( 'option', { name: /hint/i } ) ).toBeVisible();
|
|
263
342
|
} );
|
|
264
343
|
|
|
344
|
+
it( 'Should return object onChange', async () => {
|
|
345
|
+
const user = userEvent.setup();
|
|
346
|
+
const mockOnChange = jest.fn();
|
|
347
|
+
|
|
348
|
+
render( <Component { ...props } onChange={ mockOnChange } /> );
|
|
349
|
+
|
|
350
|
+
await user.click(
|
|
351
|
+
screen.getByRole( 'button', {
|
|
352
|
+
expanded: false,
|
|
353
|
+
} )
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
await user.click(
|
|
357
|
+
screen.getByRole( 'option', {
|
|
358
|
+
name: 'aquamarine',
|
|
359
|
+
} )
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
expect( mockOnChange ).toHaveBeenCalledTimes( 1 );
|
|
363
|
+
expect( mockOnChange ).toHaveBeenLastCalledWith(
|
|
364
|
+
expect.objectContaining( {
|
|
365
|
+
inputValue: '',
|
|
366
|
+
isOpen: false,
|
|
367
|
+
selectedItem: expect.objectContaining( {
|
|
368
|
+
name: 'aquamarine',
|
|
369
|
+
} ),
|
|
370
|
+
type: expect.any( String ),
|
|
371
|
+
} )
|
|
372
|
+
);
|
|
373
|
+
} );
|
|
374
|
+
|
|
375
|
+
it( 'Should return selectedItem object when specified onChange', async () => {
|
|
376
|
+
const user = userEvent.setup();
|
|
377
|
+
const mockOnChange = jest.fn();
|
|
378
|
+
|
|
379
|
+
render( <Component { ...props } onChange={ mockOnChange } /> );
|
|
380
|
+
|
|
381
|
+
await user.tab();
|
|
382
|
+
expect(
|
|
383
|
+
screen.getByRole( 'button', {
|
|
384
|
+
expanded: false,
|
|
385
|
+
} )
|
|
386
|
+
).toHaveFocus();
|
|
387
|
+
|
|
388
|
+
await user.keyboard( 'p' );
|
|
389
|
+
await user.keyboard( '{enter}' );
|
|
390
|
+
|
|
391
|
+
expect( mockOnChange ).toHaveBeenCalledTimes( 1 );
|
|
392
|
+
expect( mockOnChange ).toHaveBeenLastCalledWith(
|
|
393
|
+
expect.objectContaining( {
|
|
394
|
+
selectedItem: expect.objectContaining( {
|
|
395
|
+
key: 'flower3',
|
|
396
|
+
name: 'poppy',
|
|
397
|
+
} ),
|
|
398
|
+
} )
|
|
399
|
+
);
|
|
400
|
+
} );
|
|
401
|
+
|
|
402
|
+
it( "Should pass arbitrary props to onChange's selectedItem, but apply only style and className to DOM elements", async () => {
|
|
403
|
+
const user = userEvent.setup();
|
|
404
|
+
const onChangeMock = jest.fn();
|
|
405
|
+
|
|
406
|
+
render( <Component { ...props } onChange={ onChangeMock } /> );
|
|
407
|
+
|
|
408
|
+
const currentSelectedItem = screen.getByRole( 'button', {
|
|
409
|
+
expanded: false,
|
|
410
|
+
} );
|
|
411
|
+
|
|
412
|
+
await user.click( currentSelectedItem );
|
|
413
|
+
|
|
414
|
+
const optionWithCustomAttributes = screen.getByRole( 'option', {
|
|
415
|
+
name: 'tomato (with custom props)',
|
|
416
|
+
} );
|
|
417
|
+
|
|
418
|
+
// Assert that the option element does not have the custom attributes
|
|
419
|
+
expect( optionWithCustomAttributes ).not.toHaveAttribute(
|
|
420
|
+
'customPropFoo'
|
|
421
|
+
);
|
|
422
|
+
expect( optionWithCustomAttributes ).not.toHaveAttribute(
|
|
423
|
+
'aria-label'
|
|
424
|
+
);
|
|
425
|
+
|
|
426
|
+
await user.click( optionWithCustomAttributes );
|
|
427
|
+
|
|
428
|
+
expect( onChangeMock ).toHaveBeenCalledTimes( 1 );
|
|
429
|
+
expect( onChangeMock ).toHaveBeenCalledWith(
|
|
430
|
+
expect.objectContaining( {
|
|
431
|
+
selectedItem: expect.objectContaining( {
|
|
432
|
+
key: 'color3',
|
|
433
|
+
name: 'tomato (with custom props)',
|
|
434
|
+
className: customClassName,
|
|
435
|
+
style: customStyles,
|
|
436
|
+
'aria-label': 'test label',
|
|
437
|
+
customPropFoo: 'foo',
|
|
438
|
+
} ),
|
|
439
|
+
} )
|
|
440
|
+
);
|
|
441
|
+
} );
|
|
442
|
+
|
|
443
|
+
it( 'Should label the component correctly even when the label is not visible', () => {
|
|
444
|
+
render( <Component { ...props } hideLabelFromVision /> );
|
|
445
|
+
|
|
446
|
+
expect(
|
|
447
|
+
screen.getByRole( 'button', {
|
|
448
|
+
name: props.label,
|
|
449
|
+
} )
|
|
450
|
+
).toBeVisible();
|
|
451
|
+
} );
|
|
452
|
+
|
|
265
453
|
describe( 'Keyboard behavior and accessibility', () => {
|
|
266
454
|
it( 'Captures the keypress event and does not let it propagate', async () => {
|
|
267
455
|
const user = userEvent.setup();
|
|
@@ -282,7 +470,7 @@ describe.each( [
|
|
|
282
470
|
await user.click( currentSelectedItem );
|
|
283
471
|
|
|
284
472
|
const customSelect = screen.getByRole( 'listbox', {
|
|
285
|
-
name:
|
|
473
|
+
name: props.label,
|
|
286
474
|
} );
|
|
287
475
|
await user.type( customSelect, '{enter}' );
|
|
288
476
|
|
|
@@ -304,14 +492,16 @@ describe.each( [
|
|
|
304
492
|
await user.keyboard( '{enter}' );
|
|
305
493
|
expect(
|
|
306
494
|
screen.getByRole( 'listbox', {
|
|
307
|
-
name:
|
|
495
|
+
name: props.label,
|
|
308
496
|
} )
|
|
309
497
|
).toHaveFocus();
|
|
310
498
|
|
|
311
499
|
await user.keyboard( '{arrowdown}' );
|
|
312
500
|
await user.keyboard( '{enter}' );
|
|
313
501
|
|
|
314
|
-
expect( currentSelectedItem ).toHaveTextContent(
|
|
502
|
+
expect( currentSelectedItem ).toHaveTextContent(
|
|
503
|
+
props.options[ 1 ].name
|
|
504
|
+
);
|
|
315
505
|
} );
|
|
316
506
|
|
|
317
507
|
it( 'Should be able to type characters to select matching options', async () => {
|
|
@@ -327,7 +517,7 @@ describe.each( [
|
|
|
327
517
|
await user.keyboard( '{enter}' );
|
|
328
518
|
expect(
|
|
329
519
|
screen.getByRole( 'listbox', {
|
|
330
|
-
name:
|
|
520
|
+
name: props.label,
|
|
331
521
|
} )
|
|
332
522
|
).toHaveFocus();
|
|
333
523
|
|
|
@@ -353,7 +543,7 @@ describe.each( [
|
|
|
353
543
|
|
|
354
544
|
expect(
|
|
355
545
|
screen.queryByRole( 'listbox', {
|
|
356
|
-
name:
|
|
546
|
+
name: props.label,
|
|
357
547
|
hidden: true,
|
|
358
548
|
} )
|
|
359
549
|
).not.toBeInTheDocument();
|
|
@@ -362,6 +552,32 @@ describe.each( [
|
|
|
362
552
|
expect( currentSelectedItem ).toHaveTextContent( 'aquamarine' );
|
|
363
553
|
} );
|
|
364
554
|
|
|
555
|
+
it( 'Can change selection with a focused input and closed dropdown while pressing arrow keys', async () => {
|
|
556
|
+
const user = userEvent.setup();
|
|
557
|
+
|
|
558
|
+
render( <Component { ...props } /> );
|
|
559
|
+
|
|
560
|
+
const currentSelectedItem = screen.getByRole( 'button', {
|
|
561
|
+
expanded: false,
|
|
562
|
+
} );
|
|
563
|
+
|
|
564
|
+
await user.tab();
|
|
565
|
+
expect( currentSelectedItem ).toHaveFocus();
|
|
566
|
+
expect( currentSelectedItem ).toHaveTextContent(
|
|
567
|
+
props.options[ 0 ].name
|
|
568
|
+
);
|
|
569
|
+
|
|
570
|
+
await user.keyboard( '{arrowdown}' );
|
|
571
|
+
await user.keyboard( '{arrowdown}' );
|
|
572
|
+
expect(
|
|
573
|
+
screen.queryByRole( 'listbox', { name: props.label } )
|
|
574
|
+
).not.toBeInTheDocument();
|
|
575
|
+
|
|
576
|
+
expect( currentSelectedItem ).toHaveTextContent(
|
|
577
|
+
props.options[ 2 ].name
|
|
578
|
+
);
|
|
579
|
+
} );
|
|
580
|
+
|
|
365
581
|
it( 'Should have correct aria-selected value for selections', async () => {
|
|
366
582
|
const user = userEvent.setup();
|
|
367
583
|
|
|
@@ -422,11 +638,14 @@ describe.each( [
|
|
|
422
638
|
const onBlurMock = jest.fn();
|
|
423
639
|
|
|
424
640
|
render(
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
641
|
+
<>
|
|
642
|
+
<Component
|
|
643
|
+
{ ...props }
|
|
644
|
+
onFocus={ onFocusMock }
|
|
645
|
+
onBlur={ onBlurMock }
|
|
646
|
+
/>
|
|
647
|
+
<button>Focus stop</button>
|
|
648
|
+
</>
|
|
430
649
|
);
|
|
431
650
|
|
|
432
651
|
const currentSelectedItem = screen.getByRole( 'button', {
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import * as Ariakit from '@ariakit/react';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
|
-
import { createContext, useMemo } from '@wordpress/element';
|
|
9
|
+
import { createContext, useCallback, useMemo } from '@wordpress/element';
|
|
5
10
|
import { __, sprintf } from '@wordpress/i18n';
|
|
6
11
|
|
|
7
12
|
/**
|
|
@@ -14,11 +19,12 @@ import type {
|
|
|
14
19
|
CustomSelectStore,
|
|
15
20
|
CustomSelectButtonProps,
|
|
16
21
|
CustomSelectButtonSize,
|
|
22
|
+
_CustomSelectInternalProps,
|
|
17
23
|
_CustomSelectProps,
|
|
18
24
|
} from './types';
|
|
19
|
-
import type { WordPressComponentProps } from '../context';
|
|
20
25
|
import InputBase from '../input-control/input-base';
|
|
21
26
|
import SelectControlChevronDown from '../select-control/chevron-down';
|
|
27
|
+
import BaseControl from '../base-control';
|
|
22
28
|
|
|
23
29
|
export const CustomSelectContext =
|
|
24
30
|
createContext< CustomSelectContextType >( undefined );
|
|
@@ -50,11 +56,10 @@ const CustomSelectButton = ( {
|
|
|
50
56
|
store,
|
|
51
57
|
...restProps
|
|
52
58
|
}: Omit<
|
|
53
|
-
|
|
54
|
-
CustomSelectButtonProps &
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
>,
|
|
59
|
+
React.ComponentProps< typeof Ariakit.Select > &
|
|
60
|
+
CustomSelectButtonProps &
|
|
61
|
+
CustomSelectButtonSize &
|
|
62
|
+
CustomSelectStore,
|
|
58
63
|
'onChange'
|
|
59
64
|
> ) => {
|
|
60
65
|
const { value: currentValue } = store.useState();
|
|
@@ -70,17 +75,17 @@ const CustomSelectButton = ( {
|
|
|
70
75
|
size={ size }
|
|
71
76
|
hasCustomRenderProp={ !! renderSelectedValue }
|
|
72
77
|
store={ store }
|
|
73
|
-
// to match legacy behavior where using arrow keys
|
|
74
|
-
// move selection rather than open the popover
|
|
75
|
-
showOnKeyDown={ false }
|
|
76
78
|
>
|
|
77
|
-
|
|
79
|
+
{ computedRenderSelectedValue( currentValue ) }
|
|
78
80
|
</Styled.Select>
|
|
79
81
|
);
|
|
80
82
|
};
|
|
81
83
|
|
|
82
84
|
function _CustomSelect(
|
|
83
|
-
props:
|
|
85
|
+
props: _CustomSelectInternalProps &
|
|
86
|
+
_CustomSelectProps &
|
|
87
|
+
CustomSelectStore &
|
|
88
|
+
CustomSelectButtonSize
|
|
84
89
|
) {
|
|
85
90
|
const {
|
|
86
91
|
children,
|
|
@@ -88,18 +93,40 @@ function _CustomSelect(
|
|
|
88
93
|
label,
|
|
89
94
|
size,
|
|
90
95
|
store,
|
|
96
|
+
className,
|
|
97
|
+
isLegacy = false,
|
|
91
98
|
...restProps
|
|
92
99
|
} = props;
|
|
93
100
|
|
|
101
|
+
const onSelectPopoverKeyDown: React.KeyboardEventHandler< HTMLDivElement > =
|
|
102
|
+
useCallback(
|
|
103
|
+
( e ) => {
|
|
104
|
+
if ( isLegacy ) {
|
|
105
|
+
e.stopPropagation();
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
[ isLegacy ]
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const contextValue = useMemo( () => ( { store, size } ), [ store, size ] );
|
|
112
|
+
|
|
94
113
|
return (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
114
|
+
// Where should `restProps` be forwarded to?
|
|
115
|
+
<div className={ className }>
|
|
116
|
+
<Ariakit.SelectLabel
|
|
117
|
+
store={ store }
|
|
118
|
+
render={
|
|
119
|
+
hideLabelFromVision ? (
|
|
120
|
+
// @ts-expect-error `children` are passed via the render prop
|
|
121
|
+
<VisuallyHidden />
|
|
122
|
+
) : (
|
|
123
|
+
// @ts-expect-error `children` are passed via the render prop
|
|
124
|
+
<BaseControl.VisualLabel as="div" />
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
>
|
|
128
|
+
{ label }
|
|
129
|
+
</Ariakit.SelectLabel>
|
|
103
130
|
<InputBase
|
|
104
131
|
__next40pxDefaultSize
|
|
105
132
|
size={ size }
|
|
@@ -109,14 +136,22 @@ function _CustomSelect(
|
|
|
109
136
|
{ ...restProps }
|
|
110
137
|
size={ size }
|
|
111
138
|
store={ store }
|
|
139
|
+
// Match legacy behavior (move selection rather than open the popover)
|
|
140
|
+
showOnKeyDown={ ! isLegacy }
|
|
112
141
|
/>
|
|
113
|
-
<Styled.SelectPopover
|
|
114
|
-
|
|
142
|
+
<Styled.SelectPopover
|
|
143
|
+
gutter={ 12 }
|
|
144
|
+
store={ store }
|
|
145
|
+
sameWidth
|
|
146
|
+
slide={ false }
|
|
147
|
+
onKeyDown={ onSelectPopoverKeyDown }
|
|
148
|
+
>
|
|
149
|
+
<CustomSelectContext.Provider value={ contextValue }>
|
|
115
150
|
{ children }
|
|
116
151
|
</CustomSelectContext.Provider>
|
|
117
152
|
</Styled.SelectPopover>
|
|
118
153
|
</InputBase>
|
|
119
|
-
|
|
154
|
+
</div>
|
|
120
155
|
);
|
|
121
156
|
}
|
|
122
157
|
|
|
@@ -17,7 +17,11 @@ export function CustomSelectItem( {
|
|
|
17
17
|
}: WordPressComponentProps< CustomSelectItemProps, 'div', false > ) {
|
|
18
18
|
const customSelectContext = useContext( CustomSelectContext );
|
|
19
19
|
return (
|
|
20
|
-
<Styled.SelectItem
|
|
20
|
+
<Styled.SelectItem
|
|
21
|
+
store={ customSelectContext?.store }
|
|
22
|
+
size={ customSelectContext?.size ?? 'default' }
|
|
23
|
+
{ ...props }
|
|
24
|
+
>
|
|
21
25
|
{ children ?? props.value }
|
|
22
26
|
<Styled.SelectedItemCheck>
|
|
23
27
|
<Icon icon={ check } />
|
|
@@ -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
|
* Internal dependencies
|
|
@@ -14,20 +14,25 @@ import * as Styled from '../styles';
|
|
|
14
14
|
|
|
15
15
|
function CustomSelectControl( props: LegacyCustomSelectProps ) {
|
|
16
16
|
const {
|
|
17
|
-
__experimentalShowSelectedHint,
|
|
17
|
+
__experimentalShowSelectedHint = false,
|
|
18
18
|
__next40pxDefaultSize = false,
|
|
19
19
|
describedBy,
|
|
20
20
|
options,
|
|
21
21
|
onChange,
|
|
22
22
|
size = 'default',
|
|
23
23
|
value,
|
|
24
|
+
className: classNameProp,
|
|
24
25
|
...restProps
|
|
25
26
|
} = props;
|
|
26
27
|
|
|
27
28
|
// Forward props + store from v2 implementation
|
|
28
29
|
const store = Ariakit.useSelectStore( {
|
|
29
30
|
async setValue( nextValue ) {
|
|
30
|
-
|
|
31
|
+
const nextOption = options.find(
|
|
32
|
+
( item ) => item.name === nextValue
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
if ( ! onChange || ! nextOption ) {
|
|
31
36
|
return;
|
|
32
37
|
}
|
|
33
38
|
|
|
@@ -42,25 +47,31 @@ function CustomSelectControl( props: LegacyCustomSelectProps ) {
|
|
|
42
47
|
),
|
|
43
48
|
inputValue: '',
|
|
44
49
|
isOpen: state.open,
|
|
45
|
-
selectedItem:
|
|
46
|
-
name: nextValue as string,
|
|
47
|
-
key: nextValue as string,
|
|
48
|
-
},
|
|
50
|
+
selectedItem: nextOption,
|
|
49
51
|
type: '',
|
|
50
52
|
};
|
|
51
53
|
onChange( changeObject );
|
|
52
54
|
},
|
|
55
|
+
value: value?.name,
|
|
56
|
+
// Setting the first option as a default value when no value is provided
|
|
57
|
+
// is already done natively by the underlying Ariakit component,
|
|
58
|
+
// but doing this explicitly avoids the `onChange` callback from firing
|
|
59
|
+
// on initial render, thus making this implementation closer to the v1.
|
|
60
|
+
defaultValue: options[ 0 ]?.name,
|
|
53
61
|
} );
|
|
54
62
|
|
|
55
63
|
const children = options.map(
|
|
56
|
-
( { name, key, __experimentalHint,
|
|
64
|
+
( { name, key, __experimentalHint, style, className } ) => {
|
|
57
65
|
const withHint = (
|
|
58
|
-
<Styled.
|
|
66
|
+
<Styled.WithHintItemWrapper>
|
|
59
67
|
<span>{ name }</span>
|
|
60
|
-
<Styled.
|
|
68
|
+
<Styled.WithHintItemHint
|
|
69
|
+
// TODO: Legacy classname. Add V1 styles are removed from the codebase
|
|
70
|
+
// className="components-custom-select-control__item-hint"
|
|
71
|
+
>
|
|
61
72
|
{ __experimentalHint }
|
|
62
|
-
</Styled.
|
|
63
|
-
</Styled.
|
|
73
|
+
</Styled.WithHintItemHint>
|
|
74
|
+
</Styled.WithHintItemWrapper>
|
|
64
75
|
);
|
|
65
76
|
|
|
66
77
|
return (
|
|
@@ -68,7 +79,16 @@ function CustomSelectControl( props: LegacyCustomSelectProps ) {
|
|
|
68
79
|
key={ key }
|
|
69
80
|
value={ name }
|
|
70
81
|
children={ __experimentalHint ? withHint : name }
|
|
71
|
-
{
|
|
82
|
+
style={ style }
|
|
83
|
+
className={ clsx(
|
|
84
|
+
// TODO: Legacy classname. Add V1 styles are removed from the codebase
|
|
85
|
+
// 'components-custom-select-control__item',
|
|
86
|
+
className
|
|
87
|
+
// TODO: Legacy classname. Add V1 styles are removed from the codebase
|
|
88
|
+
// {
|
|
89
|
+
// 'has-hint': __experimentalHint,
|
|
90
|
+
// }
|
|
91
|
+
) }
|
|
72
92
|
/>
|
|
73
93
|
);
|
|
74
94
|
}
|
|
@@ -82,12 +102,15 @@ function CustomSelectControl( props: LegacyCustomSelectProps ) {
|
|
|
82
102
|
);
|
|
83
103
|
|
|
84
104
|
return (
|
|
85
|
-
|
|
105
|
+
<Styled.SelectedExperimentalHintWrapper>
|
|
86
106
|
{ currentValue }
|
|
87
|
-
<Styled.SelectedExperimentalHintItem
|
|
107
|
+
<Styled.SelectedExperimentalHintItem
|
|
108
|
+
// TODO: Legacy classname. Add V1 styles are removed from the codebase
|
|
109
|
+
// className="components-custom-select-control__hint"
|
|
110
|
+
>
|
|
88
111
|
{ currentHint?.__experimentalHint }
|
|
89
112
|
</Styled.SelectedExperimentalHintItem>
|
|
90
|
-
|
|
113
|
+
</Styled.SelectedExperimentalHintWrapper>
|
|
91
114
|
);
|
|
92
115
|
};
|
|
93
116
|
|
|
@@ -114,6 +137,12 @@ function CustomSelectControl( props: LegacyCustomSelectProps ) {
|
|
|
114
137
|
}
|
|
115
138
|
size={ translatedSize }
|
|
116
139
|
store={ store }
|
|
140
|
+
className={ clsx(
|
|
141
|
+
// TODO: Legacy classname. Add V1 styles are removed from the codebase
|
|
142
|
+
// 'components-custom-select-control',
|
|
143
|
+
classNameProp
|
|
144
|
+
) }
|
|
145
|
+
isLegacy
|
|
117
146
|
{ ...restProps }
|
|
118
147
|
>
|
|
119
148
|
{ children }
|