@wordpress/block-library 8.7.0 → 8.9.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 +4 -0
- package/build/column/index.js +2 -1
- package/build/column/index.js.map +1 -1
- package/build/columns/edit.js +24 -6
- package/build/columns/edit.js.map +1 -1
- package/build/columns/index.js +2 -1
- package/build/columns/index.js.map +1 -1
- package/build/columns/utils.js +4 -9
- package/build/columns/utils.js.map +1 -1
- package/build/cover/edit/index.js +46 -50
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +32 -6
- package/build/cover/edit/resizable-cover-popover.js.map +1 -0
- package/build/cover/index.js +12 -0
- package/build/cover/index.js.map +1 -1
- package/build/cover/transforms.js +10 -7
- package/build/cover/transforms.js.map +1 -1
- package/build/details/edit.js +67 -0
- package/build/details/edit.js.map +1 -0
- package/build/details/index.js +110 -0
- package/build/details/index.js.map +1 -0
- package/build/details/save.js +33 -0
- package/build/details/save.js.map +1 -0
- package/build/details-content/edit.js +34 -0
- package/build/details-content/edit.js.map +1 -0
- package/build/details-content/index.js +94 -0
- package/build/details-content/index.js.map +1 -0
- package/build/details-content/save.js +20 -0
- package/build/details-content/save.js.map +1 -0
- package/build/details-summary/edit.js +42 -0
- package/build/details-summary/edit.js.map +1 -0
- package/build/details-summary/index.js +97 -0
- package/build/details-summary/index.js.map +1 -0
- package/build/details-summary/save.js +24 -0
- package/build/details-summary/save.js.map +1 -0
- package/build/embed/deprecated.js +4 -1
- package/build/embed/deprecated.js.map +1 -1
- package/build/embed/embed-link-settings.native.js +1 -1
- package/build/embed/embed-link-settings.native.js.map +1 -1
- package/build/embed/embed-placeholder.js +1 -1
- package/build/embed/embed-placeholder.js.map +1 -1
- package/build/embed/index.js +4 -1
- package/build/embed/index.js.map +1 -1
- package/build/embed/transforms.js +4 -1
- package/build/embed/transforms.js.map +1 -1
- package/build/embed/util.js +4 -1
- package/build/embed/util.js.map +1 -1
- package/build/file/edit.native.js +0 -2
- package/build/file/edit.native.js.map +1 -1
- package/build/gallery/use-get-media.native.js +2 -1
- package/build/gallery/use-get-media.native.js.map +1 -1
- package/build/group/edit.js +3 -1
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +3 -0
- package/build/group/index.js.map +1 -1
- package/build/image/edit.js +16 -13
- package/build/image/edit.js.map +1 -1
- package/build/image/index.js +5 -3
- package/build/image/index.js.map +1 -1
- package/build/index.js +24 -6
- package/build/index.js.map +1 -1
- package/build/index.native.js +9 -5
- package/build/index.native.js.map +1 -1
- package/build/media-text/edit.js +4 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/index.js +3 -0
- package/build/media-text/index.js.map +1 -1
- package/build/media-text/media-container.js +2 -6
- package/build/media-text/media-container.js.map +1 -1
- package/build/media-text/media-container.native.js +3 -3
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/navigation/deprecated.js +8 -11
- package/build/navigation/deprecated.js.map +1 -1
- package/build/navigation/edit/index.js +32 -64
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +1 -14
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/post-author/index.js +0 -1
- package/build/post-author/index.js.map +1 -1
- package/build/post-date/edit.js +4 -2
- package/build/post-date/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +2 -2
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +2 -1
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/edit.js +16 -27
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-time-to-read/edit.js +1 -1
- package/build/post-time-to-read/edit.js.map +1 -1
- package/build/post-time-to-read/index.js +7 -0
- package/build/post-time-to-read/index.js.map +1 -1
- package/build/query/deprecated.js +8 -6
- package/build/query/deprecated.js.map +1 -1
- package/build/query/edit/inspector-controls/create-new-post-link.js +41 -0
- package/build/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
- package/build/query/edit/inspector-controls/index.js +14 -6
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/pattern-selection-modal.js +2 -1
- package/build/query/edit/pattern-selection-modal.js.map +1 -1
- package/build/query/index.js +5 -12
- package/build/query/index.js.map +1 -1
- package/build/site-logo/edit.js +114 -16
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +1 -1
- package/build/social-link/icons/chain.js +1 -1
- package/build/social-link/icons/chain.js.map +1 -1
- package/build/social-link/icons/mail.js +1 -1
- package/build/social-link/icons/mail.js.map +1 -1
- package/build/spacer/controls.js +25 -6
- package/build/spacer/controls.js.map +1 -1
- package/build/spacer/edit.js +129 -13
- package/build/spacer/edit.js.map +1 -1
- package/build/spacer/save.js +2 -2
- package/build/spacer/save.js.map +1 -1
- package/build/table/state.js +35 -35
- package/build/table/state.js.map +1 -1
- package/build/template-part/edit/index.js +2 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/utils/hooks.js +2 -2
- package/build/template-part/edit/utils/hooks.js.map +1 -1
- package/build/term-description/index.js +1 -2
- package/build/term-description/index.js.map +1 -1
- package/build/utils/migrate-font-family.js +12 -5
- package/build/utils/migrate-font-family.js.map +1 -1
- package/build/video/edit.native.js +4 -3
- package/build/video/edit.native.js.map +1 -1
- package/build-module/column/index.js +2 -1
- package/build-module/column/index.js.map +1 -1
- package/build-module/columns/edit.js +24 -6
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/columns/index.js +2 -1
- package/build-module/columns/index.js.map +1 -1
- package/build-module/columns/utils.js +4 -8
- package/build-module/columns/utils.js.map +1 -1
- package/build-module/cover/edit/index.js +48 -52
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +31 -6
- package/build-module/cover/edit/resizable-cover-popover.js.map +1 -0
- package/build-module/cover/index.js +12 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/transforms.js +5 -1
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/details/edit.js +52 -0
- package/build-module/details/edit.js.map +1 -0
- package/build-module/details/index.js +91 -0
- package/build-module/details/index.js.map +1 -0
- package/build-module/details/save.js +20 -0
- package/build-module/details/save.js.map +1 -0
- package/build-module/details-content/edit.js +23 -0
- package/build-module/details-content/edit.js.map +1 -0
- package/build-module/details-content/index.js +76 -0
- package/build-module/details-content/index.js.map +1 -0
- package/build-module/details-content/save.js +11 -0
- package/build-module/details-content/save.js.map +1 -0
- package/build-module/details-summary/edit.js +30 -0
- package/build-module/details-summary/edit.js.map +1 -0
- package/build-module/details-summary/index.js +79 -0
- package/build-module/details-summary/index.js.map +1 -0
- package/build-module/details-summary/save.js +16 -0
- package/build-module/details-summary/save.js.map +1 -0
- package/build-module/embed/deprecated.js +4 -1
- package/build-module/embed/deprecated.js.map +1 -1
- package/build-module/embed/embed-link-settings.native.js +1 -1
- package/build-module/embed/embed-link-settings.native.js.map +1 -1
- package/build-module/embed/embed-placeholder.js +1 -1
- package/build-module/embed/embed-placeholder.js.map +1 -1
- package/build-module/embed/index.js +4 -1
- package/build-module/embed/index.js.map +1 -1
- package/build-module/embed/transforms.js +4 -1
- package/build-module/embed/transforms.js.map +1 -1
- package/build-module/embed/util.js +4 -1
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/edit.native.js +0 -2
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/gallery/use-get-media.native.js +2 -1
- package/build-module/gallery/use-get-media.native.js.map +1 -1
- package/build-module/group/edit.js +3 -1
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +3 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/image/edit.js +16 -13
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/index.js +5 -3
- package/build-module/image/index.js.map +1 -1
- package/build-module/index.js +21 -6
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +9 -5
- package/build-module/index.native.js.map +1 -1
- package/build-module/media-text/edit.js +4 -2
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/index.js +3 -0
- package/build-module/media-text/index.js.map +1 -1
- package/build-module/media-text/media-container.js +1 -5
- package/build-module/media-text/media-container.js.map +1 -1
- package/build-module/media-text/media-container.native.js +1 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/navigation/deprecated.js +8 -10
- package/build-module/navigation/deprecated.js.map +1 -1
- package/build-module/navigation/edit/index.js +31 -63
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +1 -14
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/post-author/index.js +0 -1
- package/build-module/post-author/index.js.map +1 -1
- package/build-module/post-date/edit.js +4 -2
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +2 -2
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +2 -1
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/edit.js +16 -27
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-time-to-read/edit.js +1 -1
- package/build-module/post-time-to-read/edit.js.map +1 -1
- package/build-module/post-time-to-read/index.js +7 -0
- package/build-module/post-time-to-read/index.js.map +1 -1
- package/build-module/query/deprecated.js +5 -2
- package/build-module/query/deprecated.js.map +1 -1
- package/build-module/query/edit/inspector-controls/create-new-post-link.js +33 -0
- package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
- package/build-module/query/edit/inspector-controls/index.js +12 -7
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/pattern-selection-modal.js +2 -1
- package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
- package/build-module/query/index.js +5 -10
- package/build-module/query/index.js.map +1 -1
- package/build-module/site-logo/edit.js +115 -18
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +1 -1
- package/build-module/social-link/icons/chain.js +1 -1
- package/build-module/social-link/icons/chain.js.map +1 -1
- package/build-module/social-link/icons/mail.js +1 -1
- package/build-module/social-link/icons/mail.js.map +1 -1
- package/build-module/spacer/controls.js +27 -9
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/spacer/edit.js +129 -14
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/spacer/save.js +3 -3
- package/build-module/spacer/save.js.map +1 -1
- package/build-module/table/state.js +35 -33
- package/build-module/table/state.js.map +1 -1
- package/build-module/template-part/edit/index.js +2 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/utils/hooks.js +2 -2
- package/build-module/template-part/edit/utils/hooks.js.map +1 -1
- package/build-module/term-description/index.js +1 -2
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/utils/migrate-font-family.js +9 -1
- package/build-module/utils/migrate-font-family.js.map +1 -1
- package/build-module/video/edit.native.js +4 -3
- package/build-module/video/edit.native.js.map +1 -1
- package/build-style/columns/style-rtl.css +4 -1
- package/build-style/columns/style.css +4 -1
- package/build-style/common-rtl.css +1 -1
- package/build-style/common.css +1 -1
- package/build-style/cover/editor-rtl.css +9 -10
- package/build-style/cover/editor.css +9 -10
- package/build-style/cover/style-rtl.css +1 -1
- package/build-style/cover/style.css +1 -1
- package/build-style/details/style-rtl.css +91 -0
- package/build-style/details/style.css +91 -0
- package/build-style/details-summary/editor-rtl.css +91 -0
- package/build-style/details-summary/editor.css +91 -0
- package/build-style/details-summary/style-rtl.css +91 -0
- package/build-style/details-summary/style.css +91 -0
- package/build-style/editor-rtl.css +97 -74
- package/build-style/editor.css +97 -74
- package/build-style/file/style-rtl.css +4 -3
- package/build-style/file/style.css +4 -3
- package/build-style/html/editor-rtl.css +2 -2
- package/build-style/html/editor.css +2 -2
- package/build-style/image/editor-rtl.css +1 -1
- package/build-style/image/editor.css +1 -1
- package/build-style/post-excerpt/style-rtl.css +1 -1
- package/build-style/post-excerpt/style.css +1 -1
- package/build-style/pullquote/style-rtl.css +4 -1
- package/build-style/pullquote/style.css +4 -1
- package/build-style/query/editor-rtl.css +8 -12
- package/build-style/query/editor.css +8 -12
- package/build-style/search/style-rtl.css +2 -0
- package/build-style/search/style.css +2 -0
- package/build-style/shortcode/editor-rtl.css +15 -35
- package/build-style/shortcode/editor.css +15 -35
- package/build-style/site-logo/editor-rtl.css +46 -0
- package/build-style/site-logo/editor.css +46 -0
- package/build-style/spacer/editor-rtl.css +4 -2
- package/build-style/spacer/editor.css +4 -2
- package/build-style/style-rtl.css +25 -8
- package/build-style/style.css +25 -8
- package/build-style/template-part/editor-rtl.css +8 -12
- package/build-style/template-part/editor.css +8 -12
- package/package.json +31 -31
- package/src/buttons/test/__snapshots__/edit.native.js.snap +18 -0
- package/src/buttons/test/edit.native.js +123 -2
- package/src/column/block.json +2 -1
- package/src/columns/block.json +2 -1
- package/src/columns/edit.js +33 -9
- package/src/columns/style.scss +5 -1
- package/src/columns/utils.js +8 -9
- package/src/common.scss +1 -1
- package/src/cover/block.json +12 -0
- package/src/cover/edit/index.js +44 -37
- package/src/cover/edit/resizable-cover-popover.js +82 -0
- package/src/cover/editor.scss +20 -13
- package/src/cover/index.php +9 -10
- package/src/cover/style.scss +1 -1
- package/src/cover/test/edit.js +1 -1
- package/src/cover/transforms.js +4 -1
- package/src/details/block.json +54 -0
- package/src/details/edit.js +59 -0
- package/src/details/index.js +35 -0
- package/src/details/save.js +15 -0
- package/src/details/style.scss +3 -0
- package/src/details-content/block.json +50 -0
- package/src/details-content/edit.js +29 -0
- package/src/details-content/index.js +23 -0
- package/src/details-content/save.js +12 -0
- package/src/details-summary/block.json +53 -0
- package/src/details-summary/edit.js +27 -0
- package/src/details-summary/editor.scss +3 -0
- package/src/details-summary/index.js +23 -0
- package/src/details-summary/save.js +13 -0
- package/src/details-summary/style.scss +3 -0
- package/src/editor.scss +1 -0
- package/src/embed/block.json +4 -1
- package/src/embed/embed-link-settings.native.js +1 -1
- package/src/embed/embed-placeholder.js +1 -1
- package/src/file/edit.native.js +0 -2
- package/src/file/style.scss +5 -2
- package/src/gallery/test/index.native.js +4 -4
- package/src/gallery/test/use-get-media.native.js +24 -0
- package/src/gallery/use-get-media.native.js +1 -1
- package/src/group/block.json +3 -0
- package/src/group/edit.js +8 -2
- package/src/heading/test/__snapshots__/index.native.js.snap +12 -0
- package/src/heading/test/index.native.js +71 -0
- package/src/html/editor.scss +2 -21
- package/src/image/block.json +5 -3
- package/src/image/edit.js +21 -17
- package/src/image/editor.scss +1 -1
- package/src/index.js +13 -3
- package/src/index.native.js +9 -5
- package/src/list/test/edit.native.js +7 -7
- package/src/media-text/block.json +3 -0
- package/src/media-text/edit.js +2 -1
- package/src/media-text/media-container.js +1 -5
- package/src/media-text/media-container.native.js +1 -1
- package/src/navigation/deprecated.js +15 -19
- package/src/navigation/edit/index.js +32 -106
- package/src/navigation/edit/unsaved-inner-blocks.js +34 -46
- package/src/navigation/index.php +15 -12
- package/src/paragraph/test/edit.native.js +616 -1
- package/src/post-author/block.json +0 -1
- package/src/post-date/edit.js +4 -0
- package/src/post-date/index.php +17 -8
- package/src/post-excerpt/edit.js +1 -1
- package/src/post-excerpt/index.php +3 -3
- package/src/post-excerpt/style.scss +2 -1
- package/src/post-featured-image/dimension-controls.js +5 -1
- package/src/post-featured-image/edit.js +14 -34
- package/src/post-featured-image/index.php +1 -1
- package/src/post-time-to-read/block.json +7 -0
- package/src/post-time-to-read/edit.js +1 -1
- package/src/post-time-to-read/index.php +3 -3
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -2
- package/src/preformatted/test/edit.native.js +42 -2
- package/src/pullquote/style.scss +5 -1
- package/src/pullquote/test/edit.native.js +65 -0
- package/src/query/deprecated.js +4 -1
- package/src/query/edit/inspector-controls/create-new-post-link.js +26 -0
- package/src/query/edit/inspector-controls/index.js +13 -6
- package/src/query/edit/pattern-selection-modal.js +1 -0
- package/src/query/editor.scss +8 -11
- package/src/query/index.js +1 -7
- package/src/quote/test/edit.native.js +88 -0
- package/src/search/index.php +1 -1
- package/src/search/style.scss +3 -0
- package/src/shortcode/editor.scss +6 -5
- package/src/site-logo/block.json +1 -1
- package/src/site-logo/edit.js +123 -9
- package/src/site-logo/editor.scss +57 -0
- package/src/social-link/icons/chain.js +1 -1
- package/src/social-link/icons/mail.js +1 -1
- package/src/social-link/index.php +2 -2
- package/src/spacer/controls.js +42 -17
- package/src/spacer/edit.js +176 -18
- package/src/spacer/editor.scss +2 -1
- package/src/spacer/save.js +3 -3
- package/src/style.scss +2 -0
- package/src/table/state.js +83 -66
- package/src/template-part/edit/index.js +1 -0
- package/src/template-part/edit/utils/hooks.js +2 -2
- package/src/template-part/editor.scss +9 -11
- package/src/term-description/block.json +1 -2
- package/src/utils/migrate-font-family.js +8 -1
- package/src/verse/test/edit.native.js +28 -0
- package/src/video/edit.native.js +2 -2
- package/tsconfig.json +1 -0
- package/build/cover/edit/resizable-cover.js.map +0 -1
- package/build/media-text/media-container-icon.js +0 -27
- package/build/media-text/media-container-icon.js.map +0 -1
- package/build/query/hooks.js +0 -72
- package/build/query/hooks.js.map +0 -1
- package/build/utils/clean-empty-object.js +0 -34
- package/build/utils/clean-empty-object.js.map +0 -1
- package/build-module/cover/edit/resizable-cover.js.map +0 -1
- package/build-module/media-text/media-container-icon.js +0 -17
- package/build-module/media-text/media-container-icon.js.map +0 -1
- package/build-module/query/hooks.js +0 -59
- package/build-module/query/hooks.js.map +0 -1
- package/build-module/utils/clean-empty-object.js +0 -25
- package/build-module/utils/clean-empty-object.js.map +0 -1
- package/src/cover/edit/resizable-cover.js +0 -61
- package/src/media-text/media-container-icon.js +0 -12
- package/src/query/hooks.js +0 -53
- package/src/utils/clean-empty-object.js +0 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/spacer/controls.js"],"names":["__","InspectorControls","useSetting","PanelBody","__experimentalUseCustomUnits","useCustomUnits","__experimentalUnitControl","UnitControl","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","useInstanceId","MIN_SPACER_SIZE","DimensionInput","label","onChange","isResizing","value","inputId","availableUnitSettings","undefined","filter","availableUnit","units","availableUnits","defaultValues","px","em","rem","vw","vh","handleOnChange","unprocessedValue","parsedQuantity","parsedUnit","computedValue","join","SpacerControls","setAttributes","orientation","height","width","nextWidth","nextHeight"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/spacer/controls.js"],"names":["__","InspectorControls","useSetting","__experimentalSpacingSizesControl","SpacingSizesControl","isValueSpacingPreset","BaseControl","PanelBody","__experimentalUseCustomUnits","useCustomUnits","__experimentalUnitControl","UnitControl","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","useInstanceId","View","MIN_SPACER_SIZE","DimensionInput","label","onChange","isResizing","value","inputId","spacingSizes","availableUnitSettings","undefined","filter","availableUnit","units","availableUnits","defaultValues","px","em","rem","vw","vh","handleOnChange","unprocessedValue","all","parsedQuantity","parsedUnit","computedValue","join","length","maxWidth","SpacerControls","setAttributes","orientation","height","width","nextWidth","nextHeight"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SACCC,iBADD,EAECC,UAFD,EAGCC,iCAAiC,IAAIC,mBAHtC,EAICC,oBAJD,QAKO,yBALP;AAMA,SACCC,WADD,EAECC,SAFD,EAGCC,4BAA4B,IAAIC,cAHjC,EAICC,yBAAyB,IAAIC,WAJ9B,EAKCC,8CAA8C,IAAIC,gCALnD,QAMO,uBANP;AAOA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,IAAT,QAAqB,uBAArB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,aAAhC;;AAEA,SAASC,cAAT,OAAuE;AAAA;;AAAA,MAA9C;AAAEC,IAAAA,KAAF;AAASC,IAAAA,QAAT;AAAmBC,IAAAA,UA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EC;AAAT,KAAF,CAJf;AAMC,IAAA,UAAU,EAAG9B;AANd,IAFF,EAWG2B,WAAW,KAAK,YAAhB,IACD,cAAC,cAAD;AACC,IAAA,KAAK,EAAG/C,EAAE,CAAE,QAAF,CADX;AAEC,IAAA,KAAK,EAAGgD,MAFT;AAGC,IAAA,QAAQ,EAAKG,UAAF,IACVL,aAAa,CAAE;AAAEE,MAAAA,MAAM,EAAEG;AAAV,KAAF,CAJf;AAMC,IAAA,UAAU,EAAG/B;AANd,IAZF,CADD,CADD;AA0BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tuseSetting,\n\t__experimentalSpacingSizesControl as SpacingSizesControl,\n\tisValueSpacingPreset,\n} from '@wordpress/block-editor';\nimport {\n\tBaseControl,\n\tPanelBody,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { View } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport { MIN_SPACER_SIZE } from './constants';\n\nfunction DimensionInput( { label, onChange, isResizing, value = '' } ) {\n\tconst inputId = useInstanceId( UnitControl, 'block-spacer-height-input' );\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\n\t// In most contexts the spacer size cannot meaningfully be set to a\n\t// percentage, since this is relative to the parent container. This\n\t// unit is disabled from the UI.\n\tconst availableUnitSettings = (\n\t\tuseSetting( 'spacing.units' ) || undefined\n\t)?.filter( ( availableUnit ) => availableUnit !== '%' );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnitSettings || [\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t\t'vh',\n\t\t],\n\t\tdefaultValues: { px: 100, em: 10, rem: 10, vw: 10, vh: 25 },\n\t} );\n\n\tconst handleOnChange = ( unprocessedValue ) => {\n\t\tonChange( unprocessedValue.all );\n\t};\n\n\t// Force the unit to update to `px` when the Spacer is being resized.\n\tconst [ parsedQuantity, parsedUnit ] =\n\t\tparseQuantityAndUnitFromRawValue( value );\n\tconst computedValue = isValueSpacingPreset( value )\n\t\t? value\n\t\t: [ parsedQuantity, isResizing ? 'px' : parsedUnit ].join( '' );\n\n\treturn (\n\t\t<>\n\t\t\t{ ( ! spacingSizes || spacingSizes?.length === 0 ) && (\n\t\t\t\t<BaseControl label={ label } id={ inputId }>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tid={ inputId }\n\t\t\t\t\t\tisResetValueOnUnitChange\n\t\t\t\t\t\tmin={ MIN_SPACER_SIZE }\n\t\t\t\t\t\tonChange={ handleOnChange }\n\t\t\t\t\t\tstyle={ { maxWidth: 80 } }\n\t\t\t\t\t\tvalue={ computedValue }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t/>\n\t\t\t\t</BaseControl>\n\t\t\t) }\n\n\t\t\t{ spacingSizes?.length > 0 && (\n\t\t\t\t<View className=\"tools-panel-item-spacing\">\n\t\t\t\t\t<SpacingSizesControl\n\t\t\t\t\t\tvalues={ { all: computedValue } }\n\t\t\t\t\t\tonChange={ handleOnChange }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tsides={ [ 'all' ] }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ false }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default function SpacerControls( {\n\tsetAttributes,\n\torientation,\n\theight,\n\twidth,\n\tisResizing,\n} ) {\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t{ orientation === 'horizontal' && (\n\t\t\t\t\t<DimensionInput\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tvalue={ width }\n\t\t\t\t\t\tonChange={ ( nextWidth ) =>\n\t\t\t\t\t\t\tsetAttributes( { width: nextWidth } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ orientation !== 'horizontal' && (\n\t\t\t\t\t<DimensionInput\n\t\t\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\t\t\tvalue={ height }\n\t\t\t\t\t\tonChange={ ( nextHeight ) =>\n\t\t\t\t\t\t\tsetAttributes( { height: nextHeight } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n}\n"]}
|
|
@@ -9,10 +9,11 @@ import classnames from 'classnames';
|
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { useBlockProps } from '@wordpress/block-editor';
|
|
12
|
+
import { useBlockProps, useSetting, getCustomValueFromPreset, getSpacingPresetCssVar, store as blockEditorStore } from '@wordpress/block-editor';
|
|
13
13
|
import { ResizableBox } from '@wordpress/components';
|
|
14
14
|
import { useState, useEffect } from '@wordpress/element';
|
|
15
15
|
import { View } from '@wordpress/primitives';
|
|
16
|
+
import { useSelect } from '@wordpress/data';
|
|
16
17
|
/**
|
|
17
18
|
* Internal dependencies
|
|
18
19
|
*/
|
|
@@ -80,22 +81,38 @@ const SpacerEdit = _ref2 => {
|
|
|
80
81
|
setAttributes,
|
|
81
82
|
toggleSelection,
|
|
82
83
|
context,
|
|
83
|
-
__unstableParentLayout: parentLayout
|
|
84
|
+
__unstableParentLayout: parentLayout,
|
|
85
|
+
className
|
|
84
86
|
} = _ref2;
|
|
87
|
+
const disableCustomSpacingSizes = useSelect(select => {
|
|
88
|
+
const editorSettings = select(blockEditorStore).getSettings();
|
|
89
|
+
return editorSettings === null || editorSettings === void 0 ? void 0 : editorSettings.disableCustomSpacingSizes;
|
|
90
|
+
});
|
|
85
91
|
const {
|
|
86
92
|
orientation
|
|
87
93
|
} = context;
|
|
88
94
|
const {
|
|
89
95
|
orientation: parentOrientation,
|
|
90
96
|
type
|
|
91
|
-
} = parentLayout || {}; //
|
|
97
|
+
} = parentLayout || {}; // Check if the spacer is inside a flex container.
|
|
98
|
+
|
|
99
|
+
const isFlexLayout = type === 'flex'; // If the spacer is inside a flex container, it should either inherit the orientation
|
|
92
100
|
// of the parent or use the flex default orientation.
|
|
93
101
|
|
|
94
|
-
const inheritedOrientation = !parentOrientation &&
|
|
102
|
+
const inheritedOrientation = !parentOrientation && isFlexLayout ? 'horizontal' : parentOrientation || orientation;
|
|
95
103
|
const {
|
|
96
104
|
height,
|
|
97
|
-
width
|
|
105
|
+
width,
|
|
106
|
+
style: blockStyle = {}
|
|
98
107
|
} = attributes;
|
|
108
|
+
const {
|
|
109
|
+
layout = {}
|
|
110
|
+
} = blockStyle;
|
|
111
|
+
const {
|
|
112
|
+
selfStretch,
|
|
113
|
+
flexSize
|
|
114
|
+
} = layout;
|
|
115
|
+
const spacingSizes = useSetting('spacing.spacingSizes');
|
|
99
116
|
const [isResizing, setIsResizing] = useState(false);
|
|
100
117
|
const [temporaryHeight, setTemporaryHeight] = useState(null);
|
|
101
118
|
const [temporaryWidth, setTemporaryWidth] = useState(null);
|
|
@@ -106,6 +123,18 @@ const SpacerEdit = _ref2 => {
|
|
|
106
123
|
|
|
107
124
|
const handleOnVerticalResizeStop = newHeight => {
|
|
108
125
|
onResizeStop();
|
|
126
|
+
|
|
127
|
+
if (isFlexLayout) {
|
|
128
|
+
setAttributes({
|
|
129
|
+
style: { ...blockStyle,
|
|
130
|
+
layout: { ...layout,
|
|
131
|
+
flexSize: newHeight,
|
|
132
|
+
selfStretch: 'fixed'
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
109
138
|
setAttributes({
|
|
110
139
|
height: newHeight
|
|
111
140
|
});
|
|
@@ -114,17 +143,50 @@ const SpacerEdit = _ref2 => {
|
|
|
114
143
|
|
|
115
144
|
const handleOnHorizontalResizeStop = newWidth => {
|
|
116
145
|
onResizeStop();
|
|
146
|
+
|
|
147
|
+
if (isFlexLayout) {
|
|
148
|
+
setAttributes({
|
|
149
|
+
style: { ...blockStyle,
|
|
150
|
+
layout: { ...layout,
|
|
151
|
+
flexSize: newWidth,
|
|
152
|
+
selfStretch: 'fixed'
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
117
158
|
setAttributes({
|
|
118
159
|
width: newWidth
|
|
119
160
|
});
|
|
120
161
|
setTemporaryWidth(null);
|
|
121
162
|
};
|
|
122
163
|
|
|
164
|
+
const getHeightForVerticalBlocks = () => {
|
|
165
|
+
if (isFlexLayout) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return temporaryHeight || getSpacingPresetCssVar(height) || undefined;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const getWidthForHorizontalBlocks = () => {
|
|
173
|
+
if (isFlexLayout) {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return temporaryWidth || getSpacingPresetCssVar(width) || undefined;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const sizeConditionalOnOrientation = inheritedOrientation === 'horizontal' ? temporaryWidth || flexSize : temporaryHeight || flexSize;
|
|
123
181
|
const style = {
|
|
124
|
-
height: inheritedOrientation === 'horizontal' ? 24 :
|
|
125
|
-
width: inheritedOrientation === 'horizontal' ?
|
|
182
|
+
height: inheritedOrientation === 'horizontal' ? 24 : getHeightForVerticalBlocks(),
|
|
183
|
+
width: inheritedOrientation === 'horizontal' ? getWidthForHorizontalBlocks() : undefined,
|
|
126
184
|
// In vertical flex containers, the spacer shrinks to nothing without a minimum width.
|
|
127
|
-
minWidth: inheritedOrientation === 'vertical' &&
|
|
185
|
+
minWidth: inheritedOrientation === 'vertical' && isFlexLayout ? 48 : undefined,
|
|
186
|
+
// Add flex-basis so temporary sizes are respected.
|
|
187
|
+
flexBasis: isFlexLayout ? sizeConditionalOnOrientation : undefined,
|
|
188
|
+
// Remove flex-grow when resizing.
|
|
189
|
+
flexGrow: isFlexLayout && isResizing ? 0 : undefined
|
|
128
190
|
};
|
|
129
191
|
|
|
130
192
|
const resizableBoxWithOrientation = blockOrientation => {
|
|
@@ -174,16 +236,69 @@ const SpacerEdit = _ref2 => {
|
|
|
174
236
|
};
|
|
175
237
|
|
|
176
238
|
useEffect(() => {
|
|
177
|
-
if (
|
|
239
|
+
if (isFlexLayout && selfStretch !== 'fill' && selfStretch !== 'fit' && !flexSize) {
|
|
240
|
+
if (inheritedOrientation === 'horizontal') {
|
|
241
|
+
// If spacer is moving from a vertical container to a horizontal container,
|
|
242
|
+
// it might not have width but have height instead.
|
|
243
|
+
const newSize = getCustomValueFromPreset(width, spacingSizes) || getCustomValueFromPreset(height, spacingSizes) || '100px';
|
|
244
|
+
setAttributes({
|
|
245
|
+
width: '0px',
|
|
246
|
+
style: { ...blockStyle,
|
|
247
|
+
layout: { ...layout,
|
|
248
|
+
flexSize: newSize,
|
|
249
|
+
selfStretch: 'fixed'
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
} else {
|
|
254
|
+
const newSize = getCustomValueFromPreset(height, spacingSizes) || getCustomValueFromPreset(width, spacingSizes) || '100px';
|
|
255
|
+
setAttributes({
|
|
256
|
+
height: '0px',
|
|
257
|
+
style: { ...blockStyle,
|
|
258
|
+
layout: { ...layout,
|
|
259
|
+
flexSize: newSize,
|
|
260
|
+
selfStretch: 'fixed'
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
} else if (isFlexLayout && (selfStretch === 'fill' || selfStretch === 'fit')) {
|
|
266
|
+
if (inheritedOrientation === 'horizontal') {
|
|
267
|
+
setAttributes({
|
|
268
|
+
width: undefined
|
|
269
|
+
});
|
|
270
|
+
} else {
|
|
271
|
+
setAttributes({
|
|
272
|
+
height: undefined
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
} else if (!isFlexLayout && (selfStretch || flexSize)) {
|
|
276
|
+
if (inheritedOrientation === 'horizontal') {
|
|
277
|
+
setAttributes({
|
|
278
|
+
width: flexSize
|
|
279
|
+
});
|
|
280
|
+
} else {
|
|
281
|
+
setAttributes({
|
|
282
|
+
height: flexSize
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
178
286
|
setAttributes({
|
|
179
|
-
|
|
180
|
-
|
|
287
|
+
style: { ...blockStyle,
|
|
288
|
+
layout: { ...layout,
|
|
289
|
+
flexSize: undefined,
|
|
290
|
+
selfStretch: undefined
|
|
291
|
+
}
|
|
292
|
+
}
|
|
181
293
|
});
|
|
182
294
|
}
|
|
183
|
-
}, []);
|
|
295
|
+
}, [blockStyle, flexSize, height, inheritedOrientation, isFlexLayout, layout, selfStretch, setAttributes, spacingSizes, width]);
|
|
184
296
|
return createElement(Fragment, null, createElement(View, useBlockProps({
|
|
185
|
-
style
|
|
186
|
-
|
|
297
|
+
style,
|
|
298
|
+
className: classnames(className, {
|
|
299
|
+
'custom-sizes-disabled': disableCustomSpacingSizes
|
|
300
|
+
})
|
|
301
|
+
}), resizableBoxWithOrientation(inheritedOrientation)), !isFlexLayout && createElement(SpacerControls, {
|
|
187
302
|
setAttributes: setAttributes,
|
|
188
303
|
height: temporaryHeight || height,
|
|
189
304
|
width: temporaryWidth || width,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/spacer/edit.js"],"names":["classnames","useBlockProps","ResizableBox","useState","useEffect","View","SpacerControls","MIN_SPACER_SIZE","ResizableSpacer","orientation","onResizeStart","onResize","onResizeStop","isSelected","isResizing","setIsResizing","props","getCurrentSize","elt","clientWidth","clientHeight","getNextVal","_event","_direction","nextVal","axis","position","isVisible","SpacerEdit","attributes","setAttributes","toggleSelection","context","__unstableParentLayout","parentLayout","parentOrientation","type","inheritedOrientation","height","width","temporaryHeight","setTemporaryHeight","temporaryWidth","setTemporaryWidth","handleOnVerticalResizeStop","newHeight","handleOnHorizontalResizeStop","newWidth","style","undefined","minWidth","resizableBoxWithOrientation","blockOrientation","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,yBAA9B;AACA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,IAAT,QAAqB,uBAArB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,YAA3B;AACA,SAASC,eAAT,QAAgC,aAAhC;;AAEA,MAAMC,eAAe,GAAG,QASjB;AAAA,MATmB;AACzBC,IAAAA,WADyB;AAEzBC,IAAAA,aAFyB;AAGzBC,IAAAA,QAHyB;AAIzBC,IAAAA,YAJyB;AAKzBC,IAAAA,UALyB;AAMzBC,IAAAA,UANyB;AAOzBC,IAAAA,aAPyB;AAQzB,OAAGC;AARsB,GASnB;;AACN,QAAMC,cAAc,GAAKC,GAAF,IAAW;AACjC,WAAOT,WAAW,KAAK,YAAhB,GACJS,GAAG,CAACC,WADA,GAEJD,GAAG,CAACE,YAFP;AAGA,GAJD;;AAMA,QAAMC,UAAU,GAAKH,GAAF,IAAW;AAC7B,WAAQ,GAAGD,cAAc,CAAEC,GAAF,CAAS,IAAlC;AACA,GAFD;;AAIA,SACC,cAAC,YAAD;AACC,IAAA,SAAS,EAAGlB,UAAU,CAAE,wCAAF,EAA4C;AACjE,2BAAqBS,WAAW,KAAK,YAD4B;AAEjE,qBAAeK,UAFkD;AAGjE,qBAAeD;AAHkD,KAA5C,CADvB;AAMC,IAAA,aAAa,EAAG,CAAES,MAAF,EAAUC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AgBC,MAAA,UAAU,EAAG/B,UAhBd;AAiBC,MAAA,UAAU,EAAGC,UAjBd;AAkBC,MAAA,aAAa,EAAGC;AAlBjB,MADD,CADD;AAwBA,GAlDD;;AAoDAX,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKiC,oBAAoB,KAAK,YAAzB,IAAyC,CAAEE,KAAhD,EAAwD;AACvDT,MAAAA,aAAa,CAAE;AACdQ,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,KAAK,EAAE;AAFO,OAAF,CAAb;AAIA;AACD,GAPQ,EAON,EAPM,CAAT;AASA,SACC,8BACC,cAAC,IAAD,EAAWtC,aAAa,CAAE;AAAE+C,IAAAA;AAAF,GAAF,CAAxB,EACGG,2BAA2B,CAAEd,oBAAF,CAD9B,CADD,EAIC,cAAC,cAAD;AACC,IAAA,aAAa,EAAGP,aADjB;AAEC,IAAA,MAAM,EAAGU,eAAe,IAAIF,MAF7B;AAGC,IAAA,KAAK,EAAGI,cAAc,IAAIH,KAH3B;AAIC,IAAA,WAAW,EAAGF,oBAJf;AAKC,IAAA,UAAU,EAAGvB;AALd,IAJD,CADD;AAcA,CAjID;;AAmIA,eAAec,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { ResizableBox } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport { View } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport SpacerControls from './controls';\nimport { MIN_SPACER_SIZE } from './constants';\n\nconst ResizableSpacer = ( {\n\torientation,\n\tonResizeStart,\n\tonResize,\n\tonResizeStop,\n\tisSelected,\n\tisResizing,\n\tsetIsResizing,\n\t...props\n} ) => {\n\tconst getCurrentSize = ( elt ) => {\n\t\treturn orientation === 'horizontal'\n\t\t\t? elt.clientWidth\n\t\t\t: elt.clientHeight;\n\t};\n\n\tconst getNextVal = ( elt ) => {\n\t\treturn `${ getCurrentSize( elt ) }px`;\n\t};\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tclassName={ classnames( 'block-library-spacer__resize-container', {\n\t\t\t\t'resize-horizontal': orientation === 'horizontal',\n\t\t\t\t'is-resizing': isResizing,\n\t\t\t\t'is-selected': isSelected,\n\t\t\t} ) }\n\t\t\tonResizeStart={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = getNextVal( elt );\n\t\t\t\tonResizeStart( nextVal );\n\t\t\t\tonResize( nextVal );\n\t\t\t} }\n\t\t\tonResize={ ( _event, _direction, elt ) => {\n\t\t\t\tonResize( getNextVal( elt ) );\n\t\t\t\tif ( ! isResizing ) {\n\t\t\t\t\tsetIsResizing( true );\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonResizeStop={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = getCurrentSize( elt );\n\t\t\t\tonResizeStop( `${ nextVal }px` );\n\t\t\t\tsetIsResizing( false );\n\t\t\t} }\n\t\t\t__experimentalShowTooltip={ true }\n\t\t\t__experimentalTooltipProps={ {\n\t\t\t\taxis: orientation === 'horizontal' ? 'x' : 'y',\n\t\t\t\tposition: 'corner',\n\t\t\t\tisVisible: isResizing,\n\t\t\t} }\n\t\t\tshowHandle={ isSelected }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n};\n\nconst SpacerEdit = ( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\ttoggleSelection,\n\tcontext,\n\t__unstableParentLayout: parentLayout,\n} ) => {\n\tconst { orientation } = context;\n\tconst { orientation: parentOrientation, type } = parentLayout || {};\n\t// If the spacer is inside a flex container, it should either inherit the orientation\n\t// of the parent or use the flex default orientation.\n\tconst inheritedOrientation =\n\t\t! parentOrientation && type === 'flex'\n\t\t\t? 'horizontal'\n\t\t\t: parentOrientation || orientation;\n\tconst { height, width } = attributes;\n\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst [ temporaryHeight, setTemporaryHeight ] = useState( null );\n\tconst [ temporaryWidth, setTemporaryWidth ] = useState( null );\n\n\tconst onResizeStart = () => toggleSelection( false );\n\tconst onResizeStop = () => toggleSelection( true );\n\n\tconst handleOnVerticalResizeStop = ( newHeight ) => {\n\t\tonResizeStop();\n\n\t\tsetAttributes( { height: newHeight } );\n\t\tsetTemporaryHeight( null );\n\t};\n\n\tconst handleOnHorizontalResizeStop = ( newWidth ) => {\n\t\tonResizeStop();\n\t\tsetAttributes( { width: newWidth } );\n\t\tsetTemporaryWidth( null );\n\t};\n\n\tconst style = {\n\t\theight:\n\t\t\tinheritedOrientation === 'horizontal'\n\t\t\t\t? 24\n\t\t\t\t: temporaryHeight || height || undefined,\n\t\twidth:\n\t\t\tinheritedOrientation === 'horizontal'\n\t\t\t\t? temporaryWidth || width || undefined\n\t\t\t\t: undefined,\n\t\t// In vertical flex containers, the spacer shrinks to nothing without a minimum width.\n\t\tminWidth:\n\t\t\tinheritedOrientation === 'vertical' && type === 'flex'\n\t\t\t\t? 48\n\t\t\t\t: undefined,\n\t};\n\n\tconst resizableBoxWithOrientation = ( blockOrientation ) => {\n\t\tif ( blockOrientation === 'horizontal' ) {\n\t\t\treturn (\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tminWidth={ MIN_SPACER_SIZE }\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: true,\n\t\t\t\t\t\tbottom: false,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryWidth }\n\t\t\t\t\tonResizeStop={ handleOnHorizontalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tminHeight={ MIN_SPACER_SIZE }\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: false,\n\t\t\t\t\t\tbottom: true,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryHeight }\n\t\t\t\t\tonResizeStop={ handleOnVerticalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tif ( inheritedOrientation === 'horizontal' && ! width ) {\n\t\t\tsetAttributes( {\n\t\t\t\theight: '0px',\n\t\t\t\twidth: '72px',\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<View { ...useBlockProps( { style } ) }>\n\t\t\t\t{ resizableBoxWithOrientation( inheritedOrientation ) }\n\t\t\t</View>\n\t\t\t<SpacerControls\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\theight={ temporaryHeight || height }\n\t\t\t\twidth={ temporaryWidth || width }\n\t\t\t\torientation={ inheritedOrientation }\n\t\t\t\tisResizing={ isResizing }\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default SpacerEdit;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/spacer/edit.js"],"names":["classnames","useBlockProps","useSetting","getCustomValueFromPreset","getSpacingPresetCssVar","store","blockEditorStore","ResizableBox","useState","useEffect","View","useSelect","SpacerControls","MIN_SPACER_SIZE","ResizableSpacer","orientation","onResizeStart","onResize","onResizeStop","isSelected","isResizing","setIsResizing","props","getCurrentSize","elt","clientWidth","clientHeight","getNextVal","_event","_direction","nextVal","axis","position","isVisible","SpacerEdit","attributes","setAttributes","toggleSelection","context","__unstableParentLayout","parentLayout","className","disableCustomSpacingSizes","select","editorSettings","getSettings","parentOrientation","type","isFlexLayout","inheritedOrientation","height","width","style","blockStyle","layout","selfStretch","flexSize","spacingSizes","temporaryHeight","setTemporaryHeight","temporaryWidth","setTemporaryWidth","handleOnVerticalResizeStop","newHeight","handleOnHorizontalResizeStop","newWidth","getHeightForVerticalBlocks","undefined","getWidthForHorizontalBlocks","sizeConditionalOnOrientation","minWidth","flexBasis","flexGrow","resizableBoxWithOrientation","blockOrientation","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft","newSize"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,aADD,EAECC,UAFD,EAGCC,wBAHD,EAICC,sBAJD,EAKCC,KAAK,IAAIC,gBALV,QAMO,yBANP;AAOA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,IAAT,QAAqB,uBAArB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,YAA3B;AACA,SAASC,eAAT,QAAgC,aAAhC;;AAEA,MAAMC,eAAe,GAAG,QASjB;AAAA,MATmB;AACzBC,IAAAA,WADyB;AAEzBC,IAAAA,aAFyB;AAGzBC,IAAAA,QAHyB;AAIzBC,IAAAA,YAJyB;AAKzBC,IAAAA,UALyB;AAMzBC,IAAAA,UANyB;AAOzBC,IAAAA,aAPyB;AAQzB,OAAGC;AARsB,GASnB;;AACN,QAAMC,cAAc,GAAKC,GAAF,IAAW;AACjC,WAAOT,WAAW,KAAK,YAAhB,GACJ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,MADI;AAEPE,YAAAA,QAAQ,EAAEW,SAFH;AAGPZ,YAAAA,WAAW,EAAEY;AAHN;AAFF;AADO,OAAF,CAAb;AAUA;AACD,GA5EQ,EA4EN,CACFd,UADE,EAEFG,QAFE,EAGFN,MAHE,EAIFD,oBAJE,EAKFD,YALE,EAMFM,MANE,EAOFC,WAPE,EAQFnB,aARE,EASFqB,YATE,EAUFN,KAVE,CA5EM,CAAT;AAyFA,SACC,8BACC,cAAC,IAAD,EACMlD,aAAa,CAAE;AACnBmD,IAAAA,KADmB;AAEnBX,IAAAA,SAAS,EAAEzC,UAAU,CAAEyC,SAAF,EAAa;AACjC,+BAAyBC;AADQ,KAAb;AAFF,GAAF,CADnB,EAQG+B,2BAA2B,CAAExB,oBAAF,CAR9B,CADD,EAWG,CAAED,YAAF,IACD,cAAC,cAAD;AACC,IAAA,aAAa,EAAGZ,aADjB;AAEC,IAAA,MAAM,EAAGsB,eAAe,IAAIR,MAF7B;AAGC,IAAA,KAAK,EAAGU,cAAc,IAAIT,KAH3B;AAIC,IAAA,WAAW,EAAGF,oBAJf;AAKC,IAAA,UAAU,EAAG7B;AALd,IAZF,CADD;AAuBA,CAxRD;;AA0RA,eAAec,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseSetting,\n\tgetCustomValueFromPreset,\n\tgetSpacingPresetCssVar,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ResizableBox } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport { View } from '@wordpress/primitives';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport SpacerControls from './controls';\nimport { MIN_SPACER_SIZE } from './constants';\n\nconst ResizableSpacer = ( {\n\torientation,\n\tonResizeStart,\n\tonResize,\n\tonResizeStop,\n\tisSelected,\n\tisResizing,\n\tsetIsResizing,\n\t...props\n} ) => {\n\tconst getCurrentSize = ( elt ) => {\n\t\treturn orientation === 'horizontal'\n\t\t\t? elt.clientWidth\n\t\t\t: elt.clientHeight;\n\t};\n\n\tconst getNextVal = ( elt ) => {\n\t\treturn `${ getCurrentSize( elt ) }px`;\n\t};\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tclassName={ classnames( 'block-library-spacer__resize-container', {\n\t\t\t\t'resize-horizontal': orientation === 'horizontal',\n\t\t\t\t'is-resizing': isResizing,\n\t\t\t\t'is-selected': isSelected,\n\t\t\t} ) }\n\t\t\tonResizeStart={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = getNextVal( elt );\n\t\t\t\tonResizeStart( nextVal );\n\t\t\t\tonResize( nextVal );\n\t\t\t} }\n\t\t\tonResize={ ( _event, _direction, elt ) => {\n\t\t\t\tonResize( getNextVal( elt ) );\n\t\t\t\tif ( ! isResizing ) {\n\t\t\t\t\tsetIsResizing( true );\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonResizeStop={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = getCurrentSize( elt );\n\t\t\t\tonResizeStop( `${ nextVal }px` );\n\t\t\t\tsetIsResizing( false );\n\t\t\t} }\n\t\t\t__experimentalShowTooltip={ true }\n\t\t\t__experimentalTooltipProps={ {\n\t\t\t\taxis: orientation === 'horizontal' ? 'x' : 'y',\n\t\t\t\tposition: 'corner',\n\t\t\t\tisVisible: isResizing,\n\t\t\t} }\n\t\t\tshowHandle={ isSelected }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n};\n\nconst SpacerEdit = ( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\ttoggleSelection,\n\tcontext,\n\t__unstableParentLayout: parentLayout,\n\tclassName,\n} ) => {\n\tconst disableCustomSpacingSizes = useSelect( ( select ) => {\n\t\tconst editorSettings = select( blockEditorStore ).getSettings();\n\t\treturn editorSettings?.disableCustomSpacingSizes;\n\t} );\n\tconst { orientation } = context;\n\tconst { orientation: parentOrientation, type } = parentLayout || {};\n\t// Check if the spacer is inside a flex container.\n\tconst isFlexLayout = type === 'flex';\n\t// If the spacer is inside a flex container, it should either inherit the orientation\n\t// of the parent or use the flex default orientation.\n\tconst inheritedOrientation =\n\t\t! parentOrientation && isFlexLayout\n\t\t\t? 'horizontal'\n\t\t\t: parentOrientation || orientation;\n\tconst { height, width, style: blockStyle = {} } = attributes;\n\n\tconst { layout = {} } = blockStyle;\n\tconst { selfStretch, flexSize } = layout;\n\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\n\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst [ temporaryHeight, setTemporaryHeight ] = useState( null );\n\tconst [ temporaryWidth, setTemporaryWidth ] = useState( null );\n\n\tconst onResizeStart = () => toggleSelection( false );\n\tconst onResizeStop = () => toggleSelection( true );\n\n\tconst handleOnVerticalResizeStop = ( newHeight ) => {\n\t\tonResizeStop();\n\n\t\tif ( isFlexLayout ) {\n\t\t\tsetAttributes( {\n\t\t\t\tstyle: {\n\t\t\t\t\t...blockStyle,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\tflexSize: newHeight,\n\t\t\t\t\t\tselfStretch: 'fixed',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\tsetAttributes( { height: newHeight } );\n\t\tsetTemporaryHeight( null );\n\t};\n\n\tconst handleOnHorizontalResizeStop = ( newWidth ) => {\n\t\tonResizeStop();\n\n\t\tif ( isFlexLayout ) {\n\t\t\tsetAttributes( {\n\t\t\t\tstyle: {\n\t\t\t\t\t...blockStyle,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\tflexSize: newWidth,\n\t\t\t\t\t\tselfStretch: 'fixed',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\tsetAttributes( { width: newWidth } );\n\t\tsetTemporaryWidth( null );\n\t};\n\n\tconst getHeightForVerticalBlocks = () => {\n\t\tif ( isFlexLayout ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn temporaryHeight || getSpacingPresetCssVar( height ) || undefined;\n\t};\n\n\tconst getWidthForHorizontalBlocks = () => {\n\t\tif ( isFlexLayout ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn temporaryWidth || getSpacingPresetCssVar( width ) || undefined;\n\t};\n\n\tconst sizeConditionalOnOrientation =\n\t\tinheritedOrientation === 'horizontal'\n\t\t\t? temporaryWidth || flexSize\n\t\t\t: temporaryHeight || flexSize;\n\n\tconst style = {\n\t\theight:\n\t\t\tinheritedOrientation === 'horizontal'\n\t\t\t\t? 24\n\t\t\t\t: getHeightForVerticalBlocks(),\n\t\twidth:\n\t\t\tinheritedOrientation === 'horizontal'\n\t\t\t\t? getWidthForHorizontalBlocks()\n\t\t\t\t: undefined,\n\t\t// In vertical flex containers, the spacer shrinks to nothing without a minimum width.\n\t\tminWidth:\n\t\t\tinheritedOrientation === 'vertical' && isFlexLayout\n\t\t\t\t? 48\n\t\t\t\t: undefined,\n\t\t// Add flex-basis so temporary sizes are respected.\n\t\tflexBasis: isFlexLayout ? sizeConditionalOnOrientation : undefined,\n\t\t// Remove flex-grow when resizing.\n\t\tflexGrow: isFlexLayout && isResizing ? 0 : undefined,\n\t};\n\n\tconst resizableBoxWithOrientation = ( blockOrientation ) => {\n\t\tif ( blockOrientation === 'horizontal' ) {\n\t\t\treturn (\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tminWidth={ MIN_SPACER_SIZE }\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: true,\n\t\t\t\t\t\tbottom: false,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryWidth }\n\t\t\t\t\tonResizeStop={ handleOnHorizontalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tminHeight={ MIN_SPACER_SIZE }\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: false,\n\t\t\t\t\t\tbottom: true,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryHeight }\n\t\t\t\t\tonResizeStop={ handleOnVerticalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tisFlexLayout &&\n\t\t\tselfStretch !== 'fill' &&\n\t\t\tselfStretch !== 'fit' &&\n\t\t\t! flexSize\n\t\t) {\n\t\t\tif ( inheritedOrientation === 'horizontal' ) {\n\t\t\t\t// If spacer is moving from a vertical container to a horizontal container,\n\t\t\t\t// it might not have width but have height instead.\n\t\t\t\tconst newSize =\n\t\t\t\t\tgetCustomValueFromPreset( width, spacingSizes ) ||\n\t\t\t\t\tgetCustomValueFromPreset( height, spacingSizes ) ||\n\t\t\t\t\t'100px';\n\t\t\t\tsetAttributes( {\n\t\t\t\t\twidth: '0px',\n\t\t\t\t\tstyle: {\n\t\t\t\t\t\t...blockStyle,\n\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\tflexSize: newSize,\n\t\t\t\t\t\t\tselfStretch: 'fixed',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst newSize =\n\t\t\t\t\tgetCustomValueFromPreset( height, spacingSizes ) ||\n\t\t\t\t\tgetCustomValueFromPreset( width, spacingSizes ) ||\n\t\t\t\t\t'100px';\n\t\t\t\tsetAttributes( {\n\t\t\t\t\theight: '0px',\n\t\t\t\t\tstyle: {\n\t\t\t\t\t\t...blockStyle,\n\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\tflexSize: newSize,\n\t\t\t\t\t\t\tselfStretch: 'fixed',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t} else if (\n\t\t\tisFlexLayout &&\n\t\t\t( selfStretch === 'fill' || selfStretch === 'fit' )\n\t\t) {\n\t\t\tif ( inheritedOrientation === 'horizontal' ) {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\twidth: undefined,\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\theight: undefined,\n\t\t\t\t} );\n\t\t\t}\n\t\t} else if ( ! isFlexLayout && ( selfStretch || flexSize ) ) {\n\t\t\tif ( inheritedOrientation === 'horizontal' ) {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\twidth: flexSize,\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\theight: flexSize,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tsetAttributes( {\n\t\t\t\tstyle: {\n\t\t\t\t\t...blockStyle,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\t...layout,\n\t\t\t\t\t\tflexSize: undefined,\n\t\t\t\t\t\tselfStretch: undefined,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tblockStyle,\n\t\tflexSize,\n\t\theight,\n\t\tinheritedOrientation,\n\t\tisFlexLayout,\n\t\tlayout,\n\t\tselfStretch,\n\t\tsetAttributes,\n\t\tspacingSizes,\n\t\twidth,\n\t] );\n\n\treturn (\n\t\t<>\n\t\t\t<View\n\t\t\t\t{ ...useBlockProps( {\n\t\t\t\t\tstyle,\n\t\t\t\t\tclassName: classnames( className, {\n\t\t\t\t\t\t'custom-sizes-disabled': disableCustomSpacingSizes,\n\t\t\t\t\t} ),\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ resizableBoxWithOrientation( inheritedOrientation ) }\n\t\t\t</View>\n\t\t\t{ ! isFlexLayout && (\n\t\t\t\t<SpacerControls\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\theight={ temporaryHeight || height }\n\t\t\t\t\twidth={ temporaryWidth || width }\n\t\t\t\t\torientation={ inheritedOrientation }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport default SpacerEdit;\n"]}
|
|
@@ -3,7 +3,7 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { useBlockProps } from '@wordpress/block-editor';
|
|
6
|
+
import { useBlockProps, getSpacingPresetCssVar } from '@wordpress/block-editor';
|
|
7
7
|
export default function save(_ref) {
|
|
8
8
|
let {
|
|
9
9
|
attributes: {
|
|
@@ -13,8 +13,8 @@ export default function save(_ref) {
|
|
|
13
13
|
} = _ref;
|
|
14
14
|
return createElement("div", useBlockProps.save({
|
|
15
15
|
style: {
|
|
16
|
-
height,
|
|
17
|
-
width
|
|
16
|
+
height: getSpacingPresetCssVar(height),
|
|
17
|
+
width: getSpacingPresetCssVar(width)
|
|
18
18
|
},
|
|
19
19
|
'aria-hidden': true
|
|
20
20
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/spacer/save.js"],"names":["useBlockProps","save","attributes","height","width","style"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/spacer/save.js"],"names":["useBlockProps","getSpacingPresetCssVar","save","attributes","height","width","style"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,sBAAxB,QAAsD,yBAAtD;AAEA,eAAe,SAASC,IAAT,OAAmD;AAAA,MAApC;AAAEC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV;AAAd,GAAoC;AACjE,SACC,qBACML,aAAa,CAACE,IAAd,CAAoB;AACxBI,IAAAA,KAAK,EAAE;AACNF,MAAAA,MAAM,EAAEH,sBAAsB,CAAEG,MAAF,CADxB;AAENC,MAAAA,KAAK,EAAEJ,sBAAsB,CAAEI,KAAF;AAFvB,KADiB;AAKxB,mBAAe;AALS,GAApB,CADN,CADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useBlockProps, getSpacingPresetCssVar } from '@wordpress/block-editor';\n\nexport default function save( { attributes: { height, width } } ) {\n\treturn (\n\t\t<div\n\t\t\t{ ...useBlockProps.save( {\n\t\t\t\tstyle: {\n\t\t\t\t\theight: getSpacingPresetCssVar( height ),\n\t\t\t\t\twidth: getSpacingPresetCssVar( width ),\n\t\t\t\t},\n\t\t\t\t'aria-hidden': true,\n\t\t\t} ) }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { mapValues } from 'lodash';
|
|
5
1
|
const INHERITED_COLUMN_ATTRIBUTES = ['align'];
|
|
6
2
|
/**
|
|
7
3
|
* Creates a table state.
|
|
@@ -95,12 +91,14 @@ export function updateSelectedCell(state, selection, updateCell) {
|
|
|
95
91
|
sectionName: selectionSectionName,
|
|
96
92
|
rowIndex: selectionRowIndex
|
|
97
93
|
} = selection;
|
|
98
|
-
return
|
|
94
|
+
return Object.fromEntries(Object.entries(tableSections).map(_ref3 => {
|
|
95
|
+
let [sectionName, section] = _ref3;
|
|
96
|
+
|
|
99
97
|
if (selectionSectionName && selectionSectionName !== sectionName) {
|
|
100
|
-
return section;
|
|
98
|
+
return [sectionName, section];
|
|
101
99
|
}
|
|
102
100
|
|
|
103
|
-
return section.map((row, rowIndex) => {
|
|
101
|
+
return [sectionName, section.map((row, rowIndex) => {
|
|
104
102
|
if (selectionRowIndex && selectionRowIndex !== rowIndex) {
|
|
105
103
|
return row;
|
|
106
104
|
}
|
|
@@ -120,8 +118,8 @@ export function updateSelectedCell(state, selection, updateCell) {
|
|
|
120
118
|
return updateCell(cellAttributes);
|
|
121
119
|
})
|
|
122
120
|
};
|
|
123
|
-
});
|
|
124
|
-
});
|
|
121
|
+
})];
|
|
122
|
+
}));
|
|
125
123
|
}
|
|
126
124
|
/**
|
|
127
125
|
* Returns whether the cell at `cellLocation` is included in the selection `selection`.
|
|
@@ -157,14 +155,14 @@ export function isCellSelected(cellLocation, selection) {
|
|
|
157
155
|
* @return {Object} New table state.
|
|
158
156
|
*/
|
|
159
157
|
|
|
160
|
-
export function insertRow(state,
|
|
158
|
+
export function insertRow(state, _ref4) {
|
|
161
159
|
var _firstRow$cells;
|
|
162
160
|
|
|
163
161
|
let {
|
|
164
162
|
sectionName,
|
|
165
163
|
rowIndex,
|
|
166
164
|
columnCount
|
|
167
|
-
} =
|
|
165
|
+
} = _ref4;
|
|
168
166
|
const firstRow = getFirstRow(state);
|
|
169
167
|
const cellCount = columnCount === undefined ? firstRow === null || firstRow === void 0 ? void 0 : (_firstRow$cells = firstRow.cells) === null || _firstRow$cells === void 0 ? void 0 : _firstRow$cells.length : columnCount; // Bail early if the function cannot determine how many cells to add.
|
|
170
168
|
|
|
@@ -180,8 +178,8 @@ export function insertRow(state, _ref3) {
|
|
|
180
178
|
var _firstRow$cells$index, _firstRow$cells2;
|
|
181
179
|
|
|
182
180
|
const firstCellInColumn = (_firstRow$cells$index = firstRow === null || firstRow === void 0 ? void 0 : (_firstRow$cells2 = firstRow.cells) === null || _firstRow$cells2 === void 0 ? void 0 : _firstRow$cells2[index]) !== null && _firstRow$cells$index !== void 0 ? _firstRow$cells$index : {};
|
|
183
|
-
const inheritedAttributes = Object.fromEntries(Object.entries(firstCellInColumn).filter(
|
|
184
|
-
let [key] =
|
|
181
|
+
const inheritedAttributes = Object.fromEntries(Object.entries(firstCellInColumn).filter(_ref5 => {
|
|
182
|
+
let [key] = _ref5;
|
|
185
183
|
return INHERITED_COLUMN_ATTRIBUTES.includes(key);
|
|
186
184
|
}));
|
|
187
185
|
return { ...inheritedAttributes,
|
|
@@ -203,11 +201,11 @@ export function insertRow(state, _ref3) {
|
|
|
203
201
|
* @return {Object} New table state.
|
|
204
202
|
*/
|
|
205
203
|
|
|
206
|
-
export function deleteRow(state,
|
|
204
|
+
export function deleteRow(state, _ref6) {
|
|
207
205
|
let {
|
|
208
206
|
sectionName,
|
|
209
207
|
rowIndex
|
|
210
|
-
} =
|
|
208
|
+
} = _ref6;
|
|
211
209
|
return {
|
|
212
210
|
[sectionName]: state[sectionName].filter((row, index) => index !== rowIndex)
|
|
213
211
|
};
|
|
@@ -222,21 +220,23 @@ export function deleteRow(state, _ref5) {
|
|
|
222
220
|
* @return {Object} New table state.
|
|
223
221
|
*/
|
|
224
222
|
|
|
225
|
-
export function insertColumn(state,
|
|
223
|
+
export function insertColumn(state, _ref7) {
|
|
226
224
|
let {
|
|
227
225
|
columnIndex
|
|
228
|
-
} =
|
|
229
|
-
const tableSections = Object.fromEntries(Object.entries(state).filter(
|
|
230
|
-
let [key] =
|
|
226
|
+
} = _ref7;
|
|
227
|
+
const tableSections = Object.fromEntries(Object.entries(state).filter(_ref8 => {
|
|
228
|
+
let [key] = _ref8;
|
|
231
229
|
return ['head', 'body', 'foot'].includes(key);
|
|
232
230
|
}));
|
|
233
|
-
return
|
|
231
|
+
return Object.fromEntries(Object.entries(tableSections).map(_ref9 => {
|
|
232
|
+
let [sectionName, section] = _ref9;
|
|
233
|
+
|
|
234
234
|
// Bail early if the table section is empty.
|
|
235
235
|
if (isEmptyTableSection(section)) {
|
|
236
|
-
return section;
|
|
236
|
+
return [sectionName, section];
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
return section.map(row => {
|
|
239
|
+
return [sectionName, section.map(row => {
|
|
240
240
|
// Bail early if the row is empty or it's an attempt to insert past
|
|
241
241
|
// the last possible index of the array.
|
|
242
242
|
if (isEmptyRow(row) || row.cells.length < columnIndex) {
|
|
@@ -249,8 +249,8 @@ export function insertColumn(state, _ref6) {
|
|
|
249
249
|
tag: sectionName === 'head' ? 'th' : 'td'
|
|
250
250
|
}, ...row.cells.slice(columnIndex)]
|
|
251
251
|
};
|
|
252
|
-
});
|
|
253
|
-
});
|
|
252
|
+
})];
|
|
253
|
+
}));
|
|
254
254
|
}
|
|
255
255
|
/**
|
|
256
256
|
* Deletes a column from the table state.
|
|
@@ -262,24 +262,26 @@ export function insertColumn(state, _ref6) {
|
|
|
262
262
|
* @return {Object} New table state.
|
|
263
263
|
*/
|
|
264
264
|
|
|
265
|
-
export function deleteColumn(state,
|
|
265
|
+
export function deleteColumn(state, _ref10) {
|
|
266
266
|
let {
|
|
267
267
|
columnIndex
|
|
268
|
-
} =
|
|
269
|
-
const tableSections = Object.fromEntries(Object.entries(state).filter(
|
|
270
|
-
let [key] =
|
|
268
|
+
} = _ref10;
|
|
269
|
+
const tableSections = Object.fromEntries(Object.entries(state).filter(_ref11 => {
|
|
270
|
+
let [key] = _ref11;
|
|
271
271
|
return ['head', 'body', 'foot'].includes(key);
|
|
272
272
|
}));
|
|
273
|
-
return
|
|
273
|
+
return Object.fromEntries(Object.entries(tableSections).map(_ref12 => {
|
|
274
|
+
let [sectionName, section] = _ref12;
|
|
275
|
+
|
|
274
276
|
// Bail early if the table section is empty.
|
|
275
277
|
if (isEmptyTableSection(section)) {
|
|
276
|
-
return section;
|
|
278
|
+
return [sectionName, section];
|
|
277
279
|
}
|
|
278
280
|
|
|
279
|
-
return section.map(row => ({
|
|
281
|
+
return [sectionName, section.map(row => ({
|
|
280
282
|
cells: row.cells.length >= columnIndex ? row.cells.filter((cell, index) => index !== columnIndex) : row.cells
|
|
281
|
-
})).filter(row => row.cells.length);
|
|
282
|
-
});
|
|
283
|
+
})).filter(row => row.cells.length)];
|
|
284
|
+
}));
|
|
283
285
|
}
|
|
284
286
|
/**
|
|
285
287
|
* Toggles the existence of a section.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/table/state.js"],"names":["mapValues","INHERITED_COLUMN_ATTRIBUTES","createTable","rowCount","columnCount","body","Array","from","length","map","cells","content","tag","getFirstRow","state","isEmptyTableSection","head","foot","getCellAttribute","cellLocation","attributeName","sectionName","rowIndex","columnIndex","updateSelectedCell","selection","updateCell","tableSections","Object","fromEntries","entries","filter","key","includes","selectionSectionName","selectionRowIndex","section","row","cellAttributes","isCellSelected","type","insertRow","firstRow","cellCount","undefined","slice","_","index","firstCellInColumn","inheritedAttributes","deleteRow","insertColumn","isEmptyRow","deleteColumn","cell","toggleSection","every"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA,MAAMC,2BAA2B,GAAG,CAAE,OAAF,CAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,OAAkD;AAAA,MAA5B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;AACxD,SAAO;AACNC,IAAAA,IAAI,EAAEC,KAAK,CAACC,IAAN,CAAY;AAAEC,MAAAA,MAAM,EAAEL;AAAV,KAAZ,EAAmCM,GAAnC,CAAwC,OAAQ;AACrDC,MAAAA,KAAK,EAAEJ,KAAK,CAACC,IAAN,CAAY;AAAEC,QAAAA,MAAM,EAAEJ;AAAV,OAAZ,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AAJ,IAAa2B,GAAG,CAAC3B,KAAJ,CAAUF,MAA3B,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { mapValues } from 'lodash';\n\nconst INHERITED_COLUMN_ATTRIBUTES = [ 'align' ];\n\n/**\n * Creates a table state.\n *\n * @param {Object} options\n * @param {number} options.rowCount Row count for the table to create.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function createTable( { rowCount, columnCount } ) {\n\treturn {\n\t\tbody: Array.from( { length: rowCount } ).map( () => ( {\n\t\t\tcells: Array.from( { length: columnCount } ).map( () => ( {\n\t\t\t\tcontent: '',\n\t\t\t\ttag: 'td',\n\t\t\t} ) ),\n\t\t} ) ),\n\t};\n}\n\n/**\n * Returns the first row in the table.\n *\n * @param {Object} state Current table state.\n *\n * @return {Object | undefined} The first table row.\n */\nexport function getFirstRow( state ) {\n\tif ( ! isEmptyTableSection( state.head ) ) {\n\t\treturn state.head[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.body ) ) {\n\t\treturn state.body[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.foot ) ) {\n\t\treturn state.foot[ 0 ];\n\t}\n}\n\n/**\n * Gets an attribute for a cell.\n *\n * @param {Object} state Current table state.\n * @param {Object} cellLocation The location of the cell\n * @param {string} attributeName The name of the attribute to get the value of.\n *\n * @return {*} The attribute value.\n */\nexport function getCellAttribute( state, cellLocation, attributeName ) {\n\tconst { sectionName, rowIndex, columnIndex } = cellLocation;\n\treturn state[ sectionName ]?.[ rowIndex ]?.cells?.[ columnIndex ]?.[\n\t\tattributeName\n\t];\n}\n\n/**\n * Returns updated cell attributes after applying the `updateCell` function to the selection.\n *\n * @param {Object} state The block attributes.\n * @param {Object} selection The selection of cells to update.\n * @param {Function} updateCell A function to update the selected cell attributes.\n *\n * @return {Object} New table state including the updated cells.\n */\nexport function updateSelectedCell( state, selection, updateCell ) {\n\tif ( ! selection ) {\n\t\treturn state;\n\t}\n\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\tconst { sectionName: selectionSectionName, rowIndex: selectionRowIndex } =\n\t\tselection;\n\n\treturn mapValues( tableSections, ( section, sectionName ) => {\n\t\tif ( selectionSectionName && selectionSectionName !== sectionName ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section.map( ( row, rowIndex ) => {\n\t\t\tif ( selectionRowIndex && selectionRowIndex !== rowIndex ) {\n\t\t\t\treturn row;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcells: row.cells.map( ( cellAttributes, columnIndex ) => {\n\t\t\t\t\tconst cellLocation = {\n\t\t\t\t\t\tsectionName,\n\t\t\t\t\t\tcolumnIndex,\n\t\t\t\t\t\trowIndex,\n\t\t\t\t\t};\n\n\t\t\t\t\tif ( ! isCellSelected( cellLocation, selection ) ) {\n\t\t\t\t\t\treturn cellAttributes;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn updateCell( cellAttributes );\n\t\t\t\t} ),\n\t\t\t};\n\t\t} );\n\t} );\n}\n\n/**\n * Returns whether the cell at `cellLocation` is included in the selection `selection`.\n *\n * @param {Object} cellLocation An object containing cell location properties.\n * @param {Object} selection An object containing selection properties.\n *\n * @return {boolean} True if the cell is selected, false otherwise.\n */\nexport function isCellSelected( cellLocation, selection ) {\n\tif ( ! cellLocation || ! selection ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection.type ) {\n\t\tcase 'column':\n\t\t\treturn (\n\t\t\t\tselection.type === 'column' &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex\n\t\t\t);\n\t\tcase 'cell':\n\t\t\treturn (\n\t\t\t\tselection.type === 'cell' &&\n\t\t\t\tcellLocation.sectionName === selection.sectionName &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex &&\n\t\t\t\tcellLocation.rowIndex === selection.rowIndex\n\t\t\t);\n\t}\n}\n\n/**\n * Inserts a row in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to insert the row.\n * @param {number} options.rowIndex Row index at which to insert the row.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function insertRow( state, { sectionName, rowIndex, columnCount } ) {\n\tconst firstRow = getFirstRow( state );\n\tconst cellCount =\n\t\tcolumnCount === undefined ? firstRow?.cells?.length : columnCount;\n\n\t// Bail early if the function cannot determine how many cells to add.\n\tif ( ! cellCount ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t[ sectionName ]: [\n\t\t\t...state[ sectionName ].slice( 0, rowIndex ),\n\t\t\t{\n\t\t\t\tcells: Array.from( { length: cellCount } ).map(\n\t\t\t\t\t( _, index ) => {\n\t\t\t\t\t\tconst firstCellInColumn =\n\t\t\t\t\t\t\tfirstRow?.cells?.[ index ] ?? {};\n\n\t\t\t\t\t\tconst inheritedAttributes = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( firstCellInColumn ).filter(\n\t\t\t\t\t\t\t\t( [ key ] ) =>\n\t\t\t\t\t\t\t\t\tINHERITED_COLUMN_ATTRIBUTES.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...inheritedAttributes,\n\t\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\t...state[ sectionName ].slice( rowIndex ),\n\t\t],\n\t};\n}\n\n/**\n * Deletes a row from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to delete the row.\n * @param {number} options.rowIndex Row index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteRow( state, { sectionName, rowIndex } ) {\n\treturn {\n\t\t[ sectionName ]: state[ sectionName ].filter(\n\t\t\t( row, index ) => index !== rowIndex\n\t\t),\n\t};\n}\n\n/**\n * Inserts a column in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index at which to insert the column.\n *\n * @return {Object} New table state.\n */\nexport function insertColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn mapValues( tableSections, ( section, sectionName ) => {\n\t\t// Bail early if the table section is empty.\n\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section.map( ( row ) => {\n\t\t\t// Bail early if the row is empty or it's an attempt to insert past\n\t\t\t// the last possible index of the array.\n\t\t\tif ( isEmptyRow( row ) || row.cells.length < columnIndex ) {\n\t\t\t\treturn row;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcells: [\n\t\t\t\t\t...row.cells.slice( 0, columnIndex ),\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t},\n\t\t\t\t\t...row.cells.slice( columnIndex ),\n\t\t\t\t],\n\t\t\t};\n\t\t} );\n\t} );\n}\n\n/**\n * Deletes a column from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn mapValues( tableSections, ( section ) => {\n\t\t// Bail early if the table section is empty.\n\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section\n\t\t\t.map( ( row ) => ( {\n\t\t\t\tcells:\n\t\t\t\t\trow.cells.length >= columnIndex\n\t\t\t\t\t\t? row.cells.filter(\n\t\t\t\t\t\t\t\t( cell, index ) => index !== columnIndex\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: row.cells,\n\t\t\t} ) )\n\t\t\t.filter( ( row ) => row.cells.length );\n\t} );\n}\n\n/**\n * Toggles the existence of a section.\n *\n * @param {Object} state Current table state.\n * @param {string} sectionName Name of the section to toggle.\n *\n * @return {Object} New table state.\n */\nexport function toggleSection( state, sectionName ) {\n\t// Section exists, replace it with an empty row to remove it.\n\tif ( ! isEmptyTableSection( state[ sectionName ] ) ) {\n\t\treturn { [ sectionName ]: [] };\n\t}\n\n\t// Get the length of the first row of the body to use when creating the header.\n\tconst columnCount = state.body?.[ 0 ]?.cells?.length ?? 1;\n\n\t// Section doesn't exist, insert an empty row to create the section.\n\treturn insertRow( state, { sectionName, rowIndex: 0, columnCount } );\n}\n\n/**\n * Determines whether a table section is empty.\n *\n * @param {Object} section Table section state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyTableSection( section ) {\n\treturn ! section || ! section.length || section.every( isEmptyRow );\n}\n\n/**\n * Determines whether a table row is empty.\n *\n * @param {Object} row Table row state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyRow( row ) {\n\treturn ! ( row.cells && row.cells.length );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/table/state.js"],"names":["INHERITED_COLUMN_ATTRIBUTES","createTable","rowCount","columnCount","body","Array","from","length","map","cells","content","tag","getFirstRow","state","isEmptyTableSection","head","foot","getCellAttribute","cellLocation","attributeName","sectionName","rowIndex","columnIndex","updateSelectedCell","selection","updateCell","tableSections","Object","fromEntries","entries","filter","key","includes","selectionSectionName","selectionRowIndex","section","row","cellAttributes","isCellSelected","type","insertRow","firstRow","cellCount","undefined","slice","_","index","firstCellInColumn","inheritedAttributes","deleteRow","insertColumn","isEmptyRow","deleteColumn","cell","toggleSection","every"],"mappings":"AAAA,MAAMA,2B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WAA/B,EAA6C;AAAA;;AACnD;AACA,MAAK,CAAEN,mBAAmB,CAAED,KAAK,CAAEO,WAAF,CAAP,CAA1B,EAAqD;AACpD,WAAO;AAAE,OAAEA,WAAF,GAAiB;AAAnB,KAAP;AACA,GAJkD,CAMnD;;;AACA,QAAMjB,WAAW,2CAAGU,KAAK,CAACT,IAAT,gEAAG,YAAc,CAAd,CAAH,uEAAG,aAAmBK,KAAtB,uDAAG,mBAA0BF,MAA7B,yEAAuC,CAAxD,CAPmD,CASnD;;AACA,SAAOiC,SAAS,CAAE3B,KAAF,EAAS;AAAEO,IAAAA,WAAF;AAAeC,IAAAA,QAAQ,EAAE,CAAzB;AAA4BlB,IAAAA;AAA5B,GAAT,CAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASW,mBAAT,CAA8BqB,OAA9B,EAAwC;AAC9C,SAAO,CAAEA,OAAF,IAAa,CAAEA,OAAO,CAAC5B,MAAvB,IAAiC4B,OAAO,CAACoB,KAAR,CAAeJ,UAAf,CAAxC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASA,UAAT,CAAqBf,GAArB,EAA2B;AACjC,SAAO,EAAIA,GAAG,CAAC3B,KAAJ,IAAa2B,GAAG,CAAC3B,KAAJ,CAAUF,MAA3B,CAAP;AACA","sourcesContent":["const INHERITED_COLUMN_ATTRIBUTES = [ 'align' ];\n\n/**\n * Creates a table state.\n *\n * @param {Object} options\n * @param {number} options.rowCount Row count for the table to create.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function createTable( { rowCount, columnCount } ) {\n\treturn {\n\t\tbody: Array.from( { length: rowCount } ).map( () => ( {\n\t\t\tcells: Array.from( { length: columnCount } ).map( () => ( {\n\t\t\t\tcontent: '',\n\t\t\t\ttag: 'td',\n\t\t\t} ) ),\n\t\t} ) ),\n\t};\n}\n\n/**\n * Returns the first row in the table.\n *\n * @param {Object} state Current table state.\n *\n * @return {Object | undefined} The first table row.\n */\nexport function getFirstRow( state ) {\n\tif ( ! isEmptyTableSection( state.head ) ) {\n\t\treturn state.head[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.body ) ) {\n\t\treturn state.body[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.foot ) ) {\n\t\treturn state.foot[ 0 ];\n\t}\n}\n\n/**\n * Gets an attribute for a cell.\n *\n * @param {Object} state Current table state.\n * @param {Object} cellLocation The location of the cell\n * @param {string} attributeName The name of the attribute to get the value of.\n *\n * @return {*} The attribute value.\n */\nexport function getCellAttribute( state, cellLocation, attributeName ) {\n\tconst { sectionName, rowIndex, columnIndex } = cellLocation;\n\treturn state[ sectionName ]?.[ rowIndex ]?.cells?.[ columnIndex ]?.[\n\t\tattributeName\n\t];\n}\n\n/**\n * Returns updated cell attributes after applying the `updateCell` function to the selection.\n *\n * @param {Object} state The block attributes.\n * @param {Object} selection The selection of cells to update.\n * @param {Function} updateCell A function to update the selected cell attributes.\n *\n * @return {Object} New table state including the updated cells.\n */\nexport function updateSelectedCell( state, selection, updateCell ) {\n\tif ( ! selection ) {\n\t\treturn state;\n\t}\n\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\tconst { sectionName: selectionSectionName, rowIndex: selectionRowIndex } =\n\t\tselection;\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\tif (\n\t\t\t\tselectionSectionName &&\n\t\t\t\tselectionSectionName !== sectionName\n\t\t\t) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection.map( ( row, rowIndex ) => {\n\t\t\t\t\tif ( selectionRowIndex && selectionRowIndex !== rowIndex ) {\n\t\t\t\t\t\treturn row;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcells: row.cells.map(\n\t\t\t\t\t\t\t( cellAttributes, columnIndex ) => {\n\t\t\t\t\t\t\t\tconst cellLocation = {\n\t\t\t\t\t\t\t\t\tsectionName,\n\t\t\t\t\t\t\t\t\tcolumnIndex,\n\t\t\t\t\t\t\t\t\trowIndex,\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! isCellSelected( cellLocation, selection )\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn cellAttributes;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn updateCell( cellAttributes );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t\t];\n\t\t} )\n\t);\n}\n\n/**\n * Returns whether the cell at `cellLocation` is included in the selection `selection`.\n *\n * @param {Object} cellLocation An object containing cell location properties.\n * @param {Object} selection An object containing selection properties.\n *\n * @return {boolean} True if the cell is selected, false otherwise.\n */\nexport function isCellSelected( cellLocation, selection ) {\n\tif ( ! cellLocation || ! selection ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection.type ) {\n\t\tcase 'column':\n\t\t\treturn (\n\t\t\t\tselection.type === 'column' &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex\n\t\t\t);\n\t\tcase 'cell':\n\t\t\treturn (\n\t\t\t\tselection.type === 'cell' &&\n\t\t\t\tcellLocation.sectionName === selection.sectionName &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex &&\n\t\t\t\tcellLocation.rowIndex === selection.rowIndex\n\t\t\t);\n\t}\n}\n\n/**\n * Inserts a row in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to insert the row.\n * @param {number} options.rowIndex Row index at which to insert the row.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function insertRow( state, { sectionName, rowIndex, columnCount } ) {\n\tconst firstRow = getFirstRow( state );\n\tconst cellCount =\n\t\tcolumnCount === undefined ? firstRow?.cells?.length : columnCount;\n\n\t// Bail early if the function cannot determine how many cells to add.\n\tif ( ! cellCount ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t[ sectionName ]: [\n\t\t\t...state[ sectionName ].slice( 0, rowIndex ),\n\t\t\t{\n\t\t\t\tcells: Array.from( { length: cellCount } ).map(\n\t\t\t\t\t( _, index ) => {\n\t\t\t\t\t\tconst firstCellInColumn =\n\t\t\t\t\t\t\tfirstRow?.cells?.[ index ] ?? {};\n\n\t\t\t\t\t\tconst inheritedAttributes = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( firstCellInColumn ).filter(\n\t\t\t\t\t\t\t\t( [ key ] ) =>\n\t\t\t\t\t\t\t\t\tINHERITED_COLUMN_ATTRIBUTES.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...inheritedAttributes,\n\t\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\t...state[ sectionName ].slice( rowIndex ),\n\t\t],\n\t};\n}\n\n/**\n * Deletes a row from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to delete the row.\n * @param {number} options.rowIndex Row index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteRow( state, { sectionName, rowIndex } ) {\n\treturn {\n\t\t[ sectionName ]: state[ sectionName ].filter(\n\t\t\t( row, index ) => index !== rowIndex\n\t\t),\n\t};\n}\n\n/**\n * Inserts a column in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index at which to insert the column.\n *\n * @return {Object} New table state.\n */\nexport function insertColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\t// Bail early if the table section is empty.\n\t\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection.map( ( row ) => {\n\t\t\t\t\t// Bail early if the row is empty or it's an attempt to insert past\n\t\t\t\t\t// the last possible index of the array.\n\t\t\t\t\tif ( isEmptyRow( row ) || row.cells.length < columnIndex ) {\n\t\t\t\t\t\treturn row;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcells: [\n\t\t\t\t\t\t\t...row.cells.slice( 0, columnIndex ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...row.cells.slice( columnIndex ),\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t\t];\n\t\t} )\n\t);\n}\n\n/**\n * Deletes a column from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\t// Bail early if the table section is empty.\n\t\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection\n\t\t\t\t\t.map( ( row ) => ( {\n\t\t\t\t\t\tcells:\n\t\t\t\t\t\t\trow.cells.length >= columnIndex\n\t\t\t\t\t\t\t\t? row.cells.filter(\n\t\t\t\t\t\t\t\t\t\t( cell, index ) => index !== columnIndex\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: row.cells,\n\t\t\t\t\t} ) )\n\t\t\t\t\t.filter( ( row ) => row.cells.length ),\n\t\t\t];\n\t\t} )\n\t);\n}\n\n/**\n * Toggles the existence of a section.\n *\n * @param {Object} state Current table state.\n * @param {string} sectionName Name of the section to toggle.\n *\n * @return {Object} New table state.\n */\nexport function toggleSection( state, sectionName ) {\n\t// Section exists, replace it with an empty row to remove it.\n\tif ( ! isEmptyTableSection( state[ sectionName ] ) ) {\n\t\treturn { [ sectionName ]: [] };\n\t}\n\n\t// Get the length of the first row of the body to use when creating the header.\n\tconst columnCount = state.body?.[ 0 ]?.cells?.length ?? 1;\n\n\t// Section doesn't exist, insert an empty row to create the section.\n\treturn insertRow( state, { sectionName, rowIndex: 0, columnCount } );\n}\n\n/**\n * Determines whether a table section is empty.\n *\n * @param {Object} section Table section state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyTableSection( section ) {\n\treturn ! section || ! section.length || section.every( isEmptyRow );\n}\n\n/**\n * Determines whether a table row is empty.\n *\n * @param {Object} row Table row state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyRow( row ) {\n\treturn ! ( row.cells && row.cells.length );\n}\n"]}
|
|
@@ -128,7 +128,8 @@ export default function TemplatePartEdit(_ref) {
|
|
|
128
128
|
overlayClassName: "block-editor-template-part__selection-modal",
|
|
129
129
|
title: sprintf( // Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
130
130
|
__('Choose a %s'), areaObject.label.toLowerCase()),
|
|
131
|
-
onRequestClose: () => setIsTemplatePartSelectionOpen(false)
|
|
131
|
+
onRequestClose: () => setIsTemplatePartSelectionOpen(false),
|
|
132
|
+
isFullScreen: true
|
|
132
133
|
}, createElement(TemplatePartSelectionModal, {
|
|
133
134
|
templatePartId: templatePartId,
|
|
134
135
|
clientId: clientId,
|