@wordpress/block-editor 15.19.1-next.v.202605131032.0 → 15.20.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 +15 -1
- package/build/components/block-card/index.cjs +51 -41
- package/build/components/block-card/index.cjs.map +3 -3
- package/build/components/block-heading-level-dropdown/heading-level-icon.cjs.map +3 -3
- package/build/components/block-icon/index.cjs +7 -1
- package/build/components/block-icon/index.cjs.map +3 -3
- package/build/components/block-inspector/index.cjs +156 -11
- package/build/components/block-inspector/index.cjs.map +3 -3
- package/build/components/block-inspector/inspector-pre-tabs-slot-fill.cjs +38 -0
- package/build/components/block-inspector/inspector-pre-tabs-slot-fill.cjs.map +7 -0
- package/build/components/block-list/use-block-props/index.cjs +1 -1
- 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 +3 -4
- package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +3 -3
- package/build/components/block-list/use-block-props/use-is-hovered.cjs +24 -14
- package/build/components/block-list/use-block-props/use-is-hovered.cjs.map +3 -3
- package/build/components/block-lock/modal.cjs.map +3 -3
- package/build/components/block-patterns-list/index.cjs +13 -2
- package/build/components/block-patterns-list/index.cjs.map +2 -2
- package/build/components/block-popover/index.cjs +13 -3
- package/build/components/block-popover/index.cjs.map +2 -2
- package/build/components/block-toolbar/switch-section-style.cjs.map +3 -3
- package/build/components/block-visibility/modal.cjs.map +3 -3
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +3 -3
- package/build/components/colors-gradients/control.cjs +7 -4
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs +24 -22
- package/build/components/global-styles/advanced-panel.cjs.map +3 -3
- package/build/components/global-styles/color-panel.cjs +95 -58
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +11 -5
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/index.cjs +3 -0
- package/build/components/global-styles/index.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs +38 -26
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/state-control-badges.cjs +69 -0
- package/build/components/global-styles/state-control-badges.cjs.map +7 -0
- package/build/components/global-styles/state-control.cjs +54 -63
- package/build/components/global-styles/state-control.cjs.map +3 -3
- package/build/components/iframe/index.cjs +0 -3
- package/build/components/iframe/index.cjs.map +2 -2
- package/build/components/iframe/use-scale-canvas.cjs +4 -1
- package/build/components/iframe/use-scale-canvas.cjs.map +2 -2
- package/build/components/inserter/hooks/use-patterns-state.cjs +4 -6
- package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
- package/build/components/inserter/index.cjs +1 -0
- package/build/components/inserter/index.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-preview.cjs +27 -18
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/media-tab/utils.cjs +1 -1
- package/build/components/inserter/media-tab/utils.cjs.map +2 -2
- package/build/components/inserter/panel.cjs.map +3 -3
- package/build/components/inspector-controls/block-support-tools-panel.cjs +10 -2
- package/build/components/inspector-controls/block-support-tools-panel.cjs.map +2 -2
- package/build/components/inspector-controls/fill.cjs +14 -4
- package/build/components/inspector-controls/fill.cjs.map +2 -2
- package/build/components/inspector-controls/groups.cjs +2 -0
- package/build/components/inspector-controls/groups.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/index.cjs +13 -8
- package/build/components/inspector-controls-tabs/index.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/settings-tab.cjs +1 -4
- package/build/components/inspector-controls-tabs/settings-tab.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs +9 -0
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +11 -5
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +20 -8
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +2 -1
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/preset-input-control/custom-value-controls.cjs +10 -1
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/preset-input-control/index.cjs.map +3 -3
- package/build/components/provider/use-media-upload-settings.cjs +1 -0
- package/build/components/provider/use-media-upload-settings.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/enter.cjs +9 -2
- package/build/components/rich-text/event-listeners/enter.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/paste-handler.cjs +4 -4
- package/build/components/rich-text/event-listeners/paste-handler.cjs.map +3 -3
- package/build/hooks/background.cjs +13 -3
- package/build/hooks/background.cjs.map +2 -2
- package/build/hooks/block-fields/link/index.cjs.map +3 -3
- package/build/hooks/block-fields/media/index.cjs.map +3 -3
- package/build/hooks/block-style-state.cjs +112 -0
- package/build/hooks/block-style-state.cjs.map +7 -0
- package/build/hooks/border.cjs +13 -3
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/color.cjs +28 -9
- package/build/hooks/color.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +15 -6
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +147 -61
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +263 -56
- package/build/hooks/layout.cjs.map +3 -3
- package/build/hooks/state-utils.cjs +94 -0
- package/build/hooks/state-utils.cjs.map +7 -0
- package/build/hooks/states.cjs +124 -0
- package/build/hooks/states.cjs.map +7 -0
- package/build/hooks/style.cjs +304 -17
- package/build/hooks/style.cjs.map +3 -3
- package/build/hooks/typography.cjs +14 -5
- package/build/hooks/typography.cjs.map +2 -2
- package/build/layouts/constrained.cjs +128 -55
- package/build/layouts/constrained.cjs.map +3 -3
- package/build/layouts/flex.cjs +119 -31
- package/build/layouts/flex.cjs.map +3 -3
- package/build/layouts/grid.cjs +103 -40
- package/build/layouts/grid.cjs.map +3 -3
- package/build/private-apis.cjs +2 -0
- package/build/private-apis.cjs.map +2 -2
- package/build/store/private-actions.cjs +18 -0
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-keys.cjs +10 -2
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/private-selectors.cjs +26 -2
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +70 -1
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/utils.cjs +1 -1
- package/build/store/utils.cjs.map +2 -2
- package/build/utils/color-values.cjs +44 -0
- package/build/utils/color-values.cjs.map +7 -0
- package/build-module/components/block-card/index.mjs +52 -45
- package/build-module/components/block-card/index.mjs.map +2 -2
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.mjs +2 -2
- package/build-module/components/block-heading-level-dropdown/heading-level-icon.mjs.map +2 -2
- package/build-module/components/block-icon/index.mjs +8 -2
- package/build-module/components/block-icon/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +166 -13
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-inspector/inspector-pre-tabs-slot-fill.mjs +12 -0
- package/build-module/components/block-inspector/inspector-pre-tabs-slot-fill.mjs.map +7 -0
- package/build-module/components/block-list/use-block-props/index.mjs +1 -1
- 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 +7 -5
- 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-is-hovered.mjs +28 -15
- package/build-module/components/block-list/use-block-props/use-is-hovered.mjs.map +2 -2
- package/build-module/components/block-lock/modal.mjs +4 -4
- package/build-module/components/block-lock/modal.mjs.map +2 -2
- package/build-module/components/block-patterns-list/index.mjs +14 -4
- package/build-module/components/block-patterns-list/index.mjs.map +2 -2
- package/build-module/components/block-popover/index.mjs +13 -3
- package/build-module/components/block-popover/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs +2 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +2 -2
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +7 -4
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +25 -27
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +96 -59
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +14 -5
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/index.mjs +2 -0
- package/build-module/components/global-styles/index.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs +39 -28
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/state-control-badges.mjs +48 -0
- package/build-module/components/global-styles/state-control-badges.mjs.map +7 -0
- package/build-module/components/global-styles/state-control.mjs +57 -71
- package/build-module/components/global-styles/state-control.mjs.map +2 -2
- package/build-module/components/iframe/index.mjs +0 -3
- package/build-module/components/iframe/index.mjs.map +2 -2
- package/build-module/components/iframe/use-scale-canvas.mjs +4 -1
- package/build-module/components/iframe/use-scale-canvas.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-patterns-state.mjs +8 -7
- package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
- package/build-module/components/inserter/index.mjs +1 -0
- package/build-module/components/inserter/index.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-preview.mjs +27 -19
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/utils.mjs +1 -1
- package/build-module/components/inserter/media-tab/utils.mjs.map +2 -2
- package/build-module/components/inserter/panel.mjs +2 -2
- package/build-module/components/inserter/panel.mjs.map +2 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.mjs +10 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.mjs.map +2 -2
- package/build-module/components/inspector-controls/fill.mjs +18 -5
- package/build-module/components/inspector-controls/fill.mjs.map +2 -2
- package/build-module/components/inspector-controls/groups.mjs +2 -0
- package/build-module/components/inspector-controls/groups.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs +14 -10
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/settings-tab.mjs +1 -4
- package/build-module/components/inspector-controls-tabs/settings-tab.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +9 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +11 -5
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +20 -9
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +2 -1
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/preset-input-control/custom-value-controls.mjs +10 -2
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs +2 -2
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/provider/use-media-upload-settings.mjs +1 -0
- package/build-module/components/provider/use-media-upload-settings.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +9 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +2 -2
- package/build-module/hooks/background.mjs +18 -3
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-fields/link/index.mjs +3 -3
- package/build-module/hooks/block-fields/link/index.mjs.map +2 -2
- package/build-module/hooks/block-fields/media/index.mjs +3 -3
- package/build-module/hooks/block-fields/media/index.mjs.map +2 -2
- package/build-module/hooks/block-style-state.mjs +79 -0
- package/build-module/hooks/block-style-state.mjs.map +7 -0
- package/build-module/hooks/border.mjs +18 -3
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/color.mjs +33 -9
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +20 -6
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +141 -61
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +270 -58
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/state-utils.mjs +64 -0
- package/build-module/hooks/state-utils.mjs.map +7 -0
- package/build-module/hooks/states.mjs +85 -0
- package/build-module/hooks/states.mjs.map +7 -0
- package/build-module/hooks/style.mjs +309 -18
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +19 -5
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +130 -57
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +123 -35
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +105 -42
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +4 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +16 -0
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +7 -1
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +25 -2
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +69 -1
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/utils.mjs +5 -2
- package/build-module/store/utils.mjs.map +2 -2
- package/build-module/utils/color-values.mjs +19 -0
- package/build-module/utils/color-values.mjs.map +7 -0
- package/build-style/content-rtl.css +18 -3
- package/build-style/content.css +18 -3
- package/build-style/style-rtl.css +14 -17
- package/build-style/style.css +14 -17
- package/package.json +41 -41
- package/src/components/audio-player/index.native.js +7 -3
- package/src/components/block-card/index.js +67 -60
- package/src/components/block-heading-level-dropdown/heading-level-icon.js +2 -2
- package/src/components/block-icon/index.js +5 -2
- package/src/components/block-icon/index.native.js +2 -2
- package/src/components/block-inspector/index.js +153 -7
- package/src/components/block-inspector/inspector-pre-tabs-slot-fill.js +11 -0
- package/src/components/block-list/block-selection-button.native.js +3 -3
- package/src/components/block-list/content.scss +0 -6
- package/src/components/block-list/use-block-props/index.js +1 -1
- package/src/components/block-list/use-block-props/use-focus-handler.js +8 -6
- package/src/components/block-list/use-block-props/use-is-hovered.js +32 -15
- package/src/components/block-lock/modal.js +4 -4
- package/src/components/block-patterns-list/index.js +14 -5
- package/src/components/block-patterns-list/stories/index.story.jsx +2 -0
- package/src/components/block-patterns-list/style.scss +0 -1
- package/src/components/block-popover/index.js +20 -10
- package/src/components/block-toolbar/switch-section-style.js +2 -2
- package/src/components/block-visibility/modal.js +2 -2
- package/src/components/block-visibility/viewport-visibility-info.js +2 -2
- package/src/components/colors/test/with-colors.js +1 -1
- package/src/components/colors-gradients/control.js +10 -8
- package/src/components/colors-gradients/test/control.js +98 -1
- package/src/components/global-styles/advanced-panel.js +44 -39
- package/src/components/global-styles/color-panel.js +133 -60
- package/src/components/global-styles/dimensions-panel.js +17 -4
- package/src/components/global-styles/index.js +1 -0
- package/src/components/global-styles/shadow-panel-components.js +29 -19
- package/src/components/global-styles/state-control-badges.js +58 -0
- package/src/components/global-styles/state-control.js +28 -36
- package/src/components/global-styles/test/color-panel.js +135 -0
- package/src/components/iframe/index.js +0 -3
- package/src/components/iframe/use-scale-canvas.js +8 -2
- package/src/components/inserter/hooks/use-patterns-state.js +12 -7
- package/src/components/inserter/index.js +1 -0
- package/src/components/inserter/media-tab/media-preview.js +29 -20
- package/src/components/inserter/media-tab/utils.js +1 -1
- package/src/components/inserter/panel.js +2 -2
- package/src/components/inserter/style.scss +1 -0
- package/src/components/inserter-button/index.native.js +5 -2
- package/src/components/inspector-controls/block-support-tools-panel.js +10 -2
- package/src/components/inspector-controls/fill.js +18 -5
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/index.js +9 -5
- package/src/components/inspector-controls-tabs/settings-tab.js +1 -7
- package/src/components/inspector-controls-tabs/styles-tab.js +6 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +13 -7
- package/src/components/list-view/block-select-button.js +19 -9
- package/src/components/list-view/block.js +6 -1
- package/src/components/media-replace-flow/style.scss +0 -18
- package/src/components/preset-input-control/custom-value-controls.js +13 -6
- package/src/components/preset-input-control/index.js +2 -2
- package/src/components/provider/use-media-upload-settings.js +1 -0
- package/src/components/rich-text/event-listeners/enter.js +14 -2
- package/src/components/rich-text/event-listeners/paste-handler.js +5 -4
- package/src/components/unsupported-block-details/index.native.js +6 -2
- package/src/components/video-player/index.native.js +2 -2
- package/src/components/warning/index.native.js +2 -2
- package/src/hooks/background.js +59 -37
- package/src/hooks/block-fields/link/index.js +3 -3
- package/src/hooks/block-fields/media/index.js +3 -3
- package/src/hooks/block-style-state.js +127 -0
- package/src/hooks/border.js +25 -6
- package/src/hooks/color.js +40 -18
- package/src/hooks/dimensions.js +32 -11
- package/src/hooks/layout-child.js +179 -62
- package/src/hooks/layout.js +349 -75
- package/src/hooks/layout.scss +6 -0
- package/src/hooks/state-utils.js +158 -0
- package/src/hooks/states.js +109 -0
- package/src/hooks/style.js +456 -19
- package/src/hooks/test/block-style-state.js +270 -0
- package/src/hooks/test/layout.js +185 -0
- package/src/hooks/test/state-utils.js +193 -0
- package/src/hooks/test/style.js +301 -1
- package/src/hooks/typography.js +33 -14
- package/src/layouts/constrained.js +182 -95
- package/src/layouts/flex.js +141 -36
- package/src/layouts/grid.js +122 -32
- package/src/layouts/test/flex.js +57 -20
- package/src/private-apis.js +4 -0
- package/src/store/private-actions.js +32 -0
- package/src/store/private-keys.js +4 -0
- package/src/store/private-selectors.js +44 -2
- package/src/store/reducer.js +105 -1
- package/src/store/test/private-actions.js +26 -0
- package/src/store/test/private-selectors.js +90 -0
- package/src/store/test/reducer.js +363 -0
- package/src/store/utils.js +6 -2
- package/src/utils/color-values.js +28 -0
- package/src/utils/test/color-values.js +78 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import { createHigherOrderComponent, useInstanceId } from "@wordpress/compose";
|
|
4
4
|
import { addFilter } from "@wordpress/hooks";
|
|
5
|
+
import { useCallback } from "@wordpress/element";
|
|
5
6
|
import {
|
|
6
7
|
getBlockSupport,
|
|
7
8
|
hasBlockSupport,
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
13
14
|
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
14
15
|
ToggleControl,
|
|
15
|
-
|
|
16
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
16
17
|
privateApis as componentsPrivateApis
|
|
17
18
|
} from "@wordpress/components";
|
|
18
19
|
import { __ } from "@wordpress/i18n";
|
|
@@ -22,14 +23,67 @@ import { useSettings } from "../components/use-settings/index.mjs";
|
|
|
22
23
|
import { getLayoutType, getLayoutTypes } from "../layouts/index.mjs";
|
|
23
24
|
import { useBlockEditingMode } from "../components/block-editing-mode/index.mjs";
|
|
24
25
|
import { LAYOUT_DEFINITIONS } from "../layouts/definitions.mjs";
|
|
25
|
-
import { useBlockSettings, useStyleOverride } from "./utils.mjs";
|
|
26
|
+
import { cleanEmptyObject, useBlockSettings, useStyleOverride } from "./utils.mjs";
|
|
26
27
|
import { unlock } from "../lock-unlock.mjs";
|
|
27
28
|
import { globalStylesDataKey } from "../store/private-keys.mjs";
|
|
28
29
|
import { getVariationNameFromClass } from "./block-style-variation.mjs";
|
|
30
|
+
import {
|
|
31
|
+
DEFAULT_BLOCK_STYLE_STATE,
|
|
32
|
+
getStyleForState,
|
|
33
|
+
hasPseudoBlockStyleState,
|
|
34
|
+
hasViewportBlockStyleState,
|
|
35
|
+
isDefaultBlockStyleState,
|
|
36
|
+
setStyleForState
|
|
37
|
+
} from "./block-style-state.mjs";
|
|
29
38
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
30
39
|
var VARIATION_PREFIX = "is-style-";
|
|
31
40
|
var layoutBlockSupportKey = "layout";
|
|
41
|
+
var RESPONSIVE_BREAKPOINTS = {
|
|
42
|
+
mobile: "@media (width <= 480px)",
|
|
43
|
+
tablet: "@media (480px < width <= 782px)"
|
|
44
|
+
};
|
|
45
|
+
var CHILD_LAYOUT_KEYS = [
|
|
46
|
+
"selfStretch",
|
|
47
|
+
"flexSize",
|
|
48
|
+
"columnStart",
|
|
49
|
+
"columnSpan",
|
|
50
|
+
"rowStart",
|
|
51
|
+
"rowSpan"
|
|
52
|
+
];
|
|
32
53
|
var { kebabCase } = unlock(componentsPrivateApis);
|
|
54
|
+
function getDefaultLayout(layoutBlockSupport = {}, blockVariation) {
|
|
55
|
+
const defaultBlockLayout = layoutBlockSupport?.default;
|
|
56
|
+
return blockVariation?.attributes?.layout ?? defaultBlockLayout;
|
|
57
|
+
}
|
|
58
|
+
function getResetLayout(layoutBlockSupport = {}, blockVariation) {
|
|
59
|
+
return cleanEmptyObject({
|
|
60
|
+
...getDefaultLayout(layoutBlockSupport, blockVariation)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function getLayoutStateOverrides(layout = {}, baseLayout = {}, existingLayout = {}) {
|
|
64
|
+
const overrides = {};
|
|
65
|
+
const childLayoutValues = Object.fromEntries(
|
|
66
|
+
CHILD_LAYOUT_KEYS.filter(
|
|
67
|
+
(key) => Object.hasOwn(existingLayout || {}, key)
|
|
68
|
+
).map((key) => [key, existingLayout[key]])
|
|
69
|
+
);
|
|
70
|
+
Object.entries(layout || {}).forEach(([key, value]) => {
|
|
71
|
+
if (!CHILD_LAYOUT_KEYS.includes(key) && value !== baseLayout?.[key]) {
|
|
72
|
+
overrides[key] = value;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return cleanEmptyObject({
|
|
76
|
+
...childLayoutValues,
|
|
77
|
+
...overrides
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function getLayoutContainerValues(layout = {}) {
|
|
81
|
+
return Object.fromEntries(
|
|
82
|
+
Object.entries(layout || {}).filter(
|
|
83
|
+
([key]) => !CHILD_LAYOUT_KEYS.includes(key)
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
}
|
|
33
87
|
function hasLayoutBlockSupport(blockName) {
|
|
34
88
|
return hasBlockSupport(blockName, "layout") || hasBlockSupport(blockName, "__experimentalLayout");
|
|
35
89
|
}
|
|
@@ -86,21 +140,110 @@ function useLayoutStyles(blockAttributes = {}, blockName, selector) {
|
|
|
86
140
|
hasBlockGapSupport
|
|
87
141
|
});
|
|
88
142
|
}
|
|
143
|
+
function getResponsiveLayoutStyles({
|
|
144
|
+
attributes = {},
|
|
145
|
+
blockName,
|
|
146
|
+
selector,
|
|
147
|
+
layout = {},
|
|
148
|
+
hasBlockGapSupport,
|
|
149
|
+
globalBlockGapValue
|
|
150
|
+
}) {
|
|
151
|
+
return Object.entries(RESPONSIVE_BREAKPOINTS).map(([viewport, mediaQuery]) => {
|
|
152
|
+
const viewportStyle = attributes?.style?.[viewport];
|
|
153
|
+
const viewportLayout = getLayoutContainerValues(
|
|
154
|
+
viewportStyle?.layout
|
|
155
|
+
);
|
|
156
|
+
const hasViewportLayout = Object.keys(viewportLayout).length > 0;
|
|
157
|
+
const hasViewportBlockGap = viewportStyle?.spacing && Object.hasOwn(viewportStyle.spacing, "blockGap");
|
|
158
|
+
const hasViewportPadding = viewportStyle?.spacing && Object.hasOwn(viewportStyle.spacing, "padding");
|
|
159
|
+
if (!hasViewportLayout && !hasViewportBlockGap && !hasViewportPadding) {
|
|
160
|
+
return "";
|
|
161
|
+
}
|
|
162
|
+
const layoutType = getLayoutType(layout?.type || "default");
|
|
163
|
+
const viewportCSS = layoutType?.getLayoutStyle?.({
|
|
164
|
+
blockName,
|
|
165
|
+
selector,
|
|
166
|
+
layout,
|
|
167
|
+
viewportOverrides: viewportLayout,
|
|
168
|
+
style: viewportStyle,
|
|
169
|
+
hasBlockGapSupport,
|
|
170
|
+
globalBlockGapValue
|
|
171
|
+
});
|
|
172
|
+
return viewportCSS ? `${mediaQuery}{${viewportCSS}}` : "";
|
|
173
|
+
}).filter(Boolean).join("");
|
|
174
|
+
}
|
|
89
175
|
function LayoutPanelPure({
|
|
90
176
|
layout,
|
|
177
|
+
style,
|
|
91
178
|
setAttributes,
|
|
92
179
|
name: blockName,
|
|
93
180
|
clientId
|
|
94
181
|
}) {
|
|
95
182
|
const settings = useBlockSettings(blockName);
|
|
96
183
|
const { layout: layoutSettings } = settings;
|
|
97
|
-
const { themeSupportsLayout } = useSelect(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
184
|
+
const { themeSupportsLayout, activeBlockVariation, selectedState } = useSelect(
|
|
185
|
+
(select) => {
|
|
186
|
+
const blockEditorSelect = select(blockEditorStore);
|
|
187
|
+
const { getBlockAttributes, getSettings } = blockEditorSelect;
|
|
188
|
+
const { getSelectedBlockStyleState } = unlock(blockEditorSelect);
|
|
189
|
+
return {
|
|
190
|
+
activeBlockVariation: select(
|
|
191
|
+
blocksStore
|
|
192
|
+
).getActiveBlockVariation(
|
|
193
|
+
blockName,
|
|
194
|
+
getBlockAttributes(clientId) || {},
|
|
195
|
+
"block"
|
|
196
|
+
),
|
|
197
|
+
themeSupportsLayout: getSettings().supportsLayout,
|
|
198
|
+
selectedState: getSelectedBlockStyleState?.(clientId) ?? DEFAULT_BLOCK_STYLE_STATE
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
[blockName, clientId]
|
|
202
|
+
);
|
|
103
203
|
const blockEditingMode = useBlockEditingMode();
|
|
204
|
+
const isViewportLayoutState = hasViewportBlockStyleState(selectedState) && !hasPseudoBlockStyleState(selectedState);
|
|
205
|
+
const resetLayoutFilter = useCallback(
|
|
206
|
+
(...resetArgs) => {
|
|
207
|
+
const attributes = resetArgs[0] || {};
|
|
208
|
+
const context = resetArgs[1] || {};
|
|
209
|
+
if (isViewportLayoutState) {
|
|
210
|
+
const existingStateStyle = getStyleForState(
|
|
211
|
+
attributes.style ?? style,
|
|
212
|
+
selectedState
|
|
213
|
+
) || {};
|
|
214
|
+
const nextStateStyle = cleanEmptyObject({
|
|
215
|
+
...existingStateStyle,
|
|
216
|
+
layout: void 0
|
|
217
|
+
});
|
|
218
|
+
return {
|
|
219
|
+
style: setStyleForState(
|
|
220
|
+
attributes.style ?? style,
|
|
221
|
+
selectedState,
|
|
222
|
+
nextStateStyle
|
|
223
|
+
)
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
const resetBlockName = context.name || blockName;
|
|
227
|
+
const resetLayoutBlockSupport = getBlockSupport(
|
|
228
|
+
resetBlockName,
|
|
229
|
+
layoutBlockSupportKey,
|
|
230
|
+
{}
|
|
231
|
+
);
|
|
232
|
+
return {
|
|
233
|
+
layout: getResetLayout(
|
|
234
|
+
resetLayoutBlockSupport,
|
|
235
|
+
activeBlockVariation
|
|
236
|
+
)
|
|
237
|
+
};
|
|
238
|
+
},
|
|
239
|
+
[
|
|
240
|
+
blockName,
|
|
241
|
+
activeBlockVariation,
|
|
242
|
+
isViewportLayoutState,
|
|
243
|
+
selectedState,
|
|
244
|
+
style
|
|
245
|
+
]
|
|
246
|
+
);
|
|
104
247
|
if (blockEditingMode !== "default") {
|
|
105
248
|
return null;
|
|
106
249
|
}
|
|
@@ -122,14 +265,21 @@ function LayoutPanelPure({
|
|
|
122
265
|
if (!allowEditing) {
|
|
123
266
|
return null;
|
|
124
267
|
}
|
|
268
|
+
const baseLayout = layout || defaultBlockLayout || {};
|
|
269
|
+
const stateStyle = isViewportLayoutState ? getStyleForState(style, selectedState) : void 0;
|
|
270
|
+
const stateLayout = stateStyle?.layout;
|
|
271
|
+
const usedLayout = isViewportLayoutState ? cleanEmptyObject({
|
|
272
|
+
...baseLayout,
|
|
273
|
+
...stateLayout
|
|
274
|
+
}) || {} : baseLayout;
|
|
275
|
+
const resetLayoutDefaults = isViewportLayoutState ? baseLayout : getResetLayout(layoutBlockSupport, activeBlockVariation);
|
|
125
276
|
const blockSupportAndLayout = {
|
|
126
277
|
...layoutBlockSupport,
|
|
127
|
-
...
|
|
278
|
+
...usedLayout
|
|
128
279
|
};
|
|
129
280
|
const { type, default: { type: defaultType = "default" } = {} } = blockSupportAndLayout;
|
|
130
281
|
const blockLayoutType = type || defaultType;
|
|
131
282
|
const showInheritToggle = !!(allowInheriting && (!blockLayoutType || blockLayoutType === "default" || blockLayoutType === "constrained" || blockSupportAndLayout.inherit));
|
|
132
|
-
const usedLayout = layout || defaultBlockLayout || {};
|
|
133
283
|
const { inherit = false, contentSize = null } = usedLayout;
|
|
134
284
|
if ((blockLayoutType === "default" || blockLayoutType === "constrained") && !themeSupportsLayout) {
|
|
135
285
|
return null;
|
|
@@ -138,55 +288,106 @@ function LayoutPanelPure({
|
|
|
138
288
|
const constrainedType = getLayoutType("constrained");
|
|
139
289
|
const displayControlsForLegacyLayouts = !usedLayout.type && (contentSize || inherit);
|
|
140
290
|
const hasContentSizeOrLegacySettings = !!inherit || !!contentSize;
|
|
141
|
-
const
|
|
142
|
-
const onChangeLayout = (newLayout) =>
|
|
291
|
+
const showLayoutTypeSwitcher = isDefaultBlockStyleState(selectedState) && !inherit && allowSwitching;
|
|
292
|
+
const onChangeLayout = (newLayout) => {
|
|
293
|
+
if (isViewportLayoutState) {
|
|
294
|
+
const nextStateStyle = cleanEmptyObject({
|
|
295
|
+
...stateStyle,
|
|
296
|
+
layout: getLayoutStateOverrides(
|
|
297
|
+
cleanEmptyObject(newLayout),
|
|
298
|
+
baseLayout,
|
|
299
|
+
stateStyle?.layout
|
|
300
|
+
)
|
|
301
|
+
});
|
|
302
|
+
setAttributes({
|
|
303
|
+
style: setStyleForState(style, selectedState, nextStateStyle)
|
|
304
|
+
});
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
setAttributes({ layout: cleanEmptyObject(newLayout) });
|
|
308
|
+
};
|
|
309
|
+
const onChangeType = (newType) => onChangeLayout({ type: newType });
|
|
310
|
+
const resetLayout = () => onChangeLayout(resetLayoutDefaults);
|
|
311
|
+
const resetInheritToggle = () => onChangeLayout({ type: "default" });
|
|
312
|
+
const isUsingContentWidth = () => layoutType?.name === "constrained" || hasContentSizeOrLegacySettings;
|
|
313
|
+
const hasInheritToggleValue = () => isViewportLayoutState ? (usedLayout?.type ?? "default") !== (resetLayoutDefaults?.type ?? "default") : layout?.type === "constrained";
|
|
314
|
+
const hasLayoutTypeValue = () => (usedLayout?.type ?? "default") !== (resetLayoutDefaults?.type ?? "default");
|
|
143
315
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
316
|
+
/* @__PURE__ */ jsxs(
|
|
317
|
+
InspectorControls,
|
|
318
|
+
{
|
|
319
|
+
group: "layout",
|
|
320
|
+
resetAllFilter: resetLayoutFilter,
|
|
321
|
+
children: [
|
|
322
|
+
showInheritToggle && /* @__PURE__ */ jsx(
|
|
323
|
+
ToolsPanelItem,
|
|
324
|
+
{
|
|
325
|
+
label: __("Use content width"),
|
|
326
|
+
hasValue: hasInheritToggleValue,
|
|
327
|
+
onDeselect: resetInheritToggle,
|
|
328
|
+
isShownByDefault: true,
|
|
329
|
+
panelId: clientId,
|
|
330
|
+
children: /* @__PURE__ */ jsx(
|
|
331
|
+
ToggleControl,
|
|
332
|
+
{
|
|
333
|
+
label: __("Inner blocks use content width"),
|
|
334
|
+
checked: isUsingContentWidth(),
|
|
335
|
+
onChange: () => onChangeLayout({
|
|
336
|
+
type: isUsingContentWidth() ? "default" : "constrained"
|
|
337
|
+
}),
|
|
338
|
+
help: isUsingContentWidth() ? __(
|
|
339
|
+
"Nested blocks use content width with options for full and wide widths."
|
|
340
|
+
) : __(
|
|
341
|
+
"Nested blocks will fill the width of this container."
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
)
|
|
345
|
+
}
|
|
346
|
+
),
|
|
347
|
+
showLayoutTypeSwitcher && /* @__PURE__ */ jsx(
|
|
348
|
+
ToolsPanelItem,
|
|
349
|
+
{
|
|
350
|
+
label: __("Layout type"),
|
|
351
|
+
hasValue: hasLayoutTypeValue,
|
|
352
|
+
onDeselect: resetLayout,
|
|
353
|
+
isShownByDefault: true,
|
|
354
|
+
panelId: clientId,
|
|
355
|
+
children: /* @__PURE__ */ jsx(
|
|
356
|
+
LayoutTypeSwitcher,
|
|
357
|
+
{
|
|
358
|
+
type: blockLayoutType,
|
|
359
|
+
onChange: onChangeType
|
|
360
|
+
}
|
|
361
|
+
)
|
|
362
|
+
}
|
|
363
|
+
),
|
|
364
|
+
layoutType && layoutType.name !== "default" && /* @__PURE__ */ jsx(
|
|
365
|
+
layoutType.inspectorControls,
|
|
366
|
+
{
|
|
367
|
+
layout: usedLayout,
|
|
368
|
+
value: layout,
|
|
369
|
+
onChange: onChangeLayout,
|
|
370
|
+
layoutBlockSupport: blockSupportAndThemeSettings,
|
|
371
|
+
resetLayout: resetLayoutDefaults,
|
|
372
|
+
name: blockName,
|
|
373
|
+
clientId
|
|
374
|
+
}
|
|
375
|
+
),
|
|
376
|
+
constrainedType && displayControlsForLegacyLayouts && /* @__PURE__ */ jsx(
|
|
377
|
+
constrainedType.inspectorControls,
|
|
378
|
+
{
|
|
379
|
+
layout: usedLayout,
|
|
380
|
+
value: layout,
|
|
381
|
+
onChange: onChangeLayout,
|
|
382
|
+
layoutBlockSupport: blockSupportAndThemeSettings,
|
|
383
|
+
resetLayout: resetLayoutDefaults,
|
|
384
|
+
name: blockName,
|
|
385
|
+
clientId
|
|
153
386
|
}
|
|
154
|
-
}),
|
|
155
|
-
help: layoutType?.name === "constrained" || hasContentSizeOrLegacySettings ? __(
|
|
156
|
-
"Nested blocks use content width with options for full and wide widths."
|
|
157
|
-
) : __(
|
|
158
|
-
"Nested blocks will fill the width of this container."
|
|
159
387
|
)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
LayoutTypeSwitcher,
|
|
164
|
-
{
|
|
165
|
-
type: blockLayoutType,
|
|
166
|
-
onChange: onChangeType
|
|
167
|
-
}
|
|
168
|
-
),
|
|
169
|
-
layoutType && layoutType.name !== "default" && /* @__PURE__ */ jsx(
|
|
170
|
-
layoutType.inspectorControls,
|
|
171
|
-
{
|
|
172
|
-
layout: usedLayout,
|
|
173
|
-
onChange: onChangeLayout,
|
|
174
|
-
layoutBlockSupport: blockSupportAndThemeSettings,
|
|
175
|
-
name: blockName,
|
|
176
|
-
clientId
|
|
177
|
-
}
|
|
178
|
-
),
|
|
179
|
-
constrainedType && displayControlsForLegacyLayouts && /* @__PURE__ */ jsx(
|
|
180
|
-
constrainedType.inspectorControls,
|
|
181
|
-
{
|
|
182
|
-
layout: usedLayout,
|
|
183
|
-
onChange: onChangeLayout,
|
|
184
|
-
layoutBlockSupport: blockSupportAndThemeSettings,
|
|
185
|
-
name: blockName,
|
|
186
|
-
clientId
|
|
187
|
-
}
|
|
188
|
-
)
|
|
189
|
-
] }) }),
|
|
388
|
+
]
|
|
389
|
+
}
|
|
390
|
+
),
|
|
190
391
|
!inherit && layoutType && /* @__PURE__ */ jsx(
|
|
191
392
|
layoutType.toolBarControls,
|
|
192
393
|
{
|
|
@@ -202,7 +403,7 @@ function LayoutPanelPure({
|
|
|
202
403
|
var layout_default = {
|
|
203
404
|
shareWithChildBlocks: true,
|
|
204
405
|
edit: LayoutPanelPure,
|
|
205
|
-
attributeKeys: ["layout"],
|
|
406
|
+
attributeKeys: ["layout", "style"],
|
|
206
407
|
hasSupport(name) {
|
|
207
408
|
return hasLayoutBlockSupport(name);
|
|
208
409
|
}
|
|
@@ -261,7 +462,7 @@ function BlockWithLayoutStyles({
|
|
|
261
462
|
const selector = `.${selectorPrefix}${id}`;
|
|
262
463
|
const hasBlockGapSupport = blockGapSupport !== null;
|
|
263
464
|
const fullLayoutType = getLayoutType(usedLayout?.type || "default");
|
|
264
|
-
const
|
|
465
|
+
const baseLayoutCSS = fullLayoutType?.getLayoutStyle?.({
|
|
265
466
|
blockName: name,
|
|
266
467
|
selector,
|
|
267
468
|
layout: usedLayout,
|
|
@@ -269,6 +470,15 @@ function BlockWithLayoutStyles({
|
|
|
269
470
|
hasBlockGapSupport,
|
|
270
471
|
globalBlockGapValue
|
|
271
472
|
});
|
|
473
|
+
const responsiveLayoutCSS = getResponsiveLayoutStyles({
|
|
474
|
+
attributes,
|
|
475
|
+
blockName: name,
|
|
476
|
+
selector,
|
|
477
|
+
layout: usedLayout,
|
|
478
|
+
hasBlockGapSupport,
|
|
479
|
+
globalBlockGapValue
|
|
480
|
+
});
|
|
481
|
+
const css = [baseLayoutCSS, responsiveLayoutCSS].filter(Boolean).join("");
|
|
272
482
|
const layoutClassNames = clsx(
|
|
273
483
|
{
|
|
274
484
|
[`${selectorPrefix}${id}`]: !!css
|
|
@@ -358,6 +568,8 @@ addFilter(
|
|
|
358
568
|
export {
|
|
359
569
|
addAttribute,
|
|
360
570
|
layout_default as default,
|
|
571
|
+
getResetLayout,
|
|
572
|
+
getResponsiveLayoutStyles,
|
|
361
573
|
useLayoutClasses,
|
|
362
574
|
useLayoutStyles,
|
|
363
575
|
withLayoutStyles
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/layout.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\tToggleControl,\n\tPanelBody,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport { useSettings } from '../components/use-settings';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { useBlockSettings, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport { getVariationNameFromClass } from './block-style-variation';\n\nconst VARIATION_PREFIX = 'is-style-';\n\nconst layoutBlockSupportKey = 'layout';\nconst { kebabCase } = unlock( componentsPrivateApis );\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst { layout } = blockAttributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tconst hasGlobalPadding = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when layout doesn't use global padding\n\t\t\tif (\n\t\t\t\t! usedLayout?.inherit &&\n\t\t\t\t! usedLayout?.contentSize &&\n\t\t\t\tusedLayout?.type !== 'constrained'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn select( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalFeatures?.useRootPaddingAwareAlignments;\n\t\t},\n\t\t[ usedLayout?.contentSize, usedLayout?.inherit, usedLayout?.type ]\n\t);\n\n\tif ( hasGlobalPadding ) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\treturn fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n}\n\nfunction LayoutPanelPure( {\n\tlayout,\n\tsetAttributes,\n\tname: blockName,\n\tclientId,\n} ) {\n\tconst settings = useBlockSettings( blockName );\n\t// Block settings come from theme.json under settings.[blockName].\n\tconst { layout: layoutSettings } = settings;\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\t// Layout block support comes from the block's block.json.\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst blockSupportAndThemeSettings = {\n\t\t...layoutSettings,\n\t\t...layoutBlockSupport,\n\t};\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = blockSupportAndThemeSettings;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * Try to find the layout type from either the\n\t * block's layout settings or any saved layout config.\n\t */\n\tconst blockSupportAndLayout = {\n\t\t...layoutBlockSupport,\n\t\t...layout,\n\t};\n\tconst { type, default: { type: defaultType = 'default' } = {} } =\n\t\tblockSupportAndLayout;\n\tconst blockLayoutType = type || defaultType;\n\n\t// Only show the inherit toggle if it's supported,\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t( ! blockLayoutType ||\n\t\t\tblockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ||\n\t\t\tblockSupportAndLayout.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst { inherit = false, contentSize = null } = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( blockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( blockLayoutType );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\t\t\t\t\tlayoutType?.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t'constrained' ||\n\t\t\t\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ blockLayoutType }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\tname={ blockName }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: LayoutPanelPure,\n\tattributeKeys: [ 'layout' ],\n\thasSupport( name ) {\n\t\treturn hasLayoutBlockSupport( name );\n\t},\n};\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\t__next40pxDefaultSize\n\t\t\tisBlock\n\t\t\tlabel={ __( 'Layout type' ) }\n\t\t\thideLabelFromVision\n\t\t\tisAdaptiveWidth\n\t\t\tvalue={ type }\n\t\t\tonChange={ onChange }\n\t\t>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockWithLayoutStyles( {\n\tblock: BlockListBlock,\n\tprops,\n\tblockGapSupport,\n\tglobalBlockGapValue,\n\tlayoutClasses,\n} ) {\n\tconst { name, attributes } = props;\n\tconst id = useInstanceId( BlockListBlock );\n\tconst { layout } = attributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst selectorPrefix = `wp-container-${ kebabCase( name ) }-is-layout-`;\n\t// Higher specificity to override defaults from theme.json.\n\tconst selector = `.${ selectorPrefix }${ id }`;\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t// Get CSS string for the current layout type.\n\t// The CSS and `style` element is only output if it is not empty.\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\tstyle: attributes?.style,\n\t\thasBlockGapSupport,\n\t\tglobalBlockGapValue,\n\t} );\n\n\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\tconst layoutClassNames = clsx(\n\t\t{\n\t\t\t[ `${ selectorPrefix }${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t},\n\t\tlayoutClasses\n\t);\n\n\tuseStyleOverride( { css } );\n\n\treturn (\n\t\t<BlockListBlock\n\t\t\t{ ...props }\n\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t/>\n\t);\n}\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) =>\n\t\tfunction WithLayoutStyles( props ) {\n\t\t\tconst { clientId, name, attributes } = props;\n\t\t\tconst blockSupportsLayout = hasLayoutBlockSupport( name );\n\t\t\tconst layoutClasses = useLayoutClasses( attributes, name );\n\t\t\tconst extraProps = useSelect(\n\t\t\t\t( select ) => {\n\t\t\t\t\t// The callback returns early to avoid block editor subscription.\n\t\t\t\t\tif ( ! blockSupportsLayout ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { getSettings, getBlockSettings } = unlock(\n\t\t\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t);\n\t\t\t\t\tconst settings = getSettings();\n\t\t\t\t\tconst { disableLayoutStyles } = settings;\n\n\t\t\t\t\tif ( disableLayoutStyles ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst [ blockGapSupport ] = getBlockSettings(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t'spacing.blockGap'\n\t\t\t\t\t);\n\n\t\t\t\t\t// Get default blockGap value from global styles for use in layouts like grid.\n\t\t\t\t\t// Check style variation first, then block-specific styles, then fall back to root styles.\n\t\t\t\t\tconst globalStyles = settings[ globalStylesDataKey ];\n\n\t\t\t\t\t// Check if the block has an active style variation with a blockGap value.\n\t\t\t\t\t// Only check the registry if the className contains a variation class to avoid unnecessary lookups.\n\t\t\t\t\tlet variationBlockGapValue;\n\t\t\t\t\tconst className = attributes?.className;\n\t\t\t\t\tif ( className?.includes( VARIATION_PREFIX ) ) {\n\t\t\t\t\t\tconst { getBlockStyles } = select( blocksStore );\n\t\t\t\t\t\tconst registeredStyles = getBlockStyles( name );\n\t\t\t\t\t\tconst variationName = getVariationNameFromClass(\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\tregisteredStyles\n\t\t\t\t\t\t);\n\t\t\t\t\t\tvariationBlockGapValue = variationName\n\t\t\t\t\t\t\t? globalStyles?.blocks?.[ name ]?.variations?.[\n\t\t\t\t\t\t\t\t\tvariationName\n\t\t\t\t\t\t\t ]?.spacing?.blockGap\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst globalBlockGapValue =\n\t\t\t\t\t\tvariationBlockGapValue ??\n\t\t\t\t\t\tglobalStyles?.blocks?.[ name ]?.spacing?.blockGap ??\n\t\t\t\t\t\tglobalStyles?.spacing?.blockGap;\n\n\t\t\t\t\treturn { blockGapSupport, globalBlockGapValue };\n\t\t\t\t},\n\t\t\t\t[ blockSupportsLayout, clientId, attributes?.className, name ]\n\t\t\t);\n\n\t\t\tif ( ! extraProps ) {\n\t\t\t\treturn (\n\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t__unstableLayoutClassNames={\n\t\t\t\t\t\t\tblockSupportsLayout ? layoutClasses : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<BlockWithLayoutStyles\n\t\t\t\t\tblock={ BlockListBlock }\n\t\t\t\t\tprops={ props }\n\t\t\t\t\tlayoutClasses={ layoutClasses }\n\t\t\t\t\t{ ...extraProps }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t'withLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,4BAA4B,qBAAqB;AAC1D,SAAS,iBAAiB;AAC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L,0BACA,cAAc,SAAU,IAAK,GAAG,SAAS,YACzC,cAAc,SAAS;AAExB,eAAO,EAAE,iBAAiB,oBAAoB;AAAA,MAC/C;AAAA,MACA,CAAE,qBAAqB,UAAU,YAAY,WAAW,IAAK;AAAA,IAC9D;AAEA,QAAK,CAAE,YAAa;AACnB,aACC;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,UACL,4BACC,sBAAsB,gBAAgB;AAAA;AAAA,MAExC;AAAA,IAEF;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACE,GAAG;AAAA;AAAA,IACN;AAAA,EAEF;AAAA,EACD;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useCallback } from '@wordpress/element';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport { useSettings } from '../components/use-settings';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { cleanEmptyObject, useBlockSettings, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport { getVariationNameFromClass } from './block-style-variation';\nimport {\n\tDEFAULT_BLOCK_STYLE_STATE,\n\tgetStyleForState,\n\thasPseudoBlockStyleState,\n\thasViewportBlockStyleState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n} from './block-style-state';\n\nconst VARIATION_PREFIX = 'is-style-';\n\nconst layoutBlockSupportKey = 'layout';\n// Keep in sync with WP_Theme_JSON_Gutenberg::RESPONSIVE_BREAKPOINTS and\n// packages/global-styles-engine/src/core/render.tsx.\nconst RESPONSIVE_BREAKPOINTS = {\n\tmobile: '@media (width <= 480px)',\n\ttablet: '@media (480px < width <= 782px)',\n};\nconst CHILD_LAYOUT_KEYS = [\n\t'selfStretch',\n\t'flexSize',\n\t'columnStart',\n\t'columnSpan',\n\t'rowStart',\n\t'rowSpan',\n];\nconst { kebabCase } = unlock( componentsPrivateApis );\n\nfunction getDefaultLayout( layoutBlockSupport = {}, blockVariation ) {\n\tconst defaultBlockLayout = layoutBlockSupport?.default;\n\n\treturn blockVariation?.attributes?.layout ?? defaultBlockLayout;\n}\n\n/**\n * Returns the layout values to use when resetting layout controls.\n *\n * @param { Object } layoutBlockSupport Block layout support settings.\n * @param { Object|undefined } blockVariation Block variation settings.\n *\n * @return { Object|undefined } Reset layout values.\n */\nexport function getResetLayout( layoutBlockSupport = {}, blockVariation ) {\n\treturn cleanEmptyObject( {\n\t\t...getDefaultLayout( layoutBlockSupport, blockVariation ),\n\t} );\n}\n\nfunction getLayoutStateOverrides(\n\tlayout = {},\n\tbaseLayout = {},\n\texistingLayout = {}\n) {\n\tconst overrides = {};\n\tconst childLayoutValues = Object.fromEntries(\n\t\tCHILD_LAYOUT_KEYS.filter( ( key ) =>\n\t\t\tObject.hasOwn( existingLayout || {}, key )\n\t\t).map( ( key ) => [ key, existingLayout[ key ] ] )\n\t);\n\n\tObject.entries( layout || {} ).forEach( ( [ key, value ] ) => {\n\t\tif (\n\t\t\t! CHILD_LAYOUT_KEYS.includes( key ) &&\n\t\t\tvalue !== baseLayout?.[ key ]\n\t\t) {\n\t\t\toverrides[ key ] = value;\n\t\t}\n\t} );\n\n\treturn cleanEmptyObject( {\n\t\t...childLayoutValues,\n\t\t...overrides,\n\t} );\n}\n\nfunction getLayoutContainerValues( layout = {} ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( layout || {} ).filter(\n\t\t\t( [ key ] ) => ! CHILD_LAYOUT_KEYS.includes( key )\n\t\t)\n\t);\n}\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst { layout } = blockAttributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tconst hasGlobalPadding = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when layout doesn't use global padding\n\t\t\tif (\n\t\t\t\t! usedLayout?.inherit &&\n\t\t\t\t! usedLayout?.contentSize &&\n\t\t\t\tusedLayout?.type !== 'constrained'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn select( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalFeatures?.useRootPaddingAwareAlignments;\n\t\t},\n\t\t[ usedLayout?.contentSize, usedLayout?.inherit, usedLayout?.type ]\n\t);\n\n\tif ( hasGlobalPadding ) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\treturn fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n}\n\n/**\n * Generates responsive layout CSS for viewport state styles.\n *\n * Viewport state blockGap values need to go through the layout definitions\n * because flow/constrained layouts use child margins while flex/grid use gap.\n *\n * @param { Object } options Options.\n * @param { Object } options.attributes Block attributes.\n * @param { string } options.blockName Block name.\n * @param { string } options.selector CSS selector.\n * @param { Object } options.layout Active block layout.\n * @param { boolean } options.hasBlockGapSupport Whether block gap is supported.\n * @param { * } options.globalBlockGapValue Global block gap fallback.\n *\n * @return { string } CSS rule.\n */\nexport function getResponsiveLayoutStyles( {\n\tattributes = {},\n\tblockName,\n\tselector,\n\tlayout = {},\n\thasBlockGapSupport,\n\tglobalBlockGapValue,\n} ) {\n\treturn Object.entries( RESPONSIVE_BREAKPOINTS )\n\t\t.map( ( [ viewport, mediaQuery ] ) => {\n\t\t\tconst viewportStyle = attributes?.style?.[ viewport ];\n\t\t\tconst viewportLayout = getLayoutContainerValues(\n\t\t\t\tviewportStyle?.layout\n\t\t\t);\n\t\t\tconst hasViewportLayout = Object.keys( viewportLayout ).length > 0;\n\t\t\tconst hasViewportBlockGap =\n\t\t\t\tviewportStyle?.spacing &&\n\t\t\t\tObject.hasOwn( viewportStyle.spacing, 'blockGap' );\n\t\t\tconst hasViewportPadding =\n\t\t\t\tviewportStyle?.spacing &&\n\t\t\t\tObject.hasOwn( viewportStyle.spacing, 'padding' );\n\t\t\tif (\n\t\t\t\t! hasViewportLayout &&\n\t\t\t\t! hasViewportBlockGap &&\n\t\t\t\t! hasViewportPadding\n\t\t\t) {\n\t\t\t\treturn '';\n\t\t\t}\n\n\t\t\tconst layoutType = getLayoutType( layout?.type || 'default' );\n\t\t\tconst viewportCSS = layoutType?.getLayoutStyle?.( {\n\t\t\t\tblockName,\n\t\t\t\tselector,\n\t\t\t\tlayout,\n\t\t\t\tviewportOverrides: viewportLayout,\n\t\t\t\tstyle: viewportStyle,\n\t\t\t\thasBlockGapSupport,\n\t\t\t\tglobalBlockGapValue,\n\t\t\t} );\n\n\t\t\treturn viewportCSS ? `${ mediaQuery }{${ viewportCSS }}` : '';\n\t\t} )\n\t\t.filter( Boolean )\n\t\t.join( '' );\n}\n\nfunction LayoutPanelPure( {\n\tlayout,\n\tstyle,\n\tsetAttributes,\n\tname: blockName,\n\tclientId,\n} ) {\n\tconst settings = useBlockSettings( blockName );\n\t// Block settings come from theme.json under settings.[blockName].\n\tconst { layout: layoutSettings } = settings;\n\tconst { themeSupportsLayout, activeBlockVariation, selectedState } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst blockEditorSelect = select( blockEditorStore );\n\t\t\t\tconst { getBlockAttributes, getSettings } = blockEditorSelect;\n\t\t\t\tconst { getSelectedBlockStyleState } =\n\t\t\t\t\tunlock( blockEditorSelect );\n\t\t\t\treturn {\n\t\t\t\t\tactiveBlockVariation: select(\n\t\t\t\t\t\tblocksStore\n\t\t\t\t\t).getActiveBlockVariation(\n\t\t\t\t\t\tblockName,\n\t\t\t\t\t\tgetBlockAttributes( clientId ) || {},\n\t\t\t\t\t\t'block'\n\t\t\t\t\t),\n\t\t\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t\t\t\tselectedState:\n\t\t\t\t\t\tgetSelectedBlockStyleState?.( clientId ) ??\n\t\t\t\t\t\tDEFAULT_BLOCK_STYLE_STATE,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ blockName, clientId ]\n\t\t);\n\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isViewportLayoutState =\n\t\thasViewportBlockStyleState( selectedState ) &&\n\t\t! hasPseudoBlockStyleState( selectedState );\n\tconst resetLayoutFilter = useCallback(\n\t\t( ...resetArgs ) => {\n\t\t\tconst attributes = resetArgs[ 0 ] || {};\n\t\t\tconst context = resetArgs[ 1 ] || {};\n\n\t\t\tif ( isViewportLayoutState ) {\n\t\t\t\tconst existingStateStyle =\n\t\t\t\t\tgetStyleForState(\n\t\t\t\t\t\tattributes.style ?? style,\n\t\t\t\t\t\tselectedState\n\t\t\t\t\t) || {};\n\t\t\t\tconst nextStateStyle = cleanEmptyObject( {\n\t\t\t\t\t...existingStateStyle,\n\t\t\t\t\tlayout: undefined,\n\t\t\t\t} );\n\n\t\t\t\treturn {\n\t\t\t\t\tstyle: setStyleForState(\n\t\t\t\t\t\tattributes.style ?? style,\n\t\t\t\t\t\tselectedState,\n\t\t\t\t\t\tnextStateStyle\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst resetBlockName = context.name || blockName;\n\t\t\tconst resetLayoutBlockSupport = getBlockSupport(\n\t\t\t\tresetBlockName,\n\t\t\t\tlayoutBlockSupportKey,\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlayout: getResetLayout(\n\t\t\t\t\tresetLayoutBlockSupport,\n\t\t\t\t\tactiveBlockVariation\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tblockName,\n\t\t\tactiveBlockVariation,\n\t\t\tisViewportLayoutState,\n\t\t\tselectedState,\n\t\t\tstyle,\n\t\t]\n\t);\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\t// Layout block support comes from the block's block.json.\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst blockSupportAndThemeSettings = {\n\t\t...layoutSettings,\n\t\t...layoutBlockSupport,\n\t};\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = blockSupportAndThemeSettings;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * Try to find the layout type from either the\n\t * block's layout settings or any saved layout config.\n\t */\n\tconst baseLayout = layout || defaultBlockLayout || {};\n\tconst stateStyle = isViewportLayoutState\n\t\t? getStyleForState( style, selectedState )\n\t\t: undefined;\n\tconst stateLayout = stateStyle?.layout;\n\tconst usedLayout = isViewportLayoutState\n\t\t? cleanEmptyObject( {\n\t\t\t\t...baseLayout,\n\t\t\t\t...stateLayout,\n\t\t } ) || {}\n\t\t: baseLayout;\n\tconst resetLayoutDefaults = isViewportLayoutState\n\t\t? baseLayout\n\t\t: getResetLayout( layoutBlockSupport, activeBlockVariation );\n\tconst blockSupportAndLayout = {\n\t\t...layoutBlockSupport,\n\t\t...usedLayout,\n\t};\n\tconst { type, default: { type: defaultType = 'default' } = {} } =\n\t\tblockSupportAndLayout;\n\tconst blockLayoutType = type || defaultType;\n\n\t// Only show the inherit toggle if it's supported,\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t( ! blockLayoutType ||\n\t\t\tblockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ||\n\t\t\tblockSupportAndLayout.inherit )\n\t);\n\n\tconst { inherit = false, contentSize = null } = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( blockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( blockLayoutType );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\tconst showLayoutTypeSwitcher =\n\t\tisDefaultBlockStyleState( selectedState ) &&\n\t\t! inherit &&\n\t\tallowSwitching;\n\n\tconst onChangeLayout = ( newLayout ) => {\n\t\tif ( isViewportLayoutState ) {\n\t\t\tconst nextStateStyle = cleanEmptyObject( {\n\t\t\t\t...stateStyle,\n\t\t\t\tlayout: getLayoutStateOverrides(\n\t\t\t\t\tcleanEmptyObject( newLayout ),\n\t\t\t\t\tbaseLayout,\n\t\t\t\t\tstateStyle?.layout\n\t\t\t\t),\n\t\t\t} );\n\t\t\tsetAttributes( {\n\t\t\t\tstyle: setStyleForState( style, selectedState, nextStateStyle ),\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\tsetAttributes( { layout: cleanEmptyObject( newLayout ) } );\n\t};\n\tconst onChangeType = ( newType ) => onChangeLayout( { type: newType } );\n\tconst resetLayout = () => onChangeLayout( resetLayoutDefaults );\n\tconst resetInheritToggle = () => onChangeLayout( { type: 'default' } );\n\tconst isUsingContentWidth = () =>\n\t\tlayoutType?.name === 'constrained' || hasContentSizeOrLegacySettings;\n\tconst hasInheritToggleValue = () =>\n\t\tisViewportLayoutState\n\t\t\t? ( usedLayout?.type ?? 'default' ) !==\n\t\t\t ( resetLayoutDefaults?.type ?? 'default' )\n\t\t\t: layout?.type === 'constrained';\n\tconst hasLayoutTypeValue = () =>\n\t\t( usedLayout?.type ?? 'default' ) !==\n\t\t( resetLayoutDefaults?.type ?? 'default' );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls\n\t\t\t\tgroup=\"layout\"\n\t\t\t\tresetAllFilter={ resetLayoutFilter }\n\t\t\t>\n\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Use content width' ) }\n\t\t\t\t\t\thasValue={ hasInheritToggleValue }\n\t\t\t\t\t\tonDeselect={ resetInheritToggle }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\tchecked={ isUsingContentWidth() }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tonChangeLayout( {\n\t\t\t\t\t\t\t\t\ttype: isUsingContentWidth()\n\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t: 'constrained',\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\tisUsingContentWidth()\n\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container.'\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\n\t\t\t\t{ showLayoutTypeSwitcher && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Layout type' ) }\n\t\t\t\t\t\thasValue={ hasLayoutTypeValue }\n\t\t\t\t\t\tonDeselect={ resetLayout }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ blockLayoutType }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\n\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\tvalue={ layout }\n\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\tresetLayout={ resetLayoutDefaults }\n\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\tvalue={ layout }\n\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\tresetLayout={ resetLayoutDefaults }\n\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\tname={ blockName }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: LayoutPanelPure,\n\tattributeKeys: [ 'layout', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasLayoutBlockSupport( name );\n\t},\n};\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\t__next40pxDefaultSize\n\t\t\tisBlock\n\t\t\tlabel={ __( 'Layout type' ) }\n\t\t\thideLabelFromVision\n\t\t\tisAdaptiveWidth\n\t\t\tvalue={ type }\n\t\t\tonChange={ onChange }\n\t\t>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockWithLayoutStyles( {\n\tblock: BlockListBlock,\n\tprops,\n\tblockGapSupport,\n\tglobalBlockGapValue,\n\tlayoutClasses,\n} ) {\n\tconst { name, attributes } = props;\n\tconst id = useInstanceId( BlockListBlock );\n\tconst { layout } = attributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst selectorPrefix = `wp-container-${ kebabCase( name ) }-is-layout-`;\n\t// Higher specificity to override defaults from theme.json.\n\tconst selector = `.${ selectorPrefix }${ id }`;\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t// Get CSS string for the current layout type.\n\t// The CSS and `style` element is only output if it is not empty.\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst baseLayoutCSS = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\tstyle: attributes?.style,\n\t\thasBlockGapSupport,\n\t\tglobalBlockGapValue,\n\t} );\n\tconst responsiveLayoutCSS = getResponsiveLayoutStyles( {\n\t\tattributes,\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\thasBlockGapSupport,\n\t\tglobalBlockGapValue,\n\t} );\n\tconst css = [ baseLayoutCSS, responsiveLayoutCSS ]\n\t\t.filter( Boolean )\n\t\t.join( '' );\n\n\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\tconst layoutClassNames = clsx(\n\t\t{\n\t\t\t[ `${ selectorPrefix }${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t},\n\t\tlayoutClasses\n\t);\n\n\tuseStyleOverride( { css } );\n\n\treturn (\n\t\t<BlockListBlock\n\t\t\t{ ...props }\n\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t/>\n\t);\n}\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) =>\n\t\tfunction WithLayoutStyles( props ) {\n\t\t\tconst { clientId, name, attributes } = props;\n\t\t\tconst blockSupportsLayout = hasLayoutBlockSupport( name );\n\t\t\tconst layoutClasses = useLayoutClasses( attributes, name );\n\t\t\tconst extraProps = useSelect(\n\t\t\t\t( select ) => {\n\t\t\t\t\t// The callback returns early to avoid block editor subscription.\n\t\t\t\t\tif ( ! blockSupportsLayout ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { getSettings, getBlockSettings } = unlock(\n\t\t\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t);\n\t\t\t\t\tconst settings = getSettings();\n\t\t\t\t\tconst { disableLayoutStyles } = settings;\n\n\t\t\t\t\tif ( disableLayoutStyles ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst [ blockGapSupport ] = getBlockSettings(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t'spacing.blockGap'\n\t\t\t\t\t);\n\n\t\t\t\t\t// Get default blockGap value from global styles for use in layouts like grid.\n\t\t\t\t\t// Check style variation first, then block-specific styles, then fall back to root styles.\n\t\t\t\t\tconst globalStyles = settings[ globalStylesDataKey ];\n\n\t\t\t\t\t// Check if the block has an active style variation with a blockGap value.\n\t\t\t\t\t// Only check the registry if the className contains a variation class to avoid unnecessary lookups.\n\t\t\t\t\tlet variationBlockGapValue;\n\t\t\t\t\tconst className = attributes?.className;\n\t\t\t\t\tif ( className?.includes( VARIATION_PREFIX ) ) {\n\t\t\t\t\t\tconst { getBlockStyles } = select( blocksStore );\n\t\t\t\t\t\tconst registeredStyles = getBlockStyles( name );\n\t\t\t\t\t\tconst variationName = getVariationNameFromClass(\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\tregisteredStyles\n\t\t\t\t\t\t);\n\t\t\t\t\t\tvariationBlockGapValue = variationName\n\t\t\t\t\t\t\t? globalStyles?.blocks?.[ name ]?.variations?.[\n\t\t\t\t\t\t\t\t\tvariationName\n\t\t\t\t\t\t\t ]?.spacing?.blockGap\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst globalBlockGapValue =\n\t\t\t\t\t\tvariationBlockGapValue ??\n\t\t\t\t\t\tglobalStyles?.blocks?.[ name ]?.spacing?.blockGap ??\n\t\t\t\t\t\tglobalStyles?.spacing?.blockGap;\n\n\t\t\t\t\treturn { blockGapSupport, globalBlockGapValue };\n\t\t\t\t},\n\t\t\t\t[ blockSupportsLayout, clientId, attributes?.className, name ]\n\t\t\t);\n\n\t\t\tif ( ! extraProps ) {\n\t\t\t\treturn (\n\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t__unstableLayoutClassNames={\n\t\t\t\t\t\t\tblockSupportsLayout ? layoutClasses : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<BlockWithLayoutStyles\n\t\t\t\t\tblock={ BlockListBlock }\n\t\t\t\t\tprops={ props }\n\t\t\t\t\tlayoutClasses={ layoutClasses }\n\t\t\t\t\t{ ...extraProps }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t'withLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\n"],
|
|
5
|
+
"mappings": ";AAGA,OA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,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACE,GAAG;AAAA;AAAA,IACN;AAAA,EAEF;AAAA,EACD;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// packages/block-editor/src/hooks/state-utils.js
|
|
2
|
+
import { getBlockType } from "@wordpress/blocks";
|
|
3
|
+
import { splitSelectorList } from "@wordpress/global-styles-engine";
|
|
4
|
+
function getRelativeRootSelector(rootSelector) {
|
|
5
|
+
const match = rootSelector.trim().match(/^[^ >+~]+[ >+~](.*)$/);
|
|
6
|
+
if (!match) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const rest = match[1].trim();
|
|
10
|
+
return rest || null;
|
|
11
|
+
}
|
|
12
|
+
function buildScopedBlockSelector(baseSelector, blockSelector, suffix = "") {
|
|
13
|
+
if (typeof blockSelector !== "string" || !blockSelector) {
|
|
14
|
+
return splitSelectorList(baseSelector).map((selector) => `${selector.trim()}${suffix}`).join(", ");
|
|
15
|
+
}
|
|
16
|
+
const baseSelectors = splitSelectorList(baseSelector).filter(
|
|
17
|
+
(selector) => selector.trim()
|
|
18
|
+
);
|
|
19
|
+
const selectors = splitSelectorList(blockSelector).filter(
|
|
20
|
+
(selector) => selector.trim()
|
|
21
|
+
);
|
|
22
|
+
if (!selectors.length) {
|
|
23
|
+
return baseSelectors.map((selector) => `${selector.trim()}${suffix}`).join(", ");
|
|
24
|
+
}
|
|
25
|
+
return selectors.map((selector) => {
|
|
26
|
+
selector = selector.trim();
|
|
27
|
+
const match = selector.match(/^([.#]?[-_a-zA-Z0-9]+|\[[^\]]+\])/);
|
|
28
|
+
if (match) {
|
|
29
|
+
return baseSelectors.map(
|
|
30
|
+
(base) => `${base.trim()}${selector.slice(
|
|
31
|
+
match[0].length
|
|
32
|
+
)}${suffix}`
|
|
33
|
+
).join(", ");
|
|
34
|
+
}
|
|
35
|
+
return baseSelectors.map((base) => `${base.trim()}${suffix}`).join(", ");
|
|
36
|
+
}).join(", ");
|
|
37
|
+
}
|
|
38
|
+
function buildRootStyleStateSelector(baseSelector, name) {
|
|
39
|
+
const rootSelector = getBlockType(name)?.selectors?.root;
|
|
40
|
+
return buildScopedBlockSelector(baseSelector, rootSelector);
|
|
41
|
+
}
|
|
42
|
+
function buildPseudoStyleStateSelector(baseSelector, name, state) {
|
|
43
|
+
return `${buildRootStyleStateSelector(baseSelector, name)}${state}`;
|
|
44
|
+
}
|
|
45
|
+
function buildStateSelector(baseSelector, name, state) {
|
|
46
|
+
const rootSelector = getBlockType(name)?.selectors?.root;
|
|
47
|
+
return buildScopedBlockSelector(baseSelector, rootSelector, state);
|
|
48
|
+
}
|
|
49
|
+
function buildCanvasStateSelector(clientId, name) {
|
|
50
|
+
const rootSelector = getBlockType(name)?.selectors?.root;
|
|
51
|
+
return buildScopedBlockSelector(
|
|
52
|
+
`[data-block="${clientId}"]`,
|
|
53
|
+
rootSelector
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
buildCanvasStateSelector,
|
|
58
|
+
buildPseudoStyleStateSelector,
|
|
59
|
+
buildRootStyleStateSelector,
|
|
60
|
+
buildScopedBlockSelector,
|
|
61
|
+
buildStateSelector,
|
|
62
|
+
getRelativeRootSelector
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=state-utils.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hooks/state-utils.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { splitSelectorList } from '@wordpress/global-styles-engine';\n\n/**\n * Given a block's `selectors.root` value, returns the part of the selector\n * that is relative to the block wrapper \u2014 i.e., everything after the first\n * compound selector segment.\n *\n * Examples:\n * \".wp-block-button .wp-block-button__link\" \u2192 \".wp-block-button__link\"\n * \".wp-block-foo > .inner\" \u2192 \"> .inner\"\n * \".wp-block-foo\" \u2192 null (no descendant)\n *\n * @param {string} rootSelector The block's `selectors.root` value.\n * @return {string|null} Relative selector, or null if rootSelector targets the wrapper itself.\n */\nexport function getRelativeRootSelector( rootSelector ) {\n\t// Match everything after the first compound selector (up to the first\n\t// whitespace or combinator character).\n\t// Require at least one combinator character (space, >, +, ~) between the\n\t// first compound selector and the rest. Without this anchor, a greedy\n\t// quantifier would backtrack into the first token and produce false matches.\n\tconst match = rootSelector.trim().match( /^[^ >+~]+[ >+~](.*)$/ );\n\tif ( ! match ) {\n\t\treturn null;\n\t}\n\tconst rest = match[ 1 ].trim();\n\treturn rest || null;\n}\n\n/**\n * Builds a scoped selector from a block selector and optional suffix.\n *\n * If the block selector targets a descendant, the descendant portion is scoped\n * under the provided base selector. Otherwise the base selector itself is used.\n *\n * @param {string} baseSelector The block-instance scoping selector.\n * @param {string} blockSelector The block or feature selector from block metadata.\n * @param {string} suffix Optional selector suffix, e.g. \":hover\".\n * @return {string} The scoped CSS selector.\n */\nexport function buildScopedBlockSelector(\n\tbaseSelector,\n\tblockSelector,\n\tsuffix = ''\n) {\n\tif ( typeof blockSelector !== 'string' || ! blockSelector ) {\n\t\treturn splitSelectorList( baseSelector )\n\t\t\t.map( ( selector ) => `${ selector.trim() }${ suffix }` )\n\t\t\t.join( ', ' );\n\t}\n\n\tconst baseSelectors = splitSelectorList( baseSelector ).filter(\n\t\t( selector ) => selector.trim()\n\t);\n\tconst selectors = splitSelectorList( blockSelector ).filter( ( selector ) =>\n\t\tselector.trim()\n\t);\n\n\tif ( ! selectors.length ) {\n\t\treturn baseSelectors\n\t\t\t.map( ( selector ) => `${ selector.trim() }${ suffix }` )\n\t\t\t.join( ', ' );\n\t}\n\n\treturn selectors\n\t\t.map( ( selector ) => {\n\t\t\tselector = selector.trim();\n\n\t\t\t/*\n\t\t\t * Replace only the leading block selector part (e.g. class name,\n\t\t\t * attribute selector, ID, or tag name) with the block instance selector.\n\t\t\t * Preserve anything after that prefix, including modifier classes on the\n\t\t\t * same element and combinators without spaces.\n\t\t\t */\n\t\t\tconst match = selector.match( /^([.#]?[-_a-zA-Z0-9]+|\\[[^\\]]+\\])/ );\n\t\t\tif ( match ) {\n\t\t\t\treturn baseSelectors\n\t\t\t\t\t.map(\n\t\t\t\t\t\t( base ) =>\n\t\t\t\t\t\t\t`${ base.trim() }${ selector.slice(\n\t\t\t\t\t\t\t\tmatch[ 0 ].length\n\t\t\t\t\t\t\t) }${ suffix }`\n\t\t\t\t\t)\n\t\t\t\t\t.join( ', ' );\n\t\t\t}\n\n\t\t\treturn baseSelectors\n\t\t\t\t.map( ( base ) => `${ base.trim() }${ suffix }` )\n\t\t\t\t.join( ', ' );\n\t\t} )\n\t\t.join( ', ' );\n}\n\n/**\n * Builds the scoped selector for root block style state styles.\n *\n * Uses the block's `selectors.root` to determine which element should receive\n * root-level state styles. If `selectors.root` describes a descendant element\n * (e.g. `.wp-block-button .wp-block-button__link`), the relative portion is\n * scoped under `baseSelector`. If no descendant is present, falls back to the\n * base selector.\n *\n * @param {string} baseSelector The block-instance scoping class selector.\n * @param {string} name The block name, used to look up selectors.\n * @return {string} The fully-scoped CSS selector for root state styles.\n */\nexport function buildRootStyleStateSelector( baseSelector, name ) {\n\tconst rootSelector = getBlockType( name )?.selectors?.root;\n\treturn buildScopedBlockSelector( baseSelector, rootSelector );\n}\n\n/**\n * Builds the scoped CSS selector for a block state (e.g. :hover, :focus).\n *\n * Uses the block's `selectors.root` to determine which element the state\n * pseudo-class should apply to. If `selectors.root` describes a descendant\n * element (e.g. \".wp-block-button .wp-block-button__link\"), the relative\n * portion (\".wp-block-button__link\") is scoped under `baseSelector`. If no\n * descendant is present, falls back to appending the state to `baseSelector`.\n *\n * @param {string} baseSelector The block-instance scoping class selector.\n * @param {string} name The block name, used to look up selectors.\n * @param {string} state The pseudo-class string, e.g. \":hover\".\n * @return {string} The fully-scoped CSS selector for this state.\n */\nexport function buildPseudoStyleStateSelector( baseSelector, name, state ) {\n\treturn `${ buildRootStyleStateSelector( baseSelector, name ) }${ state }`;\n}\n\nexport function buildStateSelector( baseSelector, name, state ) {\n\tconst rootSelector = getBlockType( name )?.selectors?.root;\n\treturn buildScopedBlockSelector( baseSelector, rootSelector, state );\n}\n\n/**\n * Builds the CSS selector used to preview a state on the editor canvas,\n * scoped to a specific block instance via its `data-block` attribute.\n *\n * For blocks whose `selectors.root` targets a descendant element\n * (e.g. \".wp-block-button .wp-block-button__link\"), the selector targets\n * that descendant inside the block wrapper. Otherwise it targets the wrapper\n * itself.\n *\n * @param {string} clientId The block's clientId.\n * @param {string} name The block name, used to look up selectors.\n * @return {string} CSS selector scoped to this block instance.\n */\nexport function buildCanvasStateSelector( clientId, name ) {\n\tconst rootSelector = getBlockType( name )?.selectors?.root;\n\treturn buildScopedBlockSelector(\n\t\t`[data-block=\"${ clientId }\"]`,\n\t\trootSelector\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAe3B,SAAS,wBAAyB,cAAe;AAMvD,QAAM,QAAQ,aAAa,KAAK,EAAE,MAAO,sBAAuB;AAChE,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AACA,QAAM,OAAO,MAAO,CAAE,EAAE,KAAK;AAC7B,SAAO,QAAQ;AAChB;AAaO,SAAS,yBACf,cACA,eACA,SAAS,IACR;AACD,MAAK,OAAO,kBAAkB,YAAY,CAAE,eAAgB;AAC3D,WAAO,kBAAmB,YAAa,EACrC,IAAK,CAAE,aAAc,GAAI,SAAS,KAAK,CAAE,GAAI,MAAO,EAAG,EACvD,KAAM,IAAK;AAAA,EACd;AAEA,QAAM,gBAAgB,kBAAmB,YAAa,EAAE;AAAA,IACvD,CAAE,aAAc,SAAS,KAAK;AAAA,EAC/B;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