@wordpress/block-editor 15.19.1-next.v.202605131032.0 → 15.21.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 +17 -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/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/child-layout-control/index.cjs +10 -5
- package/build/components/child-layout-control/index.cjs.map +2 -2
- 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 +15 -8
- 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/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/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 +32 -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/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/child-layout-control/index.mjs +10 -5
- package/build-module/components/child-layout-control/index.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 +20 -8
- 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/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/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 +30 -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 +39 -39
- 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/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/child-layout-control/index.js +15 -8
- package/src/components/child-layout-control/test/index.js +126 -0
- 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 +29 -8
- 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/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/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 +61 -2
- package/src/store/reducer.js +105 -1
- package/src/store/test/private-actions.js +26 -0
- package/src/store/test/private-selectors.js +143 -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/src/hooks/border.js
CHANGED
|
@@ -11,6 +11,7 @@ import { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/com
|
|
|
11
11
|
import { Platform, useCallback, useMemo } from '@wordpress/element';
|
|
12
12
|
import { addFilter } from '@wordpress/hooks';
|
|
13
13
|
import { useSelect } from '@wordpress/data';
|
|
14
|
+
import { __ } from '@wordpress/i18n';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
@@ -29,7 +30,12 @@ import {
|
|
|
29
30
|
BorderPanel as StylesBorderPanel,
|
|
30
31
|
} from '../components/global-styles';
|
|
31
32
|
import { store as blockEditorStore } from '../store';
|
|
32
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
getStyleForState,
|
|
35
|
+
isDefaultBlockStyleState,
|
|
36
|
+
setStyleForState,
|
|
37
|
+
useBlockStyleState,
|
|
38
|
+
} from './block-style-state';
|
|
33
39
|
|
|
34
40
|
export const BORDER_SUPPORT_KEY = '__experimentalBorder';
|
|
35
41
|
export const SHADOW_SUPPORT_KEY = 'shadow';
|
|
@@ -141,6 +147,7 @@ function BordersInspectorControl( { label, children, resetAllFilter } ) {
|
|
|
141
147
|
}
|
|
142
148
|
|
|
143
149
|
export function BorderPanel( { clientId, name, setAttributes, settings } ) {
|
|
150
|
+
const selectedState = useBlockStyleState();
|
|
144
151
|
const isEnabled = useHasBorderPanel( settings );
|
|
145
152
|
const { style, borderColor } = useSelect(
|
|
146
153
|
( select ) => {
|
|
@@ -154,13 +161,25 @@ export function BorderPanel( { clientId, name, setAttributes, settings } ) {
|
|
|
154
161
|
},
|
|
155
162
|
[ clientId, isEnabled ]
|
|
156
163
|
);
|
|
164
|
+
|
|
165
|
+
const isStateSelected = ! isDefaultBlockStyleState( selectedState );
|
|
166
|
+
|
|
157
167
|
const value = useMemo( () => {
|
|
168
|
+
if ( isStateSelected ) {
|
|
169
|
+
return getStyleForState( style, selectedState );
|
|
170
|
+
}
|
|
158
171
|
return attributesToStyle( { style, borderColor } );
|
|
159
|
-
}, [ style, borderColor ] );
|
|
160
|
-
|
|
161
|
-
const onChange =
|
|
162
|
-
|
|
163
|
-
|
|
172
|
+
}, [ isStateSelected, selectedState, style, borderColor ] );
|
|
173
|
+
|
|
174
|
+
const onChange = isStateSelected
|
|
175
|
+
? ( newStyle ) => {
|
|
176
|
+
setAttributes( {
|
|
177
|
+
style: setStyleForState( style, selectedState, newStyle ),
|
|
178
|
+
} );
|
|
179
|
+
}
|
|
180
|
+
: ( newStyle ) => {
|
|
181
|
+
setAttributes( styleToAttributes( newStyle ) );
|
|
182
|
+
};
|
|
164
183
|
|
|
165
184
|
if ( ! isEnabled ) {
|
|
166
185
|
return null;
|
package/src/hooks/color.js
CHANGED
|
@@ -31,8 +31,15 @@ import {
|
|
|
31
31
|
useHasColorPanel,
|
|
32
32
|
default as StylesColorPanel,
|
|
33
33
|
} from '../components/global-styles/color-panel';
|
|
34
|
+
import { extractPresetSlug } from '../utils/color-values';
|
|
34
35
|
import BlockColorContrastChecker from './contrast-checker';
|
|
35
36
|
import { store as blockEditorStore } from '../store';
|
|
37
|
+
import {
|
|
38
|
+
getStyleForState,
|
|
39
|
+
isDefaultBlockStyleState,
|
|
40
|
+
setStyleForState,
|
|
41
|
+
useBlockStyleState,
|
|
42
|
+
} from './block-style-state';
|
|
36
43
|
|
|
37
44
|
export const COLOR_SUPPORT_KEY = 'color';
|
|
38
45
|
|
|
@@ -191,19 +198,14 @@ export function addSaveProps( props, blockNameOrType, attributes ) {
|
|
|
191
198
|
|
|
192
199
|
function styleToAttributes( style ) {
|
|
193
200
|
const textColorValue = style?.color?.text;
|
|
194
|
-
const textColorSlug =
|
|
195
|
-
? textColorValue.substring( 'var:preset|color|'.length )
|
|
196
|
-
: undefined;
|
|
201
|
+
const textColorSlug = extractPresetSlug( textColorValue, 'color' );
|
|
197
202
|
const backgroundColorValue = style?.color?.background;
|
|
198
|
-
const backgroundColorSlug =
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
: undefined;
|
|
203
|
+
const backgroundColorSlug = extractPresetSlug(
|
|
204
|
+
backgroundColorValue,
|
|
205
|
+
'color'
|
|
206
|
+
);
|
|
203
207
|
const gradientValue = style?.color?.gradient;
|
|
204
|
-
const gradientSlug =
|
|
205
|
-
? gradientValue.substring( 'var:preset|gradient|'.length )
|
|
206
|
-
: undefined;
|
|
208
|
+
const gradientSlug = extractPresetSlug( gradientValue, 'gradient' );
|
|
207
209
|
const updatedStyle = { ...style };
|
|
208
210
|
updatedStyle.color = {
|
|
209
211
|
...updatedStyle.color,
|
|
@@ -269,6 +271,7 @@ export function ColorEdit( {
|
|
|
269
271
|
label,
|
|
270
272
|
defaultControls,
|
|
271
273
|
} ) {
|
|
274
|
+
const selectedState = useBlockStyleState();
|
|
272
275
|
const isEnabled = useHasColorPanel( settings );
|
|
273
276
|
|
|
274
277
|
const { style, textColor, backgroundColor, gradient } = useSelect(
|
|
@@ -292,18 +295,39 @@ export function ColorEdit( {
|
|
|
292
295
|
},
|
|
293
296
|
[ clientId, isEnabled ]
|
|
294
297
|
);
|
|
298
|
+
|
|
299
|
+
const isStateSelected = ! isDefaultBlockStyleState( selectedState );
|
|
300
|
+
|
|
295
301
|
const value = useMemo( () => {
|
|
302
|
+
if ( isStateSelected ) {
|
|
303
|
+
return getStyleForState( style, selectedState );
|
|
304
|
+
}
|
|
296
305
|
return attributesToStyle( {
|
|
297
306
|
style,
|
|
298
307
|
textColor,
|
|
299
308
|
backgroundColor,
|
|
300
309
|
gradient,
|
|
301
310
|
} );
|
|
302
|
-
}, [
|
|
311
|
+
}, [
|
|
312
|
+
isStateSelected,
|
|
313
|
+
selectedState,
|
|
314
|
+
style,
|
|
315
|
+
textColor,
|
|
316
|
+
backgroundColor,
|
|
317
|
+
gradient,
|
|
318
|
+
] );
|
|
319
|
+
|
|
320
|
+
const onChange = isStateSelected
|
|
321
|
+
? ( newStyle ) => {
|
|
322
|
+
setAttributes( {
|
|
323
|
+
style: setStyleForState( style, selectedState, newStyle ),
|
|
324
|
+
} );
|
|
325
|
+
}
|
|
326
|
+
: ( newStyle ) => {
|
|
327
|
+
setAttributes( styleToAttributes( newStyle ) );
|
|
328
|
+
};
|
|
303
329
|
|
|
304
|
-
const
|
|
305
|
-
setAttributes( styleToAttributes( newStyle ) );
|
|
306
|
-
};
|
|
330
|
+
const Wrapper = asWrapper || ColorInspectorControl;
|
|
307
331
|
|
|
308
332
|
if ( ! isEnabled ) {
|
|
309
333
|
return null;
|
|
@@ -317,6 +341,7 @@ export function ColorEdit( {
|
|
|
317
341
|
] );
|
|
318
342
|
|
|
319
343
|
const enableContrastChecking =
|
|
344
|
+
! isStateSelected &&
|
|
320
345
|
Platform.OS === 'web' &&
|
|
321
346
|
! value?.color?.gradient &&
|
|
322
347
|
( settings?.color?.text || settings?.color?.link ) &&
|
|
@@ -329,9 +354,6 @@ export function ColorEdit( {
|
|
|
329
354
|
'enableContrastChecker',
|
|
330
355
|
] );
|
|
331
356
|
|
|
332
|
-
// Use provided wrapper or default to ColorInspectorControl
|
|
333
|
-
const Wrapper = asWrapper || ColorInspectorControl;
|
|
334
|
-
|
|
335
357
|
return (
|
|
336
358
|
<StylesColorPanel
|
|
337
359
|
as={ Wrapper }
|
package/src/hooks/dimensions.js
CHANGED
|
@@ -23,6 +23,12 @@ import { MarginVisualizer, PaddingVisualizer } from './spacing-visualizer';
|
|
|
23
23
|
import { store as blockEditorStore } from '../store';
|
|
24
24
|
import { unlock } from '../lock-unlock';
|
|
25
25
|
import { cleanEmptyObject, shouldSkipSerialization } from './utils';
|
|
26
|
+
import {
|
|
27
|
+
getStyleForState,
|
|
28
|
+
isDefaultBlockStyleState,
|
|
29
|
+
setStyleForState,
|
|
30
|
+
useBlockStyleState,
|
|
31
|
+
} from './block-style-state';
|
|
26
32
|
|
|
27
33
|
export const DIMENSIONS_SUPPORT_KEY = 'dimensions';
|
|
28
34
|
export const SPACING_SUPPORT_KEY = 'spacing';
|
|
@@ -69,8 +75,10 @@ function DimensionsInspectorControl( { children, resetAllFilter } ) {
|
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
export function DimensionsPanel( { clientId, name, setAttributes, settings } ) {
|
|
72
|
-
const
|
|
73
|
-
const
|
|
78
|
+
const selectedState = useBlockStyleState();
|
|
79
|
+
const isStateSelected = ! isDefaultBlockStyleState( selectedState );
|
|
80
|
+
const isEnabled = useHasDimensionsPanel( settings, selectedState );
|
|
81
|
+
const style = useSelect(
|
|
74
82
|
( select ) => {
|
|
75
83
|
// Early return to avoid subscription when disabled
|
|
76
84
|
if ( ! isEnabled ) {
|
|
@@ -81,13 +89,21 @@ export function DimensionsPanel( { clientId, name, setAttributes, settings } ) {
|
|
|
81
89
|
},
|
|
82
90
|
[ clientId, isEnabled ]
|
|
83
91
|
);
|
|
84
|
-
|
|
85
92
|
const [ visualizedProperty, setVisualizedProperty ] = useVisualizer();
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
const value = isStateSelected
|
|
94
|
+
? getStyleForState( style, selectedState )
|
|
95
|
+
: style;
|
|
96
|
+
const onChange = isStateSelected
|
|
97
|
+
? ( newStyle ) => {
|
|
98
|
+
setAttributes( {
|
|
99
|
+
style: setStyleForState( style, selectedState, newStyle ),
|
|
100
|
+
} );
|
|
101
|
+
}
|
|
102
|
+
: ( newStyle ) => {
|
|
103
|
+
setAttributes( {
|
|
104
|
+
style: cleanEmptyObject( newStyle ),
|
|
105
|
+
} );
|
|
106
|
+
};
|
|
91
107
|
|
|
92
108
|
if ( ! isEnabled ) {
|
|
93
109
|
return null;
|
|
@@ -119,9 +135,13 @@ export function DimensionsPanel( { clientId, name, setAttributes, settings } ) {
|
|
|
119
135
|
value={ value }
|
|
120
136
|
onChange={ onChange }
|
|
121
137
|
defaultControls={ defaultControls }
|
|
122
|
-
|
|
138
|
+
styleState={ selectedState }
|
|
139
|
+
onVisualize={
|
|
140
|
+
isStateSelected ? undefined : setVisualizedProperty
|
|
141
|
+
}
|
|
123
142
|
/>
|
|
124
|
-
{
|
|
143
|
+
{ ! isStateSelected &&
|
|
144
|
+
!! settings?.spacing?.padding &&
|
|
125
145
|
visualizedProperty === 'padding' && (
|
|
126
146
|
<PaddingVisualizer
|
|
127
147
|
forceShow={ visualizedProperty === 'padding' }
|
|
@@ -129,7 +149,8 @@ export function DimensionsPanel( { clientId, name, setAttributes, settings } ) {
|
|
|
129
149
|
value={ value }
|
|
130
150
|
/>
|
|
131
151
|
) }
|
|
132
|
-
{
|
|
152
|
+
{ ! isStateSelected &&
|
|
153
|
+
!! settings?.spacing?.margin &&
|
|
133
154
|
visualizedProperty === 'margin' && (
|
|
134
155
|
<MarginVisualizer
|
|
135
156
|
forceShow={ visualizedProperty === 'margin' }
|
|
@@ -22,12 +22,36 @@ import { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/const
|
|
|
22
22
|
|
|
23
23
|
// Used for generating the instance ID
|
|
24
24
|
const LAYOUT_CHILD_BLOCK_PROPS_REFERENCE = {};
|
|
25
|
+
// Keep in sync with WP_Theme_JSON_Gutenberg::RESPONSIVE_BREAKPOINTS.
|
|
26
|
+
const RESPONSIVE_BREAKPOINTS = {
|
|
27
|
+
mobile: '@media (width <= 480px)',
|
|
28
|
+
tablet: '@media (480px < width <= 782px)',
|
|
29
|
+
};
|
|
25
30
|
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
function serializeRule( { selector, declarations } ) {
|
|
32
|
+
return `${ selector } {
|
|
33
|
+
${ Object.entries( declarations )
|
|
34
|
+
.map( ( [ property, value ] ) => `${ property }: ${ value }` )
|
|
35
|
+
.join( '; ' ) };
|
|
36
|
+
}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function getChildLayoutStyleRules( {
|
|
40
|
+
selector,
|
|
41
|
+
layout = {},
|
|
42
|
+
viewportOverrides,
|
|
43
|
+
parentLayout = {},
|
|
44
|
+
includeContainerQuery = true,
|
|
45
|
+
} ) {
|
|
46
|
+
const hasViewportOverrides = viewportOverrides !== undefined;
|
|
47
|
+
const effectiveLayout = hasViewportOverrides
|
|
48
|
+
? {
|
|
49
|
+
...layout,
|
|
50
|
+
...viewportOverrides,
|
|
51
|
+
}
|
|
52
|
+
: layout;
|
|
53
|
+
const hasViewportOverride = ( key ) =>
|
|
54
|
+
Object.hasOwn( viewportOverrides || {}, key );
|
|
31
55
|
const {
|
|
32
56
|
selfStretch,
|
|
33
57
|
flexSize,
|
|
@@ -35,66 +59,59 @@ function useBlockPropsChildLayoutStyles( { style } ) {
|
|
|
35
59
|
rowStart,
|
|
36
60
|
columnSpan,
|
|
37
61
|
rowSpan,
|
|
38
|
-
} =
|
|
39
|
-
const parentLayout = useLayout() || {};
|
|
62
|
+
} = effectiveLayout;
|
|
40
63
|
const { columnCount, minimumColumnWidth } = parentLayout;
|
|
41
|
-
const
|
|
42
|
-
const selector = `.wp-container-content-${ id }`;
|
|
64
|
+
const rules = [];
|
|
43
65
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
if ( rowSpan && typeof rowSpan !== 'number' ) {
|
|
57
|
-
throw new Error( 'rowSpan must be a number' );
|
|
66
|
+
const declarations = {};
|
|
67
|
+
if (
|
|
68
|
+
! hasViewportOverrides ||
|
|
69
|
+
hasViewportOverride( 'selfStretch' ) ||
|
|
70
|
+
hasViewportOverride( 'flexSize' )
|
|
71
|
+
) {
|
|
72
|
+
if ( selfStretch === 'fixed' && flexSize ) {
|
|
73
|
+
declarations[ 'flex-basis' ] = flexSize;
|
|
74
|
+
declarations[ 'box-sizing' ] = 'border-box';
|
|
75
|
+
} else if ( selfStretch === 'fill' ) {
|
|
76
|
+
declarations[ 'flex-grow' ] = '1';
|
|
58
77
|
}
|
|
59
78
|
}
|
|
60
79
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
flex-grow: 1;
|
|
71
|
-
}`;
|
|
72
|
-
} else if ( columnStart && columnSpan ) {
|
|
73
|
-
css = `${ selector } {
|
|
74
|
-
grid-column: ${ columnStart } / span ${ columnSpan };
|
|
75
|
-
}`;
|
|
80
|
+
if (
|
|
81
|
+
! hasViewportOverrides ||
|
|
82
|
+
hasViewportOverride( 'columnStart' ) ||
|
|
83
|
+
hasViewportOverride( 'columnSpan' )
|
|
84
|
+
) {
|
|
85
|
+
if ( columnStart && columnSpan ) {
|
|
86
|
+
declarations[
|
|
87
|
+
'grid-column'
|
|
88
|
+
] = `${ columnStart } / span ${ columnSpan }`;
|
|
76
89
|
} else if ( columnStart ) {
|
|
77
|
-
|
|
78
|
-
grid-column: ${ columnStart };
|
|
79
|
-
}`;
|
|
90
|
+
declarations[ 'grid-column' ] = `${ columnStart }`;
|
|
80
91
|
} else if ( columnSpan ) {
|
|
81
|
-
|
|
82
|
-
grid-column: span ${ columnSpan };
|
|
83
|
-
}`;
|
|
92
|
+
declarations[ 'grid-column' ] = `span ${ columnSpan }`;
|
|
84
93
|
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (
|
|
97
|
+
! hasViewportOverrides ||
|
|
98
|
+
hasViewportOverride( 'rowStart' ) ||
|
|
99
|
+
hasViewportOverride( 'rowSpan' )
|
|
100
|
+
) {
|
|
85
101
|
if ( rowStart && rowSpan ) {
|
|
86
|
-
|
|
87
|
-
grid-row: ${ rowStart } / span ${ rowSpan };
|
|
88
|
-
}`;
|
|
102
|
+
declarations[ 'grid-row' ] = `${ rowStart } / span ${ rowSpan }`;
|
|
89
103
|
} else if ( rowStart ) {
|
|
90
|
-
|
|
91
|
-
grid-row: ${ rowStart };
|
|
92
|
-
}`;
|
|
104
|
+
declarations[ 'grid-row' ] = `${ rowStart }`;
|
|
93
105
|
} else if ( rowSpan ) {
|
|
94
|
-
|
|
95
|
-
grid-row: span ${ rowSpan };
|
|
96
|
-
}`;
|
|
106
|
+
declarations[ 'grid-row' ] = `span ${ rowSpan }`;
|
|
97
107
|
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if ( Object.keys( declarations ).length ) {
|
|
111
|
+
rules.push( { selector, declarations } );
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if ( includeContainerQuery && ! hasViewportOverrides ) {
|
|
98
115
|
/**
|
|
99
116
|
* If minimumColumnWidth is set on the parent, or if no
|
|
100
117
|
* columnCount is set, the grid is responsive so a
|
|
@@ -147,18 +164,118 @@ function useBlockPropsChildLayoutStyles( { style } ) {
|
|
|
147
164
|
const gridColumnValue =
|
|
148
165
|
columnSpan && columnSpan > 1 ? '1/-1' : 'auto';
|
|
149
166
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
${
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
167
|
+
rules.push( {
|
|
168
|
+
rulesGroup: `@container (max-width: ${ Math.max(
|
|
169
|
+
containerQueryValue,
|
|
170
|
+
minimumContainerQueryValue
|
|
171
|
+
) }${ parentColumnUnit })`,
|
|
172
|
+
selector,
|
|
173
|
+
declarations: {
|
|
174
|
+
'grid-column': gridColumnValue,
|
|
175
|
+
'grid-row': 'auto',
|
|
176
|
+
},
|
|
177
|
+
} );
|
|
159
178
|
}
|
|
160
179
|
}
|
|
161
180
|
|
|
181
|
+
return rules;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function getChildLayoutStyles( {
|
|
185
|
+
selector,
|
|
186
|
+
layout = {},
|
|
187
|
+
parentLayout = {},
|
|
188
|
+
includeContainerQuery = true,
|
|
189
|
+
} ) {
|
|
190
|
+
return getChildLayoutStyleRules( {
|
|
191
|
+
selector,
|
|
192
|
+
layout,
|
|
193
|
+
parentLayout,
|
|
194
|
+
includeContainerQuery,
|
|
195
|
+
} )
|
|
196
|
+
.map( ( rule ) => {
|
|
197
|
+
const serializedRule = serializeRule( rule );
|
|
198
|
+
return rule.rulesGroup
|
|
199
|
+
? `${ rule.rulesGroup } {
|
|
200
|
+
${ serializedRule }
|
|
201
|
+
}`
|
|
202
|
+
: serializedRule;
|
|
203
|
+
} )
|
|
204
|
+
.join( '' );
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function getResponsiveChildLayoutStyles( {
|
|
208
|
+
style = {},
|
|
209
|
+
selector,
|
|
210
|
+
parentLayout = {},
|
|
211
|
+
} ) {
|
|
212
|
+
const baseLayout = style?.layout ?? {};
|
|
213
|
+
|
|
214
|
+
return Object.entries( RESPONSIVE_BREAKPOINTS )
|
|
215
|
+
.map( ( [ viewport, mediaQuery ] ) => {
|
|
216
|
+
const viewportLayout = style?.[ viewport ]?.layout;
|
|
217
|
+
if ( ! viewportLayout || ! Object.keys( viewportLayout ).length ) {
|
|
218
|
+
return '';
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const viewportRules = getChildLayoutStyleRules( {
|
|
222
|
+
selector,
|
|
223
|
+
layout: baseLayout,
|
|
224
|
+
viewportOverrides: viewportLayout,
|
|
225
|
+
parentLayout,
|
|
226
|
+
includeContainerQuery: false,
|
|
227
|
+
} );
|
|
228
|
+
const css = viewportRules.map( serializeRule ).join( '' );
|
|
229
|
+
|
|
230
|
+
return css ? `${ mediaQuery }{${ css }}` : '';
|
|
231
|
+
} )
|
|
232
|
+
.filter( Boolean )
|
|
233
|
+
.join( '' );
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function useBlockPropsChildLayoutStyles( { style } ) {
|
|
237
|
+
const shouldRenderChildLayoutStyles = useSelect( ( select ) => {
|
|
238
|
+
return ! select( blockEditorStore ).getSettings().disableLayoutStyles;
|
|
239
|
+
} );
|
|
240
|
+
const layout = style?.layout ?? {};
|
|
241
|
+
const { columnStart, rowStart, columnSpan, rowSpan } = layout;
|
|
242
|
+
const parentLayout = useLayout() || {};
|
|
243
|
+
const id = useInstanceId( LAYOUT_CHILD_BLOCK_PROPS_REFERENCE );
|
|
244
|
+
const selector = `.wp-container-content-${ id }`;
|
|
245
|
+
|
|
246
|
+
// Check that the grid layout attributes are of the correct type, so that we don't accidentally
|
|
247
|
+
// write code that stores a string attribute instead of a number.
|
|
248
|
+
if ( process.env.NODE_ENV === 'development' ) {
|
|
249
|
+
if ( columnStart && typeof columnStart !== 'number' ) {
|
|
250
|
+
throw new Error( 'columnStart must be a number' );
|
|
251
|
+
}
|
|
252
|
+
if ( rowStart && typeof rowStart !== 'number' ) {
|
|
253
|
+
throw new Error( 'rowStart must be a number' );
|
|
254
|
+
}
|
|
255
|
+
if ( columnSpan && typeof columnSpan !== 'number' ) {
|
|
256
|
+
throw new Error( 'columnSpan must be a number' );
|
|
257
|
+
}
|
|
258
|
+
if ( rowSpan && typeof rowSpan !== 'number' ) {
|
|
259
|
+
throw new Error( 'rowSpan must be a number' );
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
let css = '';
|
|
264
|
+
if ( shouldRenderChildLayoutStyles ) {
|
|
265
|
+
css = [
|
|
266
|
+
getChildLayoutStyles( {
|
|
267
|
+
selector,
|
|
268
|
+
layout,
|
|
269
|
+
parentLayout,
|
|
270
|
+
} ),
|
|
271
|
+
getResponsiveChildLayoutStyles( {
|
|
272
|
+
style,
|
|
273
|
+
selector,
|
|
274
|
+
parentLayout,
|
|
275
|
+
} ),
|
|
276
|
+
].join( '' );
|
|
277
|
+
}
|
|
278
|
+
|
|
162
279
|
useStyleOverride( { css } );
|
|
163
280
|
|
|
164
281
|
// Only attach a container class if there is generated CSS to be attached.
|