@wordpress/components 29.0.0 → 29.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 +39 -1
- package/LICENSE.md +1 -1
- package/build/badge/index.js +64 -0
- package/build/badge/index.js.map +1 -0
- package/build/badge/types.js +6 -0
- package/build/badge/types.js.map +1 -0
- package/build/box-control/index.js +5 -1
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/input-control.js +90 -29
- package/build/box-control/input-control.js.map +1 -1
- package/build/box-control/types.js.map +1 -1
- package/build/box-control/utils.js +50 -0
- package/build/box-control/utils.js.map +1 -1
- package/build/button-group/index.js +10 -0
- package/build/button-group/index.js.map +1 -1
- package/build/button-group/types.js.map +1 -1
- package/build/custom-select-control/index.js +3 -5
- package/build/custom-select-control/index.js.map +1 -1
- package/build/custom-select-control-v2/custom-select.js +2 -3
- package/build/custom-select-control-v2/custom-select.js.map +1 -1
- package/build/date-time/date/index.js +1 -0
- package/build/date-time/date/index.js.map +1 -1
- package/build/dimension-control/index.js +1 -0
- package/build/dimension-control/index.js.map +1 -1
- package/build/font-size-picker/styles.js +9 -9
- package/build/font-size-picker/styles.js.map +1 -1
- package/build/heading/hook.js +1 -1
- package/build/heading/hook.js.map +1 -1
- package/build/input-control/index.js +9 -0
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/types.js.map +1 -1
- package/build/menu/checkbox-item.js +2 -0
- package/build/menu/checkbox-item.js.map +1 -1
- package/build/menu/index.js +25 -94
- package/build/menu/index.js.map +1 -1
- package/build/menu/item.js +10 -1
- package/build/menu/item.js.map +1 -1
- package/build/menu/popover.js +89 -0
- package/build/menu/popover.js.map +1 -0
- package/build/menu/radio-item.js +2 -0
- package/build/menu/radio-item.js.map +1 -1
- package/build/menu/submenu-trigger-item.js +58 -0
- package/build/menu/submenu-trigger-item.js.map +1 -0
- package/build/menu/trigger-button.js +45 -0
- package/build/menu/trigger-button.js.map +1 -0
- package/build/menu/types.js.map +1 -1
- package/build/navigation/back-button/index.js +1 -0
- package/build/navigation/back-button/index.js.map +1 -1
- package/build/navigation/index.js +6 -0
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/item/index.js +1 -0
- package/build/navigation/item/index.js.map +1 -1
- package/build/number-control/index.js +1 -0
- package/build/number-control/index.js.map +1 -1
- package/build/palette-edit/index.js +1 -0
- package/build/palette-edit/index.js.map +1 -1
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +1 -1
- package/build/radio-group/index.js +6 -0
- package/build/radio-group/index.js.map +1 -1
- package/build/radio-group/radio.js +2 -3
- package/build/radio-group/radio.js.map +1 -1
- package/build/range-control/styles/range-control-styles.js +28 -28
- package/build/range-control/styles/range-control-styles.js.map +1 -1
- package/build/select-control/index.js +9 -0
- package/build/select-control/index.js.map +1 -1
- package/build/select-control/types.js.map +1 -1
- package/build/slot-fill/context.js +4 -3
- package/build/slot-fill/context.js.map +1 -1
- package/build/slot-fill/fill.js +10 -15
- package/build/slot-fill/fill.js.map +1 -1
- package/build/slot-fill/provider.js +41 -55
- package/build/slot-fill/provider.js.map +1 -1
- package/build/slot-fill/slot.js +31 -23
- package/build/slot-fill/slot.js.map +1 -1
- package/build/slot-fill/types.js.map +1 -1
- package/build/tab-panel/index.js +2 -3
- package/build/tab-panel/index.js.map +1 -1
- package/build/tabs/index.js +21 -4
- package/build/tabs/index.js.map +1 -1
- package/build/tabs/types.js.map +1 -1
- package/build/text/hook.js +6 -6
- package/build/text/hook.js.map +1 -1
- package/build/text/styles.js +7 -7
- package/build/text/styles.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/as-radio-group.js +2 -3
- package/build/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
- package/build/tooltip/index.js +2 -3
- package/build/tooltip/index.js.map +1 -1
- package/build/tree-select/index.js +10 -2
- package/build/tree-select/index.js.map +1 -1
- package/build/tree-select/types.js.map +1 -1
- package/build-module/badge/index.js +57 -0
- package/build-module/badge/index.js.map +1 -0
- package/build-module/badge/types.js +2 -0
- package/build-module/badge/types.js.map +1 -0
- package/build-module/box-control/index.js +5 -1
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/input-control.js +92 -31
- package/build-module/box-control/input-control.js.map +1 -1
- package/build-module/box-control/types.js.map +1 -1
- package/build-module/box-control/utils.js +47 -0
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/button-group/index.js +10 -0
- package/build-module/button-group/index.js.map +1 -1
- package/build-module/button-group/types.js.map +1 -1
- package/build-module/custom-select-control/index.js +3 -5
- package/build-module/custom-select-control/index.js.map +1 -1
- package/build-module/custom-select-control-v2/custom-select.js +1 -2
- package/build-module/custom-select-control-v2/custom-select.js.map +1 -1
- package/build-module/date-time/date/index.js +1 -0
- package/build-module/date-time/date/index.js.map +1 -1
- package/build-module/dimension-control/index.js +1 -0
- package/build-module/dimension-control/index.js.map +1 -1
- package/build-module/font-size-picker/styles.js +9 -9
- package/build-module/font-size-picker/styles.js.map +1 -1
- package/build-module/heading/hook.js +1 -1
- package/build-module/heading/hook.js.map +1 -1
- package/build-module/input-control/index.js +9 -0
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/types.js.map +1 -1
- package/build-module/menu/checkbox-item.js +2 -0
- package/build-module/menu/checkbox-item.js.map +1 -1
- package/build-module/menu/index.js +28 -97
- package/build-module/menu/index.js.map +1 -1
- package/build-module/menu/item.js +10 -1
- package/build-module/menu/item.js.map +1 -1
- package/build-module/menu/popover.js +81 -0
- package/build-module/menu/popover.js.map +1 -0
- package/build-module/menu/radio-item.js +2 -0
- package/build-module/menu/radio-item.js.map +1 -1
- package/build-module/menu/submenu-trigger-item.js +50 -0
- package/build-module/menu/submenu-trigger-item.js.map +1 -0
- package/build-module/menu/trigger-button.js +37 -0
- package/build-module/menu/trigger-button.js.map +1 -0
- package/build-module/menu/types.js.map +1 -1
- package/build-module/navigation/back-button/index.js +1 -0
- package/build-module/navigation/back-button/index.js.map +1 -1
- package/build-module/navigation/index.js +6 -0
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/item/index.js +1 -0
- package/build-module/navigation/item/index.js.map +1 -1
- package/build-module/number-control/index.js +1 -0
- package/build-module/number-control/index.js.map +1 -1
- package/build-module/palette-edit/index.js +1 -0
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/radio-group/index.js +6 -0
- package/build-module/radio-group/index.js.map +1 -1
- package/build-module/radio-group/radio.js +1 -2
- package/build-module/radio-group/radio.js.map +1 -1
- package/build-module/range-control/styles/range-control-styles.js +28 -28
- package/build-module/range-control/styles/range-control-styles.js.map +1 -1
- package/build-module/select-control/index.js +9 -0
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/select-control/types.js.map +1 -1
- package/build-module/slot-fill/context.js +5 -3
- package/build-module/slot-fill/context.js.map +1 -1
- package/build-module/slot-fill/fill.js +10 -15
- package/build-module/slot-fill/fill.js.map +1 -1
- package/build-module/slot-fill/provider.js +41 -55
- package/build-module/slot-fill/provider.js.map +1 -1
- package/build-module/slot-fill/slot.js +32 -24
- package/build-module/slot-fill/slot.js.map +1 -1
- package/build-module/slot-fill/types.js.map +1 -1
- package/build-module/tab-panel/index.js +1 -2
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/tabs/index.js +21 -4
- package/build-module/tabs/index.js.map +1 -1
- package/build-module/tabs/types.js.map +1 -1
- package/build-module/text/hook.js +6 -6
- package/build-module/text/hook.js.map +1 -1
- package/build-module/text/styles.js +7 -7
- package/build-module/text/styles.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js +1 -2
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
- package/build-module/tooltip/index.js +1 -2
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tree-select/index.js +10 -2
- package/build-module/tree-select/index.js.map +1 -1
- package/build-module/tree-select/types.js.map +1 -1
- package/build-style/style-rtl.css +60 -13
- package/build-style/style.css +60 -13
- package/build-types/alignment-matrix-control/stories/index.story.d.ts +1 -1
- package/build-types/alignment-matrix-control/stories/index.story.d.ts.map +1 -1
- package/build-types/angle-picker-control/stories/index.story.d.ts +1 -1
- package/build-types/animate/stories/index.story.d.ts +7 -7
- package/build-types/animate/stories/index.story.d.ts.map +1 -1
- package/build-types/badge/index.d.ts +8 -0
- package/build-types/badge/index.d.ts.map +1 -0
- package/build-types/badge/stories/index.story.d.ts +17 -0
- package/build-types/badge/stories/index.story.d.ts.map +1 -0
- package/build-types/badge/test/index.d.ts +2 -0
- package/build-types/badge/test/index.d.ts.map +1 -0
- package/build-types/badge/types.d.ts +13 -0
- package/build-types/badge/types.d.ts.map +1 -0
- package/build-types/base-control/stories/index.story.d.ts +1 -1
- package/build-types/border-box-control/stories/index.story.d.ts +1 -1
- package/build-types/border-control/stories/index.story.d.ts +5 -5
- package/build-types/box-control/index.d.ts +1 -1
- package/build-types/box-control/index.d.ts.map +1 -1
- package/build-types/box-control/input-control.d.ts +1 -1
- package/build-types/box-control/input-control.d.ts.map +1 -1
- package/build-types/box-control/stories/index.story.d.ts +356 -11
- package/build-types/box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/box-control/styles/box-control-styles.d.ts +2 -2
- package/build-types/box-control/types.d.ts +17 -0
- package/build-types/box-control/types.d.ts.map +1 -1
- package/build-types/box-control/utils.d.ts +27 -1
- package/build-types/box-control/utils.d.ts.map +1 -1
- package/build-types/button/stories/e2e/index.story.d.ts +1 -1
- package/build-types/button/stories/e2e/index.story.d.ts.map +1 -1
- package/build-types/button/stories/index.story.d.ts +7 -7
- package/build-types/button/stories/index.story.d.ts.map +1 -1
- package/build-types/button-group/index.d.ts +3 -1
- package/build-types/button-group/index.d.ts.map +1 -1
- package/build-types/button-group/stories/index.story.d.ts +6 -0
- package/build-types/button-group/stories/index.story.d.ts.map +1 -1
- package/build-types/button-group/types.d.ts +7 -0
- package/build-types/button-group/types.d.ts.map +1 -1
- package/build-types/circular-option-picker/stories/index.story.d.ts +5 -5
- package/build-types/circular-option-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.story.d.ts +3 -3
- package/build-types/color-palette/stories/index.story.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +2 -2
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/combobox-control/stories/index.story.d.ts +4 -4
- package/build-types/confirm-dialog/stories/index.story.d.ts +2 -2
- package/build-types/confirm-dialog/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/stories/index.story.d.ts +1 -1
- package/build-types/custom-gradient-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-select-control/stories/index.story.d.ts +3 -3
- package/build-types/custom-select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/custom-select.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/stories/index.story.d.ts +3 -3
- package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -1
- package/build-types/date-time/date/index.d.ts.map +1 -1
- package/build-types/date-time/stories/time.story.d.ts +1 -1
- package/build-types/date-time/stories/time.story.d.ts.map +1 -1
- package/build-types/date-time/time/styles.d.ts +4 -4
- package/build-types/dimension-control/index.d.ts.map +1 -1
- package/build-types/dimension-control/stories/index.story.d.ts +1 -1
- package/build-types/disabled/stories/index.story.d.ts.map +1 -1
- package/build-types/drop-zone/stories/index.story.d.ts +1 -1
- package/build-types/drop-zone/stories/index.story.d.ts.map +1 -1
- package/build-types/duotone-picker/stories/duotone-picker.story.d.ts +1 -1
- package/build-types/duotone-picker/stories/duotone-picker.story.d.ts.map +1 -1
- package/build-types/duotone-picker/stories/duotone-swatch.story.d.ts +3 -3
- package/build-types/duotone-picker/stories/duotone-swatch.story.d.ts.map +1 -1
- package/build-types/focal-point-picker/stories/index.story.d.ts +4 -4
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
- package/build-types/font-size-picker/styles.d.ts.map +1 -1
- package/build-types/form-file-upload/stories/index.story.d.ts +5 -5
- package/build-types/form-file-upload/stories/index.story.d.ts.map +1 -1
- package/build-types/gradient-picker/stories/index.story.d.ts +3 -3
- package/build-types/gradient-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/guide/stories/index.story.d.ts +1 -1
- package/build-types/guide/stories/index.story.d.ts.map +1 -1
- package/build-types/icon/stories/index.story.d.ts +4 -4
- package/build-types/icon/stories/index.story.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts +1 -0
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/stories/index.story.d.ts +7 -7
- package/build-types/input-control/stories/index.story.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +11 -2
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/keyboard-shortcuts/stories/index.story.d.ts +1 -1
- package/build-types/keyboard-shortcuts/stories/index.story.d.ts.map +1 -1
- package/build-types/menu/checkbox-item.d.ts.map +1 -1
- package/build-types/menu/index.d.ts +10 -1
- package/build-types/menu/index.d.ts.map +1 -1
- package/build-types/menu/item.d.ts.map +1 -1
- package/build-types/menu/popover.d.ts +3 -0
- package/build-types/menu/popover.d.ts.map +1 -0
- package/build-types/menu/radio-item.d.ts.map +1 -1
- package/build-types/menu/stories/index.story.d.ts +9 -9
- package/build-types/menu/stories/index.story.d.ts.map +1 -1
- package/build-types/menu/submenu-trigger-item.d.ts +3 -0
- package/build-types/menu/submenu-trigger-item.d.ts.map +1 -0
- package/build-types/menu/trigger-button.d.ts +3 -0
- package/build-types/menu/trigger-button.d.ts.map +1 -0
- package/build-types/menu/types.d.ts +208 -57
- package/build-types/menu/types.d.ts.map +1 -1
- package/build-types/menu-group/stories/index.story.d.ts +1 -1
- package/build-types/menu-group/stories/index.story.d.ts.map +1 -1
- package/build-types/menu-item/stories/index.story.d.ts +4 -4
- package/build-types/modal/stories/index.story.d.ts.map +1 -1
- package/build-types/navigation/back-button/index.d.ts.map +1 -1
- package/build-types/navigation/index.d.ts.map +1 -1
- package/build-types/navigation/item/index.d.ts.map +1 -1
- package/build-types/navigation/stories/index.story.d.ts +6 -6
- package/build-types/navigation/stories/index.story.d.ts.map +1 -1
- package/build-types/notice/stories/index.story.d.ts +4 -4
- package/build-types/notice/stories/index.story.d.ts.map +1 -1
- 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 +2 -2
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/palette-edit/stories/index.story.d.ts +2 -2
- package/build-types/palette-edit/stories/index.story.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/progress-bar/stories/index.story.d.ts +1 -1
- package/build-types/progress-bar/stories/index.story.d.ts.map +1 -1
- package/build-types/query-controls/stories/index.story.d.ts +1 -1
- package/build-types/query-controls/stories/index.story.d.ts.map +1 -1
- package/build-types/radio-group/index.d.ts.map +1 -1
- package/build-types/radio-group/radio.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/resizable-box/stories/index.story.d.ts +2 -2
- package/build-types/responsive-wrapper/stories/index.story.d.ts +1 -1
- package/build-types/responsive-wrapper/stories/index.story.d.ts.map +1 -1
- package/build-types/sandbox/stories/index.story.d.ts +1 -1
- package/build-types/sandbox/stories/index.story.d.ts.map +1 -1
- package/build-types/search-control/stories/index.story.d.ts +1 -1
- package/build-types/search-control/stories/index.story.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts +1 -0
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/stories/index.story.d.ts +5 -5
- package/build-types/select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/select-control/types.d.ts +1 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/shortcut/stories/index.story.d.ts +1 -1
- package/build-types/shortcut/stories/index.story.d.ts.map +1 -1
- package/build-types/slot-fill/context.d.ts.map +1 -1
- package/build-types/slot-fill/fill.d.ts.map +1 -1
- package/build-types/slot-fill/provider.d.ts.map +1 -1
- package/build-types/slot-fill/slot.d.ts.map +1 -1
- package/build-types/slot-fill/types.d.ts +13 -11
- package/build-types/slot-fill/types.d.ts.map +1 -1
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/tab-panel/stories/index.story.d.ts +4 -4
- package/build-types/tab-panel/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/index.d.ts +21 -4
- package/build-types/tabs/index.d.ts.map +1 -1
- package/build-types/tabs/stories/index.story.d.ts +10 -10
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/types.d.ts +13 -13
- package/build-types/tabs/types.d.ts.map +1 -1
- package/build-types/text/stories/index.story.d.ts +3 -3
- package/build-types/theme/stories/index.story.d.ts +1 -1
- package/build-types/toggle-control/stories/index.story.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts.map +1 -1
- package/build-types/toolbar/stories/index.story.d.ts +3 -3
- package/build-types/toolbar/stories/index.story.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/tooltip/stories/index.story.d.ts +1 -1
- package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-grid/stories/index.story.d.ts +1 -1
- package/build-types/tree-grid/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-select/index.d.ts +3 -2
- package/build-types/tree-select/index.d.ts.map +1 -1
- package/build-types/tree-select/stories/index.story.d.ts +1 -1
- package/build-types/tree-select/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-select/types.d.ts +5 -1
- package/build-types/tree-select/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/v-stack/stories/index.story.d.ts +1 -1
- package/package.json +19 -19
- package/src/alignment-matrix-control/README.md +16 -15
- package/src/angle-picker-control/README.md +10 -9
- package/src/badge/README.md +24 -0
- package/src/badge/docs-manifest.json +5 -0
- package/src/badge/index.tsx +67 -0
- package/src/badge/stories/index.story.tsx +54 -0
- package/src/badge/styles.scss +49 -0
- package/src/badge/test/index.tsx +45 -0
- package/src/badge/types.ts +12 -0
- package/src/base-control/README.md +22 -21
- package/src/box-control/README.md +41 -24
- package/src/box-control/index.tsx +4 -0
- package/src/box-control/input-control.tsx +142 -40
- package/src/box-control/stories/index.story.tsx +12 -0
- package/src/box-control/types.ts +18 -0
- package/src/box-control/utils.ts +60 -0
- package/src/button/README.md +51 -50
- package/src/button/style.scss +9 -10
- package/src/button/test/index.tsx +9 -2
- package/src/button-group/README.md +4 -0
- package/src/button-group/index.tsx +11 -1
- package/src/button-group/stories/index.story.tsx +8 -1
- package/src/button-group/types.ts +7 -0
- package/src/custom-select-control/index.tsx +3 -3
- package/src/custom-select-control-v2/custom-select.tsx +1 -2
- package/src/custom-select-control-v2/stories/index.story.tsx +4 -0
- package/src/date-time/date/index.tsx +1 -0
- package/src/dimension-control/index.tsx +1 -0
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -4
- package/src/disabled/stories/index.story.tsx +1 -0
- package/src/drop-zone/stories/index.story.tsx +7 -1
- package/src/font-size-picker/styles.ts +1 -0
- package/src/form-file-upload/README.md +22 -21
- package/src/gradient-picker/README.md +36 -35
- package/src/heading/hook.ts +1 -1
- package/src/heading/test/__snapshots__/index.tsx.snap +4 -4
- package/src/icon/README.md +9 -8
- package/src/input-control/README.md +1 -0
- package/src/input-control/index.tsx +10 -0
- package/src/input-control/stories/index.story.tsx +6 -1
- package/src/input-control/test/index.js +9 -3
- package/src/input-control/types.ts +11 -2
- package/src/menu/checkbox-item.tsx +2 -1
- package/src/menu/index.tsx +61 -165
- package/src/menu/item.tsx +17 -2
- package/src/menu/popover.tsx +103 -0
- package/src/menu/radio-item.tsx +2 -1
- package/src/menu/stories/index.story.tsx +533 -381
- package/src/menu/submenu-trigger-item.tsx +61 -0
- package/src/menu/test/index.tsx +266 -182
- package/src/menu/trigger-button.tsx +46 -0
- package/src/menu/types.ts +210 -63
- package/src/modal/stories/index.story.tsx +4 -1
- package/src/navigation/back-button/index.tsx +1 -0
- package/src/navigation/index.tsx +7 -0
- package/src/navigation/item/index.tsx +2 -0
- package/src/navigation/test/index.tsx +4 -0
- package/src/navigator/test/index.tsx +4 -0
- package/src/number-control/index.tsx +1 -0
- package/src/palette-edit/index.tsx +1 -0
- package/src/panel/stories/index.story.tsx +3 -3
- package/src/private-apis.ts +2 -0
- package/src/radio-group/index.tsx +12 -1
- package/src/radio-group/radio.tsx +1 -2
- package/src/range-control/styles/range-control-styles.ts +8 -4
- package/src/select-control/README.md +3 -0
- package/src/select-control/index.tsx +10 -0
- package/src/select-control/stories/index.story.tsx +2 -0
- package/src/select-control/test/select-control.tsx +7 -1
- package/src/select-control/types.ts +1 -0
- package/src/slot-fill/context.ts +5 -3
- package/src/slot-fill/fill.ts +10 -15
- package/src/slot-fill/provider.tsx +63 -64
- package/src/slot-fill/slot.tsx +40 -27
- package/src/slot-fill/types.ts +23 -11
- package/src/style.scss +1 -0
- package/src/tab-panel/index.tsx +1 -2
- package/src/tab-panel/stories/index.story.tsx +4 -0
- package/src/tabs/README.md +151 -187
- package/src/tabs/docs-manifest.json +22 -0
- package/src/tabs/index.tsx +21 -4
- package/src/tabs/stories/best-practices.mdx +99 -0
- package/src/tabs/stories/index.story.tsx +5 -0
- package/src/tabs/types.ts +13 -14
- package/src/text/hook.ts +2 -2
- package/src/text/styles.ts +1 -1
- package/src/text/test/__snapshots__/index.tsx.snap +3 -3
- package/src/text/test/index.tsx +1 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +2 -2
- package/src/toggle-group-control/test/index.tsx +7 -1
- package/src/toggle-group-control/toggle-group-control/as-radio-group.tsx +1 -2
- package/src/tooltip/index.tsx +1 -2
- package/src/tree-grid/stories/index.story.tsx +2 -0
- package/src/tree-select/README.md +144 -28
- package/src/tree-select/docs-manifest.json +5 -0
- package/src/tree-select/index.tsx +11 -2
- package/src/tree-select/stories/index.story.tsx +1 -0
- package/src/tree-select/types.ts +8 -1
- package/tsconfig.json +0 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/build/slot-fill/use-slot.js +0 -32
- package/build/slot-fill/use-slot.js.map +0 -1
- package/build-module/slot-fill/use-slot.js +0 -24
- package/build-module/slot-fill/use-slot.js.map +0 -1
- package/build-types/slot-fill/use-slot.d.ts +0 -10
- package/build-types/slot-fill/use-slot.d.ts.map +0 -1
- package/src/slot-fill/use-slot.ts +0 -27
package/src/tabs/README.md
CHANGED
|
@@ -1,254 +1,218 @@
|
|
|
1
1
|
# Tabs
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
|
|
5
|
-
</div>
|
|
6
|
-
|
|
7
|
-
Tabs is a collection of React components that combine to render an [ARIA-compliant tabs pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/).
|
|
8
|
-
|
|
9
|
-
Tabs organizes content across different screens, data sets, and interactions. It has two sections: a list of tabs, and the view to show when tabs are chosen.
|
|
10
|
-
|
|
11
|
-
## Development guidelines
|
|
12
|
-
|
|
13
|
-
### Usage
|
|
14
|
-
|
|
15
|
-
#### Uncontrolled Mode
|
|
16
|
-
|
|
17
|
-
Tabs can be used in an uncontrolled mode, where the component manages its own state. In this mode, the `defaultTabId` prop can be used to set the initially selected tab. If this prop is not set, the first tab will be selected by default. In addition, in most cases where the currently active tab becomes disabled or otherwise unavailable, uncontrolled mode will automatically fall back to selecting the first available tab.
|
|
18
|
-
|
|
19
|
-
```jsx
|
|
20
|
-
import { Tabs } from '@wordpress/components';
|
|
21
|
-
|
|
22
|
-
const onSelect = ( tabName ) => {
|
|
23
|
-
console.log( 'Selecting tab', tabName );
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const MyUncontrolledTabs = () => (
|
|
27
|
-
<Tabs onSelect={ onSelect } defaultTabId="tab2">
|
|
28
|
-
<Tabs.TabList>
|
|
29
|
-
<Tabs.Tab tabId="tab1" title="Tab 1">
|
|
30
|
-
Tab 1
|
|
31
|
-
</Tabs.Tab>
|
|
32
|
-
<Tabs.Tab tabId="tab2" title="Tab 2">
|
|
33
|
-
Tab 2
|
|
34
|
-
</Tabs.Tab>
|
|
35
|
-
<Tabs.Tab tabId="tab3" title="Tab 3">
|
|
36
|
-
Tab 3
|
|
37
|
-
</Tabs.Tab>
|
|
38
|
-
</Tabs.TabList>
|
|
39
|
-
<Tabs.TabPanel tabId="tab1">
|
|
40
|
-
<p>Selected tab: Tab 1</p>
|
|
41
|
-
</Tabs.TabPanel>
|
|
42
|
-
<Tabs.TabPanel tabId="tab2">
|
|
43
|
-
<p>Selected tab: Tab 2</p>
|
|
44
|
-
</Tabs.TabPanel>
|
|
45
|
-
<Tabs.TabPanel tabId="tab3">
|
|
46
|
-
<p>Selected tab: Tab 3</p>
|
|
47
|
-
</Tabs.TabPanel>
|
|
48
|
-
</Tabs>
|
|
49
|
-
);
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
#### Controlled Mode
|
|
53
|
-
|
|
54
|
-
Tabs can also be used in a controlled mode, where the parent component specifies the `selectedTabId` and the `onSelect` props to control tab selection. In this mode, the `defaultTabId` prop will be ignored if it is provided. If the `selectedTabId` is `null`, no tab is selected. In this mode, if the currently selected tab becomes disabled or otherwise unavailable, the component will _not_ fall back to another available tab, leaving the controlling component in charge of implementing the desired logic.
|
|
55
|
-
|
|
56
|
-
```jsx
|
|
57
|
-
import { Tabs } from '@wordpress/components';
|
|
58
|
-
const [ selectedTabId, setSelectedTabId ] = useState<
|
|
59
|
-
string | undefined | null
|
|
60
|
-
>();
|
|
61
|
-
|
|
62
|
-
const onSelect = ( tabName ) => {
|
|
63
|
-
console.log( 'Selecting tab', tabName );
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const MyControlledTabs = () => (
|
|
67
|
-
<Tabs
|
|
68
|
-
selectedTabId={ selectedTabId }
|
|
69
|
-
onSelect={ ( selectedId ) => {
|
|
70
|
-
setSelectedTabId( selectedId );
|
|
71
|
-
onSelect( selectedId );
|
|
72
|
-
} }
|
|
73
|
-
>
|
|
74
|
-
<Tabs.TabList>
|
|
75
|
-
<Tabs.Tab tabId="tab1" title="Tab 1">
|
|
76
|
-
Tab 1
|
|
77
|
-
</Tabs.Tab>
|
|
78
|
-
<Tabs.Tab tabId="tab2" title="Tab 2">
|
|
79
|
-
Tab 2
|
|
80
|
-
</Tabs.Tab>
|
|
81
|
-
<Tabs.Tab tabId="tab3" title="Tab 3">
|
|
82
|
-
Tab 3
|
|
83
|
-
</Tabs.Tab>
|
|
84
|
-
</Tabs.TabList>
|
|
85
|
-
<Tabs.TabPanel tabId="tab1">
|
|
86
|
-
<p>Selected tab: Tab 1</p>
|
|
87
|
-
</Tabs.TabPanel>
|
|
88
|
-
<Tabs.TabPanel tabId="tab2">
|
|
89
|
-
<p>Selected tab: Tab 2</p>
|
|
90
|
-
</Tabs.TabPanel>
|
|
91
|
-
<Tabs.TabPanel tabId="tab3">
|
|
92
|
-
<p>Selected tab: Tab 3</p>
|
|
93
|
-
</Tabs.TabPanel>
|
|
94
|
-
</Tabs>
|
|
95
|
-
);
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### Components and Sub-components
|
|
99
|
-
|
|
100
|
-
Tabs is comprised of four individual components:
|
|
101
|
-
- `Tabs`: a wrapper component and context provider. It is responsible for managing the state of the tabs and rendering the `TabList` and `TabPanels`.
|
|
102
|
-
- `TabList`: a wrapper component for the `Tab` components. It is responsible for rendering the list of tabs.
|
|
103
|
-
- `Tab`: renders a single tab. The currently active tab receives default styling that can be overridden with CSS targeting [aria-selected="true"].
|
|
104
|
-
- `TabPanel`: renders the content to display for a single tab once that tab is selected.
|
|
105
|
-
|
|
106
|
-
#### Tabs
|
|
107
|
-
|
|
108
|
-
##### Props
|
|
109
|
-
|
|
110
|
-
###### `children`: `React.ReactNode`
|
|
111
|
-
|
|
112
|
-
The children elements, which should include one instance of the `Tabs.Tablist` component and as many instances of the `Tabs.TabPanel` components as there are `Tabs.Tab` components.
|
|
113
|
-
|
|
114
|
-
- Required: Yes
|
|
115
|
-
|
|
116
|
-
###### `selectOnMove`: `boolean`
|
|
117
|
-
|
|
118
|
-
Determines if the tab should be selected when it receives focus. If set to `false`, the tab will only be selected upon clicking, not when using arrow keys to shift focus (manual tab activation). See the [official W3C docs](https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/) for more info.
|
|
119
|
-
|
|
120
|
-
- Required: No
|
|
121
|
-
- Default: `true`
|
|
122
|
-
|
|
123
|
-
###### `selectedTabId`: `string | null`
|
|
3
|
+
<!-- This file is generated automatically and cannot be edited directly. Make edits via TypeScript types and TSDocs. -->
|
|
124
4
|
|
|
125
|
-
|
|
5
|
+
🔒 This component is locked as a [private API](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-private-apis/). We do not yet recommend using this outside of the Gutenberg project.
|
|
126
6
|
|
|
127
|
-
|
|
7
|
+
<p class="callout callout-info">See the <a href="https://wordpress.github.io/gutenberg/?path=/docs/components-tabs--docs">WordPress Storybook</a> for more detailed, interactive documentation.</p>
|
|
128
8
|
|
|
129
|
-
|
|
9
|
+
Tabs is a collection of React components that combine to render
|
|
10
|
+
an [ARIA-compliant tabs pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/).
|
|
130
11
|
|
|
131
|
-
|
|
12
|
+
Tabs organizes content across different screens, data sets, and interactions.
|
|
13
|
+
It has two sections: a list of tabs, and the view to show when a tab is chosen.
|
|
132
14
|
|
|
133
|
-
|
|
15
|
+
`Tabs` itself is a wrapper component and context provider.
|
|
16
|
+
It is responsible for managing the state of the tabs, and rendering one instance of the `Tabs.TabList` component and one or more instances of the `Tab.TabPanel` component.
|
|
134
17
|
|
|
135
|
-
|
|
18
|
+
## Props
|
|
136
19
|
|
|
137
|
-
|
|
20
|
+
### `activeTabId`
|
|
138
21
|
|
|
139
|
-
|
|
22
|
+
- Type: `string`
|
|
23
|
+
- Required: No
|
|
140
24
|
|
|
141
|
-
|
|
25
|
+
The current active tab `id`. The active tab is the tab element within the
|
|
26
|
+
tablist widget that has DOM focus.
|
|
142
27
|
|
|
143
|
-
|
|
28
|
+
- `null` represents the tablist (ie. the base composite element). Users
|
|
29
|
+
will be able to navigate out of it using arrow keys.
|
|
30
|
+
- If `activeTabId` is initially set to `null`, the base composite element
|
|
31
|
+
itself will have focus and users will be able to navigate to it using
|
|
32
|
+
arrow keys.
|
|
144
33
|
|
|
145
|
-
|
|
34
|
+
### `children`
|
|
146
35
|
|
|
147
|
-
-
|
|
148
|
-
-
|
|
36
|
+
- Type: `ReactNode`
|
|
37
|
+
- Required: Yes
|
|
149
38
|
|
|
150
|
-
|
|
39
|
+
The children elements, which should include one instance of the
|
|
40
|
+
`Tabs.Tablist` component and as many instances of the `Tabs.TabPanel`
|
|
41
|
+
components as there are `Tabs.Tab` components.
|
|
151
42
|
|
|
152
|
-
|
|
43
|
+
### `defaultTabId`
|
|
153
44
|
|
|
154
|
-
- `
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
arrow keys.
|
|
45
|
+
- Type: `string`
|
|
46
|
+
- Required: No
|
|
47
|
+
|
|
48
|
+
The id of the tab whose panel is currently visible.
|
|
159
49
|
|
|
160
|
-
|
|
50
|
+
If left `undefined`, it will be automatically set to the first enabled
|
|
51
|
+
tab. If set to `null`, no tab will be selected, and the tablist will be
|
|
52
|
+
tabbable.
|
|
161
53
|
|
|
162
|
-
|
|
54
|
+
Note: this prop will be overridden by the `selectedTabId` prop if it is
|
|
55
|
+
provided (meaning the component will be used in "controlled" mode).
|
|
163
56
|
|
|
164
|
-
|
|
57
|
+
### `defaultActiveTabId`
|
|
165
58
|
|
|
166
|
-
|
|
59
|
+
- Type: `string`
|
|
60
|
+
- Required: No
|
|
167
61
|
|
|
168
|
-
|
|
62
|
+
The tab id that should be active by default when the composite widget is
|
|
63
|
+
rendered. If `null`, the tablist element itself will have focus
|
|
64
|
+
and users will be able to navigate to it using arrow keys. If `undefined`,
|
|
65
|
+
the first enabled item will be focused.
|
|
169
66
|
|
|
170
|
-
|
|
67
|
+
Note: this prop will be overridden by the `activeTabId` prop if it is
|
|
68
|
+
provided.
|
|
69
|
+
|
|
70
|
+
### `onSelect`
|
|
71
|
+
|
|
72
|
+
- Type: `(selectedId: string) => void`
|
|
73
|
+
- Required: No
|
|
171
74
|
|
|
172
75
|
The function called when the `selectedTabId` changes.
|
|
173
76
|
|
|
174
|
-
|
|
175
|
-
|
|
77
|
+
### `onActiveTabIdChange`
|
|
78
|
+
|
|
79
|
+
- Type: `(activeId: string) => void`
|
|
80
|
+
- Required: No
|
|
81
|
+
|
|
82
|
+
A callback that gets called when the `activeTabId` state changes.
|
|
176
83
|
|
|
177
|
-
|
|
84
|
+
### `orientation`
|
|
178
85
|
|
|
179
|
-
|
|
86
|
+
- Type: `"horizontal" | "vertical" | "both"`
|
|
87
|
+
- Required: No
|
|
88
|
+
- Default: `"horizontal"`
|
|
180
89
|
|
|
181
|
-
|
|
182
|
-
|
|
90
|
+
Defines the orientation of the tablist and determines which arrow keys
|
|
91
|
+
can be used to move focus:
|
|
92
|
+
|
|
93
|
+
- `both`: all arrow keys work.
|
|
94
|
+
- `horizontal`: only left and right arrow keys work.
|
|
183
95
|
- `vertical`: only up and down arrow keys work.
|
|
184
96
|
|
|
185
|
-
|
|
186
|
-
|
|
97
|
+
### `selectOnMove`
|
|
98
|
+
|
|
99
|
+
- Type: `boolean`
|
|
100
|
+
- Required: No
|
|
101
|
+
- Default: `true`
|
|
102
|
+
|
|
103
|
+
Determines if the tab should be selected when it receives focus. If set to
|
|
104
|
+
`false`, the tab will only be selected upon clicking, not when using arrow
|
|
105
|
+
keys to shift focus (manual tab activation). See the [official W3C docs](https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/)
|
|
106
|
+
for more info.
|
|
107
|
+
|
|
108
|
+
### `selectedTabId`
|
|
109
|
+
|
|
110
|
+
- Type: `string`
|
|
111
|
+
- Required: No
|
|
112
|
+
|
|
113
|
+
The id of the tab whose panel is currently visible.
|
|
114
|
+
|
|
115
|
+
If left `undefined`, it will be automatically set to the first enabled
|
|
116
|
+
tab, and the component assumes it is being used in "uncontrolled" mode.
|
|
187
117
|
|
|
188
|
-
|
|
118
|
+
Consequently, any value different than `undefined` will set the component
|
|
119
|
+
in "controlled" mode. When in "controlled" mode, the `null` value will
|
|
120
|
+
result in no tabs being selected, and the tablist becoming tabbable.
|
|
189
121
|
|
|
190
|
-
|
|
122
|
+
## Subcomponents
|
|
191
123
|
|
|
192
|
-
|
|
124
|
+
### Tabs.TabList
|
|
193
125
|
|
|
194
|
-
|
|
126
|
+
A wrapper component for the `Tab` components.
|
|
195
127
|
|
|
196
|
-
|
|
128
|
+
It is responsible for rendering the list of tabs.
|
|
197
129
|
|
|
198
|
-
####
|
|
130
|
+
#### Props
|
|
199
131
|
|
|
200
|
-
#####
|
|
132
|
+
##### `children`
|
|
201
133
|
|
|
202
|
-
|
|
134
|
+
- Type: `ReactNode`
|
|
135
|
+
- Required: Yes
|
|
203
136
|
|
|
204
|
-
The
|
|
137
|
+
The children elements, which should include one or more instances of the
|
|
138
|
+
`Tabs.Tab` component.
|
|
205
139
|
|
|
206
|
-
|
|
140
|
+
### Tabs.Tab
|
|
207
141
|
|
|
208
|
-
|
|
142
|
+
Renders a single tab.
|
|
143
|
+
|
|
144
|
+
The currently active tab receives default styling that can be
|
|
145
|
+
overridden with CSS targeting `[aria-selected="true"]`.
|
|
146
|
+
|
|
147
|
+
#### Props
|
|
148
|
+
|
|
149
|
+
##### `children`
|
|
150
|
+
|
|
151
|
+
- Type: `ReactNode`
|
|
152
|
+
- Required: No
|
|
209
153
|
|
|
210
154
|
The contents of the tab.
|
|
211
155
|
|
|
212
|
-
|
|
156
|
+
##### `disabled`
|
|
213
157
|
|
|
214
|
-
|
|
158
|
+
- Type: `boolean`
|
|
159
|
+
- Required: No
|
|
160
|
+
- Default: `false`
|
|
215
161
|
|
|
216
|
-
Determines if the tab should be disabled. Note that disabled tabs can
|
|
162
|
+
Determines if the tab should be disabled. Note that disabled tabs can
|
|
163
|
+
still be accessed via the keyboard when navigating through the tablist.
|
|
217
164
|
|
|
218
|
-
|
|
219
|
-
- Default: `false`
|
|
165
|
+
##### `render`
|
|
220
166
|
|
|
221
|
-
|
|
167
|
+
- Type: `RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }> | ReactElement<any, string | JSXElementConstructor<any>>`
|
|
168
|
+
- Required: No
|
|
222
169
|
|
|
223
|
-
Allows the component to be rendered as a different HTML element or React
|
|
170
|
+
Allows the component to be rendered as a different HTML element or React
|
|
171
|
+
component. The value can be a React element or a function that takes in the
|
|
172
|
+
original component props and gives back a React element with the props
|
|
173
|
+
merged.
|
|
224
174
|
|
|
225
175
|
By default, the tab will be rendered as a `button` element.
|
|
226
176
|
|
|
227
|
-
|
|
177
|
+
##### `tabId`
|
|
228
178
|
|
|
229
|
-
|
|
179
|
+
- Type: `string`
|
|
180
|
+
- Required: Yes
|
|
230
181
|
|
|
231
|
-
|
|
182
|
+
The unique ID of the tab. It will be used to register the tab and match
|
|
183
|
+
it to a corresponding `Tabs.TabPanel` component.
|
|
232
184
|
|
|
233
|
-
|
|
185
|
+
### Tabs.TabPanel
|
|
234
186
|
|
|
235
|
-
|
|
187
|
+
Renders the content to display for a single tab once that tab is selected.
|
|
236
188
|
|
|
237
|
-
|
|
189
|
+
#### Props
|
|
238
190
|
|
|
239
|
-
|
|
191
|
+
##### `children`
|
|
240
192
|
|
|
241
|
-
|
|
193
|
+
- Type: `ReactNode`
|
|
194
|
+
- Required: No
|
|
242
195
|
|
|
243
|
-
|
|
196
|
+
The contents of the tab panel.
|
|
244
197
|
|
|
245
|
-
|
|
198
|
+
##### `focusable`
|
|
246
199
|
|
|
247
|
-
|
|
200
|
+
- Type: `boolean`
|
|
201
|
+
- Required: No
|
|
202
|
+
- Default: `true`
|
|
248
203
|
|
|
249
204
|
Determines whether or not the tabpanel element should be focusable.
|
|
205
|
+
If `false`, pressing the tab key will skip over the tabpanel, and instead
|
|
206
|
+
focus on the first focusable element in the panel (if there is one).
|
|
207
|
+
|
|
208
|
+
##### `tabId`
|
|
209
|
+
|
|
210
|
+
- Type: `string`
|
|
211
|
+
- Required: Yes
|
|
250
212
|
|
|
251
|
-
|
|
213
|
+
The unique `id` of the `Tabs.Tab` component controlling this panel. This
|
|
214
|
+
connection is used to assign the `aria-labelledby` attribute to the tab
|
|
215
|
+
panel and to determine if the tab panel should be visible.
|
|
252
216
|
|
|
253
|
-
|
|
254
|
-
|
|
217
|
+
If not provided, this link is automatically established by matching the
|
|
218
|
+
order of `Tabs.Tab` and `Tabs.TabPanel` elements in the DOM.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../schemas/docs-manifest.json",
|
|
3
|
+
"displayName": "Tabs",
|
|
4
|
+
"filePath": "./index.tsx",
|
|
5
|
+
"subcomponents": [
|
|
6
|
+
{
|
|
7
|
+
"displayName": "TabList",
|
|
8
|
+
"preferredDisplayName": "Tabs.TabList",
|
|
9
|
+
"filePath": "./tablist.tsx"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"displayName": "Tab",
|
|
13
|
+
"preferredDisplayName": "Tabs.Tab",
|
|
14
|
+
"filePath": "./tab.tsx"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"displayName": "TabPanel",
|
|
18
|
+
"preferredDisplayName": "Tabs.TabPanel",
|
|
19
|
+
"filePath": "./tabpanel.tsx"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
package/src/tabs/index.tsx
CHANGED
|
@@ -36,11 +36,14 @@ function internalToExternalTabId(
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* Tabs is a collection of React components that combine to render
|
|
40
|
+
* an [ARIA-compliant tabs pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/).
|
|
41
41
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* Tabs organizes content across different screens, data sets, and interactions.
|
|
43
|
+
* It has two sections: a list of tabs, and the view to show when a tab is chosen.
|
|
44
|
+
*
|
|
45
|
+
* `Tabs` itself is a wrapper component and context provider.
|
|
46
|
+
* It is responsible for managing the state of the tabs, and rendering one instance of the `Tabs.TabList` component and one or more instances of the `Tab.TabPanel` component.
|
|
44
47
|
*/
|
|
45
48
|
export const Tabs = Object.assign(
|
|
46
49
|
function Tabs( {
|
|
@@ -121,12 +124,26 @@ export const Tabs = Object.assign(
|
|
|
121
124
|
);
|
|
122
125
|
},
|
|
123
126
|
{
|
|
127
|
+
/**
|
|
128
|
+
* Renders a single tab.
|
|
129
|
+
*
|
|
130
|
+
* The currently active tab receives default styling that can be
|
|
131
|
+
* overridden with CSS targeting `[aria-selected="true"]`.
|
|
132
|
+
*/
|
|
124
133
|
Tab: Object.assign( Tab, {
|
|
125
134
|
displayName: 'Tabs.Tab',
|
|
126
135
|
} ),
|
|
136
|
+
/**
|
|
137
|
+
* A wrapper component for the `Tab` components.
|
|
138
|
+
*
|
|
139
|
+
* It is responsible for rendering the list of tabs.
|
|
140
|
+
*/
|
|
127
141
|
TabList: Object.assign( TabList, {
|
|
128
142
|
displayName: 'Tabs.TabList',
|
|
129
143
|
} ),
|
|
144
|
+
/**
|
|
145
|
+
* Renders the content to display for a single tab once that tab is selected.
|
|
146
|
+
*/
|
|
130
147
|
TabPanel: Object.assign( TabPanel, {
|
|
131
148
|
displayName: 'Tabs.TabPanel',
|
|
132
149
|
} ),
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Meta } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import * as TabsStories from './index.story';
|
|
4
|
+
|
|
5
|
+
<Meta of={ TabsStories } name="Best Practices" />
|
|
6
|
+
|
|
7
|
+
# Tabs
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
### Uncontrolled Mode
|
|
12
|
+
|
|
13
|
+
Tabs can be used in an uncontrolled mode, where the component manages its own state. In this mode, the `defaultTabId` prop can be used to set the initially selected tab. If this prop is not set, the first tab will be selected by default. In addition, in most cases where the currently active tab becomes disabled or otherwise unavailable, uncontrolled mode will automatically fall back to selecting the first available tab.
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
import { Tabs } from '@wordpress/components';
|
|
17
|
+
|
|
18
|
+
const onSelect = ( tabName ) => {
|
|
19
|
+
console.log( 'Selecting tab', tabName );
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const MyUncontrolledTabs = () => (
|
|
23
|
+
<Tabs onSelect={ onSelect } defaultTabId="tab2">
|
|
24
|
+
<Tabs.TabList>
|
|
25
|
+
<Tabs.Tab tabId="tab1" title="Tab 1">
|
|
26
|
+
Tab 1
|
|
27
|
+
</Tabs.Tab>
|
|
28
|
+
<Tabs.Tab tabId="tab2" title="Tab 2">
|
|
29
|
+
Tab 2
|
|
30
|
+
</Tabs.Tab>
|
|
31
|
+
<Tabs.Tab tabId="tab3" title="Tab 3">
|
|
32
|
+
Tab 3
|
|
33
|
+
</Tabs.Tab>
|
|
34
|
+
</Tabs.TabList>
|
|
35
|
+
<Tabs.TabPanel tabId="tab1">
|
|
36
|
+
<p>Selected tab: Tab 1</p>
|
|
37
|
+
</Tabs.TabPanel>
|
|
38
|
+
<Tabs.TabPanel tabId="tab2">
|
|
39
|
+
<p>Selected tab: Tab 2</p>
|
|
40
|
+
</Tabs.TabPanel>
|
|
41
|
+
<Tabs.TabPanel tabId="tab3">
|
|
42
|
+
<p>Selected tab: Tab 3</p>
|
|
43
|
+
</Tabs.TabPanel>
|
|
44
|
+
</Tabs>
|
|
45
|
+
);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Controlled Mode
|
|
49
|
+
|
|
50
|
+
Tabs can also be used in a controlled mode, where the parent component specifies the `selectedTabId` and the `onSelect` props to control tab selection. In this mode, the `defaultTabId` prop will be ignored if it is provided. If the `selectedTabId` is `null`, no tab is selected. In this mode, if the currently selected tab becomes disabled or otherwise unavailable, the component will _not_ fall back to another available tab, leaving the controlling component in charge of implementing the desired logic.
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { Tabs } from '@wordpress/components';
|
|
54
|
+
|
|
55
|
+
const [ selectedTabId, setSelectedTabId ] = useState<
|
|
56
|
+
string | undefined | null
|
|
57
|
+
>();
|
|
58
|
+
|
|
59
|
+
const onSelect = ( tabName ) => {
|
|
60
|
+
console.log( 'Selecting tab', tabName );
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const MyControlledTabs = () => (
|
|
64
|
+
<Tabs
|
|
65
|
+
selectedTabId={ selectedTabId }
|
|
66
|
+
onSelect={ ( selectedId ) => {
|
|
67
|
+
setSelectedTabId( selectedId );
|
|
68
|
+
onSelect( selectedId );
|
|
69
|
+
} }
|
|
70
|
+
>
|
|
71
|
+
<Tabs.TabList>
|
|
72
|
+
<Tabs.Tab tabId="tab1" title="Tab 1">
|
|
73
|
+
Tab 1
|
|
74
|
+
</Tabs.Tab>
|
|
75
|
+
<Tabs.Tab tabId="tab2" title="Tab 2">
|
|
76
|
+
Tab 2
|
|
77
|
+
</Tabs.Tab>
|
|
78
|
+
<Tabs.Tab tabId="tab3" title="Tab 3">
|
|
79
|
+
Tab 3
|
|
80
|
+
</Tabs.Tab>
|
|
81
|
+
</Tabs.TabList>
|
|
82
|
+
<Tabs.TabPanel tabId="tab1">
|
|
83
|
+
<p>Selected tab: Tab 1</p>
|
|
84
|
+
</Tabs.TabPanel>
|
|
85
|
+
<Tabs.TabPanel tabId="tab2">
|
|
86
|
+
<p>Selected tab: Tab 2</p>
|
|
87
|
+
</Tabs.TabPanel>
|
|
88
|
+
<Tabs.TabPanel tabId="tab3">
|
|
89
|
+
<p>Selected tab: Tab 3</p>
|
|
90
|
+
</Tabs.TabPanel>
|
|
91
|
+
</Tabs>
|
|
92
|
+
);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Using `Tabs` with links
|
|
96
|
+
|
|
97
|
+
The semantics implemented by the `Tabs` component don't align well with the semantics needed by a list of links. Furthermore, end users usually expect every link to be tabbable, while `Tabs.Tablist` is a [composite](https://w3c.github.io/aria/#composite) widget acting as a single tab stop.
|
|
98
|
+
|
|
99
|
+
For these reasons, even if the `Tabs` component is fully extensible, we don't recommend using `Tabs` with links, and we don't currently provide any related Storybook example.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { Meta, StoryFn } from '@storybook/react';
|
|
5
|
+
import { fn } from '@storybook/test';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* WordPress dependencies
|
|
@@ -39,6 +40,10 @@ const meta: Meta< typeof Tabs > = {
|
|
|
39
40
|
controls: { expanded: true },
|
|
40
41
|
docs: { canvas: { sourceState: 'shown' } },
|
|
41
42
|
},
|
|
43
|
+
args: {
|
|
44
|
+
onActiveTabIdChange: fn(),
|
|
45
|
+
onSelect: fn(),
|
|
46
|
+
},
|
|
42
47
|
};
|
|
43
48
|
export default meta;
|
|
44
49
|
|