@wordpress/block-editor 15.22.1 → 16.0.1-next.v.202607070741.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 +27 -0
- package/build/autocompleters/block.cjs +10 -2
- package/build/autocompleters/block.cjs.map +2 -2
- package/build/components/background-image-control/index.cjs +0 -2
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-inspector/edit-contents.cjs +3 -0
- package/build/components/block-inspector/edit-contents.cjs.map +3 -3
- package/build/components/block-inspector/index.cjs +18 -36
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/block-invalid-warning.cjs +8 -19
- package/build/components/block-list/block-invalid-warning.cjs.map +2 -2
- package/build/components/block-styles/use-styles-for-block.cjs +2 -1
- package/build/components/block-styles/use-styles-for-block.cjs.map +2 -2
- package/build/components/block-title/use-block-display-title.cjs +7 -2
- package/build/components/block-title/use-block-display-title.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +10 -14
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-variation-transforms/index.cjs +0 -1
- package/build/components/block-variation-transforms/index.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs +0 -2
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +5 -5
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +1 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs +0 -1
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/width-height-tool.cjs +2 -4
- package/build/components/dimensions-tool/width-height-tool.cjs.map +2 -2
- package/build/components/font-appearance-control/index.cjs +6 -25
- package/build/components/font-appearance-control/index.cjs.map +3 -3
- package/build/components/font-family/index.cjs +6 -15
- package/build/components/font-family/index.cjs.map +3 -3
- package/build/components/font-sizes/font-size-picker.cjs +1 -2
- package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
- package/build/components/global-styles/border-panel.cjs +0 -1
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +0 -3
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +4 -10
- package/build/components/global-styles/typography-panel.cjs.map +2 -2
- package/build/components/height-control/index.cjs +0 -2
- package/build/components/height-control/index.cjs.map +2 -2
- package/build/components/html-element-control/index.cjs +0 -1
- package/build/components/html-element-control/index.cjs.map +2 -2
- package/build/components/image-editor/index.cjs +5 -0
- package/build/components/image-editor/index.cjs.map +3 -3
- package/build/components/image-editor/zoom-dropdown.cjs +0 -1
- package/build/components/image-editor/zoom-dropdown.cjs.map +2 -2
- package/build/components/image-size-control/index.cjs +1 -3
- package/build/components/image-size-control/index.cjs.map +2 -2
- package/build/components/inner-content/index.cjs +107 -0
- package/build/components/inner-content/index.cjs.map +7 -0
- package/build/components/inserter/hooks/use-block-types-state.cjs +10 -2
- package/build/components/inserter/hooks/use-block-types-state.cjs.map +2 -2
- package/build/components/inserter/media-tab/hooks.cjs +34 -6
- package/build/components/inserter/media-tab/hooks.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-list.cjs +3 -1
- package/build/components/inserter/media-tab/media-list.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-panel.cjs +224 -27
- package/build/components/inserter/media-tab/media-panel.cjs.map +3 -3
- package/build/components/inserter/media-tab/media-preview.cjs +32 -17
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-tab.cjs +26 -6
- package/build/components/inserter/media-tab/media-tab.cjs.map +2 -2
- package/build/components/inserter/mobile-tab-navigation.cjs +6 -1
- package/build/components/inserter/mobile-tab-navigation.cjs.map +2 -2
- package/build/components/inserter/no-results.cjs +2 -2
- package/build/components/inserter/no-results.cjs.map +2 -2
- package/build/components/inserter/preview-panel.cjs +2 -1
- package/build/components/inserter/preview-panel.cjs.map +2 -2
- package/build/components/inserter-list-item/index.cjs +8 -2
- package/build/components/inserter-list-item/index.cjs.map +2 -2
- package/build/components/letter-spacing-control/index.cjs +0 -24
- package/build/components/letter-spacing-control/index.cjs.map +3 -3
- package/build/components/line-height-control/index.cjs +7 -22
- package/build/components/line-height-control/index.cjs.map +3 -3
- package/build/components/list-view/block-select-button.cjs +90 -84
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +51 -20
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/list-view/expander.cjs +1 -1
- package/build/components/list-view/expander.cjs.map +2 -2
- package/build/components/list-view/use-list-view-client-ids.cjs +2 -2
- package/build/components/list-view/use-list-view-client-ids.cjs.map +2 -2
- package/build/components/observe-typing/index.cjs +4 -3
- package/build/components/observe-typing/index.cjs.map +2 -2
- package/build/components/preset-input-control/custom-value-controls.cjs +1 -3
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/preset-input-control/index.cjs +1 -3
- package/build/components/preset-input-control/index.cjs.map +2 -2
- package/build/components/resolution-tool/index.cjs +1 -2
- package/build/components/resolution-tool/index.cjs.map +2 -2
- package/build/components/text-alignment-control/index.cjs +0 -1
- package/build/components/text-alignment-control/index.cjs.map +2 -2
- package/build/components/text-decoration-control/index.cjs +0 -1
- package/build/components/text-decoration-control/index.cjs.map +2 -2
- package/build/components/text-indent-control/index.cjs +0 -8
- package/build/components/text-indent-control/index.cjs.map +2 -2
- package/build/components/text-transform-control/index.cjs +0 -1
- package/build/components/text-transform-control/index.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -8
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/use-on-block-drop/index.cjs +3 -7
- package/build/components/use-on-block-drop/index.cjs.map +2 -2
- package/build/components/use-resize-canvas/index.cjs +16 -53
- package/build/components/use-resize-canvas/index.cjs.map +3 -3
- package/build/components/writing-mode-control/index.cjs +0 -1
- package/build/components/writing-mode-control/index.cjs.map +2 -2
- package/build/hooks/font-size.cjs +1 -2
- package/build/hooks/font-size.cjs.map +2 -2
- package/build/hooks/layout.cjs +5 -3
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/position.cjs +36 -16
- package/build/hooks/position.cjs.map +2 -2
- package/build/hooks/states.cjs +10 -21
- package/build/hooks/states.cjs.map +2 -2
- package/build/layouts/constrained.cjs +21 -21
- package/build/layouts/constrained.cjs.map +2 -2
- package/build/layouts/flex.cjs +0 -3
- package/build/layouts/flex.cjs.map +2 -2
- package/build/layouts/grid.cjs +51 -9
- package/build/layouts/grid.cjs.map +2 -2
- package/build/private-apis.cjs +4 -2
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-actions.cjs +16 -0
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-keys.cjs +3 -3
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/private-selectors.cjs +96 -10
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +19 -3
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +13 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/autocompleters/block.mjs +10 -2
- package/build-module/autocompleters/block.mjs.map +2 -2
- package/build-module/components/background-image-control/index.mjs +0 -2
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-inspector/edit-contents.mjs +4 -1
- package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +18 -36
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block-invalid-warning.mjs +8 -19
- package/build-module/components/block-list/block-invalid-warning.mjs.map +2 -2
- package/build-module/components/block-styles/use-styles-for-block.mjs +2 -1
- package/build-module/components/block-styles/use-styles-for-block.mjs.map +2 -2
- package/build-module/components/block-title/use-block-display-title.mjs +7 -2
- package/build-module/components/block-title/use-block-display-title.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +10 -14
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +0 -1
- package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +0 -2
- package/build-module/components/child-layout-control/index.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +5 -5
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +1 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs +0 -1
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/width-height-tool.mjs +2 -4
- package/build-module/components/dimensions-tool/width-height-tool.mjs.map +2 -2
- package/build-module/components/font-appearance-control/index.mjs +6 -15
- package/build-module/components/font-appearance-control/index.mjs.map +2 -2
- package/build-module/components/font-family/index.mjs +6 -15
- package/build-module/components/font-family/index.mjs.map +2 -2
- package/build-module/components/font-sizes/font-size-picker.mjs +1 -2
- package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +0 -1
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +4 -10
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/height-control/index.mjs +0 -2
- package/build-module/components/height-control/index.mjs.map +2 -2
- package/build-module/components/html-element-control/index.mjs +0 -1
- package/build-module/components/html-element-control/index.mjs.map +2 -2
- package/build-module/components/image-editor/index.mjs +5 -0
- package/build-module/components/image-editor/index.mjs.map +2 -2
- package/build-module/components/image-editor/zoom-dropdown.mjs +0 -1
- package/build-module/components/image-editor/zoom-dropdown.mjs.map +2 -2
- package/build-module/components/image-size-control/index.mjs +1 -3
- package/build-module/components/image-size-control/index.mjs.map +2 -2
- package/build-module/components/inner-content/index.mjs +82 -0
- package/build-module/components/inner-content/index.mjs.map +7 -0
- package/build-module/components/inserter/hooks/use-block-types-state.mjs +10 -2
- package/build-module/components/inserter/hooks/use-block-types-state.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/hooks.mjs +33 -6
- package/build-module/components/inserter/media-tab/hooks.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-list.mjs +3 -1
- package/build-module/components/inserter/media-tab/media-list.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-panel.mjs +227 -30
- package/build-module/components/inserter/media-tab/media-panel.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-preview.mjs +33 -18
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-tab.mjs +27 -7
- package/build-module/components/inserter/media-tab/media-tab.mjs.map +2 -2
- package/build-module/components/inserter/mobile-tab-navigation.mjs +6 -1
- package/build-module/components/inserter/mobile-tab-navigation.mjs.map +2 -2
- package/build-module/components/inserter/no-results.mjs +2 -2
- package/build-module/components/inserter/no-results.mjs.map +2 -2
- package/build-module/components/inserter/preview-panel.mjs +2 -1
- package/build-module/components/inserter/preview-panel.mjs.map +2 -2
- package/build-module/components/inserter-list-item/index.mjs +8 -2
- package/build-module/components/inserter-list-item/index.mjs.map +2 -2
- package/build-module/components/letter-spacing-control/index.mjs +0 -14
- package/build-module/components/letter-spacing-control/index.mjs.map +2 -2
- package/build-module/components/line-height-control/index.mjs +7 -12
- package/build-module/components/line-height-control/index.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +90 -84
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +51 -20
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/expander.mjs +1 -1
- package/build-module/components/list-view/expander.mjs.map +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.mjs +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.mjs.map +2 -2
- package/build-module/components/observe-typing/index.mjs +4 -3
- package/build-module/components/observe-typing/index.mjs.map +2 -2
- package/build-module/components/preset-input-control/custom-value-controls.mjs +1 -3
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs +1 -3
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/resolution-tool/index.mjs +1 -2
- package/build-module/components/resolution-tool/index.mjs.map +2 -2
- package/build-module/components/text-alignment-control/index.mjs +0 -1
- package/build-module/components/text-alignment-control/index.mjs.map +2 -2
- package/build-module/components/text-decoration-control/index.mjs +0 -1
- package/build-module/components/text-decoration-control/index.mjs.map +2 -2
- package/build-module/components/text-indent-control/index.mjs +0 -8
- package/build-module/components/text-indent-control/index.mjs.map +2 -2
- package/build-module/components/text-transform-control/index.mjs +0 -1
- package/build-module/components/text-transform-control/index.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -8
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/use-on-block-drop/index.mjs +4 -7
- package/build-module/components/use-on-block-drop/index.mjs.map +2 -2
- package/build-module/components/use-resize-canvas/index.mjs +6 -53
- package/build-module/components/use-resize-canvas/index.mjs.map +2 -2
- package/build-module/components/writing-mode-control/index.mjs +0 -1
- package/build-module/components/writing-mode-control/index.mjs.map +2 -2
- package/build-module/hooks/font-size.mjs +1 -2
- package/build-module/hooks/font-size.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +4 -3
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/position.mjs +38 -18
- package/build-module/hooks/position.mjs.map +2 -2
- package/build-module/hooks/states.mjs +10 -21
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +21 -21
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +0 -3
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +52 -9
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +5 -3
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +14 -0
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +2 -2
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +93 -10
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +17 -3
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +13 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/content-rtl.css +11 -5
- package/build-style/content.css +11 -5
- package/build-style/style-rtl.css +113 -3
- package/build-style/style.css +113 -3
- package/package.json +43 -41
- package/src/autocompleters/block.js +10 -3
- package/src/autocompleters/test/block.js +53 -0
- package/src/components/background-image-control/index.js +0 -2
- package/src/components/block-inspector/edit-contents.js +5 -1
- package/src/components/block-inspector/index.js +25 -44
- package/src/components/block-list/block-invalid-warning.js +8 -19
- package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
- package/src/components/block-styles/use-styles-for-block.js +1 -0
- package/src/components/block-title/use-block-display-title.js +7 -2
- package/src/components/block-toolbar/block-toolbar-icon.js +11 -16
- package/src/components/block-toolbar/test/block-toolbar-icon.js +32 -9
- package/src/components/block-variation-transforms/index.js +0 -1
- package/src/components/child-layout-control/index.js +0 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +11 -106
- package/src/components/colors-gradients/control.js +4 -4
- package/src/components/colors-gradients/style.scss +2 -2
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/dimensions-tool/aspect-ratio-tool.js +0 -1
- package/src/components/dimensions-tool/scale-tool.js +0 -1
- package/src/components/dimensions-tool/width-height-tool.js +0 -2
- package/src/components/font-appearance-control/index.js +6 -19
- package/src/components/font-family/README.md +0 -9
- package/src/components/font-family/index.js +6 -19
- package/src/components/font-family/stories/index.story.jsx +0 -1
- package/src/components/font-sizes/font-size-picker.js +0 -1
- package/src/components/global-styles/border-panel.js +0 -1
- package/src/components/global-styles/dimensions-panel.js +0 -3
- package/src/components/global-styles/typography-panel.js +0 -6
- package/src/components/height-control/index.js +0 -2
- package/src/components/html-element-control/index.js +0 -1
- package/src/components/iframe/content.scss +3 -3
- package/src/components/image-editor/index.js +22 -0
- package/src/components/image-editor/zoom-dropdown.js +0 -1
- package/src/components/image-size-control/index.js +0 -2
- package/src/components/inner-content/index.js +119 -0
- package/src/components/inner-content/test/index.js +81 -0
- package/src/components/inserter/hooks/use-block-types-state.js +10 -2
- package/src/components/inserter/media-tab/hooks.js +59 -9
- package/src/components/inserter/media-tab/media-list.js +2 -0
- package/src/components/inserter/media-tab/media-panel.js +256 -17
- package/src/components/inserter/media-tab/media-preview.js +34 -17
- package/src/components/inserter/media-tab/media-tab.js +20 -2
- package/src/components/inserter/media-tab/test/hooks.js +204 -0
- package/src/components/inserter/mobile-tab-navigation.js +6 -1
- package/src/components/inserter/no-results.js +2 -2
- package/src/components/inserter/preview-panel.js +1 -0
- package/src/components/inserter/style.scss +110 -1
- package/src/components/inserter-list-item/index.js +8 -2
- package/src/components/letter-spacing-control/README.md +0 -8
- package/src/components/letter-spacing-control/index.js +5 -23
- package/src/components/letter-spacing-control/stories/index.story.jsx +0 -12
- package/src/components/line-height-control/README.md +0 -8
- package/src/components/line-height-control/index.js +7 -16
- package/src/components/line-height-control/stories/index.story.jsx +0 -1
- package/src/components/line-height-control/test/index.js +1 -7
- package/src/components/link-picker/test/index.js +3 -1
- package/src/components/list-view/block-select-button.js +5 -1
- package/src/components/list-view/block.js +57 -20
- package/src/components/list-view/expander.js +5 -1
- package/src/components/list-view/style.scss +19 -0
- package/src/components/list-view/use-list-view-client-ids.js +2 -2
- package/src/components/observe-typing/index.js +9 -4
- package/src/components/preset-input-control/custom-value-controls.js +0 -2
- package/src/components/preset-input-control/index.js +0 -2
- package/src/components/resolution-tool/index.js +0 -1
- package/src/components/responsive-block-control/test/index.js +1 -5
- package/src/components/text-alignment-control/index.js +0 -1
- package/src/components/text-decoration-control/index.js +0 -1
- package/src/components/text-indent-control/index.js +7 -16
- package/src/components/text-transform-control/index.js +0 -1
- package/src/components/use-block-display-information/index.js +9 -13
- package/src/components/use-block-display-information/test/index.js +47 -9
- package/src/components/use-on-block-drop/index.js +4 -7
- package/src/components/use-resize-canvas/index.js +10 -71
- package/src/components/writing-mode-control/index.js +0 -1
- package/src/hooks/block-hooks.scss +15 -0
- package/src/hooks/font-size.js +0 -1
- package/src/hooks/layout.js +5 -4
- package/src/hooks/position.js +44 -23
- package/src/hooks/states.js +24 -26
- package/src/hooks/test/cross-origin-isolation.js +0 -4
- package/src/hooks/test/layout.js +75 -1
- package/src/layouts/constrained.js +51 -28
- package/src/layouts/flex.js +0 -3
- package/src/layouts/grid.js +59 -7
- package/src/layouts/test/constrained.js +91 -0
- package/src/layouts/test/grid.js +71 -0
- package/src/private-apis.js +4 -2
- package/src/store/actions.js +1 -0
- package/src/store/private-actions.js +31 -0
- package/src/store/private-keys.js +1 -1
- package/src/store/private-selectors.js +184 -11
- package/src/store/reducer.js +37 -2
- package/src/store/selectors.js +41 -0
- package/src/store/test/private-selectors.js +436 -10
- package/src/store/test/reducer.js +41 -13
- package/src/store/test/selectors.js +133 -0
- package/src/style.scss +1 -0
- package/src/components/use-resize-canvas/README.md +0 -37
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/writing-mode-control/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { textHorizontal, textVertical } from '@wordpress/icons';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\n\nconst WRITING_MODES = [\n\t{\n\t\tlabel: __( 'Horizontal' ),\n\t\tvalue: 'horizontal-tb',\n\t\ticon: textHorizontal,\n\t},\n\t{\n\t\tlabel: __( 'Vertical' ),\n\t\tvalue: isRTL() ? 'vertical-lr' : 'vertical-rl',\n\t\ticon: textVertical,\n\t},\n];\n\n/**\n * Control to facilitate writing mode selections.\n *\n * @param {Object} props Component props.\n * @param {string} props.className Class name to add to the control.\n * @param {string} props.value Currently selected writing mode.\n * @param {Function} props.onChange Handles change in the writing mode selection.\n *\n * @return {Element} Writing Mode control.\n */\nexport default function WritingModeControl( { className, value, onChange } ) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\tisDeselectable\n\t\t\
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,IAAI,aAAa;AAC1B,SAAS,gBAAgB,oBAAoB;AAC7C;AAAA,EACC,oCAAoC;AAAA,EACpC,8CAA8C;AAAA,OACxC;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { textHorizontal, textVertical } from '@wordpress/icons';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\n\nconst WRITING_MODES = [\n\t{\n\t\tlabel: __( 'Horizontal' ),\n\t\tvalue: 'horizontal-tb',\n\t\ticon: textHorizontal,\n\t},\n\t{\n\t\tlabel: __( 'Vertical' ),\n\t\tvalue: isRTL() ? 'vertical-lr' : 'vertical-rl',\n\t\ticon: textVertical,\n\t},\n];\n\n/**\n * Control to facilitate writing mode selections.\n *\n * @param {Object} props Component props.\n * @param {string} props.className Class name to add to the control.\n * @param {string} props.value Currently selected writing mode.\n * @param {Function} props.onChange Handles change in the writing mode selection.\n *\n * @return {Element} Writing Mode control.\n */\nexport default function WritingModeControl( { className, value, onChange } ) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\tisDeselectable\n\t\t\tlabel={ __( 'Orientation' ) }\n\t\t\tclassName={ clsx( 'block-editor-writing-mode-control', className ) }\n\t\t\tvalue={ value }\n\t\t\tonChange={ ( newValue ) => {\n\t\t\t\tonChange( newValue === value ? undefined : newValue );\n\t\t\t} }\n\t\t>\n\t\t\t{ WRITING_MODES.map( ( option ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\tkey={ option.value }\n\t\t\t\t\t\tvalue={ option.value }\n\t\t\t\t\t\ticon={ option.icon }\n\t\t\t\t\t\tlabel={ option.label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,IAAI,aAAa;AAC1B,SAAS,gBAAgB,oBAAoB;AAC7C;AAAA,EACC,oCAAoC;AAAA,EACpC,8CAA8C;AAAA,OACxC;AAsCF;AApCL,IAAM,gBAAgB;AAAA,EACrB;AAAA,IACC,OAAO,GAAI,YAAa;AAAA,IACxB,OAAO;AAAA,IACP,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,OAAO,GAAI,UAAW;AAAA,IACtB,OAAO,MAAM,IAAI,gBAAgB;AAAA,IACjC,MAAM;AAAA,EACP;AACD;AAYe,SAAR,mBAAqC,EAAE,WAAW,OAAO,SAAS,GAAI;AAC5E,SACC;AAAA,IAAC;AAAA;AAAA,MACA,gBAAc;AAAA,MACd,OAAQ,GAAI,aAAc;AAAA,MAC1B,WAAY,KAAM,qCAAqC,SAAU;AAAA,MACjE;AAAA,MACA,UAAW,CAAE,aAAc;AAC1B,iBAAU,aAAa,QAAQ,SAAY,QAAS;AAAA,MACrD;AAAA,MAEE,wBAAc,IAAK,CAAE,WAAY;AAClC,eACC;AAAA,UAAC;AAAA;AAAA,YAEA,OAAQ,OAAO;AAAA,YACf,MAAO,OAAO;AAAA,YACd,OAAQ,OAAO;AAAA;AAAA,UAHT,OAAO;AAAA,QAId;AAAA,MAEF,CAAE;AAAA;AAAA,EACH;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/font-size.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport TokenList from '@wordpress/token-list';\nimport { getTypographyFontSizeValue } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetFontSize,\n\tgetFontSizeClass,\n\tgetFontSizeObjectByValue,\n\tFontSizePicker,\n} from '../components/font-sizes';\nimport { TYPOGRAPHY_SUPPORT_KEY } from './typography';\nimport {\n\tcleanEmptyObject,\n\ttransformStyles,\n\tshouldSkipSerialization,\n} from './utils';\nimport { useSettings } from '../components/use-settings';\n\nexport const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';\n\n/**\n * Filters registered block settings, extending attributes to include\n * `fontSize` and `fontWeight` attributes.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, FONT_SIZE_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify a default value if needed.\n\tif ( ! settings.attributes.fontSize ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tfontSize: {\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 font size.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockNameOrType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nfunction addSaveProps( props, blockNameOrType, attributes ) {\n\tif ( ! hasBlockSupport( blockNameOrType, FONT_SIZE_SUPPORT_KEY ) ) {\n\t\treturn props;\n\t}\n\n\tif (\n\t\tshouldSkipSerialization(\n\t\t\tblockNameOrType,\n\t\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t\t\t'fontSize'\n\t\t)\n\t) {\n\t\treturn props;\n\t}\n\n\t// Use TokenList to dedupe classes.\n\tconst classes = new TokenList( props.className );\n\tclasses.add( getFontSizeClass( attributes.fontSize ) );\n\tconst newClassName = classes.value;\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Inspector control panel containing the font size related configuration\n *\n * @param {Object} props\n *\n * @return {Element} Font size edit element.\n */\nexport function FontSizeEdit( props ) {\n\tconst {\n\t\tattributes: { fontSize, style },\n\t\tsetAttributes,\n\t} = props;\n\tconst [ fontSizes ] = useSettings( 'typography.fontSizes' );\n\n\tconst onChange = ( value, selectedItem ) => {\n\t\t// Use the selectedItem's slug if available, otherwise fall back to finding by value\n\t\tconst fontSizeSlug =\n\t\t\tselectedItem?.slug ||\n\t\t\tgetFontSizeObjectByValue( fontSizes, value ).slug;\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\tfontSize: fontSizeSlug ? undefined : value,\n\t\t\t\t},\n\t\t\t} ),\n\t\t\tfontSize: fontSizeSlug,\n\t\t} );\n\t};\n\n\tconst fontSizeObject = getFontSize(\n\t\tfontSizes,\n\t\tfontSize,\n\t\tstyle?.typography?.fontSize\n\t);\n\n\tconst fontSizeValue =\n\t\tfontSizeObject?.size || style?.typography?.fontSize || fontSize;\n\n\treturn (\n\t\t<FontSizePicker\n\t\t\tonChange={ onChange }\n\t\t\tvalue={ fontSize || fontSizeValue }\n\t\t\tvalueMode={ fontSize ? 'slug' : 'literal' }\n\t\t\twithReset={ false }\n\t\t\twithSlider\n\t\t
|
|
5
|
-
"mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,OAAO,eAAe;AACtB,SAAS,kCAAkC;AAK3C;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,8BAA8B;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,mBAAmB;AAwG1B;AAtGK,IAAM,wBAAwB;AAUrC,SAAS,cAAe,UAAW;AAClC,MAAK,CAAE,gBAAiB,UAAU,qBAAsB,GAAI;AAC3D,WAAO;AAAA,EACR;AAGA,MAAK,CAAE,SAAS,WAAW,UAAW;AACrC,WAAO,OAAQ,SAAS,YAAY;AAAA,MACnC,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,IACD,CAAE;AAAA,EACH;AAEA,SAAO;AACR;AAWA,SAAS,aAAc,OAAO,iBAAiB,YAAa;AAC3D,MAAK,CAAE,gBAAiB,iBAAiB,qBAAsB,GAAI;AAClE,WAAO;AAAA,EACR;AAEA,MACC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACD,GACC;AACD,WAAO;AAAA,EACR;AAGA,QAAM,UAAU,IAAI,UAAW,MAAM,SAAU;AAC/C,UAAQ,IAAK,iBAAkB,WAAW,QAAS,CAAE;AACrD,QAAM,eAAe,QAAQ;AAC7B,QAAM,YAAY,eAAe,eAAe;AAEhD,SAAO;AACR;AASO,SAAS,aAAc,OAAQ;AACrC,QAAM;AAAA,IACL,YAAY,EAAE,UAAU,MAAM;AAAA,IAC9B;AAAA,EACD,IAAI;AACJ,QAAM,CAAE,SAAU,IAAI,YAAa,sBAAuB;AAE1D,QAAM,WAAW,CAAE,OAAO,iBAAkB;AAE3C,UAAM,eACL,cAAc,QACd,yBAA0B,WAAW,KAAM,EAAE;AAE9C,kBAAe;AAAA,MACd,OAAO,iBAAkB;AAAA,QACxB,GAAG;AAAA,QACH,YAAY;AAAA,UACX,GAAG,OAAO;AAAA,UACV,UAAU,eAAe,SAAY;AAAA,QACtC;AAAA,MACD,CAAE;AAAA,MACF,UAAU;AAAA,IACX,CAAE;AAAA,EACH;AAEA,QAAM,iBAAiB;AAAA,IACtB;AAAA,IACA;AAAA,IACA,OAAO,YAAY;AAAA,EACpB;AAEA,QAAM,gBACL,gBAAgB,QAAQ,OAAO,YAAY,YAAY;AAExD,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,OAAQ,YAAY;AAAA,MACpB,WAAY,WAAW,SAAS;AAAA,MAChC,WAAY;AAAA,MACZ,YAAU;AAAA
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport TokenList from '@wordpress/token-list';\nimport { getTypographyFontSizeValue } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetFontSize,\n\tgetFontSizeClass,\n\tgetFontSizeObjectByValue,\n\tFontSizePicker,\n} from '../components/font-sizes';\nimport { TYPOGRAPHY_SUPPORT_KEY } from './typography';\nimport {\n\tcleanEmptyObject,\n\ttransformStyles,\n\tshouldSkipSerialization,\n} from './utils';\nimport { useSettings } from '../components/use-settings';\n\nexport const FONT_SIZE_SUPPORT_KEY = 'typography.fontSize';\n\n/**\n * Filters registered block settings, extending attributes to include\n * `fontSize` and `fontWeight` attributes.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, FONT_SIZE_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify a default value if needed.\n\tif ( ! settings.attributes.fontSize ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tfontSize: {\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 font size.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockNameOrType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nfunction addSaveProps( props, blockNameOrType, attributes ) {\n\tif ( ! hasBlockSupport( blockNameOrType, FONT_SIZE_SUPPORT_KEY ) ) {\n\t\treturn props;\n\t}\n\n\tif (\n\t\tshouldSkipSerialization(\n\t\t\tblockNameOrType,\n\t\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t\t\t'fontSize'\n\t\t)\n\t) {\n\t\treturn props;\n\t}\n\n\t// Use TokenList to dedupe classes.\n\tconst classes = new TokenList( props.className );\n\tclasses.add( getFontSizeClass( attributes.fontSize ) );\n\tconst newClassName = classes.value;\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Inspector control panel containing the font size related configuration\n *\n * @param {Object} props\n *\n * @return {Element} Font size edit element.\n */\nexport function FontSizeEdit( props ) {\n\tconst {\n\t\tattributes: { fontSize, style },\n\t\tsetAttributes,\n\t} = props;\n\tconst [ fontSizes ] = useSettings( 'typography.fontSizes' );\n\n\tconst onChange = ( value, selectedItem ) => {\n\t\t// Use the selectedItem's slug if available, otherwise fall back to finding by value\n\t\tconst fontSizeSlug =\n\t\t\tselectedItem?.slug ||\n\t\t\tgetFontSizeObjectByValue( fontSizes, value ).slug;\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\tfontSize: fontSizeSlug ? undefined : value,\n\t\t\t\t},\n\t\t\t} ),\n\t\t\tfontSize: fontSizeSlug,\n\t\t} );\n\t};\n\n\tconst fontSizeObject = getFontSize(\n\t\tfontSizes,\n\t\tfontSize,\n\t\tstyle?.typography?.fontSize\n\t);\n\n\tconst fontSizeValue =\n\t\tfontSizeObject?.size || style?.typography?.fontSize || fontSize;\n\n\treturn (\n\t\t<FontSizePicker\n\t\t\tonChange={ onChange }\n\t\t\tvalue={ fontSize || fontSizeValue }\n\t\t\tvalueMode={ fontSize ? 'slug' : 'literal' }\n\t\t\twithReset={ false }\n\t\t\twithSlider\n\t\t/>\n\t);\n}\n\n/**\n * Custom hook that checks if font-size settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether setting is disabled.\n */\nexport function useIsFontSizeDisabled( { name: blockName } = {} ) {\n\tconst [ fontSizes ] = useSettings( 'typography.fontSizes' );\n\tconst hasFontSizes = !! fontSizes?.length;\n\n\treturn (\n\t\t! hasBlockSupport( blockName, FONT_SIZE_SUPPORT_KEY ) || ! hasFontSizes\n\t);\n}\n\nfunction useBlockProps( { name, fontSize, style } ) {\n\tconst [ fontSizes, fluidTypographySettings, layoutSettings ] = useSettings(\n\t\t'typography.fontSizes',\n\t\t'typography.fluid',\n\t\t'layout'\n\t);\n\n\t/*\n\t * Only add inline styles if the block supports font sizes,\n\t * doesn't skip serialization of font sizes,\n\t * and has either a custom font size or a preset font size.\n\t */\n\tif (\n\t\t! hasBlockSupport( name, FONT_SIZE_SUPPORT_KEY ) ||\n\t\tshouldSkipSerialization( name, TYPOGRAPHY_SUPPORT_KEY, 'fontSize' ) ||\n\t\t( ! fontSize && ! style?.typography?.fontSize )\n\t) {\n\t\treturn;\n\t}\n\n\tlet props;\n\n\tif ( style?.typography?.fontSize ) {\n\t\tprops = {\n\t\t\tstyle: {\n\t\t\t\tfontSize: getTypographyFontSizeValue(\n\t\t\t\t\t{ size: style.typography.fontSize },\n\t\t\t\t\t{\n\t\t\t\t\t\ttypography: {\n\t\t\t\t\t\t\tfluid: fluidTypographySettings,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlayout: layoutSettings,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t};\n\t}\n\n\tif ( fontSize ) {\n\t\tprops = {\n\t\t\tstyle: {\n\t\t\t\tfontSize: getFontSize(\n\t\t\t\t\tfontSizes,\n\t\t\t\t\tfontSize,\n\t\t\t\t\tstyle?.typography?.fontSize\n\t\t\t\t).size,\n\t\t\t},\n\t\t};\n\t}\n\n\tif ( ! props ) {\n\t\treturn;\n\t}\n\n\treturn addSaveProps( props, name, { fontSize } );\n}\n\nexport default {\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'fontSize', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, FONT_SIZE_SUPPORT_KEY );\n\t},\n};\n\nconst MIGRATION_PATHS = {\n\tfontSize: [ [ 'fontSize' ], [ 'style', 'typography', 'fontSize' ] ],\n};\n\nfunction addTransforms( result, source, index, results ) {\n\tconst destinationBlockType = result.name;\n\tconst activeSupports = {\n\t\tfontSize: hasBlockSupport(\n\t\t\tdestinationBlockType,\n\t\t\tFONT_SIZE_SUPPORT_KEY\n\t\t),\n\t};\n\treturn transformStyles(\n\t\tactiveSupports,\n\t\tMIGRATION_PATHS,\n\t\tresult,\n\t\tsource,\n\t\tindex,\n\t\tresults\n\t);\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/font/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/font-size/addTransforms',\n\taddTransforms\n);\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,OAAO,eAAe;AACtB,SAAS,kCAAkC;AAK3C;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,8BAA8B;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,mBAAmB;AAwG1B;AAtGK,IAAM,wBAAwB;AAUrC,SAAS,cAAe,U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BAAkB;AAAA,EACvB,UAAU,CAAE,CAAE,UAAW,GAAG,CAAE,SAAS,cAAc,UAAW,CAAE;AACnE;AAEA,SAAS,cAAe,QAAQ,QAAQ,OAAO,SAAU;AACxD,QAAM,uBAAuB,OAAO;AACpC,QAAM,iBAAiB;AAAA,IACtB,UAAU;AAAA,MACT;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -68,8 +68,9 @@ function getLayoutStateOverrides(layout = {}, baseLayout = {}, existingLayout =
|
|
|
68
68
|
).map((key) => [key, existingLayout[key]])
|
|
69
69
|
);
|
|
70
70
|
Object.entries(layout || {}).forEach(([key, value]) => {
|
|
71
|
+
const baseHasValue = Object.hasOwn(baseLayout || {}, key);
|
|
71
72
|
if (!CHILD_LAYOUT_KEYS.includes(key) && value !== baseLayout?.[key]) {
|
|
72
|
-
overrides[key] = value;
|
|
73
|
+
overrides[key] = value === void 0 && baseHasValue ? null : value;
|
|
73
74
|
}
|
|
74
75
|
});
|
|
75
76
|
return cleanEmptyObject({
|
|
@@ -297,7 +298,7 @@ function LayoutPanelPure({
|
|
|
297
298
|
const nextStateStyle = cleanEmptyObject({
|
|
298
299
|
...stateStyle,
|
|
299
300
|
layout: getLayoutStateOverrides(
|
|
300
|
-
|
|
301
|
+
newLayout,
|
|
301
302
|
baseLayout,
|
|
302
303
|
stateStyle?.layout
|
|
303
304
|
)
|
|
@@ -415,7 +416,6 @@ function LayoutTypeSwitcher({ type, onChange }) {
|
|
|
415
416
|
return /* @__PURE__ */ jsx(
|
|
416
417
|
ToggleGroupControl,
|
|
417
418
|
{
|
|
418
|
-
__next40pxDefaultSize: true,
|
|
419
419
|
isBlock: true,
|
|
420
420
|
label: __("Layout type"),
|
|
421
421
|
hideLabelFromVision: true,
|
|
@@ -571,6 +571,7 @@ addFilter(
|
|
|
571
571
|
export {
|
|
572
572
|
addAttribute,
|
|
573
573
|
layout_default as default,
|
|
574
|
+
getLayoutStateOverrides,
|
|
574
575
|
getResetLayout,
|
|
575
576
|
getResponsiveLayoutStyles,
|
|
576
577
|
useLayoutClasses,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/layout.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useCallback } from '@wordpress/element';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport { useSettings } from '../components/use-settings';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { cleanEmptyObject, useBlockSettings, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport { getVariationNameFromClass } from './block-style-variation';\nimport {\n\tDEFAULT_BLOCK_STYLE_STATE,\n\tgetStyleForState,\n\thasPseudoBlockStyleState,\n\thasViewportBlockStyleState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n} from './block-style-state';\n\nconst VARIATION_PREFIX = 'is-style-';\n\nconst layoutBlockSupportKey = 'layout';\n// Keep in sync with WP_Theme_JSON_Gutenberg::RESPONSIVE_BREAKPOINTS and\n// packages/global-styles-engine/src/core/render.tsx.\nconst RESPONSIVE_BREAKPOINTS = {\n\t'@mobile': '@media (width <= 480px)',\n\t'@tablet': '@media (480px < width <= 782px)',\n};\nconst CHILD_LAYOUT_KEYS = [\n\t'selfStretch',\n\t'flexSize',\n\t'columnStart',\n\t'columnSpan',\n\t'rowStart',\n\t'rowSpan',\n];\nconst { kebabCase } = unlock( componentsPrivateApis );\n\nfunction getDefaultLayout( layoutBlockSupport = {}, blockVariation ) {\n\tconst defaultBlockLayout = layoutBlockSupport?.default;\n\n\treturn blockVariation?.attributes?.layout ?? defaultBlockLayout;\n}\n\n/**\n * Returns the layout values to use when resetting layout controls.\n *\n * @param { Object } layoutBlockSupport Block layout support settings.\n * @param { Object|undefined } blockVariation Block variation settings.\n *\n * @return { Object|undefined } Reset layout values.\n */\nexport function getResetLayout( layoutBlockSupport = {}, blockVariation ) {\n\treturn cleanEmptyObject( {\n\t\t...getDefaultLayout( layoutBlockSupport, blockVariation ),\n\t} );\n}\n\nfunction getLayoutStateOverrides(\n\tlayout = {},\n\tbaseLayout = {},\n\texistingLayout = {}\n) {\n\tconst overrides = {};\n\tconst childLayoutValues = Object.fromEntries(\n\t\tCHILD_LAYOUT_KEYS.filter( ( key ) =>\n\t\t\tObject.hasOwn( existingLayout || {}, key )\n\t\t).map( ( key ) => [ key, existingLayout[ key ] ] )\n\t);\n\n\tObject.entries( layout || {} ).forEach( ( [ key, value ] ) => {\n\t\tif (\n\t\t\t! CHILD_LAYOUT_KEYS.includes( key ) &&\n\t\t\tvalue !== baseLayout?.[ key ]\n\t\t) {\n\t\t\toverrides[ key ] = value;\n\t\t}\n\t} );\n\n\treturn cleanEmptyObject( {\n\t\t...childLayoutValues,\n\t\t...overrides,\n\t} );\n}\n\nfunction getLayoutContainerValues( layout = {} ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( layout || {} ).filter(\n\t\t\t( [ key ] ) => ! CHILD_LAYOUT_KEYS.includes( key )\n\t\t)\n\t);\n}\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst { layout } = blockAttributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tconst hasGlobalPadding = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when layout doesn't use global padding\n\t\t\tif (\n\t\t\t\t! usedLayout?.inherit &&\n\t\t\t\t! usedLayout?.contentSize &&\n\t\t\t\tusedLayout?.type !== 'constrained'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn select( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalFeatures?.useRootPaddingAwareAlignments;\n\t\t},\n\t\t[ usedLayout?.contentSize, usedLayout?.inherit, usedLayout?.type ]\n\t);\n\n\tif ( hasGlobalPadding ) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\treturn fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n}\n\n/**\n * Generates responsive layout CSS for viewport state styles.\n *\n * Viewport state blockGap values need to go through the layout definitions\n * because flow/constrained layouts use child margins while flex/grid use gap.\n *\n * @param { Object } options Options.\n * @param { Object } options.attributes Block attributes.\n * @param { string } options.blockName Block name.\n * @param { string } options.selector CSS selector.\n * @param { Object } options.layout Active block layout.\n * @param { boolean } options.hasBlockGapSupport Whether block gap is supported.\n * @param { * } options.globalBlockGapValue Global block gap fallback.\n *\n * @return { string } CSS rule.\n */\nexport function getResponsiveLayoutStyles( {\n\tattributes = {},\n\tblockName,\n\tselector,\n\tlayout = {},\n\thasBlockGapSupport,\n\tglobalBlockGapValue,\n} ) {\n\treturn Object.entries( RESPONSIVE_BREAKPOINTS )\n\t\t.map( ( [ viewport, mediaQuery ] ) => {\n\t\t\tconst viewportStyle = 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 { themeSupportsLayout, activeBlockVariation, selectedState } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst blockEditorSelect = select( blockEditorStore );\n\t\t\t\tconst { getBlockAttributes, getSettings } = blockEditorSelect;\n\t\t\t\tconst { getSelectedBlockStyleState } =\n\t\t\t\t\tunlock( blockEditorSelect );\n\t\t\t\treturn {\n\t\t\t\t\tactiveBlockVariation: select(\n\t\t\t\t\t\tblocksStore\n\t\t\t\t\t).getActiveBlockVariation(\n\t\t\t\t\t\tblockName,\n\t\t\t\t\t\tgetBlockAttributes( clientId ) || {},\n\t\t\t\t\t\t'block'\n\t\t\t\t\t),\n\t\t\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t\t\t\tselectedState:\n\t\t\t\t\t\tgetSelectedBlockStyleState?.( clientId ) ??\n\t\t\t\t\t\tDEFAULT_BLOCK_STYLE_STATE,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ blockName, clientId ]\n\t\t);\n\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isViewportLayoutState =\n\t\thasViewportBlockStyleState( selectedState ) &&\n\t\t! hasPseudoBlockStyleState( selectedState );\n\tconst resetLayoutFilter = useCallback(\n\t\t( ...resetArgs ) => {\n\t\t\tconst attributes = resetArgs[ 0 ] || {};\n\t\t\tconst context = resetArgs[ 1 ] || {};\n\n\t\t\tif ( isViewportLayoutState ) {\n\t\t\t\tconst existingStateStyle =\n\t\t\t\t\tgetStyleForState(\n\t\t\t\t\t\tattributes.style ?? style,\n\t\t\t\t\t\tselectedState\n\t\t\t\t\t) || {};\n\t\t\t\tconst nextStateStyle = cleanEmptyObject( {\n\t\t\t\t\t...existingStateStyle,\n\t\t\t\t\tlayout: undefined,\n\t\t\t\t} );\n\n\t\t\t\treturn {\n\t\t\t\t\tstyle: setStyleForState(\n\t\t\t\t\t\tattributes.style ?? style,\n\t\t\t\t\t\tselectedState,\n\t\t\t\t\t\tnextStateStyle\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst resetBlockName = context.name || blockName;\n\t\t\tconst resetLayoutBlockSupport = getBlockSupport(\n\t\t\t\tresetBlockName,\n\t\t\t\tlayoutBlockSupportKey,\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlayout: getResetLayout(\n\t\t\t\t\tresetLayoutBlockSupport,\n\t\t\t\t\tactiveBlockVariation\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tblockName,\n\t\t\tactiveBlockVariation,\n\t\t\tisViewportLayoutState,\n\t\t\tselectedState,\n\t\t\tstyle,\n\t\t]\n\t);\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\t// Layout block support comes from the block's block.json.\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst blockSupportAndThemeSettings = {\n\t\t...layoutSettings,\n\t\t...layoutBlockSupport,\n\t};\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = blockSupportAndThemeSettings;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * Try to find the layout type from either the\n\t * block's layout settings or any saved layout config.\n\t */\n\tconst baseLayout = layout || defaultBlockLayout || {};\n\tconst stateStyle = isViewportLayoutState\n\t\t? getStyleForState( style, selectedState )\n\t\t: undefined;\n\tconst stateLayout = stateStyle?.layout;\n\tconst usedLayout = isViewportLayoutState\n\t\t? cleanEmptyObject( {\n\t\t\t\t...baseLayout,\n\t\t\t\t...stateLayout,\n\t\t } ) || {}\n\t\t: baseLayout;\n\tconst resetLayoutDefaults = isViewportLayoutState\n\t\t? baseLayout\n\t\t: getResetLayout( layoutBlockSupport, activeBlockVariation );\n\tconst blockSupportAndLayout = {\n\t\t...layoutBlockSupport,\n\t\t...usedLayout,\n\t};\n\tconst { type, default: { type: defaultType = 'default' } = {} } =\n\t\tblockSupportAndLayout;\n\tconst blockLayoutType = type || defaultType;\n\n\t// Only show the inherit toggle if it's supported,\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t( ! blockLayoutType ||\n\t\t\tblockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ||\n\t\t\tblockSupportAndLayout.inherit )\n\t);\n\n\tconst { inherit = false, contentSize = null } = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( blockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( blockLayoutType );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\tconst showLayoutTypeSwitcher =\n\t\tisDefaultBlockStyleState( selectedState ) &&\n\t\t! inherit &&\n\t\tallowSwitching;\n\n\tconst onChangeLayout = ( newLayout ) => {\n\t\tif ( isViewportLayoutState ) {\n\t\t\tconst nextStateStyle = cleanEmptyObject( {\n\t\t\t\t...stateStyle,\n\t\t\t\tlayout: getLayoutStateOverrides(\n\t\t\t\t\tcleanEmptyObject( newLayout ),\n\t\t\t\t\tbaseLayout,\n\t\t\t\t\tstateStyle?.layout\n\t\t\t\t),\n\t\t\t} );\n\t\t\tsetAttributes( {\n\t\t\t\tstyle: setStyleForState( style, selectedState, nextStateStyle ),\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\tsetAttributes( { layout: cleanEmptyObject( newLayout ) } );\n\t};\n\tconst onChangeType = ( newType ) => onChangeLayout( { type: newType } );\n\tconst resetLayout = () => onChangeLayout( resetLayoutDefaults );\n\tconst resetInheritToggle = () => onChangeLayout( { type: 'default' } );\n\tconst isUsingContentWidth = () =>\n\t\tlayoutType?.name === 'constrained' || hasContentSizeOrLegacySettings;\n\tconst hasInheritToggleValue = () =>\n\t\tisViewportLayoutState\n\t\t\t? ( usedLayout?.type ?? 'default' ) !==\n\t\t\t ( resetLayoutDefaults?.type ?? 'default' )\n\t\t\t: layout?.type === 'constrained';\n\tconst hasLayoutTypeValue = () =>\n\t\t( usedLayout?.type ?? 'default' ) !==\n\t\t( resetLayoutDefaults?.type ?? 'default' );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls\n\t\t\t\tgroup=\"layout\"\n\t\t\t\tresetAllFilter={ resetLayoutFilter }\n\t\t\t>\n\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Use content width' ) }\n\t\t\t\t\t\thasValue={ hasInheritToggleValue }\n\t\t\t\t\t\tonDeselect={ resetInheritToggle }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\tchecked={ isUsingContentWidth() }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tonChangeLayout( {\n\t\t\t\t\t\t\t\t\ttype: isUsingContentWidth()\n\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t: 'constrained',\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\tisUsingContentWidth()\n\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container.'\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\n\t\t\t\t{ showLayoutTypeSwitcher && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Layout type' ) }\n\t\t\t\t\t\thasValue={ hasLayoutTypeValue }\n\t\t\t\t\t\tonDeselect={ resetLayout }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ blockLayoutType }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\n\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\tvalue={ layout }\n\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\tresetLayout={ resetLayoutDefaults }\n\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\tvalue={ layout }\n\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\tresetLayout={ resetLayoutDefaults }\n\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\tname={ blockName }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: LayoutPanelPure,\n\tattributeKeys: [ 'layout', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasLayoutBlockSupport( name );\n\t},\n};\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\t__next40pxDefaultSize\n\t\t\tisBlock\n\t\t\tlabel={ __( 'Layout type' ) }\n\t\t\thideLabelFromVision\n\t\t\tisAdaptiveWidth\n\t\t\tvalue={ type }\n\t\t\tonChange={ onChange }\n\t\t>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockWithLayoutStyles( {\n\tblock: BlockListBlock,\n\tprops,\n\tblockGapSupport,\n\tglobalBlockGapValue,\n\tlayoutClasses,\n} ) {\n\tconst { name, attributes } = props;\n\tconst id = useInstanceId( BlockListBlock );\n\tconst { layout } = attributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst selectorPrefix = `wp-container-${ kebabCase( name ) }-is-layout-`;\n\t// Higher specificity to override defaults from theme.json.\n\tconst selector = `.${ selectorPrefix }${ id }`;\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t// Get CSS string for the current layout type.\n\t// The CSS and `style` element is only output if it is not empty.\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst baseLayoutCSS = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\tstyle: attributes?.style,\n\t\thasBlockGapSupport,\n\t\tglobalBlockGapValue,\n\t} );\n\tconst responsiveLayoutCSS = getResponsiveLayoutStyles( {\n\t\tattributes,\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\thasBlockGapSupport,\n\t\tglobalBlockGapValue,\n\t} );\n\tconst css = [ baseLayoutCSS, responsiveLayoutCSS ]\n\t\t.filter( Boolean )\n\t\t.join( '' );\n\n\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\tconst layoutClassNames = clsx(\n\t\t{\n\t\t\t[ `${ selectorPrefix }${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t},\n\t\tlayoutClasses\n\t);\n\n\tuseStyleOverride( { css } );\n\n\treturn (\n\t\t<BlockListBlock\n\t\t\t{ ...props }\n\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t/>\n\t);\n}\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) =>\n\t\tfunction WithLayoutStyles( props ) {\n\t\t\tconst { clientId, name, attributes } = props;\n\t\t\tconst blockSupportsLayout = hasLayoutBlockSupport( name );\n\t\t\tconst layoutClasses = useLayoutClasses( attributes, name );\n\t\t\tconst extraProps = useSelect(\n\t\t\t\t( select ) => {\n\t\t\t\t\t// The callback returns early to avoid block editor subscription.\n\t\t\t\t\tif ( ! blockSupportsLayout ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { getSettings, getBlockSettings } = unlock(\n\t\t\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t);\n\t\t\t\t\tconst settings = getSettings();\n\t\t\t\t\tconst { disableLayoutStyles } = settings;\n\n\t\t\t\t\tif ( disableLayoutStyles ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst [ blockGapSupport ] = getBlockSettings(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t'spacing.blockGap'\n\t\t\t\t\t);\n\n\t\t\t\t\t// Get default blockGap value from global styles for use in layouts like grid.\n\t\t\t\t\t// Check style variation first, then block-specific styles, then fall back to root styles.\n\t\t\t\t\tconst globalStyles = settings[ globalStylesDataKey ];\n\n\t\t\t\t\t// Check if the block has an active style variation with a blockGap value.\n\t\t\t\t\t// Only check the registry if the className contains a variation class to avoid unnecessary lookups.\n\t\t\t\t\tlet variationBlockGapValue;\n\t\t\t\t\tconst className = attributes?.className;\n\t\t\t\t\tif ( className?.includes( VARIATION_PREFIX ) ) {\n\t\t\t\t\t\tconst { getBlockStyles } = select( blocksStore );\n\t\t\t\t\t\tconst registeredStyles = getBlockStyles( name );\n\t\t\t\t\t\tconst variationName = getVariationNameFromClass(\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\tregisteredStyles\n\t\t\t\t\t\t);\n\t\t\t\t\t\tvariationBlockGapValue = variationName\n\t\t\t\t\t\t\t? globalStyles?.blocks?.[ name ]?.variations?.[\n\t\t\t\t\t\t\t\t\tvariationName\n\t\t\t\t\t\t\t ]?.spacing?.blockGap\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst globalBlockGapValue =\n\t\t\t\t\t\tvariationBlockGapValue ??\n\t\t\t\t\t\tglobalStyles?.blocks?.[ name ]?.spacing?.blockGap ??\n\t\t\t\t\t\tglobalStyles?.spacing?.blockGap;\n\n\t\t\t\t\treturn { blockGapSupport, globalBlockGapValue };\n\t\t\t\t},\n\t\t\t\t[ blockSupportsLayout, clientId, attributes?.className, name ]\n\t\t\t);\n\n\t\t\tif ( ! extraProps ) {\n\t\t\t\treturn (\n\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t__unstableLayoutClassNames={\n\t\t\t\t\t\t\tblockSupportsLayout ? layoutClasses : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<BlockWithLayoutStyles\n\t\t\t\t\tblock={ BlockListBlock }\n\t\t\t\t\tprops={ props }\n\t\t\t\t\tlayoutClasses={ layoutClasses }\n\t\t\t\t\t{ ...extraProps }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t'withLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,4BAA4B,qBAAqB;AAC1D,SAAS,iBAAiB;AAC1B,SAAS,m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AAAA;AAAA,QACA,OAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACE,GAAG;AAAA;AAAA,IACN;AAAA,EAEF;AAAA,EACD;AACD;AAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useCallback } from '@wordpress/element';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport { useSettings } from '../components/use-settings';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { cleanEmptyObject, useBlockSettings, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport { getVariationNameFromClass } from './block-style-variation';\nimport {\n\tDEFAULT_BLOCK_STYLE_STATE,\n\tgetStyleForState,\n\thasPseudoBlockStyleState,\n\thasViewportBlockStyleState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n} from './block-style-state';\n\nconst VARIATION_PREFIX = 'is-style-';\n\nconst layoutBlockSupportKey = 'layout';\n// Keep in sync with WP_Theme_JSON_Gutenberg::RESPONSIVE_BREAKPOINTS and\n// packages/global-styles-engine/src/core/render.tsx.\nconst RESPONSIVE_BREAKPOINTS = {\n\t'@mobile': '@media (width <= 480px)',\n\t'@tablet': '@media (480px < width <= 782px)',\n};\nconst CHILD_LAYOUT_KEYS = [\n\t'selfStretch',\n\t'flexSize',\n\t'columnStart',\n\t'columnSpan',\n\t'rowStart',\n\t'rowSpan',\n];\nconst { kebabCase } = unlock( componentsPrivateApis );\n\nfunction getDefaultLayout( layoutBlockSupport = {}, blockVariation ) {\n\tconst defaultBlockLayout = layoutBlockSupport?.default;\n\n\treturn blockVariation?.attributes?.layout ?? defaultBlockLayout;\n}\n\n/**\n * Returns the layout values to use when resetting layout controls.\n *\n * @param { Object } layoutBlockSupport Block layout support settings.\n * @param { Object|undefined } blockVariation Block variation settings.\n *\n * @return { Object|undefined } Reset layout values.\n */\nexport function getResetLayout( layoutBlockSupport = {}, blockVariation ) {\n\treturn cleanEmptyObject( {\n\t\t...getDefaultLayout( layoutBlockSupport, blockVariation ),\n\t} );\n}\n\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\nfunction getLayoutContainerValues( layout = {} ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( layout || {} ).filter(\n\t\t\t( [ key ] ) => ! CHILD_LAYOUT_KEYS.includes( key )\n\t\t)\n\t);\n}\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst { layout } = blockAttributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tconst hasGlobalPadding = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when layout doesn't use global padding\n\t\t\tif (\n\t\t\t\t! usedLayout?.inherit &&\n\t\t\t\t! usedLayout?.contentSize &&\n\t\t\t\tusedLayout?.type !== 'constrained'\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn select( blockEditorStore ).getSettings()\n\t\t\t\t.__experimentalFeatures?.useRootPaddingAwareAlignments;\n\t\t},\n\t\t[ usedLayout?.contentSize, usedLayout?.inherit, usedLayout?.type ]\n\t);\n\n\tif ( hasGlobalPadding ) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\treturn fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n}\n\n/**\n * Generates responsive layout CSS for viewport state styles.\n *\n * Viewport state blockGap values need to go through the layout definitions\n * because flow/constrained layouts use child margins while flex/grid use gap.\n *\n * @param { Object } options Options.\n * @param { Object } options.attributes Block attributes.\n * @param { string } options.blockName Block name.\n * @param { string } options.selector CSS selector.\n * @param { Object } options.layout Active block layout.\n * @param { boolean } options.hasBlockGapSupport Whether block gap is supported.\n * @param { * } options.globalBlockGapValue Global block gap fallback.\n *\n * @return { string } CSS rule.\n */\nexport function getResponsiveLayoutStyles( {\n\tattributes = {},\n\tblockName,\n\tselector,\n\tlayout = {},\n\thasBlockGapSupport,\n\tglobalBlockGapValue,\n} ) {\n\treturn Object.entries( RESPONSIVE_BREAKPOINTS )\n\t\t.map( ( [ viewport, mediaQuery ] ) => {\n\t\t\tconst viewportStyle = 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 { themeSupportsLayout, activeBlockVariation, selectedState } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst blockEditorSelect = select( blockEditorStore );\n\t\t\t\tconst { getBlockAttributes, getSettings } = blockEditorSelect;\n\t\t\t\tconst { getSelectedBlockStyleState } =\n\t\t\t\t\tunlock( blockEditorSelect );\n\t\t\t\treturn {\n\t\t\t\t\tactiveBlockVariation: select(\n\t\t\t\t\t\tblocksStore\n\t\t\t\t\t).getActiveBlockVariation(\n\t\t\t\t\t\tblockName,\n\t\t\t\t\t\tgetBlockAttributes( clientId ) || {},\n\t\t\t\t\t\t'block'\n\t\t\t\t\t),\n\t\t\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t\t\t\tselectedState:\n\t\t\t\t\t\tgetSelectedBlockStyleState?.( clientId ) ??\n\t\t\t\t\t\tDEFAULT_BLOCK_STYLE_STATE,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ blockName, clientId ]\n\t\t);\n\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isViewportLayoutState =\n\t\thasViewportBlockStyleState( selectedState ) &&\n\t\t! hasPseudoBlockStyleState( selectedState );\n\tconst resetLayoutFilter = useCallback(\n\t\t( ...resetArgs ) => {\n\t\t\tconst attributes = resetArgs[ 0 ] || {};\n\t\t\tconst context = resetArgs[ 1 ] || {};\n\n\t\t\tif ( isViewportLayoutState ) {\n\t\t\t\tconst existingStateStyle =\n\t\t\t\t\tgetStyleForState(\n\t\t\t\t\t\tattributes.style ?? style,\n\t\t\t\t\t\tselectedState\n\t\t\t\t\t) || {};\n\t\t\t\tconst nextStateStyle = cleanEmptyObject( {\n\t\t\t\t\t...existingStateStyle,\n\t\t\t\t\tlayout: undefined,\n\t\t\t\t} );\n\n\t\t\t\treturn {\n\t\t\t\t\tstyle: setStyleForState(\n\t\t\t\t\t\tattributes.style ?? style,\n\t\t\t\t\t\tselectedState,\n\t\t\t\t\t\tnextStateStyle\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst resetBlockName = context.name || blockName;\n\t\t\tconst resetLayoutBlockSupport = getBlockSupport(\n\t\t\t\tresetBlockName,\n\t\t\t\tlayoutBlockSupportKey,\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tlayout: getResetLayout(\n\t\t\t\t\tresetLayoutBlockSupport,\n\t\t\t\t\tactiveBlockVariation\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tblockName,\n\t\t\tactiveBlockVariation,\n\t\t\tisViewportLayoutState,\n\t\t\tselectedState,\n\t\t\tstyle,\n\t\t]\n\t);\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\t// Layout block support comes from the block's block.json.\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst blockSupportAndThemeSettings = {\n\t\t...layoutSettings,\n\t\t...layoutBlockSupport,\n\t};\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = blockSupportAndThemeSettings;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * Try to find the layout type from either the\n\t * block's layout settings or any saved layout config.\n\t */\n\tconst baseLayout = layout || defaultBlockLayout || {};\n\tconst stateStyle = isViewportLayoutState\n\t\t? getStyleForState( style, selectedState )\n\t\t: undefined;\n\tconst stateLayout = stateStyle?.layout;\n\tconst usedLayout = isViewportLayoutState\n\t\t? cleanEmptyObject( {\n\t\t\t\t...baseLayout,\n\t\t\t\t...stateLayout,\n\t\t } ) || {}\n\t\t: baseLayout;\n\tconst resetLayoutDefaults = isViewportLayoutState\n\t\t? baseLayout\n\t\t: getResetLayout( layoutBlockSupport, activeBlockVariation );\n\tconst blockSupportAndLayout = {\n\t\t...layoutBlockSupport,\n\t\t...usedLayout,\n\t};\n\tconst { type, default: { type: defaultType = 'default' } = {} } =\n\t\tblockSupportAndLayout;\n\tconst blockLayoutType = type || defaultType;\n\n\t// Only show the inherit toggle if it's supported,\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t( ! blockLayoutType ||\n\t\t\tblockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ||\n\t\t\tblockSupportAndLayout.inherit )\n\t);\n\n\tconst { inherit = false, contentSize = null } = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( blockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( blockLayoutType );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\tconst showLayoutTypeSwitcher =\n\t\tisDefaultBlockStyleState( selectedState ) &&\n\t\t! inherit &&\n\t\tallowSwitching;\n\n\tconst onChangeLayout = ( newLayout ) => {\n\t\tif ( isViewportLayoutState ) {\n\t\t\tconst nextStateStyle = cleanEmptyObject( {\n\t\t\t\t...stateStyle,\n\t\t\t\tlayout: getLayoutStateOverrides(\n\t\t\t\t\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<InspectorControls\n\t\t\t\tgroup=\"layout\"\n\t\t\t\tresetAllFilter={ resetLayoutFilter }\n\t\t\t>\n\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Use content width' ) }\n\t\t\t\t\t\thasValue={ hasInheritToggleValue }\n\t\t\t\t\t\tonDeselect={ resetInheritToggle }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\tchecked={ isUsingContentWidth() }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tonChangeLayout( {\n\t\t\t\t\t\t\t\t\ttype: isUsingContentWidth()\n\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t: 'constrained',\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\tisUsingContentWidth()\n\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container.'\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\n\t\t\t\t{ showLayoutTypeSwitcher && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Layout type' ) }\n\t\t\t\t\t\thasValue={ hasLayoutTypeValue }\n\t\t\t\t\t\tonDeselect={ resetLayout }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ blockLayoutType }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\n\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\tvalue={ layout }\n\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\tresetLayout={ resetLayoutDefaults }\n\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\tvalue={ layout }\n\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\tresetLayout={ resetLayoutDefaults }\n\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\tname={ blockName }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: LayoutPanelPure,\n\tattributeKeys: [ 'layout', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasLayoutBlockSupport( name );\n\t},\n};\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\tisBlock\n\t\t\tlabel={ __( 'Layout type' ) }\n\t\t\thideLabelFromVision\n\t\t\tisAdaptiveWidth\n\t\t\tvalue={ type }\n\t\t\tonChange={ onChange }\n\t\t>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockWithLayoutStyles( {\n\tblock: BlockListBlock,\n\tprops,\n\tblockGapSupport,\n\tglobalBlockGapValue,\n\tlayoutClasses,\n} ) {\n\tconst { name, attributes } = props;\n\tconst id = useInstanceId( BlockListBlock );\n\tconst { layout } = attributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst selectorPrefix = `wp-container-${ kebabCase( name ) }-is-layout-`;\n\t// Higher specificity to override defaults from theme.json.\n\tconst selector = `.${ selectorPrefix }${ id }`;\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t// Get CSS string for the current layout type.\n\t// The CSS and `style` element is only output if it is not empty.\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst baseLayoutCSS = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\tstyle: attributes?.style,\n\t\thasBlockGapSupport,\n\t\tglobalBlockGapValue,\n\t} );\n\tconst responsiveLayoutCSS = getResponsiveLayoutStyles( {\n\t\tattributes,\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\thasBlockGapSupport,\n\t\tglobalBlockGapValue,\n\t} );\n\tconst css = [ baseLayoutCSS, responsiveLayoutCSS ]\n\t\t.filter( Boolean )\n\t\t.join( '' );\n\n\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\tconst layoutClassNames = clsx(\n\t\t{\n\t\t\t[ `${ selectorPrefix }${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t},\n\t\tlayoutClasses\n\t);\n\n\tuseStyleOverride( { css } );\n\n\treturn (\n\t\t<BlockListBlock\n\t\t\t{ ...props }\n\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t/>\n\t);\n}\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) =>\n\t\tfunction WithLayoutStyles( props ) {\n\t\t\tconst { clientId, name, attributes } = props;\n\t\t\tconst blockSupportsLayout = hasLayoutBlockSupport( name );\n\t\t\tconst layoutClasses = useLayoutClasses( attributes, name );\n\t\t\tconst extraProps = useSelect(\n\t\t\t\t( select ) => {\n\t\t\t\t\t// The callback returns early to avoid block editor subscription.\n\t\t\t\t\tif ( ! blockSupportsLayout ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { getSettings, getBlockSettings } = unlock(\n\t\t\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t);\n\t\t\t\t\tconst settings = getSettings();\n\t\t\t\t\tconst { disableLayoutStyles } = settings;\n\n\t\t\t\t\tif ( disableLayoutStyles ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst [ blockGapSupport ] = getBlockSettings(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t'spacing.blockGap'\n\t\t\t\t\t);\n\n\t\t\t\t\t// Get default blockGap value from global styles for use in layouts like grid.\n\t\t\t\t\t// Check style variation first, then block-specific styles, then fall back to root styles.\n\t\t\t\t\tconst globalStyles = settings[ globalStylesDataKey ];\n\n\t\t\t\t\t// Check if the block has an active style variation with a blockGap value.\n\t\t\t\t\t// Only check the registry if the className contains a variation class to avoid unnecessary lookups.\n\t\t\t\t\tlet variationBlockGapValue;\n\t\t\t\t\tconst className = attributes?.className;\n\t\t\t\t\tif ( className?.includes( VARIATION_PREFIX ) ) {\n\t\t\t\t\t\tconst { getBlockStyles } = select( blocksStore );\n\t\t\t\t\t\tconst registeredStyles = getBlockStyles( name );\n\t\t\t\t\t\tconst variationName = getVariationNameFromClass(\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\tregisteredStyles\n\t\t\t\t\t\t);\n\t\t\t\t\t\tvariationBlockGapValue = variationName\n\t\t\t\t\t\t\t? globalStyles?.blocks?.[ name ]?.variations?.[\n\t\t\t\t\t\t\t\t\tvariationName\n\t\t\t\t\t\t\t ]?.spacing?.blockGap\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst globalBlockGapValue =\n\t\t\t\t\t\tvariationBlockGapValue ??\n\t\t\t\t\t\tglobalStyles?.blocks?.[ name ]?.spacing?.blockGap ??\n\t\t\t\t\t\tglobalStyles?.spacing?.blockGap;\n\n\t\t\t\t\treturn { blockGapSupport, globalBlockGapValue };\n\t\t\t\t},\n\t\t\t\t[ blockSupportsLayout, clientId, attributes?.className, name ]\n\t\t\t);\n\n\t\t\tif ( ! extraProps ) {\n\t\t\t\treturn (\n\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t__unstableLayoutClassNames={\n\t\t\t\t\t\t\tblockSupportsLayout ? layoutClasses : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<BlockWithLayoutStyles\n\t\t\t\t\tblock={ BlockListBlock }\n\t\t\t\t\tprops={ props }\n\t\t\t\t\tlayoutClasses={ layoutClasses }\n\t\t\t\t\t{ ...extraProps }\n\t\t\t\t/>\n\t\t\t);\n\t\t},\n\t'withLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,4BAA4B,qBAAqB;AAC1D,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,iBAAiB;AAC1B;AAAA,EACC,oCAAoC;AAAA,EACpC,0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AAA,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
|
}
|
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import { __, _x, sprintf } from "@wordpress/i18n";
|
|
4
4
|
import { getBlockSupport, hasBlockSupport } from "@wordpress/blocks";
|
|
5
|
-
import { BaseControl, CustomSelectControl } from "@wordpress/components";
|
|
6
5
|
import { useInstanceId } from "@wordpress/compose";
|
|
7
6
|
import { useSelect } from "@wordpress/data";
|
|
8
|
-
import { useMemo } from "@wordpress/element";
|
|
7
|
+
import { useId, useMemo } from "@wordpress/element";
|
|
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 } from "react/jsx-runtime";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
15
|
var POSITION_SUPPORT_KEY = "position";
|
|
16
16
|
var DEFAULT_OPTION = {
|
|
17
17
|
key: "default",
|
|
18
18
|
value: "",
|
|
19
|
-
|
|
19
|
+
label: __("Default")
|
|
20
20
|
};
|
|
21
21
|
var STICKY_OPTION = {
|
|
22
22
|
key: "sticky",
|
|
23
23
|
value: "sticky",
|
|
24
|
-
|
|
24
|
+
label: _x("Sticky", "Name for the value of the CSS position property"),
|
|
25
25
|
hint: __(
|
|
26
26
|
"The block will stick to the top of the window instead of scrolling."
|
|
27
27
|
)
|
|
@@ -29,7 +29,7 @@ var STICKY_OPTION = {
|
|
|
29
29
|
var FIXED_OPTION = {
|
|
30
30
|
key: "fixed",
|
|
31
31
|
value: "fixed",
|
|
32
|
-
|
|
32
|
+
label: _x("Fixed", "Name for the value of the CSS position property"),
|
|
33
33
|
hint: __("The block will not move when the page is scrolled.")
|
|
34
34
|
};
|
|
35
35
|
var POSITION_SIDES = ["top", "right", "bottom", "left"];
|
|
@@ -146,25 +146,45 @@ function PositionPanelPure({
|
|
|
146
146
|
});
|
|
147
147
|
};
|
|
148
148
|
const selectedOption = value ? options.find((option) => option.value === value) || DEFAULT_OPTION : DEFAULT_OPTION;
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
const hintIdPrefix = useId();
|
|
150
|
+
return options.length > 1 ? /* @__PURE__ */ jsx(InspectorControls, { group: "position", children: /* @__PURE__ */ jsx(
|
|
151
|
+
SelectControl,
|
|
151
152
|
{
|
|
152
|
-
__next40pxDefaultSize: true,
|
|
153
153
|
label: __("Position"),
|
|
154
154
|
hideLabelFromVision: true,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
__("Currently selected position: %s"),
|
|
158
|
-
selectedOption.name
|
|
159
|
-
),
|
|
160
|
-
options,
|
|
155
|
+
description: stickyHelpText,
|
|
156
|
+
items: options,
|
|
161
157
|
value: selectedOption,
|
|
162
|
-
|
|
158
|
+
onValueChange: (selectedItem) => {
|
|
163
159
|
onChangeType(selectedItem.value);
|
|
164
160
|
},
|
|
165
|
-
|
|
161
|
+
children: options.map((option) => {
|
|
162
|
+
const hintId = option.hint ? `${hintIdPrefix}-${option.key}` : void 0;
|
|
163
|
+
return /* @__PURE__ */ jsxs(
|
|
164
|
+
SelectControl.Item,
|
|
165
|
+
{
|
|
166
|
+
value: option,
|
|
167
|
+
label: option.label,
|
|
168
|
+
className: "block-editor-hooks__position-control-item",
|
|
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
|
+
})
|
|
166
186
|
}
|
|
167
|
-
) })
|
|
187
|
+
) }) : null;
|
|
168
188
|
}
|
|
169
189
|
var position_default = {
|
|
170
190
|
edit: function Edit(props) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/position.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { BaseControl, CustomSelectControl } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\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\tname: __( 'Default' ),\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tname: _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\tname: _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\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<BaseControl help={ stickyHelpText }>\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tdescribedBy={ sprintf(\n\t\t\t\t\t\t// translators: %s: Currently selected position.\n\t\t\t\t\t\t__( 'Currently selected position: %s' ),\n\t\t\t\t\t\tselectedOption.name\n\t\t\t\t\t) }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tvalue={ selectedOption }\n\t\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t\t} }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t/>\n\t\t\t</BaseControl>\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": ";AAGA,OAAO,UAAU;AAKjB,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\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';\n\n/**\n * Internal dependencies\n */\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\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\tclassName=\"block-editor-hooks__position-control-item\"\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": ";AAGA,OAAO,UAAU;AAKjB,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,OAAO,eAAe;AAE/B,SAAS,qBAAqB;AAK9B,SAAS,mBAAmB;AAC5B,OAAO,uBAAuB;AAC9B,OAAO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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
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// packages/block-editor/src/hooks/states.js
|
|
2
|
-
import { getBlockType } from "@wordpress/blocks";
|
|
3
2
|
import { __ } from "@wordpress/i18n";
|
|
4
3
|
import StateControl from "../components/global-styles/state-control.mjs";
|
|
5
4
|
import StateControlBadges from "../components/global-styles/state-control-badges.mjs";
|
|
@@ -15,6 +14,12 @@ var RESPONSIVE_STATE_LABELS = {
|
|
|
15
14
|
"@tablet": __("Tablet"),
|
|
16
15
|
"@mobile": __("Mobile")
|
|
17
16
|
};
|
|
17
|
+
var DEVICE_STATE_OPTIONS = Object.entries(RESPONSIVE_STATE_LABELS).map(
|
|
18
|
+
([value, label]) => ({
|
|
19
|
+
value,
|
|
20
|
+
label
|
|
21
|
+
})
|
|
22
|
+
);
|
|
18
23
|
var VALID_BLOCK_PSEUDO_STATES = {
|
|
19
24
|
"core/button": [":hover", ":focus", ":focus-visible", ":active"],
|
|
20
25
|
"core/navigation-link": [":hover", ":focus", ":focus-visible", ":active"]
|
|
@@ -27,48 +32,32 @@ function getPseudoStateOptions(name) {
|
|
|
27
32
|
}));
|
|
28
33
|
}
|
|
29
34
|
var DEFAULT_STATE_VALUE = "default";
|
|
30
|
-
function getViewportStateOptions(name) {
|
|
31
|
-
if (!getBlockType(name)?.attributes?.style) {
|
|
32
|
-
return [];
|
|
33
|
-
}
|
|
34
|
-
return Object.entries(RESPONSIVE_STATE_LABELS).map(
|
|
35
|
-
([value, label]) => ({
|
|
36
|
-
value,
|
|
37
|
-
label
|
|
38
|
-
})
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
35
|
function BlockStatesControl({ name, value, onChange }) {
|
|
42
|
-
const viewportStateOptions = getViewportStateOptions(name);
|
|
43
36
|
const pseudoStateOptions = getPseudoStateOptions(name);
|
|
44
37
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
45
|
-
if (!
|
|
38
|
+
if (!pseudoStateOptions.length) {
|
|
46
39
|
return null;
|
|
47
40
|
}
|
|
48
41
|
return /* @__PURE__ */ jsx(
|
|
49
42
|
StateControl,
|
|
50
43
|
{
|
|
51
|
-
viewportStates: viewportStateOptions,
|
|
52
44
|
pseudoStates: pseudoStateOptions,
|
|
53
|
-
viewportValue: value?.viewport ?? DEFAULT_STATE_VALUE,
|
|
54
45
|
pseudoStateValue: value?.pseudo ?? DEFAULT_STATE_VALUE,
|
|
55
|
-
onChangeViewport: (viewport) => onChange({ viewport }),
|
|
56
46
|
onChangePseudoState: (pseudo) => onChange({ pseudo }),
|
|
57
47
|
popoverProps: dropdownMenuProps.popoverProps,
|
|
58
48
|
showText: false
|
|
59
49
|
}
|
|
60
50
|
);
|
|
61
51
|
}
|
|
62
|
-
function BlockStateBadges({ name, value }) {
|
|
63
|
-
const viewportStateOptions = getViewportStateOptions(name);
|
|
52
|
+
function BlockStateBadges({ name, value, isResponsiveEditing }) {
|
|
64
53
|
const pseudoStateOptions = getPseudoStateOptions(name);
|
|
65
|
-
if (!
|
|
54
|
+
if (!pseudoStateOptions.length && !isResponsiveEditing) {
|
|
66
55
|
return null;
|
|
67
56
|
}
|
|
68
57
|
return /* @__PURE__ */ jsx(
|
|
69
58
|
StateControlBadges,
|
|
70
59
|
{
|
|
71
|
-
viewportStates:
|
|
60
|
+
viewportStates: isResponsiveEditing ? DEVICE_STATE_OPTIONS : [],
|
|
72
61
|
pseudoStates: pseudoStateOptions,
|
|
73
62
|
viewportValue: value?.viewport ?? DEFAULT_STATE_VALUE,
|
|
74
63
|
pseudoStateValue: value?.pseudo ?? DEFAULT_STATE_VALUE
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/states.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";AAGA,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport StateControl from '../components/global-styles/state-control';\nimport StateControlBadges from '../components/global-styles/state-control-badges';\nimport { useToolsPanelDropdownMenuProps } from '../components/global-styles/utils';\n\nexport const PSEUDO_STATE_LABELS = {\n\t':hover': __( 'Hover' ),\n\t':focus': __( 'Focus' ),\n\t':focus-visible': __( 'Focus-visible' ),\n\t':active': __( 'Active' ),\n};\n\nexport const RESPONSIVE_STATE_LABELS = {\n\t'@tablet': __( 'Tablet' ),\n\t'@mobile': __( 'Mobile' ),\n};\n\nconst DEVICE_STATE_OPTIONS = Object.entries( RESPONSIVE_STATE_LABELS ).map(\n\t( [ value, label ] ) => ( {\n\t\tvalue,\n\t\tlabel,\n\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';\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 = getPseudoStateOptions( name );\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);\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 = getPseudoStateOptions( name );\n\n\tif ( ! pseudoStateOptions.length && ! isResponsiveEditing ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StateControlBadges\n\t\t\tviewportStates={ isResponsiveEditing ? DEVICE_STATE_OPTIONS : [] }\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": ";AAGA,SAAS,UAAU;AAKnB,OAAO,kBAAkB;AACzB,OAAO,wBAAwB;AAC/B,SAAS,sCAAsC;AA8D7C;AA5DK,IAAM,sBAAsB;AAAA,EAClC,UAAU,GAAI,OAAQ;AAAA,EACtB,UAAU,GAAI,OAAQ;A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