@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
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createContext, useMemo } from '@wordpress/element';
|
|
5
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
+
import { Icon, chevronDown } from '@wordpress/icons';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { VisuallyHidden } from '..';
|
|
12
|
+
import * as Styled from './styles';
|
|
13
|
+
import type {
|
|
14
|
+
CustomSelectContext as CustomSelectContextType,
|
|
15
|
+
CustomSelectStore,
|
|
16
|
+
CustomSelectButtonProps,
|
|
17
|
+
_CustomSelectProps,
|
|
18
|
+
} from './types';
|
|
19
|
+
import {
|
|
20
|
+
contextConnectWithoutRef,
|
|
21
|
+
useContextSystem,
|
|
22
|
+
type WordPressComponentProps,
|
|
23
|
+
} from '../context';
|
|
24
|
+
|
|
25
|
+
export const CustomSelectContext =
|
|
26
|
+
createContext< CustomSelectContextType >( undefined );
|
|
27
|
+
|
|
28
|
+
function defaultRenderSelectedValue(
|
|
29
|
+
value: CustomSelectButtonProps[ 'value' ]
|
|
30
|
+
) {
|
|
31
|
+
const isValueEmpty = Array.isArray( value )
|
|
32
|
+
? value.length === 0
|
|
33
|
+
: value === undefined || value === null;
|
|
34
|
+
|
|
35
|
+
if ( isValueEmpty ) {
|
|
36
|
+
return __( 'Select an item' );
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if ( Array.isArray( value ) ) {
|
|
40
|
+
return value.length === 1
|
|
41
|
+
? value[ 0 ]
|
|
42
|
+
: // translators: %s: number of items selected (it will always be 2 or more items)
|
|
43
|
+
sprintf( __( '%s items selected' ), value.length );
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const UnconnectedCustomSelectButton = (
|
|
50
|
+
props: Omit<
|
|
51
|
+
WordPressComponentProps<
|
|
52
|
+
CustomSelectButtonProps & CustomSelectStore,
|
|
53
|
+
'button',
|
|
54
|
+
false
|
|
55
|
+
>,
|
|
56
|
+
'onChange'
|
|
57
|
+
>
|
|
58
|
+
) => {
|
|
59
|
+
const {
|
|
60
|
+
renderSelectedValue,
|
|
61
|
+
size = 'default',
|
|
62
|
+
store,
|
|
63
|
+
...restProps
|
|
64
|
+
} = useContextSystem( props, 'CustomSelectControlButton' );
|
|
65
|
+
|
|
66
|
+
const { value: currentValue } = store.useState();
|
|
67
|
+
|
|
68
|
+
const computedRenderSelectedValue = useMemo(
|
|
69
|
+
() => renderSelectedValue ?? defaultRenderSelectedValue,
|
|
70
|
+
[ renderSelectedValue ]
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Styled.Select
|
|
75
|
+
{ ...restProps }
|
|
76
|
+
size={ size }
|
|
77
|
+
hasCustomRenderProp={ !! renderSelectedValue }
|
|
78
|
+
store={ store }
|
|
79
|
+
// to match legacy behavior where using arrow keys
|
|
80
|
+
// move selection rather than open the popover
|
|
81
|
+
showOnKeyDown={ false }
|
|
82
|
+
>
|
|
83
|
+
<div>{ computedRenderSelectedValue( currentValue ) }</div>
|
|
84
|
+
<Icon icon={ chevronDown } size={ 18 } />
|
|
85
|
+
</Styled.Select>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const CustomSelectButton = contextConnectWithoutRef(
|
|
90
|
+
UnconnectedCustomSelectButton,
|
|
91
|
+
'CustomSelectControlButton'
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
function _CustomSelect( props: _CustomSelectProps & CustomSelectStore ) {
|
|
95
|
+
const {
|
|
96
|
+
children,
|
|
97
|
+
hideLabelFromVision = false,
|
|
98
|
+
label,
|
|
99
|
+
store,
|
|
100
|
+
...restProps
|
|
101
|
+
} = props;
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<>
|
|
105
|
+
{ hideLabelFromVision ? ( // TODO: Replace with BaseControl
|
|
106
|
+
<VisuallyHidden as="label">{ label }</VisuallyHidden>
|
|
107
|
+
) : (
|
|
108
|
+
<Styled.SelectLabel store={ store }>
|
|
109
|
+
{ label }
|
|
110
|
+
</Styled.SelectLabel>
|
|
111
|
+
) }
|
|
112
|
+
<CustomSelectButton { ...restProps } store={ store } />
|
|
113
|
+
<Styled.SelectPopover gutter={ 12 } store={ store } sameWidth>
|
|
114
|
+
<CustomSelectContext.Provider value={ { store } }>
|
|
115
|
+
{ children }
|
|
116
|
+
</CustomSelectContext.Provider>
|
|
117
|
+
</Styled.SelectPopover>
|
|
118
|
+
</>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export default _CustomSelect;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
// eslint-disable-next-line no-restricted-imports
|
|
5
|
+
import * as Ariakit from '@ariakit/react';
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import _CustomSelect from '../custom-select';
|
|
10
|
+
import type { CustomSelectProps } from '../types';
|
|
11
|
+
import type { WordPressComponentProps } from '../../context';
|
|
12
|
+
|
|
13
|
+
function CustomSelect(
|
|
14
|
+
props: WordPressComponentProps< CustomSelectProps, 'button', false >
|
|
15
|
+
) {
|
|
16
|
+
const { defaultValue, onChange, value, ...restProps } = props;
|
|
17
|
+
// Forward props + store from v2 implementation
|
|
18
|
+
const store = Ariakit.useSelectStore( {
|
|
19
|
+
setValue: ( nextValue ) => onChange?.( nextValue ),
|
|
20
|
+
defaultValue,
|
|
21
|
+
value,
|
|
22
|
+
} );
|
|
23
|
+
|
|
24
|
+
return <_CustomSelect { ...restProps } store={ store } />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default CustomSelect;
|
|
@@ -1,105 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
// eslint-disable-next-line no-restricted-imports
|
|
5
|
-
import * as Ariakit from '@ariakit/react';
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { createContext, useContext } from '@wordpress/element';
|
|
10
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
11
|
-
|
|
12
1
|
/**
|
|
13
2
|
* Internal dependencies
|
|
14
3
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
CustomSelectProps,
|
|
18
|
-
CustomSelectItemProps,
|
|
19
|
-
CustomSelectContext as CustomSelectContextType,
|
|
20
|
-
} from './types';
|
|
21
|
-
import type { WordPressComponentProps } from '../context';
|
|
22
|
-
|
|
23
|
-
export const CustomSelectContext =
|
|
24
|
-
createContext< CustomSelectContextType >( undefined );
|
|
25
|
-
|
|
26
|
-
function defaultRenderSelectedValue( value: CustomSelectProps[ 'value' ] ) {
|
|
27
|
-
const isValueEmpty = Array.isArray( value )
|
|
28
|
-
? value.length === 0
|
|
29
|
-
: value === undefined || value === null;
|
|
30
|
-
|
|
31
|
-
if ( isValueEmpty ) {
|
|
32
|
-
return __( 'Select an item' );
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if ( Array.isArray( value ) ) {
|
|
36
|
-
return value.length === 1
|
|
37
|
-
? value[ 0 ]
|
|
38
|
-
: // translators: %s: number of items selected (it will always be 2 or more items)
|
|
39
|
-
sprintf( __( '%s items selected' ), value.length );
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return value;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function CustomSelect( {
|
|
46
|
-
children,
|
|
47
|
-
defaultValue,
|
|
48
|
-
label,
|
|
49
|
-
onChange,
|
|
50
|
-
size = 'default',
|
|
51
|
-
value,
|
|
52
|
-
renderSelectedValue,
|
|
53
|
-
...props
|
|
54
|
-
}: WordPressComponentProps< CustomSelectProps, 'button', false > ) {
|
|
55
|
-
const store = Ariakit.useSelectStore( {
|
|
56
|
-
setValue: ( nextValue ) => onChange?.( nextValue ),
|
|
57
|
-
defaultValue,
|
|
58
|
-
value,
|
|
59
|
-
// fix for Safari bug: https://github.com/WordPress/gutenberg/issues/55023#issuecomment-1834035917
|
|
60
|
-
virtualFocus: false,
|
|
61
|
-
} );
|
|
62
|
-
|
|
63
|
-
const { value: currentValue } = store.useState();
|
|
64
|
-
|
|
65
|
-
const computedRenderSelectedValue =
|
|
66
|
-
renderSelectedValue ?? defaultRenderSelectedValue;
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<>
|
|
70
|
-
<Styled.CustomSelectLabel store={ store }>
|
|
71
|
-
{ label }
|
|
72
|
-
</Styled.CustomSelectLabel>
|
|
73
|
-
<Styled.CustomSelectButton
|
|
74
|
-
{ ...props }
|
|
75
|
-
size={ size }
|
|
76
|
-
hasCustomRenderProp={ !! renderSelectedValue }
|
|
77
|
-
store={ store }
|
|
78
|
-
>
|
|
79
|
-
{ computedRenderSelectedValue( currentValue ) }
|
|
80
|
-
<Ariakit.SelectArrow />
|
|
81
|
-
</Styled.CustomSelectButton>
|
|
82
|
-
<Styled.CustomSelectPopover gutter={ 12 } store={ store } sameWidth>
|
|
83
|
-
<CustomSelectContext.Provider value={ { store } }>
|
|
84
|
-
{ children }
|
|
85
|
-
</CustomSelectContext.Provider>
|
|
86
|
-
</Styled.CustomSelectPopover>
|
|
87
|
-
</>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function CustomSelectItem( {
|
|
92
|
-
children,
|
|
93
|
-
...props
|
|
94
|
-
}: WordPressComponentProps< CustomSelectItemProps, 'div', false > ) {
|
|
95
|
-
const customSelectContext = useContext( CustomSelectContext );
|
|
96
|
-
return (
|
|
97
|
-
<Styled.CustomSelectItem
|
|
98
|
-
store={ customSelectContext?.store }
|
|
99
|
-
{ ...props }
|
|
100
|
-
>
|
|
101
|
-
{ children ?? props.value }
|
|
102
|
-
<Ariakit.SelectItemCheck />
|
|
103
|
-
</Styled.CustomSelectItem>
|
|
104
|
-
);
|
|
105
|
-
}
|
|
4
|
+
export { default as CustomSelect } from './default-component';
|
|
5
|
+
export { default as CustomSelectItem } from './custom-select-item';
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
// eslint-disable-next-line no-restricted-imports
|
|
5
|
+
import * as Ariakit from '@ariakit/react';
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useMemo } from '@wordpress/element';
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import _CustomSelect from '../custom-select';
|
|
14
|
+
import type { LegacyCustomSelectProps } from '../types';
|
|
15
|
+
import { CustomSelectItem } from '..';
|
|
16
|
+
import * as Styled from '../styles';
|
|
17
|
+
import { ContextSystemProvider } from '../../context';
|
|
18
|
+
|
|
19
|
+
function CustomSelect( props: LegacyCustomSelectProps ) {
|
|
20
|
+
const {
|
|
21
|
+
__experimentalShowSelectedHint,
|
|
22
|
+
__next40pxDefaultSize = false,
|
|
23
|
+
options,
|
|
24
|
+
onChange,
|
|
25
|
+
size = 'default',
|
|
26
|
+
value,
|
|
27
|
+
...restProps
|
|
28
|
+
} = props;
|
|
29
|
+
|
|
30
|
+
// Forward props + store from v2 implementation
|
|
31
|
+
const store = Ariakit.useSelectStore( {
|
|
32
|
+
async setValue( nextValue ) {
|
|
33
|
+
if ( ! onChange ) return;
|
|
34
|
+
|
|
35
|
+
// Executes the logic in a microtask after the popup is closed.
|
|
36
|
+
// This is simply to ensure the isOpen state matches that in Downshift.
|
|
37
|
+
await Promise.resolve();
|
|
38
|
+
const state = store.getState();
|
|
39
|
+
|
|
40
|
+
const changeObject = {
|
|
41
|
+
highlightedIndex: state.renderedItems.findIndex(
|
|
42
|
+
( item ) => item.value === nextValue
|
|
43
|
+
),
|
|
44
|
+
inputValue: '',
|
|
45
|
+
isOpen: state.open,
|
|
46
|
+
selectedItem: {
|
|
47
|
+
name: nextValue as string,
|
|
48
|
+
key: nextValue as string,
|
|
49
|
+
},
|
|
50
|
+
type: '',
|
|
51
|
+
};
|
|
52
|
+
onChange( changeObject );
|
|
53
|
+
},
|
|
54
|
+
} );
|
|
55
|
+
|
|
56
|
+
const children = options.map(
|
|
57
|
+
( { name, key, __experimentalHint, ...rest } ) => {
|
|
58
|
+
const withHint = (
|
|
59
|
+
<Styled.WithHintWrapper>
|
|
60
|
+
<span>{ name }</span>
|
|
61
|
+
<Styled.ExperimentalHintItem className="components-custom-select-control__item-hint">
|
|
62
|
+
{ __experimentalHint }
|
|
63
|
+
</Styled.ExperimentalHintItem>
|
|
64
|
+
</Styled.WithHintWrapper>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<CustomSelectItem
|
|
69
|
+
key={ key }
|
|
70
|
+
value={ name }
|
|
71
|
+
children={
|
|
72
|
+
__experimentalShowSelectedHint ? withHint : name
|
|
73
|
+
}
|
|
74
|
+
{ ...rest }
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const renderSelectedValueHint = () => {
|
|
81
|
+
const { value: currentValue } = store.getState();
|
|
82
|
+
|
|
83
|
+
const currentHint = options?.find(
|
|
84
|
+
( { name } ) => currentValue === name
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<>
|
|
89
|
+
{ currentValue }
|
|
90
|
+
<Styled.SelectedExperimentalHintItem className="components-custom-select-control__hint">
|
|
91
|
+
{ currentHint?.__experimentalHint }
|
|
92
|
+
</Styled.SelectedExperimentalHintItem>
|
|
93
|
+
</>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// translate legacy button sizing
|
|
98
|
+
const contextSystemValue = useMemo( () => {
|
|
99
|
+
let selectedSize;
|
|
100
|
+
|
|
101
|
+
if (
|
|
102
|
+
( __next40pxDefaultSize && size === 'default' ) ||
|
|
103
|
+
size === '__unstable-large'
|
|
104
|
+
) {
|
|
105
|
+
selectedSize = 'default';
|
|
106
|
+
} else if ( ! __next40pxDefaultSize && size === 'default' ) {
|
|
107
|
+
selectedSize = 'compact';
|
|
108
|
+
} else {
|
|
109
|
+
selectedSize = size;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
CustomSelectControlButton: { _overrides: { size: selectedSize } },
|
|
114
|
+
};
|
|
115
|
+
}, [ __next40pxDefaultSize, size ] );
|
|
116
|
+
|
|
117
|
+
const translatedProps = {
|
|
118
|
+
'aria-describedby': props.describedBy,
|
|
119
|
+
children,
|
|
120
|
+
renderSelectedValue: __experimentalShowSelectedHint
|
|
121
|
+
? renderSelectedValueHint
|
|
122
|
+
: undefined,
|
|
123
|
+
...restProps,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<ContextSystemProvider value={ contextSystemValue }>
|
|
128
|
+
<_CustomSelect { ...translatedProps } store={ store } />
|
|
129
|
+
</ContextSystemProvider>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export default CustomSelect;
|