@wordpress/components 28.10.0 → 28.12.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 +61 -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 +13 -13
- 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-file-upload/index.js +5 -1
- package/build/form-file-upload/index.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/form-token-field/token.js +1 -0
- package/build/form-token-field/token.js.map +1 -1
- package/build/guide/page-control.js +1 -0
- package/build/guide/page-control.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/menu-item/index.js +1 -0
- package/build/menu-item/index.js.map +1 -1
- 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/notice/index.js +2 -0
- package/build/notice/index.js.map +1 -1
- package/build/palette-edit/index.js +9 -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/panel/body.js +1 -0
- package/build/panel/body.js.map +1 -1
- package/build/popover/index.js +4 -1
- package/build/popover/index.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/radio-group/radio.js +6 -0
- package/build/radio-group/radio.js.map +1 -1
- package/build/radio-group/types.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/snackbar/index.js +2 -1
- package/build/snackbar/index.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 +37 -14
- 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 +3 -2
- 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 +13 -13
- 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-file-upload/index.js +5 -1
- package/build-module/form-file-upload/index.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/form-token-field/token.js +1 -0
- package/build-module/form-token-field/token.js.map +1 -1
- package/build-module/guide/page-control.js +1 -0
- package/build-module/guide/page-control.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/menu-item/index.js +1 -0
- package/build-module/menu-item/index.js.map +1 -1
- 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/notice/index.js +2 -0
- package/build-module/notice/index.js.map +1 -1
- package/build-module/palette-edit/index.js +11 -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/panel/body.js +1 -0
- package/build-module/panel/body.js.map +1 -1
- package/build-module/popover/index.js +4 -1
- package/build-module/popover/index.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/radio-group/radio.js +6 -0
- package/build-module/radio-group/radio.js.map +1 -1
- package/build-module/radio-group/types.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/snackbar/index.js +2 -1
- package/build-module/snackbar/index.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 +37 -14
- 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 +3 -2
- 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 +21 -35
- package/build-style/style.css +21 -35
- 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/confirm-dialog/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/dropdown/stories/index.story.d.ts.map +1 -1
- package/build-types/external-link/stories/index.story.d.ts.map +1 -1
- package/build-types/form-file-upload/index.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/form-token-field/token.d.ts.map +1 -1
- package/build-types/guide/page-control.d.ts.map +1 -1
- package/build-types/heading/stories/index.story.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/lock-unlock.d.ts +2 -2
- 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/menu-item/index.d.ts.map +1 -1
- package/build-types/modal/stories/index.story.d.ts.map +1 -1
- 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/navigator/stories/index.story.d.ts.map +1 -1
- package/build-types/notice/index.d.ts.map +1 -1
- package/build-types/notice/stories/index.story.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/body.d.ts.map +1 -1
- package/build-types/panel/stories/index.story.d.ts.map +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/stories/index.story.d.ts.map +1 -1
- package/build-types/progress-bar/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 +4 -2
- package/build-types/radio-group/radio.d.ts.map +1 -1
- package/build-types/radio-group/stories/index.story.d.ts.map +1 -1
- package/build-types/radio-group/types.d.ts +5 -1
- package/build-types/radio-group/types.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/snackbar/index.d.ts.map +1 -1
- package/build-types/snackbar/stories/index.story.d.ts.map +1 -1
- package/build-types/snackbar/stories/list.story.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts.map +1 -1
- package/build-types/spinner/stories/index.story.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/text/stories/index.story.d.ts.map +1 -1
- package/build-types/text-highlight/stories/index.story.d.ts.map +1 -1
- package/build-types/theme/stories/index.story.d.ts.map +1 -1
- package/build-types/tip/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/tooltip/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-grid/stories/index.story.d.ts.map +1 -1
- package/build-types/truncate/stories/index.story.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 +21 -20
- 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 +25 -13
- 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/confirm-dialog/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/dropdown/stories/index.story.tsx +2 -1
- package/src/external-link/stories/index.story.tsx +2 -1
- package/src/font-size-picker/index.native.js +7 -7
- package/src/form-file-upload/index.tsx +7 -1
- package/src/form-token-field/index.tsx +0 -3
- package/src/form-token-field/style.scss +12 -13
- package/src/form-token-field/suggestions-list.tsx +6 -0
- package/src/form-token-field/token.tsx +1 -0
- package/src/guide/page-control.tsx +1 -0
- package/src/guide/style.scss +4 -6
- package/src/heading/stories/index.story.tsx +2 -1
- 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 +543 -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/menu-item/index.tsx +1 -0
- package/src/menu-item/test/__snapshots__/index.js.snap +4 -4
- 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/modal/stories/index.story.tsx +2 -1
- 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/navigator/stories/index.story.tsx +2 -1
- package/src/notice/index.tsx +2 -0
- package/src/notice/stories/index.story.tsx +7 -2
- package/src/notice/test/__snapshots__/index.tsx.snap +4 -4
- package/src/palette-edit/index.tsx +9 -5
- package/src/palette-edit/styles.ts +1 -67
- package/src/panel/body.tsx +1 -0
- package/src/panel/stories/index.story.tsx +2 -1
- package/src/popover/index.tsx +3 -0
- package/src/popover/stories/index.story.tsx +2 -1
- package/src/private-apis.ts +3 -3
- package/src/progress-bar/stories/index.story.tsx +2 -1
- package/src/radio-group/README.md +8 -8
- package/src/radio-group/index.tsx +2 -0
- package/src/radio-group/radio.tsx +7 -0
- package/src/radio-group/stories/index.story.tsx +16 -4
- package/src/radio-group/types.ts +6 -1
- 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/snackbar/index.tsx +2 -1
- package/src/snackbar/stories/index.story.tsx +2 -1
- package/src/snackbar/stories/list.story.tsx +2 -1
- package/src/snackbar/style.scss +7 -16
- package/src/spacer/hook.ts +3 -2
- package/src/spinner/stories/index.story.tsx +2 -1
- 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 +44 -17
- package/src/tabs/test/index.tsx +131 -118
- package/src/tabs/types.ts +89 -49
- package/src/text/stories/index.story.tsx +2 -1
- package/src/text-highlight/stories/index.story.tsx +2 -1
- package/src/theme/stories/index.story.tsx +2 -1
- package/src/tip/stories/index.story.tsx +2 -1
- package/src/toggle-group-control/toggle-group-control/component.tsx +2 -1
- 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/tooltip/stories/index.story.tsx +2 -1
- package/src/tree-grid/stories/index.story.tsx +2 -1
- package/src/truncate/stories/index.story.tsx +2 -1
- package/src/unit-control/index.native.js +2 -6
- package/src/utils/deprecated-36px-size.ts +27 -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/build/tabs/tablist.js
CHANGED
|
@@ -5,14 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.TabList = void 0;
|
|
8
|
-
var
|
|
9
|
-
var
|
|
8
|
+
var Ariakit = _interopRequireWildcard(require("@ariakit/react"));
|
|
9
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
10
10
|
var _warning = _interopRequireDefault(require("@wordpress/warning"));
|
|
11
11
|
var _element = require("@wordpress/element");
|
|
12
12
|
var _compose = require("@wordpress/compose");
|
|
13
13
|
var _context = require("./context");
|
|
14
14
|
var _styles = require("./styles");
|
|
15
|
-
var _clsx = _interopRequireDefault(require("clsx"));
|
|
16
15
|
var _elementRect = require("../utils/element-rect");
|
|
17
16
|
var _useTrackOverflow = require("./use-track-overflow");
|
|
18
17
|
var _useAnimatedOffsetRect = require("../utils/hooks/use-animated-offset-rect");
|
|
@@ -57,10 +56,21 @@ function useScrollRectIntoView(parent, rect, {
|
|
|
57
56
|
const childRightEdge = childLeft + childWidth;
|
|
58
57
|
const rightOverflow = childRightEdge + margin - parentRightEdge;
|
|
59
58
|
const leftOverflow = parentScroll - (childLeft - margin);
|
|
59
|
+
let scrollLeft = null;
|
|
60
60
|
if (leftOverflow > 0) {
|
|
61
|
-
|
|
61
|
+
scrollLeft = parentScroll - leftOverflow;
|
|
62
62
|
} else if (rightOverflow > 0) {
|
|
63
|
-
|
|
63
|
+
scrollLeft = parentScroll + rightOverflow;
|
|
64
|
+
}
|
|
65
|
+
if (scrollLeft !== null) {
|
|
66
|
+
/**
|
|
67
|
+
* The optional chaining is used here to avoid unit test failures.
|
|
68
|
+
* It can be removed when JSDOM supports `Element` scroll methods.
|
|
69
|
+
* See: https://github.com/WordPress/gutenberg/pull/66498#issuecomment-2441146096
|
|
70
|
+
*/
|
|
71
|
+
parent.scroll?.({
|
|
72
|
+
left: scrollLeft
|
|
73
|
+
});
|
|
64
74
|
}
|
|
65
75
|
}, [margin, parent, rect]);
|
|
66
76
|
}
|
|
@@ -72,13 +82,18 @@ const TabList = exports.TabList = (0, _element.forwardRef)(function TabList({
|
|
|
72
82
|
const {
|
|
73
83
|
store
|
|
74
84
|
} = (_useTabsContext = (0, _context.useTabsContext)()) !== null && _useTabsContext !== void 0 ? _useTabsContext : {};
|
|
75
|
-
const selectedId =
|
|
76
|
-
const activeId =
|
|
77
|
-
const selectOnMove =
|
|
78
|
-
const items =
|
|
85
|
+
const selectedId = Ariakit.useStoreState(store, 'selectedId');
|
|
86
|
+
const activeId = Ariakit.useStoreState(store, 'activeId');
|
|
87
|
+
const selectOnMove = Ariakit.useStoreState(store, 'selectOnMove');
|
|
88
|
+
const items = Ariakit.useStoreState(store, 'items');
|
|
79
89
|
const [parent, setParent] = (0, _element.useState)();
|
|
80
90
|
const refs = (0, _compose.useMergeRefs)([ref, setParent]);
|
|
81
|
-
const
|
|
91
|
+
const selectedItem = store?.item(selectedId);
|
|
92
|
+
const renderedItems = Ariakit.useStoreState(store, 'renderedItems');
|
|
93
|
+
const selectedItemIndex = renderedItems && selectedItem ? renderedItems.indexOf(selectedItem) : -1;
|
|
94
|
+
// Use selectedItemIndex as a dependency to force recalculation when the
|
|
95
|
+
// selected item index changes (elements are swapped / added / removed).
|
|
96
|
+
const selectedRect = (0, _elementRect.useTrackElementOffsetRect)(selectedItem?.element, [selectedItemIndex]);
|
|
82
97
|
|
|
83
98
|
// Track overflow to show scroll hints.
|
|
84
99
|
const overflow = (0, _useTrackOverflow.useTrackOverflow)(parent, {
|
|
@@ -90,7 +105,8 @@ const TabList = exports.TabList = (0, _element.forwardRef)(function TabList({
|
|
|
90
105
|
(0, _useAnimatedOffsetRect.useAnimatedOffsetRect)(parent, selectedRect, {
|
|
91
106
|
prefix: 'selected',
|
|
92
107
|
dataAttribute: 'indicator-animated',
|
|
93
|
-
transitionEndFilter: event => event.pseudoElement === '::before'
|
|
108
|
+
transitionEndFilter: event => event.pseudoElement === '::before',
|
|
109
|
+
roundRect: true
|
|
94
110
|
});
|
|
95
111
|
|
|
96
112
|
// Make sure selected tab is scrolled into view.
|
|
@@ -112,12 +128,19 @@ const TabList = exports.TabList = (0, _element.forwardRef)(function TabList({
|
|
|
112
128
|
globalThis.SCRIPT_DEBUG === true ? (0, _warning.default)('`Tabs.TabList` must be wrapped in a `Tabs` component.') : void 0;
|
|
113
129
|
return null;
|
|
114
130
|
}
|
|
115
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
131
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.StyledTabList, {
|
|
116
132
|
ref: refs,
|
|
117
133
|
store: store,
|
|
118
|
-
render:
|
|
134
|
+
render: props => {
|
|
135
|
+
var _props$tabIndex;
|
|
136
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
137
|
+
...props,
|
|
138
|
+
// Fallback to -1 to prevent browsers from making the tablist
|
|
139
|
+
// tabbable when it is a scrolling container.
|
|
140
|
+
tabIndex: (_props$tabIndex = props.tabIndex) !== null && _props$tabIndex !== void 0 ? _props$tabIndex : -1
|
|
141
|
+
});
|
|
142
|
+
},
|
|
119
143
|
onBlur: onBlur,
|
|
120
|
-
tabIndex: -1,
|
|
121
144
|
"data-select-on-move": selectOnMove ? 'true' : 'false',
|
|
122
145
|
...otherProps,
|
|
123
146
|
className: (0, _clsx.default)(overflow.first && 'is-overflowing-first', overflow.last && 'is-overflowing-last', otherProps.className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","Ariakit","_warning","_interopRequireDefault","_element","_compose","_context","_styles","_clsx","_elementRect","_useTrackOverflow","_useAnimatedOffsetRect","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DEFAULT_SCROLL_MARGIN","useScrollRectIntoView","parent","rect","margin","useLayoutEffect","scrollLeft","parentScroll","parentWidth","getBoundingClientRect","width","left","childLeft","childWidth","parentRightEdge","childRightEdge","rightOverflow","leftOverflow","TabList","exports","forwardRef","children","otherProps","ref","_useTabsContext","store","useTabsContext","selectedId","useStoreState","activeId","selectOnMove","items","setParent","useState","refs","useMergeRefs","selectedRect","useTrackElementOffsetRect","item","element","overflow","useTrackOverflow","first","at","last","useAnimatedOffsetRect","prefix","dataAttribute","transitionEndFilter","event","pseudoElement","onBlur","setActiveId","globalThis","SCRIPT_DEBUG","warning","jsx","render","TabListWrapper","tabIndex","className","clsx"],"sources":["@wordpress/components/src/tabs/tablist.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\nimport { useStoreState } from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport warning from '@wordpress/warning';\nimport { forwardRef, useLayoutEffect, useState } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { TabListProps } from './types';\nimport { useTabsContext } from './context';\nimport { TabListWrapper } from './styles';\nimport type { WordPressComponentProps } from '../context';\nimport clsx from 'clsx';\nimport type { ElementOffsetRect } from '../utils/element-rect';\nimport { useTrackElementOffsetRect } from '../utils/element-rect';\nimport { useTrackOverflow } from './use-track-overflow';\nimport { useAnimatedOffsetRect } from '../utils/hooks/use-animated-offset-rect';\n\nconst DEFAULT_SCROLL_MARGIN = 24;\n\n/**\n * Scrolls a given parent element so that a given rect is visible.\n *\n * The scroll is updated initially and whenever the rect changes.\n */\nfunction useScrollRectIntoView(\n\tparent: HTMLElement | undefined,\n\trect: ElementOffsetRect,\n\t{ margin = DEFAULT_SCROLL_MARGIN } = {}\n) {\n\tuseLayoutEffect( () => {\n\t\tif ( ! parent || ! rect ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { scrollLeft: parentScroll } = parent;\n\t\tconst parentWidth = parent.getBoundingClientRect().width;\n\t\tconst { left: childLeft, width: childWidth } = rect;\n\n\t\tconst parentRightEdge = parentScroll + parentWidth;\n\t\tconst childRightEdge = childLeft + childWidth;\n\t\tconst rightOverflow = childRightEdge + margin - parentRightEdge;\n\t\tconst leftOverflow = parentScroll - ( childLeft - margin );\n\t\tif ( leftOverflow > 0 ) {\n\t\t\tparent.scrollLeft = parentScroll - leftOverflow;\n\t\t} else if ( rightOverflow > 0 ) {\n\t\t\tparent.scrollLeft = parentScroll + rightOverflow;\n\t\t}\n\t}, [ margin, parent, rect ] );\n}\n\nexport const TabList = forwardRef<\n\tHTMLDivElement,\n\tWordPressComponentProps< TabListProps, 'div', false >\n>( function TabList( { children, ...otherProps }, ref ) {\n\tconst { store } = useTabsContext() ?? {};\n\n\tconst selectedId = useStoreState( store, 'selectedId' );\n\tconst activeId = useStoreState( store, 'activeId' );\n\tconst selectOnMove = useStoreState( store, 'selectOnMove' );\n\tconst items = useStoreState( store, 'items' );\n\tconst [ parent, setParent ] = useState< HTMLElement >();\n\tconst refs = useMergeRefs( [ ref, setParent ] );\n\tconst selectedRect = useTrackElementOffsetRect(\n\t\tstore?.item( selectedId )?.element\n\t);\n\n\t// Track overflow to show scroll hints.\n\tconst overflow = useTrackOverflow( parent, {\n\t\tfirst: items?.at( 0 )?.element,\n\t\tlast: items?.at( -1 )?.element,\n\t} );\n\n\t// Size, position, and animate the indicator.\n\tuseAnimatedOffsetRect( parent, selectedRect, {\n\t\tprefix: 'selected',\n\t\tdataAttribute: 'indicator-animated',\n\t\ttransitionEndFilter: ( event ) => event.pseudoElement === '::before',\n\t} );\n\n\t// Make sure selected tab is scrolled into view.\n\tuseScrollRectIntoView( parent, selectedRect );\n\n\tconst onBlur = () => {\n\t\tif ( ! selectOnMove ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// When automatic tab selection is on, make sure that the active tab is up\n\t\t// to date with the selected tab when leaving the tablist. This makes sure\n\t\t// that the selected tab will receive keyboard focus when tabbing back into\n\t\t// the tablist.\n\t\tif ( selectedId !== activeId ) {\n\t\t\tstore?.setActiveId( selectedId );\n\t\t}\n\t};\n\n\tif ( ! store ) {\n\t\twarning( '`Tabs.TabList` must be wrapped in a `Tabs` component.' );\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Ariakit.TabList\n\t\t\tref={ refs }\n\t\t\tstore={ store }\n\t\t\trender={ <TabListWrapper /> }\n\t\t\tonBlur={ onBlur }\n\t\t\ttabIndex={ -1 }\n\t\t\tdata-select-on-move={ selectOnMove ? 'true' : 'false' }\n\t\t\t{ ...otherProps }\n\t\t\tclassName={ clsx(\n\t\t\t\toverflow.first && 'is-overflowing-first',\n\t\t\t\toverflow.last && 'is-overflowing-last',\n\t\t\t\totherProps.className\n\t\t\t) }\n\t\t>\n\t\t\t{ children }\n\t\t</Ariakit.TabList>\n\t);\n} );\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA0C,IAAAC,OAAA,GAAAH,MAAA;AAM1C,IAAAI,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAMA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAEA,IAAAQ,KAAA,GAAAL,sBAAA,CAAAH,OAAA;AAEA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,iBAAA,GAAAV,OAAA;AACA,IAAAW,sBAAA,GAAAX,OAAA;AAAgF,IAAAY,WAAA,GAAAZ,OAAA;AAAA,SAAAa,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAf,wBAAAe,CAAA,EAAAE,CAAA,SAAAA,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,CAAA6E,GAAA,EAAClF,OAAA,CAAAoF,cAAc,IAAE,CAAG;IAC7BP,MAAM,EAAGA,MAAQ;IACjBQ,QAAQ,EAAG,CAAC,CAAG;IACf,uBAAsB7B,YAAY,GAAG,MAAM,GAAG,OAAS;IAAA,GAClDR,UAAU;IACfsC,SAAS,EAAG,IAAAC,aAAI,EACfrB,QAAQ,CAACE,KAAK,IAAI,sBAAsB,EACxCF,QAAQ,CAACI,IAAI,IAAI,qBAAqB,EACtCtB,UAAU,CAACsC,SACZ,CAAG;IAAAvC,QAAA,EAEDA;EAAQ,CACM,CAAC;AAEpB,CAAE,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Ariakit","_interopRequireWildcard","require","_clsx","_interopRequireDefault","_warning","_element","_compose","_context","_styles","_elementRect","_useTrackOverflow","_useAnimatedOffsetRect","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DEFAULT_SCROLL_MARGIN","useScrollRectIntoView","parent","rect","margin","useLayoutEffect","scrollLeft","parentScroll","parentWidth","getBoundingClientRect","width","left","childLeft","childWidth","parentRightEdge","childRightEdge","rightOverflow","leftOverflow","scroll","TabList","exports","forwardRef","children","otherProps","ref","_useTabsContext","store","useTabsContext","selectedId","useStoreState","activeId","selectOnMove","items","setParent","useState","refs","useMergeRefs","selectedItem","item","renderedItems","selectedItemIndex","indexOf","selectedRect","useTrackElementOffsetRect","element","overflow","useTrackOverflow","first","at","last","useAnimatedOffsetRect","prefix","dataAttribute","transitionEndFilter","event","pseudoElement","roundRect","onBlur","setActiveId","globalThis","SCRIPT_DEBUG","warning","jsx","StyledTabList","render","props","_props$tabIndex","tabIndex","className","clsx"],"sources":["@wordpress/components/src/tabs/tablist.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport warning from '@wordpress/warning';\nimport { forwardRef, useLayoutEffect, useState } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { TabListProps } from './types';\nimport type { WordPressComponentProps } from '../context';\nimport type { ElementOffsetRect } from '../utils/element-rect';\nimport { useTabsContext } from './context';\nimport { StyledTabList } from './styles';\nimport { useTrackElementOffsetRect } from '../utils/element-rect';\nimport { useTrackOverflow } from './use-track-overflow';\nimport { useAnimatedOffsetRect } from '../utils/hooks/use-animated-offset-rect';\n\nconst DEFAULT_SCROLL_MARGIN = 24;\n\n/**\n * Scrolls a given parent element so that a given rect is visible.\n *\n * The scroll is updated initially and whenever the rect changes.\n */\nfunction useScrollRectIntoView(\n\tparent: HTMLElement | undefined,\n\trect: ElementOffsetRect,\n\t{ margin = DEFAULT_SCROLL_MARGIN } = {}\n) {\n\tuseLayoutEffect( () => {\n\t\tif ( ! parent || ! rect ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { scrollLeft: parentScroll } = parent;\n\t\tconst parentWidth = parent.getBoundingClientRect().width;\n\t\tconst { left: childLeft, width: childWidth } = rect;\n\n\t\tconst parentRightEdge = parentScroll + parentWidth;\n\t\tconst childRightEdge = childLeft + childWidth;\n\t\tconst rightOverflow = childRightEdge + margin - parentRightEdge;\n\t\tconst leftOverflow = parentScroll - ( childLeft - margin );\n\n\t\tlet scrollLeft = null;\n\t\tif ( leftOverflow > 0 ) {\n\t\t\tscrollLeft = parentScroll - leftOverflow;\n\t\t} else if ( rightOverflow > 0 ) {\n\t\t\tscrollLeft = parentScroll + rightOverflow;\n\t\t}\n\n\t\tif ( scrollLeft !== null ) {\n\t\t\t/**\n\t\t\t * The optional chaining is used here to avoid unit test failures.\n\t\t\t * It can be removed when JSDOM supports `Element` scroll methods.\n\t\t\t * See: https://github.com/WordPress/gutenberg/pull/66498#issuecomment-2441146096\n\t\t\t */\n\t\t\tparent.scroll?.( { left: scrollLeft } );\n\t\t}\n\t}, [ margin, parent, rect ] );\n}\n\nexport const TabList = forwardRef<\n\tHTMLDivElement,\n\tWordPressComponentProps< TabListProps, 'div', false >\n>( function TabList( { children, ...otherProps }, ref ) {\n\tconst { store } = useTabsContext() ?? {};\n\n\tconst selectedId = Ariakit.useStoreState( store, 'selectedId' );\n\tconst activeId = Ariakit.useStoreState( store, 'activeId' );\n\tconst selectOnMove = Ariakit.useStoreState( store, 'selectOnMove' );\n\tconst items = Ariakit.useStoreState( store, 'items' );\n\tconst [ parent, setParent ] = useState< HTMLElement >();\n\tconst refs = useMergeRefs( [ ref, setParent ] );\n\n\tconst selectedItem = store?.item( selectedId );\n\tconst renderedItems = Ariakit.useStoreState( store, 'renderedItems' );\n\n\tconst selectedItemIndex =\n\t\trenderedItems && selectedItem\n\t\t\t? renderedItems.indexOf( selectedItem )\n\t\t\t: -1;\n\t// Use selectedItemIndex as a dependency to force recalculation when the\n\t// selected item index changes (elements are swapped / added / removed).\n\tconst selectedRect = useTrackElementOffsetRect( selectedItem?.element, [\n\t\tselectedItemIndex,\n\t] );\n\n\t// Track overflow to show scroll hints.\n\tconst overflow = useTrackOverflow( parent, {\n\t\tfirst: items?.at( 0 )?.element,\n\t\tlast: items?.at( -1 )?.element,\n\t} );\n\n\t// Size, position, and animate the indicator.\n\tuseAnimatedOffsetRect( parent, selectedRect, {\n\t\tprefix: 'selected',\n\t\tdataAttribute: 'indicator-animated',\n\t\ttransitionEndFilter: ( event ) => event.pseudoElement === '::before',\n\t\troundRect: true,\n\t} );\n\n\t// Make sure selected tab is scrolled into view.\n\tuseScrollRectIntoView( parent, selectedRect );\n\n\tconst onBlur = () => {\n\t\tif ( ! selectOnMove ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// When automatic tab selection is on, make sure that the active tab is up\n\t\t// to date with the selected tab when leaving the tablist. This makes sure\n\t\t// that the selected tab will receive keyboard focus when tabbing back into\n\t\t// the tablist.\n\t\tif ( selectedId !== activeId ) {\n\t\t\tstore?.setActiveId( selectedId );\n\t\t}\n\t};\n\n\tif ( ! store ) {\n\t\twarning( '`Tabs.TabList` must be wrapped in a `Tabs` component.' );\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StyledTabList\n\t\t\tref={ refs }\n\t\t\tstore={ store }\n\t\t\trender={ ( props ) => (\n\t\t\t\t<div\n\t\t\t\t\t{ ...props }\n\t\t\t\t\t// Fallback to -1 to prevent browsers from making the tablist\n\t\t\t\t\t// tabbable when it is a scrolling container.\n\t\t\t\t\ttabIndex={ props.tabIndex ?? -1 }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\tonBlur={ onBlur }\n\t\t\tdata-select-on-move={ selectOnMove ? 'true' : 'false' }\n\t\t\t{ ...otherProps }\n\t\t\tclassName={ clsx(\n\t\t\t\toverflow.first && 'is-overflowing-first',\n\t\t\t\toverflow.last && 'is-overflowing-last',\n\t\t\t\totherProps.className\n\t\t\t) }\n\t\t>\n\t\t\t{ children }\n\t\t</StyledTabList>\n\t);\n} );\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAQA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,iBAAA,GAAAT,OAAA;AACA,IAAAU,sBAAA,GAAAV,OAAA;AAAgF,IAAAW,WAAA,GAAAX,OAAA;AAAA,SAAAY,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAd,wBAAAc,CA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AEwC,YAAa,CAAC;EAE7C,MAAMe,MAAM,GAAGA,CAAA,KAAM;IACpB,IAAK,CAAE1B,YAAY,EAAG;MACrB;IACD;;IAEA;IACA;IACA;IACA;IACA,IAAKH,UAAU,KAAKE,QAAQ,EAAG;MAC9BJ,KAAK,EAAEgC,WAAW,CAAE9B,UAAW,CAAC;IACjC;EACD,CAAC;EAED,IAAK,CAAEF,KAAK,EAAG;IACdiC,UAAA,CAAAC,YAAA,gBAAAC,gBAAO,EAAE,uDAAwD,CAAC;IAClE,OAAO,IAAI;EACZ;EAEA,oBACC,IAAAlF,WAAA,CAAAmF,GAAA,EAACvF,OAAA,CAAAwF,aAAa;IACbvC,GAAG,EAAGW,IAAM;IACZT,KAAK,EAAGA,KAAO;IACfsC,MAAM,EAAKC,KAAK;MAAA,IAAAC,eAAA;MAAA,oBACf,IAAAvF,WAAA,CAAAmF,GAAA;QAAA,GACMG,KAAK;QACV;QACA;QACAE,QAAQ,GAAAD,eAAA,GAAGD,KAAK,CAACE,QAAQ,cAAAD,eAAA,cAAAA,eAAA,GAAI,CAAC;MAAG,CACjC,CAAC;IAAA,CACA;IACHT,MAAM,EAAGA,MAAQ;IACjB,uBAAsB1B,YAAY,GAAG,MAAM,GAAG,OAAS;IAAA,GAClDR,UAAU;IACf6C,SAAS,EAAG,IAAAC,aAAI,EACfxB,QAAQ,CAACE,KAAK,IAAI,sBAAsB,EACxCF,QAAQ,CAACI,IAAI,IAAI,qBAAqB,EACtC1B,UAAU,CAAC6C,SACZ,CAAG;IAAA9C,QAAA,EAEDA;EAAQ,CACI,CAAC;AAElB,CAAE,CAAC","ignoreList":[]}
|
package/build/tabs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/components/src/tabs/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type * as Ariakit from '@ariakit/react';\n\nexport type TabsContextProps =\n\t| {\n\t\t\t/**\n\t\t\t * The tabStore object returned by Ariakit's `useTabStore` hook.\n\t\t\t */\n\t\t\tstore: Ariakit.TabStore;\n\t\t\t/**\n\t\t\t * The unique id string for this instance of the Tabs component.\n\t\t\t */\n\t\t\tinstanceId: string;\n\t }\n\t| undefined;\n\nexport type TabsProps = {\n\t/**\n\t * The children elements, which should
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/components/src/tabs/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type * as Ariakit from '@ariakit/react';\n\nexport type TabsContextProps =\n\t| {\n\t\t\t/**\n\t\t\t * The tabStore object returned by Ariakit's `useTabStore` hook.\n\t\t\t */\n\t\t\tstore: Ariakit.TabStore;\n\t\t\t/**\n\t\t\t * The unique id string for this instance of the Tabs component.\n\t\t\t */\n\t\t\tinstanceId: string;\n\t }\n\t| undefined;\n\nexport type TabsProps = {\n\t/**\n\t * The children elements, which should include one instance of the\n\t * `Tabs.Tablist` component and as many instances of the `Tabs.TabPanel`\n\t * components as there are `Tabs.Tab` components.\n\t */\n\tchildren: Ariakit.TabProps[ 'children' ];\n\t/**\n\t * Determines if the tab should be selected when it receives focus. If set to\n\t * `false`, the tab will only be selected upon clicking, not when using arrow\n\t * keys to shift focus (manual tab activation). See the official W3C docs\n\t * for more info.\n\t *\n\t * @default true\n\t *\n\t * @see https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/\n\t */\n\tselectOnMove?: Ariakit.TabStoreProps[ 'selectOnMove' ];\n\t/**\n\t * The id of the tab whose panel is currently visible.\n\t *\n\t * If left `undefined`, it will be automatically set to the first enabled\n\t * tab, and the component assumes it is being used in \"uncontrolled\" mode.\n\t *\n\t * Consequently, any value different than `undefined` will set the component\n\t * in \"controlled\" mode. When in \"controlled\" mode, the `null` value will\n\t * result in no tabs being selected, and the tablist becoming tabbable.\n\t */\n\tselectedTabId?: Ariakit.TabStoreProps[ 'selectedId' ];\n\t/**\n\t * The id of the tab whose panel is currently visible.\n\t *\n\t * If left `undefined`, it will be automatically set to the first enabled\n\t * tab. If set to `null`, no tab will be selected, and the tablist will be\n\t * tabbable.\n\t *\n\t * Note: this prop will be overridden by the `selectedTabId` prop if it is\n\t * provided (meaning the component will be used in \"controlled\" mode).\n\t */\n\tdefaultTabId?: Ariakit.TabStoreProps[ 'defaultSelectedId' ];\n\t/**\n\t * The function called when the `selectedTabId` changes.\n\t */\n\tonSelect?: Ariakit.TabStoreProps[ 'setSelectedId' ];\n\t/**\n\t * The current active tab `id`. The active tab is the tab element within the\n\t * tablist widget that has DOM focus.\n\t * - `null` represents the tablist (ie. the base composite element). Users\n\t * will be able to navigate out of it using arrow keys.\n\t * - If `activeTabId` is initially set to `null`, the base composite element\n\t * itself will have focus and users will be able to navigate to it using\n\t * arrow keys.activeTabId\n\t */\n\tactiveTabId?: Ariakit.TabStoreProps[ 'activeId' ];\n\t/**\n\t * The tab id that should be active by default when the composite widget is\n\t * rendered. If `null`, the tablist element itself will have focus\n\t * and users will be able to navigate to it using arrow keys. If `undefined`,\n\t * the first enabled item will be focused.\n\t *\n\t * Note: this prop will be overridden by the `activeTabId` prop if it is\n\t * provided.\n\t */\n\tdefaultActiveTabId?: Ariakit.TabStoreProps[ 'defaultActiveId' ];\n\t/**\n\t * A callback that gets called when the `activeTabId` state changes.\n\t */\n\tonActiveTabIdChange?: Ariakit.TabStoreProps[ 'setActiveId' ];\n\t/**\n\t * Defines the orientation of the tablist and determines which arrow keys\n\t * can be used to move focus:\n\t * - `both`: all arrow keys work.\n\t * - `horizontal`: only left and right arrow keys work.\n\t * - `vertical`: only up and down arrow keys work.\n\t *\n\t * @default \"horizontal\"\n\t */\n\torientation?: Ariakit.TabStoreProps[ 'orientation' ];\n};\n\nexport type TabListProps = {\n\t/**\n\t * The children elements, which should include one or more instances of the\n\t * `Tabs.Tab` component.\n\t */\n\tchildren: Ariakit.TabListProps[ 'children' ];\n};\n\n// TODO: consider prop name changes (tabId, selectedTabId)\n// switch to auto-generated README\n// compound technique\n\nexport type TabProps = {\n\t/**\n\t * The unique ID of the tab. It will be used to register the tab and match\n\t * it to a corresponding `Tabs.TabPanel` component.\n\t */\n\ttabId: NonNullable< Ariakit.TabProps[ 'id' ] >;\n\t/**\n\t * The contents of the tab.\n\t */\n\tchildren?: Ariakit.TabProps[ 'children' ];\n\t/**\n\t * Determines if the tab should be disabled. Note that disabled tabs can\n\t * still be accessed via the keyboard when navigating through the tablist.\n\t *\n\t * @default false\n\t */\n\tdisabled?: Ariakit.TabProps[ 'disabled' ];\n\t/**\n\t * Allows the component to be rendered as a different HTML element or React\n\t * component. The value can be a React element or a function that takes in the\n\t * original component props and gives back a React element with the props\n\t * merged.\n\t *\n\t * By default, the tab will be rendered as a `button` element.\n\t */\n\trender?: Ariakit.TabProps[ 'render' ];\n};\n\nexport type TabPanelProps = {\n\t/**\n\t * The contents of the tab panel.\n\t */\n\tchildren?: Ariakit.TabPanelProps[ 'children' ];\n\t/**\n\t * The unique `id` of the `Tabs.Tab` component controlling this panel. This\n\t * connection is used to assign the `aria-labelledby` attribute to the tab\n\t * panel and to determine if the tab panel should be visible.\n\t *\n\t * If not provided, this link is automatically established by matching the\n\t * order of `Tabs.Tab` and `Tabs.TabPanel` elements in the DOM.\n\t */\n\ttabId: NonNullable< Ariakit.TabPanelProps[ 'tabId' ] >;\n\t/**\n\t * Determines whether or not the tabpanel element should be focusable.\n\t * If `false`, pressing the tab key will skip over the tabpanel, and instead\n\t * focus on the first focusable element in the panel (if there is one).\n\t *\n\t * @default true\n\t */\n\tfocusable?: Ariakit.TabPanelProps[ 'focusable' ];\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -52,11 +52,12 @@ function UnconnectedToggleGroupControl(props, forwardedRef) {
|
|
|
52
52
|
const [selectedElement, setSelectedElement] = (0, _element.useState)();
|
|
53
53
|
const [controlElement, setControlElement] = (0, _element.useState)();
|
|
54
54
|
const refs = (0, _compose.useMergeRefs)([setControlElement, forwardedRef]);
|
|
55
|
-
const selectedRect = (0, _elementRect.useTrackElementOffsetRect)(value ? selectedElement : undefined);
|
|
55
|
+
const selectedRect = (0, _elementRect.useTrackElementOffsetRect)(value || value === 0 ? selectedElement : undefined);
|
|
56
56
|
(0, _useAnimatedOffsetRect.useAnimatedOffsetRect)(controlElement, selectedRect, {
|
|
57
57
|
prefix: 'selected',
|
|
58
58
|
dataAttribute: 'indicator-animated',
|
|
59
|
-
transitionEndFilter: event => event.pseudoElement === '::before'
|
|
59
|
+
transitionEndFilter: event => event.pseudoElement === '::before',
|
|
60
|
+
roundRect: true
|
|
60
61
|
});
|
|
61
62
|
const cx = (0, _hooks.useCx)();
|
|
62
63
|
const classes = (0, _element.useMemo)(() => cx(styles.toggleGroupControl({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_context","_hooks","_baseControl","_interopRequireDefault","_styles","_interopRequireWildcard","styles","_asRadioGroup","_asButtonGroup","_elementRect","_compose","_useAnimatedOffsetRect","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","UnconnectedToggleGroupControl","props","forwardedRef","__nextHasNoMarginBottom","__next40pxDefaultSize","className","isAdaptiveWidth","isBlock","isDeselectable","label","hideLabelFromVision","help","onChange","size","value","children","otherProps","useContextSystem","normalizedSize","selectedElement","setSelectedElement","useState","controlElement","setControlElement","refs","useMergeRefs","selectedRect","useTrackElementOffsetRect","undefined","useAnimatedOffsetRect","prefix","dataAttribute","transitionEndFilter","event","pseudoElement","cx","useCx","classes","useMemo","toggleGroupControl","block","MainControl","ToggleGroupControlAsButtonGroup","ToggleGroupControlAsRadioGroup","jsxs","__associatedWPComponentName","jsx","VisualLabelWrapper","VisualLabel","ref","ToggleGroupControl","exports","contextConnect","_default"],"sources":["@wordpress/components/src/toggle-group-control/toggle-group-control/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect, useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks';\nimport BaseControl from '../../base-control';\nimport type { ToggleGroupControlProps } from '../types';\nimport { VisualLabelWrapper } from './styles';\nimport * as styles from './styles';\nimport { ToggleGroupControlAsRadioGroup } from './as-radio-group';\nimport { ToggleGroupControlAsButtonGroup } from './as-button-group';\nimport { useTrackElementOffsetRect } from '../../utils/element-rect';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { useAnimatedOffsetRect } from '../../utils/hooks/use-animated-offset-rect';\n\nfunction UnconnectedToggleGroupControl(\n\tprops: WordPressComponentProps< ToggleGroupControlProps, 'div', false >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\t__nextHasNoMarginBottom = false,\n\t\t__next40pxDefaultSize = false,\n\t\tclassName,\n\t\tisAdaptiveWidth = false,\n\t\tisBlock = false,\n\t\tisDeselectable = false,\n\t\tlabel,\n\t\thideLabelFromVision = false,\n\t\thelp,\n\t\tonChange,\n\t\tsize = 'default',\n\t\tvalue,\n\t\tchildren,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToggleGroupControl' );\n\n\tconst normalizedSize =\n\t\t__next40pxDefaultSize && size === 'default' ? '__unstable-large' : size;\n\n\tconst [ selectedElement, setSelectedElement ] = useState< HTMLElement >();\n\tconst [ controlElement, setControlElement ] = useState< HTMLElement >();\n\tconst refs = useMergeRefs( [ setControlElement, forwardedRef ] );\n\tconst selectedRect = useTrackElementOffsetRect(\n\t\tvalue ? selectedElement : undefined\n\t);\n\tuseAnimatedOffsetRect( controlElement, selectedRect, {\n\t\tprefix: 'selected',\n\t\tdataAttribute: 'indicator-animated',\n\t\ttransitionEndFilter: ( event ) => event.pseudoElement === '::before',\n\t} );\n\n\tconst cx = useCx();\n\n\tconst classes = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\tstyles.toggleGroupControl( {\n\t\t\t\t\tisBlock,\n\t\t\t\t\tisDeselectable,\n\t\t\t\t\tsize: normalizedSize,\n\t\t\t\t} ),\n\t\t\t\tisBlock && styles.block,\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ className, cx, isBlock, isDeselectable, normalizedSize ]\n\t);\n\n\tconst MainControl = isDeselectable\n\t\t? ToggleGroupControlAsButtonGroup\n\t\t: ToggleGroupControlAsRadioGroup;\n\n\treturn (\n\t\t<BaseControl\n\t\t\thelp={ help }\n\t\t\t__nextHasNoMarginBottom={ __nextHasNoMarginBottom }\n\t\t\t__associatedWPComponentName=\"ToggleGroupControl\"\n\t\t>\n\t\t\t{ ! hideLabelFromVision && (\n\t\t\t\t<VisualLabelWrapper>\n\t\t\t\t\t<BaseControl.VisualLabel>{ label }</BaseControl.VisualLabel>\n\t\t\t\t</VisualLabelWrapper>\n\t\t\t) }\n\t\t\t<MainControl\n\t\t\t\t{ ...otherProps }\n\t\t\t\tsetSelectedElement={ setSelectedElement }\n\t\t\t\tclassName={ classes }\n\t\t\t\tisAdaptiveWidth={ isAdaptiveWidth }\n\t\t\t\tlabel={ label }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tref={ refs }\n\t\t\t\tsize={ normalizedSize }\n\t\t\t\tvalue={ value }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</MainControl>\n\t\t</BaseControl>\n\t);\n}\n\n/**\n * `ToggleGroupControl` is a form component that lets users choose options\n * represented in horizontal segments. To render options for this control use\n * `ToggleGroupControlOption` component.\n *\n * This component is intended for selecting a single persistent value from a set of options,\n * similar to a how a radio button group would work. If you simply want a toggle to switch between views,\n * use a `TabPanel` instead.\n *\n * Only use this control when you know for sure the labels of items inside won't\n * wrap. For items with longer labels, you can consider a `SelectControl` or a\n * `CustomSelectControl` component instead.\n *\n * ```jsx\n * import {\n * __experimentalToggleGroupControl as ToggleGroupControl,\n * __experimentalToggleGroupControlOption as ToggleGroupControlOption,\n * } from '@wordpress/components';\n *\n * function Example() {\n * return (\n * <ToggleGroupControl\n * label=\"my label\"\n * value=\"vertical\"\n * isBlock\n * __nextHasNoMarginBottom\n * >\n * <ToggleGroupControlOption value=\"horizontal\" label=\"Horizontal\" />\n * <ToggleGroupControlOption value=\"vertical\" label=\"Vertical\" />\n * </ToggleGroupControl>\n * );\n * }\n * ```\n */\nexport const ToggleGroupControl = contextConnect(\n\tUnconnectedToggleGroupControl,\n\t'ToggleGroupControl'\n);\n\nexport default ToggleGroupControl;\n"],"mappings":";;;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAEA,IAAAK,OAAA,GAAAC,uBAAA,CAAAN,OAAA;AAA8C,IAAAO,MAAA,GAAAF,OAAA;AAE9C,IAAAG,aAAA,GAAAR,OAAA;AACA,IAAAS,cAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AACA,IAAAW,QAAA,GAAAX,OAAA;AACA,IAAAY,sBAAA,GAAAZ,OAAA;AAAmF,IAAAa,WAAA,GAAAb,OAAA;AAAA,SAAAc,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,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CAAE,GAAG,IAAAF,iBAAQ,EAAgB,CAAC;EACvE,MAAMG,IAAI,GAAG,IAAAC,qBAAY,EAAE,CAAEF,iBAAiB,EAAErB,YAAY,CAAG,CAAC;EAChE,MAAMwB,YAAY,GAAG,IAAAC,sCAAyB,EAC7Cb,KAAK,GAAGK,eAAe,GAAGS,
|
|
1
|
+
{"version":3,"names":["_element","require","_context","_hooks","_baseControl","_interopRequireDefault","_styles","_interopRequireWildcard","styles","_asRadioGroup","_asButtonGroup","_elementRect","_compose","_useAnimatedOffsetRect","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","UnconnectedToggleGroupControl","props","forwardedRef","__nextHasNoMarginBottom","__next40pxDefaultSize","className","isAdaptiveWidth","isBlock","isDeselectable","label","hideLabelFromVision","help","onChange","size","value","children","otherProps","useContextSystem","normalizedSize","selectedElement","setSelectedElement","useState","controlElement","setControlElement","refs","useMergeRefs","selectedRect","useTrackElementOffsetRect","undefined","useAnimatedOffsetRect","prefix","dataAttribute","transitionEndFilter","event","pseudoElement","roundRect","cx","useCx","classes","useMemo","toggleGroupControl","block","MainControl","ToggleGroupControlAsButtonGroup","ToggleGroupControlAsRadioGroup","jsxs","__associatedWPComponentName","jsx","VisualLabelWrapper","VisualLabel","ref","ToggleGroupControl","exports","contextConnect","_default"],"sources":["@wordpress/components/src/toggle-group-control/toggle-group-control/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect, useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks';\nimport BaseControl from '../../base-control';\nimport type { ToggleGroupControlProps } from '../types';\nimport { VisualLabelWrapper } from './styles';\nimport * as styles from './styles';\nimport { ToggleGroupControlAsRadioGroup } from './as-radio-group';\nimport { ToggleGroupControlAsButtonGroup } from './as-button-group';\nimport { useTrackElementOffsetRect } from '../../utils/element-rect';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { useAnimatedOffsetRect } from '../../utils/hooks/use-animated-offset-rect';\n\nfunction UnconnectedToggleGroupControl(\n\tprops: WordPressComponentProps< ToggleGroupControlProps, 'div', false >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\t__nextHasNoMarginBottom = false,\n\t\t__next40pxDefaultSize = false,\n\t\tclassName,\n\t\tisAdaptiveWidth = false,\n\t\tisBlock = false,\n\t\tisDeselectable = false,\n\t\tlabel,\n\t\thideLabelFromVision = false,\n\t\thelp,\n\t\tonChange,\n\t\tsize = 'default',\n\t\tvalue,\n\t\tchildren,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToggleGroupControl' );\n\n\tconst normalizedSize =\n\t\t__next40pxDefaultSize && size === 'default' ? '__unstable-large' : size;\n\n\tconst [ selectedElement, setSelectedElement ] = useState< HTMLElement >();\n\tconst [ controlElement, setControlElement ] = useState< HTMLElement >();\n\tconst refs = useMergeRefs( [ setControlElement, forwardedRef ] );\n\tconst selectedRect = useTrackElementOffsetRect(\n\t\tvalue || value === 0 ? selectedElement : undefined\n\t);\n\tuseAnimatedOffsetRect( controlElement, selectedRect, {\n\t\tprefix: 'selected',\n\t\tdataAttribute: 'indicator-animated',\n\t\ttransitionEndFilter: ( event ) => event.pseudoElement === '::before',\n\t\troundRect: true,\n\t} );\n\n\tconst cx = useCx();\n\n\tconst classes = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\tstyles.toggleGroupControl( {\n\t\t\t\t\tisBlock,\n\t\t\t\t\tisDeselectable,\n\t\t\t\t\tsize: normalizedSize,\n\t\t\t\t} ),\n\t\t\t\tisBlock && styles.block,\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ className, cx, isBlock, isDeselectable, normalizedSize ]\n\t);\n\n\tconst MainControl = isDeselectable\n\t\t? ToggleGroupControlAsButtonGroup\n\t\t: ToggleGroupControlAsRadioGroup;\n\n\treturn (\n\t\t<BaseControl\n\t\t\thelp={ help }\n\t\t\t__nextHasNoMarginBottom={ __nextHasNoMarginBottom }\n\t\t\t__associatedWPComponentName=\"ToggleGroupControl\"\n\t\t>\n\t\t\t{ ! hideLabelFromVision && (\n\t\t\t\t<VisualLabelWrapper>\n\t\t\t\t\t<BaseControl.VisualLabel>{ label }</BaseControl.VisualLabel>\n\t\t\t\t</VisualLabelWrapper>\n\t\t\t) }\n\t\t\t<MainControl\n\t\t\t\t{ ...otherProps }\n\t\t\t\tsetSelectedElement={ setSelectedElement }\n\t\t\t\tclassName={ classes }\n\t\t\t\tisAdaptiveWidth={ isAdaptiveWidth }\n\t\t\t\tlabel={ label }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tref={ refs }\n\t\t\t\tsize={ normalizedSize }\n\t\t\t\tvalue={ value }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</MainControl>\n\t\t</BaseControl>\n\t);\n}\n\n/**\n * `ToggleGroupControl` is a form component that lets users choose options\n * represented in horizontal segments. To render options for this control use\n * `ToggleGroupControlOption` component.\n *\n * This component is intended for selecting a single persistent value from a set of options,\n * similar to a how a radio button group would work. If you simply want a toggle to switch between views,\n * use a `TabPanel` instead.\n *\n * Only use this control when you know for sure the labels of items inside won't\n * wrap. For items with longer labels, you can consider a `SelectControl` or a\n * `CustomSelectControl` component instead.\n *\n * ```jsx\n * import {\n * __experimentalToggleGroupControl as ToggleGroupControl,\n * __experimentalToggleGroupControlOption as ToggleGroupControlOption,\n * } from '@wordpress/components';\n *\n * function Example() {\n * return (\n * <ToggleGroupControl\n * label=\"my label\"\n * value=\"vertical\"\n * isBlock\n * __nextHasNoMarginBottom\n * >\n * <ToggleGroupControlOption value=\"horizontal\" label=\"Horizontal\" />\n * <ToggleGroupControlOption value=\"vertical\" label=\"Vertical\" />\n * </ToggleGroupControl>\n * );\n * }\n * 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AAe,EAAGA,eAAiB;MACnCG,KAAK,EAAGA,KAAO;MACfG,QAAQ,EAAGA,QAAU;MACrBsC,GAAG,EAAG1B,IAAM;MACZX,IAAI,EAAGK,cAAgB;MACvBJ,KAAK,EAAGA,KAAO;MAAAC,QAAA,EAEbA;IAAQ,CACE,CAAC;EAAA,CACF,CAAC;AAEhB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMoC,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,IAAAE,uBAAc,EAC/CrD,6BAA6B,EAC7B,oBACD,CAAC;AAAC,IAAAsD,QAAA,GAAAF,OAAA,CAAAlE,OAAA,GAEaiE,kBAAkB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_element","_deprecated","_toolbarGroup","_toolbarContainer","_context","_jsxRuntime","UnforwardedToolbar","className","label","variant","props","ref","isVariantDefined","undefined","contextSystemValue","useMemo","DropdownMenu","Dropdown","deprecated","since","alternative","link","title","_title","restProps","jsx","default","isCollapsed","finalClassName","clsx","ContextSystemProvider","value","children","Toolbar","exports","forwardRef","_default"],"sources":["@wordpress/components/src/toolbar/toolbar/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport ToolbarGroup from '../toolbar-group';\nimport ToolbarContainer from './toolbar-container';\nimport type { ToolbarProps } from './types';\nimport type { WordPressComponentProps } from '../../context';\nimport { ContextSystemProvider } from '../../context';\n\nfunction UnforwardedToolbar(\n\t{\n\t\tclassName,\n\t\tlabel,\n\t\tvariant,\n\t\t...props\n\t}: WordPressComponentProps< ToolbarProps, 'div', false >,\n\tref: ForwardedRef< any >\n) {\n\tconst isVariantDefined = variant !== undefined;\n\tconst contextSystemValue = useMemo( () => {\n\t\tif ( isVariantDefined ) {\n\t\t\treturn {};\n\t\t}\n\t\treturn {\n\t\t\tDropdownMenu: {\n\t\t\t\tvariant: 'toolbar',\n\t\t\t},\n\t\t\tDropdown: {\n\t\t\t\tvariant: 'toolbar',\n\t\t\t},\n\t\t};\n\t}, [ isVariantDefined ] );\n\n\tif ( ! label ) {\n\t\tdeprecated( 'Using Toolbar without label prop', {\n\t\t\tsince: '5.6',\n\t\t\talternative: 'ToolbarGroup component',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/components/toolbar/',\n\t\t} );\n\t\t// Extracting title from `props` because `ToolbarGroup` doesn't accept it.\n\t\tconst { title: _title, ...restProps } = props;\n\t\treturn (\n\t\t\t<ToolbarGroup\n\t\t\t\tisCollapsed={ false }\n\t\t\t\t{ ...restProps }\n\t\t\t\tclassName={ className }\n\t\t\t/>\n\t\t);\n\t}\n\t// `ToolbarGroup` already uses components-toolbar for compatibility reasons.\n\tconst finalClassName = clsx(\n\t\t'components-accessible-toolbar',\n\t\tclassName,\n\t\tvariant && `is-${ variant }`\n\t);\n\n\treturn (\n\t\t<ContextSystemProvider value={ contextSystemValue }>\n\t\t\t<ToolbarContainer\n\t\t\t\tclassName={ finalClassName }\n\t\t\t\tlabel={ label }\n\t\t\t\tref={ ref }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t</ContextSystemProvider>\n\t);\n}\n\n/**\n * Renders a toolbar.\n *\n * To add controls, simply pass `ToolbarButton` components as children.\n *\n * ```jsx\n * import { Toolbar, ToolbarButton } from '@wordpress/components';\n * import { formatBold, formatItalic, link } from '@wordpress/icons';\n *\n * function MyToolbar() {\n * return (\n * <Toolbar label=\"Options\">\n * <ToolbarButton icon={ formatBold } label=\"Bold\" />\n * <ToolbarButton icon={ formatItalic } label=\"Italic\" />\n * <ToolbarButton icon={ link } label=\"Link\" />\n * </Toolbar>\n * );\n * }\n * ```\n */\nexport const Toolbar = forwardRef( UnforwardedToolbar );\nexport default Toolbar;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAH,sBAAA,CAAAC,OAAA;AAKA,IAAAG,aAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,iBAAA,GAAAL,sBAAA,CAAAC,OAAA;AAGA,IAAAK,QAAA,GAAAL,OAAA;AAAsD,IAAAM,WAAA,GAAAN,OAAA;AAnBtD;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;;AAOA,SAASO,kBAAkBA,CAC1B;EACCC,SAAS;EACTC,KAAK;EACLC,OAAO;EACP,GAAGC;AACmD,CAAC,EACxDC,GAAwB,EACvB;EACD,MAAMC,gBAAgB,GAAGH,OAAO,KAAKI,SAAS;EAC9C,MAAMC,kBAAkB,GAAG,IAAAC,gBAAO,EAAE,MAAM;IACzC,IAAKH,gBAAgB,EAAG;MACvB,OAAO,CAAC,CAAC;IACV;IACA,OAAO;MACNI,YAAY,EAAE;QACbP,OAAO,EAAE;MACV,CAAC;MACDQ,QAAQ,EAAE;QACTR,OAAO,EAAE;MACV;IACD,CAAC;EACF,CAAC,EAAE,CAAEG,gBAAgB,CAAG,CAAC;EAEzB,IAAK,CAAEJ,KAAK,EAAG;IACd,
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_element","_deprecated","_toolbarGroup","_toolbarContainer","_context","_jsxRuntime","UnforwardedToolbar","className","label","variant","props","ref","isVariantDefined","undefined","contextSystemValue","useMemo","DropdownMenu","Dropdown","Menu","deprecated","since","alternative","link","title","_title","restProps","jsx","default","isCollapsed","finalClassName","clsx","ContextSystemProvider","value","children","Toolbar","exports","forwardRef","_default"],"sources":["@wordpress/components/src/toolbar/toolbar/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useMemo } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport ToolbarGroup from '../toolbar-group';\nimport ToolbarContainer from './toolbar-container';\nimport type { ToolbarProps } from './types';\nimport type { WordPressComponentProps } from '../../context';\nimport { ContextSystemProvider } from '../../context';\n\nfunction UnforwardedToolbar(\n\t{\n\t\tclassName,\n\t\tlabel,\n\t\tvariant,\n\t\t...props\n\t}: WordPressComponentProps< ToolbarProps, 'div', false >,\n\tref: ForwardedRef< any >\n) {\n\tconst isVariantDefined = variant !== undefined;\n\tconst contextSystemValue = useMemo( () => {\n\t\tif ( isVariantDefined ) {\n\t\t\treturn {};\n\t\t}\n\t\treturn {\n\t\t\tDropdownMenu: {\n\t\t\t\tvariant: 'toolbar',\n\t\t\t},\n\t\t\tDropdown: {\n\t\t\t\tvariant: 'toolbar',\n\t\t\t},\n\t\t\tMenu: {\n\t\t\t\tvariant: 'toolbar',\n\t\t\t},\n\t\t};\n\t}, [ isVariantDefined ] );\n\n\tif ( ! label ) {\n\t\tdeprecated( 'Using Toolbar without label prop', {\n\t\t\tsince: '5.6',\n\t\t\talternative: 'ToolbarGroup component',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/components/toolbar/',\n\t\t} );\n\t\t// Extracting title from `props` because `ToolbarGroup` doesn't accept it.\n\t\tconst { title: _title, ...restProps } = props;\n\t\treturn (\n\t\t\t<ToolbarGroup\n\t\t\t\tisCollapsed={ false }\n\t\t\t\t{ ...restProps }\n\t\t\t\tclassName={ className }\n\t\t\t/>\n\t\t);\n\t}\n\t// `ToolbarGroup` already uses components-toolbar for compatibility reasons.\n\tconst finalClassName = clsx(\n\t\t'components-accessible-toolbar',\n\t\tclassName,\n\t\tvariant && `is-${ variant }`\n\t);\n\n\treturn (\n\t\t<ContextSystemProvider value={ contextSystemValue }>\n\t\t\t<ToolbarContainer\n\t\t\t\tclassName={ finalClassName }\n\t\t\t\tlabel={ label }\n\t\t\t\tref={ ref }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t</ContextSystemProvider>\n\t);\n}\n\n/**\n * Renders a toolbar.\n *\n * To add controls, simply pass `ToolbarButton` components as children.\n *\n * ```jsx\n * import { Toolbar, ToolbarButton } from '@wordpress/components';\n * import { formatBold, formatItalic, link } from '@wordpress/icons';\n *\n * function MyToolbar() {\n * return (\n * <Toolbar label=\"Options\">\n * <ToolbarButton icon={ formatBold } label=\"Bold\" />\n * <ToolbarButton icon={ formatItalic } label=\"Italic\" />\n * <ToolbarButton icon={ link } label=\"Link\" />\n * </Toolbar>\n * );\n * }\n * ```\n */\nexport const Toolbar = forwardRef( UnforwardedToolbar );\nexport default Toolbar;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAH,sBAAA,CAAAC,OAAA;AAKA,IAAAG,aAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,iBAAA,GAAAL,sBAAA,CAAAC,OAAA;AAGA,IAAAK,QAAA,GAAAL,OAAA;AAAsD,IAAAM,WAAA,GAAAN,OAAA;AAnBtD;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;;AAOA,SAASO,kBAAkBA,CAC1B;EACCC,SAAS;EACTC,KAAK;EACLC,OAAO;EACP,GAAGC;AACmD,CAAC,EACxDC,GAAwB,EACvB;EACD,MAAMC,gBAAgB,GAAGH,OAAO,KAAKI,SAAS;EAC9C,MAAMC,kBAAkB,GAAG,IAAAC,gBAAO,EAAE,MAAM;IACzC,IAAKH,gBAAgB,EAAG;MACvB,OAAO,CAAC,CAAC;IACV;IACA,OAAO;MACNI,YAAY,EAAE;QACbP,OAAO,EAAE;MACV,CAAC;MAC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|
|
@@ -84,7 +84,7 @@ const OptionalControlsGroup = ({
|
|
|
84
84
|
// translators: %s: The name of the control being hidden and reset e.g. "Padding".
|
|
85
85
|
(0, _i18n.__)('Hide and reset %s'), label) : (0, _i18n.sprintf)(
|
|
86
86
|
// translators: %s: The name of the control to display e.g. "Padding".
|
|
87
|
-
(0, _i18n.
|
|
87
|
+
(0, _i18n._x)('Show %s', 'input control'), label);
|
|
88
88
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_menuItem.default, {
|
|
89
89
|
icon: isSelected ? _icons.check : null,
|
|
90
90
|
isSelected: isSelected,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_a11y","require","_icons","_i18n","_dropdownMenu","_interopRequireDefault","_menuGroup","_menuItem","_hStack","_heading","_hook","_context","_styles","_jsxRuntime","DefaultControlsGroup","itemClassName","items","toggleItem","length","resetSuffix","jsx","ResetLabel","children","__","Fragment","map","label","hasValue","default","className","role","sprintf","onClick","speak","suffix","icon","check","isSelected","OptionalControlsGroup","itemLabel","ToolsPanelHeader","props","forwardedRef","areAllOptionalControlsHidden","defaultControlsItemClassName","dropdownMenuClassName","hasMenuItems","headingClassName","headingLevel","labelText","menuItems","resetAll","dropdownMenuProps","headerProps","useToolsPanelHeader","defaultItems","Object","entries","optionalItems","optional","dropDownMenuIcon","plus","moreVertical","dropDownMenuLabelText","_x","dropdownMenuDescriptionText","undefined","canResetAll","some","jsxs","HStack","ref","Heading","level","menuProps","toggleProps","size","description","variant","ConnectedToolsPanelHeader","contextConnect","_default","exports"],"sources":["@wordpress/components/src/tools-panel/tools-panel-header/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { check, moreVertical, plus } from '@wordpress/icons';\nimport { __, _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport MenuGroup from '../../menu-group';\nimport MenuItem from '../../menu-item';\nimport { HStack } from '../../h-stack';\nimport { Heading } from '../../heading';\nimport { useToolsPanelHeader } from './hook';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport { ResetLabel } from '../styles';\nimport type {\n\tToolsPanelControlsGroupProps,\n\tToolsPanelHeaderProps,\n} from '../types';\n\nconst DefaultControlsGroup = ( {\n\titemClassName,\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\tconst resetSuffix = <ResetLabel aria-hidden>{ __( 'Reset' ) }</ResetLabel>;\n\n\treturn (\n\t\t<>\n\t\t\t{ items.map( ( [ label, hasValue ] ) => {\n\t\t\t\tif ( hasValue ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\tclassName={ itemClassName }\n\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t__( 'Reset %s' ),\n\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsuffix={ resetSuffix }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\ticon={ check }\n\t\t\t\t\t\tclassName={ itemClassName }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\tisSelected\n\t\t\t\t\t\taria-disabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n};\n\nconst OptionalControlsGroup = ( {\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ items.map( ( [ label, isSelected ] ) => {\n\t\t\t\tconst itemLabel = isSelected\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control being hidden and reset e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Hide and reset %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control to display e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Show %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t );\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\ticon={ isSelected ? check : null }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tlabel={ itemLabel }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( isSelected ) {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s hidden and reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s is now visible' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n};\n\nconst ToolsPanelHeader = (\n\tprops: WordPressComponentProps< ToolsPanelHeaderProps, 'h2' >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tareAllOptionalControlsHidden,\n\t\tdefaultControlsItemClassName,\n\t\tdropdownMenuClassName,\n\t\thasMenuItems,\n\t\theadingClassName,\n\t\theadingLevel = 2,\n\t\tlabel: labelText,\n\t\tmenuItems,\n\t\tresetAll,\n\t\ttoggleItem,\n\t\tdropdownMenuProps,\n\t\t...headerProps\n\t} = useToolsPanelHeader( props );\n\n\tif ( ! labelText ) {\n\t\treturn null;\n\t}\n\n\tconst defaultItems = Object.entries( menuItems?.default || {} );\n\tconst optionalItems = Object.entries( menuItems?.optional || {} );\n\tconst dropDownMenuIcon = areAllOptionalControlsHidden ? plus : moreVertical;\n\tconst dropDownMenuLabelText = sprintf(\n\t\t// translators: %s: The name of the tool e.g. \"Color\" or \"Typography\".\n\t\t_x( '%s options', 'Button label to reveal tool panel options' ),\n\t\tlabelText\n\t);\n\tconst dropdownMenuDescriptionText = areAllOptionalControlsHidden\n\t\t? __( 'All options are currently hidden' )\n\t\t: undefined;\n\n\tconst canResetAll = [ ...defaultItems, ...optionalItems ].some(\n\t\t( [ , isSelected ] ) => isSelected\n\t);\n\n\treturn (\n\t\t<HStack { ...headerProps } ref={ forwardedRef }>\n\t\t\t<Heading level={ headingLevel } className={ headingClassName }>\n\t\t\t\t{ labelText }\n\t\t\t</Heading>\n\t\t\t{ hasMenuItems && (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\t{ ...dropdownMenuProps }\n\t\t\t\t\ticon={ dropDownMenuIcon }\n\t\t\t\t\tlabel={ dropDownMenuLabelText }\n\t\t\t\t\tmenuProps={ { className: dropdownMenuClassName } }\n\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\tsize: 'small',\n\t\t\t\t\t\tdescription: dropdownMenuDescriptionText,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ () => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<MenuGroup label={ labelText }>\n\t\t\t\t\t\t\t\t<DefaultControlsGroup\n\t\t\t\t\t\t\t\t\titems={ defaultItems }\n\t\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t\t\titemClassName={\n\t\t\t\t\t\t\t\t\t\tdefaultControlsItemClassName\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<OptionalControlsGroup\n\t\t\t\t\t\t\t\t\titems={ optionalItems }\n\t\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\taria-disabled={ ! canResetAll }\n\t\t\t\t\t\t\t\t\t// @ts-expect-error - TODO: If this \"tertiary\" style is something we really want to allow on MenuItem,\n\t\t\t\t\t\t\t\t\t// we should rename it and explicitly allow it as an official API. All the other Button variants\n\t\t\t\t\t\t\t\t\t// don't make sense in a MenuItem context, and should be disallowed.\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tif ( canResetAll ) {\n\t\t\t\t\t\t\t\t\t\t\tresetAll();\n\t\t\t\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'All options reset' ),\n\t\t\t\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Reset all' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</DropdownMenu>\n\t\t\t) }\n\t\t</HStack>\n\t);\n};\n\nconst ConnectedToolsPanelHeader = contextConnect(\n\tToolsPanelHeader,\n\t'ToolsPanelHeader'\n);\n\nexport default ConnectedToolsPanelHeader;\n"],"mappings":";;;;;;;AAQA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,aAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,SAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AAEA,IAAAU,QAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AAAuC,IAAAY,WAAA,GAAAZ,OAAA;AAvBvC;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAeA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AG,IAAAC,uBAAc,EAC/CxC,gBAAgB,EAChB,kBACD,CAAC;AAAC,IAAAyC,QAAA,GAAAC,OAAA,CAAAtD,OAAA,GAEamD,yBAAyB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_a11y","require","_icons","_i18n","_dropdownMenu","_interopRequireDefault","_menuGroup","_menuItem","_hStack","_heading","_hook","_context","_styles","_jsxRuntime","DefaultControlsGroup","itemClassName","items","toggleItem","length","resetSuffix","jsx","ResetLabel","children","__","Fragment","map","label","hasValue","default","className","role","sprintf","onClick","speak","suffix","icon","check","isSelected","OptionalControlsGroup","itemLabel","_x","ToolsPanelHeader","props","forwardedRef","areAllOptionalControlsHidden","defaultControlsItemClassName","dropdownMenuClassName","hasMenuItems","headingClassName","headingLevel","labelText","menuItems","resetAll","dropdownMenuProps","headerProps","useToolsPanelHeader","defaultItems","Object","entries","optionalItems","optional","dropDownMenuIcon","plus","moreVertical","dropDownMenuLabelText","dropdownMenuDescriptionText","undefined","canResetAll","some","jsxs","HStack","ref","Heading","level","menuProps","toggleProps","size","description","variant","ConnectedToolsPanelHeader","contextConnect","_default","exports"],"sources":["@wordpress/components/src/tools-panel/tools-panel-header/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { check, moreVertical, plus } from '@wordpress/icons';\nimport { __, _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport MenuGroup from '../../menu-group';\nimport MenuItem from '../../menu-item';\nimport { HStack } from '../../h-stack';\nimport { Heading } from '../../heading';\nimport { useToolsPanelHeader } from './hook';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport { ResetLabel } from '../styles';\nimport type {\n\tToolsPanelControlsGroupProps,\n\tToolsPanelHeaderProps,\n} from '../types';\n\nconst DefaultControlsGroup = ( {\n\titemClassName,\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\tconst resetSuffix = <ResetLabel aria-hidden>{ __( 'Reset' ) }</ResetLabel>;\n\n\treturn (\n\t\t<>\n\t\t\t{ items.map( ( [ label, hasValue ] ) => {\n\t\t\t\tif ( hasValue ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\tclassName={ itemClassName }\n\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t__( 'Reset %s' ),\n\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsuffix={ resetSuffix }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\ticon={ check }\n\t\t\t\t\t\tclassName={ itemClassName }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\tisSelected\n\t\t\t\t\t\taria-disabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n};\n\nconst OptionalControlsGroup = ( {\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ items.map( ( [ label, isSelected ] ) => {\n\t\t\t\tconst itemLabel = isSelected\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control being hidden and reset e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Hide and reset %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control to display e.g. \"Padding\".\n\t\t\t\t\t\t\t_x( 'Show %s', 'input control' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t );\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\ticon={ isSelected ? check : null }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tlabel={ itemLabel }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( isSelected ) {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s hidden and reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s is now visible' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n};\n\nconst ToolsPanelHeader = (\n\tprops: WordPressComponentProps< ToolsPanelHeaderProps, 'h2' >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tareAllOptionalControlsHidden,\n\t\tdefaultControlsItemClassName,\n\t\tdropdownMenuClassName,\n\t\thasMenuItems,\n\t\theadingClassName,\n\t\theadingLevel = 2,\n\t\tlabel: labelText,\n\t\tmenuItems,\n\t\tresetAll,\n\t\ttoggleItem,\n\t\tdropdownMenuProps,\n\t\t...headerProps\n\t} = useToolsPanelHeader( props );\n\n\tif ( ! labelText ) {\n\t\treturn null;\n\t}\n\n\tconst defaultItems = Object.entries( menuItems?.default || {} );\n\tconst optionalItems = Object.entries( menuItems?.optional || {} );\n\tconst dropDownMenuIcon = areAllOptionalControlsHidden ? plus : moreVertical;\n\tconst dropDownMenuLabelText = sprintf(\n\t\t// translators: %s: The name of the tool e.g. \"Color\" or \"Typography\".\n\t\t_x( '%s options', 'Button label to reveal tool panel options' ),\n\t\tlabelText\n\t);\n\tconst dropdownMenuDescriptionText = areAllOptionalControlsHidden\n\t\t? __( 'All options are currently hidden' )\n\t\t: undefined;\n\n\tconst canResetAll = [ ...defaultItems, ...optionalItems ].some(\n\t\t( [ , isSelected ] ) => isSelected\n\t);\n\n\treturn (\n\t\t<HStack { ...headerProps } ref={ forwardedRef }>\n\t\t\t<Heading level={ headingLevel } className={ headingClassName }>\n\t\t\t\t{ labelText }\n\t\t\t</Heading>\n\t\t\t{ hasMenuItems && (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\t{ ...dropdownMenuProps }\n\t\t\t\t\ticon={ dropDownMenuIcon }\n\t\t\t\t\tlabel={ dropDownMenuLabelText }\n\t\t\t\t\tmenuProps={ { className: dropdownMenuClassName } }\n\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\tsize: 'small',\n\t\t\t\t\t\tdescription: dropdownMenuDescriptionText,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ () => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<MenuGroup label={ labelText }>\n\t\t\t\t\t\t\t\t<DefaultControlsGroup\n\t\t\t\t\t\t\t\t\titems={ defaultItems }\n\t\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t\t\titemClassName={\n\t\t\t\t\t\t\t\t\t\tdefaultControlsItemClassName\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<OptionalControlsGroup\n\t\t\t\t\t\t\t\t\titems={ optionalItems }\n\t\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\taria-disabled={ ! canResetAll }\n\t\t\t\t\t\t\t\t\t// @ts-expect-error - TODO: If this \"tertiary\" style is something we really want to allow on MenuItem,\n\t\t\t\t\t\t\t\t\t// we should rename it and explicitly allow it as an official API. All the other Button variants\n\t\t\t\t\t\t\t\t\t// don't make sense in a MenuItem context, and should be disallowed.\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tif ( canResetAll ) {\n\t\t\t\t\t\t\t\t\t\t\tresetAll();\n\t\t\t\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'All options reset' ),\n\t\t\t\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Reset all' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</DropdownMenu>\n\t\t\t) }\n\t\t</HStack>\n\t);\n};\n\nconst ConnectedToolsPanelHeader = contextConnect(\n\tToolsPanelHeader,\n\t'ToolsPanelHeader'\n);\n\nexport default ConnectedToolsPanelHeader;\n"],"mappings":";;;;;;;AAQA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,aAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,SAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AAEA,IAAAU,QAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AAAuC,IAAAY,WAAA,GAAAZ,OAAA;AAvBvC;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAeA,MAAMa,oBAAoB,GAAGA,CAAE;EAC9BC,aAAa;EACbC,KAAK;EACLC;AAC6B,CAAC,KAAM;EACpC,IAAK,CAAED,KAAK,CAACE,MAAM,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,MAAMC,WAAW,gBAAG,IAAAN,WAAA,CAAAO,GAAA,EAACR,OAAA,CAAAS,UAAU;IAAC,mBAAW;IAAAC,QAAA,EAAG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,kBACD,IAAAT,WAAA,CAAAwD,IAAA,EAAAxD,WAAA,CAAAW,QAAA;QAAAF,QAAA,gBACC,IAAAT,WAAA,CAAAwD,IAAA,EAAC/D,UAAA,CAAAsB,OAAS;UAACF,KAAK,EAAGwB,SAAW;UAAA5B,QAAA,gBAC7B,IAAAT,WAAA,CAAAO,GAAA,EAACN,oBAAoB;YACpBE,KAAK,EAAGwC,YAAc;YACtBvC,UAAU,EAAGA,UAAY;YACzBF,aAAa,EACZ8B;UACA,CACD,CAAC,eACF,IAAAhC,WAAA,CAAAO,GAAA,EAACkB,qBAAqB;YACrBtB,KAAK,EAAG2C,aAAe;YACvB1C,UAAU,EAAGA;UAAY,CACzB,CAAC;QAAA,CACQ,CAAC,eACZ,IAAAJ,WAAA,CAAAO,GAAA,EAACd,UAAA,CAAAsB,OAAS;UAAAN,QAAA,eACT,IAAAT,WAAA,CAAAO,GAAA,EAACb,SAAA,CAAAqB,OAAQ;YACR,iBAAgB,CAAEuC;YAClB;YACA;YACA;YAAA;YACAW,OAAO,EAAC,UAAU;YAClB9C,OAAO,EAAGA,CAAA,KAAM;cACf,IAAKmC,WAAW,EAAG;gBAClBf,QAAQ,CAAC,CAAC;gBACV,IAAAnB,WAAK,EACJ,IAAAV,QAAE,EAAE,mBAAoB,CAAC,EACzB,WACD,CAAC;cACF;YACD,CAAG;YAAAD,QAAA,EAED,IAAAC,QAAE,EAAE,WAAY;UAAC,CACV;QAAC,CACD,CAAC;MAAA,CACX;IACF,CACY,CACd;EAAA,CACM,CAAC;AAEX,CAAC;AAED,MAAMwD,yBAAyB,GAAG,IAAAC,uBAAc,EAC/CvC,gBAAgB,EAChB,kBACD,CAAC;AAAC,IAAAwC,QAAA,GAAAC,OAAA,CAAAtD,OAAA,GAEamD,yBAAyB","ignoreList":[]}
|
|
@@ -51,11 +51,9 @@ function useToolsPanelItem(props) {
|
|
|
51
51
|
|
|
52
52
|
// hasValue is a new function on every render, so do not add it as a
|
|
53
53
|
// dependency to the useCallback hook! If needed, we should use a ref.
|
|
54
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
54
|
const hasValueCallback = (0, _element.useCallback)(hasValue, [panelId]);
|
|
56
55
|
// resetAllFilter is a new function on every render, so do not add it as a
|
|
57
56
|
// dependency to the useCallback hook! If needed, we should use a ref.
|
|
58
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
57
|
const resetAllFilterCallback = (0, _element.useCallback)(resetAllFilter, [panelId]);
|
|
60
58
|
const previousPanelId = (0, _compose.usePrevious)(currentPanelId);
|
|
61
59
|
const hasMatchingPanel = currentPanelId === panelId || currentPanelId === null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_element","styles","_interopRequireWildcard","_context","_context2","_useCx","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","noop","useToolsPanelItem","props","className","hasValue","isShownByDefault","label","panelId","resetAllFilter","onDeselect","onSelect","otherProps","useContextSystem","currentPanelId","menuItems","registerResetAllFilter","deregisterResetAllFilter","registerPanelItem","deregisterPanelItem","flagItemCustomization","isResetting","shouldRenderPlaceholderItems","shouldRenderPlaceholder","firstDisplayedItem","lastDisplayedItem","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass","useToolsPanelContext","hasValueCallback","useCallback","resetAllFilterCallback","previousPanelId","usePrevious","hasMatchingPanel","useLayoutEffect","useEffect","menuGroup","isMenuItemChecked","wasMenuItemChecked","isRegistered","undefined","isValueSet","isShown","cx","useCx","classes","useMemo","shouldApplyPlaceholderStyles","firstItemStyle","lastItemStyle","ToolsPanelItem","ToolsPanelItemPlaceholder"],"sources":["@wordpress/components/src/tools-panel/tools-panel-item/hook.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseMemo,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useToolsPanelContext } from '../context';\nimport type { WordPressComponentProps } from '../../context';\nimport { useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type { ToolsPanelItemProps } from '../types';\n\nconst noop = () => {};\n\nexport function useToolsPanelItem(\n\tprops: WordPressComponentProps< ToolsPanelItemProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\thasValue,\n\t\tisShownByDefault = false,\n\t\tlabel,\n\t\tpanelId,\n\t\tresetAllFilter = noop,\n\t\tonDeselect,\n\t\tonSelect,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToolsPanelItem' );\n\n\tconst {\n\t\tpanelId: currentPanelId,\n\t\tmenuItems,\n\t\tregisterResetAllFilter,\n\t\tderegisterResetAllFilter,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t\tflagItemCustomization,\n\t\tisResetting,\n\t\tshouldRenderPlaceholderItems: shouldRenderPlaceholder,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t} = useToolsPanelContext();\n\n\t// hasValue is a new function on every render, so do not add it as a\n\t// dependency to the useCallback hook! If needed, we should use a ref.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tconst hasValueCallback = useCallback( hasValue, [ panelId ] );\n\t// resetAllFilter is a new function on every render, so do not add it as a\n\t// dependency to the useCallback hook! If needed, we should use a ref.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tconst resetAllFilterCallback = useCallback( resetAllFilter, [ panelId ] );\n\tconst previousPanelId = usePrevious( currentPanelId );\n\n\tconst hasMatchingPanel =\n\t\tcurrentPanelId === panelId || currentPanelId === null;\n\n\t// Registering the panel item allows the panel to include it in its\n\t// automatically generated menu and determine its initial checked status.\n\t//\n\t// This is performed in a layout effect to ensure that the panel item\n\t// is registered before it is rendered preventing a rendering glitch.\n\t// See: https://github.com/WordPress/gutenberg/issues/56470\n\tuseLayoutEffect( () => {\n\t\tif ( hasMatchingPanel && previousPanelId !== null ) {\n\t\t\tregisterPanelItem( {\n\t\t\t\thasValue: hasValueCallback,\n\t\t\t\tisShownByDefault,\n\t\t\t\tlabel,\n\t\t\t\tpanelId,\n\t\t\t} );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif (\n\t\t\t\t( previousPanelId === null && !! currentPanelId ) ||\n\t\t\t\tcurrentPanelId === panelId\n\t\t\t) {\n\t\t\t\tderegisterPanelItem( label );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tcurrentPanelId,\n\t\thasMatchingPanel,\n\t\tisShownByDefault,\n\t\tlabel,\n\t\thasValueCallback,\n\t\tpanelId,\n\t\tpreviousPanelId,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t] );\n\n\tuseEffect( () => {\n\t\tif ( hasMatchingPanel ) {\n\t\t\tregisterResetAllFilter( resetAllFilterCallback );\n\t\t}\n\t\treturn () => {\n\t\t\tif ( hasMatchingPanel ) {\n\t\t\t\tderegisterResetAllFilter( resetAllFilterCallback );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tregisterResetAllFilter,\n\t\tderegisterResetAllFilter,\n\t\tresetAllFilterCallback,\n\t\thasMatchingPanel,\n\t] );\n\n\t// Note: `label` is used as a key when building menu item state in\n\t// `ToolsPanel`.\n\tconst menuGroup = isShownByDefault ? 'default' : 'optional';\n\tconst isMenuItemChecked = menuItems?.[ menuGroup ]?.[ label ];\n\tconst wasMenuItemChecked = usePrevious( isMenuItemChecked );\n\tconst isRegistered = menuItems?.[ menuGroup ]?.[ label ] !== undefined;\n\n\tconst isValueSet = hasValue();\n\t// Notify the panel when an item's value has changed except for optional\n\t// items without value because the item should not cause itself to hide.\n\tuseEffect( () => {\n\t\tif ( ! isShownByDefault && ! isValueSet ) {\n\t\t\treturn;\n\t\t}\n\n\t\tflagItemCustomization( isValueSet, label, menuGroup );\n\t}, [\n\t\tisValueSet,\n\t\tmenuGroup,\n\t\tlabel,\n\t\tflagItemCustomization,\n\t\tisShownByDefault,\n\t] );\n\n\t// Determine if the panel item's corresponding menu is being toggled and\n\t// trigger appropriate callback if it is.\n\tuseEffect( () => {\n\t\t// We check whether this item is currently registered as items rendered\n\t\t// via fills can persist through the parent panel being remounted.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/45673\n\t\tif ( ! isRegistered || isResetting || ! hasMatchingPanel ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isMenuItemChecked && ! isValueSet && ! wasMenuItemChecked ) {\n\t\t\tonSelect?.();\n\t\t}\n\n\t\tif ( ! isMenuItemChecked && isValueSet && wasMenuItemChecked ) {\n\t\t\tonDeselect?.();\n\t\t}\n\t}, [\n\t\thasMatchingPanel,\n\t\tisMenuItemChecked,\n\t\tisRegistered,\n\t\tisResetting,\n\t\tisValueSet,\n\t\twasMenuItemChecked,\n\t\tonSelect,\n\t\tonDeselect,\n\t] );\n\n\t// The item is shown if it is a default control regardless of whether it\n\t// has a value. Optional items are shown when they are checked or have\n\t// a value.\n\tconst isShown = isShownByDefault\n\t\t? menuItems?.[ menuGroup ]?.[ label ] !== undefined\n\t\t: isMenuItemChecked;\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\tconst shouldApplyPlaceholderStyles =\n\t\t\tshouldRenderPlaceholder && ! isShown;\n\t\tconst firstItemStyle =\n\t\t\tfirstDisplayedItem === label && __experimentalFirstVisibleItemClass;\n\t\tconst lastItemStyle =\n\t\t\tlastDisplayedItem === label && __experimentalLastVisibleItemClass;\n\t\treturn cx(\n\t\t\tstyles.ToolsPanelItem,\n\t\t\tshouldApplyPlaceholderStyles && styles.ToolsPanelItemPlaceholder,\n\t\t\t! shouldApplyPlaceholderStyles && className,\n\t\t\tfirstItemStyle,\n\t\t\tlastItemStyle\n\t\t);\n\t}, [\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\tclassName,\n\t\tcx,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t\tlabel,\n\t] );\n\n\treturn {\n\t\t...otherProps,\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\tclassName: classes,\n\t};\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAUA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAEA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAAiD,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GA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M,CAAC4E,yBAAyB,EAChE,CAAEJ,4BAA4B,IAAI5C,SAAS,EAC3C6C,cAAc,EACdC,aACD,CAAC;EACF,CAAC,EAAE,CACFP,OAAO,EACPpB,uBAAuB,EACvBnB,SAAS,EACTwC,EAAE,EACFpB,kBAAkB,EAClBC,iBAAiB,EACjBC,mCAAmC,EACnCC,kCAAkC,EAClCpB,KAAK,CACJ,CAAC;EAEH,OAAO;IACN,GAAGK,UAAU;IACb+B,OAAO;IACPpB,uBAAuB;IACvBnB,SAAS,EAAE0C;EACZ,CAAC;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_compose","require","_element","styles","_interopRequireWildcard","_context","_context2","_useCx","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","noop","useToolsPanelItem","props","className","hasValue","isShownByDefault","label","panelId","resetAllFilter","onDeselect","onSelect","otherProps","useContextSystem","currentPanelId","menuItems","registerResetAllFilter","deregisterResetAllFilter","registerPanelItem","deregisterPanelItem","flagItemCustomization","isResetting","shouldRenderPlaceholderItems","shouldRenderPlaceholder","firstDisplayedItem","lastDisplayedItem","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass","useToolsPanelContext","hasValueCallback","useCallback","resetAllFilterCallback","previousPanelId","usePrevious","hasMatchingPanel","useLayoutEffect","useEffect","menuGroup","isMenuItemChecked","wasMenuItemChecked","isRegistered","undefined","isValueSet","isShown","cx","useCx","classes","useMemo","shouldApplyPlaceholderStyles","firstItemStyle","lastItemStyle","ToolsPanelItem","ToolsPanelItemPlaceholder"],"sources":["@wordpress/components/src/tools-panel/tools-panel-item/hook.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseMemo,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useToolsPanelContext } from '../context';\nimport type { WordPressComponentProps } from '../../context';\nimport { useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type { ToolsPanelItemProps } from '../types';\n\nconst noop = () => {};\n\nexport function useToolsPanelItem(\n\tprops: WordPressComponentProps< ToolsPanelItemProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\thasValue,\n\t\tisShownByDefault = false,\n\t\tlabel,\n\t\tpanelId,\n\t\tresetAllFilter = noop,\n\t\tonDeselect,\n\t\tonSelect,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToolsPanelItem' );\n\n\tconst {\n\t\tpanelId: currentPanelId,\n\t\tmenuItems,\n\t\tregisterResetAllFilter,\n\t\tderegisterResetAllFilter,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t\tflagItemCustomization,\n\t\tisResetting,\n\t\tshouldRenderPlaceholderItems: shouldRenderPlaceholder,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t} = useToolsPanelContext();\n\n\t// hasValue is a new function on every render, so do not add it as a\n\t// dependency to the useCallback hook! If needed, we should use a ref.\n\tconst hasValueCallback = useCallback( hasValue, [ panelId ] );\n\t// resetAllFilter is a new function on every render, so do not add it as a\n\t// dependency to the useCallback hook! If needed, we should use a ref.\n\tconst resetAllFilterCallback = useCallback( resetAllFilter, [ panelId ] );\n\tconst previousPanelId = usePrevious( currentPanelId );\n\n\tconst hasMatchingPanel =\n\t\tcurrentPanelId === panelId || currentPanelId === null;\n\n\t// Registering the panel item allows the panel to include it in its\n\t// automatically generated menu and determine its initial checked status.\n\t//\n\t// This is performed in a layout effect to ensure that the panel item\n\t// is registered before it is rendered preventing a rendering glitch.\n\t// See: https://github.com/WordPress/gutenberg/issues/56470\n\tuseLayoutEffect( () => {\n\t\tif ( hasMatchingPanel && previousPanelId !== null ) {\n\t\t\tregisterPanelItem( {\n\t\t\t\thasValue: hasValueCallback,\n\t\t\t\tisShownByDefault,\n\t\t\t\tlabel,\n\t\t\t\tpanelId,\n\t\t\t} );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif (\n\t\t\t\t( previousPanelId === null && !! currentPanelId ) ||\n\t\t\t\tcurrentPanelId === panelId\n\t\t\t) {\n\t\t\t\tderegisterPanelItem( label );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tcurrentPanelId,\n\t\thasMatchingPanel,\n\t\tisShownByDefault,\n\t\tlabel,\n\t\thasValueCallback,\n\t\tpanelId,\n\t\tpreviousPanelId,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t] );\n\n\tuseEffect( () => {\n\t\tif ( hasMatchingPanel ) {\n\t\t\tregisterResetAllFilter( resetAllFilterCallback );\n\t\t}\n\t\treturn () => {\n\t\t\tif ( hasMatchingPanel ) {\n\t\t\t\tderegisterResetAllFilter( resetAllFilterCallback );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tregisterResetAllFilter,\n\t\tderegisterResetAllFilter,\n\t\tresetAllFilterCallback,\n\t\thasMatchingPanel,\n\t] );\n\n\t// Note: `label` is used as a key when building menu item state in\n\t// `ToolsPanel`.\n\tconst menuGroup = isShownByDefault ? 'default' : 'optional';\n\tconst isMenuItemChecked = menuItems?.[ menuGroup ]?.[ label ];\n\tconst wasMenuItemChecked = usePrevious( isMenuItemChecked );\n\tconst isRegistered = menuItems?.[ menuGroup ]?.[ label ] !== undefined;\n\n\tconst isValueSet = hasValue();\n\t// Notify the panel when an item's value has changed except for optional\n\t// items without value because the item should not cause itself to hide.\n\tuseEffect( () => {\n\t\tif ( ! isShownByDefault && ! isValueSet ) {\n\t\t\treturn;\n\t\t}\n\n\t\tflagItemCustomization( isValueSet, label, menuGroup );\n\t}, [\n\t\tisValueSet,\n\t\tmenuGroup,\n\t\tlabel,\n\t\tflagItemCustomization,\n\t\tisShownByDefault,\n\t] );\n\n\t// Determine if the panel item's corresponding menu is being toggled and\n\t// trigger appropriate callback if it is.\n\tuseEffect( () => {\n\t\t// We check whether this item is currently registered as items rendered\n\t\t// via fills can persist through the parent panel being remounted.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/45673\n\t\tif ( ! isRegistered || isResetting || ! hasMatchingPanel ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isMenuItemChecked && ! isValueSet && ! wasMenuItemChecked ) {\n\t\t\tonSelect?.();\n\t\t}\n\n\t\tif ( ! isMenuItemChecked && isValueSet && wasMenuItemChecked ) {\n\t\t\tonDeselect?.();\n\t\t}\n\t}, [\n\t\thasMatchingPanel,\n\t\tisMenuItemChecked,\n\t\tisRegistered,\n\t\tisResetting,\n\t\tisValueSet,\n\t\twasMenuItemChecked,\n\t\tonSelect,\n\t\tonDeselect,\n\t] );\n\n\t// The item is shown if it is a default control regardless of whether it\n\t// has a value. Optional items are shown when they are checked or have\n\t// a value.\n\tconst isShown = isShownByDefault\n\t\t? menuItems?.[ menuGroup ]?.[ label ] !== undefined\n\t\t: isMenuItemChecked;\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\tconst shouldApplyPlaceholderStyles =\n\t\t\tshouldRenderPlaceholder && ! isShown;\n\t\tconst firstItemStyle =\n\t\t\tfirstDisplayedItem === label && __experimentalFirstVisibleItemClass;\n\t\tconst lastItemStyle =\n\t\t\tlastDisplayedItem === label && __experimentalLastVisibleItemClass;\n\t\treturn cx(\n\t\t\tstyles.ToolsPanelItem,\n\t\t\tshouldApplyPlaceholderStyles && styles.ToolsPanelItemPlaceholder,\n\t\t\t! shouldApplyPlaceholderStyles && className,\n\t\t\tfirstItemStyle,\n\t\t\tlastItemStyle\n\t\t);\n\t}, [\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\tclassName,\n\t\tcx,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t\tlabel,\n\t] );\n\n\treturn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BnB,SAAS,EACTwC,EAAE,EACFpB,kBAAkB,EAClBC,iBAAiB,EACjBC,mCAAmC,EACnCC,kCAAkC,EAClCpB,KAAK,CACJ,CAAC;EAEH,OAAO;IACN,GAAGK,UAAU;IACb+B,OAAO;IACPpB,uBAAuB;IACvBnB,SAAS,EAAE0C;EACZ,CAAC;AACF","ignoreList":[]}
|
|
@@ -54,9 +54,7 @@ const useKeyboardVisibility = () => {
|
|
|
54
54
|
showListener.remove();
|
|
55
55
|
hideListener.remove();
|
|
56
56
|
};
|
|
57
|
-
//
|
|
58
|
-
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
59
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
+
// See https://github.com/WordPress/gutenberg/pull/41166
|
|
60
58
|
}, []);
|
|
61
59
|
return keyboardVisible;
|
|
62
60
|
};
|
|
@@ -97,9 +95,7 @@ const Tooltip = ({
|
|
|
97
95
|
});
|
|
98
96
|
}
|
|
99
97
|
return () => onHandleScreenTouch(null);
|
|
100
|
-
//
|
|
101
|
-
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
102
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
|
+
// See https://github.com/WordPress/gutenberg/pull/41166
|
|
103
99
|
}, [visible]);
|
|
104
100
|
|
|
105
101
|
// Manage visibility animation.
|
|
@@ -112,9 +108,7 @@ const Tooltip = ({
|
|
|
112
108
|
setAnimating(true);
|
|
113
109
|
startAnimation();
|
|
114
110
|
}
|
|
115
|
-
//
|
|
116
|
-
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
117
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
111
|
+
// See https://github.com/WordPress/gutenberg/pull/41166
|
|
118
112
|
}, [visible]);
|
|
119
113
|
|
|
120
114
|
// Manage tooltip visibility and position in relation to keyboard.
|
|
@@ -133,9 +127,7 @@ const Tooltip = ({
|
|
|
133
127
|
setAnimating(true);
|
|
134
128
|
setVisible(false);
|
|
135
129
|
}
|
|
136
|
-
//
|
|
137
|
-
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
138
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
130
|
+
// See https://github.com/WordPress/gutenberg/pull/41166
|
|
139
131
|
}, [visible, keyboardVisible]);
|
|
140
132
|
|
|
141
133
|
// Manage tooltip position during keyboard frame changes.
|
|
@@ -249,9 +241,7 @@ const TooltipSlot = ({
|
|
|
249
241
|
setHandleScreenTouch(null);
|
|
250
242
|
};
|
|
251
243
|
// Memoize context value to avoid unnecessary rerenders of the Provider's children
|
|
252
|
-
//
|
|
253
|
-
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
254
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
244
|
+
// See https://github.com/WordPress/gutenberg/pull/41166
|
|
255
245
|
const value = (0, _element.useMemo)(() => ({
|
|
256
246
|
onHandleScreenTouch
|
|
257
247
|
}));
|