@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
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { Props as IconProps } from '../icon';
|
|
10
|
+
import type { PopoverProps } from '../popover/types';
|
|
11
|
+
import type { WordPressComponentProps } from '../ui/context/wordpress-component';
|
|
12
|
+
|
|
13
|
+
export type ButtonProps =
|
|
14
|
+
| WordPressComponentProps< BaseButtonProps & _ButtonProps, 'button', false >
|
|
15
|
+
| WordPressComponentProps< BaseButtonProps & AnchorProps, 'a', false >;
|
|
16
|
+
|
|
17
|
+
type BaseButtonProps = {
|
|
18
|
+
/**
|
|
19
|
+
* The button's children.
|
|
20
|
+
*/
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* An accessible description for the button.
|
|
24
|
+
*/
|
|
25
|
+
describedBy?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the button is focused.
|
|
28
|
+
*/
|
|
29
|
+
focus?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* If provided, renders an Icon component inside the button.
|
|
32
|
+
*/
|
|
33
|
+
icon?: IconProps< unknown >[ 'icon' ];
|
|
34
|
+
/**
|
|
35
|
+
* If provided with `icon`, sets the position of icon relative to the `text`.
|
|
36
|
+
*
|
|
37
|
+
* @default 'left'
|
|
38
|
+
*/
|
|
39
|
+
iconPosition?: 'left' | 'right';
|
|
40
|
+
/**
|
|
41
|
+
* If provided with `icon`, sets the icon size.
|
|
42
|
+
* Please refer to the Icon component for more details regarding
|
|
43
|
+
* the default value of its `size` prop.
|
|
44
|
+
*/
|
|
45
|
+
iconSize?: IconProps< unknown >[ 'size' ];
|
|
46
|
+
/**
|
|
47
|
+
* Indicates activity while a action is being performed.
|
|
48
|
+
*/
|
|
49
|
+
isBusy?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Renders a red text-based button style to indicate destructive behavior.
|
|
52
|
+
*/
|
|
53
|
+
isDestructive?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Renders a pressed button style.
|
|
56
|
+
*/
|
|
57
|
+
isPressed?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Decreases the size of the button.
|
|
60
|
+
*/
|
|
61
|
+
isSmall?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Sets the `aria-label` of the component, if none is provided.
|
|
64
|
+
* Sets the Tooltip content if `showTooltip` is provided.
|
|
65
|
+
*/
|
|
66
|
+
label?: string;
|
|
67
|
+
/**
|
|
68
|
+
* If provided with `showTooltip`, appends the Shortcut label to the tooltip content.
|
|
69
|
+
* If an object is provided, it should contain `display` and `ariaLabel` keys.
|
|
70
|
+
*/
|
|
71
|
+
shortcut?: string | { display: string; ariaLabel: string };
|
|
72
|
+
/**
|
|
73
|
+
* If provided, renders a Tooltip component for the button.
|
|
74
|
+
*/
|
|
75
|
+
showTooltip?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* If provided, displays the given text inside the button. If the button contains children elements, the text is displayed before them.
|
|
78
|
+
*/
|
|
79
|
+
text?: string;
|
|
80
|
+
/**
|
|
81
|
+
* If provided with `showTooltip`, sets the position of the tooltip.
|
|
82
|
+
* Please refer to the Tooltip component for more details regarding the defaults.
|
|
83
|
+
*/
|
|
84
|
+
tooltipPosition?: PopoverProps[ 'position' ];
|
|
85
|
+
/**
|
|
86
|
+
* Specifies the button's style.
|
|
87
|
+
* The accepted values are:
|
|
88
|
+
* 'primary' (the primary button styles)
|
|
89
|
+
* 'secondary' (the default button styles)
|
|
90
|
+
* 'tertiary' (the text-based button styles)
|
|
91
|
+
* 'link' (the link button styles)
|
|
92
|
+
*/
|
|
93
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'link';
|
|
94
|
+
/**
|
|
95
|
+
* Whether this is focusable.
|
|
96
|
+
*/
|
|
97
|
+
__experimentalIsFocusable?: boolean;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
type _ButtonProps = {
|
|
101
|
+
/**
|
|
102
|
+
* Whether the button is disabled.
|
|
103
|
+
* If `true`, this will force a `button` element to be rendered.
|
|
104
|
+
*/
|
|
105
|
+
disabled?: boolean;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
type AnchorProps = {
|
|
109
|
+
/**
|
|
110
|
+
* Whether the button is disabled.
|
|
111
|
+
* If `true`, this will force a `button` element to be rendered.
|
|
112
|
+
*/
|
|
113
|
+
disabled?: false;
|
|
114
|
+
/**
|
|
115
|
+
* If provided, renders `a` instead of `button`.
|
|
116
|
+
*/
|
|
117
|
+
href: string;
|
|
118
|
+
/**
|
|
119
|
+
* If provided with `href`, sets the `target` attribute to the `a`.
|
|
120
|
+
*/
|
|
121
|
+
target?: string;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export type DeprecatedButtonProps = {
|
|
125
|
+
isDefault?: boolean;
|
|
126
|
+
isLink?: boolean;
|
|
127
|
+
isPrimary?: boolean;
|
|
128
|
+
isSecondary?: boolean;
|
|
129
|
+
isTertiary?: boolean;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export type DeprecatedIconButtonProps = {
|
|
133
|
+
labelPosition: ButtonProps[ 'tooltipPosition' ];
|
|
134
|
+
showTooltip?: boolean;
|
|
135
|
+
size: ButtonProps[ 'iconSize' ];
|
|
136
|
+
label: ButtonProps[ 'label' ];
|
|
137
|
+
tooltip: ButtonProps[ 'label' ];
|
|
138
|
+
};
|
|
@@ -15,8 +15,6 @@ import { useState } from '@wordpress/element';
|
|
|
15
15
|
import BaseCheckboxControl from '..';
|
|
16
16
|
import type { CheckboxControlProps } from '../types';
|
|
17
17
|
|
|
18
|
-
jest.useFakeTimers();
|
|
19
|
-
|
|
20
18
|
const noop = () => {};
|
|
21
19
|
|
|
22
20
|
const getInput = () => screen.getByRole( 'checkbox' ) as HTMLInputElement;
|
|
@@ -85,9 +83,7 @@ describe( 'CheckboxControl', () => {
|
|
|
85
83
|
|
|
86
84
|
describe( 'Value', () => {
|
|
87
85
|
it( 'should flip the checked property when clicked', async () => {
|
|
88
|
-
const user = userEvent.setup(
|
|
89
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
90
|
-
} );
|
|
86
|
+
const user = userEvent.setup();
|
|
91
87
|
|
|
92
88
|
let state = false;
|
|
93
89
|
const setState = jest.fn(
|
|
@@ -12,6 +12,7 @@ import ColorPalette from '../color-palette';
|
|
|
12
12
|
import ColorIndicator from '../color-indicator';
|
|
13
13
|
import Icon from '../icon';
|
|
14
14
|
import { HStack } from '../h-stack';
|
|
15
|
+
import type { ColorListPickerProps, ColorOptionProps } from './types';
|
|
15
16
|
|
|
16
17
|
function ColorOption( {
|
|
17
18
|
label,
|
|
@@ -20,7 +21,7 @@ function ColorOption( {
|
|
|
20
21
|
disableCustomColors,
|
|
21
22
|
enableAlpha,
|
|
22
23
|
onChange,
|
|
23
|
-
} ) {
|
|
24
|
+
}: ColorOptionProps ) {
|
|
24
25
|
const [ isOpen, setIsOpen ] = useState( false );
|
|
25
26
|
return (
|
|
26
27
|
<>
|
|
@@ -62,7 +63,7 @@ function ColorListPicker( {
|
|
|
62
63
|
disableCustomColors,
|
|
63
64
|
enableAlpha,
|
|
64
65
|
onChange,
|
|
65
|
-
} ) {
|
|
66
|
+
}: ColorListPickerProps ) {
|
|
66
67
|
return (
|
|
67
68
|
<div className="components-color-list-picker">
|
|
68
69
|
{ labels.map( ( label, index ) => (
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { CSSProperties } from 'react';
|
|
5
|
+
|
|
6
|
+
export type ColorListPickerProps = {
|
|
7
|
+
/**
|
|
8
|
+
* A list of predifened colors. Each color is an object with a `name` and a
|
|
9
|
+
* `color` value.
|
|
10
|
+
* The `name` is a string used to identify the color in the UI.
|
|
11
|
+
* The `color` is a valid CSS color string.
|
|
12
|
+
*/
|
|
13
|
+
colors: Array< {
|
|
14
|
+
name: string;
|
|
15
|
+
color: NonNullable< CSSProperties[ 'color' ] >;
|
|
16
|
+
} >;
|
|
17
|
+
/**
|
|
18
|
+
* A list of labels for each of the options displayed in the UI.
|
|
19
|
+
*/
|
|
20
|
+
labels: Array< string >;
|
|
21
|
+
/**
|
|
22
|
+
* An array containing the currently selected colors.
|
|
23
|
+
*/
|
|
24
|
+
value?: Array< string | undefined >;
|
|
25
|
+
/**
|
|
26
|
+
* Controls whether the custom color picker is displayed.
|
|
27
|
+
*/
|
|
28
|
+
disableCustomColors?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Controls whether the ColorPalette should show an alpha channel control.
|
|
31
|
+
*/
|
|
32
|
+
enableAlpha?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* A function that receives the updated color value.
|
|
35
|
+
*/
|
|
36
|
+
onChange: ( newValue: Array< string | undefined > ) => void;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type ColorOptionProps = Pick<
|
|
40
|
+
ColorListPickerProps,
|
|
41
|
+
'colors' | 'disableCustomColors' | 'enableAlpha'
|
|
42
|
+
> & {
|
|
43
|
+
label: ColorListPickerProps[ 'labels' ][ number ];
|
|
44
|
+
value: string | undefined;
|
|
45
|
+
onChange: ( newValue: string | undefined ) => void;
|
|
46
|
+
};
|
|
@@ -43,7 +43,7 @@ Whether the palette should have a clearing button.
|
|
|
43
43
|
- Required: No
|
|
44
44
|
- Default: `true`
|
|
45
45
|
|
|
46
|
-
### `colors`: `
|
|
46
|
+
### `colors`: `PaletteObject[] | ColorObject[]`
|
|
47
47
|
|
|
48
48
|
Array with the colors to be shown. When displaying multiple color palettes to choose from, the format of the array changes from an array of colors objects, to an array of color palettes.
|
|
49
49
|
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
Platform,
|
|
12
12
|
Text,
|
|
13
13
|
} from 'react-native';
|
|
14
|
-
import { map } from 'lodash';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* WordPress dependencies
|
|
@@ -64,13 +63,21 @@ function ColorPalette( {
|
|
|
64
63
|
const opacity = useRef( new Animated.Value( 1 ) ).current;
|
|
65
64
|
|
|
66
65
|
const defaultColors = [
|
|
67
|
-
...new Set(
|
|
66
|
+
...new Set(
|
|
67
|
+
( defaultSettings.colors ?? [] ).map( ( { color } ) => color )
|
|
68
|
+
),
|
|
68
69
|
];
|
|
69
70
|
const mergedColors = [
|
|
70
|
-
...new Set(
|
|
71
|
+
...new Set(
|
|
72
|
+
( defaultSettings.allColors ?? [] ).map( ( { color } ) => color )
|
|
73
|
+
),
|
|
71
74
|
];
|
|
72
75
|
const defaultGradientColors = [
|
|
73
|
-
...new Set(
|
|
76
|
+
...new Set(
|
|
77
|
+
( defaultSettings.gradients ?? [] ).map(
|
|
78
|
+
( { gradient } ) => gradient
|
|
79
|
+
)
|
|
80
|
+
),
|
|
74
81
|
];
|
|
75
82
|
const colors = isGradientSegment ? defaultGradientColors : defaultColors;
|
|
76
83
|
|
|
@@ -10,7 +10,7 @@ import a11yPlugin from 'colord/plugins/a11y';
|
|
|
10
10
|
* WordPress dependencies
|
|
11
11
|
*/
|
|
12
12
|
import { __, sprintf } from '@wordpress/i18n';
|
|
13
|
-
import { useCallback, useMemo, forwardRef } from '@wordpress/element';
|
|
13
|
+
import { useCallback, useRef, useMemo, forwardRef } from '@wordpress/element';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
@@ -33,6 +33,12 @@ import type {
|
|
|
33
33
|
} from './types';
|
|
34
34
|
import type { WordPressComponentProps } from '../ui/context';
|
|
35
35
|
import type { DropdownProps } from '../dropdown/types';
|
|
36
|
+
import {
|
|
37
|
+
extractColorNameFromCurrentValue,
|
|
38
|
+
isMultiplePaletteArray,
|
|
39
|
+
normalizeColorValue,
|
|
40
|
+
showTransparentBackground,
|
|
41
|
+
} from './utils';
|
|
36
42
|
|
|
37
43
|
extend( [ namesPlugin, a11yPlugin ] );
|
|
38
44
|
|
|
@@ -164,60 +170,11 @@ export function CustomColorPickerDropdown( {
|
|
|
164
170
|
);
|
|
165
171
|
}
|
|
166
172
|
|
|
167
|
-
export const extractColorNameFromCurrentValue = (
|
|
168
|
-
currentValue?: ColorPaletteProps[ 'value' ],
|
|
169
|
-
colors: ColorPaletteProps[ 'colors' ] = [],
|
|
170
|
-
showMultiplePalettes: boolean = false
|
|
171
|
-
) => {
|
|
172
|
-
if ( ! currentValue ) {
|
|
173
|
-
return '';
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const currentValueIsCssVariable = /^var\(/.test( currentValue );
|
|
177
|
-
const normalizedCurrentValue = currentValueIsCssVariable
|
|
178
|
-
? currentValue
|
|
179
|
-
: colord( currentValue ).toHex();
|
|
180
|
-
|
|
181
|
-
// Normalize format of `colors` to simplify the following loop
|
|
182
|
-
type normalizedPaletteObject = { colors: ColorObject[] };
|
|
183
|
-
const colorPalettes: normalizedPaletteObject[] = showMultiplePalettes
|
|
184
|
-
? ( colors as PaletteObject[] )
|
|
185
|
-
: [ { colors: colors as ColorObject[] } ];
|
|
186
|
-
for ( const { colors: paletteColors } of colorPalettes ) {
|
|
187
|
-
for ( const { name: colorName, color: colorValue } of paletteColors ) {
|
|
188
|
-
const normalizedColorValue = currentValueIsCssVariable
|
|
189
|
-
? colorValue
|
|
190
|
-
: colord( colorValue ).toHex();
|
|
191
|
-
|
|
192
|
-
if ( normalizedCurrentValue === normalizedColorValue ) {
|
|
193
|
-
return colorName;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// translators: shown when the user has picked a custom color (i.e not in the palette of colors).
|
|
199
|
-
return __( 'Custom' );
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
export const showTransparentBackground = ( currentValue?: string ) => {
|
|
203
|
-
if ( typeof currentValue === 'undefined' ) {
|
|
204
|
-
return true;
|
|
205
|
-
}
|
|
206
|
-
return colord( currentValue ).alpha() === 0;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
const areColorsMultiplePalette = (
|
|
210
|
-
colors: NonNullable< ColorPaletteProps[ 'colors' ] >
|
|
211
|
-
): colors is PaletteObject[] => {
|
|
212
|
-
return colors.every( ( colorObj ) =>
|
|
213
|
-
Array.isArray( ( colorObj as PaletteObject ).colors )
|
|
214
|
-
);
|
|
215
|
-
};
|
|
216
|
-
|
|
217
173
|
function UnforwardedColorPalette(
|
|
218
174
|
props: WordPressComponentProps< ColorPaletteProps, 'div' >,
|
|
219
175
|
forwardedRef: ForwardedRef< any >
|
|
220
176
|
) {
|
|
177
|
+
const customColorPaletteRef = useRef< HTMLElement | null >( null );
|
|
221
178
|
const {
|
|
222
179
|
clearable = true,
|
|
223
180
|
colors = [],
|
|
@@ -230,9 +187,7 @@ function UnforwardedColorPalette(
|
|
|
230
187
|
} = props;
|
|
231
188
|
const clearColor = useCallback( () => onChange( undefined ), [ onChange ] );
|
|
232
189
|
|
|
233
|
-
const hasMultipleColorOrigins =
|
|
234
|
-
colors.length > 0 &&
|
|
235
|
-
( colors as PaletteObject[] )[ 0 ].colors !== undefined;
|
|
190
|
+
const hasMultipleColorOrigins = isMultiplePaletteArray( colors );
|
|
236
191
|
const buttonLabelName = useMemo(
|
|
237
192
|
() =>
|
|
238
193
|
extractColorNameFromCurrentValue(
|
|
@@ -243,22 +198,10 @@ function UnforwardedColorPalette(
|
|
|
243
198
|
[ value, colors, hasMultipleColorOrigins ]
|
|
244
199
|
);
|
|
245
200
|
|
|
246
|
-
// Make sure that the `colors` array has a valid format.
|
|
247
|
-
if (
|
|
248
|
-
colors.length > 0 &&
|
|
249
|
-
hasMultipleColorOrigins !== areColorsMultiplePalette( colors )
|
|
250
|
-
) {
|
|
251
|
-
// eslint-disable-next-line no-console
|
|
252
|
-
console.warn(
|
|
253
|
-
'wp.components.ColorPalette: please specify a valid format for the `colors` prop. '
|
|
254
|
-
);
|
|
255
|
-
return null;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
201
|
const renderCustomColorPicker = () => (
|
|
259
202
|
<DropdownContentWrapper paddingSize="none">
|
|
260
203
|
<ColorPicker
|
|
261
|
-
color={ value }
|
|
204
|
+
color={ normalizeColorValue( value, customColorPaletteRef ) }
|
|
262
205
|
onChange={ ( color ) => onChange( color ) }
|
|
263
206
|
enableAlpha={ enableAlpha }
|
|
264
207
|
/>
|
|
@@ -303,6 +246,7 @@ function UnforwardedColorPalette(
|
|
|
303
246
|
renderToggle={ ( { isOpen, onToggle } ) => (
|
|
304
247
|
<Flex
|
|
305
248
|
as={ 'button' }
|
|
249
|
+
ref={ customColorPaletteRef }
|
|
306
250
|
justify="space-between"
|
|
307
251
|
align="flex-start"
|
|
308
252
|
className="components-color-palette__custom-color"
|
|
@@ -9,8 +9,6 @@ import userEvent from '@testing-library/user-event';
|
|
|
9
9
|
*/
|
|
10
10
|
import ColorPalette from '..';
|
|
11
11
|
|
|
12
|
-
jest.useFakeTimers();
|
|
13
|
-
|
|
14
12
|
const EXAMPLE_COLORS = [
|
|
15
13
|
{ name: 'red', color: '#f00' },
|
|
16
14
|
{ name: 'green', color: '#0f0' },
|
|
@@ -54,9 +52,7 @@ describe( 'ColorPalette', () => {
|
|
|
54
52
|
} );
|
|
55
53
|
|
|
56
54
|
it( 'should call onClick on an active button with undefined', async () => {
|
|
57
|
-
const user = userEvent.setup(
|
|
58
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
59
|
-
} );
|
|
55
|
+
const user = userEvent.setup();
|
|
60
56
|
const onChange = jest.fn();
|
|
61
57
|
|
|
62
58
|
render(
|
|
@@ -76,9 +72,7 @@ describe( 'ColorPalette', () => {
|
|
|
76
72
|
} );
|
|
77
73
|
|
|
78
74
|
it( 'should call onClick on an inactive button', async () => {
|
|
79
|
-
const user = userEvent.setup(
|
|
80
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
81
|
-
} );
|
|
75
|
+
const user = userEvent.setup();
|
|
82
76
|
const onChange = jest.fn();
|
|
83
77
|
|
|
84
78
|
render(
|
|
@@ -104,9 +98,7 @@ describe( 'ColorPalette', () => {
|
|
|
104
98
|
} );
|
|
105
99
|
|
|
106
100
|
it( 'should call onClick with undefined, when the clearButton onClick is triggered', async () => {
|
|
107
|
-
const user = userEvent.setup(
|
|
108
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
109
|
-
} );
|
|
101
|
+
const user = userEvent.setup();
|
|
110
102
|
const onChange = jest.fn();
|
|
111
103
|
|
|
112
104
|
render(
|
|
@@ -139,9 +131,7 @@ describe( 'ColorPalette', () => {
|
|
|
139
131
|
} );
|
|
140
132
|
|
|
141
133
|
it( 'should render dropdown and its content', async () => {
|
|
142
|
-
const user = userEvent.setup(
|
|
143
|
-
advanceTimers: jest.advanceTimersByTime,
|
|
144
|
-
} );
|
|
134
|
+
const user = userEvent.setup();
|
|
145
135
|
const onChange = jest.fn();
|
|
146
136
|
|
|
147
137
|
render(
|
|
@@ -55,7 +55,7 @@ export type ColorPaletteProps = Pick< PaletteProps, 'onChange' > & {
|
|
|
55
55
|
*
|
|
56
56
|
* @default []
|
|
57
57
|
*/
|
|
58
|
-
colors?:
|
|
58
|
+
colors?: PaletteObject[] | ColorObject[];
|
|
59
59
|
/**
|
|
60
60
|
* Whether to allow the user to pick a custom color on top of the predefined
|
|
61
61
|
* choices (defined via the `colors` prop).
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { RefObject } from 'react';
|
|
5
|
+
import { colord, extend } from 'colord';
|
|
6
|
+
import namesPlugin from 'colord/plugins/names';
|
|
7
|
+
import a11yPlugin from 'colord/plugins/a11y';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* WordPress dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import type { ColorObject, ColorPaletteProps, PaletteObject } from './types';
|
|
18
|
+
|
|
19
|
+
extend( [ namesPlugin, a11yPlugin ] );
|
|
20
|
+
|
|
21
|
+
export const extractColorNameFromCurrentValue = (
|
|
22
|
+
currentValue?: ColorPaletteProps[ 'value' ],
|
|
23
|
+
colors: ColorPaletteProps[ 'colors' ] = [],
|
|
24
|
+
showMultiplePalettes: boolean = false
|
|
25
|
+
) => {
|
|
26
|
+
if ( ! currentValue ) {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const currentValueIsCssVariable = /^var\(/.test( currentValue );
|
|
31
|
+
const normalizedCurrentValue = currentValueIsCssVariable
|
|
32
|
+
? currentValue
|
|
33
|
+
: colord( currentValue ).toHex();
|
|
34
|
+
|
|
35
|
+
// Normalize format of `colors` to simplify the following loop
|
|
36
|
+
type normalizedPaletteObject = { colors: ColorObject[] };
|
|
37
|
+
const colorPalettes: normalizedPaletteObject[] = showMultiplePalettes
|
|
38
|
+
? ( colors as PaletteObject[] )
|
|
39
|
+
: [ { colors: colors as ColorObject[] } ];
|
|
40
|
+
for ( const { colors: paletteColors } of colorPalettes ) {
|
|
41
|
+
for ( const { name: colorName, color: colorValue } of paletteColors ) {
|
|
42
|
+
const normalizedColorValue = currentValueIsCssVariable
|
|
43
|
+
? colorValue
|
|
44
|
+
: colord( colorValue ).toHex();
|
|
45
|
+
|
|
46
|
+
if ( normalizedCurrentValue === normalizedColorValue ) {
|
|
47
|
+
return colorName;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// translators: shown when the user has picked a custom color (i.e not in the palette of colors).
|
|
53
|
+
return __( 'Custom' );
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const showTransparentBackground = ( currentValue?: string ) => {
|
|
57
|
+
if ( typeof currentValue === 'undefined' ) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return colord( currentValue ).alpha() === 0;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// The PaletteObject type has a `colors` property (an array of ColorObject),
|
|
64
|
+
// while the ColorObject type has a `color` property (the CSS color value).
|
|
65
|
+
export const isMultiplePaletteObject = (
|
|
66
|
+
obj: PaletteObject | ColorObject
|
|
67
|
+
): obj is PaletteObject =>
|
|
68
|
+
Array.isArray( ( obj as PaletteObject ).colors ) && ! ( 'color' in obj );
|
|
69
|
+
|
|
70
|
+
export const isMultiplePaletteArray = (
|
|
71
|
+
arr: ( PaletteObject | ColorObject )[]
|
|
72
|
+
): arr is PaletteObject[] => {
|
|
73
|
+
return (
|
|
74
|
+
arr.length > 0 &&
|
|
75
|
+
arr.every( ( colorObj ) => isMultiplePaletteObject( colorObj ) )
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const normalizeColorValue = (
|
|
80
|
+
value: string | undefined,
|
|
81
|
+
ref: RefObject< HTMLElement > | null
|
|
82
|
+
) => {
|
|
83
|
+
const currentValueIsCssVariable = /^var\(/.test( value ?? '' );
|
|
84
|
+
|
|
85
|
+
if ( ! currentValueIsCssVariable || ! ref?.current ) {
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const { ownerDocument } = ref.current;
|
|
90
|
+
const { defaultView } = ownerDocument;
|
|
91
|
+
const computedBackgroundColor = defaultView?.getComputedStyle(
|
|
92
|
+
ref.current
|
|
93
|
+
).backgroundColor;
|
|
94
|
+
|
|
95
|
+
return computedBackgroundColor
|
|
96
|
+
? colord( computedBackgroundColor ).toHex()
|
|
97
|
+
: value;
|
|
98
|
+
};
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { boolean, select } from '@storybook/addon-knobs';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -12,70 +7,35 @@ import { useState } from '@wordpress/element';
|
|
|
12
7
|
* Internal dependencies
|
|
13
8
|
*/
|
|
14
9
|
import { ColorPicker } from '..';
|
|
15
|
-
import { Flex } from '../../flex';
|
|
16
|
-
import { Spacer } from '../../spacer';
|
|
17
|
-
import { space } from '../../ui/utils/space';
|
|
18
10
|
|
|
19
11
|
export default {
|
|
20
12
|
component: ColorPicker,
|
|
21
13
|
title: 'Components/ColorPicker',
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
argTypes: {
|
|
15
|
+
color: { control: { type: null } },
|
|
16
|
+
copyFormat: {
|
|
17
|
+
control: { type: 'select' },
|
|
18
|
+
options: [ 'rgb', 'hsl', 'hex', undefined ],
|
|
19
|
+
},
|
|
20
|
+
// We can't use a `on*` regex because this component will switch to
|
|
21
|
+
// legacy mode when an onChangeComplete prop is passed.
|
|
22
|
+
onChange: { action: 'onChange' },
|
|
24
23
|
},
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const Example = () => {
|
|
30
|
-
const [ color, setColor ] = useState( undefined );
|
|
31
|
-
const props = {
|
|
32
|
-
enableAlpha: boolean( 'enableAlpha', false ),
|
|
33
|
-
copyFormat: select(
|
|
34
|
-
'copyFormat',
|
|
35
|
-
[ PROP_UNSET, 'rgb', 'hsl', 'hex' ],
|
|
36
|
-
PROP_UNSET
|
|
37
|
-
),
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
if ( props.copyFormat === PROP_UNSET ) {
|
|
41
|
-
delete props.copyFormat;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<Flex
|
|
46
|
-
as={ Spacer }
|
|
47
|
-
gap={ space( 2 ) }
|
|
48
|
-
justify="space-around"
|
|
49
|
-
align="flex-start"
|
|
50
|
-
marginTop={ space( 10 ) }
|
|
51
|
-
>
|
|
52
|
-
<ColorPicker { ...props } color={ color } onChange={ setColor } />
|
|
53
|
-
<div style={ { width: 200, textAlign: 'center' } }>{ color }</div>
|
|
54
|
-
<ColorPicker { ...props } color={ color } onChange={ setColor } />
|
|
55
|
-
</Flex>
|
|
56
|
-
);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const _default = () => {
|
|
60
|
-
return <Example />;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const LegacyExample = () => {
|
|
64
|
-
const [ legacyColor, setLegacyColor ] = useState( '#fff' );
|
|
65
|
-
const legacyProps = {
|
|
66
|
-
color: legacyColor,
|
|
67
|
-
onChangeComplete: setLegacyColor,
|
|
68
|
-
disableAlpha: boolean( 'disableAlpha', true ),
|
|
69
|
-
};
|
|
26
|
+
const Template = ( { onChange, ...props } ) => {
|
|
27
|
+
const [ color, setColor ] = useState();
|
|
70
28
|
|
|
71
29
|
return (
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
30
|
+
<ColorPicker
|
|
31
|
+
{ ...props }
|
|
32
|
+
color={ color }
|
|
33
|
+
onChange={ ( ...changeArgs ) => {
|
|
34
|
+
onChange( ...changeArgs );
|
|
35
|
+
setColor( ...changeArgs );
|
|
36
|
+
} }
|
|
37
|
+
/>
|
|
78
38
|
);
|
|
79
39
|
};
|
|
80
40
|
|
|
81
|
-
export const
|
|
41
|
+
export const Default = Template.bind( {} );
|