@wordpress/components 29.0.0 → 29.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -1
- package/LICENSE.md +1 -1
- package/build/badge/index.js +64 -0
- package/build/badge/index.js.map +1 -0
- package/build/badge/types.js +6 -0
- package/build/badge/types.js.map +1 -0
- package/build/box-control/index.js +5 -1
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/input-control.js +90 -29
- package/build/box-control/input-control.js.map +1 -1
- package/build/box-control/types.js.map +1 -1
- package/build/box-control/utils.js +50 -0
- package/build/box-control/utils.js.map +1 -1
- package/build/button-group/index.js +10 -0
- package/build/button-group/index.js.map +1 -1
- package/build/button-group/types.js.map +1 -1
- package/build/custom-select-control/index.js +3 -5
- package/build/custom-select-control/index.js.map +1 -1
- package/build/custom-select-control-v2/custom-select.js +2 -3
- package/build/custom-select-control-v2/custom-select.js.map +1 -1
- package/build/date-time/date/index.js +1 -0
- package/build/date-time/date/index.js.map +1 -1
- package/build/dimension-control/index.js +1 -0
- package/build/dimension-control/index.js.map +1 -1
- package/build/font-size-picker/styles.js +9 -9
- package/build/font-size-picker/styles.js.map +1 -1
- package/build/heading/hook.js +1 -1
- package/build/heading/hook.js.map +1 -1
- package/build/input-control/index.js +9 -0
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/types.js.map +1 -1
- package/build/menu/checkbox-item.js +2 -0
- package/build/menu/checkbox-item.js.map +1 -1
- package/build/menu/index.js +25 -94
- package/build/menu/index.js.map +1 -1
- package/build/menu/item.js +10 -1
- package/build/menu/item.js.map +1 -1
- package/build/menu/popover.js +89 -0
- package/build/menu/popover.js.map +1 -0
- package/build/menu/radio-item.js +2 -0
- package/build/menu/radio-item.js.map +1 -1
- package/build/menu/submenu-trigger-item.js +58 -0
- package/build/menu/submenu-trigger-item.js.map +1 -0
- package/build/menu/trigger-button.js +45 -0
- package/build/menu/trigger-button.js.map +1 -0
- package/build/menu/types.js.map +1 -1
- package/build/navigation/back-button/index.js +1 -0
- package/build/navigation/back-button/index.js.map +1 -1
- package/build/navigation/index.js +6 -0
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/item/index.js +1 -0
- package/build/navigation/item/index.js.map +1 -1
- package/build/number-control/index.js +1 -0
- package/build/number-control/index.js.map +1 -1
- package/build/palette-edit/index.js +1 -0
- package/build/palette-edit/index.js.map +1 -1
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +1 -1
- package/build/radio-group/index.js +6 -0
- package/build/radio-group/index.js.map +1 -1
- package/build/radio-group/radio.js +2 -3
- package/build/radio-group/radio.js.map +1 -1
- package/build/range-control/styles/range-control-styles.js +28 -28
- package/build/range-control/styles/range-control-styles.js.map +1 -1
- package/build/select-control/index.js +9 -0
- package/build/select-control/index.js.map +1 -1
- package/build/select-control/types.js.map +1 -1
- package/build/slot-fill/context.js +4 -3
- package/build/slot-fill/context.js.map +1 -1
- package/build/slot-fill/fill.js +10 -15
- package/build/slot-fill/fill.js.map +1 -1
- package/build/slot-fill/provider.js +41 -55
- package/build/slot-fill/provider.js.map +1 -1
- package/build/slot-fill/slot.js +31 -23
- package/build/slot-fill/slot.js.map +1 -1
- package/build/slot-fill/types.js.map +1 -1
- package/build/tab-panel/index.js +2 -3
- package/build/tab-panel/index.js.map +1 -1
- package/build/tabs/index.js +21 -4
- package/build/tabs/index.js.map +1 -1
- package/build/tabs/types.js.map +1 -1
- package/build/text/hook.js +6 -6
- package/build/text/hook.js.map +1 -1
- package/build/text/styles.js +7 -7
- package/build/text/styles.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/as-radio-group.js +2 -3
- package/build/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
- package/build/tooltip/index.js +2 -3
- package/build/tooltip/index.js.map +1 -1
- package/build/tree-select/index.js +10 -2
- package/build/tree-select/index.js.map +1 -1
- package/build/tree-select/types.js.map +1 -1
- package/build-module/badge/index.js +57 -0
- package/build-module/badge/index.js.map +1 -0
- package/build-module/badge/types.js +2 -0
- package/build-module/badge/types.js.map +1 -0
- package/build-module/box-control/index.js +5 -1
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/input-control.js +92 -31
- package/build-module/box-control/input-control.js.map +1 -1
- package/build-module/box-control/types.js.map +1 -1
- package/build-module/box-control/utils.js +47 -0
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/button-group/index.js +10 -0
- package/build-module/button-group/index.js.map +1 -1
- package/build-module/button-group/types.js.map +1 -1
- package/build-module/custom-select-control/index.js +3 -5
- package/build-module/custom-select-control/index.js.map +1 -1
- package/build-module/custom-select-control-v2/custom-select.js +1 -2
- package/build-module/custom-select-control-v2/custom-select.js.map +1 -1
- package/build-module/date-time/date/index.js +1 -0
- package/build-module/date-time/date/index.js.map +1 -1
- package/build-module/dimension-control/index.js +1 -0
- package/build-module/dimension-control/index.js.map +1 -1
- package/build-module/font-size-picker/styles.js +9 -9
- package/build-module/font-size-picker/styles.js.map +1 -1
- package/build-module/heading/hook.js +1 -1
- package/build-module/heading/hook.js.map +1 -1
- package/build-module/input-control/index.js +9 -0
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/types.js.map +1 -1
- package/build-module/menu/checkbox-item.js +2 -0
- package/build-module/menu/checkbox-item.js.map +1 -1
- package/build-module/menu/index.js +28 -97
- package/build-module/menu/index.js.map +1 -1
- package/build-module/menu/item.js +10 -1
- package/build-module/menu/item.js.map +1 -1
- package/build-module/menu/popover.js +81 -0
- package/build-module/menu/popover.js.map +1 -0
- package/build-module/menu/radio-item.js +2 -0
- package/build-module/menu/radio-item.js.map +1 -1
- package/build-module/menu/submenu-trigger-item.js +50 -0
- package/build-module/menu/submenu-trigger-item.js.map +1 -0
- package/build-module/menu/trigger-button.js +37 -0
- package/build-module/menu/trigger-button.js.map +1 -0
- package/build-module/menu/types.js.map +1 -1
- package/build-module/navigation/back-button/index.js +1 -0
- package/build-module/navigation/back-button/index.js.map +1 -1
- package/build-module/navigation/index.js +6 -0
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/item/index.js +1 -0
- package/build-module/navigation/item/index.js.map +1 -1
- package/build-module/number-control/index.js +1 -0
- package/build-module/number-control/index.js.map +1 -1
- package/build-module/palette-edit/index.js +1 -0
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/radio-group/index.js +6 -0
- package/build-module/radio-group/index.js.map +1 -1
- package/build-module/radio-group/radio.js +1 -2
- package/build-module/radio-group/radio.js.map +1 -1
- package/build-module/range-control/styles/range-control-styles.js +28 -28
- package/build-module/range-control/styles/range-control-styles.js.map +1 -1
- package/build-module/select-control/index.js +9 -0
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/select-control/types.js.map +1 -1
- package/build-module/slot-fill/context.js +5 -3
- package/build-module/slot-fill/context.js.map +1 -1
- package/build-module/slot-fill/fill.js +10 -15
- package/build-module/slot-fill/fill.js.map +1 -1
- package/build-module/slot-fill/provider.js +41 -55
- package/build-module/slot-fill/provider.js.map +1 -1
- package/build-module/slot-fill/slot.js +32 -24
- package/build-module/slot-fill/slot.js.map +1 -1
- package/build-module/slot-fill/types.js.map +1 -1
- package/build-module/tab-panel/index.js +1 -2
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/tabs/index.js +21 -4
- package/build-module/tabs/index.js.map +1 -1
- package/build-module/tabs/types.js.map +1 -1
- package/build-module/text/hook.js +6 -6
- package/build-module/text/hook.js.map +1 -1
- package/build-module/text/styles.js +7 -7
- package/build-module/text/styles.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js +1 -2
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
- package/build-module/tooltip/index.js +1 -2
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tree-select/index.js +10 -2
- package/build-module/tree-select/index.js.map +1 -1
- package/build-module/tree-select/types.js.map +1 -1
- package/build-style/style-rtl.css +60 -13
- package/build-style/style.css +60 -13
- package/build-types/alignment-matrix-control/stories/index.story.d.ts +1 -1
- package/build-types/alignment-matrix-control/stories/index.story.d.ts.map +1 -1
- package/build-types/angle-picker-control/stories/index.story.d.ts +1 -1
- package/build-types/animate/stories/index.story.d.ts +7 -7
- package/build-types/animate/stories/index.story.d.ts.map +1 -1
- package/build-types/badge/index.d.ts +8 -0
- package/build-types/badge/index.d.ts.map +1 -0
- package/build-types/badge/stories/index.story.d.ts +17 -0
- package/build-types/badge/stories/index.story.d.ts.map +1 -0
- package/build-types/badge/test/index.d.ts +2 -0
- package/build-types/badge/test/index.d.ts.map +1 -0
- package/build-types/badge/types.d.ts +13 -0
- package/build-types/badge/types.d.ts.map +1 -0
- package/build-types/base-control/stories/index.story.d.ts +1 -1
- package/build-types/border-box-control/stories/index.story.d.ts +1 -1
- package/build-types/border-control/stories/index.story.d.ts +5 -5
- package/build-types/box-control/index.d.ts +1 -1
- package/build-types/box-control/index.d.ts.map +1 -1
- package/build-types/box-control/input-control.d.ts +1 -1
- package/build-types/box-control/input-control.d.ts.map +1 -1
- package/build-types/box-control/stories/index.story.d.ts +356 -11
- package/build-types/box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/box-control/styles/box-control-styles.d.ts +2 -2
- package/build-types/box-control/types.d.ts +17 -0
- package/build-types/box-control/types.d.ts.map +1 -1
- package/build-types/box-control/utils.d.ts +27 -1
- package/build-types/box-control/utils.d.ts.map +1 -1
- package/build-types/button/stories/e2e/index.story.d.ts +1 -1
- package/build-types/button/stories/e2e/index.story.d.ts.map +1 -1
- package/build-types/button/stories/index.story.d.ts +7 -7
- package/build-types/button/stories/index.story.d.ts.map +1 -1
- package/build-types/button-group/index.d.ts +3 -1
- package/build-types/button-group/index.d.ts.map +1 -1
- package/build-types/button-group/stories/index.story.d.ts +6 -0
- package/build-types/button-group/stories/index.story.d.ts.map +1 -1
- package/build-types/button-group/types.d.ts +7 -0
- package/build-types/button-group/types.d.ts.map +1 -1
- package/build-types/circular-option-picker/stories/index.story.d.ts +5 -5
- package/build-types/circular-option-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.story.d.ts +3 -3
- package/build-types/color-palette/stories/index.story.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +2 -2
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/combobox-control/stories/index.story.d.ts +4 -4
- package/build-types/confirm-dialog/stories/index.story.d.ts +2 -2
- package/build-types/confirm-dialog/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/stories/index.story.d.ts +1 -1
- package/build-types/custom-gradient-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-select-control/stories/index.story.d.ts +3 -3
- package/build-types/custom-select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/custom-select.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/stories/index.story.d.ts +3 -3
- package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -1
- package/build-types/date-time/date/index.d.ts.map +1 -1
- package/build-types/date-time/stories/time.story.d.ts +1 -1
- package/build-types/date-time/stories/time.story.d.ts.map +1 -1
- package/build-types/date-time/time/styles.d.ts +4 -4
- package/build-types/dimension-control/index.d.ts.map +1 -1
- package/build-types/dimension-control/stories/index.story.d.ts +1 -1
- package/build-types/disabled/stories/index.story.d.ts.map +1 -1
- package/build-types/drop-zone/stories/index.story.d.ts +1 -1
- package/build-types/drop-zone/stories/index.story.d.ts.map +1 -1
- package/build-types/duotone-picker/stories/duotone-picker.story.d.ts +1 -1
- package/build-types/duotone-picker/stories/duotone-picker.story.d.ts.map +1 -1
- package/build-types/duotone-picker/stories/duotone-swatch.story.d.ts +3 -3
- package/build-types/duotone-picker/stories/duotone-swatch.story.d.ts.map +1 -1
- package/build-types/focal-point-picker/stories/index.story.d.ts +4 -4
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
- package/build-types/font-size-picker/styles.d.ts.map +1 -1
- package/build-types/form-file-upload/stories/index.story.d.ts +5 -5
- package/build-types/form-file-upload/stories/index.story.d.ts.map +1 -1
- package/build-types/gradient-picker/stories/index.story.d.ts +3 -3
- package/build-types/gradient-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/guide/stories/index.story.d.ts +1 -1
- package/build-types/guide/stories/index.story.d.ts.map +1 -1
- package/build-types/icon/stories/index.story.d.ts +4 -4
- package/build-types/icon/stories/index.story.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts +1 -0
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/stories/index.story.d.ts +7 -7
- package/build-types/input-control/stories/index.story.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +11 -2
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/keyboard-shortcuts/stories/index.story.d.ts +1 -1
- package/build-types/keyboard-shortcuts/stories/index.story.d.ts.map +1 -1
- package/build-types/menu/checkbox-item.d.ts.map +1 -1
- package/build-types/menu/index.d.ts +10 -1
- package/build-types/menu/index.d.ts.map +1 -1
- package/build-types/menu/item.d.ts.map +1 -1
- package/build-types/menu/popover.d.ts +3 -0
- package/build-types/menu/popover.d.ts.map +1 -0
- package/build-types/menu/radio-item.d.ts.map +1 -1
- package/build-types/menu/stories/index.story.d.ts +9 -9
- package/build-types/menu/stories/index.story.d.ts.map +1 -1
- package/build-types/menu/submenu-trigger-item.d.ts +3 -0
- package/build-types/menu/submenu-trigger-item.d.ts.map +1 -0
- package/build-types/menu/trigger-button.d.ts +3 -0
- package/build-types/menu/trigger-button.d.ts.map +1 -0
- package/build-types/menu/types.d.ts +208 -57
- package/build-types/menu/types.d.ts.map +1 -1
- package/build-types/menu-group/stories/index.story.d.ts +1 -1
- package/build-types/menu-group/stories/index.story.d.ts.map +1 -1
- package/build-types/menu-item/stories/index.story.d.ts +4 -4
- package/build-types/modal/stories/index.story.d.ts.map +1 -1
- package/build-types/navigation/back-button/index.d.ts.map +1 -1
- package/build-types/navigation/index.d.ts.map +1 -1
- package/build-types/navigation/item/index.d.ts.map +1 -1
- package/build-types/navigation/stories/index.story.d.ts +6 -6
- package/build-types/navigation/stories/index.story.d.ts.map +1 -1
- package/build-types/notice/stories/index.story.d.ts +4 -4
- package/build-types/notice/stories/index.story.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts +1 -1
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/stories/index.story.d.ts +2 -2
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/palette-edit/stories/index.story.d.ts +2 -2
- package/build-types/palette-edit/stories/index.story.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/progress-bar/stories/index.story.d.ts +1 -1
- package/build-types/progress-bar/stories/index.story.d.ts.map +1 -1
- package/build-types/query-controls/stories/index.story.d.ts +1 -1
- package/build-types/query-controls/stories/index.story.d.ts.map +1 -1
- package/build-types/radio-group/index.d.ts.map +1 -1
- package/build-types/radio-group/radio.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/resizable-box/stories/index.story.d.ts +2 -2
- package/build-types/responsive-wrapper/stories/index.story.d.ts +1 -1
- package/build-types/responsive-wrapper/stories/index.story.d.ts.map +1 -1
- package/build-types/sandbox/stories/index.story.d.ts +1 -1
- package/build-types/sandbox/stories/index.story.d.ts.map +1 -1
- package/build-types/search-control/stories/index.story.d.ts +1 -1
- package/build-types/search-control/stories/index.story.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts +1 -0
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/stories/index.story.d.ts +5 -5
- package/build-types/select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/select-control/types.d.ts +1 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/shortcut/stories/index.story.d.ts +1 -1
- package/build-types/shortcut/stories/index.story.d.ts.map +1 -1
- package/build-types/slot-fill/context.d.ts.map +1 -1
- package/build-types/slot-fill/fill.d.ts.map +1 -1
- package/build-types/slot-fill/provider.d.ts.map +1 -1
- package/build-types/slot-fill/slot.d.ts.map +1 -1
- package/build-types/slot-fill/types.d.ts +13 -11
- package/build-types/slot-fill/types.d.ts.map +1 -1
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/tab-panel/stories/index.story.d.ts +4 -4
- package/build-types/tab-panel/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/index.d.ts +21 -4
- package/build-types/tabs/index.d.ts.map +1 -1
- package/build-types/tabs/stories/index.story.d.ts +10 -10
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/types.d.ts +13 -13
- package/build-types/tabs/types.d.ts.map +1 -1
- package/build-types/text/stories/index.story.d.ts +3 -3
- package/build-types/theme/stories/index.story.d.ts +1 -1
- package/build-types/toggle-control/stories/index.story.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts.map +1 -1
- package/build-types/toolbar/stories/index.story.d.ts +3 -3
- package/build-types/toolbar/stories/index.story.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/tooltip/stories/index.story.d.ts +1 -1
- package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-grid/stories/index.story.d.ts +1 -1
- package/build-types/tree-grid/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-select/index.d.ts +3 -2
- package/build-types/tree-select/index.d.ts.map +1 -1
- package/build-types/tree-select/stories/index.story.d.ts +1 -1
- package/build-types/tree-select/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-select/types.d.ts +5 -1
- package/build-types/tree-select/types.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
- package/build-types/v-stack/stories/index.story.d.ts +1 -1
- package/package.json +19 -19
- package/src/alignment-matrix-control/README.md +16 -15
- package/src/angle-picker-control/README.md +10 -9
- package/src/badge/README.md +24 -0
- package/src/badge/docs-manifest.json +5 -0
- package/src/badge/index.tsx +67 -0
- package/src/badge/stories/index.story.tsx +54 -0
- package/src/badge/styles.scss +49 -0
- package/src/badge/test/index.tsx +45 -0
- package/src/badge/types.ts +12 -0
- package/src/base-control/README.md +22 -21
- package/src/box-control/README.md +41 -24
- package/src/box-control/index.tsx +4 -0
- package/src/box-control/input-control.tsx +142 -40
- package/src/box-control/stories/index.story.tsx +12 -0
- package/src/box-control/types.ts +18 -0
- package/src/box-control/utils.ts +60 -0
- package/src/button/README.md +51 -50
- package/src/button/style.scss +9 -10
- package/src/button/test/index.tsx +9 -2
- package/src/button-group/README.md +4 -0
- package/src/button-group/index.tsx +11 -1
- package/src/button-group/stories/index.story.tsx +8 -1
- package/src/button-group/types.ts +7 -0
- package/src/custom-select-control/index.tsx +3 -3
- package/src/custom-select-control-v2/custom-select.tsx +1 -2
- package/src/custom-select-control-v2/stories/index.story.tsx +4 -0
- package/src/date-time/date/index.tsx +1 -0
- package/src/dimension-control/index.tsx +1 -0
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -4
- package/src/disabled/stories/index.story.tsx +1 -0
- package/src/drop-zone/stories/index.story.tsx +7 -1
- package/src/font-size-picker/styles.ts +1 -0
- package/src/form-file-upload/README.md +22 -21
- package/src/gradient-picker/README.md +36 -35
- package/src/heading/hook.ts +1 -1
- package/src/heading/test/__snapshots__/index.tsx.snap +4 -4
- package/src/icon/README.md +9 -8
- package/src/input-control/README.md +1 -0
- package/src/input-control/index.tsx +10 -0
- package/src/input-control/stories/index.story.tsx +6 -1
- package/src/input-control/test/index.js +9 -3
- package/src/input-control/types.ts +11 -2
- package/src/menu/checkbox-item.tsx +2 -1
- package/src/menu/index.tsx +61 -165
- package/src/menu/item.tsx +17 -2
- package/src/menu/popover.tsx +103 -0
- package/src/menu/radio-item.tsx +2 -1
- package/src/menu/stories/index.story.tsx +533 -381
- package/src/menu/submenu-trigger-item.tsx +61 -0
- package/src/menu/test/index.tsx +266 -182
- package/src/menu/trigger-button.tsx +46 -0
- package/src/menu/types.ts +210 -63
- package/src/modal/stories/index.story.tsx +4 -1
- package/src/navigation/back-button/index.tsx +1 -0
- package/src/navigation/index.tsx +7 -0
- package/src/navigation/item/index.tsx +2 -0
- package/src/navigation/test/index.tsx +4 -0
- package/src/navigator/test/index.tsx +4 -0
- package/src/number-control/index.tsx +1 -0
- package/src/palette-edit/index.tsx +1 -0
- package/src/panel/stories/index.story.tsx +3 -3
- package/src/private-apis.ts +2 -0
- package/src/radio-group/index.tsx +12 -1
- package/src/radio-group/radio.tsx +1 -2
- package/src/range-control/styles/range-control-styles.ts +8 -4
- package/src/select-control/README.md +3 -0
- package/src/select-control/index.tsx +10 -0
- package/src/select-control/stories/index.story.tsx +2 -0
- package/src/select-control/test/select-control.tsx +7 -1
- package/src/select-control/types.ts +1 -0
- package/src/slot-fill/context.ts +5 -3
- package/src/slot-fill/fill.ts +10 -15
- package/src/slot-fill/provider.tsx +63 -64
- package/src/slot-fill/slot.tsx +40 -27
- package/src/slot-fill/types.ts +23 -11
- package/src/style.scss +1 -0
- package/src/tab-panel/index.tsx +1 -2
- package/src/tab-panel/stories/index.story.tsx +4 -0
- package/src/tabs/README.md +151 -187
- package/src/tabs/docs-manifest.json +22 -0
- package/src/tabs/index.tsx +21 -4
- package/src/tabs/stories/best-practices.mdx +99 -0
- package/src/tabs/stories/index.story.tsx +5 -0
- package/src/tabs/types.ts +13 -14
- package/src/text/hook.ts +2 -2
- package/src/text/styles.ts +1 -1
- package/src/text/test/__snapshots__/index.tsx.snap +3 -3
- package/src/text/test/index.tsx +1 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +2 -2
- package/src/toggle-group-control/test/index.tsx +7 -1
- package/src/toggle-group-control/toggle-group-control/as-radio-group.tsx +1 -2
- package/src/tooltip/index.tsx +1 -2
- package/src/tree-grid/stories/index.story.tsx +2 -0
- package/src/tree-select/README.md +144 -28
- package/src/tree-select/docs-manifest.json +5 -0
- package/src/tree-select/index.tsx +11 -2
- package/src/tree-select/stories/index.story.tsx +1 -0
- package/src/tree-select/types.ts +8 -1
- package/tsconfig.json +0 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/build/slot-fill/use-slot.js +0 -32
- package/build/slot-fill/use-slot.js.map +0 -1
- package/build-module/slot-fill/use-slot.js +0 -24
- package/build-module/slot-fill/use-slot.js.map +0 -1
- package/build-types/slot-fill/use-slot.d.ts +0 -10
- package/build-types/slot-fill/use-slot.d.ts.map +0 -1
- package/src/slot-fill/use-slot.ts +0 -27
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useInstanceId } from '@wordpress/compose';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { useState } from '@wordpress/element';
|
|
7
|
+
import { settings } from '@wordpress/icons';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Internal dependencies
|
|
@@ -11,10 +13,13 @@ import Tooltip from '../tooltip';
|
|
|
11
13
|
import { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';
|
|
12
14
|
import {
|
|
13
15
|
CUSTOM_VALUE_SETTINGS,
|
|
14
|
-
getAllowedSides,
|
|
15
16
|
getMergedValue,
|
|
16
|
-
|
|
17
|
+
getAllowedSides,
|
|
18
|
+
getPresetIndexFromValue,
|
|
19
|
+
getPresetValueFromIndex,
|
|
20
|
+
isValuePreset,
|
|
17
21
|
isValuesDefined,
|
|
22
|
+
isValueMixed,
|
|
18
23
|
LABELS,
|
|
19
24
|
} from './utils';
|
|
20
25
|
import {
|
|
@@ -24,6 +29,7 @@ import {
|
|
|
24
29
|
StyledUnitControl,
|
|
25
30
|
} from './styles/box-control-styles';
|
|
26
31
|
import type { BoxControlInputControlProps, BoxControlValue } from './types';
|
|
32
|
+
import Button from '../button';
|
|
27
33
|
|
|
28
34
|
const noop = () => {};
|
|
29
35
|
|
|
@@ -78,6 +84,9 @@ export default function BoxInputControl( {
|
|
|
78
84
|
setSelectedUnits,
|
|
79
85
|
sides,
|
|
80
86
|
side,
|
|
87
|
+
min = 0,
|
|
88
|
+
presets,
|
|
89
|
+
presetKey,
|
|
81
90
|
...props
|
|
82
91
|
}: BoxControlInputControlProps ) {
|
|
83
92
|
const defaultValuesToModify = getSidesToModify( side, sides );
|
|
@@ -90,6 +99,15 @@ export default function BoxInputControl( {
|
|
|
90
99
|
onChange( nextValues );
|
|
91
100
|
};
|
|
92
101
|
|
|
102
|
+
const handleRawOnValueChange = ( next?: string ) => {
|
|
103
|
+
const nextValues = { ...values };
|
|
104
|
+
defaultValuesToModify.forEach( ( modifiedSide ) => {
|
|
105
|
+
nextValues[ modifiedSide ] = next;
|
|
106
|
+
} );
|
|
107
|
+
|
|
108
|
+
handleOnChange( nextValues );
|
|
109
|
+
};
|
|
110
|
+
|
|
93
111
|
const handleOnValueChange = (
|
|
94
112
|
next?: string,
|
|
95
113
|
extra?: { event: React.SyntheticEvent< Element, Event > }
|
|
@@ -147,51 +165,135 @@ export default function BoxInputControl( {
|
|
|
147
165
|
const usedValue =
|
|
148
166
|
mergedValue === undefined && computedUnit ? computedUnit : mergedValue;
|
|
149
167
|
const mixedPlaceholder = isMixed || isMixedUnit ? __( 'Mixed' ) : undefined;
|
|
168
|
+
const hasPresets = presets && presets.length > 0 && presetKey;
|
|
169
|
+
const hasPresetValue =
|
|
170
|
+
hasPresets &&
|
|
171
|
+
mergedValue !== undefined &&
|
|
172
|
+
! isMixed &&
|
|
173
|
+
isValuePreset( mergedValue, presetKey );
|
|
174
|
+
const [ showCustomValueControl, setShowCustomValueControl ] = useState(
|
|
175
|
+
! hasPresets ||
|
|
176
|
+
( ! hasPresetValue && ! isMixed && mergedValue !== undefined )
|
|
177
|
+
);
|
|
178
|
+
const presetIndex = hasPresetValue
|
|
179
|
+
? getPresetIndexFromValue( mergedValue, presetKey, presets )
|
|
180
|
+
: undefined;
|
|
181
|
+
const marks = hasPresets
|
|
182
|
+
? [ { value: 0, label: '', tooltip: __( 'None' ) } ].concat(
|
|
183
|
+
presets.map( ( preset, index ) => ( {
|
|
184
|
+
value: index + 1,
|
|
185
|
+
label: '',
|
|
186
|
+
tooltip: preset.name ?? preset.slug,
|
|
187
|
+
} ) )
|
|
188
|
+
)
|
|
189
|
+
: [];
|
|
150
190
|
|
|
151
191
|
return (
|
|
152
192
|
<InputWrapper key={ `box-control-${ side }` } expanded>
|
|
153
193
|
<FlexedBoxControlIcon side={ side } sides={ sides } />
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
{
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
194
|
+
{ showCustomValueControl && (
|
|
195
|
+
<>
|
|
196
|
+
<Tooltip placement="top-end" text={ LABELS[ side ] }>
|
|
197
|
+
<StyledUnitControl
|
|
198
|
+
{ ...props }
|
|
199
|
+
min={ min }
|
|
200
|
+
__shouldNotWarnDeprecated36pxSize
|
|
201
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
202
|
+
className="component-box-control__unit-control"
|
|
203
|
+
id={ inputId }
|
|
204
|
+
isPressEnterToChange
|
|
205
|
+
disableUnits={ isMixed || isMixedUnit }
|
|
206
|
+
value={ usedValue }
|
|
207
|
+
onChange={ handleOnValueChange }
|
|
208
|
+
onUnitChange={ handleOnUnitChange }
|
|
209
|
+
onFocus={ handleOnFocus }
|
|
210
|
+
label={ LABELS[ side ] }
|
|
211
|
+
placeholder={ mixedPlaceholder }
|
|
212
|
+
hideLabelFromVision
|
|
213
|
+
/>
|
|
214
|
+
</Tooltip>
|
|
215
|
+
|
|
216
|
+
<FlexedRangeControl
|
|
217
|
+
__nextHasNoMarginBottom
|
|
218
|
+
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
219
|
+
__shouldNotWarnDeprecated36pxSize
|
|
220
|
+
aria-controls={ inputId }
|
|
221
|
+
label={ LABELS[ side ] }
|
|
222
|
+
hideLabelFromVision
|
|
223
|
+
onChange={ ( newValue ) => {
|
|
224
|
+
handleOnValueChange(
|
|
225
|
+
newValue !== undefined
|
|
226
|
+
? [ newValue, computedUnit ].join( '' )
|
|
227
|
+
: undefined
|
|
228
|
+
);
|
|
229
|
+
} }
|
|
230
|
+
min={ isFinite( min ) ? min : 0 }
|
|
231
|
+
max={
|
|
232
|
+
CUSTOM_VALUE_SETTINGS[ computedUnit ?? 'px' ]
|
|
233
|
+
?.max ?? 10
|
|
234
|
+
}
|
|
235
|
+
step={
|
|
236
|
+
CUSTOM_VALUE_SETTINGS[ computedUnit ?? 'px' ]
|
|
237
|
+
?.step ?? 0.1
|
|
238
|
+
}
|
|
239
|
+
value={ parsedQuantity ?? 0 }
|
|
240
|
+
withInputField={ false }
|
|
241
|
+
/>
|
|
242
|
+
</>
|
|
243
|
+
) }
|
|
244
|
+
|
|
245
|
+
{ hasPresets && ! showCustomValueControl && (
|
|
246
|
+
<FlexedRangeControl
|
|
247
|
+
__next40pxDefaultSize
|
|
248
|
+
className="spacing-sizes-control__range-control"
|
|
249
|
+
value={ presetIndex !== undefined ? presetIndex + 1 : 0 }
|
|
250
|
+
onChange={ ( newIndex ) => {
|
|
251
|
+
const newValue =
|
|
252
|
+
newIndex === 0 || newIndex === undefined
|
|
253
|
+
? undefined
|
|
254
|
+
: getPresetValueFromIndex(
|
|
255
|
+
newIndex - 1,
|
|
256
|
+
presetKey,
|
|
257
|
+
presets
|
|
258
|
+
);
|
|
259
|
+
handleRawOnValueChange( newValue );
|
|
260
|
+
} }
|
|
261
|
+
withInputField={ false }
|
|
262
|
+
aria-valuenow={
|
|
263
|
+
presetIndex !== undefined ? presetIndex + 1 : 0
|
|
264
|
+
}
|
|
265
|
+
aria-valuetext={
|
|
266
|
+
marks[ presetIndex !== undefined ? presetIndex + 1 : 0 ]
|
|
267
|
+
.tooltip
|
|
268
|
+
}
|
|
269
|
+
renderTooltipContent={ ( index ) =>
|
|
270
|
+
marks[ ! index ? 0 : index ].tooltip
|
|
271
|
+
}
|
|
272
|
+
min={ 0 }
|
|
273
|
+
max={ marks.length - 1 }
|
|
274
|
+
marks={ marks }
|
|
167
275
|
label={ LABELS[ side ] }
|
|
168
|
-
placeholder={ mixedPlaceholder }
|
|
169
276
|
hideLabelFromVision
|
|
277
|
+
__nextHasNoMarginBottom
|
|
278
|
+
/>
|
|
279
|
+
) }
|
|
280
|
+
|
|
281
|
+
{ hasPresets && (
|
|
282
|
+
<Button
|
|
283
|
+
label={
|
|
284
|
+
showCustomValueControl
|
|
285
|
+
? __( 'Use size preset' )
|
|
286
|
+
: __( 'Set custom size' )
|
|
287
|
+
}
|
|
288
|
+
icon={ settings }
|
|
289
|
+
onClick={ () => {
|
|
290
|
+
setShowCustomValueControl( ! showCustomValueControl );
|
|
291
|
+
} }
|
|
292
|
+
isPressed={ showCustomValueControl }
|
|
293
|
+
size="small"
|
|
294
|
+
iconSize={ 24 }
|
|
170
295
|
/>
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
<FlexedRangeControl
|
|
174
|
-
__nextHasNoMarginBottom
|
|
175
|
-
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
176
|
-
__shouldNotWarnDeprecated36pxSize
|
|
177
|
-
aria-controls={ inputId }
|
|
178
|
-
label={ LABELS[ side ] }
|
|
179
|
-
hideLabelFromVision
|
|
180
|
-
onChange={ ( newValue ) => {
|
|
181
|
-
handleOnValueChange(
|
|
182
|
-
newValue !== undefined
|
|
183
|
-
? [ newValue, computedUnit ].join( '' )
|
|
184
|
-
: undefined
|
|
185
|
-
);
|
|
186
|
-
} }
|
|
187
|
-
min={ 0 }
|
|
188
|
-
max={ CUSTOM_VALUE_SETTINGS[ computedUnit ?? 'px' ]?.max ?? 10 }
|
|
189
|
-
step={
|
|
190
|
-
CUSTOM_VALUE_SETTINGS[ computedUnit ?? 'px' ]?.step ?? 0.1
|
|
191
|
-
}
|
|
192
|
-
value={ parsedQuantity ?? 0 }
|
|
193
|
-
withInputField={ false }
|
|
194
|
-
/>
|
|
296
|
+
) }
|
|
195
297
|
</InputWrapper>
|
|
196
298
|
);
|
|
197
299
|
}
|
|
@@ -81,3 +81,15 @@ AxialControlsWithSingleSide.args = {
|
|
|
81
81
|
sides: [ 'horizontal' ],
|
|
82
82
|
splitOnAxis: true,
|
|
83
83
|
};
|
|
84
|
+
|
|
85
|
+
export const ControlWithPresets = TemplateControlled.bind( {} );
|
|
86
|
+
ControlWithPresets.args = {
|
|
87
|
+
...Default.args,
|
|
88
|
+
presets: [
|
|
89
|
+
{ name: 'Small', slug: 'small', value: '4px' },
|
|
90
|
+
{ name: 'Medium', slug: 'medium', value: '8px' },
|
|
91
|
+
{ name: 'Large', slug: 'large', value: '12px' },
|
|
92
|
+
{ name: 'Extra Large', slug: 'extra-large', value: '16px' },
|
|
93
|
+
],
|
|
94
|
+
presetKey: 'padding',
|
|
95
|
+
};
|
package/src/box-control/types.ts
CHANGED
|
@@ -15,6 +15,12 @@ export type CustomValueUnits = {
|
|
|
15
15
|
[ key: string ]: { max: number; step: number };
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
export interface Preset {
|
|
19
|
+
name: string;
|
|
20
|
+
slug: string;
|
|
21
|
+
value?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
18
24
|
type UnitControlPassthroughProps = Omit<
|
|
19
25
|
UnitControlProps,
|
|
20
26
|
'label' | 'onChange' | 'onFocus' | 'units'
|
|
@@ -94,6 +100,16 @@ export type BoxControlProps = Pick< UnitControlProps, 'units' > &
|
|
|
94
100
|
* @default false
|
|
95
101
|
*/
|
|
96
102
|
__next40pxDefaultSize?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Available presets to pick from.
|
|
105
|
+
*/
|
|
106
|
+
presets?: Preset[];
|
|
107
|
+
/**
|
|
108
|
+
* The key of the preset to apply.
|
|
109
|
+
* If you provide a list of presets, you must provide a preset key to use.
|
|
110
|
+
* The format of preset selected values is going to be `var:preset|${ presetKey }|${ presetSlug }`
|
|
111
|
+
*/
|
|
112
|
+
presetKey?: string;
|
|
97
113
|
};
|
|
98
114
|
|
|
99
115
|
export type BoxControlInputControlProps = UnitControlPassthroughProps & {
|
|
@@ -120,6 +136,8 @@ export type BoxControlInputControlProps = UnitControlPassthroughProps & {
|
|
|
120
136
|
* It can be a concrete side like: left, right, top, bottom or a combined one like: horizontal, vertical.
|
|
121
137
|
*/
|
|
122
138
|
side: keyof typeof LABELS;
|
|
139
|
+
presets?: Preset[];
|
|
140
|
+
presetKey?: string;
|
|
123
141
|
};
|
|
124
142
|
|
|
125
143
|
export type BoxControlIconProps = {
|
package/src/box-control/utils.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
BoxControlProps,
|
|
12
12
|
BoxControlValue,
|
|
13
13
|
CustomValueUnits,
|
|
14
|
+
Preset,
|
|
14
15
|
} from './types';
|
|
15
16
|
import deprecated from '@wordpress/deprecated';
|
|
16
17
|
|
|
@@ -272,3 +273,62 @@ export function getAllowedSides(
|
|
|
272
273
|
} );
|
|
273
274
|
return allowedSides;
|
|
274
275
|
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Checks if a value is a preset value.
|
|
279
|
+
*
|
|
280
|
+
* @param value The value to check.
|
|
281
|
+
* @param presetKey The preset key to check against.
|
|
282
|
+
* @return Whether the value is a preset value.
|
|
283
|
+
*/
|
|
284
|
+
export function isValuePreset( value: string, presetKey: string ) {
|
|
285
|
+
return value.startsWith( `var:preset|${ presetKey }|` );
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Returns the index of the preset value in the presets array.
|
|
290
|
+
*
|
|
291
|
+
* @param value The value to check.
|
|
292
|
+
* @param presetKey The preset key to check against.
|
|
293
|
+
* @param presets The array of presets to search.
|
|
294
|
+
* @return The index of the preset value in the presets array.
|
|
295
|
+
*/
|
|
296
|
+
export function getPresetIndexFromValue(
|
|
297
|
+
value: string,
|
|
298
|
+
presetKey: string,
|
|
299
|
+
presets: Preset[]
|
|
300
|
+
) {
|
|
301
|
+
if ( ! isValuePreset( value, presetKey ) ) {
|
|
302
|
+
return undefined;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const match = value.match(
|
|
306
|
+
new RegExp( `^var:preset\\|${ presetKey }\\|(.+)$` )
|
|
307
|
+
);
|
|
308
|
+
if ( ! match ) {
|
|
309
|
+
return undefined;
|
|
310
|
+
}
|
|
311
|
+
const slug = match[ 1 ];
|
|
312
|
+
const index = presets.findIndex( ( preset ) => {
|
|
313
|
+
return preset.slug === slug;
|
|
314
|
+
} );
|
|
315
|
+
|
|
316
|
+
return index !== -1 ? index : undefined;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Returns the preset value from the index.
|
|
321
|
+
*
|
|
322
|
+
* @param index The index of the preset value in the presets array.
|
|
323
|
+
* @param presetKey The preset key to check against.
|
|
324
|
+
* @param presets The array of presets to search.
|
|
325
|
+
* @return The preset value from the index.
|
|
326
|
+
*/
|
|
327
|
+
export function getPresetValueFromIndex(
|
|
328
|
+
index: number,
|
|
329
|
+
presetKey: string,
|
|
330
|
+
presets: Preset[]
|
|
331
|
+
) {
|
|
332
|
+
const preset = presets[ index ];
|
|
333
|
+
return `var:preset|${ presetKey }|${ preset.slug }`;
|
|
334
|
+
}
|
package/src/button/README.md
CHANGED
|
@@ -17,19 +17,24 @@ const Mybutton = () => (
|
|
|
17
17
|
</Button>
|
|
18
18
|
);
|
|
19
19
|
```
|
|
20
|
+
|
|
20
21
|
## Props
|
|
21
22
|
|
|
22
23
|
### `__next40pxDefaultSize`
|
|
23
24
|
|
|
25
|
+
- Type: `boolean`
|
|
26
|
+
- Required: No
|
|
27
|
+
- Default: `false`
|
|
28
|
+
|
|
24
29
|
Start opting into the larger default height that will become the
|
|
25
30
|
default size in a future version.
|
|
26
31
|
|
|
32
|
+
### `accessibleWhenDisabled`
|
|
33
|
+
|
|
27
34
|
- Type: `boolean`
|
|
28
35
|
- Required: No
|
|
29
36
|
- Default: `false`
|
|
30
37
|
|
|
31
|
-
### `accessibleWhenDisabled`
|
|
32
|
-
|
|
33
38
|
Whether to keep the button focusable when disabled.
|
|
34
39
|
|
|
35
40
|
In most cases, it is recommended to set this to `true`. Disabling a control without maintaining focusability
|
|
@@ -39,111 +44,111 @@ or by preventing focus from returning to a trigger element.
|
|
|
39
44
|
Learn more about the [focusability of disabled controls](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#focusabilityofdisabledcontrols)
|
|
40
45
|
in the WAI-ARIA Authoring Practices Guide.
|
|
41
46
|
|
|
42
|
-
- Type: `boolean`
|
|
43
|
-
- Required: No
|
|
44
|
-
- Default: `false`
|
|
45
|
-
|
|
46
47
|
### `children`
|
|
47
48
|
|
|
48
|
-
The button's children.
|
|
49
|
-
|
|
50
49
|
- Type: `ReactNode`
|
|
51
50
|
- Required: No
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
The button's children.
|
|
54
53
|
|
|
55
|
-
|
|
54
|
+
### `description`
|
|
56
55
|
|
|
57
56
|
- Type: `string`
|
|
58
57
|
- Required: No
|
|
59
58
|
|
|
59
|
+
A visually hidden accessible description for the button.
|
|
60
|
+
|
|
60
61
|
### `disabled`
|
|
61
62
|
|
|
63
|
+
- Type: `boolean`
|
|
64
|
+
- Required: No
|
|
65
|
+
|
|
62
66
|
Whether the button is disabled. If `true`, this will force a `button` element
|
|
63
67
|
to be rendered, even when an `href` is given.
|
|
64
68
|
|
|
65
69
|
In most cases, it is recommended to also set the `accessibleWhenDisabled` prop to `true`.
|
|
66
70
|
|
|
67
|
-
- Type: `boolean`
|
|
68
|
-
- Required: No
|
|
69
|
-
|
|
70
71
|
### `href`
|
|
71
72
|
|
|
72
|
-
If provided, renders `a` instead of `button`.
|
|
73
|
-
|
|
74
73
|
- Type: `string`
|
|
75
74
|
- Required: Yes
|
|
76
75
|
|
|
77
|
-
|
|
76
|
+
If provided, renders `a` instead of `button`.
|
|
78
77
|
|
|
79
|
-
|
|
78
|
+
### `icon`
|
|
80
79
|
|
|
81
80
|
- Type: `IconType`
|
|
82
81
|
- Required: No
|
|
83
82
|
|
|
84
|
-
|
|
83
|
+
If provided, renders an Icon component inside the button.
|
|
85
84
|
|
|
86
|
-
|
|
85
|
+
### `iconPosition`
|
|
87
86
|
|
|
88
87
|
- Type: `"left" | "right"`
|
|
89
88
|
- Required: No
|
|
90
89
|
- Default: `'left'`
|
|
91
90
|
|
|
91
|
+
If provided with `icon`, sets the position of icon relative to the `text`.
|
|
92
|
+
|
|
92
93
|
### `iconSize`
|
|
93
94
|
|
|
95
|
+
- Type: `number`
|
|
96
|
+
- Required: No
|
|
97
|
+
|
|
94
98
|
If provided with `icon`, sets the icon size.
|
|
95
99
|
Please refer to the Icon component for more details regarding
|
|
96
100
|
the default value of its `size` prop.
|
|
97
101
|
|
|
98
|
-
- Type: `number`
|
|
99
|
-
- Required: No
|
|
100
|
-
|
|
101
102
|
### `isBusy`
|
|
102
103
|
|
|
103
|
-
Indicates activity while a action is being performed.
|
|
104
|
-
|
|
105
104
|
- Type: `boolean`
|
|
106
105
|
- Required: No
|
|
107
106
|
|
|
108
|
-
|
|
107
|
+
Indicates activity while a action is being performed.
|
|
109
108
|
|
|
110
|
-
|
|
109
|
+
### `isDestructive`
|
|
111
110
|
|
|
112
111
|
- Type: `boolean`
|
|
113
112
|
- Required: No
|
|
114
113
|
|
|
115
|
-
|
|
114
|
+
Renders a red text-based button style to indicate destructive behavior.
|
|
116
115
|
|
|
117
|
-
|
|
116
|
+
### `isPressed`
|
|
118
117
|
|
|
119
118
|
- Type: `boolean`
|
|
120
119
|
- Required: No
|
|
121
120
|
|
|
122
|
-
|
|
121
|
+
Renders a pressed button style.
|
|
123
122
|
|
|
124
|
-
|
|
125
|
-
Sets the Tooltip content if `showTooltip` is provided.
|
|
123
|
+
### `label`
|
|
126
124
|
|
|
127
125
|
- Type: `string`
|
|
128
126
|
- Required: No
|
|
129
127
|
|
|
130
|
-
|
|
128
|
+
Sets the `aria-label` of the component, if none is provided.
|
|
129
|
+
Sets the Tooltip content if `showTooltip` is provided.
|
|
131
130
|
|
|
132
|
-
|
|
133
|
-
If an object is provided, it should contain `display` and `ariaLabel` keys.
|
|
131
|
+
### `shortcut`
|
|
134
132
|
|
|
135
133
|
- Type: `string | { display: string; ariaLabel: string; }`
|
|
136
134
|
- Required: No
|
|
137
135
|
|
|
138
|
-
|
|
136
|
+
If provided with `showTooltip`, appends the Shortcut label to the tooltip content.
|
|
137
|
+
If an object is provided, it should contain `display` and `ariaLabel` keys.
|
|
139
138
|
|
|
140
|
-
|
|
139
|
+
### `showTooltip`
|
|
141
140
|
|
|
142
141
|
- Type: `boolean`
|
|
143
142
|
- Required: No
|
|
144
143
|
|
|
144
|
+
If provided, renders a Tooltip component for the button.
|
|
145
|
+
|
|
145
146
|
### `size`
|
|
146
147
|
|
|
148
|
+
- Type: `"small" | "default" | "compact"`
|
|
149
|
+
- Required: No
|
|
150
|
+
- Default: `'default'`
|
|
151
|
+
|
|
147
152
|
The size of the button.
|
|
148
153
|
|
|
149
154
|
- `'default'`: For normal text-label buttons, unless it is a toggle button.
|
|
@@ -152,34 +157,33 @@ The size of the button.
|
|
|
152
157
|
|
|
153
158
|
If the deprecated `isSmall` prop is also defined, this prop will take precedence.
|
|
154
159
|
|
|
155
|
-
- Type: `"small" | "default" | "compact"`
|
|
156
|
-
- Required: No
|
|
157
|
-
- Default: `'default'`
|
|
158
|
-
|
|
159
160
|
### `text`
|
|
160
161
|
|
|
161
|
-
If provided, displays the given text inside the button. If the button contains children elements, the text is displayed before them.
|
|
162
|
-
|
|
163
162
|
- Type: `string`
|
|
164
163
|
- Required: No
|
|
165
164
|
|
|
166
|
-
|
|
165
|
+
If provided, displays the given text inside the button. If the button contains children elements, the text is displayed before them.
|
|
167
166
|
|
|
168
|
-
|
|
169
|
-
Please refer to the Tooltip component for more details regarding the defaults.
|
|
167
|
+
### `tooltipPosition`
|
|
170
168
|
|
|
171
169
|
- Type: `"top" | "middle" | "bottom" | "top center" | "top left" | "top right" | "middle center" | "middle left" | "middle right" | "bottom center" | ...`
|
|
172
170
|
- Required: No
|
|
173
171
|
|
|
174
|
-
|
|
172
|
+
If provided with `showTooltip`, sets the position of the tooltip.
|
|
173
|
+
Please refer to the Tooltip component for more details regarding the defaults.
|
|
175
174
|
|
|
176
|
-
|
|
175
|
+
### `target`
|
|
177
176
|
|
|
178
177
|
- Type: `string`
|
|
179
178
|
- Required: No
|
|
180
179
|
|
|
180
|
+
If provided with `href`, sets the `target` attribute to the `a`.
|
|
181
|
+
|
|
181
182
|
### `variant`
|
|
182
183
|
|
|
184
|
+
- Type: `"link" | "primary" | "secondary" | "tertiary"`
|
|
185
|
+
- Required: No
|
|
186
|
+
|
|
183
187
|
Specifies the button's style.
|
|
184
188
|
|
|
185
189
|
The accepted values are:
|
|
@@ -188,6 +192,3 @@ The accepted values are:
|
|
|
188
192
|
2. `'secondary'` (the default button styles)
|
|
189
193
|
3. `'tertiary'` (the text-based button styles)
|
|
190
194
|
4. `'link'` (the link button styles)
|
|
191
|
-
|
|
192
|
-
- Type: `"link" | "primary" | "secondary" | "tertiary"`
|
|
193
|
-
- Required: No
|
package/src/button/style.scss
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
display: inline-flex;
|
|
10
10
|
text-decoration: none;
|
|
11
11
|
font-family: inherit;
|
|
12
|
-
font-weight: normal;
|
|
13
12
|
font-size: $default-font-size;
|
|
14
13
|
margin: 0;
|
|
15
14
|
border: 0;
|
|
@@ -139,8 +138,10 @@
|
|
|
139
138
|
color: $components-color-accent;
|
|
140
139
|
background: transparent;
|
|
141
140
|
|
|
142
|
-
&:hover:not(:disabled, [aria-disabled="true"]) {
|
|
143
|
-
box-shadow: inset 0 0 0 $border-width $components-color-accent-darker-
|
|
141
|
+
&:hover:not(:disabled, [aria-disabled="true"], .is-pressed) {
|
|
142
|
+
box-shadow: inset 0 0 0 $border-width $components-color-accent-darker-20;
|
|
143
|
+
color: $components-color-accent-darker-20;
|
|
144
|
+
background: color-mix(in srgb, $components-color-accent 4%, transparent);
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
&:disabled:not(:focus),
|
|
@@ -164,15 +165,12 @@
|
|
|
164
165
|
background: transparent;
|
|
165
166
|
|
|
166
167
|
&:hover:not(:disabled, [aria-disabled="true"]) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
|
|
168
|
+
background: color-mix(in srgb, $components-color-accent 4%, transparent);
|
|
169
|
+
color: $components-color-accent-darker-20;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
&:active:not(:disabled, [aria-disabled="true"]) {
|
|
173
|
-
|
|
174
|
-
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- Allow tertiary buttons to use colors from the user admin color scheme. */
|
|
175
|
-
background: rgba(var(--wp-admin-theme-color--rgb), 0.08);
|
|
173
|
+
background: color-mix(in srgb, $components-color-accent 8%, transparent);
|
|
176
174
|
}
|
|
177
175
|
|
|
178
176
|
// Pull left if the tertiary button stands alone after a description, so as to vertically align with items above.
|
|
@@ -220,7 +218,8 @@
|
|
|
220
218
|
}
|
|
221
219
|
}
|
|
222
220
|
|
|
223
|
-
&.is-tertiary
|
|
221
|
+
&.is-tertiary,
|
|
222
|
+
&.is-secondary {
|
|
224
223
|
&:hover:not(:disabled, [aria-disabled="true"]) {
|
|
225
224
|
background: rgba($alert-red, 0.04);
|
|
226
225
|
}
|
|
@@ -6,19 +6,26 @@ import { render, screen } from '@testing-library/react';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { createRef } from '@wordpress/element';
|
|
9
|
+
import { createRef, forwardRef } from '@wordpress/element';
|
|
10
10
|
import { plusCircle } from '@wordpress/icons';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
|
-
import
|
|
15
|
+
import _Button from '..';
|
|
16
16
|
import Tooltip from '../../tooltip';
|
|
17
17
|
import cleanupTooltip from '../../tooltip/test/utils';
|
|
18
18
|
import { press } from '@ariakit/test';
|
|
19
19
|
|
|
20
20
|
jest.mock( '../../icon', () => () => <div data-testid="test-icon" /> );
|
|
21
21
|
|
|
22
|
+
const Button = forwardRef(
|
|
23
|
+
(
|
|
24
|
+
props: React.ComponentProps< typeof _Button >,
|
|
25
|
+
ref: React.ForwardedRef< unknown >
|
|
26
|
+
) => <_Button __next40pxDefaultSize { ...props } ref={ ref } />
|
|
27
|
+
);
|
|
28
|
+
|
|
22
29
|
describe( 'Button', () => {
|
|
23
30
|
describe( 'basic rendering', () => {
|
|
24
31
|
it( 'should render a button element with only one class', () => {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# ButtonGroup
|
|
2
2
|
|
|
3
|
+
<div class="callout callout-alert">
|
|
4
|
+
This component is deprecated. Use `ToggleGroupControl` instead.
|
|
5
|
+
</div>
|
|
6
|
+
|
|
3
7
|
ButtonGroup can be used to group any related buttons together. To emphasize related buttons, a group should share a common container.
|
|
4
8
|
|
|
5
9
|

|