@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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint jest/expect-expect: ["warn", { "assertFunctionNames": ["expect", "expectTokensToBeInTheDocument", "expectTokensNotToBeInTheDocument", "expectVisibleSuggestionsToBe", "expectEscapedProperly"] }] */
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* External dependencies
|
|
3
5
|
*/
|
|
@@ -21,8 +23,6 @@ import { useState } from '@wordpress/element';
|
|
|
21
23
|
*/
|
|
22
24
|
import FormTokenField from '../';
|
|
23
25
|
|
|
24
|
-
jest.useFakeTimers();
|
|
25
|
-
|
|
26
26
|
const FormTokenFieldWithState = ( {
|
|
27
27
|
onChange,
|
|
28
28
|
value,
|
|
@@ -85,6 +85,17 @@ const expectTokensNotToBeInTheDocument = ( tokensText: string[] ) => {
|
|
|
85
85
|
);
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
const expectEscapedProperly = ( tokenHtml: string ) => {
|
|
89
|
+
screen.getByText( ( _, node: Element | null ) => {
|
|
90
|
+
if ( node === null ) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// This is hacky, but it's a way we can check exactly the output HTML
|
|
95
|
+
return node.innerHTML === tokenHtml;
|
|
96
|
+
} );
|
|
97
|
+
};
|
|
98
|
+
|
|
88
99
|
const expectVisibleSuggestionsToBe = (
|
|
89
100
|
listElement: HTMLElement,
|
|
90
101
|
suggestionsText: string[]
|
|
@@ -109,9 +120,7 @@ function unescapeAndFormatSpaces( str: string ) {
|
|
|
109
120
|
describe( 'FormTokenField', () => {
|
|
110
121
|
describe( 'basic usage', () => {
|
|
111
122
|
it( "should add tokens with the input's value when pressing the enter key", async () => {
|
|
112
|
-
const user = userEvent.setup(
|
|
113
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
114
|
-
} );
|
|
123
|
+
const user = userEvent.setup();
|
|
115
124
|
|
|
116
125
|
const onChangeSpy = jest.fn();
|
|
117
126
|
|
|
@@ -136,9 +145,7 @@ describe( 'FormTokenField', () => {
|
|
|
136
145
|
} );
|
|
137
146
|
|
|
138
147
|
it( "should add a token with the input's value when pressing the comma key", async () => {
|
|
139
|
-
const user = userEvent.setup(
|
|
140
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
141
|
-
} );
|
|
148
|
+
const user = userEvent.setup();
|
|
142
149
|
|
|
143
150
|
const onChangeSpy = jest.fn();
|
|
144
151
|
|
|
@@ -154,9 +161,7 @@ describe( 'FormTokenField', () => {
|
|
|
154
161
|
} );
|
|
155
162
|
|
|
156
163
|
it( 'should add a token with the input value when pressing the space key and the `tokenizeOnSpace` prop is `true`', async () => {
|
|
157
|
-
const user = userEvent.setup(
|
|
158
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
159
|
-
} );
|
|
164
|
+
const user = userEvent.setup();
|
|
160
165
|
|
|
161
166
|
const onChangeSpy = jest.fn();
|
|
162
167
|
|
|
@@ -200,9 +205,7 @@ describe( 'FormTokenField', () => {
|
|
|
200
205
|
} );
|
|
201
206
|
|
|
202
207
|
it( "should not add a token with the input's value when pressing the tab key", async () => {
|
|
203
|
-
const user = userEvent.setup(
|
|
204
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
205
|
-
} );
|
|
208
|
+
const user = userEvent.setup();
|
|
206
209
|
|
|
207
210
|
const onChangeSpy = jest.fn();
|
|
208
211
|
|
|
@@ -218,9 +221,7 @@ describe( 'FormTokenField', () => {
|
|
|
218
221
|
} );
|
|
219
222
|
|
|
220
223
|
it( 'should remove the last token when pressing the backspace key', async () => {
|
|
221
|
-
const user = userEvent.setup(
|
|
222
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
223
|
-
} );
|
|
224
|
+
const user = userEvent.setup();
|
|
224
225
|
|
|
225
226
|
const onChangeSpy = jest.fn();
|
|
226
227
|
|
|
@@ -248,9 +249,7 @@ describe( 'FormTokenField', () => {
|
|
|
248
249
|
} );
|
|
249
250
|
|
|
250
251
|
it( 'should remove a token when clicking the token\'s "remove" button', async () => {
|
|
251
|
-
const user = userEvent.setup(
|
|
252
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
253
|
-
} );
|
|
252
|
+
const user = userEvent.setup();
|
|
254
253
|
|
|
255
254
|
const onChangeSpy = jest.fn();
|
|
256
255
|
|
|
@@ -292,9 +291,7 @@ describe( 'FormTokenField', () => {
|
|
|
292
291
|
} );
|
|
293
292
|
|
|
294
293
|
it( 'should remove a token when by focusing on the token\'s "remove" button and pressing space bar', async () => {
|
|
295
|
-
const user = userEvent.setup(
|
|
296
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
297
|
-
} );
|
|
294
|
+
const user = userEvent.setup();
|
|
298
295
|
|
|
299
296
|
const onChangeSpy = jest.fn();
|
|
300
297
|
|
|
@@ -329,9 +326,7 @@ describe( 'FormTokenField', () => {
|
|
|
329
326
|
} );
|
|
330
327
|
|
|
331
328
|
it( 'should not add a new token if a token with the same value already exists', async () => {
|
|
332
|
-
const user = userEvent.setup(
|
|
333
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
334
|
-
} );
|
|
329
|
+
const user = userEvent.setup();
|
|
335
330
|
|
|
336
331
|
const onChangeSpy = jest.fn();
|
|
337
332
|
|
|
@@ -358,9 +353,7 @@ describe( 'FormTokenField', () => {
|
|
|
358
353
|
} );
|
|
359
354
|
|
|
360
355
|
it( 'should not add a new token if the text input is blank', async () => {
|
|
361
|
-
const user = userEvent.setup(
|
|
362
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
363
|
-
} );
|
|
356
|
+
const user = userEvent.setup();
|
|
364
357
|
|
|
365
358
|
const onChangeSpy = jest.fn();
|
|
366
359
|
|
|
@@ -380,9 +373,7 @@ describe( 'FormTokenField', () => {
|
|
|
380
373
|
} );
|
|
381
374
|
|
|
382
375
|
it( 'should allow moving the cursor through the tokens when pressing the arrow keys, and should remove the token in front of the cursor when pressing the delete key', async () => {
|
|
383
|
-
const user = userEvent.setup(
|
|
384
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
385
|
-
} );
|
|
376
|
+
const user = userEvent.setup();
|
|
386
377
|
|
|
387
378
|
const onChangeSpy = jest.fn();
|
|
388
379
|
|
|
@@ -509,9 +500,7 @@ describe( 'FormTokenField', () => {
|
|
|
509
500
|
} );
|
|
510
501
|
|
|
511
502
|
it( 'should fire the `onFocus` callback when the input is focused', async () => {
|
|
512
|
-
const user = userEvent.setup(
|
|
513
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
514
|
-
} );
|
|
503
|
+
const user = userEvent.setup();
|
|
515
504
|
|
|
516
505
|
const onFocusSpy = jest.fn();
|
|
517
506
|
|
|
@@ -533,9 +522,7 @@ describe( 'FormTokenField', () => {
|
|
|
533
522
|
} );
|
|
534
523
|
|
|
535
524
|
it( "should fire the `onInputChange` callback when the input's value changes", async () => {
|
|
536
|
-
const user = userEvent.setup(
|
|
537
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
538
|
-
} );
|
|
525
|
+
const user = userEvent.setup();
|
|
539
526
|
|
|
540
527
|
const onInputChangeSpy = jest.fn();
|
|
541
528
|
|
|
@@ -602,9 +589,7 @@ describe( 'FormTokenField', () => {
|
|
|
602
589
|
} );
|
|
603
590
|
|
|
604
591
|
it( "should use the value of the `placeholder` prop as the input's placeholder only when there are no tokens", async () => {
|
|
605
|
-
const user = userEvent.setup(
|
|
606
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
607
|
-
} );
|
|
592
|
+
const user = userEvent.setup();
|
|
608
593
|
|
|
609
594
|
const onChangeSpy = jest.fn();
|
|
610
595
|
|
|
@@ -633,9 +618,7 @@ describe( 'FormTokenField', () => {
|
|
|
633
618
|
} );
|
|
634
619
|
|
|
635
620
|
it( 'should handle accents and special characters in tokens and input value', async () => {
|
|
636
|
-
const user = userEvent.setup(
|
|
637
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
638
|
-
} );
|
|
621
|
+
const user = userEvent.setup();
|
|
639
622
|
|
|
640
623
|
const onChangeSpy = jest.fn();
|
|
641
624
|
|
|
@@ -680,9 +663,7 @@ describe( 'FormTokenField', () => {
|
|
|
680
663
|
} );
|
|
681
664
|
|
|
682
665
|
it( 'should render suggestions when receiving focus if the `__experimentalExpandOnFocus` prop is set to `true`', async () => {
|
|
683
|
-
const user = userEvent.setup(
|
|
684
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
685
|
-
} );
|
|
666
|
+
const user = userEvent.setup();
|
|
686
667
|
|
|
687
668
|
const onFocusSpy = jest.fn();
|
|
688
669
|
|
|
@@ -725,9 +706,7 @@ describe( 'FormTokenField', () => {
|
|
|
725
706
|
} );
|
|
726
707
|
|
|
727
708
|
it( 'should not render suggestions if the text input is not matching any of the suggestions', async () => {
|
|
728
|
-
const user = userEvent.setup(
|
|
729
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
730
|
-
} );
|
|
709
|
+
const user = userEvent.setup();
|
|
731
710
|
|
|
732
711
|
const suggestions = [ 'White', 'Pearl', 'Alabaster' ];
|
|
733
712
|
|
|
@@ -742,9 +721,7 @@ describe( 'FormTokenField', () => {
|
|
|
742
721
|
} );
|
|
743
722
|
|
|
744
723
|
it( 'should render the matching suggestions only if the text input has the minimum length', async () => {
|
|
745
|
-
const user = userEvent.setup(
|
|
746
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
747
|
-
} );
|
|
724
|
+
const user = userEvent.setup();
|
|
748
725
|
|
|
749
726
|
const suggestions = [ 'Yellow', 'Canary', 'Gold', 'Blonde' ];
|
|
750
727
|
|
|
@@ -769,9 +746,7 @@ describe( 'FormTokenField', () => {
|
|
|
769
746
|
} );
|
|
770
747
|
|
|
771
748
|
it( 'should not render a matching suggestion if a token with the same value has already been added', async () => {
|
|
772
|
-
const user = userEvent.setup(
|
|
773
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
774
|
-
} );
|
|
749
|
+
const user = userEvent.setup();
|
|
775
750
|
|
|
776
751
|
const suggestions = [ 'Green', 'Emerald', 'Seaweed' ];
|
|
777
752
|
|
|
@@ -794,9 +769,7 @@ describe( 'FormTokenField', () => {
|
|
|
794
769
|
} );
|
|
795
770
|
|
|
796
771
|
it( 'should allow the user to use the keyboard to navigate and select suggestions (which are marked with the `aria-selected` attribute)', async () => {
|
|
797
|
-
const user = userEvent.setup(
|
|
798
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
799
|
-
} );
|
|
772
|
+
const user = userEvent.setup();
|
|
800
773
|
|
|
801
774
|
const onChangeSpy = jest.fn();
|
|
802
775
|
|
|
@@ -875,9 +848,7 @@ describe( 'FormTokenField', () => {
|
|
|
875
848
|
} );
|
|
876
849
|
|
|
877
850
|
it( 'should allow the user to use the mouse to navigate and select suggestions (which are marked with the `aria-selected` attribute)', async () => {
|
|
878
|
-
const user = userEvent.setup(
|
|
879
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
880
|
-
} );
|
|
851
|
+
const user = userEvent.setup();
|
|
881
852
|
|
|
882
853
|
const onChangeSpy = jest.fn();
|
|
883
854
|
|
|
@@ -947,9 +918,7 @@ describe( 'FormTokenField', () => {
|
|
|
947
918
|
} );
|
|
948
919
|
|
|
949
920
|
it( 'should hide the suggestion list when the Escape key is pressed', async () => {
|
|
950
|
-
const user = userEvent.setup(
|
|
951
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
952
|
-
} );
|
|
921
|
+
const user = userEvent.setup();
|
|
953
922
|
|
|
954
923
|
const onChangeSpy = jest.fn();
|
|
955
924
|
|
|
@@ -982,9 +951,7 @@ describe( 'FormTokenField', () => {
|
|
|
982
951
|
} );
|
|
983
952
|
|
|
984
953
|
it( 'matches the search text with the suggestions in a case-insensitive way', async () => {
|
|
985
|
-
const user = userEvent.setup(
|
|
986
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
987
|
-
} );
|
|
954
|
+
const user = userEvent.setup();
|
|
988
955
|
|
|
989
956
|
const suggestions = [ 'Cinnamon', 'Tawny', 'Mocha' ];
|
|
990
957
|
|
|
@@ -1003,9 +970,7 @@ describe( 'FormTokenField', () => {
|
|
|
1003
970
|
} );
|
|
1004
971
|
|
|
1005
972
|
it( 'should show, at most, a number of suggestions equals to the value of the `maxSuggestions` prop', async () => {
|
|
1006
|
-
const user = userEvent.setup(
|
|
1007
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1008
|
-
} );
|
|
973
|
+
const user = userEvent.setup();
|
|
1009
974
|
|
|
1010
975
|
const suggestions = [
|
|
1011
976
|
'Ablaze',
|
|
@@ -1053,9 +1018,7 @@ describe( 'FormTokenField', () => {
|
|
|
1053
1018
|
} );
|
|
1054
1019
|
|
|
1055
1020
|
it( 'should match the search text against the unescaped values of suggestions with special characters (including spaces)', async () => {
|
|
1056
|
-
const user = userEvent.setup(
|
|
1057
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1058
|
-
} );
|
|
1021
|
+
const user = userEvent.setup();
|
|
1059
1022
|
|
|
1060
1023
|
render(
|
|
1061
1024
|
<FormTokenFieldWithState
|
|
@@ -1096,9 +1059,7 @@ describe( 'FormTokenField', () => {
|
|
|
1096
1059
|
} );
|
|
1097
1060
|
|
|
1098
1061
|
it( 'should re-render if suggestions change', async () => {
|
|
1099
|
-
const user = userEvent.setup(
|
|
1100
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1101
|
-
} );
|
|
1062
|
+
const user = userEvent.setup();
|
|
1102
1063
|
|
|
1103
1064
|
const suggestions = [ 'Aluminum', 'Silver', 'Bronze' ];
|
|
1104
1065
|
|
|
@@ -1119,9 +1080,7 @@ describe( 'FormTokenField', () => {
|
|
|
1119
1080
|
} );
|
|
1120
1081
|
|
|
1121
1082
|
it( 'should automatically select the first matching suggestions when the `__experimentalAutoSelectFirstMatch` prop is set to `true`', async () => {
|
|
1122
|
-
const user = userEvent.setup(
|
|
1123
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1124
|
-
} );
|
|
1083
|
+
const user = userEvent.setup();
|
|
1125
1084
|
|
|
1126
1085
|
const suggestions = [ 'Walnut', 'Hazelnut', 'Pecan' ];
|
|
1127
1086
|
|
|
@@ -1162,9 +1121,7 @@ describe( 'FormTokenField', () => {
|
|
|
1162
1121
|
} );
|
|
1163
1122
|
|
|
1164
1123
|
it( 'should allow to render custom suggestion items via the `__experimentalRenderItem` prop', async () => {
|
|
1165
|
-
const user = userEvent.setup(
|
|
1166
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1167
|
-
} );
|
|
1124
|
+
const user = userEvent.setup();
|
|
1168
1125
|
|
|
1169
1126
|
const suggestions = [ 'Wood', 'Stone', 'Metal' ];
|
|
1170
1127
|
|
|
@@ -1195,9 +1152,7 @@ describe( 'FormTokenField', () => {
|
|
|
1195
1152
|
|
|
1196
1153
|
describe( 'tokens as objects', () => {
|
|
1197
1154
|
it( 'should accept tokens in their object format', async () => {
|
|
1198
|
-
const user = userEvent.setup(
|
|
1199
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1200
|
-
} );
|
|
1155
|
+
const user = userEvent.setup();
|
|
1201
1156
|
|
|
1202
1157
|
const onChangeSpy = jest.fn();
|
|
1203
1158
|
|
|
@@ -1237,9 +1192,7 @@ describe( 'FormTokenField', () => {
|
|
|
1237
1192
|
} );
|
|
1238
1193
|
|
|
1239
1194
|
it( 'should trigger mouse callbacks if the `onMouseEnter` and/or the `onMouseLeave` properties are set on a token data object', async () => {
|
|
1240
|
-
const user = userEvent.setup(
|
|
1241
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1242
|
-
} );
|
|
1195
|
+
const user = userEvent.setup();
|
|
1243
1196
|
|
|
1244
1197
|
const onMouseEnterSpy = jest.fn();
|
|
1245
1198
|
const onMouseLeaveSpy = jest.fn();
|
|
@@ -1293,21 +1246,35 @@ describe( 'FormTokenField', () => {
|
|
|
1293
1246
|
expect( screen.getByTitle( 'España' ) ).toBeVisible();
|
|
1294
1247
|
} );
|
|
1295
1248
|
|
|
1296
|
-
it( 'should be still used to filter out duplicate suggestions', () => {
|
|
1249
|
+
it( 'should be still used to filter out duplicate suggestions', async () => {
|
|
1250
|
+
const user = userEvent.setup();
|
|
1251
|
+
|
|
1297
1252
|
render(
|
|
1298
1253
|
<FormTokenFieldWithState
|
|
1299
1254
|
__experimentalExpandOnFocus
|
|
1300
|
-
initialValue={ [
|
|
1255
|
+
initialValue={ [
|
|
1256
|
+
{ value: 'Slovenia' },
|
|
1257
|
+
{ value: 'Spain' },
|
|
1258
|
+
] }
|
|
1259
|
+
suggestions={ [ 'Slovenia', 'Slovakia', 'Sweden' ] }
|
|
1301
1260
|
/>
|
|
1302
1261
|
);
|
|
1262
|
+
|
|
1263
|
+
const input = screen.getByRole( 'combobox' );
|
|
1264
|
+
|
|
1265
|
+
// Typing `slov` will match both `Slovenia` and `Slovakia`.
|
|
1266
|
+
await user.type( input, 'slov' );
|
|
1267
|
+
|
|
1268
|
+
// However, `Slovenia` is already selected.
|
|
1269
|
+
expectVisibleSuggestionsToBe( screen.getByRole( 'listbox' ), [
|
|
1270
|
+
'Slovakia',
|
|
1271
|
+
] );
|
|
1303
1272
|
} );
|
|
1304
1273
|
} );
|
|
1305
1274
|
|
|
1306
1275
|
describe( 'saveTransform', () => {
|
|
1307
1276
|
it( "by default, it should trim the input's value from extra white spaces before attempting to add it as a token", async () => {
|
|
1308
|
-
const user = userEvent.setup(
|
|
1309
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1310
|
-
} );
|
|
1277
|
+
const user = userEvent.setup();
|
|
1311
1278
|
|
|
1312
1279
|
const onChangeSpy = jest.fn();
|
|
1313
1280
|
|
|
@@ -1371,9 +1338,7 @@ describe( 'FormTokenField', () => {
|
|
|
1371
1338
|
} );
|
|
1372
1339
|
|
|
1373
1340
|
it( "should allow to modify the input's value when saving it as a token", async () => {
|
|
1374
|
-
const user = userEvent.setup(
|
|
1375
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1376
|
-
} );
|
|
1341
|
+
const user = userEvent.setup();
|
|
1377
1342
|
|
|
1378
1343
|
const onChangeSpy = jest.fn();
|
|
1379
1344
|
|
|
@@ -1436,9 +1401,7 @@ describe( 'FormTokenField', () => {
|
|
|
1436
1401
|
} );
|
|
1437
1402
|
|
|
1438
1403
|
it( 'is applied to the search value when matching it against the list of suggestions', async () => {
|
|
1439
|
-
const user = userEvent.setup(
|
|
1440
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1441
|
-
} );
|
|
1404
|
+
const user = userEvent.setup();
|
|
1442
1405
|
|
|
1443
1406
|
const onChangeSpy = jest.fn();
|
|
1444
1407
|
|
|
@@ -1476,9 +1439,7 @@ describe( 'FormTokenField', () => {
|
|
|
1476
1439
|
|
|
1477
1440
|
describe( 'displayTransform', () => {
|
|
1478
1441
|
it( 'should allow to modify the text rendered in the browser for each token', async () => {
|
|
1479
|
-
const user = userEvent.setup(
|
|
1480
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1481
|
-
} );
|
|
1442
|
+
const user = userEvent.setup();
|
|
1482
1443
|
|
|
1483
1444
|
const onChangeSpy = jest.fn();
|
|
1484
1445
|
|
|
@@ -1534,9 +1495,7 @@ describe( 'FormTokenField', () => {
|
|
|
1534
1495
|
} );
|
|
1535
1496
|
|
|
1536
1497
|
it( "is applied to each suggestions, but doesn't influence the matching against the search value", async () => {
|
|
1537
|
-
const user = userEvent.setup(
|
|
1538
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1539
|
-
} );
|
|
1498
|
+
const user = userEvent.setup();
|
|
1540
1499
|
|
|
1541
1500
|
const onChangeSpy = jest.fn();
|
|
1542
1501
|
|
|
@@ -1586,15 +1545,7 @@ describe( 'FormTokenField', () => {
|
|
|
1586
1545
|
'a b',
|
|
1587
1546
|
'i <3 tags',
|
|
1588
1547
|
'1&2&3&4',
|
|
1589
|
-
].forEach( ( tokenHtml ) =>
|
|
1590
|
-
screen.getByText( ( _, node: Element | null ) => {
|
|
1591
|
-
if ( node === null ) {
|
|
1592
|
-
return false;
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
return node.innerHTML === tokenHtml;
|
|
1596
|
-
} );
|
|
1597
|
-
} );
|
|
1548
|
+
].forEach( ( tokenHtml ) => expectEscapedProperly( tokenHtml ) );
|
|
1598
1549
|
} );
|
|
1599
1550
|
|
|
1600
1551
|
it( 'should allow to pass a function that renders tokens with special characters correctly', async () => {
|
|
@@ -1616,23 +1567,13 @@ describe( 'FormTokenField', () => {
|
|
|
1616
1567
|
'a b',
|
|
1617
1568
|
'i <3 tags',
|
|
1618
1569
|
'1&2&3&4',
|
|
1619
|
-
].forEach( ( tokenHtml ) =>
|
|
1620
|
-
screen.getByText( ( _, node: Element | null ) => {
|
|
1621
|
-
if ( node === null ) {
|
|
1622
|
-
return false;
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
return node.innerHTML === tokenHtml;
|
|
1626
|
-
} );
|
|
1627
|
-
} );
|
|
1570
|
+
].forEach( ( tokenHtml ) => expectEscapedProperly( tokenHtml ) );
|
|
1628
1571
|
} );
|
|
1629
1572
|
} );
|
|
1630
1573
|
|
|
1631
1574
|
describe( 'validation', () => {
|
|
1632
1575
|
it( 'should add a token only if it passes the validation set via `__experimentalValidateInput`', async () => {
|
|
1633
|
-
const user = userEvent.setup(
|
|
1634
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1635
|
-
} );
|
|
1576
|
+
const user = userEvent.setup();
|
|
1636
1577
|
|
|
1637
1578
|
const onChangeSpy = jest.fn();
|
|
1638
1579
|
const startsWithCapitalLetter = ( tokenText: string ) =>
|
|
@@ -1677,9 +1618,7 @@ describe( 'FormTokenField', () => {
|
|
|
1677
1618
|
|
|
1678
1619
|
describe( 'maxLength', () => {
|
|
1679
1620
|
it( 'should not allow adding new tokens beyond the value defined by the `maxLength` prop', async () => {
|
|
1680
|
-
const user = userEvent.setup(
|
|
1681
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1682
|
-
} );
|
|
1621
|
+
const user = userEvent.setup();
|
|
1683
1622
|
|
|
1684
1623
|
const onChangeSpy = jest.fn();
|
|
1685
1624
|
|
|
@@ -1747,9 +1686,7 @@ describe( 'FormTokenField', () => {
|
|
|
1747
1686
|
} );
|
|
1748
1687
|
|
|
1749
1688
|
it( 'should not affect tokens that were added before the limit was imposed', async () => {
|
|
1750
|
-
const user = userEvent.setup(
|
|
1751
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1752
|
-
} );
|
|
1689
|
+
const user = userEvent.setup();
|
|
1753
1690
|
|
|
1754
1691
|
const onChangeSpy = jest.fn();
|
|
1755
1692
|
|
|
@@ -1792,9 +1729,7 @@ describe( 'FormTokenField', () => {
|
|
|
1792
1729
|
|
|
1793
1730
|
describe( 'disabled', () => {
|
|
1794
1731
|
it( 'should not allow adding tokens when the `disabled` prop is `true`', async () => {
|
|
1795
|
-
const user = userEvent.setup(
|
|
1796
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1797
|
-
} );
|
|
1732
|
+
const user = userEvent.setup();
|
|
1798
1733
|
|
|
1799
1734
|
const onChangeSpy = jest.fn();
|
|
1800
1735
|
|
|
@@ -1822,9 +1757,7 @@ describe( 'FormTokenField', () => {
|
|
|
1822
1757
|
} );
|
|
1823
1758
|
|
|
1824
1759
|
it( 'should not allow removing tokens when the `disable` prop is `true`', async () => {
|
|
1825
|
-
const user = userEvent.setup(
|
|
1826
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1827
|
-
} );
|
|
1760
|
+
const user = userEvent.setup();
|
|
1828
1761
|
|
|
1829
1762
|
const onChangeSpy = jest.fn();
|
|
1830
1763
|
|
|
@@ -1870,9 +1803,7 @@ describe( 'FormTokenField', () => {
|
|
|
1870
1803
|
};
|
|
1871
1804
|
|
|
1872
1805
|
it( 'should announce to assistive technology the addition of a new token', async () => {
|
|
1873
|
-
const user = userEvent.setup(
|
|
1874
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1875
|
-
} );
|
|
1806
|
+
const user = userEvent.setup();
|
|
1876
1807
|
|
|
1877
1808
|
render( <FormTokenFieldWithState /> );
|
|
1878
1809
|
|
|
@@ -1888,9 +1819,7 @@ describe( 'FormTokenField', () => {
|
|
|
1888
1819
|
} );
|
|
1889
1820
|
|
|
1890
1821
|
it( 'should announce to assistive technology the addition of a new token with a custom message', async () => {
|
|
1891
|
-
const user = userEvent.setup(
|
|
1892
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1893
|
-
} );
|
|
1822
|
+
const user = userEvent.setup();
|
|
1894
1823
|
|
|
1895
1824
|
render( <FormTokenFieldWithState messages={ customMessages } /> );
|
|
1896
1825
|
|
|
@@ -1906,9 +1835,7 @@ describe( 'FormTokenField', () => {
|
|
|
1906
1835
|
} );
|
|
1907
1836
|
|
|
1908
1837
|
it( 'should announce to assistive technology the removal of a token', async () => {
|
|
1909
|
-
const user = userEvent.setup(
|
|
1910
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1911
|
-
} );
|
|
1838
|
+
const user = userEvent.setup();
|
|
1912
1839
|
|
|
1913
1840
|
render( <FormTokenFieldWithState initialValue={ [ 'horse' ] } /> );
|
|
1914
1841
|
|
|
@@ -1923,9 +1850,7 @@ describe( 'FormTokenField', () => {
|
|
|
1923
1850
|
} );
|
|
1924
1851
|
|
|
1925
1852
|
it( 'should announce to assistive technology the removal of a token with a custom message', async () => {
|
|
1926
|
-
const user = userEvent.setup(
|
|
1927
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1928
|
-
} );
|
|
1853
|
+
const user = userEvent.setup();
|
|
1929
1854
|
|
|
1930
1855
|
render(
|
|
1931
1856
|
<FormTokenFieldWithState
|
|
@@ -1945,9 +1870,7 @@ describe( 'FormTokenField', () => {
|
|
|
1945
1870
|
} );
|
|
1946
1871
|
|
|
1947
1872
|
it( 'should announce to assistive technology the failure of a potential token to pass validation', async () => {
|
|
1948
|
-
const user = userEvent.setup(
|
|
1949
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1950
|
-
} );
|
|
1873
|
+
const user = userEvent.setup();
|
|
1951
1874
|
|
|
1952
1875
|
render(
|
|
1953
1876
|
<FormTokenFieldWithState
|
|
@@ -1967,9 +1890,7 @@ describe( 'FormTokenField', () => {
|
|
|
1967
1890
|
} );
|
|
1968
1891
|
|
|
1969
1892
|
it( 'should announce to assistive technology the failure of a potential token to pass validation with a custom message', async () => {
|
|
1970
|
-
const user = userEvent.setup(
|
|
1971
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1972
|
-
} );
|
|
1893
|
+
const user = userEvent.setup();
|
|
1973
1894
|
|
|
1974
1895
|
render(
|
|
1975
1896
|
<FormTokenFieldWithState
|
|
@@ -1990,9 +1911,7 @@ describe( 'FormTokenField', () => {
|
|
|
1990
1911
|
} );
|
|
1991
1912
|
|
|
1992
1913
|
it( 'should announce to assistive technology the result of the matching of the search text against the list of suggestions', async () => {
|
|
1993
|
-
const user = userEvent.setup(
|
|
1994
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
1995
|
-
} );
|
|
1914
|
+
const user = userEvent.setup();
|
|
1996
1915
|
|
|
1997
1916
|
render(
|
|
1998
1917
|
<FormTokenFieldWithState
|
|
@@ -2054,9 +1973,7 @@ describe( 'FormTokenField', () => {
|
|
|
2054
1973
|
// but I wasn't sure if there was a better way.
|
|
2055
1974
|
describe( 'aria attributes', () => {
|
|
2056
1975
|
it( 'should add the correct aria attributes to the input as the user interacts with it', async () => {
|
|
2057
|
-
const user = userEvent.setup(
|
|
2058
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
2059
|
-
} );
|
|
1976
|
+
const user = userEvent.setup();
|
|
2060
1977
|
|
|
2061
1978
|
const suggestions = [ 'Pine', 'Pistachio', 'Sage' ];
|
|
2062
1979
|
|
|
@@ -73,7 +73,7 @@ export default function Token( {
|
|
|
73
73
|
<Button
|
|
74
74
|
className="components-form-token-field__remove-token"
|
|
75
75
|
icon={ closeSmall }
|
|
76
|
-
onClick={ ! disabled
|
|
76
|
+
onClick={ ! disabled ? onClick : undefined }
|
|
77
77
|
label={ messages.remove }
|
|
78
78
|
aria-describedby={ `components-form-token-field__token-text-${ instanceId }` }
|
|
79
79
|
/>
|
|
@@ -14,6 +14,18 @@ import { VStack } from '../v-stack';
|
|
|
14
14
|
import { ColorHeading } from '../color-palette/styles';
|
|
15
15
|
import { Spacer } from '../spacer';
|
|
16
16
|
|
|
17
|
+
// The Multiple Origin Gradients have a `gradients` property (an array of
|
|
18
|
+
// gradient objects), while Single Origin ones have a `gradient` property.
|
|
19
|
+
const isMultipleOriginObject = ( obj ) =>
|
|
20
|
+
Array.isArray( obj.gradients ) && ! ( 'gradient' in obj );
|
|
21
|
+
|
|
22
|
+
const isMultipleOriginArray = ( arr ) => {
|
|
23
|
+
return (
|
|
24
|
+
arr.length > 0 &&
|
|
25
|
+
arr.every( ( gradientObj ) => isMultipleOriginObject( gradientObj ) )
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
17
29
|
function SingleOrigin( {
|
|
18
30
|
className,
|
|
19
31
|
clearGradient,
|
|
@@ -105,10 +117,9 @@ export default function GradientPicker( {
|
|
|
105
117
|
() => onChange( undefined ),
|
|
106
118
|
[ onChange ]
|
|
107
119
|
);
|
|
108
|
-
const Component =
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
: SingleOrigin;
|
|
120
|
+
const Component = isMultipleOriginArray( gradients )
|
|
121
|
+
? MultipleOrigin
|
|
122
|
+
: SingleOrigin;
|
|
112
123
|
|
|
113
124
|
if ( ! __nextHasNoMargin ) {
|
|
114
125
|
deprecated( 'Outer margin styles for wp.components.GradientPicker', {
|