@wordpress/components 26.0.4 → 27.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.stylelintrc.js +2 -2
- package/CHANGELOG.md +45 -0
- package/CONTRIBUTING.md +72 -0
- package/build/autocomplete/index.js +3 -8
- package/build/autocomplete/index.js.map +1 -1
- package/build/base-control/index.native.js.map +1 -1
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/button/index.js +2 -2
- package/build/button/index.js.map +1 -1
- package/build/button/index.native.js.map +1 -1
- package/build/color-picker/component.js +10 -1
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/styles.js +8 -9
- package/build/color-picker/styles.js.map +1 -1
- package/build/combobox-control/index.js +4 -9
- package/build/combobox-control/index.js.map +1 -1
- package/build/confirm-dialog/component.js.map +1 -1
- package/build/custom-select-control/index.js +2 -15
- package/build/custom-select-control/index.js.map +1 -1
- package/build/custom-select-control-v2/custom-select-item.js +32 -0
- package/build/custom-select-control-v2/custom-select-item.js.map +1 -0
- package/build/custom-select-control-v2/custom-select.js +91 -0
- package/build/custom-select-control-v2/custom-select.js.map +1 -0
- package/build/custom-select-control-v2/default-component/index.js +41 -0
- package/build/custom-select-control-v2/default-component/index.js.map +1 -0
- package/build/custom-select-control-v2/index.js +13 -82
- package/build/custom-select-control-v2/index.js.map +1 -1
- package/build/custom-select-control-v2/legacy-component/index.js +123 -0
- package/build/custom-select-control-v2/legacy-component/index.js.map +1 -0
- package/build/custom-select-control-v2/styles.js +73 -50
- package/build/custom-select-control-v2/styles.js.map +1 -1
- package/build/custom-select-control-v2/types.js.map +1 -1
- package/build/draggable/index.native.js +2 -2
- package/build/draggable/index.native.js.map +1 -1
- package/build/dropdown-menu/index.native.js.map +1 -1
- package/build/flex/flex/hook.js +1 -1
- package/build/flex/flex/hook.js.map +1 -1
- package/build/font-size-picker/font-size-picker-select.js +0 -1
- package/build/font-size-picker/font-size-picker-select.js.map +1 -1
- package/build/font-size-picker/index.native.js.map +1 -1
- package/build/form-token-field/index.js +3 -8
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/suggestions-list.js +5 -12
- package/build/form-token-field/suggestions-list.js.map +1 -1
- package/build/h-stack/hook.js +6 -1
- package/build/h-stack/hook.js.map +1 -1
- package/build/mobile/bottom-sheet/button.native.js.map +1 -1
- package/build/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet/range-cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
- package/build/mobile/gradient/index.native.js.map +1 -1
- package/build/mobile/image/index.native.js +4 -13
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js +1 -1
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -1
- package/build/mobile/media-edit/index.native.js.map +1 -1
- package/build/modal/index.js +2 -10
- package/build/modal/index.js.map +1 -1
- package/build/palette-edit/index.js.map +1 -1
- package/build/progress-bar/styles.js +5 -5
- package/build/progress-bar/styles.js.map +1 -1
- package/build/query-controls/index.native.js.map +1 -1
- package/build/range-control/index.js.map +1 -1
- package/build/search-control/index.native.js.map +1 -1
- package/build/snackbar/index.js +3 -2
- package/build/snackbar/index.js.map +1 -1
- package/build/snackbar/list.js +2 -1
- package/build/snackbar/list.js.map +1 -1
- package/build/snackbar/types.js.map +1 -1
- package/build/tabs/index.js +7 -7
- package/build/tabs/index.js.map +1 -1
- package/build/tabs/types.js.map +1 -1
- package/build/utils/hooks/index.js +0 -7
- package/build/utils/hooks/index.js.map +1 -1
- package/build/utils/with-ignore-ime-events.js +34 -0
- package/build/utils/with-ignore-ime-events.js.map +1 -0
- package/build-module/autocomplete/index.js +3 -8
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/base-control/index.native.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/button/index.js +2 -2
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/index.native.js.map +1 -1
- package/build-module/color-picker/component.js +11 -2
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/styles.js +8 -9
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/combobox-control/index.js +4 -9
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/confirm-dialog/component.js.map +1 -1
- package/build-module/custom-select-control/index.js +2 -15
- package/build-module/custom-select-control/index.js.map +1 -1
- package/build-module/custom-select-control-v2/custom-select-item.js +26 -0
- package/build-module/custom-select-control-v2/custom-select-item.js.map +1 -0
- package/build-module/custom-select-control-v2/custom-select.js +82 -0
- package/build-module/custom-select-control-v2/custom-select.js.map +1 -0
- package/build-module/custom-select-control-v2/default-component/index.js +30 -0
- package/build-module/custom-select-control-v2/default-component/index.js.map +1 -0
- package/build-module/custom-select-control-v2/index.js +2 -74
- package/build-module/custom-select-control-v2/index.js.map +1 -1
- package/build-module/custom-select-control-v2/legacy-component/index.js +111 -0
- package/build-module/custom-select-control-v2/legacy-component/index.js.map +1 -0
- package/build-module/custom-select-control-v2/styles.js +73 -42
- 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/draggable/index.native.js +2 -2
- package/build-module/draggable/index.native.js.map +1 -1
- package/build-module/dropdown-menu/index.native.js.map +1 -1
- package/build-module/flex/flex/hook.js +1 -1
- package/build-module/flex/flex/hook.js.map +1 -1
- package/build-module/font-size-picker/font-size-picker-select.js +0 -1
- package/build-module/font-size-picker/font-size-picker-select.js.map +1 -1
- package/build-module/font-size-picker/index.native.js.map +1 -1
- package/build-module/form-token-field/index.js +3 -8
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/suggestions-list.js +5 -12
- package/build-module/form-token-field/suggestions-list.js.map +1 -1
- package/build-module/h-stack/hook.js +6 -1
- package/build-module/h-stack/hook.js.map +1 -1
- package/build-module/mobile/bottom-sheet/button.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/range-cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
- package/build-module/mobile/gradient/index.native.js.map +1 -1
- package/build-module/mobile/image/index.native.js +6 -15
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -1
- package/build-module/mobile/media-edit/index.native.js.map +1 -1
- package/build-module/modal/index.js +3 -10
- package/build-module/modal/index.js.map +1 -1
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/progress-bar/styles.js +5 -5
- package/build-module/progress-bar/styles.js.map +1 -1
- package/build-module/query-controls/index.native.js.map +1 -1
- package/build-module/range-control/index.js.map +1 -1
- package/build-module/search-control/index.native.js.map +1 -1
- package/build-module/snackbar/index.js +3 -2
- package/build-module/snackbar/index.js.map +1 -1
- package/build-module/snackbar/list.js +2 -1
- package/build-module/snackbar/list.js.map +1 -1
- package/build-module/snackbar/types.js.map +1 -1
- package/build-module/tabs/index.js +7 -7
- package/build-module/tabs/index.js.map +1 -1
- package/build-module/tabs/types.js.map +1 -1
- package/build-module/utils/hooks/index.js +0 -1
- package/build-module/utils/hooks/index.js.map +1 -1
- package/build-module/utils/with-ignore-ime-events.js +28 -0
- package/build-module/utils/with-ignore-ime-events.js.map +1 -0
- package/build-style/style-rtl.css +10 -2
- package/build-style/style.css +10 -2
- package/build-types/alignment-matrix-control/stories/index.story.d.ts +1 -1
- package/build-types/angle-picker-control/stories/index.story.d.ts +1 -1
- package/build-types/animate/stories/index.story.d.ts +7 -7
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/base-control/stories/index.story.d.ts +1 -1
- package/build-types/border-box-control/stories/index.story.d.ts +1 -1
- package/build-types/border-control/stories/index.story.d.ts +6 -6
- package/build-types/box-control/stories/index.story.d.ts +6 -6
- package/build-types/button/stories/e2e/index.story.d.ts +1 -1
- package/build-types/button/stories/index.story.d.ts +7 -7
- package/build-types/card/stories/index.story.d.ts +2 -2
- package/build-types/circular-option-picker/stories/index.story.d.ts +5 -5
- package/build-types/color-palette/stories/index.story.d.ts +3 -3
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/stories/index.story.d.ts +1 -1
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/combobox-control/index.d.ts.map +1 -1
- package/build-types/combobox-control/stories/index.story.d.ts +2 -2
- package/build-types/confirm-dialog/stories/index.story.d.ts +2 -2
- package/build-types/custom-gradient-picker/stories/index.story.d.ts +1 -1
- package/build-types/custom-select-control/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/custom-select-item.d.ts +9 -0
- package/build-types/custom-select-control-v2/custom-select-item.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/custom-select.d.ts +6 -0
- package/build-types/custom-select-control-v2/custom-select.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/default-component/index.d.ts +6 -0
- package/build-types/custom-select-control-v2/default-component/index.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/index.d.ts +5 -6
- package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/legacy-component/index.d.ts +5 -0
- package/build-types/custom-select-control-v2/legacy-component/index.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/legacy-component/test/index.d.ts +2 -0
- package/build-types/custom-select-control-v2/legacy-component/test/index.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/stories/default.story.d.ts +30 -0
- package/build-types/custom-select-control-v2/stories/default.story.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/stories/legacy.story.d.ts +12 -0
- package/build-types/custom-select-control-v2/stories/legacy.story.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/styles.d.ts +31 -6
- package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/types.d.ts +136 -14
- package/build-types/custom-select-control-v2/types.d.ts.map +1 -1
- package/build-types/dimension-control/stories/index.story.d.ts +2 -2
- package/build-types/drop-zone/stories/index.story.d.ts +1 -1
- package/build-types/dropdown/stories/index.story.d.ts +3 -3
- package/build-types/dropdown-menu/stories/index.story.d.ts +2 -2
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -1
- package/build-types/duotone-picker/stories/duotone-picker.story.d.ts +1 -1
- package/build-types/duotone-picker/stories/duotone-swatch.story.d.ts +3 -3
- package/build-types/flex/flex/hook.d.ts +2 -3
- package/build-types/flex/flex/hook.d.ts.map +1 -1
- package/build-types/focal-point-picker/stories/index.story.d.ts +4 -4
- package/build-types/font-size-picker/font-size-picker-select.d.ts.map +1 -1
- package/build-types/form-file-upload/stories/index.story.d.ts +5 -5
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/suggestions-list.d.ts.map +1 -1
- package/build-types/gradient-picker/stories/index.story.d.ts +3 -3
- package/build-types/guide/stories/index.story.d.ts +1 -1
- package/build-types/h-stack/hook.d.ts +2 -4
- package/build-types/h-stack/hook.d.ts.map +1 -1
- package/build-types/icon/stories/index.story.d.ts +4 -4
- package/build-types/input-control/stories/index.story.d.ts +6 -6
- package/build-types/keyboard-shortcuts/stories/index.story.d.ts +1 -1
- package/build-types/menu-group/stories/index.story.d.ts +1 -1
- package/build-types/menu-item/stories/index.story.d.ts +4 -4
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/navigation/stories/index.story.d.ts +6 -6
- package/build-types/navigation/stories/utils/hide-if-empty.d.ts.map +1 -1
- package/build-types/notice/stories/index.story.d.ts +4 -4
- package/build-types/number-control/stories/index.story.d.ts +1 -1
- package/build-types/palette-edit/stories/index.story.d.ts +2 -2
- package/build-types/progress-bar/stories/index.story.d.ts.map +1 -1
- package/build-types/query-controls/stories/index.story.d.ts +1 -1
- package/build-types/radio-group/stories/index.story.d.ts.map +1 -1
- package/build-types/resizable-box/stories/index.story.d.ts +2 -2
- package/build-types/responsive-wrapper/stories/index.story.d.ts +1 -1
- package/build-types/sandbox/stories/index.story.d.ts +1 -1
- package/build-types/search-control/stories/index.story.d.ts +2 -2
- package/build-types/select-control/stories/index.story.d.ts +2 -2
- package/build-types/shortcut/stories/index.story.d.ts +1 -1
- package/build-types/snackbar/index.d.ts +5 -2
- package/build-types/snackbar/index.d.ts.map +1 -1
- package/build-types/snackbar/list.d.ts.map +1 -1
- package/build-types/snackbar/test/index.d.ts +2 -0
- package/build-types/snackbar/test/index.d.ts.map +1 -0
- package/build-types/snackbar/test/list.d.ts +2 -0
- package/build-types/snackbar/test/list.d.ts.map +1 -0
- package/build-types/snackbar/types.d.ts +18 -2
- package/build-types/snackbar/types.d.ts.map +1 -1
- package/build-types/tab-panel/stories/index.story.d.ts +4 -4
- package/build-types/tabs/index.d.ts +1 -1
- package/build-types/tabs/stories/index.story.d.ts +9 -9
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/types.d.ts +1 -1
- package/build-types/text/stories/index.story.d.ts +3 -3
- package/build-types/theme/stories/index.story.d.ts +1 -1
- package/build-types/theme/stories/index.story.d.ts.map +1 -1
- package/build-types/toggle-control/stories/index.story.d.ts +2 -2
- package/build-types/toolbar/stories/index.story.d.ts +3 -3
- package/build-types/tooltip/stories/index.story.d.ts +1 -1
- package/build-types/tree-grid/stories/index.story.d.ts +1 -1
- package/build-types/tree-select/stories/index.story.d.ts +1 -1
- package/build-types/utils/hooks/index.d.ts +0 -1
- package/build-types/utils/with-ignore-ime-events.d.ts +15 -0
- package/build-types/utils/with-ignore-ime-events.d.ts.map +1 -0
- package/build-types/v-stack/hook.d.ts +2 -4
- package/build-types/v-stack/hook.d.ts.map +1 -1
- package/build-types/v-stack/stories/index.story.d.ts +1 -1
- package/package.json +19 -20
- package/src/alignment-matrix-control/test/index.tsx +3 -1
- package/src/autocomplete/index.tsx +3 -10
- package/src/base-control/index.native.js +1 -1
- package/src/base-control/test/index.tsx +1 -1
- package/src/border-box-control/border-box-control/component.tsx +1 -1
- package/src/border-box-control/border-box-control-split-controls/component.tsx +4 -4
- package/src/border-control/border-control-dropdown/component.tsx +1 -1
- package/src/button/index.native.js +1 -1
- package/src/button/index.tsx +1 -1
- package/src/button/style.scss +1 -3
- package/src/circular-option-picker/test/index.tsx +6 -5
- package/src/color-picker/component.tsx +22 -11
- package/src/color-picker/styles.ts +1 -15
- package/src/combobox-control/index.tsx +33 -41
- package/src/combobox-control/test/index.tsx +1 -1
- package/src/composite/legacy/test/index.tsx +18 -2
- package/src/confirm-dialog/component.tsx +1 -1
- package/src/confirm-dialog/test/index.tsx +5 -21
- package/src/custom-select-control/README.md +0 -10
- package/src/custom-select-control/index.js +3 -22
- package/src/custom-select-control/stories/index.story.js +0 -1
- package/src/custom-select-control/test/index.js +17 -17
- package/src/custom-select-control-v2/README.md +97 -7
- package/src/custom-select-control-v2/custom-select-item.tsx +29 -0
- package/src/custom-select-control-v2/custom-select.tsx +122 -0
- package/src/custom-select-control-v2/default-component/index.tsx +27 -0
- package/src/custom-select-control-v2/index.tsx +2 -102
- package/src/custom-select-control-v2/legacy-component/index.tsx +133 -0
- package/src/custom-select-control-v2/legacy-component/test/index.tsx +457 -0
- package/src/custom-select-control-v2/stories/{index.story.tsx → default.story.tsx} +27 -33
- package/src/custom-select-control-v2/stories/legacy.story.tsx +87 -0
- package/src/custom-select-control-v2/styles.ts +82 -38
- package/src/custom-select-control-v2/test/index.tsx +207 -17
- package/src/custom-select-control-v2/types.ts +147 -20
- package/src/disabled/test/index.tsx +1 -1
- package/src/draggable/index.native.js +2 -2
- package/src/draggable/test/index.native.js +6 -2
- package/src/dropdown-menu/index.native.js +2 -2
- package/src/dropdown-menu-v2/stories/index.story.tsx +1 -0
- package/src/dropdown-menu-v2/test/index.tsx +4 -1
- package/src/flex/flex/hook.ts +1 -1
- package/src/font-size-picker/font-size-picker-select.tsx +0 -1
- package/src/font-size-picker/index.native.js +2 -2
- package/src/form-token-field/index.tsx +4 -11
- package/src/form-token-field/suggestions-list.tsx +5 -17
- package/src/h-stack/hook.tsx +2 -1
- package/src/h-stack/test/index.tsx +10 -0
- package/src/item-group/test/index.js +2 -2
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +10 -15
- package/src/mobile/bottom-sheet/button.native.js +1 -5
- package/src/mobile/bottom-sheet/index.native.js +2 -2
- package/src/mobile/bottom-sheet/range-cell.native.js +1 -1
- package/src/mobile/bottom-sheet/stepper-cell/index.native.js +2 -2
- package/src/mobile/bottom-sheet-select-control/index.native.js +1 -1
- package/src/mobile/bottom-sheet-text-control/index.native.js +1 -1
- package/src/mobile/gradient/index.native.js +1 -1
- package/src/mobile/image/index.native.js +8 -23
- package/src/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js +1 -1
- package/src/mobile/media-edit/index.native.js +1 -1
- package/src/modal/index.tsx +2 -12
- package/src/modal/style.scss +1 -0
- package/src/modal/test/index.tsx +1 -1
- package/src/navigation/stories/utils/hide-if-empty.tsx +2 -6
- package/src/palette-edit/index.tsx +2 -2
- package/src/popover/test/index.tsx +1 -4
- package/src/progress-bar/stories/index.story.tsx +1 -0
- package/src/progress-bar/styles.ts +2 -2
- package/src/query-controls/index.native.js +2 -2
- package/src/radio-group/stories/index.story.tsx +1 -0
- package/src/range-control/index.tsx +3 -3
- package/src/range-control/test/index.tsx +2 -2
- package/src/search-control/index.native.js +1 -1
- package/src/snackbar/index.tsx +5 -2
- package/src/snackbar/list.tsx +6 -1
- package/src/snackbar/stories/list.story.tsx +0 -3
- package/src/snackbar/test/index.tsx +267 -0
- package/src/snackbar/test/list.tsx +46 -0
- package/src/snackbar/types.ts +31 -3
- package/src/tab-panel/test/index.tsx +8 -1
- package/src/tabs/README.md +18 -18
- package/src/tabs/index.tsx +7 -7
- package/src/tabs/stories/index.story.tsx +2 -1
- package/src/tabs/test/index.tsx +66 -36
- package/src/tabs/types.ts +1 -1
- package/src/theme/stories/index.story.tsx +1 -0
- package/src/toggle-group-control/test/index.tsx +5 -1
- package/src/toolbar/toolbar-group/style.scss +1 -0
- package/src/tools-panel/stories/index.story.tsx +8 -8
- package/src/tools-panel/test/index.tsx +10 -28
- package/src/tooltip/style.scss +2 -1
- package/src/tooltip/test/index.native.js +3 -3
- package/src/tooltip/test/index.tsx +5 -0
- package/src/tree-grid/test/index.tsx +1 -1
- package/src/utils/hooks/index.js +0 -1
- package/src/utils/with-ignore-ime-events.ts +32 -0
- package/src/v-stack/test/index.tsx +10 -0
- package/tsconfig.json +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/custom-select-control/styles.js +0 -27
- package/build/custom-select-control/styles.js.map +0 -1
- package/build/utils/hooks/use-latest-ref.js +0 -33
- package/build/utils/hooks/use-latest-ref.js.map +0 -1
- package/build-module/custom-select-control/styles.js +0 -18
- package/build-module/custom-select-control/styles.js.map +0 -1
- package/build-module/utils/hooks/use-latest-ref.js +0 -27
- package/build-module/utils/hooks/use-latest-ref.js.map +0 -1
- package/build-types/custom-select-control/styles.d.ts +0 -11
- package/build-types/custom-select-control/styles.d.ts.map +0 -1
- package/build-types/custom-select-control-v2/stories/index.story.d.ts +0 -20
- package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +0 -1
- package/build-types/utils/hooks/use-latest-ref.d.ts +0 -15
- package/build-types/utils/hooks/use-latest-ref.d.ts.map +0 -1
- package/src/custom-select-control/styles.ts +0 -28
- package/src/utils/hooks/test/use-latest-ref.js +0 -119
- package/src/utils/hooks/use-latest-ref.ts +0 -29
|
@@ -1,18 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import styled from '@emotion/styled';
|
|
5
4
|
// eslint-disable-next-line no-restricted-imports
|
|
6
5
|
import * as Ariakit from '@ariakit/react';
|
|
7
|
-
|
|
6
|
+
import { css } from '@emotion/react';
|
|
7
|
+
import styled from '@emotion/styled';
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
|
-
import { COLORS } from '../utils';
|
|
11
|
+
import { COLORS, CONFIG } from '../utils';
|
|
12
12
|
import { space } from '../utils/space';
|
|
13
|
-
import type {
|
|
13
|
+
import type { CustomSelectButtonProps } from './types';
|
|
14
|
+
|
|
15
|
+
const ITEM_PADDING = space( 2 );
|
|
16
|
+
|
|
17
|
+
export const WithHintWrapper = styled.div`
|
|
18
|
+
display: flex;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
flex: 1;
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
export const SelectedExperimentalHintItem = styled.span`
|
|
24
|
+
color: ${ COLORS.theme.gray[ 600 ] };
|
|
25
|
+
margin-inline-start: ${ space( 2 ) };
|
|
26
|
+
`;
|
|
14
27
|
|
|
15
|
-
export const
|
|
28
|
+
export const ExperimentalHintItem = styled.span`
|
|
29
|
+
color: ${ COLORS.theme.gray[ 600 ] };
|
|
30
|
+
text-align: right;
|
|
31
|
+
margin-inline-end: ${ space( 1 ) };
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
export const SelectLabel = styled( Ariakit.SelectLabel )`
|
|
16
35
|
font-size: 11px;
|
|
17
36
|
font-weight: 500;
|
|
18
37
|
line-height: 1.4;
|
|
@@ -20,57 +39,82 @@ export const CustomSelectLabel = styled( Ariakit.SelectLabel )`
|
|
|
20
39
|
margin-bottom: ${ space( 2 ) };
|
|
21
40
|
`;
|
|
22
41
|
|
|
23
|
-
const
|
|
24
|
-
default: 40,
|
|
25
|
-
small: 24,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const CustomSelectButton = styled( Ariakit.Select, {
|
|
42
|
+
export const Select = styled( Ariakit.Select, {
|
|
29
43
|
// Do not forward `hasCustomRenderProp` to the underlying Ariakit.Select component
|
|
30
44
|
shouldForwardProp: ( prop ) => prop !== 'hasCustomRenderProp',
|
|
31
45
|
} )( ( {
|
|
32
46
|
size,
|
|
33
47
|
hasCustomRenderProp,
|
|
34
48
|
}: {
|
|
35
|
-
size: NonNullable<
|
|
49
|
+
size: NonNullable< CustomSelectButtonProps[ 'size' ] >;
|
|
36
50
|
hasCustomRenderProp: boolean;
|
|
37
51
|
} ) => {
|
|
38
|
-
const isSmallSize = size === 'small' && ! hasCustomRenderProp;
|
|
39
52
|
const heightProperty = hasCustomRenderProp ? 'minHeight' : 'height';
|
|
40
53
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const getSize = () => {
|
|
55
|
+
const sizes = {
|
|
56
|
+
compact: {
|
|
57
|
+
[ heightProperty ]: 32,
|
|
58
|
+
paddingInlineStart: space( 2 ),
|
|
59
|
+
paddingInlineEnd: space( 1 ),
|
|
60
|
+
},
|
|
61
|
+
default: {
|
|
62
|
+
[ heightProperty ]: 40,
|
|
63
|
+
paddingInlineStart: space( 4 ),
|
|
64
|
+
paddingInlineEnd: space( 3 ),
|
|
65
|
+
},
|
|
66
|
+
small: {
|
|
67
|
+
[ heightProperty ]: 24,
|
|
68
|
+
paddingInlineStart: space( 2 ),
|
|
69
|
+
paddingInlineEnd: space( 1 ),
|
|
70
|
+
fontSize: 11,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return sizes[ size ] || sizes.default;
|
|
59
75
|
};
|
|
76
|
+
|
|
77
|
+
return css`
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: space-between;
|
|
81
|
+
background-color: ${ COLORS.theme.background };
|
|
82
|
+
border: 1px solid ${ COLORS.ui.border };
|
|
83
|
+
border-radius: 2px;
|
|
84
|
+
cursor: pointer;
|
|
85
|
+
font-size: ${ CONFIG.fontSize };
|
|
86
|
+
width: 100%;
|
|
87
|
+
&[data-focus-visible] {
|
|
88
|
+
outline-style: solid;
|
|
89
|
+
}
|
|
90
|
+
&[aria-expanded='true'] {
|
|
91
|
+
outline: 1.5px solid ${ COLORS.theme.accent };
|
|
92
|
+
}
|
|
93
|
+
${ getSize() }
|
|
94
|
+
`;
|
|
60
95
|
} );
|
|
61
96
|
|
|
62
|
-
export const
|
|
63
|
-
border-radius:
|
|
64
|
-
background: ${ COLORS.
|
|
65
|
-
border: 1px solid ${ COLORS.
|
|
97
|
+
export const SelectPopover = styled( Ariakit.SelectPopover )`
|
|
98
|
+
border-radius: 2px;
|
|
99
|
+
background: ${ COLORS.theme.background };
|
|
100
|
+
border: 1px solid ${ COLORS.theme.foreground };
|
|
66
101
|
`;
|
|
67
102
|
|
|
68
|
-
export const
|
|
103
|
+
export const SelectItem = styled( Ariakit.SelectItem )`
|
|
69
104
|
display: flex;
|
|
70
105
|
align-items: center;
|
|
71
106
|
justify-content: space-between;
|
|
72
|
-
padding: ${
|
|
107
|
+
padding: ${ ITEM_PADDING };
|
|
108
|
+
font-size: ${ CONFIG.fontSize };
|
|
109
|
+
line-height: 2.15rem; // TODO: Remove this in default but keep for back-compat in legacy
|
|
73
110
|
&[data-active-item] {
|
|
74
|
-
background-color: ${ COLORS.gray[ 300 ] };
|
|
111
|
+
background-color: ${ COLORS.theme.gray[ 300 ] };
|
|
75
112
|
}
|
|
76
113
|
`;
|
|
114
|
+
|
|
115
|
+
export const SelectedItemCheck = styled( Ariakit.SelectItemCheck )`
|
|
116
|
+
display: flex;
|
|
117
|
+
align-items: center;
|
|
118
|
+
margin-inline-start: ${ ITEM_PADDING };
|
|
119
|
+
font-size: 24px; // Size of checkmark icon
|
|
120
|
+
`;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { render, screen } from '@testing-library/react';
|
|
5
|
-
import
|
|
5
|
+
import { click, press, sleep, type } from '@ariakit/test';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
@@ -12,15 +12,45 @@ import { useState } from '@wordpress/element';
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
|
-
import { CustomSelect, CustomSelectItem } from '..';
|
|
15
|
+
import { CustomSelect as UncontrolledCustomSelect, CustomSelectItem } from '..';
|
|
16
16
|
import type { CustomSelectProps } from '../types';
|
|
17
17
|
|
|
18
|
+
const items = [
|
|
19
|
+
{
|
|
20
|
+
key: 'flower1',
|
|
21
|
+
value: 'violets',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
key: 'flower2',
|
|
25
|
+
value: 'crimson clover',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
key: 'flower3',
|
|
29
|
+
value: 'poppy',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
key: 'color1',
|
|
33
|
+
value: 'amber',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
key: 'color2',
|
|
37
|
+
value: 'aquamarine',
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const defaultProps = {
|
|
42
|
+
label: 'label!',
|
|
43
|
+
children: items.map( ( { value, key } ) => (
|
|
44
|
+
<CustomSelectItem value={ value } key={ key } />
|
|
45
|
+
) ),
|
|
46
|
+
};
|
|
47
|
+
|
|
18
48
|
const ControlledCustomSelect = ( props: CustomSelectProps ) => {
|
|
19
49
|
const [ value, setValue ] = useState< string | string[] >();
|
|
20
50
|
return (
|
|
21
|
-
<
|
|
51
|
+
<UncontrolledCustomSelect
|
|
22
52
|
{ ...props }
|
|
23
|
-
onChange={ ( nextValue ) => {
|
|
53
|
+
onChange={ ( nextValue: string | string[] ) => {
|
|
24
54
|
setValue( nextValue );
|
|
25
55
|
props.onChange?.( nextValue );
|
|
26
56
|
} }
|
|
@@ -30,14 +60,178 @@ const ControlledCustomSelect = ( props: CustomSelectProps ) => {
|
|
|
30
60
|
};
|
|
31
61
|
|
|
32
62
|
describe.each( [
|
|
33
|
-
[ '
|
|
34
|
-
[ '
|
|
35
|
-
] )( '
|
|
63
|
+
[ 'Uncontrolled', UncontrolledCustomSelect ],
|
|
64
|
+
[ 'Controlled', ControlledCustomSelect ],
|
|
65
|
+
] )( 'CustomSelectControlV2 (%s)', ( ...modeAndComponent ) => {
|
|
36
66
|
const [ , Component ] = modeAndComponent;
|
|
37
67
|
|
|
68
|
+
it( 'Should replace the initial selection when a new item is selected', async () => {
|
|
69
|
+
render( <Component { ...defaultProps } /> );
|
|
70
|
+
|
|
71
|
+
const currentSelectedItem = screen.getByRole( 'combobox', {
|
|
72
|
+
expanded: false,
|
|
73
|
+
} );
|
|
74
|
+
|
|
75
|
+
await click( currentSelectedItem );
|
|
76
|
+
|
|
77
|
+
await click(
|
|
78
|
+
screen.getByRole( 'option', {
|
|
79
|
+
name: 'crimson clover',
|
|
80
|
+
} )
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
expect( currentSelectedItem ).toHaveTextContent( 'crimson clover' );
|
|
84
|
+
|
|
85
|
+
await click( currentSelectedItem );
|
|
86
|
+
|
|
87
|
+
await click(
|
|
88
|
+
screen.getByRole( 'option', {
|
|
89
|
+
name: 'poppy',
|
|
90
|
+
} )
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
expect( currentSelectedItem ).toHaveTextContent( 'poppy' );
|
|
94
|
+
} );
|
|
95
|
+
|
|
96
|
+
it( 'Should keep current selection if dropdown is closed without changing selection', async () => {
|
|
97
|
+
render( <Component { ...defaultProps } /> );
|
|
98
|
+
|
|
99
|
+
const currentSelectedItem = screen.getByRole( 'combobox', {
|
|
100
|
+
expanded: false,
|
|
101
|
+
} );
|
|
102
|
+
|
|
103
|
+
await sleep();
|
|
104
|
+
await press.Tab();
|
|
105
|
+
await press.Enter();
|
|
106
|
+
expect(
|
|
107
|
+
screen.getByRole( 'listbox', {
|
|
108
|
+
name: 'label!',
|
|
109
|
+
} )
|
|
110
|
+
).toBeVisible();
|
|
111
|
+
|
|
112
|
+
await press.Escape();
|
|
113
|
+
expect(
|
|
114
|
+
screen.queryByRole( 'listbox', {
|
|
115
|
+
name: 'label!',
|
|
116
|
+
} )
|
|
117
|
+
).not.toBeInTheDocument();
|
|
118
|
+
|
|
119
|
+
expect( currentSelectedItem ).toHaveTextContent( items[ 0 ].value );
|
|
120
|
+
} );
|
|
121
|
+
|
|
122
|
+
describe( 'Keyboard behavior and accessibility', () => {
|
|
123
|
+
it( 'Should be able to change selection using keyboard', async () => {
|
|
124
|
+
render( <Component { ...defaultProps } /> );
|
|
125
|
+
|
|
126
|
+
const currentSelectedItem = screen.getByRole( 'combobox', {
|
|
127
|
+
expanded: false,
|
|
128
|
+
} );
|
|
129
|
+
|
|
130
|
+
await sleep();
|
|
131
|
+
await press.Tab();
|
|
132
|
+
expect( currentSelectedItem ).toHaveFocus();
|
|
133
|
+
|
|
134
|
+
await press.Enter();
|
|
135
|
+
expect(
|
|
136
|
+
screen.getByRole( 'listbox', {
|
|
137
|
+
name: 'label!',
|
|
138
|
+
} )
|
|
139
|
+
).toHaveFocus();
|
|
140
|
+
|
|
141
|
+
await press.ArrowDown();
|
|
142
|
+
await press.Enter();
|
|
143
|
+
|
|
144
|
+
expect( currentSelectedItem ).toHaveTextContent( 'crimson clover' );
|
|
145
|
+
} );
|
|
146
|
+
|
|
147
|
+
it( 'Should be able to type characters to select matching options', async () => {
|
|
148
|
+
render( <Component { ...defaultProps } /> );
|
|
149
|
+
|
|
150
|
+
const currentSelectedItem = screen.getByRole( 'combobox', {
|
|
151
|
+
expanded: false,
|
|
152
|
+
} );
|
|
153
|
+
|
|
154
|
+
await sleep();
|
|
155
|
+
await press.Tab();
|
|
156
|
+
await press.Enter();
|
|
157
|
+
expect(
|
|
158
|
+
screen.getByRole( 'listbox', {
|
|
159
|
+
name: 'label!',
|
|
160
|
+
} )
|
|
161
|
+
).toHaveFocus();
|
|
162
|
+
|
|
163
|
+
await type( 'a' );
|
|
164
|
+
await press.Enter();
|
|
165
|
+
expect( currentSelectedItem ).toHaveTextContent( 'amber' );
|
|
166
|
+
} );
|
|
167
|
+
|
|
168
|
+
it( 'Can change selection with a focused input and closed dropdown if typed characters match an option', async () => {
|
|
169
|
+
render( <Component { ...defaultProps } /> );
|
|
170
|
+
|
|
171
|
+
const currentSelectedItem = screen.getByRole( 'combobox', {
|
|
172
|
+
expanded: false,
|
|
173
|
+
} );
|
|
174
|
+
|
|
175
|
+
await sleep();
|
|
176
|
+
await press.Tab();
|
|
177
|
+
expect( currentSelectedItem ).toHaveFocus();
|
|
178
|
+
|
|
179
|
+
await type( 'aq' );
|
|
180
|
+
|
|
181
|
+
expect(
|
|
182
|
+
screen.queryByRole( 'listbox', {
|
|
183
|
+
name: 'label!',
|
|
184
|
+
hidden: true,
|
|
185
|
+
} )
|
|
186
|
+
).not.toBeInTheDocument();
|
|
187
|
+
|
|
188
|
+
await press.Enter();
|
|
189
|
+
expect( currentSelectedItem ).toHaveTextContent( 'aquamarine' );
|
|
190
|
+
} );
|
|
191
|
+
|
|
192
|
+
it( 'Should have correct aria-selected value for selections', async () => {
|
|
193
|
+
render( <Component { ...defaultProps } /> );
|
|
194
|
+
|
|
195
|
+
const currentSelectedItem = screen.getByRole( 'combobox', {
|
|
196
|
+
expanded: false,
|
|
197
|
+
} );
|
|
198
|
+
|
|
199
|
+
await click( currentSelectedItem );
|
|
200
|
+
|
|
201
|
+
// assert that first item has aria-selected="true"
|
|
202
|
+
expect(
|
|
203
|
+
screen.getByRole( 'option', {
|
|
204
|
+
name: 'violets',
|
|
205
|
+
selected: true,
|
|
206
|
+
} )
|
|
207
|
+
).toBeVisible();
|
|
208
|
+
|
|
209
|
+
// change the current selection
|
|
210
|
+
await click( screen.getByRole( 'option', { name: 'poppy' } ) );
|
|
211
|
+
|
|
212
|
+
// click combobox to mount listbox with options again
|
|
213
|
+
await click( currentSelectedItem );
|
|
214
|
+
|
|
215
|
+
// check that first item is has aria-selected="false" after new selection
|
|
216
|
+
expect(
|
|
217
|
+
screen.getByRole( 'option', {
|
|
218
|
+
name: 'violets',
|
|
219
|
+
selected: false,
|
|
220
|
+
} )
|
|
221
|
+
).toBeVisible();
|
|
222
|
+
|
|
223
|
+
// check that new selected item now has aria-selected="true"
|
|
224
|
+
expect(
|
|
225
|
+
screen.getByRole( 'option', {
|
|
226
|
+
name: 'poppy',
|
|
227
|
+
selected: true,
|
|
228
|
+
} )
|
|
229
|
+
).toBeVisible();
|
|
230
|
+
} );
|
|
231
|
+
} );
|
|
232
|
+
|
|
38
233
|
describe( 'Multiple selection', () => {
|
|
39
234
|
it( 'Should be able to select multiple items when provided an array', async () => {
|
|
40
|
-
const user = userEvent.setup();
|
|
41
235
|
const onChangeMock = jest.fn();
|
|
42
236
|
|
|
43
237
|
// initial selection as defaultValue
|
|
@@ -75,7 +269,7 @@ describe.each( [
|
|
|
75
269
|
`${ defaultValues.length } items selected`
|
|
76
270
|
);
|
|
77
271
|
|
|
78
|
-
await
|
|
272
|
+
await click( currentSelectedItem );
|
|
79
273
|
|
|
80
274
|
expect( screen.getByRole( 'listbox' ) ).toHaveAttribute(
|
|
81
275
|
'aria-multiselectable'
|
|
@@ -100,7 +294,7 @@ describe.each( [
|
|
|
100
294
|
} );
|
|
101
295
|
|
|
102
296
|
// click next selection to add another item to current selection
|
|
103
|
-
await
|
|
297
|
+
await click( nextSelection );
|
|
104
298
|
|
|
105
299
|
// updated array containing defaultValues + the item just selected
|
|
106
300
|
const updatedSelection = defaultValues.concat( nextSelectionName );
|
|
@@ -116,8 +310,6 @@ describe.each( [
|
|
|
116
310
|
} );
|
|
117
311
|
|
|
118
312
|
it( 'Should be able to deselect items when provided an array', async () => {
|
|
119
|
-
const user = userEvent.setup();
|
|
120
|
-
|
|
121
313
|
// initial selection as defaultValue
|
|
122
314
|
const defaultValues = [
|
|
123
315
|
'aurora borealis green',
|
|
@@ -141,7 +333,7 @@ describe.each( [
|
|
|
141
333
|
expanded: false,
|
|
142
334
|
} );
|
|
143
335
|
|
|
144
|
-
await
|
|
336
|
+
await click( currentSelectedItem );
|
|
145
337
|
|
|
146
338
|
// Array containing items to deselect
|
|
147
339
|
const nextSelection = [
|
|
@@ -154,7 +346,7 @@ describe.each( [
|
|
|
154
346
|
// are reflected correctly
|
|
155
347
|
await Promise.all(
|
|
156
348
|
nextSelection.map( async ( value ) => {
|
|
157
|
-
await
|
|
349
|
+
await click(
|
|
158
350
|
screen.getByRole( 'option', { name: value } )
|
|
159
351
|
);
|
|
160
352
|
expect(
|
|
@@ -176,8 +368,6 @@ describe.each( [
|
|
|
176
368
|
} );
|
|
177
369
|
|
|
178
370
|
it( 'Should allow rendering a custom value when using `renderSelectedValue`', async () => {
|
|
179
|
-
const user = userEvent.setup();
|
|
180
|
-
|
|
181
371
|
const renderValue = ( value: string | string[] ) => {
|
|
182
372
|
return <img src={ `${ value }.jpg` } alt={ value as string } />;
|
|
183
373
|
};
|
|
@@ -208,7 +398,7 @@ describe.each( [
|
|
|
208
398
|
screen.queryByRole( 'img', { name: 'july-9' } )
|
|
209
399
|
).not.toBeInTheDocument();
|
|
210
400
|
|
|
211
|
-
await
|
|
401
|
+
await click( currentSelectedItem );
|
|
212
402
|
|
|
213
403
|
// expect that the other image is only visible after opening popover with options
|
|
214
404
|
expect( screen.getByRole( 'img', { name: 'july-9' } ) ).toBeVisible();
|
|
@@ -3,30 +3,23 @@
|
|
|
3
3
|
*/
|
|
4
4
|
// eslint-disable-next-line no-restricted-imports
|
|
5
5
|
import type * as Ariakit from '@ariakit/react';
|
|
6
|
+
import type { FocusEventHandler, MouseEventHandler } from 'react';
|
|
6
7
|
|
|
7
|
-
export type
|
|
8
|
-
| {
|
|
9
|
-
/**
|
|
10
|
-
* The store object returned by Ariakit's `useSelectStore` hook.
|
|
11
|
-
*/
|
|
12
|
-
store: Ariakit.SelectStore;
|
|
13
|
-
}
|
|
14
|
-
| undefined;
|
|
15
|
-
|
|
16
|
-
export type CustomSelectProps = {
|
|
8
|
+
export type CustomSelectStore = {
|
|
17
9
|
/**
|
|
18
|
-
* The
|
|
10
|
+
* The store object returned by Ariakit's `useSelectStore` hook.
|
|
19
11
|
*/
|
|
20
|
-
|
|
12
|
+
store: Ariakit.SelectStore;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type CustomSelectContext = CustomSelectStore | undefined;
|
|
16
|
+
|
|
17
|
+
export type CustomSelectButtonProps = {
|
|
21
18
|
/**
|
|
22
|
-
* An optional default value for the control
|
|
23
|
-
* non-disabled item will be used.
|
|
19
|
+
* An optional default value for the control when used in uncontrolled mode.
|
|
20
|
+
* If left `undefined`, the first non-disabled item will be used.
|
|
24
21
|
*/
|
|
25
22
|
defaultValue?: string | string[];
|
|
26
|
-
/**
|
|
27
|
-
* Label for the control.
|
|
28
|
-
*/
|
|
29
|
-
label: string;
|
|
30
23
|
/**
|
|
31
24
|
* A function that receives the new value of the input.
|
|
32
25
|
*/
|
|
@@ -42,13 +35,147 @@ export type CustomSelectProps = {
|
|
|
42
35
|
*
|
|
43
36
|
* @default 'default'
|
|
44
37
|
*/
|
|
45
|
-
size?: 'default' | 'small';
|
|
38
|
+
size?: 'compact' | 'default' | 'small';
|
|
46
39
|
/**
|
|
47
|
-
*
|
|
40
|
+
* The value of the control when used in uncontrolled mode.
|
|
48
41
|
*/
|
|
49
42
|
value?: string | string[];
|
|
50
43
|
};
|
|
51
44
|
|
|
45
|
+
export type _CustomSelectProps = {
|
|
46
|
+
/**
|
|
47
|
+
* The child elements. This should be composed of `CustomSelectItem` components.
|
|
48
|
+
*/
|
|
49
|
+
children: React.ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Used to visually hide the label. It will always be visible to screen readers.
|
|
52
|
+
*
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
hideLabelFromVision?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Accessible label for the control.
|
|
58
|
+
*/
|
|
59
|
+
label: string;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type CustomSelectProps = _CustomSelectProps &
|
|
63
|
+
Omit< CustomSelectButtonProps, 'size' > & {
|
|
64
|
+
/**
|
|
65
|
+
* The size of the control.
|
|
66
|
+
*
|
|
67
|
+
* @default 'default'
|
|
68
|
+
*/
|
|
69
|
+
size?: Exclude< CustomSelectButtonProps[ 'size' ], 'small' >;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The legacy object structure for the options array.
|
|
74
|
+
*/
|
|
75
|
+
type LegacyOption = {
|
|
76
|
+
key: string;
|
|
77
|
+
name: string;
|
|
78
|
+
style?: React.CSSProperties;
|
|
79
|
+
className?: string;
|
|
80
|
+
__experimentalHint?: string;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The legacy object returned from the onChange event.
|
|
85
|
+
*/
|
|
86
|
+
type LegacyOnChangeObject = {
|
|
87
|
+
highlightedIndex?: number;
|
|
88
|
+
inputValue?: string;
|
|
89
|
+
isOpen?: boolean;
|
|
90
|
+
type?: string;
|
|
91
|
+
selectedItem: LegacyOption;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export type LegacyCustomSelectProps = {
|
|
95
|
+
/**
|
|
96
|
+
* Optional classname for the component.
|
|
97
|
+
*/
|
|
98
|
+
className?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Used to visually hide the label. It will always be visible to screen readers.
|
|
101
|
+
*
|
|
102
|
+
*/
|
|
103
|
+
hideLabelFromVision?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Pass in a description that will be shown to screen readers associated with the
|
|
106
|
+
* select trigger button. If no value is passed, the text "Currently selected:
|
|
107
|
+
* selectedItem.name" will be used fully translated.
|
|
108
|
+
*/
|
|
109
|
+
describedBy?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Label for the control.
|
|
112
|
+
*/
|
|
113
|
+
label: string;
|
|
114
|
+
/**
|
|
115
|
+
* Function called with the control's internal state changes. The `selectedItem`
|
|
116
|
+
* property contains the next selected item.
|
|
117
|
+
*/
|
|
118
|
+
onChange?: ( newValue: LegacyOnChangeObject ) => void;
|
|
119
|
+
/**
|
|
120
|
+
* A handler for `onBlur` events.
|
|
121
|
+
*
|
|
122
|
+
* @ignore
|
|
123
|
+
*/
|
|
124
|
+
onBlur?: FocusEventHandler< HTMLButtonElement >;
|
|
125
|
+
/**
|
|
126
|
+
* A handler for `onFocus` events.
|
|
127
|
+
*
|
|
128
|
+
* @ignore
|
|
129
|
+
*/
|
|
130
|
+
onFocus?: FocusEventHandler< HTMLButtonElement >;
|
|
131
|
+
/**
|
|
132
|
+
* A handler for `onMouseOver` events.
|
|
133
|
+
*
|
|
134
|
+
* @ignore
|
|
135
|
+
*/
|
|
136
|
+
onMouseOut?: MouseEventHandler< HTMLButtonElement >;
|
|
137
|
+
/**
|
|
138
|
+
* A handler for `onMouseOut` events.
|
|
139
|
+
*
|
|
140
|
+
* @ignore
|
|
141
|
+
*/
|
|
142
|
+
onMouseOver?: MouseEventHandler< HTMLButtonElement >;
|
|
143
|
+
/**
|
|
144
|
+
* The options that can be chosen from.
|
|
145
|
+
*/
|
|
146
|
+
options: Array< LegacyOption >;
|
|
147
|
+
/**
|
|
148
|
+
* The size of the control.
|
|
149
|
+
*
|
|
150
|
+
* @default 'default'
|
|
151
|
+
*/
|
|
152
|
+
size?: 'default' | 'small' | '__unstable-large';
|
|
153
|
+
/**
|
|
154
|
+
* Can be used to externally control the value of the control.
|
|
155
|
+
*/
|
|
156
|
+
value?: LegacyOption;
|
|
157
|
+
/**
|
|
158
|
+
* Legacy way to add additional text to the right of each option.
|
|
159
|
+
*
|
|
160
|
+
* @default false
|
|
161
|
+
*/
|
|
162
|
+
__experimentalShowSelectedHint?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Opt-in prop for an unconstrained width style which became the default in
|
|
165
|
+
* WordPress 6.5. The prop is no longer needed and can be safely removed.
|
|
166
|
+
*
|
|
167
|
+
* @deprecated
|
|
168
|
+
* @ignore
|
|
169
|
+
*/
|
|
170
|
+
__nextUnconstrainedWidth?: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Start opting into the larger default height that will become the default size in a future version.
|
|
173
|
+
*
|
|
174
|
+
* @default false
|
|
175
|
+
*/
|
|
176
|
+
__next40pxDefaultSize?: boolean;
|
|
177
|
+
};
|
|
178
|
+
|
|
52
179
|
export type CustomSelectItemProps = {
|
|
53
180
|
/**
|
|
54
181
|
* The value of the select item. This will be used as the children if
|
|
@@ -94,7 +94,7 @@ describe( 'Disabled', () => {
|
|
|
94
94
|
'This is contentEditable.'
|
|
95
95
|
);
|
|
96
96
|
|
|
97
|
-
rerender( <MaybeDisable isDisabled
|
|
97
|
+
rerender( <MaybeDisable isDisabled /> );
|
|
98
98
|
expect( getInput() ).toHaveValue( 'This is input.' );
|
|
99
99
|
expect( getContentEditable() ).toHaveTextContent(
|
|
100
100
|
'This is contentEditable.'
|
|
@@ -63,7 +63,7 @@ const Draggable = ( {
|
|
|
63
63
|
useAnimatedReaction(
|
|
64
64
|
() => isDragging.value,
|
|
65
65
|
( result, previous ) => {
|
|
66
|
-
if ( result === previous
|
|
66
|
+
if ( result === previous ) {
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -75,7 +75,7 @@ const Draggable = ( {
|
|
|
75
75
|
id: draggingId.value,
|
|
76
76
|
} );
|
|
77
77
|
}
|
|
78
|
-
} else if ( onDragEnd ) {
|
|
78
|
+
} else if ( previous !== null && onDragEnd ) {
|
|
79
79
|
onDragEnd( {
|
|
80
80
|
x: lastPosition.x.value,
|
|
81
81
|
y: lastPosition.y.value,
|