@wordpress/block-editor 11.4.0 → 11.6.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 +8 -0
- package/build/components/block-inspector/index.js +11 -10
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build/components/block-list/block-invalid-warning.js +63 -80
- package/build/components/block-list/block-invalid-warning.js.map +1 -1
- package/build/components/block-lock/modal.js +1 -0
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/index.js +2 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build/components/child-layout-control/index.js +107 -0
- package/build/components/child-layout-control/index.js.map +1 -0
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/date-format-picker/index.js +3 -3
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +306 -0
- package/build/components/global-styles/border-panel.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +594 -0
- package/build/components/global-styles/dimensions-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +127 -37
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +36 -2
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +87 -27
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +21 -14
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/index.native.js +23 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/index.js +29 -17
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +10 -11
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +5 -108
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +242 -0
- package/build/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build/components/inserter/menu.js +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -2
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +10 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -1
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js +38 -9
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-item.js +5 -2
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +1 -1
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/settings.js +1 -0
- package/build/components/link-control/settings.js.map +1 -1
- package/build/components/list-view/block.js +17 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +2 -2
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/expander.js +2 -1
- package/build/components/list-view/expander.js.map +1 -1
- package/build/components/list-view/leaf.js +10 -6
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -2
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
- package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build/components/off-canvas-editor/appender.js +33 -13
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +6 -3
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +8 -2
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build/components/provider/use-block-sync.js +17 -3
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/responsive-block-control/index.js +1 -0
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +0 -3
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +9 -43
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-delete.js +73 -0
- package/build/components/rich-text/use-delete.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +14 -6
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +4 -1
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/align.js +3 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/border.js +91 -240
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/custom-class-name.js +4 -4
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-class-name.native.js +3 -4
- package/build/hooks/custom-class-name.native.js.map +1 -1
- package/build/hooks/dimensions.js +72 -190
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +94 -25
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/gap.js +0 -202
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/layout.js +33 -27
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +7 -163
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +7 -163
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/supports.js +7 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +52 -66
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +101 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +6 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +1 -0
- package/build/layouts/flex.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +28 -14
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +28 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +53 -47
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +24 -4
- package/build/store/selectors.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +49 -10
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-inspector/index.js +9 -9
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build-module/components/block-list/block-invalid-warning.js +66 -78
- package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
- package/build-module/components/block-lock/modal.js +1 -0
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +98 -0
- package/build-module/components/child-layout-control/index.js.map +1 -0
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +4 -4
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +291 -0
- package/build-module/components/global-styles/border-panel.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +574 -0
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +123 -34
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +88 -27
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +21 -14
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/index.js +28 -16
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +10 -11
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +6 -105
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +222 -0
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build-module/components/inserter/menu.js +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +4 -2
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +10 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -1
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +39 -9
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-item.js +4 -2
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +1 -1
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/settings.js +1 -0
- package/build-module/components/link-control/settings.js.map +1 -1
- package/build-module/components/list-view/block.js +16 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +2 -2
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/expander.js +2 -1
- package/build-module/components/list-view/expander.js.map +1 -1
- package/build-module/components/list-view/leaf.js +8 -4
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -2
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
- package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build-module/components/off-canvas-editor/appender.js +33 -14
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +6 -3
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +8 -2
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +17 -3
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +1 -0
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +0 -3
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +9 -43
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-delete.js +62 -0
- package/build-module/components/rich-text/use-delete.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +14 -6
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +4 -1
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/align.js +3 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/border.js +93 -240
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +4 -4
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-class-name.native.js +3 -4
- package/build-module/hooks/custom-class-name.native.js.map +1 -1
- package/build-module/hooks/dimensions.js +75 -187
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +86 -24
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/gap.js +0 -183
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/layout.js +33 -27
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -143
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +4 -143
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/supports.js +7 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +54 -66
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +96 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +6 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +1 -0
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +28 -14
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +28 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +53 -45
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +22 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +49 -10
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +39 -27
- package/build-style/style.css +39 -27
- package/package.json +31 -31
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
- package/src/components/block-inspector/index.js +11 -14
- package/src/components/block-inspector/style.scss +3 -0
- package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
- package/src/components/block-list/block-invalid-warning.js +72 -64
- package/src/components/block-lock/modal.js +1 -0
- package/src/components/block-lock/style.scss +0 -9
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +35 -17
- package/src/components/block-preview/test/index.js +0 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/block-settings-menu-controls/index.js +2 -1
- package/src/components/block-styles/index.js +5 -1
- package/src/components/block-styles/style.scss +2 -2
- package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/src/components/child-layout-control/index.js +106 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +17 -15
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
- package/src/components/date-format-picker/index.js +6 -8
- package/src/components/date-format-picker/style.scss +0 -5
- package/src/components/global-styles/border-panel.js +285 -0
- package/src/components/global-styles/dimensions-panel.js +627 -0
- package/src/components/global-styles/hooks.js +160 -44
- package/src/components/global-styles/index.js +7 -1
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/typography-panel.js +81 -9
- package/src/components/global-styles/use-global-styles-output.js +17 -16
- package/src/components/global-styles/utils.js +2 -0
- package/src/components/index.native.js +5 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inserter/index.js +30 -11
- package/src/components/inserter/media-tab/hooks.js +9 -8
- package/src/components/inserter/media-tab/media-list.js +3 -122
- package/src/components/inserter/media-tab/media-preview.js +268 -0
- package/src/components/inserter/menu.js +0 -1
- package/src/components/inserter/quick-inserter.js +2 -0
- package/src/components/inserter/search-results.js +7 -1
- package/src/components/inserter/style.scss +25 -0
- package/src/components/inserter/tabs.js +1 -9
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
- package/src/components/inspector-controls/fill.js +32 -8
- package/src/components/link-control/index.js +1 -1
- package/src/components/link-control/search-item.js +3 -1
- package/src/components/link-control/settings-drawer.js +2 -1
- package/src/components/link-control/settings.js +1 -0
- package/src/components/link-control/style.scss +18 -12
- package/src/components/link-control/test/index.js +3 -5
- package/src/components/list-view/block.js +19 -1
- package/src/components/list-view/branch.js +1 -2
- package/src/components/list-view/expander.js +1 -0
- package/src/components/list-view/leaf.js +43 -29
- package/src/components/list-view/use-block-selection.js +0 -2
- package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
- package/src/components/media-replace-flow/style.scss +7 -9
- package/src/components/off-canvas-editor/appender.js +44 -21
- package/src/components/off-canvas-editor/branch.js +4 -1
- package/src/components/off-canvas-editor/index.js +7 -1
- package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
- package/src/components/provider/use-block-sync.js +21 -4
- package/src/components/responsive-block-control/index.js +1 -0
- package/src/components/rich-text/format-toolbar-container.js +1 -7
- package/src/components/rich-text/index.js +8 -44
- package/src/components/rich-text/use-delete.js +59 -0
- package/src/components/rich-text/use-input-rules.js +13 -5
- package/src/components/spacing-sizes-control/style.scss +1 -1
- package/src/components/url-popover/stories/index.js +1 -0
- package/src/components/url-popover/test/index.js +0 -2
- package/src/components/writing-flow/use-selection-observer.js +5 -1
- package/src/hooks/align.js +1 -1
- package/src/hooks/border.js +94 -225
- package/src/hooks/custom-class-name.js +4 -4
- package/src/hooks/custom-class-name.native.js +3 -4
- package/src/hooks/dimensions.js +85 -269
- package/src/hooks/duotone.js +100 -30
- package/src/hooks/gap.js +0 -208
- package/src/hooks/layout.js +38 -22
- package/src/hooks/margin.js +1 -164
- package/src/hooks/padding.js +1 -163
- package/src/hooks/supports.js +6 -0
- package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
- package/src/hooks/test/duotone.js +102 -0
- package/src/hooks/test/style.js +2 -1
- package/src/hooks/test/use-typography-props.js +2 -0
- package/src/hooks/typography.js +68 -88
- package/src/hooks/utils.js +126 -0
- package/src/layouts/constrained.js +23 -17
- package/src/layouts/flex.js +1 -0
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +16 -6
- package/src/store/defaults.js +14 -1
- package/src/store/reducer.js +68 -43
- package/src/store/selectors.js +28 -4
- package/src/store/test/actions.js +4 -2
- package/src/utils/parse-css-unit-to-px.js +48 -13
- package/src/utils/test/parse-css-unit-to-px.js +13 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/border-radius.js +0 -100
- package/build/hooks/border-radius.js.map +0 -1
- package/build/hooks/child-layout.js +0 -213
- package/build/hooks/child-layout.js.map +0 -1
- package/build/hooks/min-height.js +0 -139
- package/build/hooks/min-height.js.map +0 -1
- package/build-module/hooks/border-radius.js +0 -84
- package/build-module/hooks/border-radius.js.map +0 -1
- package/build-module/hooks/child-layout.js +0 -193
- package/build-module/hooks/child-layout.js.map +0 -1
- package/build-module/hooks/min-height.js +0 -116
- package/build-module/hooks/min-height.js.map +0 -1
- package/src/hooks/border-radius.js +0 -70
- package/src/hooks/child-layout.js +0 -195
- package/src/hooks/min-height.js +0 -104
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.ChildLayoutEdit = ChildLayoutEdit;
|
|
9
|
-
exports.childLayoutOrientation = childLayoutOrientation;
|
|
10
|
-
exports.hasChildLayoutSupport = hasChildLayoutSupport;
|
|
11
|
-
exports.hasChildLayoutValue = hasChildLayoutValue;
|
|
12
|
-
exports.resetChildLayout = resetChildLayout;
|
|
13
|
-
exports.useIsChildLayoutDisabled = useIsChildLayoutDisabled;
|
|
14
|
-
|
|
15
|
-
var _element = require("@wordpress/element");
|
|
16
|
-
|
|
17
|
-
var _components = require("@wordpress/components");
|
|
18
|
-
|
|
19
|
-
var _i18n = require("@wordpress/i18n");
|
|
20
|
-
|
|
21
|
-
var _useSetting = _interopRequireDefault(require("../components/use-setting"));
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* WordPress dependencies
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Internal dependencies
|
|
29
|
-
*/
|
|
30
|
-
function helpText(selfStretch, parentLayout) {
|
|
31
|
-
const {
|
|
32
|
-
orientation = 'horizontal'
|
|
33
|
-
} = parentLayout;
|
|
34
|
-
|
|
35
|
-
if (selfStretch === 'fill') {
|
|
36
|
-
return (0, _i18n.__)('Stretch to fill available space.');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (selfStretch === 'fixed') {
|
|
40
|
-
if (orientation === 'horizontal') {
|
|
41
|
-
return (0, _i18n.__)('Specify a fixed width.');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return (0, _i18n.__)('Specify a fixed height.');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (0, _i18n.__)('Fit contents.');
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Inspector controls containing the child layout related configuration.
|
|
51
|
-
*
|
|
52
|
-
* @param {Object} props Block props.
|
|
53
|
-
* @param {Object} props.attributes Block attributes.
|
|
54
|
-
* @param {Object} props.setAttributes Function to set block attributes.
|
|
55
|
-
* @param {Object} props.__unstableParentLayout
|
|
56
|
-
*
|
|
57
|
-
* @return {WPElement} child layout edit element.
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
function ChildLayoutEdit(_ref) {
|
|
62
|
-
let {
|
|
63
|
-
attributes,
|
|
64
|
-
setAttributes,
|
|
65
|
-
__unstableParentLayout: parentLayout
|
|
66
|
-
} = _ref;
|
|
67
|
-
const {
|
|
68
|
-
style = {}
|
|
69
|
-
} = attributes;
|
|
70
|
-
const {
|
|
71
|
-
layout: childLayout = {}
|
|
72
|
-
} = style;
|
|
73
|
-
const {
|
|
74
|
-
selfStretch,
|
|
75
|
-
flexSize
|
|
76
|
-
} = childLayout;
|
|
77
|
-
(0, _element.useEffect)(() => {
|
|
78
|
-
if (selfStretch === 'fixed' && !flexSize) {
|
|
79
|
-
setAttributes({
|
|
80
|
-
style: { ...style,
|
|
81
|
-
layout: { ...childLayout,
|
|
82
|
-
selfStretch: 'fit'
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}, []);
|
|
88
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.__experimentalToggleGroupControl, {
|
|
89
|
-
__nextHasNoMarginBottom: true,
|
|
90
|
-
size: '__unstable-large',
|
|
91
|
-
label: childLayoutOrientation(parentLayout),
|
|
92
|
-
value: selfStretch || 'fit',
|
|
93
|
-
help: helpText(selfStretch, parentLayout),
|
|
94
|
-
onChange: value => {
|
|
95
|
-
const newFlexSize = value !== 'fixed' ? null : flexSize;
|
|
96
|
-
setAttributes({
|
|
97
|
-
style: { ...style,
|
|
98
|
-
layout: { ...childLayout,
|
|
99
|
-
selfStretch: value,
|
|
100
|
-
flexSize: newFlexSize
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
isBlock: true
|
|
106
|
-
}, (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
107
|
-
key: 'fit',
|
|
108
|
-
value: 'fit',
|
|
109
|
-
label: (0, _i18n.__)('Fit')
|
|
110
|
-
}), (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
111
|
-
key: 'fill',
|
|
112
|
-
value: 'fill',
|
|
113
|
-
label: (0, _i18n.__)('Fill')
|
|
114
|
-
}), (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
115
|
-
key: 'fixed',
|
|
116
|
-
value: 'fixed',
|
|
117
|
-
label: (0, _i18n.__)('Fixed')
|
|
118
|
-
})), selfStretch === 'fixed' && (0, _element.createElement)(_components.__experimentalUnitControl, {
|
|
119
|
-
size: '__unstable-large',
|
|
120
|
-
onChange: value => {
|
|
121
|
-
setAttributes({
|
|
122
|
-
style: { ...style,
|
|
123
|
-
layout: { ...childLayout,
|
|
124
|
-
flexSize: value
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
},
|
|
129
|
-
value: flexSize
|
|
130
|
-
}));
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Determines if there is child layout support.
|
|
134
|
-
*
|
|
135
|
-
* @param {Object} props Block Props object.
|
|
136
|
-
* @param {Object} props.__unstableParentLayout Parent layout.
|
|
137
|
-
*
|
|
138
|
-
* @return {boolean} Whether there is support.
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
function hasChildLayoutSupport(_ref2) {
|
|
143
|
-
let {
|
|
144
|
-
__unstableParentLayout: parentLayout = {}
|
|
145
|
-
} = _ref2;
|
|
146
|
-
const {
|
|
147
|
-
type: parentLayoutType = 'default',
|
|
148
|
-
default: {
|
|
149
|
-
type: defaultParentLayoutType = 'default'
|
|
150
|
-
} = {},
|
|
151
|
-
allowSizingOnChildren = false
|
|
152
|
-
} = parentLayout;
|
|
153
|
-
const support = (defaultParentLayoutType === 'flex' || parentLayoutType === 'flex') && allowSizingOnChildren;
|
|
154
|
-
return support;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Checks if there is a current value in the child layout attributes.
|
|
158
|
-
*
|
|
159
|
-
* @param {Object} props Block props.
|
|
160
|
-
* @return {boolean} Whether or not the block has a child layout value set.
|
|
161
|
-
*/
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
function hasChildLayoutValue(props) {
|
|
165
|
-
var _props$attributes$sty;
|
|
166
|
-
|
|
167
|
-
return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.layout) !== undefined;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Resets the child layout attribute. This can be used when disabling
|
|
171
|
-
* child layout controls for a block via a progressive discovery panel.
|
|
172
|
-
*
|
|
173
|
-
* @param {Object} props Block props.
|
|
174
|
-
* @param {Object} props.attributes Block attributes.
|
|
175
|
-
* @param {Object} props.setAttributes Function to set block attributes.
|
|
176
|
-
*/
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
function resetChildLayout(_ref3) {
|
|
180
|
-
let {
|
|
181
|
-
attributes = {},
|
|
182
|
-
setAttributes
|
|
183
|
-
} = _ref3;
|
|
184
|
-
const {
|
|
185
|
-
style
|
|
186
|
-
} = attributes;
|
|
187
|
-
setAttributes({
|
|
188
|
-
style: { ...style,
|
|
189
|
-
layout: undefined
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Custom hook that checks if child layout settings have been disabled.
|
|
195
|
-
*
|
|
196
|
-
* @param {Object} props Block props.
|
|
197
|
-
*
|
|
198
|
-
* @return {boolean} Whether the child layout setting is disabled.
|
|
199
|
-
*/
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
function useIsChildLayoutDisabled(props) {
|
|
203
|
-
const isDisabled = !(0, _useSetting.default)('layout');
|
|
204
|
-
return !hasChildLayoutSupport(props) || isDisabled;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function childLayoutOrientation(parentLayout) {
|
|
208
|
-
const {
|
|
209
|
-
orientation = 'horizontal'
|
|
210
|
-
} = parentLayout;
|
|
211
|
-
return orientation === 'horizontal' ? (0, _i18n.__)('Width') : (0, _i18n.__)('Height');
|
|
212
|
-
}
|
|
213
|
-
//# sourceMappingURL=child-layout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/child-layout.js"],"names":["helpText","selfStretch","parentLayout","orientation","ChildLayoutEdit","attributes","setAttributes","__unstableParentLayout","style","layout","childLayout","flexSize","childLayoutOrientation","value","newFlexSize","hasChildLayoutSupport","type","parentLayoutType","default","defaultParentLayoutType","allowSizingOnChildren","support","hasChildLayoutValue","props","undefined","resetChildLayout","useIsChildLayoutDisabled","isDisabled"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\n\nfunction helpText( selfStretch, parentLayout ) {\n\tconst { orientation = 'horizontal' } = parentLayout;\n\n\tif ( selfStretch === 'fill' ) {\n\t\treturn __( 'Stretch to fill available space.' );\n\t}\n\tif ( selfStretch === 'fixed' ) {\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\treturn __( 'Specify a fixed width.' );\n\t\t}\n\t\treturn __( 'Specify a fixed height.' );\n\t}\n\treturn __( 'Fit contents.' );\n}\n\n/**\n * Inspector controls containing the child layout related configuration.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block attributes.\n * @param {Object} props.setAttributes Function to set block attributes.\n * @param {Object} props.__unstableParentLayout\n *\n * @return {WPElement} child layout edit element.\n */\nexport function ChildLayoutEdit( {\n\tattributes,\n\tsetAttributes,\n\t__unstableParentLayout: parentLayout,\n} ) {\n\tconst { style = {} } = attributes;\n\tconst { layout: childLayout = {} } = style;\n\tconst { selfStretch, flexSize } = childLayout;\n\n\tuseEffect( () => {\n\t\tif ( selfStretch === 'fixed' && ! flexSize ) {\n\t\t\tsetAttributes( {\n\t\t\t\tstyle: {\n\t\t\t\t\t...style,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\t...childLayout,\n\t\t\t\t\t\tselfStretch: 'fit',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<ToggleGroupControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\tlabel={ childLayoutOrientation( parentLayout ) }\n\t\t\t\tvalue={ selfStretch || 'fit' }\n\t\t\t\thelp={ helpText( selfStretch, parentLayout ) }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tconst newFlexSize = value !== 'fixed' ? null : flexSize;\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t...childLayout,\n\t\t\t\t\t\t\t\tselfStretch: value,\n\t\t\t\t\t\t\t\tflexSize: newFlexSize,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tisBlock={ true }\n\t\t\t>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'fit' }\n\t\t\t\t\tvalue={ 'fit' }\n\t\t\t\t\tlabel={ __( 'Fit' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'fill' }\n\t\t\t\t\tvalue={ 'fill' }\n\t\t\t\t\tlabel={ __( 'Fill' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'fixed' }\n\t\t\t\t\tvalue={ 'fixed' }\n\t\t\t\t\tlabel={ __( 'Fixed' ) }\n\t\t\t\t/>\n\t\t\t</ToggleGroupControl>\n\t\t\t{ selfStretch === 'fixed' && (\n\t\t\t\t<UnitControl\n\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t...childLayout,\n\t\t\t\t\t\t\t\t\tflexSize: value,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ flexSize }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * Determines if there is child layout support.\n *\n * @param {Object} props Block Props object.\n * @param {Object} props.__unstableParentLayout Parent layout.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasChildLayoutSupport( {\n\t__unstableParentLayout: parentLayout = {},\n} ) {\n\tconst {\n\t\ttype: parentLayoutType = 'default',\n\t\tdefault: { type: defaultParentLayoutType = 'default' } = {},\n\t\tallowSizingOnChildren = false,\n\t} = parentLayout;\n\n\tconst support =\n\t\t( defaultParentLayoutType === 'flex' || parentLayoutType === 'flex' ) &&\n\t\tallowSizingOnChildren;\n\n\treturn support;\n}\n\n/**\n * Checks if there is a current value in the child layout attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a child layout value set.\n */\nexport function hasChildLayoutValue( props ) {\n\treturn props.attributes.style?.layout !== undefined;\n}\n\n/**\n * Resets the child layout attribute. This can be used when disabling\n * child layout controls for a block via a progressive discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block attributes.\n * @param {Object} props.setAttributes Function to set block attributes.\n */\nexport function resetChildLayout( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: {\n\t\t\t...style,\n\t\t\tlayout: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Custom hook that checks if child layout settings have been disabled.\n *\n * @param {Object} props Block props.\n *\n * @return {boolean} Whether the child layout setting is disabled.\n */\nexport function useIsChildLayoutDisabled( props ) {\n\tconst isDisabled = ! useSetting( 'layout' );\n\n\treturn ! hasChildLayoutSupport( props ) || isDisabled;\n}\n\nexport function childLayoutOrientation( parentLayout ) {\n\tconst { orientation = 'horizontal' } = parentLayout;\n\n\treturn orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );\n}\n"]}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.MinHeightEdit = MinHeightEdit;
|
|
9
|
-
exports.hasMinHeightSupport = hasMinHeightSupport;
|
|
10
|
-
exports.hasMinHeightValue = hasMinHeightValue;
|
|
11
|
-
exports.resetMinHeight = resetMinHeight;
|
|
12
|
-
exports.useIsMinHeightDisabled = useIsMinHeightDisabled;
|
|
13
|
-
|
|
14
|
-
var _element = require("@wordpress/element");
|
|
15
|
-
|
|
16
|
-
var _blocks = require("@wordpress/blocks");
|
|
17
|
-
|
|
18
|
-
var _i18n = require("@wordpress/i18n");
|
|
19
|
-
|
|
20
|
-
var _useSetting = _interopRequireDefault(require("../components/use-setting"));
|
|
21
|
-
|
|
22
|
-
var _heightControl = _interopRequireDefault(require("../components/height-control"));
|
|
23
|
-
|
|
24
|
-
var _dimensions = require("./dimensions");
|
|
25
|
-
|
|
26
|
-
var _utils = require("./utils");
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* WordPress dependencies
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Internal dependencies
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Determines if there is minHeight support.
|
|
38
|
-
*
|
|
39
|
-
* @param {string|Object} blockType Block name or Block Type object.
|
|
40
|
-
* @return {boolean} Whether there is support.
|
|
41
|
-
*/
|
|
42
|
-
function hasMinHeightSupport(blockType) {
|
|
43
|
-
const support = (0, _blocks.getBlockSupport)(blockType, _dimensions.DIMENSIONS_SUPPORT_KEY);
|
|
44
|
-
return !!(true === support || support !== null && support !== void 0 && support.minHeight);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Checks if there is a current value in the minHeight block support attributes.
|
|
48
|
-
*
|
|
49
|
-
* @param {Object} props Block props.
|
|
50
|
-
* @return {boolean} Whether or not the block has a minHeight value set.
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
function hasMinHeightValue(props) {
|
|
55
|
-
var _props$attributes$sty, _props$attributes$sty2;
|
|
56
|
-
|
|
57
|
-
return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.dimensions) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.minHeight) !== undefined;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Resets the minHeight block support attributes. This can be used when disabling
|
|
61
|
-
* the padding support controls for a block via a `ToolsPanel`.
|
|
62
|
-
*
|
|
63
|
-
* @param {Object} props Block props.
|
|
64
|
-
* @param {Object} props.attributes Block's attributes.
|
|
65
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
function resetMinHeight(_ref) {
|
|
70
|
-
let {
|
|
71
|
-
attributes = {},
|
|
72
|
-
setAttributes
|
|
73
|
-
} = _ref;
|
|
74
|
-
const {
|
|
75
|
-
style
|
|
76
|
-
} = attributes;
|
|
77
|
-
setAttributes({
|
|
78
|
-
style: (0, _utils.cleanEmptyObject)({ ...style,
|
|
79
|
-
dimensions: { ...(style === null || style === void 0 ? void 0 : style.dimensions),
|
|
80
|
-
minHeight: undefined
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Custom hook that checks if minHeight controls have been disabled.
|
|
87
|
-
*
|
|
88
|
-
* @param {string} name The name of the block.
|
|
89
|
-
* @return {boolean} Whether minHeight control is disabled.
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
function useIsMinHeightDisabled() {
|
|
94
|
-
let {
|
|
95
|
-
name: blockName
|
|
96
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
97
|
-
const isDisabled = !(0, _useSetting.default)('dimensions.minHeight');
|
|
98
|
-
return !hasMinHeightSupport(blockName) || isDisabled;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Inspector control panel containing the minHeight related configuration.
|
|
102
|
-
*
|
|
103
|
-
* @param {Object} props Block props.
|
|
104
|
-
* @return {WPElement} Edit component for height.
|
|
105
|
-
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
function MinHeightEdit(props) {
|
|
109
|
-
var _style$dimensions;
|
|
110
|
-
|
|
111
|
-
const {
|
|
112
|
-
attributes: {
|
|
113
|
-
style
|
|
114
|
-
},
|
|
115
|
-
setAttributes
|
|
116
|
-
} = props;
|
|
117
|
-
|
|
118
|
-
if (useIsMinHeightDisabled(props)) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const onChange = next => {
|
|
123
|
-
const newStyle = { ...style,
|
|
124
|
-
dimensions: { ...(style === null || style === void 0 ? void 0 : style.dimensions),
|
|
125
|
-
minHeight: next
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
setAttributes({
|
|
129
|
-
style: (0, _utils.cleanEmptyObject)(newStyle)
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
return (0, _element.createElement)(_heightControl.default, {
|
|
134
|
-
label: (0, _i18n.__)('Min. height'),
|
|
135
|
-
value: style === null || style === void 0 ? void 0 : (_style$dimensions = style.dimensions) === null || _style$dimensions === void 0 ? void 0 : _style$dimensions.minHeight,
|
|
136
|
-
onChange: onChange
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=min-height.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/min-height.js"],"names":["hasMinHeightSupport","blockType","support","DIMENSIONS_SUPPORT_KEY","minHeight","hasMinHeightValue","props","attributes","style","dimensions","undefined","resetMinHeight","setAttributes","useIsMinHeightDisabled","name","blockName","isDisabled","MinHeightEdit","onChange","next","newStyle"],"mappings":";;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAZA;AACA;AACA;;AAIA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAT,CAA8BC,SAA9B,EAA0C;AAChD,QAAMC,OAAO,GAAG,6BAAiBD,SAAjB,EAA4BE,kCAA5B,CAAhB;AACA,SAAO,CAAC,EAAI,SAASD,OAAT,IAAoBA,OAApB,aAAoBA,OAApB,eAAoBA,OAAO,CAAEE,SAAjC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,iBAAT,CAA4BC,KAA5B,EAAoC;AAAA;;AAC1C,SAAO,0BAAAA,KAAK,CAACC,UAAN,CAAiBC,KAAjB,0GAAwBC,UAAxB,kFAAoCL,SAApC,MAAkDM,SAAzD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,cAAT,OAA8D;AAAA,MAArC;AAAEJ,IAAAA,UAAU,GAAG,EAAf;AAAmBK,IAAAA;AAAnB,GAAqC;AACpE,QAAM;AAAEJ,IAAAA;AAAF,MAAYD,UAAlB;AAEAK,EAAAA,aAAa,CAAE;AACdJ,IAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBC,MAAAA,UAAU,EAAE,EACX,IAAGD,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEC,UAAV,CADW;AAEXL,QAAAA,SAAS,EAAEM;AAFA;AAFY,KAAlB;AADO,GAAF,CAAb;AASA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,sBAAT,GAA4D;AAAA,MAA3B;AAAEC,IAAAA,IAAI,EAAEC;AAAR,GAA2B,uEAAL,EAAK;AAClE,QAAMC,UAAU,GAAG,CAAE,yBAAY,sBAAZ,CAArB;AACA,SAAO,CAAEhB,mBAAmB,CAAEe,SAAF,CAArB,IAAsCC,UAA7C;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,aAAT,CAAwBX,KAAxB,EAAgC;AAAA;;AACtC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELI,IAAAA;AAFK,MAGFN,KAHJ;;AAKA,MAAKO,sBAAsB,CAAEP,KAAF,CAA3B,EAAuC;AACtC,WAAO,IAAP;AACA;;AAED,QAAMY,QAAQ,GAAKC,IAAF,IAAY;AAC5B,UAAMC,QAAQ,GAAG,EAChB,GAAGZ,KADa;AAEhBC,MAAAA,UAAU,EAAE,EACX,IAAGD,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEC,UAAV,CADW;AAEXL,QAAAA,SAAS,EAAEe;AAFA;AAFI,KAAjB;AAQAP,IAAAA,aAAa,CAAE;AAAEJ,MAAAA,KAAK,EAAE,6BAAkBY,QAAlB;AAAT,KAAF,CAAb;AACA,GAVD;;AAYA,SACC,4BAAC,sBAAD;AACC,IAAA,KAAK,EAAG,cAAI,aAAJ,CADT;AAEC,IAAA,KAAK,EAAGZ,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAEC,UAAV,sDAAG,kBAAmBL,SAF5B;AAGC,IAAA,QAAQ,EAAGc;AAHZ,IADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\nimport HeightControl from '../components/height-control';\nimport { DIMENSIONS_SUPPORT_KEY } from './dimensions';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Determines if there is minHeight support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n * @return {boolean} Whether there is support.\n */\nexport function hasMinHeightSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, DIMENSIONS_SUPPORT_KEY );\n\treturn !! ( true === support || support?.minHeight );\n}\n\n/**\n * Checks if there is a current value in the minHeight block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a minHeight value set.\n */\nexport function hasMinHeightValue( props ) {\n\treturn props.attributes.style?.dimensions?.minHeight !== undefined;\n}\n\n/**\n * Resets the minHeight block support attributes. This can be used when disabling\n * the padding 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 resetMinHeight( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tdimensions: {\n\t\t\t\t...style?.dimensions,\n\t\t\t\tminHeight: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if minHeight controls have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether minHeight control is disabled.\n */\nexport function useIsMinHeightDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'dimensions.minHeight' );\n\treturn ! hasMinHeightSupport( blockName ) || isDisabled;\n}\n\n/**\n * Inspector control panel containing the minHeight related configuration.\n *\n * @param {Object} props Block props.\n * @return {WPElement} Edit component for height.\n */\nexport function MinHeightEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tif ( useIsMinHeightDisabled( props ) ) {\n\t\treturn null;\n\t}\n\n\tconst onChange = ( next ) => {\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tdimensions: {\n\t\t\t\t...style?.dimensions,\n\t\t\t\tminHeight: next,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( { style: cleanEmptyObject( newStyle ) } );\n\t};\n\n\treturn (\n\t\t<HeightControl\n\t\t\tlabel={ __( 'Min. height' ) }\n\t\t\tvalue={ style?.dimensions?.minHeight }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Internal dependencies
|
|
5
|
-
*/
|
|
6
|
-
import BorderRadiusControl from '../components/border-radius-control';
|
|
7
|
-
import { cleanEmptyObject } from './utils';
|
|
8
|
-
import { removeBorderAttribute } from './border';
|
|
9
|
-
/**
|
|
10
|
-
* Inspector control panel containing the border radius related configuration.
|
|
11
|
-
*
|
|
12
|
-
* @param {Object} props Block properties.
|
|
13
|
-
*
|
|
14
|
-
* @return {WPElement} Border radius edit element.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export function BorderRadiusEdit(props) {
|
|
18
|
-
var _style$border;
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
attributes: {
|
|
22
|
-
style
|
|
23
|
-
},
|
|
24
|
-
setAttributes
|
|
25
|
-
} = props;
|
|
26
|
-
|
|
27
|
-
const onChange = newRadius => {
|
|
28
|
-
const newStyle = cleanEmptyObject({ ...style,
|
|
29
|
-
border: { ...(style === null || style === void 0 ? void 0 : style.border),
|
|
30
|
-
radius: newRadius
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
setAttributes({
|
|
34
|
-
style: newStyle
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return createElement(BorderRadiusControl, {
|
|
39
|
-
values: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius,
|
|
40
|
-
onChange: onChange
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Checks if there is a current value in the border radius block support
|
|
45
|
-
* attributes.
|
|
46
|
-
*
|
|
47
|
-
* @param {Object} props Block props.
|
|
48
|
-
* @return {boolean} Whether or not the block has a border radius value set.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
export function hasBorderRadiusValue(props) {
|
|
52
|
-
var _props$attributes$sty, _props$attributes$sty2;
|
|
53
|
-
|
|
54
|
-
const borderRadius = (_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.border) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.radius;
|
|
55
|
-
|
|
56
|
-
if (typeof borderRadius === 'object') {
|
|
57
|
-
return Object.entries(borderRadius).some(Boolean);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return !!borderRadius;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Resets the border radius block support attributes. This can be used when
|
|
64
|
-
* disabling the border radius support controls for a block via a progressive
|
|
65
|
-
* discovery panel.
|
|
66
|
-
*
|
|
67
|
-
* @param {Object} props Block props.
|
|
68
|
-
* @param {Object} props.attributes Block's attributes.
|
|
69
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
export function resetBorderRadius(_ref) {
|
|
73
|
-
let {
|
|
74
|
-
attributes = {},
|
|
75
|
-
setAttributes
|
|
76
|
-
} = _ref;
|
|
77
|
-
const {
|
|
78
|
-
style
|
|
79
|
-
} = attributes;
|
|
80
|
-
setAttributes({
|
|
81
|
-
style: removeBorderAttribute(style, 'radius')
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=border-radius.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/border-radius.js"],"names":["BorderRadiusControl","cleanEmptyObject","removeBorderAttribute","BorderRadiusEdit","props","attributes","style","setAttributes","onChange","newRadius","newStyle","border","radius","hasBorderRadiusValue","borderRadius","Object","entries","some","Boolean","resetBorderRadius"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,mBAAP,MAAgC,qCAAhC;AACA,SAASC,gBAAT,QAAiC,SAAjC;AACA,SAASC,qBAAT,QAAsC,UAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,gBAAT,CAA2BC,KAA3B,EAAmC;AAAA;;AACzC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,QAAMI,QAAQ,GAAKC,SAAF,IAAiB;AACjC,UAAMC,QAAQ,GAAGT,gBAAgB,CAAE,EAClC,GAAGK,KAD+B;AAElCK,MAAAA,MAAM,EAAE,EACP,IAAGL,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEK,MAAV,CADO;AAEPC,QAAAA,MAAM,EAAEH;AAFD;AAF0B,KAAF,CAAjC;AAQAF,IAAAA,aAAa,CAAE;AAAED,MAAAA,KAAK,EAAEI;AAAT,KAAF,CAAb;AACA,GAVD;;AAYA,SACC,cAAC,mBAAD;AACC,IAAA,MAAM,EAAGJ,KAAH,aAAGA,KAAH,wCAAGA,KAAK,CAAEK,MAAV,kDAAG,cAAeC,MADzB;AAEC,IAAA,QAAQ,EAAGJ;AAFZ,IADD;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,oBAAT,CAA+BT,KAA/B,EAAuC;AAAA;;AAC7C,QAAMU,YAAY,4BAAGV,KAAK,CAACC,UAAN,CAAiBC,KAApB,oFAAG,sBAAwBK,MAA3B,2DAAG,uBAAgCC,MAArD;;AAEA,MAAK,OAAOE,YAAP,KAAwB,QAA7B,EAAwC;AACvC,WAAOC,MAAM,CAACC,OAAP,CAAgBF,YAAhB,EAA+BG,IAA/B,CAAqCC,OAArC,CAAP;AACA;;AAED,SAAO,CAAC,CAAEJ,YAAV;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,iBAAT,OAAiE;AAAA,MAArC;AAAEd,IAAAA,UAAU,GAAG,EAAf;AAAmBE,IAAAA;AAAnB,GAAqC;AACvE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AACAE,EAAAA,aAAa,CAAE;AAAED,IAAAA,KAAK,EAAEJ,qBAAqB,CAAEI,KAAF,EAAS,QAAT;AAA9B,GAAF,CAAb;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport BorderRadiusControl from '../components/border-radius-control';\nimport { cleanEmptyObject } from './utils';\nimport { removeBorderAttribute } from './border';\n\n/**\n * Inspector control panel containing the border radius related configuration.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border radius edit element.\n */\nexport function BorderRadiusEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst onChange = ( newRadius ) => {\n\t\tconst newStyle = cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tradius: newRadius,\n\t\t\t},\n\t\t} );\n\n\t\tsetAttributes( { style: newStyle } );\n\t};\n\n\treturn (\n\t\t<BorderRadiusControl\n\t\t\tvalues={ style?.border?.radius }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Checks if there is a current value in the border radius block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a border radius value set.\n */\nexport function hasBorderRadiusValue( props ) {\n\tconst borderRadius = props.attributes.style?.border?.radius;\n\n\tif ( typeof borderRadius === 'object' ) {\n\t\treturn Object.entries( borderRadius ).some( Boolean );\n\t}\n\n\treturn !! borderRadius;\n}\n\n/**\n * Resets the border radius block support attributes. This can be used when\n * disabling the border radius support controls for a block via a progressive\n * discovery panel.\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 resetBorderRadius( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\tsetAttributes( { style: removeBorderAttribute( style, 'radius' ) } );\n}\n"]}
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalUnitControl as UnitControl } from '@wordpress/components';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
-
import { useEffect } from '@wordpress/element';
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import useSetting from '../components/use-setting';
|
|
14
|
-
|
|
15
|
-
function helpText(selfStretch, parentLayout) {
|
|
16
|
-
const {
|
|
17
|
-
orientation = 'horizontal'
|
|
18
|
-
} = parentLayout;
|
|
19
|
-
|
|
20
|
-
if (selfStretch === 'fill') {
|
|
21
|
-
return __('Stretch to fill available space.');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (selfStretch === 'fixed') {
|
|
25
|
-
if (orientation === 'horizontal') {
|
|
26
|
-
return __('Specify a fixed width.');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return __('Specify a fixed height.');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return __('Fit contents.');
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Inspector controls containing the child layout related configuration.
|
|
36
|
-
*
|
|
37
|
-
* @param {Object} props Block props.
|
|
38
|
-
* @param {Object} props.attributes Block attributes.
|
|
39
|
-
* @param {Object} props.setAttributes Function to set block attributes.
|
|
40
|
-
* @param {Object} props.__unstableParentLayout
|
|
41
|
-
*
|
|
42
|
-
* @return {WPElement} child layout edit element.
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export function ChildLayoutEdit(_ref) {
|
|
47
|
-
let {
|
|
48
|
-
attributes,
|
|
49
|
-
setAttributes,
|
|
50
|
-
__unstableParentLayout: parentLayout
|
|
51
|
-
} = _ref;
|
|
52
|
-
const {
|
|
53
|
-
style = {}
|
|
54
|
-
} = attributes;
|
|
55
|
-
const {
|
|
56
|
-
layout: childLayout = {}
|
|
57
|
-
} = style;
|
|
58
|
-
const {
|
|
59
|
-
selfStretch,
|
|
60
|
-
flexSize
|
|
61
|
-
} = childLayout;
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
if (selfStretch === 'fixed' && !flexSize) {
|
|
64
|
-
setAttributes({
|
|
65
|
-
style: { ...style,
|
|
66
|
-
layout: { ...childLayout,
|
|
67
|
-
selfStretch: 'fit'
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}, []);
|
|
73
|
-
return createElement(Fragment, null, createElement(ToggleGroupControl, {
|
|
74
|
-
__nextHasNoMarginBottom: true,
|
|
75
|
-
size: '__unstable-large',
|
|
76
|
-
label: childLayoutOrientation(parentLayout),
|
|
77
|
-
value: selfStretch || 'fit',
|
|
78
|
-
help: helpText(selfStretch, parentLayout),
|
|
79
|
-
onChange: value => {
|
|
80
|
-
const newFlexSize = value !== 'fixed' ? null : flexSize;
|
|
81
|
-
setAttributes({
|
|
82
|
-
style: { ...style,
|
|
83
|
-
layout: { ...childLayout,
|
|
84
|
-
selfStretch: value,
|
|
85
|
-
flexSize: newFlexSize
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
},
|
|
90
|
-
isBlock: true
|
|
91
|
-
}, createElement(ToggleGroupControlOption, {
|
|
92
|
-
key: 'fit',
|
|
93
|
-
value: 'fit',
|
|
94
|
-
label: __('Fit')
|
|
95
|
-
}), createElement(ToggleGroupControlOption, {
|
|
96
|
-
key: 'fill',
|
|
97
|
-
value: 'fill',
|
|
98
|
-
label: __('Fill')
|
|
99
|
-
}), createElement(ToggleGroupControlOption, {
|
|
100
|
-
key: 'fixed',
|
|
101
|
-
value: 'fixed',
|
|
102
|
-
label: __('Fixed')
|
|
103
|
-
})), selfStretch === 'fixed' && createElement(UnitControl, {
|
|
104
|
-
size: '__unstable-large',
|
|
105
|
-
onChange: value => {
|
|
106
|
-
setAttributes({
|
|
107
|
-
style: { ...style,
|
|
108
|
-
layout: { ...childLayout,
|
|
109
|
-
flexSize: value
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
},
|
|
114
|
-
value: flexSize
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Determines if there is child layout support.
|
|
119
|
-
*
|
|
120
|
-
* @param {Object} props Block Props object.
|
|
121
|
-
* @param {Object} props.__unstableParentLayout Parent layout.
|
|
122
|
-
*
|
|
123
|
-
* @return {boolean} Whether there is support.
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
export function hasChildLayoutSupport(_ref2) {
|
|
127
|
-
let {
|
|
128
|
-
__unstableParentLayout: parentLayout = {}
|
|
129
|
-
} = _ref2;
|
|
130
|
-
const {
|
|
131
|
-
type: parentLayoutType = 'default',
|
|
132
|
-
default: {
|
|
133
|
-
type: defaultParentLayoutType = 'default'
|
|
134
|
-
} = {},
|
|
135
|
-
allowSizingOnChildren = false
|
|
136
|
-
} = parentLayout;
|
|
137
|
-
const support = (defaultParentLayoutType === 'flex' || parentLayoutType === 'flex') && allowSizingOnChildren;
|
|
138
|
-
return support;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Checks if there is a current value in the child layout attributes.
|
|
142
|
-
*
|
|
143
|
-
* @param {Object} props Block props.
|
|
144
|
-
* @return {boolean} Whether or not the block has a child layout value set.
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
export function hasChildLayoutValue(props) {
|
|
148
|
-
var _props$attributes$sty;
|
|
149
|
-
|
|
150
|
-
return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.layout) !== undefined;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Resets the child layout attribute. This can be used when disabling
|
|
154
|
-
* child layout controls for a block via a progressive discovery panel.
|
|
155
|
-
*
|
|
156
|
-
* @param {Object} props Block props.
|
|
157
|
-
* @param {Object} props.attributes Block attributes.
|
|
158
|
-
* @param {Object} props.setAttributes Function to set block attributes.
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
export function resetChildLayout(_ref3) {
|
|
162
|
-
let {
|
|
163
|
-
attributes = {},
|
|
164
|
-
setAttributes
|
|
165
|
-
} = _ref3;
|
|
166
|
-
const {
|
|
167
|
-
style
|
|
168
|
-
} = attributes;
|
|
169
|
-
setAttributes({
|
|
170
|
-
style: { ...style,
|
|
171
|
-
layout: undefined
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Custom hook that checks if child layout settings have been disabled.
|
|
177
|
-
*
|
|
178
|
-
* @param {Object} props Block props.
|
|
179
|
-
*
|
|
180
|
-
* @return {boolean} Whether the child layout setting is disabled.
|
|
181
|
-
*/
|
|
182
|
-
|
|
183
|
-
export function useIsChildLayoutDisabled(props) {
|
|
184
|
-
const isDisabled = !useSetting('layout');
|
|
185
|
-
return !hasChildLayoutSupport(props) || isDisabled;
|
|
186
|
-
}
|
|
187
|
-
export function childLayoutOrientation(parentLayout) {
|
|
188
|
-
const {
|
|
189
|
-
orientation = 'horizontal'
|
|
190
|
-
} = parentLayout;
|
|
191
|
-
return orientation === 'horizontal' ? __('Width') : __('Height');
|
|
192
|
-
}
|
|
193
|
-
//# sourceMappingURL=child-layout.js.map
|