@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
package/build/hooks/style.cjs
CHANGED
|
@@ -22,12 +22,18 @@ var style_exports = {};
|
|
|
22
22
|
__export(style_exports, {
|
|
23
23
|
addSaveProps: () => addSaveProps,
|
|
24
24
|
default: () => style_default,
|
|
25
|
+
getBlockStateStylesCSS: () => getBlockStateStylesCSS,
|
|
26
|
+
getCanvasStateStyleValue: () => getCanvasStateStyleValue,
|
|
25
27
|
getInlineStyles: () => getInlineStyles,
|
|
28
|
+
getResponsiveStateCSSRules: () => getResponsiveStateCSSRules,
|
|
29
|
+
getStateStylesCSS: () => getStateStylesCSS,
|
|
26
30
|
omitStyle: () => omitStyle
|
|
27
31
|
});
|
|
28
32
|
module.exports = __toCommonJS(style_exports);
|
|
29
33
|
var import_element = require("@wordpress/element");
|
|
30
34
|
var import_hooks = require("@wordpress/hooks");
|
|
35
|
+
var import_data = require("@wordpress/data");
|
|
36
|
+
var import_global_styles_engine = require("@wordpress/global-styles-engine");
|
|
31
37
|
var import_blocks = require("@wordpress/blocks");
|
|
32
38
|
var import_compose = require("@wordpress/compose");
|
|
33
39
|
var import_style_engine = require("@wordpress/style-engine");
|
|
@@ -37,9 +43,20 @@ var import_color = require("./color.cjs");
|
|
|
37
43
|
var import_typography = require("./typography.cjs");
|
|
38
44
|
var import_dimensions = require("./dimensions.cjs");
|
|
39
45
|
var import_utils = require("./utils.cjs");
|
|
46
|
+
var import_block_style_state = require("./block-style-state.cjs");
|
|
47
|
+
var import_states = require("./states.cjs");
|
|
48
|
+
var import_state_utils = require("./state-utils.cjs");
|
|
40
49
|
var import_utils2 = require("../components/global-styles/utils.cjs");
|
|
41
50
|
var import_block_editing_mode = require("../components/block-editing-mode/index.cjs");
|
|
51
|
+
var import_store = require("../store/index.cjs");
|
|
52
|
+
var import_private_keys = require("../store/private-keys.cjs");
|
|
53
|
+
var import_lock_unlock = require("../lock-unlock.cjs");
|
|
42
54
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
55
|
+
var BORDER_SIDES = ["Top", "Right", "Bottom", "Left"];
|
|
56
|
+
var RESPONSIVE_BREAKPOINTS = {
|
|
57
|
+
mobile: "@media (width <= 480px)",
|
|
58
|
+
tablet: "@media (480px < width <= 782px)"
|
|
59
|
+
};
|
|
43
60
|
var styleSupportKeys = [
|
|
44
61
|
...import_typography.TYPOGRAPHY_SUPPORT_KEYS,
|
|
45
62
|
import_border.BORDER_SUPPORT_KEY,
|
|
@@ -57,6 +74,200 @@ function getInlineStyles(styles = {}) {
|
|
|
57
74
|
});
|
|
58
75
|
return output;
|
|
59
76
|
}
|
|
77
|
+
function getStateFallbackBorderStyles(stateStyles) {
|
|
78
|
+
const border = stateStyles?.border;
|
|
79
|
+
if (!border) {
|
|
80
|
+
return void 0;
|
|
81
|
+
}
|
|
82
|
+
const hasBorderStyle = !!border.style;
|
|
83
|
+
const hasBorderColor = !!border.color;
|
|
84
|
+
const hasBorderWidth = !!border.width;
|
|
85
|
+
const fallbackBorder = {};
|
|
86
|
+
if (!hasBorderStyle && (hasBorderColor || hasBorderWidth)) {
|
|
87
|
+
fallbackBorder.style = "solid";
|
|
88
|
+
}
|
|
89
|
+
BORDER_SIDES.forEach((side) => {
|
|
90
|
+
const sideKey = side.toLowerCase();
|
|
91
|
+
const sideBorder = border[sideKey];
|
|
92
|
+
const hasSideStyle = !!sideBorder?.style;
|
|
93
|
+
const hasSideColor = !!sideBorder?.color;
|
|
94
|
+
const hasSideWidth = !!sideBorder?.width;
|
|
95
|
+
if (!hasBorderStyle && !hasSideStyle && (hasSideColor || hasSideWidth)) {
|
|
96
|
+
fallbackBorder[sideKey] = { style: "solid" };
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return (0, import_utils.cleanEmptyObject)({ border: (0, import_utils.cleanEmptyObject)(fallbackBorder) });
|
|
100
|
+
}
|
|
101
|
+
function getStateStylesCSS(stateStyles, selector) {
|
|
102
|
+
const css = (0, import_style_engine.compileCSS)(stateStyles, { selector });
|
|
103
|
+
const importantCSS = css ? css.replace(/;/g, " !important;") : void 0;
|
|
104
|
+
const fallbackBorderStyles = getStateFallbackBorderStyles(stateStyles);
|
|
105
|
+
const fallbackCSS = fallbackBorderStyles ? (0, import_style_engine.compileCSS)(fallbackBorderStyles, { selector }) : void 0;
|
|
106
|
+
return [importantCSS, fallbackCSS].filter(Boolean).join("\n");
|
|
107
|
+
}
|
|
108
|
+
function isPlainObject(value) {
|
|
109
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
110
|
+
}
|
|
111
|
+
function mergeStyleObjects(target = {}, source = {}) {
|
|
112
|
+
const merged = { ...target };
|
|
113
|
+
Object.entries(source).forEach(([key, value]) => {
|
|
114
|
+
merged[key] = isPlainObject(value) && isPlainObject(merged[key]) ? mergeStyleObjects(merged[key], value) : value;
|
|
115
|
+
});
|
|
116
|
+
return merged;
|
|
117
|
+
}
|
|
118
|
+
function addStyleGroup(groups, selector, style) {
|
|
119
|
+
const key = selector || "";
|
|
120
|
+
const existing = groups.get(key) || { selector, style: {} };
|
|
121
|
+
groups.set(key, {
|
|
122
|
+
selector,
|
|
123
|
+
style: mergeStyleObjects(existing.style, style)
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function getStateStyleGroups(stateStyles, name) {
|
|
127
|
+
const blockSelectors = (0, import_blocks.getBlockType)(name)?.selectors || {};
|
|
128
|
+
const groups = /* @__PURE__ */ new Map();
|
|
129
|
+
Object.entries(stateStyles || {}).forEach(
|
|
130
|
+
([feature, featureStyles]) => {
|
|
131
|
+
const featureSelectors = blockSelectors[feature];
|
|
132
|
+
if (typeof featureSelectors === "string") {
|
|
133
|
+
addStyleGroup(groups, featureSelectors, {
|
|
134
|
+
[feature]: featureStyles
|
|
135
|
+
});
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (isPlainObject(featureSelectors) && isPlainObject(featureStyles)) {
|
|
139
|
+
const remainingStyles = { ...featureStyles };
|
|
140
|
+
Object.entries(featureSelectors).forEach(
|
|
141
|
+
([subfeature, subfeatureSelector]) => {
|
|
142
|
+
if (subfeature === "root" || typeof subfeatureSelector !== "string" || !Object.hasOwn(featureStyles, subfeature)) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
addStyleGroup(groups, subfeatureSelector, {
|
|
146
|
+
[feature]: {
|
|
147
|
+
[subfeature]: featureStyles[subfeature]
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
delete remainingStyles[subfeature];
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
if (Object.keys(remainingStyles).length) {
|
|
154
|
+
addStyleGroup(
|
|
155
|
+
groups,
|
|
156
|
+
featureSelectors.root || blockSelectors.root,
|
|
157
|
+
{
|
|
158
|
+
[feature]: remainingStyles
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
addStyleGroup(groups, blockSelectors.root, {
|
|
165
|
+
[feature]: featureStyles
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
return Array.from(groups.values());
|
|
170
|
+
}
|
|
171
|
+
function getBlockStateStylesCSS(stateStyles, options) {
|
|
172
|
+
const { name, baseSelector, state = "" } = options;
|
|
173
|
+
const rules = getStateStyleGroups(stateStyles, name).map(
|
|
174
|
+
({ selector: blockSelector, style }) => getStateStylesCSS(
|
|
175
|
+
style,
|
|
176
|
+
(0, import_state_utils.buildScopedBlockSelector)(baseSelector, blockSelector, state)
|
|
177
|
+
)
|
|
178
|
+
).filter(Boolean);
|
|
179
|
+
return rules.length ? rules.join("\n") : void 0;
|
|
180
|
+
}
|
|
181
|
+
function getRootStateStyles(stateStyles, nestedKeys) {
|
|
182
|
+
if (!stateStyles) {
|
|
183
|
+
return stateStyles;
|
|
184
|
+
}
|
|
185
|
+
const rootStyles = { ...stateStyles };
|
|
186
|
+
nestedKeys.forEach((key) => {
|
|
187
|
+
delete rootStyles[key];
|
|
188
|
+
});
|
|
189
|
+
return rootStyles;
|
|
190
|
+
}
|
|
191
|
+
function getPseudoStateCSSRules(style, name, baseSelector) {
|
|
192
|
+
const validPseudoStates = import_states.VALID_BLOCK_PSEUDO_STATES[name];
|
|
193
|
+
if (!validPseudoStates) {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
const cssRules = [];
|
|
197
|
+
validPseudoStates.forEach((pseudoState) => {
|
|
198
|
+
const stateStyles = style?.[pseudoState];
|
|
199
|
+
if (stateStyles) {
|
|
200
|
+
const css = getBlockStateStylesCSS(stateStyles, {
|
|
201
|
+
name,
|
|
202
|
+
baseSelector,
|
|
203
|
+
state: pseudoState
|
|
204
|
+
});
|
|
205
|
+
if (css) {
|
|
206
|
+
cssRules.push(css);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
return cssRules;
|
|
211
|
+
}
|
|
212
|
+
function getResponsiveStateCSSRules(style, name, baseSelector) {
|
|
213
|
+
const cssRules = [];
|
|
214
|
+
const validPseudoStates = import_states.VALID_BLOCK_PSEUDO_STATES[name] ?? [];
|
|
215
|
+
const nestedStateKeys = ["elements", ...validPseudoStates];
|
|
216
|
+
Object.entries(RESPONSIVE_BREAKPOINTS).forEach(
|
|
217
|
+
([viewport, mediaQuery]) => {
|
|
218
|
+
const viewportStyles = style?.[viewport];
|
|
219
|
+
if (!viewportStyles) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const viewportCSSRules = [];
|
|
223
|
+
const rootCSS = getBlockStateStylesCSS(
|
|
224
|
+
getRootStateStyles(viewportStyles, nestedStateKeys),
|
|
225
|
+
{
|
|
226
|
+
name,
|
|
227
|
+
baseSelector
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
if (rootCSS) {
|
|
231
|
+
viewportCSSRules.push(rootCSS);
|
|
232
|
+
}
|
|
233
|
+
const elementCSS = getElementCSSRules(
|
|
234
|
+
viewportStyles.elements,
|
|
235
|
+
name,
|
|
236
|
+
baseSelector
|
|
237
|
+
);
|
|
238
|
+
if (elementCSS) {
|
|
239
|
+
viewportCSSRules.push(elementCSS);
|
|
240
|
+
}
|
|
241
|
+
viewportCSSRules.push(
|
|
242
|
+
...getPseudoStateCSSRules(viewportStyles, name, baseSelector)
|
|
243
|
+
);
|
|
244
|
+
if (viewportCSSRules.length) {
|
|
245
|
+
cssRules.push(
|
|
246
|
+
`${mediaQuery}{${viewportCSSRules.join("")}}`
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
return cssRules;
|
|
252
|
+
}
|
|
253
|
+
function getCanvasStateStyleValue(style, selectedState) {
|
|
254
|
+
const stateValue = (0, import_block_style_state.getStyleForState)(style, selectedState);
|
|
255
|
+
if (!(0, import_block_style_state.hasViewportBlockStyleState)(selectedState)) {
|
|
256
|
+
return stateValue;
|
|
257
|
+
}
|
|
258
|
+
const defaultViewportState = {
|
|
259
|
+
...selectedState,
|
|
260
|
+
viewport: import_block_style_state.DEFAULT_BLOCK_STYLE_STATE.viewport
|
|
261
|
+
};
|
|
262
|
+
const defaultViewportStateValue = (0, import_block_style_state.getStyleForState)(
|
|
263
|
+
style,
|
|
264
|
+
defaultViewportState
|
|
265
|
+
);
|
|
266
|
+
if (defaultViewportStateValue && stateValue) {
|
|
267
|
+
return (0, import_global_styles_engine.mergeGlobalStyles)(defaultViewportStateValue, stateValue);
|
|
268
|
+
}
|
|
269
|
+
return stateValue || defaultViewportStateValue;
|
|
270
|
+
}
|
|
60
271
|
function addAttribute(settings) {
|
|
61
272
|
if (!hasStyleSupport(settings) && !(0, import_blocks.hasBlockSupport)(settings, "customCSS", true)) {
|
|
62
273
|
return settings;
|
|
@@ -153,28 +364,86 @@ function BlockStyleControls({
|
|
|
153
364
|
clientId,
|
|
154
365
|
name,
|
|
155
366
|
setAttributes,
|
|
367
|
+
style,
|
|
156
368
|
__unstableParentLayout
|
|
157
369
|
}) {
|
|
158
370
|
const settings = (0, import_utils.useBlockSettings)(name, __unstableParentLayout);
|
|
159
371
|
const blockEditingMode = (0, import_block_editing_mode.useBlockEditingMode)();
|
|
372
|
+
const { globalBlockStyles, selectedState, showStateOnCanvas } = (0, import_data.useSelect)(
|
|
373
|
+
(select) => {
|
|
374
|
+
const blockEditorSelect = select(import_store.store);
|
|
375
|
+
const {
|
|
376
|
+
getSelectedBlockStyleState,
|
|
377
|
+
isSelectedBlockStyleStateShownOnCanvas
|
|
378
|
+
} = (0, import_lock_unlock.unlock)(blockEditorSelect);
|
|
379
|
+
const editorSettings = blockEditorSelect.getSettings();
|
|
380
|
+
return {
|
|
381
|
+
globalBlockStyles: editorSettings?.[import_private_keys.globalStylesDataKey]?.blocks?.[name],
|
|
382
|
+
selectedState: getSelectedBlockStyleState(clientId),
|
|
383
|
+
showStateOnCanvas: isSelectedBlockStyleStateShownOnCanvas(clientId)
|
|
384
|
+
};
|
|
385
|
+
},
|
|
386
|
+
[clientId, name]
|
|
387
|
+
);
|
|
388
|
+
const isPseudoSelectorState = (0, import_block_style_state.hasPseudoBlockStyleState)(selectedState);
|
|
389
|
+
const canvasStateCSS = (0, import_element.useMemo)(() => {
|
|
390
|
+
if (!showStateOnCanvas || !isPseudoSelectorState) {
|
|
391
|
+
return void 0;
|
|
392
|
+
}
|
|
393
|
+
const globalStateValue = getCanvasStateStyleValue(
|
|
394
|
+
globalBlockStyles,
|
|
395
|
+
selectedState
|
|
396
|
+
);
|
|
397
|
+
const instanceStateValue = getCanvasStateStyleValue(
|
|
398
|
+
style,
|
|
399
|
+
selectedState
|
|
400
|
+
);
|
|
401
|
+
let stateValue;
|
|
402
|
+
if (globalStateValue && instanceStateValue) {
|
|
403
|
+
stateValue = (0, import_global_styles_engine.mergeGlobalStyles)(
|
|
404
|
+
globalStateValue,
|
|
405
|
+
instanceStateValue
|
|
406
|
+
);
|
|
407
|
+
} else if (instanceStateValue) {
|
|
408
|
+
stateValue = instanceStateValue;
|
|
409
|
+
} else if (globalStateValue) {
|
|
410
|
+
stateValue = globalStateValue;
|
|
411
|
+
} else {
|
|
412
|
+
return void 0;
|
|
413
|
+
}
|
|
414
|
+
return getBlockStateStylesCSS(stateValue, {
|
|
415
|
+
name,
|
|
416
|
+
baseSelector: `[data-block="${clientId}"]`
|
|
417
|
+
});
|
|
418
|
+
}, [
|
|
419
|
+
showStateOnCanvas,
|
|
420
|
+
isPseudoSelectorState,
|
|
421
|
+
globalBlockStyles,
|
|
422
|
+
style,
|
|
423
|
+
selectedState,
|
|
424
|
+
clientId,
|
|
425
|
+
name
|
|
426
|
+
]);
|
|
427
|
+
(0, import_utils.useStyleOverride)({ css: canvasStateCSS });
|
|
428
|
+
if (blockEditingMode !== "default") {
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
const panelSettings = {
|
|
432
|
+
...settings,
|
|
433
|
+
typography: {
|
|
434
|
+
...settings.typography,
|
|
435
|
+
// The text alignment UI for individual blocks is rendered in
|
|
436
|
+
// the block toolbar, so disable it here.
|
|
437
|
+
textAlign: false
|
|
438
|
+
}
|
|
439
|
+
};
|
|
160
440
|
const passedProps = {
|
|
161
441
|
clientId,
|
|
162
442
|
name,
|
|
163
443
|
setAttributes,
|
|
164
|
-
settings:
|
|
165
|
-
...settings,
|
|
166
|
-
typography: {
|
|
167
|
-
...settings.typography,
|
|
168
|
-
// The text alignment UI for individual blocks is rendered in
|
|
169
|
-
// the block toolbar, so disable it here.
|
|
170
|
-
textAlign: false
|
|
171
|
-
}
|
|
172
|
-
}
|
|
444
|
+
settings: panelSettings
|
|
173
445
|
};
|
|
174
|
-
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_block_style_state.BlockStyleStateProvider, { value: selectedState, children: [
|
|
178
447
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_color.ColorEdit, { ...passedProps }),
|
|
179
448
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_background.BackgroundImagePanel, { ...passedProps }),
|
|
180
449
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_typography.TypographyPanel, { ...passedProps }),
|
|
@@ -258,10 +527,24 @@ function useBlockProps({ name, style }) {
|
|
|
258
527
|
);
|
|
259
528
|
const baseElementSelector = `.${blockElementsContainerIdentifier}`;
|
|
260
529
|
const blockElementStyles = style?.elements;
|
|
261
|
-
const styles = (0, import_element.useMemo)(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
530
|
+
const styles = (0, import_element.useMemo)(() => {
|
|
531
|
+
const cssRules = [];
|
|
532
|
+
const elementCSS = getElementCSSRules(
|
|
533
|
+
blockElementStyles,
|
|
534
|
+
name,
|
|
535
|
+
baseElementSelector
|
|
536
|
+
);
|
|
537
|
+
if (elementCSS) {
|
|
538
|
+
cssRules.push(elementCSS);
|
|
539
|
+
}
|
|
540
|
+
cssRules.push(
|
|
541
|
+
...getPseudoStateCSSRules(style, name, baseElementSelector)
|
|
542
|
+
);
|
|
543
|
+
cssRules.push(
|
|
544
|
+
...getResponsiveStateCSSRules(style, name, baseElementSelector)
|
|
545
|
+
);
|
|
546
|
+
return cssRules.length > 0 ? cssRules.join("") : void 0;
|
|
547
|
+
}, [baseElementSelector, blockElementStyles, name, style]);
|
|
265
548
|
(0, import_utils.useStyleOverride)({ css: styles });
|
|
266
549
|
return addSaveProps(
|
|
267
550
|
{ className: blockElementsContainerIdentifier },
|
|
@@ -278,7 +561,11 @@ function useBlockProps({ name, style }) {
|
|
|
278
561
|
// Annotate the CommonJS export names for ESM import in node:
|
|
279
562
|
0 && (module.exports = {
|
|
280
563
|
addSaveProps,
|
|
564
|
+
getBlockStateStylesCSS,
|
|
565
|
+
getCanvasStateStyleValue,
|
|
281
566
|
getInlineStyles,
|
|
567
|
+
getResponsiveStateCSSRules,
|
|
568
|
+
getStateStylesCSS,
|
|
282
569
|
omitStyle
|
|
283
570
|
});
|
|
284
571
|
//# sourceMappingURL=style.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/style.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\t__EXPERIMENTAL_ELEMENTS as ELEMENTS,\n} from '@wordpress/blocks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { getCSSRules, compileCSS } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport { BACKGROUND_SUPPORT_KEY, BackgroundImagePanel } from './background';\nimport { BORDER_SUPPORT_KEY, BorderPanel, SHADOW_SUPPORT_KEY } from './border';\nimport { COLOR_SUPPORT_KEY, ColorEdit } from './color';\nimport {\n\tTypographyPanel,\n\tTYPOGRAPHY_SUPPORT_KEY,\n\tTYPOGRAPHY_SUPPORT_KEYS,\n} from './typography';\nimport {\n\tDIMENSIONS_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n\tDimensionsPanel,\n} from './dimensions';\nimport {\n\tshouldSkipSerialization,\n\tuseStyleOverride,\n\tuseBlockSettings,\n} from './utils';\nimport { scopeSelector } from '../components/global-styles/utils';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\nconst styleSupportKeys = [\n\t...TYPOGRAPHY_SUPPORT_KEYS,\n\tBORDER_SUPPORT_KEY,\n\tCOLOR_SUPPORT_KEY,\n\tDIMENSIONS_SUPPORT_KEY,\n\tBACKGROUND_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n\tSHADOW_SUPPORT_KEY,\n];\n\nconst hasStyleSupport = ( nameOrType ) =>\n\tstyleSupportKeys.some( ( key ) => hasBlockSupport( nameOrType, key ) );\n\n/**\n * Returns the inline styles to add depending on the style object\n *\n * @param {Object} styles Styles configuration.\n *\n * @return {Object} Flattened CSS variables declaration.\n */\nexport function getInlineStyles( styles = {} ) {\n\tconst output = {};\n\t// The goal is to move everything to server side generated engine styles\n\t// This is temporary as we absorb more and more styles into the engine.\n\tgetCSSRules( styles ).forEach( ( rule ) => {\n\t\toutput[ rule.key ] = rule.value;\n\t} );\n\n\treturn output;\n}\n\n/**\n * Filters registered block settings, extending attributes to include `style` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttribute( settings ) {\n\tif (\n\t\t! hasStyleSupport( settings ) &&\n\t\t! hasBlockSupport( settings, 'customCSS', true )\n\t) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsEdit = {\n\t[ `${ BORDER_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [ 'border' ],\n\t[ `${ COLOR_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tCOLOR_SUPPORT_KEY,\n\t],\n\t[ `${ TYPOGRAPHY_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t],\n\t[ `${ DIMENSIONS_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tDIMENSIONS_SUPPORT_KEY,\n\t],\n\t[ `${ SPACING_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tSPACING_SUPPORT_KEY,\n\t],\n\t[ `${ SHADOW_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tSHADOW_SUPPORT_KEY,\n\t],\n};\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * Extends the Edit skip paths to enable skipping additional paths in just\n * the Save component. This allows a block support to be serialized within the\n * editor, while using an alternate approach, such as server-side rendering, when\n * the support is saved.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsSave = {\n\t...skipSerializationPathsEdit,\n\t[ `${ DIMENSIONS_SUPPORT_KEY }.aspectRatio` ]: [\n\t\t`${ DIMENSIONS_SUPPORT_KEY }.aspectRatio`,\n\t], // Skip serialization of aspect ratio in save mode.\n\t[ `${ BACKGROUND_SUPPORT_KEY }` ]: [ BACKGROUND_SUPPORT_KEY ], // Skip serialization of background support in save mode.\n};\n\nconst skipSerializationPathsSaveChecks = {\n\t[ `${ DIMENSIONS_SUPPORT_KEY }.aspectRatio` ]: true,\n\t[ `${ BACKGROUND_SUPPORT_KEY }` ]: true,\n};\n\n/**\n * A dictionary used to normalize feature names between support flags, style\n * object properties and __experimentSkipSerialization configuration arrays.\n *\n * This allows not having to provide a migration for a support flag and possible\n * backwards compatibility bridges, while still achieving consistency between\n * the support flag and the skip serialization array.\n *\n * @constant\n * @type {Record<string, string>}\n */\nconst renamedFeatures = { gradients: 'gradient' };\n\n/**\n * A utility function used to remove one or more paths from a style object.\n * Works in a way similar to Lodash's `omit()`. See unit tests and examples below.\n *\n * It supports a single string path:\n *\n * ```\n * omitStyle( { color: 'red' }, 'color' ); // {}\n * ```\n *\n * or an array of paths:\n *\n * ```\n * omitStyle( { color: 'red', background: '#fff' }, [ 'color', 'background' ] ); // {}\n * ```\n *\n * It also allows you to specify paths at multiple levels in a string.\n *\n * ```\n * omitStyle( { typography: { textDecoration: 'underline' } }, 'typography.textDecoration' ); // {}\n * ```\n *\n * You can remove multiple paths at the same time:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\ttypography: {\n * \t\t\t\ttextDecoration: 'underline',\n * \t\t\t\ttextTransform: 'uppercase',\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t'typography.textDecoration',\n * \t\t\t'typography.textTransform',\n *\t\t]\n * );\n * // {}\n * ```\n *\n * You can also specify nested paths as arrays:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\ttypography: {\n * \t\t\t\ttextDecoration: 'underline',\n * \t\t\t\ttextTransform: 'uppercase',\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t[ 'typography', 'textDecoration' ],\n * \t\t\t[ 'typography', 'textTransform' ],\n *\t\t]\n * );\n * // {}\n * ```\n *\n * With regards to nesting of styles, infinite depth is supported:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\tborder: {\n * \t\t\t\tradius: {\n * \t\t\t\t\ttopLeft: '10px',\n * \t\t\t\t\ttopRight: '0.5rem',\n * \t\t\t\t}\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t[ 'border', 'radius', 'topRight' ],\n *\t\t]\n * );\n * // { border: { radius: { topLeft: '10px' } } }\n * ```\n *\n * The third argument, `preserveReference`, defines how to treat the input style object.\n * It is mostly necessary to properly handle mutation when recursively handling the style object.\n * Defaulting to `false`, this will always create a new object, avoiding to mutate `style`.\n * However, when recursing, we change that value to `true` in order to work with a single copy\n * of the original style object.\n *\n * @see https://lodash.com/docs/4.17.15#omit\n *\n * @param {Object} style Styles object.\n * @param {Array|string} paths Paths to remove.\n * @param {boolean} preserveReference True to mutate the `style` object, false otherwise.\n * @return {Object} Styles object with the specified paths removed.\n */\nexport function omitStyle( style, paths, preserveReference = false ) {\n\tif ( ! style ) {\n\t\treturn style;\n\t}\n\n\tlet newStyle = style;\n\tif ( ! preserveReference ) {\n\t\tnewStyle = JSON.parse( JSON.stringify( style ) );\n\t}\n\n\tif ( ! Array.isArray( paths ) ) {\n\t\tpaths = [ paths ];\n\t}\n\n\tpaths.forEach( ( path ) => {\n\t\tif ( ! Array.isArray( path ) ) {\n\t\t\tpath = path.split( '.' );\n\t\t}\n\n\t\tif ( path.length > 1 ) {\n\t\t\tconst [ firstSubpath, ...restPath ] = path;\n\t\t\tomitStyle( newStyle[ firstSubpath ], [ restPath ], true );\n\t\t} else if ( path.length === 1 ) {\n\t\t\tdelete newStyle[ path[ 0 ] ];\n\t\t}\n\t} );\n\n\treturn newStyle;\n}\n\n/**\n * Override props assigned to save component to inject the CSS variables definition.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object|string} blockNameOrType Block type.\n * @param {Object} attributes Block attributes.\n * @param {?Record<string, string[]>} skipPaths An object of keys and paths to skip serialization.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps(\n\tprops,\n\tblockNameOrType,\n\tattributes,\n\tskipPaths = skipSerializationPathsSave\n) {\n\tif ( ! hasStyleSupport( blockNameOrType ) ) {\n\t\treturn props;\n\t}\n\n\tlet { style } = attributes;\n\tObject.entries( skipPaths ).forEach( ( [ indicator, path ] ) => {\n\t\tconst skipSerialization =\n\t\t\tskipSerializationPathsSaveChecks[ indicator ] ||\n\t\t\tgetBlockSupport( blockNameOrType, indicator );\n\n\t\tif ( skipSerialization === true ) {\n\t\t\tstyle = omitStyle( style, path );\n\t\t}\n\n\t\tif ( Array.isArray( skipSerialization ) ) {\n\t\t\tskipSerialization.forEach( ( featureName ) => {\n\t\t\t\tconst feature = renamedFeatures[ featureName ] || featureName;\n\t\t\t\tstyle = omitStyle( style, [ [ ...path, feature ] ] );\n\t\t\t} );\n\t\t}\n\t} );\n\n\tprops.style = {\n\t\t...getInlineStyles( style ),\n\t\t...props.style,\n\t};\n\n\treturn props;\n}\n\nfunction BlockStyleControls( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\t__unstableParentLayout,\n} ) {\n\tconst settings = useBlockSettings( name, __unstableParentLayout );\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst passedProps = {\n\t\tclientId,\n\t\tname,\n\t\tsetAttributes,\n\t\tsettings: {\n\t\t\t...settings,\n\t\t\ttypography: {\n\t\t\t\t...settings.typography,\n\t\t\t\t// The text alignment UI for individual blocks is rendered in\n\t\t\t\t// the block toolbar, so disable it here.\n\t\t\t\ttextAlign: false,\n\t\t\t},\n\t\t},\n\t};\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<ColorEdit { ...passedProps } />\n\t\t\t<BackgroundImagePanel { ...passedProps } />\n\t\t\t<TypographyPanel { ...passedProps } />\n\t\t\t<BorderPanel { ...passedProps } />\n\t\t\t<DimensionsPanel { ...passedProps } />\n\t\t</>\n\t);\n}\n\nexport default {\n\tedit: BlockStyleControls,\n\thasSupport: hasStyleSupport,\n\taddSaveProps,\n\tattributeKeys: [ 'style' ],\n\tuseBlockProps,\n};\n\n// Defines which element types are supported, including their hover styles or\n// any other elements that have been included under a single element type\n// e.g. heading and h1-h6.\nconst elementTypes = [\n\t{ elementType: 'button' },\n\t{ elementType: 'link', pseudo: [ ':hover' ] },\n\t{\n\t\telementType: 'heading',\n\t\telements: [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ],\n\t},\n];\n\n// Used for generating the instance ID\nconst STYLE_BLOCK_PROPS_REFERENCE = {};\n\n/**\n * Generates CSS rules for block element styles (buttons, links, headings, etc.).\n *\n * Iterates over supported element types and compiles their styles, including\n * pseudo-selectors (e.g. :hover) and related sub-elements (e.g. h1-h6 for headings),\n * into scoped CSS rule strings.\n *\n * @param {Object} blockElementStyles The block's `style.elements` object.\n * @param {string} blockName The block name, used for skip-serialization checks.\n * @param {string} baseSelector The base CSS selector to scope rules under.\n * @return {string|undefined} Concatenated CSS rules string, or undefined if none.\n */\nfunction getElementCSSRules( blockElementStyles, blockName, baseSelector ) {\n\tif ( ! blockElementStyles ) {\n\t\treturn;\n\t}\n\n\tconst rules = [];\n\n\telementTypes.forEach( ( { elementType, pseudo, elements } ) => {\n\t\tconst skipSerialization = shouldSkipSerialization(\n\t\t\tblockName,\n\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\telementType\n\t\t);\n\n\t\tif ( skipSerialization ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst elementStyles = blockElementStyles?.[ elementType ];\n\n\t\t// Process primary element type styles.\n\t\tif ( elementStyles ) {\n\t\t\tconst selector = scopeSelector(\n\t\t\t\tbaseSelector,\n\t\t\t\tELEMENTS[ elementType ]\n\t\t\t);\n\n\t\t\trules.push( compileCSS( elementStyles, { selector } ) );\n\n\t\t\t// Process any interactive states for the element type.\n\t\t\tif ( pseudo ) {\n\t\t\t\tpseudo.forEach( ( pseudoSelector ) => {\n\t\t\t\t\tif ( elementStyles[ pseudoSelector ] ) {\n\t\t\t\t\t\trules.push(\n\t\t\t\t\t\t\tcompileCSS( elementStyles[ pseudoSelector ], {\n\t\t\t\t\t\t\t\tselector: scopeSelector(\n\t\t\t\t\t\t\t\t\tbaseSelector,\n\t\t\t\t\t\t\t\t\t`${ ELEMENTS[ elementType ] }${ pseudoSelector }`\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\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\t// Process related elements e.g. h1-h6 for headings\n\t\tif ( elements ) {\n\t\t\telements.forEach( ( element ) => {\n\t\t\t\tif ( blockElementStyles[ element ] ) {\n\t\t\t\t\trules.push(\n\t\t\t\t\t\tcompileCSS( blockElementStyles[ element ], {\n\t\t\t\t\t\t\tselector: scopeSelector(\n\t\t\t\t\t\t\t\tbaseSelector,\n\t\t\t\t\t\t\t\tELEMENTS[ element ]\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\n\treturn rules.length > 0 ? rules.join( '' ) : undefined;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tconst blockElementsContainerIdentifier = useInstanceId(\n\t\tSTYLE_BLOCK_PROPS_REFERENCE,\n\t\t'wp-elements'\n\t);\n\n\tconst baseElementSelector = `.${ blockElementsContainerIdentifier }`;\n\tconst blockElementStyles = style?.elements;\n\n\tconst styles = useMemo(\n\t\t() =>\n\t\t\tgetElementCSSRules( blockElementStyles, name, baseElementSelector ),\n\t\t[ baseElementSelector, blockElementStyles, name ]\n\t);\n\n\tuseStyleOverride( { css: styles } );\n\n\treturn addSaveProps(\n\t\t{ className: blockElementsContainerIdentifier },\n\t\tname,\n\t\t{ style },\n\t\tskipSerializationPathsEdit\n\t);\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addAttribute',\n\taddAttribute\n);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AACxB,mBAA0B;AAC1B,oBAIO;AACP,qBAA8B;AAC9B,0BAAwC;AAKxC,wBAA6D;AAC7D,oBAAoE;AACpE,mBAA6C;AAC7C,wBAIO;AACP,wBAIO;AACP,mBAIO;AACP,IAAAA,gBAA8B;AAC9B,gCAAoC;AA4TlC;AA1TF,IAAM,mBAAmB;AAAA,EACxB,GAAG;AAAA,EACH;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEA,IAAM,kBAAkB,CAAE,eACzB,iBAAiB,KAAM,CAAE,YAAS,+BAAiB,YAAY,GAAI,CAAE;AAS/D,SAAS,gBAAiB,SAAS,CAAC,GAAI;AAC9C,QAAM,SAAS,CAAC;AAGhB,uCAAa,MAAO,EAAE,QAAS,CAAE,SAAU;AAC1C,WAAQ,KAAK,GAAI,IAAI,KAAK;AAAA,EAC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A,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
|
-
"names": ["import_utils", "ELEMENTS"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport { useSelect } from '@wordpress/data';\nimport { mergeGlobalStyles } from '@wordpress/global-styles-engine';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\thasBlockSupport,\n\t__EXPERIMENTAL_ELEMENTS as ELEMENTS,\n} from '@wordpress/blocks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { getCSSRules, compileCSS } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport { BACKGROUND_SUPPORT_KEY, BackgroundImagePanel } from './background';\nimport { BORDER_SUPPORT_KEY, BorderPanel, SHADOW_SUPPORT_KEY } from './border';\nimport { COLOR_SUPPORT_KEY, ColorEdit } from './color';\nimport {\n\tTypographyPanel,\n\tTYPOGRAPHY_SUPPORT_KEY,\n\tTYPOGRAPHY_SUPPORT_KEYS,\n} from './typography';\nimport {\n\tDIMENSIONS_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n\tDimensionsPanel,\n} from './dimensions';\nimport {\n\tcleanEmptyObject,\n\tshouldSkipSerialization,\n\tuseStyleOverride,\n\tuseBlockSettings,\n} from './utils';\nimport {\n\tBlockStyleStateProvider,\n\tDEFAULT_BLOCK_STYLE_STATE,\n\tgetStyleForState,\n\thasViewportBlockStyleState,\n\thasPseudoBlockStyleState,\n} from './block-style-state';\nimport { VALID_BLOCK_PSEUDO_STATES } from './states';\nimport { buildScopedBlockSelector } from './state-utils';\nimport { scopeSelector } from '../components/global-styles/utils';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { store as blockEditorStore } from '../store';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport { unlock } from '../lock-unlock';\n\nconst BORDER_SIDES = [ 'Top', 'Right', 'Bottom', 'Left' ];\n\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};\n\nconst styleSupportKeys = [\n\t...TYPOGRAPHY_SUPPORT_KEYS,\n\tBORDER_SUPPORT_KEY,\n\tCOLOR_SUPPORT_KEY,\n\tDIMENSIONS_SUPPORT_KEY,\n\tBACKGROUND_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n\tSHADOW_SUPPORT_KEY,\n];\n\nconst hasStyleSupport = ( nameOrType ) =>\n\tstyleSupportKeys.some( ( key ) => hasBlockSupport( nameOrType, key ) );\n\n/**\n * Returns the inline styles to add depending on the style object\n *\n * @param {Object} styles Styles configuration.\n *\n * @return {Object} Flattened CSS variables declaration.\n */\nexport function getInlineStyles( styles = {} ) {\n\tconst output = {};\n\t// The goal is to move everything to server side generated engine styles\n\t// This is temporary as we absorb more and more styles into the engine.\n\tgetCSSRules( styles ).forEach( ( rule ) => {\n\t\toutput[ rule.key ] = rule.value;\n\t} );\n\n\treturn output;\n}\n\n/**\n * Returns fallback border styles for visible state border styles.\n *\n * State styles are emitted as stylesheet rules rather than inline styles, so\n * they cannot rely on the block-library inline-style attribute fallback rules.\n *\n * @param {Object} stateStyles State style object.\n * @return {Object|undefined} Style object containing fallback border styles.\n */\nfunction getStateFallbackBorderStyles( stateStyles ) {\n\tconst border = stateStyles?.border;\n\tif ( ! border ) {\n\t\treturn undefined;\n\t}\n\n\tconst hasBorderStyle = !! border.style;\n\tconst hasBorderColor = !! border.color;\n\tconst hasBorderWidth = !! border.width;\n\tconst fallbackBorder = {};\n\n\tif ( ! hasBorderStyle && ( hasBorderColor || hasBorderWidth ) ) {\n\t\tfallbackBorder.style = 'solid';\n\t}\n\n\tBORDER_SIDES.forEach( ( side ) => {\n\t\tconst sideKey = side.toLowerCase();\n\t\tconst sideBorder = border[ sideKey ];\n\t\tconst hasSideStyle = !! sideBorder?.style;\n\t\tconst hasSideColor = !! sideBorder?.color;\n\t\tconst hasSideWidth = !! sideBorder?.width;\n\n\t\tif (\n\t\t\t! hasBorderStyle &&\n\t\t\t! hasSideStyle &&\n\t\t\t( hasSideColor || hasSideWidth )\n\t\t) {\n\t\t\tfallbackBorder[ sideKey ] = { style: 'solid' };\n\t\t}\n\t} );\n\n\treturn cleanEmptyObject( { border: cleanEmptyObject( fallbackBorder ) } );\n}\n\n/**\n * Generates CSS for a block instance state style object.\n *\n * State declarations need to win over preset utility classes, but fallback\n * border styles should not become important because they must not override\n * explicitly authored default border styles.\n *\n * @param {Object} stateStyles State style object.\n * @param {string} selector CSS selector for the generated style.\n * @return {string} Generated stylesheet.\n */\nexport function getStateStylesCSS( stateStyles, selector ) {\n\tconst css = compileCSS( stateStyles, { selector } );\n\tconst importantCSS = css ? css.replace( /;/g, ' !important;' ) : undefined;\n\tconst fallbackBorderStyles = getStateFallbackBorderStyles( stateStyles );\n\tconst fallbackCSS = fallbackBorderStyles\n\t\t? compileCSS( fallbackBorderStyles, { selector } )\n\t\t: undefined;\n\n\treturn [ importantCSS, fallbackCSS ].filter( Boolean ).join( '\\n' );\n}\n\nfunction isPlainObject( value ) {\n\treturn !! value && typeof value === 'object' && ! Array.isArray( value );\n}\n\nfunction mergeStyleObjects( target = {}, source = {} ) {\n\tconst merged = { ...target };\n\n\tObject.entries( source ).forEach( ( [ key, value ] ) => {\n\t\tmerged[ key ] =\n\t\t\tisPlainObject( value ) && isPlainObject( merged[ key ] )\n\t\t\t\t? mergeStyleObjects( merged[ key ], value )\n\t\t\t\t: value;\n\t} );\n\n\treturn merged;\n}\n\nfunction addStyleGroup( groups, selector, style ) {\n\tconst key = selector || '';\n\tconst existing = groups.get( key ) || { selector, style: {} };\n\n\tgroups.set( key, {\n\t\tselector,\n\t\tstyle: mergeStyleObjects( existing.style, style ),\n\t} );\n}\n\nfunction getStateStyleGroups( stateStyles, name ) {\n\tconst blockSelectors = getBlockType( name )?.selectors || {};\n\tconst groups = new Map();\n\n\tObject.entries( stateStyles || {} ).forEach(\n\t\t( [ feature, featureStyles ] ) => {\n\t\t\tconst featureSelectors = blockSelectors[ feature ];\n\n\t\t\tif ( typeof featureSelectors === 'string' ) {\n\t\t\t\taddStyleGroup( groups, featureSelectors, {\n\t\t\t\t\t[ feature ]: featureStyles,\n\t\t\t\t} );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tisPlainObject( featureSelectors ) &&\n\t\t\t\tisPlainObject( featureStyles )\n\t\t\t) {\n\t\t\t\tconst remainingStyles = { ...featureStyles };\n\n\t\t\t\tObject.entries( featureSelectors ).forEach(\n\t\t\t\t\t( [ subfeature, subfeatureSelector ] ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tsubfeature === 'root' ||\n\t\t\t\t\t\t\ttypeof subfeatureSelector !== 'string' ||\n\t\t\t\t\t\t\t! Object.hasOwn( featureStyles, subfeature )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\taddStyleGroup( groups, subfeatureSelector, {\n\t\t\t\t\t\t\t[ feature ]: {\n\t\t\t\t\t\t\t\t[ subfeature ]: featureStyles[ subfeature ],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tdelete remainingStyles[ subfeature ];\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tif ( Object.keys( remainingStyles ).length ) {\n\t\t\t\t\taddStyleGroup(\n\t\t\t\t\t\tgroups,\n\t\t\t\t\t\tfeatureSelectors.root || blockSelectors.root,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[ feature ]: remainingStyles,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\taddStyleGroup( groups, blockSelectors.root, {\n\t\t\t\t[ feature ]: featureStyles,\n\t\t\t} );\n\t\t}\n\t);\n\n\treturn Array.from( groups.values() );\n}\n\n/**\n * Generates CSS for block instance state styles, honoring feature selectors.\n *\n * @param {Object} stateStyles State style object.\n * @param {Object} options Generation options.\n * @param {string} options.name Block name.\n * @param {string} options.baseSelector Block-instance scoping selector.\n * @param {string=} options.state Optional pseudo-state, e.g. \":hover\".\n * @return {string|undefined} Generated stylesheet.\n */\nexport function getBlockStateStylesCSS( stateStyles, options ) {\n\tconst { name, baseSelector, state = '' } = options;\n\tconst rules = getStateStyleGroups( stateStyles, name )\n\t\t.map( ( { selector: blockSelector, style } ) =>\n\t\t\tgetStateStylesCSS(\n\t\t\t\tstyle,\n\t\t\t\tbuildScopedBlockSelector( baseSelector, blockSelector, state )\n\t\t\t)\n\t\t)\n\t\t.filter( Boolean );\n\n\treturn rules.length ? rules.join( '\\n' ) : undefined;\n}\n\n/**\n * Returns a style object with nested state/element keys removed.\n *\n * Viewport state objects can contain root declarations alongside nested\n * `elements` and pseudo-state styles. Only root declarations should be passed\n * to the style engine for the viewport root selector.\n *\n * @param {Object} stateStyles Style object for a selected state.\n * @param {string[]} nestedKeys Keys to remove from the root style object.\n * @return {Object|undefined} Root-only style object.\n */\nfunction getRootStateStyles( stateStyles, nestedKeys ) {\n\tif ( ! stateStyles ) {\n\t\treturn stateStyles;\n\t}\n\n\tconst rootStyles = { ...stateStyles };\n\tnestedKeys.forEach( ( key ) => {\n\t\tdelete rootStyles[ key ];\n\t} );\n\treturn rootStyles;\n}\n\n/**\n * Generates CSS rules for supported pseudo-state styles.\n *\n * @param {Object} style Block style object containing pseudo-state styles.\n * @param {string} name Block name.\n * @param {string} baseSelector Base selector used to scope generated CSS.\n * @return {string[]} Generated CSS rule strings.\n */\nfunction getPseudoStateCSSRules( style, name, baseSelector ) {\n\tconst validPseudoStates = VALID_BLOCK_PSEUDO_STATES[ name ];\n\tif ( ! validPseudoStates ) {\n\t\treturn [];\n\t}\n\n\tconst cssRules = [];\n\tvalidPseudoStates.forEach( ( pseudoState ) => {\n\t\tconst stateStyles = style?.[ pseudoState ];\n\t\tif ( stateStyles ) {\n\t\t\tconst css = getBlockStateStylesCSS( stateStyles, {\n\t\t\t\tname,\n\t\t\t\tbaseSelector,\n\t\t\t\tstate: pseudoState,\n\t\t\t} );\n\t\t\tif ( css ) {\n\t\t\t\tcssRules.push( css );\n\t\t\t}\n\t\t}\n\t} );\n\treturn cssRules;\n}\n\n/**\n * Generates CSS rules for responsive block instance style states.\n *\n * Each responsive state can contain root styles, element styles, and nested\n * pseudo-state styles. Generated rules are wrapped in the matching breakpoint\n * media query.\n *\n * @param {Object} style Block style object containing responsive states.\n * @param {string} name Block name.\n * @param {string} baseSelector Base selector used to scope generated CSS.\n * @return {string[]} Generated CSS rule strings.\n */\nexport function getResponsiveStateCSSRules( style, name, baseSelector ) {\n\tconst cssRules = [];\n\tconst validPseudoStates = VALID_BLOCK_PSEUDO_STATES[ name ] ?? [];\n\tconst nestedStateKeys = [ 'elements', ...validPseudoStates ];\n\n\tObject.entries( RESPONSIVE_BREAKPOINTS ).forEach(\n\t\t( [ viewport, mediaQuery ] ) => {\n\t\t\tconst viewportStyles = style?.[ viewport ];\n\t\t\tif ( ! viewportStyles ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst viewportCSSRules = [];\n\t\t\tconst rootCSS = getBlockStateStylesCSS(\n\t\t\t\tgetRootStateStyles( viewportStyles, nestedStateKeys ),\n\t\t\t\t{\n\t\t\t\t\tname,\n\t\t\t\t\tbaseSelector,\n\t\t\t\t}\n\t\t\t);\n\t\t\tif ( rootCSS ) {\n\t\t\t\tviewportCSSRules.push( rootCSS );\n\t\t\t}\n\n\t\t\tconst elementCSS = getElementCSSRules(\n\t\t\t\tviewportStyles.elements,\n\t\t\t\tname,\n\t\t\t\tbaseSelector\n\t\t\t);\n\t\t\tif ( elementCSS ) {\n\t\t\t\tviewportCSSRules.push( elementCSS );\n\t\t\t}\n\n\t\t\tviewportCSSRules.push(\n\t\t\t\t...getPseudoStateCSSRules( viewportStyles, name, baseSelector )\n\t\t\t);\n\n\t\t\tif ( viewportCSSRules.length ) {\n\t\t\t\tcssRules.push(\n\t\t\t\t\t`${ mediaQuery }{${ viewportCSSRules.join( '' ) }}`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t);\n\n\treturn cssRules;\n}\n\n/**\n * Returns the style value used to force-preview a selected state on canvas.\n *\n * Responsive pseudo states inherit from their default-viewport pseudo state.\n * For example, selecting `mobile + :hover` should preview styles from\n * `:hover`, with `mobile.:hover` values layered on top when present.\n *\n * @param {Object} style Block style object.\n * @param {Object} selectedState Selected block style state.\n * @return {Object|undefined} Style value for the canvas preview.\n */\nexport function getCanvasStateStyleValue( style, selectedState ) {\n\tconst stateValue = getStyleForState( style, selectedState );\n\tif ( ! hasViewportBlockStyleState( selectedState ) ) {\n\t\treturn stateValue;\n\t}\n\n\tconst defaultViewportState = {\n\t\t...selectedState,\n\t\tviewport: DEFAULT_BLOCK_STYLE_STATE.viewport,\n\t};\n\tconst defaultViewportStateValue = getStyleForState(\n\t\tstyle,\n\t\tdefaultViewportState\n\t);\n\n\tif ( defaultViewportStateValue && stateValue ) {\n\t\treturn mergeGlobalStyles( defaultViewportStateValue, stateValue );\n\t}\n\treturn stateValue || defaultViewportStateValue;\n}\n\n/**\n * Filters registered block settings, extending attributes to include `style` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttribute( settings ) {\n\tif (\n\t\t! hasStyleSupport( settings ) &&\n\t\t! hasBlockSupport( settings, 'customCSS', true )\n\t) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsEdit = {\n\t[ `${ BORDER_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [ 'border' ],\n\t[ `${ COLOR_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tCOLOR_SUPPORT_KEY,\n\t],\n\t[ `${ TYPOGRAPHY_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t],\n\t[ `${ DIMENSIONS_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tDIMENSIONS_SUPPORT_KEY,\n\t],\n\t[ `${ SPACING_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tSPACING_SUPPORT_KEY,\n\t],\n\t[ `${ SHADOW_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tSHADOW_SUPPORT_KEY,\n\t],\n};\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * Extends the Edit skip paths to enable skipping additional paths in just\n * the Save component. This allows a block support to be serialized within the\n * editor, while using an alternate approach, such as server-side rendering, when\n * the support is saved.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsSave = {\n\t...skipSerializationPathsEdit,\n\t[ `${ DIMENSIONS_SUPPORT_KEY }.aspectRatio` ]: [\n\t\t`${ DIMENSIONS_SUPPORT_KEY }.aspectRatio`,\n\t], // Skip serialization of aspect ratio in save mode.\n\t[ `${ BACKGROUND_SUPPORT_KEY }` ]: [ BACKGROUND_SUPPORT_KEY ], // Skip serialization of background support in save mode.\n};\n\nconst skipSerializationPathsSaveChecks = {\n\t[ `${ DIMENSIONS_SUPPORT_KEY }.aspectRatio` ]: true,\n\t[ `${ BACKGROUND_SUPPORT_KEY }` ]: true,\n};\n\n/**\n * A dictionary used to normalize feature names between support flags, style\n * object properties and __experimentSkipSerialization configuration arrays.\n *\n * This allows not having to provide a migration for a support flag and possible\n * backwards compatibility bridges, while still achieving consistency between\n * the support flag and the skip serialization array.\n *\n * @constant\n * @type {Record<string, string>}\n */\nconst renamedFeatures = { gradients: 'gradient' };\n\n/**\n * A utility function used to remove one or more paths from a style object.\n * Works in a way similar to Lodash's `omit()`. See unit tests and examples below.\n *\n * It supports a single string path:\n *\n * ```\n * omitStyle( { color: 'red' }, 'color' ); // {}\n * ```\n *\n * or an array of paths:\n *\n * ```\n * omitStyle( { color: 'red', background: '#fff' }, [ 'color', 'background' ] ); // {}\n * ```\n *\n * It also allows you to specify paths at multiple levels in a string.\n *\n * ```\n * omitStyle( { typography: { textDecoration: 'underline' } }, 'typography.textDecoration' ); // {}\n * ```\n *\n * You can remove multiple paths at the same time:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\ttypography: {\n * \t\t\t\ttextDecoration: 'underline',\n * \t\t\t\ttextTransform: 'uppercase',\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t'typography.textDecoration',\n * \t\t\t'typography.textTransform',\n *\t\t]\n * );\n * // {}\n * ```\n *\n * You can also specify nested paths as arrays:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\ttypography: {\n * \t\t\t\ttextDecoration: 'underline',\n * \t\t\t\ttextTransform: 'uppercase',\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t[ 'typography', 'textDecoration' ],\n * \t\t\t[ 'typography', 'textTransform' ],\n *\t\t]\n * );\n * // {}\n * ```\n *\n * With regards to nesting of styles, infinite depth is supported:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\tborder: {\n * \t\t\t\tradius: {\n * \t\t\t\t\ttopLeft: '10px',\n * \t\t\t\t\ttopRight: '0.5rem',\n * \t\t\t\t}\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t[ 'border', 'radius', 'topRight' ],\n *\t\t]\n * );\n * // { border: { radius: { topLeft: '10px' } } }\n * ```\n *\n * The third argument, `preserveReference`, defines how to treat the input style object.\n * It is mostly necessary to properly handle mutation when recursively handling the style object.\n * Defaulting to `false`, this will always create a new object, avoiding to mutate `style`.\n * However, when recursing, we change that value to `true` in order to work with a single copy\n * of the original style object.\n *\n * @see https://lodash.com/docs/4.17.15#omit\n *\n * @param {Object} style Styles object.\n * @param {Array|string} paths Paths to remove.\n * @param {boolean} preserveReference True to mutate the `style` object, false otherwise.\n * @return {Object} Styles object with the specified paths removed.\n */\nexport function omitStyle( style, paths, preserveReference = false ) {\n\tif ( ! style ) {\n\t\treturn style;\n\t}\n\n\tlet newStyle = style;\n\tif ( ! preserveReference ) {\n\t\tnewStyle = JSON.parse( JSON.stringify( style ) );\n\t}\n\n\tif ( ! Array.isArray( paths ) ) {\n\t\tpaths = [ paths ];\n\t}\n\n\tpaths.forEach( ( path ) => {\n\t\tif ( ! Array.isArray( path ) ) {\n\t\t\tpath = path.split( '.' );\n\t\t}\n\n\t\tif ( path.length > 1 ) {\n\t\t\tconst [ firstSubpath, ...restPath ] = path;\n\t\t\tomitStyle( newStyle[ firstSubpath ], [ restPath ], true );\n\t\t} else if ( path.length === 1 ) {\n\t\t\tdelete newStyle[ path[ 0 ] ];\n\t\t}\n\t} );\n\n\treturn newStyle;\n}\n\n/**\n * Override props assigned to save component to inject the CSS variables definition.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object|string} blockNameOrType Block type.\n * @param {Object} attributes Block attributes.\n * @param {?Record<string, string[]>} skipPaths An object of keys and paths to skip serialization.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps(\n\tprops,\n\tblockNameOrType,\n\tattributes,\n\tskipPaths = skipSerializationPathsSave\n) {\n\tif ( ! hasStyleSupport( blockNameOrType ) ) {\n\t\treturn props;\n\t}\n\n\tlet { style } = attributes;\n\tObject.entries( skipPaths ).forEach( ( [ indicator, path ] ) => {\n\t\tconst skipSerialization =\n\t\t\tskipSerializationPathsSaveChecks[ indicator ] ||\n\t\t\tgetBlockSupport( blockNameOrType, indicator );\n\n\t\tif ( skipSerialization === true ) {\n\t\t\tstyle = omitStyle( style, path );\n\t\t}\n\n\t\tif ( Array.isArray( skipSerialization ) ) {\n\t\t\tskipSerialization.forEach( ( featureName ) => {\n\t\t\t\tconst feature = renamedFeatures[ featureName ] || featureName;\n\t\t\t\tstyle = omitStyle( style, [ [ ...path, feature ] ] );\n\t\t\t} );\n\t\t}\n\t} );\n\n\tprops.style = {\n\t\t...getInlineStyles( style ),\n\t\t...props.style,\n\t};\n\n\treturn props;\n}\n\nfunction BlockStyleControls( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\tstyle,\n\t__unstableParentLayout,\n} ) {\n\tconst settings = useBlockSettings( name, __unstableParentLayout );\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst { globalBlockStyles, selectedState, showStateOnCanvas } = useSelect(\n\t\t( select ) => {\n\t\t\tconst blockEditorSelect = select( blockEditorStore );\n\t\t\tconst {\n\t\t\t\tgetSelectedBlockStyleState,\n\t\t\t\tisSelectedBlockStyleStateShownOnCanvas,\n\t\t\t} = unlock( blockEditorSelect );\n\t\t\tconst editorSettings = blockEditorSelect.getSettings();\n\t\t\treturn {\n\t\t\t\tglobalBlockStyles:\n\t\t\t\t\teditorSettings?.[ globalStylesDataKey ]?.blocks?.[ name ],\n\t\t\t\tselectedState: getSelectedBlockStyleState( clientId ),\n\t\t\t\tshowStateOnCanvas:\n\t\t\t\t\tisSelectedBlockStyleStateShownOnCanvas( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, name ]\n\t);\n\tconst isPseudoSelectorState = hasPseudoBlockStyleState( selectedState );\n\n\t// Inject state styles onto the editor canvas so the selected state is\n\t// visible while editing. Scoped to this block instance via data-block so\n\t// other blocks of the same type are not affected. Must be called before\n\t// any early returns because it is a hook.\n\tconst canvasStateCSS = useMemo( () => {\n\t\tif ( ! showStateOnCanvas || ! isPseudoSelectorState ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst globalStateValue = getCanvasStateStyleValue(\n\t\t\tglobalBlockStyles,\n\t\t\tselectedState\n\t\t);\n\t\tconst instanceStateValue = getCanvasStateStyleValue(\n\t\t\tstyle,\n\t\t\tselectedState\n\t\t);\n\t\tlet stateValue;\n\n\t\tif ( globalStateValue && instanceStateValue ) {\n\t\t\tstateValue = mergeGlobalStyles(\n\t\t\t\tglobalStateValue,\n\t\t\t\tinstanceStateValue\n\t\t\t);\n\t\t} else if ( instanceStateValue ) {\n\t\t\tstateValue = instanceStateValue;\n\t\t} else if ( globalStateValue ) {\n\t\t\tstateValue = globalStateValue;\n\t\t} else {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn getBlockStateStylesCSS( stateValue, {\n\t\t\tname,\n\t\t\tbaseSelector: `[data-block=\"${ clientId }\"]`,\n\t\t} );\n\t}, [\n\t\tshowStateOnCanvas,\n\t\tisPseudoSelectorState,\n\t\tglobalBlockStyles,\n\t\tstyle,\n\t\tselectedState,\n\t\tclientId,\n\t\tname,\n\t] );\n\tuseStyleOverride( { css: canvasStateCSS } );\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\tconst panelSettings = {\n\t\t...settings,\n\t\ttypography: {\n\t\t\t...settings.typography,\n\t\t\t// The text alignment UI for individual blocks is rendered in\n\t\t\t// the block toolbar, so disable it here.\n\t\t\ttextAlign: false,\n\t\t},\n\t};\n\n\tconst passedProps = {\n\t\tclientId,\n\t\tname,\n\t\tsetAttributes,\n\t\tsettings: panelSettings,\n\t};\n\n\treturn (\n\t\t<BlockStyleStateProvider value={ selectedState }>\n\t\t\t<ColorEdit { ...passedProps } />\n\t\t\t<BackgroundImagePanel { ...passedProps } />\n\t\t\t<TypographyPanel { ...passedProps } />\n\t\t\t<BorderPanel { ...passedProps } />\n\t\t\t<DimensionsPanel { ...passedProps } />\n\t\t</BlockStyleStateProvider>\n\t);\n}\n\nexport default {\n\tedit: BlockStyleControls,\n\thasSupport: hasStyleSupport,\n\taddSaveProps,\n\tattributeKeys: [ 'style' ],\n\tuseBlockProps,\n};\n\n// Defines which element types are supported, including their hover styles or\n// any other elements that have been included under a single element type\n// e.g. heading and h1-h6.\nconst elementTypes = [\n\t{ elementType: 'button' },\n\t{ elementType: 'link', pseudo: [ ':hover' ] },\n\t{\n\t\telementType: 'heading',\n\t\telements: [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ],\n\t},\n];\n\n// Used for generating the instance ID\nconst STYLE_BLOCK_PROPS_REFERENCE = {};\n\n/**\n * Generates CSS rules for block element styles (buttons, links, headings, etc.).\n *\n * Iterates over supported element types and compiles their styles, including\n * pseudo-selectors (e.g. :hover) and related sub-elements (e.g. h1-h6 for headings),\n * into scoped CSS rule strings.\n *\n * @param {Object} blockElementStyles The block's `style.elements` object.\n * @param {string} blockName The block name, used for skip-serialization checks.\n * @param {string} baseSelector The base CSS selector to scope rules under.\n * @return {string|undefined} Concatenated CSS rules string, or undefined if none.\n */\nfunction getElementCSSRules( blockElementStyles, blockName, baseSelector ) {\n\tif ( ! blockElementStyles ) {\n\t\treturn;\n\t}\n\n\tconst rules = [];\n\n\telementTypes.forEach( ( { elementType, pseudo, elements } ) => {\n\t\tconst skipSerialization = shouldSkipSerialization(\n\t\t\tblockName,\n\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\telementType\n\t\t);\n\n\t\tif ( skipSerialization ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst elementStyles = blockElementStyles?.[ elementType ];\n\n\t\t// Process primary element type styles.\n\t\tif ( elementStyles ) {\n\t\t\tconst selector = scopeSelector(\n\t\t\t\tbaseSelector,\n\t\t\t\tELEMENTS[ elementType ]\n\t\t\t);\n\n\t\t\trules.push( compileCSS( elementStyles, { selector } ) );\n\n\t\t\t// Process any interactive states for the element type.\n\t\t\tif ( pseudo ) {\n\t\t\t\tpseudo.forEach( ( pseudoSelector ) => {\n\t\t\t\t\tif ( elementStyles[ pseudoSelector ] ) {\n\t\t\t\t\t\trules.push(\n\t\t\t\t\t\t\tcompileCSS( elementStyles[ pseudoSelector ], {\n\t\t\t\t\t\t\t\tselector: scopeSelector(\n\t\t\t\t\t\t\t\t\tbaseSelector,\n\t\t\t\t\t\t\t\t\t`${ ELEMENTS[ elementType ] }${ pseudoSelector }`\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\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\t// Process related elements e.g. h1-h6 for headings\n\t\tif ( elements ) {\n\t\t\telements.forEach( ( element ) => {\n\t\t\t\tif ( blockElementStyles[ element ] ) {\n\t\t\t\t\trules.push(\n\t\t\t\t\t\tcompileCSS( blockElementStyles[ element ], {\n\t\t\t\t\t\t\tselector: scopeSelector(\n\t\t\t\t\t\t\t\tbaseSelector,\n\t\t\t\t\t\t\t\tELEMENTS[ element ]\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\n\treturn rules.length > 0 ? rules.join( '' ) : undefined;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tconst blockElementsContainerIdentifier = useInstanceId(\n\t\tSTYLE_BLOCK_PROPS_REFERENCE,\n\t\t'wp-elements'\n\t);\n\n\tconst baseElementSelector = `.${ blockElementsContainerIdentifier }`;\n\tconst blockElementStyles = style?.elements;\n\n\tconst styles = useMemo( () => {\n\t\tconst cssRules = [];\n\n\t\tconst elementCSS = getElementCSSRules(\n\t\t\tblockElementStyles,\n\t\t\tname,\n\t\t\tbaseElementSelector\n\t\t);\n\t\tif ( elementCSS ) {\n\t\t\tcssRules.push( elementCSS );\n\t\t}\n\n\t\tcssRules.push(\n\t\t\t...getPseudoStateCSSRules( style, name, baseElementSelector )\n\t\t);\n\n\t\tcssRules.push(\n\t\t\t...getResponsiveStateCSSRules( style, name, baseElementSelector )\n\t\t);\n\n\t\treturn cssRules.length > 0 ? cssRules.join( '' ) : undefined;\n\t}, [ baseElementSelector, blockElementStyles, name, style ] );\n\n\tuseStyleOverride( { css: styles } );\n\n\treturn addSaveProps(\n\t\t{ className: blockElementsContainerIdentifier },\n\t\tname,\n\t\t{ style },\n\t\tskipSerializationPathsEdit\n\t);\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addAttribute',\n\taddAttribute\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AACxB,mBAA0B;AAC1B,kBAA0B;AAC1B,kCAAkC;AAClC,oBAKO;AACP,qBAA8B;AAC9B,0BAAwC;AAKxC,wBAA6D;AAC7D,oBAAoE;AACpE,mBAA6C;AAC7C,wBAIO;AACP,wBAIO;AACP,mBAKO;AACP,+BAMO;AACP,oBAA0C;AAC1C,yBAAyC;AACzC,IAAAA,gBAA8B;AAC9B,gCAAoC;AACpC,mBAA0C;AAC1C,0BAAoC;AACpC,yBAAuB;AAgtBrB;AA9sBF,IAAM,eAAe,CAAE,OAAO,SAAS,UAAU,MAAO;AAIxD,IAAM,yBAAyB;AAAA,EAC9B,QAAQ;AAAA,EACR,QAAQ;AACT;AAEA,IAAM,mBAAmB;AAAA,EACxB,GAAG;AAAA,EACH;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEA,IAAM,kBAAkB,CAAE,eACzB,iBAAiB,KAAM,CAAE,YAAS,+BAAiB,YAAY,GAAI,CAAE;AAS/D,SAAS,gBAAiB,SAAS,CAAC,GAAI;AAC9C,QAAM,SAAS,CAAC;AAGhB,uCAAa,MAAO,EAAE,QAAS,CAAE,SAAU;AAC1C,WAAQ,KAAK,GAAI,IAAI,KAAK;AAAA,EAC3B,CAAE;AAEF,SAAO;AACR;AAWA,SAAS,6BAA8B,aAAc;AACpD,QAAM,SAAS,aAAa;AAC5B,MAAK,CAAE,QAAS;AACf,WAAO;AAAA,EACR;AAEA,QAAM,iBAAiB,CAAC,CAAE,OAAO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K,OAAO,CAAE;AAElC,SAAO;AAAA,IACN,EAAE,WAAW,iCAAiC;AAAA,IAC9C;AAAA,IACA,EAAE,MAAM;AAAA,IACR;AAAA,EACD;AACD;AAAA,IAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
|
+
"names": ["import_utils", "blockEditorStore", "ELEMENTS"]
|
|
7
7
|
}
|
|
@@ -48,6 +48,7 @@ var import_text_align = require("./text-align.cjs");
|
|
|
48
48
|
var import_fit_text = require("./fit-text.cjs");
|
|
49
49
|
var import_utils = require("./utils.cjs");
|
|
50
50
|
var import_store = require("../store/index.cjs");
|
|
51
|
+
var import_block_style_state = require("./block-style-state.cjs");
|
|
51
52
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
53
|
function omit(object, keys) {
|
|
53
54
|
return Object.fromEntries(
|
|
@@ -128,6 +129,7 @@ function TypographyInspectorControl({ children, resetAllFilter }) {
|
|
|
128
129
|
);
|
|
129
130
|
}
|
|
130
131
|
function TypographyPanel({ clientId, name, setAttributes, settings }) {
|
|
132
|
+
const selectedState = (0, import_block_style_state.useBlockStyleState)();
|
|
131
133
|
const isEnabled = (0, import_typography_panel.useHasTypographyPanel)(settings);
|
|
132
134
|
const { style, fontFamily, fontSize, fitText } = (0, import_data.useSelect)(
|
|
133
135
|
(select) => {
|
|
@@ -149,11 +151,18 @@ function TypographyPanel({ clientId, name, setAttributes, settings }) {
|
|
|
149
151
|
},
|
|
150
152
|
[clientId, isEnabled]
|
|
151
153
|
);
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
const isStateSelected = !(0, import_block_style_state.isDefaultBlockStyleState)(selectedState);
|
|
155
|
+
const value = (0, import_element.useMemo)(() => {
|
|
156
|
+
if (isStateSelected) {
|
|
157
|
+
return (0, import_block_style_state.getStyleForState)(style, selectedState);
|
|
158
|
+
}
|
|
159
|
+
return attributesToStyle({ style, fontFamily, fontSize });
|
|
160
|
+
}, [isStateSelected, selectedState, style, fontSize, fontFamily]);
|
|
161
|
+
const onChange = isStateSelected ? (newStyle) => {
|
|
162
|
+
setAttributes({
|
|
163
|
+
style: (0, import_block_style_state.setStyleForState)(style, selectedState, newStyle)
|
|
164
|
+
});
|
|
165
|
+
} : (newStyle) => {
|
|
157
166
|
const newAttributes = styleToAttributes(newStyle);
|
|
158
167
|
const hasFontSize = newAttributes.fontSize || newAttributes.style?.typography?.fontSize;
|
|
159
168
|
if (hasFontSize && fitText) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/typography.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tdefault as StylesTypographyPanel,\n\tuseHasTypographyPanel,\n} from '../components/global-styles/typography-panel';\n\nimport { LINE_HEIGHT_SUPPORT_KEY } from './line-height';\nimport { FONT_FAMILY_SUPPORT_KEY } from './font-family';\nimport { FONT_SIZE_SUPPORT_KEY } from './font-size';\nimport { TEXT_ALIGN_SUPPORT_KEY } from './text-align';\nimport { FIT_TEXT_SUPPORT_KEY } from './fit-text';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\n\nfunction omit( object, keys ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( object ).filter( ( [ key ] ) => ! keys.includes( key ) )\n\t);\n}\n\nconst LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';\nconst TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';\nconst TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';\nconst TEXT_INDENT_SUPPORT_KEY = 'typography.textIndent';\nconst TEXT_COLUMNS_SUPPORT_KEY = 'typography.textColumns';\nconst FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';\nconst FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';\nconst WRITING_MODE_SUPPORT_KEY = 'typography.__experimentalWritingMode';\nexport const TYPOGRAPHY_SUPPORT_KEY = 'typography';\nexport const TYPOGRAPHY_SUPPORT_KEYS = [\n\tLINE_HEIGHT_SUPPORT_KEY,\n\tFONT_SIZE_SUPPORT_KEY,\n\tFONT_STYLE_SUPPORT_KEY,\n\tFONT_WEIGHT_SUPPORT_KEY,\n\tFONT_FAMILY_SUPPORT_KEY,\n\tTEXT_ALIGN_SUPPORT_KEY,\n\tTEXT_COLUMNS_SUPPORT_KEY,\n\tTEXT_DECORATION_SUPPORT_KEY,\n\tTEXT_INDENT_SUPPORT_KEY,\n\tWRITING_MODE_SUPPORT_KEY,\n\tTEXT_TRANSFORM_SUPPORT_KEY,\n\tLETTER_SPACING_SUPPORT_KEY,\n\tFIT_TEXT_SUPPORT_KEY,\n];\n\nfunction styleToAttributes( style ) {\n\tconst updatedStyle = { ...omit( style, [ 'fontFamily' ] ) };\n\tconst fontSizeValue = style?.typography?.fontSize;\n\tconst fontFamilyValue = style?.typography?.fontFamily;\n\tconst fontSizeSlug =\n\t\ttypeof fontSizeValue === 'string' &&\n\t\tfontSizeValue?.startsWith( 'var:preset|font-size|' )\n\t\t\t? fontSizeValue.substring( 'var:preset|font-size|'.length )\n\t\t\t: undefined;\n\tconst fontFamilySlug = fontFamilyValue?.startsWith(\n\t\t'var:preset|font-family|'\n\t)\n\t\t? fontFamilyValue.substring( 'var:preset|font-family|'.length )\n\t\t: undefined;\n\tupdatedStyle.typography = {\n\t\t...omit( updatedStyle.typography, [ 'fontFamily' ] ),\n\t\tfontSize: fontSizeSlug ? undefined : fontSizeValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\tfontFamily: fontFamilySlug,\n\t\tfontSize: fontSizeSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\treturn {\n\t\t...attributes.style,\n\t\ttypography: {\n\t\t\t...attributes.style?.typography,\n\t\t\tfontFamily: attributes.fontFamily\n\t\t\t\t? 'var:preset|font-family|' + attributes.fontFamily\n\t\t\t\t: undefined,\n\t\t\tfontSize: attributes.fontSize\n\t\t\t\t? 'var:preset|font-size|' + attributes.fontSize\n\t\t\t\t: attributes.style?.typography?.fontSize,\n\t\t},\n\t};\n}\n\nfunction TypographyInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"typography\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function TypographyPanel( { clientId, name, setAttributes, settings } ) {\n\tconst isEnabled = useHasTypographyPanel( settings );\n\n\tconst { style, fontFamily, fontSize, fitText } = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when disabled.\n\t\t\tif ( ! isEnabled ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst {\n\t\t\t\tstyle: _style,\n\t\t\t\tfontFamily: _fontFamily,\n\t\t\t\tfontSize: _fontSize,\n\t\t\t\tfitText: _fitText,\n\t\t\t} = select( blockEditorStore ).getBlockAttributes( clientId ) || {};\n\t\t\treturn {\n\t\t\t\tstyle: _style,\n\t\t\t\tfontFamily: _fontFamily,\n\t\t\t\tfontSize: _fontSize,\n\t\t\t\tfitText: _fitText,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isEnabled ]\n\t);\n\tconst value = useMemo(\n\t\t()
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAiD;AACjD,qBAAqC;AACrC,kBAA0B;AAK1B,gCAA8B;AAC9B,8BAGO;AAEP,yBAAwC;AACxC,yBAAwC;AACxC,uBAAsC;AACtC,wBAAuC;AACvC,sBAAqC;AACrC,mBAAiC;AACjC,mBAA0C;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tdefault as StylesTypographyPanel,\n\tuseHasTypographyPanel,\n} from '../components/global-styles/typography-panel';\n\nimport { LINE_HEIGHT_SUPPORT_KEY } from './line-height';\nimport { FONT_FAMILY_SUPPORT_KEY } from './font-family';\nimport { FONT_SIZE_SUPPORT_KEY } from './font-size';\nimport { TEXT_ALIGN_SUPPORT_KEY } from './text-align';\nimport { FIT_TEXT_SUPPORT_KEY } from './fit-text';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\n\nfunction omit( object, keys ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( object ).filter( ( [ key ] ) => ! keys.includes( key ) )\n\t);\n}\n\nconst LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';\nconst TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';\nconst TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';\nconst TEXT_INDENT_SUPPORT_KEY = 'typography.textIndent';\nconst TEXT_COLUMNS_SUPPORT_KEY = 'typography.textColumns';\nconst FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';\nconst FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';\nconst WRITING_MODE_SUPPORT_KEY = 'typography.__experimentalWritingMode';\nexport const TYPOGRAPHY_SUPPORT_KEY = 'typography';\nexport const TYPOGRAPHY_SUPPORT_KEYS = [\n\tLINE_HEIGHT_SUPPORT_KEY,\n\tFONT_SIZE_SUPPORT_KEY,\n\tFONT_STYLE_SUPPORT_KEY,\n\tFONT_WEIGHT_SUPPORT_KEY,\n\tFONT_FAMILY_SUPPORT_KEY,\n\tTEXT_ALIGN_SUPPORT_KEY,\n\tTEXT_COLUMNS_SUPPORT_KEY,\n\tTEXT_DECORATION_SUPPORT_KEY,\n\tTEXT_INDENT_SUPPORT_KEY,\n\tWRITING_MODE_SUPPORT_KEY,\n\tTEXT_TRANSFORM_SUPPORT_KEY,\n\tLETTER_SPACING_SUPPORT_KEY,\n\tFIT_TEXT_SUPPORT_KEY,\n];\n\nfunction styleToAttributes( style ) {\n\tconst updatedStyle = { ...omit( style, [ 'fontFamily' ] ) };\n\tconst fontSizeValue = style?.typography?.fontSize;\n\tconst fontFamilyValue = style?.typography?.fontFamily;\n\tconst fontSizeSlug =\n\t\ttypeof fontSizeValue === 'string' &&\n\t\tfontSizeValue?.startsWith( 'var:preset|font-size|' )\n\t\t\t? fontSizeValue.substring( 'var:preset|font-size|'.length )\n\t\t\t: undefined;\n\tconst fontFamilySlug = fontFamilyValue?.startsWith(\n\t\t'var:preset|font-family|'\n\t)\n\t\t? fontFamilyValue.substring( 'var:preset|font-family|'.length )\n\t\t: undefined;\n\tupdatedStyle.typography = {\n\t\t...omit( updatedStyle.typography, [ 'fontFamily' ] ),\n\t\tfontSize: fontSizeSlug ? undefined : fontSizeValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\tfontFamily: fontFamilySlug,\n\t\tfontSize: fontSizeSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\treturn {\n\t\t...attributes.style,\n\t\ttypography: {\n\t\t\t...attributes.style?.typography,\n\t\t\tfontFamily: attributes.fontFamily\n\t\t\t\t? 'var:preset|font-family|' + attributes.fontFamily\n\t\t\t\t: undefined,\n\t\t\tfontSize: attributes.fontSize\n\t\t\t\t? 'var:preset|font-size|' + attributes.fontSize\n\t\t\t\t: attributes.style?.typography?.fontSize,\n\t\t},\n\t};\n}\n\nfunction TypographyInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"typography\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function TypographyPanel( { clientId, name, setAttributes, settings } ) {\n\tconst selectedState = useBlockStyleState();\n\tconst isEnabled = useHasTypographyPanel( settings );\n\n\tconst { style, fontFamily, fontSize, fitText } = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when disabled.\n\t\t\tif ( ! isEnabled ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst {\n\t\t\t\tstyle: _style,\n\t\t\t\tfontFamily: _fontFamily,\n\t\t\t\tfontSize: _fontSize,\n\t\t\t\tfitText: _fitText,\n\t\t\t} = select( blockEditorStore ).getBlockAttributes( clientId ) || {};\n\t\t\treturn {\n\t\t\t\tstyle: _style,\n\t\t\t\tfontFamily: _fontFamily,\n\t\t\t\tfontSize: _fontSize,\n\t\t\t\tfitText: _fitText,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isEnabled ]\n\t);\n\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\n\tconst value = useMemo( () => {\n\t\tif ( isStateSelected ) {\n\t\t\treturn getStyleForState( style, selectedState );\n\t\t}\n\t\treturn attributesToStyle( { style, fontFamily, fontSize } );\n\t}, [ isStateSelected, selectedState, style, fontSize, fontFamily ] );\n\n\tconst onChange = isStateSelected\n\t\t? ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: setStyleForState( style, selectedState, newStyle ),\n\t\t\t\t} );\n\t\t }\n\t\t: ( newStyle ) => {\n\t\t\t\tconst newAttributes = styleToAttributes( newStyle );\n\n\t\t\t\t// If setting a font size and fitText is currently enabled, disable it.\n\t\t\t\tconst hasFontSize =\n\t\t\t\t\tnewAttributes.fontSize ||\n\t\t\t\t\tnewAttributes.style?.typography?.fontSize;\n\t\t\t\tif ( hasFontSize && fitText ) {\n\t\t\t\t\tnewAttributes.fitText = undefined;\n\t\t\t\t}\n\n\t\t\t\tsetAttributes( newAttributes );\n\t\t };\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = getBlockSupport( name, [\n\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<StylesTypographyPanel\n\t\t\tas={ TypographyInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t/>\n\t);\n}\n\nexport const hasTypographySupport = ( blockName ) => {\n\treturn TYPOGRAPHY_SUPPORT_KEYS.some( ( key ) =>\n\t\thasBlockSupport( blockName, key )\n\t);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAiD;AACjD,qBAAqC;AACrC,kBAA0B;AAK1B,gCAA8B;AAC9B,8BAGO;AAEP,yBAAwC;AACxC,yBAA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