@wordpress/block-editor 15.21.1 → 15.22.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 +6 -0
- package/README.md +2 -2
- package/build/components/block-card/index.cjs +4 -5
- package/build/components/block-card/index.cjs.map +2 -2
- package/build/components/block-editing-mode/index.cjs +13 -7
- package/build/components/block-editing-mode/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +35 -20
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-mover/mover-description.cjs +6 -6
- package/build/components/block-mover/mover-description.cjs.map +1 -1
- package/build/components/block-patterns-list/index.cjs.map +2 -2
- package/build/components/block-patterns-paging/index.cjs +4 -4
- package/build/components/block-patterns-paging/index.cjs.map +2 -2
- package/build/components/block-popover/use-popover-scroll.cjs.map +1 -1
- package/build/components/block-quick-navigation/index.cjs +7 -5
- package/build/components/block-quick-navigation/index.cjs.map +2 -2
- package/build/components/block-rename/modal.cjs +0 -1
- package/build/components/block-rename/modal.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-toolbar/edit-section-button.cjs.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.cjs +10 -4
- package/build/components/block-tools/use-block-toolbar-popover-props.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs +51 -19
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +25 -14
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +4 -1
- package/build/components/colors-gradients/dropdown.cjs.map +3 -3
- package/build/components/contrast-checker/index.cjs +22 -4
- package/build/components/contrast-checker/index.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/index.cjs +4 -5
- package/build/components/dimensions-tool/index.cjs.map +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs +1 -1
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +153 -25
- package/build/components/global-styles/background-panel.cjs.map +3 -3
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
- package/build/components/global-styles/color-panel.cjs +98 -375
- package/build/components/global-styles/color-panel.cjs.map +3 -3
- package/build/components/global-styles/dimensions-panel.cjs +1 -4
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +34 -0
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +82 -10
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/grid/grid-item-resizer.cjs.map +1 -1
- package/build/components/grid/grid-visualizer.cjs.map +1 -1
- package/build/components/iframe/index.cjs +6 -3
- package/build/components/iframe/index.cjs.map +3 -3
- package/build/components/image-editor/use-transform-image.cjs.map +1 -1
- package/build/components/inserter/get-appender-label.cjs.map +1 -1
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/search-items.cjs.map +1 -1
- package/build/components/inspector-controls/fill.cjs +1 -3
- package/build/components/inspector-controls/fill.cjs.map +2 -2
- package/build/components/inspector-controls/groups.cjs +2 -0
- package/build/components/inspector-controls/groups.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +76 -32
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
- package/build/components/line-height-control/index.cjs.map +1 -1
- package/build/components/link-control/index.cjs +2 -3
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/link-control/normalize-url.cjs.map +1 -1
- package/build/components/list-view/block-select-button.cjs +1 -10
- package/build/components/list-view/block-select-button.cjs.map +3 -3
- package/build/components/list-view/utils.cjs.map +1 -1
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/provider/index.cjs.map +1 -1
- package/build/components/provider/use-block-sync.cjs +3 -1
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/before-input-rules.cjs +1 -1
- package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/paste-handler.cjs.map +1 -1
- package/build/components/rich-text/prevent-event-discovery.cjs +1 -1
- package/build/components/rich-text/prevent-event-discovery.cjs.map +1 -1
- package/build/components/url-popover/image-url-input-ui.cjs +0 -2
- package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -3
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/writing-flow/use-tab-nav.cjs.map +1 -1
- package/build/hooks/anchor.cjs +1 -2
- package/build/hooks/anchor.cjs.map +2 -2
- package/build/hooks/background.cjs +124 -75
- package/build/hooks/background.cjs.map +3 -3
- package/build/hooks/block-fields/index.cjs +13 -2
- package/build/hooks/block-fields/index.cjs.map +2 -2
- package/build/hooks/color.cjs +0 -162
- package/build/hooks/color.cjs.map +3 -3
- package/build/hooks/contrast-checker.cjs +31 -28
- package/build/hooks/contrast-checker.cjs.map +3 -3
- package/build/hooks/custom-class-name.cjs +0 -1
- package/build/hooks/custom-class-name.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +13 -2
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/elements.cjs +142 -0
- package/build/hooks/elements.cjs.map +7 -0
- package/build/hooks/grid-visualizer.cjs +21 -11
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +65 -10
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +6 -3
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/list-view.cjs +10 -7
- package/build/hooks/list-view.cjs.map +2 -2
- package/build/hooks/spacing-visualizer.cjs.map +1 -1
- package/build/hooks/state-utils.cjs.map +1 -1
- package/build/hooks/states.cjs +2 -2
- package/build/hooks/states.cjs.map +2 -2
- package/build/hooks/style.cjs +50 -6
- package/build/hooks/style.cjs.map +2 -2
- package/build/hooks/typography.cjs +62 -10
- package/build/hooks/typography.cjs.map +3 -3
- package/build/layouts/flex.cjs +99 -6
- package/build/layouts/flex.cjs.map +2 -2
- package/build/private-apis.cjs +4 -0
- package/build/private-apis.cjs.map +2 -2
- package/build/store/actions.cjs.map +1 -1
- package/build/store/private-selectors.cjs +19 -2
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs.map +1 -1
- package/build/store/selectors.cjs.map +1 -1
- package/build/utils/block-bindings.cjs +9 -9
- package/build/utils/block-bindings.cjs.map +3 -3
- package/build/utils/color-values.cjs +10 -1
- package/build/utils/color-values.cjs.map +3 -3
- package/build/utils/dom.cjs +2 -5
- package/build/utils/dom.cjs.map +3 -3
- package/build/utils/fit-text-frontend.cjs +6 -2
- package/build/utils/fit-text-frontend.cjs.map +3 -3
- package/build/utils/fit-text-utils.cjs +1 -1
- package/build/utils/fit-text-utils.cjs.map +3 -3
- package/build/utils/format-font-style.cjs +1 -1
- package/build/utils/format-font-style.cjs.map +3 -3
- package/build/utils/format-font-weight.cjs +1 -1
- package/build/utils/format-font-weight.cjs.map +3 -3
- package/build/utils/get-editor-region.cjs +4 -2
- package/build/utils/get-editor-region.cjs.map +3 -3
- package/build/utils/get-font-styles-and-weights.cjs +8 -12
- package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
- package/build/utils/get-px-from-css-unit.cjs +1 -1
- package/build/utils/get-px-from-css-unit.cjs.map +1 -1
- package/build/utils/index.cjs +1 -1
- package/build/utils/index.cjs.map +1 -1
- package/build/utils/math.cjs +1 -1
- package/build/utils/math.cjs.map +3 -3
- package/build/utils/object.cjs +8 -8
- package/build/utils/object.cjs.map +3 -3
- package/build/utils/order-inserter-block-items.cjs +1 -1
- package/build/utils/order-inserter-block-items.cjs.map +3 -3
- package/build/utils/pasting.cjs +4 -2
- package/build/utils/pasting.cjs.map +3 -3
- package/build/utils/selection.cjs +3 -2
- package/build/utils/selection.cjs.map +3 -3
- package/build/utils/sorting.cjs +9 -3
- package/build/utils/sorting.cjs.map +3 -3
- package/build/utils/transform-styles/index.cjs +3 -2
- package/build/utils/transform-styles/index.cjs.map +3 -3
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
- package/build/utils/transform-styles/types.cjs +19 -0
- package/build/utils/transform-styles/types.cjs.map +7 -0
- package/build/utils/types.cjs +19 -0
- package/build/utils/types.cjs.map +7 -0
- package/build-module/components/block-card/index.mjs +5 -6
- package/build-module/components/block-card/index.mjs.map +2 -2
- package/build-module/components/block-editing-mode/index.mjs +14 -8
- package/build-module/components/block-editing-mode/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +35 -21
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-mover/mover-description.mjs +6 -6
- package/build-module/components/block-mover/mover-description.mjs.map +1 -1
- package/build-module/components/block-patterns-list/index.mjs.map +2 -2
- package/build-module/components/block-patterns-paging/index.mjs +4 -4
- package/build-module/components/block-patterns-paging/index.mjs.map +2 -2
- package/build-module/components/block-popover/use-popover-scroll.mjs.map +1 -1
- package/build-module/components/block-quick-navigation/index.mjs +8 -6
- package/build-module/components/block-quick-navigation/index.mjs.map +2 -2
- package/build-module/components/block-rename/modal.mjs +0 -1
- package/build-module/components/block-rename/modal.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-toolbar/edit-section-button.mjs.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs +10 -4
- package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +51 -19
- package/build-module/components/child-layout-control/index.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +27 -15
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +4 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/contrast-checker/index.mjs +18 -4
- package/build-module/components/contrast-checker/index.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/index.mjs +4 -5
- package/build-module/components/dimensions-tool/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs +1 -1
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +155 -27
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
- package/build-module/components/global-styles/color-panel.mjs +106 -387
- package/build-module/components/global-styles/color-panel.mjs.map +3 -3
- package/build-module/components/global-styles/dimensions-panel.mjs +1 -5
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +33 -0
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +84 -10
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/grid/grid-item-resizer.mjs.map +1 -1
- package/build-module/components/grid/grid-visualizer.mjs.map +1 -1
- package/build-module/components/iframe/index.mjs +6 -3
- package/build-module/components/iframe/index.mjs.map +2 -2
- package/build-module/components/image-editor/use-transform-image.mjs.map +1 -1
- package/build-module/components/inserter/get-appender-label.mjs.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/search-items.mjs.map +1 -1
- package/build-module/components/inspector-controls/fill.mjs +1 -3
- package/build-module/components/inspector-controls/fill.mjs.map +2 -2
- package/build-module/components/inspector-controls/groups.mjs +2 -0
- package/build-module/components/inspector-controls/groups.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +76 -32
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -1
- package/build-module/components/line-height-control/index.mjs.map +1 -1
- package/build-module/components/link-control/index.mjs +2 -3
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/link-control/normalize-url.mjs.map +1 -1
- package/build-module/components/list-view/block-select-button.mjs +2 -17
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/utils.mjs.map +1 -1
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/provider/index.mjs.map +1 -1
- package/build-module/components/provider/use-block-sync.mjs +3 -1
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +1 -1
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +1 -1
- package/build-module/components/rich-text/prevent-event-discovery.mjs +1 -1
- package/build-module/components/rich-text/prevent-event-discovery.mjs.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -3
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-tab-nav.mjs.map +1 -1
- package/build-module/hooks/anchor.mjs +1 -2
- package/build-module/hooks/anchor.mjs.map +2 -2
- package/build-module/hooks/background.mjs +123 -75
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-fields/index.mjs +13 -2
- package/build-module/hooks/block-fields/index.mjs.map +2 -2
- package/build-module/hooks/color.mjs +2 -175
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/contrast-checker.mjs +32 -19
- package/build-module/hooks/contrast-checker.mjs.map +2 -2
- package/build-module/hooks/custom-class-name.mjs +0 -1
- package/build-module/hooks/custom-class-name.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +12 -2
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +115 -0
- package/build-module/hooks/elements.mjs.map +7 -0
- package/build-module/hooks/grid-visualizer.mjs +21 -11
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +68 -10
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +6 -3
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/list-view.mjs +10 -7
- package/build-module/hooks/list-view.mjs.map +2 -2
- package/build-module/hooks/spacing-visualizer.mjs.map +1 -1
- package/build-module/hooks/state-utils.mjs.map +1 -1
- package/build-module/hooks/states.mjs +2 -2
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/style.mjs +53 -8
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +62 -10
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +105 -7
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/private-apis.mjs +8 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs.map +1 -1
- package/build-module/store/private-selectors.mjs +18 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs.map +1 -1
- package/build-module/store/selectors.mjs.map +1 -1
- package/build-module/utils/block-bindings.mjs +9 -9
- package/build-module/utils/block-bindings.mjs.map +3 -3
- package/build-module/utils/color-values.mjs +9 -1
- package/build-module/utils/color-values.mjs.map +3 -3
- package/build-module/utils/dom.mjs +2 -5
- package/build-module/utils/dom.mjs.map +3 -3
- package/build-module/utils/fit-text-frontend.mjs +6 -2
- package/build-module/utils/fit-text-frontend.mjs.map +3 -3
- package/build-module/utils/fit-text-utils.mjs +1 -1
- package/build-module/utils/fit-text-utils.mjs.map +3 -3
- package/build-module/utils/format-font-style.mjs +1 -1
- package/build-module/utils/format-font-style.mjs.map +3 -3
- package/build-module/utils/format-font-weight.mjs +1 -1
- package/build-module/utils/format-font-weight.mjs.map +3 -3
- package/build-module/utils/get-editor-region.mjs +4 -2
- package/build-module/utils/get-editor-region.mjs.map +3 -3
- package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
- package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
- package/build-module/utils/get-px-from-css-unit.mjs +1 -1
- package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
- package/build-module/utils/index.mjs +1 -1
- package/build-module/utils/index.mjs.map +1 -1
- package/build-module/utils/math.mjs +1 -1
- package/build-module/utils/math.mjs.map +3 -3
- package/build-module/utils/object.mjs +8 -8
- package/build-module/utils/object.mjs.map +3 -3
- package/build-module/utils/order-inserter-block-items.mjs +1 -1
- package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
- package/build-module/utils/pasting.mjs +4 -2
- package/build-module/utils/pasting.mjs.map +3 -3
- package/build-module/utils/selection.mjs +3 -2
- package/build-module/utils/selection.mjs.map +3 -3
- package/build-module/utils/sorting.mjs +9 -3
- package/build-module/utils/sorting.mjs.map +3 -3
- package/build-module/utils/transform-styles/index.mjs +3 -2
- package/build-module/utils/transform-styles/index.mjs.map +3 -3
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
- package/build-module/utils/transform-styles/types.mjs +1 -0
- package/build-module/utils/transform-styles/types.mjs.map +7 -0
- package/build-module/utils/types.mjs +1 -0
- package/build-module/utils/types.mjs.map +7 -0
- package/build-style/content-rtl.css +2 -0
- package/build-style/content.css +2 -0
- package/build-style/style-rtl.css +34 -41
- package/build-style/style.css +34 -41
- package/build-types/utils/block-bindings.d.ts +27 -0
- package/build-types/utils/block-bindings.d.ts.map +1 -0
- package/build-types/utils/color-values.d.ts +40 -0
- package/build-types/utils/color-values.d.ts.map +1 -0
- package/build-types/utils/dom.d.ts +19 -19
- package/build-types/utils/dom.d.ts.map +1 -1
- package/build-types/utils/fit-text-frontend.d.ts +7 -0
- package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
- package/build-types/utils/fit-text-utils.d.ts +15 -0
- package/build-types/utils/fit-text-utils.d.ts.map +1 -0
- package/build-types/utils/format-font-style.d.ts +12 -0
- package/build-types/utils/format-font-style.d.ts.map +1 -0
- package/build-types/utils/format-font-weight.d.ts +12 -0
- package/build-types/utils/format-font-weight.d.ts.map +1 -0
- package/build-types/utils/get-editor-region.d.ts +9 -0
- package/build-types/utils/get-editor-region.d.ts.map +1 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
- package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
- package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +3 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/build-types/utils/math.d.ts +61 -0
- package/build-types/utils/math.d.ts.map +1 -0
- package/build-types/utils/object.d.ts +39 -0
- package/build-types/utils/object.d.ts.map +1 -0
- package/build-types/utils/order-inserter-block-items.d.ts +13 -0
- package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
- package/build-types/utils/pasting.d.ts +28 -0
- package/build-types/utils/pasting.d.ts.map +1 -0
- package/build-types/utils/selection.d.ts +21 -0
- package/build-types/utils/selection.d.ts.map +1 -0
- package/build-types/utils/sorting.d.ts +17 -0
- package/build-types/utils/sorting.d.ts.map +1 -0
- package/build-types/utils/transform-styles/index.d.ts +15 -0
- package/build-types/utils/transform-styles/index.d.ts.map +1 -0
- package/build-types/utils/transform-styles/types.d.ts +13 -0
- package/build-types/utils/transform-styles/types.d.ts.map +1 -0
- package/build-types/utils/types.d.ts +28 -0
- package/build-types/utils/types.d.ts.map +1 -0
- package/package.json +46 -40
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
- package/src/components/block-card/index.js +7 -13
- package/src/components/block-editing-mode/index.js +17 -9
- package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
- package/src/components/block-inspector/index.js +22 -20
- package/src/components/block-patterns-list/index.js +0 -1
- package/src/components/block-quick-navigation/index.js +7 -7
- package/src/components/block-rename/modal.js +0 -1
- package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
- package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +10 -4
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
- package/src/components/child-layout-control/index.js +65 -20
- package/src/components/child-layout-control/test/index.js +64 -0
- package/src/components/colors-gradients/control.js +29 -12
- package/src/components/colors-gradients/dropdown.js +4 -1
- package/src/components/colors-gradients/style.scss +39 -2
- package/src/components/contrast-checker/README.md +9 -0
- package/src/components/contrast-checker/index.js +42 -3
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/default-block-appender/content.scss +3 -0
- package/src/components/dimensions-tool/index.js +4 -9
- package/src/components/dimensions-tool/scale-tool.js +1 -2
- package/src/components/dimensions-tool/test/index.js +89 -11
- package/src/components/global-styles/background-panel.js +201 -34
- package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
- package/src/components/global-styles/color-panel.js +125 -487
- package/src/components/global-styles/dimensions-panel.js +1 -5
- package/src/components/global-styles/hooks.js +45 -0
- package/src/components/global-styles/shadow-panel-components.js +0 -1
- package/src/components/global-styles/test/background-panel.js +56 -0
- package/src/components/global-styles/test/color-panel.js +172 -118
- package/src/components/global-styles/test/typography-panel.js +167 -0
- package/src/components/global-styles/typography-panel.js +100 -11
- package/src/components/iframe/index.js +8 -3
- package/src/components/inserter/media-tab/media-preview.js +0 -1
- package/src/components/inspector-controls/README.md +0 -2
- package/src/components/inspector-controls/fill.js +6 -8
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/index.js +0 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +78 -28
- package/src/components/link-control/index.js +0 -1
- package/src/components/link-control/test/index.js +2 -3
- package/src/components/list-view/block-select-button.js +2 -18
- package/src/components/preset-input-control/custom-value-controls.js +0 -1
- package/src/components/provider/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +2 -0
- package/src/components/url-popover/image-url-input-ui.js +0 -2
- package/src/components/use-block-display-information/index.js +15 -2
- package/src/components/use-block-display-information/test/index.js +140 -0
- package/src/hooks/anchor.js +0 -1
- package/src/hooks/background.js +210 -133
- package/src/hooks/background.scss +0 -35
- package/src/hooks/block-fields/index.js +27 -2
- package/src/hooks/color.js +2 -205
- package/src/hooks/color.scss +3 -9
- package/src/hooks/contrast-checker.js +60 -17
- package/src/hooks/custom-class-name.js +0 -1
- package/src/hooks/dimensions.js +14 -3
- package/src/hooks/elements.js +140 -0
- package/src/hooks/elements.scss +8 -0
- package/src/hooks/grid-visualizer.js +59 -45
- package/src/hooks/layout-child.js +92 -14
- package/src/hooks/layout.js +6 -3
- package/src/hooks/list-view.js +10 -11
- package/src/hooks/states.js +2 -2
- package/src/hooks/style.js +91 -9
- package/src/hooks/test/background.js +59 -0
- package/src/hooks/test/block-style-state.js +14 -14
- package/src/hooks/test/dimensions.js +71 -0
- package/src/hooks/test/layout-child.js +165 -0
- package/src/hooks/test/layout.js +6 -6
- package/src/hooks/test/style.js +133 -11
- package/src/hooks/typography.js +70 -6
- package/src/layouts/flex.js +118 -15
- package/src/private-apis.js +8 -0
- package/src/store/private-selectors.js +47 -0
- package/src/store/test/private-selectors.js +166 -7
- package/src/store/test/reducer.js +61 -10
- package/src/style.scss +1 -0
- package/src/utils/block-bindings.ts +51 -0
- package/src/utils/color-values.ts +63 -0
- package/src/utils/{dom.js → dom.ts} +27 -27
- package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
- package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
- package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
- package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
- package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
- package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
- package/src/utils/{math.js → math.ts} +37 -30
- package/src/utils/object.ts +89 -0
- package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
- package/src/utils/{pasting.js → pasting.ts} +18 -11
- package/src/utils/{selection.js → selection.ts} +11 -4
- package/src/utils/sorting.ts +81 -0
- package/src/utils/test/color-values.js +44 -1
- package/src/utils/transform-styles/{index.js → index.ts} +25 -25
- package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
- package/src/utils/transform-styles/types.ts +13 -0
- package/src/utils/types.ts +29 -0
- package/src/utils/block-bindings.js +0 -46
- package/src/utils/color-values.js +0 -28
- package/src/utils/object.js +0 -67
- package/src/utils/sorting.js +0 -54
- /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
- /package/src/utils/{index.js → index.ts} +0 -0
|
@@ -7,19 +7,24 @@ import {
|
|
|
7
7
|
} from '@wordpress/components';
|
|
8
8
|
import { useCallback } from '@wordpress/element';
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Internal dependencies
|
|
14
13
|
*/
|
|
15
14
|
import BackgroundImageControl from '../background-image-control';
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
15
|
+
import ColorGradientDropdownItem from './color-gradient-dropdown-item';
|
|
16
|
+
import { useHasBackgroundColorPanel } from './color-panel';
|
|
17
|
+
import { useColorGradientSettings } from './hooks';
|
|
18
18
|
import { useToolsPanelDropdownMenuProps } from './utils';
|
|
19
19
|
import { setImmutably } from '../../utils/object';
|
|
20
|
+
import {
|
|
21
|
+
extractPresetSlug,
|
|
22
|
+
encodeColorValueWithPalette,
|
|
23
|
+
} from '../../utils/color-values';
|
|
20
24
|
|
|
21
25
|
const DEFAULT_CONTROLS = {
|
|
22
26
|
backgroundImage: true,
|
|
27
|
+
backgroundColor: true,
|
|
23
28
|
gradient: true,
|
|
24
29
|
};
|
|
25
30
|
|
|
@@ -39,12 +44,17 @@ export function useHasBackgroundControl( settings, feature ) {
|
|
|
39
44
|
* `settings.background.backgroundSize` exists also,
|
|
40
45
|
* but can only be used if settings?.background?.backgroundImage is `true`.
|
|
41
46
|
*
|
|
47
|
+
* The panel is also shown when the block has color panel background
|
|
48
|
+
* support (`settings.color.background`), because background color and
|
|
49
|
+
* the legacy `color.gradient` control are rendered here.
|
|
50
|
+
*
|
|
42
51
|
* @param {Object} settings Site settings
|
|
43
52
|
* @return {boolean} Whether site settings has activated background panel.
|
|
44
53
|
*/
|
|
45
54
|
export function useHasBackgroundPanel( settings ) {
|
|
55
|
+
const hasBackgroundColor = useHasBackgroundColorPanel( settings );
|
|
46
56
|
const { backgroundImage, gradient } = settings?.background || {};
|
|
47
|
-
return backgroundImage || gradient;
|
|
57
|
+
return backgroundImage || gradient || hasBackgroundColor;
|
|
48
58
|
}
|
|
49
59
|
|
|
50
60
|
/**
|
|
@@ -92,7 +102,30 @@ export function hasBackgroundGradientValue( style ) {
|
|
|
92
102
|
);
|
|
93
103
|
}
|
|
94
104
|
|
|
95
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Checks if there is a current value for the background color (written to
|
|
107
|
+
* `color.background`).
|
|
108
|
+
*
|
|
109
|
+
* @param {Object} style Style attribute.
|
|
110
|
+
* @return {boolean} Whether the block has a background color value set.
|
|
111
|
+
*/
|
|
112
|
+
export function hasBackgroundColorValue( style ) {
|
|
113
|
+
return !! style?.color?.background;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Checks if there is a current value in the legacy `color.gradient` location
|
|
118
|
+
* (used by blocks with color panel gradient support that haven't adopted the
|
|
119
|
+
* `background.gradient` block support).
|
|
120
|
+
*
|
|
121
|
+
* @param {Object} style Style attribute.
|
|
122
|
+
* @return {boolean} Whether the block has a legacy color gradient value set.
|
|
123
|
+
*/
|
|
124
|
+
export function hasLegacyColorGradientValue( style ) {
|
|
125
|
+
return !! style?.color?.gradient;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function BackgroundToolsPanel( {
|
|
96
129
|
resetAllFilter,
|
|
97
130
|
onChange,
|
|
98
131
|
value,
|
|
@@ -128,23 +161,46 @@ export default function BackgroundImagePanel( {
|
|
|
128
161
|
as: Wrapper = BackgroundToolsPanel,
|
|
129
162
|
value,
|
|
130
163
|
onChange,
|
|
131
|
-
inheritedValue,
|
|
164
|
+
inheritedValue = value,
|
|
132
165
|
settings,
|
|
133
166
|
panelId,
|
|
134
167
|
defaultControls = DEFAULT_CONTROLS,
|
|
135
168
|
defaultValues = {},
|
|
136
169
|
headerLabel = __( 'Background' ),
|
|
170
|
+
contrastWarning,
|
|
137
171
|
} ) {
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
172
|
+
const {
|
|
173
|
+
colors,
|
|
174
|
+
gradients,
|
|
175
|
+
allColors,
|
|
176
|
+
areCustomSolidsEnabled,
|
|
177
|
+
areCustomGradientsEnabled,
|
|
178
|
+
hasSolidColors,
|
|
179
|
+
hasGradientColors,
|
|
180
|
+
decodeValue,
|
|
181
|
+
encodeGradientValue,
|
|
182
|
+
} = useColorGradientSettings( settings );
|
|
141
183
|
|
|
142
184
|
const hasBackgroundGradientControl = useHasBackgroundControl(
|
|
143
185
|
settings,
|
|
144
186
|
'gradient'
|
|
145
187
|
);
|
|
188
|
+
const hasColorPanelBackgroundSupport =
|
|
189
|
+
useHasBackgroundColorPanel( settings );
|
|
190
|
+
const showBackgroundColorControl =
|
|
191
|
+
hasColorPanelBackgroundSupport && hasSolidColors;
|
|
192
|
+
// New `background.gradient` block support — gradient lives under the
|
|
193
|
+
// `background` style path.
|
|
146
194
|
const showBackgroundGradientControl =
|
|
147
195
|
hasGradientColors && hasBackgroundGradientControl;
|
|
196
|
+
// Legacy `color.gradient` path — only rendered when the block has
|
|
197
|
+
// color panel background support and hasn't adopted the newer
|
|
198
|
+
// `background.gradient` support. Keeps the UI consistent for blocks
|
|
199
|
+
// that still write gradients to `color.gradient`.
|
|
200
|
+
const showLegacyColorGradientControl =
|
|
201
|
+
hasColorPanelBackgroundSupport &&
|
|
202
|
+
hasGradientColors &&
|
|
203
|
+
! hasBackgroundGradientControl;
|
|
148
204
|
const showBackgroundImageControl = useHasBackgroundControl(
|
|
149
205
|
settings,
|
|
150
206
|
'backgroundImage'
|
|
@@ -152,38 +208,38 @@ export default function BackgroundImagePanel( {
|
|
|
152
208
|
|
|
153
209
|
const resetAllFilter = useCallback(
|
|
154
210
|
( previousValue ) => {
|
|
211
|
+
const clearsColorBackground = showBackgroundColorControl;
|
|
212
|
+
const clearsColorGradient =
|
|
213
|
+
hasBackgroundGradientControl || showLegacyColorGradientControl;
|
|
214
|
+
if ( ! clearsColorBackground && ! clearsColorGradient ) {
|
|
215
|
+
return { ...previousValue, background: {} };
|
|
216
|
+
}
|
|
155
217
|
return {
|
|
156
218
|
...previousValue,
|
|
157
219
|
background: {},
|
|
158
|
-
color:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
: previousValue?.color,
|
|
220
|
+
color: {
|
|
221
|
+
...previousValue?.color,
|
|
222
|
+
...( clearsColorBackground && { background: undefined } ),
|
|
223
|
+
...( clearsColorGradient && { gradient: undefined } ),
|
|
224
|
+
},
|
|
164
225
|
};
|
|
165
226
|
},
|
|
166
|
-
[
|
|
227
|
+
[
|
|
228
|
+
hasBackgroundGradientControl,
|
|
229
|
+
showBackgroundColorControl,
|
|
230
|
+
showLegacyColorGradientControl,
|
|
231
|
+
]
|
|
167
232
|
);
|
|
168
233
|
|
|
169
|
-
if (
|
|
234
|
+
if (
|
|
235
|
+
! showBackgroundImageControl &&
|
|
236
|
+
! showBackgroundColorControl &&
|
|
237
|
+
! showBackgroundGradientControl &&
|
|
238
|
+
! showLegacyColorGradientControl
|
|
239
|
+
) {
|
|
170
240
|
return null;
|
|
171
241
|
}
|
|
172
242
|
|
|
173
|
-
const decodeValue = ( rawValue ) =>
|
|
174
|
-
getValueFromVariable( { settings }, '', rawValue );
|
|
175
|
-
const encodeGradientValue = ( gradientValue ) => {
|
|
176
|
-
const allGradients = gradients.flatMap(
|
|
177
|
-
( { gradients: originGradients } ) => originGradients
|
|
178
|
-
);
|
|
179
|
-
const gradientObject = allGradients.find(
|
|
180
|
-
( { gradient } ) => gradient === gradientValue
|
|
181
|
-
);
|
|
182
|
-
return gradientObject
|
|
183
|
-
? 'var:preset|gradient|' + gradientObject.slug
|
|
184
|
-
: gradientValue;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
243
|
const resetBackground = () =>
|
|
188
244
|
onChange(
|
|
189
245
|
setImmutably(
|
|
@@ -203,6 +259,50 @@ export default function BackgroundImagePanel( {
|
|
|
203
259
|
onChange( newValue );
|
|
204
260
|
};
|
|
205
261
|
|
|
262
|
+
// Background color (written to `color.background`).
|
|
263
|
+
const backgroundColor = decodeValue( inheritedValue?.color?.background );
|
|
264
|
+
const userBackgroundColor = decodeValue( value?.color?.background );
|
|
265
|
+
const setBackgroundColor = ( newColor, newSlug ) => {
|
|
266
|
+
const newValue = setImmutably(
|
|
267
|
+
value,
|
|
268
|
+
[ 'color', 'background' ],
|
|
269
|
+
encodeColorValueWithPalette( allColors, newColor, newSlug )
|
|
270
|
+
);
|
|
271
|
+
// Legacy `color.gradient` is mutually exclusive with
|
|
272
|
+
// `color.background`. `background.gradient` is independent and
|
|
273
|
+
// should not be touched.
|
|
274
|
+
if ( showLegacyColorGradientControl ) {
|
|
275
|
+
newValue.color.gradient = undefined;
|
|
276
|
+
}
|
|
277
|
+
onChange( newValue );
|
|
278
|
+
};
|
|
279
|
+
const resetBackgroundColor = () => {
|
|
280
|
+
const newValue = setImmutably(
|
|
281
|
+
value,
|
|
282
|
+
[ 'color', 'background' ],
|
|
283
|
+
undefined
|
|
284
|
+
);
|
|
285
|
+
if ( showLegacyColorGradientControl ) {
|
|
286
|
+
newValue.color.gradient = undefined;
|
|
287
|
+
}
|
|
288
|
+
onChange( newValue );
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// Legacy `color.gradient` setters.
|
|
292
|
+
const legacyColorGradient = decodeValue( inheritedValue?.color?.gradient );
|
|
293
|
+
const userLegacyColorGradient = decodeValue( value?.color?.gradient );
|
|
294
|
+
const setLegacyColorGradient = ( newGradient ) => {
|
|
295
|
+
const newValue = setImmutably(
|
|
296
|
+
value,
|
|
297
|
+
[ 'color', 'gradient' ],
|
|
298
|
+
encodeGradientValue( newGradient )
|
|
299
|
+
);
|
|
300
|
+
newValue.color.background = undefined;
|
|
301
|
+
onChange( newValue );
|
|
302
|
+
};
|
|
303
|
+
const resetLegacyColorGradient = () =>
|
|
304
|
+
onChange( setImmutably( value, [ 'color', 'gradient' ], undefined ) );
|
|
305
|
+
|
|
206
306
|
// Get current gradient value, decoding preset slug references.
|
|
207
307
|
// Fall back to color.gradient for legacy blocks that haven't migrated
|
|
208
308
|
// to background.gradient yet (mirrors block inspector fallback in
|
|
@@ -237,7 +337,7 @@ export default function BackgroundImagePanel( {
|
|
|
237
337
|
>
|
|
238
338
|
{ showBackgroundImageControl && (
|
|
239
339
|
<ToolsPanelItem
|
|
240
|
-
className="block-editor-
|
|
340
|
+
className="block-editor-color-gradient-item"
|
|
241
341
|
hasValue={ () => hasBackgroundImageValue( value ) }
|
|
242
342
|
label={ __( 'Image' ) }
|
|
243
343
|
onDeselect={ resetBackground }
|
|
@@ -254,9 +354,49 @@ export default function BackgroundImagePanel( {
|
|
|
254
354
|
/>
|
|
255
355
|
</ToolsPanelItem>
|
|
256
356
|
) }
|
|
357
|
+
{ showBackgroundColorControl && (
|
|
358
|
+
<ColorGradientDropdownItem
|
|
359
|
+
label={ __( 'Color' ) }
|
|
360
|
+
hasValue={ () => hasBackgroundColorValue( value ) }
|
|
361
|
+
resetValue={ resetBackgroundColor }
|
|
362
|
+
isShownByDefault={ defaultControls.backgroundColor }
|
|
363
|
+
indicators={ [ userBackgroundColor ?? backgroundColor ] }
|
|
364
|
+
contrastWarning={ contrastWarning }
|
|
365
|
+
tabs={ [
|
|
366
|
+
{
|
|
367
|
+
key: 'background',
|
|
368
|
+
label: __( 'Color' ),
|
|
369
|
+
inheritedValue:
|
|
370
|
+
userBackgroundColor ?? backgroundColor,
|
|
371
|
+
// Resolve the slug from the same source as the
|
|
372
|
+
// displayed value (user value first, then the
|
|
373
|
+
// inherited fallback). For a block instance the
|
|
374
|
+
// selection lives in `value` while `inheritedValue`
|
|
375
|
+
// only holds the global styles fallback, so reading
|
|
376
|
+
// the slug from `inheritedValue` alone would miss it
|
|
377
|
+
// and two same-hex presets would both appear selected.
|
|
378
|
+
inheritedSlug:
|
|
379
|
+
extractPresetSlug(
|
|
380
|
+
value?.color?.background,
|
|
381
|
+
'color'
|
|
382
|
+
) ??
|
|
383
|
+
extractPresetSlug(
|
|
384
|
+
inheritedValue?.color?.background,
|
|
385
|
+
'color'
|
|
386
|
+
),
|
|
387
|
+
setValue: setBackgroundColor,
|
|
388
|
+
userValue: userBackgroundColor,
|
|
389
|
+
},
|
|
390
|
+
] }
|
|
391
|
+
colorGradientControlSettings={ {
|
|
392
|
+
colors,
|
|
393
|
+
disableCustomColors: ! areCustomSolidsEnabled,
|
|
394
|
+
} }
|
|
395
|
+
panelId={ panelId }
|
|
396
|
+
/>
|
|
397
|
+
) }
|
|
257
398
|
{ showBackgroundGradientControl && (
|
|
258
|
-
<
|
|
259
|
-
className="block-editor-background-panel__item"
|
|
399
|
+
<ColorGradientDropdownItem
|
|
260
400
|
label={ __( 'Gradient' ) }
|
|
261
401
|
hasValue={ () => hasBackgroundGradientValue( value ) }
|
|
262
402
|
resetValue={ resetGradient }
|
|
@@ -280,6 +420,33 @@ export default function BackgroundImagePanel( {
|
|
|
280
420
|
panelId={ panelId }
|
|
281
421
|
/>
|
|
282
422
|
) }
|
|
423
|
+
{ showLegacyColorGradientControl && (
|
|
424
|
+
<ColorGradientDropdownItem
|
|
425
|
+
label={ __( 'Gradient' ) }
|
|
426
|
+
hasValue={ () => hasLegacyColorGradientValue( value ) }
|
|
427
|
+
resetValue={ resetLegacyColorGradient }
|
|
428
|
+
isShownByDefault={ defaultControls.gradient }
|
|
429
|
+
indicators={ [
|
|
430
|
+
userLegacyColorGradient ?? legacyColorGradient,
|
|
431
|
+
] }
|
|
432
|
+
tabs={ [
|
|
433
|
+
{
|
|
434
|
+
key: 'gradient',
|
|
435
|
+
label: __( 'Gradient' ),
|
|
436
|
+
inheritedValue:
|
|
437
|
+
userLegacyColorGradient ?? legacyColorGradient,
|
|
438
|
+
setValue: setLegacyColorGradient,
|
|
439
|
+
userValue: userLegacyColorGradient,
|
|
440
|
+
isGradient: true,
|
|
441
|
+
},
|
|
442
|
+
] }
|
|
443
|
+
colorGradientControlSettings={ {
|
|
444
|
+
gradients,
|
|
445
|
+
disableCustomGradients: ! areCustomGradientsEnabled,
|
|
446
|
+
} }
|
|
447
|
+
panelId={ panelId }
|
|
448
|
+
/>
|
|
449
|
+
) }
|
|
283
450
|
</Wrapper>
|
|
284
451
|
);
|
|
285
452
|
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import {
|
|
10
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
11
|
+
__experimentalHStack as HStack,
|
|
12
|
+
__experimentalZStack as ZStack,
|
|
13
|
+
__experimentalDropdownContentWrapper as DropdownContentWrapper,
|
|
14
|
+
ColorIndicator,
|
|
15
|
+
Flex,
|
|
16
|
+
FlexItem,
|
|
17
|
+
Dropdown,
|
|
18
|
+
Button,
|
|
19
|
+
privateApis as componentsPrivateApis,
|
|
20
|
+
} from '@wordpress/components';
|
|
21
|
+
import { useRef } from '@wordpress/element';
|
|
22
|
+
import { __ } from '@wordpress/i18n';
|
|
23
|
+
import { reset as resetIcon, caution as cautionIcon } from '@wordpress/icons';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Internal dependencies
|
|
27
|
+
*/
|
|
28
|
+
import ColorGradientControl from '../colors-gradients/control';
|
|
29
|
+
import { unlock } from '../../lock-unlock';
|
|
30
|
+
|
|
31
|
+
const { Tabs } = unlock( componentsPrivateApis );
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {Object} DropdownContentProps
|
|
35
|
+
* @property {Array} tabs Tab configurations to render.
|
|
36
|
+
* @property {Object} colorGradientControlSettings Settings passed to ColorGradientControl.
|
|
37
|
+
* @property {string} [contrastWarning] Contrast warning message for the color value.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Renders the dropdown content containing the color/gradient picker tabs.
|
|
42
|
+
*
|
|
43
|
+
* @param {DropdownContentProps} props
|
|
44
|
+
*/
|
|
45
|
+
function DropdownContent( {
|
|
46
|
+
tabs,
|
|
47
|
+
colorGradientControlSettings,
|
|
48
|
+
contrastWarning,
|
|
49
|
+
} ) {
|
|
50
|
+
const { key: firstTabKey, ...firstTab } = tabs[ 0 ] ?? {};
|
|
51
|
+
const defaultTabId = tabs.find(
|
|
52
|
+
( tab ) => tab.userValue !== undefined
|
|
53
|
+
)?.key;
|
|
54
|
+
return (
|
|
55
|
+
<DropdownContentWrapper paddingSize="none">
|
|
56
|
+
<div className="block-editor-panel-color-gradient-settings__dropdown-content">
|
|
57
|
+
{ tabs.length === 1 && (
|
|
58
|
+
<ColorGradientTab
|
|
59
|
+
key={ firstTabKey }
|
|
60
|
+
{ ...firstTab }
|
|
61
|
+
colorGradientControlSettings={
|
|
62
|
+
colorGradientControlSettings
|
|
63
|
+
}
|
|
64
|
+
contrastWarning={ contrastWarning }
|
|
65
|
+
/>
|
|
66
|
+
) }
|
|
67
|
+
{ tabs.length > 1 && (
|
|
68
|
+
<Tabs defaultTabId={ defaultTabId }>
|
|
69
|
+
<Tabs.TabList>
|
|
70
|
+
{ tabs.map( ( tab ) => (
|
|
71
|
+
<Tabs.Tab key={ tab.key } tabId={ tab.key }>
|
|
72
|
+
{ tab.label }
|
|
73
|
+
</Tabs.Tab>
|
|
74
|
+
) ) }
|
|
75
|
+
</Tabs.TabList>
|
|
76
|
+
|
|
77
|
+
{ tabs.map( ( tab ) => {
|
|
78
|
+
const { key: tabKey, ...restTabProps } = tab;
|
|
79
|
+
return (
|
|
80
|
+
<Tabs.TabPanel
|
|
81
|
+
key={ tabKey }
|
|
82
|
+
tabId={ tabKey }
|
|
83
|
+
focusable={ false }
|
|
84
|
+
>
|
|
85
|
+
<ColorGradientTab
|
|
86
|
+
key={ tabKey }
|
|
87
|
+
{ ...restTabProps }
|
|
88
|
+
colorGradientControlSettings={
|
|
89
|
+
colorGradientControlSettings
|
|
90
|
+
}
|
|
91
|
+
contrastWarning={ contrastWarning }
|
|
92
|
+
/>
|
|
93
|
+
</Tabs.TabPanel>
|
|
94
|
+
);
|
|
95
|
+
} ) }
|
|
96
|
+
</Tabs>
|
|
97
|
+
) }
|
|
98
|
+
</div>
|
|
99
|
+
</DropdownContentWrapper>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const popoverProps = {
|
|
104
|
+
placement: 'left-start',
|
|
105
|
+
offset: 36,
|
|
106
|
+
shift: true,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const LabeledColorIndicators = ( { indicators, label } ) => (
|
|
110
|
+
<HStack justify="flex-start">
|
|
111
|
+
<ZStack isLayered={ false } offset={ -8 }>
|
|
112
|
+
{ indicators.map( ( indicator, index ) => (
|
|
113
|
+
<Flex key={ index } expanded={ false }>
|
|
114
|
+
<ColorIndicator colorValue={ indicator } />
|
|
115
|
+
</Flex>
|
|
116
|
+
) ) }
|
|
117
|
+
</ZStack>
|
|
118
|
+
<FlexItem className="block-editor-panel-color-gradient-settings__color-name">
|
|
119
|
+
{ label }
|
|
120
|
+
</FlexItem>
|
|
121
|
+
</HStack>
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
function ColorGradientTab( {
|
|
125
|
+
isGradient,
|
|
126
|
+
inheritedValue,
|
|
127
|
+
inheritedSlug,
|
|
128
|
+
userValue,
|
|
129
|
+
setValue,
|
|
130
|
+
colorGradientControlSettings,
|
|
131
|
+
contrastWarning,
|
|
132
|
+
} ) {
|
|
133
|
+
return (
|
|
134
|
+
<ColorGradientControl
|
|
135
|
+
{ ...colorGradientControlSettings }
|
|
136
|
+
showTitle={ false }
|
|
137
|
+
enableAlpha
|
|
138
|
+
__experimentalIsRenderedInSidebar
|
|
139
|
+
colorValue={ isGradient ? undefined : inheritedValue }
|
|
140
|
+
colorSlug={ isGradient ? undefined : inheritedSlug }
|
|
141
|
+
gradientValue={ isGradient ? inheritedValue : undefined }
|
|
142
|
+
onColorChange={ isGradient ? undefined : setValue }
|
|
143
|
+
onGradientChange={ isGradient ? setValue : undefined }
|
|
144
|
+
clearable={ inheritedValue === userValue }
|
|
145
|
+
headingLevel={ 3 }
|
|
146
|
+
noticeProps={
|
|
147
|
+
! isGradient && contrastWarning
|
|
148
|
+
? {
|
|
149
|
+
children: contrastWarning,
|
|
150
|
+
status: 'warning',
|
|
151
|
+
spokenMessage: null,
|
|
152
|
+
className:
|
|
153
|
+
'block-editor-panel-color-gradient-settings__contrast-notice',
|
|
154
|
+
}
|
|
155
|
+
: undefined
|
|
156
|
+
}
|
|
157
|
+
/>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Renders a ToolsPanelItem that opens a dropdown containing one or more
|
|
162
|
+
// color/gradient pickers. Shared between the Color, Background, and
|
|
163
|
+
// Typography panels for consistent color-style controls.
|
|
164
|
+
export default function ColorGradientDropdownItem( {
|
|
165
|
+
label,
|
|
166
|
+
hasValue,
|
|
167
|
+
resetValue,
|
|
168
|
+
isShownByDefault,
|
|
169
|
+
indicators,
|
|
170
|
+
tabs,
|
|
171
|
+
colorGradientControlSettings,
|
|
172
|
+
panelId,
|
|
173
|
+
contrastWarning,
|
|
174
|
+
className = 'block-editor-tools-panel-color-gradient-settings__item',
|
|
175
|
+
} ) {
|
|
176
|
+
const colorGradientDropdownButtonRef = useRef( undefined );
|
|
177
|
+
return (
|
|
178
|
+
<ToolsPanelItem
|
|
179
|
+
className={ clsx( 'block-editor-color-gradient-item', className ) }
|
|
180
|
+
hasValue={ hasValue }
|
|
181
|
+
label={ label }
|
|
182
|
+
onDeselect={ resetValue }
|
|
183
|
+
isShownByDefault={ isShownByDefault }
|
|
184
|
+
panelId={ panelId }
|
|
185
|
+
>
|
|
186
|
+
<Dropdown
|
|
187
|
+
popoverProps={ popoverProps }
|
|
188
|
+
className="block-editor-tools-panel-color-gradient-settings__dropdown"
|
|
189
|
+
renderToggle={ ( { onToggle, isOpen } ) => {
|
|
190
|
+
const toggleProps = {
|
|
191
|
+
onClick: onToggle,
|
|
192
|
+
className: clsx(
|
|
193
|
+
'block-editor-panel-color-gradient-settings__dropdown',
|
|
194
|
+
{
|
|
195
|
+
'is-open': isOpen,
|
|
196
|
+
'has-contrast-warning': !! contrastWarning,
|
|
197
|
+
}
|
|
198
|
+
),
|
|
199
|
+
'aria-expanded': isOpen,
|
|
200
|
+
ref: colorGradientDropdownButtonRef,
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<>
|
|
205
|
+
<Button { ...toggleProps } __next40pxDefaultSize>
|
|
206
|
+
<LabeledColorIndicators
|
|
207
|
+
indicators={ indicators }
|
|
208
|
+
label={ label }
|
|
209
|
+
/>
|
|
210
|
+
</Button>
|
|
211
|
+
{ hasValue() && (
|
|
212
|
+
<Button
|
|
213
|
+
__next40pxDefaultSize
|
|
214
|
+
label={ __( 'Reset' ) }
|
|
215
|
+
className="block-editor-panel-color-gradient-settings__reset"
|
|
216
|
+
size="small"
|
|
217
|
+
icon={ resetIcon }
|
|
218
|
+
onClick={ () => {
|
|
219
|
+
resetValue();
|
|
220
|
+
if ( isOpen ) {
|
|
221
|
+
onToggle();
|
|
222
|
+
}
|
|
223
|
+
colorGradientDropdownButtonRef.current?.focus();
|
|
224
|
+
} }
|
|
225
|
+
/>
|
|
226
|
+
) }
|
|
227
|
+
{ contrastWarning && (
|
|
228
|
+
// An icon-only warning that stays visible while a
|
|
229
|
+
// contrast warning is in effect. It is not a menu;
|
|
230
|
+
// activating it opens the color picker popover where
|
|
231
|
+
// the full warning notice is shown, so the indicator
|
|
232
|
+
// doubles as a shortcut to where the issue is fixed.
|
|
233
|
+
<Button
|
|
234
|
+
__next40pxDefaultSize
|
|
235
|
+
size="small"
|
|
236
|
+
icon={ cautionIcon }
|
|
237
|
+
label={ __( 'Low contrast' ) }
|
|
238
|
+
className="block-editor-panel-color-gradient-settings__contrast-warning"
|
|
239
|
+
aria-expanded={ isOpen }
|
|
240
|
+
onClick={ onToggle }
|
|
241
|
+
/>
|
|
242
|
+
) }
|
|
243
|
+
</>
|
|
244
|
+
);
|
|
245
|
+
} }
|
|
246
|
+
renderContent={ () => (
|
|
247
|
+
<DropdownContent
|
|
248
|
+
tabs={ tabs }
|
|
249
|
+
colorGradientControlSettings={
|
|
250
|
+
colorGradientControlSettings
|
|
251
|
+
}
|
|
252
|
+
contrastWarning={ contrastWarning }
|
|
253
|
+
/>
|
|
254
|
+
) }
|
|
255
|
+
/>
|
|
256
|
+
</ToolsPanelItem>
|
|
257
|
+
);
|
|
258
|
+
}
|