@wordpress/components 23.1.0 → 23.3.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 +53 -0
- package/CONTRIBUTING.md +1 -1
- package/LICENSE.md +1 -1
- package/build/alignment-matrix-control/utils.js +2 -2
- package/build/alignment-matrix-control/utils.js.map +1 -1
- package/build/autocomplete/autocompleter-ui.js +1 -3
- package/build/autocomplete/autocompleter-ui.js.map +1 -1
- package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
- package/build/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +8 -4
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/button/deprecated.js +8 -6
- package/build/button/deprecated.js.map +1 -1
- package/build/button/index.js +52 -23
- package/build/button/index.js.map +1 -1
- package/build/button/types.js +6 -0
- package/build/button/types.js.map +1 -0
- package/build/color-list-picker/index.js.map +1 -1
- package/build/color-list-picker/types.js +6 -0
- package/build/color-list-picker/types.js.map +1 -0
- package/build/color-palette/index.js +9 -61
- package/build/color-palette/index.js.map +1 -1
- package/build/color-palette/index.native.js +24 -9
- package/build/color-palette/index.native.js.map +1 -1
- package/build/color-palette/utils.js +103 -0
- package/build/color-palette/utils.js.map +1 -0
- package/build/color-picker/component.js +1 -0
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/styles.js +8 -10
- package/build/color-picker/styles.js.map +1 -1
- package/build/combobox-control/index.js +5 -1
- package/build/combobox-control/index.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/utils.js +1 -1
- package/build/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
- package/build/date-time/date/index.js.map +1 -1
- package/build/dropdown/index.js +20 -8
- package/build/dropdown/index.js.map +1 -1
- package/build/focal-point-picker/utils.js +1 -1
- package/build/focal-point-picker/utils.js.map +1 -1
- package/build/form-token-field/token.js +1 -1
- package/build/form-token-field/token.js.map +1 -1
- package/build/gradient-picker/index.js +9 -1
- package/build/gradient-picker/index.js.map +1 -1
- package/build/h-stack/component.js +0 -1
- package/build/h-stack/component.js.map +1 -1
- package/build/index.js +7 -17
- package/build/index.js.map +1 -1
- package/build/index.native.js +8 -18
- package/build/index.native.js.map +1 -1
- package/build/input-control/input-field.js +4 -2
- package/build/input-control/input-field.js.map +1 -1
- package/build/item-group/item/component.js +27 -3
- package/build/item-group/item/component.js.map +1 -1
- package/build/item-group/item-group/component.js +26 -3
- package/build/item-group/item-group/component.js.map +1 -1
- package/build/item-group/styles.js +14 -14
- package/build/item-group/styles.js.map +1 -1
- package/build/keyboard-shortcuts/index.js +44 -16
- package/build/keyboard-shortcuts/index.js.map +1 -1
- package/build/keyboard-shortcuts/types.js +6 -0
- package/build/keyboard-shortcuts/types.js.map +1 -0
- package/build/modal/index.js +1 -1
- package/build/modal/index.js.map +1 -1
- package/build/notice/index.js +16 -18
- package/build/notice/index.js.map +1 -1
- package/build/notice/list.js +23 -8
- package/build/notice/list.js.map +1 -1
- package/build/notice/types.js +6 -0
- package/build/notice/types.js.map +1 -0
- package/build/number-control/index.js +1 -1
- package/build/number-control/index.js.map +1 -1
- package/build/panel/row.js +5 -3
- package/build/panel/row.js.map +1 -1
- package/build/query-controls/author-select.js +7 -3
- package/build/query-controls/author-select.js.map +1 -1
- package/build/query-controls/category-select.js +7 -3
- package/build/query-controls/category-select.js.map +1 -1
- package/build/query-controls/index.js +69 -20
- package/build/query-controls/index.js.map +1 -1
- package/build/query-controls/terms.js +4 -3
- package/build/query-controls/terms.js.map +1 -1
- package/build/query-controls/types.js +6 -0
- package/build/query-controls/types.js.map +1 -0
- package/build/resizable-box/index.js +5 -4
- package/build/resizable-box/index.js.map +1 -1
- package/build/responsive-wrapper/index.js +18 -1
- package/build/responsive-wrapper/index.js.map +1 -1
- package/build/responsive-wrapper/types.js +6 -0
- package/build/responsive-wrapper/types.js.map +1 -0
- package/build/sandbox/index.js +35 -24
- package/build/sandbox/index.js.map +1 -1
- package/build/sandbox/types.js +6 -0
- package/build/sandbox/types.js.map +1 -0
- package/build/slot-fill/bubbles-virtually/fill.js +1 -0
- package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build/slot-fill/slot.js +1 -0
- package/build/slot-fill/slot.js.map +1 -1
- package/build/slot-fill/use-slot.js +1 -11
- package/build/slot-fill/use-slot.js.map +1 -1
- package/build/snackbar/index.js.map +1 -1
- package/build/snackbar/list.js.map +1 -1
- package/build/tab-panel/index.js +40 -7
- package/build/tab-panel/index.js.map +1 -1
- package/build/toolbar/index.js +42 -60
- package/build/toolbar/index.js.map +1 -1
- package/build/toolbar/toolbar/index.js +74 -0
- package/build/toolbar/toolbar/index.js.map +1 -0
- package/build/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
- package/build/toolbar/toolbar/toolbar-container.js.map +1 -0
- package/build/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
- package/build/toolbar/toolbar/toolbar-container.native.js.map +1 -0
- package/build/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
- package/build/toolbar/toolbar-button/index.js.map +1 -0
- package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
- package/build/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
- package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
- package/build/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
- package/build/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
- package/build/toolbar/toolbar-context/index.js.map +1 -0
- package/build/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
- package/build/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
- package/build/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
- package/build/toolbar/toolbar-group/index.js.map +1 -0
- package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
- package/build/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
- package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
- package/build/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
- package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
- package/build/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
- package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
- package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
- package/build/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
- package/build/toolbar/toolbar-item/index.js.map +1 -0
- package/build/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
- package/build/toolbar/toolbar-item/index.native.js.map +1 -0
- package/build/tree-grid/index.js +4 -4
- package/build/tree-grid/index.js.map +1 -1
- package/build/tree-select/index.js +2 -6
- package/build/tree-select/index.js.map +1 -1
- package/build-module/alignment-matrix-control/utils.js +2 -2
- package/build-module/alignment-matrix-control/utils.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.js +1 -2
- package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
- package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +7 -4
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/button/deprecated.js +8 -5
- package/build-module/button/deprecated.js.map +1 -1
- package/build-module/button/index.js +51 -22
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/types.js +2 -0
- package/build-module/button/types.js.map +1 -0
- package/build-module/color-list-picker/index.js.map +1 -1
- package/build-module/color-list-picker/types.js +2 -0
- package/build-module/color-list-picker/types.js.map +1 -0
- package/build-module/color-palette/index.js +7 -54
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-palette/index.native.js +24 -8
- package/build-module/color-palette/index.native.js.map +1 -1
- package/build-module/color-palette/utils.js +79 -0
- package/build-module/color-palette/utils.js.map +1 -0
- package/build-module/color-picker/component.js +1 -0
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/styles.js +8 -9
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/combobox-control/index.js +5 -1
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/utils.js +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
- package/build-module/date-time/date/index.js +1 -1
- package/build-module/date-time/date/index.js.map +1 -1
- package/build-module/dropdown/index.js +19 -8
- package/build-module/dropdown/index.js.map +1 -1
- package/build-module/focal-point-picker/utils.js +1 -1
- package/build-module/focal-point-picker/utils.js.map +1 -1
- package/build-module/form-token-field/token.js +1 -1
- package/build-module/form-token-field/token.js.map +1 -1
- package/build-module/gradient-picker/index.js +9 -2
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/h-stack/component.js +0 -1
- package/build-module/h-stack/component.js.map +1 -1
- package/build-module/index.js +1 -6
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +1 -6
- package/build-module/index.native.js.map +1 -1
- package/build-module/input-control/input-field.js +4 -2
- package/build-module/input-control/input-field.js.map +1 -1
- package/build-module/item-group/item/component.js +26 -2
- package/build-module/item-group/item/component.js.map +1 -1
- package/build-module/item-group/item-group/component.js +25 -2
- package/build-module/item-group/item-group/component.js.map +1 -1
- package/build-module/item-group/styles.js +14 -14
- package/build-module/item-group/styles.js.map +1 -1
- package/build-module/keyboard-shortcuts/index.js +48 -16
- package/build-module/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/keyboard-shortcuts/types.js +2 -0
- package/build-module/keyboard-shortcuts/types.js.map +1 -0
- package/build-module/modal/index.js +1 -1
- package/build-module/modal/index.js.map +1 -1
- package/build-module/notice/index.js +14 -15
- package/build-module/notice/index.js.map +1 -1
- package/build-module/notice/list.js +23 -8
- package/build-module/notice/list.js.map +1 -1
- package/build-module/notice/types.js +2 -0
- package/build-module/notice/types.js.map +1 -0
- package/build-module/number-control/index.js +1 -1
- package/build-module/number-control/index.js.map +1 -1
- package/build-module/panel/row.js +5 -3
- package/build-module/panel/row.js.map +1 -1
- package/build-module/query-controls/author-select.js +7 -3
- package/build-module/query-controls/author-select.js.map +1 -1
- package/build-module/query-controls/category-select.js +8 -4
- package/build-module/query-controls/category-select.js.map +1 -1
- package/build-module/query-controls/index.js +65 -20
- package/build-module/query-controls/index.js.map +1 -1
- package/build-module/query-controls/terms.js +8 -4
- package/build-module/query-controls/terms.js.map +1 -1
- package/build-module/query-controls/types.js +2 -0
- package/build-module/query-controls/types.js.map +1 -0
- package/build-module/resizable-box/index.js +3 -2
- package/build-module/resizable-box/index.js.map +1 -1
- package/build-module/responsive-wrapper/index.js +20 -1
- package/build-module/responsive-wrapper/index.js.map +1 -1
- package/build-module/responsive-wrapper/types.js +2 -0
- package/build-module/responsive-wrapper/types.js.map +1 -0
- package/build-module/sandbox/index.js +37 -23
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/sandbox/types.js +2 -0
- package/build-module/sandbox/types.js.map +1 -0
- package/build-module/slot-fill/bubbles-virtually/fill.js +1 -0
- package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build-module/slot-fill/slot.js +1 -0
- package/build-module/slot-fill/slot.js.map +1 -1
- package/build-module/slot-fill/use-slot.js +2 -12
- package/build-module/slot-fill/use-slot.js.map +1 -1
- package/build-module/snackbar/index.js.map +1 -1
- package/build-module/snackbar/list.js.map +1 -1
- package/build-module/tab-panel/index.js +40 -7
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/toolbar/index.js +6 -58
- package/build-module/toolbar/index.js.map +1 -1
- package/build-module/toolbar/toolbar/index.js +59 -0
- package/build-module/toolbar/toolbar/index.js.map +1 -0
- package/build-module/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
- package/{build → build-module/toolbar}/toolbar/toolbar-container.js.map +1 -1
- package/build-module/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
- package/build-module/toolbar/toolbar/toolbar-container.native.js.map +1 -0
- package/build-module/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
- package/build-module/toolbar/toolbar-button/index.js.map +1 -0
- package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
- package/build-module/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
- package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
- package/build-module/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
- package/build-module/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
- package/build-module/toolbar/toolbar-context/index.js.map +1 -0
- package/build-module/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
- package/build-module/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
- package/build-module/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
- package/build-module/toolbar/toolbar-group/index.js.map +1 -0
- package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
- package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
- package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
- package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
- package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
- package/build-module/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
- package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
- package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
- package/build-module/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
- package/build-module/toolbar/toolbar-item/index.js.map +1 -0
- package/build-module/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
- package/build-module/toolbar/toolbar-item/index.native.js.map +1 -0
- package/build-module/tree-grid/index.js +4 -4
- package/build-module/tree-grid/index.js.map +1 -1
- package/build-module/tree-select/index.js +2 -6
- package/build-module/tree-select/index.js.map +1 -1
- package/build-style/style-rtl.css +6 -1
- package/build-style/style.css +6 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +1 -1
- package/build-types/border-box-control/border-box-control-linked-button/component.d.ts +1 -1
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +171 -160
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -1
- package/build-types/border-control/border-control/hook.d.ts +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -1
- package/build-types/button/deprecated.d.ts +143 -7
- package/build-types/button/deprecated.d.ts.map +1 -1
- package/build-types/button/index.d.ts +20 -3
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/button/stories/index.d.ts +20 -0
- package/build-types/button/stories/index.d.ts.map +1 -0
- package/build-types/button/test/index.d.ts +2 -0
- package/build-types/button/test/index.d.ts.map +1 -0
- package/build-types/button/types.d.ts +134 -0
- package/build-types/button/types.d.ts.map +1 -0
- package/build-types/color-list-picker/index.d.ts +5 -0
- package/build-types/color-list-picker/index.d.ts.map +1 -0
- package/build-types/color-list-picker/types.d.ts +42 -0
- package/build-types/color-list-picker/types.d.ts.map +1 -0
- package/build-types/color-palette/index.d.ts +2 -4
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.d.ts +2 -2
- package/build-types/color-palette/styles.d.ts +1 -1
- package/build-types/color-palette/types.d.ts +1 -1
- package/build-types/color-palette/types.d.ts.map +1 -1
- package/build-types/color-palette/utils.d.ts +14 -0
- package/build-types/color-palette/utils.d.ts.map +1 -0
- package/build-types/color-picker/component.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/dashicon/types.d.ts +0 -4
- package/build-types/dashicon/types.d.ts.map +1 -1
- package/build-types/date-time/date/index.d.ts.map +1 -1
- package/build-types/date-time/date/styles.d.ts +3 -3
- package/build-types/dropdown/index.d.ts +4 -4
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.d.ts.map +1 -1
- package/build-types/dropdown/types.d.ts +9 -10
- package/build-types/dropdown/types.d.ts.map +1 -1
- package/build-types/focal-point-picker/utils.d.ts.map +1 -1
- package/build-types/font-size-picker/styles.d.ts +2 -2
- package/build-types/h-stack/component.d.ts +0 -1
- package/build-types/h-stack/component.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/item-group/item/component.d.ts +24 -2
- package/build-types/item-group/item/component.d.ts.map +1 -1
- package/build-types/item-group/item-group/component.d.ts +23 -2
- package/build-types/item-group/item-group/component.d.ts.map +1 -1
- package/build-types/item-group/stories/index.d.ts +15 -0
- package/build-types/item-group/stories/index.d.ts.map +1 -0
- package/build-types/item-group/styles.d.ts.map +1 -1
- package/build-types/keyboard-shortcuts/index.d.ts +38 -0
- package/build-types/keyboard-shortcuts/index.d.ts.map +1 -0
- package/build-types/keyboard-shortcuts/stories/index.d.ts +12 -0
- package/build-types/keyboard-shortcuts/stories/index.d.ts.map +1 -0
- package/build-types/keyboard-shortcuts/test/index.d.ts +2 -0
- package/build-types/keyboard-shortcuts/test/index.d.ts.map +1 -0
- package/build-types/keyboard-shortcuts/types.d.ts +48 -0
- package/build-types/keyboard-shortcuts/types.d.ts.map +1 -0
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/component.d.ts +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +2 -2
- package/build-types/navigator/navigator-button/component.d.ts +1 -1
- package/build-types/navigator/navigator-button/hook.d.ts +2 -2
- package/build-types/notice/index.d.ts +16 -0
- package/build-types/notice/index.d.ts.map +1 -0
- package/build-types/notice/list.d.ts +32 -0
- package/build-types/notice/list.d.ts.map +1 -0
- package/build-types/notice/stories/index.d.ts +17 -0
- package/build-types/notice/stories/index.d.ts.map +1 -0
- package/build-types/notice/test/index.d.ts +2 -0
- package/build-types/notice/test/index.d.ts.map +1 -0
- package/build-types/notice/test/list.d.ts +2 -0
- package/build-types/notice/test/list.d.ts.map +1 -0
- package/build-types/notice/types.d.ts +128 -0
- package/build-types/notice/types.d.ts.map +1 -0
- package/build-types/number-control/styles/number-control-styles.d.ts +2 -2
- package/build-types/number-control/styles/number-control-styles.d.ts.map +1 -1
- package/build-types/placeholder/stories/index.d.ts.map +1 -1
- package/build-types/query-controls/author-select.d.ts +4 -0
- package/build-types/query-controls/author-select.d.ts.map +1 -0
- package/build-types/query-controls/category-select.d.ts +4 -0
- package/build-types/query-controls/category-select.d.ts.map +1 -0
- package/build-types/query-controls/index.d.ts +30 -0
- package/build-types/query-controls/index.d.ts.map +1 -0
- package/build-types/query-controls/stories/index.d.ts +13 -0
- package/build-types/query-controls/stories/index.d.ts.map +1 -0
- package/build-types/query-controls/terms.d.ts +13 -0
- package/build-types/query-controls/terms.d.ts.map +1 -0
- package/build-types/query-controls/test/terms.d.ts +2 -0
- package/build-types/query-controls/test/terms.d.ts.map +1 -0
- package/build-types/query-controls/types.d.ts +131 -0
- package/build-types/query-controls/types.d.ts.map +1 -0
- package/build-types/range-control/index.d.ts +1 -1
- package/build-types/resizable-box/index.d.ts +6 -7
- package/build-types/resizable-box/index.d.ts.map +1 -1
- package/build-types/resizable-box/stories/index.d.ts +61 -0
- package/build-types/resizable-box/stories/index.d.ts.map +1 -0
- package/build-types/responsive-wrapper/index.d.ts +24 -0
- package/build-types/responsive-wrapper/index.d.ts.map +1 -0
- package/build-types/responsive-wrapper/stories/index.d.ts +12 -0
- package/build-types/responsive-wrapper/stories/index.d.ts.map +1 -0
- package/build-types/responsive-wrapper/types.d.ts +22 -0
- package/build-types/responsive-wrapper/types.d.ts.map +1 -0
- package/build-types/sandbox/index.d.ts +19 -0
- package/build-types/sandbox/index.d.ts.map +1 -0
- package/build-types/sandbox/stories/index.d.ts +12 -0
- package/build-types/sandbox/stories/index.d.ts.map +1 -0
- package/build-types/sandbox/test/index.d.ts +2 -0
- package/build-types/sandbox/test/index.d.ts.map +1 -0
- package/build-types/sandbox/types.d.ts +36 -0
- package/build-types/sandbox/types.d.ts.map +1 -0
- package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
- package/build-types/slot-fill/use-slot.d.ts.map +1 -1
- package/build-types/snackbar/index.d.ts +9 -2
- package/build-types/snackbar/index.d.ts.map +1 -1
- package/build-types/snackbar/list.d.ts.map +1 -1
- package/build-types/snackbar/types.d.ts +15 -88
- package/build-types/snackbar/types.d.ts.map +1 -1
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/tab-panel/stories/index.d.ts +1 -0
- package/build-types/tab-panel/stories/index.d.ts.map +1 -1
- package/build-types/tab-panel/types.d.ts +11 -5
- package/build-types/tab-panel/types.d.ts.map +1 -1
- package/build-types/toggle-group-control/stories/index.d.ts.map +1 -1
- package/build-types/tree-select/index.d.ts.map +1 -1
- package/build-types/ui/form-group/form-group.d.ts +2 -2
- package/package.json +18 -17
- package/src/alignment-matrix-control/utils.tsx +2 -2
- package/src/autocomplete/autocompleter-ui.js +1 -2
- package/src/autocomplete/test/index.js +1 -5
- package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -1
- package/src/border-box-control/border-box-control-linked-button/hook.ts +1 -1
- package/src/border-control/border-control-dropdown/component.tsx +9 -8
- package/src/box-control/test/index.js +11 -35
- package/src/button/README.md +49 -55
- package/src/button/{deprecated.js → deprecated.tsx} +19 -4
- package/src/button/{index.js → index.tsx} +95 -34
- package/src/button/stories/index.tsx +106 -0
- package/src/button/style.scss +3 -2
- package/src/button/test/{index.js → index.tsx} +30 -7
- package/src/button/types.ts +138 -0
- package/src/checkbox-control/test/index.tsx +1 -5
- package/src/color-list-picker/{index.js → index.tsx} +3 -2
- package/src/color-list-picker/types.ts +46 -0
- package/src/color-palette/README.md +1 -1
- package/src/color-palette/index.native.js +11 -4
- package/src/color-palette/index.tsx +11 -67
- package/src/color-palette/test/index.tsx +4 -14
- package/src/color-palette/test/utils.ts +1 -1
- package/src/color-palette/types.ts +1 -1
- package/src/color-palette/utils.ts +98 -0
- package/src/color-picker/component.tsx +1 -0
- package/src/color-picker/stories/index.js +20 -60
- package/src/color-picker/styles.ts +0 -5
- package/src/color-picker/test/index.js +6 -15
- package/src/combobox-control/index.js +9 -1
- package/src/combobox-control/test/index.js +1 -6
- package/src/confirm-dialog/test/index.js +9 -29
- package/src/custom-gradient-picker/gradient-bar/utils.js +1 -1
- package/src/dashicon/types.ts +0 -6
- package/src/date-time/date/index.tsx +2 -1
- package/src/date-time/date/test/index.tsx +2 -8
- package/src/date-time/time/test/index.tsx +9 -29
- package/src/dimension-control/test/index.test.js +2 -8
- package/src/disabled/test/index.tsx +1 -5
- package/src/draggable/test/index.native.js +4 -4
- package/src/dropdown/README.md +1 -8
- package/src/dropdown/index.tsx +17 -6
- package/src/dropdown/stories/index.tsx +3 -3
- package/src/dropdown/test/index.tsx +2 -8
- package/src/dropdown/types.ts +9 -10
- package/src/dropdown-menu/README.md +1 -1
- package/src/dropdown-menu/stories/index.js +96 -27
- package/src/dropdown-menu/test/index.js +2 -8
- package/src/external-link/test/index.tsx +1 -6
- package/src/focal-point-picker/stories/index.tsx +1 -1
- package/src/focal-point-picker/test/index.js +3 -11
- package/src/focal-point-picker/utils.ts +4 -1
- package/src/font-size-picker/test/index.tsx +14 -44
- package/src/form-file-upload/test/index.tsx +2 -17
- package/src/form-toggle/test/index.tsx +1 -5
- package/src/form-token-field/test/index.tsx +80 -163
- package/src/form-token-field/token.tsx +1 -1
- package/src/gradient-picker/index.js +15 -4
- package/src/guide/stories/index.js +14 -41
- package/src/guide/test/index.js +5 -17
- package/src/h-stack/component.tsx +0 -1
- package/src/higher-order/with-filters/test/index.js +24 -24
- package/src/higher-order/with-focus-outside/test/index.js +11 -25
- package/src/higher-order/with-focus-return/test/index.js +1 -5
- package/src/index.js +8 -6
- package/src/index.native.js +8 -6
- package/src/input-control/input-field.tsx +3 -1
- package/src/input-control/test/index.js +1 -6
- package/src/isolated-event-container/test/index.js +2 -8
- package/src/item-group/item/component.tsx +26 -2
- package/src/item-group/item-group/component.tsx +25 -2
- package/src/item-group/stories/index.tsx +103 -0
- package/src/item-group/styles.ts +1 -0
- package/src/item-group/test/__snapshots__/index.js.snap +11 -10
- package/src/keyboard-shortcuts/README.md +1 -1
- package/src/keyboard-shortcuts/index.tsx +93 -0
- package/src/keyboard-shortcuts/stories/index.tsx +60 -0
- package/src/keyboard-shortcuts/test/{index.js → index.tsx} +16 -6
- package/src/keyboard-shortcuts/types.ts +51 -0
- package/src/modal/index.tsx +1 -2
- package/src/navigable-container/test/navigable-menu.js +5 -17
- package/src/navigable-container/test/tababble-container.js +3 -11
- package/src/navigation/test/index.js +3 -11
- package/src/navigator/test/index.tsx +6 -20
- package/src/notice/README.md +89 -42
- package/src/notice/{index.js → index.tsx} +28 -20
- package/src/notice/list.tsx +72 -0
- package/src/notice/stories/index.tsx +119 -0
- package/src/notice/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
- package/src/notice/test/{index.js → index.tsx} +7 -4
- package/src/notice/test/{list.js → list.tsx} +0 -0
- package/src/notice/types.ts +136 -0
- package/src/number-control/index.tsx +1 -1
- package/src/number-control/test/index.tsx +28 -86
- package/src/panel/row.js +3 -3
- package/src/panel/stories/index.js +62 -80
- package/src/panel/test/body.js +2 -8
- package/src/placeholder/stories/index.tsx +1 -0
- package/src/placeholder/style.scss +1 -1
- package/src/query-controls/README.md +56 -56
- package/src/query-controls/author-select.tsx +37 -0
- package/src/query-controls/category-select.tsx +46 -0
- package/src/query-controls/index.tsx +192 -0
- package/src/query-controls/stories/index.tsx +205 -0
- package/src/query-controls/terms.ts +57 -0
- package/src/query-controls/test/{terms.js → terms.ts} +36 -20
- package/src/query-controls/types.ts +150 -0
- package/src/resizable-box/README.md +2 -2
- package/src/resizable-box/index.tsx +7 -6
- package/src/resizable-box/stories/index.tsx +92 -0
- package/src/responsive-wrapper/README.md +29 -0
- package/src/responsive-wrapper/{index.js → index.tsx} +23 -2
- package/src/responsive-wrapper/stories/index.tsx +38 -0
- package/src/responsive-wrapper/types.ts +20 -0
- package/src/sandbox/README.md +45 -2
- package/src/sandbox/{index.js → index.tsx} +47 -24
- package/src/sandbox/stories/index.tsx +32 -0
- package/src/sandbox/test/{index.js → index.tsx} +9 -4
- package/src/sandbox/types.ts +34 -0
- package/src/select-control/test/select-control.tsx +1 -6
- package/src/slot-fill/bubbles-virtually/fill.js +1 -0
- package/src/slot-fill/slot.js +1 -1
- package/src/slot-fill/stories/index.js +12 -17
- package/src/slot-fill/use-slot.js +6 -16
- package/src/snackbar/index.tsx +6 -5
- package/src/snackbar/list.tsx +4 -2
- package/src/snackbar/types.ts +18 -92
- package/src/style.scss +3 -3
- package/src/tab-panel/README.md +1 -0
- package/src/tab-panel/index.tsx +42 -6
- package/src/tab-panel/stories/index.tsx +20 -0
- package/src/tab-panel/style.scss +8 -0
- package/src/tab-panel/test/index.tsx +124 -7
- package/src/tab-panel/types.ts +11 -5
- package/src/theme/test/index.tsx +4 -4
- package/src/toggle-group-control/stories/index.tsx +1 -0
- package/src/toggle-group-control/test/index.tsx +7 -23
- package/src/toolbar/index.js +6 -52
- package/src/toolbar/stories/index.js +71 -75
- package/src/toolbar/test/index.js +1 -2
- package/src/{toolbar-group/test/index.js → toolbar/test/toolbar-group.js} +1 -1
- package/src/toolbar/{README.md → toolbar/README.md} +0 -0
- package/src/toolbar/toolbar/index.js +52 -0
- package/src/toolbar/{style.native.scss → toolbar/style.native.scss} +0 -0
- package/src/toolbar/{style.scss → toolbar/style.scss} +0 -0
- package/src/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
- package/src/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
- package/src/{toolbar-button → toolbar/toolbar-button}/README.md +0 -0
- package/src/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
- package/src/{toolbar-button → toolbar/toolbar-button}/style.scss +0 -0
- package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
- package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
- package/src/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
- package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/README.md +0 -0
- package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
- package/src/{toolbar-group → toolbar/toolbar-group}/README.md +0 -0
- package/src/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
- package/src/{toolbar-group → toolbar/toolbar-group}/style.native.scss +0 -0
- package/src/{toolbar-group → toolbar/toolbar-group}/style.scss +0 -0
- package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
- package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
- package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
- package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
- package/src/{toolbar-item → toolbar/toolbar-item}/README.md +0 -0
- package/src/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
- package/src/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
- package/src/tools-panel/stories/index.js +3 -0
- package/src/tools-panel/test/index.js +1 -1
- package/src/tree-grid/index.js +3 -5
- package/src/tree-select/index.tsx +3 -6
- package/src/ui/context/test/context-connect.tsx +2 -0
- package/src/ui/context/test/wordpress-component.tsx +2 -0
- package/src/unit-control/test/index.tsx +21 -74
- package/src/utils/hooks/test/use-latest-ref.js +15 -18
- package/tsconfig.json +1 -11
- package/tsconfig.tsbuildinfo +1 -1
- package/build/toolbar/toolbar-container.native.js.map +0 -1
- package/build/toolbar-button/index.js.map +0 -1
- package/build/toolbar-button/toolbar-button-container.js.map +0 -1
- package/build/toolbar-button/toolbar-button-container.native.js.map +0 -1
- package/build/toolbar-context/index.js.map +0 -1
- package/build/toolbar-dropdown-menu/index.js.map +0 -1
- package/build/toolbar-group/index.js.map +0 -1
- package/build/toolbar-group/toolbar-group-collapsed.js.map +0 -1
- package/build/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
- package/build/toolbar-group/toolbar-group-container.js.map +0 -1
- package/build/toolbar-group/toolbar-group-container.native.js.map +0 -1
- package/build/toolbar-item/index.js.map +0 -1
- package/build/toolbar-item/index.native.js.map +0 -1
- package/build-module/toolbar/toolbar-container.js.map +0 -1
- package/build-module/toolbar/toolbar-container.native.js.map +0 -1
- package/build-module/toolbar-button/index.js.map +0 -1
- package/build-module/toolbar-button/toolbar-button-container.js.map +0 -1
- package/build-module/toolbar-button/toolbar-button-container.native.js.map +0 -1
- package/build-module/toolbar-context/index.js.map +0 -1
- package/build-module/toolbar-dropdown-menu/index.js.map +0 -1
- package/build-module/toolbar-group/index.js.map +0 -1
- package/build-module/toolbar-group/toolbar-group-collapsed.js.map +0 -1
- package/build-module/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
- package/build-module/toolbar-group/toolbar-group-container.js.map +0 -1
- package/build-module/toolbar-group/toolbar-group-container.native.js.map +0 -1
- package/build-module/toolbar-item/index.js.map +0 -1
- package/build-module/toolbar-item/index.native.js.map +0 -1
- package/src/button/stories/index.js +0 -179
- package/src/item-group/stories/index.js +0 -270
- package/src/keyboard-shortcuts/index.js +0 -56
- package/src/notice/list.js +0 -48
- package/src/notice/stories/index.js +0 -74
- package/src/query-controls/author-select.js +0 -23
- package/src/query-controls/category-select.js +0 -31
- package/src/query-controls/index.js +0 -121
- package/src/query-controls/terms.js +0 -40
- package/src/resizable-box/stories/index.js +0 -97
- package/src/toolbar-button/stories/index.js +0 -33
- package/src/toolbar-group/stories/index.js +0 -33
package/src/button/README.md
CHANGED
|
@@ -121,131 +121,125 @@ The presence of a `href` prop determines whether an `anchor` element is rendered
|
|
|
121
121
|
|
|
122
122
|
Props not included in this set will be applied to the `a` or `button` element.
|
|
123
123
|
|
|
124
|
-
####
|
|
124
|
+
#### `children`: `ReactNode`
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
The button's children.
|
|
127
127
|
|
|
128
|
-
- Type: `Boolean`
|
|
129
128
|
- Required: No
|
|
130
129
|
|
|
131
|
-
####
|
|
130
|
+
#### `className`: `string`
|
|
132
131
|
|
|
133
|
-
|
|
132
|
+
An optional additional class name to apply to the rendered button.
|
|
134
133
|
|
|
135
|
-
- Type: `String`
|
|
136
134
|
- Required: No
|
|
137
135
|
|
|
138
|
-
####
|
|
136
|
+
#### `describedBy`: `string`
|
|
139
137
|
|
|
140
|
-
|
|
138
|
+
An accessible description for the button.
|
|
141
139
|
|
|
142
|
-
- Type: `String`
|
|
143
140
|
- Required: No
|
|
144
141
|
|
|
145
|
-
####
|
|
142
|
+
#### `disabled`: `boolean`
|
|
146
143
|
|
|
147
|
-
|
|
144
|
+
Whether the button is disabled. If `true`, this will force a `button` element to be rendered.
|
|
148
145
|
|
|
149
|
-
- Type: `Boolean`
|
|
150
146
|
- Required: No
|
|
151
147
|
|
|
152
|
-
####
|
|
148
|
+
#### `focus`: `boolean`
|
|
153
149
|
|
|
154
|
-
|
|
150
|
+
Whether the button is focused.
|
|
155
151
|
|
|
156
|
-
- Type: `Boolean`
|
|
157
152
|
- Required: No
|
|
158
153
|
|
|
159
|
-
####
|
|
154
|
+
#### `href`: `string`
|
|
160
155
|
|
|
161
|
-
|
|
156
|
+
If provided, renders `a` instead of `button`.
|
|
162
157
|
|
|
163
|
-
- Type: `Boolean`
|
|
164
158
|
- Required: No
|
|
165
159
|
|
|
166
|
-
####
|
|
160
|
+
#### `icon`: `IconProps< unknown >[ 'icon' ]`
|
|
167
161
|
|
|
168
|
-
|
|
162
|
+
If provided, renders an [Icon](/packages/components/src/icon/README.md) component inside the button.
|
|
169
163
|
|
|
170
|
-
- Type: `Boolean`
|
|
171
164
|
- Required: No
|
|
172
165
|
|
|
173
|
-
####
|
|
166
|
+
#### `iconPosition`: `'left' | 'right'`
|
|
174
167
|
|
|
175
|
-
|
|
168
|
+
If provided with `icon`, sets the position of icon relative to the `text`. Available options are `left|right`.
|
|
176
169
|
|
|
177
|
-
- Type: `Boolean`
|
|
178
170
|
- Required: No
|
|
171
|
+
- Default: `left`
|
|
179
172
|
|
|
180
|
-
####
|
|
173
|
+
#### `iconSize`: `IconProps< unknown >[ 'size' ]`
|
|
181
174
|
|
|
182
|
-
If provided with `
|
|
175
|
+
If provided with `icon`, sets the icon size. Please refer to the [Icon](/packages/components/src/icon/README.md) component for more details regarding the default value of its `size` prop.
|
|
183
176
|
|
|
184
|
-
- Type: `String`
|
|
185
177
|
- Required: No
|
|
186
178
|
|
|
187
|
-
####
|
|
179
|
+
#### `isBusy`: `boolean`
|
|
188
180
|
|
|
189
|
-
|
|
181
|
+
Indicates activity while a action is being performed.
|
|
190
182
|
|
|
191
|
-
- Type: `String`
|
|
192
183
|
- Required: No
|
|
193
184
|
|
|
194
|
-
####
|
|
185
|
+
#### `isDestructive`: `boolean`
|
|
195
186
|
|
|
196
|
-
|
|
187
|
+
Renders a red text-based button style to indicate destructive behavior.
|
|
197
188
|
|
|
198
|
-
- Type: `String|Function|WPComponent|null`
|
|
199
189
|
- Required: No
|
|
200
190
|
|
|
201
|
-
####
|
|
191
|
+
#### `isPressed`: `boolean`
|
|
202
192
|
|
|
203
|
-
|
|
193
|
+
Renders a pressed button style.
|
|
204
194
|
|
|
205
|
-
- Type: `Number`
|
|
206
195
|
- Required: No
|
|
207
196
|
|
|
208
|
-
####
|
|
197
|
+
#### `isSmall`: `boolean`
|
|
209
198
|
|
|
210
|
-
|
|
199
|
+
Decreases the size of the button.
|
|
211
200
|
|
|
212
|
-
- Type: `string`
|
|
213
201
|
- Required: No
|
|
214
|
-
- Default: `left`
|
|
215
202
|
|
|
216
|
-
####
|
|
203
|
+
#### `label`: `string`
|
|
217
204
|
|
|
218
|
-
|
|
205
|
+
Sets the `aria-label` of the component, if none is provided. Sets the Tooltip content if `showTooltip` is provided.
|
|
219
206
|
|
|
220
|
-
- Type: `String`
|
|
221
207
|
- Required: No
|
|
222
208
|
|
|
223
|
-
####
|
|
209
|
+
#### `shortcut`: `string | { display: string; ariaLabel: string; }`
|
|
210
|
+
|
|
211
|
+
If provided with `showTooltip`, appends the Shortcut label to the tooltip content. If an object is provided, it should contain `display` and `ariaLabel` keys.
|
|
212
|
+
|
|
213
|
+
- Required: No
|
|
214
|
+
|
|
215
|
+
#### `showTooltip`: `boolean`
|
|
224
216
|
|
|
225
217
|
If provided, renders a [Tooltip](/packages/components/src/tooltip/README.md) component for the button.
|
|
226
218
|
|
|
227
|
-
- Type: `Boolean`
|
|
228
219
|
- Required: No
|
|
229
220
|
|
|
230
|
-
####
|
|
221
|
+
#### `target`: `string`
|
|
231
222
|
|
|
232
|
-
If provided with`
|
|
223
|
+
If provided with `href`, sets the `target` attribute to the `a`.
|
|
233
224
|
|
|
234
|
-
-
|
|
235
|
-
- Require: No
|
|
225
|
+
- Required: No
|
|
236
226
|
|
|
237
|
-
####
|
|
227
|
+
#### `text`: `string`
|
|
238
228
|
|
|
239
|
-
If provided
|
|
229
|
+
If provided, displays the given text inside the button. If the button contains children elements, the text is displayed before them.
|
|
240
230
|
|
|
241
|
-
- Type: `String|Object`
|
|
242
231
|
- Required: No
|
|
243
232
|
|
|
244
|
-
####
|
|
233
|
+
#### `tooltipPosition`: `PopoverProps[ 'position' ]`
|
|
245
234
|
|
|
246
|
-
|
|
235
|
+
If provided with`showTooltip`, sets the position of the tooltip. Please refer to the [Tooltip](/packages/components/src/tooltip/README.md) component for more details regarding the defaults.
|
|
236
|
+
|
|
237
|
+
- Required: No
|
|
238
|
+
|
|
239
|
+
#### `variant`: `'primary' | 'secondary' | 'tertiary' | 'link'`
|
|
240
|
+
|
|
241
|
+
Specifies the button's style. The accepted values are `'primary'` (the primary button styles), `'secondary'` (the default button styles), `'tertiary'` (the text-based button styles), and `'link'` (the link button styles).
|
|
247
242
|
|
|
248
|
-
- Type: `String`
|
|
249
243
|
- Required: No
|
|
250
244
|
|
|
251
245
|
## Related components
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ForwardedRef } from 'react';
|
|
5
|
+
|
|
2
6
|
/**
|
|
3
7
|
* WordPress dependencies
|
|
4
8
|
*/
|
|
@@ -8,9 +12,20 @@ import { forwardRef } from '@wordpress/element';
|
|
|
8
12
|
/**
|
|
9
13
|
* Internal dependencies
|
|
10
14
|
*/
|
|
11
|
-
import Button from '
|
|
15
|
+
import Button from '.';
|
|
16
|
+
import type { DeprecatedIconButtonProps } from './types';
|
|
12
17
|
|
|
13
|
-
function
|
|
18
|
+
function UnforwardedIconButton(
|
|
19
|
+
{
|
|
20
|
+
label,
|
|
21
|
+
labelPosition,
|
|
22
|
+
size,
|
|
23
|
+
tooltip,
|
|
24
|
+
...props
|
|
25
|
+
}: React.ComponentPropsWithoutRef< typeof Button > &
|
|
26
|
+
DeprecatedIconButtonProps,
|
|
27
|
+
ref: ForwardedRef< any >
|
|
28
|
+
) {
|
|
14
29
|
deprecated( 'wp.components.IconButton', {
|
|
15
30
|
since: '5.4',
|
|
16
31
|
alternative: 'wp.components.Button',
|
|
@@ -29,4 +44,4 @@ function IconButton( { labelPosition, size, tooltip, label, ...props }, ref ) {
|
|
|
29
44
|
);
|
|
30
45
|
}
|
|
31
46
|
|
|
32
|
-
export default forwardRef(
|
|
47
|
+
export default forwardRef( UnforwardedIconButton );
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* External dependencies
|
|
4
3
|
*/
|
|
5
4
|
import classnames from 'classnames';
|
|
5
|
+
import type {
|
|
6
|
+
ComponentPropsWithoutRef,
|
|
7
|
+
ForwardedRef,
|
|
8
|
+
HTMLAttributes,
|
|
9
|
+
MouseEvent,
|
|
10
|
+
ReactElement,
|
|
11
|
+
} from 'react';
|
|
6
12
|
|
|
7
13
|
/**
|
|
8
14
|
* WordPress dependencies
|
|
@@ -17,8 +23,9 @@ import { useInstanceId } from '@wordpress/compose';
|
|
|
17
23
|
import Tooltip from '../tooltip';
|
|
18
24
|
import Icon from '../icon';
|
|
19
25
|
import { VisuallyHidden } from '../visually-hidden';
|
|
26
|
+
import type { ButtonProps, DeprecatedButtonProps } from './types';
|
|
20
27
|
|
|
21
|
-
const disabledEventsOnDisabledButton = [ 'onMouseDown', 'onClick' ];
|
|
28
|
+
const disabledEventsOnDisabledButton = [ 'onMouseDown', 'onClick' ] as const;
|
|
22
29
|
|
|
23
30
|
function useDeprecatedProps( {
|
|
24
31
|
isDefault,
|
|
@@ -28,7 +35,7 @@ function useDeprecatedProps( {
|
|
|
28
35
|
isLink,
|
|
29
36
|
variant,
|
|
30
37
|
...otherProps
|
|
31
|
-
} ) {
|
|
38
|
+
}: ButtonProps & DeprecatedButtonProps ): ButtonProps {
|
|
32
39
|
let computedVariant = variant;
|
|
33
40
|
|
|
34
41
|
if ( isPrimary ) {
|
|
@@ -63,10 +70,11 @@ function useDeprecatedProps( {
|
|
|
63
70
|
};
|
|
64
71
|
}
|
|
65
72
|
|
|
66
|
-
export function
|
|
73
|
+
export function UnforwardedButton(
|
|
74
|
+
props: ButtonProps,
|
|
75
|
+
ref: ForwardedRef< any >
|
|
76
|
+
) {
|
|
67
77
|
const {
|
|
68
|
-
href,
|
|
69
|
-
target,
|
|
70
78
|
isSmall,
|
|
71
79
|
isPressed,
|
|
72
80
|
isBusy,
|
|
@@ -85,18 +93,26 @@ export function Button( props, ref ) {
|
|
|
85
93
|
variant,
|
|
86
94
|
__experimentalIsFocusable: isFocusable,
|
|
87
95
|
describedBy,
|
|
88
|
-
...
|
|
96
|
+
...buttonOrAnchorProps
|
|
89
97
|
} = useDeprecatedProps( props );
|
|
98
|
+
|
|
99
|
+
const { href, target, ...additionalProps } =
|
|
100
|
+
'href' in buttonOrAnchorProps
|
|
101
|
+
? buttonOrAnchorProps
|
|
102
|
+
: { href: undefined, target: undefined, ...buttonOrAnchorProps };
|
|
103
|
+
|
|
90
104
|
const instanceId = useInstanceId(
|
|
91
105
|
Button,
|
|
92
106
|
'components-button__description'
|
|
93
107
|
);
|
|
94
108
|
|
|
95
109
|
const hasChildren =
|
|
96
|
-
children
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
110
|
+
( 'string' === typeof children && !! children ) ||
|
|
111
|
+
( Array.isArray( children ) &&
|
|
112
|
+
children?.[ 0 ] &&
|
|
113
|
+
children[ 0 ] !== null &&
|
|
114
|
+
// Tooltip should not considered as a child
|
|
115
|
+
children?.[ 0 ]?.props?.className !== 'components-tooltip' );
|
|
100
116
|
|
|
101
117
|
const classes = classnames( 'components-button', className, {
|
|
102
118
|
'is-secondary': variant === 'secondary',
|
|
@@ -113,24 +129,29 @@ export function Button( props, ref ) {
|
|
|
113
129
|
|
|
114
130
|
const trulyDisabled = disabled && ! isFocusable;
|
|
115
131
|
const Tag = href !== undefined && ! trulyDisabled ? 'a' : 'button';
|
|
116
|
-
const
|
|
117
|
-
Tag === '
|
|
118
|
-
? {
|
|
119
|
-
: {
|
|
132
|
+
const buttonProps: ComponentPropsWithoutRef< 'button' > =
|
|
133
|
+
Tag === 'button'
|
|
134
|
+
? {
|
|
120
135
|
type: 'button',
|
|
121
136
|
disabled: trulyDisabled,
|
|
122
137
|
'aria-pressed': isPressed,
|
|
123
|
-
}
|
|
138
|
+
}
|
|
139
|
+
: {};
|
|
140
|
+
const anchorProps: ComponentPropsWithoutRef< 'a' > =
|
|
141
|
+
Tag === 'a' ? { href, target } : {};
|
|
124
142
|
|
|
125
143
|
if ( disabled && isFocusable ) {
|
|
126
144
|
// In this case, the button will be disabled, but still focusable and
|
|
127
145
|
// perceivable by screen reader users.
|
|
128
|
-
|
|
146
|
+
buttonProps[ 'aria-disabled' ] = true;
|
|
147
|
+
anchorProps[ 'aria-disabled' ] = true;
|
|
129
148
|
|
|
130
149
|
for ( const disabledEvent of disabledEventsOnDisabledButton ) {
|
|
131
|
-
additionalProps[ disabledEvent ] = ( event ) => {
|
|
132
|
-
event
|
|
133
|
-
|
|
150
|
+
additionalProps[ disabledEvent ] = ( event: MouseEvent ) => {
|
|
151
|
+
if ( event ) {
|
|
152
|
+
event.stopPropagation();
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
}
|
|
134
155
|
};
|
|
135
156
|
}
|
|
136
157
|
}
|
|
@@ -145,24 +166,24 @@ export function Button( props, ref ) {
|
|
|
145
166
|
// There's a label and...
|
|
146
167
|
( !! label &&
|
|
147
168
|
// The children are empty and...
|
|
148
|
-
! children?.length &&
|
|
169
|
+
! ( children as string | ReactElement[] )?.length &&
|
|
149
170
|
// The tooltip is not explicitly disabled.
|
|
150
171
|
false !== showTooltip ) );
|
|
151
172
|
|
|
152
|
-
const descriptionId = describedBy ? instanceId :
|
|
173
|
+
const descriptionId = describedBy ? instanceId : undefined;
|
|
153
174
|
|
|
154
175
|
const describedById =
|
|
155
176
|
additionalProps[ 'aria-describedby' ] || descriptionId;
|
|
156
177
|
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
178
|
+
const commonProps = {
|
|
179
|
+
className: classes,
|
|
180
|
+
'aria-label': additionalProps[ 'aria-label' ] || label,
|
|
181
|
+
'aria-describedby': describedById,
|
|
182
|
+
ref,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const elementChildren = (
|
|
186
|
+
<>
|
|
166
187
|
{ icon && iconPosition === 'left' && (
|
|
167
188
|
<Icon icon={ icon } size={ iconSize } />
|
|
168
189
|
) }
|
|
@@ -171,9 +192,28 @@ export function Button( props, ref ) {
|
|
|
171
192
|
<Icon icon={ icon } size={ iconSize } />
|
|
172
193
|
) }
|
|
173
194
|
{ children }
|
|
174
|
-
|
|
195
|
+
</>
|
|
175
196
|
);
|
|
176
197
|
|
|
198
|
+
const element =
|
|
199
|
+
Tag === 'a' ? (
|
|
200
|
+
<a
|
|
201
|
+
{ ...anchorProps }
|
|
202
|
+
{ ...( additionalProps as HTMLAttributes< HTMLAnchorElement > ) }
|
|
203
|
+
{ ...commonProps }
|
|
204
|
+
>
|
|
205
|
+
{ elementChildren }
|
|
206
|
+
</a>
|
|
207
|
+
) : (
|
|
208
|
+
<button
|
|
209
|
+
{ ...buttonProps }
|
|
210
|
+
{ ...( additionalProps as HTMLAttributes< HTMLButtonElement > ) }
|
|
211
|
+
{ ...commonProps }
|
|
212
|
+
>
|
|
213
|
+
{ elementChildren }
|
|
214
|
+
</button>
|
|
215
|
+
);
|
|
216
|
+
|
|
177
217
|
if ( ! shouldShowTooltip ) {
|
|
178
218
|
return (
|
|
179
219
|
<>
|
|
@@ -190,7 +230,12 @@ export function Button( props, ref ) {
|
|
|
190
230
|
return (
|
|
191
231
|
<>
|
|
192
232
|
<Tooltip
|
|
193
|
-
text={
|
|
233
|
+
text={
|
|
234
|
+
( children as string | ReactElement[] )?.length &&
|
|
235
|
+
describedBy
|
|
236
|
+
? describedBy
|
|
237
|
+
: label
|
|
238
|
+
}
|
|
194
239
|
shortcut={ shortcut }
|
|
195
240
|
position={ tooltipPosition }
|
|
196
241
|
>
|
|
@@ -205,4 +250,20 @@ export function Button( props, ref ) {
|
|
|
205
250
|
);
|
|
206
251
|
}
|
|
207
252
|
|
|
208
|
-
|
|
253
|
+
/**
|
|
254
|
+
* Lets users take actions and make choices with a single click or tap.
|
|
255
|
+
*
|
|
256
|
+
* ```jsx
|
|
257
|
+
* import { Button } from '@wordpress/components';
|
|
258
|
+
* const Mybutton = () => (
|
|
259
|
+
* <Button
|
|
260
|
+
* variant="primary"
|
|
261
|
+
* onClick={ handleClick }
|
|
262
|
+
* >
|
|
263
|
+
* Click here
|
|
264
|
+
* </Button>
|
|
265
|
+
* );
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
export const Button = forwardRef( UnforwardedButton );
|
|
269
|
+
export default Button;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
import type { ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import {
|
|
11
|
+
formatBold,
|
|
12
|
+
formatItalic,
|
|
13
|
+
link,
|
|
14
|
+
more,
|
|
15
|
+
wordpress,
|
|
16
|
+
} from '@wordpress/icons';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
import './style.css';
|
|
22
|
+
import Button from '..';
|
|
23
|
+
|
|
24
|
+
const meta: ComponentMeta< typeof Button > = {
|
|
25
|
+
title: 'Components/Button',
|
|
26
|
+
component: Button,
|
|
27
|
+
argTypes: {
|
|
28
|
+
// Overrides a limitation of the docgen interpreting our TS types for this as required.
|
|
29
|
+
href: { type: { name: 'string', required: false } },
|
|
30
|
+
icon: {
|
|
31
|
+
control: { type: 'select' },
|
|
32
|
+
options: [ 'wordpress', 'link', 'more' ],
|
|
33
|
+
mapping: {
|
|
34
|
+
wordpress,
|
|
35
|
+
link,
|
|
36
|
+
more,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
parameters: {
|
|
41
|
+
controls: { expanded: true },
|
|
42
|
+
docs: { source: { state: 'open' } },
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
export default meta;
|
|
46
|
+
|
|
47
|
+
const Template: ComponentStory< typeof Button > = ( props ) => {
|
|
48
|
+
return <Button { ...props }></Button>;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const Default: ComponentStory< typeof Button > = Template.bind( {} );
|
|
52
|
+
Default.args = {
|
|
53
|
+
children: 'Code is poetry',
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const Primary: ComponentStory< typeof Button > = Template.bind( {} );
|
|
57
|
+
Primary.args = {
|
|
58
|
+
...Default.args,
|
|
59
|
+
variant: 'primary',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const Secondary: ComponentStory< typeof Button > = Template.bind( {} );
|
|
63
|
+
Secondary.args = {
|
|
64
|
+
...Default.args,
|
|
65
|
+
variant: 'secondary',
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const Tertiary: ComponentStory< typeof Button > = Template.bind( {} );
|
|
69
|
+
Tertiary.args = {
|
|
70
|
+
...Default.args,
|
|
71
|
+
variant: 'tertiary',
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const Link: ComponentStory< typeof Button > = Template.bind( {} );
|
|
75
|
+
Link.args = {
|
|
76
|
+
...Default.args,
|
|
77
|
+
variant: 'link',
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const IsDestructive: ComponentStory< typeof Button > = Template.bind(
|
|
81
|
+
{}
|
|
82
|
+
);
|
|
83
|
+
IsDestructive.args = {
|
|
84
|
+
...Default.args,
|
|
85
|
+
isDestructive: true,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const Icon: ComponentStory< typeof Button > = Template.bind( {} );
|
|
89
|
+
Icon.args = {
|
|
90
|
+
label: 'Code is poetry',
|
|
91
|
+
icon: 'wordpress',
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const GroupedIcons: ComponentStory< typeof Button > = () => {
|
|
95
|
+
const GroupContainer = ( { children }: { children: ReactNode } ) => (
|
|
96
|
+
<div style={ { display: 'inline-flex' } }>{ children }</div>
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<GroupContainer>
|
|
101
|
+
<Button icon={ formatBold } label="Bold" />
|
|
102
|
+
<Button icon={ formatItalic } label="Italic" />
|
|
103
|
+
<Button icon={ link } label="Link" />
|
|
104
|
+
</GroupContainer>
|
|
105
|
+
);
|
|
106
|
+
};
|
package/src/button/style.scss
CHANGED
|
@@ -282,14 +282,15 @@
|
|
|
282
282
|
|
|
283
283
|
&.has-text {
|
|
284
284
|
justify-content: start;
|
|
285
|
+
padding-right: 12px;
|
|
285
286
|
}
|
|
286
287
|
|
|
287
288
|
&.has-text svg {
|
|
288
|
-
margin-right:
|
|
289
|
+
margin-right: $grid-unit-10;
|
|
289
290
|
}
|
|
290
291
|
|
|
291
292
|
&.has-text .dashicon {
|
|
292
|
-
margin-right:
|
|
293
|
+
margin-right: $grid-unit-10 + 2px;
|
|
293
294
|
}
|
|
294
295
|
}
|
|
295
296
|
|
|
@@ -12,8 +12,8 @@ import { plusCircle } from '@wordpress/icons';
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
|
-
import Button from '
|
|
16
|
-
import
|
|
15
|
+
import Button from '..';
|
|
16
|
+
import Tooltip from '../../tooltip';
|
|
17
17
|
|
|
18
18
|
jest.mock( '../../icon', () => () => <div data-testid="test-icon" /> );
|
|
19
19
|
|
|
@@ -126,6 +126,7 @@ describe( 'Button', () => {
|
|
|
126
126
|
} );
|
|
127
127
|
|
|
128
128
|
it( 'should not pass the prop target into the element', () => {
|
|
129
|
+
// @ts-expect-error - `target` requires `href`
|
|
129
130
|
render( <Button target="_blank" /> );
|
|
130
131
|
|
|
131
132
|
expect( screen.getByRole( 'button' ) ).not.toHaveAttribute(
|
|
@@ -139,13 +140,12 @@ describe( 'Button', () => {
|
|
|
139
140
|
expect( screen.getByRole( 'button' ) ).toHaveClass( 'gutenberg' );
|
|
140
141
|
} );
|
|
141
142
|
|
|
142
|
-
it( 'should
|
|
143
|
-
render( <Button
|
|
143
|
+
it( 'should pass additional props to the element', () => {
|
|
144
|
+
render( <Button type="submit" /> );
|
|
144
145
|
|
|
145
|
-
expect( console ).toHaveErrored();
|
|
146
146
|
expect( screen.getByRole( 'button' ) ).toHaveAttribute(
|
|
147
|
-
'
|
|
148
|
-
'
|
|
147
|
+
'type',
|
|
148
|
+
'submit'
|
|
149
149
|
);
|
|
150
150
|
} );
|
|
151
151
|
|
|
@@ -342,6 +342,7 @@ describe( 'Button', () => {
|
|
|
342
342
|
} );
|
|
343
343
|
|
|
344
344
|
it( 'should become a button again when disabled is supplied', () => {
|
|
345
|
+
// @ts-expect-error - a button should not have `href`
|
|
345
346
|
render( <Button href="https://wordpress.org/" disabled /> );
|
|
346
347
|
|
|
347
348
|
expect( screen.getByRole( 'button' ) ).toBeVisible();
|
|
@@ -360,11 +361,13 @@ describe( 'Button', () => {
|
|
|
360
361
|
|
|
361
362
|
describe( 'deprecated props', () => {
|
|
362
363
|
it( 'should not break when the legacy isPrimary prop is passed', () => {
|
|
364
|
+
// @ts-expect-error
|
|
363
365
|
render( <Button isPrimary /> );
|
|
364
366
|
expect( screen.getByRole( 'button' ) ).toHaveClass( 'is-primary' );
|
|
365
367
|
} );
|
|
366
368
|
|
|
367
369
|
it( 'should not break when the legacy isSecondary prop is passed', () => {
|
|
370
|
+
// @ts-expect-error
|
|
368
371
|
render( <Button isSecondary /> );
|
|
369
372
|
expect( screen.getByRole( 'button' ) ).toHaveClass(
|
|
370
373
|
'is-secondary'
|
|
@@ -372,16 +375,19 @@ describe( 'Button', () => {
|
|
|
372
375
|
} );
|
|
373
376
|
|
|
374
377
|
it( 'should not break when the legacy isTertiary prop is passed', () => {
|
|
378
|
+
// @ts-expect-error
|
|
375
379
|
render( <Button isTertiary /> );
|
|
376
380
|
expect( screen.getByRole( 'button' ) ).toHaveClass( 'is-tertiary' );
|
|
377
381
|
} );
|
|
378
382
|
|
|
379
383
|
it( 'should not break when the legacy isLink prop is passed', () => {
|
|
384
|
+
// @ts-expect-error
|
|
380
385
|
render( <Button isLink /> );
|
|
381
386
|
expect( screen.getByRole( 'button' ) ).toHaveClass( 'is-link' );
|
|
382
387
|
} );
|
|
383
388
|
|
|
384
389
|
it( 'should warn when the isDefault prop is passed', () => {
|
|
390
|
+
// @ts-expect-error
|
|
385
391
|
render( <Button isDefault /> );
|
|
386
392
|
expect( screen.getByRole( 'button' ) ).toHaveClass(
|
|
387
393
|
'is-secondary'
|
|
@@ -389,4 +395,21 @@ describe( 'Button', () => {
|
|
|
389
395
|
expect( console ).toHaveWarned();
|
|
390
396
|
} );
|
|
391
397
|
} );
|
|
398
|
+
|
|
399
|
+
describe( 'static typing', () => {
|
|
400
|
+
<>
|
|
401
|
+
<Button href="foo" />
|
|
402
|
+
{ /* @ts-expect-error - `target` requires `href` */ }
|
|
403
|
+
<Button target="foo" />
|
|
404
|
+
{ /* @ts-expect-error - `disabled` is only for buttons */ }
|
|
405
|
+
<Button href="foo" disabled />
|
|
406
|
+
<Button href="foo" type="image/png" />
|
|
407
|
+
{ /* @ts-expect-error - if button, type must be submit/reset/button */ }
|
|
408
|
+
<Button type="image/png" />
|
|
409
|
+
{ /* @ts-expect-error */ }
|
|
410
|
+
<Button type="invalidtype" />
|
|
411
|
+
{ /* @ts-expect-error - although the runtime behavior will allow this to be an anchor, this is probably a mistake. */ }
|
|
412
|
+
<Button disabled __experimentalIsFocusable href="foo" />
|
|
413
|
+
</>;
|
|
414
|
+
} );
|
|
392
415
|
} );
|