@wordpress/block-editor 16.0.0 → 16.1.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 +18 -0
- package/README.md +8 -0
- package/build/components/alignment-control/ui.cjs +2 -4
- package/build/components/alignment-control/ui.cjs.map +2 -2
- package/build/components/background-image-control/index.cjs +40 -10
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-alignment-control/ui.cjs +5 -3
- package/build/components/block-alignment-control/ui.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +73 -46
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/block-html.cjs +4 -1
- package/build/components/block-list/block-html.cjs.map +2 -2
- package/build/components/block-list/use-block-props/index.cjs +5 -2
- package/build/components/block-list/use-block-props/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-handler.cjs +2 -3
- package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-register-block-event-handlers.cjs +48 -0
- package/build/components/block-list/use-block-props/use-register-block-event-handlers.cjs.map +7 -0
- package/build/components/block-parent-selector/index.cjs +2 -2
- package/build/components/block-parent-selector/index.cjs.map +2 -2
- package/build/components/block-toolbar/switch-section-style.cjs +4 -2
- package/build/components/block-toolbar/switch-section-style.cjs.map +3 -3
- package/build/components/block-tools/empty-block-inserter.cjs +2 -7
- package/build/components/block-tools/empty-block-inserter.cjs.map +2 -2
- package/build/components/block-vertical-alignment-control/ui.cjs +3 -5
- package/build/components/block-vertical-alignment-control/ui.cjs.map +2 -2
- package/build/components/border-radius-control/utils.cjs +8 -58
- package/build/components/border-radius-control/utils.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +5 -3
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/dimension-control/index.cjs +30 -20
- package/build/components/dimension-control/index.cjs.map +3 -3
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +9 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +3 -3
- package/build/components/editor-styles/index.cjs +9 -1
- package/build/components/editor-styles/index.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +66 -25
- package/build/components/global-styles/background-panel.cjs.map +3 -3
- package/build/components/global-styles/border-panel.cjs +153 -55
- package/build/components/global-styles/border-panel.cjs.map +3 -3
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +46 -14
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +3 -3
- package/build/components/global-styles/color-panel.cjs +63 -17
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +242 -64
- package/build/components/global-styles/dimensions-panel.cjs.map +3 -3
- package/build/components/global-styles/filters-panel.cjs +59 -20
- package/build/components/global-styles/filters-panel.cjs.map +3 -3
- package/build/components/global-styles/hooks.cjs +4 -1
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/inheritance/index.cjs +142 -0
- package/build/components/global-styles/inheritance/index.cjs.map +7 -0
- package/build/components/global-styles/inherited-value-context.cjs +173 -0
- package/build/components/global-styles/inherited-value-context.cjs.map +7 -0
- package/build/components/global-styles/shadow-panel-components.cjs +38 -20
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/state-control.cjs +1 -1
- package/build/components/global-styles/state-control.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +271 -78
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs +10 -1
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/line-height-control/index.cjs +1 -1
- package/build/components/line-height-control/index.cjs.map +2 -2
- package/build/components/link-control/index.cjs +3 -1
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/preset-input-control/index.cjs +2 -1
- package/build/components/preset-input-control/index.cjs.map +2 -2
- package/build/components/provider/block-refs-provider.cjs +8 -2
- package/build/components/provider/block-refs-provider.cjs.map +2 -2
- package/build/components/provider/index.cjs +1 -1
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/provider/use-block-sync.cjs +18 -6
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/provider/use-media-upload-settings.cjs +3 -1
- package/build/components/provider/use-media-upload-settings.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +23 -13
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/spacing-sizes-control/utils.cjs +6 -19
- package/build/components/spacing-sizes-control/utils.cjs.map +2 -2
- package/build/components/text-indent-control/index.cjs +8 -2
- package/build/components/text-indent-control/index.cjs.map +2 -2
- package/build/components/url-input/index.cjs +303 -344
- package/build/components/url-input/index.cjs.map +3 -3
- package/build/components/writing-flow/index.cjs +2 -0
- package/build/components/writing-flow/index.cjs.map +3 -3
- package/build/components/writing-flow/use-arrow-nav.cjs +24 -1
- package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
- package/build/components/writing-flow/use-click-selection.cjs +28 -2
- package/build/components/writing-flow/use-click-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-editable-root-event-handlers.cjs +179 -0
- package/build/components/writing-flow/use-editable-root-event-handlers.cjs.map +7 -0
- package/build/components/writing-flow/use-editable-root.cjs +5 -42
- package/build/components/writing-flow/use-editable-root.cjs.map +2 -2
- package/build/components/writing-flow/use-home-end.cjs +1 -1
- package/build/components/writing-flow/use-home-end.cjs.map +2 -2
- package/build/components/writing-flow/use-selection-observer.cjs +17 -13
- package/build/components/writing-flow/use-selection-observer.cjs.map +2 -2
- package/build/components/writing-flow/utils.cjs +3 -14
- package/build/components/writing-flow/utils.cjs.map +2 -2
- package/build/hooks/background.cjs +13 -10
- package/build/hooks/background.cjs.map +2 -2
- package/build/hooks/block-style-variation.cjs +4 -45
- package/build/hooks/block-style-variation.cjs.map +3 -3
- package/build/hooks/border.cjs +19 -4
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/custom-css.cjs +6 -2
- package/build/hooks/custom-css.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +15 -4
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/duotone.cjs +26 -14
- package/build/hooks/duotone.cjs.map +3 -3
- package/build/hooks/elements.cjs +14 -4
- package/build/hooks/elements.cjs.map +2 -2
- package/build/hooks/line-height.cjs +1 -2
- package/build/hooks/line-height.cjs.map +2 -2
- package/build/hooks/typography.cjs +13 -4
- package/build/hooks/typography.cjs.map +2 -2
- package/build/private-apis.cjs +9 -5
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs +9 -4
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +28 -1
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +6 -6
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +23 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/native-undo.cjs +55 -0
- package/build/utils/native-undo.cjs.map +7 -0
- package/build-module/components/alignment-control/ui.mjs +2 -4
- package/build-module/components/alignment-control/ui.mjs.map +2 -2
- package/build-module/components/background-image-control/index.mjs +43 -10
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-alignment-control/ui.mjs +5 -3
- package/build-module/components/block-alignment-control/ui.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +74 -46
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block-html.mjs +4 -1
- package/build-module/components/block-list/block-html.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/index.mjs +5 -2
- package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +2 -3
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-register-block-event-handlers.mjs +28 -0
- package/build-module/components/block-list/use-block-props/use-register-block-event-handlers.mjs.map +7 -0
- package/build-module/components/block-parent-selector/index.mjs +2 -2
- package/build-module/components/block-parent-selector/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs +4 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs.map +2 -2
- package/build-module/components/block-tools/empty-block-inserter.mjs +2 -7
- package/build-module/components/block-tools/empty-block-inserter.mjs.map +2 -2
- package/build-module/components/block-vertical-alignment-control/ui.mjs +4 -6
- package/build-module/components/block-vertical-alignment-control/ui.mjs.map +2 -2
- package/build-module/components/border-radius-control/utils.mjs +11 -53
- package/build-module/components/border-radius-control/utils.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +5 -3
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/dimension-control/index.mjs +30 -20
- package/build-module/components/dimension-control/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +10 -6
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/editor-styles/index.mjs +9 -1
- package/build-module/components/editor-styles/index.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +71 -29
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +157 -56
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +51 -15
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +63 -17
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +248 -66
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +64 -21
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +4 -1
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/inheritance/index.mjs +108 -0
- package/build-module/components/global-styles/inheritance/index.mjs.map +7 -0
- package/build-module/components/global-styles/inherited-value-context.mjs +141 -0
- package/build-module/components/global-styles/inherited-value-context.mjs.map +7 -0
- package/build-module/components/global-styles/shadow-panel-components.mjs +38 -20
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/state-control.mjs +1 -1
- package/build-module/components/global-styles/state-control.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +276 -79
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +6 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/line-height-control/index.mjs +1 -1
- package/build-module/components/line-height-control/index.mjs.map +2 -2
- package/build-module/components/link-control/index.mjs +4 -2
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs +2 -1
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/provider/block-refs-provider.mjs +8 -2
- package/build-module/components/provider/block-refs-provider.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +1 -1
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs +18 -6
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/provider/use-media-upload-settings.mjs +3 -1
- package/build-module/components/provider/use-media-upload-settings.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +28 -14
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/spacing-sizes-control/utils.mjs +6 -18
- package/build-module/components/spacing-sizes-control/utils.mjs.map +2 -2
- package/build-module/components/text-indent-control/index.mjs +8 -2
- package/build-module/components/text-indent-control/index.mjs.map +2 -2
- package/build-module/components/url-input/index.mjs +306 -353
- package/build-module/components/url-input/index.mjs.map +2 -2
- package/build-module/components/writing-flow/index.mjs +2 -0
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs +24 -1
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
- package/build-module/components/writing-flow/use-click-selection.mjs +28 -2
- package/build-module/components/writing-flow/use-click-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-editable-root-event-handlers.mjs +154 -0
- package/build-module/components/writing-flow/use-editable-root-event-handlers.mjs.map +7 -0
- package/build-module/components/writing-flow/use-editable-root.mjs +5 -37
- package/build-module/components/writing-flow/use-editable-root.mjs.map +2 -2
- package/build-module/components/writing-flow/use-home-end.mjs +1 -1
- package/build-module/components/writing-flow/use-home-end.mjs.map +2 -2
- package/build-module/components/writing-flow/use-selection-observer.mjs +18 -14
- package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
- package/build-module/components/writing-flow/utils.mjs +2 -11
- package/build-module/components/writing-flow/utils.mjs.map +2 -2
- package/build-module/hooks/background.mjs +13 -10
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-style-variation.mjs +8 -44
- package/build-module/hooks/block-style-variation.mjs.map +2 -2
- package/build-module/hooks/border.mjs +19 -4
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +7 -3
- package/build-module/hooks/custom-css.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +15 -4
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/duotone.mjs +20 -9
- package/build-module/hooks/duotone.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +14 -4
- package/build-module/hooks/elements.mjs.map +2 -2
- package/build-module/hooks/line-height.mjs +1 -2
- package/build-module/hooks/line-height.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +13 -4
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/private-apis.mjs +7 -3
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +9 -4
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +29 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +6 -6
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +23 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/native-undo.mjs +29 -0
- package/build-module/utils/native-undo.mjs.map +7 -0
- package/build-style/content-rtl.css +10 -18
- package/build-style/content.css +10 -18
- package/build-style/style-rtl.css +150 -7
- package/build-style/style.css +150 -7
- package/package.json +40 -41
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +1 -1
- package/src/components/alignment-control/ui.js +2 -4
- package/src/components/background-image-control/index.js +74 -37
- package/src/components/background-image-control/style.scss +13 -4
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +3 -3
- package/src/components/block-alignment-control/test/index.js +1 -1
- package/src/components/block-alignment-control/ui.js +4 -2
- package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +1 -1
- package/src/components/block-compare/test/__snapshots__/block-view.js.snap +1 -1
- package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -1
- package/src/components/block-inspector/index.js +60 -31
- package/src/components/block-list/block-html.js +5 -0
- package/src/components/block-list/content.scss +1 -11
- package/src/components/block-list/use-block-props/index.js +5 -1
- package/src/components/block-list/use-block-props/use-focus-handler.js +9 -8
- package/src/components/block-list/use-block-props/use-register-block-event-handlers.js +45 -0
- package/src/components/block-parent-selector/index.js +5 -2
- package/src/components/block-toolbar/switch-section-style.js +5 -2
- package/src/components/block-tools/empty-block-inserter.js +3 -7
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +3 -3
- package/src/components/block-vertical-alignment-control/test/index.js +18 -2
- package/src/components/block-vertical-alignment-control/ui.js +3 -5
- package/src/components/border-radius-control/test/utils.js +0 -41
- package/src/components/border-radius-control/utils.js +16 -107
- package/src/components/button-block-appender/content.scss +6 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/colors-gradients/control.js +6 -3
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +1 -1
- package/src/components/dimension-control/index.js +13 -1
- package/src/components/dimensions-tool/aspect-ratio-tool.js +13 -6
- package/src/components/editor-styles/index.js +16 -1
- package/src/components/global-styles/background-panel.js +107 -34
- package/src/components/global-styles/border-panel.js +219 -48
- package/src/components/global-styles/color-gradient-dropdown-item.js +93 -28
- package/src/components/global-styles/color-panel.js +92 -11
- package/src/components/global-styles/dimensions-panel.js +422 -71
- package/src/components/global-styles/filters-panel.js +88 -28
- package/src/components/global-styles/hooks.js +8 -1
- package/src/components/global-styles/inheritance/index.js +204 -0
- package/src/components/global-styles/inheritance/style.scss +184 -0
- package/src/components/global-styles/inheritance/test/index.js +281 -0
- package/src/components/global-styles/inherited-value-context.js +271 -0
- package/src/components/global-styles/shadow-panel-components.js +48 -26
- package/src/components/global-styles/state-control.js +2 -2
- package/src/components/global-styles/test/background-panel.js +338 -1
- package/src/components/global-styles/test/border-panel.js +441 -0
- package/src/components/global-styles/test/color-panel.js +182 -2
- package/src/components/global-styles/test/dimensions-panel.js +753 -0
- package/src/components/global-styles/test/filters-panel.js +194 -0
- package/src/components/global-styles/test/inherited-value-context-core.js +98 -0
- package/src/components/global-styles/test/inherited-value-context.js +454 -0
- package/src/components/global-styles/test/typography-panel-core.js +185 -0
- package/src/components/global-styles/test/typography-panel.js +849 -12
- package/src/components/global-styles/typography-panel.js +449 -100
- package/src/components/image-editor/style.scss +33 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +5 -1
- package/src/components/line-height-control/index.js +1 -1
- package/src/components/link-control/index.js +7 -2
- package/src/components/preset-input-control/index.js +4 -1
- package/src/components/provider/block-refs-provider.js +12 -2
- package/src/components/provider/index.js +2 -2
- package/src/components/provider/use-block-sync.js +18 -6
- package/src/components/provider/use-media-upload-settings.js +2 -0
- package/src/components/rich-text/index.js +37 -16
- package/src/components/spacing-sizes-control/test/utils.js +16 -5
- package/src/components/spacing-sizes-control/utils.js +11 -28
- package/src/components/text-indent-control/index.js +8 -0
- package/src/components/url-input/index.js +363 -431
- package/src/components/url-input/test/index.js +592 -0
- package/src/components/warning/test/__snapshots__/index.js.snap +1 -1
- package/src/components/writing-flow/index.js +2 -0
- package/src/components/writing-flow/use-arrow-nav.js +51 -1
- package/src/components/writing-flow/use-click-selection.js +54 -3
- package/src/components/writing-flow/use-editable-root-event-handlers.js +266 -0
- package/src/components/writing-flow/use-editable-root.js +7 -77
- package/src/components/writing-flow/use-home-end.js +17 -9
- package/src/components/writing-flow/use-selection-observer.js +32 -15
- package/src/components/writing-flow/utils.js +3 -24
- package/src/hooks/background.js +26 -21
- package/src/hooks/block-fields/rich-text/styles.scss +1 -1
- package/src/hooks/block-style-variation.js +8 -74
- package/src/hooks/border.js +19 -4
- package/src/hooks/custom-css.js +15 -6
- package/src/hooks/dimensions.js +17 -4
- package/src/hooks/duotone.js +26 -8
- package/src/hooks/elements.js +14 -3
- package/src/hooks/line-height.js +0 -1
- package/src/hooks/test/inherited-value-wiring.js +411 -0
- package/src/hooks/test/preset-round-trip.js +456 -0
- package/src/hooks/typography.js +35 -23
- package/src/private-apis.js +11 -2
- package/src/store/actions.js +10 -4
- package/src/store/private-selectors.js +57 -1
- package/src/store/reducer.js +9 -9
- package/src/store/selectors.js +56 -8
- package/src/store/test/private-selectors.js +160 -1
- package/src/style.scss +2 -0
- package/src/utils/native-undo.js +56 -0
- package/build/components/duotone/utils.cjs +0 -87
- package/build/components/duotone/utils.cjs.map +0 -7
- package/build-module/components/duotone/utils.mjs +0 -59
- package/build-module/components/duotone/utils.mjs.map +0 -7
- package/src/components/duotone/utils.js +0 -90
- package/src/hooks/test/get-variation-styles-with-ref-values.js +0 -91
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import BorderPanel from '../border-panel';
|
|
11
|
+
|
|
12
|
+
// The inheritance treatment sits behind the
|
|
13
|
+
// `gutenberg-global-styles-inheritance-ui` experiment. Turn it on so these
|
|
14
|
+
// tests exercise the inheriting path.
|
|
15
|
+
beforeEach( () => {
|
|
16
|
+
window.__experimentalGlobalStylesInheritanceUI = true;
|
|
17
|
+
} );
|
|
18
|
+
|
|
19
|
+
afterEach( () => {
|
|
20
|
+
delete window.__experimentalGlobalStylesInheritanceUI;
|
|
21
|
+
} );
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Tests for the inherited Global Styles label treatment in `BorderPanel`.
|
|
25
|
+
* The visual treatment lands on the parent `ToolsPanelItem` via the
|
|
26
|
+
* `.is-inherited-from-global-styles` / `.has-local-override-from-global-styles`
|
|
27
|
+
* class hooks. The inner controls (`BorderBoxControl`,
|
|
28
|
+
* `BorderRadiusControl`, `ShadowPopover`) carry no special className
|
|
29
|
+
* for inheritance state.
|
|
30
|
+
*
|
|
31
|
+
* For the input archetype (`BorderRadiusControl`) the inherited value
|
|
32
|
+
* is forwarded as the displayed `values=` while local values are unset, so
|
|
33
|
+
* the underlying UnitControl can parse the quantity and unit normally without
|
|
34
|
+
* committing the inherited value on mount.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
const settingsAll = {
|
|
38
|
+
border: {
|
|
39
|
+
color: true,
|
|
40
|
+
radius: true,
|
|
41
|
+
style: true,
|
|
42
|
+
width: true,
|
|
43
|
+
},
|
|
44
|
+
shadow: {
|
|
45
|
+
defaultPresets: true,
|
|
46
|
+
presets: {
|
|
47
|
+
default: [
|
|
48
|
+
{
|
|
49
|
+
name: 'Soft',
|
|
50
|
+
slug: 'soft',
|
|
51
|
+
shadow: '0 4px 8px rgba(0,0,0,0.1)',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'Hard',
|
|
55
|
+
slug: 'hard',
|
|
56
|
+
shadow: '0 8px 16px rgba(0,0,0,0.2)',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
describe( 'BorderPanel — inherited Global Styles label treatment', () => {
|
|
64
|
+
describe( 'Border radius (input archetype)', () => {
|
|
65
|
+
it( 'renders an inherited string radius as the displayed value when local is empty', () => {
|
|
66
|
+
const inheritedValue = { border: { radius: '8px' } };
|
|
67
|
+
|
|
68
|
+
render(
|
|
69
|
+
<BorderPanel
|
|
70
|
+
value={ {} }
|
|
71
|
+
inheritedValue={ inheritedValue }
|
|
72
|
+
settings={ settingsAll }
|
|
73
|
+
onChange={ () => {} }
|
|
74
|
+
panelId="test-panel"
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const radiusInput = screen.getByRole( 'spinbutton', {
|
|
79
|
+
name: /border radius/i,
|
|
80
|
+
} );
|
|
81
|
+
expect( radiusInput ).toHaveValue( 8 );
|
|
82
|
+
expect( radiusInput ).not.toHaveAttribute( 'placeholder' );
|
|
83
|
+
} );
|
|
84
|
+
|
|
85
|
+
it( 'uses the inherited radius unit as the selected unit when local is empty', () => {
|
|
86
|
+
const inheritedValue = { border: { radius: '2.5em' } };
|
|
87
|
+
|
|
88
|
+
render(
|
|
89
|
+
<BorderPanel
|
|
90
|
+
value={ {} }
|
|
91
|
+
inheritedValue={ inheritedValue }
|
|
92
|
+
settings={ settingsAll }
|
|
93
|
+
onChange={ () => {} }
|
|
94
|
+
panelId="test-panel"
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const radiusInput = screen.getByRole( 'spinbutton', {
|
|
99
|
+
name: /border radius/i,
|
|
100
|
+
} );
|
|
101
|
+
expect( radiusInput ).toHaveValue( 2.5 );
|
|
102
|
+
const unitControls = screen.getAllByRole( 'combobox', {
|
|
103
|
+
name: /select unit/i,
|
|
104
|
+
} );
|
|
105
|
+
expect( unitControls[ 1 ] ).toHaveValue( 'em' );
|
|
106
|
+
} );
|
|
107
|
+
|
|
108
|
+
it( 'renders a locally-set radius as the value with no placeholder', () => {
|
|
109
|
+
const inheritedValue = { border: { radius: '8px' } };
|
|
110
|
+
const value = { border: { radius: '12px' } };
|
|
111
|
+
|
|
112
|
+
render(
|
|
113
|
+
<BorderPanel
|
|
114
|
+
value={ value }
|
|
115
|
+
inheritedValue={ inheritedValue }
|
|
116
|
+
settings={ settingsAll }
|
|
117
|
+
onChange={ () => {} }
|
|
118
|
+
panelId="test-panel"
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const radiusInput = screen.getByRole( 'spinbutton', {
|
|
123
|
+
name: /border radius/i,
|
|
124
|
+
} );
|
|
125
|
+
expect( radiusInput ).toHaveValue( 12 );
|
|
126
|
+
expect( radiusInput ).not.toHaveAttribute( 'placeholder' );
|
|
127
|
+
expect(
|
|
128
|
+
screen.getByRole( 'button', {
|
|
129
|
+
name: /reset to inherited value/i,
|
|
130
|
+
} )
|
|
131
|
+
).toBeInTheDocument();
|
|
132
|
+
} );
|
|
133
|
+
|
|
134
|
+
it( 'does not invoke onChange on mount when only an inherited radius is present (display-without-commit)', () => {
|
|
135
|
+
const onChange = jest.fn();
|
|
136
|
+
const inheritedValue = { border: { radius: '8px' } };
|
|
137
|
+
|
|
138
|
+
render(
|
|
139
|
+
<BorderPanel
|
|
140
|
+
value={ {} }
|
|
141
|
+
inheritedValue={ inheritedValue }
|
|
142
|
+
settings={ settingsAll }
|
|
143
|
+
onChange={ onChange }
|
|
144
|
+
panelId="test-panel"
|
|
145
|
+
/>
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
expect( onChange ).not.toHaveBeenCalled();
|
|
149
|
+
} );
|
|
150
|
+
|
|
151
|
+
it( 'commits a typed local radius override without copying any inherited values (strip-not-copy)', async () => {
|
|
152
|
+
const user = userEvent.setup();
|
|
153
|
+
const onChange = jest.fn();
|
|
154
|
+
const inheritedValue = {
|
|
155
|
+
border: { radius: '8px' },
|
|
156
|
+
shadow: 'var:preset|shadow|soft',
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
render(
|
|
160
|
+
<BorderPanel
|
|
161
|
+
value={ {} }
|
|
162
|
+
inheritedValue={ inheritedValue }
|
|
163
|
+
settings={ settingsAll }
|
|
164
|
+
onChange={ onChange }
|
|
165
|
+
panelId="test-panel"
|
|
166
|
+
/>
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
const radiusInput = screen.getByRole( 'spinbutton', {
|
|
170
|
+
name: /border radius/i,
|
|
171
|
+
} );
|
|
172
|
+
await user.type( radiusInput, '20' );
|
|
173
|
+
|
|
174
|
+
expect( onChange ).toHaveBeenCalled();
|
|
175
|
+
const lastCall = onChange.mock.calls.at( -1 )[ 0 ];
|
|
176
|
+
expect( lastCall?.border?.radius ).toBeDefined();
|
|
177
|
+
expect( lastCall?.shadow ).toBeUndefined();
|
|
178
|
+
} );
|
|
179
|
+
|
|
180
|
+
it( 'does not bake the inherited border color/style/width into the local override when only a radius is set', async () => {
|
|
181
|
+
const user = userEvent.setup();
|
|
182
|
+
const onChange = jest.fn();
|
|
183
|
+
const inheritedValue = {
|
|
184
|
+
border: {
|
|
185
|
+
color: '#000000',
|
|
186
|
+
style: 'solid',
|
|
187
|
+
width: '1px',
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
render(
|
|
192
|
+
<BorderPanel
|
|
193
|
+
value={ {} }
|
|
194
|
+
inheritedValue={ inheritedValue }
|
|
195
|
+
settings={ settingsAll }
|
|
196
|
+
onChange={ onChange }
|
|
197
|
+
panelId="test-panel"
|
|
198
|
+
/>
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
const radiusInput = screen.getByRole( 'spinbutton', {
|
|
202
|
+
name: /border radius/i,
|
|
203
|
+
} );
|
|
204
|
+
await user.type( radiusInput, '20' );
|
|
205
|
+
|
|
206
|
+
expect( onChange ).toHaveBeenCalled();
|
|
207
|
+
const committedBorder = onChange.mock.calls.at( -1 )[ 0 ]?.border;
|
|
208
|
+
expect( committedBorder?.radius ).toBeDefined();
|
|
209
|
+
expect( committedBorder?.color ).toBeUndefined();
|
|
210
|
+
expect( committedBorder?.style ).toBeUndefined();
|
|
211
|
+
expect( committedBorder?.width ).toBeUndefined();
|
|
212
|
+
} );
|
|
213
|
+
} );
|
|
214
|
+
|
|
215
|
+
describe( 'Border box (compound archetype)', () => {
|
|
216
|
+
it( 'surfaces the accessible reset affordance when a local border is defined', () => {
|
|
217
|
+
const inheritedValue = {
|
|
218
|
+
border: {
|
|
219
|
+
color: '#000000',
|
|
220
|
+
style: 'solid',
|
|
221
|
+
width: '1px',
|
|
222
|
+
radius: '8px',
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
const value = {
|
|
226
|
+
border: {
|
|
227
|
+
color: '#ff0000',
|
|
228
|
+
style: 'dashed',
|
|
229
|
+
width: '2px',
|
|
230
|
+
radius: '12px',
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
render(
|
|
235
|
+
<BorderPanel
|
|
236
|
+
value={ value }
|
|
237
|
+
inheritedValue={ inheritedValue }
|
|
238
|
+
settings={ settingsAll }
|
|
239
|
+
onChange={ () => {} }
|
|
240
|
+
panelId="test-panel"
|
|
241
|
+
/>
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
// The local override surfaces the accessible reset affordance.
|
|
245
|
+
expect(
|
|
246
|
+
screen.getAllByRole( 'button', {
|
|
247
|
+
name: /reset to inherited value/i,
|
|
248
|
+
} ).length
|
|
249
|
+
).toBeGreaterThanOrEqual( 1 );
|
|
250
|
+
} );
|
|
251
|
+
|
|
252
|
+
it( 'does not bake the inherited radius into the local override when only color/style/width are customised (regression)', async () => {
|
|
253
|
+
// Regression: when at-rest the panel displays the inherited
|
|
254
|
+
// border in `BorderBoxControl`, including the inherited
|
|
255
|
+
// `radius`. Customising color/style/width must not copy
|
|
256
|
+
// the inherited radius into `value.border.radius` —
|
|
257
|
+
// otherwise the radius `ToolsPanelItem` flips into the
|
|
258
|
+
// `has-local-override-from-global-styles` state (and
|
|
259
|
+
// renders the blue dot) even though the user never
|
|
260
|
+
// customised the radius.
|
|
261
|
+
const user = userEvent.setup();
|
|
262
|
+
const onChange = jest.fn();
|
|
263
|
+
const inheritedValue = {
|
|
264
|
+
border: {
|
|
265
|
+
color: '#000000',
|
|
266
|
+
style: 'solid',
|
|
267
|
+
width: '1px',
|
|
268
|
+
radius: '8px',
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
render(
|
|
273
|
+
<BorderPanel
|
|
274
|
+
value={ {} }
|
|
275
|
+
inheritedValue={ inheritedValue }
|
|
276
|
+
settings={ settingsAll }
|
|
277
|
+
onChange={ onChange }
|
|
278
|
+
panelId="test-panel"
|
|
279
|
+
/>
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
// Trigger a border change via the width input rendered by
|
|
283
|
+
// `BorderBoxControl`. We don't depend on the exact role
|
|
284
|
+
// markup beyond there being a numeric width input — the
|
|
285
|
+
// regression is observable in the resulting `onChange`
|
|
286
|
+
// payload, not the DOM.
|
|
287
|
+
const widthInput = screen.getByRole( 'spinbutton', {
|
|
288
|
+
name: /border width/i,
|
|
289
|
+
} );
|
|
290
|
+
await user.clear( widthInput );
|
|
291
|
+
await user.type( widthInput, '4' );
|
|
292
|
+
|
|
293
|
+
expect( onChange ).toHaveBeenCalled();
|
|
294
|
+
const lastCall = onChange.mock.calls.at( -1 )[ 0 ];
|
|
295
|
+
expect( lastCall?.border?.radius ).toBeUndefined();
|
|
296
|
+
} );
|
|
297
|
+
|
|
298
|
+
it( 'does not invoke onChange on mount when only an inherited border is present', () => {
|
|
299
|
+
const onChange = jest.fn();
|
|
300
|
+
const inheritedValue = {
|
|
301
|
+
border: {
|
|
302
|
+
color: '#000000',
|
|
303
|
+
style: 'solid',
|
|
304
|
+
width: '1px',
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
render(
|
|
309
|
+
<BorderPanel
|
|
310
|
+
value={ {} }
|
|
311
|
+
inheritedValue={ inheritedValue }
|
|
312
|
+
settings={ settingsAll }
|
|
313
|
+
onChange={ onChange }
|
|
314
|
+
panelId="test-panel"
|
|
315
|
+
/>
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
expect( onChange ).not.toHaveBeenCalled();
|
|
319
|
+
} );
|
|
320
|
+
} );
|
|
321
|
+
|
|
322
|
+
describe( 'Shadow (popover-trigger archetype)', () => {
|
|
323
|
+
it( 'surfaces the accessible reset affordance when a local shadow is set', () => {
|
|
324
|
+
const inheritedValue = {
|
|
325
|
+
shadow: 'var:preset|shadow|soft',
|
|
326
|
+
};
|
|
327
|
+
const value = { shadow: 'var:preset|shadow|hard' };
|
|
328
|
+
|
|
329
|
+
render(
|
|
330
|
+
<BorderPanel
|
|
331
|
+
value={ value }
|
|
332
|
+
inheritedValue={ inheritedValue }
|
|
333
|
+
settings={ settingsAll }
|
|
334
|
+
onChange={ () => {} }
|
|
335
|
+
panelId="test-panel"
|
|
336
|
+
/>
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
expect(
|
|
340
|
+
screen.getByRole( 'button', {
|
|
341
|
+
name: /reset to inherited value/i,
|
|
342
|
+
} )
|
|
343
|
+
).toBeInTheDocument();
|
|
344
|
+
} );
|
|
345
|
+
|
|
346
|
+
it( 'does not invoke onChange on mount when only an inherited shadow is present', () => {
|
|
347
|
+
const onChange = jest.fn();
|
|
348
|
+
const inheritedValue = {
|
|
349
|
+
shadow: 'var:preset|shadow|soft',
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
render(
|
|
353
|
+
<BorderPanel
|
|
354
|
+
value={ {} }
|
|
355
|
+
inheritedValue={ inheritedValue }
|
|
356
|
+
settings={ settingsAll }
|
|
357
|
+
onChange={ onChange }
|
|
358
|
+
panelId="test-panel"
|
|
359
|
+
/>
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
expect( onChange ).not.toHaveBeenCalled();
|
|
363
|
+
} );
|
|
364
|
+
|
|
365
|
+
it( 'renders no reset affordance when the shadow is only inherited (no local override)', () => {
|
|
366
|
+
const inheritedValue = { shadow: 'var:preset|shadow|soft' };
|
|
367
|
+
|
|
368
|
+
render(
|
|
369
|
+
<BorderPanel
|
|
370
|
+
value={ {} }
|
|
371
|
+
inheritedValue={ inheritedValue }
|
|
372
|
+
settings={ settingsAll }
|
|
373
|
+
onChange={ () => {} }
|
|
374
|
+
panelId="test-panel"
|
|
375
|
+
/>
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
// A merely-inherited value must not show the default remove
|
|
379
|
+
// button nor the local-override blue-dot reset.
|
|
380
|
+
expect(
|
|
381
|
+
screen.queryByRole( 'button', { name: /^remove$/i } )
|
|
382
|
+
).not.toBeInTheDocument();
|
|
383
|
+
expect(
|
|
384
|
+
screen.queryByRole( 'button', {
|
|
385
|
+
name: /reset to inherited value/i,
|
|
386
|
+
} )
|
|
387
|
+
).not.toBeInTheDocument();
|
|
388
|
+
} );
|
|
389
|
+
|
|
390
|
+
it( 'renders the blue-dot InheritanceResetButton for a local override', () => {
|
|
391
|
+
const inheritedValue = { shadow: 'var:preset|shadow|soft' };
|
|
392
|
+
const value = { shadow: 'var:preset|shadow|hard' };
|
|
393
|
+
|
|
394
|
+
render(
|
|
395
|
+
<BorderPanel
|
|
396
|
+
value={ value }
|
|
397
|
+
inheritedValue={ inheritedValue }
|
|
398
|
+
settings={ settingsAll }
|
|
399
|
+
onChange={ () => {} }
|
|
400
|
+
panelId="test-panel"
|
|
401
|
+
/>
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
// The local override renders the blue-dot reset (mirroring the
|
|
405
|
+
// color/gradient controls), not the plain remove button.
|
|
406
|
+
expect(
|
|
407
|
+
screen.getByRole( 'button', {
|
|
408
|
+
name: /reset to inherited value/i,
|
|
409
|
+
} )
|
|
410
|
+
).toBeInTheDocument();
|
|
411
|
+
expect(
|
|
412
|
+
screen.queryByRole( 'button', { name: /^remove$/i } )
|
|
413
|
+
).not.toBeInTheDocument();
|
|
414
|
+
} );
|
|
415
|
+
|
|
416
|
+
it( 'renders the default remove button for a locally-set shadow with no inherited value', () => {
|
|
417
|
+
const value = { shadow: 'var:preset|shadow|hard' };
|
|
418
|
+
|
|
419
|
+
render(
|
|
420
|
+
<BorderPanel
|
|
421
|
+
value={ value }
|
|
422
|
+
inheritedValue={ {} }
|
|
423
|
+
settings={ settingsAll }
|
|
424
|
+
onChange={ () => {} }
|
|
425
|
+
panelId="test-panel"
|
|
426
|
+
/>
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
// With no inherited value there is no override to reset to, so
|
|
430
|
+
// the plain remove button is used, not the blue-dot affordance.
|
|
431
|
+
expect(
|
|
432
|
+
screen.getByRole( 'button', { name: /^remove$/i } )
|
|
433
|
+
).toBeInTheDocument();
|
|
434
|
+
expect(
|
|
435
|
+
screen.queryByRole( 'button', {
|
|
436
|
+
name: /reset to inherited value/i,
|
|
437
|
+
} )
|
|
438
|
+
).not.toBeInTheDocument();
|
|
439
|
+
} );
|
|
440
|
+
} );
|
|
441
|
+
} );
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { renderHook } from '@testing-library/react';
|
|
4
|
+
import { render, renderHook, screen } from '@testing-library/react';
|
|
5
|
+
import { click, render as renderAriakit } from '@ariakit/test/react';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
|
-
import {
|
|
10
|
+
import ColorPanel, {
|
|
10
11
|
useHasColorPanel,
|
|
11
12
|
useHasTextPanel,
|
|
12
13
|
useHasBackgroundColorPanel,
|
|
@@ -16,6 +17,17 @@ import {
|
|
|
16
17
|
useHasCaptionPanel,
|
|
17
18
|
} from '../color-panel';
|
|
18
19
|
|
|
20
|
+
// The inheritance treatment sits behind the
|
|
21
|
+
// `gutenberg-global-styles-inheritance-ui` experiment. Turn it on so these
|
|
22
|
+
// tests exercise the inheriting path.
|
|
23
|
+
beforeEach( () => {
|
|
24
|
+
window.__experimentalGlobalStylesInheritanceUI = true;
|
|
25
|
+
} );
|
|
26
|
+
|
|
27
|
+
afterEach( () => {
|
|
28
|
+
delete window.__experimentalGlobalStylesInheritanceUI;
|
|
29
|
+
} );
|
|
30
|
+
|
|
19
31
|
const settingsWithColors = ( overrides = {} ) => ( {
|
|
20
32
|
color: {
|
|
21
33
|
palette: {
|
|
@@ -187,3 +199,171 @@ describe( 'element color hooks', () => {
|
|
|
187
199
|
expect( result.current ).toBeTruthy();
|
|
188
200
|
} );
|
|
189
201
|
} );
|
|
202
|
+
|
|
203
|
+
// Inherited Global Styles label treatment for the controls the Color
|
|
204
|
+
// ("Elements") panel still owns after relocation — i.e. link and
|
|
205
|
+
// element-scoped colors. Top-level text and background color label
|
|
206
|
+
// treatment is covered by the Typography and Background panel tests, which
|
|
207
|
+
// now own those controls.
|
|
208
|
+
const baseSettings = {
|
|
209
|
+
color: {
|
|
210
|
+
link: true,
|
|
211
|
+
heading: false,
|
|
212
|
+
button: false,
|
|
213
|
+
caption: false,
|
|
214
|
+
defaultPalette: true,
|
|
215
|
+
palette: {
|
|
216
|
+
default: [
|
|
217
|
+
{ name: 'Red', slug: 'red', color: '#ff0000' },
|
|
218
|
+
{ name: 'Blue', slug: 'blue', color: '#0000ff' },
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
describe( 'ColorPanel — duplicate-hex preset slug identity', () => {
|
|
225
|
+
const duplicateHexSettings = {
|
|
226
|
+
color: {
|
|
227
|
+
link: true,
|
|
228
|
+
defaultPalette: false,
|
|
229
|
+
palette: {
|
|
230
|
+
theme: [
|
|
231
|
+
{
|
|
232
|
+
slug: 'dark-background',
|
|
233
|
+
color: '#000000',
|
|
234
|
+
name: 'Dark background',
|
|
235
|
+
},
|
|
236
|
+
{ slug: 'dark-text', color: '#000000', name: 'Dark text' },
|
|
237
|
+
],
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
it( 'marks only the local link preset as selected when another preset shares its hex', async () => {
|
|
243
|
+
await renderAriakit(
|
|
244
|
+
<ColorPanel
|
|
245
|
+
value={ {
|
|
246
|
+
elements: {
|
|
247
|
+
link: {
|
|
248
|
+
color: { text: 'var:preset|color|dark-text' },
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
} }
|
|
252
|
+
settings={ duplicateHexSettings }
|
|
253
|
+
onChange={ () => {} }
|
|
254
|
+
panelId="test-panel"
|
|
255
|
+
/>
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
await click( screen.getByRole( 'button', { name: /^Link/ } ) );
|
|
259
|
+
const swatches = await screen.findAllByRole( 'option' );
|
|
260
|
+
|
|
261
|
+
// swatch[0] = 'Dark background', swatch[1] = 'Dark text'. Selection
|
|
262
|
+
// must follow the stored slug; matching by hex would mark both.
|
|
263
|
+
expect( swatches[ 1 ] ).toHaveAttribute( 'aria-selected', 'true' );
|
|
264
|
+
expect( swatches[ 0 ] ).toHaveAttribute( 'aria-selected', 'false' );
|
|
265
|
+
} );
|
|
266
|
+
} );
|
|
267
|
+
|
|
268
|
+
describe( 'ColorPanel — inherited Global Styles label treatment', () => {
|
|
269
|
+
describe( 'Link color', () => {
|
|
270
|
+
it( 'exposes an accessible reset when local link.text overrides the inherited value', () => {
|
|
271
|
+
const inheritedValue = {
|
|
272
|
+
elements: { link: { color: { text: '#0000ff' } } },
|
|
273
|
+
};
|
|
274
|
+
const value = {
|
|
275
|
+
elements: { link: { color: { text: '#aaaaaa' } } },
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
render(
|
|
279
|
+
<ColorPanel
|
|
280
|
+
value={ value }
|
|
281
|
+
inheritedValue={ inheritedValue }
|
|
282
|
+
settings={ baseSettings }
|
|
283
|
+
onChange={ () => {} }
|
|
284
|
+
panelId="test-panel"
|
|
285
|
+
/>
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
expect(
|
|
289
|
+
screen.getAllByRole( 'button', {
|
|
290
|
+
name: /reset to inherited value/i,
|
|
291
|
+
} ).length
|
|
292
|
+
).toBeGreaterThanOrEqual( 1 );
|
|
293
|
+
} );
|
|
294
|
+
} );
|
|
295
|
+
|
|
296
|
+
// An inherited element colour can be a preset slug that isn't in the
|
|
297
|
+
// block panel's palette. It must fall back to the preset's CSS custom
|
|
298
|
+
// property so the swatch paints instead of rendering black.
|
|
299
|
+
describe( 'inherited preset missing from the palette', () => {
|
|
300
|
+
function getSwatchStyles( container ) {
|
|
301
|
+
return Array.from(
|
|
302
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
303
|
+
container.querySelectorAll( '.component-color-indicator' )
|
|
304
|
+
).map( ( node ) => node.getAttribute( 'style' ) ?? '' );
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Palette intentionally lacks `vivid-purple`.
|
|
308
|
+
const settings = {
|
|
309
|
+
color: {
|
|
310
|
+
link: true,
|
|
311
|
+
heading: true,
|
|
312
|
+
defaultPalette: true,
|
|
313
|
+
palette: {
|
|
314
|
+
default: [ { name: 'Red', slug: 'red', color: '#ff0000' } ],
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
it( 'paints an inherited link preset via its CSS custom property', () => {
|
|
320
|
+
const { container } = render(
|
|
321
|
+
<ColorPanel
|
|
322
|
+
value={ {} }
|
|
323
|
+
inheritedValue={ {
|
|
324
|
+
elements: {
|
|
325
|
+
link: {
|
|
326
|
+
color: {
|
|
327
|
+
text: 'var:preset|color|vivid-purple',
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
} }
|
|
332
|
+
settings={ settings }
|
|
333
|
+
onChange={ () => {} }
|
|
334
|
+
panelId="test-panel"
|
|
335
|
+
/>
|
|
336
|
+
);
|
|
337
|
+
expect(
|
|
338
|
+
getSwatchStyles( container ).some( ( s ) =>
|
|
339
|
+
s.includes( 'var(--wp--preset--color--vivid-purple)' )
|
|
340
|
+
)
|
|
341
|
+
).toBe( true );
|
|
342
|
+
} );
|
|
343
|
+
|
|
344
|
+
it( 'paints an inherited element (heading) preset via its CSS custom property', () => {
|
|
345
|
+
const { container } = render(
|
|
346
|
+
<ColorPanel
|
|
347
|
+
value={ {} }
|
|
348
|
+
inheritedValue={ {
|
|
349
|
+
elements: {
|
|
350
|
+
heading: {
|
|
351
|
+
color: {
|
|
352
|
+
text: 'var:preset|color|vivid-purple',
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
} }
|
|
357
|
+
settings={ settings }
|
|
358
|
+
onChange={ () => {} }
|
|
359
|
+
panelId="test-panel"
|
|
360
|
+
/>
|
|
361
|
+
);
|
|
362
|
+
expect(
|
|
363
|
+
getSwatchStyles( container ).some( ( s ) =>
|
|
364
|
+
s.includes( 'var(--wp--preset--color--vivid-purple)' )
|
|
365
|
+
)
|
|
366
|
+
).toBe( true );
|
|
367
|
+
} );
|
|
368
|
+
} );
|
|
369
|
+
} );
|