@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
|
@@ -11,8 +11,8 @@ Snapshot Diff:
|
|
|
11
11
|
role="listitem"
|
|
12
12
|
>
|
|
13
13
|
<div
|
|
14
|
-
- class="components-item css-
|
|
15
|
-
+ class="components-item css-
|
|
14
|
+
- class="components-item css-ufjlmj-View-medium-item-spacedAround e19lxcc00"
|
|
15
|
+
+ class="components-item css-17haj95-View-large-item-spacedAround e19lxcc00"
|
|
16
16
|
data-wp-c16t="true"
|
|
17
17
|
data-wp-component="Item"
|
|
18
18
|
>
|
|
@@ -24,8 +24,8 @@ Snapshot Diff:
|
|
|
24
24
|
role="listitem"
|
|
25
25
|
>
|
|
26
26
|
<div
|
|
27
|
-
- class="components-item css-
|
|
28
|
-
+ class="components-item css-
|
|
27
|
+
- class="components-item css-ufjlmj-View-medium-item-spacedAround e19lxcc00"
|
|
28
|
+
+ class="components-item css-17haj95-View-large-item-spacedAround e19lxcc00"
|
|
29
29
|
data-wp-c16t="true"
|
|
30
30
|
data-wp-component="Item"
|
|
31
31
|
>
|
|
@@ -44,8 +44,8 @@ Snapshot Diff:
|
|
|
44
44
|
role="listitem"
|
|
45
45
|
>
|
|
46
46
|
<div
|
|
47
|
-
- class="components-item css-
|
|
48
|
-
+ class="components-item css-
|
|
47
|
+
- class="components-item css-cl593w-View-medium-item e19lxcc00"
|
|
48
|
+
+ class="components-item css-1yvqxd-View-large-item e19lxcc00"
|
|
49
49
|
data-wp-c16t="true"
|
|
50
50
|
data-wp-component="Item"
|
|
51
51
|
>
|
|
@@ -75,6 +75,7 @@ exports[`ItemGroup ItemGroup component should render correctly 1`] = `
|
|
|
75
75
|
|
|
76
76
|
.emotion-3 {
|
|
77
77
|
padding: calc((36px - calc(13px * 1.2) - 2px) / 2) 12px;
|
|
78
|
+
box-sizing: border-box;
|
|
78
79
|
width: 100%;
|
|
79
80
|
display: block;
|
|
80
81
|
margin: 0;
|
|
@@ -124,8 +125,8 @@ Snapshot Diff:
|
|
|
124
125
|
role="listitem"
|
|
125
126
|
>
|
|
126
127
|
<div
|
|
127
|
-
- class="components-item css-
|
|
128
|
-
+ class="components-item css-
|
|
128
|
+
- class="components-item css-ufjlmj-View-medium-item-spacedAround e19lxcc00"
|
|
129
|
+
+ class="components-item css-cl593w-View-medium-item e19lxcc00"
|
|
129
130
|
data-wp-c16t="true"
|
|
130
131
|
data-wp-component="Item"
|
|
131
132
|
>
|
|
@@ -152,8 +153,8 @@ Snapshot Diff:
|
|
|
152
153
|
role="listitem"
|
|
153
154
|
>
|
|
154
155
|
<div
|
|
155
|
-
- class="components-item css-
|
|
156
|
-
+ class="components-item css-
|
|
156
|
+
- class="components-item css-ufjlmj-View-medium-item-spacedAround e19lxcc00"
|
|
157
|
+
+ class="components-item css-cl593w-View-medium-item e19lxcc00"
|
|
157
158
|
data-wp-c16t="true"
|
|
158
159
|
data-wp-component="Item"
|
|
159
160
|
>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRef, Children } from '@wordpress/element';
|
|
5
|
+
import { useKeyboardShortcut } from '@wordpress/compose';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import type { KeyboardShortcutProps, KeyboardShortcutsProps } from './types';
|
|
11
|
+
|
|
12
|
+
function KeyboardShortcut( {
|
|
13
|
+
target,
|
|
14
|
+
callback,
|
|
15
|
+
shortcut,
|
|
16
|
+
bindGlobal,
|
|
17
|
+
eventName,
|
|
18
|
+
}: KeyboardShortcutProps ) {
|
|
19
|
+
useKeyboardShortcut( shortcut, callback, {
|
|
20
|
+
bindGlobal,
|
|
21
|
+
target,
|
|
22
|
+
eventName,
|
|
23
|
+
} );
|
|
24
|
+
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* `KeyboardShortcuts` is a component which handles keyboard sequences during the lifetime of the rendering element.
|
|
30
|
+
*
|
|
31
|
+
* When passed children, it will capture key events which occur on or within the children. If no children are passed, events are captured on the document.
|
|
32
|
+
*
|
|
33
|
+
* It uses the [Mousetrap](https://craig.is/killing/mice) library to implement keyboard sequence bindings.
|
|
34
|
+
*
|
|
35
|
+
* ```jsx
|
|
36
|
+
* import { KeyboardShortcuts } from '@wordpress/components';
|
|
37
|
+
* import { useState } from '@wordpress/element';
|
|
38
|
+
*
|
|
39
|
+
* const MyKeyboardShortcuts = () => {
|
|
40
|
+
* const [ isAllSelected, setIsAllSelected ] = useState( false );
|
|
41
|
+
* const selectAll = () => {
|
|
42
|
+
* setIsAllSelected( true );
|
|
43
|
+
* };
|
|
44
|
+
*
|
|
45
|
+
* return (
|
|
46
|
+
* <div>
|
|
47
|
+
* <KeyboardShortcuts
|
|
48
|
+
* shortcuts={ {
|
|
49
|
+
* 'mod+a': selectAll,
|
|
50
|
+
* } }
|
|
51
|
+
* />
|
|
52
|
+
* [cmd/ctrl + A] Combination pressed? { isAllSelected ? 'Yes' : 'No' }
|
|
53
|
+
* </div>
|
|
54
|
+
* );
|
|
55
|
+
* };
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
function KeyboardShortcuts( {
|
|
59
|
+
children,
|
|
60
|
+
shortcuts,
|
|
61
|
+
bindGlobal,
|
|
62
|
+
eventName,
|
|
63
|
+
}: KeyboardShortcutsProps ) {
|
|
64
|
+
const target = useRef( null );
|
|
65
|
+
|
|
66
|
+
const element = Object.entries( shortcuts ?? {} ).map(
|
|
67
|
+
( [ shortcut, callback ] ) => (
|
|
68
|
+
<KeyboardShortcut
|
|
69
|
+
key={ shortcut }
|
|
70
|
+
shortcut={ shortcut }
|
|
71
|
+
callback={ callback }
|
|
72
|
+
bindGlobal={ bindGlobal }
|
|
73
|
+
eventName={ eventName }
|
|
74
|
+
target={ target }
|
|
75
|
+
/>
|
|
76
|
+
)
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// Render as non-visual if there are no children pressed. Keyboard
|
|
80
|
+
// events will be bound to the document instead.
|
|
81
|
+
if ( ! Children.count( children ) ) {
|
|
82
|
+
return <>{ element }</>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div ref={ target }>
|
|
87
|
+
{ element }
|
|
88
|
+
{ children }
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export default KeyboardShortcuts;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import KeyboardShortcuts from '..';
|
|
10
|
+
|
|
11
|
+
const meta: ComponentMeta< typeof KeyboardShortcuts > = {
|
|
12
|
+
component: KeyboardShortcuts,
|
|
13
|
+
title: 'Components/KeyboardShortcuts',
|
|
14
|
+
parameters: {
|
|
15
|
+
controls: { expanded: true },
|
|
16
|
+
docs: { source: { state: 'open' } },
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export default meta;
|
|
20
|
+
|
|
21
|
+
const Template: ComponentStory< typeof KeyboardShortcuts > = ( props ) => (
|
|
22
|
+
<KeyboardShortcuts { ...props } />
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const Default = Template.bind( {} );
|
|
26
|
+
Default.args = {
|
|
27
|
+
shortcuts: {
|
|
28
|
+
// eslint-disable-next-line no-alert
|
|
29
|
+
a: () => window.alert( 'You hit "a"!' ),
|
|
30
|
+
// eslint-disable-next-line no-alert
|
|
31
|
+
b: () => window.alert( 'You hit "b"!' ),
|
|
32
|
+
},
|
|
33
|
+
children: (
|
|
34
|
+
<div>
|
|
35
|
+
<p>{ `Hit the "a" or "b" key in this textarea:` }</p>
|
|
36
|
+
<textarea />
|
|
37
|
+
</div>
|
|
38
|
+
),
|
|
39
|
+
};
|
|
40
|
+
Default.parameters = {
|
|
41
|
+
docs: {
|
|
42
|
+
source: {
|
|
43
|
+
code: `
|
|
44
|
+
<KeyboardShortcuts
|
|
45
|
+
shortcuts={{
|
|
46
|
+
a: () => window.alert('You hit "a"!'),
|
|
47
|
+
b: () => window.alert('You hit "b"!'),
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<div>
|
|
51
|
+
<p>
|
|
52
|
+
Hit the "a" or "b" key in this textarea:
|
|
53
|
+
</p>
|
|
54
|
+
<textarea />
|
|
55
|
+
</div>
|
|
56
|
+
</KeyboardShortcuts>
|
|
57
|
+
`,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
|
+
import { createEvent, fireEvent, render, screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import KeyboardShortcuts from '
|
|
9
|
+
import KeyboardShortcuts from '..';
|
|
10
10
|
|
|
11
11
|
describe( 'KeyboardShortcuts', () => {
|
|
12
|
-
function keyPress(
|
|
12
|
+
function keyPress(
|
|
13
|
+
which: KeyboardEvent[ 'which' ],
|
|
14
|
+
target: Parameters< typeof fireEvent >[ 0 ]
|
|
15
|
+
) {
|
|
13
16
|
[ 'keydown', 'keypress', 'keyup' ].forEach( ( eventName ) => {
|
|
14
|
-
const event =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
const event = createEvent(
|
|
18
|
+
eventName,
|
|
19
|
+
target,
|
|
20
|
+
{
|
|
21
|
+
bubbles: true,
|
|
22
|
+
keyCode: which,
|
|
23
|
+
which,
|
|
24
|
+
},
|
|
25
|
+
{ EventType: 'KeyboardEvent' }
|
|
26
|
+
);
|
|
17
27
|
fireEvent( target, event );
|
|
18
28
|
} );
|
|
19
29
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { useKeyboardShortcut } from '@wordpress/compose';
|
|
5
|
+
|
|
6
|
+
// TODO: We wouldn't have to do this if this type was exported from `@wordpress/compose`.
|
|
7
|
+
type WPKeyboardShortcutConfig = NonNullable<
|
|
8
|
+
Parameters< typeof useKeyboardShortcut >[ 2 ]
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
export type KeyboardShortcutProps = {
|
|
12
|
+
shortcut: string | string[];
|
|
13
|
+
/**
|
|
14
|
+
* @see {@link https://craig.is/killing/mice Mousetrap documentation}
|
|
15
|
+
*/
|
|
16
|
+
callback: ( event: Mousetrap.ExtendedKeyboardEvent, combo: string ) => void;
|
|
17
|
+
} & Pick< WPKeyboardShortcutConfig, 'bindGlobal' | 'eventName' | 'target' >;
|
|
18
|
+
|
|
19
|
+
export type KeyboardShortcutsProps = {
|
|
20
|
+
/**
|
|
21
|
+
* Elements to render, upon whom key events are to be monitored.
|
|
22
|
+
*/
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* An object of shortcut bindings, where each key is a keyboard combination,
|
|
26
|
+
* the value of which is the callback to be invoked when the key combination is pressed.
|
|
27
|
+
*
|
|
28
|
+
* The value of each shortcut should be a consistent function reference, not an anonymous function.
|
|
29
|
+
* Otherwise, the callback will not be correctly unbound when the component unmounts.
|
|
30
|
+
*
|
|
31
|
+
* The `KeyboardShortcuts` component will not update to reflect a changed `shortcuts` prop.
|
|
32
|
+
* If you need to change shortcuts, mount a separate `KeyboardShortcuts` element,
|
|
33
|
+
* which can be achieved by assigning a unique `key` prop.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://craig.is/killing/mice Mousetrap documentation}
|
|
36
|
+
*/
|
|
37
|
+
shortcuts: Record< string, KeyboardShortcutProps[ 'callback' ] >;
|
|
38
|
+
/**
|
|
39
|
+
* By default, a callback will not be invoked if the key combination occurs in an editable field.
|
|
40
|
+
* Pass `bindGlobal` as `true` if the key events should be observed globally, including within editable fields.
|
|
41
|
+
*
|
|
42
|
+
* Tip: If you need some but not all keyboard events to be observed globally,
|
|
43
|
+
* simply render two distinct `KeyboardShortcuts` elements, one with and one without the `bindGlobal` prop.
|
|
44
|
+
*/
|
|
45
|
+
bindGlobal?: KeyboardShortcutProps[ 'bindGlobal' ];
|
|
46
|
+
/**
|
|
47
|
+
* By default, a callback is invoked in response to the `keydown` event.
|
|
48
|
+
* To override this, pass `eventName` with the name of a specific keyboard event.
|
|
49
|
+
*/
|
|
50
|
+
eventName?: KeyboardShortcutProps[ 'eventName' ];
|
|
51
|
+
};
|
package/src/modal/index.tsx
CHANGED
|
@@ -9,8 +9,6 @@ import userEvent from '@testing-library/user-event';
|
|
|
9
9
|
*/
|
|
10
10
|
import { NavigableMenu } from '../menu';
|
|
11
11
|
|
|
12
|
-
jest.useFakeTimers();
|
|
13
|
-
|
|
14
12
|
const NavigableMenuTestCase = ( props ) => (
|
|
15
13
|
<NavigableMenu { ...props }>
|
|
16
14
|
<button>Item 1</button>
|
|
@@ -46,9 +44,7 @@ describe( 'NavigableMenu', () => {
|
|
|
46
44
|
} );
|
|
47
45
|
|
|
48
46
|
it( 'moves focus on its focusable children by using the up/down arrow keys', async () => {
|
|
49
|
-
const user = userEvent.setup(
|
|
50
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
51
|
-
} );
|
|
47
|
+
const user = userEvent.setup();
|
|
52
48
|
|
|
53
49
|
const onNavigateSpy = jest.fn();
|
|
54
50
|
|
|
@@ -87,9 +83,7 @@ describe( 'NavigableMenu', () => {
|
|
|
87
83
|
} );
|
|
88
84
|
|
|
89
85
|
it( 'moves focus on its focusable children by using the left/right arrow keys when the `orientation`prop is set to `horizontal', async () => {
|
|
90
|
-
const user = userEvent.setup(
|
|
91
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
92
|
-
} );
|
|
86
|
+
const user = userEvent.setup();
|
|
93
87
|
|
|
94
88
|
const onNavigateSpy = jest.fn();
|
|
95
89
|
|
|
@@ -133,9 +127,7 @@ describe( 'NavigableMenu', () => {
|
|
|
133
127
|
} );
|
|
134
128
|
|
|
135
129
|
it( 'should stop at the edges when the `cycle` prop is set to `false`', async () => {
|
|
136
|
-
const user = userEvent.setup(
|
|
137
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
138
|
-
} );
|
|
130
|
+
const user = userEvent.setup();
|
|
139
131
|
|
|
140
132
|
const onNavigateSpy = jest.fn();
|
|
141
133
|
|
|
@@ -193,9 +185,7 @@ describe( 'NavigableMenu', () => {
|
|
|
193
185
|
} );
|
|
194
186
|
|
|
195
187
|
it( 'stops keydown event propagation when arrow keys are pressed, regardless of the `orientation` prop', async () => {
|
|
196
|
-
const user = userEvent.setup(
|
|
197
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
198
|
-
} );
|
|
188
|
+
const user = userEvent.setup();
|
|
199
189
|
|
|
200
190
|
const externalWrapperOnKeyDownSpy = jest.fn();
|
|
201
191
|
|
|
@@ -224,9 +214,7 @@ describe( 'NavigableMenu', () => {
|
|
|
224
214
|
} );
|
|
225
215
|
|
|
226
216
|
it( 'skips its internal logic when the tab key is pressed', async () => {
|
|
227
|
-
const user = userEvent.setup(
|
|
228
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
229
|
-
} );
|
|
217
|
+
const user = userEvent.setup();
|
|
230
218
|
|
|
231
219
|
render(
|
|
232
220
|
<>
|
|
@@ -9,8 +9,6 @@ import userEvent from '@testing-library/user-event';
|
|
|
9
9
|
*/
|
|
10
10
|
import { TabbableContainer } from '../tabbable';
|
|
11
11
|
|
|
12
|
-
jest.useFakeTimers();
|
|
13
|
-
|
|
14
12
|
const TabbableContainerTestCase = ( props ) => (
|
|
15
13
|
<TabbableContainer { ...props }>
|
|
16
14
|
<button>Item 1</button>
|
|
@@ -49,9 +47,7 @@ describe( 'TabbableContainer', () => {
|
|
|
49
47
|
} );
|
|
50
48
|
|
|
51
49
|
it( 'moves focus on its tabbable children by using the tab key', async () => {
|
|
52
|
-
const user = userEvent.setup(
|
|
53
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
54
|
-
} );
|
|
50
|
+
const user = userEvent.setup();
|
|
55
51
|
|
|
56
52
|
const onNavigateSpy = jest.fn();
|
|
57
53
|
|
|
@@ -80,9 +76,7 @@ describe( 'TabbableContainer', () => {
|
|
|
80
76
|
} );
|
|
81
77
|
|
|
82
78
|
it( 'should stop at the edges when the `cycle` prop is set to `false`', async () => {
|
|
83
|
-
const user = userEvent.setup(
|
|
84
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
85
|
-
} );
|
|
79
|
+
const user = userEvent.setup();
|
|
86
80
|
|
|
87
81
|
const onNavigateSpy = jest.fn();
|
|
88
82
|
|
|
@@ -141,9 +135,7 @@ describe( 'TabbableContainer', () => {
|
|
|
141
135
|
} );
|
|
142
136
|
|
|
143
137
|
it( 'stops keydown event propagation when the tab key is pressed', async () => {
|
|
144
|
-
const user = userEvent.setup(
|
|
145
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
146
|
-
} );
|
|
138
|
+
const user = userEvent.setup();
|
|
147
139
|
|
|
148
140
|
const externalWrapperOnKeyDownSpy = jest.fn();
|
|
149
141
|
|
|
@@ -16,8 +16,6 @@ import Navigation from '..';
|
|
|
16
16
|
import NavigationItem from '../item';
|
|
17
17
|
import NavigationMenu from '../menu';
|
|
18
18
|
|
|
19
|
-
jest.useFakeTimers();
|
|
20
|
-
|
|
21
19
|
const TestNavigation = ( { activeItem, rootTitle, showBadge } = {} ) => (
|
|
22
20
|
<Navigation activeItem={ activeItem }>
|
|
23
21
|
<NavigationMenu title={ rootTitle }>
|
|
@@ -192,9 +190,7 @@ describe( 'Navigation', () => {
|
|
|
192
190
|
} );
|
|
193
191
|
|
|
194
192
|
it( 'should set an active category on click', async () => {
|
|
195
|
-
const user = userEvent.setup(
|
|
196
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
197
|
-
} );
|
|
193
|
+
const user = userEvent.setup();
|
|
198
194
|
|
|
199
195
|
render( <TestNavigation /> );
|
|
200
196
|
|
|
@@ -236,9 +232,7 @@ describe( 'Navigation', () => {
|
|
|
236
232
|
} );
|
|
237
233
|
|
|
238
234
|
it( 'should navigate up a level when clicking the back button', async () => {
|
|
239
|
-
const user = userEvent.setup(
|
|
240
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
241
|
-
} );
|
|
235
|
+
const user = userEvent.setup();
|
|
242
236
|
|
|
243
237
|
render( <TestNavigation rootTitle="Home" /> );
|
|
244
238
|
|
|
@@ -252,9 +246,7 @@ describe( 'Navigation', () => {
|
|
|
252
246
|
} );
|
|
253
247
|
|
|
254
248
|
it( 'should navigate correctly when controlled', async () => {
|
|
255
|
-
const user = userEvent.setup(
|
|
256
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
257
|
-
} );
|
|
249
|
+
const user = userEvent.setup();
|
|
258
250
|
|
|
259
251
|
render( <TestNavigationControlled /> );
|
|
260
252
|
|
|
@@ -20,8 +20,6 @@ import {
|
|
|
20
20
|
NavigatorBackButton,
|
|
21
21
|
} from '..';
|
|
22
22
|
|
|
23
|
-
jest.useFakeTimers();
|
|
24
|
-
|
|
25
23
|
jest.mock( 'framer-motion', () => {
|
|
26
24
|
const actual = jest.requireActual( 'framer-motion' );
|
|
27
25
|
return {
|
|
@@ -304,9 +302,7 @@ describe( 'Navigator', () => {
|
|
|
304
302
|
it( 'should navigate across screens', async () => {
|
|
305
303
|
const spy = jest.fn();
|
|
306
304
|
|
|
307
|
-
const user = userEvent.setup(
|
|
308
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
309
|
-
} );
|
|
305
|
+
const user = userEvent.setup();
|
|
310
306
|
|
|
311
307
|
render( <MyNavigation onNavigatorButtonClick={ spy } /> );
|
|
312
308
|
|
|
@@ -376,9 +372,7 @@ describe( 'Navigator', () => {
|
|
|
376
372
|
it( 'should not rended anything if the path does not match any available screen', async () => {
|
|
377
373
|
const spy = jest.fn();
|
|
378
374
|
|
|
379
|
-
const user = userEvent.setup(
|
|
380
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
381
|
-
} );
|
|
375
|
+
const user = userEvent.setup();
|
|
382
376
|
|
|
383
377
|
render( <MyNavigation onNavigatorButtonClick={ spy } /> );
|
|
384
378
|
|
|
@@ -402,9 +396,7 @@ describe( 'Navigator', () => {
|
|
|
402
396
|
} );
|
|
403
397
|
|
|
404
398
|
it( 'should escape the value of the `path` prop', async () => {
|
|
405
|
-
const user = userEvent.setup(
|
|
406
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
407
|
-
} );
|
|
399
|
+
const user = userEvent.setup();
|
|
408
400
|
|
|
409
401
|
render( <MyNavigation /> );
|
|
410
402
|
|
|
@@ -437,9 +429,7 @@ describe( 'Navigator', () => {
|
|
|
437
429
|
|
|
438
430
|
describe( 'focus management', () => {
|
|
439
431
|
it( 'should restore focus correctly', async () => {
|
|
440
|
-
const user = userEvent.setup(
|
|
441
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
442
|
-
} );
|
|
432
|
+
const user = userEvent.setup();
|
|
443
433
|
|
|
444
434
|
render( <MyNavigation /> );
|
|
445
435
|
|
|
@@ -469,9 +459,7 @@ describe( 'Navigator', () => {
|
|
|
469
459
|
} );
|
|
470
460
|
|
|
471
461
|
it( 'should keep focus on an active element inside navigator, while re-rendering', async () => {
|
|
472
|
-
const user = userEvent.setup(
|
|
473
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
474
|
-
} );
|
|
462
|
+
const user = userEvent.setup();
|
|
475
463
|
|
|
476
464
|
render( <MyNavigation /> );
|
|
477
465
|
|
|
@@ -489,9 +477,7 @@ describe( 'Navigator', () => {
|
|
|
489
477
|
} );
|
|
490
478
|
|
|
491
479
|
it( 'should keep focus on an active element outside navigator, while re-rendering', async () => {
|
|
492
|
-
const user = userEvent.setup(
|
|
493
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
494
|
-
} );
|
|
480
|
+
const user = userEvent.setup();
|
|
495
481
|
|
|
496
482
|
render( <MyNavigation /> );
|
|
497
483
|
|