@wordpress/components 25.13.0 → 25.15.1-next.79a6196f.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 +89 -1
- package/CONTRIBUTING.md +57 -115
- package/LICENSE.md +1 -1
- package/build/base-control/index.js +17 -13
- package/build/base-control/index.js.map +1 -1
- package/build/border-box-control/border-box-control-linked-button/component.js +1 -1
- package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +4 -2
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/border-control-dropdown/hook.js +3 -2
- package/build/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build/border-control/border-control-style-picker/component.js +1 -1
- package/build/border-control/border-control-style-picker/component.js.map +1 -1
- package/build/border-control/styles.js +17 -17
- package/build/border-control/styles.js.map +1 -1
- package/build/box-control/index.js +1 -1
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/linked-button.js +1 -1
- package/build/box-control/linked-button.js.map +1 -1
- package/build/button/index.js +1 -1
- package/build/button/index.js.map +1 -1
- package/build/checkbox-control/index.js +1 -1
- package/build/checkbox-control/index.js.map +1 -1
- package/build/checkbox-control/types.js.map +1 -1
- package/build/color-palette/index.native.js +11 -7
- package/build/color-palette/index.native.js.map +1 -1
- package/build/color-picker/color-copy-button.js +1 -1
- package/build/color-picker/color-copy-button.js.map +1 -1
- package/build/context/wordpress-component.js.map +1 -1
- package/build/custom-select-control-v2/index.js +11 -10
- package/build/custom-select-control-v2/index.js.map +1 -1
- package/build/date-time/date/styles.js +8 -8
- package/build/date-time/date/styles.js.map +1 -1
- package/build/date-time/time/timezone.js +11 -2
- package/build/date-time/time/timezone.js.map +1 -1
- package/build/dimension-control/index.js +2 -0
- package/build/dimension-control/index.js.map +1 -1
- package/build/dimension-control/types.js.map +1 -1
- package/build/dropdown-menu-v2/index.js +205 -159
- package/build/dropdown-menu-v2/index.js.map +1 -1
- package/build/dropdown-menu-v2/styles.js +86 -77
- package/build/dropdown-menu-v2/styles.js.map +1 -1
- package/build/dropdown-menu-v2/types.js.map +1 -1
- package/build/duotone-picker/duotone-picker.js +4 -3
- package/build/duotone-picker/duotone-picker.js.map +1 -1
- package/build/focal-point-picker/controls.js +5 -1
- package/build/focal-point-picker/controls.js.map +1 -1
- package/build/focal-point-picker/index.js +2 -0
- package/build/focal-point-picker/index.js.map +1 -1
- package/build/focal-point-picker/styles/focal-point-picker-style.js +15 -15
- package/build/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
- package/build/focal-point-picker/types.js.map +1 -1
- package/build/font-size-picker/font-size-picker-select.js +2 -0
- package/build/font-size-picker/font-size-picker-select.js.map +1 -1
- package/build/font-size-picker/font-size-picker-toggle-group.js +2 -0
- package/build/font-size-picker/font-size-picker-toggle-group.js.map +1 -1
- package/build/font-size-picker/index.js +10 -3
- package/build/font-size-picker/index.js.map +1 -1
- package/build/font-size-picker/index.native.js +6 -3
- package/build/font-size-picker/index.native.js.map +1 -1
- package/build/font-size-picker/types.js.map +1 -1
- package/build/form-token-field/index.js +10 -5
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/token.js +1 -0
- package/build/form-token-field/token.js.map +1 -1
- package/build/gradient-picker/index.js +3 -2
- package/build/gradient-picker/index.js.map +1 -1
- package/build/index.native.js +20 -19
- package/build/index.native.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +32 -29
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/input-control/types.js.map +1 -1
- package/build/lock-unlock.js +18 -0
- package/build/lock-unlock.js.map +1 -0
- package/build/mobile/bottom-sheet/index.native.js +8 -0
- package/build/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build/mobile/color-settings/palette.screen.native.js +8 -4
- package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +39 -13
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/mobile/image/constants.js +12 -0
- package/build/mobile/image/constants.js.map +1 -0
- package/build/mobile/image/index.native.js +26 -18
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.android.js +40 -8
- package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.ios.js +44 -68
- package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +39 -0
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
- package/build/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -29
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
- package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js +93 -0
- package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
- package/build/mobile/utils/get-px-from-css-unit.native.js +302 -0
- package/build/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
- package/build/modal/index.js +18 -13
- package/build/modal/index.js.map +1 -1
- package/build/navigation/menu/menu-title.js +1 -1
- package/build/navigation/menu/menu-title.js.map +1 -1
- package/build/navigator/navigator-provider/component.js +13 -15
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +23 -63
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/navigator/styles.js +52 -0
- package/build/navigator/styles.js.map +1 -0
- package/build/number-control/index.js +4 -8
- package/build/number-control/index.js.map +1 -1
- package/build/number-control/types.js.map +1 -1
- package/build/palette-edit/index.js +15 -34
- package/build/palette-edit/index.js.map +1 -1
- package/build/private-apis.js +11 -26
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +21 -0
- package/build/private-apis.native.js.map +1 -0
- package/build/query-controls/author-select.js +3 -1
- package/build/query-controls/author-select.js.map +1 -1
- package/build/query-controls/category-select.js +3 -1
- package/build/query-controls/category-select.js.map +1 -1
- package/build/query-controls/index.js +6 -1
- package/build/query-controls/index.js.map +1 -1
- package/build/query-controls/types.js.map +1 -1
- package/build/radio-control/index.js +1 -0
- package/build/radio-control/index.js.map +1 -1
- package/build/range-control/index.js +1 -1
- package/build/range-control/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +15 -25
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/slot-fill/index.js +3 -2
- package/build/slot-fill/index.js.map +1 -1
- package/build/slot-fill/types.js.map +1 -1
- package/build/snackbar/types.js.map +1 -1
- package/build/tabs/index.js +18 -1
- package/build/tabs/index.js.map +1 -1
- package/build/tabs/styles.js +3 -3
- package/build/tabs/styles.js.map +1 -1
- package/build/tabs/tab.js +2 -2
- package/build/tabs/tab.js.map +1 -1
- package/build/tabs/tabpanel.js +11 -8
- package/build/tabs/tabpanel.js.map +1 -1
- package/build/tabs/types.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +4 -4
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/styles.js +29 -15
- package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/utils.js +17 -17
- package/build/toggle-group-control/toggle-group-control/utils.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build/tools-panel/tools-panel/component.js +3 -1
- package/build/tools-panel/tools-panel/component.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +9 -8
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +11 -11
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/tools-panel/types.js.map +1 -1
- package/build/tooltip/index.js +34 -10
- package/build/tooltip/index.js.map +1 -1
- package/build/tooltip/types.js.map +1 -1
- package/build/truncate/hook.js +10 -4
- package/build/truncate/hook.js.map +1 -1
- package/build/truncate/types.js.map +1 -1
- package/build/unit-control/index.js +1 -1
- package/build/unit-control/index.js.map +1 -1
- package/build/utils/strings.js +34 -3
- package/build/utils/strings.js.map +1 -1
- package/build-module/base-control/index.js +16 -12
- package/build-module/base-control/index.js.map +1 -1
- package/build-module/border-box-control/border-box-control-linked-button/component.js +1 -1
- package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +4 -2
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/hook.js +3 -2
- package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build-module/border-control/border-control-style-picker/component.js +1 -1
- package/build-module/border-control/border-control-style-picker/component.js.map +1 -1
- package/build-module/border-control/styles.js +17 -17
- package/build-module/border-control/styles.js.map +1 -1
- package/build-module/box-control/index.js +1 -1
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/linked-button.js +1 -1
- package/build-module/box-control/linked-button.js.map +1 -1
- package/build-module/button/index.js +1 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/checkbox-control/index.js +1 -1
- package/build-module/checkbox-control/index.js.map +1 -1
- package/build-module/checkbox-control/types.js.map +1 -1
- package/build-module/color-palette/index.native.js +11 -7
- package/build-module/color-palette/index.native.js.map +1 -1
- package/build-module/color-picker/color-copy-button.js +1 -1
- package/build-module/color-picker/color-copy-button.js.map +1 -1
- package/build-module/context/wordpress-component.js.map +1 -1
- package/build-module/custom-select-control-v2/index.js +11 -10
- package/build-module/custom-select-control-v2/index.js.map +1 -1
- package/build-module/date-time/date/styles.js +8 -8
- package/build-module/date-time/date/styles.js.map +1 -1
- package/build-module/date-time/time/timezone.js +11 -2
- package/build-module/date-time/time/timezone.js.map +1 -1
- package/build-module/dimension-control/index.js +2 -0
- package/build-module/dimension-control/index.js.map +1 -1
- package/build-module/dimension-control/types.js.map +1 -1
- package/build-module/dropdown-menu-v2/index.js +201 -154
- package/build-module/dropdown-menu-v2/index.js.map +1 -1
- package/build-module/dropdown-menu-v2/styles.js +68 -61
- 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/duotone-picker/duotone-picker.js +4 -3
- package/build-module/duotone-picker/duotone-picker.js.map +1 -1
- package/build-module/focal-point-picker/controls.js +5 -1
- package/build-module/focal-point-picker/controls.js.map +1 -1
- package/build-module/focal-point-picker/index.js +2 -0
- package/build-module/focal-point-picker/index.js.map +1 -1
- package/build-module/focal-point-picker/styles/focal-point-picker-style.js +15 -15
- package/build-module/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
- package/build-module/focal-point-picker/types.js.map +1 -1
- package/build-module/font-size-picker/font-size-picker-select.js +2 -0
- package/build-module/font-size-picker/font-size-picker-select.js.map +1 -1
- package/build-module/font-size-picker/font-size-picker-toggle-group.js +2 -0
- package/build-module/font-size-picker/font-size-picker-toggle-group.js.map +1 -1
- package/build-module/font-size-picker/index.js +10 -3
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/font-size-picker/index.native.js +5 -2
- package/build-module/font-size-picker/index.native.js.map +1 -1
- package/build-module/font-size-picker/types.js.map +1 -1
- package/build-module/form-token-field/index.js +10 -5
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/token.js +1 -0
- package/build-module/form-token-field/token.js.map +1 -1
- package/build-module/gradient-picker/index.js +3 -2
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/index.native.js +6 -3
- package/build-module/index.native.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +31 -29
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/input-control/types.js.map +1 -1
- package/build-module/lock-unlock.js +9 -0
- package/build-module/lock-unlock.js.map +1 -0
- package/build-module/mobile/bottom-sheet/index.native.js +9 -1
- package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/palette.screen.native.js +8 -4
- package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +38 -13
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/mobile/image/constants.js +5 -0
- package/build-module/mobile/image/constants.js.map +1 -0
- package/build-module/mobile/image/index.native.js +25 -16
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js +40 -6
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +46 -68
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +33 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
- package/build-module/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +21 -27
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js +86 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
- package/build-module/mobile/utils/get-px-from-css-unit.native.js +294 -0
- package/build-module/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
- package/build-module/modal/index.js +18 -13
- package/build-module/modal/index.js.map +1 -1
- package/build-module/navigation/menu/menu-title.js +1 -1
- package/build-module/navigation/menu/menu-title.js.map +1 -1
- package/build-module/navigator/navigator-provider/component.js +3 -16
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +16 -70
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/navigator/styles.js +47 -0
- package/build-module/navigator/styles.js.map +1 -0
- package/build-module/number-control/index.js +4 -8
- package/build-module/number-control/index.js.map +1 -1
- package/build-module/number-control/types.js.map +1 -1
- package/build-module/palette-edit/index.js +14 -33
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/private-apis.js +10 -23
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +14 -0
- package/build-module/private-apis.native.js.map +1 -0
- package/build-module/query-controls/author-select.js +3 -1
- package/build-module/query-controls/author-select.js.map +1 -1
- package/build-module/query-controls/category-select.js +3 -1
- package/build-module/query-controls/category-select.js.map +1 -1
- package/build-module/query-controls/index.js +6 -1
- package/build-module/query-controls/index.js.map +1 -1
- package/build-module/query-controls/types.js.map +1 -1
- package/build-module/radio-control/index.js +1 -0
- package/build-module/radio-control/index.js.map +1 -1
- package/build-module/range-control/index.js +1 -1
- package/build-module/range-control/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +15 -25
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/slot-fill/index.js +3 -2
- package/build-module/slot-fill/index.js.map +1 -1
- package/build-module/slot-fill/types.js.map +1 -1
- package/build-module/snackbar/types.js.map +1 -1
- package/build-module/tabs/index.js +18 -1
- package/build-module/tabs/index.js.map +1 -1
- package/build-module/tabs/styles.js +3 -3
- package/build-module/tabs/styles.js.map +1 -1
- package/build-module/tabs/tab.js +2 -2
- package/build-module/tabs/tab.js.map +1 -1
- package/build-module/tabs/tabpanel.js +11 -8
- package/build-module/tabs/tabpanel.js.map +1 -1
- package/build-module/tabs/types.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +4 -4
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/styles.js +29 -15
- package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/utils.js +17 -17
- package/build-module/toggle-group-control/toggle-group-control/utils.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build-module/tools-panel/tools-panel/component.js +3 -1
- package/build-module/tools-panel/tools-panel/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +9 -8
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +11 -11
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/tools-panel/types.js.map +1 -1
- package/build-module/tooltip/index.js +34 -12
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tooltip/types.js.map +1 -1
- package/build-module/truncate/hook.js +10 -4
- package/build-module/truncate/hook.js.map +1 -1
- package/build-module/truncate/types.js.map +1 -1
- package/build-module/unit-control/index.js +1 -1
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/utils/strings.js +32 -2
- package/build-module/utils/strings.js.map +1 -1
- package/build-style/style-rtl.css +30 -6
- package/build-style/style.css +30 -6
- package/build-types/base-control/index.d.ts +3 -27
- package/build-types/base-control/index.d.ts.map +1 -1
- package/build-types/base-control/stories/index.story.d.ts +4 -1
- package/build-types/base-control/stories/index.story.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +4 -4
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +6 -6
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +4 -4
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +4 -4
- package/build-types/border-box-control/stories/index.story.d.ts +1 -1
- package/build-types/border-control/border-control/hook.d.ts +4 -4
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +5 -4
- package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-style-picker/hook.d.ts +4 -4
- package/build-types/border-control/stories/index.story.d.ts +6 -6
- package/build-types/border-control/styles.d.ts +1 -1
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/box-control/stories/index.story.d.ts +42 -42
- package/build-types/box-control/styles/box-control-styles.d.ts +1 -1
- package/build-types/button/deprecated.d.ts +3 -3
- package/build-types/card/card/hook.d.ts +4 -4
- package/build-types/card/card-body/hook.d.ts +4 -4
- package/build-types/card/card-divider/hook.d.ts +4 -4
- package/build-types/card/card-footer/hook.d.ts +4 -4
- package/build-types/card/card-header/hook.d.ts +4 -4
- package/build-types/card/card-media/hook.d.ts +4 -4
- package/build-types/checkbox-control/index.d.ts.map +1 -1
- package/build-types/checkbox-control/types.d.ts +3 -2
- package/build-types/checkbox-control/types.d.ts.map +1 -1
- package/build-types/color-palette/styles.d.ts +2 -2
- package/build-types/color-picker/component.d.ts +2 -2
- package/build-types/color-picker/stories/index.story.d.ts +1 -1
- package/build-types/color-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +3 -3
- package/build-types/composite/test/index.d.ts.map +1 -0
- package/build-types/context/wordpress-component.d.ts +3 -3
- package/build-types/context/wordpress-component.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/index.d.ts +3 -2
- package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/stories/index.story.d.ts +4 -3
- package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -1
- package/build-types/date-time/date/styles.d.ts +3 -3
- package/build-types/date-time/date-time/styles.d.ts +1 -1
- package/build-types/date-time/time/styles.d.ts +4 -4
- package/build-types/date-time/time/timezone.d.ts.map +1 -1
- package/build-types/dimension-control/index.d.ts.map +1 -1
- package/build-types/dimension-control/types.d.ts +6 -0
- package/build-types/dimension-control/types.d.ts.map +1 -1
- package/build-types/dropdown/index.d.ts +1 -1
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.story.d.ts +3 -3
- package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown-menu/index.d.ts +1 -1
- package/build-types/dropdown-menu/index.d.ts.map +1 -1
- package/build-types/dropdown-menu/stories/index.story.d.ts +2 -2
- package/build-types/dropdown-menu/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/index.d.ts +18 -15
- package/build-types/dropdown-menu-v2/index.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts +7 -2
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/styles.d.ts +77 -23
- package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/types.d.ts +89 -173
- package/build-types/dropdown-menu-v2/types.d.ts.map +1 -1
- package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -1
- package/build-types/elevation/hook.d.ts +4 -4
- package/build-types/flex/flex/hook.d.ts +4 -4
- package/build-types/flex/flex-block/hook.d.ts +4 -4
- package/build-types/flex/flex-item/hook.d.ts +4 -4
- package/build-types/focal-point-picker/controls.d.ts +1 -1
- package/build-types/focal-point-picker/controls.d.ts.map +1 -1
- package/build-types/focal-point-picker/index.d.ts +1 -1
- package/build-types/focal-point-picker/index.d.ts.map +1 -1
- package/build-types/focal-point-picker/stories/index.story.d.ts +8 -4
- package/build-types/focal-point-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
- package/build-types/focal-point-picker/types.d.ts +7 -0
- package/build-types/focal-point-picker/types.d.ts.map +1 -1
- package/build-types/font-size-picker/font-size-picker-select.d.ts.map +1 -1
- package/build-types/font-size-picker/font-size-picker-toggle-group.d.ts.map +1 -1
- package/build-types/font-size-picker/index.d.ts.map +1 -1
- package/build-types/font-size-picker/styles.d.ts +1 -1
- package/build-types/font-size-picker/types.d.ts +8 -1
- package/build-types/font-size-picker/types.d.ts.map +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/token.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts +4 -4
- package/build-types/h-stack/hook.d.ts +4 -4
- package/build-types/heading/component.d.ts +1 -1
- package/build-types/heading/hook.d.ts +4 -4
- package/build-types/input-control/styles/input-control-styles.d.ts +11 -0
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +1 -1
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/item-group/item/hook.d.ts +4 -4
- package/build-types/item-group/item-group/hook.d.ts +4 -4
- package/build-types/lock-unlock.d.ts +3 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/menu-item/index.d.ts +1 -1
- package/build-types/menu-item/stories/index.story.d.ts +4 -4
- package/build-types/mobile/image/constants.d.ts +5 -0
- package/build-types/mobile/image/constants.d.ts.map +1 -0
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/navigation/styles/navigation-styles.d.ts +3 -3
- package/build-types/navigator/navigator-back-button/hook.d.ts +6 -6
- package/build-types/navigator/navigator-button/hook.d.ts +6 -6
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts +1 -7
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/navigator/styles.d.ts +9 -0
- package/build-types/navigator/styles.d.ts.map +1 -0
- package/build-types/number-control/index.d.ts +1 -1
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/stories/index.story.d.ts +1 -1
- package/build-types/number-control/types.d.ts +1 -1
- package/build-types/palette-edit/index.d.ts +2 -2
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/palette-edit/styles.d.ts +3 -3
- package/build-types/popover/index.d.ts +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/stories/e2e/index.story.d.ts +1 -1
- package/build-types/private-apis.d.ts +0 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/query-controls/author-select.d.ts +1 -1
- package/build-types/query-controls/author-select.d.ts.map +1 -1
- package/build-types/query-controls/category-select.d.ts +1 -1
- package/build-types/query-controls/category-select.d.ts.map +1 -1
- package/build-types/query-controls/index.d.ts +1 -1
- package/build-types/query-controls/index.d.ts.map +1 -1
- package/build-types/query-controls/types.d.ts +9 -0
- package/build-types/query-controls/types.d.ts.map +1 -1
- package/build-types/radio-control/index.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
- package/build-types/resizable-box/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
- package/build-types/resizable-box/stories/index.story.d.ts +2 -2
- package/build-types/scrollable/hook.d.ts +4 -4
- package/build-types/search-control/index.d.ts +1 -1
- package/build-types/search-control/stories/index.story.d.ts +2 -2
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/slot-fill/index.d.ts +1 -1
- package/build-types/slot-fill/index.d.ts.map +1 -1
- package/build-types/slot-fill/types.d.ts +4 -0
- package/build-types/slot-fill/types.d.ts.map +1 -1
- package/build-types/snackbar/index.d.ts +2 -2
- package/build-types/snackbar/stories/index.story.d.ts +0 -3
- package/build-types/snackbar/stories/index.story.d.ts.map +1 -1
- package/build-types/snackbar/types.d.ts +1 -1
- package/build-types/snackbar/types.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts +4 -4
- package/build-types/surface/hook.d.ts +4 -4
- package/build-types/tabs/index.d.ts +2 -2
- package/build-types/tabs/index.d.ts.map +1 -1
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/tabs/tab.d.ts +2 -1
- package/build-types/tabs/tab.d.ts.map +1 -1
- package/build-types/tabs/tabpanel.d.ts +3 -2
- package/build-types/tabs/tabpanel.d.ts.map +1 -1
- package/build-types/tabs/types.d.ts +8 -3
- package/build-types/tabs/types.d.ts.map +1 -1
- package/build-types/text/hook.d.ts +4 -4
- package/build-types/text-control/index.d.ts +1 -1
- package/build-types/textarea-control/index.d.ts +1 -1
- package/build-types/toggle-control/stories/index.story.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +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/styles.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/utils.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
- package/build-types/toolbar/toolbar-button/index.d.ts +3 -3
- package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +5 -4
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +5 -4
- package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +4 -4
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +9 -0
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/tooltip/stories/index.story.d.ts +10 -1
- package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
- package/build-types/tooltip/types.d.ts +3 -0
- package/build-types/tooltip/types.d.ts.map +1 -1
- package/build-types/truncate/hook.d.ts +5 -5
- package/build-types/truncate/hook.d.ts.map +1 -1
- package/build-types/truncate/types.d.ts +4 -0
- package/build-types/truncate/types.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
- package/build-types/utils/strings.d.ts +14 -2
- package/build-types/utils/strings.d.ts.map +1 -1
- package/build-types/v-stack/hook.d.ts +4 -4
- package/build-types/v-stack/stories/index.story.d.ts +1 -1
- package/package.json +20 -21
- package/src/alignment-matrix-control/test/index.tsx +10 -16
- package/src/base-control/index.tsx +21 -16
- package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -1
- package/src/border-control/border-control-dropdown/component.tsx +3 -1
- package/src/border-control/border-control-dropdown/hook.ts +3 -2
- package/src/border-control/border-control-style-picker/component.tsx +1 -1
- package/src/border-control/styles.ts +2 -9
- package/src/box-control/index.tsx +1 -1
- package/src/box-control/linked-button.tsx +1 -1
- package/src/button/README.md +32 -6
- package/src/button/index.tsx +1 -1
- package/src/button-group/README.md +0 -6
- package/src/card/card/README.md +1 -1
- package/src/checkbox-control/README.md +3 -10
- package/src/checkbox-control/index.tsx +8 -6
- package/src/checkbox-control/test/__snapshots__/index.tsx.snap +3 -8
- package/src/checkbox-control/test/index.tsx +7 -0
- package/src/checkbox-control/types.ts +3 -2
- package/src/color-palette/index.native.js +18 -7
- package/src/color-picker/color-copy-button.tsx +1 -1
- package/src/combobox-control/README.md +0 -6
- package/src/composite/test/index.tsx +576 -0
- package/src/context/wordpress-component.ts +11 -6
- package/src/custom-select-control/README.md +0 -6
- package/src/custom-select-control/test/index.js +367 -35
- package/src/custom-select-control-v2/index.tsx +13 -12
- package/src/date-time/date/styles.ts +3 -3
- package/src/date-time/time/timezone.tsx +15 -3
- package/src/dimension-control/index.tsx +2 -0
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +2 -2
- package/src/dimension-control/types.ts +6 -0
- package/src/dropdown-menu/README.md +0 -5
- package/src/dropdown-menu-v2/README.md +75 -136
- package/src/dropdown-menu-v2/index.tsx +321 -231
- package/src/dropdown-menu-v2/stories/index.story.tsx +522 -126
- package/src/dropdown-menu-v2/styles.ts +226 -151
- package/src/dropdown-menu-v2/test/index.tsx +480 -188
- package/src/dropdown-menu-v2/types.ts +98 -184
- package/src/duotone-picker/duotone-picker.tsx +7 -3
- package/src/focal-point-picker/controls.tsx +4 -0
- package/src/focal-point-picker/index.tsx +2 -0
- package/src/focal-point-picker/styles/focal-point-picker-style.ts +1 -1
- package/src/focal-point-picker/types.ts +7 -0
- package/src/font-size-picker/font-size-picker-select.tsx +2 -0
- package/src/font-size-picker/font-size-picker-toggle-group.tsx +9 -1
- package/src/font-size-picker/index.native.js +8 -2
- package/src/font-size-picker/index.tsx +15 -5
- package/src/font-size-picker/types.ts +8 -1
- package/src/form-toggle/README.md +0 -6
- package/src/form-toggle/style.scss +4 -2
- package/src/form-token-field/index.tsx +11 -7
- package/src/form-token-field/test/index.tsx +97 -0
- package/src/form-token-field/token.tsx +1 -0
- package/src/gradient-picker/index.tsx +2 -2
- package/src/index.native.js +6 -3
- package/src/input-control/styles/input-control-styles.tsx +10 -8
- package/src/input-control/types.ts +1 -1
- package/src/lock-unlock.js +10 -0
- package/src/menu-group/README.md +0 -8
- package/src/menu-items-choice/README.md +0 -7
- package/src/mobile/bottom-sheet/index.native.js +15 -1
- package/src/mobile/color-settings/palette.screen.native.js +7 -5
- package/src/mobile/global-styles-context/test/fixtures/theme.native.js +0 -20
- package/src/mobile/global-styles-context/test/utils.native.js +22 -0
- package/src/mobile/global-styles-context/utils.native.js +42 -19
- package/src/mobile/image/constants.js +1 -0
- package/src/mobile/image/index.native.js +55 -18
- package/src/mobile/image/style.native.scss +35 -9
- package/src/mobile/keyboard-aware-flat-list/index.android.js +50 -5
- package/src/mobile/keyboard-aware-flat-list/index.ios.js +65 -91
- package/src/mobile/keyboard-aware-flat-list/test/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +27 -25
- package/src/mobile/keyboard-aware-flat-list/test/use-scroll.native.js +71 -0
- package/src/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +41 -0
- package/src/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -27
- package/src/mobile/keyboard-aware-flat-list/use-scroll.native.js +100 -0
- package/src/mobile/link-settings/style.native.scss +0 -17
- package/src/mobile/utils/get-px-from-css-unit.native.js +329 -0
- package/src/mobile/utils/test/get-px-from-css-unit.native.js +172 -0
- package/src/modal/README.md +0 -6
- package/src/modal/index.tsx +18 -16
- package/src/modal/test/index.tsx +90 -1
- package/src/navigation/menu/menu-title.tsx +1 -1
- package/src/navigator/navigator-provider/component.tsx +3 -4
- package/src/navigator/navigator-screen/component.tsx +15 -93
- package/src/navigator/styles.ts +71 -0
- package/src/navigator/test/index.tsx +0 -64
- package/src/notice/README.md +0 -6
- package/src/number-control/README.md +2 -2
- package/src/number-control/index.tsx +4 -8
- package/src/number-control/types.ts +1 -1
- package/src/palette-edit/index.tsx +14 -43
- package/src/palette-edit/style.scss +2 -2
- package/src/panel/README.md +0 -6
- package/src/private-apis.native.js +13 -0
- package/src/private-apis.ts +12 -37
- package/src/query-controls/author-select.tsx +2 -0
- package/src/query-controls/category-select.tsx +2 -0
- package/src/query-controls/index.tsx +6 -1
- package/src/query-controls/types.ts +9 -0
- package/src/radio-control/README.md +0 -6
- package/src/radio-control/index.tsx +4 -1
- package/src/radio-control/style.scss +29 -2
- package/src/radio-group/README.md +0 -6
- package/src/range-control/README.md +1 -9
- package/src/range-control/index.tsx +1 -1
- package/src/search-control/README.md +1 -5
- package/src/select-control/README.md +0 -6
- package/src/select-control/styles/select-control-styles.ts +10 -28
- package/src/slot-fill/index.tsx +5 -2
- package/src/slot-fill/types.ts +5 -0
- package/src/snackbar/README.md +0 -6
- package/src/snackbar/stories/index.story.tsx +7 -5
- package/src/snackbar/style.scss +4 -3
- package/src/snackbar/types.ts +2 -1
- package/src/spacer/README.md +0 -2
- package/src/spinner/README.md +2 -0
- package/src/tab-panel/README.md +0 -5
- package/src/tab-panel/test/index.tsx +39 -56
- package/src/tabs/README.md +4 -4
- package/src/tabs/index.tsx +22 -1
- package/src/tabs/stories/index.story.tsx +48 -48
- package/src/tabs/styles.ts +7 -1
- package/src/tabs/tab.tsx +3 -3
- package/src/tabs/tabpanel.tsx +13 -8
- package/src/tabs/test/index.tsx +236 -106
- package/src/tabs/types.ts +8 -3
- package/src/text-control/README.md +0 -6
- package/src/textarea-control/README.md +0 -6
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +12 -16
- package/src/toggle-group-control/test/index.tsx +107 -41
- package/src/toggle-group-control/toggle-group-control/component.tsx +5 -4
- package/src/toggle-group-control/toggle-group-control/styles.ts +13 -19
- package/src/toggle-group-control/toggle-group-control/utils.ts +15 -20
- package/src/toggle-group-control/toggle-group-control-option/README.md +1 -1
- package/src/toggle-group-control/toggle-group-control-option-base/README.md +1 -1
- package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +3 -2
- package/src/toggle-group-control/toggle-group-control-option-icon/README.md +1 -1
- package/src/toolbar/toolbar/README.md +0 -6
- package/src/tools-panel/test/index.tsx +12 -20
- package/src/tools-panel/tools-panel/README.md +7 -0
- package/src/tools-panel/tools-panel/component.tsx +2 -0
- package/src/tools-panel/tools-panel-header/README.md +7 -0
- package/src/tools-panel/tools-panel-header/component.tsx +20 -13
- package/src/tools-panel/tools-panel-item/hook.ts +10 -21
- package/src/tools-panel/types.ts +9 -0
- package/src/tooltip/README.md +4 -0
- package/src/tooltip/index.tsx +48 -10
- package/src/tooltip/stories/index.story.tsx +18 -1
- package/src/tooltip/test/index.tsx +404 -254
- package/src/tooltip/types.ts +4 -0
- package/src/tree-grid/README.md +0 -4
- package/src/truncate/README.md +8 -0
- package/src/truncate/hook.ts +17 -10
- package/src/truncate/test/index.tsx +54 -27
- package/src/truncate/types.ts +4 -0
- package/src/unit-control/index.tsx +1 -1
- package/src/utils/strings.ts +30 -2
- package/src/utils/test/strings.js +96 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dropdown-menu-v2-ariakit/index.js +0 -256
- package/build/dropdown-menu-v2-ariakit/index.js.map +0 -1
- package/build/dropdown-menu-v2-ariakit/styles.js +0 -180
- package/build/dropdown-menu-v2-ariakit/styles.js.map +0 -1
- package/build/dropdown-menu-v2-ariakit/types.js +0 -6
- package/build/dropdown-menu-v2-ariakit/types.js.map +0 -1
- package/build/mobile/inserter-button/index.native.js +0 -98
- package/build/mobile/inserter-button/index.native.js.map +0 -1
- package/build/mobile/inserter-button/sparkles.js +0 -23
- package/build/mobile/inserter-button/sparkles.js.map +0 -1
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
- package/build/mobile/link-settings/image-link-destinations-screen.native.js +0 -119
- package/build/mobile/link-settings/image-link-destinations-screen.native.js.map +0 -1
- package/build-module/dropdown-menu-v2-ariakit/index.js +0 -237
- package/build-module/dropdown-menu-v2-ariakit/index.js.map +0 -1
- package/build-module/dropdown-menu-v2-ariakit/styles.js +0 -165
- package/build-module/dropdown-menu-v2-ariakit/styles.js.map +0 -1
- package/build-module/dropdown-menu-v2-ariakit/types.js +0 -2
- package/build-module/dropdown-menu-v2-ariakit/types.js.map +0 -1
- package/build-module/mobile/inserter-button/index.native.js +0 -89
- package/build-module/mobile/inserter-button/index.native.js.map +0 -1
- package/build-module/mobile/inserter-button/sparkles.js +0 -15
- package/build-module/mobile/inserter-button/sparkles.js.map +0 -1
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
- package/build-module/mobile/link-settings/image-link-destinations-screen.native.js +0 -110
- package/build-module/mobile/link-settings/image-link-destinations-screen.native.js.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/index.d.ts +0 -20
- package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts +0 -16
- package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +0 -96
- package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/types.d.ts +0 -168
- package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +0 -1
- package/build-types/mobile/inserter-button/sparkles.d.ts +0 -3
- package/build-types/mobile/inserter-button/sparkles.d.ts.map +0 -1
- package/src/dropdown-menu-v2-ariakit/README.md +0 -331
- package/src/dropdown-menu-v2-ariakit/index.tsx +0 -383
- package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +0 -617
- package/src/dropdown-menu-v2-ariakit/styles.ts +0 -333
- package/src/dropdown-menu-v2-ariakit/test/index.tsx +0 -1108
- package/src/dropdown-menu-v2-ariakit/types.ts +0 -179
- package/src/mobile/inserter-button/README.md +0 -62
- package/src/mobile/inserter-button/index.native.js +0 -116
- package/src/mobile/inserter-button/sparkles.js +0 -15
- package/src/mobile/inserter-button/style.native.scss +0 -72
- package/src/mobile/link-settings/image-link-destinations-screen.native.js +0 -152
- /package/build-types/{dropdown-menu-v2-ariakit → composite}/test/index.d.ts +0 -0
package/src/tabs/test/index.tsx
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
5
|
-
import
|
|
5
|
+
import { press, click } from '@ariakit/test';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { useState } from '@wordpress/element';
|
|
10
|
+
import { useEffect, useState } from '@wordpress/element';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
@@ -16,7 +16,7 @@ import Tabs from '..';
|
|
|
16
16
|
import type { TabsProps } from '../types';
|
|
17
17
|
|
|
18
18
|
type Tab = {
|
|
19
|
-
|
|
19
|
+
tabId: string;
|
|
20
20
|
title: string;
|
|
21
21
|
content: React.ReactNode;
|
|
22
22
|
tab: {
|
|
@@ -30,19 +30,19 @@ type Tab = {
|
|
|
30
30
|
|
|
31
31
|
const TABS: Tab[] = [
|
|
32
32
|
{
|
|
33
|
-
|
|
33
|
+
tabId: 'alpha',
|
|
34
34
|
title: 'Alpha',
|
|
35
35
|
content: 'Selected tab: Alpha',
|
|
36
36
|
tab: { className: 'alpha-class' },
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
|
-
|
|
39
|
+
tabId: 'beta',
|
|
40
40
|
title: 'Beta',
|
|
41
41
|
content: 'Selected tab: Beta',
|
|
42
42
|
tab: { className: 'beta-class' },
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
|
-
|
|
45
|
+
tabId: 'gamma',
|
|
46
46
|
title: 'Gamma',
|
|
47
47
|
content: 'Selected tab: Gamma',
|
|
48
48
|
tab: { className: 'gamma-class' },
|
|
@@ -52,7 +52,7 @@ const TABS: Tab[] = [
|
|
|
52
52
|
const TABS_WITH_DELTA: Tab[] = [
|
|
53
53
|
...TABS,
|
|
54
54
|
{
|
|
55
|
-
|
|
55
|
+
tabId: 'delta',
|
|
56
56
|
title: 'Delta',
|
|
57
57
|
content: 'Selected tab: Delta',
|
|
58
58
|
tab: { className: 'delta-class' },
|
|
@@ -70,8 +70,8 @@ const UncontrolledTabs = ( {
|
|
|
70
70
|
<Tabs.TabList>
|
|
71
71
|
{ tabs.map( ( tabObj ) => (
|
|
72
72
|
<Tabs.Tab
|
|
73
|
-
key={ tabObj.
|
|
74
|
-
|
|
73
|
+
key={ tabObj.tabId }
|
|
74
|
+
tabId={ tabObj.tabId }
|
|
75
75
|
className={ tabObj.tab.className }
|
|
76
76
|
disabled={ tabObj.tab.disabled }
|
|
77
77
|
>
|
|
@@ -81,8 +81,8 @@ const UncontrolledTabs = ( {
|
|
|
81
81
|
</Tabs.TabList>
|
|
82
82
|
{ tabs.map( ( tabObj ) => (
|
|
83
83
|
<Tabs.TabPanel
|
|
84
|
-
key={ tabObj.
|
|
85
|
-
|
|
84
|
+
key={ tabObj.tabId }
|
|
85
|
+
tabId={ tabObj.tabId }
|
|
86
86
|
focusable={ tabObj.tabpanel?.focusable }
|
|
87
87
|
>
|
|
88
88
|
{ tabObj.content }
|
|
@@ -102,6 +102,10 @@ const ControlledTabs = ( {
|
|
|
102
102
|
string | undefined | null
|
|
103
103
|
>( props.selectedTabId );
|
|
104
104
|
|
|
105
|
+
useEffect( () => {
|
|
106
|
+
setSelectedTabId( props.selectedTabId );
|
|
107
|
+
}, [ props.selectedTabId ] );
|
|
108
|
+
|
|
105
109
|
return (
|
|
106
110
|
<Tabs
|
|
107
111
|
{ ...props }
|
|
@@ -114,8 +118,8 @@ const ControlledTabs = ( {
|
|
|
114
118
|
<Tabs.TabList>
|
|
115
119
|
{ tabs.map( ( tabObj ) => (
|
|
116
120
|
<Tabs.Tab
|
|
117
|
-
key={ tabObj.
|
|
118
|
-
|
|
121
|
+
key={ tabObj.tabId }
|
|
122
|
+
tabId={ tabObj.tabId }
|
|
119
123
|
className={ tabObj.tab.className }
|
|
120
124
|
disabled={ tabObj.tab.disabled }
|
|
121
125
|
>
|
|
@@ -124,7 +128,7 @@ const ControlledTabs = ( {
|
|
|
124
128
|
) ) }
|
|
125
129
|
</Tabs.TabList>
|
|
126
130
|
{ tabs.map( ( tabObj ) => (
|
|
127
|
-
<Tabs.TabPanel key={ tabObj.
|
|
131
|
+
<Tabs.TabPanel key={ tabObj.tabId } tabId={ tabObj.tabId }>
|
|
128
132
|
{ tabObj.content }
|
|
129
133
|
</Tabs.TabPanel>
|
|
130
134
|
) ) }
|
|
@@ -184,28 +188,24 @@ describe( 'Tabs', () => {
|
|
|
184
188
|
} );
|
|
185
189
|
describe( 'Focus Behavior', () => {
|
|
186
190
|
it( 'should focus on the related TabPanel when pressing the Tab key', async () => {
|
|
187
|
-
const user = userEvent.setup();
|
|
188
|
-
|
|
189
191
|
render( <UncontrolledTabs tabs={ TABS } /> );
|
|
190
192
|
|
|
191
193
|
const selectedTabPanel = await screen.findByRole( 'tabpanel' );
|
|
192
194
|
|
|
193
195
|
// Tab should initially focus the first tab in the tablist, which
|
|
194
196
|
// is Alpha.
|
|
195
|
-
await
|
|
197
|
+
await press.Tab();
|
|
196
198
|
expect(
|
|
197
199
|
await screen.findByRole( 'tab', { name: 'Alpha' } )
|
|
198
200
|
).toHaveFocus();
|
|
199
201
|
|
|
200
202
|
// By default the tabpanel should receive focus
|
|
201
|
-
await
|
|
203
|
+
await press.Tab();
|
|
202
204
|
expect( selectedTabPanel ).toHaveFocus();
|
|
203
205
|
} );
|
|
204
206
|
it( 'should not focus on the related TabPanel when pressing the Tab key if `focusable: false` is set', async () => {
|
|
205
|
-
const user = userEvent.setup();
|
|
206
|
-
|
|
207
207
|
const TABS_WITH_ALPHA_FOCUSABLE_FALSE = TABS.map( ( tabObj ) =>
|
|
208
|
-
tabObj.
|
|
208
|
+
tabObj.tabId === 'alpha'
|
|
209
209
|
? {
|
|
210
210
|
...tabObj,
|
|
211
211
|
content: (
|
|
@@ -229,13 +229,13 @@ describe( 'Tabs', () => {
|
|
|
229
229
|
|
|
230
230
|
// Tab should initially focus the first tab in the tablist, which
|
|
231
231
|
// is Alpha.
|
|
232
|
-
await
|
|
232
|
+
await press.Tab();
|
|
233
233
|
expect(
|
|
234
234
|
await screen.findByRole( 'tab', { name: 'Alpha' } )
|
|
235
235
|
).toHaveFocus();
|
|
236
236
|
// Because the alpha tabpanel is set to `focusable: false`, pressing
|
|
237
237
|
// the Tab key should focus the button, not the tabpanel
|
|
238
|
-
await
|
|
238
|
+
await press.Tab();
|
|
239
239
|
expect( alphaButton ).toHaveFocus();
|
|
240
240
|
} );
|
|
241
241
|
} );
|
|
@@ -258,7 +258,6 @@ describe( 'Tabs', () => {
|
|
|
258
258
|
|
|
259
259
|
describe( 'Tab Activation', () => {
|
|
260
260
|
it( 'defaults to automatic tab activation (pointer clicks)', async () => {
|
|
261
|
-
const user = userEvent.setup();
|
|
262
261
|
const mockOnSelect = jest.fn();
|
|
263
262
|
|
|
264
263
|
render(
|
|
@@ -273,7 +272,7 @@ describe( 'Tabs', () => {
|
|
|
273
272
|
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'alpha' );
|
|
274
273
|
|
|
275
274
|
// Click on Beta, make sure beta is the selected tab
|
|
276
|
-
await
|
|
275
|
+
await click( screen.getByRole( 'tab', { name: 'Beta' } ) );
|
|
277
276
|
|
|
278
277
|
expect( await getSelectedTab() ).toHaveTextContent( 'Beta' );
|
|
279
278
|
expect(
|
|
@@ -282,7 +281,7 @@ describe( 'Tabs', () => {
|
|
|
282
281
|
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'beta' );
|
|
283
282
|
|
|
284
283
|
// Click on Alpha, make sure beta is the selected tab
|
|
285
|
-
await
|
|
284
|
+
await click( screen.getByRole( 'tab', { name: 'Alpha' } ) );
|
|
286
285
|
|
|
287
286
|
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
288
287
|
expect(
|
|
@@ -292,7 +291,6 @@ describe( 'Tabs', () => {
|
|
|
292
291
|
} );
|
|
293
292
|
|
|
294
293
|
it( 'defaults to automatic tab activation (arrow keys)', async () => {
|
|
295
|
-
const user = userEvent.setup();
|
|
296
294
|
const mockOnSelect = jest.fn();
|
|
297
295
|
|
|
298
296
|
render(
|
|
@@ -307,12 +305,12 @@ describe( 'Tabs', () => {
|
|
|
307
305
|
// Tab to focus the tablist. Make sure alpha is focused.
|
|
308
306
|
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
309
307
|
expect( await getSelectedTab() ).not.toHaveFocus();
|
|
310
|
-
await
|
|
308
|
+
await press.Tab();
|
|
311
309
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
312
310
|
|
|
313
311
|
// Navigate forward with arrow keys and make sure the Beta tab is
|
|
314
312
|
// selected automatically.
|
|
315
|
-
await
|
|
313
|
+
await press.ArrowRight();
|
|
316
314
|
expect( await getSelectedTab() ).toHaveTextContent( 'Beta' );
|
|
317
315
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
318
316
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 2 );
|
|
@@ -320,7 +318,7 @@ describe( 'Tabs', () => {
|
|
|
320
318
|
|
|
321
319
|
// Navigate backwards with arrow keys. Make sure alpha is
|
|
322
320
|
// selected automatically.
|
|
323
|
-
await
|
|
321
|
+
await press.ArrowLeft();
|
|
324
322
|
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
325
323
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
326
324
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 3 );
|
|
@@ -328,7 +326,6 @@ describe( 'Tabs', () => {
|
|
|
328
326
|
} );
|
|
329
327
|
|
|
330
328
|
it( 'wraps around the last/first tab when using arrow keys', async () => {
|
|
331
|
-
const user = userEvent.setup();
|
|
332
329
|
const mockOnSelect = jest.fn();
|
|
333
330
|
|
|
334
331
|
render(
|
|
@@ -341,12 +338,12 @@ describe( 'Tabs', () => {
|
|
|
341
338
|
// Tab to focus the tablist. Make sure Alpha is focused.
|
|
342
339
|
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
343
340
|
expect( await getSelectedTab() ).not.toHaveFocus();
|
|
344
|
-
await
|
|
341
|
+
await press.Tab();
|
|
345
342
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
346
343
|
|
|
347
344
|
// Navigate backwards with arrow keys and make sure that the Gamma tab
|
|
348
345
|
// (the last tab) is selected automatically.
|
|
349
|
-
await
|
|
346
|
+
await press.ArrowLeft();
|
|
350
347
|
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
351
348
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
352
349
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 2 );
|
|
@@ -354,7 +351,7 @@ describe( 'Tabs', () => {
|
|
|
354
351
|
|
|
355
352
|
// Navigate forward with arrow keys. Make sure alpha (the first tab) is
|
|
356
353
|
// selected automatically.
|
|
357
|
-
await
|
|
354
|
+
await press.ArrowRight();
|
|
358
355
|
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
359
356
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
360
357
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 3 );
|
|
@@ -362,7 +359,6 @@ describe( 'Tabs', () => {
|
|
|
362
359
|
} );
|
|
363
360
|
|
|
364
361
|
it( 'should not move tab selection when pressing the up/down arrow keys, unless the orientation is changed to `vertical`', async () => {
|
|
365
|
-
const user = userEvent.setup();
|
|
366
362
|
const mockOnSelect = jest.fn();
|
|
367
363
|
|
|
368
364
|
const { rerender } = render(
|
|
@@ -377,18 +373,18 @@ describe( 'Tabs', () => {
|
|
|
377
373
|
// Tab to focus the tablist. Make sure alpha is focused.
|
|
378
374
|
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
379
375
|
expect( await getSelectedTab() ).not.toHaveFocus();
|
|
380
|
-
await
|
|
376
|
+
await press.Tab();
|
|
381
377
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
382
378
|
|
|
383
379
|
// Press the arrow up key, nothing happens.
|
|
384
|
-
await
|
|
380
|
+
await press.ArrowUp();
|
|
385
381
|
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
386
382
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
387
383
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 1 );
|
|
388
384
|
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'alpha' );
|
|
389
385
|
|
|
390
386
|
// Press the arrow down key, nothing happens
|
|
391
|
-
await
|
|
387
|
+
await press.ArrowDown();
|
|
392
388
|
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
393
389
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
394
390
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 1 );
|
|
@@ -415,7 +411,7 @@ describe( 'Tabs', () => {
|
|
|
415
411
|
|
|
416
412
|
// Navigate forward with arrow keys and make sure the Beta tab is
|
|
417
413
|
// selected automatically.
|
|
418
|
-
await
|
|
414
|
+
await press.ArrowDown();
|
|
419
415
|
expect( await getSelectedTab() ).toHaveTextContent( 'Beta' );
|
|
420
416
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
421
417
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 2 );
|
|
@@ -423,7 +419,7 @@ describe( 'Tabs', () => {
|
|
|
423
419
|
|
|
424
420
|
// Navigate backwards with arrow keys. Make sure alpha is
|
|
425
421
|
// selected automatically.
|
|
426
|
-
await
|
|
422
|
+
await press.ArrowUp();
|
|
427
423
|
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
428
424
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
429
425
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 3 );
|
|
@@ -431,7 +427,7 @@ describe( 'Tabs', () => {
|
|
|
431
427
|
|
|
432
428
|
// Navigate backwards with arrow keys. Make sure alpha is
|
|
433
429
|
// selected automatically.
|
|
434
|
-
await
|
|
430
|
+
await press.ArrowUp();
|
|
435
431
|
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
436
432
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
437
433
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 4 );
|
|
@@ -439,7 +435,7 @@ describe( 'Tabs', () => {
|
|
|
439
435
|
|
|
440
436
|
// Navigate backwards with arrow keys. Make sure alpha is
|
|
441
437
|
// selected automatically.
|
|
442
|
-
await
|
|
438
|
+
await press.ArrowDown();
|
|
443
439
|
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
444
440
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
445
441
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 5 );
|
|
@@ -447,11 +443,10 @@ describe( 'Tabs', () => {
|
|
|
447
443
|
} );
|
|
448
444
|
|
|
449
445
|
it( 'should move focus on a tab even if disabled with arrow key, but not with pointer clicks', async () => {
|
|
450
|
-
const user = userEvent.setup();
|
|
451
446
|
const mockOnSelect = jest.fn();
|
|
452
447
|
|
|
453
448
|
const TABS_WITH_DELTA_DISABLED = TABS_WITH_DELTA.map( ( tabObj ) =>
|
|
454
|
-
tabObj.
|
|
449
|
+
tabObj.tabId === 'delta'
|
|
455
450
|
? {
|
|
456
451
|
...tabObj,
|
|
457
452
|
tab: {
|
|
@@ -477,7 +472,7 @@ describe( 'Tabs', () => {
|
|
|
477
472
|
// Tab to focus the tablist. Make sure Alpha is focused.
|
|
478
473
|
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
479
474
|
expect( await getSelectedTab() ).not.toHaveFocus();
|
|
480
|
-
await
|
|
475
|
+
await press.Tab();
|
|
481
476
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
482
477
|
// Confirm onSelect has not been re-called
|
|
483
478
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 1 );
|
|
@@ -487,7 +482,9 @@ describe( 'Tabs', () => {
|
|
|
487
482
|
// it was the tab that was last selected before delta. Therefore, the
|
|
488
483
|
// `mockOnSelect` function gets called only twice (and not three times)
|
|
489
484
|
// - it will receive focus, when using arrow keys
|
|
490
|
-
await
|
|
485
|
+
await press.ArrowRight();
|
|
486
|
+
await press.ArrowRight();
|
|
487
|
+
await press.ArrowRight();
|
|
491
488
|
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
492
489
|
expect(
|
|
493
490
|
screen.getByRole( 'tab', { name: 'Delta' } )
|
|
@@ -498,7 +495,7 @@ describe( 'Tabs', () => {
|
|
|
498
495
|
// Navigate backwards with arrow keys. The gamma tab receives focus.
|
|
499
496
|
// The `mockOnSelect` callback doesn't fire, since the gamma tab was
|
|
500
497
|
// already selected.
|
|
501
|
-
await
|
|
498
|
+
await press.ArrowLeft();
|
|
502
499
|
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
503
500
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
504
501
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 3 );
|
|
@@ -506,37 +503,26 @@ describe( 'Tabs', () => {
|
|
|
506
503
|
// Click on the disabled tab. Compared to using arrow keys to move the
|
|
507
504
|
// focus, disabled tabs ignore pointer clicks — and therefore, they don't
|
|
508
505
|
// receive focus, nor they cause the `mockOnSelect` function to fire.
|
|
509
|
-
await
|
|
506
|
+
await click( screen.getByRole( 'tab', { name: 'Delta' } ) );
|
|
510
507
|
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
511
508
|
expect( await getSelectedTab() ).toHaveFocus();
|
|
512
509
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 3 );
|
|
513
510
|
} );
|
|
514
511
|
|
|
515
512
|
it( 'should not focus the next tab when the Tab key is pressed', async () => {
|
|
516
|
-
const user = userEvent.setup();
|
|
517
|
-
|
|
518
513
|
render( <UncontrolledTabs tabs={ TABS } /> );
|
|
519
514
|
|
|
520
515
|
// Tab should initially focus the first tab in the tablist, which
|
|
521
516
|
// is Alpha.
|
|
522
|
-
await
|
|
517
|
+
await press.Tab();
|
|
523
518
|
expect(
|
|
524
519
|
await screen.findByRole( 'tab', { name: 'Alpha' } )
|
|
525
520
|
).toHaveFocus();
|
|
526
521
|
|
|
527
|
-
// This assertion ensures the component has had time to fully
|
|
528
|
-
// render, preventing flakiness.
|
|
529
|
-
// see https://github.com/WordPress/gutenberg/pull/55950
|
|
530
|
-
await waitFor( () =>
|
|
531
|
-
expect(
|
|
532
|
-
screen.getByRole( 'tab', { name: 'Beta' } )
|
|
533
|
-
).toHaveAttribute( 'tabindex', '-1' )
|
|
534
|
-
);
|
|
535
|
-
|
|
536
522
|
// Because all other tabs should have `tabindex=-1`, pressing Tab
|
|
537
523
|
// should NOT move the focus to the next tab, which is Beta.
|
|
538
524
|
// Instead, focus should go to the currently selected tabpanel (alpha).
|
|
539
|
-
await
|
|
525
|
+
await press.Tab();
|
|
540
526
|
expect(
|
|
541
527
|
await screen.findByRole( 'tabpanel', {
|
|
542
528
|
name: 'Alpha',
|
|
@@ -545,7 +531,6 @@ describe( 'Tabs', () => {
|
|
|
545
531
|
} );
|
|
546
532
|
|
|
547
533
|
it( 'switches to manual tab activation when the `selectOnMove` prop is set to `false`', async () => {
|
|
548
|
-
const user = userEvent.setup();
|
|
549
534
|
const mockOnSelect = jest.fn();
|
|
550
535
|
|
|
551
536
|
render(
|
|
@@ -563,7 +548,7 @@ describe( 'Tabs', () => {
|
|
|
563
548
|
|
|
564
549
|
// Click on Alpha and make sure it is selected.
|
|
565
550
|
// onSelect shouldn't fire since the selected tab didn't change.
|
|
566
|
-
await
|
|
551
|
+
await click( screen.getByRole( 'tab', { name: 'Alpha' } ) );
|
|
567
552
|
expect(
|
|
568
553
|
await screen.findByRole( 'tab', { name: 'Alpha' } )
|
|
569
554
|
).toHaveFocus();
|
|
@@ -574,13 +559,13 @@ describe( 'Tabs', () => {
|
|
|
574
559
|
// that the tab selection happens only when pressing the spacebar
|
|
575
560
|
// or enter key. onSelect shouldn't fire since the selected tab
|
|
576
561
|
// didn't change.
|
|
577
|
-
await
|
|
562
|
+
await press.ArrowRight();
|
|
578
563
|
expect(
|
|
579
564
|
await screen.findByRole( 'tab', { name: 'Beta' } )
|
|
580
565
|
).toHaveFocus();
|
|
581
566
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 1 );
|
|
582
567
|
|
|
583
|
-
await
|
|
568
|
+
await press.Enter();
|
|
584
569
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 2 );
|
|
585
570
|
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'beta' );
|
|
586
571
|
|
|
@@ -588,7 +573,7 @@ describe( 'Tabs', () => {
|
|
|
588
573
|
// focused, but that tab selection happens only when pressing the
|
|
589
574
|
// spacebar or enter key. onSelect shouldn't fire since the selected
|
|
590
575
|
// tab didn't change.
|
|
591
|
-
await
|
|
576
|
+
await press.ArrowRight();
|
|
592
577
|
expect(
|
|
593
578
|
await screen.findByRole( 'tab', { name: 'Gamma' } )
|
|
594
579
|
).toHaveFocus();
|
|
@@ -597,7 +582,7 @@ describe( 'Tabs', () => {
|
|
|
597
582
|
screen.getByRole( 'tab', { name: 'Gamma' } )
|
|
598
583
|
).toHaveFocus();
|
|
599
584
|
|
|
600
|
-
await
|
|
585
|
+
await press.Space();
|
|
601
586
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 3 );
|
|
602
587
|
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'gamma' );
|
|
603
588
|
} );
|
|
@@ -623,7 +608,7 @@ describe( 'Tabs', () => {
|
|
|
623
608
|
} );
|
|
624
609
|
it( 'should not load any tab if the active tab is removed and there are no enabled tabs', async () => {
|
|
625
610
|
const TABS_WITH_BETA_GAMMA_DISABLED = TABS.map( ( tabObj ) =>
|
|
626
|
-
tabObj.
|
|
611
|
+
tabObj.tabId !== 'alpha'
|
|
627
612
|
? {
|
|
628
613
|
...tabObj,
|
|
629
614
|
tab: {
|
|
@@ -700,7 +685,6 @@ describe( 'Tabs', () => {
|
|
|
700
685
|
} );
|
|
701
686
|
|
|
702
687
|
it( 'should fall back to the tab associated to `initialTabId` if the currently active tab is removed', async () => {
|
|
703
|
-
const user = userEvent.setup();
|
|
704
688
|
const mockOnSelect = jest.fn();
|
|
705
689
|
|
|
706
690
|
const { rerender } = render(
|
|
@@ -713,9 +697,7 @@ describe( 'Tabs', () => {
|
|
|
713
697
|
|
|
714
698
|
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
715
699
|
|
|
716
|
-
await
|
|
717
|
-
screen.getByRole( 'tab', { name: 'Alpha' } )
|
|
718
|
-
);
|
|
700
|
+
await click( screen.getByRole( 'tab', { name: 'Alpha' } ) );
|
|
719
701
|
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
720
702
|
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'alpha' );
|
|
721
703
|
|
|
@@ -731,7 +713,6 @@ describe( 'Tabs', () => {
|
|
|
731
713
|
} );
|
|
732
714
|
|
|
733
715
|
it( 'should fall back to the tab associated to `initialTabId` if the currently active tab becomes disabled', async () => {
|
|
734
|
-
const user = userEvent.setup();
|
|
735
716
|
const mockOnSelect = jest.fn();
|
|
736
717
|
|
|
737
718
|
const { rerender } = render(
|
|
@@ -744,14 +725,12 @@ describe( 'Tabs', () => {
|
|
|
744
725
|
|
|
745
726
|
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
746
727
|
|
|
747
|
-
await
|
|
748
|
-
screen.getByRole( 'tab', { name: 'Alpha' } )
|
|
749
|
-
);
|
|
728
|
+
await click( screen.getByRole( 'tab', { name: 'Alpha' } ) );
|
|
750
729
|
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
751
730
|
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'alpha' );
|
|
752
731
|
|
|
753
732
|
const TABS_WITH_ALPHA_DISABLED = TABS.map( ( tabObj ) =>
|
|
754
|
-
tabObj.
|
|
733
|
+
tabObj.tabId === 'alpha'
|
|
755
734
|
? {
|
|
756
735
|
...tabObj,
|
|
757
736
|
tab: {
|
|
@@ -822,12 +801,11 @@ describe( 'Tabs', () => {
|
|
|
822
801
|
|
|
823
802
|
describe( 'Disabled tab', () => {
|
|
824
803
|
it( 'should disable the tab when `disabled` is `true`', async () => {
|
|
825
|
-
const user = userEvent.setup();
|
|
826
804
|
const mockOnSelect = jest.fn();
|
|
827
805
|
|
|
828
806
|
const TABS_WITH_DELTA_DISABLED = TABS_WITH_DELTA.map(
|
|
829
807
|
( tabObj ) =>
|
|
830
|
-
tabObj.
|
|
808
|
+
tabObj.tabId === 'delta'
|
|
831
809
|
? {
|
|
832
810
|
...tabObj,
|
|
833
811
|
tab: {
|
|
@@ -853,20 +831,15 @@ describe( 'Tabs', () => {
|
|
|
853
831
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 1 );
|
|
854
832
|
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'alpha' );
|
|
855
833
|
|
|
834
|
+
// Move focus to the tablist, make sure alpha is focused.
|
|
835
|
+
await press.Tab();
|
|
836
|
+
expect(
|
|
837
|
+
screen.getByRole( 'tab', { name: 'Alpha' } )
|
|
838
|
+
).toHaveFocus();
|
|
839
|
+
|
|
856
840
|
// onSelect should not be called since the disabled tab is
|
|
857
841
|
// highlighted, but not selected.
|
|
858
|
-
await
|
|
859
|
-
|
|
860
|
-
// This assertion ensures focus has time to move to the first
|
|
861
|
-
// tab before the test proceeds, preventing flakiness.
|
|
862
|
-
// see https://github.com/WordPress/gutenberg/pull/55950
|
|
863
|
-
await waitFor( () =>
|
|
864
|
-
expect(
|
|
865
|
-
screen.getByRole( 'tab', { name: 'Alpha' } )
|
|
866
|
-
).toHaveFocus()
|
|
867
|
-
);
|
|
868
|
-
|
|
869
|
-
await user.keyboard( '[ArrowLeft]' );
|
|
842
|
+
await press.ArrowLeft();
|
|
870
843
|
expect( mockOnSelect ).toHaveBeenCalledTimes( 1 );
|
|
871
844
|
|
|
872
845
|
// Delta (which is disabled) has focus
|
|
@@ -880,7 +853,7 @@ describe( 'Tabs', () => {
|
|
|
880
853
|
|
|
881
854
|
it( 'should select first enabled tab when the initial tab is disabled', async () => {
|
|
882
855
|
const TABS_WITH_ALPHA_DISABLED = TABS.map( ( tabObj ) =>
|
|
883
|
-
tabObj.
|
|
856
|
+
tabObj.tabId === 'alpha'
|
|
884
857
|
? {
|
|
885
858
|
...tabObj,
|
|
886
859
|
tab: {
|
|
@@ -909,7 +882,7 @@ describe( 'Tabs', () => {
|
|
|
909
882
|
|
|
910
883
|
it( 'should select first enabled tab when the tab associated to `initialTabId` is disabled', async () => {
|
|
911
884
|
const TABS_ONLY_GAMMA_ENABLED = TABS.map( ( tabObj ) =>
|
|
912
|
-
tabObj.
|
|
885
|
+
tabObj.tabId !== 'gamma'
|
|
913
886
|
? {
|
|
914
887
|
...tabObj,
|
|
915
888
|
tab: {
|
|
@@ -951,7 +924,7 @@ describe( 'Tabs', () => {
|
|
|
951
924
|
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'alpha' );
|
|
952
925
|
|
|
953
926
|
const TABS_WITH_ALPHA_DISABLED = TABS.map( ( tabObj ) =>
|
|
954
|
-
tabObj.
|
|
927
|
+
tabObj.tabId === 'alpha'
|
|
955
928
|
? {
|
|
956
929
|
...tabObj,
|
|
957
930
|
tab: {
|
|
@@ -998,7 +971,7 @@ describe( 'Tabs', () => {
|
|
|
998
971
|
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
999
972
|
|
|
1000
973
|
const TABS_WITH_GAMMA_DISABLED = TABS.map( ( tabObj ) =>
|
|
1001
|
-
tabObj.
|
|
974
|
+
tabObj.tabId === 'gamma'
|
|
1002
975
|
? {
|
|
1003
976
|
...tabObj,
|
|
1004
977
|
tab: {
|
|
@@ -1067,14 +1040,10 @@ describe( 'Tabs', () => {
|
|
|
1067
1040
|
/>
|
|
1068
1041
|
);
|
|
1069
1042
|
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
expect(
|
|
1075
|
-
screen.queryByRole( 'tab', { selected: true } )
|
|
1076
|
-
).not.toBeInTheDocument()
|
|
1077
|
-
);
|
|
1043
|
+
expect(
|
|
1044
|
+
screen.queryByRole( 'tab', { selected: true } )
|
|
1045
|
+
).not.toBeInTheDocument();
|
|
1046
|
+
|
|
1078
1047
|
// No tabpanel should be rendered either
|
|
1079
1048
|
expect( screen.queryByRole( 'tabpanel' ) ).not.toBeInTheDocument();
|
|
1080
1049
|
} );
|
|
@@ -1086,7 +1055,7 @@ describe( 'Tabs', () => {
|
|
|
1086
1055
|
// Remove beta
|
|
1087
1056
|
rerender(
|
|
1088
1057
|
<ControlledTabs
|
|
1089
|
-
tabs={ TABS.filter( ( tab ) => tab.
|
|
1058
|
+
tabs={ TABS.filter( ( tab ) => tab.tabId !== 'beta' ) }
|
|
1090
1059
|
selectedTabId="beta"
|
|
1091
1060
|
/>
|
|
1092
1061
|
);
|
|
@@ -1120,7 +1089,7 @@ describe( 'Tabs', () => {
|
|
|
1120
1089
|
it( 'should not render any tab if `selectedTabId` refers to a disabled tab', async () => {
|
|
1121
1090
|
const TABS_WITH_DELTA_WITH_BETA_DISABLED = TABS_WITH_DELTA.map(
|
|
1122
1091
|
( tabObj ) =>
|
|
1123
|
-
tabObj.
|
|
1092
|
+
tabObj.tabId === 'beta'
|
|
1124
1093
|
? {
|
|
1125
1094
|
...tabObj,
|
|
1126
1095
|
tab: {
|
|
@@ -1157,7 +1126,7 @@ describe( 'Tabs', () => {
|
|
|
1157
1126
|
expect( await getSelectedTab() ).toHaveTextContent( 'Beta' );
|
|
1158
1127
|
|
|
1159
1128
|
const TABS_WITH_BETA_DISABLED = TABS.map( ( tabObj ) =>
|
|
1160
|
-
tabObj.
|
|
1129
|
+
tabObj.tabId === 'beta'
|
|
1161
1130
|
? {
|
|
1162
1131
|
...tabObj,
|
|
1163
1132
|
tab: {
|
|
@@ -1203,5 +1172,166 @@ describe( 'Tabs', () => {
|
|
|
1203
1172
|
).not.toBeInTheDocument();
|
|
1204
1173
|
} );
|
|
1205
1174
|
} );
|
|
1175
|
+
|
|
1176
|
+
describe( 'When `selectOnMove` is `true`', () => {
|
|
1177
|
+
it( 'should automatically select a newly focused tab', async () => {
|
|
1178
|
+
render( <ControlledTabs tabs={ TABS } selectedTabId="beta" /> );
|
|
1179
|
+
|
|
1180
|
+
await press.Tab();
|
|
1181
|
+
|
|
1182
|
+
// Tab key should focus the currently selected tab, which is Beta.
|
|
1183
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Beta' );
|
|
1184
|
+
expect( await getSelectedTab() ).toHaveFocus();
|
|
1185
|
+
|
|
1186
|
+
// Arrow keys should select and move focus to the next tab.
|
|
1187
|
+
await press.ArrowRight();
|
|
1188
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
1189
|
+
expect( await getSelectedTab() ).toHaveFocus();
|
|
1190
|
+
} );
|
|
1191
|
+
it( 'should automatically update focus when the selected tab is changed by the controlling component', async () => {
|
|
1192
|
+
const { rerender } = render(
|
|
1193
|
+
<ControlledTabs tabs={ TABS } selectedTabId="beta" />
|
|
1194
|
+
);
|
|
1195
|
+
|
|
1196
|
+
// Tab key should focus the currently selected tab, which is Beta.
|
|
1197
|
+
await press.Tab();
|
|
1198
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Beta' );
|
|
1199
|
+
expect( await getSelectedTab() ).toHaveFocus();
|
|
1200
|
+
|
|
1201
|
+
rerender(
|
|
1202
|
+
<ControlledTabs tabs={ TABS } selectedTabId="gamma" />
|
|
1203
|
+
);
|
|
1204
|
+
|
|
1205
|
+
// When the selected tab is changed, it should automatically receive focus.
|
|
1206
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
1207
|
+
expect( await getSelectedTab() ).toHaveFocus();
|
|
1208
|
+
} );
|
|
1209
|
+
} );
|
|
1210
|
+
describe( 'When `selectOnMove` is `false`', () => {
|
|
1211
|
+
it( 'should apply focus without automatically changing the selected tab', async () => {
|
|
1212
|
+
render(
|
|
1213
|
+
<ControlledTabs
|
|
1214
|
+
tabs={ TABS }
|
|
1215
|
+
selectedTabId="beta"
|
|
1216
|
+
selectOnMove={ false }
|
|
1217
|
+
/>
|
|
1218
|
+
);
|
|
1219
|
+
|
|
1220
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Beta' );
|
|
1221
|
+
|
|
1222
|
+
// Tab key should focus the currently selected tab, which is Beta.
|
|
1223
|
+
await press.Tab();
|
|
1224
|
+
expect(
|
|
1225
|
+
await screen.findByRole( 'tab', { name: 'Beta' } )
|
|
1226
|
+
).toHaveFocus();
|
|
1227
|
+
|
|
1228
|
+
// Arrow key should move focus but not automatically change the selected tab.
|
|
1229
|
+
await press.ArrowRight();
|
|
1230
|
+
expect(
|
|
1231
|
+
screen.getByRole( 'tab', { name: 'Gamma' } )
|
|
1232
|
+
).toHaveFocus();
|
|
1233
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Beta' );
|
|
1234
|
+
|
|
1235
|
+
// Pressing the spacebar should select the focused tab.
|
|
1236
|
+
await press.Space();
|
|
1237
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
1238
|
+
|
|
1239
|
+
// Arrow key should move focus but not automatically change the selected tab.
|
|
1240
|
+
await press.ArrowRight();
|
|
1241
|
+
expect(
|
|
1242
|
+
screen.getByRole( 'tab', { name: 'Alpha' } )
|
|
1243
|
+
).toHaveFocus();
|
|
1244
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
1245
|
+
|
|
1246
|
+
// Pressing the enter/return should select the focused tab.
|
|
1247
|
+
await press.Enter();
|
|
1248
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
1249
|
+
} );
|
|
1250
|
+
it( 'should not automatically update focus when the selected tab is changed by the controlling component', async () => {
|
|
1251
|
+
const { rerender } = render(
|
|
1252
|
+
<ControlledTabs
|
|
1253
|
+
tabs={ TABS }
|
|
1254
|
+
selectedTabId="beta"
|
|
1255
|
+
selectOnMove={ false }
|
|
1256
|
+
/>
|
|
1257
|
+
);
|
|
1258
|
+
|
|
1259
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Beta' );
|
|
1260
|
+
|
|
1261
|
+
// Tab key should focus the currently selected tab, which is Beta.
|
|
1262
|
+
await press.Tab();
|
|
1263
|
+
expect( await getSelectedTab() ).toHaveFocus();
|
|
1264
|
+
|
|
1265
|
+
rerender(
|
|
1266
|
+
<ControlledTabs
|
|
1267
|
+
tabs={ TABS }
|
|
1268
|
+
selectedTabId="gamma"
|
|
1269
|
+
selectOnMove={ false }
|
|
1270
|
+
/>
|
|
1271
|
+
);
|
|
1272
|
+
|
|
1273
|
+
// When the selected tab is changed, it should not automatically receive focus.
|
|
1274
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
1275
|
+
expect(
|
|
1276
|
+
screen.getByRole( 'tab', { name: 'Beta' } )
|
|
1277
|
+
).toHaveFocus();
|
|
1278
|
+
} );
|
|
1279
|
+
} );
|
|
1280
|
+
} );
|
|
1281
|
+
it( 'should associate each `Tab` with the correct `TabPanel`, even if they are not rendered in the same order', async () => {
|
|
1282
|
+
const TABS_WITH_DELTA_REVERSED = [ ...TABS_WITH_DELTA ].reverse();
|
|
1283
|
+
|
|
1284
|
+
render(
|
|
1285
|
+
<Tabs>
|
|
1286
|
+
<Tabs.TabList>
|
|
1287
|
+
{ TABS_WITH_DELTA.map( ( tabObj ) => (
|
|
1288
|
+
<Tabs.Tab
|
|
1289
|
+
key={ tabObj.tabId }
|
|
1290
|
+
tabId={ tabObj.tabId }
|
|
1291
|
+
className={ tabObj.tab.className }
|
|
1292
|
+
disabled={ tabObj.tab.disabled }
|
|
1293
|
+
>
|
|
1294
|
+
{ tabObj.title }
|
|
1295
|
+
</Tabs.Tab>
|
|
1296
|
+
) ) }
|
|
1297
|
+
</Tabs.TabList>
|
|
1298
|
+
{ TABS_WITH_DELTA_REVERSED.map( ( tabObj ) => (
|
|
1299
|
+
<Tabs.TabPanel
|
|
1300
|
+
key={ tabObj.tabId }
|
|
1301
|
+
tabId={ tabObj.tabId }
|
|
1302
|
+
focusable={ tabObj.tabpanel?.focusable }
|
|
1303
|
+
>
|
|
1304
|
+
{ tabObj.content }
|
|
1305
|
+
</Tabs.TabPanel>
|
|
1306
|
+
) ) }
|
|
1307
|
+
</Tabs>
|
|
1308
|
+
);
|
|
1309
|
+
|
|
1310
|
+
// Alpha is the initially selected tab,and should render the correct tabpanel
|
|
1311
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Alpha' );
|
|
1312
|
+
expect( screen.getByRole( 'tabpanel' ) ).toHaveTextContent(
|
|
1313
|
+
'Selected tab: Alpha'
|
|
1314
|
+
);
|
|
1315
|
+
|
|
1316
|
+
// Select Beta, make sure the correct tabpanel is rendered
|
|
1317
|
+
await click( screen.getByRole( 'tab', { name: 'Beta' } ) );
|
|
1318
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Beta' );
|
|
1319
|
+
expect( screen.getByRole( 'tabpanel' ) ).toHaveTextContent(
|
|
1320
|
+
'Selected tab: Beta'
|
|
1321
|
+
);
|
|
1322
|
+
|
|
1323
|
+
// Select Gamma, make sure the correct tabpanel is rendered
|
|
1324
|
+
await click( screen.getByRole( 'tab', { name: 'Gamma' } ) );
|
|
1325
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Gamma' );
|
|
1326
|
+
expect( screen.getByRole( 'tabpanel' ) ).toHaveTextContent(
|
|
1327
|
+
'Selected tab: Gamma'
|
|
1328
|
+
);
|
|
1329
|
+
|
|
1330
|
+
// Select Delta, make sure the correct tabpanel is rendered
|
|
1331
|
+
await click( screen.getByRole( 'tab', { name: 'Delta' } ) );
|
|
1332
|
+
expect( await getSelectedTab() ).toHaveTextContent( 'Delta' );
|
|
1333
|
+
expect( screen.getByRole( 'tabpanel' ) ).toHaveTextContent(
|
|
1334
|
+
'Selected tab: Delta'
|
|
1335
|
+
);
|
|
1206
1336
|
} );
|
|
1207
1337
|
} );
|