@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/notice/README.md
CHANGED
|
@@ -16,62 +16,50 @@ A Notice displays a succinct message. It can also offer the user options, like v
|
|
|
16
16
|
|
|
17
17
|
Use Notices to communicate things that are important but don’t necessarily require action — a user can keep using the product even if they don’t choose to act on a Notice. They are less interruptive than a Modal.
|
|
18
18
|
|
|
19
|
-
### Anatomy
|
|
20
|
-
|
|
21
|
-

|
|
22
|
-
|
|
23
|
-
1. Container (status indicated with color)
|
|
24
|
-
2. Icon (optional)
|
|
25
|
-
3. Message
|
|
26
|
-
4. Dismiss icon (optional)
|
|
27
|
-
|
|
28
19
|
### Usage
|
|
29
20
|
|
|
30
21
|
Notices display at the top of the screen, below any toolbars anchored to the top of the page. They’re persistent and non-modal. Since they don’t overlay the content, users can ignore or dismiss them, and choose when to interact with them.
|
|
31
22
|
|
|
32
|
-

|
|
33
|
-
|
|
34
23
|
Notices are color-coded to indicate the type of message being communicated:
|
|
35
24
|
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
- **Error** notices are **red.**
|
|
25
|
+
- **Informational** notices are **blue** by default.
|
|
26
|
+
- If there is a parent `Theme` component with an `accent` color prop, informational notices will take on that color instead.
|
|
27
|
+
- **Success** notices are **green.**
|
|
28
|
+
- **Warning** notices are **yellow\*\***.\*\*
|
|
29
|
+
- **Error** notices are **red.**
|
|
42
30
|
|
|
43
31
|
If an icon is included in the Notice, it should be color-coded to match the Notice state.
|
|
44
32
|
|
|
33
|
+
### Do's and Don'ts
|
|
34
|
+
**Do** use a Notice when you want to communicate a message of medium importance.
|
|
35
|
+
|
|
45
36
|

|
|
46
37
|
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
---
|
|
39
|
+
**Don’t** use a Notice for a message that requires immediate attention and action from the user. Use a Modal for this instead.
|
|
49
40
|
|
|
50
41
|

|
|
51
42
|
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
---
|
|
44
|
+
**Do** display Notices at the top of the screen, below any toolbars.
|
|
54
45
|
|
|
55
46
|

|
|
56
47
|
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
---
|
|
49
|
+
**Don’t** show Notices on top of toolbars.
|
|
59
50
|
|
|
60
51
|

|
|
61
52
|
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
---
|
|
54
|
+
**Do** use color to indicate the type of message being communicated.
|
|
64
55
|
|
|
65
56
|

|
|
66
57
|
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
---
|
|
59
|
+
**Don’t** apply any colors other than those for Warnings, Success, or Errors.
|
|
69
60
|
|
|
70
61
|

|
|
71
62
|
|
|
72
|
-
**Don’t**
|
|
73
|
-
Don't apply any colors other than those for Warnings, Success, or Errors.
|
|
74
|
-
|
|
75
63
|
## Development guidelines
|
|
76
64
|
|
|
77
65
|
### Usage
|
|
@@ -79,6 +67,8 @@ Don't apply any colors other than those for Warnings, Success, or Errors.
|
|
|
79
67
|
To display a plain notice, pass `Notice` a string:
|
|
80
68
|
|
|
81
69
|
```jsx
|
|
70
|
+
import { Notice } from `@wordpress/components`;
|
|
71
|
+
|
|
82
72
|
const MyNotice = () => (
|
|
83
73
|
<Notice status="error">An unknown error occurred.</Notice>
|
|
84
74
|
);
|
|
@@ -87,6 +77,8 @@ const MyNotice = () => (
|
|
|
87
77
|
For more complex markup, you can pass any JSX element:
|
|
88
78
|
|
|
89
79
|
```jsx
|
|
80
|
+
import { Notice } from `@wordpress/components`;
|
|
81
|
+
|
|
90
82
|
const MyNotice = () => (
|
|
91
83
|
<Notice status="error">
|
|
92
84
|
<p>
|
|
@@ -96,21 +88,76 @@ const MyNotice = () => (
|
|
|
96
88
|
);
|
|
97
89
|
```
|
|
98
90
|
|
|
99
|
-
|
|
91
|
+
### Props
|
|
100
92
|
|
|
101
93
|
The following props are used to control the behavior of the component.
|
|
102
94
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
95
|
+
#### `children`: `ReactNode`
|
|
96
|
+
|
|
97
|
+
The displayed message of a notice. Also used as the spoken message for assistive technology, unless `spokenMessage` is provided as an alternative message.
|
|
98
|
+
|
|
99
|
+
- Required: Yes
|
|
100
|
+
|
|
101
|
+
#### `spokenMessage`: `ReactNode`
|
|
102
|
+
|
|
103
|
+
Used to provide a custom spoken message in place of the `children` default.
|
|
104
|
+
|
|
105
|
+
- Required: No
|
|
106
|
+
- Default: `children`
|
|
107
|
+
|
|
108
|
+
#### `status`: `'warning' | 'success' | 'error' | 'info'`
|
|
109
|
+
|
|
110
|
+
Determines the color of the notice: `warning` (yellow), `success` (green), `error` (red), or `'info'`. By default `'info'` will be blue, but if there is a parent Theme component with an accent color prop, the notice will take on that color instead.
|
|
111
|
+
|
|
112
|
+
- Required: No
|
|
113
|
+
- Default: `info`
|
|
114
|
+
|
|
115
|
+
#### `onRemove`: `() => void`
|
|
116
|
+
|
|
117
|
+
A function called to dismiss/remove the notice.
|
|
118
|
+
|
|
119
|
+
- Required: No
|
|
120
|
+
- Default: `noop`
|
|
121
|
+
|
|
122
|
+
#### `politeness`: `'polite' | 'assertive'`
|
|
123
|
+
|
|
124
|
+
A politeness level for the notice's spoken message. Should be provided as one of the valid options for [an `aria-live` attribute value](https://www.w3.org/TR/wai-aria-1.1/#aria-live).
|
|
125
|
+
|
|
126
|
+
- A value of `'assertive'` is to be used for important, and usually time-sensitive, information. It will interrupt anything else the screen reader is announcing in that moment.
|
|
127
|
+
- A value of `'polite'` is to be used for advisory information. It should not interrupt what the screen reader is announcing in that moment (the "speech queue") or interrupt the current task.
|
|
128
|
+
|
|
129
|
+
Note that this value should be considered a suggestion; assistive technologies may override it based on internal heuristics.
|
|
130
|
+
|
|
131
|
+
- Required: No
|
|
132
|
+
- Default: `'assertive'` or `'polite'`, based on the notice status.
|
|
133
|
+
|
|
134
|
+
#### `isDismissible`: `boolean`
|
|
135
|
+
|
|
136
|
+
Whether the notice should be dismissible or not
|
|
137
|
+
|
|
138
|
+
- Required: No
|
|
139
|
+
- Default: `true`
|
|
140
|
+
|
|
141
|
+
#### `onDismiss` : `() => void`
|
|
142
|
+
|
|
143
|
+
A deprecated alternative to `onRemove`. This prop is kept for compatibilty reasons but should be avoided.
|
|
144
|
+
|
|
145
|
+
- Requiered: No
|
|
146
|
+
- Default: `noop`
|
|
147
|
+
|
|
148
|
+
#### `actions`: `Array<NoticeAction>`.
|
|
149
|
+
|
|
150
|
+
An array of notice actions. Each member object should contain:
|
|
151
|
+
|
|
152
|
+
- `label`: `string` containing the text of the button/link
|
|
153
|
+
- `url`: `string` OR `onClick`: `( event: SyntheticEvent ) => void` to specify what the action does.
|
|
154
|
+
- `className`: `string` (optional) to add custom classes to the button styles.
|
|
155
|
+
- `noDefaultClasses`: `boolean` (optional) A value of `true` will remove all default styling.
|
|
156
|
+
- `variant`: `'primary' | 'secondary' | 'link'` (optional) You can denote a primary button action for a notice by passing a value of `primary`.
|
|
157
|
+
|
|
158
|
+
The default appearance of an action button is inferred based on whether `url` or `onClick` are provided, rendering the button as a link if appropriate. If both props are provided, `url` takes precedence, and the action button will render as an anchor tag.
|
|
113
159
|
|
|
114
160
|
## Related components
|
|
115
161
|
|
|
116
|
-
-
|
|
162
|
+
- To create a more prominent message that requires action, use a Modal.
|
|
163
|
+
- For low priority, non-interruptive messsages, use Snackbar.
|
|
@@ -14,20 +14,21 @@ import { close } from '@wordpress/icons';
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
import Button from '../button';
|
|
18
|
+
import type { NoticeAction, NoticeProps } from './types';
|
|
19
|
+
import type { SyntheticEvent } from 'react';
|
|
20
|
+
import type { DeprecatedButtonProps } from '../button/types';
|
|
20
21
|
|
|
21
22
|
const noop = () => {};
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Custom hook which announces the message with the given politeness, if a
|
|
25
26
|
* valid message is provided.
|
|
26
|
-
*
|
|
27
|
-
* @param {string|WPElement} [message] Message to announce.
|
|
28
|
-
* @param {'polite'|'assertive'} politeness Politeness to announce.
|
|
29
27
|
*/
|
|
30
|
-
function useSpokenMessage(
|
|
28
|
+
function useSpokenMessage(
|
|
29
|
+
message: NoticeProps[ 'spokenMessage' ],
|
|
30
|
+
politeness: NoticeProps[ 'politeness' ]
|
|
31
|
+
) {
|
|
31
32
|
const spokenMessage =
|
|
32
33
|
typeof message === 'string' ? message : renderToString( message );
|
|
33
34
|
|
|
@@ -38,15 +39,7 @@ function useSpokenMessage( message, politeness ) {
|
|
|
38
39
|
}, [ spokenMessage, politeness ] );
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
* Given a notice status, returns an assumed default politeness for the status.
|
|
43
|
-
* Defaults to 'assertive'.
|
|
44
|
-
*
|
|
45
|
-
* @param {string} [status] Notice status.
|
|
46
|
-
*
|
|
47
|
-
* @return {'polite'|'assertive'} Notice politeness.
|
|
48
|
-
*/
|
|
49
|
-
function getDefaultPoliteness( status ) {
|
|
42
|
+
function getDefaultPoliteness( status: NoticeProps[ 'status' ] ) {
|
|
50
43
|
switch ( status ) {
|
|
51
44
|
case 'success':
|
|
52
45
|
case 'warning':
|
|
@@ -59,6 +52,17 @@ function getDefaultPoliteness( status ) {
|
|
|
59
52
|
}
|
|
60
53
|
}
|
|
61
54
|
|
|
55
|
+
/**
|
|
56
|
+
* `Notice` is a component used to communicate feedback to the user.
|
|
57
|
+
*
|
|
58
|
+
*```jsx
|
|
59
|
+
* import { Notice } from `@wordpress/components`;
|
|
60
|
+
*
|
|
61
|
+
* const MyNotice = () => (
|
|
62
|
+
* <Notice status="error">An unknown error occurred.</Notice>
|
|
63
|
+
* );
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
62
66
|
function Notice( {
|
|
63
67
|
className,
|
|
64
68
|
status = 'info',
|
|
@@ -73,7 +77,7 @@ function Notice( {
|
|
|
73
77
|
// It is distinct from onRemove, which _looks_ like a callback but is
|
|
74
78
|
// actually the function to call to remove the notice from the UI.
|
|
75
79
|
onDismiss = noop,
|
|
76
|
-
} ) {
|
|
80
|
+
}: NoticeProps ) {
|
|
77
81
|
useSpokenMessage( spokenMessage, politeness );
|
|
78
82
|
|
|
79
83
|
const classes = classnames(
|
|
@@ -85,11 +89,11 @@ function Notice( {
|
|
|
85
89
|
}
|
|
86
90
|
);
|
|
87
91
|
|
|
88
|
-
if ( __unstableHTML ) {
|
|
92
|
+
if ( __unstableHTML && typeof children === 'string' ) {
|
|
89
93
|
children = <RawHTML>{ children }</RawHTML>;
|
|
90
94
|
}
|
|
91
95
|
|
|
92
|
-
const onDismissNotice = ( event ) => {
|
|
96
|
+
const onDismissNotice = ( event: SyntheticEvent ) => {
|
|
93
97
|
event?.preventDefault?.();
|
|
94
98
|
onDismiss();
|
|
95
99
|
onRemove();
|
|
@@ -110,7 +114,11 @@ function Notice( {
|
|
|
110
114
|
noDefaultClasses = false,
|
|
111
115
|
onClick,
|
|
112
116
|
url,
|
|
113
|
-
}
|
|
117
|
+
}: NoticeAction &
|
|
118
|
+
// `isPrimary` is a legacy prop included for
|
|
119
|
+
// backcompat, but `variant` should be used
|
|
120
|
+
// instead.
|
|
121
|
+
Pick< DeprecatedButtonProps, 'isPrimary' >,
|
|
114
122
|
index
|
|
115
123
|
) => {
|
|
116
124
|
let computedVariant = variant;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import Notice from '.';
|
|
10
|
+
import type { WordPressComponentProps } from '../ui/context';
|
|
11
|
+
import type { NoticeListProps } from './types';
|
|
12
|
+
|
|
13
|
+
const noop = () => {};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `NoticeList` is a component used to render a collection of notices.
|
|
17
|
+
*
|
|
18
|
+
*```jsx
|
|
19
|
+
* import { Notice, NoticeList } from `@wordpress/components`;
|
|
20
|
+
*
|
|
21
|
+
* const MyNoticeList = () => {
|
|
22
|
+
* const [ notices, setNotices ] = useState( [
|
|
23
|
+
* {
|
|
24
|
+
* id: 'second-notice',
|
|
25
|
+
* content: 'second notice content',
|
|
26
|
+
* },
|
|
27
|
+
* {
|
|
28
|
+
* id: 'fist-notice',
|
|
29
|
+
* content: 'first notice content',
|
|
30
|
+
* },
|
|
31
|
+
* ] );
|
|
32
|
+
*
|
|
33
|
+
* const removeNotice = ( id ) => {
|
|
34
|
+
* setNotices( notices.filter( ( notice ) => notice.id !== id ) );
|
|
35
|
+
* };
|
|
36
|
+
*
|
|
37
|
+
* return <NoticeList notices={ notices } onRemove={ removeNotice } />;
|
|
38
|
+
*};
|
|
39
|
+
*```
|
|
40
|
+
*/
|
|
41
|
+
function NoticeList( {
|
|
42
|
+
notices,
|
|
43
|
+
onRemove = noop,
|
|
44
|
+
className,
|
|
45
|
+
children,
|
|
46
|
+
}: WordPressComponentProps< NoticeListProps, 'div', false > ) {
|
|
47
|
+
const removeNotice =
|
|
48
|
+
( id: NoticeListProps[ 'notices' ][ number ][ 'id' ] ) => () =>
|
|
49
|
+
onRemove( id );
|
|
50
|
+
|
|
51
|
+
className = classnames( 'components-notice-list', className );
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div className={ className }>
|
|
55
|
+
{ children }
|
|
56
|
+
{ [ ...notices ].reverse().map( ( notice ) => {
|
|
57
|
+
const { content, ...restNotice } = notice;
|
|
58
|
+
return (
|
|
59
|
+
<Notice
|
|
60
|
+
{ ...restNotice }
|
|
61
|
+
key={ notice.id }
|
|
62
|
+
onRemove={ removeNotice( notice.id ) }
|
|
63
|
+
>
|
|
64
|
+
{ notice.content }
|
|
65
|
+
</Notice>
|
|
66
|
+
);
|
|
67
|
+
} ) }
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default NoticeList;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import Notice from '..';
|
|
15
|
+
import Button from '../../button';
|
|
16
|
+
import NoticeList from '../list';
|
|
17
|
+
import type { NoticeListProps } from '../types';
|
|
18
|
+
|
|
19
|
+
const meta: ComponentMeta< typeof Notice > = {
|
|
20
|
+
title: 'Components/Notice',
|
|
21
|
+
component: Notice,
|
|
22
|
+
subcomponents: { NoticeList },
|
|
23
|
+
parameters: {
|
|
24
|
+
actions: { argTypesRegex: '^on.*' },
|
|
25
|
+
controls: { expanded: true },
|
|
26
|
+
docs: { source: { state: 'open' } },
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export default meta;
|
|
30
|
+
|
|
31
|
+
const Template: ComponentStory< typeof Notice > = ( props ) => {
|
|
32
|
+
return <Notice { ...props } />;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const Default = Template.bind( {} );
|
|
36
|
+
Default.args = {
|
|
37
|
+
children: 'This is a notice.',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const WithCustomSpokenMessage = Template.bind( {} );
|
|
41
|
+
WithCustomSpokenMessage.args = {
|
|
42
|
+
...Default.args,
|
|
43
|
+
politeness: 'assertive',
|
|
44
|
+
spokenMessage: 'This is a notice with a custom spoken message',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const WithJSXChildren = Template.bind( {} );
|
|
48
|
+
WithJSXChildren.args = {
|
|
49
|
+
...Default.args,
|
|
50
|
+
children: (
|
|
51
|
+
<>
|
|
52
|
+
<p>
|
|
53
|
+
JSX elements can be helpful
|
|
54
|
+
<strong> if you need to format</strong> the notice output.
|
|
55
|
+
</p>
|
|
56
|
+
<code>
|
|
57
|
+
note: in the interest of consistency, this should not be
|
|
58
|
+
overused!
|
|
59
|
+
</code>
|
|
60
|
+
</>
|
|
61
|
+
),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const WithActions = Template.bind( {} );
|
|
65
|
+
WithActions.args = {
|
|
66
|
+
...Default.args,
|
|
67
|
+
actions: [
|
|
68
|
+
{
|
|
69
|
+
label: 'Click me!',
|
|
70
|
+
onClick: () => {},
|
|
71
|
+
variant: 'primary',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
label: 'Or click me instead!',
|
|
75
|
+
onClick: () => {},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
label: 'Or visit a link for more info',
|
|
79
|
+
url: 'https://wordpress.org',
|
|
80
|
+
variant: 'link',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const NoticeListSubcomponent: ComponentStory<
|
|
86
|
+
typeof NoticeList
|
|
87
|
+
> = () => {
|
|
88
|
+
const exampleNotices = [
|
|
89
|
+
{
|
|
90
|
+
id: 'second-notice',
|
|
91
|
+
content: 'second notice content',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: 'first-notice',
|
|
95
|
+
content: 'first notice content',
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
const [ notices, setNotices ] = useState( exampleNotices );
|
|
99
|
+
|
|
100
|
+
const removeNotice = (
|
|
101
|
+
id: NoticeListProps[ 'notices' ][ number ][ 'id' ]
|
|
102
|
+
) => {
|
|
103
|
+
setNotices( notices.filter( ( notice ) => notice.id !== id ) );
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const resetNotices = () => {
|
|
107
|
+
setNotices( exampleNotices );
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<>
|
|
112
|
+
<NoticeList notices={ notices } onRemove={ removeNotice } />
|
|
113
|
+
<Button variant={ 'primary' } onClick={ resetNotices }>
|
|
114
|
+
Reset Notices
|
|
115
|
+
</Button>
|
|
116
|
+
</>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
NoticeListSubcomponent.storyName = 'NoticeList Subcomponent';
|
|
File without changes
|
|
@@ -14,14 +14,15 @@ import { speak } from '@wordpress/a11y';
|
|
|
14
14
|
import Notice from '../index';
|
|
15
15
|
|
|
16
16
|
jest.mock( '@wordpress/a11y', () => ( { speak: jest.fn() } ) );
|
|
17
|
+
const mockedSpeak = jest.mocked( speak );
|
|
17
18
|
|
|
18
|
-
function getNoticeWrapper( container ) {
|
|
19
|
+
function getNoticeWrapper( container: HTMLElement ) {
|
|
19
20
|
return container.firstChild;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
describe( 'Notice', () => {
|
|
23
24
|
beforeEach( () => {
|
|
24
|
-
|
|
25
|
+
mockedSpeak.mockReset();
|
|
25
26
|
} );
|
|
26
27
|
|
|
27
28
|
it( 'should match snapshot', () => {
|
|
@@ -42,7 +43,9 @@ describe( 'Notice', () => {
|
|
|
42
43
|
} );
|
|
43
44
|
|
|
44
45
|
it( 'should not have is-dismissible class when isDismissible prop is false', () => {
|
|
45
|
-
const { container } = render(
|
|
46
|
+
const { container } = render(
|
|
47
|
+
<Notice isDismissible={ false }>I cannot be dismissed!</Notice>
|
|
48
|
+
);
|
|
46
49
|
const wrapper = getNoticeWrapper( container );
|
|
47
50
|
|
|
48
51
|
expect( wrapper ).toHaveClass( 'components-notice' );
|
|
@@ -50,7 +53,7 @@ describe( 'Notice', () => {
|
|
|
50
53
|
} );
|
|
51
54
|
|
|
52
55
|
it( 'should default to info status', () => {
|
|
53
|
-
const { container } = render( <Notice
|
|
56
|
+
const { container } = render( <Notice>FYI</Notice> );
|
|
54
57
|
|
|
55
58
|
expect( getNoticeWrapper( container ) ).toHaveClass( 'is-info' );
|
|
56
59
|
} );
|
|
File without changes
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { MouseEventHandler, ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
type CommonNoticeActionProps = {
|
|
7
|
+
label: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
noDefaultClasses?: boolean;
|
|
10
|
+
variant?: 'primary' | 'secondary' | 'link';
|
|
11
|
+
};
|
|
12
|
+
// `url` and `onClick` can both be provided, but `url` takes precedence. If
|
|
13
|
+
// `url` is provided, the action's button will be rendered as an anchor and
|
|
14
|
+
// `onClick` will be ignored.
|
|
15
|
+
type NoticeActionWithURL = CommonNoticeActionProps & {
|
|
16
|
+
url: string;
|
|
17
|
+
onClick?: never;
|
|
18
|
+
};
|
|
19
|
+
type NoticeActionWithOnClick = CommonNoticeActionProps & {
|
|
20
|
+
url?: never;
|
|
21
|
+
onClick: MouseEventHandler< HTMLButtonElement >;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type NoticeAction = NoticeActionWithURL | NoticeActionWithOnClick;
|
|
25
|
+
|
|
26
|
+
export type NoticeChildren = string | JSX.Element;
|
|
27
|
+
|
|
28
|
+
export type NoticeProps = {
|
|
29
|
+
/**
|
|
30
|
+
* A CSS `class` to give to the wrapper element.
|
|
31
|
+
*/
|
|
32
|
+
className?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The displayed message of a notice. Also used as the spoken message for
|
|
35
|
+
* assistive technology, unless `spokenMessage` is provided as an alternative message.
|
|
36
|
+
*/
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Used to provide a custom spoken message in place of the `children` default.
|
|
40
|
+
*
|
|
41
|
+
* @default `children`
|
|
42
|
+
*/
|
|
43
|
+
spokenMessage?: ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Determines the color of the notice: `warning` (yellow),
|
|
46
|
+
* `success` (green), `error` (red), or `'info'`.
|
|
47
|
+
* By default `'info'` will be blue, but if there is a parent Theme component
|
|
48
|
+
* with an accent color prop, the notice will take on that color instead.
|
|
49
|
+
*
|
|
50
|
+
* @default 'info'
|
|
51
|
+
*/
|
|
52
|
+
status?: 'warning' | 'success' | 'error' | 'info';
|
|
53
|
+
/**
|
|
54
|
+
* Function called when dismissing the notice
|
|
55
|
+
*
|
|
56
|
+
* @default noop
|
|
57
|
+
*/
|
|
58
|
+
onRemove?: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* A politeness level for the notice's spoken message. Should be provided as
|
|
61
|
+
* one of the valid options for an `aria-live` attribute value.
|
|
62
|
+
*
|
|
63
|
+
* A value of `'assertive'` is to be used for important, and usually
|
|
64
|
+
* time-sensitive, information. It will interrupt anything else the screen
|
|
65
|
+
* reader is announcing in that moment.
|
|
66
|
+
* A value of `'polite'` is to be used for advisory information. It should
|
|
67
|
+
* not interrupt what the screen reader is announcing in that moment
|
|
68
|
+
* (the "speech queue") or interrupt the current task.
|
|
69
|
+
*
|
|
70
|
+
* Note that this value should be considered a suggestion; assistive
|
|
71
|
+
* technologies may override it based on internal heuristics.
|
|
72
|
+
*
|
|
73
|
+
* @see https://www.w3.org/TR/wai-aria-1.1/#aria-live
|
|
74
|
+
*
|
|
75
|
+
* @default 'assertive' for 'error' status, 'polite' for all other statuses
|
|
76
|
+
*/
|
|
77
|
+
politeness?: 'polite' | 'assertive';
|
|
78
|
+
/**
|
|
79
|
+
* Whether the notice should be dismissible or not
|
|
80
|
+
*
|
|
81
|
+
* @default true
|
|
82
|
+
*/
|
|
83
|
+
isDismissible?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* A deprecated alternative to `onRemove`. This prop is kept for
|
|
86
|
+
* compatibilty reasons but should be avoided.
|
|
87
|
+
*
|
|
88
|
+
* @default noop
|
|
89
|
+
*/
|
|
90
|
+
onDismiss?: () => void;
|
|
91
|
+
/**
|
|
92
|
+
* An array of action objects. Each member object should contain:
|
|
93
|
+
*
|
|
94
|
+
* - `label`: `string` containing the text of the button/link
|
|
95
|
+
* - `url`: `string` OR `onClick`: `( event: SyntheticEvent ) => void` to specify
|
|
96
|
+
* what the action does.
|
|
97
|
+
* - `className`: `string` (optional) to add custom classes to the button styles.
|
|
98
|
+
* - `noDefaultClasses`: `boolean` (optional) A value of `true` will remove all
|
|
99
|
+
* default styling.
|
|
100
|
+
* - `variant`: `'primary' | 'secondary' | 'link'` (optional) You can denote a
|
|
101
|
+
* primary button action for a notice by passing a value of `primary`.
|
|
102
|
+
*
|
|
103
|
+
* The default appearance of an action button is inferred based on whether
|
|
104
|
+
* `url` or `onClick` are provided, rendering the button as a link if
|
|
105
|
+
* appropriate. If both props are provided, `url` takes precedence, and the
|
|
106
|
+
* action button will render as an anchor tag.
|
|
107
|
+
*
|
|
108
|
+
* @default []
|
|
109
|
+
*/
|
|
110
|
+
actions?: Array< NoticeAction >;
|
|
111
|
+
/**
|
|
112
|
+
* Determines whether or not the message should be parsed as custom HTML
|
|
113
|
+
* instead of a string.
|
|
114
|
+
*/
|
|
115
|
+
__unstableHTML?: boolean;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export type NoticeListProps = {
|
|
119
|
+
/**
|
|
120
|
+
* Array of notices to render.
|
|
121
|
+
*/
|
|
122
|
+
notices: Array<
|
|
123
|
+
Omit< NoticeProps, 'children' > & {
|
|
124
|
+
id: string;
|
|
125
|
+
content: string;
|
|
126
|
+
}
|
|
127
|
+
>;
|
|
128
|
+
/**
|
|
129
|
+
* Function called when a notice should be removed / dismissed.
|
|
130
|
+
*/
|
|
131
|
+
onRemove?: ( id: string ) => void;
|
|
132
|
+
/**
|
|
133
|
+
* Children to be rendered inside the notice list.
|
|
134
|
+
*/
|
|
135
|
+
children?: ReactNode;
|
|
136
|
+
};
|
|
@@ -52,7 +52,7 @@ function UnforwardedNumberControl(
|
|
|
52
52
|
forwardedRef: ForwardedRef< any >
|
|
53
53
|
) {
|
|
54
54
|
if ( hideHTMLArrows ) {
|
|
55
|
-
deprecated( 'hideHTMLArrows', {
|
|
55
|
+
deprecated( 'wp.components.NumberControl hideHTMLArrows prop ', {
|
|
56
56
|
alternative: 'spinControls="none"',
|
|
57
57
|
since: '6.2',
|
|
58
58
|
version: '6.3',
|