@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
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import clsx from 'clsx';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* WordPress dependencies
|
|
@@ -9,11 +8,11 @@ import clsx from 'clsx';
|
|
|
9
8
|
import { __ } from '@wordpress/i18n';
|
|
10
9
|
import {
|
|
11
10
|
__experimentalToolsPanel as ToolsPanel,
|
|
12
|
-
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
13
11
|
BoxControl,
|
|
14
12
|
__experimentalUnitControl as UnitControl,
|
|
15
13
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
16
14
|
__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,
|
|
15
|
+
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
|
|
17
16
|
} from '@wordpress/components';
|
|
18
17
|
import { Icon, alignNone, stretchWide } from '@wordpress/icons';
|
|
19
18
|
import { useCallback, useState } from '@wordpress/element';
|
|
@@ -34,9 +33,39 @@ import {
|
|
|
34
33
|
hasPseudoBlockStyleState,
|
|
35
34
|
hasViewportBlockStyleState,
|
|
36
35
|
} from '../../hooks/block-style-state';
|
|
36
|
+
import {
|
|
37
|
+
getInheritanceProps,
|
|
38
|
+
InheritanceToolsPanelItem,
|
|
39
|
+
isGlobalStylesInheritanceEnabled,
|
|
40
|
+
} from './inheritance';
|
|
37
41
|
|
|
38
42
|
const AXIAL_SIDES = [ 'horizontal', 'vertical' ];
|
|
39
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Determines whether a spacing control (`BoxControl` or `SpacingSizesControl`)
|
|
46
|
+
* renders its linked/unlink toggle button, which the local-override reset dot
|
|
47
|
+
* offsets itself against.
|
|
48
|
+
*
|
|
49
|
+
* @param {string[]|undefined} sides Configurable sides for the control.
|
|
50
|
+
* @param {boolean} isPresetsControl Whether the presets-based
|
|
51
|
+
* `SpacingSizesControl` is used.
|
|
52
|
+
*
|
|
53
|
+
* @return {boolean} Whether the toggle button is rendered.
|
|
54
|
+
*/
|
|
55
|
+
function hasSpacingToggle( sides, isPresetsControl ) {
|
|
56
|
+
if ( sides?.length === 1 ) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if ( isPresetsControl ) {
|
|
60
|
+
const hasOnlyAxialSides =
|
|
61
|
+
sides?.includes( 'horizontal' ) &&
|
|
62
|
+
sides?.includes( 'vertical' ) &&
|
|
63
|
+
sides?.length === 2;
|
|
64
|
+
return ! hasOnlyAxialSides;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
|
|
40
69
|
export function useHasDimensionsPanel(
|
|
41
70
|
settings,
|
|
42
71
|
styleState = DEFAULT_BLOCK_STYLE_STATE
|
|
@@ -153,9 +182,32 @@ function filterValuesBySides( values, sides ) {
|
|
|
153
182
|
return filteredValues;
|
|
154
183
|
}
|
|
155
184
|
|
|
185
|
+
const EMPTY_VALUES = [ undefined, null, '' ];
|
|
186
|
+
|
|
187
|
+
function hasValue( value ) {
|
|
188
|
+
return ! EMPTY_VALUES.includes( value );
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Extracts the numeric quantity from a raw CSS value so it can be used as a
|
|
193
|
+
* unit-control placeholder. The control's unit selector already reflects the
|
|
194
|
+
* inherited unit, so the placeholder must contain only the number (e.g.
|
|
195
|
+
* `120px` -> `120`) rather than the full unit string.
|
|
196
|
+
*
|
|
197
|
+
* @param {string|number|undefined} rawValue Inherited value to parse.
|
|
198
|
+
* @return {number|undefined} The numeric quantity, or `undefined` when absent.
|
|
199
|
+
*/
|
|
200
|
+
function getNumericPlaceholder( rawValue ) {
|
|
201
|
+
if ( ! hasValue( rawValue ) ) {
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
const [ quantity ] = parseQuantityAndUnitFromRawValue( rawValue );
|
|
205
|
+
return quantity;
|
|
206
|
+
}
|
|
207
|
+
|
|
156
208
|
function splitStyleValue( value ) {
|
|
157
209
|
// Check for shorthand value (a string value).
|
|
158
|
-
if ( value && typeof value === 'string' ) {
|
|
210
|
+
if ( hasValue( value ) && typeof value === 'string' ) {
|
|
159
211
|
// Convert to value for individual sides for BoxControl.
|
|
160
212
|
return {
|
|
161
213
|
top: value,
|
|
@@ -168,8 +220,69 @@ function splitStyleValue( value ) {
|
|
|
168
220
|
return value;
|
|
169
221
|
}
|
|
170
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Returns the common side value of a sides object (top/right/bottom/left)
|
|
225
|
+
* when all four sides are defined and equal; otherwise returns undefined.
|
|
226
|
+
*
|
|
227
|
+
* Used to derive a placeholder string for BoxControl's
|
|
228
|
+
* `inputProps.placeholder` from an inherited shorthand or
|
|
229
|
+
* shorthand-equivalent split-side value. When the inherited sides differ
|
|
230
|
+
* from each other, the placeholder is suppressed because BoxControl's
|
|
231
|
+
* `inputProps.placeholder` cannot vary per side.
|
|
232
|
+
*
|
|
233
|
+
* @param {Object|string|undefined} sidesValue The inherited sides shape.
|
|
234
|
+
* @return {string|undefined} The common value, or undefined.
|
|
235
|
+
*/
|
|
236
|
+
function getCommonSidesValue( sidesValue ) {
|
|
237
|
+
if ( ! hasValue( sidesValue ) ) {
|
|
238
|
+
return undefined;
|
|
239
|
+
}
|
|
240
|
+
if ( typeof sidesValue === 'string' ) {
|
|
241
|
+
return sidesValue !== '' ? sidesValue : undefined;
|
|
242
|
+
}
|
|
243
|
+
if ( typeof sidesValue !== 'object' ) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
const sideKeys = [ 'top', 'right', 'bottom', 'left' ];
|
|
247
|
+
const values = sideKeys.map( ( k ) => sidesValue[ k ] );
|
|
248
|
+
const allDefined = values.every( hasValue );
|
|
249
|
+
if ( ! allDefined ) {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
const first = values[ 0 ];
|
|
253
|
+
return values.every( ( v ) => v === first ) ? first : undefined;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Returns whether a sides object (top/right/bottom/left) or shorthand string
|
|
258
|
+
* holds any value on at least one side.
|
|
259
|
+
*
|
|
260
|
+
* Unlike `getCommonSidesValue`, this does not require every side to be defined
|
|
261
|
+
* or equal. It is used to drive the inherited-from-Global-Styles label
|
|
262
|
+
* treatment and the local-override dot, which should reflect the mere presence
|
|
263
|
+
* of an inherited value regardless of whether the individual sides match (a
|
|
264
|
+
* constraint that only applies to BoxControl's single-string placeholder).
|
|
265
|
+
*
|
|
266
|
+
* @param {Object|string|undefined} sidesValue The sides shape.
|
|
267
|
+
* @return {boolean} Whether any side holds a value.
|
|
268
|
+
*/
|
|
269
|
+
function hasAnySideValue( sidesValue ) {
|
|
270
|
+
if ( ! hasValue( sidesValue ) ) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
if ( typeof sidesValue === 'string' ) {
|
|
274
|
+
return sidesValue !== '';
|
|
275
|
+
}
|
|
276
|
+
if ( typeof sidesValue !== 'object' ) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
return [ 'top', 'right', 'bottom', 'left' ].some( ( side ) =>
|
|
280
|
+
hasValue( sidesValue[ side ] )
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
|
|
171
284
|
function splitGapValue( value, isAxialGap ) {
|
|
172
|
-
if ( ! value ) {
|
|
285
|
+
if ( ! hasValue( value ) ) {
|
|
173
286
|
return value;
|
|
174
287
|
}
|
|
175
288
|
|
|
@@ -246,6 +359,7 @@ export default function DimensionsPanel( {
|
|
|
246
359
|
// in global styles but not in block inspector.
|
|
247
360
|
includeLayoutControls = false,
|
|
248
361
|
styleState = DEFAULT_BLOCK_STYLE_STATE,
|
|
362
|
+
showInheritanceLabelIndicators = isGlobalStylesInheritanceEnabled(),
|
|
249
363
|
} ) {
|
|
250
364
|
const { dimensions, spacing } = settings;
|
|
251
365
|
|
|
@@ -266,6 +380,14 @@ export default function DimensionsPanel( {
|
|
|
266
380
|
rawValue
|
|
267
381
|
);
|
|
268
382
|
};
|
|
383
|
+
// Always keep the layout className (e.g. `single-column`); only the
|
|
384
|
+
// inheritance treatment is gated on `showInheritanceLabelIndicators`.
|
|
385
|
+
const inheritanceProps = ( isInherited, hasLocalOverride, className ) =>
|
|
386
|
+
getInheritanceProps(
|
|
387
|
+
showInheritanceLabelIndicators && isInherited,
|
|
388
|
+
showInheritanceLabelIndicators && hasLocalOverride,
|
|
389
|
+
className
|
|
390
|
+
);
|
|
269
391
|
|
|
270
392
|
const showSpacingPresetsControl = hasSpacingPresets( settings );
|
|
271
393
|
const units = useCustomUnits( {
|
|
@@ -316,39 +438,77 @@ export default function DimensionsPanel( {
|
|
|
316
438
|
// Content Width
|
|
317
439
|
const showContentSizeControl =
|
|
318
440
|
hasContentSize( settings ) && includeLayoutControls;
|
|
319
|
-
const
|
|
441
|
+
const localContentSizeValue = decodeValue( value?.layout?.contentSize );
|
|
442
|
+
const inheritedContentSizeValue = decodeValue(
|
|
443
|
+
inheritedValue?.layout?.contentSize
|
|
444
|
+
);
|
|
445
|
+
const isContentSizePlaceholder =
|
|
446
|
+
! hasValue( value?.layout?.contentSize ) &&
|
|
447
|
+
hasValue( inheritedContentSizeValue );
|
|
320
448
|
const setContentSizeValue = ( newValue ) => {
|
|
321
449
|
onChange(
|
|
322
450
|
setImmutably(
|
|
323
451
|
value,
|
|
324
452
|
[ 'layout', 'contentSize' ],
|
|
325
|
-
newValue
|
|
453
|
+
hasValue( newValue ) ? newValue : undefined
|
|
326
454
|
)
|
|
327
455
|
);
|
|
328
456
|
};
|
|
329
|
-
const hasUserSetContentSizeValue = () =>
|
|
457
|
+
const hasUserSetContentSizeValue = () =>
|
|
458
|
+
hasValue( value?.layout?.contentSize );
|
|
330
459
|
const resetContentSizeValue = () => setContentSizeValue( undefined );
|
|
331
460
|
|
|
332
461
|
// Wide Width
|
|
333
462
|
const showWideSizeControl =
|
|
334
463
|
hasWideSize( settings ) && includeLayoutControls;
|
|
335
|
-
const
|
|
464
|
+
const localWideSizeValue = decodeValue( value?.layout?.wideSize );
|
|
465
|
+
const inheritedWideSizeValue = decodeValue(
|
|
466
|
+
inheritedValue?.layout?.wideSize
|
|
467
|
+
);
|
|
468
|
+
const isWideSizePlaceholder =
|
|
469
|
+
! hasValue( value?.layout?.wideSize ) &&
|
|
470
|
+
hasValue( inheritedWideSizeValue );
|
|
336
471
|
const setWideSizeValue = ( newValue ) => {
|
|
337
472
|
onChange(
|
|
338
473
|
setImmutably(
|
|
339
474
|
value,
|
|
340
475
|
[ 'layout', 'wideSize' ],
|
|
341
|
-
newValue
|
|
476
|
+
hasValue( newValue ) ? newValue : undefined
|
|
342
477
|
)
|
|
343
478
|
);
|
|
344
479
|
};
|
|
345
|
-
const hasUserSetWideSizeValue = () =>
|
|
480
|
+
const hasUserSetWideSizeValue = () => hasValue( value?.layout?.wideSize );
|
|
346
481
|
const resetWideSizeValue = () => setWideSizeValue( undefined );
|
|
347
482
|
|
|
348
483
|
// Padding
|
|
349
484
|
const showPaddingControl = hasPadding( settings );
|
|
350
|
-
const
|
|
351
|
-
|
|
485
|
+
const inheritedPaddingValues = splitStyleValue(
|
|
486
|
+
decodeValue( inheritedValue?.spacing?.padding )
|
|
487
|
+
);
|
|
488
|
+
// Local-only values feed BoxControl's `values` (with the inherited
|
|
489
|
+
// surfaced via the at-rest placeholder).
|
|
490
|
+
const localPaddingValues = splitStyleValue(
|
|
491
|
+
decodeValue( value?.spacing?.padding )
|
|
492
|
+
);
|
|
493
|
+
// Merged local-then-inherited values feed SpacingSizesControl's
|
|
494
|
+
// `values` because the preset slider has no placeholder slot — the
|
|
495
|
+
// active chip itself is the at-rest cue.
|
|
496
|
+
const paddingValues = hasValue( value?.spacing?.padding )
|
|
497
|
+
? localPaddingValues
|
|
498
|
+
: inheritedPaddingValues;
|
|
499
|
+
const inheritedPaddingPlaceholder = getCommonSidesValue(
|
|
500
|
+
inheritedPaddingValues
|
|
501
|
+
);
|
|
502
|
+
const isPaddingPlaceholder =
|
|
503
|
+
! hasValue( value?.spacing?.padding ) &&
|
|
504
|
+
inheritedPaddingPlaceholder !== undefined;
|
|
505
|
+
// Label/dot inheritance treatment is independent of whether the inherited
|
|
506
|
+
// sides share a common value — it only reflects the presence of an
|
|
507
|
+
// inherited value (the all-sides-equal constraint applies solely to the
|
|
508
|
+
// single-string BoxControl placeholder above).
|
|
509
|
+
const hasInheritedPadding = hasAnySideValue( inheritedPaddingValues );
|
|
510
|
+
const isPaddingInherited =
|
|
511
|
+
! hasValue( value?.spacing?.padding ) && hasInheritedPadding;
|
|
352
512
|
const paddingSides = Array.isArray( settings?.spacing?.padding )
|
|
353
513
|
? settings?.spacing?.padding
|
|
354
514
|
: settings?.spacing?.padding?.sides;
|
|
@@ -360,15 +520,31 @@ export default function DimensionsPanel( {
|
|
|
360
520
|
onChange( setImmutably( value, [ 'spacing', 'padding' ], padding ) );
|
|
361
521
|
};
|
|
362
522
|
const hasPaddingValue = () =>
|
|
363
|
-
|
|
523
|
+
hasValue( value?.spacing?.padding ) &&
|
|
364
524
|
Object.keys( value?.spacing?.padding ).length;
|
|
365
525
|
const resetPaddingValue = () => setPaddingValues( undefined );
|
|
366
526
|
const onMouseOverPadding = () => onVisualize( 'padding' );
|
|
367
527
|
|
|
368
528
|
// Margin
|
|
369
529
|
const showMarginControl = hasMargin( settings );
|
|
370
|
-
const
|
|
371
|
-
|
|
530
|
+
const inheritedMarginValues = splitStyleValue(
|
|
531
|
+
decodeValue( inheritedValue?.spacing?.margin )
|
|
532
|
+
);
|
|
533
|
+
const localMarginValues = splitStyleValue(
|
|
534
|
+
decodeValue( value?.spacing?.margin )
|
|
535
|
+
);
|
|
536
|
+
const marginValues = hasValue( value?.spacing?.margin )
|
|
537
|
+
? localMarginValues
|
|
538
|
+
: inheritedMarginValues;
|
|
539
|
+
const inheritedMarginPlaceholder = getCommonSidesValue(
|
|
540
|
+
inheritedMarginValues
|
|
541
|
+
);
|
|
542
|
+
const isMarginPlaceholder =
|
|
543
|
+
! hasValue( value?.spacing?.margin ) &&
|
|
544
|
+
inheritedMarginPlaceholder !== undefined;
|
|
545
|
+
const hasInheritedMargin = hasAnySideValue( inheritedMarginValues );
|
|
546
|
+
const isMarginInherited =
|
|
547
|
+
! hasValue( value?.spacing?.margin ) && hasInheritedMargin;
|
|
372
548
|
const marginSides = Array.isArray( settings?.spacing?.margin )
|
|
373
549
|
? settings?.spacing?.margin
|
|
374
550
|
: settings?.spacing?.margin?.sides;
|
|
@@ -380,7 +556,7 @@ export default function DimensionsPanel( {
|
|
|
380
556
|
onChange( setImmutably( value, [ 'spacing', 'margin' ], margin ) );
|
|
381
557
|
};
|
|
382
558
|
const hasMarginValue = () =>
|
|
383
|
-
|
|
559
|
+
hasValue( value?.spacing?.margin ) &&
|
|
384
560
|
Object.keys( value?.spacing?.margin ).length;
|
|
385
561
|
const resetMarginValue = () => setMarginValues( undefined );
|
|
386
562
|
const onMouseOverMargin = () => onVisualize( 'margin' );
|
|
@@ -392,15 +568,30 @@ export default function DimensionsPanel( {
|
|
|
392
568
|
: settings?.spacing?.blockGap?.sides;
|
|
393
569
|
const isAxialGap =
|
|
394
570
|
gapSides && gapSides.some( ( side ) => AXIAL_SIDES.includes( side ) );
|
|
395
|
-
const
|
|
396
|
-
const
|
|
571
|
+
const localGapRaw = decodeValue( value?.spacing?.blockGap );
|
|
572
|
+
const inheritedGapRaw = decodeValue( inheritedValue?.spacing?.blockGap );
|
|
573
|
+
// Merge local-then-inherited so SpacingSizesControl's chip slider and
|
|
574
|
+
// the axial-gap BoxControl reflect the local value when set and fall
|
|
575
|
+
// back to the inherited value at rest.
|
|
576
|
+
const gapRawForDisplay = hasValue( value?.spacing?.blockGap )
|
|
577
|
+
? localGapRaw
|
|
578
|
+
: inheritedGapRaw;
|
|
579
|
+
const gapValues = splitGapValue( gapRawForDisplay, isAxialGap );
|
|
580
|
+
// Placeholder state for the single-input (non-axial, non-preset) blockGap
|
|
581
|
+
// path. The axial / preset paths render compound or chip controls without
|
|
582
|
+
// a native placeholder slot — the displayed `values` themselves are the
|
|
583
|
+
// at-rest cue for those.
|
|
584
|
+
const isGapPlaceholder =
|
|
585
|
+
! hasValue( value?.spacing?.blockGap ) &&
|
|
586
|
+
typeof inheritedGapRaw === 'string' &&
|
|
587
|
+
inheritedGapRaw !== '';
|
|
397
588
|
const setGapValue = ( newGapValue ) => {
|
|
398
589
|
onChange(
|
|
399
590
|
setImmutably( value, [ 'spacing', 'blockGap' ], newGapValue )
|
|
400
591
|
);
|
|
401
592
|
};
|
|
402
593
|
const setGapValues = ( nextBoxGapValue ) => {
|
|
403
|
-
if ( ! nextBoxGapValue ) {
|
|
594
|
+
if ( ! hasValue( nextBoxGapValue ) ) {
|
|
404
595
|
setGapValue( null );
|
|
405
596
|
}
|
|
406
597
|
// If axial gap is not enabled, treat the 'top' value as the shorthand gap value.
|
|
@@ -414,11 +605,17 @@ export default function DimensionsPanel( {
|
|
|
414
605
|
}
|
|
415
606
|
};
|
|
416
607
|
const resetGapValue = () => setGapValue( undefined );
|
|
417
|
-
const hasGapValue = () =>
|
|
608
|
+
const hasGapValue = () => hasValue( value?.spacing?.blockGap );
|
|
418
609
|
|
|
419
610
|
// Min Height
|
|
420
611
|
const showMinHeightControl = hasMinHeight( settings );
|
|
421
|
-
const
|
|
612
|
+
const localMinHeightValue = decodeValue( value?.dimensions?.minHeight );
|
|
613
|
+
const inheritedMinHeightValue = decodeValue(
|
|
614
|
+
inheritedValue?.dimensions?.minHeight
|
|
615
|
+
);
|
|
616
|
+
const isMinHeightPlaceholder =
|
|
617
|
+
! hasValue( value?.dimensions?.minHeight ) &&
|
|
618
|
+
hasValue( inheritedMinHeightValue );
|
|
422
619
|
const setMinHeightValue = ( newValue ) => {
|
|
423
620
|
const tempValue = setImmutably(
|
|
424
621
|
value,
|
|
@@ -437,11 +634,17 @@ export default function DimensionsPanel( {
|
|
|
437
634
|
const resetMinHeightValue = () => {
|
|
438
635
|
setMinHeightValue( undefined );
|
|
439
636
|
};
|
|
440
|
-
const hasMinHeightValue = () =>
|
|
637
|
+
const hasMinHeightValue = () => hasValue( value?.dimensions?.minHeight );
|
|
441
638
|
|
|
442
639
|
// Height
|
|
443
640
|
const showHeightControl = hasHeight( settings );
|
|
444
|
-
const
|
|
641
|
+
const localHeightValue = decodeValue( value?.dimensions?.height );
|
|
642
|
+
const inheritedHeightValue = decodeValue(
|
|
643
|
+
inheritedValue?.dimensions?.height
|
|
644
|
+
);
|
|
645
|
+
const isHeightPlaceholder =
|
|
646
|
+
! hasValue( value?.dimensions?.height ) &&
|
|
647
|
+
hasValue( inheritedHeightValue );
|
|
445
648
|
const setHeightValue = ( newValue ) => {
|
|
446
649
|
const tempValue = setImmutably(
|
|
447
650
|
value,
|
|
@@ -460,11 +663,17 @@ export default function DimensionsPanel( {
|
|
|
460
663
|
const resetHeightValue = () => {
|
|
461
664
|
setHeightValue( undefined );
|
|
462
665
|
};
|
|
463
|
-
const hasHeightValue = () =>
|
|
666
|
+
const hasHeightValue = () => hasValue( value?.dimensions?.height );
|
|
464
667
|
|
|
465
668
|
// Min Width
|
|
466
669
|
const showMinWidthControl = hasMinWidth( settings );
|
|
467
|
-
const
|
|
670
|
+
const localMinWidthValue = decodeValue( value?.dimensions?.minWidth );
|
|
671
|
+
const inheritedMinWidthValue = decodeValue(
|
|
672
|
+
inheritedValue?.dimensions?.minWidth
|
|
673
|
+
);
|
|
674
|
+
const isMinWidthPlaceholder =
|
|
675
|
+
! hasValue( value?.dimensions?.minWidth ) &&
|
|
676
|
+
hasValue( inheritedMinWidthValue );
|
|
468
677
|
const setMinWidthValue = ( newValue ) => {
|
|
469
678
|
onChange(
|
|
470
679
|
setImmutably( value, [ 'dimensions', 'minWidth' ], newValue )
|
|
@@ -473,24 +682,35 @@ export default function DimensionsPanel( {
|
|
|
473
682
|
const resetMinWidthValue = () => {
|
|
474
683
|
setMinWidthValue( undefined );
|
|
475
684
|
};
|
|
476
|
-
const hasMinWidthValue = () =>
|
|
685
|
+
const hasMinWidthValue = () => hasValue( value?.dimensions?.minWidth );
|
|
477
686
|
|
|
478
687
|
// Width
|
|
479
688
|
const showWidthControl = hasWidth( settings );
|
|
480
|
-
const
|
|
689
|
+
const localWidthValue = decodeValue( value?.dimensions?.width );
|
|
690
|
+
const inheritedWidthValue = decodeValue(
|
|
691
|
+
inheritedValue?.dimensions?.width
|
|
692
|
+
);
|
|
693
|
+
const isWidthPlaceholder =
|
|
694
|
+
! hasValue( value?.dimensions?.width ) &&
|
|
695
|
+
hasValue( inheritedWidthValue );
|
|
481
696
|
const setWidthValue = ( newValue ) => {
|
|
482
697
|
onChange( setImmutably( value, [ 'dimensions', 'width' ], newValue ) );
|
|
483
698
|
};
|
|
484
699
|
const resetWidthValue = () => {
|
|
485
700
|
setWidthValue( undefined );
|
|
486
701
|
};
|
|
487
|
-
const hasWidthValue = () =>
|
|
702
|
+
const hasWidthValue = () => hasValue( value?.dimensions?.width );
|
|
488
703
|
|
|
489
704
|
// Aspect Ratio
|
|
490
705
|
const showAspectRatioControl = hasAspectRatio( settings, styleState );
|
|
491
|
-
const
|
|
706
|
+
const localAspectRatioValue = decodeValue( value?.dimensions?.aspectRatio );
|
|
707
|
+
const inheritedAspectRatioValue = decodeValue(
|
|
492
708
|
inheritedValue?.dimensions?.aspectRatio
|
|
493
709
|
);
|
|
710
|
+
const aspectRatioValue = localAspectRatioValue ?? inheritedAspectRatioValue;
|
|
711
|
+
const isAspectRatioPlaceholder =
|
|
712
|
+
! hasValue( value?.dimensions?.aspectRatio ) &&
|
|
713
|
+
hasValue( inheritedAspectRatioValue );
|
|
494
714
|
const setAspectRatioValue = ( newValue ) => {
|
|
495
715
|
const tempValue = setImmutably(
|
|
496
716
|
value,
|
|
@@ -502,11 +722,17 @@ export default function DimensionsPanel( {
|
|
|
502
722
|
setImmutably( tempValue, [ 'dimensions', 'minHeight' ], undefined )
|
|
503
723
|
);
|
|
504
724
|
};
|
|
505
|
-
const hasAspectRatioValue = () =>
|
|
725
|
+
const hasAspectRatioValue = () =>
|
|
726
|
+
hasValue( value?.dimensions?.aspectRatio );
|
|
506
727
|
|
|
507
|
-
// Child Layout
|
|
728
|
+
// Child Layout. There is no Global Styles inheritance model for the
|
|
729
|
+
// child-layout sub-keys (`selfStretch`, `flexSize`, `columnStart`,
|
|
730
|
+
// `rowStart`, `columnSpan`, `rowSpan`); they are per-block attributes
|
|
731
|
+
// only. Render the local value directly so user-set overrides are
|
|
732
|
+
// reflected in the control rather than washed out by a misshapen
|
|
733
|
+
// inherited layout payload.
|
|
508
734
|
const showChildLayoutControl = hasChildLayout( settings, styleState );
|
|
509
|
-
const childLayout =
|
|
735
|
+
const childLayout = value?.layout;
|
|
510
736
|
|
|
511
737
|
const setChildLayout = ( newChildLayout ) => {
|
|
512
738
|
onChange( {
|
|
@@ -533,7 +759,12 @@ export default function DimensionsPanel( {
|
|
|
533
759
|
</span>
|
|
534
760
|
) }
|
|
535
761
|
{ showContentSizeControl && (
|
|
536
|
-
<
|
|
762
|
+
<InheritanceToolsPanelItem
|
|
763
|
+
{ ...inheritanceProps(
|
|
764
|
+
isContentSizePlaceholder,
|
|
765
|
+
hasUserSetContentSizeValue() &&
|
|
766
|
+
inheritedContentSizeValue !== undefined
|
|
767
|
+
) }
|
|
537
768
|
label={ __( 'Content width' ) }
|
|
538
769
|
hasValue={ hasUserSetContentSizeValue }
|
|
539
770
|
onDeselect={ resetContentSizeValue }
|
|
@@ -546,7 +777,21 @@ export default function DimensionsPanel( {
|
|
|
546
777
|
<UnitControl
|
|
547
778
|
label={ __( 'Content width' ) }
|
|
548
779
|
labelPosition="top"
|
|
549
|
-
|
|
780
|
+
// Local-then-inherited: render the inherited value as the
|
|
781
|
+
// control's value at rest so the unit parses from it
|
|
782
|
+
// (e.g. "620px" keeps its unit rather than the value
|
|
783
|
+
// string sitting greyed-out behind a default px unit). It
|
|
784
|
+
// is only written to local on user change.
|
|
785
|
+
value={
|
|
786
|
+
localContentSizeValue ?? inheritedContentSizeValue
|
|
787
|
+
}
|
|
788
|
+
placeholder={
|
|
789
|
+
isContentSizePlaceholder
|
|
790
|
+
? getNumericPlaceholder(
|
|
791
|
+
inheritedContentSizeValue
|
|
792
|
+
)
|
|
793
|
+
: undefined
|
|
794
|
+
}
|
|
550
795
|
onChange={ ( nextContentSize ) => {
|
|
551
796
|
setContentSizeValue( nextContentSize );
|
|
552
797
|
} }
|
|
@@ -557,10 +802,15 @@ export default function DimensionsPanel( {
|
|
|
557
802
|
</InputControlPrefixWrapper>
|
|
558
803
|
}
|
|
559
804
|
/>
|
|
560
|
-
</
|
|
805
|
+
</InheritanceToolsPanelItem>
|
|
561
806
|
) }
|
|
562
807
|
{ showWideSizeControl && (
|
|
563
|
-
<
|
|
808
|
+
<InheritanceToolsPanelItem
|
|
809
|
+
{ ...inheritanceProps(
|
|
810
|
+
isWideSizePlaceholder,
|
|
811
|
+
hasUserSetWideSizeValue() &&
|
|
812
|
+
inheritedWideSizeValue !== undefined
|
|
813
|
+
) }
|
|
564
814
|
label={ __( 'Wide width' ) }
|
|
565
815
|
hasValue={ hasUserSetWideSizeValue }
|
|
566
816
|
onDeselect={ resetWideSizeValue }
|
|
@@ -572,7 +822,19 @@ export default function DimensionsPanel( {
|
|
|
572
822
|
<UnitControl
|
|
573
823
|
label={ __( 'Wide width' ) }
|
|
574
824
|
labelPosition="top"
|
|
575
|
-
|
|
825
|
+
// Local-then-inherited: render the inherited value as the
|
|
826
|
+
// control's value at rest so the unit parses from it
|
|
827
|
+
// rather than the value string sitting greyed-out behind
|
|
828
|
+
// a default px unit. It is only written to local on user
|
|
829
|
+
// change.
|
|
830
|
+
value={ localWideSizeValue ?? inheritedWideSizeValue }
|
|
831
|
+
placeholder={
|
|
832
|
+
isWideSizePlaceholder
|
|
833
|
+
? getNumericPlaceholder(
|
|
834
|
+
inheritedWideSizeValue
|
|
835
|
+
)
|
|
836
|
+
: undefined
|
|
837
|
+
}
|
|
576
838
|
onChange={ ( nextWideSize ) => {
|
|
577
839
|
setWideSizeValue( nextWideSize );
|
|
578
840
|
} }
|
|
@@ -583,24 +845,33 @@ export default function DimensionsPanel( {
|
|
|
583
845
|
</InputControlPrefixWrapper>
|
|
584
846
|
}
|
|
585
847
|
/>
|
|
586
|
-
</
|
|
848
|
+
</InheritanceToolsPanelItem>
|
|
587
849
|
) }
|
|
588
850
|
{ showPaddingControl && (
|
|
589
|
-
<
|
|
851
|
+
<InheritanceToolsPanelItem
|
|
590
852
|
hasValue={ hasPaddingValue }
|
|
591
853
|
label={ __( 'Padding' ) }
|
|
854
|
+
hasInlineEndToggle={ hasSpacingToggle(
|
|
855
|
+
paddingSides,
|
|
856
|
+
showSpacingPresetsControl
|
|
857
|
+
) }
|
|
592
858
|
onDeselect={ resetPaddingValue }
|
|
593
859
|
isShownByDefault={
|
|
594
860
|
defaultControls.padding ?? DEFAULT_CONTROLS.padding
|
|
595
861
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
862
|
+
{ ...inheritanceProps(
|
|
863
|
+
isPaddingInherited,
|
|
864
|
+
hasPaddingValue() && hasInheritedPadding,
|
|
865
|
+
{
|
|
866
|
+
'tools-panel-item-spacing':
|
|
867
|
+
showSpacingPresetsControl,
|
|
868
|
+
}
|
|
869
|
+
) }
|
|
599
870
|
panelId={ panelId }
|
|
600
871
|
>
|
|
601
872
|
{ ! showSpacingPresetsControl && (
|
|
602
873
|
<BoxControl
|
|
603
|
-
values={
|
|
874
|
+
values={ localPaddingValues }
|
|
604
875
|
onChange={ setPaddingValues }
|
|
605
876
|
label={ __( 'Padding' ) }
|
|
606
877
|
sides={ paddingSides }
|
|
@@ -610,6 +881,9 @@ export default function DimensionsPanel( {
|
|
|
610
881
|
inputProps={ {
|
|
611
882
|
onMouseOver: onMouseOverPadding,
|
|
612
883
|
onMouseOut: onMouseLeaveControls,
|
|
884
|
+
placeholder: isPaddingPlaceholder
|
|
885
|
+
? inheritedPaddingPlaceholder
|
|
886
|
+
: undefined,
|
|
613
887
|
} }
|
|
614
888
|
/>
|
|
615
889
|
) }
|
|
@@ -625,24 +899,33 @@ export default function DimensionsPanel( {
|
|
|
625
899
|
onMouseOut={ onMouseLeaveControls }
|
|
626
900
|
/>
|
|
627
901
|
) }
|
|
628
|
-
</
|
|
902
|
+
</InheritanceToolsPanelItem>
|
|
629
903
|
) }
|
|
630
904
|
{ showMarginControl && (
|
|
631
|
-
<
|
|
905
|
+
<InheritanceToolsPanelItem
|
|
632
906
|
hasValue={ hasMarginValue }
|
|
633
907
|
label={ __( 'Margin' ) }
|
|
908
|
+
hasInlineEndToggle={ hasSpacingToggle(
|
|
909
|
+
marginSides,
|
|
910
|
+
showSpacingPresetsControl
|
|
911
|
+
) }
|
|
634
912
|
onDeselect={ resetMarginValue }
|
|
635
913
|
isShownByDefault={
|
|
636
914
|
defaultControls.margin ?? DEFAULT_CONTROLS.margin
|
|
637
915
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
916
|
+
{ ...inheritanceProps(
|
|
917
|
+
isMarginInherited,
|
|
918
|
+
hasMarginValue() && hasInheritedMargin,
|
|
919
|
+
{
|
|
920
|
+
'tools-panel-item-spacing':
|
|
921
|
+
showSpacingPresetsControl,
|
|
922
|
+
}
|
|
923
|
+
) }
|
|
641
924
|
panelId={ panelId }
|
|
642
925
|
>
|
|
643
926
|
{ ! showSpacingPresetsControl && (
|
|
644
927
|
<BoxControl
|
|
645
|
-
values={
|
|
928
|
+
values={ localMarginValues }
|
|
646
929
|
onChange={ setMarginValues }
|
|
647
930
|
inputProps={ {
|
|
648
931
|
min: minMarginValue,
|
|
@@ -655,6 +938,9 @@ export default function DimensionsPanel( {
|
|
|
655
938
|
},
|
|
656
939
|
onMouseOver: onMouseOverMargin,
|
|
657
940
|
onMouseOut: onMouseLeaveControls,
|
|
941
|
+
placeholder: isMarginPlaceholder
|
|
942
|
+
? inheritedMarginPlaceholder
|
|
943
|
+
: undefined,
|
|
658
944
|
} }
|
|
659
945
|
label={ __( 'Margin' ) }
|
|
660
946
|
sides={ marginSides }
|
|
@@ -676,22 +962,28 @@ export default function DimensionsPanel( {
|
|
|
676
962
|
onMouseOut={ onMouseLeaveControls }
|
|
677
963
|
/>
|
|
678
964
|
) }
|
|
679
|
-
</
|
|
965
|
+
</InheritanceToolsPanelItem>
|
|
680
966
|
) }
|
|
681
967
|
{ showGapControl && (
|
|
682
|
-
<
|
|
968
|
+
<InheritanceToolsPanelItem
|
|
683
969
|
hasValue={ hasGapValue }
|
|
684
970
|
label={ __( 'Block spacing' ) }
|
|
971
|
+
hasInlineEndToggle={ isAxialGap }
|
|
685
972
|
onDeselect={ resetGapValue }
|
|
686
973
|
isShownByDefault={
|
|
687
974
|
defaultControls.blockGap ?? DEFAULT_CONTROLS.blockGap
|
|
688
975
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
976
|
+
{ ...inheritanceProps(
|
|
977
|
+
isGapPlaceholder,
|
|
978
|
+
hasGapValue() && inheritedGapRaw !== undefined,
|
|
979
|
+
{
|
|
980
|
+
'tools-panel-item-spacing':
|
|
981
|
+
showSpacingPresetsControl,
|
|
982
|
+
'single-column':
|
|
983
|
+
// If UnitControl is used, should be single-column.
|
|
984
|
+
! showSpacingPresetsControl && ! isAxialGap,
|
|
985
|
+
}
|
|
986
|
+
) }
|
|
695
987
|
panelId={ panelId }
|
|
696
988
|
>
|
|
697
989
|
{ ! showSpacingPresetsControl &&
|
|
@@ -712,7 +1004,12 @@ export default function DimensionsPanel( {
|
|
|
712
1004
|
min={ 0 }
|
|
713
1005
|
onChange={ setGapValue }
|
|
714
1006
|
units={ units }
|
|
715
|
-
value={
|
|
1007
|
+
value={ localGapRaw ?? undefined }
|
|
1008
|
+
placeholder={
|
|
1009
|
+
isGapPlaceholder
|
|
1010
|
+
? inheritedGapRaw
|
|
1011
|
+
: undefined
|
|
1012
|
+
}
|
|
716
1013
|
/>
|
|
717
1014
|
) ) }
|
|
718
1015
|
{ showSpacingPresetsControl && (
|
|
@@ -726,7 +1023,7 @@ export default function DimensionsPanel( {
|
|
|
726
1023
|
allowReset={ false }
|
|
727
1024
|
/>
|
|
728
1025
|
) }
|
|
729
|
-
</
|
|
1026
|
+
</InheritanceToolsPanelItem>
|
|
730
1027
|
) }
|
|
731
1028
|
{ showChildLayoutControl && (
|
|
732
1029
|
<ChildLayoutControl
|
|
@@ -744,7 +1041,12 @@ export default function DimensionsPanel( {
|
|
|
744
1041
|
/>
|
|
745
1042
|
) }
|
|
746
1043
|
{ showMinHeightControl && (
|
|
747
|
-
<
|
|
1044
|
+
<InheritanceToolsPanelItem
|
|
1045
|
+
{ ...inheritanceProps(
|
|
1046
|
+
isMinHeightPlaceholder,
|
|
1047
|
+
hasMinHeightValue() &&
|
|
1048
|
+
inheritedMinHeightValue !== undefined
|
|
1049
|
+
) }
|
|
748
1050
|
hasValue={ hasMinHeightValue }
|
|
749
1051
|
label={ __( 'Minimum height' ) }
|
|
750
1052
|
onDeselect={ resetMinHeightValue }
|
|
@@ -755,14 +1057,31 @@ export default function DimensionsPanel( {
|
|
|
755
1057
|
>
|
|
756
1058
|
<DimensionControl
|
|
757
1059
|
label={ __( 'Minimum height' ) }
|
|
758
|
-
value
|
|
1060
|
+
// Local-then-inherited: render the inherited value as the
|
|
1061
|
+
// control's value at rest so the unit parses from it
|
|
1062
|
+
// (e.g. "120px" keeps its unit rather than the value
|
|
1063
|
+
// string sitting behind a default px unit). It is only
|
|
1064
|
+
// written to local on user change.
|
|
1065
|
+
value={ localMinHeightValue ?? inheritedMinHeightValue }
|
|
759
1066
|
onChange={ setMinHeightValue }
|
|
1067
|
+
placeholder={
|
|
1068
|
+
isMinHeightPlaceholder
|
|
1069
|
+
? getNumericPlaceholder(
|
|
1070
|
+
inheritedMinHeightValue
|
|
1071
|
+
)
|
|
1072
|
+
: undefined
|
|
1073
|
+
}
|
|
760
1074
|
dimensionSizes={ dimensions?.dimensionSizes }
|
|
761
1075
|
/>
|
|
762
|
-
</
|
|
1076
|
+
</InheritanceToolsPanelItem>
|
|
763
1077
|
) }
|
|
764
1078
|
{ showMinWidthControl && (
|
|
765
|
-
<
|
|
1079
|
+
<InheritanceToolsPanelItem
|
|
1080
|
+
{ ...inheritanceProps(
|
|
1081
|
+
isMinWidthPlaceholder,
|
|
1082
|
+
hasMinWidthValue() &&
|
|
1083
|
+
inheritedMinWidthValue !== undefined
|
|
1084
|
+
) }
|
|
766
1085
|
hasValue={ hasMinWidthValue }
|
|
767
1086
|
label={ __( 'Minimum width' ) }
|
|
768
1087
|
onDeselect={ resetMinWidthValue }
|
|
@@ -773,14 +1092,29 @@ export default function DimensionsPanel( {
|
|
|
773
1092
|
>
|
|
774
1093
|
<DimensionControl
|
|
775
1094
|
label={ __( 'Minimum width' ) }
|
|
776
|
-
value
|
|
1095
|
+
// Local-then-inherited: render the inherited value as the
|
|
1096
|
+
// control's value at rest so the unit parses from it
|
|
1097
|
+
// rather than the value string sitting behind a default
|
|
1098
|
+
// px unit. It is only written to local on user change.
|
|
1099
|
+
value={ localMinWidthValue ?? inheritedMinWidthValue }
|
|
777
1100
|
onChange={ setMinWidthValue }
|
|
1101
|
+
placeholder={
|
|
1102
|
+
isMinWidthPlaceholder
|
|
1103
|
+
? getNumericPlaceholder(
|
|
1104
|
+
inheritedMinWidthValue
|
|
1105
|
+
)
|
|
1106
|
+
: undefined
|
|
1107
|
+
}
|
|
778
1108
|
dimensionSizes={ dimensions?.dimensionSizes }
|
|
779
1109
|
/>
|
|
780
|
-
</
|
|
1110
|
+
</InheritanceToolsPanelItem>
|
|
781
1111
|
) }
|
|
782
1112
|
{ showHeightControl && (
|
|
783
|
-
<
|
|
1113
|
+
<InheritanceToolsPanelItem
|
|
1114
|
+
{ ...inheritanceProps(
|
|
1115
|
+
isHeightPlaceholder,
|
|
1116
|
+
hasHeightValue() && inheritedHeightValue !== undefined
|
|
1117
|
+
) }
|
|
784
1118
|
hasValue={ hasHeightValue }
|
|
785
1119
|
label={ __( 'Height' ) }
|
|
786
1120
|
onDeselect={ resetHeightValue }
|
|
@@ -791,14 +1125,23 @@ export default function DimensionsPanel( {
|
|
|
791
1125
|
>
|
|
792
1126
|
<DimensionControl
|
|
793
1127
|
label={ __( 'Height' ) }
|
|
794
|
-
value={
|
|
1128
|
+
value={ localHeightValue }
|
|
795
1129
|
onChange={ setHeightValue }
|
|
1130
|
+
placeholder={
|
|
1131
|
+
isHeightPlaceholder
|
|
1132
|
+
? inheritedHeightValue
|
|
1133
|
+
: undefined
|
|
1134
|
+
}
|
|
796
1135
|
dimensionSizes={ dimensions?.dimensionSizes }
|
|
797
1136
|
/>
|
|
798
|
-
</
|
|
1137
|
+
</InheritanceToolsPanelItem>
|
|
799
1138
|
) }
|
|
800
1139
|
{ showWidthControl && (
|
|
801
|
-
<
|
|
1140
|
+
<InheritanceToolsPanelItem
|
|
1141
|
+
{ ...inheritanceProps(
|
|
1142
|
+
isWidthPlaceholder,
|
|
1143
|
+
hasWidthValue() && inheritedWidthValue !== undefined
|
|
1144
|
+
) }
|
|
802
1145
|
hasValue={ hasWidthValue }
|
|
803
1146
|
label={ __( 'Width' ) }
|
|
804
1147
|
onDeselect={ resetWidthValue }
|
|
@@ -809,11 +1152,14 @@ export default function DimensionsPanel( {
|
|
|
809
1152
|
>
|
|
810
1153
|
<DimensionControl
|
|
811
1154
|
label={ __( 'Width' ) }
|
|
812
|
-
value={
|
|
1155
|
+
value={ localWidthValue }
|
|
813
1156
|
onChange={ setWidthValue }
|
|
1157
|
+
placeholder={
|
|
1158
|
+
isWidthPlaceholder ? inheritedWidthValue : undefined
|
|
1159
|
+
}
|
|
814
1160
|
dimensionSizes={ dimensions?.dimensionSizes }
|
|
815
1161
|
/>
|
|
816
|
-
</
|
|
1162
|
+
</InheritanceToolsPanelItem>
|
|
817
1163
|
) }
|
|
818
1164
|
{ showAspectRatioControl && (
|
|
819
1165
|
<AspectRatioTool
|
|
@@ -821,6 +1167,11 @@ export default function DimensionsPanel( {
|
|
|
821
1167
|
value={ aspectRatioValue }
|
|
822
1168
|
onChange={ setAspectRatioValue }
|
|
823
1169
|
panelId={ panelId }
|
|
1170
|
+
{ ...inheritanceProps(
|
|
1171
|
+
isAspectRatioPlaceholder,
|
|
1172
|
+
hasAspectRatioValue() &&
|
|
1173
|
+
inheritedAspectRatioValue !== undefined
|
|
1174
|
+
) }
|
|
824
1175
|
isShownByDefault={
|
|
825
1176
|
defaultControls.aspectRatio ??
|
|
826
1177
|
DEFAULT_CONTROLS.aspectRatio
|