@wordpress/components 22.1.0 → 23.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/CHANGELOG.md +67 -0
- package/CONTRIBUTING.md +0 -21
- package/build/alignment-matrix-control/cell.js.map +1 -1
- package/build/alignment-matrix-control/icon.js +4 -2
- package/build/alignment-matrix-control/icon.js.map +1 -1
- package/build/alignment-matrix-control/index.js +25 -1
- package/build/alignment-matrix-control/index.js.map +1 -1
- package/build/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js +13 -13
- package/build/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js.map +1 -1
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +16 -16
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build/alignment-matrix-control/types.js +6 -0
- package/build/alignment-matrix-control/types.js.map +1 -0
- package/build/alignment-matrix-control/utils.js +9 -8
- package/build/alignment-matrix-control/utils.js.map +1 -1
- package/build/angle-picker-control/styles/angle-picker-control-styles.js +9 -9
- package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
- package/build/autocomplete/index.js +39 -12
- package/build/autocomplete/index.js.map +1 -1
- package/build/base-control/hooks.js +52 -0
- package/build/base-control/hooks.js.map +1 -0
- package/build/base-control/index.js +24 -7
- package/build/base-control/index.js.map +1 -1
- package/build/base-field/hook.js +0 -14
- package/build/base-field/hook.js.map +1 -1
- package/build/base-field/index.js.map +1 -1
- package/build/base-field/styles.js +5 -5
- package/build/base-field/styles.js.map +1 -1
- package/build/base-field/types.js +6 -0
- package/build/base-field/types.js.map +1 -0
- package/build/border-box-control/border-box-control/component.js +0 -3
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control/hook.js +0 -2
- package/build/border-box-control/border-box-control/hook.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/component.js +0 -2
- package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/hook.js +0 -2
- package/build/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
- package/build/border-control/border-control/component.js +1 -2
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/border-control/hook.js +0 -2
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +6 -11
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/border-control-dropdown/hook.js +0 -2
- package/build/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build/border-control/styles.js +16 -16
- package/build/border-control/styles.js.map +1 -1
- package/build/box-control/linked-button.js +3 -4
- package/build/box-control/linked-button.js.map +1 -1
- package/build/color-palette/index.js +7 -15
- package/build/color-palette/index.js.map +1 -1
- package/build/color-picker/input-with-slider.js +1 -0
- package/build/color-picker/input-with-slider.js.map +1 -1
- package/build/color-picker/styles.js +8 -8
- package/build/color-picker/styles.js.map +1 -1
- package/build/custom-select-control/index.js +14 -2
- package/build/custom-select-control/index.js.map +1 -1
- package/build/dashicon/index.js +1 -4
- package/build/dashicon/index.js.map +1 -1
- package/build/date-time/date-time/index.js +4 -4
- package/build/date-time/date-time/index.js.map +1 -1
- package/build/dimension-control/index.js.map +1 -1
- package/build/dropdown/index.js +45 -10
- package/build/dropdown/index.js.map +1 -1
- package/build/duotone-picker/duotone-picker.js +2 -2
- package/build/duotone-picker/duotone-picker.js.map +1 -1
- package/build/gradient-picker/index.js +4 -11
- package/build/gradient-picker/index.js.map +1 -1
- package/build/higher-order/navigate-regions/index.js +4 -3
- package/build/higher-order/navigate-regions/index.js.map +1 -1
- package/build/higher-order/with-fallback-styles/index.js +2 -2
- package/build/higher-order/with-fallback-styles/index.js.map +1 -1
- package/build/index.js +13 -9
- package/build/index.js.map +1 -1
- package/build/input-control/index.js +17 -5
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/input-base.js +2 -0
- package/build/input-control/input-base.js.map +1 -1
- package/build/mobile/bottom-sheet/cell.native.js +1 -1
- package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet/picker-cell.native.js +1 -9
- package/build/mobile/bottom-sheet/picker-cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet/switch-cell.native.js +1 -3
- package/build/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
- package/build/mobile/global-styles-context/index.native.js +8 -8
- package/build/mobile/global-styles-context/index.native.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +30 -12
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.ios.js +4 -2
- package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build/modal/index.js +8 -0
- package/build/modal/index.js.map +1 -1
- package/build/navigator/navigator-provider/component.js +12 -8
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/number-control/styles/number-control-styles.js +8 -8
- package/build/number-control/styles/number-control-styles.js.map +1 -1
- package/build/palette-edit/index.js +72 -33
- package/build/palette-edit/index.js.map +1 -1
- package/build/popover/index.js +10 -2
- package/build/popover/index.js.map +1 -1
- package/build/query-controls/index.js +1 -0
- package/build/query-controls/index.js.map +1 -1
- package/build/snackbar/index.js +35 -24
- package/build/snackbar/index.js.map +1 -1
- package/build/snackbar/list.js +14 -19
- package/build/snackbar/list.js.map +1 -1
- package/build/snackbar/types.js +6 -0
- package/build/snackbar/types.js.map +1 -0
- package/build/tab-panel/index.js +15 -9
- package/build/tab-panel/index.js.map +1 -1
- package/build/theme/color-algorithms.js +118 -0
- package/build/theme/color-algorithms.js.map +1 -0
- package/build/theme/index.js +21 -18
- package/build/theme/index.js.map +1 -1
- package/build/theme/styles.js +10 -7
- package/build/theme/styles.js.map +1 -1
- package/build/toggle-control/index.js +5 -2
- package/build/toggle-control/index.js.map +1 -1
- package/build/ui/context/context-system-provider.js +3 -1
- package/build/ui/context/context-system-provider.js.map +1 -1
- package/build/unit-control/index.js +5 -2
- package/build/unit-control/index.js.map +1 -1
- package/build/utils/colors-values.js +1 -1
- package/build/utils/colors-values.js.map +1 -1
- package/build/utils/config-values.js +0 -2
- package/build/utils/config-values.js.map +1 -1
- package/build/utils/hooks/use-controlled-value.js.map +1 -1
- package/build-module/alignment-matrix-control/cell.js.map +1 -1
- package/build-module/alignment-matrix-control/icon.js +4 -2
- package/build-module/alignment-matrix-control/icon.js.map +1 -1
- package/build-module/alignment-matrix-control/index.js +23 -1
- package/build-module/alignment-matrix-control/index.js.map +1 -1
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js +13 -13
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js.map +1 -1
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +16 -16
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build-module/alignment-matrix-control/types.js +2 -0
- package/build-module/alignment-matrix-control/types.js.map +1 -0
- package/build-module/alignment-matrix-control/utils.js +13 -8
- package/build-module/alignment-matrix-control/utils.js.map +1 -1
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +9 -9
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
- package/build-module/autocomplete/index.js +39 -11
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/base-control/hooks.js +41 -0
- package/build-module/base-control/hooks.js.map +1 -0
- package/build-module/base-control/index.js +18 -8
- package/build-module/base-control/index.js.map +1 -1
- package/build-module/base-field/hook.js +0 -14
- package/build-module/base-field/hook.js.map +1 -1
- package/build-module/base-field/index.js.map +1 -1
- package/build-module/base-field/styles.js +5 -5
- package/build-module/base-field/styles.js.map +1 -1
- package/build-module/base-field/types.js +2 -0
- package/build-module/base-field/types.js.map +1 -0
- package/build-module/border-box-control/border-box-control/component.js +0 -3
- package/build-module/border-box-control/border-box-control/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control/hook.js +0 -2
- package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js +0 -2
- package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/hook.js +0 -2
- package/build-module/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
- package/build-module/border-control/border-control/component.js +1 -2
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +0 -2
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +6 -11
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/hook.js +0 -2
- package/build-module/border-control/border-control-dropdown/hook.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/linked-button.js +3 -4
- package/build-module/box-control/linked-button.js.map +1 -1
- package/build-module/color-palette/index.js +7 -15
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-picker/input-with-slider.js +1 -0
- package/build-module/color-picker/input-with-slider.js.map +1 -1
- package/build-module/color-picker/styles.js +8 -8
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/custom-select-control/index.js +14 -2
- package/build-module/custom-select-control/index.js.map +1 -1
- package/build-module/dashicon/index.js +1 -4
- package/build-module/dashicon/index.js.map +1 -1
- package/build-module/date-time/date-time/index.js +4 -4
- package/build-module/date-time/date-time/index.js.map +1 -1
- package/build-module/dimension-control/index.js +1 -2
- package/build-module/dimension-control/index.js.map +1 -1
- package/build-module/dropdown/index.js +44 -10
- package/build-module/dropdown/index.js.map +1 -1
- package/build-module/duotone-picker/duotone-picker.js +2 -2
- package/build-module/duotone-picker/duotone-picker.js.map +1 -1
- package/build-module/gradient-picker/index.js +4 -10
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/higher-order/navigate-regions/index.js +4 -3
- package/build-module/higher-order/navigate-regions/index.js.map +1 -1
- package/build-module/higher-order/with-fallback-styles/index.js +2 -2
- package/build-module/higher-order/with-fallback-styles/index.js.map +1 -1
- package/build-module/index.js +2 -3
- package/build-module/index.js.map +1 -1
- package/build-module/input-control/index.js +16 -5
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/input-base.js +2 -0
- package/build-module/input-control/input-base.js.map +1 -1
- package/build-module/mobile/bottom-sheet/cell.native.js +1 -1
- package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/picker-cell.native.js +1 -8
- package/build-module/mobile/bottom-sheet/picker-cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/switch-cell.native.js +1 -2
- package/build-module/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/index.native.js +8 -7
- package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +31 -13
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build-module/modal/index.js +8 -0
- package/build-module/modal/index.js.map +1 -1
- package/build-module/navigator/navigator-provider/component.js +12 -8
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/number-control/styles/number-control-styles.js +8 -10
- package/build-module/number-control/styles/number-control-styles.js.map +1 -1
- package/build-module/palette-edit/index.js +73 -34
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/popover/index.js +10 -2
- package/build-module/popover/index.js.map +1 -1
- package/build-module/query-controls/index.js +1 -0
- package/build-module/query-controls/index.js.map +1 -1
- package/build-module/snackbar/index.js +33 -23
- package/build-module/snackbar/index.js.map +1 -1
- package/build-module/snackbar/list.js +14 -22
- package/build-module/snackbar/list.js.map +1 -1
- package/build-module/snackbar/types.js +2 -0
- package/build-module/snackbar/types.js.map +1 -0
- package/build-module/tab-panel/index.js +15 -8
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/theme/color-algorithms.js +105 -0
- package/build-module/theme/color-algorithms.js.map +1 -0
- package/build-module/theme/index.js +21 -17
- package/build-module/theme/index.js.map +1 -1
- package/build-module/theme/styles.js +8 -6
- package/build-module/theme/styles.js.map +1 -1
- package/build-module/toggle-control/index.js +4 -2
- package/build-module/toggle-control/index.js.map +1 -1
- package/build-module/ui/context/context-system-provider.js +3 -2
- package/build-module/ui/context/context-system-provider.js.map +1 -1
- package/build-module/unit-control/index.js +5 -2
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/utils/colors-values.js +1 -1
- package/build-module/utils/colors-values.js.map +1 -1
- package/build-module/utils/config-values.js +0 -2
- package/build-module/utils/config-values.js.map +1 -1
- package/build-module/utils/hooks/use-controlled-value.js.map +1 -1
- package/build-style/style-rtl.css +108 -104
- package/build-style/style.css +108 -104
- package/build-types/alignment-matrix-control/cell.d.ts +5 -0
- package/build-types/alignment-matrix-control/cell.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/icon.d.ts +6 -0
- package/build-types/alignment-matrix-control/icon.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/index.d.ts +30 -0
- package/build-types/alignment-matrix-control/index.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/stories/index.d.ts +14 -0
- package/build-types/alignment-matrix-control/stories/index.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts +19 -0
- package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/styles/alignment-matrix-control-styles.d.ts +23 -0
- package/build-types/alignment-matrix-control/styles/alignment-matrix-control-styles.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/test/index.d.ts +2 -0
- package/build-types/alignment-matrix-control/test/index.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/types.d.ts +39 -0
- package/build-types/alignment-matrix-control/types.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/utils.d.ts +33 -0
- package/build-types/alignment-matrix-control/utils.d.ts.map +1 -0
- package/build-types/base-control/hooks.d.ts +23 -0
- package/build-types/base-control/hooks.d.ts.map +1 -0
- package/build-types/base-control/index.d.ts +17 -7
- package/build-types/base-control/index.d.ts.map +1 -1
- package/build-types/base-control/stories/index.d.ts.map +1 -1
- package/build-types/base-control/test/index.d.ts +2 -0
- package/build-types/base-control/test/index.d.ts.map +1 -0
- package/build-types/base-control/types.d.ts +8 -2
- package/build-types/base-control/types.d.ts.map +1 -1
- package/build-types/base-field/hook.d.ts +7 -31
- package/build-types/base-field/hook.d.ts.map +1 -1
- package/build-types/base-field/index.d.ts +1 -1
- package/build-types/base-field/index.d.ts.map +1 -1
- package/build-types/base-field/styles.d.ts +5 -5
- package/build-types/base-field/styles.d.ts.map +1 -1
- package/build-types/base-field/test/index.d.ts +2 -0
- package/build-types/base-field/test/index.d.ts.map +1 -0
- package/build-types/base-field/types.d.ts +29 -0
- package/build-types/base-field/types.d.ts.map +1 -0
- package/build-types/border-box-control/border-box-control/component.d.ts +1 -1
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +2 -3
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +2 -2
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +2 -3
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +2 -2
- package/build-types/border-box-control/stories/index.d.ts +1 -1
- package/build-types/border-control/border-control/component.d.ts +1 -1
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +2 -3
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts +1 -1
- 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 +2 -3
- 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 +2 -2
- package/build-types/border-control/stories/index.d.ts +6 -6
- package/build-types/border-control/stories/index.d.ts.map +1 -1
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +1 -1
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/card/card/hook.d.ts +2 -2
- package/build-types/card/card-body/hook.d.ts +2 -2
- package/build-types/card/card-divider/hook.d.ts +2 -2
- package/build-types/card/card-footer/hook.d.ts +2 -2
- package/build-types/card/card-header/hook.d.ts +2 -2
- package/build-types/card/card-media/hook.d.ts +2 -2
- package/build-types/color-palette/index.d.ts +3 -4
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.d.ts +6 -14
- package/build-types/color-palette/stories/index.d.ts.map +1 -1
- package/build-types/color-palette/styles.d.ts +1 -1
- package/build-types/color-palette/types.d.ts +4 -17
- package/build-types/color-palette/types.d.ts.map +1 -1
- package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +5 -5
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/custom-select-control/index.d.ts.map +1 -1
- package/build-types/dashicon/index.d.ts +6 -20
- package/build-types/dashicon/index.d.ts.map +1 -1
- package/build-types/dashicon/types.d.ts +14 -0
- package/build-types/dashicon/types.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 +3 -3
- package/build-types/date-time/time/styles.d.ts +8 -8
- package/build-types/disabled/stories/index.d.ts.map +1 -1
- package/build-types/dropdown/index.d.ts +29 -1
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.d.ts +23 -0
- package/build-types/dropdown/stories/index.d.ts.map +1 -0
- package/build-types/dropdown/test/index.d.ts +2 -0
- package/build-types/dropdown/test/index.d.ts.map +1 -0
- package/build-types/dropdown/types.d.ts +101 -0
- package/build-types/dropdown/types.d.ts.map +1 -1
- package/build-types/elevation/hook.d.ts +2 -2
- package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
- package/build-types/flex/flex/hook.d.ts +2 -2
- package/build-types/flex/flex-block/hook.d.ts +2 -2
- package/build-types/flex/flex-item/hook.d.ts +2 -2
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +2 -5
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts +2 -2
- package/build-types/h-stack/component.d.ts +1 -1
- package/build-types/h-stack/hook.d.ts +2 -2
- package/build-types/heading/hook.d.ts +2 -2
- package/build-types/icon/stories/index.d.ts +22 -0
- package/build-types/icon/stories/index.d.ts.map +1 -0
- package/build-types/input-control/index.d.ts +1 -1
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-base.d.ts.map +1 -1
- package/build-types/input-control/stories/index.d.ts +1 -0
- package/build-types/input-control/stories/index.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +2 -1
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/item-group/item/hook.d.ts +2 -2
- package/build-types/item-group/item-group/hook.d.ts +2 -2
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/modal/stories/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +3 -3
- package/build-types/navigator/navigator-button/hook.d.ts +3 -3
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts +2 -2
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/stories/index.d.ts +25 -0
- package/build-types/number-control/stories/index.d.ts.map +1 -0
- package/build-types/number-control/styles/number-control-styles.d.ts +6 -6
- package/build-types/number-control/styles/number-control-styles.d.ts.map +1 -1
- package/build-types/number-control/test/index.d.ts +2 -0
- package/build-types/number-control/test/index.d.ts.map +1 -0
- 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.d.ts +1 -1
- package/build-types/range-control/index.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +2 -2
- package/build-types/resizable-box/resize-tooltip/index.d.ts +15 -19
- package/build-types/resizable-box/resize-tooltip/index.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/label.d.ts +4 -3
- package/build-types/resizable-box/resize-tooltip/label.d.ts.map +1 -1
- package/build-types/scrollable/hook.d.ts +2 -2
- package/build-types/search-control/index.d.ts +1 -1
- package/build-types/search-control/stories/index.d.ts +2 -2
- package/build-types/snackbar/index.d.ts +19 -0
- package/build-types/snackbar/index.d.ts.map +1 -0
- package/build-types/snackbar/list.d.ts +18 -0
- package/build-types/snackbar/list.d.ts.map +1 -0
- package/build-types/snackbar/stories/index.d.ts +16 -0
- package/build-types/snackbar/stories/index.d.ts.map +1 -0
- package/build-types/snackbar/stories/list.d.ts +12 -0
- package/build-types/snackbar/stories/list.d.ts.map +1 -0
- package/build-types/snackbar/types.d.ts +111 -0
- package/build-types/snackbar/types.d.ts.map +1 -0
- package/build-types/spacer/hook.d.ts +2 -2
- package/build-types/spinner/index.d.ts +1 -1
- package/build-types/surface/hook.d.ts +2 -2
- package/build-types/tab-panel/index.d.ts +1 -1
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/tab-panel/types.d.ts +19 -1
- package/build-types/tab-panel/types.d.ts.map +1 -1
- package/build-types/text/hook.d.ts +2 -2
- package/build-types/text-control/index.d.ts +2 -2
- package/build-types/text-control/stories/index.d.ts.map +1 -1
- package/build-types/text-control/types.d.ts +1 -5
- package/build-types/text-control/types.d.ts.map +1 -1
- package/build-types/theme/color-algorithms.d.ts +20 -0
- package/build-types/theme/color-algorithms.d.ts.map +1 -0
- package/build-types/theme/index.d.ts +1 -1
- package/build-types/theme/index.d.ts.map +1 -1
- package/build-types/theme/stories/index.d.ts +4 -0
- package/build-types/theme/stories/index.d.ts.map +1 -1
- package/build-types/theme/styles.d.ts +3 -2
- package/build-types/theme/styles.d.ts.map +1 -1
- package/build-types/theme/test/color-algorithms.d.ts +2 -0
- package/build-types/theme/test/color-algorithms.d.ts.map +1 -0
- package/build-types/theme/types.d.ts +41 -3
- package/build-types/theme/types.d.ts.map +1 -1
- package/build-types/toggle-control/index.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +2 -2
- 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-icon/component.d.ts +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +2 -2
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +2 -2
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +2 -2
- package/build-types/truncate/hook.d.ts +2 -2
- package/build-types/ui/context/context-system-provider.d.ts.map +1 -1
- package/build-types/ui/control-group/hook.d.ts +2 -2
- package/build-types/ui/control-label/hook.d.ts +2 -2
- package/build-types/ui/form-group/form-group.d.ts +2 -2
- package/build-types/ui/form-group/use-form-group.d.ts +5 -5
- package/build-types/unit-control/index.d.ts +2 -1
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +2 -2
- package/build-types/unit-control/types.d.ts +4 -0
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/utils/config-values.d.ts +0 -2
- package/build-types/utils/hooks/use-controlled-value.d.ts +2 -1
- package/build-types/utils/hooks/use-controlled-value.d.ts.map +1 -1
- package/build-types/v-stack/component.d.ts +2 -2
- package/build-types/v-stack/hook.d.ts +2 -2
- package/build-types/v-stack/stories/index.d.ts +2 -2
- package/package.json +21 -20
- package/src/alignment-matrix-control/README.md +7 -7
- package/src/alignment-matrix-control/{cell.js → cell.tsx} +7 -1
- package/src/alignment-matrix-control/{icon.js → icon.tsx} +6 -3
- package/src/alignment-matrix-control/{index.js → index.tsx} +31 -4
- package/src/alignment-matrix-control/stories/{index.js → index.tsx} +17 -9
- package/src/alignment-matrix-control/styles/{alignment-matrix-control-icon-styles.js → alignment-matrix-control-icon-styles.ts} +11 -3
- package/src/alignment-matrix-control/styles/{alignment-matrix-control-styles.js → alignment-matrix-control-styles.ts} +13 -3
- package/src/alignment-matrix-control/test/{index.js → index.tsx} +5 -5
- package/src/alignment-matrix-control/types.ts +54 -0
- package/src/alignment-matrix-control/{utils.js → utils.tsx} +24 -14
- package/src/angle-picker-control/styles/angle-picker-control-styles.js +4 -0
- package/src/autocomplete/index.js +44 -15
- package/src/autocomplete/test/index.js +2 -0
- package/src/base-control/README.md +21 -12
- package/src/base-control/hooks.ts +45 -0
- package/src/base-control/index.tsx +18 -7
- package/src/base-control/stories/index.tsx +8 -10
- package/src/base-control/test/index.tsx +53 -0
- package/src/base-control/types.ts +8 -2
- package/src/base-field/README.md +21 -22
- package/src/base-field/{hook.js → hook.ts} +5 -15
- package/src/base-field/{index.js → index.ts} +0 -0
- package/src/base-field/{styles.js → styles.ts} +2 -2
- package/src/base-field/test/__snapshots__/{index.js.snap → index.tsx.snap} +4 -4
- package/src/base-field/test/{index.js → index.tsx} +10 -5
- package/src/base-field/types.ts +29 -0
- package/src/border-box-control/border-box-control/README.md +1 -0
- package/src/border-box-control/border-box-control/component.tsx +0 -7
- package/src/border-box-control/border-box-control/hook.ts +0 -2
- package/src/border-box-control/border-box-control-split-controls/component.tsx +0 -2
- package/src/border-box-control/border-box-control-split-controls/hook.ts +0 -2
- package/src/border-box-control/test/index.js +5 -1
- package/src/border-control/border-control/component.tsx +1 -4
- package/src/border-control/border-control/hook.ts +0 -2
- package/src/border-control/border-control-dropdown/component.tsx +11 -17
- package/src/border-control/border-control-dropdown/hook.ts +0 -2
- package/src/border-control/stories/index.tsx +0 -1
- package/src/border-control/styles.ts +1 -10
- package/src/border-control/test/index.js +70 -67
- package/src/border-control/types.ts +1 -4
- package/src/box-control/linked-button.js +8 -11
- package/src/box-control/test/index.js +207 -134
- package/src/button/stories/index.js +30 -0
- package/src/button/style.scss +17 -14
- package/src/button/test/index.js +32 -15
- package/src/card/test/index.tsx +32 -20
- package/src/checkbox-control/test/index.tsx +2 -0
- package/src/circular-option-picker/style.scss +1 -0
- package/src/color-palette/index.tsx +16 -18
- package/src/color-palette/stories/index.tsx +1 -18
- package/src/color-palette/test/__snapshots__/index.tsx.snap +4 -4
- package/src/color-palette/test/index.tsx +86 -36
- package/src/color-palette/types.ts +4 -18
- package/src/color-picker/README.md +1 -0
- package/src/color-picker/input-with-slider.tsx +1 -0
- package/src/color-picker/styles.ts +0 -4
- package/src/color-picker/test/index.js +2 -0
- package/src/combobox-control/test/index.js +2 -0
- package/src/confirm-dialog/README.md +3 -2
- package/src/confirm-dialog/test/index.js +2 -0
- package/src/custom-select-control/README.md +14 -0
- package/src/custom-select-control/index.js +14 -2
- package/src/dashicon/{index.js → index.tsx} +10 -4
- package/src/dashicon/types.ts +17 -0
- package/src/date-time/date/test/index.tsx +2 -0
- package/src/date-time/date-time/index.tsx +2 -2
- package/src/date-time/time/test/index.tsx +2 -0
- package/src/dimension-control/index.js +2 -3
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -8
- package/src/dimension-control/test/index.test.js +2 -0
- package/src/disabled/stories/index.tsx +6 -2
- package/src/disabled/test/index.tsx +23 -11
- package/src/dropdown/README.md +41 -46
- package/src/dropdown/{index.js → index.tsx} +57 -13
- package/src/dropdown/stories/{index.js → index.tsx} +21 -8
- package/src/dropdown/test/index.tsx +88 -0
- package/src/dropdown/types.ts +107 -0
- package/src/dropdown-menu/README.md +2 -3
- package/src/dropdown-menu/test/index.js +20 -12
- package/src/duotone-picker/duotone-picker.js +2 -2
- package/src/external-link/test/index.tsx +2 -0
- package/src/focal-point-picker/test/index.js +2 -0
- package/src/focal-point-picker/test/media.js +26 -21
- package/src/font-size-picker/test/index.tsx +2 -0
- package/src/form-file-upload/test/index.tsx +2 -0
- package/src/form-toggle/test/index.tsx +2 -0
- package/src/form-token-field/style.scss +1 -1
- package/src/form-token-field/test/index.tsx +3 -0
- package/src/gradient-picker/index.js +6 -10
- package/src/gradient-picker/stories/index.js +0 -1
- package/src/grid/test/grid.tsx +31 -31
- package/src/guide/test/index.js +2 -0
- package/src/higher-order/navigate-regions/index.js +5 -2
- package/src/higher-order/navigate-regions/style.scss +13 -59
- package/src/higher-order/with-fallback-styles/index.js +4 -2
- package/src/higher-order/with-filters/test/index.js +32 -43
- package/src/higher-order/with-focus-outside/test/index.js +2 -0
- package/src/higher-order/with-focus-return/test/index.js +3 -4
- package/src/higher-order/with-notices/test/index.js +1 -0
- package/src/icon/stories/index.tsx +103 -0
- package/src/index.js +2 -3
- package/src/input-control/index.tsx +42 -28
- package/src/input-control/input-base.tsx +8 -1
- package/src/input-control/stories/index.tsx +6 -0
- package/src/input-control/test/index.js +21 -0
- package/src/input-control/types.ts +2 -0
- package/src/isolated-event-container/test/index.js +2 -0
- package/src/mobile/bottom-sheet/cell.native.js +1 -1
- package/src/mobile/bottom-sheet/picker-cell.native.js +1 -6
- package/src/mobile/bottom-sheet/switch-cell.native.js +2 -2
- package/src/mobile/global-styles-context/index.native.js +9 -11
- package/src/mobile/global-styles-context/utils.native.js +17 -16
- package/src/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
- package/src/mobile/link-settings/test/edit.native.js +68 -124
- package/src/modal/index.tsx +11 -0
- package/src/modal/stories/index.tsx +3 -0
- package/src/modal/test/index.tsx +13 -0
- package/src/navigable-container/test/navigable-menu.js +2 -0
- package/src/navigable-container/test/tababble-container.js +2 -0
- package/src/navigation/stories/index.js +6 -6
- package/src/navigation/stories/{controlled-state.js → utils/controlled-state.js} +3 -3
- package/src/navigation/stories/{default.js → utils/default.js} +3 -3
- package/src/navigation/stories/{group.js → utils/group.js} +4 -4
- package/src/navigation/stories/{hide-if-empty.js → utils/hide-if-empty.js} +3 -3
- package/src/navigation/stories/{more-examples.js → utils/more-examples.js} +4 -4
- package/src/navigation/stories/{search.js → utils/search.js} +5 -5
- package/src/navigation/test/index.js +2 -0
- package/src/navigator/navigator-provider/component.tsx +13 -10
- package/src/navigator/test/index.tsx +2 -0
- package/src/notice/test/index.js +8 -3
- package/src/notice/test/list.js +8 -5
- package/src/number-control/stories/{index.js → index.tsx} +24 -7
- package/src/number-control/styles/{number-control-styles.js → number-control-styles.ts} +5 -3
- package/src/number-control/test/index.tsx +602 -0
- package/src/palette-edit/index.js +88 -39
- package/src/palette-edit/test/index.js +25 -1
- package/src/panel/test/__snapshots__/body.js.snap +9 -0
- package/src/panel/test/body.js +71 -62
- package/src/placeholder/test/index.tsx +3 -0
- package/src/popover/index.tsx +10 -2
- package/src/popover/style.scss +12 -11
- package/src/popover/test/index.tsx +25 -15
- package/src/query-controls/index.js +1 -0
- package/src/range-control/test/index.tsx +57 -60
- package/src/resizable-box/style.scss +1 -0
- package/src/sandbox/test/index.js +13 -11
- package/src/search-control/style.scss +4 -0
- package/src/select-control/test/select-control.tsx +2 -0
- package/src/snackbar/README.md +63 -8
- package/src/snackbar/{index.js → index.tsx} +46 -28
- package/src/snackbar/{list.js → list.tsx} +20 -21
- package/src/snackbar/stories/index.tsx +96 -0
- package/src/snackbar/stories/list.tsx +98 -0
- package/src/snackbar/types.ts +116 -0
- package/src/tab-panel/README.md +9 -0
- package/src/tab-panel/index.tsx +15 -5
- package/src/tab-panel/style.scss +46 -34
- package/src/tab-panel/test/index.tsx +113 -0
- package/src/tab-panel/types.ts +20 -1
- package/src/text/test/__snapshots__/index.tsx.snap +1 -0
- package/src/text/test/index.tsx +98 -46
- package/src/text-control/stories/index.tsx +0 -1
- package/src/text-control/types.ts +1 -6
- package/src/text-highlight/test/index.tsx +1 -0
- package/src/theme/README.md +32 -2
- package/src/theme/color-algorithms.ts +138 -0
- package/src/theme/index.tsx +23 -16
- package/src/theme/stories/index.tsx +67 -0
- package/src/theme/styles.ts +22 -17
- package/src/theme/test/color-algorithms.ts +100 -0
- package/src/theme/test/index.tsx +68 -35
- package/src/theme/types.ts +43 -3
- package/src/toggle-control/index.tsx +4 -2
- package/src/toggle-group-control/test/index.tsx +15 -2
- package/src/toolbar/style.scss +1 -1
- package/src/toolbar-group/test/index.js +10 -6
- package/src/tools-panel/stories/index.js +1 -1
- package/src/tools-panel/stories/{tools-panel-with-item-group-slot.js → utils/tools-panel-with-item-group-slot.js} +14 -11
- package/src/tools-panel/test/index.js +20 -14
- package/src/tooltip/README.md +7 -0
- package/src/tooltip/stories/index.js +68 -78
- package/src/tooltip/style.scss +2 -2
- package/src/tooltip/test/index.js +111 -18
- package/src/ui/context/context-system-provider.js +3 -2
- package/src/ui/context/test/context-system-provider.js +5 -4
- package/src/ui/control-label/test/index.js +3 -5
- package/src/unit-control/README.md +9 -1
- package/src/unit-control/index.tsx +3 -0
- package/src/unit-control/test/index.tsx +4 -0
- package/src/unit-control/types.ts +4 -0
- package/src/utils/colors-values.js +1 -1
- package/src/utils/config-values.js +0 -2
- package/src/utils/hooks/test/use-latest-ref.js +2 -0
- package/src/utils/hooks/use-controlled-value.ts +2 -2
- package/src/utils/theme-variables.scss +20 -0
- package/tsconfig.json +2 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/src/dropdown/test/index.js +0 -98
- package/src/icon/stories/index.js +0 -128
- package/src/number-control/test/index.js +0 -478
- package/src/snackbar/stories/index.js +0 -89
|
@@ -12,13 +12,14 @@ import { useRef } from '@wordpress/element';
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
|
-
import Snackbar from '
|
|
15
|
+
import Snackbar from '.';
|
|
16
16
|
import {
|
|
17
17
|
__unstableMotion as motion,
|
|
18
18
|
__unstableAnimatePresence as AnimatePresence,
|
|
19
19
|
} from '../animation';
|
|
20
|
+
import type { Notice, SnackbarListProps } from './types';
|
|
21
|
+
import type { WordPressComponentProps } from '../ui/context';
|
|
20
22
|
|
|
21
|
-
const noop = () => {};
|
|
22
23
|
const SNACKBAR_VARIANTS = {
|
|
23
24
|
init: {
|
|
24
25
|
height: 0,
|
|
@@ -39,28 +40,28 @@ const SNACKBAR_VARIANTS = {
|
|
|
39
40
|
},
|
|
40
41
|
};
|
|
41
42
|
|
|
42
|
-
const SNACKBAR_REDUCE_MOTION_VARIANTS = {
|
|
43
|
-
init: false,
|
|
44
|
-
open: false,
|
|
45
|
-
exit: false,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
43
|
/**
|
|
49
44
|
* Renders a list of notices.
|
|
50
45
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
46
|
+
* ```jsx
|
|
47
|
+
* const MySnackbarListNotice = () => (
|
|
48
|
+
* <SnackbarList
|
|
49
|
+
* notices={ notices }
|
|
50
|
+
* onRemove={ removeNotice }
|
|
51
|
+
* />
|
|
52
|
+
* );
|
|
53
|
+
* ```
|
|
58
54
|
*/
|
|
59
|
-
function SnackbarList( {
|
|
60
|
-
|
|
55
|
+
export function SnackbarList( {
|
|
56
|
+
notices,
|
|
57
|
+
className,
|
|
58
|
+
children,
|
|
59
|
+
onRemove,
|
|
60
|
+
}: WordPressComponentProps< SnackbarListProps, 'div' > ) {
|
|
61
|
+
const listRef = useRef< HTMLDivElement | null >( null );
|
|
61
62
|
const isReducedMotion = useReducedMotion();
|
|
62
63
|
className = classnames( 'components-snackbar-list', className );
|
|
63
|
-
const removeNotice = ( notice ) => () => onRemove( notice.id );
|
|
64
|
+
const removeNotice = ( notice: Notice ) => () => onRemove?.( notice.id );
|
|
64
65
|
return (
|
|
65
66
|
<div className={ className } tabIndex={ -1 } ref={ listRef }>
|
|
66
67
|
{ children }
|
|
@@ -76,9 +77,7 @@ function SnackbarList( { notices, className, children, onRemove = noop } ) {
|
|
|
76
77
|
exit={ 'exit' }
|
|
77
78
|
key={ notice.id }
|
|
78
79
|
variants={
|
|
79
|
-
isReducedMotion
|
|
80
|
-
? SNACKBAR_REDUCE_MOTION_VARIANTS
|
|
81
|
-
: SNACKBAR_VARIANTS
|
|
80
|
+
isReducedMotion ? undefined : SNACKBAR_VARIANTS
|
|
82
81
|
}
|
|
83
82
|
>
|
|
84
83
|
<div className="components-snackbar-list__notice-container">
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import Snackbar from '..';
|
|
10
|
+
|
|
11
|
+
const meta: ComponentMeta< typeof Snackbar > = {
|
|
12
|
+
title: 'Components/Snackbar',
|
|
13
|
+
component: Snackbar,
|
|
14
|
+
argTypes: {
|
|
15
|
+
as: { control: { type: null } },
|
|
16
|
+
onRemove: {
|
|
17
|
+
action: 'onRemove',
|
|
18
|
+
control: { type: null },
|
|
19
|
+
},
|
|
20
|
+
onDismiss: {
|
|
21
|
+
action: 'onDismiss',
|
|
22
|
+
control: { type: null },
|
|
23
|
+
},
|
|
24
|
+
listRef: {
|
|
25
|
+
control: { type: null },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
parameters: {
|
|
29
|
+
controls: {
|
|
30
|
+
expanded: true,
|
|
31
|
+
},
|
|
32
|
+
docs: { source: { state: 'open' } },
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
export default meta;
|
|
36
|
+
|
|
37
|
+
const DefaultTemplate: ComponentStory< typeof Snackbar > = ( {
|
|
38
|
+
children,
|
|
39
|
+
...props
|
|
40
|
+
} ) => {
|
|
41
|
+
return <Snackbar { ...props }>{ children }</Snackbar>;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const Default: ComponentStory< typeof Snackbar > = DefaultTemplate.bind(
|
|
45
|
+
{}
|
|
46
|
+
);
|
|
47
|
+
Default.args = {
|
|
48
|
+
children:
|
|
49
|
+
'Use Snackbars to communicate low priority, non-interruptive messages to the user.',
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const WithActions: ComponentStory< typeof Snackbar > =
|
|
53
|
+
DefaultTemplate.bind( {} );
|
|
54
|
+
WithActions.args = {
|
|
55
|
+
actions: [
|
|
56
|
+
{
|
|
57
|
+
label: 'Open WP.org',
|
|
58
|
+
url: 'https://wordpress.org',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
children: 'Use Snackbars with an action link to an external page.',
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const WithIcon: ComponentStory< typeof Snackbar > = DefaultTemplate.bind(
|
|
65
|
+
{}
|
|
66
|
+
);
|
|
67
|
+
WithIcon.args = {
|
|
68
|
+
children: 'Add an icon to make your snackbar stand out',
|
|
69
|
+
icon: (
|
|
70
|
+
<span role="img" aria-label="Icon" style={ { fontSize: 21 } }>
|
|
71
|
+
🌮
|
|
72
|
+
</span>
|
|
73
|
+
),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const WithExplicitDismiss: ComponentStory< typeof Snackbar > =
|
|
77
|
+
DefaultTemplate.bind( {} );
|
|
78
|
+
WithExplicitDismiss.args = {
|
|
79
|
+
children:
|
|
80
|
+
'Add a cross to explicitly close the snackbar, and do not hide it automatically',
|
|
81
|
+
explicitDismiss: true,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const WithActionAndExplicitDismiss: ComponentStory< typeof Snackbar > =
|
|
85
|
+
DefaultTemplate.bind( {} );
|
|
86
|
+
WithActionAndExplicitDismiss.args = {
|
|
87
|
+
actions: [
|
|
88
|
+
{
|
|
89
|
+
label: 'Open WP.org',
|
|
90
|
+
url: 'https://wordpress.org',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
children:
|
|
94
|
+
'Add an action and a cross to explicitly close the snackbar, and do not hide it automatically',
|
|
95
|
+
explicitDismiss: true,
|
|
96
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import SnackbarList from '../list';
|
|
15
|
+
|
|
16
|
+
const meta: ComponentMeta< typeof SnackbarList > = {
|
|
17
|
+
title: 'Components/SnackbarList',
|
|
18
|
+
component: SnackbarList,
|
|
19
|
+
argTypes: {
|
|
20
|
+
as: { control: { type: null } },
|
|
21
|
+
onRemove: {
|
|
22
|
+
action: 'onRemove',
|
|
23
|
+
control: { type: null },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
parameters: {
|
|
27
|
+
controls: {
|
|
28
|
+
expanded: true,
|
|
29
|
+
},
|
|
30
|
+
docs: { source: { state: 'open' } },
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export default meta;
|
|
34
|
+
|
|
35
|
+
export const Default: ComponentStory< typeof SnackbarList > = ( {
|
|
36
|
+
children,
|
|
37
|
+
notices: noticesProp,
|
|
38
|
+
...props
|
|
39
|
+
} ) => {
|
|
40
|
+
const [ notices, setNotices ] = useState( noticesProp );
|
|
41
|
+
|
|
42
|
+
const onRemove = ( id: string ) => {
|
|
43
|
+
const matchIndex = notices.findIndex( ( n ) => n.id === id );
|
|
44
|
+
if ( matchIndex > -1 ) {
|
|
45
|
+
setNotices( [
|
|
46
|
+
...notices.slice( 0, matchIndex ),
|
|
47
|
+
...notices.slice( matchIndex + 1 ),
|
|
48
|
+
] );
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<SnackbarList { ...props } notices={ notices } onRemove={ onRemove }>
|
|
54
|
+
{ children }
|
|
55
|
+
</SnackbarList>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
Default.args = {
|
|
60
|
+
children:
|
|
61
|
+
'Use SnackbarList to communicate multiple low priority, non-interruptive messages to the user.',
|
|
62
|
+
notices: [
|
|
63
|
+
{
|
|
64
|
+
id: 'SAVE_POST_NOTICE_ID_1',
|
|
65
|
+
spokenMessage: 'Post published.',
|
|
66
|
+
actions: [
|
|
67
|
+
{
|
|
68
|
+
label: 'View Post',
|
|
69
|
+
url: 'https://example.com/?p=522',
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
content: 'Post published.',
|
|
73
|
+
isDismissible: true,
|
|
74
|
+
explicitDismiss: false,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 'SAVE_POST_NOTICE_ID_2',
|
|
78
|
+
spokenMessage: 'Post updated',
|
|
79
|
+
actions: [
|
|
80
|
+
{
|
|
81
|
+
label: 'View Post',
|
|
82
|
+
url: 'https://example.com/?p=522',
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
content: 'Post updated.',
|
|
86
|
+
isDismissible: true,
|
|
87
|
+
explicitDismiss: false,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: 'global1',
|
|
91
|
+
spokenMessage: 'All content copied.',
|
|
92
|
+
actions: [],
|
|
93
|
+
content: 'All content copied.',
|
|
94
|
+
isDismissible: true,
|
|
95
|
+
explicitDismiss: false,
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { MutableRefObject, ReactNode, SyntheticEvent } from 'react';
|
|
5
|
+
|
|
6
|
+
export type NoticeActionWithURL = {
|
|
7
|
+
label: string;
|
|
8
|
+
url: string;
|
|
9
|
+
onClick?: ( event: SyntheticEvent ) => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type NoticeActionWithOnClick = {
|
|
13
|
+
label: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
onClick: ( event: SyntheticEvent ) => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// TODO: move this type to the Notice component once it gets typed.
|
|
19
|
+
export type NoticeAction = NoticeActionWithURL | NoticeActionWithOnClick;
|
|
20
|
+
|
|
21
|
+
export type Notice = {
|
|
22
|
+
id: string;
|
|
23
|
+
spokenMessage: string;
|
|
24
|
+
actions: NoticeAction[];
|
|
25
|
+
icon?: ReactNode;
|
|
26
|
+
onDismiss?: () => void;
|
|
27
|
+
content: string;
|
|
28
|
+
isDismissible: boolean;
|
|
29
|
+
explicitDismiss: boolean;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type SnackbarProps = {
|
|
33
|
+
/**
|
|
34
|
+
* The displayed message of a notice.
|
|
35
|
+
*
|
|
36
|
+
* Also used as the spoken message for assistive technology,
|
|
37
|
+
* unless `spokenMessage` is provided as an alternative message.
|
|
38
|
+
*/
|
|
39
|
+
children: string;
|
|
40
|
+
/**
|
|
41
|
+
* Used to provide a custom spoken message.
|
|
42
|
+
*
|
|
43
|
+
* @default children
|
|
44
|
+
*/
|
|
45
|
+
spokenMessage?: Notice[ 'spokenMessage' ];
|
|
46
|
+
/**
|
|
47
|
+
* A politeness level for the notice's spoken message. Should be provided as
|
|
48
|
+
* one of the valid options for an `aria-live` attribute value. Note that this
|
|
49
|
+
* value should be considered a suggestion; assistive technologies may
|
|
50
|
+
* override it based on internal heuristics.
|
|
51
|
+
*
|
|
52
|
+
* A value of `'assertive'` is to be used for important, and usually
|
|
53
|
+
* time-sensitive, information. It will interrupt anything else the screen
|
|
54
|
+
* reader is announcing in that moment.
|
|
55
|
+
* A value of `'polite'` is to be used for advisory information. It should
|
|
56
|
+
* not interrupt what the screen reader is announcing in that moment
|
|
57
|
+
* (the "speech queue") or interrupt the current task.
|
|
58
|
+
*
|
|
59
|
+
* @see https://www.w3.org/TR/wai-aria-1.1/#aria-live
|
|
60
|
+
*
|
|
61
|
+
* @default 'polite'
|
|
62
|
+
*/
|
|
63
|
+
politeness?: 'polite' | 'assertive';
|
|
64
|
+
/**
|
|
65
|
+
* An array of action objects.
|
|
66
|
+
*
|
|
67
|
+
* Each member object should contain
|
|
68
|
+
* a `label` and either a `url` link string or `onClick` callback function.
|
|
69
|
+
*
|
|
70
|
+
* @default []
|
|
71
|
+
*/
|
|
72
|
+
actions?: Notice[ 'actions' ];
|
|
73
|
+
/**
|
|
74
|
+
* Called to remove the snackbar from the UI.
|
|
75
|
+
*/
|
|
76
|
+
onRemove?: () => void;
|
|
77
|
+
/**
|
|
78
|
+
* The icon to render in the snackbar.
|
|
79
|
+
*
|
|
80
|
+
* @default null
|
|
81
|
+
*/
|
|
82
|
+
icon?: Notice[ 'icon' ];
|
|
83
|
+
/**
|
|
84
|
+
* Whether to require user action to dismiss the snackbar.
|
|
85
|
+
* By default, this is dismissed on a timeout, without user interaction.
|
|
86
|
+
*
|
|
87
|
+
* @default false
|
|
88
|
+
*/
|
|
89
|
+
explicitDismiss?: Notice[ 'explicitDismiss' ];
|
|
90
|
+
/**
|
|
91
|
+
* A callback executed when the snackbar is dismissed.
|
|
92
|
+
*
|
|
93
|
+
* It is distinct from onRemove, which _looks_ like a callback but is
|
|
94
|
+
* actually the function to call to remove the snackbar from the UI.
|
|
95
|
+
*/
|
|
96
|
+
onDismiss?: Notice[ 'onDismiss' ];
|
|
97
|
+
/**
|
|
98
|
+
* A ref to the list that contains the snackbar.
|
|
99
|
+
*/
|
|
100
|
+
listRef?: MutableRefObject< HTMLDivElement | null >;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export type SnackbarListProps = {
|
|
104
|
+
/**
|
|
105
|
+
* Array of notices to render.
|
|
106
|
+
*/
|
|
107
|
+
notices: Notice[];
|
|
108
|
+
/**
|
|
109
|
+
* Children to be rendered inside the notice list.
|
|
110
|
+
*/
|
|
111
|
+
children?: ReactNode;
|
|
112
|
+
/**
|
|
113
|
+
* Function called when a notice should be removed / dismissed.
|
|
114
|
+
*/
|
|
115
|
+
onRemove?: ( id: Notice[ 'id' ] ) => void;
|
|
116
|
+
};
|
package/src/tab-panel/README.md
CHANGED
|
@@ -120,6 +120,7 @@ An array of objects containing the following properties:
|
|
|
120
120
|
- `name`: `(string)` Defines the key for the tab.
|
|
121
121
|
- `title`:`(string)` Defines the translated text for the tab.
|
|
122
122
|
- `className`:`(string)` Optional. Defines the class to put on the tab.
|
|
123
|
+
- `icon`:`(ReactNode)` Optional. When set, displays the icon in place of the tab title. The title is then rendered as an aria-label and tooltip.
|
|
123
124
|
|
|
124
125
|
> > **Note:** Other fields may be added to the object and accessed from the child function if desired.
|
|
125
126
|
|
|
@@ -142,6 +143,14 @@ The name of the tab to be selected upon mounting of component. If this prop is n
|
|
|
142
143
|
- Required: No
|
|
143
144
|
- Default: none
|
|
144
145
|
|
|
146
|
+
#### selectOnMove
|
|
147
|
+
|
|
148
|
+
When `true`, the tab will be selected when receiving focus (automatic tab activation). When `false`, the tab will be selected only when clicked (manual tab activation). See the [official W3C docs](https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/) for more info.
|
|
149
|
+
|
|
150
|
+
- Type: `boolean`
|
|
151
|
+
- Required: No
|
|
152
|
+
- Default: `true`
|
|
153
|
+
|
|
145
154
|
#### children
|
|
146
155
|
|
|
147
156
|
A function which renders the tabviews given the selected tab. The function is passed the active tab object as an argument as defined the tabs prop.
|
package/src/tab-panel/index.tsx
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { find } from 'lodash';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
@@ -77,6 +76,7 @@ export function TabPanel( {
|
|
|
77
76
|
className,
|
|
78
77
|
children,
|
|
79
78
|
tabs,
|
|
79
|
+
selectOnMove = true,
|
|
80
80
|
initialTabName,
|
|
81
81
|
orientation = 'horizontal',
|
|
82
82
|
activeClass = 'is-active',
|
|
@@ -93,10 +93,15 @@ export function TabPanel( {
|
|
|
93
93
|
[ onSelect ]
|
|
94
94
|
);
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
// Simulate a click on the newly focused tab, which causes the component
|
|
97
|
+
// to show the `tab-panel` associated with the clicked tab.
|
|
98
|
+
const activateTabAutomatically = (
|
|
99
|
+
_childIndex: number,
|
|
100
|
+
child: HTMLButtonElement
|
|
101
|
+
) => {
|
|
97
102
|
child.click();
|
|
98
103
|
};
|
|
99
|
-
const selectedTab = find(
|
|
104
|
+
const selectedTab = tabs.find( ( { name } ) => name === selected );
|
|
100
105
|
const selectedId = `${ instanceId }-${ selectedTab?.name ?? 'none' }`;
|
|
101
106
|
|
|
102
107
|
useEffect( () => {
|
|
@@ -110,7 +115,9 @@ export function TabPanel( {
|
|
|
110
115
|
<NavigableMenu
|
|
111
116
|
role="tablist"
|
|
112
117
|
orientation={ orientation }
|
|
113
|
-
onNavigate={
|
|
118
|
+
onNavigate={
|
|
119
|
+
selectOnMove ? activateTabAutomatically : undefined
|
|
120
|
+
}
|
|
114
121
|
className="components-tab-panel__tabs"
|
|
115
122
|
>
|
|
116
123
|
{ tabs.map( ( tab ) => (
|
|
@@ -127,8 +134,11 @@ export function TabPanel( {
|
|
|
127
134
|
selected={ tab.name === selected }
|
|
128
135
|
key={ tab.name }
|
|
129
136
|
onClick={ () => handleTabSelection( tab.name ) }
|
|
137
|
+
label={ tab.icon && tab.title }
|
|
138
|
+
icon={ tab.icon }
|
|
139
|
+
showTooltip={ !! tab.icon }
|
|
130
140
|
>
|
|
131
|
-
{ tab.title }
|
|
141
|
+
{ ! tab.icon && tab.title }
|
|
132
142
|
</TabButton>
|
|
133
143
|
) ) }
|
|
134
144
|
</NavigableMenu>
|
package/src/tab-panel/style.scss
CHANGED
|
@@ -7,57 +7,69 @@
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
// This tab style CSS is duplicated verbatim in
|
|
11
|
+
// /packages/edit-post/src/components/sidebar/settings-header/style.scss
|
|
10
12
|
.components-tab-panel__tabs-item {
|
|
13
|
+
position: relative;
|
|
14
|
+
border-radius: 0;
|
|
15
|
+
height: $grid-unit-60;
|
|
11
16
|
background: transparent;
|
|
12
17
|
border: none;
|
|
13
18
|
box-shadow: none;
|
|
14
|
-
border-radius: 0;
|
|
15
19
|
cursor: pointer;
|
|
16
|
-
height: $grid-unit-60;
|
|
17
20
|
padding: 3px $grid-unit-20; // Use padding to offset the is-active border, this benefits Windows High Contrast mode
|
|
18
21
|
margin-left: 0;
|
|
19
22
|
font-weight: 500;
|
|
20
|
-
transition: box-shadow 0.1s linear;
|
|
21
|
-
box-sizing: border-box;
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
&:focus:not(:disabled) {
|
|
25
|
+
position: relative;
|
|
26
|
+
box-shadow: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Tab indicator
|
|
26
30
|
&::after {
|
|
27
|
-
content:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
content: "";
|
|
32
|
+
position: absolute;
|
|
33
|
+
right: 0;
|
|
34
|
+
bottom: 0;
|
|
35
|
+
left: 0;
|
|
36
|
+
pointer-events: none;
|
|
37
|
+
|
|
38
|
+
// Draw the indicator.
|
|
39
|
+
background: $components-color-accent;
|
|
40
|
+
height: calc(0 * var(--wp-admin-border-width-focus));
|
|
41
|
+
border-radius: 0;
|
|
42
|
+
|
|
43
|
+
// Animation
|
|
44
|
+
transition: all 0.1s linear;
|
|
45
|
+
@include reduce-motion("transition");
|
|
33
46
|
}
|
|
34
47
|
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
// Active.
|
|
49
|
+
&.is-active::after {
|
|
50
|
+
height: calc(1 * var(--wp-admin-border-width-focus));
|
|
37
51
|
}
|
|
38
52
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
position:
|
|
53
|
+
// Focus.
|
|
54
|
+
&::before {
|
|
55
|
+
content: "";
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: $grid-unit-15;
|
|
58
|
+
right: $grid-unit-15;
|
|
59
|
+
bottom: $grid-unit-15;
|
|
60
|
+
left: $grid-unit-15;
|
|
61
|
+
pointer-events: none;
|
|
43
62
|
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
position: absolute;
|
|
48
|
-
top: 0;
|
|
49
|
-
bottom: 1px;
|
|
50
|
-
right: 0;
|
|
51
|
-
left: 0;
|
|
52
|
-
border-bottom: $border-width-tab solid transparent;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
63
|
+
// Draw the indicator.
|
|
64
|
+
box-shadow: 0 0 0 0 transparent;
|
|
65
|
+
border-radius: $radius-block-ui;
|
|
55
66
|
|
|
56
|
-
|
|
57
|
-
|
|
67
|
+
// Animation
|
|
68
|
+
transition: all 0.1s linear;
|
|
69
|
+
@include reduce-motion("transition");
|
|
58
70
|
}
|
|
59
71
|
|
|
60
|
-
|
|
61
|
-
box-shadow:
|
|
72
|
+
&:focus-visible::before {
|
|
73
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
|
|
62
74
|
}
|
|
63
75
|
}
|
|
@@ -9,6 +9,8 @@ import userEvent from '@testing-library/user-event';
|
|
|
9
9
|
*/
|
|
10
10
|
import TabPanel from '..';
|
|
11
11
|
|
|
12
|
+
jest.useFakeTimers();
|
|
13
|
+
|
|
12
14
|
const setupUser = () =>
|
|
13
15
|
userEvent.setup( {
|
|
14
16
|
advanceTimers: jest.advanceTimersByTime,
|
|
@@ -34,7 +36,24 @@ const TABS = [
|
|
|
34
36
|
|
|
35
37
|
const getSelectedTab = () => screen.getByRole( 'tab', { selected: true } );
|
|
36
38
|
|
|
39
|
+
let originalGetClientRects: () => DOMRectList;
|
|
40
|
+
|
|
37
41
|
describe( 'TabPanel', () => {
|
|
42
|
+
beforeAll( () => {
|
|
43
|
+
originalGetClientRects = window.HTMLElement.prototype.getClientRects;
|
|
44
|
+
// Mocking `getClientRects()` is necessary to pass a check performed by
|
|
45
|
+
// the `focus.tabbable.find()` and by the `focus.focusable.find()` functions
|
|
46
|
+
// from the `@wordpress/dom` package.
|
|
47
|
+
// @ts-expect-error We're not trying to comply to the DOM spec, only mocking
|
|
48
|
+
window.HTMLElement.prototype.getClientRects = function () {
|
|
49
|
+
return [ 'trick-jsdom-into-having-size-for-element-rect' ];
|
|
50
|
+
};
|
|
51
|
+
} );
|
|
52
|
+
|
|
53
|
+
afterAll( () => {
|
|
54
|
+
window.HTMLElement.prototype.getClientRects = originalGetClientRects;
|
|
55
|
+
} );
|
|
56
|
+
|
|
38
57
|
it( 'should render a tabpanel, and clicking should change tabs', async () => {
|
|
39
58
|
const user = setupUser();
|
|
40
59
|
const panelRenderFunction = jest.fn();
|
|
@@ -194,4 +213,98 @@ describe( 'TabPanel', () => {
|
|
|
194
213
|
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'beta' );
|
|
195
214
|
} );
|
|
196
215
|
} );
|
|
216
|
+
|
|
217
|
+
describe( 'tab activation', () => {
|
|
218
|
+
it( 'defaults to automatic tab activation', async () => {
|
|
219
|
+
const user = setupUser();
|
|
220
|
+
const mockOnSelect = jest.fn();
|
|
221
|
+
|
|
222
|
+
render(
|
|
223
|
+
<TabPanel
|
|
224
|
+
tabs={ TABS }
|
|
225
|
+
children={ () => undefined }
|
|
226
|
+
onSelect={ mockOnSelect }
|
|
227
|
+
/>
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
// onSelect gets called on the initial render.
|
|
231
|
+
expect( mockOnSelect ).toHaveBeenCalledTimes( 1 );
|
|
232
|
+
|
|
233
|
+
// Click on Alpha, make sure Alpha is selected
|
|
234
|
+
await user.click( screen.getByRole( 'tab', { name: 'Alpha' } ) );
|
|
235
|
+
expect( mockOnSelect ).toHaveBeenCalledTimes( 2 );
|
|
236
|
+
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'alpha' );
|
|
237
|
+
|
|
238
|
+
// Navigate forward with arrow keys,
|
|
239
|
+
// make sure Beta is selected automatically.
|
|
240
|
+
await user.keyboard( '[ArrowRight]' );
|
|
241
|
+
expect( mockOnSelect ).toHaveBeenCalledTimes( 3 );
|
|
242
|
+
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'beta' );
|
|
243
|
+
|
|
244
|
+
// Navigate forward with arrow keys,
|
|
245
|
+
// make sure Gamma (last tab) is selected automatically.
|
|
246
|
+
await user.keyboard( '[ArrowRight]' );
|
|
247
|
+
expect( mockOnSelect ).toHaveBeenCalledTimes( 4 );
|
|
248
|
+
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'gamma' );
|
|
249
|
+
|
|
250
|
+
// Navigate forward with arrow keys,
|
|
251
|
+
// make sure Alpha (first tab) is selected automatically.
|
|
252
|
+
await user.keyboard( '[ArrowRight]' );
|
|
253
|
+
expect( mockOnSelect ).toHaveBeenCalledTimes( 5 );
|
|
254
|
+
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'alpha' );
|
|
255
|
+
|
|
256
|
+
// Navigate backwards with arrow keys,
|
|
257
|
+
// make sure Gamma (last tab) is selected automatically
|
|
258
|
+
await user.keyboard( '[ArrowLeft]' );
|
|
259
|
+
expect( mockOnSelect ).toHaveBeenCalledTimes( 6 );
|
|
260
|
+
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'gamma' );
|
|
261
|
+
} );
|
|
262
|
+
|
|
263
|
+
it( 'switches to manual tab activation when the `selectOnMove` prop is set to `false`', async () => {
|
|
264
|
+
const user = setupUser();
|
|
265
|
+
const mockOnSelect = jest.fn();
|
|
266
|
+
|
|
267
|
+
render(
|
|
268
|
+
<TabPanel
|
|
269
|
+
tabs={ TABS }
|
|
270
|
+
children={ () => undefined }
|
|
271
|
+
onSelect={ mockOnSelect }
|
|
272
|
+
selectOnMove={ false }
|
|
273
|
+
/>
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
// onSelect gets called on the initial render.
|
|
277
|
+
expect( mockOnSelect ).toHaveBeenCalledTimes( 1 );
|
|
278
|
+
|
|
279
|
+
// Click on Alpha, make sure Alpha is selected
|
|
280
|
+
await user.click( screen.getByRole( 'tab', { name: 'Alpha' } ) );
|
|
281
|
+
expect( mockOnSelect ).toHaveBeenCalledTimes( 2 );
|
|
282
|
+
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'alpha' );
|
|
283
|
+
|
|
284
|
+
// Navigate forward with arrow keys.
|
|
285
|
+
// Make sure Beta is focused, but that the tab selection happens only when
|
|
286
|
+
// pressing the spacebar or the enter key.
|
|
287
|
+
await user.keyboard( '[ArrowRight]' );
|
|
288
|
+
expect( mockOnSelect ).toHaveBeenCalledTimes( 2 );
|
|
289
|
+
expect( screen.getByRole( 'tab', { name: 'Beta' } ) ).toHaveFocus();
|
|
290
|
+
await user.keyboard( '[Enter]' );
|
|
291
|
+
expect( mockOnSelect ).toHaveBeenCalledTimes( 3 );
|
|
292
|
+
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'beta' );
|
|
293
|
+
|
|
294
|
+
// Navigate forward with arrow keys.
|
|
295
|
+
// Make sure Gamma (last tab) is focused, but that the tab selection
|
|
296
|
+
// happens only when pressing the spacebar or the enter key.
|
|
297
|
+
await user.keyboard( '[ArrowRight]' );
|
|
298
|
+
expect( mockOnSelect ).toHaveBeenCalledTimes( 3 );
|
|
299
|
+
expect(
|
|
300
|
+
screen.getByRole( 'tab', { name: 'Gamma' } )
|
|
301
|
+
).toHaveFocus();
|
|
302
|
+
await user.keyboard( '[Space]' );
|
|
303
|
+
expect( mockOnSelect ).toHaveBeenCalledTimes( 4 );
|
|
304
|
+
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'gamma' );
|
|
305
|
+
|
|
306
|
+
// No need to test the "wrap-around" behavior, as it's being tested in the
|
|
307
|
+
// "automatic tab activation" test above.
|
|
308
|
+
} );
|
|
309
|
+
} );
|
|
197
310
|
} );
|