@wordpress/components 23.3.2 → 23.4.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 +20 -5
- package/build/alignment-matrix-control/utils.js +4 -4
- package/build/alignment-matrix-control/utils.js.map +1 -1
- package/build/angle-picker-control/angle-circle.js +37 -29
- package/build/angle-picker-control/angle-circle.js.map +1 -1
- package/build/angle-picker-control/index.js +44 -9
- package/build/angle-picker-control/index.js.map +1 -1
- package/build/angle-picker-control/styles/angle-picker-control-styles.js +13 -13
- package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
- package/build/{base-field → angle-picker-control}/types.js +0 -0
- package/build/angle-picker-control/types.js.map +1 -0
- package/build/autocomplete/autocompleter-ui.native.js +1 -0
- package/build/autocomplete/autocompleter-ui.native.js.map +1 -1
- package/build/base-control/hooks.js +1 -1
- package/build/base-control/hooks.js.map +1 -1
- package/build/border-box-control/utils.js +1 -1
- package/build/border-box-control/utils.js.map +1 -1
- package/build/box-control/all-input-control.js +2 -2
- package/build/box-control/all-input-control.js.map +1 -1
- package/build/box-control/axial-input-controls.js +1 -1
- package/build/box-control/axial-input-controls.js.map +1 -1
- package/build/box-control/icon.js.map +1 -1
- package/build/box-control/index.js +32 -3
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/input-controls.js +5 -5
- package/build/box-control/input-controls.js.map +1 -1
- package/build/box-control/linked-button.js.map +1 -1
- package/build/box-control/styles/box-control-icon-styles.js +28 -28
- package/build/box-control/styles/box-control-icon-styles.js.map +1 -1
- package/build/box-control/styles/box-control-styles.js +23 -23
- package/build/box-control/styles/box-control-styles.js.map +1 -1
- package/build/box-control/styles/box-control-visualizer-styles.js +19 -19
- package/build/box-control/styles/box-control-visualizer-styles.js.map +1 -1
- package/build/box-control/types.js +6 -0
- package/build/box-control/types.js.map +1 -0
- package/build/box-control/unit-control.js.map +1 -1
- package/build/box-control/utils.js +23 -23
- package/build/box-control/utils.js.map +1 -1
- package/build/color-palette/index.js +8 -3
- package/build/color-palette/index.js.map +1 -1
- package/build/combobox-control/index.js +68 -12
- package/build/combobox-control/index.js.map +1 -1
- package/build/combobox-control/styles.js +2 -2
- package/build/combobox-control/styles.js.map +1 -1
- package/build/combobox-control/types.js +6 -0
- package/build/combobox-control/types.js.map +1 -0
- package/build/custom-gradient-picker/index.js +0 -1
- package/build/custom-gradient-picker/index.js.map +1 -1
- package/build/date-time/time/index.js +1 -1
- package/build/date-time/time/index.js.map +1 -1
- package/build/date-time/utils.js +1 -1
- package/build/date-time/utils.js.map +1 -1
- package/build/draggable/index.js +2 -2
- package/build/draggable/index.js.map +1 -1
- package/build/focal-point-picker/utils.js +3 -3
- package/build/focal-point-picker/utils.js.map +1 -1
- package/build/font-size-picker/utils.js +2 -2
- package/build/font-size-picker/utils.js.map +1 -1
- package/build/gradient-picker/index.js +9 -4
- package/build/gradient-picker/index.js.map +1 -1
- package/build/input-control/reducer/reducer.js +5 -5
- package/build/input-control/reducer/reducer.js.map +1 -1
- package/build/input-control/utils.js +1 -1
- package/build/input-control/utils.js.map +1 -1
- package/build/menu-items-choice/index.js +40 -3
- package/build/menu-items-choice/index.js.map +1 -1
- package/build/menu-items-choice/types.js +6 -0
- package/build/menu-items-choice/types.js.map +1 -0
- package/build/modal/index.js +41 -3
- package/build/modal/index.js.map +1 -1
- package/build/palette-edit/index.js +4 -1
- package/build/palette-edit/index.js.map +1 -1
- package/build/panel/header.js +9 -0
- package/build/panel/header.js.map +1 -1
- package/build/panel/index.js +21 -3
- package/build/panel/index.js.map +1 -1
- package/build/panel/row.js +10 -4
- package/build/panel/row.js.map +1 -1
- package/build/panel/types.js +6 -0
- package/build/panel/types.js.map +1 -0
- package/build/popover/index.js +15 -3
- package/build/popover/index.js.map +1 -1
- package/build/popover/overlay-middlewares.js +46 -0
- package/build/popover/overlay-middlewares.js.map +1 -0
- package/build/popover/utils.js +45 -6
- package/build/popover/utils.js.map +1 -1
- package/build/query-controls/terms.js +1 -1
- package/build/query-controls/terms.js.map +1 -1
- package/build/range-control/utils.js +4 -4
- package/build/range-control/utils.js.map +1 -1
- package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +12 -12
- package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
- package/build/resizable-box/resize-tooltip/utils.js +14 -14
- package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build/snackbar/index.js +2 -2
- package/build/snackbar/index.js.map +1 -1
- package/build/toolbar/toolbar/index.js +25 -14
- package/build/toolbar/toolbar/index.js.map +1 -1
- package/build/toolbar/toolbar/toolbar-container.js +5 -4
- package/build/toolbar/toolbar/toolbar-container.js.map +1 -1
- package/build/toolbar/toolbar/types.js +6 -0
- package/build/toolbar/toolbar/types.js.map +1 -0
- package/build/toolbar/toolbar-button/index.js +2 -0
- package/build/toolbar/toolbar-button/index.js.map +1 -1
- package/build/toolbar/toolbar-button/toolbar-button-container.js +1 -0
- package/build/toolbar/toolbar-button/toolbar-button-container.js.map +1 -1
- package/build/toolbar/toolbar-context/index.js +2 -0
- package/build/toolbar/toolbar-context/index.js.map +1 -1
- package/build/toolbar/toolbar-dropdown-menu/index.js +2 -0
- package/build/toolbar/toolbar-dropdown-menu/index.js.map +1 -1
- package/build/toolbar/toolbar-group/index.js +2 -0
- package/build/toolbar/toolbar-group/index.js.map +1 -1
- package/build/toolbar/toolbar-group/toolbar-group-collapsed.js +2 -0
- package/build/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -1
- package/build/toolbar/toolbar-group/toolbar-group-container.js +1 -0
- package/build/toolbar/toolbar-group/toolbar-group-container.js.map +1 -1
- package/build/toolbar/toolbar-item/index.js +2 -0
- package/build/toolbar/toolbar-item/index.js.map +1 -1
- package/build/tools-panel/tools-panel/component.js +61 -5
- package/build/tools-panel/tools-panel/component.js.map +1 -1
- package/build/tools-panel/tools-panel/hook.js +4 -2
- package/build/tools-panel/tools-panel/hook.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +2 -1
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/tools-panel/tools-panel-header/hook.js +2 -0
- package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
- package/build/tools-panel/tools-panel-item/component.js +5 -4
- package/build/tools-panel/tools-panel-item/component.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +4 -2
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/tree-grid/cell.js +15 -4
- package/build/tree-grid/cell.js.map +1 -1
- package/build/tree-grid/index.js +81 -19
- package/build/tree-grid/index.js.map +1 -1
- package/build/tree-grid/item.js +14 -3
- package/build/tree-grid/item.js.map +1 -1
- package/build/tree-grid/roving-tab-index-context.js +1 -1
- package/build/tree-grid/roving-tab-index-context.js.map +1 -1
- package/build/tree-grid/roving-tab-index-item.js +13 -6
- package/build/tree-grid/roving-tab-index-item.js.map +1 -1
- package/build/tree-grid/roving-tab-index.js +0 -3
- package/build/tree-grid/roving-tab-index.js.map +1 -1
- package/build/tree-grid/row.js +20 -18
- package/build/tree-grid/row.js.map +1 -1
- package/build/tree-grid/types.js +6 -0
- package/build/tree-grid/types.js.map +1 -0
- package/build/ui/context/context-connect.js +7 -7
- package/build/ui/context/context-connect.js.map +1 -1
- package/build/ui/context/get-styled-class-name-from-key.js +1 -1
- package/build/ui/context/get-styled-class-name-from-key.js.map +1 -1
- package/build/ui/utils/get-valid-children.js +1 -1
- package/build/ui/utils/get-valid-children.js.map +1 -1
- package/build/ui/utils/space.js +1 -1
- package/build/ui/utils/space.js.map +1 -1
- package/build/unit-control/index.js +2 -2
- package/build/unit-control/index.js.map +1 -1
- package/build/unit-control/utils.js +20 -20
- package/build/unit-control/utils.js.map +1 -1
- package/build/utils/events.js +4 -4
- package/build/utils/events.js.map +1 -1
- package/build/utils/hooks/use-controlled-state.js +2 -2
- package/build/utils/hooks/use-controlled-state.js.map +1 -1
- package/build/utils/hooks/use-controlled-value.js +4 -4
- package/build/utils/hooks/use-controlled-value.js.map +1 -1
- package/build/utils/hooks/use-latest-ref.js +1 -1
- package/build/utils/hooks/use-latest-ref.js.map +1 -1
- package/build/utils/unit-values.js +3 -3
- package/build/utils/unit-values.js.map +1 -1
- package/build-module/alignment-matrix-control/utils.js +4 -4
- package/build-module/alignment-matrix-control/utils.js.map +1 -1
- package/build-module/angle-picker-control/angle-circle.js +37 -29
- package/build-module/angle-picker-control/angle-circle.js.map +1 -1
- package/build-module/angle-picker-control/index.js +42 -8
- package/build-module/angle-picker-control/index.js.map +1 -1
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +13 -13
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
- package/build-module/{base-field → angle-picker-control}/types.js +0 -0
- package/build-module/{base-field → angle-picker-control}/types.js.map +0 -0
- package/build-module/autocomplete/autocompleter-ui.native.js +1 -0
- package/build-module/autocomplete/autocompleter-ui.native.js.map +1 -1
- package/build-module/base-control/hooks.js +1 -1
- package/build-module/base-control/hooks.js.map +1 -1
- package/build-module/border-box-control/utils.js +1 -1
- package/build-module/border-box-control/utils.js.map +1 -1
- package/build-module/box-control/all-input-control.js +2 -2
- package/build-module/box-control/all-input-control.js.map +1 -1
- package/build-module/box-control/axial-input-controls.js +1 -1
- package/build-module/box-control/axial-input-controls.js.map +1 -1
- package/build-module/box-control/icon.js.map +1 -1
- package/build-module/box-control/index.js +31 -3
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/input-controls.js +5 -5
- package/build-module/box-control/input-controls.js.map +1 -1
- package/build-module/box-control/linked-button.js.map +1 -1
- package/build-module/box-control/styles/box-control-icon-styles.js +28 -28
- package/build-module/box-control/styles/box-control-icon-styles.js.map +1 -1
- package/build-module/box-control/styles/box-control-styles.js +23 -23
- package/build-module/box-control/styles/box-control-styles.js.map +1 -1
- package/build-module/box-control/styles/box-control-visualizer-styles.js +19 -19
- package/build-module/box-control/styles/box-control-visualizer-styles.js.map +1 -1
- package/build-module/box-control/types.js +2 -0
- package/{build/base-field → build-module/box-control}/types.js.map +0 -0
- package/build-module/box-control/unit-control.js.map +1 -1
- package/build-module/box-control/utils.js +23 -23
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/color-palette/index.js +8 -3
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/combobox-control/index.js +68 -12
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/combobox-control/styles.js +2 -2
- package/build-module/combobox-control/styles.js.map +1 -1
- package/build-module/combobox-control/types.js +2 -0
- package/build-module/{resizable-box/styles/resizable-box.styles.js.map → combobox-control/types.js.map} +0 -0
- package/build-module/custom-gradient-picker/index.js +0 -1
- package/build-module/custom-gradient-picker/index.js.map +1 -1
- package/build-module/date-time/time/index.js +1 -1
- package/build-module/date-time/time/index.js.map +1 -1
- package/build-module/date-time/utils.js +1 -1
- package/build-module/date-time/utils.js.map +1 -1
- package/build-module/draggable/index.js +2 -2
- package/build-module/draggable/index.js.map +1 -1
- package/build-module/focal-point-picker/utils.js +3 -3
- package/build-module/focal-point-picker/utils.js.map +1 -1
- package/build-module/font-size-picker/utils.js +2 -2
- package/build-module/font-size-picker/utils.js.map +1 -1
- package/build-module/gradient-picker/index.js +9 -4
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/input-control/reducer/reducer.js +5 -5
- package/build-module/input-control/reducer/reducer.js.map +1 -1
- package/build-module/input-control/utils.js +1 -1
- package/build-module/input-control/utils.js.map +1 -1
- package/build-module/menu-items-choice/index.js +40 -4
- package/build-module/menu-items-choice/index.js.map +1 -1
- package/build-module/menu-items-choice/types.js +2 -0
- package/{build/resizable-box/styles/resizable-box.styles.js.map → build-module/menu-items-choice/types.js.map} +0 -0
- package/build-module/modal/index.js +41 -4
- package/build-module/modal/index.js.map +1 -1
- package/build-module/palette-edit/index.js +4 -1
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/panel/header.js +9 -0
- package/build-module/panel/header.js.map +1 -1
- package/build-module/panel/index.js +20 -2
- package/build-module/panel/index.js.map +1 -1
- package/build-module/panel/row.js +9 -3
- package/build-module/panel/row.js.map +1 -1
- package/build-module/panel/types.js +2 -0
- package/build-module/panel/types.js.map +1 -0
- package/build-module/popover/index.js +14 -4
- package/build-module/popover/index.js.map +1 -1
- package/build-module/popover/overlay-middlewares.js +38 -0
- package/build-module/popover/overlay-middlewares.js.map +1 -0
- package/build-module/popover/utils.js +41 -5
- package/build-module/popover/utils.js.map +1 -1
- package/build-module/query-controls/terms.js +1 -1
- package/build-module/query-controls/terms.js.map +1 -1
- package/build-module/range-control/utils.js +4 -4
- package/build-module/range-control/utils.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +12 -12
- package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/utils.js +14 -14
- package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build-module/snackbar/index.js +2 -2
- package/build-module/snackbar/index.js.map +1 -1
- package/build-module/toolbar/toolbar/index.js +25 -13
- package/build-module/toolbar/toolbar/index.js.map +1 -1
- package/build-module/toolbar/toolbar/toolbar-container.js +4 -3
- package/build-module/toolbar/toolbar/toolbar-container.js.map +1 -1
- package/build-module/toolbar/toolbar/types.js +2 -0
- package/build-module/toolbar/toolbar/types.js.map +1 -0
- package/build-module/toolbar/toolbar-button/index.js +1 -0
- package/build-module/toolbar/toolbar-button/index.js.map +1 -1
- package/build-module/toolbar/toolbar-button/toolbar-button-container.js +1 -0
- package/build-module/toolbar/toolbar-button/toolbar-button-container.js.map +1 -1
- package/build-module/toolbar/toolbar-context/index.js +2 -0
- package/build-module/toolbar/toolbar-context/index.js.map +1 -1
- package/build-module/toolbar/toolbar-dropdown-menu/index.js +1 -0
- package/build-module/toolbar/toolbar-dropdown-menu/index.js.map +1 -1
- package/build-module/toolbar/toolbar-group/index.js +1 -0
- package/build-module/toolbar/toolbar-group/index.js.map +1 -1
- package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js +1 -0
- package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -1
- package/build-module/toolbar/toolbar-group/toolbar-group-container.js +1 -0
- package/build-module/toolbar/toolbar-group/toolbar-group-container.js.map +1 -1
- package/build-module/toolbar/toolbar-item/index.js +1 -0
- package/build-module/toolbar/toolbar-item/index.js.map +1 -1
- package/build-module/tools-panel/tools-panel/component.js +59 -4
- package/build-module/tools-panel/tools-panel/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel/hook.js +4 -2
- package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +2 -1
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/hook.js +2 -0
- package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/component.js +3 -3
- package/build-module/tools-panel/tools-panel-item/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +5 -2
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/tree-grid/cell.js +16 -4
- package/build-module/tree-grid/cell.js.map +1 -1
- package/build-module/tree-grid/index.js +81 -21
- package/build-module/tree-grid/index.js.map +1 -1
- package/build-module/tree-grid/item.js +14 -2
- package/build-module/tree-grid/item.js.map +1 -1
- package/build-module/tree-grid/roving-tab-index-context.js +1 -1
- package/build-module/tree-grid/roving-tab-index-context.js.map +1 -1
- package/build-module/tree-grid/roving-tab-index-item.js +11 -4
- package/build-module/tree-grid/roving-tab-index-item.js.map +1 -1
- package/build-module/tree-grid/roving-tab-index.js +0 -3
- package/build-module/tree-grid/roving-tab-index.js.map +1 -1
- package/build-module/tree-grid/row.js +22 -17
- package/build-module/tree-grid/row.js.map +1 -1
- package/build-module/tree-grid/types.js +2 -0
- package/build-module/tree-grid/types.js.map +1 -0
- package/build-module/ui/context/context-connect.js +7 -7
- package/build-module/ui/context/context-connect.js.map +1 -1
- package/build-module/ui/context/get-styled-class-name-from-key.js +1 -1
- package/build-module/ui/context/get-styled-class-name-from-key.js.map +1 -1
- package/build-module/ui/utils/get-valid-children.js +1 -1
- package/build-module/ui/utils/get-valid-children.js.map +1 -1
- package/build-module/ui/utils/space.js +1 -1
- package/build-module/ui/utils/space.js.map +1 -1
- package/build-module/unit-control/index.js +2 -2
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/unit-control/utils.js +20 -20
- package/build-module/unit-control/utils.js.map +1 -1
- package/build-module/utils/events.js +4 -4
- package/build-module/utils/events.js.map +1 -1
- package/build-module/utils/hooks/use-controlled-state.js +2 -2
- package/build-module/utils/hooks/use-controlled-state.js.map +1 -1
- package/build-module/utils/hooks/use-controlled-value.js +4 -4
- package/build-module/utils/hooks/use-controlled-value.js.map +1 -1
- package/build-module/utils/hooks/use-latest-ref.js +1 -1
- package/build-module/utils/hooks/use-latest-ref.js.map +1 -1
- package/build-module/utils/unit-values.js +3 -3
- package/build-module/utils/unit-values.js.map +1 -1
- package/build-style/style-rtl.css +5 -0
- package/build-style/style.css +5 -0
- package/build-types/alignment-matrix-control/utils.d.ts +4 -4
- package/build-types/angle-picker-control/angle-circle.d.ts +6 -0
- package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -0
- package/build-types/angle-picker-control/index.d.ts +29 -0
- package/build-types/angle-picker-control/index.d.ts.map +1 -0
- package/build-types/angle-picker-control/stories/index.d.ts +15 -0
- package/build-types/angle-picker-control/stories/index.d.ts.map +1 -0
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +20 -0
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +1 -0
- package/build-types/angle-picker-control/types.d.ts +26 -0
- package/build-types/angle-picker-control/types.d.ts.map +1 -0
- package/build-types/base-control/hooks.d.ts +1 -1
- package/build-types/border-box-control/border-box-control/component.d.ts +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -1
- package/build-types/border-box-control/stories/index.d.ts +1 -1
- package/build-types/{base-field → border-box-control}/test/index.d.ts +0 -0
- package/build-types/border-box-control/test/index.d.ts.map +1 -0
- package/build-types/border-box-control/test/utils.d.ts +2 -0
- package/build-types/border-box-control/test/utils.d.ts.map +1 -0
- package/build-types/box-control/all-input-control.d.ts +4 -0
- package/build-types/box-control/all-input-control.d.ts.map +1 -0
- package/build-types/box-control/axial-input-controls.d.ts +4 -0
- package/build-types/box-control/axial-input-controls.d.ts.map +1 -0
- package/build-types/box-control/icon.d.ts +8 -0
- package/build-types/box-control/icon.d.ts.map +1 -0
- package/build-types/box-control/index.d.ts +31 -0
- package/build-types/box-control/index.d.ts.map +1 -0
- package/build-types/box-control/input-controls.d.ts +4 -0
- package/build-types/box-control/input-controls.d.ts.map +1 -0
- package/build-types/box-control/linked-button.d.ts +9 -0
- package/build-types/box-control/linked-button.d.ts.map +1 -0
- package/build-types/box-control/styles/box-control-icon-styles.d.ts +42 -0
- package/build-types/box-control/styles/box-control-icon-styles.d.ts.map +1 -0
- package/build-types/box-control/styles/box-control-styles.d.ts +42 -0
- package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -0
- package/build-types/box-control/styles/box-control-visualizer-styles.d.ts +46 -0
- package/build-types/box-control/styles/box-control-visualizer-styles.d.ts.map +1 -0
- package/build-types/box-control/test/index.d.ts +2 -0
- package/build-types/box-control/test/index.d.ts.map +1 -0
- package/build-types/box-control/types.d.ts +99 -0
- package/build-types/box-control/types.d.ts.map +1 -0
- package/build-types/box-control/unit-control.d.ts +4 -0
- package/build-types/box-control/unit-control.d.ts.map +1 -0
- package/build-types/box-control/utils.d.ts +84 -0
- package/build-types/box-control/utils.d.ts.map +1 -0
- package/build-types/color-palette/index.d.ts +3 -1
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.d.ts +6 -2
- package/build-types/color-palette/stories/index.d.ts.map +1 -1
- package/build-types/color-palette/types.d.ts +8 -0
- package/build-types/color-palette/types.d.ts.map +1 -1
- package/build-types/combobox-control/index.d.ts +51 -0
- package/build-types/combobox-control/index.d.ts.map +1 -0
- package/build-types/combobox-control/stories/index.d.ts +18 -0
- package/build-types/combobox-control/stories/index.d.ts.map +1 -0
- package/build-types/combobox-control/styles.d.ts +8 -0
- package/build-types/combobox-control/styles.d.ts.map +1 -0
- package/build-types/combobox-control/test/index.d.ts +2 -0
- package/build-types/combobox-control/test/index.d.ts.map +1 -0
- package/build-types/combobox-control/types.d.ts +62 -0
- package/build-types/combobox-control/types.d.ts.map +1 -0
- package/build-types/date-time/utils.d.ts +1 -1
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
- package/build-types/focal-point-picker/utils.d.ts +3 -3
- package/build-types/font-size-picker/utils.d.ts +2 -2
- package/build-types/input-control/reducer/reducer.d.ts +3 -3
- package/build-types/input-control/utils.d.ts +1 -1
- package/build-types/menu-items-choice/index.d.ts +38 -0
- package/build-types/menu-items-choice/index.d.ts.map +1 -0
- package/build-types/menu-items-choice/stories/index.d.ts +12 -0
- package/build-types/menu-items-choice/stories/index.d.ts.map +1 -0
- package/build-types/menu-items-choice/types.d.ts +53 -0
- package/build-types/menu-items-choice/types.d.ts.map +1 -0
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/modal/types.d.ts +2 -0
- package/build-types/modal/types.d.ts.map +1 -1
- package/build-types/panel/header.d.ts +13 -0
- package/build-types/panel/header.d.ts.map +1 -0
- package/build-types/panel/index.d.ts +21 -0
- package/build-types/panel/index.d.ts.map +1 -0
- package/build-types/panel/row.d.ts +12 -0
- package/build-types/panel/row.d.ts.map +1 -0
- package/build-types/panel/test/header.d.ts +2 -0
- package/build-types/panel/test/header.d.ts.map +1 -0
- package/build-types/panel/test/index.d.ts +2 -0
- package/build-types/{base-field → panel}/test/index.d.ts.map +1 -1
- package/build-types/panel/test/row.d.ts +2 -0
- package/build-types/panel/test/row.d.ts.map +1 -0
- package/build-types/panel/types.d.ts +38 -0
- package/build-types/panel/types.d.ts.map +1 -0
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/overlay-middlewares.d.ts +9 -0
- package/build-types/popover/overlay-middlewares.d.ts.map +1 -0
- package/build-types/popover/stories/index.d.ts.map +1 -1
- package/build-types/popover/types.d.ts +3 -2
- package/build-types/popover/types.d.ts.map +1 -1
- package/build-types/popover/utils.d.ts +12 -4
- package/build-types/popover/utils.d.ts.map +1 -1
- package/build-types/query-controls/terms.d.ts +1 -1
- package/build-types/range-control/utils.d.ts +4 -4
- package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts +5 -4
- package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts +6 -6
- package/build-types/toolbar/index.d.ts +7 -0
- package/build-types/toolbar/index.d.ts.map +1 -0
- package/build-types/toolbar/stories/index.d.ts +14 -0
- package/build-types/toolbar/stories/index.d.ts.map +1 -0
- package/build-types/toolbar/test/index.d.ts +2 -0
- package/build-types/toolbar/test/index.d.ts.map +1 -0
- package/build-types/toolbar/test/toolbar-group.d.ts +2 -0
- package/build-types/toolbar/test/toolbar-group.d.ts.map +1 -0
- package/build-types/toolbar/toolbar/index.d.ts +25 -0
- package/build-types/toolbar/toolbar/index.d.ts.map +1 -0
- package/build-types/toolbar/toolbar/toolbar-container.d.ts +5 -0
- package/build-types/toolbar/toolbar/toolbar-container.d.ts.map +1 -0
- package/build-types/toolbar/toolbar/types.d.ts +15 -0
- package/build-types/toolbar/toolbar/types.d.ts.map +1 -0
- package/build-types/toolbar/toolbar-button/index.d.ts +12 -0
- package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -0
- package/build-types/toolbar/toolbar-button/toolbar-button-container.d.ts +3 -0
- package/build-types/toolbar/toolbar-button/toolbar-button-container.d.ts.map +1 -0
- package/build-types/toolbar/toolbar-context/index.d.ts +3 -0
- package/build-types/toolbar/toolbar-context/index.d.ts.map +1 -0
- package/build-types/toolbar/toolbar-dropdown-menu/index.d.ts +3 -0
- package/build-types/toolbar/toolbar-dropdown-menu/index.d.ts.map +1 -0
- package/build-types/toolbar/toolbar-group/index.d.ts +39 -0
- package/build-types/toolbar/toolbar-group/index.d.ts.map +1 -0
- package/build-types/toolbar/toolbar-group/toolbar-group-collapsed.d.ts +7 -0
- package/build-types/toolbar/toolbar-group/toolbar-group-collapsed.d.ts.map +1 -0
- package/build-types/toolbar/toolbar-group/toolbar-group-container.d.ts +7 -0
- package/build-types/toolbar/toolbar-group/toolbar-group-container.d.ts.map +1 -0
- package/build-types/toolbar/toolbar-item/index.d.ts +7 -0
- package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -0
- package/build-types/tools-panel/stories/index.d.ts +17 -0
- package/build-types/tools-panel/stories/index.d.ts.map +1 -0
- package/build-types/tools-panel/tools-panel/component.d.ts +54 -2
- package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +2 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +2 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/component.d.ts +2 -2
- package/build-types/tools-panel/tools-panel-item/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +42 -15
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/tree-grid/cell.d.ts +13 -0
- package/build-types/tree-grid/cell.d.ts.map +1 -0
- package/build-types/tree-grid/index.d.ts +70 -0
- package/build-types/tree-grid/index.d.ts.map +1 -0
- package/build-types/tree-grid/item.d.ts +12 -0
- package/build-types/tree-grid/item.d.ts.map +1 -0
- package/build-types/tree-grid/roving-tab-index-context.d.ts +10 -0
- package/build-types/tree-grid/roving-tab-index-context.d.ts.map +1 -0
- package/build-types/tree-grid/roving-tab-index-item.d.ts +5 -0
- package/build-types/tree-grid/roving-tab-index-item.d.ts.map +1 -0
- package/build-types/tree-grid/roving-tab-index.d.ts +10 -0
- package/build-types/tree-grid/roving-tab-index.d.ts.map +1 -0
- package/build-types/tree-grid/row.d.ts +12 -0
- package/build-types/tree-grid/row.d.ts.map +1 -0
- package/build-types/tree-grid/stories/index.d.ts +13 -0
- package/build-types/tree-grid/stories/index.d.ts.map +1 -0
- package/build-types/tree-grid/test/cell.d.ts +2 -0
- package/build-types/tree-grid/test/cell.d.ts.map +1 -0
- package/build-types/tree-grid/test/index.d.ts +2 -0
- package/build-types/tree-grid/test/index.d.ts.map +1 -0
- package/build-types/tree-grid/test/roving-tab-index-item.d.ts +2 -0
- package/build-types/tree-grid/test/roving-tab-index-item.d.ts.map +1 -0
- package/build-types/tree-grid/test/roving-tab-index.d.ts +2 -0
- package/build-types/tree-grid/test/roving-tab-index.d.ts.map +1 -0
- package/build-types/tree-grid/test/row.d.ts +2 -0
- package/build-types/tree-grid/test/row.d.ts.map +1 -0
- package/build-types/tree-grid/types.d.ts +109 -0
- package/build-types/tree-grid/types.d.ts.map +1 -0
- package/build-types/ui/context/context-connect.d.ts +7 -7
- package/build-types/ui/context/get-styled-class-name-from-key.d.ts +1 -1
- package/build-types/ui/utils/get-valid-children.d.ts +1 -1
- package/build-types/ui/utils/space.d.ts +1 -1
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/utils.d.ts +20 -20
- package/build-types/utils/events.d.ts +2 -2
- package/build-types/utils/hooks/use-controlled-state.d.ts +1 -1
- package/build-types/utils/hooks/use-controlled-state.d.ts.map +1 -1
- package/build-types/utils/hooks/use-controlled-value.d.ts +4 -4
- package/build-types/utils/hooks/use-latest-ref.d.ts +1 -1
- package/build-types/utils/unit-values.d.ts +3 -3
- package/package.json +19 -19
- package/src/alignment-matrix-control/utils.tsx +4 -4
- package/src/angle-picker-control/README.md +17 -14
- package/src/angle-picker-control/{angle-circle.js → angle-circle.tsx} +44 -12
- package/src/angle-picker-control/{index.js → index.tsx} +54 -10
- package/src/angle-picker-control/stories/index.tsx +57 -0
- package/src/angle-picker-control/styles/{angle-picker-control-styles.js → angle-picker-control-styles.tsx} +5 -1
- package/src/angle-picker-control/types.ts +29 -0
- package/src/autocomplete/autocompleter-ui.native.js +1 -0
- package/src/base-control/hooks.ts +1 -1
- package/src/border-box-control/test/{index.js → index.tsx} +76 -102
- package/src/border-box-control/test/{utils.js → utils.ts} +20 -0
- package/src/border-box-control/utils.ts +1 -1
- package/src/box-control/README.md +17 -26
- package/src/box-control/{all-input-control.js → all-input-control.tsx} +10 -6
- package/src/box-control/{axial-input-controls.js → axial-input-controls.tsx} +29 -24
- package/src/box-control/{icon.js → icon.tsx} +9 -4
- package/src/box-control/{index.js → index.tsx} +43 -8
- package/src/box-control/{input-controls.js → input-controls.tsx} +26 -16
- package/src/box-control/{linked-button.js → linked-button.tsx} +4 -1
- package/src/box-control/styles/{box-control-icon-styles.js → box-control-icon-styles.ts} +1 -1
- package/src/box-control/styles/{box-control-styles.js → box-control-styles.ts} +10 -2
- package/src/box-control/styles/{box-control-visualizer-styles.js → box-control-visualizer-styles.ts} +6 -2
- package/src/box-control/test/{index.js → index.tsx} +12 -9
- package/src/box-control/types.ts +121 -0
- package/src/box-control/{unit-control.js → unit-control.tsx} +9 -2
- package/src/box-control/{utils.js → utils.ts} +47 -38
- package/src/button/test/index.tsx +38 -30
- package/src/color-palette/README.md +7 -0
- package/src/color-palette/index.tsx +6 -1
- package/src/color-palette/types.ts +8 -0
- package/src/combobox-control/README.md +8 -15
- package/src/combobox-control/{index.js → index.tsx} +91 -19
- package/src/combobox-control/stories/index.tsx +114 -0
- package/src/combobox-control/styles.ts +4 -1
- package/src/combobox-control/test/{index.js → index.tsx} +9 -7
- package/src/combobox-control/types.ts +69 -0
- package/src/custom-gradient-picker/index.js +0 -1
- package/src/custom-select-control/stories/index.js +1 -1
- package/src/date-time/time/index.tsx +1 -1
- package/src/date-time/utils.ts +1 -1
- package/src/draggable/index.tsx +2 -2
- package/src/dropdown-menu/test/index.js +3 -11
- package/src/focal-point-picker/utils.ts +3 -3
- package/src/font-size-picker/utils.ts +2 -2
- package/src/gradient-picker/README.md +8 -0
- package/src/gradient-picker/index.js +6 -1
- package/src/input-control/reducer/reducer.ts +5 -5
- package/src/input-control/utils.ts +1 -1
- package/src/menu-items-choice/index.tsx +83 -0
- package/src/menu-items-choice/stories/index.tsx +79 -0
- package/src/menu-items-choice/types.ts +54 -0
- package/src/modal/index.tsx +45 -1
- package/src/modal/style.scss +8 -0
- package/src/modal/types.ts +2 -0
- package/src/palette-edit/index.js +4 -1
- package/src/panel/README.md +2 -2
- package/src/panel/header.tsx +20 -0
- package/src/panel/index.tsx +48 -0
- package/src/panel/row.tsx +37 -0
- package/src/panel/stories/index.js +22 -0
- package/src/panel/test/__snapshots__/{header.js.snap → header.tsx.snap} +0 -0
- package/src/panel/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
- package/src/panel/test/__snapshots__/{row.js.snap → row.tsx.snap} +0 -0
- package/src/panel/test/{header.js → header.tsx} +1 -1
- package/src/panel/test/{index.js → index.tsx} +6 -4
- package/src/panel/test/{row.js → row.tsx} +4 -2
- package/src/panel/types.ts +38 -0
- package/src/popover/README.md +4 -1
- package/src/popover/index.tsx +17 -1
- package/src/popover/overlay-middlewares.tsx +29 -0
- package/src/popover/stories/index.tsx +7 -1
- package/src/popover/test/index.tsx +29 -21
- package/src/popover/types.ts +4 -2
- package/src/popover/utils.ts +39 -3
- package/src/query-controls/terms.ts +1 -1
- package/src/range-control/utils.ts +4 -4
- package/src/resizable-box/resize-tooltip/styles/{resize-tooltip.styles.js → resize-tooltip.styles.ts} +0 -0
- package/src/resizable-box/resize-tooltip/utils.ts +14 -14
- package/src/snackbar/index.tsx +2 -2
- package/src/toolbar/stories/{index.js → index.tsx} +39 -26
- package/src/toolbar/test/{index.js → index.tsx} +0 -0
- package/src/toolbar/test/{toolbar-group.js → toolbar-group.tsx} +2 -2
- package/src/toolbar/toolbar/README.md +7 -2
- package/src/toolbar/toolbar/{index.js → index.tsx} +33 -12
- package/src/toolbar/toolbar/{toolbar-container.js → toolbar-container.tsx} +9 -2
- package/src/toolbar/toolbar/types.ts +15 -0
- package/src/toolbar/toolbar-button/index.js +2 -0
- package/src/toolbar/toolbar-button/toolbar-button-container.js +2 -0
- package/src/toolbar/toolbar-context/index.js +2 -0
- package/src/toolbar/toolbar-dropdown-menu/index.js +2 -0
- package/src/toolbar/toolbar-group/index.js +2 -0
- package/src/toolbar/toolbar-group/toolbar-group-collapsed.js +2 -0
- package/src/toolbar/toolbar-group/toolbar-group-container.js +2 -0
- package/src/toolbar/toolbar-item/index.js +2 -0
- package/src/tools-panel/stories/{index.js → index.tsx} +196 -95
- package/src/tools-panel/test/index.js +6 -6
- package/src/tools-panel/tools-panel/README.md +12 -4
- package/src/tools-panel/tools-panel/component.tsx +57 -3
- package/src/tools-panel/tools-panel/hook.ts +4 -2
- package/src/tools-panel/tools-panel-header/README.md +7 -0
- package/src/tools-panel/tools-panel-header/component.tsx +2 -1
- package/src/tools-panel/tools-panel-header/hook.ts +6 -4
- package/src/tools-panel/tools-panel-item/README.md +6 -4
- package/src/tools-panel/tools-panel-item/component.tsx +4 -4
- package/src/tools-panel/tools-panel-item/hook.ts +4 -2
- package/src/tools-panel/types.ts +43 -15
- package/src/tree-grid/README.md +18 -58
- package/src/tree-grid/cell.tsx +41 -0
- package/src/tree-grid/{index.js → index.tsx} +111 -35
- package/src/tree-grid/item.tsx +32 -0
- package/src/tree-grid/{roving-tab-index-context.js → roving-tab-index-context.ts} +9 -1
- package/src/tree-grid/roving-tab-index-item.tsx +50 -0
- package/src/tree-grid/{roving-tab-index.js → roving-tab-index.tsx} +7 -5
- package/src/tree-grid/row.tsx +47 -0
- package/src/tree-grid/stories/index.tsx +144 -0
- package/src/tree-grid/test/__snapshots__/{cell.js.snap → cell.tsx.snap} +0 -0
- package/src/tree-grid/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
- package/src/tree-grid/test/__snapshots__/{roving-tab-index-item.js.snap → roving-tab-index-item.tsx.snap} +0 -0
- package/src/tree-grid/test/__snapshots__/{roving-tab-index.js.snap → roving-tab-index.tsx.snap} +0 -0
- package/src/tree-grid/test/__snapshots__/{row.js.snap → row.tsx.snap} +0 -0
- package/src/tree-grid/test/{cell.js → cell.tsx} +7 -4
- package/src/tree-grid/test/{index.js → index.tsx} +13 -5
- package/src/tree-grid/test/{roving-tab-index-item.js → roving-tab-index-item.tsx} +7 -4
- package/src/tree-grid/test/{roving-tab-index.js → roving-tab-index.tsx} +0 -0
- package/src/tree-grid/test/{row.js → row.tsx} +4 -4
- package/src/tree-grid/types.ts +116 -0
- package/src/ui/context/context-connect.ts +7 -7
- package/src/ui/context/get-styled-class-name-from-key.ts +1 -1
- package/src/ui/utils/get-valid-children.ts +1 -1
- package/src/ui/utils/space.ts +1 -1
- package/src/unit-control/index.tsx +2 -2
- package/src/unit-control/utils.ts +20 -20
- package/src/utils/events.ts +4 -4
- package/src/utils/hooks/use-controlled-state.js +2 -2
- package/src/utils/hooks/use-controlled-value.ts +4 -4
- package/src/utils/hooks/use-latest-ref.ts +1 -1
- package/src/utils/unit-values.ts +3 -3
- package/tsconfig.json +1 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/build/base-field/hook.js +0 -54
- package/build/base-field/hook.js.map +0 -1
- package/build/base-field/index.js +0 -14
- package/build/base-field/index.js.map +0 -1
- package/build/base-field/styles.js +0 -33
- package/build/base-field/styles.js.map +0 -1
- package/build/resizable-box/styles/resizable-box.styles.js +0 -2
- package/build-module/base-field/hook.js +0 -37
- package/build-module/base-field/hook.js.map +0 -1
- package/build-module/base-field/index.js +0 -2
- package/build-module/base-field/index.js.map +0 -1
- package/build-module/base-field/styles.js +0 -18
- package/build-module/base-field/styles.js.map +0 -1
- package/build-module/resizable-box/styles/resizable-box.styles.js +0 -2
- package/build-types/base-field/hook.d.ts +0 -270
- package/build-types/base-field/hook.d.ts.map +0 -1
- package/build-types/base-field/index.d.ts +0 -2
- package/build-types/base-field/index.d.ts.map +0 -1
- package/build-types/base-field/styles.d.ts +0 -6
- package/build-types/base-field/styles.d.ts.map +0 -1
- package/build-types/base-field/types.d.ts +0 -29
- package/build-types/base-field/types.d.ts.map +0 -1
- package/build-types/resizable-box/styles/resizable-box.styles.d.ts +0 -1
- package/build-types/resizable-box/styles/resizable-box.styles.d.ts.map +0 -1
- package/src/angle-picker-control/stories/index.js +0 -29
- package/src/base-field/README.md +0 -66
- package/src/base-field/hook.ts +0 -51
- package/src/base-field/index.ts +0 -1
- package/src/base-field/styles.ts +0 -86
- package/src/base-field/test/__snapshots__/index.tsx.snap +0 -141
- package/src/base-field/test/index.tsx +0 -84
- package/src/base-field/types.ts +0 -29
- package/src/combobox-control/stories/index.js +0 -339
- package/src/menu-items-choice/index.js +0 -43
- package/src/panel/header.js +0 -10
- package/src/panel/index.js +0 -26
- package/src/panel/row.js +0 -20
- package/src/resizable-box/styles/resizable-box.styles.js +0 -0
- package/src/tools-panel/stories/utils/tools-panel-with-item-group-slot.js +0 -246
- package/src/tree-grid/cell.js +0 -24
- package/src/tree-grid/item.js +0 -20
- package/src/tree-grid/roving-tab-index-item.js +0 -33
- package/src/tree-grid/row.js +0 -31
- package/src/tree-grid/stories/index.js +0 -106
|
@@ -5,10 +5,10 @@ import { createElement } from "@wordpress/element";
|
|
|
5
5
|
* External dependencies
|
|
6
6
|
*/
|
|
7
7
|
import { useToolbarState, Toolbar } from 'reakit/Toolbar';
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
10
|
* WordPress dependencies
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
12
|
import { forwardRef } from '@wordpress/element';
|
|
13
13
|
import { isRTL } from '@wordpress/i18n';
|
|
14
14
|
/**
|
|
@@ -17,7 +17,7 @@ import { isRTL } from '@wordpress/i18n';
|
|
|
17
17
|
|
|
18
18
|
import ToolbarContext from '../toolbar-context';
|
|
19
19
|
|
|
20
|
-
function
|
|
20
|
+
function UnforwardedToolbarContainer(_ref, ref) {
|
|
21
21
|
let {
|
|
22
22
|
label,
|
|
23
23
|
...props
|
|
@@ -40,5 +40,6 @@ function ToolbarContainer(_ref, ref) {
|
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export
|
|
43
|
+
export const ToolbarContainer = forwardRef(UnforwardedToolbarContainer);
|
|
44
|
+
export default ToolbarContainer;
|
|
44
45
|
//# sourceMappingURL=toolbar-container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar/toolbar-container.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar/toolbar-container.tsx"],"names":["useToolbarState","Toolbar","forwardRef","isRTL","ToolbarContext","UnforwardedToolbarContainer","ref","label","props","toolbarState","loop","baseId","id","rtl","ToolbarContainer"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,eAAT,EAA0BC,OAA1B,QAAyC,gBAAzC;;AAGA;AACA;AACA;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oBAA3B;;AAIA,SAASC,2BAAT,OAECC,GAFD,EAGE;AAAA,MAFD;AAAEC,IAAAA,KAAF;AAAS,OAAGC;AAAZ,GAEC;AACD;AACA;AACA;AACA,QAAMC,YAAY,GAAGT,eAAe,CAAE;AACrCU,IAAAA,IAAI,EAAE,IAD+B;AAErCC,IAAAA,MAAM,EAAEH,KAAK,CAACI,EAFuB;AAGrCC,IAAAA,GAAG,EAAEV,KAAK;AAH2B,GAAF,CAApC;AAMA,SACC;AACA,kBAAC,cAAD,CAAgB,QAAhB;AAAyB,MAAA,KAAK,EAAGM;AAAjC,OACC,cAAC,OAAD;AACC,MAAA,GAAG,EAAGH,GADP;AAEC,oBAAaC;AAFd,OAGME,YAHN,EAIMD,KAJN,EADD;AAFD;AAWA;;AAED,OAAO,MAAMM,gBAAgB,GAAGZ,UAAU,CAAEG,2BAAF,CAAnC;AACP,eAAeS,gBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { useToolbarState, Toolbar } from 'reakit/Toolbar';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ToolbarContext from '../toolbar-context';\nimport type { ToolbarProps } from './types';\nimport type { WordPressComponentProps } from '../../ui/context';\n\nfunction UnforwardedToolbarContainer(\n\t{ label, ...props }: WordPressComponentProps< ToolbarProps, 'div', false >,\n\tref: ForwardedRef< any >\n) {\n\t// https://reakit.io/docs/basic-concepts/#state-hooks\n\t// Passing baseId for server side rendering (which includes snapshots)\n\t// If an id prop is passed to Toolbar, toolbar items will use it as a base for their ids\n\tconst toolbarState = useToolbarState( {\n\t\tloop: true,\n\t\tbaseId: props.id,\n\t\trtl: isRTL(),\n\t} );\n\n\treturn (\n\t\t// This will provide state for `ToolbarButton`'s\n\t\t<ToolbarContext.Provider value={ toolbarState }>\n\t\t\t<Toolbar\n\t\t\t\tref={ ref }\n\t\t\t\taria-label={ label }\n\t\t\t\t{ ...toolbarState }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t</ToolbarContext.Provider>\n\t);\n}\n\nexport const ToolbarContainer = forwardRef( UnforwardedToolbarContainer );\nexport default ToolbarContainer;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-button/index.js"],"names":["classnames","useContext","forwardRef","Button","ToolbarItem","ToolbarContext","ToolbarButtonContainer","ToolbarButton","ref","containerClassName","className","extraProps","children","title","isActive","isDisabled","props","accessibleToolbarState","icon","shortcut","subscript","event","stopPropagation","onClick","toolbarItemProps"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-button/index.js"],"names":["classnames","useContext","forwardRef","Button","ToolbarItem","ToolbarContext","ToolbarButtonContainer","ToolbarButton","ref","containerClassName","className","extraProps","children","title","isActive","isDisabled","props","accessibleToolbarState","icon","shortcut","subscript","event","stopPropagation","onClick","toolbarItemProps"],"mappings":";;AAAA;;AAEA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,UAArB,QAAuC,oBAAvC;AACA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;;AAEA,SAASC,aAAT,OAWCC,GAXD,EAYE;AAAA,MAXD;AACCC,IAAAA,kBADD;AAECC,IAAAA,SAFD;AAGCC,IAAAA,UAHD;AAICC,IAAAA,QAJD;AAKCC,IAAAA,KALD;AAMCC,IAAAA,QAND;AAOCC,IAAAA,UAPD;AAQC,OAAGC;AARJ,GAWC;AACD,QAAMC,sBAAsB,GAAGhB,UAAU,CAAEI,cAAF,CAAzC;;AAEA,MAAK,CAAEY,sBAAP,EAAgC;AAC/B,WACC,cAAC,sBAAD;AAAwB,MAAA,SAAS,EAAGR;AAApC,OACC,cAAC,MAAD;AACC,MAAA,GAAG,EAAGD,GADP;AAEC,MAAA,IAAI,EAAGQ,KAAK,CAACE,IAFd;AAGC,MAAA,KAAK,EAAGL,KAHT;AAIC,MAAA,QAAQ,EAAGG,KAAK,CAACG,QAJlB;AAKC,wBAAiBH,KAAK,CAACI,SALxB;AAMC,MAAA,OAAO,EAAKC,KAAF,IAAa;AACtBA,QAAAA,KAAK,CAACC,eAAN;;AACA,YAAKN,KAAK,CAACO,OAAX,EAAqB;AACpBP,UAAAA,KAAK,CAACO,OAAN,CAAeF,KAAf;AACA;AACD,OAXF;AAYC,MAAA,SAAS,EAAGrB,UAAU,CACrB,6BADqB,EAErBU,SAFqB,CAZvB;AAgBC,MAAA,SAAS,EAAGI,QAhBb;AAiBC,MAAA,QAAQ,EAAGC,UAjBZ;AAkBC;AAlBD,OAmBMJ,UAnBN,EAoBMK,KApBN,GAsBGJ,QAtBH,CADD,CADD;AA4BA,GAhCA,CAkCD;AACA;AACA;;;AACA,SACC,cAAC,WAAD;AACC,IAAA,SAAS,EAAGZ,UAAU,CAAE,2BAAF,EAA+BU,SAA/B;AADvB,KAEMC,UAFN,EAGMK,KAHN;AAIC,IAAA,GAAG,EAAGR;AAJP,MAMKgB,gBAAF,IACD,cAAC,MAAD;AACC,IAAA,KAAK,EAAGX,KADT;AAEC,IAAA,SAAS,EAAGC,QAFb;AAGC,IAAA,QAAQ,EAAGC;AAHZ,KAIMS,gBAJN,GAMGZ,QANH,CAPF,CADD;AAmBA;;AAED,eAAeV,UAAU,CAAEK,aAAF,CAAzB","sourcesContent":["// @ts-nocheck\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n/**\n * WordPress dependencies\n */\nimport { useContext, forwardRef } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport Button from '../../button';\nimport ToolbarItem from '../toolbar-item';\nimport ToolbarContext from '../toolbar-context';\nimport ToolbarButtonContainer from './toolbar-button-container';\n\nfunction ToolbarButton(\n\t{\n\t\tcontainerClassName,\n\t\tclassName,\n\t\textraProps,\n\t\tchildren,\n\t\ttitle,\n\t\tisActive,\n\t\tisDisabled,\n\t\t...props\n\t},\n\tref\n) {\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tif ( ! accessibleToolbarState ) {\n\t\treturn (\n\t\t\t<ToolbarButtonContainer className={ containerClassName }>\n\t\t\t\t<Button\n\t\t\t\t\tref={ ref }\n\t\t\t\t\ticon={ props.icon }\n\t\t\t\t\tlabel={ title }\n\t\t\t\t\tshortcut={ props.shortcut }\n\t\t\t\t\tdata-subscript={ props.subscript }\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tif ( props.onClick ) {\n\t\t\t\t\t\t\tprops.onClick( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'components-toolbar__control',\n\t\t\t\t\t\tclassName\n\t\t\t\t\t) }\n\t\t\t\t\tisPressed={ isActive }\n\t\t\t\t\tdisabled={ isDisabled }\n\t\t\t\t\tdata-toolbar-item\n\t\t\t\t\t{ ...extraProps }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</Button>\n\t\t\t</ToolbarButtonContainer>\n\t\t);\n\t}\n\n\t// ToobarItem will pass all props to the render prop child, which will pass\n\t// all props to Button. This means that ToolbarButton has the same API as\n\t// Button.\n\treturn (\n\t\t<ToolbarItem\n\t\t\tclassName={ classnames( 'components-toolbar-button', className ) }\n\t\t\t{ ...extraProps }\n\t\t\t{ ...props }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t{ ( toolbarItemProps ) => (\n\t\t\t\t<Button\n\t\t\t\t\tlabel={ title }\n\t\t\t\t\tisPressed={ isActive }\n\t\t\t\t\tdisabled={ isDisabled }\n\t\t\t\t\t{ ...toolbarItemProps }\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</ToolbarItem>\n\t);\n}\n\nexport default forwardRef( ToolbarButton );\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-button/toolbar-button-container.js"],"names":["ToolbarButtonContainer","props","className","children"],"mappings":";;AAAA,MAAMA,sBAAsB,GAAKC,KAAF,IAC9B;AAAK,EAAA,SAAS,EAAGA,KAAK,CAACC;AAAvB,GAAqCD,KAAK,CAACE,QAA3C,CADD;;AAGA,eAAeH,sBAAf","sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-button/toolbar-button-container.js"],"names":["ToolbarButtonContainer","props","className","children"],"mappings":";;AAAA;AAEA,MAAMA,sBAAsB,GAAKC,KAAF,IAC9B;AAAK,EAAA,SAAS,EAAGA,KAAK,CAACC;AAAvB,GAAqCD,KAAK,CAACE,QAA3C,CADD;;AAGA,eAAeH,sBAAf","sourcesContent":["// @ts-nocheck\n\nconst ToolbarButtonContainer = ( props ) => (\n\t<div className={ props.className }>{ props.children }</div>\n);\nexport default ToolbarButtonContainer;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-context/index.js"],"names":["createContext","ToolbarContext"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,oBAA9B;AAEA,MAAMC,cAAc,GAAGD,aAAa,EAApC;AAEA,eAAeC,cAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nconst ToolbarContext = createContext();\n\nexport default ToolbarContext;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-context/index.js"],"names":["createContext","ToolbarContext"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,oBAA9B;AAEA,MAAMC,cAAc,GAAGD,aAAa,EAApC;AAEA,eAAeC,cAAf","sourcesContent":["// @ts-nocheck\n\n/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nconst ToolbarContext = createContext();\n\nexport default ToolbarContext;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-dropdown-menu/index.js"],"names":["forwardRef","useContext","ToolbarItem","ToolbarContext","DropdownMenu","ToolbarDropdownMenu","props","ref","accessibleToolbarState","toggleProps","toolbarItemProps","variant","popoverProps"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-dropdown-menu/index.js"],"names":["forwardRef","useContext","ToolbarItem","ToolbarContext","DropdownMenu","ToolbarDropdownMenu","props","ref","accessibleToolbarState","toggleProps","toolbarItemProps","variant","popoverProps"],"mappings":";;AAAA;;AAEA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,UAArB,QAAuC,oBAAvC;AAEA;AACA;AACA;;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,YAAP,MAAyB,qBAAzB;;AAEA,SAASC,mBAAT,CAA8BC,KAA9B,EAAqCC,GAArC,EAA2C;AAC1C,QAAMC,sBAAsB,GAAGP,UAAU,CAAEE,cAAF,CAAzC;;AAEA,MAAK,CAAEK,sBAAP,EAAgC;AAC/B,WAAO,cAAC,YAAD,EAAmBF,KAAnB,CAAP;AACA,GALyC,CAO1C;AACA;AACA;;;AACA,SACC,cAAC,WAAD;AAAa,IAAA,GAAG,EAAGC;AAAnB,KAA8BD,KAAK,CAACG,WAApC,GACKC,gBAAF,IACD,cAAC,YAAD,eACMJ,KADN;AAEC,IAAA,YAAY,EAAG;AACdK,MAAAA,OAAO,EAAE,SADK;AAEd,SAAGL,KAAK,CAACM;AAFK,KAFhB;AAMC,IAAA,WAAW,EAAGF;AANf,KAFF,CADD;AAcA;;AAED,eAAeV,UAAU,CAAEK,mBAAF,CAAzB","sourcesContent":["// @ts-nocheck\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ToolbarItem from '../toolbar-item';\nimport ToolbarContext from '../toolbar-context';\nimport DropdownMenu from '../../dropdown-menu';\n\nfunction ToolbarDropdownMenu( props, ref ) {\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tif ( ! accessibleToolbarState ) {\n\t\treturn <DropdownMenu { ...props } />;\n\t}\n\n\t// ToobarItem will pass all props to the render prop child, which will pass\n\t// all props to the toggle of DropdownMenu. This means that ToolbarDropdownMenu\n\t// has the same API as DropdownMenu.\n\treturn (\n\t\t<ToolbarItem ref={ ref } { ...props.toggleProps }>\n\t\t\t{ ( toolbarItemProps ) => (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\tvariant: 'toolbar',\n\t\t\t\t\t\t...props.popoverProps,\n\t\t\t\t\t} }\n\t\t\t\t\ttoggleProps={ toolbarItemProps }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</ToolbarItem>\n\t);\n}\n\nexport default forwardRef( ToolbarDropdownMenu );\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-group/index.js"],"names":["classnames","useContext","ToolbarButton","ToolbarGroupContainer","ToolbarGroupCollapsed","ToolbarContext","ToolbarGroup","controls","children","className","isCollapsed","title","props","accessibleToolbarState","length","finalClassName","controlSets","Array","isArray","flatMap","controlSet","indexOfSet","map","control","indexOfControl","join"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-group/index.js"],"names":["classnames","useContext","ToolbarButton","ToolbarGroupContainer","ToolbarGroupCollapsed","ToolbarContext","ToolbarGroup","controls","children","className","isCollapsed","title","props","accessibleToolbarState","length","finalClassName","controlSets","Array","isArray","flatMap","controlSet","indexOfSet","map","control","indexOfControl","join"],"mappings":";;AAAA;;AAEA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,qBAAP,MAAkC,2BAAlC;AACA,OAAOC,qBAAP,MAAkC,2BAAlC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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cAAd,EAA+BC,IAA/B,EADP;AAEC,IAAA,kBAAkB,EACjBJ,UAAU,GAAG,CAAb,IAAkBG,cAAc,KAAK,CAArC,GACG,kBADH,GAEG;AALL,KAOMD,OAPN,EADD,CADC,CADH,EAcGf,QAdH,CADD;AAkBA;;AAED,eAAeF,YAAf","sourcesContent":["// @ts-nocheck\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ToolbarButton from '../toolbar-button';\nimport ToolbarGroupContainer from './toolbar-group-container';\nimport ToolbarGroupCollapsed from './toolbar-group-collapsed';\nimport ToolbarContext from '../toolbar-context';\n\n/**\n * Renders a collapsible group of controls\n *\n * The `controls` prop accepts an array of sets. A set is an array of controls.\n * Controls have the following shape:\n *\n * ```\n * {\n * icon: string,\n * title: string,\n * subscript: string,\n * onClick: Function,\n * isActive: boolean,\n * isDisabled: boolean\n * }\n * ```\n *\n * For convenience it is also possible to pass only an array of controls. It is\n * then assumed this is the only set.\n *\n * Either `controls` or `children` is required, otherwise this components\n * renders nothing.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.controls] The controls to render in this toolbar.\n * @param {WPElement} [props.children] Any other things to render inside the toolbar besides the controls.\n * @param {string} [props.className] Class to set on the container div.\n * @param {boolean} [props.isCollapsed] Turns ToolbarGroup into a dropdown menu.\n * @param {string} [props.title] ARIA label for dropdown menu if is collapsed.\n */\nfunction ToolbarGroup( {\n\tcontrols = [],\n\tchildren,\n\tclassName,\n\tisCollapsed,\n\ttitle,\n\t...props\n} ) {\n\t// It'll contain state if `ToolbarGroup` is being used within\n\t// `<Toolbar label=\"label\" />`\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tif ( ( ! controls || ! controls.length ) && ! children ) {\n\t\treturn null;\n\t}\n\n\tconst finalClassName = classnames(\n\t\t// Unfortunately, there's legacy code referencing to `.components-toolbar`\n\t\t// So we can't get rid of it\n\t\taccessibleToolbarState\n\t\t\t? 'components-toolbar-group'\n\t\t\t: 'components-toolbar',\n\t\tclassName\n\t);\n\n\t// Normalize controls to nested array of objects (sets of controls)\n\tlet controlSets = controls;\n\tif ( ! Array.isArray( controlSets[ 0 ] ) ) {\n\t\tcontrolSets = [ controlSets ];\n\t}\n\n\tif ( isCollapsed ) {\n\t\treturn (\n\t\t\t<ToolbarGroupCollapsed\n\t\t\t\tlabel={ title }\n\t\t\t\tcontrols={ controlSets }\n\t\t\t\tclassName={ finalClassName }\n\t\t\t\tchildren={ children }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<ToolbarGroupContainer className={ finalClassName } { ...props }>\n\t\t\t{ controlSets?.flatMap( ( controlSet, indexOfSet ) =>\n\t\t\t\tcontrolSet.map( ( control, indexOfControl ) => (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tkey={ [ indexOfSet, indexOfControl ].join() }\n\t\t\t\t\t\tcontainerClassName={\n\t\t\t\t\t\t\tindexOfSet > 0 && indexOfControl === 0\n\t\t\t\t\t\t\t\t? 'has-left-divider'\n\t\t\t\t\t\t\t\t: null\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{ ...control }\n\t\t\t\t\t/>\n\t\t\t\t) )\n\t\t\t) }\n\t\t\t{ children }\n\t\t</ToolbarGroupContainer>\n\t);\n}\n\nexport default ToolbarGroup;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-collapsed.js"],"names":["useContext","DropdownMenu","ToolbarContext","ToolbarItem","ToolbarGroupCollapsed","controls","toggleProps","props","accessibleToolbarState","renderDropdownMenu","internalToggleProps"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-collapsed.js"],"names":["useContext","DropdownMenu","ToolbarContext","ToolbarItem","ToolbarGroupCollapsed","controls","toggleProps","props","accessibleToolbarState","renderDropdownMenu","internalToggleProps"],"mappings":";;AAAA;;AAEA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,qBAAzB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,WAAP,MAAwB,iBAAxB;;AAEA,SAASC,qBAAT,OAA2E;AAAA,MAA3C;AAAEC,IAAAA,QAAQ,GAAG,EAAb;AAAiBC,IAAAA,WAAjB;AAA8B,OAAGC;AAAjC,GAA2C;AAC1E;AACA;AACA,QAAMC,sBAAsB,GAAGR,UAAU,CAAEE,cAAF,CAAzC;;AAEA,QAAMO,kBAAkB,GAAKC,mBAAF,IAC1B,cAAC,YAAD;AACC,IAAA,QAAQ,EAAGL,QADZ;AAEC,IAAA,WAAW,EAAG,EACb,GAAGK,mBADU;AAEb,2BAAqB;AAFR;AAFf,KAMMH,KANN,EADD;;AAWA,MAAKC,sBAAL,EAA8B;AAC7B,WACC,cAAC,WAAD,EAAkBF,WAAlB,EAAkCG,kBAAlC,CADD;AAGA;;AAED,SAAOA,kBAAkB,CAAEH,WAAF,CAAzB;AACA;;AAED,eAAeF,qBAAf","sourcesContent":["// @ts-nocheck\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport ToolbarContext from '../toolbar-context';\nimport ToolbarItem from '../toolbar-item';\n\nfunction ToolbarGroupCollapsed( { controls = [], toggleProps, ...props } ) {\n\t// It'll contain state if `ToolbarGroup` is being used within\n\t// `<Toolbar label=\"label\" />`\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tconst renderDropdownMenu = ( internalToggleProps ) => (\n\t\t<DropdownMenu\n\t\t\tcontrols={ controls }\n\t\t\ttoggleProps={ {\n\t\t\t\t...internalToggleProps,\n\t\t\t\t'data-toolbar-item': true,\n\t\t\t} }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n\n\tif ( accessibleToolbarState ) {\n\t\treturn (\n\t\t\t<ToolbarItem { ...toggleProps }>{ renderDropdownMenu }</ToolbarItem>\n\t\t);\n\t}\n\n\treturn renderDropdownMenu( toggleProps );\n}\n\nexport default ToolbarGroupCollapsed;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-container.js"],"names":["ToolbarGroupContainer","className","children","props"],"mappings":";;;AAAA,MAAMA,qBAAqB,GAAG;AAAA,MAAE;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,QAAb;AAAuB,OAAGC;AAA1B,GAAF;AAAA,SAC7B;AAAK,IAAA,SAAS,EAAGF;AAAjB,KAAkCE,KAAlC,GACGD,QADH,CAD6B;AAAA,CAA9B;;AAKA,eAAeF,qBAAf","sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-group/toolbar-group-container.js"],"names":["ToolbarGroupContainer","className","children","props"],"mappings":";;;AAAA;AAEA,MAAMA,qBAAqB,GAAG;AAAA,MAAE;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,QAAb;AAAuB,OAAGC;AAA1B,GAAF;AAAA,SAC7B;AAAK,IAAA,SAAS,EAAGF;AAAjB,KAAkCE,KAAlC,GACGD,QADH,CAD6B;AAAA,CAA9B;;AAKA,eAAeF,qBAAf","sourcesContent":["// @ts-nocheck\n\nconst ToolbarGroupContainer = ( { className, children, ...props } ) => (\n\t<div className={ className } { ...props }>\n\t\t{ children }\n\t</div>\n);\nexport default ToolbarGroupContainer;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-item/index.js"],"names":["ToolbarItem","BaseToolbarItem","forwardRef","useContext","warning","ToolbarContext","ref","children","as","Component","props","accessibleToolbarState","allProps"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/toolbar/toolbar-item/index.js"],"names":["ToolbarItem","BaseToolbarItem","forwardRef","useContext","warning","ToolbarContext","ref","children","as","Component","props","accessibleToolbarState","allProps"],"mappings":";;AAAA;;AAEA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,eAAxB,QAA+C,gBAA/C;AAEA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,UAArB,QAAuC,oBAAvC;AACA,OAAOC,OAAP,MAAoB,oBAApB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oBAA3B;;AAEA,SAASL,WAAT,OAA6DM,GAA7D,EAAmE;AAAA,MAA7C;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,EAAE,EAAEC,SAAhB;AAA2B,OAAGC;AAA9B,GAA6C;AAClE,QAAMC,sBAAsB,GAAGR,UAAU,CAAEE,cAAF,CAAzC;;AAEA,MAAK,OAAOE,QAAP,KAAoB,UAApB,IAAkC,CAAEE,SAAzC,EAAqD;AACpD,6FAAAL,OAAO,CACN,yIACC,2EAFK,CAAP;AAIA,WAAO,IAAP;AACA;;AAED,QAAMQ,QAAQ,GAAG,EAAE,GAAGF,KAAL;AAAYJ,IAAAA,GAAZ;AAAiB,yBAAqB;AAAtC,GAAjB;;AAEA,MAAK,CAAEK,sBAAP,EAAgC;AAC/B,QAAKF,SAAL,EAAiB;AAChB,aAAO,cAAC,SAAD,EAAgBG,QAAhB,EAA6BL,QAA7B,CAAP;AACA;;AACD,WAAOA,QAAQ,CAAEK,QAAF,CAAf;AACA;;AAED,SACC,cAAC,eAAD,eACMD,sBADN,EAEMC,QAFN;AAGC,IAAA,EAAE,EAAGH;AAHN,MAKGF,QALH,CADD;AASA;;AAED,eAAeL,UAAU,CAAEF,WAAF,CAAzB","sourcesContent":["// @ts-nocheck\n\n/**\n * External dependencies\n */\nimport { ToolbarItem as BaseToolbarItem } from 'reakit/Toolbar';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport ToolbarContext from '../toolbar-context';\n\nfunction ToolbarItem( { children, as: Component, ...props }, ref ) {\n\tconst accessibleToolbarState = useContext( ToolbarContext );\n\n\tif ( typeof children !== 'function' && ! Component ) {\n\t\twarning(\n\t\t\t'`ToolbarItem` is a generic headless component. You must pass either a `children` prop as a function or an `as` prop as a component. ' +\n\t\t\t\t'See https://developer.wordpress.org/block-editor/components/toolbar-item/'\n\t\t);\n\t\treturn null;\n\t}\n\n\tconst allProps = { ...props, ref, 'data-toolbar-item': true };\n\n\tif ( ! accessibleToolbarState ) {\n\t\tif ( Component ) {\n\t\t\treturn <Component { ...allProps }>{ children }</Component>;\n\t\t}\n\t\treturn children( allProps );\n\t}\n\n\treturn (\n\t\t<BaseToolbarItem\n\t\t\t{ ...accessibleToolbarState }\n\t\t\t{ ...allProps }\n\t\t\tas={ Component }\n\t\t>\n\t\t\t{ children }\n\t\t</BaseToolbarItem>\n\t);\n}\n\nexport default forwardRef( ToolbarItem );\n"]}
|
|
@@ -14,13 +14,14 @@ import { useToolsPanel } from './hook';
|
|
|
14
14
|
import { Grid } from '../../grid';
|
|
15
15
|
import { contextConnect } from '../../ui/context';
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const UnconnectedToolsPanel = (props, forwardedRef) => {
|
|
18
18
|
const {
|
|
19
19
|
children,
|
|
20
20
|
label,
|
|
21
21
|
panelContext,
|
|
22
22
|
resetAllItems,
|
|
23
23
|
toggleItem,
|
|
24
|
+
headingLevel,
|
|
24
25
|
...toolsPanelProps
|
|
25
26
|
} = useToolsPanel(props);
|
|
26
27
|
return createElement(Grid, _extends({}, toolsPanelProps, {
|
|
@@ -31,10 +32,64 @@ const ToolsPanel = (props, forwardedRef) => {
|
|
|
31
32
|
}, createElement(ToolsPanelHeader, {
|
|
32
33
|
label: label,
|
|
33
34
|
resetAll: resetAllItems,
|
|
34
|
-
toggleItem: toggleItem
|
|
35
|
+
toggleItem: toggleItem,
|
|
36
|
+
headingLevel: headingLevel
|
|
35
37
|
}), children));
|
|
36
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* The `ToolsPanel` is a container component that displays its children preceded
|
|
41
|
+
* by a header. The header includes a dropdown menu which is automatically
|
|
42
|
+
* generated from the panel's inner `ToolsPanelItems`.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```jsx
|
|
46
|
+
* import { __ } from '@wordpress/i18n';
|
|
47
|
+
* import {
|
|
48
|
+
* __experimentalToolsPanel as ToolsPanel,
|
|
49
|
+
* __experimentalToolsPanelItem as ToolsPanelItem,
|
|
50
|
+
* __experimentalUnitControl as UnitControl
|
|
51
|
+
* } from '@wordpress/components';
|
|
52
|
+
*
|
|
53
|
+
* function Example() {
|
|
54
|
+
* const [ height, setHeight ] = useState();
|
|
55
|
+
* const [ width, setWidth ] = useState();
|
|
56
|
+
*
|
|
57
|
+
* const resetAll = () => {
|
|
58
|
+
* setHeight();
|
|
59
|
+
* setWidth();
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* return (
|
|
63
|
+
* <ToolsPanel label={ __( 'Dimensions' ) } resetAll={ resetAll }>
|
|
64
|
+
* <ToolsPanelItem
|
|
65
|
+
* hasValue={ () => !! height }
|
|
66
|
+
* label={ __( 'Height' ) }
|
|
67
|
+
* onDeselect={ () => setHeight() }
|
|
68
|
+
* >
|
|
69
|
+
* <UnitControl
|
|
70
|
+
* label={ __( 'Height' ) }
|
|
71
|
+
* onChange={ setHeight }
|
|
72
|
+
* value={ height }
|
|
73
|
+
* />
|
|
74
|
+
* </ToolsPanelItem>
|
|
75
|
+
* <ToolsPanelItem
|
|
76
|
+
* hasValue={ () => !! width }
|
|
77
|
+
* label={ __( 'Width' ) }
|
|
78
|
+
* onDeselect={ () => setWidth() }
|
|
79
|
+
* >
|
|
80
|
+
* <UnitControl
|
|
81
|
+
* label={ __( 'Width' ) }
|
|
82
|
+
* onChange={ setWidth }
|
|
83
|
+
* value={ width }
|
|
84
|
+
* />
|
|
85
|
+
* </ToolsPanelItem>
|
|
86
|
+
* </ToolsPanel>
|
|
87
|
+
* );
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
|
|
37
92
|
|
|
38
|
-
const
|
|
39
|
-
export default
|
|
93
|
+
export const ToolsPanel = contextConnect(UnconnectedToolsPanel, 'ToolsPanel');
|
|
94
|
+
export default ToolsPanel;
|
|
40
95
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel/component.tsx"],"names":["ToolsPanelHeader","ToolsPanelContext","useToolsPanel","Grid","contextConnect","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel/component.tsx"],"names":["ToolsPanelHeader","ToolsPanelContext","useToolsPanel","Grid","contextConnect","UnconnectedToolsPanel","props","forwardedRef","children","label","panelContext","resetAllItems","toggleItem","headingLevel","toolsPanelProps","ToolsPanel"],"mappings":";;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOA,gBAAP,MAA6B,uBAA7B;AACA,SAASC,iBAAT,QAAkC,YAAlC;AACA,SAASC,aAAT,QAA8B,QAA9B;AACA,SAASC,IAAT,QAAqB,YAArB;AACA,SAASC,cAAT,QAAwD,kBAAxD;;AAGA,MAAMC,qBAAqB,GAAG,CAC7BC,KAD6B,EAE7BC,YAF6B,KAGzB;AACJ,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,YAHK;AAILC,IAAAA,aAJK;AAKLC,IAAAA,UALK;AAMLC,IAAAA,YANK;AAOL,OAAGC;AAPE,MAQFZ,aAAa,CAAEI,KAAF,CARjB;AAUA,SACC,cAAC,IAAD,eAAWQ,eAAX;AAA6B,IAAA,OAAO,EAAG,CAAvC;AAA2C,IAAA,GAAG,EAAGP;AAAjD,MACC,cAAC,iBAAD,CAAmB,QAAnB;AAA4B,IAAA,KAAK,EAAGG;AAApC,KACC,cAAC,gBAAD;AACC,IAAA,KAAK,EAAGD,KADT;AAEC,IAAA,QAAQ,EAAGE,aAFZ;AAGC,IAAA,UAAU,EAAGC,UAHd;AAIC,IAAA,YAAY,EAAGC;AAJhB,IADD,EAOGL,QAPH,CADD,CADD;AAaA,CA3BD;AA6BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMO,UAAU,GAAGX,cAAc,CAAEC,qBAAF,EAAyB,YAAzB,CAAjC;AAEP,eAAeU,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport ToolsPanelHeader from '../tools-panel-header';\nimport { ToolsPanelContext } from '../context';\nimport { useToolsPanel } from './hook';\nimport { Grid } from '../../grid';\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport type { ToolsPanelProps } from '../types';\n\nconst UnconnectedToolsPanel = (\n\tprops: WordPressComponentProps< ToolsPanelProps, 'div' >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tchildren,\n\t\tlabel,\n\t\tpanelContext,\n\t\tresetAllItems,\n\t\ttoggleItem,\n\t\theadingLevel,\n\t\t...toolsPanelProps\n\t} = useToolsPanel( props );\n\n\treturn (\n\t\t<Grid { ...toolsPanelProps } columns={ 2 } ref={ forwardedRef }>\n\t\t\t<ToolsPanelContext.Provider value={ panelContext }>\n\t\t\t\t<ToolsPanelHeader\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tresetAll={ resetAllItems }\n\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\theadingLevel={ headingLevel }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</ToolsPanelContext.Provider>\n\t\t</Grid>\n\t);\n};\n\n/**\n * The `ToolsPanel` is a container component that displays its children preceded\n * by a header. The header includes a dropdown menu which is automatically\n * generated from the panel's inner `ToolsPanelItems`.\n *\n * @example\n * ```jsx\n * import { __ } from '@wordpress/i18n';\n * import {\n * __experimentalToolsPanel as ToolsPanel,\n * __experimentalToolsPanelItem as ToolsPanelItem,\n * __experimentalUnitControl as UnitControl\n * } from '@wordpress/components';\n *\n * function Example() {\n * const [ height, setHeight ] = useState();\n * const [ width, setWidth ] = useState();\n *\n * const resetAll = () => {\n * setHeight();\n * setWidth();\n * }\n *\n * return (\n * <ToolsPanel label={ __( 'Dimensions' ) } resetAll={ resetAll }>\n * <ToolsPanelItem\n * hasValue={ () => !! height }\n * label={ __( 'Height' ) }\n * onDeselect={ () => setHeight() }\n * >\n * <UnitControl\n * label={ __( 'Height' ) }\n * onChange={ setHeight }\n * value={ height }\n * />\n * </ToolsPanelItem>\n * <ToolsPanelItem\n * hasValue={ () => !! width }\n * label={ __( 'Width' ) }\n * onDeselect={ () => setWidth() }\n * >\n * <UnitControl\n * label={ __( 'Width' ) }\n * onChange={ setWidth }\n * value={ width }\n * />\n * </ToolsPanelItem>\n * </ToolsPanel>\n * );\n * }\n * ```\n */\nexport const ToolsPanel = contextConnect( UnconnectedToolsPanel, 'ToolsPanel' );\n\nexport default ToolsPanel;\n"]}
|
|
@@ -45,10 +45,11 @@ const isMenuItemTypeEmpty = obj => obj && Object.keys(obj).length === 0;
|
|
|
45
45
|
export function useToolsPanel(props) {
|
|
46
46
|
const {
|
|
47
47
|
className,
|
|
48
|
+
headingLevel = 2,
|
|
48
49
|
resetAll,
|
|
49
50
|
panelId,
|
|
50
|
-
hasInnerWrapper,
|
|
51
|
-
shouldRenderPlaceholderItems,
|
|
51
|
+
hasInnerWrapper = false,
|
|
52
|
+
shouldRenderPlaceholderItems = false,
|
|
52
53
|
__experimentalFirstVisibleItemClass,
|
|
53
54
|
__experimentalLastVisibleItemClass,
|
|
54
55
|
...otherProps
|
|
@@ -214,6 +215,7 @@ export function useToolsPanel(props) {
|
|
|
214
215
|
__experimentalLastVisibleItemClass
|
|
215
216
|
}), [areAllOptionalControlsHidden, deregisterPanelItem, firstDisplayedItem, flagItemCustomization, lastDisplayedItem, menuItems, panelId, panelItems, registerPanelItem, shouldRenderPlaceholderItems, __experimentalFirstVisibleItemClass, __experimentalLastVisibleItemClass]);
|
|
216
217
|
return { ...otherProps,
|
|
218
|
+
headingLevel,
|
|
217
219
|
panelContext,
|
|
218
220
|
resetAllItems,
|
|
219
221
|
toggleItem,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel/hook.ts"],"names":["useCallback","useEffect","useMemo","useRef","useState","styles","useContextSystem","useCx","DEFAULT_COLUMNS","generateMenuItems","panelItems","shouldReset","currentMenuItems","menuItems","default","optional","forEach","hasValue","isShownByDefault","label","group","existingItemValue","value","isMenuItemTypeEmpty","obj","Object","keys","length","useToolsPanel","props","className","resetAll","panelId","hasInnerWrapper","shouldRenderPlaceholderItems","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass","otherProps","isResetting","wasResetting","current","setPanelItems","registerPanelItem","item","items","newItems","existingIndex","findIndex","oldItem","splice","deregisterPanelItem","index","setMenuItems","prevState","flagItemCustomization","newState","areAllOptionalControlsHidden","setAreAllOptionalControlsHidden","allControlsHidden","entries","some","isSelected","cx","classes","wrapperStyle","ToolsPanelWithInnerWrapper","emptyStyle","ToolsPanelHiddenInnerWrapper","ToolsPanel","toggleItem","currentItem","find","menuGroup","newMenuItems","resetAllItems","filters","resetAllFilter","push","resetMenuItems","getFirstVisibleItemLabel","optionalItems","firstItem","firstDisplayedItem","lastDisplayedItem","reverse","panelContext","hasMenuItems"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,WADD,EAECC,SAFD,EAGCC,OAHD,EAICC,MAJD,EAKCC,QALD,QAMO,oB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n\tuseState,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type {\n\tToolsPanelItem,\n\tToolsPanelMenuItemKey,\n\tToolsPanelMenuItems,\n\tToolsPanelMenuItemsConfig,\n\tToolsPanelProps,\n} from '../types';\n\nconst DEFAULT_COLUMNS = 2;\n\nconst generateMenuItems = ( {\n\tpanelItems,\n\tshouldReset,\n\tcurrentMenuItems,\n}: ToolsPanelMenuItemsConfig ) => {\n\tconst menuItems: ToolsPanelMenuItems = { default: {}, optional: {} };\n\n\tpanelItems.forEach( ( { hasValue, isShownByDefault, label } ) => {\n\t\tconst group = isShownByDefault ? 'default' : 'optional';\n\n\t\t// If a menu item for this label has already been flagged as customized\n\t\t// (for default controls), or toggled on (for optional controls), do not\n\t\t// overwrite its value as those controls would lose that state.\n\t\tconst existingItemValue = currentMenuItems?.[ group ]?.[ label ];\n\t\tconst value = existingItemValue ? existingItemValue : hasValue();\n\n\t\tmenuItems[ group ][ label ] = shouldReset ? false : value;\n\t} );\n\n\treturn menuItems;\n};\n\nconst isMenuItemTypeEmpty = (\n\tobj?: ToolsPanelMenuItems[ ToolsPanelMenuItemKey ]\n) => obj && Object.keys( obj ).length === 0;\n\nexport function useToolsPanel(\n\tprops: WordPressComponentProps< ToolsPanelProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\tresetAll,\n\t\tpanelId,\n\t\thasInnerWrapper,\n\t\tshouldRenderPlaceholderItems,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToolsPanel' );\n\n\tconst isResetting = useRef( false );\n\tconst wasResetting = isResetting.current;\n\n\t// `isResetting` is cleared via this hook to effectively batch together\n\t// the resetAll task. Without this, the flag is cleared after the first\n\t// control updates and forces a rerender with subsequent controls then\n\t// believing they need to reset, unfortunately using stale data.\n\tuseEffect( () => {\n\t\tif ( wasResetting ) {\n\t\t\tisResetting.current = false;\n\t\t}\n\t}, [ wasResetting ] );\n\n\t// Allow panel items to register themselves.\n\tconst [ panelItems, setPanelItems ] = useState< ToolsPanelItem[] >( [] );\n\n\tconst registerPanelItem = useCallback(\n\t\t( item: ToolsPanelItem ) => {\n\t\t\tsetPanelItems( ( items ) => {\n\t\t\t\tconst newItems = [ ...items ];\n\t\t\t\t// If an item with this label has already been registered, remove it\n\t\t\t\t// first. This can happen when an item is moved between the default\n\t\t\t\t// and optional groups.\n\t\t\t\tconst existingIndex = newItems.findIndex(\n\t\t\t\t\t( oldItem ) => oldItem.label === item.label\n\t\t\t\t);\n\t\t\t\tif ( existingIndex !== -1 ) {\n\t\t\t\t\tnewItems.splice( existingIndex, 1 );\n\t\t\t\t}\n\t\t\t\treturn [ ...newItems, item ];\n\t\t\t} );\n\t\t},\n\t\t[ setPanelItems ]\n\t);\n\n\t// Panels need to deregister on unmount to avoid orphans in menu state.\n\t// This is an issue when panel items are being injected via SlotFills.\n\tconst deregisterPanelItem = useCallback(\n\t\t( label: string ) => {\n\t\t\t// When switching selections between components injecting matching\n\t\t\t// controls, e.g. both panels have a \"padding\" control, the\n\t\t\t// deregistration of the first panel doesn't occur until after the\n\t\t\t// registration of the next.\n\t\t\tsetPanelItems( ( items ) => {\n\t\t\t\tconst newItems = [ ...items ];\n\t\t\t\tconst index = newItems.findIndex(\n\t\t\t\t\t( item ) => item.label === label\n\t\t\t\t);\n\t\t\t\tif ( index !== -1 ) {\n\t\t\t\t\tnewItems.splice( index, 1 );\n\t\t\t\t}\n\t\t\t\treturn newItems;\n\t\t\t} );\n\t\t},\n\t\t[ setPanelItems ]\n\t);\n\n\t// Manage and share display state of menu items representing child controls.\n\tconst [ menuItems, setMenuItems ] = useState< ToolsPanelMenuItems >( {\n\t\tdefault: {},\n\t\toptional: {},\n\t} );\n\n\t// Setup menuItems state as panel items register themselves.\n\tuseEffect( () => {\n\t\tsetMenuItems( ( prevState ) => {\n\t\t\tconst items = generateMenuItems( {\n\t\t\t\tpanelItems,\n\t\t\t\tshouldReset: false,\n\t\t\t\tcurrentMenuItems: prevState,\n\t\t\t} );\n\t\t\treturn items;\n\t\t} );\n\t}, [ panelItems, setMenuItems ] );\n\n\t// Force a menu item to be checked.\n\t// This is intended for use with default panel items. They are displayed\n\t// separately to optional items and have different display states,\n\t// we need to update that when their value is customized.\n\tconst flagItemCustomization = useCallback(\n\t\t( label: string, group: ToolsPanelMenuItemKey = 'default' ) => {\n\t\t\tsetMenuItems( ( items ) => {\n\t\t\t\tconst newState = {\n\t\t\t\t\t...items,\n\t\t\t\t\t[ group ]: {\n\t\t\t\t\t\t...items[ group ],\n\t\t\t\t\t\t[ label ]: true,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn newState;\n\t\t\t} );\n\t\t},\n\t\t[ setMenuItems ]\n\t);\n\n\t// Whether all optional menu items are hidden or not must be tracked\n\t// in order to later determine if the panel display is empty and handle\n\t// conditional display of a plus icon to indicate the presence of further\n\t// menu items.\n\tconst [ areAllOptionalControlsHidden, setAreAllOptionalControlsHidden ] =\n\t\tuseState( false );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tisMenuItemTypeEmpty( menuItems?.default ) &&\n\t\t\t! isMenuItemTypeEmpty( menuItems?.optional )\n\t\t) {\n\t\t\tconst allControlsHidden = ! Object.entries(\n\t\t\t\tmenuItems.optional\n\t\t\t).some( ( [ , isSelected ] ) => isSelected );\n\t\t\tsetAreAllOptionalControlsHidden( allControlsHidden );\n\t\t}\n\t}, [ menuItems, setAreAllOptionalControlsHidden ] );\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\tconst wrapperStyle =\n\t\t\thasInnerWrapper &&\n\t\t\tstyles.ToolsPanelWithInnerWrapper( DEFAULT_COLUMNS );\n\t\tconst emptyStyle =\n\t\t\tisMenuItemTypeEmpty( menuItems?.default ) &&\n\t\t\tareAllOptionalControlsHidden &&\n\t\t\tstyles.ToolsPanelHiddenInnerWrapper;\n\n\t\treturn cx(\n\t\t\tstyles.ToolsPanel( DEFAULT_COLUMNS ),\n\t\t\twrapperStyle,\n\t\t\temptyStyle,\n\t\t\tclassName\n\t\t);\n\t}, [\n\t\tareAllOptionalControlsHidden,\n\t\tclassName,\n\t\tcx,\n\t\thasInnerWrapper,\n\t\tmenuItems,\n\t] );\n\n\t// Toggle the checked state of a menu item which is then used to determine\n\t// display of the item within the panel.\n\tconst toggleItem = useCallback(\n\t\t( label: string ) => {\n\t\t\tconst currentItem = panelItems.find(\n\t\t\t\t( item ) => item.label === label\n\t\t\t);\n\n\t\t\tif ( ! currentItem ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst menuGroup = currentItem.isShownByDefault\n\t\t\t\t? 'default'\n\t\t\t\t: 'optional';\n\n\t\t\tconst newMenuItems = {\n\t\t\t\t...menuItems,\n\t\t\t\t[ menuGroup ]: {\n\t\t\t\t\t...menuItems[ menuGroup ],\n\t\t\t\t\t[ label ]: ! menuItems[ menuGroup ][ label ],\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tsetMenuItems( newMenuItems );\n\t\t},\n\t\t[ menuItems, panelItems, setMenuItems ]\n\t);\n\n\t// Resets display of children and executes resetAll callback if available.\n\tconst resetAllItems = useCallback( () => {\n\t\tif ( typeof resetAll === 'function' ) {\n\t\t\tisResetting.current = true;\n\n\t\t\t// Collect available reset filters from panel items.\n\t\t\tconst filters: Array< () => void > = [];\n\t\t\tpanelItems.forEach( ( item ) => {\n\t\t\t\tif ( item.resetAllFilter ) {\n\t\t\t\t\tfilters.push( item.resetAllFilter );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tresetAll( filters );\n\t\t}\n\n\t\t// Turn off display of all non-default items.\n\t\tconst resetMenuItems = generateMenuItems( {\n\t\t\tpanelItems,\n\t\t\tshouldReset: true,\n\t\t} );\n\t\tsetMenuItems( resetMenuItems );\n\t}, [ panelItems, resetAll, setMenuItems ] );\n\n\t// Assist ItemGroup styling when there are potentially hidden placeholder\n\t// items by identifying first & last items that are toggled on for display.\n\tconst getFirstVisibleItemLabel = ( items: ToolsPanelItem[] ) => {\n\t\tconst optionalItems = menuItems.optional || {};\n\t\tconst firstItem = items.find(\n\t\t\t( item ) => item.isShownByDefault || !! optionalItems[ item.label ]\n\t\t);\n\n\t\treturn firstItem?.label;\n\t};\n\n\tconst firstDisplayedItem = getFirstVisibleItemLabel( panelItems );\n\tconst lastDisplayedItem = getFirstVisibleItemLabel(\n\t\t[ ...panelItems ].reverse()\n\t);\n\n\tconst panelContext = useMemo(\n\t\t() => ( {\n\t\t\tareAllOptionalControlsHidden,\n\t\t\tderegisterPanelItem,\n\t\t\tfirstDisplayedItem,\n\t\t\tflagItemCustomization,\n\t\t\thasMenuItems: !! panelItems.length,\n\t\t\tisResetting: isResetting.current,\n\t\t\tlastDisplayedItem,\n\t\t\tmenuItems,\n\t\t\tpanelId,\n\t\t\tregisterPanelItem,\n\t\t\tshouldRenderPlaceholderItems,\n\t\t\t__experimentalFirstVisibleItemClass,\n\t\t\t__experimentalLastVisibleItemClass,\n\t\t} ),\n\t\t[\n\t\t\tareAllOptionalControlsHidden,\n\t\t\tderegisterPanelItem,\n\t\t\tfirstDisplayedItem,\n\t\t\tflagItemCustomization,\n\t\t\tlastDisplayedItem,\n\t\t\tmenuItems,\n\t\t\tpanelId,\n\t\t\tpanelItems,\n\t\t\tregisterPanelItem,\n\t\t\tshouldRenderPlaceholderItems,\n\t\t\t__experimentalFirstVisibleItemClass,\n\t\t\t__experimentalLastVisibleItemClass,\n\t\t]\n\t);\n\n\treturn {\n\t\t...otherProps,\n\t\tpanelContext,\n\t\tresetAllItems,\n\t\ttoggleItem,\n\t\tclassName: classes,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel/hook.ts"],"names":["useCallback","useEffect","useMemo","useRef","useState","styles","useContextSystem","useCx","DEFAULT_COLUMNS","generateMenuItems","panelItems","shouldReset","currentMenuItems","menuItems","default","optional","forEach","hasValue","isShownByDefault","label","group","existingItemValue","value","isMenuItemTypeEmpty","obj","Object","keys","length","useToolsPanel","props","className","headingLevel","resetAll","panelId","hasInnerWrapper","shouldRenderPlaceholderItems","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass","otherProps","isResetting","wasResetting","current","setPanelItems","registerPanelItem","item","items","newItems","existingIndex","findIndex","oldItem","splice","deregisterPanelItem","index","setMenuItems","prevState","flagItemCustomization","newState","areAllOptionalControlsHidden","setAreAllOptionalControlsHidden","allControlsHidden","entries","some","isSelected","cx","classes","wrapperStyle","ToolsPanelWithInnerWrapper","emptyStyle","ToolsPanelHiddenInnerWrapper","ToolsPanel","toggleItem","currentItem","find","menuGroup","newMenuItems","resetAllItems","filters","resetAllFilter","push","resetMenuItems","getFirstVisibleItemLabel","optionalItems","firstItem","firstDisplayedItem","lastDisplayedItem","reverse","panelContext","hasMenuItems"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,WADD,EAECC,SAFD,EAGCC,OAHD,EAICC,MAJD,EAKCC,QALD,QAMO,oBANP;AAQA;AACA;AACA;;AACA,OAAO,KAAKC,MAAZ,MAAwB,WAAxB;AACA,SAASC,gBAAT,QAA0D,kBAA1D;AACA,SAASC,KAAT,QAAsB,0BAAtB;AASA,MAAMC,eAAe,GAAG,CAAxB;;AAEA,MAAMC,iBAAiB,GAAG,QAIQ;AAAA,MAJN;AAC3BC,IAAAA,UAD2B;AAE3BC,IAAAA,WAF2B;AAG3BC,IAAAA;AAH2B,GAIM;AACjC,QAAMC,SAA8B,GAAG;AAAEC,IAAAA,OAAO,EAAE,EAAX;AAAeC,IAAAA,QAAQ,EAAE;AAAzB,GAAvC;AAEAL,EAAAA,UAAU,CAACM,OAAX,CAAoB,SAA6C;AAAA;;AAAA,QAA3C;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,gBAAZ;AAA8BC,MAAAA;AAA9B,KAA2C;AAChE,UAAM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AAA,4BADO;AAEPN,IAAAA,mBAFO;AAGPgC,IAAAA,kBAHO;AAIP5B,IAAAA,qBAJO;AAKPgC,IAAAA,YAAY,EAAE,CAAC,CAAE7E,UAAU,CAACiB,MALrB;AAMPY,IAAAA,WAAW,EAAEA,WAAW,CAACE,OANlB;AAOP2C,IAAAA,iBAPO;AAQPvE,IAAAA,SARO;AASPoB,IAAAA,OATO;AAUPU,IAAAA,iBAVO;AAWPR,IAAAA,4BAXO;AAYPC,IAAAA,mCAZO;AAaPC,IAAAA;AAbO,GAAR,CAD2B,EAgB3B,CACCoB,4BADD,EAECN,mBAFD,EAGCgC,kBAHD,EAIC5B,qBAJD,EAKC6B,iBALD,EAMCvE,SAND,EAOCoB,OAPD,EAQCvB,UARD,EASCiC,iBATD,EAUCR,4BAVD,EAWCC,mCAXD,EAYCC,kCAZD,CAhB2B,CAA5B;AAgCA,SAAO,EACN,GAAGC,UADG;AAENP,IAAAA,YAFM;AAGNuD,IAAAA,YAHM;AAINX,IAAAA,aAJM;AAKNL,IAAAA,UALM;AAMNxC,IAAAA,SAAS,EAAEkC;AANL,GAAP;AAQA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type {\n\tToolsPanelItem,\n\tToolsPanelMenuItemKey,\n\tToolsPanelMenuItems,\n\tToolsPanelMenuItemsConfig,\n\tToolsPanelProps,\n} from '../types';\n\nconst DEFAULT_COLUMNS = 2;\n\nconst generateMenuItems = ( {\n\tpanelItems,\n\tshouldReset,\n\tcurrentMenuItems,\n}: ToolsPanelMenuItemsConfig ) => {\n\tconst menuItems: ToolsPanelMenuItems = { default: {}, optional: {} };\n\n\tpanelItems.forEach( ( { hasValue, isShownByDefault, label } ) => {\n\t\tconst group = isShownByDefault ? 'default' : 'optional';\n\n\t\t// If a menu item for this label has already been flagged as customized\n\t\t// (for default controls), or toggled on (for optional controls), do not\n\t\t// overwrite its value as those controls would lose that state.\n\t\tconst existingItemValue = currentMenuItems?.[ group ]?.[ label ];\n\t\tconst value = existingItemValue ? existingItemValue : hasValue();\n\n\t\tmenuItems[ group ][ label ] = shouldReset ? false : value;\n\t} );\n\n\treturn menuItems;\n};\n\nconst isMenuItemTypeEmpty = (\n\tobj?: ToolsPanelMenuItems[ ToolsPanelMenuItemKey ]\n) => obj && Object.keys( obj ).length === 0;\n\nexport function useToolsPanel(\n\tprops: WordPressComponentProps< ToolsPanelProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\theadingLevel = 2,\n\t\tresetAll,\n\t\tpanelId,\n\t\thasInnerWrapper = false,\n\t\tshouldRenderPlaceholderItems = false,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToolsPanel' );\n\n\tconst isResetting = useRef( false );\n\tconst wasResetting = isResetting.current;\n\n\t// `isResetting` is cleared via this hook to effectively batch together\n\t// the resetAll task. Without this, the flag is cleared after the first\n\t// control updates and forces a rerender with subsequent controls then\n\t// believing they need to reset, unfortunately using stale data.\n\tuseEffect( () => {\n\t\tif ( wasResetting ) {\n\t\t\tisResetting.current = false;\n\t\t}\n\t}, [ wasResetting ] );\n\n\t// Allow panel items to register themselves.\n\tconst [ panelItems, setPanelItems ] = useState< ToolsPanelItem[] >( [] );\n\n\tconst registerPanelItem = useCallback(\n\t\t( item: ToolsPanelItem ) => {\n\t\t\tsetPanelItems( ( items ) => {\n\t\t\t\tconst newItems = [ ...items ];\n\t\t\t\t// If an item with this label has already been registered, remove it\n\t\t\t\t// first. This can happen when an item is moved between the default\n\t\t\t\t// and optional groups.\n\t\t\t\tconst existingIndex = newItems.findIndex(\n\t\t\t\t\t( oldItem ) => oldItem.label === item.label\n\t\t\t\t);\n\t\t\t\tif ( existingIndex !== -1 ) {\n\t\t\t\t\tnewItems.splice( existingIndex, 1 );\n\t\t\t\t}\n\t\t\t\treturn [ ...newItems, item ];\n\t\t\t} );\n\t\t},\n\t\t[ setPanelItems ]\n\t);\n\n\t// Panels need to deregister on unmount to avoid orphans in menu state.\n\t// This is an issue when panel items are being injected via SlotFills.\n\tconst deregisterPanelItem = useCallback(\n\t\t( label: string ) => {\n\t\t\t// When switching selections between components injecting matching\n\t\t\t// controls, e.g. both panels have a \"padding\" control, the\n\t\t\t// deregistration of the first panel doesn't occur until after the\n\t\t\t// registration of the next.\n\t\t\tsetPanelItems( ( items ) => {\n\t\t\t\tconst newItems = [ ...items ];\n\t\t\t\tconst index = newItems.findIndex(\n\t\t\t\t\t( item ) => item.label === label\n\t\t\t\t);\n\t\t\t\tif ( index !== -1 ) {\n\t\t\t\t\tnewItems.splice( index, 1 );\n\t\t\t\t}\n\t\t\t\treturn newItems;\n\t\t\t} );\n\t\t},\n\t\t[ setPanelItems ]\n\t);\n\n\t// Manage and share display state of menu items representing child controls.\n\tconst [ menuItems, setMenuItems ] = useState< ToolsPanelMenuItems >( {\n\t\tdefault: {},\n\t\toptional: {},\n\t} );\n\n\t// Setup menuItems state as panel items register themselves.\n\tuseEffect( () => {\n\t\tsetMenuItems( ( prevState ) => {\n\t\t\tconst items = generateMenuItems( {\n\t\t\t\tpanelItems,\n\t\t\t\tshouldReset: false,\n\t\t\t\tcurrentMenuItems: prevState,\n\t\t\t} );\n\t\t\treturn items;\n\t\t} );\n\t}, [ panelItems, setMenuItems ] );\n\n\t// Force a menu item to be checked.\n\t// This is intended for use with default panel items. They are displayed\n\t// separately to optional items and have different display states,\n\t// we need to update that when their value is customized.\n\tconst flagItemCustomization = useCallback(\n\t\t( label: string, group: ToolsPanelMenuItemKey = 'default' ) => {\n\t\t\tsetMenuItems( ( items ) => {\n\t\t\t\tconst newState = {\n\t\t\t\t\t...items,\n\t\t\t\t\t[ group ]: {\n\t\t\t\t\t\t...items[ group ],\n\t\t\t\t\t\t[ label ]: true,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn newState;\n\t\t\t} );\n\t\t},\n\t\t[ setMenuItems ]\n\t);\n\n\t// Whether all optional menu items are hidden or not must be tracked\n\t// in order to later determine if the panel display is empty and handle\n\t// conditional display of a plus icon to indicate the presence of further\n\t// menu items.\n\tconst [ areAllOptionalControlsHidden, setAreAllOptionalControlsHidden ] =\n\t\tuseState( false );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tisMenuItemTypeEmpty( menuItems?.default ) &&\n\t\t\t! isMenuItemTypeEmpty( menuItems?.optional )\n\t\t) {\n\t\t\tconst allControlsHidden = ! Object.entries(\n\t\t\t\tmenuItems.optional\n\t\t\t).some( ( [ , isSelected ] ) => isSelected );\n\t\t\tsetAreAllOptionalControlsHidden( allControlsHidden );\n\t\t}\n\t}, [ menuItems, setAreAllOptionalControlsHidden ] );\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\tconst wrapperStyle =\n\t\t\thasInnerWrapper &&\n\t\t\tstyles.ToolsPanelWithInnerWrapper( DEFAULT_COLUMNS );\n\t\tconst emptyStyle =\n\t\t\tisMenuItemTypeEmpty( menuItems?.default ) &&\n\t\t\tareAllOptionalControlsHidden &&\n\t\t\tstyles.ToolsPanelHiddenInnerWrapper;\n\n\t\treturn cx(\n\t\t\tstyles.ToolsPanel( DEFAULT_COLUMNS ),\n\t\t\twrapperStyle,\n\t\t\temptyStyle,\n\t\t\tclassName\n\t\t);\n\t}, [\n\t\tareAllOptionalControlsHidden,\n\t\tclassName,\n\t\tcx,\n\t\thasInnerWrapper,\n\t\tmenuItems,\n\t] );\n\n\t// Toggle the checked state of a menu item which is then used to determine\n\t// display of the item within the panel.\n\tconst toggleItem = useCallback(\n\t\t( label: string ) => {\n\t\t\tconst currentItem = panelItems.find(\n\t\t\t\t( item ) => item.label === label\n\t\t\t);\n\n\t\t\tif ( ! currentItem ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst menuGroup = currentItem.isShownByDefault\n\t\t\t\t? 'default'\n\t\t\t\t: 'optional';\n\n\t\t\tconst newMenuItems = {\n\t\t\t\t...menuItems,\n\t\t\t\t[ menuGroup ]: {\n\t\t\t\t\t...menuItems[ menuGroup ],\n\t\t\t\t\t[ label ]: ! menuItems[ menuGroup ][ label ],\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tsetMenuItems( newMenuItems );\n\t\t},\n\t\t[ menuItems, panelItems, setMenuItems ]\n\t);\n\n\t// Resets display of children and executes resetAll callback if available.\n\tconst resetAllItems = useCallback( () => {\n\t\tif ( typeof resetAll === 'function' ) {\n\t\t\tisResetting.current = true;\n\n\t\t\t// Collect available reset filters from panel items.\n\t\t\tconst filters: Array< () => void > = [];\n\t\t\tpanelItems.forEach( ( item ) => {\n\t\t\t\tif ( item.resetAllFilter ) {\n\t\t\t\t\tfilters.push( item.resetAllFilter );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tresetAll( filters );\n\t\t}\n\n\t\t// Turn off display of all non-default items.\n\t\tconst resetMenuItems = generateMenuItems( {\n\t\t\tpanelItems,\n\t\t\tshouldReset: true,\n\t\t} );\n\t\tsetMenuItems( resetMenuItems );\n\t}, [ panelItems, resetAll, setMenuItems ] );\n\n\t// Assist ItemGroup styling when there are potentially hidden placeholder\n\t// items by identifying first & last items that are toggled on for display.\n\tconst getFirstVisibleItemLabel = ( items: ToolsPanelItem[] ) => {\n\t\tconst optionalItems = menuItems.optional || {};\n\t\tconst firstItem = items.find(\n\t\t\t( item ) => item.isShownByDefault || !! optionalItems[ item.label ]\n\t\t);\n\n\t\treturn firstItem?.label;\n\t};\n\n\tconst firstDisplayedItem = getFirstVisibleItemLabel( panelItems );\n\tconst lastDisplayedItem = getFirstVisibleItemLabel(\n\t\t[ ...panelItems ].reverse()\n\t);\n\n\tconst panelContext = useMemo(\n\t\t() => ( {\n\t\t\tareAllOptionalControlsHidden,\n\t\t\tderegisterPanelItem,\n\t\t\tfirstDisplayedItem,\n\t\t\tflagItemCustomization,\n\t\t\thasMenuItems: !! panelItems.length,\n\t\t\tisResetting: isResetting.current,\n\t\t\tlastDisplayedItem,\n\t\t\tmenuItems,\n\t\t\tpanelId,\n\t\t\tregisterPanelItem,\n\t\t\tshouldRenderPlaceholderItems,\n\t\t\t__experimentalFirstVisibleItemClass,\n\t\t\t__experimentalLastVisibleItemClass,\n\t\t} ),\n\t\t[\n\t\t\tareAllOptionalControlsHidden,\n\t\t\tderegisterPanelItem,\n\t\t\tfirstDisplayedItem,\n\t\t\tflagItemCustomization,\n\t\t\tlastDisplayedItem,\n\t\t\tmenuItems,\n\t\t\tpanelId,\n\t\t\tpanelItems,\n\t\t\tregisterPanelItem,\n\t\t\tshouldRenderPlaceholderItems,\n\t\t\t__experimentalFirstVisibleItemClass,\n\t\t\t__experimentalLastVisibleItemClass,\n\t\t]\n\t);\n\n\treturn {\n\t\t...otherProps,\n\t\theadingLevel,\n\t\tpanelContext,\n\t\tresetAllItems,\n\t\ttoggleItem,\n\t\tclassName: classes,\n\t};\n}\n"]}
|
|
@@ -114,6 +114,7 @@ const ToolsPanelHeader = (props, forwardedRef) => {
|
|
|
114
114
|
dropdownMenuClassName,
|
|
115
115
|
hasMenuItems,
|
|
116
116
|
headingClassName,
|
|
117
|
+
headingLevel = 2,
|
|
117
118
|
label: labelText,
|
|
118
119
|
menuItems,
|
|
119
120
|
resetAll,
|
|
@@ -138,7 +139,7 @@ const ToolsPanelHeader = (props, forwardedRef) => {
|
|
|
138
139
|
return createElement(HStack, _extends({}, headerProps, {
|
|
139
140
|
ref: forwardedRef
|
|
140
141
|
}), createElement(Heading, {
|
|
141
|
-
level:
|
|
142
|
+
level: headingLevel,
|
|
142
143
|
className: headingClassName
|
|
143
144
|
}, labelText), hasMenuItems && createElement(DropdownMenu, {
|
|
144
145
|
icon: dropDownMenuIcon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-header/component.tsx"],"names":["speak","check","moreVertical","plus","__","_x","sprintf","DropdownMenu","MenuGroup","MenuItem","HStack","Heading","useToolsPanelHeader","contextConnect","ResetLabel","DefaultControlsGroup","itemClassName","items","toggleItem","length","resetSuffix","map","label","hasValue","OptionalControlsGroup","isSelected","itemLabel","ToolsPanelHeader","props","forwardedRef","areAllOptionalControlsHidden","defaultControlsItemClassName","dropdownMenuClassName","hasMenuItems","headingClassName","labelText","menuItems","resetAll","headerProps","defaultItems","Object","entries","default","optionalItems","optional","dropDownMenuIcon","dropDownMenuLabelText","dropdownMenuDescriptionText","undefined","canResetAll","some","className","isSmall","describedBy","ConnectedToolsPanelHeader"],"mappings":";;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,iBAAtB;AACA,SAASC,KAAT,EAAgBC,YAAhB,EAA8BC,IAA9B,QAA0C,kBAA1C;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,qBAAzB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,SAASC,MAAT,QAAuB,eAAvB;AACA,SAASC,OAAT,QAAwB,eAAxB;AACA,SAASC,mBAAT,QAAoC,QAApC;AACA,SAASC,cAAT,QAAwD,kBAAxD;AACA,SAASC,UAAT,QAA2B,WAA3B;;AAMA,MAAMC,oBAAoB,GAAG,QAIQ;AAAA,MAJN;AAC9BC,IAAAA,aAD8B;AAE9BC,IAAAA,KAF8B;AAG9BC,IAAAA;AAH8B,GAIM;;AACpC,MAAK,CAAED,KAAK,CAACE,MAAb,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,QAAMC,WAAW,GAAG,cAAC,UAAD;AAAY;AAAZ,KAA0BhB,EAAE,CAAE,OAAF,CAA5B,CAApB;AAEA,SACC,cAAC,SAAD;AAAW,IAAA,KAA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ACC,qBAAgB,CAAE+B,WADnB;AAEC,IAAA,OAAO,EAAG,UAFX;AAGC,IAAA,OAAO,EAAG,MAAM;AACf,UAAKA,WAAL,EAAmB;AAClBZ,QAAAA,QAAQ;AACRrC,QAAAA,KAAK,CACJI,EAAE,CAAE,mBAAF,CADE,EAEJ,WAFI,CAAL;AAIA;AACD;AAXF,KAaGA,EAAE,CAAE,WAAF,CAbL,CADD,CAVD,CAVF,CALF,CADD;AAiDA,CAtFD;;AAwFA,MAAMkD,yBAAyB,GAAGzC,cAAc,CAC/Cc,gBAD+C,EAE/C,kBAF+C,CAAhD;AAKA,eAAe2B,yBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { check, moreVertical, plus } from '@wordpress/icons';\nimport { __, _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport MenuGroup from '../../menu-group';\nimport MenuItem from '../../menu-item';\nimport { HStack } from '../../h-stack';\nimport { Heading } from '../../heading';\nimport { useToolsPanelHeader } from './hook';\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport { ResetLabel } from '../styles';\nimport type {\n\tToolsPanelControlsGroupProps,\n\tToolsPanelHeaderProps,\n} from '../types';\n\nconst DefaultControlsGroup = ( {\n\titemClassName,\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\tconst resetSuffix = <ResetLabel aria-hidden>{ __( 'Reset' ) }</ResetLabel>;\n\n\treturn (\n\t\t<MenuGroup label={ __( 'Defaults' ) }>\n\t\t\t{ items.map( ( [ label, hasValue ] ) => {\n\t\t\t\tif ( hasValue ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\tclassName={ itemClassName }\n\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t__( 'Reset %s' ),\n\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsuffix={ resetSuffix }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\tclassName={ itemClassName }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\tisSelected\n\t\t\t\t\t\taria-disabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</MenuGroup>\n\t);\n};\n\nconst OptionalControlsGroup = ( {\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t{ items.map( ( [ label, isSelected ] ) => {\n\t\t\t\tconst itemLabel = isSelected\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control being hidden and reset e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Hide and reset %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control to display e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Show %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t );\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\ticon={ isSelected && check }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tlabel={ itemLabel }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( isSelected ) {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s hidden and reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s is now visible' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</MenuGroup>\n\t);\n};\n\nconst ToolsPanelHeader = (\n\tprops: WordPressComponentProps< ToolsPanelHeaderProps, 'h2' >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tareAllOptionalControlsHidden,\n\t\tdefaultControlsItemClassName,\n\t\tdropdownMenuClassName,\n\t\thasMenuItems,\n\t\theadingClassName,\n\t\tlabel: labelText,\n\t\tmenuItems,\n\t\tresetAll,\n\t\ttoggleItem,\n\t\t...headerProps\n\t} = useToolsPanelHeader( props );\n\n\tif ( ! labelText ) {\n\t\treturn null;\n\t}\n\n\tconst defaultItems = Object.entries( menuItems?.default || {} );\n\tconst optionalItems = Object.entries( menuItems?.optional || {} );\n\tconst dropDownMenuIcon = areAllOptionalControlsHidden ? plus : moreVertical;\n\tconst dropDownMenuLabelText = sprintf(\n\t\t// translators: %s: The name of the tool e.g. \"Color\" or \"Typography\".\n\t\t_x( '%s options', 'Button label to reveal tool panel options' ),\n\t\tlabelText\n\t);\n\tconst dropdownMenuDescriptionText = areAllOptionalControlsHidden\n\t\t? __( 'All options are currently hidden' )\n\t\t: undefined;\n\n\tconst canResetAll = [ ...defaultItems, ...optionalItems ].some(\n\t\t( [ , isSelected ] ) => isSelected\n\t);\n\n\treturn (\n\t\t<HStack { ...headerProps } ref={ forwardedRef }>\n\t\t\t<Heading level={ 2 } className={ headingClassName }>\n\t\t\t\t{ labelText }\n\t\t\t</Heading>\n\t\t\t{ hasMenuItems && (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\ticon={ dropDownMenuIcon }\n\t\t\t\t\tlabel={ dropDownMenuLabelText }\n\t\t\t\t\tmenuProps={ { className: dropdownMenuClassName } }\n\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\tisSmall: true,\n\t\t\t\t\t\tdescribedBy: dropdownMenuDescriptionText,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ () => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<DefaultControlsGroup\n\t\t\t\t\t\t\t\titems={ defaultItems }\n\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t\titemClassName={ defaultControlsItemClassName }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<OptionalControlsGroup\n\t\t\t\t\t\t\t\titems={ optionalItems }\n\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\taria-disabled={ ! canResetAll }\n\t\t\t\t\t\t\t\t\tvariant={ 'tertiary' }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tif ( canResetAll ) {\n\t\t\t\t\t\t\t\t\t\t\tresetAll();\n\t\t\t\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'All options reset' ),\n\t\t\t\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Reset all' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</DropdownMenu>\n\t\t\t) }\n\t\t</HStack>\n\t);\n};\n\nconst ConnectedToolsPanelHeader = contextConnect(\n\tToolsPanelHeader,\n\t'ToolsPanelHeader'\n);\n\nexport default ConnectedToolsPanelHeader;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-header/component.tsx"],"names":["speak","check","moreVertical","plus","__","_x","sprintf","DropdownMenu","MenuGroup","MenuItem","HStack","Heading","useToolsPanelHeader","contextConnect","ResetLabel","DefaultControlsGroup","itemClassName","items","toggleItem","length","resetSuffix","map","label","hasValue","OptionalControlsGroup","isSelected","itemLabel","ToolsPanelHeader","props","forwardedRef","areAllOptionalControlsHidden","defaultControlsItemClassName","dropdownMenuClassName","hasMenuItems","headingClassName","headingLevel","labelText","menuItems","resetAll","headerProps","defaultItems","Object","entries","default","optionalItems","optional","dropDownMenuIcon","dropDownMenuLabelText","dropdownMenuDescriptionText","undefined","canResetAll","some","className","isSmall","describedBy","ConnectedToolsPanelHeader"],"mappings":";;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,iBAAtB;AACA,SAASC,KAAT,EAAgBC,YAAhB,EAA8BC,IAA9B,QAA0C,kBAA1C;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,qBAAzB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,SAASC,MAAT,QAAuB,eAAvB;AACA,SAASC,OAAT,QAAwB,eAAxB;AACA,SAASC,mBAAT,QAAoC,QAApC;AACA,SAASC,cAAT,QAAwD,kBAAxD;AACA,SAASC,UAAT,QAA2B,WAA3B;;AAMA,MAAMC,oBAAoB,GAAG,QAIQ;AAAA,MAJN;AAC9BC,IAAAA,aAD8B;AAE9BC,IAAAA,KAF8B;AAG9BC,IAAAA;AAH8B,GAIM;;AACpC,MAAK,CAAED,KAAK,CAACE,MAAb,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,QAAMC,WAAW,GAAG,cAAC,UAAD;AAAY;AAAZ,KAA0BhB,EAAE,CAAE,OAAF,CAA5B,CAApB;AAEA,SACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGA,EAAE,CAAE,UAAF;AAArB,KACGa,KAAK,CAACI,GAAN,CAAW,SAA2B;AAAA,QAAzB,CAAEC,KAAF,EAASC,QAAT,CAAyB;;AACvC,QAAKA,QAAL,EAAgB;AACf,aACC,cAAC,QAAD;AACC,QAAA,GAAG,EAAGD,KADP;AAEC,Q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AAE,mBAAF,CADE,EAEJ,WAFI,CAAL;AAIA;AACD;AAXF,KAaGA,EAAE,CAAE,WAAF,CAbL,CADD,CAVD,CAVF,CALF,CADD;AAiDA,CAvFD;;AAyFA,MAAMmD,yBAAyB,GAAG1C,cAAc,CAC/Cc,gBAD+C,EAE/C,kBAF+C,CAAhD;AAKA,eAAe4B,yBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { check, moreVertical, plus } from '@wordpress/icons';\nimport { __, _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport MenuGroup from '../../menu-group';\nimport MenuItem from '../../menu-item';\nimport { HStack } from '../../h-stack';\nimport { Heading } from '../../heading';\nimport { useToolsPanelHeader } from './hook';\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport { ResetLabel } from '../styles';\nimport type {\n\tToolsPanelControlsGroupProps,\n\tToolsPanelHeaderProps,\n} from '../types';\n\nconst DefaultControlsGroup = ( {\n\titemClassName,\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\tconst resetSuffix = <ResetLabel aria-hidden>{ __( 'Reset' ) }</ResetLabel>;\n\n\treturn (\n\t\t<MenuGroup label={ __( 'Defaults' ) }>\n\t\t\t{ items.map( ( [ label, hasValue ] ) => {\n\t\t\t\tif ( hasValue ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\tclassName={ itemClassName }\n\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t__( 'Reset %s' ),\n\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsuffix={ resetSuffix }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\tclassName={ itemClassName }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\tisSelected\n\t\t\t\t\t\taria-disabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</MenuGroup>\n\t);\n};\n\nconst OptionalControlsGroup = ( {\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t{ items.map( ( [ label, isSelected ] ) => {\n\t\t\t\tconst itemLabel = isSelected\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control being hidden and reset e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Hide and reset %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control to display e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Show %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t );\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\ticon={ isSelected && check }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tlabel={ itemLabel }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( isSelected ) {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s hidden and reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s is now visible' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</MenuGroup>\n\t);\n};\n\nconst ToolsPanelHeader = (\n\tprops: WordPressComponentProps< ToolsPanelHeaderProps, 'h2' >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tareAllOptionalControlsHidden,\n\t\tdefaultControlsItemClassName,\n\t\tdropdownMenuClassName,\n\t\thasMenuItems,\n\t\theadingClassName,\n\t\theadingLevel = 2,\n\t\tlabel: labelText,\n\t\tmenuItems,\n\t\tresetAll,\n\t\ttoggleItem,\n\t\t...headerProps\n\t} = useToolsPanelHeader( props );\n\n\tif ( ! labelText ) {\n\t\treturn null;\n\t}\n\n\tconst defaultItems = Object.entries( menuItems?.default || {} );\n\tconst optionalItems = Object.entries( menuItems?.optional || {} );\n\tconst dropDownMenuIcon = areAllOptionalControlsHidden ? plus : moreVertical;\n\tconst dropDownMenuLabelText = sprintf(\n\t\t// translators: %s: The name of the tool e.g. \"Color\" or \"Typography\".\n\t\t_x( '%s options', 'Button label to reveal tool panel options' ),\n\t\tlabelText\n\t);\n\tconst dropdownMenuDescriptionText = areAllOptionalControlsHidden\n\t\t? __( 'All options are currently hidden' )\n\t\t: undefined;\n\n\tconst canResetAll = [ ...defaultItems, ...optionalItems ].some(\n\t\t( [ , isSelected ] ) => isSelected\n\t);\n\n\treturn (\n\t\t<HStack { ...headerProps } ref={ forwardedRef }>\n\t\t\t<Heading level={ headingLevel } className={ headingClassName }>\n\t\t\t\t{ labelText }\n\t\t\t</Heading>\n\t\t\t{ hasMenuItems && (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\ticon={ dropDownMenuIcon }\n\t\t\t\t\tlabel={ dropDownMenuLabelText }\n\t\t\t\t\tmenuProps={ { className: dropdownMenuClassName } }\n\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\tisSmall: true,\n\t\t\t\t\t\tdescribedBy: dropdownMenuDescriptionText,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ () => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<DefaultControlsGroup\n\t\t\t\t\t\t\t\titems={ defaultItems }\n\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t\titemClassName={ defaultControlsItemClassName }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<OptionalControlsGroup\n\t\t\t\t\t\t\t\titems={ optionalItems }\n\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\taria-disabled={ ! canResetAll }\n\t\t\t\t\t\t\t\t\tvariant={ 'tertiary' }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tif ( canResetAll ) {\n\t\t\t\t\t\t\t\t\t\t\tresetAll();\n\t\t\t\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'All options reset' ),\n\t\t\t\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Reset all' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</DropdownMenu>\n\t\t\t) }\n\t\t</HStack>\n\t);\n};\n\nconst ConnectedToolsPanelHeader = contextConnect(\n\tToolsPanelHeader,\n\t'ToolsPanelHeader'\n);\n\nexport default ConnectedToolsPanelHeader;\n"]}
|
|
@@ -13,6 +13,7 @@ import { useCx } from '../../utils/hooks/use-cx';
|
|
|
13
13
|
export function useToolsPanelHeader(props) {
|
|
14
14
|
const {
|
|
15
15
|
className,
|
|
16
|
+
headingLevel = 2,
|
|
16
17
|
...otherProps
|
|
17
18
|
} = useContextSystem(props, 'ToolsPanelHeader');
|
|
18
19
|
const cx = useCx();
|
|
@@ -39,6 +40,7 @@ export function useToolsPanelHeader(props) {
|
|
|
39
40
|
dropdownMenuClassName,
|
|
40
41
|
hasMenuItems,
|
|
41
42
|
headingClassName,
|
|
43
|
+
headingLevel,
|
|
42
44
|
menuItems,
|
|
43
45
|
className: classes
|
|
44
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-header/hook.ts"],"names":["useMemo","styles","useToolsPanelContext","useContextSystem","useCx","useToolsPanelHeader","props","className","otherProps","cx","classes","ToolsPanelHeader","dropdownMenuClassName","DropdownMenu","headingClassName","ToolsPanelHeading","defaultControlsItemClassName","DefaultControlsItem","menuItems","hasMenuItems","areAllOptionalControlsHidden"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,OAAO,KAAKC,MAAZ,MAAwB,WAAxB;AACA,SAASC,oBAAT,QAAqC,YAArC;AACA,SAASC,gBAAT,QAA0D,kBAA1D;AACA,SAASC,KAAT,QAAsB,0BAAtB;AAGA,OAAO,SAASC,mBAAT,CACNC,KADM,EAEL;AACD,QAAM;
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-header/hook.ts"],"names":["useMemo","styles","useToolsPanelContext","useContextSystem","useCx","useToolsPanelHeader","props","className","headingLevel","otherProps","cx","classes","ToolsPanelHeader","dropdownMenuClassName","DropdownMenu","headingClassName","ToolsPanelHeading","defaultControlsItemClassName","DefaultControlsItem","menuItems","hasMenuItems","areAllOptionalControlsHidden"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,OAAO,KAAKC,MAAZ,MAAwB,WAAxB;AACA,SAASC,oBAAT,QAAqC,YAArC;AACA,SAASC,gBAAT,QAA0D,kBAA1D;AACA,SAASC,KAAT,QAAsB,0BAAtB;AAGA,OAAO,SAASC,mBAAT,CACNC,KADM,EAEL;AACD,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,YAAY,GAAG,CAFV;AAGL,OAAGC;AAHE,MAIFN,gBAAgB,CAAEG,KAAF,EAAS,kBAAT,CAJpB;AAMA,QAAMI,EAAE,GAAGN,KAAK,EAAhB;AACA,QAAMO,OAAO,GAAGX,OAAO,CAAE,MAAM;AAC9B,WAAOU,EAAE,CAAET,MAAM,CAACW,gBAAT,EAA2BL,SAA3B,CAAT;AACA,GAFsB,EAEpB,CAAEA,SAAF,EAAaG,EAAb,CAFoB,CAAvB;AAIA,QAAMG,qBAAqB,GAAGb,OAAO,CAAE,MAAM;AAC5C,WAAOU,EAAE,CAAET,MAAM,CAACa,YAAT,CAAT;AACA,GAFoC,EAElC,CAAEJ,EAAF,CAFkC,CAArC;AAIA,QAAMK,gBAAgB,GAAGf,OAAO,CAAE,MAAM;AACvC,WAAOU,EAAE,CAAET,MAAM,CAACe,iBAAT,CAAT;AACA,GAF+B,EAE7B,CAAEN,EAAF,CAF6B,CAAhC;AAIA,QAAMO,4BAA4B,GAAGjB,OAAO,CAAE,MAAM;AACnD,WAAOU,EAAE,CAAET,MAAM,CAACiB,mBAAT,CAAT;AACA,GAF2C,EAEzC,CAAER,EAAF,CAFyC,CAA5C;AAIA,QAAM;AAAES,IAAAA,SAAF;AAAaC,IAAAA,YAAb;AAA2BC,IAAAA;AAA3B,MACLnB,oBAAoB,EADrB;AAGA,SAAO,EACN,GAAGO,UADG;AAENY,IAAAA,4BAFM;AAGNJ,IAAAA,4BAHM;AAINJ,IAAAA,qBAJM;AAKNO,IAAAA,YALM;AAMNL,IAAAA,gBANM;AAONP,IAAAA,YAPM;AAQNW,IAAAA,SARM;AASNZ,IAAAA,SAAS,EAAEI;AATL,GAAP;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useToolsPanelContext } from '../context';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type { ToolsPanelHeaderProps } from '../types';\n\nexport function useToolsPanelHeader(\n\tprops: WordPressComponentProps< ToolsPanelHeaderProps, 'h2' >\n) {\n\tconst {\n\t\tclassName,\n\t\theadingLevel = 2,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToolsPanelHeader' );\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\treturn cx( styles.ToolsPanelHeader, className );\n\t}, [ className, cx ] );\n\n\tconst dropdownMenuClassName = useMemo( () => {\n\t\treturn cx( styles.DropdownMenu );\n\t}, [ cx ] );\n\n\tconst headingClassName = useMemo( () => {\n\t\treturn cx( styles.ToolsPanelHeading );\n\t}, [ cx ] );\n\n\tconst defaultControlsItemClassName = useMemo( () => {\n\t\treturn cx( styles.DefaultControlsItem );\n\t}, [ cx ] );\n\n\tconst { menuItems, hasMenuItems, areAllOptionalControlsHidden } =\n\t\tuseToolsPanelContext();\n\n\treturn {\n\t\t...otherProps,\n\t\tareAllOptionalControlsHidden,\n\t\tdefaultControlsItemClassName,\n\t\tdropdownMenuClassName,\n\t\thasMenuItems,\n\t\theadingClassName,\n\t\theadingLevel,\n\t\tmenuItems,\n\t\tclassName: classes,\n\t};\n}\n"]}
|
|
@@ -14,7 +14,7 @@ import { contextConnect } from '../../ui/context';
|
|
|
14
14
|
|
|
15
15
|
// This wraps controls to be conditionally displayed within a tools panel. It
|
|
16
16
|
// prevents props being applied to HTML elements that would make them invalid.
|
|
17
|
-
const
|
|
17
|
+
const UnconnectedToolsPanelItem = (props, forwardedRef) => {
|
|
18
18
|
const {
|
|
19
19
|
children,
|
|
20
20
|
isShown,
|
|
@@ -33,6 +33,6 @@ const ToolsPanelItem = (props, forwardedRef) => {
|
|
|
33
33
|
}), children);
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
const
|
|
37
|
-
export default
|
|
36
|
+
export const ToolsPanelItem = contextConnect(UnconnectedToolsPanelItem, 'ToolsPanelItem');
|
|
37
|
+
export default ToolsPanelItem;
|
|
38
38
|
//# sourceMappingURL=component.js.map
|