@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,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { groupBy } from 'lodash';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type {
|
|
10
|
+
Author,
|
|
11
|
+
Category,
|
|
12
|
+
TermWithParentAndChildren,
|
|
13
|
+
TermsByParent,
|
|
14
|
+
} from './types';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Returns terms in a tree form.
|
|
18
|
+
*
|
|
19
|
+
* @param flatTerms Array of terms in flat format.
|
|
20
|
+
*
|
|
21
|
+
* @return Terms in tree format.
|
|
22
|
+
*/
|
|
23
|
+
export function buildTermsTree( flatTerms: readonly ( Author | Category )[] ) {
|
|
24
|
+
const flatTermsWithParentAndChildren: TermWithParentAndChildren[] =
|
|
25
|
+
flatTerms.map( ( term ) => {
|
|
26
|
+
return {
|
|
27
|
+
children: [],
|
|
28
|
+
parent: null,
|
|
29
|
+
...term,
|
|
30
|
+
id: String( term.id ),
|
|
31
|
+
};
|
|
32
|
+
} );
|
|
33
|
+
|
|
34
|
+
const termsByParent: TermsByParent = groupBy(
|
|
35
|
+
flatTermsWithParentAndChildren,
|
|
36
|
+
'parent'
|
|
37
|
+
);
|
|
38
|
+
if ( termsByParent.null && termsByParent.null.length ) {
|
|
39
|
+
return flatTermsWithParentAndChildren;
|
|
40
|
+
}
|
|
41
|
+
const fillWithChildren = (
|
|
42
|
+
terms: TermWithParentAndChildren[]
|
|
43
|
+
): TermWithParentAndChildren[] => {
|
|
44
|
+
return terms.map( ( term ) => {
|
|
45
|
+
const children = termsByParent[ term.id ];
|
|
46
|
+
return {
|
|
47
|
+
...term,
|
|
48
|
+
children:
|
|
49
|
+
children && children.length
|
|
50
|
+
? fillWithChildren( children )
|
|
51
|
+
: [],
|
|
52
|
+
};
|
|
53
|
+
} );
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return fillWithChildren( termsByParent[ '0' ] || [] );
|
|
57
|
+
}
|
|
@@ -6,38 +6,53 @@ import { buildTermsTree } from '../terms';
|
|
|
6
6
|
describe( 'buildTermsTree()', () => {
|
|
7
7
|
it( 'Should return same array as input with null parent and empty children added if parent is never specified.', () => {
|
|
8
8
|
const input = Object.freeze( [
|
|
9
|
-
{ id: 2232, dummy: true },
|
|
10
|
-
{ id: 2245, dummy: true },
|
|
9
|
+
{ id: 2232, name: 'foo', dummy: true },
|
|
10
|
+
{ id: 2245, name: 'baz', dummy: true },
|
|
11
11
|
] );
|
|
12
12
|
const output = Object.freeze( [
|
|
13
|
-
{
|
|
14
|
-
|
|
13
|
+
{
|
|
14
|
+
id: '2232',
|
|
15
|
+
name: 'foo',
|
|
16
|
+
parent: null,
|
|
17
|
+
children: [],
|
|
18
|
+
dummy: true,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: '2245',
|
|
22
|
+
name: 'baz',
|
|
23
|
+
parent: null,
|
|
24
|
+
children: [],
|
|
25
|
+
dummy: true,
|
|
26
|
+
},
|
|
15
27
|
] );
|
|
16
28
|
const termsTreem = buildTermsTree( input );
|
|
17
29
|
expect( termsTreem ).toEqual( output );
|
|
18
30
|
} );
|
|
19
31
|
it( 'Should return same array as input with empty children added if all the elements are top level', () => {
|
|
20
32
|
const input = Object.freeze( [
|
|
21
|
-
{ id: 2232, parent: 0, dummy: true },
|
|
22
|
-
{ id: 2245, parent: 0, dummy: false },
|
|
33
|
+
{ id: 2232, name: 'foo', parent: 0, dummy: true },
|
|
34
|
+
{ id: 2245, name: 'baz', parent: 0, dummy: false },
|
|
23
35
|
] );
|
|
24
36
|
const output = [
|
|
25
|
-
{ id: 2232, parent: 0, children: [], dummy: true },
|
|
26
|
-
{ id: 2245, parent: 0, children: [], dummy: false },
|
|
37
|
+
{ id: '2232', name: 'foo', parent: 0, children: [], dummy: true },
|
|
38
|
+
{ id: '2245', name: 'baz', parent: 0, children: [], dummy: false },
|
|
27
39
|
];
|
|
28
40
|
const termsTreem = buildTermsTree( input );
|
|
29
41
|
expect( termsTreem ).toEqual( output );
|
|
30
42
|
} );
|
|
31
43
|
it( 'Should return element with its child if a child exists', () => {
|
|
32
44
|
const input = Object.freeze( [
|
|
33
|
-
{ id: 2232, parent: 0 },
|
|
34
|
-
{ id: 2245, parent: 2232 },
|
|
45
|
+
{ id: 2232, name: 'foo', parent: 0 },
|
|
46
|
+
{ id: 2245, name: 'baz', parent: 2232 },
|
|
35
47
|
] );
|
|
36
48
|
const output = [
|
|
37
49
|
{
|
|
38
|
-
id: 2232,
|
|
50
|
+
id: '2232',
|
|
51
|
+
name: 'foo',
|
|
39
52
|
parent: 0,
|
|
40
|
-
children: [
|
|
53
|
+
children: [
|
|
54
|
+
{ id: '2245', name: 'baz', parent: 2232, children: [] },
|
|
55
|
+
],
|
|
41
56
|
},
|
|
42
57
|
];
|
|
43
58
|
const termsTreem = buildTermsTree( input );
|
|
@@ -45,21 +60,22 @@ describe( 'buildTermsTree()', () => {
|
|
|
45
60
|
} );
|
|
46
61
|
it( 'Should return elements with multiple children and elements with no children', () => {
|
|
47
62
|
const input = Object.freeze( [
|
|
48
|
-
{ id: 2232, parent: 0 },
|
|
49
|
-
{ id: 2245, parent: 2232 },
|
|
50
|
-
{ id: 2249, parent: 0 },
|
|
51
|
-
{ id: 2246, parent: 2232 },
|
|
63
|
+
{ id: 2232, name: 'a', parent: 0 },
|
|
64
|
+
{ id: 2245, name: 'b', parent: 2232 },
|
|
65
|
+
{ id: 2249, name: 'c', parent: 0 },
|
|
66
|
+
{ id: 2246, name: 'd', parent: 2232 },
|
|
52
67
|
] );
|
|
53
68
|
const output = [
|
|
54
69
|
{
|
|
55
|
-
id: 2232,
|
|
70
|
+
id: '2232',
|
|
71
|
+
name: 'a',
|
|
56
72
|
parent: 0,
|
|
57
73
|
children: [
|
|
58
|
-
{ id: 2245, parent: 2232, children: [] },
|
|
59
|
-
{ id: 2246, parent: 2232, children: [] },
|
|
74
|
+
{ id: '2245', name: 'b', parent: 2232, children: [] },
|
|
75
|
+
{ id: '2246', name: 'd', parent: 2232, children: [] },
|
|
60
76
|
],
|
|
61
77
|
},
|
|
62
|
-
{ id: 2249, parent: 0, children: [] },
|
|
78
|
+
{ id: '2249', name: 'c', parent: 0, children: [] },
|
|
63
79
|
];
|
|
64
80
|
const termsTreem = buildTermsTree( input );
|
|
65
81
|
expect( termsTreem ).toEqual( output );
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { FormTokenFieldProps } from '../form-token-field/types';
|
|
5
|
+
import type { TreeSelectProps } from '../tree-select/types';
|
|
6
|
+
|
|
7
|
+
export type Author = {
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type Category = {
|
|
13
|
+
id: number;
|
|
14
|
+
name: string;
|
|
15
|
+
parent: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type TermWithParentAndChildren = {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
parent: number | null;
|
|
22
|
+
children: TermWithParentAndChildren[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type TermsByParent = Record< string, TermWithParentAndChildren[] >;
|
|
26
|
+
|
|
27
|
+
export type CategorySelectProps = Pick<
|
|
28
|
+
TreeSelectProps,
|
|
29
|
+
'label' | 'noOptionLabel'
|
|
30
|
+
> & {
|
|
31
|
+
categoriesList: Category[];
|
|
32
|
+
onChange: ( newCategory: string ) => void;
|
|
33
|
+
selectedCategoryId?: Category[ 'id' ];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type AuthorSelectProps = Pick<
|
|
37
|
+
TreeSelectProps,
|
|
38
|
+
'label' | 'noOptionLabel'
|
|
39
|
+
> & {
|
|
40
|
+
authorList?: Author[];
|
|
41
|
+
onChange: ( newAuthor: string ) => void;
|
|
42
|
+
selectedAuthorId?: Author[ 'id' ];
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type Order = 'asc' | 'desc';
|
|
46
|
+
type OrderBy = 'date' | 'title';
|
|
47
|
+
|
|
48
|
+
type BaseQueryControlsProps = {
|
|
49
|
+
/**
|
|
50
|
+
* An array of the authors to select from.
|
|
51
|
+
*/
|
|
52
|
+
authorList?: AuthorSelectProps[ 'authorList' ];
|
|
53
|
+
/**
|
|
54
|
+
* The maximum number of items.
|
|
55
|
+
*
|
|
56
|
+
* @default 100
|
|
57
|
+
*/
|
|
58
|
+
maxItems?: number;
|
|
59
|
+
/**
|
|
60
|
+
* The minimum number of items.
|
|
61
|
+
*
|
|
62
|
+
* @default 1
|
|
63
|
+
*/
|
|
64
|
+
minItems?: number;
|
|
65
|
+
/**
|
|
66
|
+
* The selected number of items to retrieve via the query.
|
|
67
|
+
*/
|
|
68
|
+
numberOfItems?: number;
|
|
69
|
+
/**
|
|
70
|
+
* A function that receives the new author value.
|
|
71
|
+
* If not specified, the author controls are not rendered.
|
|
72
|
+
*/
|
|
73
|
+
onAuthorChange?: AuthorSelectProps[ 'onChange' ];
|
|
74
|
+
/**
|
|
75
|
+
* A function that receives the new number of items.
|
|
76
|
+
* If not specified, then the number of items
|
|
77
|
+
* range control is not rendered.
|
|
78
|
+
*/
|
|
79
|
+
onNumberOfItemsChange?: ( newNumber?: number ) => void;
|
|
80
|
+
/**
|
|
81
|
+
* A function that receives the new order value.
|
|
82
|
+
* If this prop or the `onOrderByChange` prop are not specified,
|
|
83
|
+
* then the order controls are not rendered.
|
|
84
|
+
*/
|
|
85
|
+
onOrderChange?: ( newOrder: Order ) => void;
|
|
86
|
+
/**
|
|
87
|
+
* A function that receives the new orderby value.
|
|
88
|
+
* If this prop or the `onOrderChange` prop are not specified,
|
|
89
|
+
* then the order controls are not rendered.
|
|
90
|
+
*/
|
|
91
|
+
onOrderByChange?: ( newOrderBy: OrderBy ) => void;
|
|
92
|
+
/**
|
|
93
|
+
* The order in which to retrieve posts.
|
|
94
|
+
*/
|
|
95
|
+
order?: Order;
|
|
96
|
+
/**
|
|
97
|
+
* The meta key by which to order posts.
|
|
98
|
+
*/
|
|
99
|
+
orderBy?: OrderBy;
|
|
100
|
+
/**
|
|
101
|
+
* The selected author ID.
|
|
102
|
+
*/
|
|
103
|
+
selectedAuthorId?: AuthorSelectProps[ 'selectedAuthorId' ];
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type QueryControlsWithSingleCategorySelectionProps =
|
|
107
|
+
BaseQueryControlsProps & {
|
|
108
|
+
/**
|
|
109
|
+
* An array of categories. When passed in conjunction with the
|
|
110
|
+
* `onCategoryChange` prop, it causes the component to render UI that allows
|
|
111
|
+
* selecting one category at a time.
|
|
112
|
+
*/
|
|
113
|
+
categoriesList?: CategorySelectProps[ 'categoriesList' ];
|
|
114
|
+
/**
|
|
115
|
+
* The selected category for the `categoriesList` prop.
|
|
116
|
+
*/
|
|
117
|
+
selectedCategoryId?: CategorySelectProps[ 'selectedCategoryId' ];
|
|
118
|
+
/**
|
|
119
|
+
* A function that receives the new category value. If not specified, the
|
|
120
|
+
* category controls are not rendered.
|
|
121
|
+
* The function's signature changes depending on whether multiple category
|
|
122
|
+
* selection is enabled or not.
|
|
123
|
+
*/
|
|
124
|
+
onCategoryChange?: CategorySelectProps[ 'onChange' ];
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export type QueryControlsWithMultipleCategorySelectionProps =
|
|
128
|
+
BaseQueryControlsProps & {
|
|
129
|
+
/**
|
|
130
|
+
* An object of categories with the category name as the key. When passed in
|
|
131
|
+
* conjunction with the `onCategoryChange` prop, it causes the component to
|
|
132
|
+
* render UI that enables multiple selection.
|
|
133
|
+
*/
|
|
134
|
+
categorySuggestions?: Record< Category[ 'name' ], Category >;
|
|
135
|
+
/**
|
|
136
|
+
* The selected categories for the `categorySuggestions` prop.
|
|
137
|
+
*/
|
|
138
|
+
selectedCategories?: Category[];
|
|
139
|
+
/**
|
|
140
|
+
* A function that receives the new category value. If not specified, the
|
|
141
|
+
* category controls are not rendered.
|
|
142
|
+
* The function's signature changes depending on whether multiple category
|
|
143
|
+
* selection is enabled or not.
|
|
144
|
+
*/
|
|
145
|
+
onCategoryChange?: FormTokenFieldProps[ 'onChange' ];
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export type QueryControlsProps =
|
|
149
|
+
| QueryControlsWithSingleCategorySelectionProps
|
|
150
|
+
| QueryControlsWithMultipleCategorySelectionProps;
|
|
@@ -38,8 +38,8 @@ const Edit = ( props ) => {
|
|
|
38
38
|
} }
|
|
39
39
|
onResizeStop={ ( event, direction, elt, delta ) => {
|
|
40
40
|
setAttributes( {
|
|
41
|
-
height:
|
|
42
|
-
width:
|
|
41
|
+
height: height + delta.height,
|
|
42
|
+
width: width + delta.width,
|
|
43
43
|
} );
|
|
44
44
|
toggleSelection( true );
|
|
45
45
|
} }
|
|
@@ -88,14 +88,13 @@ const HANDLE_STYLES = {
|
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
type ResizableBoxProps = ResizableProps & {
|
|
91
|
-
className: string;
|
|
92
91
|
children: ReactNode;
|
|
93
|
-
showHandle
|
|
94
|
-
__experimentalShowTooltip
|
|
95
|
-
__experimentalTooltipProps
|
|
92
|
+
showHandle?: boolean;
|
|
93
|
+
__experimentalShowTooltip?: boolean;
|
|
94
|
+
__experimentalTooltipProps?: Parameters< typeof ResizeTooltip >[ 0 ];
|
|
96
95
|
};
|
|
97
96
|
|
|
98
|
-
function
|
|
97
|
+
function UnforwardedResizableBox(
|
|
99
98
|
{
|
|
100
99
|
className,
|
|
101
100
|
children,
|
|
@@ -124,4 +123,6 @@ function ResizableBox(
|
|
|
124
123
|
);
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
export
|
|
126
|
+
export const ResizableBox = forwardRef( UnforwardedResizableBox );
|
|
127
|
+
|
|
128
|
+
export default ResizableBox;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import ResizableBox from '..';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* WordPress dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { useState } from '@wordpress/element';
|
|
15
|
+
|
|
16
|
+
const meta: ComponentMeta< typeof ResizableBox > = {
|
|
17
|
+
title: 'Components/ResizableBox',
|
|
18
|
+
component: ResizableBox,
|
|
19
|
+
argTypes: {
|
|
20
|
+
children: { control: { type: null } },
|
|
21
|
+
enable: { control: 'object' },
|
|
22
|
+
onResizeStop: { action: 'onResizeStop' },
|
|
23
|
+
},
|
|
24
|
+
parameters: {
|
|
25
|
+
controls: { expanded: true },
|
|
26
|
+
docs: { source: { state: 'open' } },
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export default meta;
|
|
30
|
+
|
|
31
|
+
const Template: ComponentStory< typeof ResizableBox > = ( {
|
|
32
|
+
onResizeStop,
|
|
33
|
+
...props
|
|
34
|
+
} ) => {
|
|
35
|
+
const [ { height, width }, setAttributes ] = useState( {
|
|
36
|
+
height: 200,
|
|
37
|
+
width: 400,
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<ResizableBox
|
|
42
|
+
{ ...props }
|
|
43
|
+
size={ {
|
|
44
|
+
height,
|
|
45
|
+
width,
|
|
46
|
+
} }
|
|
47
|
+
onResizeStop={ ( event, direction, elt, delta ) => {
|
|
48
|
+
onResizeStop?.( event, direction, elt, delta );
|
|
49
|
+
setAttributes( {
|
|
50
|
+
height: height + delta.height,
|
|
51
|
+
width: width + delta.width,
|
|
52
|
+
} );
|
|
53
|
+
} }
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const Default = Template.bind( {} );
|
|
59
|
+
Default.args = {
|
|
60
|
+
children: (
|
|
61
|
+
<div
|
|
62
|
+
style={ {
|
|
63
|
+
background: '#eee',
|
|
64
|
+
display: 'flex',
|
|
65
|
+
height: '100%',
|
|
66
|
+
width: '100%',
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
justifyContent: 'center',
|
|
69
|
+
} }
|
|
70
|
+
>
|
|
71
|
+
Resize
|
|
72
|
+
</div>
|
|
73
|
+
),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The `enable` prop can be used to disable resizing in specific directions.
|
|
78
|
+
*/
|
|
79
|
+
export const DisabledDirections = Template.bind( {} );
|
|
80
|
+
DisabledDirections.args = {
|
|
81
|
+
...Default.args,
|
|
82
|
+
enable: {
|
|
83
|
+
top: false,
|
|
84
|
+
right: true,
|
|
85
|
+
bottom: true,
|
|
86
|
+
left: false,
|
|
87
|
+
topRight: false,
|
|
88
|
+
bottomRight: true,
|
|
89
|
+
bottomLeft: false,
|
|
90
|
+
topLeft: false,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# ResponsiveWrapper
|
|
2
2
|
|
|
3
|
+
A wrapper component that maintains its aspect ratio when resized.
|
|
4
|
+
|
|
3
5
|
## Usage
|
|
4
6
|
|
|
5
7
|
```jsx
|
|
@@ -14,3 +16,30 @@ const MyResponsiveWrapper = () => (
|
|
|
14
16
|
</ResponsiveWrapper>
|
|
15
17
|
);
|
|
16
18
|
```
|
|
19
|
+
|
|
20
|
+
## Props
|
|
21
|
+
|
|
22
|
+
### `children`: `React.ReactElement`
|
|
23
|
+
|
|
24
|
+
The element to wrap.
|
|
25
|
+
|
|
26
|
+
- Required: Yes
|
|
27
|
+
|
|
28
|
+
### `isInline`: `boolean`
|
|
29
|
+
|
|
30
|
+
If true, the wrapper will be `span` instead of `div`.
|
|
31
|
+
|
|
32
|
+
- Required: No
|
|
33
|
+
- Default: `false`
|
|
34
|
+
|
|
35
|
+
### `naturalHeight`: `number`
|
|
36
|
+
|
|
37
|
+
The intrinsic height of the element to wrap. Will be used to determine the aspect ratio.
|
|
38
|
+
|
|
39
|
+
- Required: Yes
|
|
40
|
+
|
|
41
|
+
### `naturalWidth`: `number`
|
|
42
|
+
|
|
43
|
+
The intrinsic width of the element to wrap. Will be used to determine the aspect ratio.
|
|
44
|
+
|
|
45
|
+
- Required: Yes
|
|
@@ -9,12 +9,33 @@ import classnames from 'classnames';
|
|
|
9
9
|
import { cloneElement, Children } from '@wordpress/element';
|
|
10
10
|
import { useResizeObserver } from '@wordpress/compose';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import type { ResponsiveWrapperProps } from './types';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A wrapper component that maintains its aspect ratio when resized.
|
|
19
|
+
*
|
|
20
|
+
* ```jsx
|
|
21
|
+
* import { ResponsiveWrapper } from '@wordpress/components';
|
|
22
|
+
*
|
|
23
|
+
* const MyResponsiveWrapper = () => (
|
|
24
|
+
* <ResponsiveWrapper naturalWidth={ 2000 } naturalHeight={ 680 }>
|
|
25
|
+
* <img
|
|
26
|
+
* src="https://s.w.org/style/images/about/WordPress-logotype-standard.png"
|
|
27
|
+
* alt="WordPress"
|
|
28
|
+
* />
|
|
29
|
+
* </ResponsiveWrapper>
|
|
30
|
+
* );
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
12
33
|
function ResponsiveWrapper( {
|
|
13
34
|
naturalWidth,
|
|
14
35
|
naturalHeight,
|
|
15
36
|
children,
|
|
16
37
|
isInline = false,
|
|
17
|
-
} ) {
|
|
38
|
+
}: ResponsiveWrapperProps ) {
|
|
18
39
|
const [ containerResizeListener, { width: containerWidth } ] =
|
|
19
40
|
useResizeObserver();
|
|
20
41
|
if ( Children.count( children ) !== 1 ) {
|
|
@@ -22,7 +43,7 @@ function ResponsiveWrapper( {
|
|
|
22
43
|
}
|
|
23
44
|
const imageStyle = {
|
|
24
45
|
paddingBottom:
|
|
25
|
-
naturalWidth < containerWidth
|
|
46
|
+
naturalWidth < ( containerWidth ?? 0 )
|
|
26
47
|
? naturalHeight
|
|
27
48
|
: ( naturalHeight / naturalWidth ) * 100 + '%',
|
|
28
49
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import ResponsiveWrapper from '..';
|
|
10
|
+
|
|
11
|
+
const meta: ComponentMeta< typeof ResponsiveWrapper > = {
|
|
12
|
+
component: ResponsiveWrapper,
|
|
13
|
+
title: 'Components/ResponsiveWrapper',
|
|
14
|
+
argTypes: {
|
|
15
|
+
children: { control: { type: null } },
|
|
16
|
+
},
|
|
17
|
+
parameters: {
|
|
18
|
+
controls: { expanded: true },
|
|
19
|
+
docs: { source: { state: 'open' } },
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export default meta;
|
|
23
|
+
|
|
24
|
+
const Template: ComponentStory< typeof ResponsiveWrapper > = ( args ) => (
|
|
25
|
+
<ResponsiveWrapper { ...args } />
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export const Default = Template.bind( {} );
|
|
29
|
+
Default.args = {
|
|
30
|
+
naturalWidth: 2000,
|
|
31
|
+
naturalHeight: 680,
|
|
32
|
+
children: (
|
|
33
|
+
<img
|
|
34
|
+
src="https://s.w.org/style/images/about/WordPress-logotype-standard.png"
|
|
35
|
+
alt="WordPress"
|
|
36
|
+
/>
|
|
37
|
+
),
|
|
38
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ResponsiveWrapperProps = {
|
|
2
|
+
/**
|
|
3
|
+
* The intrinsic width of the element to wrap. Will be used to determine the aspect ratio.
|
|
4
|
+
*/
|
|
5
|
+
naturalWidth: number;
|
|
6
|
+
/**
|
|
7
|
+
* The intrinsic height of the element to wrap. Will be used to determine the aspect ratio.
|
|
8
|
+
*/
|
|
9
|
+
naturalHeight: number;
|
|
10
|
+
/**
|
|
11
|
+
* The element to wrap.
|
|
12
|
+
*/
|
|
13
|
+
children: React.ReactElement;
|
|
14
|
+
/**
|
|
15
|
+
* If true, the wrapper will be `span` instead of `div`.
|
|
16
|
+
*
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
isInline?: boolean;
|
|
20
|
+
};
|
package/src/sandbox/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SandBox
|
|
2
2
|
|
|
3
3
|
This component provides an isolated environment for arbitrary HTML via iframes.
|
|
4
4
|
|
|
@@ -8,6 +8,49 @@ This component provides an isolated environment for arbitrary HTML via iframes.
|
|
|
8
8
|
import { SandBox } from '@wordpress/components';
|
|
9
9
|
|
|
10
10
|
const MySandBox = () => (
|
|
11
|
-
<SandBox html="<p>Content</p>" title="
|
|
11
|
+
<SandBox html="<p>Content</p>" title="SandBox" type="embed" />
|
|
12
12
|
);
|
|
13
13
|
```
|
|
14
|
+
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
### `html`: `string`
|
|
18
|
+
|
|
19
|
+
The HTML to render in the body of the iframe document.
|
|
20
|
+
|
|
21
|
+
- Required: No
|
|
22
|
+
- Default: ""
|
|
23
|
+
|
|
24
|
+
### `onFocus`: `React.DOMAttributes< HTMLIFrameElement >[ 'onFocus' ]`
|
|
25
|
+
|
|
26
|
+
The `onFocus` callback for the iframe.
|
|
27
|
+
|
|
28
|
+
- Required: No
|
|
29
|
+
|
|
30
|
+
### `scripts`: `string[]`
|
|
31
|
+
|
|
32
|
+
An array of script URLs to inject as `<script>` tags into the bottom of the `<body>` of the iframe document.
|
|
33
|
+
|
|
34
|
+
- Required: No
|
|
35
|
+
- Default: []
|
|
36
|
+
|
|
37
|
+
### `styles`: `string[]`
|
|
38
|
+
|
|
39
|
+
An array of CSS strings to inject into the `<head>` of the iframe document.
|
|
40
|
+
|
|
41
|
+
- Required: No
|
|
42
|
+
- Default: []
|
|
43
|
+
|
|
44
|
+
### `title`: `string`
|
|
45
|
+
|
|
46
|
+
The `<title>` of the iframe document.
|
|
47
|
+
|
|
48
|
+
- Required: No
|
|
49
|
+
- Default: ""
|
|
50
|
+
|
|
51
|
+
### `type`: `string`
|
|
52
|
+
|
|
53
|
+
The CSS class name to apply to the `<html>` and `<body>` elements of the iframe.
|
|
54
|
+
|
|
55
|
+
- Required: No
|
|
56
|
+
- Default: ""
|