@wordpress/components 28.10.0 → 28.11.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 +35 -0
- package/build/autocomplete/autocompleter-ui.js +2 -6
- package/build/autocomplete/autocompleter-ui.js.map +1 -1
- package/build/autocomplete/autocompleter-ui.native.js +2 -4
- package/build/autocomplete/autocompleter-ui.native.js.map +1 -1
- package/build/autocomplete/index.js +4 -5
- package/build/autocomplete/index.js.map +1 -1
- package/build/base-control/types.js.map +1 -1
- package/build/border-box-control/border-box-control/component.js +1 -0
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control/hook.js +6 -0
- package/build/border-box-control/border-box-control/hook.js.map +1 -1
- package/build/border-control/border-control/component.js +1 -0
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/border-control/hook.js +6 -0
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +12 -12
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/color-palette/index.js +1 -1
- package/build/color-palette/index.js.map +1 -1
- package/build/color-palette/index.native.js +1 -2
- package/build/color-palette/index.native.js.map +1 -1
- package/build/color-picker/index.native.js +0 -1
- package/build/color-picker/index.native.js.map +1 -1
- package/build/composite/legacy/index.js +5 -2
- package/build/composite/legacy/index.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/control-points.js +1 -1
- package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build/date-time/date/index.js +0 -1
- package/build/date-time/date/index.js.map +1 -1
- package/build/font-size-picker/index.native.js +6 -6
- package/build/font-size-picker/index.native.js.map +1 -1
- package/build/form-token-field/index.js +0 -3
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/suggestions-list.js +7 -3
- package/build/form-token-field/suggestions-list.js.map +1 -1
- package/build/{dropdown-menu-v2 → menu}/checkbox-item.js +8 -8
- package/build/menu/checkbox-item.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/context.js +2 -2
- package/build/menu/context.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/group-label.js +5 -5
- package/build/menu/group-label.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/group.js +5 -5
- package/build/menu/group.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/index.js +38 -38
- package/build/menu/index.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/item-help-text.js +3 -3
- package/build/menu/item-help-text.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/item-label.js +3 -3
- package/build/menu/item-label.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/item.js +7 -7
- package/build/menu/item.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/radio-item.js +8 -8
- package/build/menu/radio-item.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/separator.js +6 -6
- package/build/menu/separator.js.map +1 -0
- package/build/menu/styles.js +150 -0
- package/build/menu/styles.js.map +1 -0
- package/build/menu/types.js.map +1 -0
- package/build/menu/use-temporary-focus-visible-fix.js.map +1 -0
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +3 -5
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build/mobile/bottom-sheet/range-cell.native.js +1 -1
- package/build/mobile/bottom-sheet/range-cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet/stepper-cell/index.native.js +1 -1
- package/build/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet/sub-sheet/index.native.js +1 -3
- package/build/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet-select-control/index.native.js +2 -2
- package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build/mobile/color-settings/index.native.js +1 -3
- package/build/mobile/color-settings/index.native.js.map +1 -1
- package/build/mobile/color-settings/picker-screen.native.js +1 -3
- package/build/mobile/color-settings/picker-screen.native.js.map +1 -1
- package/build/mobile/image/index.native.js +1 -3
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/mobile/keyboard-avoiding-view/index.ios.js +1 -3
- package/build/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
- package/build/mobile/link-picker/link-picker-results.native.js +2 -5
- package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-screen.native.js +1 -3
- package/build/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build/mobile/link-settings/index.native.js +6 -18
- package/build/mobile/link-settings/index.native.js.map +1 -1
- package/build/mobile/link-settings/link-settings-screen.native.js +1 -3
- package/build/mobile/link-settings/link-settings-screen.native.js.map +1 -1
- package/build/mobile/segmented-control/index.native.js +2 -6
- package/build/mobile/segmented-control/index.native.js.map +1 -1
- package/build/mobile/utils/use-unit-converter-to-mobile.native.js +2 -6
- package/build/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
- package/build/navigation/index.js +1 -2
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/item/use-navigation-tree-item.js +2 -2
- package/build/navigation/item/use-navigation-tree-item.js.map +1 -1
- package/build/navigation/menu/menu-title-search.js +2 -2
- package/build/navigation/menu/menu-title-search.js.map +1 -1
- package/build/navigation/menu/use-navigation-tree-menu.js +2 -2
- package/build/navigation/menu/use-navigation-tree-menu.js.map +1 -1
- package/build/palette-edit/index.js +4 -2
- package/build/palette-edit/index.js.map +1 -1
- package/build/palette-edit/styles.js +13 -28
- package/build/palette-edit/styles.js.map +1 -1
- package/build/private-apis.js +4 -4
- package/build/private-apis.js.map +1 -1
- package/build/radio-group/index.js +3 -1
- package/build/radio-group/index.js.map +1 -1
- package/build/sandbox/index.js +3 -6
- package/build/sandbox/index.js.map +1 -1
- package/build/sandbox/index.native.js +1 -3
- package/build/sandbox/index.native.js.map +1 -1
- package/build/search-control/index.native.js +1 -3
- package/build/search-control/index.native.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot.js +1 -2
- package/build/slot-fill/bubbles-virtually/slot.js.map +1 -1
- package/build/slot-fill/fill.js +3 -6
- package/build/slot-fill/fill.js.map +1 -1
- package/build/spacer/hook.js +5 -3
- package/build/spacer/hook.js.map +1 -1
- package/build/tab-panel/index.js +4 -1
- package/build/tab-panel/index.js.map +1 -1
- package/build/tabs/index.js +48 -113
- package/build/tabs/index.js.map +1 -1
- package/build/tabs/styles.js +12 -12
- package/build/tabs/styles.js.map +1 -1
- package/build/tabs/tab.js +23 -6
- package/build/tabs/tab.js.map +1 -1
- package/build/tabs/tablist.js +24 -12
- package/build/tabs/tablist.js.map +1 -1
- package/build/tabs/types.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +2 -1
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toolbar/toolbar/index.js +3 -0
- package/build/toolbar/toolbar/index.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +1 -1
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +0 -2
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/tooltip/index.native.js +5 -15
- package/build/tooltip/index.native.js.map +1 -1
- package/build/unit-control/index.native.js +2 -6
- package/build/unit-control/index.native.js.map +1 -1
- package/build/utils/deprecated-36px-size.js +27 -0
- package/build/utils/deprecated-36px-size.js.map +1 -0
- package/build/utils/element-rect.js +13 -2
- package/build/utils/element-rect.js.map +1 -1
- package/build/utils/hooks/use-animated-offset-rect.js +3 -2
- package/build/utils/hooks/use-animated-offset-rect.js.map +1 -1
- package/build/utils/hooks/use-update-effect.js +0 -2
- package/build/utils/hooks/use-update-effect.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.js +2 -6
- package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.native.js +2 -4
- package/build-module/autocomplete/autocompleter-ui.native.js.map +1 -1
- package/build-module/autocomplete/index.js +4 -5
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/base-control/types.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js +1 -0
- 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 +6 -0
- package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
- package/build-module/border-control/border-control/component.js +1 -0
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +7 -0
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +12 -12
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/color-palette/index.js +1 -1
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-palette/index.native.js +1 -2
- package/build-module/color-palette/index.native.js.map +1 -1
- package/build-module/color-picker/index.native.js +0 -1
- package/build-module/color-picker/index.native.js.map +1 -1
- package/build-module/composite/legacy/index.js +5 -2
- package/build-module/composite/legacy/index.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build-module/date-time/date/index.js +0 -1
- package/build-module/date-time/date/index.js.map +1 -1
- package/build-module/font-size-picker/index.native.js +7 -7
- package/build-module/font-size-picker/index.native.js.map +1 -1
- package/build-module/form-token-field/index.js +0 -3
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/suggestions-list.js +7 -3
- package/build-module/form-token-field/suggestions-list.js.map +1 -1
- package/build-module/{dropdown-menu-v2 → menu}/checkbox-item.js +8 -8
- package/build-module/menu/checkbox-item.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/context.js +1 -1
- package/build-module/menu/context.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/group-label.js +5 -5
- package/build-module/menu/group-label.js.map +1 -0
- package/build-module/menu/group.js +21 -0
- package/build-module/menu/group.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/index.js +46 -46
- package/build-module/menu/index.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/item-help-text.js +2 -2
- package/build-module/menu/item-help-text.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/item-label.js +2 -2
- package/build-module/menu/item-label.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/item.js +7 -7
- package/build-module/menu/item.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/radio-item.js +8 -8
- package/build-module/menu/radio-item.js.map +1 -0
- package/build-module/menu/separator.js +22 -0
- package/build-module/menu/separator.js.map +1 -0
- package/build-module/menu/styles.js +143 -0
- package/build-module/menu/styles.js.map +1 -0
- package/build-module/menu/types.js.map +1 -0
- package/build-module/menu/use-temporary-focus-visible-fix.js.map +1 -0
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +3 -5
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/range-cell.native.js +1 -1
- package/build-module/mobile/bottom-sheet/range-cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js +1 -1
- package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js +1 -3
- package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet-select-control/index.native.js +2 -2
- package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/index.native.js +1 -3
- package/build-module/mobile/color-settings/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/picker-screen.native.js +1 -3
- package/build-module/mobile/color-settings/picker-screen.native.js.map +1 -1
- package/build-module/mobile/image/index.native.js +1 -3
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/mobile/keyboard-avoiding-view/index.ios.js +1 -3
- package/build-module/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js +2 -5
- package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-screen.native.js +1 -3
- package/build-module/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build-module/mobile/link-settings/index.native.js +6 -18
- package/build-module/mobile/link-settings/index.native.js.map +1 -1
- package/build-module/mobile/link-settings/link-settings-screen.native.js +1 -3
- package/build-module/mobile/link-settings/link-settings-screen.native.js.map +1 -1
- package/build-module/mobile/segmented-control/index.native.js +2 -6
- package/build-module/mobile/segmented-control/index.native.js.map +1 -1
- package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js +2 -6
- package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
- package/build-module/navigation/index.js +1 -2
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/item/use-navigation-tree-item.js +2 -2
- package/build-module/navigation/item/use-navigation-tree-item.js.map +1 -1
- package/build-module/navigation/menu/menu-title-search.js +2 -2
- package/build-module/navigation/menu/menu-title-search.js.map +1 -1
- package/build-module/navigation/menu/use-navigation-tree-menu.js +2 -2
- package/build-module/navigation/menu/use-navigation-tree-menu.js.map +1 -1
- package/build-module/palette-edit/index.js +6 -4
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/palette-edit/styles.js +13 -29
- package/build-module/palette-edit/styles.js.map +1 -1
- package/build-module/private-apis.js +3 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/radio-group/index.js +3 -1
- package/build-module/radio-group/index.js.map +1 -1
- package/build-module/sandbox/index.js +3 -6
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/sandbox/index.native.js +1 -3
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/search-control/index.native.js +1 -3
- package/build-module/search-control/index.native.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot.js +1 -2
- package/build-module/slot-fill/bubbles-virtually/slot.js.map +1 -1
- package/build-module/slot-fill/fill.js +3 -6
- package/build-module/slot-fill/fill.js.map +1 -1
- package/build-module/spacer/hook.js +5 -3
- package/build-module/spacer/hook.js.map +1 -1
- package/build-module/tab-panel/index.js +4 -1
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/tabs/index.js +47 -112
- package/build-module/tabs/index.js.map +1 -1
- package/build-module/tabs/styles.js +11 -11
- package/build-module/tabs/styles.js.map +1 -1
- package/build-module/tabs/tab.js +21 -6
- package/build-module/tabs/tab.js.map +1 -1
- package/build-module/tabs/tablist.js +24 -12
- package/build-module/tabs/tablist.js.map +1 -1
- package/build-module/tabs/types.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +2 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toolbar/toolbar/index.js +3 -0
- package/build-module/toolbar/toolbar/index.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +0 -2
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/tooltip/index.native.js +5 -15
- package/build-module/tooltip/index.native.js.map +1 -1
- package/build-module/unit-control/index.native.js +2 -6
- package/build-module/unit-control/index.native.js.map +1 -1
- package/build-module/utils/deprecated-36px-size.js +19 -0
- package/build-module/utils/deprecated-36px-size.js.map +1 -0
- package/build-module/utils/element-rect.js +13 -2
- package/build-module/utils/element-rect.js.map +1 -1
- package/build-module/utils/hooks/use-animated-offset-rect.js +3 -2
- package/build-module/utils/hooks/use-animated-offset-rect.js.map +1 -1
- package/build-module/utils/hooks/use-update-effect.js +0 -2
- package/build-module/utils/hooks/use-update-effect.js.map +1 -1
- package/build-style/style-rtl.css +6 -6
- package/build-style/style.css +6 -6
- package/build-types/animate/stories/index.story.d.ts.map +1 -1
- package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/base-control/stories/index.story.d.ts.map +1 -1
- package/build-types/base-control/types.d.ts +3 -0
- package/build-types/base-control/types.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/component.d.ts +1 -0
- 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.map +1 -1
- package/build-types/border-control/border-control/component.d.ts +1 -0
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/stories/index.story.d.ts.map +1 -1
- package/build-types/button/stories/index.story.d.ts.map +1 -1
- package/build-types/card/stories/index.story.d.ts.map +1 -1
- package/build-types/composite/legacy/index.d.ts.map +1 -1
- package/build-types/composite/stories/index.story.d.ts.map +1 -1
- package/build-types/date-time/date/index.d.ts.map +1 -1
- package/build-types/disabled/stories/index.story.d.ts.map +1 -1
- package/build-types/draggable/stories/index.story.d.ts.map +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/suggestions-list.d.ts.map +1 -1
- package/build-types/item-group/stories/index.story.d.ts +1 -1
- package/build-types/item-group/stories/index.story.d.ts.map +1 -1
- package/build-types/keyboard-shortcuts/stories/index.story.d.ts.map +1 -1
- package/build-types/menu/checkbox-item.d.ts +3 -0
- package/build-types/menu/checkbox-item.d.ts.map +1 -0
- package/build-types/menu/context.d.ts +6 -0
- package/build-types/menu/context.d.ts.map +1 -0
- package/build-types/menu/group-label.d.ts +3 -0
- package/build-types/menu/group-label.d.ts.map +1 -0
- package/build-types/menu/group.d.ts +3 -0
- package/build-types/menu/group.d.ts.map +1 -0
- package/build-types/menu/index.d.ts +40 -0
- package/build-types/menu/index.d.ts.map +1 -0
- package/build-types/{dropdown-menu-v2 → menu}/item-help-text.d.ts +1 -1
- package/build-types/menu/item-help-text.d.ts.map +1 -0
- package/build-types/{dropdown-menu-v2 → menu}/item-label.d.ts +1 -1
- package/build-types/menu/item-label.d.ts.map +1 -0
- package/build-types/menu/item.d.ts +3 -0
- package/build-types/menu/item.d.ts.map +1 -0
- package/build-types/menu/radio-item.d.ts +3 -0
- package/build-types/menu/radio-item.d.ts.map +1 -0
- package/build-types/menu/separator.d.ts +3 -0
- package/build-types/menu/separator.d.ts.map +1 -0
- package/build-types/menu/stories/index.story.d.ts +16 -0
- package/build-types/menu/stories/index.story.d.ts.map +1 -0
- package/build-types/{dropdown-menu-v2 → menu}/styles.d.ts +13 -13
- package/build-types/menu/styles.d.ts.map +1 -0
- package/build-types/menu/test/index.d.ts.map +1 -0
- package/build-types/{dropdown-menu-v2 → menu}/types.d.ts +22 -21
- package/build-types/menu/types.d.ts.map +1 -0
- package/build-types/menu/use-temporary-focus-visible-fix.d.ts.map +1 -0
- package/build-types/navigable-container/stories/navigable-menu.story.d.ts.map +1 -1
- package/build-types/navigable-container/stories/tabbable-container.story.d.ts.map +1 -1
- package/build-types/navigation/index.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/palette-edit/styles.d.ts +0 -256
- package/build-types/palette-edit/styles.d.ts.map +1 -1
- package/build-types/panel/stories/index.story.d.ts.map +1 -1
- package/build-types/radio-group/index.d.ts.map +1 -1
- package/build-types/resizable-box/stories/index.story.d.ts.map +1 -1
- package/build-types/sandbox/index.d.ts.map +1 -1
- package/build-types/sandbox/stories/index.story.d.ts.map +1 -1
- package/build-types/scroll-lock/stories/index.story.d.ts.map +1 -1
- package/build-types/shortcut/stories/index.story.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot.d.ts.map +1 -1
- package/build-types/slot-fill/fill.d.ts.map +1 -1
- package/build-types/slot-fill/stories/index.story.d.ts.map +1 -1
- package/build-types/spacer/hook.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.map +1 -1
- package/build-types/tabs/index.d.ts +21 -8
- package/build-types/tabs/index.d.ts.map +1 -1
- package/build-types/tabs/stories/index.story.d.ts +1 -1
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/styles.d.ts +6 -3
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/tabs/tab.d.ts +0 -3
- package/build-types/tabs/tab.d.ts.map +1 -1
- package/build-types/tabs/tablist.d.ts.map +1 -1
- package/build-types/tabs/types.d.ts +85 -48
- package/build-types/tabs/types.d.ts.map +1 -1
- package/build-types/theme/stories/index.story.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toolbar/toolbar/index.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/utils/deprecated-36px-size.d.ts +6 -0
- package/build-types/utils/deprecated-36px-size.d.ts.map +1 -0
- package/build-types/utils/element-rect.d.ts +1 -1
- package/build-types/utils/element-rect.d.ts.map +1 -1
- package/build-types/utils/hooks/use-animated-offset-rect.d.ts +8 -1
- package/build-types/utils/hooks/use-animated-offset-rect.d.ts.map +1 -1
- package/build-types/utils/hooks/use-update-effect.d.ts.map +1 -1
- package/build-types/visually-hidden/stories/index.story.d.ts.map +1 -1
- package/package.json +20 -19
- package/src/alignment-matrix-control/README.md +1 -2
- package/src/angle-picker-control/README.md +1 -2
- package/src/animate/stories/index.story.tsx +2 -1
- package/src/autocomplete/autocompleter-ui.native.js +2 -4
- package/src/autocomplete/autocompleter-ui.tsx +2 -6
- package/src/autocomplete/index.tsx +4 -5
- package/src/base-control/README.md +58 -47
- package/src/base-control/docs-manifest.json +12 -0
- package/src/base-control/stories/index.story.tsx +4 -0
- package/src/base-control/types.ts +3 -0
- package/src/border-box-control/border-box-control/README.md +1 -0
- package/src/border-box-control/border-box-control/component.tsx +1 -0
- package/src/border-box-control/border-box-control/hook.ts +7 -0
- package/src/border-box-control/stories/index.story.tsx +1 -0
- package/src/border-box-control/test/index.tsx +1 -0
- package/src/border-control/border-control/README.md +1 -0
- package/src/border-control/border-control/component.tsx +1 -0
- package/src/border-control/border-control/hook.ts +7 -1
- package/src/border-control/border-control-dropdown/component.tsx +24 -12
- package/src/border-control/stories/index.story.tsx +1 -0
- package/src/border-control/test/index.js +1 -0
- package/src/button/stories/index.story.tsx +2 -1
- package/src/card/stories/index.story.tsx +2 -1
- package/src/color-palette/index.native.js +1 -2
- package/src/color-palette/index.tsx +1 -1
- package/src/color-palette/style.scss +2 -4
- package/src/color-picker/index.native.js +0 -1
- package/src/composite/legacy/index.tsx +5 -2
- package/src/composite/stories/index.story.tsx +2 -1
- package/src/custom-gradient-picker/gradient-bar/control-points.tsx +1 -1
- package/src/date-time/date/index.tsx +0 -1
- package/src/disabled/stories/index.story.tsx +2 -1
- package/src/draggable/stories/index.story.tsx +2 -1
- package/src/font-size-picker/index.native.js +7 -7
- package/src/form-token-field/index.tsx +0 -3
- package/src/form-token-field/style.scss +4 -1
- package/src/form-token-field/suggestions-list.tsx +6 -0
- package/src/item-group/stories/index.story.tsx +8 -4
- package/src/keyboard-shortcuts/stories/index.story.tsx +2 -1
- package/src/{dropdown-menu-v2 → menu}/README.md +34 -34
- package/src/{dropdown-menu-v2 → menu}/checkbox-item.tsx +14 -14
- package/src/menu/context.tsx +13 -0
- package/src/{dropdown-menu-v2 → menu}/group-label.tsx +8 -8
- package/src/menu/group.tsx +26 -0
- package/src/{dropdown-menu-v2 → menu}/index.tsx +65 -70
- package/src/{dropdown-menu-v2 → menu}/item-help-text.tsx +3 -7
- package/src/{dropdown-menu-v2 → menu}/item-label.tsx +3 -7
- package/src/{dropdown-menu-v2 → menu}/item.tsx +13 -13
- package/src/{dropdown-menu-v2 → menu}/radio-item.tsx +14 -14
- package/src/menu/separator.tsx +27 -0
- package/src/menu/stories/index.story.tsx +542 -0
- package/src/{dropdown-menu-v2 → menu}/styles.ts +17 -17
- package/src/{dropdown-menu-v2 → menu}/test/index.tsx +145 -225
- package/src/{dropdown-menu-v2 → menu}/types.ts +24 -23
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +3 -5
- package/src/mobile/bottom-sheet/range-cell.native.js +1 -1
- package/src/mobile/bottom-sheet/stepper-cell/index.native.js +1 -1
- package/src/mobile/bottom-sheet/sub-sheet/index.native.js +1 -3
- package/src/mobile/bottom-sheet-select-control/index.native.js +2 -2
- package/src/mobile/color-settings/index.native.js +1 -3
- package/src/mobile/color-settings/picker-screen.native.js +1 -3
- package/src/mobile/image/index.native.js +1 -3
- package/src/mobile/keyboard-avoiding-view/index.ios.js +1 -3
- package/src/mobile/link-picker/link-picker-results.native.js +2 -5
- package/src/mobile/link-picker/link-picker-screen.native.js +1 -3
- package/src/mobile/link-settings/index.native.js +6 -18
- package/src/mobile/link-settings/link-settings-screen.native.js +1 -3
- package/src/mobile/segmented-control/index.native.js +2 -6
- package/src/mobile/utils/use-unit-converter-to-mobile.native.js +2 -6
- package/src/navigable-container/stories/navigable-menu.story.tsx +2 -1
- package/src/navigable-container/stories/tabbable-container.story.tsx +2 -1
- package/src/navigation/index.tsx +1 -2
- package/src/navigation/item/use-navigation-tree-item.tsx +2 -2
- package/src/navigation/menu/menu-title-search.tsx +2 -2
- package/src/navigation/menu/use-navigation-tree-menu.tsx +2 -2
- package/src/palette-edit/index.tsx +4 -5
- package/src/palette-edit/styles.ts +1 -67
- package/src/panel/stories/index.story.tsx +2 -1
- package/src/private-apis.ts +3 -3
- package/src/radio-group/index.tsx +2 -0
- package/src/resizable-box/stories/index.story.tsx +2 -1
- package/src/sandbox/index.native.js +1 -3
- package/src/sandbox/index.tsx +3 -6
- package/src/sandbox/stories/index.story.tsx +2 -1
- package/src/scroll-lock/stories/index.story.tsx +2 -1
- package/src/search-control/index.native.js +1 -3
- package/src/shortcut/stories/index.story.tsx +2 -1
- package/src/slot-fill/bubbles-virtually/slot.tsx +1 -2
- package/src/slot-fill/fill.ts +3 -6
- package/src/slot-fill/stories/index.story.tsx +2 -1
- package/src/spacer/hook.ts +3 -2
- package/src/tab-panel/index.tsx +3 -0
- package/src/tab-panel/stories/index.story.tsx +2 -1
- package/src/tab-panel/style.scss +1 -3
- package/src/tabs/README.md +63 -21
- package/src/tabs/index.tsx +112 -189
- package/src/tabs/stories/index.story.tsx +5 -2
- package/src/tabs/styles.ts +13 -5
- package/src/tabs/tab.tsx +23 -3
- package/src/tabs/tablist.tsx +31 -15
- package/src/tabs/test/index.tsx +131 -118
- package/src/tabs/types.ts +89 -49
- package/src/theme/stories/index.story.tsx +2 -1
- package/src/toggle-group-control/toggle-group-control/component.tsx +1 -0
- package/src/toolbar/toolbar/index.tsx +3 -0
- package/src/tools-panel/tools-panel-header/component.tsx +1 -1
- package/src/tools-panel/tools-panel-item/hook.ts +0 -2
- package/src/tooltip/index.native.js +5 -15
- package/src/unit-control/index.native.js +2 -6
- package/src/utils/deprecated-36px-size.ts +24 -0
- package/src/utils/element-rect.ts +14 -2
- package/src/utils/hooks/use-animated-offset-rect.ts +13 -1
- package/src/utils/hooks/use-update-effect.js +0 -2
- package/src/visually-hidden/stories/index.story.tsx +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dropdown-menu-v2/checkbox-item.js.map +0 -1
- package/build/dropdown-menu-v2/context.js.map +0 -1
- package/build/dropdown-menu-v2/group-label.js.map +0 -1
- package/build/dropdown-menu-v2/group.js.map +0 -1
- package/build/dropdown-menu-v2/index.js.map +0 -1
- package/build/dropdown-menu-v2/item-help-text.js.map +0 -1
- package/build/dropdown-menu-v2/item-label.js.map +0 -1
- package/build/dropdown-menu-v2/item.js.map +0 -1
- package/build/dropdown-menu-v2/radio-item.js.map +0 -1
- package/build/dropdown-menu-v2/separator.js.map +0 -1
- package/build/dropdown-menu-v2/styles.js +0 -150
- package/build/dropdown-menu-v2/styles.js.map +0 -1
- package/build/dropdown-menu-v2/types.js.map +0 -1
- package/build/dropdown-menu-v2/use-temporary-focus-visible-fix.js.map +0 -1
- package/build-module/dropdown-menu-v2/checkbox-item.js.map +0 -1
- package/build-module/dropdown-menu-v2/context.js.map +0 -1
- package/build-module/dropdown-menu-v2/group-label.js.map +0 -1
- package/build-module/dropdown-menu-v2/group.js +0 -21
- package/build-module/dropdown-menu-v2/group.js.map +0 -1
- package/build-module/dropdown-menu-v2/index.js.map +0 -1
- package/build-module/dropdown-menu-v2/item-help-text.js.map +0 -1
- package/build-module/dropdown-menu-v2/item-label.js.map +0 -1
- package/build-module/dropdown-menu-v2/item.js.map +0 -1
- package/build-module/dropdown-menu-v2/radio-item.js.map +0 -1
- package/build-module/dropdown-menu-v2/separator.js +0 -22
- package/build-module/dropdown-menu-v2/separator.js.map +0 -1
- package/build-module/dropdown-menu-v2/styles.js +0 -143
- package/build-module/dropdown-menu-v2/styles.js.map +0 -1
- package/build-module/dropdown-menu-v2/types.js.map +0 -1
- package/build-module/dropdown-menu-v2/use-temporary-focus-visible-fix.js.map +0 -1
- package/build-types/dropdown-menu-v2/checkbox-item.d.ts +0 -3
- package/build-types/dropdown-menu-v2/checkbox-item.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/context.d.ts +0 -6
- package/build-types/dropdown-menu-v2/context.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/group-label.d.ts +0 -3
- package/build-types/dropdown-menu-v2/group-label.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/group.d.ts +0 -3
- package/build-types/dropdown-menu-v2/group.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/index.d.ts +0 -40
- package/build-types/dropdown-menu-v2/index.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/item-help-text.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/item-label.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/item.d.ts +0 -3
- package/build-types/dropdown-menu-v2/item.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/radio-item.d.ts +0 -3
- package/build-types/dropdown-menu-v2/radio-item.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/separator.d.ts +0 -3
- package/build-types/dropdown-menu-v2/separator.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts +0 -16
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/styles.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/test/index.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/types.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/use-temporary-focus-visible-fix.d.ts.map +0 -1
- package/src/dropdown-menu-v2/context.tsx +0 -13
- package/src/dropdown-menu-v2/group.tsx +0 -26
- package/src/dropdown-menu-v2/separator.tsx +0 -27
- package/src/dropdown-menu-v2/stories/index.story.tsx +0 -639
- /package/build/{dropdown-menu-v2 → menu}/types.js +0 -0
- /package/build/{dropdown-menu-v2 → menu}/use-temporary-focus-visible-fix.js +0 -0
- /package/build-module/{dropdown-menu-v2 → menu}/types.js +0 -0
- /package/build-module/{dropdown-menu-v2 → menu}/use-temporary-focus-visible-fix.js +0 -0
- /package/build-types/{dropdown-menu-v2 → menu}/test/index.d.ts +0 -0
- /package/build-types/{dropdown-menu-v2 → menu}/use-temporary-focus-visible-fix.d.ts +0 -0
- /package/src/{dropdown-menu-v2 → menu}/use-temporary-focus-visible-fix.ts +0 -0
package/src/tabs/index.tsx
CHANGED
|
@@ -2,18 +2,13 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import * as Ariakit from '@ariakit/react';
|
|
5
|
-
import { useStoreState } from '@ariakit/react';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
9
8
|
*/
|
|
10
9
|
import { useInstanceId } from '@wordpress/compose';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
useLayoutEffect,
|
|
14
|
-
useMemo,
|
|
15
|
-
useRef,
|
|
16
|
-
} from '@wordpress/element';
|
|
10
|
+
import { useEffect, useMemo } from '@wordpress/element';
|
|
11
|
+
import { isRTL } from '@wordpress/i18n';
|
|
17
12
|
|
|
18
13
|
/**
|
|
19
14
|
* Internal dependencies
|
|
@@ -24,191 +19,119 @@ import { Tab } from './tab';
|
|
|
24
19
|
import { TabList } from './tablist';
|
|
25
20
|
import { TabPanel } from './tabpanel';
|
|
26
21
|
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
selectedTabId,
|
|
34
|
-
}: TabsProps ) {
|
|
35
|
-
const instanceId = useInstanceId( Tabs, 'tabs' );
|
|
36
|
-
const store = Ariakit.useTabStore( {
|
|
37
|
-
selectOnMove,
|
|
38
|
-
orientation,
|
|
39
|
-
defaultSelectedId: defaultTabId && `${ instanceId }-${ defaultTabId }`,
|
|
40
|
-
setSelectedId: ( selectedId ) => {
|
|
41
|
-
const strippedDownId =
|
|
42
|
-
typeof selectedId === 'string'
|
|
43
|
-
? selectedId.replace( `${ instanceId }-`, '' )
|
|
44
|
-
: selectedId;
|
|
45
|
-
onSelect?.( strippedDownId );
|
|
46
|
-
},
|
|
47
|
-
selectedId: selectedTabId && `${ instanceId }-${ selectedTabId }`,
|
|
48
|
-
} );
|
|
49
|
-
|
|
50
|
-
const isControlled = selectedTabId !== undefined;
|
|
51
|
-
|
|
52
|
-
const { items, selectedId, activeId } = useStoreState( store );
|
|
53
|
-
const { setSelectedId, setActiveId } = store;
|
|
54
|
-
|
|
55
|
-
// Keep track of whether tabs have been populated. This is used to prevent
|
|
56
|
-
// certain effects from firing too early while tab data and relevant
|
|
57
|
-
// variables are undefined during the initial render.
|
|
58
|
-
const tabsHavePopulatedRef = useRef( false );
|
|
59
|
-
if ( items.length > 0 ) {
|
|
60
|
-
tabsHavePopulatedRef.current = true;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const selectedTab = items.find( ( item ) => item.id === selectedId );
|
|
64
|
-
const firstEnabledTab = items.find( ( item ) => {
|
|
65
|
-
// Ariakit internally refers to disabled tabs as `dimmed`.
|
|
66
|
-
return ! item.dimmed;
|
|
67
|
-
} );
|
|
68
|
-
const initialTab = items.find(
|
|
69
|
-
( item ) => item.id === `${ instanceId }-${ defaultTabId }`
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
// Handle selecting the initial tab.
|
|
73
|
-
useLayoutEffect( () => {
|
|
74
|
-
if ( isControlled ) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Wait for the denoted initial tab to be declared before making a
|
|
79
|
-
// selection. This ensures that if a tab is declared lazily it can
|
|
80
|
-
// still receive initial selection, as well as ensuring no tab is
|
|
81
|
-
// selected if an invalid `defaultTabId` is provided.
|
|
82
|
-
if ( defaultTabId && ! initialTab ) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
22
|
+
function externalToInternalTabId(
|
|
23
|
+
externalId: string | undefined | null,
|
|
24
|
+
instanceId: string
|
|
25
|
+
) {
|
|
26
|
+
return externalId && `${ instanceId }-${ externalId }`;
|
|
27
|
+
}
|
|
85
28
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
29
|
+
function internalToExternalTabId(
|
|
30
|
+
internalId: string | undefined | null,
|
|
31
|
+
instanceId: string
|
|
32
|
+
) {
|
|
33
|
+
return typeof internalId === 'string'
|
|
34
|
+
? internalId.replace( `${ instanceId }-`, '' )
|
|
35
|
+
: internalId;
|
|
36
|
+
}
|
|
94
37
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Display one panel of content at a time with a tabbed interface, based on the
|
|
40
|
+
* WAI-ARIA Tabs Pattern.
|
|
41
|
+
*
|
|
42
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/tabs/
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export const Tabs = Object.assign(
|
|
46
|
+
function Tabs( {
|
|
47
|
+
selectOnMove = true,
|
|
104
48
|
defaultTabId,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
isControlled,
|
|
139
|
-
selectedTab?.dimmed,
|
|
140
|
-
setSelectedId,
|
|
141
|
-
] );
|
|
142
|
-
|
|
143
|
-
// Clear `selectedId` if the active tab is removed from the DOM in controlled mode.
|
|
144
|
-
useLayoutEffect( () => {
|
|
145
|
-
if ( ! isControlled ) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Once the tabs have populated, if the `selectedTabId` still can't be
|
|
150
|
-
// found, clear the selection.
|
|
151
|
-
if (
|
|
152
|
-
tabsHavePopulatedRef.current &&
|
|
153
|
-
!! selectedTabId &&
|
|
154
|
-
! selectedTab
|
|
155
|
-
) {
|
|
156
|
-
setSelectedId( null );
|
|
157
|
-
}
|
|
158
|
-
}, [ isControlled, selectedTab, selectedTabId, setSelectedId ] );
|
|
159
|
-
|
|
160
|
-
useEffect( () => {
|
|
161
|
-
// If there is no active tab, fallback to place focus on the first enabled tab
|
|
162
|
-
// so there is always an active element
|
|
163
|
-
if ( selectedTabId === null && ! activeId && firstEnabledTab?.id ) {
|
|
164
|
-
setActiveId( firstEnabledTab.id );
|
|
165
|
-
}
|
|
166
|
-
}, [ selectedTabId, activeId, firstEnabledTab?.id, setActiveId ] );
|
|
167
|
-
|
|
168
|
-
useEffect( () => {
|
|
169
|
-
if ( ! isControlled ) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
requestAnimationFrame( () => {
|
|
174
|
-
const focusedElement =
|
|
175
|
-
items?.[ 0 ]?.element?.ownerDocument.activeElement;
|
|
176
|
-
|
|
177
|
-
if (
|
|
178
|
-
! focusedElement ||
|
|
179
|
-
! items.some( ( item ) => focusedElement === item.element )
|
|
180
|
-
) {
|
|
181
|
-
return; // Return early if no tabs are focused.
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// If, after ariakit re-computes the active tab, that tab doesn't match
|
|
185
|
-
// the currently focused tab, then we force an update to ariakit to avoid
|
|
186
|
-
// any mismatches, especially when navigating to previous/next tab with
|
|
187
|
-
// arrow keys.
|
|
188
|
-
if ( activeId !== focusedElement.id ) {
|
|
189
|
-
setActiveId( focusedElement.id );
|
|
190
|
-
}
|
|
49
|
+
orientation = 'horizontal',
|
|
50
|
+
onSelect,
|
|
51
|
+
children,
|
|
52
|
+
selectedTabId,
|
|
53
|
+
activeTabId,
|
|
54
|
+
defaultActiveTabId,
|
|
55
|
+
onActiveTabIdChange,
|
|
56
|
+
}: TabsProps ) {
|
|
57
|
+
const instanceId = useInstanceId( Tabs, 'tabs' );
|
|
58
|
+
const store = Ariakit.useTabStore( {
|
|
59
|
+
selectOnMove,
|
|
60
|
+
orientation,
|
|
61
|
+
defaultSelectedId: externalToInternalTabId(
|
|
62
|
+
defaultTabId,
|
|
63
|
+
instanceId
|
|
64
|
+
),
|
|
65
|
+
setSelectedId: ( newSelectedId ) => {
|
|
66
|
+
onSelect?.(
|
|
67
|
+
internalToExternalTabId( newSelectedId, instanceId )
|
|
68
|
+
);
|
|
69
|
+
},
|
|
70
|
+
selectedId: externalToInternalTabId( selectedTabId, instanceId ),
|
|
71
|
+
defaultActiveId: externalToInternalTabId(
|
|
72
|
+
defaultActiveTabId,
|
|
73
|
+
instanceId
|
|
74
|
+
),
|
|
75
|
+
setActiveId: ( newActiveId ) => {
|
|
76
|
+
onActiveTabIdChange?.(
|
|
77
|
+
internalToExternalTabId( newActiveId, instanceId )
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
activeId: externalToInternalTabId( activeTabId, instanceId ),
|
|
81
|
+
rtl: isRTL(),
|
|
191
82
|
} );
|
|
192
|
-
}, [ activeId, isControlled, items, setActiveId ] );
|
|
193
83
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
84
|
+
const { items, activeId } = Ariakit.useStoreState( store );
|
|
85
|
+
const { setActiveId } = store;
|
|
86
|
+
|
|
87
|
+
useEffect( () => {
|
|
88
|
+
requestAnimationFrame( () => {
|
|
89
|
+
const focusedElement =
|
|
90
|
+
items?.[ 0 ]?.element?.ownerDocument.activeElement;
|
|
91
|
+
|
|
92
|
+
if (
|
|
93
|
+
! focusedElement ||
|
|
94
|
+
! items.some( ( item ) => focusedElement === item.element )
|
|
95
|
+
) {
|
|
96
|
+
return; // Return early if no tabs are focused.
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// If, after ariakit re-computes the active tab, that tab doesn't match
|
|
100
|
+
// the currently focused tab, then we force an update to ariakit to avoid
|
|
101
|
+
// any mismatches, especially when navigating to previous/next tab with
|
|
102
|
+
// arrow keys.
|
|
103
|
+
if ( activeId !== focusedElement.id ) {
|
|
104
|
+
setActiveId( focusedElement.id );
|
|
105
|
+
}
|
|
106
|
+
} );
|
|
107
|
+
}, [ activeId, items, setActiveId ] );
|
|
108
|
+
|
|
109
|
+
const contextValue = useMemo(
|
|
110
|
+
() => ( {
|
|
111
|
+
store,
|
|
112
|
+
instanceId,
|
|
113
|
+
} ),
|
|
114
|
+
[ store, instanceId ]
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<TabsContext.Provider value={ contextValue }>
|
|
119
|
+
{ children }
|
|
120
|
+
</TabsContext.Provider>
|
|
121
|
+
);
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
Tab: Object.assign( Tab, {
|
|
125
|
+
displayName: 'Tabs.Tab',
|
|
198
126
|
} ),
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
Tabs.Tab = Tab;
|
|
211
|
-
Tabs.TabPanel = TabPanel;
|
|
212
|
-
Tabs.Context = TabsContext;
|
|
213
|
-
|
|
214
|
-
export default Tabs;
|
|
127
|
+
TabList: Object.assign( TabList, {
|
|
128
|
+
displayName: 'Tabs.TabList',
|
|
129
|
+
} ),
|
|
130
|
+
TabPanel: Object.assign( TabPanel, {
|
|
131
|
+
displayName: 'Tabs.TabPanel',
|
|
132
|
+
} ),
|
|
133
|
+
Context: Object.assign( TabsContext, {
|
|
134
|
+
displayName: 'Tabs.Context',
|
|
135
|
+
} ),
|
|
136
|
+
}
|
|
137
|
+
);
|
|
@@ -12,7 +12,7 @@ import { useState } from '@wordpress/element';
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
|
-
import Tabs from '..';
|
|
15
|
+
import { Tabs } from '..';
|
|
16
16
|
import { Slot, Fill, Provider as SlotFillProvider } from '../../slot-fill';
|
|
17
17
|
import DropdownMenu from '../../dropdown-menu';
|
|
18
18
|
import Button from '../../button';
|
|
@@ -20,7 +20,8 @@ import Tooltip from '../../tooltip';
|
|
|
20
20
|
import Icon from '../../icon';
|
|
21
21
|
|
|
22
22
|
const meta: Meta< typeof Tabs > = {
|
|
23
|
-
title: 'Components
|
|
23
|
+
title: 'Components/Containers/Tabs',
|
|
24
|
+
id: 'components-tabs',
|
|
24
25
|
component: Tabs,
|
|
25
26
|
subcomponents: {
|
|
26
27
|
// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
|
|
@@ -29,6 +30,8 @@ const meta: Meta< typeof Tabs > = {
|
|
|
29
30
|
'Tabs.Tab': Tabs.Tab,
|
|
30
31
|
// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
|
|
31
32
|
'Tabs.TabPanel': Tabs.TabPanel,
|
|
33
|
+
// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
|
|
34
|
+
'Tabs.Context': Tabs.Context,
|
|
32
35
|
},
|
|
33
36
|
tags: [ 'status-private' ],
|
|
34
37
|
parameters: {
|
package/src/tabs/styles.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { COLORS, CONFIG } from '../utils';
|
|
|
11
11
|
import { space } from '../utils/space';
|
|
12
12
|
import Icon from '../icon';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const StyledTabList = styled( Ariakit.TabList )`
|
|
15
15
|
display: flex;
|
|
16
16
|
align-items: stretch;
|
|
17
17
|
overflow-x: auto;
|
|
@@ -195,7 +195,7 @@ export const Tab = styled( Ariakit.Tab )`
|
|
|
195
195
|
opacity: 0;
|
|
196
196
|
|
|
197
197
|
@media not ( prefers-reduced-motion ) {
|
|
198
|
-
transition: opacity 0.
|
|
198
|
+
transition: opacity 0.1s linear;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
@@ -207,7 +207,6 @@ export const Tab = styled( Ariakit.Tab )`
|
|
|
207
207
|
[aria-orientation='horizontal'] & {
|
|
208
208
|
padding-inline: ${ space( 4 ) };
|
|
209
209
|
height: ${ space( 12 ) };
|
|
210
|
-
text-align: center;
|
|
211
210
|
scroll-margin: 24px;
|
|
212
211
|
|
|
213
212
|
&::after {
|
|
@@ -219,7 +218,6 @@ export const Tab = styled( Ariakit.Tab )`
|
|
|
219
218
|
[aria-orientation='vertical'] & {
|
|
220
219
|
padding: ${ space( 2 ) } ${ space( 3 ) };
|
|
221
220
|
min-height: ${ space( 10 ) };
|
|
222
|
-
text-align: start;
|
|
223
221
|
|
|
224
222
|
&[aria-selected='true'] {
|
|
225
223
|
color: ${ COLORS.theme.accent };
|
|
@@ -234,6 +232,16 @@ export const Tab = styled( Ariakit.Tab )`
|
|
|
234
232
|
|
|
235
233
|
export const TabChildren = styled.span`
|
|
236
234
|
flex-grow: 1;
|
|
235
|
+
|
|
236
|
+
display: flex;
|
|
237
|
+
align-items: center;
|
|
238
|
+
|
|
239
|
+
[aria-orientation='horizontal'] & {
|
|
240
|
+
justify-content: center;
|
|
241
|
+
}
|
|
242
|
+
[aria-orientation='vertical'] & {
|
|
243
|
+
justify-content: start;
|
|
244
|
+
}
|
|
237
245
|
`;
|
|
238
246
|
|
|
239
247
|
export const TabChevron = styled( Icon )`
|
|
@@ -253,7 +261,7 @@ export const TabChevron = styled( Icon )`
|
|
|
253
261
|
[data-select-on-move='true']
|
|
254
262
|
[role='tab']:is( [aria-selected='true'], )
|
|
255
263
|
& {
|
|
256
|
-
transition: opacity 0.
|
|
264
|
+
transition: opacity 0.15s 0.15s linear;
|
|
257
265
|
}
|
|
258
266
|
}
|
|
259
267
|
&:dir( rtl ) {
|
package/src/tabs/tab.tsx
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import * as Ariakit from '@ariakit/react';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -22,13 +27,27 @@ export const Tab = forwardRef<
|
|
|
22
27
|
HTMLButtonElement,
|
|
23
28
|
Omit< WordPressComponentProps< TabProps, 'button', false >, 'id' >
|
|
24
29
|
>( function Tab( { children, tabId, disabled, render, ...otherProps }, ref ) {
|
|
25
|
-
const
|
|
26
|
-
|
|
30
|
+
const { store, instanceId } = useTabsContext() ?? {};
|
|
31
|
+
|
|
32
|
+
// If the active item is not connected, the tablist may end up in a state
|
|
33
|
+
// where none of the tabs are tabbable. In this case, we force all tabs to
|
|
34
|
+
// be tabbable, so that as soon as an item received focus, it becomes active
|
|
35
|
+
// and Tablist goes back to working as expected.
|
|
36
|
+
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
|
|
37
|
+
const tabbable = Ariakit.useStoreState( store, ( state ) => {
|
|
38
|
+
return (
|
|
39
|
+
state?.activeId !== null &&
|
|
40
|
+
! store?.item( state?.activeId )?.element?.isConnected
|
|
41
|
+
);
|
|
42
|
+
} );
|
|
43
|
+
|
|
44
|
+
if ( ! store ) {
|
|
27
45
|
warning( '`Tabs.Tab` must be wrapped in a `Tabs` component.' );
|
|
28
46
|
return null;
|
|
29
47
|
}
|
|
30
|
-
|
|
48
|
+
|
|
31
49
|
const instancedTabId = `${ instanceId }-${ tabId }`;
|
|
50
|
+
|
|
32
51
|
return (
|
|
33
52
|
<StyledTab
|
|
34
53
|
ref={ ref }
|
|
@@ -36,6 +55,7 @@ export const Tab = forwardRef<
|
|
|
36
55
|
id={ instancedTabId }
|
|
37
56
|
disabled={ disabled }
|
|
38
57
|
render={ render }
|
|
58
|
+
tabbable={ tabbable }
|
|
39
59
|
{ ...otherProps }
|
|
40
60
|
>
|
|
41
61
|
<StyledTabChildren>{ children }</StyledTabChildren>
|
package/src/tabs/tablist.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import * as Ariakit from '@ariakit/react';
|
|
5
|
-
import
|
|
5
|
+
import clsx from 'clsx';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
@@ -15,11 +15,10 @@ import { useMergeRefs } from '@wordpress/compose';
|
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
17
|
import type { TabListProps } from './types';
|
|
18
|
-
import { useTabsContext } from './context';
|
|
19
|
-
import { TabListWrapper } from './styles';
|
|
20
18
|
import type { WordPressComponentProps } from '../context';
|
|
21
|
-
import clsx from 'clsx';
|
|
22
19
|
import type { ElementOffsetRect } from '../utils/element-rect';
|
|
20
|
+
import { useTabsContext } from './context';
|
|
21
|
+
import { StyledTabList } from './styles';
|
|
23
22
|
import { useTrackElementOffsetRect } from '../utils/element-rect';
|
|
24
23
|
import { useTrackOverflow } from './use-track-overflow';
|
|
25
24
|
import { useAnimatedOffsetRect } from '../utils/hooks/use-animated-offset-rect';
|
|
@@ -63,15 +62,25 @@ export const TabList = forwardRef<
|
|
|
63
62
|
>( function TabList( { children, ...otherProps }, ref ) {
|
|
64
63
|
const { store } = useTabsContext() ?? {};
|
|
65
64
|
|
|
66
|
-
const selectedId = useStoreState( store, 'selectedId' );
|
|
67
|
-
const activeId = useStoreState( store, 'activeId' );
|
|
68
|
-
const selectOnMove = useStoreState( store, 'selectOnMove' );
|
|
69
|
-
const items = useStoreState( store, 'items' );
|
|
65
|
+
const selectedId = Ariakit.useStoreState( store, 'selectedId' );
|
|
66
|
+
const activeId = Ariakit.useStoreState( store, 'activeId' );
|
|
67
|
+
const selectOnMove = Ariakit.useStoreState( store, 'selectOnMove' );
|
|
68
|
+
const items = Ariakit.useStoreState( store, 'items' );
|
|
70
69
|
const [ parent, setParent ] = useState< HTMLElement >();
|
|
71
70
|
const refs = useMergeRefs( [ ref, setParent ] );
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
);
|
|
71
|
+
|
|
72
|
+
const selectedItem = store?.item( selectedId );
|
|
73
|
+
const renderedItems = Ariakit.useStoreState( store, 'renderedItems' );
|
|
74
|
+
|
|
75
|
+
const selectedItemIndex =
|
|
76
|
+
renderedItems && selectedItem
|
|
77
|
+
? renderedItems.indexOf( selectedItem )
|
|
78
|
+
: -1;
|
|
79
|
+
// Use selectedItemIndex as a dependency to force recalculation when the
|
|
80
|
+
// selected item index changes (elements are swapped / added / removed).
|
|
81
|
+
const selectedRect = useTrackElementOffsetRect( selectedItem?.element, [
|
|
82
|
+
selectedItemIndex,
|
|
83
|
+
] );
|
|
75
84
|
|
|
76
85
|
// Track overflow to show scroll hints.
|
|
77
86
|
const overflow = useTrackOverflow( parent, {
|
|
@@ -84,6 +93,7 @@ export const TabList = forwardRef<
|
|
|
84
93
|
prefix: 'selected',
|
|
85
94
|
dataAttribute: 'indicator-animated',
|
|
86
95
|
transitionEndFilter: ( event ) => event.pseudoElement === '::before',
|
|
96
|
+
roundRect: true,
|
|
87
97
|
} );
|
|
88
98
|
|
|
89
99
|
// Make sure selected tab is scrolled into view.
|
|
@@ -109,12 +119,18 @@ export const TabList = forwardRef<
|
|
|
109
119
|
}
|
|
110
120
|
|
|
111
121
|
return (
|
|
112
|
-
<
|
|
122
|
+
<StyledTabList
|
|
113
123
|
ref={ refs }
|
|
114
124
|
store={ store }
|
|
115
|
-
render={
|
|
125
|
+
render={ ( props ) => (
|
|
126
|
+
<div
|
|
127
|
+
{ ...props }
|
|
128
|
+
// Fallback to -1 to prevent browsers from making the tablist
|
|
129
|
+
// tabbable when it is a scrolling container.
|
|
130
|
+
tabIndex={ props.tabIndex ?? -1 }
|
|
131
|
+
/>
|
|
132
|
+
) }
|
|
116
133
|
onBlur={ onBlur }
|
|
117
|
-
tabIndex={ -1 }
|
|
118
134
|
data-select-on-move={ selectOnMove ? 'true' : 'false' }
|
|
119
135
|
{ ...otherProps }
|
|
120
136
|
className={ clsx(
|
|
@@ -124,6 +140,6 @@ export const TabList = forwardRef<
|
|
|
124
140
|
) }
|
|
125
141
|
>
|
|
126
142
|
{ children }
|
|
127
|
-
</
|
|
143
|
+
</StyledTabList>
|
|
128
144
|
);
|
|
129
145
|
} );
|