@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
|
@@ -32,7 +32,6 @@ import { setImmutably } from '../../utils/object';
|
|
|
32
32
|
import {
|
|
33
33
|
DEFAULT_BLOCK_STYLE_STATE,
|
|
34
34
|
hasPseudoBlockStyleState,
|
|
35
|
-
isDefaultBlockStyleState,
|
|
36
35
|
hasViewportBlockStyleState,
|
|
37
36
|
} from '../../hooks/block-style-state';
|
|
38
37
|
|
|
@@ -95,7 +94,7 @@ function hasWidth( settings ) {
|
|
|
95
94
|
|
|
96
95
|
function hasAspectRatio( settings, styleState = DEFAULT_BLOCK_STYLE_STATE ) {
|
|
97
96
|
return (
|
|
98
|
-
|
|
97
|
+
! hasPseudoBlockStyleState( styleState ) &&
|
|
99
98
|
settings?.dimensions?.aspectRatio
|
|
100
99
|
);
|
|
101
100
|
}
|
|
@@ -603,7 +602,6 @@ export default function DimensionsPanel( {
|
|
|
603
602
|
>
|
|
604
603
|
{ ! showSpacingPresetsControl && (
|
|
605
604
|
<BoxControl
|
|
606
|
-
__next40pxDefaultSize
|
|
607
605
|
values={ paddingValues }
|
|
608
606
|
onChange={ setPaddingValues }
|
|
609
607
|
label={ __( 'Padding' ) }
|
|
@@ -646,7 +644,6 @@ export default function DimensionsPanel( {
|
|
|
646
644
|
>
|
|
647
645
|
{ ! showSpacingPresetsControl && (
|
|
648
646
|
<BoxControl
|
|
649
|
-
__next40pxDefaultSize
|
|
650
647
|
values={ marginValues }
|
|
651
648
|
onChange={ setMarginValues }
|
|
652
649
|
inputProps={ {
|
|
@@ -702,7 +699,6 @@ export default function DimensionsPanel( {
|
|
|
702
699
|
{ ! showSpacingPresetsControl &&
|
|
703
700
|
( isAxialGap ? (
|
|
704
701
|
<BoxControl
|
|
705
|
-
__next40pxDefaultSize
|
|
706
702
|
label={ __( 'Block spacing' ) }
|
|
707
703
|
min={ 0 }
|
|
708
704
|
onChange={ setGapValues }
|
|
@@ -5,6 +5,7 @@ import { useMemo } from '@wordpress/element';
|
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
7
7
|
import { _x } from '@wordpress/i18n';
|
|
8
|
+
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
@@ -306,3 +307,47 @@ export function useGradientsPerOrigin( settings ) {
|
|
|
306
307
|
shouldDisplayDefaultGradients,
|
|
307
308
|
] );
|
|
308
309
|
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Derives the color/gradient palette data and encode/decode helpers shared by
|
|
313
|
+
* the Color, Background, and Typography style panels, so the common preamble
|
|
314
|
+
* is defined once rather than repeated in each panel.
|
|
315
|
+
*
|
|
316
|
+
* @param {Object} settings Style settings object.
|
|
317
|
+
*
|
|
318
|
+
* @return {Object} Shared color/gradient palette data and helpers.
|
|
319
|
+
*/
|
|
320
|
+
export function useColorGradientSettings( settings ) {
|
|
321
|
+
const colors = useColorsPerOrigin( settings );
|
|
322
|
+
const gradients = useGradientsPerOrigin( settings );
|
|
323
|
+
const areCustomSolidsEnabled = settings?.color?.custom;
|
|
324
|
+
const areCustomGradientsEnabled = settings?.color?.customGradient;
|
|
325
|
+
const allColors = useMemo(
|
|
326
|
+
() => colors.flatMap( ( { colors: originColors } ) => originColors ),
|
|
327
|
+
[ colors ]
|
|
328
|
+
);
|
|
329
|
+
const decodeValue = ( rawValue ) =>
|
|
330
|
+
getValueFromVariable( { settings }, '', rawValue );
|
|
331
|
+
const encodeGradientValue = ( gradientValue ) => {
|
|
332
|
+
const allGradients = gradients.flatMap(
|
|
333
|
+
( { gradients: originGradients } ) => originGradients
|
|
334
|
+
);
|
|
335
|
+
const gradientObject = allGradients.find(
|
|
336
|
+
( { gradient } ) => gradient === gradientValue
|
|
337
|
+
);
|
|
338
|
+
return gradientObject
|
|
339
|
+
? 'var:preset|gradient|' + gradientObject.slug
|
|
340
|
+
: gradientValue;
|
|
341
|
+
};
|
|
342
|
+
return {
|
|
343
|
+
colors,
|
|
344
|
+
gradients,
|
|
345
|
+
allColors,
|
|
346
|
+
areCustomSolidsEnabled,
|
|
347
|
+
areCustomGradientsEnabled,
|
|
348
|
+
hasSolidColors: colors.length > 0 || areCustomSolidsEnabled,
|
|
349
|
+
hasGradientColors: gradients.length > 0 || areCustomGradientsEnabled,
|
|
350
|
+
decodeValue,
|
|
351
|
+
encodeGradientValue,
|
|
352
|
+
};
|
|
353
|
+
}
|
|
@@ -20,7 +20,6 @@ import { shadow as shadowIcon, Icon, check, reset } from '@wordpress/icons';
|
|
|
20
20
|
*/
|
|
21
21
|
import clsx from 'clsx';
|
|
22
22
|
|
|
23
|
-
// eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.
|
|
24
23
|
import { Tooltip } from '@wordpress/ui';
|
|
25
24
|
|
|
26
25
|
/**
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
import {
|
|
6
6
|
hasBackgroundImageValue,
|
|
7
7
|
hasBackgroundGradientValue,
|
|
8
|
+
hasBackgroundColorValue,
|
|
9
|
+
hasLegacyColorGradientValue,
|
|
8
10
|
} from '../background-panel';
|
|
9
11
|
|
|
10
12
|
describe( 'hasBackgroundImageValue', () => {
|
|
@@ -80,3 +82,57 @@ describe( 'hasBackgroundGradientValue', () => {
|
|
|
80
82
|
expect( hasBackgroundGradientValue( undefined ) ).toBe( false );
|
|
81
83
|
} );
|
|
82
84
|
} );
|
|
85
|
+
|
|
86
|
+
describe( 'hasBackgroundColorValue', () => {
|
|
87
|
+
it( 'should return `true` when a background color string is set', () => {
|
|
88
|
+
expect(
|
|
89
|
+
hasBackgroundColorValue( { color: { background: '#ff0000' } } )
|
|
90
|
+
).toBe( true );
|
|
91
|
+
} );
|
|
92
|
+
|
|
93
|
+
it( 'should return `true` for a preset slug reference', () => {
|
|
94
|
+
expect(
|
|
95
|
+
hasBackgroundColorValue( {
|
|
96
|
+
color: { background: 'var:preset|color|vivid-red' },
|
|
97
|
+
} )
|
|
98
|
+
).toBe( true );
|
|
99
|
+
} );
|
|
100
|
+
|
|
101
|
+
it( 'should return `false` when background color is undefined', () => {
|
|
102
|
+
expect( hasBackgroundColorValue( { color: {} } ) ).toBe( false );
|
|
103
|
+
} );
|
|
104
|
+
|
|
105
|
+
it( 'should return `false` when color is undefined', () => {
|
|
106
|
+
expect( hasBackgroundColorValue( {} ) ).toBe( false );
|
|
107
|
+
} );
|
|
108
|
+
|
|
109
|
+
it( 'should return `false` when style is undefined', () => {
|
|
110
|
+
expect( hasBackgroundColorValue( undefined ) ).toBe( false );
|
|
111
|
+
} );
|
|
112
|
+
} );
|
|
113
|
+
|
|
114
|
+
describe( 'hasLegacyColorGradientValue', () => {
|
|
115
|
+
it( 'should return `true` when a legacy color.gradient string is set', () => {
|
|
116
|
+
expect(
|
|
117
|
+
hasLegacyColorGradientValue( {
|
|
118
|
+
color: { gradient: 'linear-gradient(135deg, red, blue)' },
|
|
119
|
+
} )
|
|
120
|
+
).toBe( true );
|
|
121
|
+
} );
|
|
122
|
+
|
|
123
|
+
it( 'should return `false` when color.gradient is undefined', () => {
|
|
124
|
+
expect( hasLegacyColorGradientValue( { color: {} } ) ).toBe( false );
|
|
125
|
+
} );
|
|
126
|
+
|
|
127
|
+
it( 'should return `false` when style is undefined', () => {
|
|
128
|
+
expect( hasLegacyColorGradientValue( undefined ) ).toBe( false );
|
|
129
|
+
} );
|
|
130
|
+
|
|
131
|
+
it( 'should not be confused by background.gradient', () => {
|
|
132
|
+
expect(
|
|
133
|
+
hasLegacyColorGradientValue( {
|
|
134
|
+
background: { gradient: 'linear-gradient(red, blue)' },
|
|
135
|
+
} )
|
|
136
|
+
).toBe( false );
|
|
137
|
+
} );
|
|
138
|
+
} );
|
|
@@ -1,135 +1,189 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { click, render } from '@ariakit/test/react';
|
|
4
|
+
import { renderHook } from '@testing-library/react';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Internal dependencies
|
|
9
8
|
*/
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
import {
|
|
10
|
+
useHasColorPanel,
|
|
11
|
+
useHasTextPanel,
|
|
12
|
+
useHasBackgroundColorPanel,
|
|
13
|
+
useHasLinkPanel,
|
|
14
|
+
useHasHeadingPanel,
|
|
15
|
+
useHasButtonPanel,
|
|
16
|
+
useHasCaptionPanel,
|
|
17
|
+
} from '../color-panel';
|
|
18
|
+
|
|
19
|
+
const settingsWithColors = ( overrides = {} ) => ( {
|
|
20
20
|
color: {
|
|
21
|
-
text: true,
|
|
22
|
-
link: false, // keep the panel simple so button queries are unambiguous
|
|
23
|
-
background: false,
|
|
24
|
-
custom: false,
|
|
25
|
-
customGradient: false,
|
|
26
|
-
defaultPalette: false,
|
|
27
21
|
palette: {
|
|
28
|
-
theme: [
|
|
29
|
-
{
|
|
30
|
-
color: '#000',
|
|
31
|
-
name: 'Dark Background',
|
|
32
|
-
slug: 'dark-background',
|
|
33
|
-
},
|
|
34
|
-
{ color: '#000', name: 'Dark Text', slug: 'dark-text' },
|
|
35
|
-
],
|
|
22
|
+
theme: [ { slug: 'red', color: '#ff0000', name: 'Red' } ],
|
|
36
23
|
},
|
|
24
|
+
...overrides,
|
|
37
25
|
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
expect(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
26
|
+
} );
|
|
27
|
+
|
|
28
|
+
describe( 'useHasColorPanel', () => {
|
|
29
|
+
// After moving top-level text color to TypographyPanel and top-level
|
|
30
|
+
// background color to BackgroundPanel, the Color panel only aggregates
|
|
31
|
+
// link and element controls (heading, button, caption).
|
|
32
|
+
it( 'should be false when only text color is enabled', () => {
|
|
33
|
+
const { result } = renderHook( () =>
|
|
34
|
+
useHasColorPanel( settingsWithColors( { text: true } ) )
|
|
35
|
+
);
|
|
36
|
+
expect( result.current ).toBeFalsy();
|
|
37
|
+
} );
|
|
38
|
+
|
|
39
|
+
it( 'should be false when only background color is enabled', () => {
|
|
40
|
+
const { result } = renderHook( () =>
|
|
41
|
+
useHasColorPanel( settingsWithColors( { background: true } ) )
|
|
42
|
+
);
|
|
43
|
+
expect( result.current ).toBeFalsy();
|
|
44
|
+
} );
|
|
45
|
+
|
|
46
|
+
it( 'should be false when both text and background are enabled but no element controls are', () => {
|
|
47
|
+
const { result } = renderHook( () =>
|
|
48
|
+
useHasColorPanel(
|
|
49
|
+
settingsWithColors( { text: true, background: true } )
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
expect( result.current ).toBeFalsy();
|
|
53
|
+
} );
|
|
54
|
+
|
|
55
|
+
it( 'should be true when link color is enabled', () => {
|
|
56
|
+
const { result } = renderHook( () =>
|
|
57
|
+
useHasColorPanel( settingsWithColors( { link: true } ) )
|
|
58
|
+
);
|
|
59
|
+
expect( result.current ).toBeTruthy();
|
|
60
|
+
} );
|
|
61
|
+
|
|
62
|
+
it( 'should be true when heading element is enabled', () => {
|
|
63
|
+
const { result } = renderHook( () =>
|
|
64
|
+
useHasColorPanel( settingsWithColors( { heading: true } ) )
|
|
65
|
+
);
|
|
66
|
+
expect( result.current ).toBeTruthy();
|
|
67
|
+
} );
|
|
68
|
+
|
|
69
|
+
it( 'should be true when button element is enabled', () => {
|
|
70
|
+
const { result } = renderHook( () =>
|
|
71
|
+
useHasColorPanel( settingsWithColors( { button: true } ) )
|
|
72
|
+
);
|
|
73
|
+
expect( result.current ).toBeTruthy();
|
|
74
|
+
} );
|
|
75
|
+
|
|
76
|
+
it( 'should be true when caption element is enabled', () => {
|
|
77
|
+
const { result } = renderHook( () =>
|
|
78
|
+
useHasColorPanel( settingsWithColors( { caption: true } ) )
|
|
79
|
+
);
|
|
80
|
+
expect( result.current ).toBeTruthy();
|
|
81
|
+
} );
|
|
82
|
+
|
|
83
|
+
it( 'should be false when no color controls are enabled', () => {
|
|
84
|
+
const { result } = renderHook( () => useHasColorPanel( {} ) );
|
|
85
|
+
expect( result.current ).toBeFalsy();
|
|
86
|
+
} );
|
|
87
|
+
} );
|
|
88
|
+
|
|
89
|
+
describe( 'useHasTextPanel', () => {
|
|
90
|
+
// Still exported for TypographyPanel to consume as its text color gate.
|
|
91
|
+
it( 'should be true when text color is enabled and colors exist', () => {
|
|
92
|
+
const { result } = renderHook( () =>
|
|
93
|
+
useHasTextPanel( settingsWithColors( { text: true } ) )
|
|
94
|
+
);
|
|
95
|
+
expect( result.current ).toBeTruthy();
|
|
96
|
+
} );
|
|
97
|
+
|
|
98
|
+
it( 'should be true when text color is enabled with custom colors support', () => {
|
|
99
|
+
const { result } = renderHook( () =>
|
|
100
|
+
useHasTextPanel( { color: { text: true, custom: true } } )
|
|
101
|
+
);
|
|
102
|
+
expect( result.current ).toBeTruthy();
|
|
103
|
+
} );
|
|
104
|
+
|
|
105
|
+
it( 'should be false when text color is disabled', () => {
|
|
106
|
+
const { result } = renderHook( () =>
|
|
107
|
+
useHasTextPanel( settingsWithColors( { text: false } ) )
|
|
108
|
+
);
|
|
109
|
+
expect( result.current ).toBeFalsy();
|
|
110
|
+
} );
|
|
111
|
+
|
|
112
|
+
it( 'should be false when no colors or custom support exist', () => {
|
|
113
|
+
const { result } = renderHook( () =>
|
|
114
|
+
useHasTextPanel( { color: { text: true } } )
|
|
115
|
+
);
|
|
116
|
+
expect( result.current ).toBeFalsy();
|
|
117
|
+
} );
|
|
118
|
+
} );
|
|
119
|
+
|
|
120
|
+
describe( 'useHasBackgroundColorPanel', () => {
|
|
121
|
+
// Still exported for BackgroundPanel to consume as its background color gate.
|
|
122
|
+
it( 'should be true when background is enabled and colors exist', () => {
|
|
123
|
+
const { result } = renderHook( () =>
|
|
124
|
+
useHasBackgroundColorPanel(
|
|
125
|
+
settingsWithColors( { background: true } )
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
expect( result.current ).toBeTruthy();
|
|
129
|
+
} );
|
|
130
|
+
|
|
131
|
+
it( 'should be true when only gradients are available', () => {
|
|
132
|
+
const { result } = renderHook( () =>
|
|
133
|
+
useHasBackgroundColorPanel( {
|
|
134
|
+
color: {
|
|
135
|
+
background: true,
|
|
136
|
+
gradients: {
|
|
137
|
+
theme: [
|
|
138
|
+
{
|
|
139
|
+
slug: 'cyan',
|
|
140
|
+
gradient: 'linear-gradient(cyan, blue)',
|
|
141
|
+
name: 'Cyan',
|
|
142
|
+
},
|
|
143
|
+
],
|
|
118
144
|
},
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
145
|
+
},
|
|
146
|
+
} )
|
|
147
|
+
);
|
|
148
|
+
expect( result.current ).toBeTruthy();
|
|
149
|
+
} );
|
|
150
|
+
|
|
151
|
+
it( 'should be false when background color is disabled', () => {
|
|
152
|
+
const { result } = renderHook( () =>
|
|
153
|
+
useHasBackgroundColorPanel(
|
|
154
|
+
settingsWithColors( { background: false } )
|
|
155
|
+
)
|
|
124
156
|
);
|
|
157
|
+
expect( result.current ).toBeFalsy();
|
|
158
|
+
} );
|
|
159
|
+
} );
|
|
125
160
|
|
|
126
|
-
|
|
127
|
-
|
|
161
|
+
describe( 'element color hooks', () => {
|
|
162
|
+
it( 'useHasLinkPanel is truthy when link is enabled with colors', () => {
|
|
163
|
+
const { result } = renderHook( () =>
|
|
164
|
+
useHasLinkPanel( settingsWithColors( { link: true } ) )
|
|
165
|
+
);
|
|
166
|
+
expect( result.current ).toBeTruthy();
|
|
167
|
+
} );
|
|
128
168
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
expect( result
|
|
169
|
+
it( 'useHasHeadingPanel is truthy when heading is enabled with colors', () => {
|
|
170
|
+
const { result } = renderHook( () =>
|
|
171
|
+
useHasHeadingPanel( settingsWithColors( { heading: true } ) )
|
|
172
|
+
);
|
|
173
|
+
expect( result.current ).toBeTruthy();
|
|
174
|
+
} );
|
|
175
|
+
|
|
176
|
+
it( 'useHasButtonPanel is truthy when button is enabled with colors', () => {
|
|
177
|
+
const { result } = renderHook( () =>
|
|
178
|
+
useHasButtonPanel( settingsWithColors( { button: true } ) )
|
|
179
|
+
);
|
|
180
|
+
expect( result.current ).toBeTruthy();
|
|
181
|
+
} );
|
|
182
|
+
|
|
183
|
+
it( 'useHasCaptionPanel is truthy when caption is enabled with colors', () => {
|
|
184
|
+
const { result } = renderHook( () =>
|
|
185
|
+
useHasCaptionPanel( settingsWithColors( { caption: true } ) )
|
|
186
|
+
);
|
|
187
|
+
expect( result.current ).toBeTruthy();
|
|
134
188
|
} );
|
|
135
189
|
} );
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { renderHook, screen } from '@testing-library/react';
|
|
5
|
+
import { click, render } from '@ariakit/test/react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import TypographyPanel, { useHasTypographyPanel } from '../typography-panel';
|
|
11
|
+
|
|
12
|
+
const settingsWithColors = ( overrides = {} ) => ( {
|
|
13
|
+
color: {
|
|
14
|
+
palette: {
|
|
15
|
+
theme: [ { slug: 'red', color: '#ff0000', name: 'Red' } ],
|
|
16
|
+
},
|
|
17
|
+
...overrides,
|
|
18
|
+
},
|
|
19
|
+
} );
|
|
20
|
+
|
|
21
|
+
describe( 'useHasTypographyPanel', () => {
|
|
22
|
+
// After moving top-level text color into TypographyPanel, text color
|
|
23
|
+
// alone should be enough to open the panel.
|
|
24
|
+
it( 'should be true when only text color is enabled', () => {
|
|
25
|
+
const { result } = renderHook( () =>
|
|
26
|
+
useHasTypographyPanel( settingsWithColors( { text: true } ) )
|
|
27
|
+
);
|
|
28
|
+
expect( result.current ).toBeTruthy();
|
|
29
|
+
} );
|
|
30
|
+
|
|
31
|
+
it( 'should be true when only font family is enabled', () => {
|
|
32
|
+
const { result } = renderHook( () =>
|
|
33
|
+
useHasTypographyPanel( {
|
|
34
|
+
typography: {
|
|
35
|
+
fontFamilies: {
|
|
36
|
+
theme: [ { slug: 'sans', fontFamily: 'sans-serif' } ],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
} )
|
|
40
|
+
);
|
|
41
|
+
expect( result.current ).toBeTruthy();
|
|
42
|
+
} );
|
|
43
|
+
|
|
44
|
+
it( 'should be true when only line height is enabled', () => {
|
|
45
|
+
const { result } = renderHook( () =>
|
|
46
|
+
useHasTypographyPanel( { typography: { lineHeight: true } } )
|
|
47
|
+
);
|
|
48
|
+
expect( result.current ).toBeTruthy();
|
|
49
|
+
} );
|
|
50
|
+
|
|
51
|
+
it( 'should be false when no typography or text color controls are enabled', () => {
|
|
52
|
+
const { result } = renderHook( () => useHasTypographyPanel( {} ) );
|
|
53
|
+
expect( result.current ).toBeFalsy();
|
|
54
|
+
} );
|
|
55
|
+
|
|
56
|
+
it( 'should be false when text color is enabled but no colors or custom support exist', () => {
|
|
57
|
+
const { result } = renderHook( () =>
|
|
58
|
+
useHasTypographyPanel( { color: { text: true } } )
|
|
59
|
+
);
|
|
60
|
+
expect( result.current ).toBeFalsy();
|
|
61
|
+
} );
|
|
62
|
+
|
|
63
|
+
it( 'should be true when text color is enabled with custom colors support', () => {
|
|
64
|
+
const { result } = renderHook( () =>
|
|
65
|
+
useHasTypographyPanel( { color: { text: true, custom: true } } )
|
|
66
|
+
);
|
|
67
|
+
expect( result.current ).toBeTruthy();
|
|
68
|
+
} );
|
|
69
|
+
} );
|
|
70
|
+
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
// TypographyPanel — setTextColor link-sync behaviour (render tests)
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
// Setting the text color should keep an in-sync link color following it (e.g.
|
|
76
|
+
// a Button's link color tracks its text color). The two palette entries below
|
|
77
|
+
// share the same decoded hex value (#000) but carry distinct slugs, ensuring
|
|
78
|
+
// the sync keys off the raw preset reference rather than the decoded hex.
|
|
79
|
+
const DUPLICATE_PALETTE_SETTINGS = {
|
|
80
|
+
color: {
|
|
81
|
+
text: true,
|
|
82
|
+
custom: false,
|
|
83
|
+
customGradient: false,
|
|
84
|
+
defaultPalette: false,
|
|
85
|
+
palette: {
|
|
86
|
+
theme: [
|
|
87
|
+
{
|
|
88
|
+
color: '#000',
|
|
89
|
+
name: 'Dark Background',
|
|
90
|
+
slug: 'dark-background',
|
|
91
|
+
},
|
|
92
|
+
{ color: '#000', name: 'Dark Text', slug: 'dark-text' },
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
describe( 'TypographyPanel — setTextColor link sync', () => {
|
|
99
|
+
// Helper: open the text Color dropdown and return the rendered swatches.
|
|
100
|
+
async function openTextColorDropdown() {
|
|
101
|
+
await click(
|
|
102
|
+
screen.getByRole( 'button', { name: /Color/, expanded: false } )
|
|
103
|
+
);
|
|
104
|
+
// `findAllByRole` waits for the Popover/portal content to appear.
|
|
105
|
+
return screen.findAllByRole( 'option' );
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
it( 'syncs the link color when text and link share the same raw preset reference', async () => {
|
|
109
|
+
const onChange = jest.fn();
|
|
110
|
+
const sharedRef = 'var:preset|color|dark-background';
|
|
111
|
+
|
|
112
|
+
await render(
|
|
113
|
+
<TypographyPanel
|
|
114
|
+
value={ {} }
|
|
115
|
+
inheritedValue={ {
|
|
116
|
+
color: { text: sharedRef },
|
|
117
|
+
elements: { link: { color: { text: sharedRef } } },
|
|
118
|
+
} }
|
|
119
|
+
settings={ DUPLICATE_PALETTE_SETTINGS }
|
|
120
|
+
panelId="test"
|
|
121
|
+
onChange={ onChange }
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const swatches = await openTextColorDropdown();
|
|
126
|
+
// swatch[0] = 'dark-background', swatch[1] = 'dark-text'
|
|
127
|
+
await click( swatches[ 1 ] );
|
|
128
|
+
|
|
129
|
+
const result = onChange.mock.calls[ 0 ][ 0 ];
|
|
130
|
+
expect( result?.color?.text ).toBe( 'var:preset|color|dark-text' );
|
|
131
|
+
// Link must follow because text and link shared the same ref.
|
|
132
|
+
expect( result?.elements?.link?.color?.text ).toBe(
|
|
133
|
+
'var:preset|color|dark-text'
|
|
134
|
+
);
|
|
135
|
+
} );
|
|
136
|
+
|
|
137
|
+
it( 'does NOT sync the link color when text and link have different raw refs, even if their decoded hex values match', async () => {
|
|
138
|
+
const onChange = jest.fn();
|
|
139
|
+
|
|
140
|
+
await render(
|
|
141
|
+
<TypographyPanel
|
|
142
|
+
value={ {} }
|
|
143
|
+
inheritedValue={ {
|
|
144
|
+
// Both resolve to #000, but they are different preset references.
|
|
145
|
+
color: { text: 'var:preset|color|dark-background' },
|
|
146
|
+
elements: {
|
|
147
|
+
link: {
|
|
148
|
+
color: { text: 'var:preset|color|dark-text' },
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
} }
|
|
152
|
+
settings={ DUPLICATE_PALETTE_SETTINGS }
|
|
153
|
+
panelId="test"
|
|
154
|
+
onChange={ onChange }
|
|
155
|
+
/>
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const swatches = await openTextColorDropdown();
|
|
159
|
+
await click( swatches[ 1 ] );
|
|
160
|
+
|
|
161
|
+
const result = onChange.mock.calls[ 0 ][ 0 ];
|
|
162
|
+
expect( result?.color?.text ).toBe( 'var:preset|color|dark-text' );
|
|
163
|
+
// Link must NOT be updated: raw-ref identity is what matters,
|
|
164
|
+
// not decoded-value equality.
|
|
165
|
+
expect( result?.elements?.link?.color?.text ).toBeUndefined();
|
|
166
|
+
} );
|
|
167
|
+
} );
|