@wordpress/block-editor 17.1.0 → 17.2.1-next.v.202609171837.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 +32 -0
- package/README.md +214 -214
- package/build/autocompleters/block.cjs.map +2 -2
- package/build/components/alignment-control/ui.cjs.map +2 -2
- package/build/components/background-image-control/index.cjs +1 -1
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-alignment-control/ui.cjs +21 -7
- package/build/components/block-alignment-control/ui.cjs.map +3 -3
- package/build/components/block-alignment-control/use-available-alignments.cjs +60 -13
- package/build/components/block-alignment-control/use-available-alignments.cjs.map +2 -2
- package/build/components/block-allowed-blocks/allowed-blocks-control.cjs.map +2 -2
- package/build/components/block-bindings/attribute-control.cjs +30 -30
- package/build/components/block-bindings/attribute-control.cjs.map +3 -3
- package/build/components/block-bindings/source-fields-list.cjs +27 -32
- package/build/components/block-bindings/source-fields-list.cjs.map +3 -3
- package/build/components/block-canvas/index.cjs.map +2 -2
- package/build/components/block-card/index.cjs +1 -2
- package/build/components/block-card/index.cjs.map +3 -3
- package/build/components/block-edit/edit.cjs.map +2 -2
- package/build/components/block-heading-level-dropdown/index.cjs.map +2 -2
- package/build/components/block-icon/index.cjs.map +2 -2
- package/build/components/block-inspector/edit-contents.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +27 -8
- package/build/components/block-inspector/index.cjs.map +3 -3
- package/build/components/block-keyboard-shortcuts/index.cjs.map +2 -2
- package/build/components/block-list/block-html.cjs +1 -12
- package/build/components/block-list/block-html.cjs.map +3 -3
- package/build/components/block-list/block.cjs +2 -4
- package/build/components/block-list/block.cjs.map +2 -2
- package/build/components/block-list/layout.cjs +1 -1
- package/build/components/block-list/layout.cjs.map +2 -2
- package/build/components/block-list/use-block-props/index.cjs.map +2 -2
- package/build/components/block-lock/modal.cjs +1 -3
- package/build/components/block-lock/modal.cjs.map +2 -2
- package/build/components/block-parent-selector/index.cjs +8 -5
- package/build/components/block-parent-selector/index.cjs.map +2 -2
- package/build/components/block-popover/index.cjs.map +2 -2
- package/build/components/block-rename/modal.cjs.map +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.cjs.map +2 -2
- package/build/components/block-styles/utils.cjs.map +2 -2
- package/build/components/block-switcher/index.cjs.map +2 -2
- package/build/components/block-toolbar/edit-section-button.cjs.map +2 -2
- package/build/components/block-toolbar/index.cjs +6 -4
- package/build/components/block-toolbar/index.cjs.map +2 -2
- package/build/components/block-toolbar/switch-section-style.cjs.map +2 -2
- package/build/components/block-variation-transforms/index.cjs +28 -18
- package/build/components/block-variation-transforms/index.cjs.map +3 -3
- package/build/components/block-visibility/modal.cjs.map +2 -2
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +2 -2
- package/build/components/border-radius-control/index.cjs.map +2 -2
- package/build/components/color-palette/with-color-context.cjs.map +2 -2
- package/build/components/colors/with-colors.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/contrast-checker/index.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +3 -3
- package/build/components/dimensions-tool/width-height-tool.cjs.map +2 -2
- package/build/components/font-sizes/with-font-sizes.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +1 -1
- package/build/components/global-styles/background-panel.cjs.map +2 -2
- package/build/components/global-styles/border-panel.cjs +1 -1
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +1 -1
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +2 -2
- package/build/components/global-styles/color-panel.cjs +1 -1
- package/build/components/global-styles/color-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +1 -1
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/filters-panel.cjs +1 -1
- package/build/components/global-styles/filters-panel.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +1 -0
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/inheritance/index.cjs +3 -3
- package/build/components/global-styles/inheritance/index.cjs.map +2 -2
- package/build/components/global-styles/inherited-value-context.cjs +0 -5
- package/build/components/global-styles/inherited-value-context.cjs.map +2 -2
- package/build/components/global-styles/state-control-badges.cjs +0 -1
- package/build/components/global-styles/state-control-badges.cjs.map +2 -2
- package/build/components/global-styles/state-control.cjs +6 -4
- package/build/components/global-styles/state-control.cjs.map +2 -2
- package/build/components/global-styles/text-shadow-panel.cjs +254 -0
- package/build/components/global-styles/text-shadow-panel.cjs.map +7 -0
- package/build/components/global-styles/typography-panel.cjs +46 -5
- package/build/components/global-styles/typography-panel.cjs.map +2 -2
- package/build/components/global-styles/typography-utils.cjs.map +2 -2
- package/build/components/global-styles/utils.cjs.map +2 -2
- package/build/components/html-element-control/index.cjs.map +3 -3
- package/build/components/iframe/index.cjs.map +2 -2
- package/build/components/iframe/use-scale-canvas.cjs.map +2 -2
- package/build/components/image-size-control/index.cjs.map +3 -3
- package/build/components/inner-blocks/index.cjs +6 -1
- package/build/components/inner-blocks/index.cjs.map +2 -2
- package/build/components/inner-content/index.cjs.map +2 -2
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.cjs +4 -23
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.cjs.map +2 -2
- package/build/components/inserter/block-patterns-tab/utils.cjs +26 -0
- package/build/components/inserter/block-patterns-tab/utils.cjs.map +2 -2
- package/build/components/inserter/hooks/use-block-types-state.cjs.map +2 -2
- package/build/components/inserter/hooks/use-insertion-point.cjs.map +2 -2
- package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-panel.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter-list-item/index.cjs.map +2 -2
- package/build/components/inspector-controls/list-view-content-popover.cjs.map +2 -2
- package/build/components/link-control/search-results.cjs.map +2 -2
- package/build/components/link-control/use-search-handler.cjs +3 -0
- package/build/components/link-control/use-search-handler.cjs.map +2 -2
- package/build/components/list-view/branch.cjs.map +2 -2
- package/build/components/list-view/drop-indicator.cjs.map +2 -2
- package/build/components/list-view/index.cjs.map +2 -2
- package/build/components/list-view/use-list-view-drop-zone.cjs.map +2 -2
- package/build/components/list-view/utils.cjs.map +2 -2
- package/build/components/media-replace-flow/index.cjs +4 -1
- package/build/components/media-replace-flow/index.cjs.map +2 -2
- package/build/components/plain-text/index.cjs +1 -2
- package/build/components/plain-text/index.cjs.map +3 -3
- package/build/components/preset-input-control/index.cjs.map +2 -2
- package/build/components/provider/index.cjs +3 -1
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/publish-date-time-picker/index.cjs.map +2 -2
- package/build/components/resizable-box-popover/index.cjs +1 -1
- package/build/components/resizable-box-popover/index.cjs.map +1 -1
- package/build/components/resolution-tool/index.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/enter.cjs +8 -22
- package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
- package/build/components/rich-text/format-edit.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +20 -0
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/rich-text/multiline.cjs +10 -2
- package/build/components/rich-text/multiline.cjs.map +2 -2
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.cjs.map +2 -2
- package/build/components/typewriter/index.cjs.map +2 -2
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/components/writing-flow/index.cjs +3 -0
- package/build/components/writing-flow/index.cjs.map +2 -2
- package/build/components/writing-flow/use-clipboard-handler.cjs.map +2 -2
- package/build/components/writing-flow/use-selection-observer.cjs +5 -3
- package/build/components/writing-flow/use-selection-observer.cjs.map +2 -2
- package/build/hooks/align.cjs +3 -5
- package/build/hooks/align.cjs.map +2 -2
- package/build/hooks/background.cjs.map +2 -2
- package/build/hooks/block-bindings.cjs.map +2 -2
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/contrast-checker.cjs.map +2 -2
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/duotone.cjs.map +2 -2
- package/build/hooks/elements.cjs.map +2 -2
- package/build/hooks/fit-text.cjs.map +2 -2
- package/build/hooks/gap.cjs +2 -1
- package/build/hooks/gap.cjs.map +3 -3
- package/build/hooks/index.cjs +4 -2
- package/build/hooks/index.cjs.map +3 -3
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +15 -14
- package/build/hooks/layout.cjs.map +3 -3
- package/build/hooks/position.cjs +3 -31
- package/build/hooks/position.cjs.map +2 -2
- package/build/hooks/states.cjs +3 -2
- package/build/hooks/states.cjs.map +2 -2
- package/build/hooks/text-shadow.cjs +100 -0
- package/build/hooks/text-shadow.cjs.map +7 -0
- package/build/hooks/typography.cjs +30 -6
- package/build/hooks/typography.cjs.map +2 -2
- package/build/hooks/utils.cjs +24 -2
- package/build/hooks/utils.cjs.map +2 -2
- package/build/layouts/grid.cjs.map +2 -2
- package/build/layouts/utils.cjs +7 -2
- package/build/layouts/utils.cjs.map +2 -2
- package/build/private-apis.cjs +9 -6
- package/build/private-apis.cjs.map +2 -2
- package/build/store/actions.cjs +26 -4
- package/build/store/actions.cjs.map +3 -3
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/get-font-styles-and-weights.cjs.map +2 -2
- package/build/utils/transform-styles/index.cjs.map +1 -1
- package/build-module/autocompleters/block.mjs.map +2 -2
- package/build-module/components/alignment-control/ui.mjs.map +2 -2
- package/build-module/components/background-image-control/index.mjs +2 -2
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-alignment-control/ui.mjs +21 -7
- package/build-module/components/block-alignment-control/ui.mjs.map +2 -2
- package/build-module/components/block-alignment-control/use-available-alignments.mjs +56 -13
- package/build-module/components/block-alignment-control/use-available-alignments.mjs.map +2 -2
- package/build-module/components/block-allowed-blocks/allowed-blocks-control.mjs.map +2 -2
- package/build-module/components/block-bindings/attribute-control.mjs +31 -32
- package/build-module/components/block-bindings/attribute-control.mjs.map +2 -2
- package/build-module/components/block-bindings/source-fields-list.mjs +25 -30
- package/build-module/components/block-bindings/source-fields-list.mjs.map +2 -2
- package/build-module/components/block-canvas/index.mjs.map +2 -2
- package/build-module/components/block-card/index.mjs +3 -8
- package/build-module/components/block-card/index.mjs.map +2 -2
- package/build-module/components/block-edit/edit.mjs.map +2 -2
- package/build-module/components/block-heading-level-dropdown/index.mjs.map +2 -2
- package/build-module/components/block-icon/index.mjs.map +2 -2
- package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +29 -10
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-keyboard-shortcuts/index.mjs.map +2 -2
- package/build-module/components/block-list/block-html.mjs +1 -2
- package/build-module/components/block-list/block-html.mjs.map +2 -2
- package/build-module/components/block-list/block.mjs +2 -4
- package/build-module/components/block-list/block.mjs.map +2 -2
- package/build-module/components/block-list/layout.mjs +1 -1
- package/build-module/components/block-list/layout.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
- package/build-module/components/block-lock/modal.mjs +1 -3
- package/build-module/components/block-lock/modal.mjs.map +2 -2
- package/build-module/components/block-parent-selector/index.mjs +8 -5
- package/build-module/components/block-parent-selector/index.mjs.map +2 -2
- package/build-module/components/block-popover/index.mjs.map +2 -2
- package/build-module/components/block-rename/modal.mjs.map +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.mjs.map +2 -2
- package/build-module/components/block-styles/utils.mjs.map +2 -2
- package/build-module/components/block-switcher/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/edit-section-button.mjs.map +2 -2
- package/build-module/components/block-toolbar/index.mjs +6 -4
- package/build-module/components/block-toolbar/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/switch-section-style.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +30 -21
- package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
- package/build-module/components/border-radius-control/index.mjs.map +2 -2
- package/build-module/components/color-palette/with-color-context.mjs.map +2 -2
- package/build-module/components/colors/with-colors.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/contrast-checker/index.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/width-height-tool.mjs.map +2 -2
- package/build-module/components/font-sizes/with-font-sizes.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +2 -2
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +2 -2
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +2 -2
- package/build-module/components/global-styles/color-panel.mjs +2 -2
- package/build-module/components/global-styles/color-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +2 -2
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +1 -0
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/inheritance/index.mjs +2 -2
- package/build-module/components/global-styles/inheritance/index.mjs.map +2 -2
- package/build-module/components/global-styles/inherited-value-context.mjs +0 -5
- package/build-module/components/global-styles/inherited-value-context.mjs.map +2 -2
- package/build-module/components/global-styles/state-control-badges.mjs +0 -1
- package/build-module/components/global-styles/state-control-badges.mjs.map +2 -2
- package/build-module/components/global-styles/state-control.mjs +6 -4
- package/build-module/components/global-styles/state-control.mjs.map +2 -2
- package/build-module/components/global-styles/text-shadow-panel.mjs +224 -0
- package/build-module/components/global-styles/text-shadow-panel.mjs.map +7 -0
- package/build-module/components/global-styles/typography-panel.mjs +47 -6
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/global-styles/typography-utils.mjs.map +2 -2
- package/build-module/components/global-styles/utils.mjs.map +2 -2
- package/build-module/components/html-element-control/index.mjs +2 -2
- package/build-module/components/html-element-control/index.mjs.map +2 -2
- package/build-module/components/iframe/index.mjs.map +2 -2
- package/build-module/components/iframe/use-scale-canvas.mjs.map +2 -2
- package/build-module/components/image-size-control/index.mjs +2 -2
- package/build-module/components/image-size-control/index.mjs.map +2 -2
- package/build-module/components/inner-blocks/index.mjs +6 -1
- package/build-module/components/inner-blocks/index.mjs.map +2 -2
- package/build-module/components/inner-content/index.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.mjs +6 -24
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.mjs.map +2 -2
- package/build-module/components/inserter/block-patterns-tab/utils.mjs +25 -0
- package/build-module/components/inserter/block-patterns-tab/utils.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-block-types-state.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-insertion-point.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-panel.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter-list-item/index.mjs.map +2 -2
- package/build-module/components/inspector-controls/list-view-content-popover.mjs.map +2 -2
- package/build-module/components/link-control/search-results.mjs.map +2 -2
- package/build-module/components/link-control/use-search-handler.mjs +3 -0
- package/build-module/components/link-control/use-search-handler.mjs.map +2 -2
- package/build-module/components/list-view/branch.mjs.map +2 -2
- package/build-module/components/list-view/drop-indicator.mjs.map +2 -2
- package/build-module/components/list-view/index.mjs.map +2 -2
- package/build-module/components/list-view/use-list-view-drop-zone.mjs.map +2 -2
- package/build-module/components/list-view/utils.mjs.map +2 -2
- package/build-module/components/media-replace-flow/index.mjs +4 -1
- package/build-module/components/media-replace-flow/index.mjs.map +2 -2
- package/build-module/components/plain-text/index.mjs +1 -2
- package/build-module/components/plain-text/index.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +3 -1
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/publish-date-time-picker/index.mjs.map +2 -2
- package/build-module/components/resizable-box-popover/index.mjs +1 -1
- package/build-module/components/resizable-box-popover/index.mjs.map +1 -1
- package/build-module/components/resolution-tool/index.mjs +2 -2
- package/build-module/components/resolution-tool/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +8 -22
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/format-edit.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +21 -0
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/rich-text/multiline.mjs +11 -3
- package/build-module/components/rich-text/multiline.mjs.map +2 -2
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.mjs.map +2 -2
- package/build-module/components/typewriter/index.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/components/writing-flow/index.mjs +3 -0
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-clipboard-handler.mjs.map +2 -2
- package/build-module/components/writing-flow/use-selection-observer.mjs +5 -3
- package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
- package/build-module/hooks/align.mjs +6 -6
- package/build-module/hooks/align.mjs.map +2 -2
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-bindings.mjs.map +2 -2
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/contrast-checker.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/duotone.mjs.map +2 -2
- package/build-module/hooks/elements.mjs.map +2 -2
- package/build-module/hooks/fit-text.mjs.map +2 -2
- package/build-module/hooks/gap.mjs +2 -1
- package/build-module/hooks/gap.mjs.map +2 -2
- package/build-module/hooks/index.mjs +4 -2
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +6 -5
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/position.mjs +5 -33
- package/build-module/hooks/position.mjs.map +2 -2
- package/build-module/hooks/states.mjs +3 -2
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/text-shadow.mjs +65 -0
- package/build-module/hooks/text-shadow.mjs.map +7 -0
- package/build-module/hooks/typography.mjs +30 -6
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/hooks/utils.mjs +24 -2
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/layouts/utils.mjs +5 -1
- package/build-module/layouts/utils.mjs.map +2 -2
- package/build-module/private-apis.mjs +6 -2
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +28 -5
- package/build-module/store/actions.mjs.map +3 -3
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/get-font-styles-and-weights.mjs.map +2 -2
- package/build-module/utils/transform-styles/index.mjs.map +1 -1
- package/build-style/content-rtl.css +7 -2
- package/build-style/content.css +7 -2
- package/build-style/style-rtl.css +90 -25
- package/build-style/style.css +92 -25
- package/package.json +42 -43
- package/src/autocompleters/block.jsx +4 -4
- package/src/components/alignment-control/ui.jsx +1 -1
- package/src/components/background-image-control/index.jsx +3 -3
- package/src/components/block-alignment-control/test/index.jsdom.test.jsx +267 -0
- package/src/components/block-alignment-control/ui.jsx +47 -9
- package/src/components/block-alignment-control/use-available-alignments.js +106 -20
- package/src/components/block-allowed-blocks/allowed-blocks-control.jsx +1 -1
- package/src/components/block-bindings/attribute-control.jsx +27 -29
- package/src/components/block-bindings/source-fields-list.jsx +22 -32
- package/src/components/block-bindings/test/attribute-control.jsdom.test.jsx +115 -0
- package/src/components/block-canvas/index.jsx +1 -1
- package/src/components/block-card/index.jsx +5 -11
- package/src/components/block-card/style.scss +1 -0
- package/src/components/block-edit/edit.jsx +1 -1
- package/src/components/block-heading-level-dropdown/index.jsx +1 -1
- package/src/components/block-icon/index.jsx +1 -1
- package/src/components/block-icon/test/index.browser.test.jsx +74 -0
- package/src/components/block-inspector/edit-contents.jsx +2 -2
- package/src/components/block-inspector/index.jsx +46 -15
- package/src/components/block-inspector/style.scss +16 -0
- package/src/components/block-keyboard-shortcuts/index.jsx +2 -2
- package/src/components/block-list/block-html.jsx +2 -3
- package/src/components/block-list/block.jsx +7 -5
- package/src/components/block-list/content.scss +3 -2
- package/src/components/block-list/layout.jsx +4 -1
- package/src/components/block-list/test/layout.jsdom.test.js +40 -0
- package/src/components/block-list/use-block-props/index.js +1 -1
- package/src/components/block-lock/modal.jsx +2 -3
- package/src/components/block-lock/style.scss +1 -1
- package/src/components/block-mover/style.scss +0 -13
- package/src/components/block-parent-selector/index.jsx +12 -6
- package/src/components/block-patterns-list/style.scss +1 -1
- package/src/components/block-popover/index.jsx +1 -1
- package/src/components/block-rename/modal.jsx +3 -3
- package/src/components/block-settings-menu/block-settings-dropdown.jsx +1 -1
- package/src/components/block-styles/utils.js +1 -1
- package/src/components/block-switcher/index.jsx +3 -3
- package/src/components/block-toolbar/edit-section-button.jsx +2 -2
- package/src/components/block-toolbar/index.jsx +8 -4
- package/src/components/block-toolbar/switch-section-style.jsx +1 -1
- package/src/components/block-variation-transforms/index.jsx +24 -23
- package/src/components/block-variation-transforms/test/index.jsdom.test.jsx +93 -0
- package/src/components/block-visibility/modal.jsx +7 -7
- package/src/components/block-visibility/style.scss +1 -1
- package/src/components/block-visibility/viewport-visibility-info.jsx +5 -7
- package/src/components/border-radius-control/index.jsx +2 -2
- package/src/components/border-radius-control/test/index.jsdom.test.jsx +0 -22
- package/src/components/border-radius-control/test/select.browser.test.js +30 -0
- package/src/components/color-palette/with-color-context.jsx +1 -1
- package/src/components/colors/with-colors.jsx +1 -1
- package/src/components/colors-gradients/control.jsx +2 -2
- package/src/components/colors-gradients/test/{control.jsdom.test.jsx → control.browser.test.jsx} +6 -9
- package/src/components/contrast-checker/index.jsx +2 -2
- package/src/components/date-format-picker/index.jsx +2 -2
- package/src/components/dimensions-tool/aspect-ratio-tool.jsx +4 -4
- package/src/components/dimensions-tool/test/index.jsdom.test.jsx +17 -11
- package/src/components/dimensions-tool/width-height-tool.jsx +2 -2
- package/src/components/font-sizes/with-font-sizes.jsx +2 -3
- package/src/components/global-styles/background-panel.jsx +2 -2
- package/src/components/global-styles/border-panel.jsx +2 -2
- package/src/components/global-styles/color-gradient-dropdown-item.jsx +3 -3
- package/src/components/global-styles/color-panel.jsx +3 -3
- package/src/components/global-styles/dimensions-panel.jsx +6 -6
- package/src/components/global-styles/filters-panel.jsx +2 -2
- package/src/components/global-styles/hooks.js +1 -0
- package/src/components/global-styles/inheritance/index.jsx +9 -6
- package/src/components/global-styles/inheritance/test/{index.jsdom.test.jsx → index.browser.test.jsx} +34 -28
- package/src/components/global-styles/inherited-value-context.js +1 -9
- package/src/components/global-styles/state-control-badges.jsx +0 -1
- package/src/components/global-styles/state-control.jsx +12 -3
- package/src/components/global-styles/style.scss +68 -0
- package/src/components/global-styles/test/{color-panel.jsdom.test.jsx → color-panel.browser.test.jsx} +53 -54
- package/src/components/global-styles/test/inherited-value-context-core.jsdom.test.js +17 -26
- package/src/components/global-styles/test/{typography-panel-core.jsdom.test.jsx → typography-panel-core.browser.test.jsx} +84 -39
- package/src/components/global-styles/test/{typography-panel.jsdom.test.jsx → typography-panel.browser.test.jsx} +80 -122
- package/src/components/global-styles/text-shadow-panel.tsx +257 -0
- package/src/components/global-styles/typography-panel.jsx +52 -13
- package/src/components/global-styles/typography-utils.js +2 -2
- package/src/components/global-styles/utils.js +1 -1
- package/src/components/html-element-control/index.jsx +2 -2
- package/src/components/iframe/index.jsx +1 -1
- package/src/components/iframe/use-scale-canvas.js +1 -1
- package/src/components/image-size-control/index.jsx +2 -2
- package/src/components/inner-blocks/index.jsx +9 -1
- package/src/components/inner-content/index.jsx +1 -1
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +7 -33
- package/src/components/inserter/block-patterns-tab/utils.js +44 -0
- package/src/components/inserter/hooks/use-block-types-state.js +2 -2
- package/src/components/inserter/hooks/use-insertion-point.js +1 -1
- package/src/components/inserter/hooks/use-patterns-state.js +1 -1
- package/src/components/inserter/media-tab/media-panel.jsx +9 -9
- package/src/components/inserter/media-tab/media-preview.jsx +1 -1
- package/src/components/inserter-list-item/index.jsx +1 -1
- package/src/components/inserter-list-item/style.scss +2 -2
- package/src/components/inspector-controls/list-view-content-popover.jsx +1 -1
- package/src/components/link-control/search-results.jsx +1 -1
- package/src/components/link-control/style.scss +1 -1
- package/src/components/link-control/test/index.jsdom.test.jsx +38 -110
- package/src/components/link-control/test/keyboard-selection.browser.test.js +110 -0
- package/src/components/link-control/use-search-handler.js +8 -3
- package/src/components/list-view/branch.jsx +1 -1
- package/src/components/list-view/drop-indicator.jsx +3 -3
- package/src/components/list-view/index.jsx +1 -1
- package/src/components/list-view/style.scss +1 -9
- package/src/components/list-view/use-list-view-drop-zone.js +1 -1
- package/src/components/list-view/utils.js +1 -1
- package/src/components/media-replace-flow/index.jsx +4 -1
- package/src/components/navigable-toolbar/test/index.browser.test.js +6 -7
- package/src/components/plain-text/README.md +3 -2
- package/src/components/plain-text/content.scss +0 -1
- package/src/components/plain-text/index.jsx +2 -3
- package/src/components/plain-text/style.scss +4 -0
- package/src/components/preset-input-control/index.jsx +2 -2
- package/src/components/preset-input-control/test/index.jsdom.test.jsx +0 -56
- package/src/components/preset-input-control/test/interaction.browser.test.js +63 -0
- package/src/components/provider/index.jsx +5 -3
- package/src/components/provider/use-block-sync.js +5 -5
- package/src/components/publish-date-time-picker/index.jsx +1 -1
- package/src/components/resizable-box-popover/index.jsx +1 -1
- package/src/components/resolution-tool/index.jsx +2 -2
- package/src/components/responsive-block-control/style.scss +1 -2
- package/src/components/responsive-block-control/test/index.jsdom.test.jsx +2 -2
- package/src/components/rich-text/event-listeners/enter.js +16 -23
- package/src/components/rich-text/format-edit.jsx +1 -1
- package/src/components/rich-text/index.jsx +39 -2
- package/src/components/rich-text/multiline.jsx +11 -3
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/src/components/spacing-sizes-control/test/index.jsdom.test.jsx +0 -21
- package/src/components/spacing-sizes-control/test/select.browser.test.js +58 -0
- package/src/components/typewriter/index.jsx +1 -1
- package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +1 -1
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-block-drop-zone/test/index.js +2 -2
- package/src/components/writing-flow/index.jsx +8 -0
- package/src/components/writing-flow/use-clipboard-handler.js +1 -1
- package/src/components/writing-flow/use-selection-observer.js +15 -6
- package/src/content.scss +1 -0
- package/src/hooks/align.jsx +22 -6
- package/src/hooks/background.jsx +1 -1
- package/src/hooks/block-bindings.jsx +1 -1
- package/src/hooks/block-hooks.scss +0 -6
- package/src/hooks/border.jsx +2 -2
- package/src/hooks/contrast-checker.js +1 -1
- package/src/hooks/dimensions.jsx +2 -2
- package/src/hooks/duotone.jsx +3 -3
- package/src/hooks/elements.jsx +3 -3
- package/src/hooks/fit-text.jsx +1 -1
- package/src/hooks/gap.js +2 -4
- package/src/hooks/index.js +3 -1
- package/src/hooks/layout-child.jsx +3 -4
- package/src/hooks/layout.jsx +17 -18
- package/src/hooks/position.jsx +5 -36
- package/src/hooks/states.jsx +6 -2
- package/src/hooks/test/layout.jsdom.test.js +44 -1
- package/src/hooks/text-shadow.ts +105 -0
- package/src/hooks/typography.jsx +58 -30
- package/src/hooks/utils.jsx +23 -1
- package/src/layouts/grid.jsx +2 -2
- package/src/layouts/test/flex.jsdom.test.jsx +4 -3
- package/src/layouts/test/utils.js +48 -1
- package/src/layouts/utils.js +19 -0
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +50 -10
- package/src/store/private-selectors.js +5 -5
- package/src/store/reducer.js +6 -6
- package/src/store/selectors.js +3 -3
- package/src/store/test/actions.jsdom.test.js +60 -0
- package/src/style.scss +1 -0
- package/src/utils/get-font-styles-and-weights.ts +1 -1
- package/src/utils/transform-styles/index.ts +1 -1
- package/build/hooks/cross-origin-isolation.cjs +0 -56
- package/build/hooks/cross-origin-isolation.cjs.map +0 -7
- package/build-module/hooks/cross-origin-isolation.mjs +0 -54
- package/build-module/hooks/cross-origin-isolation.mjs.map +0 -7
- package/src/components/block-icon/test/__snapshots__/index.jsdom.test.jsx.snap +0 -27
- package/src/components/block-icon/test/index.jsdom.test.jsx +0 -67
- package/src/hooks/cross-origin-isolation.js +0 -73
- package/src/hooks/test/cross-origin-isolation.jsdom.test.js +0 -173
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/layout.jsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useCallback } from '@wordpress/element';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { privateApis as globalStylesEnginePrivateApis } from '@wordpress/global-styles-engine';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { kebabCase } from '@wordpress/kebab-case';\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport { useSettings } from '../components/use-settings';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { cleanEmptyObject, useBlockSettings, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport { getVariationNameFromClass } from './block-style-variation';\nimport {\n\tDEFAULT_BLOCK_STYLE_STATE,\n\tgetStyleForState,\n\thasPseudoBlockStyleState,\n\thasViewportBlockStyleState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n} from './block-style-state';\n\nconst VARIATION_PREFIX = 'is-style-';\n\nconst layoutBlockSupportKey = 'layout';\nconst CHILD_LAYOUT_KEYS = [\n\t'selfStretch',\n\t'flexSize',\n\t'columnStart',\n\t'columnSpan',\n\t'rowStart',\n\t'rowSpan',\n];\nconst { getResponsiveMediaQueries } = unlock( globalStylesEnginePrivateApis );\n\nfunction getDefaultLayout( layoutBlockSupport = {}, blockVariation ) {\n\tconst defaultBlockLayout = layoutBlockSupport?.default;\n\n\treturn blockVariation?.attributes?.layout ?? defaultBlockLayout;\n}\n\n/**\n * Returns the layout values to use when resetting layout controls.\n *\n * @param { Object } layoutBlockSupport Block layout support settings.\n * @param { Object|undefined } blockVariation Block variation settings.\n *\n * @return { Object|undefined } Reset layout values.\n */\nexport function getResetLayout( layoutBlockSupport = {}, blockVariation ) {\n\treturn cleanEmptyObject( {\n\t\t...getDefaultLayout( layoutBlockSupport, blockVariation ),\n\t} );\n}\n\nexport function getLayoutStateOverrides(\n\tlayout = {},\n\tbaseLayout = {},\n\texistingLayout = {}\n) {\n\tconst overrides = {};\n\tconst childLayoutValues = Object.fromEntries(\n\t\tCHILD_LAYOUT_KEYS.filter( ( key ) =>\n\t\t\tObject.hasOwn( existingLayout || {}, key )\n\t\t).map( ( key ) => [ key, existingLayout[ key ] ] )\n\t);\n\n\tObject.entries( layout || {} ).forEach( ( [ key, value ] ) => {\n\t\tconst baseHasValue = Object.hasOwn( baseLayout || {}, key );\n\t\tif (\n\t\t\t! CHILD_LAYOUT_KEYS.includes( key ) &&\n\t\t\tvalue !== baseLayout?.[ key ]\n\t\t) {\n\t\t\toverrides[ key ] =\n\t\t\t\tvalue === undefined && baseHasValue ? null : value;\n\t\t}\n\t} );\n\n\treturn cleanEmptyObject( {\n\t\t...childLayoutValues,\n\t\t...overrides,\n\t} );\n}\n\n/**\n * Checks whether the layout panel has any controls to display.\n *\n * @param {Object} options Options.\n * @param {Object} options.layoutType Active layout type.\n * @param {Object} options.constrainedType Constrained layout type.\n * @param {Object} options.layoutBlockSupport Layout support settings.\n * @param {boolean} options.showInheritToggle Whether to show the inherit toggle.\n * @param {boolean} options.showLayoutTypeSwitcher Whether to show the layout type switcher.\n * @param {boolean} options.displayControlsForLegacyLayouts Whether to show legacy layout controls.\n *\n * @return {boolean} Whether the layout panel has controls.\n */\nexport function hasLayoutPanelControls( {\n\tlayoutType,\n\tconstrainedType,\n\tlayoutBlockSupport,\n\tshowInheritToggle,\n\tshowLayoutTypeSwitcher,\n\tdisplayControlsForLegacyLayouts,\n} ) {\n\tconst hasActiveLayoutControls =\n\t\tlayoutType?.name !== 'default' &&\n\t\tlayoutType?.hasInspectorControls( layoutBlockSupport );\n\tconst hasLegacyLayoutControls =\n\t\tdisplayControlsForLegacyLayouts &&\n\t\tconstrainedType?.hasInspectorControls( layoutBlockSupport );\n\n\treturn !! (\n\t\tshowInheritToggle ||\n\t\tshowLayoutTypeSwitcher ||\n\t\thasActiveLayoutControls ||\n\t\thasLegacyLayoutControls\n\t);\n}\n\nfunction getLayoutContainerValues( layout = {} ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( layout || {} ).filter(\n\t\t\t( [ key ] ) => ! CHILD_LAYOUT_KEYS.includes( key )\n\t\t)\n\t);\n}\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst { layout } = blockAttributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tconst hasGlobalPadding = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when layout doesn't use global padding\n\t\t\tif (\n\t\t\t\t! usedLayout?.inherit &&\n\t\t\t\t! usedLayout?.contentSize &&\n\t\t\t\tusedLayout?.type !== 'constrained'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn select( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalFeatures?.useRootPaddingAwareAlignments;\n\t\t},\n\t\t[ usedLayout?.contentSize, usedLayout?.inherit, usedLayout?.type ]\n\t);\n\n\tif ( hasGlobalPadding ) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\treturn fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n}\n\n/**\n * Generates responsive layout CSS for viewport state styles.\n *\n * Viewport state blockGap values need to go through the layout definitions\n * because flow/constrained layouts use child margins while flex/grid use gap.\n *\n * @param { Object } options Options.\n * @param { Object } options.attributes Block attributes.\n * @param { string } options.blockName Block name.\n * @param { string } options.selector CSS selector.\n * @param { Object } options.layout Active block layout.\n * @param { boolean } options.hasBlockGapSupport Whether block gap is supported.\n * @param { * } options.globalBlockGapValue Global block gap fallback.\n * @param { Object } options.viewportSettings Viewport breakpoint settings.\n *\n * @return { string } CSS rule.\n */\nexport function getResponsiveLayoutStyles( {\n\tattributes = {},\n\tblockName,\n\tselector,\n\tlayout = {},\n\thasBlockGapSupport,\n\tglobalBlockGapValue,\n\tviewportSettings,\n} ) {\n\treturn Object.entries( getResponsiveMediaQueries( viewportSettings ) )\n\t\t.map( ( [ viewport, mediaQuery ] ) => {\n\t\t\tconst viewportStyle = getStyleForState( attributes?.style, {\n\t\t\t\tviewport,\n\t\t\t\tpseudo: DEFAULT_BLOCK_STYLE_STATE.pseudo,\n\t\t\t} );\n\t\t\tconst viewportLayout = getLayoutContainerValues(\n\t\t\t\tviewportStyle?.layout\n\t\t\t);\n\t\t\tconst hasViewportLayout = Object.keys( viewportLayout ).length > 0;\n\t\t\tconst hasViewportBlockGap =\n\t\t\t\tviewportStyle?.spacing &&\n\t\t\t\tObject.hasOwn( viewportStyle.spacing, 'blockGap' );\n\t\t\tconst hasViewportPadding =\n\t\t\t\tviewportStyle?.spacing &&\n\t\t\t\tObject.hasOwn( viewportStyle.spacing, 'padding' );\n\t\t\tif (\n\t\t\t\t! hasViewportLayout &&\n\t\t\t\t! hasViewportBlockGap &&\n\t\t\t\t! hasViewportPadding\n\t\t\t) {\n\t\t\t\treturn '';\n\t\t\t}\n\n\t\t\tconst layoutType = getLayoutType( layout?.type || 'default' );\n\t\t\tconst viewportCSS = layoutType?.getLayoutStyle?.( {\n\t\t\t\tblockName,\n\t\t\t\tselector,\n\t\t\t\tlayout,\n\t\t\t\tviewportOverrides: viewportLayout,\n\t\t\t\tstyle: viewportStyle,\n\t\t\t\thasBlockGapSupport,\n\t\t\t\tglobalBlockGapValue,\n\t\t\t} );\n\n\t\t\treturn viewportCSS ? `${ mediaQuery }{${ viewportCSS }}` : '';\n\t\t} )\n\t\t.filter( Boolean )\n\t\t.join( '' );\n}\n\nfunction LayoutPanelPure( {\n\tlayout,\n\tstyle,\n\tsetAttributes,\n\tname: blockName,\n\tclientId,\n} ) {\n\tconst settings = useBlockSettings( blockName );\n\t// Block settings come from theme.json under settings.[blockName].\n\tconst { layout: layoutSettings } = settings;\n\tconst {\n\t\tthemeSupportsLayout,\n\t\tactiveBlockVariation,\n\t\tselectedState,\n\t\tisResponsiveEditing,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetSettings,\n\t\t\t\tgetSelectedBlockStyleState,\n\t\t\t\tisResponsiveEditing: getIsResponsiveEditing,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\treturn {\n\t\t\t\tactiveBlockVariation: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).getActiveBlockVariation(\n\t\t\t\t\tblockName,\n\t\t\t\t\tgetBlockAttributes( clientId ) || {},\n\t\t\t\t\t'block'\n\t\t\t\t),\n\t\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t\t\tselectedState: getSelectedBlockStyleState( clientId ),\n\t\t\t\tisResponsiveEditing: getIsResponsiveEditing(),\n\t\t\t};\n\t\t},\n\t\t[ blockName, clientId ]\n\t);\n\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isViewportLayoutState =\n\t\thasViewportBlockStyleState( selectedState ) &&\n\t\t! hasPseudoBlockStyleState( selectedState );\n\tconst resetLayoutFilter = useCallback(\n\t\t( ...resetArgs ) => {\n\t\t\tconst attributes = resetArgs[ 0 ] || {};\n\t\t\tconst context = resetArgs[ 1 ] || {};\n\n\t\t\tif ( isViewportLayoutState ) {\n\t\t\t\tconst existingStateStyle =\n\t\t\t\t\tgetStyleForState(\n\t\t\t\t\t\tattributes.style ?? style,\n\t\t\t\t\t\tselectedState\n\t\t\t\t\t) || {};\n\t\t\t\tconst nextStateStyle = cleanEmptyObject( {\n\t\t\t\t\t...existingStateStyle,\n\t\t\t\t\tlayout: undefined,\n\t\t\t\t} );\n\n\t\t\t\treturn {\n\t\t\t\t\tstyle: setStyleForState(\n\t\t\t\t\t\tattributes.style ?? style,\n\t\t\t\t\t\tselectedState,\n\t\t\t\t\t\tnextStateStyle\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst resetBlockName = context.name || blockName;\n\t\t\tconst resetLayoutBlockSupport = getBlockSupport(\n\t\t\t\tresetBlockName,\n\t\t\t\tlayoutBlockSupportKey,\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlayout: getResetLayout(\n\t\t\t\t\tresetLayoutBlockSupport,\n\t\t\t\t\tactiveBlockVariation\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tblockName,\n\t\t\tactiveBlockVariation,\n\t\t\tisViewportLayoutState,\n\t\t\tselectedState,\n\t\t\tstyle,\n\t\t]\n\t);\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\t// Layout block support comes from the block's block.json.\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst blockSupportAndThemeSettings = {\n\t\t...layoutSettings,\n\t\t...layoutBlockSupport,\n\t};\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = blockSupportAndThemeSettings;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * Try to find the layout type from either the\n\t * block's layout settings or any saved layout config.\n\t */\n\tconst baseLayout = layout || defaultBlockLayout || {};\n\tconst stateStyle = isViewportLayoutState\n\t\t? getStyleForState( style, selectedState )\n\t\t: undefined;\n\tconst stateLayout = stateStyle?.layout;\n\tconst usedLayout = isViewportLayoutState\n\t\t? cleanEmptyObject( {\n\t\t\t\t...baseLayout,\n\t\t\t\t...stateLayout,\n\t\t } ) || {}\n\t\t: baseLayout;\n\tconst resetLayoutDefaults = isViewportLayoutState\n\t\t? baseLayout\n\t\t: getResetLayout( layoutBlockSupport, activeBlockVariation );\n\tconst blockSupportAndLayout = {\n\t\t...layoutBlockSupport,\n\t\t...usedLayout,\n\t};\n\tconst { type, default: { type: defaultType = 'default' } = {} } =\n\t\tblockSupportAndLayout;\n\tconst blockLayoutType = type || defaultType;\n\n\t// Only show the inherit toggle if it's supported,\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t( ! blockLayoutType ||\n\t\t\tblockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ||\n\t\t\tblockSupportAndLayout.inherit )\n\t);\n\n\tconst { inherit = false, contentSize = null } = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( blockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( blockLayoutType );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\tconst showLayoutTypeSwitcher =\n\t\tisDefaultBlockStyleState( selectedState ) &&\n\t\t! inherit &&\n\t\tallowSwitching;\n\tconst showLayoutPanel = hasLayoutPanelControls( {\n\t\tlayoutType,\n\t\tconstrainedType,\n\t\tlayoutBlockSupport: blockSupportAndThemeSettings,\n\t\tshowInheritToggle,\n\t\tshowLayoutTypeSwitcher,\n\t\tdisplayControlsForLegacyLayouts,\n\t} );\n\n\tconst onChangeLayout = ( newLayout ) => {\n\t\tif ( isViewportLayoutState ) {\n\t\t\tconst nextStateStyle = cleanEmptyObject( {\n\t\t\t\t...stateStyle,\n\t\t\t\tlayout: getLayoutStateOverrides(\n\t\t\t\t\tnewLayout,\n\t\t\t\t\tbaseLayout,\n\t\t\t\t\tstateStyle?.layout\n\t\t\t\t),\n\t\t\t} );\n\t\t\tsetAttributes( {\n\t\t\t\tstyle: setStyleForState( style, selectedState, nextStateStyle ),\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\tsetAttributes( { layout: cleanEmptyObject( newLayout ) } );\n\t};\n\tconst onChangeType = ( newType ) => onChangeLayout( { type: newType } );\n\tconst resetLayout = () => onChangeLayout( resetLayoutDefaults );\n\tconst resetInheritToggle = () => onChangeLayout( { type: 'default' } );\n\tconst isUsingContentWidth = () =>\n\t\tlayoutType?.name === 'constrained' || hasContentSizeOrLegacySettings;\n\tconst hasInheritToggleValue = () =>\n\t\tisViewportLayoutState\n\t\t\t? ( usedLayout?.type ?? 'default' ) !==\n\t\t\t ( resetLayoutDefaults?.type ?? 'default' )\n\t\t\t: layout?.type === 'constrained';\n\tconst hasLayoutTypeValue = () =>\n\t\t( usedLayout?.type ?? 'default' ) !==\n\t\t( resetLayoutDefaults?.type ?? 'default' );\n\n\treturn (\n\t\t<>\n\t\t\t{ showLayoutPanel && (\n\t\t\t\t<InspectorControls\n\t\t\t\t\tgroup=\"layout\"\n\t\t\t\t\tresetAllFilter={ resetLayoutFilter }\n\t\t\t\t>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Use content width' ) }\n\t\t\t\t\t\t\thasValue={ hasInheritToggleValue }\n\t\t\t\t\t\t\tonDeselect={ resetInheritToggle }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={ isUsingContentWidth() }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tonChangeLayout( {\n\t\t\t\t\t\t\t\t\t\ttype: isUsingContentWidth()\n\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\tisUsingContentWidth()\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ showLayoutTypeSwitcher && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Layout type' ) }\n\t\t\t\t\t\t\thasValue={ hasLayoutTypeValue }\n\t\t\t\t\t\t\tonDeselect={ resetLayout }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\t\ttype={ blockLayoutType }\n\t\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tvalue={ layout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t\tresetLayout={ resetLayoutDefaults }\n\t\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tvalue={ layout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t\tresetLayout={ resetLayoutDefaults }\n\t\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\tcontrolsGroup={\n\t\t\t\t\t\tisResponsiveEditing &&\n\t\t\t\t\t\thasViewportBlockStyleState( selectedState ) &&\n\t\t\t\t\t\t! hasPseudoBlockStyleState( selectedState )\n\t\t\t\t\t\t\t? 'style-state'\n\t\t\t\t\t\t\t: 'block'\n\t\t\t\t\t}\n\t\t\t\t\tname={ blockName }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: LayoutPanelPure,\n\tattributeKeys: [ 'layout', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasLayoutBlockSupport( name );\n\t},\n};\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\tisBlock\n\t\t\tlabel={ __( 'Layout type' ) }\n\t\t\thideLabelFromVision\n\t\t\tisAdaptiveWidth\n\t\t\tvalue={ type }\n\t\t\tonChange={ onChange }\n\t\t>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockWithLayoutStyles( {\n\tblock: BlockListBlock,\n\tprops,\n\tblockGapSupport,\n\tglobalBlockGapValue,\n\tviewportSettings,\n\tlayoutClasses,\n} ) {\n\tconst { name, attributes } = props;\n\tconst id = useInstanceId( BlockListBlock );\n\tconst { layout } = attributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst selectorPrefix = `wp-container-${ kebabCase( name ) }-is-layout-`;\n\t// Higher specificity to override defaults from theme.json.\n\tconst selector = `.${ selectorPrefix }${ id }`;\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t// Get CSS string for the current layout type.\n\t// The CSS and `style` element is only output if it is not empty.\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst baseLayoutCSS = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\tstyle: attributes?.style,\n\t\thasBlockGapSupport,\n\t\tglobalBlockGapValue,\n\t} );\n\tconst responsiveLayoutCSS = getResponsiveLayoutStyles( {\n\t\tattributes,\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\thasBlockGapSupport,\n\t\tglobalBlockGapValue,\n\t\tviewportSettings,\n\t} );\n\tconst css = [ baseLayoutCSS, responsiveLayoutCSS ]\n\t\t.filter( Boolean )\n\t\t.join( '' );\n\n\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\tconst layoutClassNames = clsx(\n\t\t{\n\t\t\t[ `${ selectorPrefix }${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t},\n\t\tlayoutClasses\n\t);\n\n\tuseStyleOverride( { css } );\n\n\treturn (\n\t\t<BlockListBlock\n\t\t\t{ ...props }\n\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t/>\n\t);\n}\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) =>\n\t\tfunction WithLayoutStyles( props ) {\n\t\t\tconst { clientId, name, attributes } = props;\n\t\t\tconst blockSupportsLayout = hasLayoutBlockSupport( name );\n\t\t\tconst layoutClasses = useLayoutClasses( attributes, name );\n\t\t\tconst extraProps = useSelect(\n\t\t\t\t( select ) => {\n\t\t\t\t\t// The callback returns early to avoid block editor subscription.\n\t\t\t\t\tif ( ! blockSupportsLayout ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { getSettings, getBlockSettings } = unlock(\n\t\t\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t);\n\t\t\t\t\tconst settings = getSettings();\n\t\t\t\t\tconst { disableLayoutStyles } = settings;\n\n\t\t\t\t\tif ( disableLayoutStyles ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst [ blockGapSupport ] = getBlockSettings(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t'spacing.blockGap'\n\t\t\t\t\t);\n\n\t\t\t\t\t// Get default blockGap value from global styles for use in layouts like grid.\n\t\t\t\t\t// Check style variation first, then block-specific styles, then fall back to root styles.\n\t\t\t\t\tconst globalStyles = settings[ globalStylesDataKey ];\n\n\t\t\t\t\t// Check if the block has an active style variation with a blockGap value.\n\t\t\t\t\t// Only check the registry if the className contains a variation class to avoid unnecessary lookups.\n\t\t\t\t\tlet variationBlockGapValue;\n\t\t\t\t\tconst className = attributes?.className;\n\t\t\t\t\tif ( className?.includes( VARIATION_PREFIX ) ) {\n\t\t\t\t\t\tconst { getBlockStyles } = select( blocksStore );\n\t\t\t\t\t\tconst registeredStyles = getBlockStyles( name );\n\t\t\t\t\t\tconst variationName = getVariationNameFromClass(\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\tregisteredStyles\n\t\t\t\t\t\t);\n\t\t\t\t\t\tvariationBlockGapValue = variationName\n\t\t\t\t\t\t\t? globalStyles?.blocks?.[ name ]?.variations?.[\n\t\t\t\t\t\t\t\t\tvariationName\n\t\t\t\t\t\t\t ]?.spacing?.blockGap\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst globalBlockGapValue =\n\t\t\t\t\t\tvariationBlockGapValue ??\n\t\t\t\t\t\tglobalStyles?.blocks?.[ name ]?.spacing?.blockGap ??\n\t\t\t\t\t\tglobalStyles?.spacing?.blockGap;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tblockGapSupport,\n\t\t\t\t\t\tglobalBlockGapValue,\n\t\t\t\t\t\tviewportSettings:\n\t\t\t\t\t\t\tsettings?.__experimentalFeatures?.viewport,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[ blockSupportsLayout, clientId, attributes?.className, name ]\n\t\t\t);\n\n\t\t\tif ( ! extraProps ) {\n\t\t\t\treturn (\n\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t__unstableLayoutClassNames={\n\t\t\t\t\t\t\tblockSupportsLayout ? layoutClasses : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<BlockWithLayoutStyles\n\t\t\t\t\tblock={ BlockListBlock }\n\t\t\t\t\tprops={ props }\n\t\t\t\t\tlayoutClasses={ layoutClasses }\n\t\t\t\t\t{ ...extraProps }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t'withLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,4BAA4B,qBAAqB;AAC1D,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,eAAe,qCAAqC;AAC7D,SAAS,iBAAiB;AAC1B;AAAA,EACC,oCAAoC;AAAA,EACpC,0CAA0C;AAAA,EAC1C;AAAA,EACA,gCAAgC;AAAA,OAC1B;AACP,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,eAAe,sBAAsB;AAC9C,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,kBAAkB,kBAAkB,wBAAwB;AACrE,SAAS,cAAc;AACvB,SAAS,2BAA2B;AACpC,SAAS,iCAAiC;AAC1C;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AA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gBAAgB;AAAA;AAAA,MAExC;AAAA,IAEF;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACE,GAAG;AAAA;AAAA,IACN;AAAA,EAEF;AAAA,EACD;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useCallback } from '@wordpress/element';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { privateApis as globalStylesEnginePrivateApis } from '@wordpress/global-styles-engine';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { kebabCase } from '@wordpress/kebab-case';\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport { useSettings } from '../components/use-settings';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { normalizeLegacyLayout } from '../layouts/utils';\nimport { cleanEmptyObject, useBlockSettings, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport { getVariationNameFromClass } from './block-style-variation';\nimport {\n\tDEFAULT_BLOCK_STYLE_STATE,\n\tgetStyleForState,\n\thasPseudoBlockStyleState,\n\thasViewportBlockStyleState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n} from './block-style-state';\n\nconst VARIATION_PREFIX = 'is-style-';\n\nconst layoutBlockSupportKey = 'layout';\nconst CHILD_LAYOUT_KEYS = [\n\t'selfStretch',\n\t'flexSize',\n\t'columnStart',\n\t'columnSpan',\n\t'rowStart',\n\t'rowSpan',\n];\nconst { getResponsiveMediaQueries } = unlock( globalStylesEnginePrivateApis );\n\nfunction getDefaultLayout( layoutBlockSupport = {}, blockVariation ) {\n\tconst defaultBlockLayout = layoutBlockSupport?.default;\n\n\treturn blockVariation?.attributes?.layout ?? defaultBlockLayout;\n}\n\n/**\n * Returns the layout values to use when resetting layout controls.\n *\n * @param { Object } layoutBlockSupport Block layout support settings.\n * @param { Object|undefined } blockVariation Block variation settings.\n *\n * @return { Object|undefined } Reset layout values.\n */\nexport function getResetLayout( layoutBlockSupport = {}, blockVariation ) {\n\treturn cleanEmptyObject( {\n\t\t...getDefaultLayout( layoutBlockSupport, blockVariation ),\n\t} );\n}\n\nexport function getLayoutStateOverrides(\n\tlayout = {},\n\tbaseLayout = {},\n\texistingLayout = {}\n) {\n\tconst overrides = {};\n\tconst childLayoutValues = Object.fromEntries(\n\t\tCHILD_LAYOUT_KEYS.filter( ( key ) =>\n\t\t\tObject.hasOwn( existingLayout || {}, key )\n\t\t).map( ( key ) => [ key, existingLayout[ key ] ] )\n\t);\n\n\tObject.entries( layout || {} ).forEach( ( [ key, value ] ) => {\n\t\tconst baseHasValue = Object.hasOwn( baseLayout || {}, key );\n\t\tif (\n\t\t\t! CHILD_LAYOUT_KEYS.includes( key ) &&\n\t\t\tvalue !== baseLayout?.[ key ]\n\t\t) {\n\t\t\toverrides[ key ] =\n\t\t\t\tvalue === undefined && baseHasValue ? null : value;\n\t\t}\n\t} );\n\n\treturn cleanEmptyObject( {\n\t\t...childLayoutValues,\n\t\t...overrides,\n\t} );\n}\n\n/**\n * Checks whether the layout panel has any controls to display.\n *\n * @param {Object} options Options.\n * @param {Object} options.layoutType Active layout type.\n * @param {Object} options.constrainedType Constrained layout type.\n * @param {Object} options.layoutBlockSupport Layout support settings.\n * @param {boolean} options.showInheritToggle Whether to show the inherit toggle.\n * @param {boolean} options.showLayoutTypeSwitcher Whether to show the layout type switcher.\n * @param {boolean} options.displayControlsForLegacyLayouts Whether to show legacy layout controls.\n *\n * @return {boolean} Whether the layout panel has controls.\n */\nexport function hasLayoutPanelControls( {\n\tlayoutType,\n\tconstrainedType,\n\tlayoutBlockSupport,\n\tshowInheritToggle,\n\tshowLayoutTypeSwitcher,\n\tdisplayControlsForLegacyLayouts,\n} ) {\n\tconst hasActiveLayoutControls =\n\t\tlayoutType?.name !== 'default' &&\n\t\tlayoutType?.hasInspectorControls( layoutBlockSupport );\n\tconst hasLegacyLayoutControls =\n\t\tdisplayControlsForLegacyLayouts &&\n\t\tconstrainedType?.hasInspectorControls( layoutBlockSupport );\n\n\treturn !! (\n\t\tshowInheritToggle ||\n\t\tshowLayoutTypeSwitcher ||\n\t\thasActiveLayoutControls ||\n\t\thasLegacyLayoutControls\n\t);\n}\n\nfunction getLayoutContainerValues( layout = {} ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( layout || {} ).filter(\n\t\t\t( [ key ] ) => ! CHILD_LAYOUT_KEYS.includes( key )\n\t\t)\n\t);\n}\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst { layout } = blockAttributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tnormalizeLegacyLayout( layout ) || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tconst hasGlobalPadding = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when layout doesn't use global padding\n\t\t\tif (\n\t\t\t\t! usedLayout?.inherit &&\n\t\t\t\t! usedLayout?.contentSize &&\n\t\t\t\tusedLayout?.type !== 'constrained'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn select( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalFeatures?.useRootPaddingAwareAlignments;\n\t\t},\n\t\t[ usedLayout?.contentSize, usedLayout?.inherit, usedLayout?.type ]\n\t);\n\n\tif ( hasGlobalPadding ) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\tconst usedLayout = normalizeLegacyLayout( layout ) || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\t// Like the server's `isset()` check, an unset or `null` setting means the\n\t// theme has not opted into block gap.\n\tconst hasBlockGapSupport =\n\t\tblockGapSupport !== null && blockGapSupport !== undefined;\n\treturn fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n}\n\n/**\n * Generates responsive layout CSS for viewport state styles.\n *\n * Viewport state blockGap values need to go through the layout definitions\n * because flow/constrained layouts use child margins while flex/grid use gap.\n *\n * @param { Object } options Options.\n * @param { Object } options.attributes Block attributes.\n * @param { string } options.blockName Block name.\n * @param { string } options.selector CSS selector.\n * @param { Object } options.layout Active block layout.\n * @param { boolean } options.hasBlockGapSupport Whether block gap is supported.\n * @param { * } options.globalBlockGapValue Global block gap fallback.\n * @param { Object } options.viewportSettings Viewport breakpoint settings.\n *\n * @return { string } CSS rule.\n */\nexport function getResponsiveLayoutStyles( {\n\tattributes = {},\n\tblockName,\n\tselector,\n\tlayout = {},\n\thasBlockGapSupport,\n\tglobalBlockGapValue,\n\tviewportSettings,\n} ) {\n\treturn Object.entries( getResponsiveMediaQueries( viewportSettings ) )\n\t\t.map( ( [ viewport, mediaQuery ] ) => {\n\t\t\tconst viewportStyle = getStyleForState( attributes?.style, {\n\t\t\t\tviewport,\n\t\t\t\tpseudo: DEFAULT_BLOCK_STYLE_STATE.pseudo,\n\t\t\t} );\n\t\t\tconst viewportLayout = getLayoutContainerValues(\n\t\t\t\tviewportStyle?.layout\n\t\t\t);\n\t\t\tconst hasViewportLayout = Object.keys( viewportLayout ).length > 0;\n\t\t\tconst hasViewportBlockGap =\n\t\t\t\tviewportStyle?.spacing &&\n\t\t\t\tObject.hasOwn( viewportStyle.spacing, 'blockGap' );\n\t\t\tconst hasViewportPadding =\n\t\t\t\tviewportStyle?.spacing &&\n\t\t\t\tObject.hasOwn( viewportStyle.spacing, 'padding' );\n\t\t\tif (\n\t\t\t\t! hasViewportLayout &&\n\t\t\t\t! hasViewportBlockGap &&\n\t\t\t\t! hasViewportPadding\n\t\t\t) {\n\t\t\t\treturn '';\n\t\t\t}\n\n\t\t\tconst layoutType = getLayoutType( layout?.type || 'default' );\n\t\t\tconst viewportCSS = layoutType?.getLayoutStyle?.( {\n\t\t\t\tblockName,\n\t\t\t\tselector,\n\t\t\t\tlayout,\n\t\t\t\tviewportOverrides: viewportLayout,\n\t\t\t\tstyle: viewportStyle,\n\t\t\t\thasBlockGapSupport,\n\t\t\t\tglobalBlockGapValue,\n\t\t\t} );\n\n\t\t\treturn viewportCSS ? `${ mediaQuery }{${ viewportCSS }}` : '';\n\t\t} )\n\t\t.filter( Boolean )\n\t\t.join( '' );\n}\n\nfunction LayoutPanelPure( {\n\tlayout,\n\tstyle,\n\tsetAttributes,\n\tname: blockName,\n\tclientId,\n} ) {\n\tconst settings = useBlockSettings( blockName );\n\t// Block settings come from theme.json under settings.[blockName].\n\tconst { layout: layoutSettings } = settings;\n\tconst {\n\t\tthemeSupportsLayout,\n\t\tactiveBlockVariation,\n\t\tselectedState,\n\t\tisResponsiveEditing,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetSettings,\n\t\t\t\tgetSelectedBlockStyleState,\n\t\t\t\tisResponsiveEditing: getIsResponsiveEditing,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\treturn {\n\t\t\t\tactiveBlockVariation: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).getActiveBlockVariation(\n\t\t\t\t\tblockName,\n\t\t\t\t\tgetBlockAttributes( clientId ) || {},\n\t\t\t\t\t'block'\n\t\t\t\t),\n\t\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t\t\tselectedState: getSelectedBlockStyleState( clientId ),\n\t\t\t\tisResponsiveEditing: getIsResponsiveEditing(),\n\t\t\t};\n\t\t},\n\t\t[ blockName, clientId ]\n\t);\n\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isViewportLayoutState =\n\t\thasViewportBlockStyleState( selectedState ) &&\n\t\t! hasPseudoBlockStyleState( selectedState );\n\tconst resetLayoutFilter = useCallback(\n\t\t( ...resetArgs ) => {\n\t\t\tconst attributes = resetArgs[ 0 ] || {};\n\t\t\tconst context = resetArgs[ 1 ] || {};\n\n\t\t\tif ( isViewportLayoutState ) {\n\t\t\t\tconst existingStateStyle =\n\t\t\t\t\tgetStyleForState(\n\t\t\t\t\t\tattributes.style ?? style,\n\t\t\t\t\t\tselectedState\n\t\t\t\t\t) || {};\n\t\t\t\tconst nextStateStyle = cleanEmptyObject( {\n\t\t\t\t\t...existingStateStyle,\n\t\t\t\t\tlayout: undefined,\n\t\t\t\t} );\n\n\t\t\t\treturn {\n\t\t\t\t\tstyle: setStyleForState(\n\t\t\t\t\t\tattributes.style ?? style,\n\t\t\t\t\t\tselectedState,\n\t\t\t\t\t\tnextStateStyle\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst resetBlockName = context.name || blockName;\n\t\t\tconst resetLayoutBlockSupport = getBlockSupport(\n\t\t\t\tresetBlockName,\n\t\t\t\tlayoutBlockSupportKey,\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlayout: getResetLayout(\n\t\t\t\t\tresetLayoutBlockSupport,\n\t\t\t\t\tactiveBlockVariation\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tblockName,\n\t\t\tactiveBlockVariation,\n\t\t\tisViewportLayoutState,\n\t\t\tselectedState,\n\t\t\tstyle,\n\t\t]\n\t);\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\t// Layout block support comes from the block's block.json.\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst blockSupportAndThemeSettings = {\n\t\t...layoutSettings,\n\t\t...layoutBlockSupport,\n\t};\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = blockSupportAndThemeSettings;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * Try to find the layout type from either the\n\t * block's layout settings or any saved layout config.\n\t */\n\tconst baseLayout = layout || defaultBlockLayout || {};\n\tconst stateStyle = isViewportLayoutState\n\t\t? getStyleForState( style, selectedState )\n\t\t: undefined;\n\tconst stateLayout = stateStyle?.layout;\n\tconst usedLayout = isViewportLayoutState\n\t\t? cleanEmptyObject( {\n\t\t\t\t...baseLayout,\n\t\t\t\t...stateLayout,\n\t\t\t} ) || {}\n\t\t: baseLayout;\n\tconst resetLayoutDefaults = isViewportLayoutState\n\t\t? baseLayout\n\t\t: getResetLayout( layoutBlockSupport, activeBlockVariation );\n\tconst blockSupportAndLayout = {\n\t\t...layoutBlockSupport,\n\t\t...usedLayout,\n\t};\n\tconst { type, default: { type: defaultType = 'default' } = {} } =\n\t\tblockSupportAndLayout;\n\tconst blockLayoutType = type || defaultType;\n\n\t// Only show the inherit toggle if it's supported,\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t( ! blockLayoutType ||\n\t\t\tblockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ||\n\t\t\tblockSupportAndLayout.inherit )\n\t);\n\n\tconst { inherit = false, contentSize = null } = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( blockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( blockLayoutType );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\tconst showLayoutTypeSwitcher =\n\t\tisDefaultBlockStyleState( selectedState ) &&\n\t\t! inherit &&\n\t\tallowSwitching;\n\tconst showLayoutPanel = hasLayoutPanelControls( {\n\t\tlayoutType,\n\t\tconstrainedType,\n\t\tlayoutBlockSupport: blockSupportAndThemeSettings,\n\t\tshowInheritToggle,\n\t\tshowLayoutTypeSwitcher,\n\t\tdisplayControlsForLegacyLayouts,\n\t} );\n\n\tconst onChangeLayout = ( newLayout ) => {\n\t\tif ( isViewportLayoutState ) {\n\t\t\tconst nextStateStyle = cleanEmptyObject( {\n\t\t\t\t...stateStyle,\n\t\t\t\tlayout: getLayoutStateOverrides(\n\t\t\t\t\tnewLayout,\n\t\t\t\t\tbaseLayout,\n\t\t\t\t\tstateStyle?.layout\n\t\t\t\t),\n\t\t\t} );\n\t\t\tsetAttributes( {\n\t\t\t\tstyle: setStyleForState( style, selectedState, nextStateStyle ),\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\tsetAttributes( { layout: cleanEmptyObject( newLayout ) } );\n\t};\n\tconst onChangeType = ( newType ) => onChangeLayout( { type: newType } );\n\tconst resetLayout = () => onChangeLayout( resetLayoutDefaults );\n\tconst resetInheritToggle = () => onChangeLayout( { type: 'default' } );\n\tconst isUsingContentWidth = () =>\n\t\tlayoutType?.name === 'constrained' || hasContentSizeOrLegacySettings;\n\tconst hasInheritToggleValue = () =>\n\t\tisViewportLayoutState\n\t\t\t? ( usedLayout?.type ?? 'default' ) !==\n\t\t\t\t( resetLayoutDefaults?.type ?? 'default' )\n\t\t\t: layout?.type === 'constrained';\n\tconst hasLayoutTypeValue = () =>\n\t\t( usedLayout?.type ?? 'default' ) !==\n\t\t( resetLayoutDefaults?.type ?? 'default' );\n\n\treturn (\n\t\t<>\n\t\t\t{ showLayoutPanel && (\n\t\t\t\t<InspectorControls\n\t\t\t\t\tgroup=\"layout\"\n\t\t\t\t\tresetAllFilter={ resetLayoutFilter }\n\t\t\t\t>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Use content width' ) }\n\t\t\t\t\t\t\thasValue={ hasInheritToggleValue }\n\t\t\t\t\t\t\tonDeselect={ resetInheritToggle }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={ isUsingContentWidth() }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tonChangeLayout( {\n\t\t\t\t\t\t\t\t\t\ttype: isUsingContentWidth()\n\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\tisUsingContentWidth()\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container.'\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ showLayoutTypeSwitcher && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\tlabel={ __( 'Layout type' ) }\n\t\t\t\t\t\t\thasValue={ hasLayoutTypeValue }\n\t\t\t\t\t\t\tonDeselect={ resetLayout }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\t\ttype={ blockLayoutType }\n\t\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tvalue={ layout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t\tresetLayout={ resetLayoutDefaults }\n\t\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tvalue={ layout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t\tresetLayout={ resetLayoutDefaults }\n\t\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\tcontrolsGroup={\n\t\t\t\t\t\tisResponsiveEditing &&\n\t\t\t\t\t\thasViewportBlockStyleState( selectedState ) &&\n\t\t\t\t\t\t! hasPseudoBlockStyleState( selectedState )\n\t\t\t\t\t\t\t? 'style-state'\n\t\t\t\t\t\t\t: 'block'\n\t\t\t\t\t}\n\t\t\t\t\tname={ blockName }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: LayoutPanelPure,\n\tattributeKeys: [ 'layout', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasLayoutBlockSupport( name );\n\t},\n};\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\tisBlock\n\t\t\tlabel={ __( 'Layout type' ) }\n\t\t\thideLabelFromVision\n\t\t\tisAdaptiveWidth\n\t\t\tvalue={ type }\n\t\t\tonChange={ onChange }\n\t\t>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockWithLayoutStyles( {\n\tblock: BlockListBlock,\n\tprops,\n\tblockGapSupport,\n\tglobalBlockGapValue,\n\tviewportSettings,\n\tlayoutClasses,\n} ) {\n\tconst { name, attributes } = props;\n\tconst id = useInstanceId( BlockListBlock );\n\tconst { layout } = attributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tnormalizeLegacyLayout( layout ) || defaultBlockLayout || {};\n\n\tconst selectorPrefix = `wp-container-${ kebabCase( name ) }-is-layout-`;\n\t// Higher specificity to override defaults from theme.json.\n\tconst selector = `.${ selectorPrefix }${ id }`;\n\t// Like the server's `isset()` check, an unset or `null` setting means the\n\t// theme has not opted into block gap.\n\tconst hasBlockGapSupport =\n\t\tblockGapSupport !== null && blockGapSupport !== undefined;\n\n\t// Get CSS string for the current layout type.\n\t// The CSS and `style` element is only output if it is not empty.\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst baseLayoutCSS = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\tstyle: attributes?.style,\n\t\thasBlockGapSupport,\n\t\tglobalBlockGapValue,\n\t} );\n\tconst responsiveLayoutCSS = getResponsiveLayoutStyles( {\n\t\tattributes,\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\thasBlockGapSupport,\n\t\tglobalBlockGapValue,\n\t\tviewportSettings,\n\t} );\n\tconst css = [ baseLayoutCSS, responsiveLayoutCSS ]\n\t\t.filter( Boolean )\n\t\t.join( '' );\n\n\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\tconst layoutClassNames = clsx(\n\t\t{\n\t\t\t[ `${ selectorPrefix }${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t},\n\t\tlayoutClasses\n\t);\n\n\tuseStyleOverride( { css } );\n\n\treturn (\n\t\t<BlockListBlock\n\t\t\t{ ...props }\n\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t/>\n\t);\n}\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) =>\n\t\tfunction WithLayoutStyles( props ) {\n\t\t\tconst { clientId, name, attributes } = props;\n\t\t\tconst blockSupportsLayout = hasLayoutBlockSupport( name );\n\t\t\tconst layoutClasses = useLayoutClasses( attributes, name );\n\t\t\tconst extraProps = useSelect(\n\t\t\t\t( select ) => {\n\t\t\t\t\t// The callback returns early to avoid block editor subscription.\n\t\t\t\t\tif ( ! blockSupportsLayout ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { getSettings, getBlockSettings } = unlock(\n\t\t\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t);\n\t\t\t\t\tconst settings = getSettings();\n\t\t\t\t\tconst { disableLayoutStyles } = settings;\n\n\t\t\t\t\tif ( disableLayoutStyles ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst [ blockGapSupport ] = getBlockSettings(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t'spacing.blockGap'\n\t\t\t\t\t);\n\n\t\t\t\t\t// Get default blockGap value from global styles for use in layouts like grid.\n\t\t\t\t\t// Check style variation first, then block-specific styles, then fall back to root styles.\n\t\t\t\t\tconst globalStyles = settings[ globalStylesDataKey ];\n\n\t\t\t\t\t// Check if the block has an active style variation with a blockGap value.\n\t\t\t\t\t// Only check the registry if the className contains a variation class to avoid unnecessary lookups.\n\t\t\t\t\tlet variationBlockGapValue;\n\t\t\t\t\tconst className = attributes?.className;\n\t\t\t\t\tif ( className?.includes( VARIATION_PREFIX ) ) {\n\t\t\t\t\t\tconst { getBlockStyles } = select( blocksStore );\n\t\t\t\t\t\tconst registeredStyles = getBlockStyles( name );\n\t\t\t\t\t\tconst variationName = getVariationNameFromClass(\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\tregisteredStyles\n\t\t\t\t\t\t);\n\t\t\t\t\t\tvariationBlockGapValue = variationName\n\t\t\t\t\t\t\t? globalStyles?.blocks?.[ name ]?.variations?.[\n\t\t\t\t\t\t\t\t\tvariationName\n\t\t\t\t\t\t\t\t]?.spacing?.blockGap\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst globalBlockGapValue =\n\t\t\t\t\t\tvariationBlockGapValue ??\n\t\t\t\t\t\tglobalStyles?.blocks?.[ name ]?.spacing?.blockGap ??\n\t\t\t\t\t\tglobalStyles?.spacing?.blockGap;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tblockGapSupport,\n\t\t\t\t\t\tglobalBlockGapValue,\n\t\t\t\t\t\tviewportSettings:\n\t\t\t\t\t\t\tsettings?.__experimentalFeatures?.viewport,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[ blockSupportsLayout, clientId, attributes?.className, name ]\n\t\t\t);\n\n\t\t\tif ( ! extraProps ) {\n\t\t\t\treturn (\n\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t__unstableLayoutClassNames={\n\t\t\t\t\t\t\tblockSupportsLayout ? layoutClasses : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<BlockWithLayoutStyles\n\t\t\t\t\tblock={ BlockListBlock }\n\t\t\t\t\tprops={ props }\n\t\t\t\t\tlayoutClasses={ layoutClasses }\n\t\t\t\t\t{ ...extraProps }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t'withLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,4BAA4B,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,gBAAgB;AAAA,YACrB;AAAA,YACA;AAAA,UACD;AACA,mCAAyB,gBACtB,cAAc,SAAU,IAAK,GAAG,aAChC,aACD,GAAG,SAAS,WACX;AAAA,QACJ;AAEA,cAAM,sBACL,0BACA,cAAc,SAAU,IAAK,GAAG,SAAS,YACzC,cAAc,SAAS;AAExB,eAAO;AAAA,UACN;AAAA,UACA;AAAA,UACA,kBACC,UAAU,wBAAwB;AAAA,QACpC;AAAA,MACD;AAAA,MACA,CAAE,qBAAqB,UAAU,YAAY,WAAW,IAAK;AAAA,IAC9D;AAEA,QAAK,CAAE,YAAa;AACnB,aACC;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,UACL,4BACC,sBAAsB,gBAAgB;AAAA;AAAA,MAExC;AAAA,IAEF;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACE,GAAG;AAAA;AAAA,IACN;AAAA,EAEF;AAAA,EACD;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,33 +4,30 @@ import { __, _x, sprintf } from "@wordpress/i18n";
|
|
|
4
4
|
import { getBlockSupport, hasBlockSupport } from "@wordpress/blocks";
|
|
5
5
|
import { useInstanceId } from "@wordpress/compose";
|
|
6
6
|
import { useSelect } from "@wordpress/data";
|
|
7
|
-
import {
|
|
7
|
+
import { useMemo } from "@wordpress/element";
|
|
8
8
|
import { SelectControl } from "@wordpress/ui";
|
|
9
9
|
import { useSettings } from "../components/use-settings/index.mjs";
|
|
10
10
|
import InspectorControls from "../components/inspector-controls/index.mjs";
|
|
11
11
|
import useBlockDisplayInformation from "../components/use-block-display-information/index.mjs";
|
|
12
12
|
import { cleanEmptyObject, useStyleOverride } from "./utils.mjs";
|
|
13
13
|
import { store as blockEditorStore } from "../store/index.mjs";
|
|
14
|
-
import { jsx
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
15
15
|
var POSITION_SUPPORT_KEY = "position";
|
|
16
16
|
var DEFAULT_OPTION = {
|
|
17
|
-
key: "default",
|
|
18
17
|
value: "",
|
|
19
18
|
label: __("Default")
|
|
20
19
|
};
|
|
21
20
|
var STICKY_OPTION = {
|
|
22
|
-
key: "sticky",
|
|
23
21
|
value: "sticky",
|
|
24
22
|
label: _x("Sticky", "Name for the value of the CSS position property"),
|
|
25
|
-
|
|
23
|
+
description: __(
|
|
26
24
|
"The block will stick to the top of the window instead of scrolling."
|
|
27
25
|
)
|
|
28
26
|
};
|
|
29
27
|
var FIXED_OPTION = {
|
|
30
|
-
key: "fixed",
|
|
31
28
|
value: "fixed",
|
|
32
29
|
label: _x("Fixed", "Name for the value of the CSS position property"),
|
|
33
|
-
|
|
30
|
+
description: __("The block will not move when the page is scrolled.")
|
|
34
31
|
};
|
|
35
32
|
var POSITION_SIDES = ["top", "right", "bottom", "left"];
|
|
36
33
|
var VALID_POSITION_TYPES = ["sticky", "fixed"];
|
|
@@ -146,7 +143,6 @@ function PositionPanelPure({
|
|
|
146
143
|
});
|
|
147
144
|
};
|
|
148
145
|
const selectedOption = value ? options.find((option) => option.value === value) || DEFAULT_OPTION : DEFAULT_OPTION;
|
|
149
|
-
const hintIdPrefix = useId();
|
|
150
146
|
return options.length > 1 ? /* @__PURE__ */ jsx(InspectorControls, { group: "position", children: /* @__PURE__ */ jsx(
|
|
151
147
|
SelectControl,
|
|
152
148
|
{
|
|
@@ -158,31 +154,7 @@ function PositionPanelPure({
|
|
|
158
154
|
value: selectedOption,
|
|
159
155
|
onValueChange: (selectedItem) => {
|
|
160
156
|
onChangeType(selectedItem.value);
|
|
161
|
-
}
|
|
162
|
-
children: options.map((option) => {
|
|
163
|
-
const hintId = option.hint ? `${hintIdPrefix}-${option.key}` : void 0;
|
|
164
|
-
return /* @__PURE__ */ jsxs(
|
|
165
|
-
SelectControl.Item,
|
|
166
|
-
{
|
|
167
|
-
value: option,
|
|
168
|
-
label: option.label,
|
|
169
|
-
"aria-describedby": hintId,
|
|
170
|
-
children: [
|
|
171
|
-
/* @__PURE__ */ jsx("div", { children: option.label }),
|
|
172
|
-
option.hint && /* @__PURE__ */ jsx(
|
|
173
|
-
"div",
|
|
174
|
-
{
|
|
175
|
-
id: hintId,
|
|
176
|
-
className: "block-editor-hooks__position-control-item-hint",
|
|
177
|
-
"aria-hidden": "true",
|
|
178
|
-
children: option.hint
|
|
179
|
-
}
|
|
180
|
-
)
|
|
181
|
-
]
|
|
182
|
-
},
|
|
183
|
-
option.key
|
|
184
|
-
);
|
|
185
|
-
})
|
|
157
|
+
}
|
|
186
158
|
}
|
|
187
159
|
) }) : null;
|
|
188
160
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/position.jsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useId, useMemo } from '@wordpress/element';\n// eslint-disable-next-line @wordpress/use-recommended-components -- Use the portal-based popup to avoid inspector clipping.\nimport { SelectControl } from '@wordpress/ui';\nimport { useSettings } from '../components/use-settings';\nimport InspectorControls from '../components/inspector-controls';\nimport useBlockDisplayInformation from '../components/use-block-display-information';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { store as blockEditorStore } from '../store';\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst DEFAULT_OPTION = {\n\tkey: 'default',\n\tvalue: '',\n\tlabel: __( 'Default' ),\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tlabel: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\thint: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tkey: 'fixed',\n\tvalue: 'fixed',\n\tlabel: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\thint: __( 'The block will not move when the page is scrolled.' ),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst [ allowFixed, allowSticky ] = useSettings(\n\t\t'position.fixed',\n\t\t'position.sticky'\n\t);\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {Element} Position panel.\n */\nexport function PositionPanelPure( {\n\tstyle = {},\n\tclientId,\n\tname: blockName,\n\tsetAttributes,\n} ) {\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { firstParentClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn { firstParentClientId: parents[ parents.length - 1 ] };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\tconst stickyHelpText =\n\t\tallowSticky && value === STICKY_OPTION.value && blockInformation\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: the name of the parent block. */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The block will stick to the scrollable area of the parent %s block.'\n\t\t\t\t\t),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: null;\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Display options if they are allowed, or if a block already has a valid value set.\n\t\t// This allows for a block to be switched off from a position type that is not allowed.\n\t\tif ( allowSticky || value === STICKY_OPTION.value ) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\tconst hintIdPrefix = useId();\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn options.length > 1 ? (\n\t\t<InspectorControls group=\"position\">\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\thideLabelFromVision\n\t\t\t\tdescription={ stickyHelpText }\n\t\t\t\tpopupWidth=\"anchor\"\n\t\t\t\titems={ options }\n\t\t\t\tvalue={ selectedOption }\n\t\t\t\tonValueChange={ ( selectedItem ) => {\n\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ options.map( ( option ) => {\n\t\t\t\t\tconst hintId = option.hint\n\t\t\t\t\t\t? `${ hintIdPrefix }-${ option.key }`\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SelectControl.Item\n\t\t\t\t\t\t\tkey={ option.key }\n\t\t\t\t\t\t\tvalue={ option }\n\t\t\t\t\t\t\tlabel={ option.label }\n\t\t\t\t\t\t\taria-describedby={ hintId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div>{ option.label }</div>\n\t\t\t\t\t\t\t{ option.hint && (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tid={ hintId }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__position-control-item-hint\"\n\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ option.hint }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</SelectControl.Item>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</SelectControl>\n\t\t</InspectorControls>\n\t) : null;\n}\n\nexport default {\n\tedit: function Edit( props ) {\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tif ( isPositionDisabled ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn <PositionPanelPure { ...props } />;\n\t},\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, POSITION_SUPPORT_KEY );\n\t},\n};\n\n// Used for generating the instance ID\nconst POSITION_BLOCK_PROPS_REFERENCE = {};\n\nfunction useBlockProps( { name, style } ) {\n\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\tname,\n\t\tPOSITION_SUPPORT_KEY\n\t);\n\tconst isPositionDisabled = useIsPositionDisabled( { name } );\n\tconst allowPositionStyles = hasPositionBlockSupport && ! isPositionDisabled;\n\n\tconst id = useInstanceId( POSITION_BLOCK_PROPS_REFERENCE );\n\n\t// Higher specificity to override defaults in editor UI.\n\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t// Get CSS string for the current position values.\n\tlet css;\n\tif ( allowPositionStyles ) {\n\t\tcss =\n\t\t\tgetPositionCSS( {\n\t\t\t\tselector: positionSelector,\n\t\t\t\tstyle,\n\t\t\t} ) || '';\n\t}\n\n\t// Attach a `wp-container-` id-based class name.\n\tconst className = clsx( {\n\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t[ `is-position-${ style?.position?.type }` ]:\n\t\t\tallowPositionStyles && !! css && !! style?.position?.type,\n\t} );\n\n\tuseStyleOverride( { css } );\n\n\treturn { className };\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { SelectControl } from '@wordpress/ui';\nimport { useSettings } from '../components/use-settings';\nimport InspectorControls from '../components/inspector-controls';\nimport useBlockDisplayInformation from '../components/use-block-display-information';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { store as blockEditorStore } from '../store';\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst DEFAULT_OPTION = {\n\tvalue: '',\n\tlabel: __( 'Default' ),\n};\n\nconst STICKY_OPTION = {\n\tvalue: 'sticky',\n\tlabel: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\tdescription: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tvalue: 'fixed',\n\tlabel: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\tdescription: __( 'The block will not move when the page is scrolled.' ),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst [ allowFixed, allowSticky ] = useSettings(\n\t\t'position.fixed',\n\t\t'position.sticky'\n\t);\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {Element} Position panel.\n */\nexport function PositionPanelPure( {\n\tstyle = {},\n\tclientId,\n\tname: blockName,\n\tsetAttributes,\n} ) {\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { firstParentClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn { firstParentClientId: parents[ parents.length - 1 ] };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\tconst stickyHelpText =\n\t\tallowSticky && value === STICKY_OPTION.value && blockInformation\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: the name of the parent block. */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The block will stick to the scrollable area of the parent %s block.'\n\t\t\t\t\t),\n\t\t\t\t\tblockInformation.title\n\t\t\t\t)\n\t\t\t: null;\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Display options if they are allowed, or if a block already has a valid value set.\n\t\t// This allows for a block to be switched off from a position type that is not allowed.\n\t\tif ( allowSticky || value === STICKY_OPTION.value ) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn options.length > 1 ? (\n\t\t<InspectorControls group=\"position\">\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\thideLabelFromVision\n\t\t\t\tdescription={ stickyHelpText }\n\t\t\t\tpopupWidth=\"anchor\"\n\t\t\t\titems={ options }\n\t\t\t\tvalue={ selectedOption }\n\t\t\t\tonValueChange={ ( selectedItem ) => {\n\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</InspectorControls>\n\t) : null;\n}\n\nexport default {\n\tedit: function Edit( props ) {\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tif ( isPositionDisabled ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn <PositionPanelPure { ...props } />;\n\t},\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, POSITION_SUPPORT_KEY );\n\t},\n};\n\n// Used for generating the instance ID\nconst POSITION_BLOCK_PROPS_REFERENCE = {};\n\nfunction useBlockProps( { name, style } ) {\n\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\tname,\n\t\tPOSITION_SUPPORT_KEY\n\t);\n\tconst isPositionDisabled = useIsPositionDisabled( { name } );\n\tconst allowPositionStyles = hasPositionBlockSupport && ! isPositionDisabled;\n\n\tconst id = useInstanceId( POSITION_BLOCK_PROPS_REFERENCE );\n\n\t// Higher specificity to override defaults in editor UI.\n\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t// Get CSS string for the current position values.\n\tlet css;\n\tif ( allowPositionStyles ) {\n\t\tcss =\n\t\t\tgetPositionCSS( {\n\t\t\t\tselector: positionSelector,\n\t\t\t\tstyle,\n\t\t\t} ) || '';\n\t}\n\n\t// Attach a `wp-container-` id-based class name.\n\tconst className = clsx( {\n\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t[ `is-position-${ style?.position?.type }` ]:\n\t\t\tallowPositionStyles && !! css && !! style?.position?.type,\n\t} );\n\n\tuseStyleOverride( { css } );\n\n\treturn { className };\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,OAAO,uBAAuB;AAC9B,OAAO,gCAAgC;AACvC,SAAS,kBAAkB,wBAAwB;AACnD,SAAS,SAAS,wBAAwB;AAmPvC;AAjPH,IAAM,uBAAuB;AAE7B,IAAM,iBAAiB;AAAA,EACtB,OAAO;AAAA,EACP,OAAO,GAAI,SAAU;AACtB;AAEA,IAAM,gBAAgB;AAAA,EACrB,OAAO;AAAA,EACP,OAAO,GA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M,MAAM,GAAI;AACzC,QAAM,0BAA0B;AAAA,IAC/B;AAAA,IACA;AAAA,EACD;AACA,QAAM,qBAAqB,sBAAuB,EAAE,KAAK,CAAE;AAC3D,QAAM,sBAAsB,2BAA2B,CAAE;AAEzD,QAAM,KAAK,cAAe,8BAA+B;AAGzD,QAAM,mBAAmB,iBAAkB,EAAG,iBAAkB,EAAG;AAGnE,MAAI;AACJ,MAAK,qBAAsB;AAC1B,UACC,eAAgB;AAAA,MACf,UAAU;AAAA,MACV;AAAA,IACD,CAAE,KAAK;AAAA,EACT;AAGA,QAAM,YAAY,KAAM;AAAA,IACvB,CAAE,gBAAiB,EAAG,EAAG,GAAG,uBAAuB,CAAC,CAAE;AAAA;AAAA,IACtD,CAAE,eAAgB,OAAO,UAAU,IAAK,EAAG,GAC1C,uBAAuB,CAAC,CAAE,OAAO,CAAC,CAAE,OAAO,UAAU;AAAA,EACvD,CAAE;AAEF,mBAAkB,EAAE,IAAI,CAAE;AAE1B,SAAO,EAAE,UAAU;AACpB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -44,7 +44,7 @@ function getPseudoStateOptions(name) {
|
|
|
44
44
|
}
|
|
45
45
|
var DEFAULT_STATE_VALUE = "default";
|
|
46
46
|
var EMPTY_STATE_OPTIONS = [];
|
|
47
|
-
function BlockStatesControl({ name, value, onChange }) {
|
|
47
|
+
function BlockStatesControl({ name, value, onChange, children }) {
|
|
48
48
|
const pseudoStateOptions = useMemo(
|
|
49
49
|
() => getPseudoStateOptions(name),
|
|
50
50
|
[name]
|
|
@@ -60,7 +60,8 @@ function BlockStatesControl({ name, value, onChange }) {
|
|
|
60
60
|
pseudoStateValue: value?.pseudo ?? DEFAULT_STATE_VALUE,
|
|
61
61
|
onChangePseudoState: (pseudo) => onChange({ pseudo }),
|
|
62
62
|
popoverProps: dropdownMenuProps.popoverProps,
|
|
63
|
-
showText: false
|
|
63
|
+
showText: false,
|
|
64
|
+
children
|
|
64
65
|
}
|
|
65
66
|
);
|
|
66
67
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/states.jsx"],
|
|
4
|
-
"sourcesContent": ["import { useMemo } from '@wordpress/element';\nimport { privateApis as globalStylesEnginePrivateApis } from '@wordpress/global-styles-engine';\nimport { __, _x } from '@wordpress/i18n';\nimport StateControl from '../components/global-styles/state-control';\nimport StateControlBadges from '../components/global-styles/state-control-badges';\nimport { useToolsPanelDropdownMenuProps } from '../components/global-styles/utils';\nimport { useSettings } from '../components/use-settings';\nimport { unlock } from '../lock-unlock';\n\nconst { getViewportBreakpoints } = unlock( globalStylesEnginePrivateApis );\n\nexport const PSEUDO_STATE_LABELS = {\n\t':hover': _x( 'Hover', 'Name for the CSS pseudo-class selector' ),\n\t':focus': _x( 'Focus', 'Name for the CSS pseudo-class selector' ),\n\t':focus-visible': _x(\n\t\t'Focus-visible',\n\t\t'Name for the CSS pseudo-class selector'\n\t),\n\t':active': _x( 'Active', 'Name for the CSS pseudo-class selector' ),\n};\n\nexport const RESPONSIVE_STATE_LABELS = {\n\t'@tablet': __( 'Tablet' ),\n\t'@mobile': __( 'Mobile' ),\n};\n\n// Viewport states are selected globally via the editor's device preview.\nfunction getDeviceStateOptions( viewportSettings ) {\n\tconst breakpoints = getViewportBreakpoints( viewportSettings );\n\n\treturn Object.entries( RESPONSIVE_STATE_LABELS )\n\t\t.filter(\n\t\t\t( [ value ] ) =>\n\t\t\t\t( value !== '@tablet' || breakpoints.tablet !== undefined ) &&\n\t\t\t\t( value !== '@mobile' || breakpoints.mobile !== undefined )\n\t\t)\n\t\t.map( ( [ value, label ] ) => ( {\n\t\t\tvalue,\n\t\t\tlabel,\n\t\t} ) );\n}\n\n// Keep in sync with WP_Theme_JSON_Gutenberg::VALID_BLOCK_PSEUDO_SELECTORS\n// and packages/global-styles-engine/src/core/render.tsx.\nexport const VALID_BLOCK_PSEUDO_STATES = {\n\t'core/button': [ ':hover', ':focus', ':focus-visible', ':active' ],\n\t'core/navigation-link': [ ':hover', ':focus', ':focus-visible', ':active' ],\n};\n\nfunction getPseudoStateOptions( name ) {\n\tconst validStates = VALID_BLOCK_PSEUDO_STATES[ name ] ?? [];\n\n\treturn validStates\n\t\t.filter( ( state ) => PSEUDO_STATE_LABELS[ state ] )\n\t\t.map( ( state ) => ( {\n\t\t\tvalue: state,\n\t\t\tlabel: PSEUDO_STATE_LABELS[ state ],\n\t\t} ) );\n}\n\nconst DEFAULT_STATE_VALUE = 'default';\nconst EMPTY_STATE_OPTIONS = [];\n\n/**\n * Renders a pseudo-state selector in the block card header.\n *\n * Viewport states are selected globally via the editor's device preview\n * (Responsive editing), so only pseudo-states are exposed here.\n *\n * @param {Object} props Component props.\n * @param {string} props.name Block name.\n * @param {Object} props.value Currently selected style-state value.\n * @param {Function} props.onChange Callback when style-state selection changes.\n * @return {Element|null} State control component, or null if not applicable.\n */\nexport function BlockStatesControl( { name, value, onChange } ) {\n\tconst pseudoStateOptions = useMemo(\n\t\t() => getPseudoStateOptions( name ),\n\t\t[ name ]\n\t);\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tif ( ! pseudoStateOptions.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StateControl\n\t\t\tpseudoStates={ pseudoStateOptions }\n\t\t\tpseudoStateValue={ value?.pseudo ?? DEFAULT_STATE_VALUE }\n\t\t\tonChangePseudoState={ ( pseudo ) => onChange( { pseudo } ) }\n\t\t\tpopoverProps={ dropdownMenuProps.popoverProps }\n\t\t\tshowText={ false }\n\t\t
|
|
5
|
-
"mappings": ";AAAA,SAAS,eAAe;AACxB,SAAS,eAAe,qCAAqC;AAC7D,SAAS,IAAI,UAAU;AACvB,OAAO,kBAAkB;AACzB,OAAO,wBAAwB;AAC/B,SAAS,sCAAsC;AAC/C,SAAS,mBAAmB;AAC5B,SAAS,cAAc;
|
|
4
|
+
"sourcesContent": ["import { useMemo } from '@wordpress/element';\nimport { privateApis as globalStylesEnginePrivateApis } from '@wordpress/global-styles-engine';\nimport { __, _x } from '@wordpress/i18n';\nimport StateControl from '../components/global-styles/state-control';\nimport StateControlBadges from '../components/global-styles/state-control-badges';\nimport { useToolsPanelDropdownMenuProps } from '../components/global-styles/utils';\nimport { useSettings } from '../components/use-settings';\nimport { unlock } from '../lock-unlock';\n\nconst { getViewportBreakpoints } = unlock( globalStylesEnginePrivateApis );\n\nexport const PSEUDO_STATE_LABELS = {\n\t':hover': _x( 'Hover', 'Name for the CSS pseudo-class selector' ),\n\t':focus': _x( 'Focus', 'Name for the CSS pseudo-class selector' ),\n\t':focus-visible': _x(\n\t\t'Focus-visible',\n\t\t'Name for the CSS pseudo-class selector'\n\t),\n\t':active': _x( 'Active', 'Name for the CSS pseudo-class selector' ),\n};\n\nexport const RESPONSIVE_STATE_LABELS = {\n\t'@tablet': __( 'Tablet' ),\n\t'@mobile': __( 'Mobile' ),\n};\n\n// Viewport states are selected globally via the editor's device preview.\nfunction getDeviceStateOptions( viewportSettings ) {\n\tconst breakpoints = getViewportBreakpoints( viewportSettings );\n\n\treturn Object.entries( RESPONSIVE_STATE_LABELS )\n\t\t.filter(\n\t\t\t( [ value ] ) =>\n\t\t\t\t( value !== '@tablet' || breakpoints.tablet !== undefined ) &&\n\t\t\t\t( value !== '@mobile' || breakpoints.mobile !== undefined )\n\t\t)\n\t\t.map( ( [ value, label ] ) => ( {\n\t\t\tvalue,\n\t\t\tlabel,\n\t\t} ) );\n}\n\n// Keep in sync with WP_Theme_JSON_Gutenberg::VALID_BLOCK_PSEUDO_SELECTORS\n// and packages/global-styles-engine/src/core/render.tsx.\nexport const VALID_BLOCK_PSEUDO_STATES = {\n\t'core/button': [ ':hover', ':focus', ':focus-visible', ':active' ],\n\t'core/navigation-link': [ ':hover', ':focus', ':focus-visible', ':active' ],\n};\n\nfunction getPseudoStateOptions( name ) {\n\tconst validStates = VALID_BLOCK_PSEUDO_STATES[ name ] ?? [];\n\n\treturn validStates\n\t\t.filter( ( state ) => PSEUDO_STATE_LABELS[ state ] )\n\t\t.map( ( state ) => ( {\n\t\t\tvalue: state,\n\t\t\tlabel: PSEUDO_STATE_LABELS[ state ],\n\t\t} ) );\n}\n\nconst DEFAULT_STATE_VALUE = 'default';\nconst EMPTY_STATE_OPTIONS = [];\n\n/**\n * Renders a pseudo-state selector in the block card header.\n *\n * Viewport states are selected globally via the editor's device preview\n * (Responsive editing), so only pseudo-states are exposed here.\n *\n * @param {Object} props Component props.\n * @param {string} props.name Block name.\n * @param {Object} props.value Currently selected style-state value.\n * @param {Function} props.onChange Callback when style-state selection changes.\n * @param {Element} props.children Optional menu content rendered after the\n * state groups.\n * @return {Element|null} State control component, or null if not applicable.\n */\nexport function BlockStatesControl( { name, value, onChange, children } ) {\n\tconst pseudoStateOptions = useMemo(\n\t\t() => getPseudoStateOptions( name ),\n\t\t[ name ]\n\t);\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\tif ( ! pseudoStateOptions.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StateControl\n\t\t\tpseudoStates={ pseudoStateOptions }\n\t\t\tpseudoStateValue={ value?.pseudo ?? DEFAULT_STATE_VALUE }\n\t\t\tonChangePseudoState={ ( pseudo ) => onChange( { pseudo } ) }\n\t\t\tpopoverProps={ dropdownMenuProps.popoverProps }\n\t\t\tshowText={ false }\n\t\t>\n\t\t\t{ children }\n\t\t</StateControl>\n\t);\n}\n\n/**\n * Renders badges for the active style states of a block.\n *\n * @param {Object} props Component props.\n * @param {string} props.name Block name.\n * @param {Object} props.value Currently selected style-state value.\n * @param {boolean} props.isResponsiveEditing Whether Responsive editing is enabled.\n * @return {Element|null} Badges component, or null if there is nothing to show.\n */\nexport function BlockStateBadges( { name, value, isResponsiveEditing } ) {\n\tconst pseudoStateOptions = useMemo(\n\t\t() => getPseudoStateOptions( name ),\n\t\t[ name ]\n\t);\n\tconst [ viewportSettings ] = useSettings( 'viewport' );\n\tconst deviceStateOptions = useMemo(\n\t\t() => getDeviceStateOptions( viewportSettings ),\n\t\t[ viewportSettings ]\n\t);\n\n\tif ( ! pseudoStateOptions.length && ! isResponsiveEditing ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StateControlBadges\n\t\t\tviewportStates={\n\t\t\t\tisResponsiveEditing ? deviceStateOptions : EMPTY_STATE_OPTIONS\n\t\t\t}\n\t\t\tpseudoStates={ pseudoStateOptions }\n\t\t\tviewportValue={ value?.viewport ?? DEFAULT_STATE_VALUE }\n\t\t\tpseudoStateValue={ value?.pseudo ?? DEFAULT_STATE_VALUE }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,eAAe;AACxB,SAAS,eAAe,qCAAqC;AAC7D,SAAS,IAAI,UAAU;AACvB,OAAO,kBAAkB;AACzB,OAAO,wBAAwB;AAC/B,SAAS,sCAAsC;AAC/C,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AAkFrB;AAhFF,IAAM,EAAE,uBAAuB,IAAI,OAAQ,6BAA8B;AAElE,IAAM,sBAAsB;AAAA,EAClC,UAAU,GAAI,SAAS,wCAAyC;AAAA,EAChE,UAAU,GAAI,SAAS,wCAAyC;AAAA,EAChE,kBAAkB;AAAA,IACjB;AAAA,IACA;AAAA,EACD;AAAA,EACA,WAAW,GAAI,UAAU,wCAAyC;AACnE;AAEO,IAAM,0BAA0B;AAAA,EACtC,WAAW,GAAI,QAAS;AAAA,EACxB,WAAW,GAAI,QAAS;AACzB;AAGA,SAAS,sBAAuB,kBAAmB;AAClD,QAAM,cAAc,uBAAwB,gBAAiB;AAE7D,SAAO,OAAO,QAAS,uBAAwB,EAC7C;AAAA,IACA,CAAE,CAAE,KAAM,OACP,UAAU,aAAa,YAAY,WAAW,YAC9C,UAAU,aAAa,YAAY,WAAW;AAAA,EAClD,EACC,IAAK,CAAE,CAAE,OAAO,KAAM,OAAS;AAAA,IAC/B;AAAA,IACA;AAAA,EACD,EAAI;AACN;AAIO,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A,gBACC,sBAAsB,qBAAqB;AAAA,MAE5C,cAAe;AAAA,MACf,eAAgB,OAAO,YAAY;AAAA,MACnC,kBAAmB,OAAO,UAAU;AAAA;AAAA,EACrC;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// packages/block-editor/src/hooks/text-shadow.ts
|
|
2
|
+
import { addFilter } from "@wordpress/hooks";
|
|
3
|
+
import { hasBlockSupport } from "@wordpress/blocks";
|
|
4
|
+
import TokenList from "@wordpress/token-list";
|
|
5
|
+
import { kebabCase } from "@wordpress/kebab-case";
|
|
6
|
+
import { shouldSkipSerialization } from "./utils.mjs";
|
|
7
|
+
import { TYPOGRAPHY_SUPPORT_KEY } from "./typography.mjs";
|
|
8
|
+
var TEXT_SHADOW_SUPPORT_KEY = "typography.textShadow";
|
|
9
|
+
function addAttributes(settings) {
|
|
10
|
+
if (!hasBlockSupport(settings, TEXT_SHADOW_SUPPORT_KEY)) {
|
|
11
|
+
return settings;
|
|
12
|
+
}
|
|
13
|
+
if (!settings.attributes.textShadow) {
|
|
14
|
+
Object.assign(settings.attributes, {
|
|
15
|
+
textShadow: {
|
|
16
|
+
type: "string"
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return settings;
|
|
21
|
+
}
|
|
22
|
+
function addSaveProps(props, blockType, attributes) {
|
|
23
|
+
if (!hasBlockSupport(blockType, TEXT_SHADOW_SUPPORT_KEY)) {
|
|
24
|
+
return props;
|
|
25
|
+
}
|
|
26
|
+
if (shouldSkipSerialization(
|
|
27
|
+
blockType,
|
|
28
|
+
TYPOGRAPHY_SUPPORT_KEY,
|
|
29
|
+
"textShadow"
|
|
30
|
+
)) {
|
|
31
|
+
return props;
|
|
32
|
+
}
|
|
33
|
+
if (!attributes?.textShadow) {
|
|
34
|
+
return props;
|
|
35
|
+
}
|
|
36
|
+
const classes = new TokenList(props.className);
|
|
37
|
+
classes.add(`has-${kebabCase(attributes.textShadow)}-text-shadow`);
|
|
38
|
+
const newClassName = classes.value;
|
|
39
|
+
props.className = newClassName ? newClassName : void 0;
|
|
40
|
+
return props;
|
|
41
|
+
}
|
|
42
|
+
function useBlockProps({
|
|
43
|
+
name,
|
|
44
|
+
textShadow
|
|
45
|
+
}) {
|
|
46
|
+
return addSaveProps({}, name, { textShadow });
|
|
47
|
+
}
|
|
48
|
+
var text_shadow_default = {
|
|
49
|
+
useBlockProps,
|
|
50
|
+
addSaveProps,
|
|
51
|
+
attributeKeys: ["textShadow"],
|
|
52
|
+
hasSupport(name) {
|
|
53
|
+
return hasBlockSupport(name, TEXT_SHADOW_SUPPORT_KEY);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
addFilter(
|
|
57
|
+
"blocks.registerBlockType",
|
|
58
|
+
"core/textShadow/addAttribute",
|
|
59
|
+
addAttributes
|
|
60
|
+
);
|
|
61
|
+
export {
|
|
62
|
+
TEXT_SHADOW_SUPPORT_KEY,
|
|
63
|
+
text_shadow_default as default
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=text-shadow.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hooks/text-shadow.ts"],
|
|
4
|
+
"sourcesContent": ["import { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport type { BlockType } from '@wordpress/blocks';\nimport TokenList from '@wordpress/token-list';\nimport { kebabCase } from '@wordpress/kebab-case';\nimport { shouldSkipSerialization } from './utils';\nimport { TYPOGRAPHY_SUPPORT_KEY } from './typography';\n\nexport const TEXT_SHADOW_SUPPORT_KEY = 'typography.textShadow';\n\ninterface TextShadowAttributes {\n\ttextShadow?: string;\n}\n\ninterface SaveProps {\n\tclassName?: string;\n\t[ key: string ]: unknown;\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `textShadow` attribute.\n *\n * @param settings Original block settings.\n * @return Filtered block settings.\n */\nfunction addAttributes( settings: BlockType ) {\n\tif ( ! hasBlockSupport( settings, TEXT_SHADOW_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify a default value if needed.\n\tif ( ! settings.attributes.textShadow ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\ttextShadow: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject the text shadow preset\n * class name.\n *\n * @param props Additional props applied to save element.\n * @param blockType Block type.\n * @param attributes Block attributes.\n * @return Filtered props applied to save element.\n */\nfunction addSaveProps(\n\tprops: SaveProps,\n\tblockType: string | BlockType,\n\tattributes: TextShadowAttributes | undefined\n) {\n\tif ( ! hasBlockSupport( blockType, TEXT_SHADOW_SUPPORT_KEY ) ) {\n\t\treturn props;\n\t}\n\n\tif (\n\t\tshouldSkipSerialization(\n\t\t\tblockType,\n\t\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t\t\t'textShadow'\n\t\t)\n\t) {\n\t\treturn props;\n\t}\n\n\tif ( ! attributes?.textShadow ) {\n\t\treturn props;\n\t}\n\n\t// Use TokenList to dedupe classes.\n\tconst classes = new TokenList( props.className );\n\tclasses.add( `has-${ kebabCase( attributes.textShadow ) }-text-shadow` );\n\tconst newClassName = classes.value;\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\nfunction useBlockProps( {\n\tname,\n\ttextShadow,\n}: TextShadowAttributes & { name: string } ) {\n\treturn addSaveProps( {}, name, { textShadow } );\n}\n\nexport default {\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'textShadow' ],\n\thasSupport( name: string ) {\n\t\treturn hasBlockSupport( name, TEXT_SHADOW_SUPPORT_KEY );\n\t},\n};\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/textShadow/addAttribute',\n\taddAttributes\n);\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,iBAAiB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PPORT_KEY = "typography.textColumns";
|
|
38
38
|
var FONT_STYLE_SUPPORT_KEY = "typography.__experimentalFontStyle";
|
|
39
39
|
var FONT_WEIGHT_SUPPORT_KEY = "typography.__experimentalFontWeight";
|
|
40
|
+
var TEXT_SHADOW_SUPPORT_KEY = "typography.textShadow";
|
|
40
41
|
var WRITING_MODE_SUPPORT_KEY = "typography.__experimentalWritingMode";
|
|
41
42
|
var TYPOGRAPHY_SUPPORT_KEY = "typography";
|
|
42
43
|
var TYPOGRAPHY_SUPPORT_KEYS = [
|
|
@@ -52,6 +53,7 @@ var TYPOGRAPHY_SUPPORT_KEYS = [
|
|
|
52
53
|
WRITING_MODE_SUPPORT_KEY,
|
|
53
54
|
TEXT_TRANSFORM_SUPPORT_KEY,
|
|
54
55
|
LETTER_SPACING_SUPPORT_KEY,
|
|
56
|
+
TEXT_SHADOW_SUPPORT_KEY,
|
|
55
57
|
FIT_TEXT_SUPPORT_KEY
|
|
56
58
|
];
|
|
57
59
|
function styleToAttributes(style) {
|
|
@@ -59,14 +61,17 @@ function styleToAttributes(style) {
|
|
|
59
61
|
const fontSizeValue = style?.typography?.fontSize;
|
|
60
62
|
const fontFamilyValue = style?.typography?.fontFamily;
|
|
61
63
|
const textColorValue = style?.color?.text;
|
|
64
|
+
const textShadowValue = style?.typography?.textShadow;
|
|
62
65
|
const fontSizeSlug = typeof fontSizeValue === "string" && fontSizeValue?.startsWith("var:preset|font-size|") ? fontSizeValue.substring("var:preset|font-size|".length) : void 0;
|
|
63
66
|
const fontFamilySlug = fontFamilyValue?.startsWith(
|
|
64
67
|
"var:preset|font-family|"
|
|
65
68
|
) ? fontFamilyValue.substring("var:preset|font-family|".length) : void 0;
|
|
66
69
|
const textColorSlug = extractPresetSlug(textColorValue, "color");
|
|
70
|
+
const textShadowSlug = typeof textShadowValue === "string" && textShadowValue?.startsWith("var:preset|text-shadow|") ? textShadowValue.substring("var:preset|text-shadow|".length) : void 0;
|
|
67
71
|
updatedStyle.typography = {
|
|
68
72
|
...omit(updatedStyle.typography, ["fontFamily"]),
|
|
69
|
-
fontSize: fontSizeSlug ? void 0 : fontSizeValue
|
|
73
|
+
fontSize: fontSizeSlug ? void 0 : fontSizeValue,
|
|
74
|
+
textShadow: textShadowSlug ? void 0 : textShadowValue
|
|
70
75
|
};
|
|
71
76
|
updatedStyle.color = {
|
|
72
77
|
...updatedStyle.color,
|
|
@@ -76,7 +81,8 @@ function styleToAttributes(style) {
|
|
|
76
81
|
style: cleanEmptyObject(updatedStyle),
|
|
77
82
|
fontFamily: fontFamilySlug,
|
|
78
83
|
fontSize: fontSizeSlug,
|
|
79
|
-
textColor: textColorSlug
|
|
84
|
+
textColor: textColorSlug,
|
|
85
|
+
textShadow: textShadowSlug
|
|
80
86
|
};
|
|
81
87
|
}
|
|
82
88
|
function attributesToStyle(attributes) {
|
|
@@ -85,7 +91,8 @@ function attributesToStyle(attributes) {
|
|
|
85
91
|
typography: {
|
|
86
92
|
...attributes.style?.typography,
|
|
87
93
|
fontFamily: attributes.fontFamily ? "var:preset|font-family|" + attributes.fontFamily : void 0,
|
|
88
|
-
fontSize: attributes.fontSize ? "var:preset|font-size|" + attributes.fontSize : attributes.style?.typography?.fontSize
|
|
94
|
+
fontSize: attributes.fontSize ? "var:preset|font-size|" + attributes.fontSize : attributes.style?.typography?.fontSize,
|
|
95
|
+
textShadow: attributes.textShadow ? "var:preset|text-shadow|" + attributes.textShadow : attributes.style?.typography?.textShadow
|
|
89
96
|
},
|
|
90
97
|
color: {
|
|
91
98
|
...attributes.style?.color,
|
|
@@ -126,7 +133,15 @@ function TypographyPanel({
|
|
|
126
133
|
}) {
|
|
127
134
|
const selectedState = useBlockStyleState();
|
|
128
135
|
const isEnabled = useHasTypographyPanel(settings);
|
|
129
|
-
const {
|
|
136
|
+
const {
|
|
137
|
+
style,
|
|
138
|
+
fontFamily,
|
|
139
|
+
fontSize,
|
|
140
|
+
fitText,
|
|
141
|
+
textColor,
|
|
142
|
+
textShadow,
|
|
143
|
+
className
|
|
144
|
+
} = useSelect(
|
|
130
145
|
(select) => {
|
|
131
146
|
if (!isEnabled) {
|
|
132
147
|
return {};
|
|
@@ -135,6 +150,7 @@ function TypographyPanel({
|
|
|
135
150
|
style: _style,
|
|
136
151
|
fontFamily: _fontFamily,
|
|
137
152
|
fontSize: _fontSize,
|
|
153
|
+
textShadow: _textShadow,
|
|
138
154
|
fitText: _fitText,
|
|
139
155
|
textColor: _textColor,
|
|
140
156
|
className: _className
|
|
@@ -145,6 +161,7 @@ function TypographyPanel({
|
|
|
145
161
|
fontSize: _fontSize,
|
|
146
162
|
fitText: _fitText,
|
|
147
163
|
textColor: _textColor,
|
|
164
|
+
textShadow: _textShadow,
|
|
148
165
|
className: _className
|
|
149
166
|
};
|
|
150
167
|
},
|
|
@@ -160,14 +177,21 @@ function TypographyPanel({
|
|
|
160
177
|
if (isStateSelected) {
|
|
161
178
|
return getStyleForState(style, selectedState);
|
|
162
179
|
}
|
|
163
|
-
return attributesToStyle({
|
|
180
|
+
return attributesToStyle({
|
|
181
|
+
style,
|
|
182
|
+
fontFamily,
|
|
183
|
+
fontSize,
|
|
184
|
+
textColor,
|
|
185
|
+
textShadow
|
|
186
|
+
});
|
|
164
187
|
}, [
|
|
165
188
|
isStateSelected,
|
|
166
189
|
selectedState,
|
|
167
190
|
style,
|
|
168
191
|
fontSize,
|
|
169
192
|
fontFamily,
|
|
170
|
-
textColor
|
|
193
|
+
textColor,
|
|
194
|
+
textShadow
|
|
171
195
|
]);
|
|
172
196
|
const onChange = isStateSelected ? (newStyle) => {
|
|
173
197
|
setAttributes({
|