@wordpress/block-library 9.3.0 → 9.5.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/avatar/edit.js +1 -0
- package/build/avatar/edit.js.map +1 -1
- package/build/block/edit.js +38 -23
- package/build/block/edit.js.map +1 -1
- package/build/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/buttons/index.js +26 -0
- package/build/buttons/index.js.map +1 -1
- package/build/categories/edit.js +20 -3
- package/build/categories/edit.js.map +1 -1
- package/build/categories/index.js +20 -0
- package/build/categories/index.js.map +1 -1
- package/build/column/edit.js +2 -2
- package/build/column/edit.js.map +1 -1
- package/build/column/index.js +2 -0
- package/build/column/index.js.map +1 -1
- package/build/columns/index.js +2 -2
- package/build/columns/index.js.map +1 -1
- package/build/comment-template/index.js +12 -0
- package/build/comment-template/index.js.map +1 -1
- package/build/comments-title/deprecated.js +3 -0
- package/build/comments-title/deprecated.js.map +1 -1
- package/build/comments-title/edit.js +3 -1
- package/build/comments-title/edit.js.map +1 -1
- package/build/comments-title/index.js +3 -0
- package/build/comments-title/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +2 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/details/edit.js +1 -0
- package/build/details/edit.js.map +1 -1
- package/build/embed/variations.js +39 -34
- package/build/embed/variations.js.map +1 -1
- package/build/footnotes/index.js +1 -1
- package/build/footnotes/index.js.map +1 -1
- package/build/form/edit.js +4 -4
- package/build/form/edit.js.map +1 -1
- package/build/form-input/edit.js +3 -0
- package/build/form-input/edit.js.map +1 -1
- package/build/gallery/edit.js +42 -8
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gap-styles.js +1 -9
- package/build/gallery/gap-styles.js.map +1 -1
- package/build/gallery/index.js +10 -0
- package/build/gallery/index.js.map +1 -1
- package/build/gallery/use-image-sizes.js +2 -2
- package/build/gallery/use-image-sizes.js.map +1 -1
- package/build/group/deprecated.js +2 -5
- package/build/group/deprecated.js.map +1 -1
- package/build/group/index.js +27 -30
- package/build/group/index.js.map +1 -1
- package/build/group/variations.js +51 -3
- package/build/group/variations.js.map +1 -1
- package/build/heading/edit.js +2 -0
- package/build/heading/edit.js.map +1 -1
- package/build/heading/index.js +17 -1
- package/build/heading/index.js.map +1 -1
- package/build/image/edit.js +1 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +24 -11
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +3 -0
- package/build/image/index.js.map +1 -1
- package/build/image/view.js +65 -49
- package/build/image/view.js.map +1 -1
- package/build/latest-comments/index.js +9 -0
- package/build/latest-comments/index.js.map +1 -1
- package/build/latest-posts/edit.js +1 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/list/edit.js +3 -3
- package/build/list/edit.js.map +1 -1
- package/build/list/index.js +1 -1
- package/build/list/ordered-list-settings.js +19 -17
- package/build/list/ordered-list-settings.js.map +1 -1
- package/build/list-item/edit.js +2 -2
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/index.js +0 -7
- package/build/list-item/hooks/index.js.map +1 -1
- package/build/list-item/index.js +3 -2
- package/build/list-item/index.js.map +1 -1
- package/build/loginout/index.js +14 -1
- package/build/loginout/index.js.map +1 -1
- package/build/media-text/index.js +12 -0
- package/build/media-text/index.js.map +1 -1
- package/build/navigation/edit/index.js +5 -4
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-delete-control.js +1 -0
- package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +5 -1
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation-link/link-ui.js +13 -17
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/navigation-submenu/edit.js +0 -11
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/edit.js +1 -0
- package/build/page-list/edit.js.map +1 -1
- package/build/page-list-item/edit.js +4 -1
- package/build/page-list-item/edit.js.map +1 -1
- package/build/paragraph/index.js +6 -0
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +6 -0
- package/build/paragraph/transforms.js.map +1 -1
- package/build/post-author/index.js +8 -0
- package/build/post-author/index.js.map +1 -1
- package/build/post-author-biography/index.js +3 -0
- package/build/post-author-biography/index.js.map +1 -1
- package/build/post-author-name/index.js +3 -0
- package/build/post-author-name/index.js.map +1 -1
- package/build/post-comments-form/index.js +12 -0
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-content/index.js +1 -0
- package/build/post-content/index.js.map +1 -1
- package/build/post-date/index.js +15 -0
- package/build/post-date/index.js.map +1 -1
- package/build/post-excerpt/edit.js +1 -0
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-excerpt/index.js +12 -0
- package/build/post-excerpt/index.js.map +1 -1
- package/build/post-featured-image/index.js +3 -0
- package/build/post-featured-image/index.js.map +1 -1
- package/build/post-navigation-link/edit.js +2 -0
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-terms/index.js +15 -0
- package/build/post-terms/index.js.map +1 -1
- package/build/post-time-to-read/index.js +6 -0
- package/build/post-time-to-read/index.js.map +1 -1
- package/build/post-title/edit.js +9 -3
- package/build/post-title/edit.js.map +1 -1
- package/build/post-title/index.js +15 -0
- package/build/post-title/index.js.map +1 -1
- package/build/query/edit/inspector-controls/author-control.js +3 -1
- package/build/query/edit/inspector-controls/author-control.js.map +1 -1
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js +1 -0
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +90 -12
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/offset-controls.js +37 -0
- package/build/query/edit/inspector-controls/offset-controls.js.map +1 -0
- package/build/query/edit/inspector-controls/order-control.js +1 -0
- package/build/query/edit/inspector-controls/order-control.js.map +1 -1
- package/build/query/edit/inspector-controls/pages-control.js +36 -0
- package/build/query/edit/inspector-controls/pages-control.js.map +1 -0
- package/build/query/edit/inspector-controls/parent-control.js +2 -1
- package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build/query/edit/inspector-controls/per-page-control.js +40 -0
- package/build/query/edit/inspector-controls/per-page-control.js.map +1 -0
- package/build/query/edit/inspector-controls/sticky-control.js +2 -1
- package/build/query/edit/inspector-controls/sticky-control.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +5 -2
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query/edit/query-content.js +11 -2
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +1 -14
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/edit/query-toolbar.js +3 -76
- package/build/query/edit/query-toolbar.js.map +1 -1
- package/build/query/utils.js +15 -6
- package/build/query/utils.js.map +1 -1
- package/build/query/variations.js +9 -55
- package/build/query/variations.js.map +1 -1
- package/build/query-pagination-numbers/edit.js +1 -0
- package/build/query-pagination-numbers/edit.js.map +1 -1
- package/build/query-title/edit.js +13 -19
- package/build/query-title/edit.js.map +1 -1
- package/build/query-title/index.js +3 -0
- package/build/query-title/index.js.map +1 -1
- package/build/query-title/use-archive-label.js +95 -0
- package/build/query-title/use-archive-label.js.map +1 -0
- package/build/quote/index.js +15 -1
- package/build/quote/index.js.map +1 -1
- package/build/search/index.js +3 -0
- package/build/search/index.js.map +1 -1
- package/build/site-logo/edit.js +19 -9
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-tagline/edit.js +8 -5
- package/build/site-tagline/edit.js.map +1 -1
- package/build/site-tagline/index.js +18 -2
- package/build/site-tagline/index.js.map +1 -1
- package/build/site-title/edit.js +6 -3
- package/build/site-title/edit.js.map +1 -1
- package/build/site-title/index.js +16 -1
- package/build/site-title/index.js.map +1 -1
- package/build/social-link/edit.js +0 -1
- package/build/social-link/edit.js.map +1 -1
- package/build/social-link/icons/soundcloud.js +1 -1
- package/build/social-link/icons/soundcloud.js.map +1 -1
- package/build/social-links/index.js +12 -0
- package/build/social-links/index.js.map +1 -1
- package/build/spacer/controls.js +8 -13
- package/build/spacer/controls.js.map +1 -1
- package/build/table-of-contents/index.js +14 -1
- package/build/table-of-contents/index.js.map +1 -1
- package/build/tag-cloud/edit.js +42 -33
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/tag-cloud/index.js +1 -1
- package/build/template-part/edit/index.js +8 -5
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/inner-blocks.js +11 -4
- package/build/template-part/edit/inner-blocks.js.map +1 -1
- package/build/template-part/edit/placeholder.js +23 -3
- package/build/template-part/edit/placeholder.js.map +1 -1
- package/build/template-part/edit/title-modal.js +20 -8
- package/build/template-part/edit/title-modal.js.map +1 -1
- package/build/term-description/index.js +12 -0
- package/build/term-description/index.js.map +1 -1
- package/build/utils/hooks.js +5 -1
- package/build/utils/hooks.js.map +1 -1
- package/build-module/avatar/edit.js +1 -0
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/block/edit.js +38 -23
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/edit.js +1 -1
- package/build-module/button/edit.js.map +1 -1
- package/build-module/buttons/index.js +26 -0
- package/build-module/buttons/index.js.map +1 -1
- package/build-module/categories/edit.js +21 -4
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/categories/index.js +20 -0
- package/build-module/categories/index.js.map +1 -1
- package/build-module/column/edit.js +2 -2
- package/build-module/column/edit.js.map +1 -1
- package/build-module/column/index.js +2 -0
- package/build-module/column/index.js.map +1 -1
- package/build-module/columns/index.js +2 -2
- package/build-module/columns/index.js.map +1 -1
- package/build-module/comment-template/index.js +12 -0
- package/build-module/comment-template/index.js.map +1 -1
- package/build-module/comments-title/deprecated.js +3 -0
- package/build-module/comments-title/deprecated.js.map +1 -1
- package/build-module/comments-title/edit.js +3 -1
- package/build-module/comments-title/edit.js.map +1 -1
- package/build-module/comments-title/index.js +3 -0
- package/build-module/comments-title/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +2 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/details/edit.js +1 -0
- package/build-module/details/edit.js.map +1 -1
- package/build-module/embed/variations.js +40 -35
- package/build-module/embed/variations.js.map +1 -1
- package/build-module/footnotes/index.js +1 -1
- package/build-module/footnotes/index.js.map +1 -1
- package/build-module/form/edit.js +4 -4
- package/build-module/form/edit.js.map +1 -1
- package/build-module/form-input/edit.js +3 -0
- package/build-module/form-input/edit.js.map +1 -1
- package/build-module/gallery/edit.js +43 -9
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gap-styles.js +1 -9
- package/build-module/gallery/gap-styles.js.map +1 -1
- package/build-module/gallery/index.js +10 -0
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/gallery/use-image-sizes.js +2 -2
- package/build-module/gallery/use-image-sizes.js.map +1 -1
- package/build-module/group/deprecated.js +2 -5
- package/build-module/group/deprecated.js.map +1 -1
- package/build-module/group/index.js +27 -30
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/variations.js +51 -3
- package/build-module/group/variations.js.map +1 -1
- package/build-module/heading/edit.js +2 -0
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/heading/index.js +17 -1
- package/build-module/heading/index.js.map +1 -1
- package/build-module/image/edit.js +1 -1
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +25 -12
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +3 -0
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/view.js +65 -49
- package/build-module/image/view.js.map +1 -1
- package/build-module/latest-comments/index.js +9 -0
- package/build-module/latest-comments/index.js.map +1 -1
- package/build-module/latest-posts/edit.js +1 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/list/edit.js +3 -3
- package/build-module/list/edit.js.map +1 -1
- package/build-module/list/index.js +1 -1
- package/build-module/list/ordered-list-settings.js +19 -17
- package/build-module/list/ordered-list-settings.js.map +1 -1
- package/build-module/list-item/edit.js +2 -2
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/index.js +0 -1
- package/build-module/list-item/hooks/index.js.map +1 -1
- package/build-module/list-item/index.js +3 -2
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/loginout/index.js +14 -1
- package/build-module/loginout/index.js.map +1 -1
- package/build-module/media-text/index.js +12 -0
- package/build-module/media-text/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +5 -4
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-delete-control.js +1 -0
- package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +5 -1
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +13 -17
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +0 -11
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/edit.js +1 -0
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/page-list-item/edit.js +4 -1
- package/build-module/page-list-item/edit.js.map +1 -1
- package/build-module/paragraph/index.js +6 -0
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +6 -0
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/post-author/index.js +8 -0
- package/build-module/post-author/index.js.map +1 -1
- package/build-module/post-author-biography/index.js +3 -0
- package/build-module/post-author-biography/index.js.map +1 -1
- package/build-module/post-author-name/index.js +3 -0
- package/build-module/post-author-name/index.js.map +1 -1
- package/build-module/post-comments-form/index.js +12 -0
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-content/index.js +1 -0
- package/build-module/post-content/index.js.map +1 -1
- package/build-module/post-date/index.js +15 -0
- package/build-module/post-date/index.js.map +1 -1
- package/build-module/post-excerpt/edit.js +1 -0
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-excerpt/index.js +12 -0
- package/build-module/post-excerpt/index.js.map +1 -1
- package/build-module/post-featured-image/index.js +3 -0
- package/build-module/post-featured-image/index.js.map +1 -1
- package/build-module/post-navigation-link/edit.js +2 -0
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-terms/index.js +15 -0
- package/build-module/post-terms/index.js.map +1 -1
- package/build-module/post-time-to-read/index.js +6 -0
- package/build-module/post-time-to-read/index.js.map +1 -1
- package/build-module/post-title/edit.js +9 -3
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/post-title/index.js +15 -0
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/author-control.js +3 -1
- package/build-module/query/edit/inspector-controls/author-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +1 -0
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +92 -14
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/offset-controls.js +29 -0
- package/build-module/query/edit/inspector-controls/offset-controls.js.map +1 -0
- package/build-module/query/edit/inspector-controls/order-control.js +1 -0
- package/build-module/query/edit/inspector-controls/order-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/pages-control.js +28 -0
- package/build-module/query/edit/inspector-controls/pages-control.js.map +1 -0
- package/build-module/query/edit/inspector-controls/parent-control.js +2 -1
- package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/per-page-control.js +33 -0
- package/build-module/query/edit/inspector-controls/per-page-control.js.map +1 -0
- package/build-module/query/edit/inspector-controls/sticky-control.js +2 -1
- package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +6 -4
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query/edit/query-content.js +11 -2
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +1 -14
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/edit/query-toolbar.js +4 -78
- package/build-module/query/edit/query-toolbar.js.map +1 -1
- package/build-module/query/utils.js +15 -6
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query/variations.js +4 -50
- package/build-module/query/variations.js.map +1 -1
- package/build-module/query-pagination-numbers/edit.js +1 -0
- package/build-module/query-pagination-numbers/edit.js.map +1 -1
- package/build-module/query-title/edit.js +14 -20
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/query-title/index.js +3 -0
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/query-title/use-archive-label.js +88 -0
- package/build-module/query-title/use-archive-label.js.map +1 -0
- package/build-module/quote/index.js +15 -1
- package/build-module/quote/index.js.map +1 -1
- package/build-module/search/index.js +3 -0
- package/build-module/search/index.js.map +1 -1
- package/build-module/site-logo/edit.js +19 -9
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-tagline/edit.js +8 -5
- package/build-module/site-tagline/edit.js.map +1 -1
- package/build-module/site-tagline/index.js +18 -2
- package/build-module/site-tagline/index.js.map +1 -1
- package/build-module/site-title/edit.js +6 -3
- package/build-module/site-title/edit.js.map +1 -1
- package/build-module/site-title/index.js +16 -1
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-link/edit.js +0 -1
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-link/icons/soundcloud.js +1 -1
- package/build-module/social-link/icons/soundcloud.js.map +1 -1
- package/build-module/social-links/index.js +12 -0
- package/build-module/social-links/index.js.map +1 -1
- package/build-module/spacer/controls.js +9 -14
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/table-of-contents/index.js +14 -1
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-module/tag-cloud/edit.js +43 -34
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/tag-cloud/index.js +1 -1
- package/build-module/template-part/edit/index.js +8 -5
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/inner-blocks.js +11 -4
- package/build-module/template-part/edit/inner-blocks.js.map +1 -1
- package/build-module/template-part/edit/placeholder.js +23 -3
- package/build-module/template-part/edit/placeholder.js.map +1 -1
- package/build-module/template-part/edit/title-modal.js +20 -8
- package/build-module/template-part/edit/title-modal.js.map +1 -1
- package/build-module/term-description/index.js +12 -0
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/utils/hooks.js +5 -1
- package/build-module/utils/hooks.js.map +1 -1
- package/build-style/archives/editor-rtl.css +3 -0
- package/build-style/archives/editor.css +3 -0
- package/build-style/archives/style-rtl.css +3 -0
- package/build-style/archives/style.css +3 -0
- package/build-style/audio/editor-rtl.css +3 -0
- package/build-style/audio/editor.css +3 -0
- package/build-style/audio/style-rtl.css +3 -0
- package/build-style/audio/style.css +3 -0
- package/build-style/audio/theme-rtl.css +3 -0
- package/build-style/audio/theme.css +3 -0
- package/build-style/avatar/editor-rtl.css +3 -0
- package/build-style/avatar/editor.css +3 -0
- package/build-style/avatar/style-rtl.css +3 -0
- package/build-style/avatar/style.css +3 -0
- package/build-style/button/editor-rtl.css +3 -0
- package/build-style/button/editor.css +3 -0
- package/build-style/button/style-rtl.css +3 -0
- package/build-style/button/style.css +3 -0
- package/build-style/buttons/editor-rtl.css +3 -0
- package/build-style/buttons/editor.css +3 -0
- package/build-style/buttons/style-rtl.css +3 -0
- package/build-style/buttons/style.css +3 -0
- package/build-style/calendar/style-rtl.css +3 -0
- package/build-style/calendar/style.css +3 -0
- package/build-style/categories/editor-rtl.css +7 -0
- package/build-style/categories/editor.css +7 -0
- package/build-style/categories/style-rtl.css +7 -0
- package/build-style/categories/style.css +7 -0
- package/build-style/classic-rtl.css +3 -0
- package/build-style/classic.css +3 -0
- package/build-style/code/editor-rtl.css +3 -0
- package/build-style/code/editor.css +3 -0
- package/build-style/code/style-rtl.css +3 -0
- package/build-style/code/style.css +3 -0
- package/build-style/code/theme-rtl.css +3 -0
- package/build-style/code/theme.css +3 -0
- package/build-style/columns/editor-rtl.css +3 -0
- package/build-style/columns/editor.css +3 -0
- package/build-style/columns/style-rtl.css +3 -0
- package/build-style/columns/style.css +3 -0
- package/build-style/comment-author-avatar/editor-rtl.css +3 -0
- package/build-style/comment-author-avatar/editor.css +3 -0
- package/build-style/comment-content/style-rtl.css +3 -0
- package/build-style/comment-content/style.css +3 -0
- package/build-style/comment-template/style-rtl.css +3 -0
- package/build-style/comment-template/style.css +3 -0
- package/build-style/comments/editor-rtl.css +3 -0
- package/build-style/comments/editor.css +3 -0
- package/build-style/comments/style-rtl.css +3 -0
- package/build-style/comments/style.css +3 -0
- package/build-style/comments-pagination/editor-rtl.css +3 -0
- package/build-style/comments-pagination/editor.css +3 -0
- package/build-style/comments-pagination/style-rtl.css +3 -0
- package/build-style/comments-pagination/style.css +3 -0
- package/build-style/comments-pagination-numbers/editor-rtl.css +3 -0
- package/build-style/comments-pagination-numbers/editor.css +3 -0
- package/build-style/comments-title/editor-rtl.css +3 -0
- package/build-style/comments-title/editor.css +3 -0
- package/build-style/common-rtl.css +3 -0
- package/build-style/common.css +3 -0
- package/build-style/cover/editor-rtl.css +3 -0
- package/build-style/cover/editor.css +3 -0
- package/build-style/cover/style-rtl.css +3 -0
- package/build-style/cover/style.css +3 -0
- package/build-style/details/editor-rtl.css +3 -0
- package/build-style/details/editor.css +3 -0
- package/build-style/details/style-rtl.css +3 -0
- package/build-style/details/style.css +3 -0
- package/build-style/editor-elements-rtl.css +3 -0
- package/build-style/editor-elements.css +3 -0
- package/build-style/editor-rtl.css +29 -42
- package/build-style/editor.css +29 -42
- package/build-style/elements-rtl.css +3 -0
- package/build-style/elements.css +3 -0
- package/build-style/embed/editor-rtl.css +3 -0
- package/build-style/embed/editor.css +3 -0
- package/build-style/embed/style-rtl.css +3 -0
- package/build-style/embed/style.css +3 -0
- package/build-style/embed/theme-rtl.css +3 -0
- package/build-style/embed/theme.css +3 -0
- package/build-style/file/editor-rtl.css +3 -0
- package/build-style/file/editor.css +3 -0
- package/build-style/file/style-rtl.css +3 -0
- package/build-style/file/style.css +3 -0
- package/build-style/footnotes/style-rtl.css +3 -0
- package/build-style/footnotes/style.css +3 -0
- package/build-style/form-input/editor-rtl.css +3 -0
- package/build-style/form-input/editor.css +3 -0
- package/build-style/form-input/style-rtl.css +4 -0
- package/build-style/form-input/style.css +4 -0
- package/build-style/form-submission-notification/editor-rtl.css +3 -0
- package/build-style/form-submission-notification/editor.css +3 -0
- package/build-style/form-submit-button/style-rtl.css +3 -0
- package/build-style/form-submit-button/style.css +3 -0
- package/build-style/freeform/editor-rtl.css +3 -0
- package/build-style/freeform/editor.css +3 -0
- package/build-style/gallery/editor-rtl.css +3 -1
- package/build-style/gallery/editor.css +3 -1
- package/build-style/gallery/style-rtl.css +3 -0
- package/build-style/gallery/style.css +3 -0
- package/build-style/gallery/theme-rtl.css +3 -0
- package/build-style/gallery/theme.css +3 -0
- package/build-style/group/editor-rtl.css +3 -11
- package/build-style/group/editor.css +3 -11
- package/build-style/group/style-rtl.css +3 -0
- package/build-style/group/style.css +3 -0
- package/build-style/group/theme-rtl.css +3 -0
- package/build-style/group/theme.css +3 -0
- package/build-style/heading/style-rtl.css +3 -0
- package/build-style/heading/style.css +3 -0
- package/build-style/html/editor-rtl.css +3 -0
- package/build-style/html/editor.css +3 -0
- package/build-style/image/editor-rtl.css +19 -4
- package/build-style/image/editor.css +19 -4
- package/build-style/image/style-rtl.css +22 -0
- package/build-style/image/style.css +22 -0
- package/build-style/image/theme-rtl.css +3 -0
- package/build-style/image/theme.css +3 -0
- package/build-style/latest-comments/style-rtl.css +3 -0
- package/build-style/latest-comments/style.css +3 -0
- package/build-style/latest-posts/editor-rtl.css +3 -3
- package/build-style/latest-posts/editor.css +3 -3
- package/build-style/latest-posts/style-rtl.css +3 -0
- package/build-style/latest-posts/style.css +3 -0
- package/build-style/list/style-rtl.css +4 -1
- package/build-style/list/style.css +4 -1
- package/build-style/loginout/style-rtl.css +94 -0
- package/build-style/loginout/style.css +94 -0
- package/build-style/media-text/editor-rtl.css +3 -0
- package/build-style/media-text/editor.css +3 -0
- package/build-style/media-text/style-rtl.css +3 -0
- package/build-style/media-text/style.css +3 -0
- package/build-style/more/editor-rtl.css +3 -0
- package/build-style/more/editor.css +3 -0
- package/build-style/navigation/editor-rtl.css +3 -12
- package/build-style/navigation/editor.css +3 -12
- package/build-style/navigation/style-rtl.css +4 -4
- package/build-style/navigation/style.css +4 -4
- package/build-style/navigation-link/editor-rtl.css +3 -0
- package/build-style/navigation-link/editor.css +3 -0
- package/build-style/navigation-link/style-rtl.css +3 -0
- package/build-style/navigation-link/style.css +3 -0
- package/build-style/navigation-submenu/editor-rtl.css +3 -0
- package/build-style/navigation-submenu/editor.css +3 -0
- package/build-style/nextpage/editor-rtl.css +3 -0
- package/build-style/nextpage/editor.css +3 -0
- package/build-style/page-list/editor-rtl.css +3 -0
- package/build-style/page-list/editor.css +3 -0
- package/build-style/page-list/style-rtl.css +3 -0
- package/build-style/page-list/style.css +3 -0
- package/build-style/paragraph/editor-rtl.css +3 -0
- package/build-style/paragraph/editor.css +3 -0
- package/build-style/paragraph/style-rtl.css +3 -0
- package/build-style/paragraph/style.css +3 -0
- package/build-style/post-author/style-rtl.css +3 -0
- package/build-style/post-author/style.css +3 -0
- package/build-style/post-comments-form/editor-rtl.css +3 -0
- package/build-style/post-comments-form/editor.css +3 -0
- package/build-style/post-comments-form/style-rtl.css +4 -1
- package/build-style/post-comments-form/style.css +4 -1
- package/build-style/post-content/editor-rtl.css +3 -0
- package/build-style/post-content/editor.css +3 -0
- package/build-style/post-content/style-rtl.css +96 -0
- package/build-style/post-content/style.css +96 -0
- package/build-style/post-date/style-rtl.css +3 -0
- package/build-style/post-date/style.css +3 -0
- package/build-style/post-excerpt/editor-rtl.css +3 -0
- package/build-style/post-excerpt/editor.css +3 -0
- package/build-style/post-excerpt/style-rtl.css +4 -0
- package/build-style/post-excerpt/style.css +4 -0
- package/build-style/post-featured-image/editor-rtl.css +3 -0
- package/build-style/post-featured-image/editor.css +3 -0
- package/build-style/post-featured-image/style-rtl.css +3 -0
- package/build-style/post-featured-image/style.css +3 -0
- package/build-style/post-navigation-link/style-rtl.css +3 -0
- package/build-style/post-navigation-link/style.css +3 -0
- package/build-style/post-template/editor-rtl.css +3 -0
- package/build-style/post-template/editor.css +3 -0
- package/build-style/post-template/style-rtl.css +3 -0
- package/build-style/post-template/style.css +3 -0
- package/build-style/post-terms/style-rtl.css +3 -0
- package/build-style/post-terms/style.css +3 -0
- package/build-style/post-time-to-read/style-rtl.css +3 -0
- package/build-style/post-time-to-read/style.css +3 -0
- package/build-style/post-title/style-rtl.css +3 -0
- package/build-style/post-title/style.css +3 -0
- package/build-style/preformatted/style-rtl.css +3 -0
- package/build-style/preformatted/style.css +3 -0
- package/build-style/pullquote/editor-rtl.css +3 -0
- package/build-style/pullquote/editor.css +3 -0
- package/build-style/pullquote/style-rtl.css +3 -0
- package/build-style/pullquote/style.css +3 -0
- package/build-style/pullquote/theme-rtl.css +3 -0
- package/build-style/pullquote/theme.css +3 -0
- package/build-style/query/editor-rtl.css +3 -7
- package/build-style/query/editor.css +3 -7
- package/build-style/query-pagination/editor-rtl.css +3 -0
- package/build-style/query-pagination/editor.css +3 -0
- package/build-style/query-pagination/style-rtl.css +3 -0
- package/build-style/query-pagination/style.css +3 -0
- package/build-style/query-pagination-numbers/editor-rtl.css +3 -0
- package/build-style/query-pagination-numbers/editor.css +3 -0
- package/build-style/query-title/style-rtl.css +3 -0
- package/build-style/query-title/style.css +3 -0
- package/build-style/quote/style-rtl.css +3 -0
- package/build-style/quote/style.css +3 -0
- package/build-style/quote/theme-rtl.css +6 -3
- package/build-style/quote/theme.css +6 -3
- package/build-style/read-more/style-rtl.css +3 -0
- package/build-style/read-more/style.css +3 -0
- package/build-style/reset-rtl.css +3 -0
- package/build-style/reset.css +3 -0
- package/build-style/rss/editor-rtl.css +3 -0
- package/build-style/rss/editor.css +3 -0
- package/build-style/rss/style-rtl.css +3 -0
- package/build-style/rss/style.css +3 -0
- package/build-style/search/editor-rtl.css +4 -1
- package/build-style/search/editor.css +4 -1
- package/build-style/search/style-rtl.css +3 -0
- package/build-style/search/style.css +3 -0
- package/build-style/search/theme-rtl.css +3 -0
- package/build-style/search/theme.css +3 -0
- package/build-style/separator/editor-rtl.css +3 -0
- package/build-style/separator/editor.css +3 -0
- package/build-style/separator/style-rtl.css +3 -0
- package/build-style/separator/style.css +3 -0
- package/build-style/separator/theme-rtl.css +3 -0
- package/build-style/separator/theme.css +3 -0
- package/build-style/shortcode/editor-rtl.css +3 -0
- package/build-style/shortcode/editor.css +3 -0
- package/build-style/site-logo/editor-rtl.css +3 -0
- package/build-style/site-logo/editor.css +3 -0
- package/build-style/site-logo/style-rtl.css +3 -0
- package/build-style/site-logo/style.css +3 -0
- package/build-style/site-tagline/editor-rtl.css +3 -0
- package/build-style/site-tagline/editor.css +3 -0
- package/build-style/site-tagline/style-rtl.css +94 -0
- package/build-style/site-tagline/style.css +94 -0
- package/build-style/site-title/editor-rtl.css +3 -0
- package/build-style/site-title/editor.css +3 -0
- package/build-style/site-title/style-rtl.css +7 -1
- package/build-style/site-title/style.css +7 -1
- package/build-style/social-link/editor-rtl.css +3 -0
- package/build-style/social-link/editor.css +3 -0
- package/build-style/social-links/editor-rtl.css +3 -0
- package/build-style/social-links/editor.css +3 -0
- package/build-style/social-links/style-rtl.css +5 -2
- package/build-style/social-links/style.css +5 -2
- package/build-style/spacer/editor-rtl.css +3 -0
- package/build-style/spacer/editor.css +3 -0
- package/build-style/spacer/style-rtl.css +3 -0
- package/build-style/spacer/style.css +3 -0
- package/build-style/style-rtl.css +56 -9
- package/build-style/style.css +56 -9
- package/build-style/table/editor-rtl.css +3 -0
- package/build-style/table/editor.css +3 -0
- package/build-style/table/style-rtl.css +3 -0
- package/build-style/table/style.css +3 -0
- package/build-style/table/theme-rtl.css +3 -0
- package/build-style/table/theme.css +3 -0
- package/build-style/table-of-contents/style-rtl.css +94 -0
- package/build-style/table-of-contents/style.css +94 -0
- package/build-style/tag-cloud/editor-rtl.css +95 -0
- package/build-style/tag-cloud/editor.css +95 -0
- package/build-style/tag-cloud/style-rtl.css +3 -0
- package/build-style/tag-cloud/style.css +3 -0
- package/build-style/template-part/editor-rtl.css +3 -0
- package/build-style/template-part/editor.css +3 -0
- package/build-style/template-part/theme-rtl.css +3 -0
- package/build-style/template-part/theme.css +3 -0
- package/build-style/term-description/style-rtl.css +4 -0
- package/build-style/term-description/style.css +4 -0
- package/build-style/text-columns/editor-rtl.css +3 -0
- package/build-style/text-columns/editor.css +3 -0
- package/build-style/text-columns/style-rtl.css +3 -0
- package/build-style/text-columns/style.css +3 -0
- package/build-style/theme-rtl.css +6 -3
- package/build-style/theme.css +6 -3
- package/build-style/verse/style-rtl.css +3 -0
- package/build-style/verse/style.css +3 -0
- package/build-style/video/editor-rtl.css +3 -3
- package/build-style/video/editor.css +3 -3
- package/build-style/video/style-rtl.css +3 -0
- package/build-style/video/style.css +3 -0
- package/build-style/video/theme-rtl.css +3 -0
- package/build-style/video/theme.css +3 -0
- package/package.json +35 -35
- package/src/avatar/edit.js +1 -0
- package/src/block/edit.js +58 -27
- package/src/block/test/edit.native.js +6 -2
- package/src/button/edit.js +1 -1
- package/src/button/index.php +1 -14
- package/src/buttons/block.json +20 -0
- package/src/buttons/index.js +6 -0
- package/src/categories/block.json +20 -0
- package/src/categories/edit.js +32 -4
- package/src/categories/editor.scss +4 -0
- package/src/categories/index.php +4 -1
- package/src/categories/style.scss +4 -0
- package/src/column/block.json +2 -0
- package/src/column/edit.js +2 -2
- package/src/columns/index.js +1 -1
- package/src/comment-template/block.json +12 -0
- package/src/comments-title/block.json +3 -0
- package/src/comments-title/edit.js +8 -1
- package/src/cover/edit/inspector-controls.js +1 -0
- package/src/details/edit.js +1 -0
- package/src/editor.scss +1 -0
- package/src/embed/test/__snapshots__/index.native.js.snap +8 -8
- package/src/embed/test/index.js +1 -1
- package/src/embed/test/index.native.js +24 -23
- package/src/embed/variations.js +43 -35
- package/src/footnotes/index.js +1 -2
- package/src/form/edit.js +3 -2
- package/src/form-input/edit.js +3 -0
- package/src/form-input/style.scss +1 -0
- package/src/gallery/block.json +10 -0
- package/src/gallery/edit.js +75 -13
- package/src/gallery/editor.scss +0 -1
- package/src/gallery/gap-styles.js +1 -8
- package/src/gallery/test/__snapshots__/index.native.js.snap +1 -1
- package/src/gallery/test/index.native.js +5 -5
- package/src/gallery/use-image-sizes.js +2 -2
- package/src/group/deprecated.js +3 -7
- package/src/group/editor.scss +1 -1
- package/src/group/index.js +26 -29
- package/src/group/variations.js +56 -0
- package/src/heading/block.json +15 -0
- package/src/heading/edit.js +3 -1
- package/src/heading/index.js +1 -0
- package/src/image/block.json +3 -0
- package/src/image/edit.js +1 -1
- package/src/image/editor.scss +18 -1
- package/src/image/image.js +55 -35
- package/src/image/index.php +32 -15
- package/src/image/style.scss +22 -0
- package/src/image/test/edit.native.js +1 -0
- package/src/image/view.js +69 -49
- package/src/latest-comments/block.json +9 -0
- package/src/latest-posts/edit.js +1 -0
- package/src/latest-posts/editor.scss +0 -4
- package/src/list/block.json +1 -1
- package/src/list/edit.js +3 -3
- package/src/list/ordered-list-settings.js +20 -18
- package/src/list/style.scss +1 -1
- package/src/list/test/edit.native.js +1 -3
- package/src/list-item/block.json +3 -2
- package/src/list-item/edit.js +2 -2
- package/src/list-item/hooks/index.js +0 -1
- package/src/loginout/block.json +14 -1
- package/src/loginout/style.scss +4 -0
- package/src/media-text/block.json +12 -0
- package/src/media-text/style.native.scss +2 -0
- package/src/navigation/edit/index.js +5 -5
- package/src/navigation/edit/navigation-menu-delete-control.js +1 -0
- package/src/navigation/editor.scss +0 -1
- package/src/navigation/index.php +1 -1
- package/src/navigation/style.scss +4 -9
- package/src/navigation/test/use-navigation-menu.js +54 -15
- package/src/navigation/use-navigation-menu.js +5 -1
- package/src/navigation-link/link-ui.js +8 -14
- package/src/navigation-submenu/edit.js +1 -13
- package/src/page-list/edit.js +1 -0
- package/src/page-list-item/edit.js +4 -4
- package/src/paragraph/block.json +6 -0
- package/src/post-author/index.js +8 -0
- package/src/post-author-biography/block.json +3 -0
- package/src/post-author-name/block.json +3 -0
- package/src/post-comments-form/block.json +12 -0
- package/src/post-comments-form/style.scss +1 -1
- package/src/post-content/block.json +1 -0
- package/src/post-content/style.scss +5 -0
- package/src/post-date/block.json +15 -0
- package/src/post-excerpt/block.json +12 -0
- package/src/post-excerpt/edit.js +1 -0
- package/src/post-excerpt/style.scss +3 -0
- package/src/post-featured-image/block.json +3 -0
- package/src/post-navigation-link/edit.js +2 -0
- package/src/post-terms/block.json +15 -0
- package/src/post-time-to-read/block.json +6 -0
- package/src/post-title/block.json +15 -0
- package/src/post-title/edit.js +9 -8
- package/src/query/edit/inspector-controls/author-control.js +2 -0
- package/src/query/edit/inspector-controls/enhanced-pagination-control.js +1 -0
- package/src/query/edit/inspector-controls/index.js +123 -23
- package/src/query/edit/inspector-controls/offset-controls.js +31 -0
- package/src/query/edit/inspector-controls/order-control.js +1 -0
- package/src/query/edit/inspector-controls/pages-control.js +27 -0
- package/src/query/edit/inspector-controls/parent-control.js +1 -0
- package/src/query/edit/inspector-controls/per-page-control.js +33 -0
- package/src/query/edit/inspector-controls/sticky-control.js +2 -1
- package/src/query/edit/inspector-controls/taxonomy-controls.js +8 -3
- package/src/query/edit/query-content.js +17 -3
- package/src/query/edit/query-placeholder.js +1 -21
- package/src/query/edit/query-toolbar.js +1 -90
- package/src/query/editor.scss +0 -9
- package/src/query/utils.js +13 -5
- package/src/query/variations.js +4 -46
- package/src/query-pagination-numbers/edit.js +1 -0
- package/src/query-title/block.json +3 -0
- package/src/query-title/edit.js +19 -18
- package/src/query-title/use-archive-label.js +99 -0
- package/src/quote/block.json +15 -1
- package/src/quote/theme.scss +5 -3
- package/src/search/block.json +3 -0
- package/src/search/editor.scss +1 -1
- package/src/site-logo/edit.js +27 -10
- package/src/site-tagline/block.json +18 -2
- package/src/site-tagline/edit.js +7 -6
- package/src/site-tagline/style.scss +4 -0
- package/src/site-title/block.json +10 -0
- package/src/site-title/edit.js +6 -5
- package/src/site-title/index.js +6 -1
- package/src/site-title/style.scss +7 -2
- package/src/social-link/edit.js +0 -1
- package/src/social-link/icons/soundcloud.js +1 -1
- package/src/social-link/socials-with-bg.scss +1 -1
- package/src/social-link/socials-without-bg.scss +1 -1
- package/src/social-links/block.json +12 -0
- package/src/spacer/controls.js +10 -13
- package/src/style.scss +4 -0
- package/src/table-of-contents/block.json +14 -1
- package/src/table-of-contents/style.scss +4 -0
- package/src/tag-cloud/block.json +1 -1
- package/src/tag-cloud/edit.js +53 -35
- package/src/tag-cloud/editor.scss +9 -0
- package/src/template-part/edit/index.js +10 -5
- package/src/template-part/edit/inner-blocks.js +11 -6
- package/src/template-part/edit/placeholder.js +31 -6
- package/src/template-part/edit/title-modal.js +18 -4
- package/src/term-description/block.json +12 -0
- package/src/term-description/style.scss +2 -0
- package/src/utils/hooks.js +5 -1
- package/src/video/editor.scss +0 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/build/list-item/hooks/use-split.js +0 -39
- package/build/list-item/hooks/use-split.js.map +0 -1
- package/build-module/list-item/hooks/use-split.js +0 -32
- package/build-module/list-item/hooks/use-split.js.map +0 -1
- package/src/list-item/hooks/use-split.js +0 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","FormTokenField","useSelect","store","coreStore","useState","useEffect","useMemo","useDebounce","getEntitiesInfo","mapToIHasNameAndId","jsx","_jsx","EMPTY_ARRAY","BASE_QUERY","order","_fields","context","ParentControl","parents","postType","onChange","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","selectorArgs","orderby","exclude","per_page","currentParents","length","include","currentParentsInfo","sanitizedValue","reduce","accumulator","id","entity","mapById","push","name","entitiesInfo","names","getIdByValue","entitiesMappedByName","onParentChange","newValue","ids","Array","from","mapByName","add","Set","label","onInputChange","__experimentalShowHowTo"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/parent-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getEntitiesInfo, mapToIHasNameAndId } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,title',\n\tcontext: 'view',\n};\n\nfunction ParentControl( { parents, postType, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\texclude: parents,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, parents ]\n\t);\n\tconst currentParents = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! parents?.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'postType', postType, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: parents,\n\t\t\t\tper_page: parents.length,\n\t\t\t} );\n\t\t},\n\t\t[ parents ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing parents.\n\tuseEffect( () => {\n\t\tif ( ! parents?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! currentParents?.length ) {\n\t\t\treturn;\n\t\t}\n\t\tconst currentParentsInfo = getEntitiesInfo(\n\t\t\tmapToIHasNameAndId( currentParents, 'title.rendered' )\n\t\t);\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = parents.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = currentParentsInfo.mapById[ id ];\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ parents, currentParents ] );\n\n\tconst entitiesInfo = useMemo( () => {\n\t\tif ( ! searchResults?.length ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn getEntitiesInfo(\n\t\t\tmapToIHasNameAndId( searchResults, 'title.rendered' )\n\t\t);\n\t}, [ searchResults ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) {\n\t\t\treturn;\n\t\t}\n\t\tsetSuggestions( entitiesInfo.names );\n\t}, [ entitiesInfo.names, searchHasResolved ] );\n\n\tconst getIdByValue = ( entitiesMappedByName, entity ) => {\n\t\tconst id = entity?.id || entitiesMappedByName?.[ entity ]?.id;\n\t\tif ( id ) {\n\t\t\treturn id;\n\t\t}\n\t};\n\tconst onParentChange = ( newValue ) => {\n\t\tconst ids = Array.from(\n\t\t\tnewValue.reduce( ( accumulator, entity ) => {\n\t\t\t\t// Verify that new values point to existing entities.\n\t\t\t\tconst id = getIdByValue( entitiesInfo.mapByName, entity );\n\t\t\t\tif ( id ) {\n\t\t\t\t\taccumulator.add( id );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, new Set() )\n\t\t);\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( { parents: ids } );\n\t};\n\treturn (\n\t\t<FormTokenField\n\t\t\tlabel={ __( 'Parents' ) }\n\t\t\tvalue={ value }\n\t\t\tonInputChange={ debouncedSearch }\n\t\t\tsuggestions={ suggestions }\n\t\t\tonChange={ onParentChange }\n\t\t\t__experimentalShowHowTo={ false }\n\t\t/>\n\t);\n}\n\nexport default ParentControl;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,EAAEC,SAAS,EAAEC,OAAO,QAAQ,oBAAoB;AACjE,SAASC,WAAW,QAAQ,oBAAoB;;AAEhD;AACA;AACA;AACA,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAElE,MAAMC,WAAW,GAAG,EAAE;AACtB,MAAMC,UAAU,GAAG;EAClBC,KAAK,EAAE,KAAK;EACZC,OAAO,EAAE,UAAU;EACnBC,OAAO,EAAE;AACV,CAAC;AAED,SAASC,aAAaA,CAAE;EAAEC,OAAO;EAAEC,QAAQ;EAAEC;AAAS,CAAC,EAAG;EACzD,MAAM,CAAEC,MAAM,EAAEC,SAAS,CAAE,GAAGlB,QAAQ,CAAE,EAAG,CAAC;EAC5C,MAAM,CAAEmB,KAAK,EAAEC,QAAQ,CAAE,GAA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AAIP,MAAM,CAAE,EAAED,EAAE;IAC7D,IAAKA,EAAE,EAAG;MACT,OAAOA,EAAE;IACV;EACD,CAAC;EACD,MAAMS,cAAc,GAAKC,QAAQ,IAAM;IACtC,MAAMC,GAAG,GAAGC,KAAK,CAACC,IAAI,CACrBH,QAAQ,CAACZ,MAAM,CAAE,CAAEC,WAAW,EAAEE,MAAM,KAAM;MAC3C;MACA,MAAMD,EAAE,GAAGO,YAAY,CAAEF,YAAY,CAACS,SAAS,EAAEb,MAAO,CAAC;MACzD,IAAKD,EAAE,EAAG;QACTD,WAAW,CAACgB,GAAG,CAAEf,EAAG,CAAC;MACtB;MACA,OAAOD,WAAW;IACnB,CAAC,EAAE,IAAIiB,GAAG,CAAC,CAAE,CACd,CAAC;IACDlC,cAAc,CAAEd,WAAY,CAAC;IAC7BQ,QAAQ,CAAE;MAAEF,OAAO,EAAEqC;IAAI,CAAE,CAAC;EAC7B,CAAC;EACD,oBACC5C,IAAA,CAACX,cAAc;IACd6D,KAAK,EAAG9D,EAAE,CAAE,SAAU,CAAG;IACzBwB,KAAK,EAAGA,KAAO;IACfuC,aAAa,EAAGnC,eAAiB;IACjCF,WAAW,EAAGA,WAAa;IAC3BL,QAAQ,EAAGiC,cAAgB;IAC3BU,uBAAuB,EAAG;
|
|
1
|
+
{"version":3,"names":["__","FormTokenField","useSelect","store","coreStore","useState","useEffect","useMemo","useDebounce","getEntitiesInfo","mapToIHasNameAndId","jsx","_jsx","EMPTY_ARRAY","BASE_QUERY","order","_fields","context","ParentControl","parents","postType","onChange","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","selectorArgs","orderby","exclude","per_page","currentParents","length","include","currentParentsInfo","sanitizedValue","reduce","accumulator","id","entity","mapById","push","name","entitiesInfo","names","getIdByValue","entitiesMappedByName","onParentChange","newValue","ids","Array","from","mapByName","add","Set","label","onInputChange","__experimentalShowHowTo","__nextHasNoMarginBottom"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/parent-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getEntitiesInfo, mapToIHasNameAndId } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,title',\n\tcontext: 'view',\n};\n\nfunction ParentControl( { parents, postType, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\texclude: parents,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, parents ]\n\t);\n\tconst currentParents = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! parents?.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'postType', postType, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: parents,\n\t\t\t\tper_page: parents.length,\n\t\t\t} );\n\t\t},\n\t\t[ parents ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing parents.\n\tuseEffect( () => {\n\t\tif ( ! parents?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! currentParents?.length ) {\n\t\t\treturn;\n\t\t}\n\t\tconst currentParentsInfo = getEntitiesInfo(\n\t\t\tmapToIHasNameAndId( currentParents, 'title.rendered' )\n\t\t);\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = parents.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = currentParentsInfo.mapById[ id ];\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ parents, currentParents ] );\n\n\tconst entitiesInfo = useMemo( () => {\n\t\tif ( ! searchResults?.length ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn getEntitiesInfo(\n\t\t\tmapToIHasNameAndId( searchResults, 'title.rendered' )\n\t\t);\n\t}, [ searchResults ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) {\n\t\t\treturn;\n\t\t}\n\t\tsetSuggestions( entitiesInfo.names );\n\t}, [ entitiesInfo.names, searchHasResolved ] );\n\n\tconst getIdByValue = ( entitiesMappedByName, entity ) => {\n\t\tconst id = entity?.id || entitiesMappedByName?.[ entity ]?.id;\n\t\tif ( id ) {\n\t\t\treturn id;\n\t\t}\n\t};\n\tconst onParentChange = ( newValue ) => {\n\t\tconst ids = Array.from(\n\t\t\tnewValue.reduce( ( accumulator, entity ) => {\n\t\t\t\t// Verify that new values point to existing entities.\n\t\t\t\tconst id = getIdByValue( entitiesInfo.mapByName, entity );\n\t\t\t\tif ( id ) {\n\t\t\t\t\taccumulator.add( id );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, new Set() )\n\t\t);\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( { parents: ids } );\n\t};\n\treturn (\n\t\t<FormTokenField\n\t\t\tlabel={ __( 'Parents' ) }\n\t\t\tvalue={ value }\n\t\t\tonInputChange={ debouncedSearch }\n\t\t\tsuggestions={ suggestions }\n\t\t\tonChange={ onParentChange }\n\t\t\t__experimentalShowHowTo={ false }\n\t\t\t__nextHasNoMarginBottom\n\t\t/>\n\t);\n}\n\nexport default ParentControl;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,EAAEC,SAAS,EAAEC,OAAO,QAAQ,oBAAoB;AACjE,SAASC,WAAW,QAAQ,oBAAoB;;AAEhD;AACA;AACA;AACA,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAElE,MAAMC,WAAW,GAAG,EAAE;AACtB,MAAMC,UAAU,GAAG;EAClBC,KAAK,EAAE,KAAK;EACZC,OAAO,EAAE,UAAU;EACnBC,OAAO,EAAE;AACV,CAAC;AAED,SAASC,aAAaA,CAAE;EAAEC,OAAO;EAAEC,QAAQ;EAAEC;AAAS,CAAC,EAAG;EACzD,MAAM,CAAEC,MAAM,EAAEC,SAAS,CAAE,GAAGlB,QAAQ,CAAE,EAAG,CAAC;EAC5C,MAAM,CAAEmB,KAAK,EA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AE,IAAIQ,oBAAoB,GAAIP,MAAM,CAAE,EAAED,EAAE;IAC7D,IAAKA,EAAE,EAAG;MACT,OAAOA,EAAE;IACV;EACD,CAAC;EACD,MAAMS,cAAc,GAAKC,QAAQ,IAAM;IACtC,MAAMC,GAAG,GAAGC,KAAK,CAACC,IAAI,CACrBH,QAAQ,CAACZ,MAAM,CAAE,CAAEC,WAAW,EAAEE,MAAM,KAAM;MAC3C;MACA,MAAMD,EAAE,GAAGO,YAAY,CAAEF,YAAY,CAACS,SAAS,EAAEb,MAAO,CAAC;MACzD,IAAKD,EAAE,EAAG;QACTD,WAAW,CAACgB,GAAG,CAAEf,EAAG,CAAC;MACtB;MACA,OAAOD,WAAW;IACnB,CAAC,EAAE,IAAIiB,GAAG,CAAC,CAAE,CACd,CAAC;IACDlC,cAAc,CAAEd,WAAY,CAAC;IAC7BQ,QAAQ,CAAE;MAAEF,OAAO,EAAEqC;IAAI,CAAE,CAAC;EAC7B,CAAC;EACD,oBACC5C,IAAA,CAACX,cAAc;IACd6D,KAAK,EAAG9D,EAAE,CAAE,SAAU,CAAG;IACzBwB,KAAK,EAAGA,KAAO;IACfuC,aAAa,EAAGnC,eAAiB;IACjCF,WAAW,EAAGA,WAAa;IAC3BL,QAAQ,EAAGiC,cAAgB;IAC3BU,uBAAuB,EAAG,KAAO;IACjCC,uBAAuB;EAAA,CACvB,CAAC;AAEJ;AAEA,eAAe/C,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { RangeControl } from '@wordpress/components';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
const MIN_POSTS_PER_PAGE = 1;
|
|
8
|
+
const MAX_POSTS_PER_PAGE = 100;
|
|
9
|
+
const PerPageControl = ({
|
|
10
|
+
perPage,
|
|
11
|
+
offset = 0,
|
|
12
|
+
onChange
|
|
13
|
+
}) => {
|
|
14
|
+
return /*#__PURE__*/_jsx(RangeControl, {
|
|
15
|
+
__next40pxDefaultSize: true,
|
|
16
|
+
__nextHasNoMarginBottom: true,
|
|
17
|
+
label: __('Posts per page'),
|
|
18
|
+
min: MIN_POSTS_PER_PAGE,
|
|
19
|
+
max: MAX_POSTS_PER_PAGE,
|
|
20
|
+
onChange: newPerPage => {
|
|
21
|
+
if (isNaN(newPerPage) || newPerPage < MIN_POSTS_PER_PAGE || newPerPage > MAX_POSTS_PER_PAGE) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
onChange({
|
|
25
|
+
perPage: newPerPage,
|
|
26
|
+
offset
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
value: parseInt(perPage, 10)
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
export default PerPageControl;
|
|
33
|
+
//# sourceMappingURL=per-page-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["RangeControl","__","jsx","_jsx","MIN_POSTS_PER_PAGE","MAX_POSTS_PER_PAGE","PerPageControl","perPage","offset","onChange","__next40pxDefaultSize","__nextHasNoMarginBottom","label","min","max","newPerPage","isNaN","value","parseInt"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/per-page-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { RangeControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst MIN_POSTS_PER_PAGE = 1;\nconst MAX_POSTS_PER_PAGE = 100;\n\nconst PerPageControl = ( { perPage, offset = 0, onChange } ) => {\n\treturn (\n\t\t<RangeControl\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t\tlabel={ __( 'Posts per page' ) }\n\t\t\tmin={ MIN_POSTS_PER_PAGE }\n\t\t\tmax={ MAX_POSTS_PER_PAGE }\n\t\t\tonChange={ ( newPerPage ) => {\n\t\t\t\tif (\n\t\t\t\t\tisNaN( newPerPage ) ||\n\t\t\t\t\tnewPerPage < MIN_POSTS_PER_PAGE ||\n\t\t\t\t\tnewPerPage > MAX_POSTS_PER_PAGE\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonChange( { perPage: newPerPage, offset } );\n\t\t\t} }\n\t\t\tvalue={ parseInt( perPage, 10 ) }\n\t\t/>\n\t);\n};\n\nexport default PerPageControl;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,uBAAuB;AACpD,SAASC,EAAE,QAAQ,iBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAErC,MAAMC,kBAAkB,GAAG,CAAC;AAC5B,MAAMC,kBAAkB,GAAG,GAAG;AAE9B,MAAMC,cAAc,GAAGA,CAAE;EAAEC,OAAO;EAAEC,MAAM,GAAG,CAAC;EAAEC;AAAS,CAAC,KAAM;EAC/D,oBACCN,IAAA,CAACH,YAAY;IACZU,qBAAqB;IACrBC,uBAAuB;IACvBC,KAAK,EAAGX,EAAE,CAAE,gBAAiB,CAAG;IAChCY,GAAG,EAAGT,kBAAoB;IAC1BU,GAAG,EAAGT,kBAAoB;IAC1BI,QAAQ,EAAKM,UAAU,IAAM;MAC5B,IACCC,KAAK,CAAED,UAAW,CAAC,IACnBA,UAAU,GAAGX,kBAAkB,IAC/BW,UAAU,GAAGV,kBAAkB,EAC9B;QACD;MACD;MACAI,QAAQ,CAAE;QAAEF,OAAO,EAAEQ,UAAU;QAAEP;MAAO,CAAE,CAAC;IAC5C,CAAG;IACHS,KAAK,EAAGC,QAAQ,CAAEX,OAAO,EAAE,EAAG;EAAG,CACjC,CAAC;AAEJ,CAAC;AAED,eAAeD,cAAc","ignoreList":[]}
|
|
@@ -20,11 +20,12 @@ export default function StickyControl({
|
|
|
20
20
|
}) {
|
|
21
21
|
return /*#__PURE__*/_jsx(SelectControl, {
|
|
22
22
|
__nextHasNoMarginBottom: true,
|
|
23
|
+
__next40pxDefaultSize: true,
|
|
23
24
|
label: __('Sticky posts'),
|
|
24
25
|
options: stickyOptions,
|
|
25
26
|
value: value,
|
|
26
27
|
onChange: onChange,
|
|
27
|
-
help: __('
|
|
28
|
+
help: __('Sticky posts always appear first, regardless of their publish date.')
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
31
|
//# sourceMappingURL=sticky-control.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SelectControl","__","jsx","_jsx","stickyOptions","label","value","StickyControl","onChange","__nextHasNoMarginBottom","options","help"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/sticky-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst stickyOptions = [\n\t{ label: __( 'Include' ), value: '' },\n\t{ label: __( 'Exclude' ), value: 'exclude' },\n\t{ label: __( 'Only' ), value: 'only' },\n];\n\nexport default function StickyControl( { value, onChange } ) {\n\treturn (\n\t\t<SelectControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tlabel={ __( 'Sticky posts' ) }\n\t\t\toptions={ stickyOptions }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\thelp={ __(\n\t\t\t\t'
|
|
1
|
+
{"version":3,"names":["SelectControl","__","jsx","_jsx","stickyOptions","label","value","StickyControl","onChange","__nextHasNoMarginBottom","__next40pxDefaultSize","options","help"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/sticky-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst stickyOptions = [\n\t{ label: __( 'Include' ), value: '' },\n\t{ label: __( 'Exclude' ), value: 'exclude' },\n\t{ label: __( 'Only' ), value: 'only' },\n];\n\nexport default function StickyControl( { value, onChange } ) {\n\treturn (\n\t\t<SelectControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Sticky posts' ) }\n\t\t\toptions={ stickyOptions }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\thelp={ __(\n\t\t\t\t'Sticky posts always appear first, regardless of their publish date.'\n\t\t\t) }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,uBAAuB;AACrD,SAASC,EAAE,QAAQ,iBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAErC,MAAMC,aAAa,GAAG,CACrB;EAAEC,KAAK,EAAEJ,EAAE,CAAE,SAAU,CAAC;EAAEK,KAAK,EAAE;AAAG,CAAC,EACrC;EAAED,KAAK,EAAEJ,EAAE,CAAE,SAAU,CAAC;EAAEK,KAAK,EAAE;AAAU,CAAC,EAC5C;EAAED,KAAK,EAAEJ,EAAE,CAAE,MAAO,CAAC;EAAEK,KAAK,EAAE;AAAO,CAAC,CACtC;AAED,eAAe,SAASC,aAAaA,CAAE;EAAED,KAAK;EAAEE;AAAS,CAAC,EAAG;EAC5D,oBACCL,IAAA,CAACH,aAAa;IACbS,uBAAuB;IACvBC,qBAAqB;IACrBL,KAAK,EAAGJ,EAAE,CAAE,cAAe,CAAG;IAC9BU,OAAO,EAAGP,aAAe;IACzBE,KAAK,EAAGA,KAAO;IACfE,QAAQ,EAAGA,QAAU;IACrBI,IAAI,EAAGX,EAAE,CACR,qEACD;EAAG,CACH,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { FormTokenField } from '@wordpress/components';
|
|
4
|
+
import { FormTokenField, __experimentalVStack as VStack } from '@wordpress/components';
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
7
7
|
import { useState, useEffect } from '@wordpress/element';
|
|
@@ -13,7 +13,6 @@ import { decodeEntities } from '@wordpress/html-entities';
|
|
|
13
13
|
*/
|
|
14
14
|
import { useTaxonomies } from '../../utils';
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
16
|
const EMPTY_ARRAY = [];
|
|
18
17
|
const BASE_QUERY = {
|
|
19
18
|
order: 'asc',
|
|
@@ -53,7 +52,8 @@ export function TaxonomyControls({
|
|
|
53
52
|
if (!taxonomies || taxonomies.length === 0) {
|
|
54
53
|
return null;
|
|
55
54
|
}
|
|
56
|
-
return /*#__PURE__*/_jsx(
|
|
55
|
+
return /*#__PURE__*/_jsx(VStack, {
|
|
56
|
+
spacing: 4,
|
|
57
57
|
children: taxonomies.map(taxonomy => {
|
|
58
58
|
const termIds = taxQuery?.[taxonomy.slug] || [];
|
|
59
59
|
const handleChange = newTermIds => onChange({
|
|
@@ -181,7 +181,9 @@ function TaxonomyItem({
|
|
|
181
181
|
suggestions: suggestions,
|
|
182
182
|
displayTransform: decodeEntities,
|
|
183
183
|
onChange: onTermsChange,
|
|
184
|
-
__experimentalShowHowTo: false
|
|
184
|
+
__experimentalShowHowTo: false,
|
|
185
|
+
__nextHasNoMarginBottom: true,
|
|
186
|
+
__next40pxDefaultSize: true
|
|
185
187
|
})
|
|
186
188
|
});
|
|
187
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FormTokenField","useSelect","store","coreStore","useState","useEffect","useDebounce","decodeEntities","useTaxonomies","jsx","_jsx","Fragment","_Fragment","EMPTY_ARRAY","BASE_QUERY","order","_fields","context","getTermIdByTermValue","terms","termValue","termId","id","find","term","name","termValueLower","toLocaleLowerCase","TaxonomyControls","onChange","query","postType","taxQuery","taxonomies","length","children","map","taxonomy","termIds","slug","handleChange","newTermIds","TaxonomyItem","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","selectorArgs","orderby","exclude","per_page","existingTerms","include","sanitizedValue","reduce","accumulator","entity","push","result","onTermsChange","newTermValues","Set","add","Array","from","className","label","onInputChange","displayTransform","__experimentalShowHowTo"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { useTaxonomies } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( terms, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId =\n\t\ttermValue?.id || terms?.find( ( term ) => term.name === termValue )?.id;\n\tif ( termId ) {\n\t\treturn termId;\n\t}\n\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\treturn terms?.find(\n\t\t( term ) => term.name.toLocaleLowerCase() === termValueLower\n\t)?.id;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst { postType, taxQuery } = query;\n\n\tconst taxonomies = useTaxonomies( postType );\n\tif ( ! taxonomies || taxonomies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ taxonomies.map( ( taxonomy ) => {\n\t\t\t\tconst termIds = taxQuery?.[ taxonomy.slug ] || [];\n\t\t\t\tconst handleChange = ( newTermIds ) =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\ttaxQuery: {\n\t\t\t\t\t\t\t...taxQuery,\n\t\t\t\t\t\t\t[ taxonomy.slug ]: newTermIds,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\treturn (\n\t\t\t\t\t<TaxonomyItem\n\t\t\t\t\t\tkey={ taxonomy.slug }\n\t\t\t\t\t\ttaxonomy={ taxonomy }\n\t\t\t\t\t\ttermIds={ termIds }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\n/**\n * Renders a `FormTokenField` for a given taxonomy.\n *\n * @param {Object} props The props for the component.\n * @param {Object} props.taxonomy The taxonomy object.\n * @param {number[]} props.termIds An array with the block's term ids for the given taxonomy.\n * @param {Function} props.onChange Callback `onChange` function.\n * @return {JSX.Element} The rendered component.\n */\nfunction TaxonomyItem( { taxonomy, termIds, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'taxonomy',\n\t\t\t\ttaxonomy.slug,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'name',\n\t\t\t\t\texclude: termIds,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, termIds ]\n\t);\n\t// `existingTerms` are the ones fetched from the API and their type is `{ id: number; name: string }`.\n\t// They are used to extract the terms' names to populate the `FormTokenField` properly\n\t// and to sanitize the provided `termIds`, by setting only the ones that exist.\n\tconst existingTerms = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! termIds?.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'taxonomy', taxonomy.slug, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: termIds,\n\t\t\t\tper_page: termIds.length,\n\t\t\t} );\n\t\t},\n\t\t[ termIds ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing terms.\n\tuseEffect( () => {\n\t\tif ( ! termIds?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! existingTerms?.length ) {\n\t\t\treturn;\n\t\t}\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = termIds.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = existingTerms.find( ( term ) => term.id === id );\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ termIds, existingTerms ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) {\n\t\t\treturn;\n\t\t}\n\t\tsetSuggestions( searchResults.map( ( result ) => result.name ) );\n\t}, [ searchResults, searchHasResolved ] );\n\tconst onTermsChange = ( newTermValues ) => {\n\t\tconst newTermIds = new Set();\n\t\tfor ( const termValue of newTermValues ) {\n\t\t\tconst termId = getTermIdByTermValue( searchResults, termValue );\n\t\t\tif ( termId ) {\n\t\t\t\tnewTermIds.add( termId );\n\t\t\t}\n\t\t}\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( Array.from( newTermIds ) );\n\t};\n\treturn (\n\t\t<div className=\"block-library-query-inspector__taxonomy-control\">\n\t\t\t<FormTokenField\n\t\t\t\tlabel={ taxonomy.name }\n\t\t\t\tvalue={ value }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tdisplayTransform={ decodeEntities }\n\t\t\t\tonChange={ onTermsChange }\n\t\t\t\t__experimentalShowHowTo={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAc,QAAQ,uBAAuB;AACtD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;AACxD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,SAASC,aAAa,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAE5C,MAAMC,WAAW,GAAG,EAAE;AACtB,MAAMC,UAAU,GAAG;EAClBC,KAAK,EAAE,KAAK;EACZC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE;AACV,CAAC;;AAED;AACA,MAAMC,oBAAoB,GAAGA,CAAEC,KAAK,EAAEC,SAAS,KAAM;EACpD;EACA,MAAMC,MAAM,GACXD,SAAS,EAAEE,EAAE,IAAIH,KAAK,EAAEI,IAAI,CAAIC,IAAI,IAAMA,IAAI,CAACC,IAAI,KAAKL,SAAU,CAAC,EAAEE,EAAE;EACxE,IAAKD,MAAM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,UAAU,CAAC6B,GAAG,CAAEjD,MAAO,CAAC;MACzB;IACD;IACA2B,cAAc,CAAEnC,WAAY,CAAC;IAC7BgB,QAAQ,CAAE0C,KAAK,CAACC,IAAI,CAAE/B,UAAW,CAAE,CAAC;EACrC,CAAC;EACD,oBACC/B,IAAA;IAAK+D,SAAS,EAAC,iDAAiD;IAAAtC,QAAA,eAC/DzB,IAAA,CAACV,cAAc;MACd0E,KAAK,EAAGrC,QAAQ,CAACZ,IAAM;MACvBoB,KAAK,EAAGA,KAAO;MACf8B,aAAa,EAAG1B,eAAiB;MACjCF,WAAW,EAAGA,WAAa;MAC3B6B,gBAAgB,EAAGrE,cAAgB;MACnCsB,QAAQ,EAAGsC,aAAe;MAC1BU,uBAAuB,EAAG;IAAO,CACjC;EAAC,CACE,CAAC;AAER","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["FormTokenField","__experimentalVStack","VStack","useSelect","store","coreStore","useState","useEffect","useDebounce","decodeEntities","useTaxonomies","jsx","_jsx","EMPTY_ARRAY","BASE_QUERY","order","_fields","context","getTermIdByTermValue","terms","termValue","termId","id","find","term","name","termValueLower","toLocaleLowerCase","TaxonomyControls","onChange","query","postType","taxQuery","taxonomies","length","spacing","children","map","taxonomy","termIds","slug","handleChange","newTermIds","TaxonomyItem","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","selectorArgs","orderby","exclude","per_page","existingTerms","include","sanitizedValue","reduce","accumulator","entity","push","result","onTermsChange","newTermValues","Set","add","Array","from","className","label","onInputChange","displayTransform","__experimentalShowHowTo","__nextHasNoMarginBottom","__next40pxDefaultSize"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tFormTokenField,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { useTaxonomies } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( terms, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId =\n\t\ttermValue?.id || terms?.find( ( term ) => term.name === termValue )?.id;\n\tif ( termId ) {\n\t\treturn termId;\n\t}\n\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\treturn terms?.find(\n\t\t( term ) => term.name.toLocaleLowerCase() === termValueLower\n\t)?.id;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst { postType, taxQuery } = query;\n\n\tconst taxonomies = useTaxonomies( postType );\n\tif ( ! taxonomies || taxonomies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 4 }>\n\t\t\t{ taxonomies.map( ( taxonomy ) => {\n\t\t\t\tconst termIds = taxQuery?.[ taxonomy.slug ] || [];\n\t\t\t\tconst handleChange = ( newTermIds ) =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\ttaxQuery: {\n\t\t\t\t\t\t\t...taxQuery,\n\t\t\t\t\t\t\t[ taxonomy.slug ]: newTermIds,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\treturn (\n\t\t\t\t\t<TaxonomyItem\n\t\t\t\t\t\tkey={ taxonomy.slug }\n\t\t\t\t\t\ttaxonomy={ taxonomy }\n\t\t\t\t\t\ttermIds={ termIds }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</VStack>\n\t);\n}\n\n/**\n * Renders a `FormTokenField` for a given taxonomy.\n *\n * @param {Object} props The props for the component.\n * @param {Object} props.taxonomy The taxonomy object.\n * @param {number[]} props.termIds An array with the block's term ids for the given taxonomy.\n * @param {Function} props.onChange Callback `onChange` function.\n * @return {JSX.Element} The rendered component.\n */\nfunction TaxonomyItem( { taxonomy, termIds, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'taxonomy',\n\t\t\t\ttaxonomy.slug,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'name',\n\t\t\t\t\texclude: termIds,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, termIds ]\n\t);\n\t// `existingTerms` are the ones fetched from the API and their type is `{ id: number; name: string }`.\n\t// They are used to extract the terms' names to populate the `FormTokenField` properly\n\t// and to sanitize the provided `termIds`, by setting only the ones that exist.\n\tconst existingTerms = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! termIds?.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'taxonomy', taxonomy.slug, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: termIds,\n\t\t\t\tper_page: termIds.length,\n\t\t\t} );\n\t\t},\n\t\t[ termIds ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing terms.\n\tuseEffect( () => {\n\t\tif ( ! termIds?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! existingTerms?.length ) {\n\t\t\treturn;\n\t\t}\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = termIds.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = existingTerms.find( ( term ) => term.id === id );\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ termIds, existingTerms ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) {\n\t\t\treturn;\n\t\t}\n\t\tsetSuggestions( searchResults.map( ( result ) => result.name ) );\n\t}, [ searchResults, searchHasResolved ] );\n\tconst onTermsChange = ( newTermValues ) => {\n\t\tconst newTermIds = new Set();\n\t\tfor ( const termValue of newTermValues ) {\n\t\t\tconst termId = getTermIdByTermValue( searchResults, termValue );\n\t\t\tif ( termId ) {\n\t\t\t\tnewTermIds.add( termId );\n\t\t\t}\n\t\t}\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( Array.from( newTermIds ) );\n\t};\n\treturn (\n\t\t<div className=\"block-library-query-inspector__taxonomy-control\">\n\t\t\t<FormTokenField\n\t\t\t\tlabel={ taxonomy.name }\n\t\t\t\tvalue={ value }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tdisplayTransform={ decodeEntities }\n\t\t\t\tonChange={ onTermsChange }\n\t\t\t\t__experimentalShowHowTo={ false }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,cAAc,EACdC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;AACxD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,SAASC,aAAa,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE5C,MAAMC,WAAW,GAAG,EAAE;AACtB,MAAMC,UAAU,GAAG;EAClBC,KAAK,EAAE,KAAK;EACZC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE;AACV,CAAC;;AAED;AACA,MAAMC,oBAAoB,GAAGA,CAAEC,KAAK,EAAEC,SAAS,KAAM;EACpD;EACA,MAAMC,MAAM,GACXD,SAAS,EAAEE,EAAE,IAAIH,KAAK,EAAEI,IAAI,CAAIC,IAAI,IAAMA,IAAI,CAACC,IAAI,KAAKL,SAAU,CAAC,EAAEE,EAAE;EACxE,IAAKD,MAAM,EAAG;IACb,OAAOA,MAAM;EACd;;EAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMK,cAAc,GAAGN,SAAS,CAACO,iBAAiB,CAAC,CAAC;EACpD,OAAOR,KAAK,EAAEI,IAAI,CACfC,IAAI,I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;EACrC,CAAC;EACD,oBACC9B,IAAA;IAAK8D,SAAS,EAAC,iDAAiD;IAAAtC,QAAA,eAC/DxB,IAAA,CAACZ,cAAc;MACd2E,KAAK,EAAGrC,QAAQ,CAACb,IAAM;MACvBqB,KAAK,EAAGA,KAAO;MACf8B,aAAa,EAAG1B,eAAiB;MACjCF,WAAW,EAAGA,WAAa;MAC3B6B,gBAAgB,EAAGpE,cAAgB;MACnCoB,QAAQ,EAAGuC,aAAe;MAC1BU,uBAAuB,EAAG,KAAO;MACjCC,uBAAuB;MACvBC,qBAAqB;IAAA,CACrB;EAAC,CACE,CAAC;AAER","ignoreList":[]}
|
|
@@ -52,11 +52,20 @@ export default function QueryContent({
|
|
|
52
52
|
} = select(blockEditorStore);
|
|
53
53
|
const {
|
|
54
54
|
getEntityRecord,
|
|
55
|
+
getEntityRecordEdits,
|
|
55
56
|
canUser
|
|
56
57
|
} = select(coreStore);
|
|
57
|
-
const settingPerPage = canUser('read',
|
|
58
|
+
const settingPerPage = canUser('read', {
|
|
59
|
+
kind: 'root',
|
|
60
|
+
name: 'site'
|
|
61
|
+
}) ? +getEntityRecord('root', 'site')?.posts_per_page : +getSettings().postsPerPage;
|
|
62
|
+
|
|
63
|
+
// Gets changes made via the template area posts per page setting. These won't be saved
|
|
64
|
+
// until the page is saved, but we should reflect this setting within the query loops
|
|
65
|
+
// that inherit it.
|
|
66
|
+
const editedSettingPerPage = +getEntityRecordEdits('root', 'site')?.posts_per_page;
|
|
58
67
|
return {
|
|
59
|
-
postsPerPage: settingPerPage || DEFAULTS_POSTS_PER_PAGE
|
|
68
|
+
postsPerPage: editedSettingPerPage || settingPerPage || DEFAULTS_POSTS_PER_PAGE
|
|
60
69
|
};
|
|
61
70
|
}, []);
|
|
62
71
|
// There are some effects running where some initialization logic is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","useInstanceId","useEffect","BlockControls","InspectorControls","useBlockProps","store","blockEditorStore","useInnerBlocksProps","SelectControl","__","coreStore","QueryToolbar","QueryInspectorControls","EnhancedPaginationModal","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","inherit","__unstableMarkNextChangeAsNotPersistent","instanceId","blockProps","innerBlocksProps","template","postsPerPage","select","getSettings","getEntityRecord","canUser","settingPerPage","posts_per_page","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","htmlElementMessages","main","section","aside","children","setQuery","setDisplayLayout","group","__nextHasNoMarginBottom","__next40pxDefaultSize","label","options","value","onChange","help"],"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\nimport EnhancedPaginationModal from './enhanced-pagination-modal';\n\nconst DEFAULTS_POSTS_PER_PAGE = 3;\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport default function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\ttagName: TagName = 'div',\n\t\tquery: { inherit } = {},\n\t} = attributes;\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getEntityRecord, canUser } = select( coreStore );\n\t\tconst settingPerPage = canUser( 'read', 'settings' )\n\t\t\t? +getEntityRecord( 'root', 'site' )?.posts_per_page\n\t\t\t: +getSettings().postsPerPage;\n\t\treturn {\n\t\t\tpostsPerPage: settingPerPage || DEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\t// When we inherit from global query always need to set the `perPage`\n\t\t// based on the reading settings.\n\t\tif ( inherit && query.perPage !== postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t} else if ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [ query.perPage, postsPerPage, inherit ] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [ queryId, instanceId ] );\n\tconst updateQuery = ( newQuery ) =>\n\t\tsetAttributes( { query: { ...query, ...newQuery } } );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\tconst htmlElementMessages = {\n\t\tmain: __(\n\t\t\t'The <main> element should be used for the primary content of your document only. '\n\t\t),\n\t\tsection: __(\n\t\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t\t),\n\t\taside: __(\n\t\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t\t),\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<EnhancedPaginationModal\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tclientId={ clientId }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<QueryInspectorControls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ htmlElementMessages[ TagName ] }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SACCC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,mBAAmB,QACb,yBAAyB;AAChC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASJ,KAAK,IAAIK,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,sBAAsB,MAAM,sBAAsB;AACzD,OAAOC,uBAAuB,MAAM,6BAA6B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAElE,MAAMC,uBAAuB,GAAG,CAAC;AAEjC,MAAMC,QAAQ,GAAG,CAAE,CAAE,oBAAoB,CAAE,CAAE;AAC7C,eAAe,SAASC,YAAYA,CAAE;EACrCC,UAAU;EACVC,aAAa;EACbC,yBAAyB;EACzBC,IAAI;EACJC;AACD,CAAC,EAAG;EACH,MAAM;IACLC,OAAO;IACPC,KAAK;IACLC,aAAa;IACbC,OAAO,EAAEC,OAAO,GAAG,KAAK;IACxBH,KAAK,EAAE;MAAEI;IAAQ,CAAC,GAAG,CAAC;EACvB,CAAC,GAAGV,UAAU;EACd,MAAM;IAAEW;EAAwC,CAAC,GAChDnC,WAAW,CAAEO,gBAAiB,CAAC;EAChC,MAAM6B,UA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ACzBsC,QAAQ,EAAGV,WAAa;QACxB1B,yBAAyB,EAAGA;MAA2B,CACvD;IAAC,CACY,CAAC,eAChBV,IAAA,CAACZ,iBAAiB;MAAC4D,KAAK,EAAC,UAAU;MAAAH,QAAA,eAClC7C,IAAA,CAACP,aAAa;QACbwD,uBAAuB;QACvBC,qBAAqB;QACrBC,KAAK,EAAGzD,EAAE,CAAE,cAAe,CAAG;QAC9B0D,OAAO,EAAG,CACT;UAAED,KAAK,EAAEzD,EAAE,CAAE,iBAAkB,CAAC;UAAE2D,KAAK,EAAE;QAAM,CAAC,EAChD;UAAEF,KAAK,EAAE,QAAQ;UAAEE,KAAK,EAAE;QAAO,CAAC,EAClC;UAAEF,KAAK,EAAE,WAAW;UAAEE,KAAK,EAAE;QAAU,CAAC,EACxC;UAAEF,KAAK,EAAE,SAAS;UAAEE,KAAK,EAAE;QAAQ,CAAC,CAClC;QACHA,KAAK,EAAGpC,OAAS;QACjBqC,QAAQ,EAAKD,KAAK,IACjB5C,aAAa,CAAE;UAAEO,OAAO,EAAEqC;QAAM,CAAE,CAClC;QACDE,IAAI,EAAGd,mBAAmB,CAAExB,OAAO;MAAI,CACvC;IAAC,CACgB,CAAC,eACpBjB,IAAA,CAACiB,OAAO;MAAA,GAAMK;IAAgB,CAAI,CAAC;EAAA,CAClC,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","useInstanceId","useEffect","BlockControls","InspectorControls","useBlockProps","store","blockEditorStore","useInnerBlocksProps","SelectControl","__","coreStore","QueryToolbar","QueryInspectorControls","EnhancedPaginationModal","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","inherit","__unstableMarkNextChangeAsNotPersistent","instanceId","blockProps","innerBlocksProps","template","postsPerPage","select","getSettings","getEntityRecord","getEntityRecordEdits","canUser","settingPerPage","kind","posts_per_page","editedSettingPerPage","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","htmlElementMessages","main","section","aside","children","setQuery","setDisplayLayout","group","__nextHasNoMarginBottom","__next40pxDefaultSize","label","options","value","onChange","help"],"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\nimport EnhancedPaginationModal from './enhanced-pagination-modal';\n\nconst DEFAULTS_POSTS_PER_PAGE = 3;\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport default function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\ttagName: TagName = 'div',\n\t\tquery: { inherit } = {},\n\t} = attributes;\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getEntityRecord, getEntityRecordEdits, canUser } =\n\t\t\tselect( coreStore );\n\t\tconst settingPerPage = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? +getEntityRecord( 'root', 'site' )?.posts_per_page\n\t\t\t: +getSettings().postsPerPage;\n\n\t\t// Gets changes made via the template area posts per page setting. These won't be saved\n\t\t// until the page is saved, but we should reflect this setting within the query loops\n\t\t// that inherit it.\n\t\tconst editedSettingPerPage = +getEntityRecordEdits( 'root', 'site' )\n\t\t\t?.posts_per_page;\n\n\t\treturn {\n\t\t\tpostsPerPage:\n\t\t\t\teditedSettingPerPage ||\n\t\t\t\tsettingPerPage ||\n\t\t\t\tDEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\t// When we inherit from global query always need to set the `perPage`\n\t\t// based on the reading settings.\n\t\tif ( inherit && query.perPage !== postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t} else if ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [ query.perPage, postsPerPage, inherit ] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [ queryId, instanceId ] );\n\tconst updateQuery = ( newQuery ) =>\n\t\tsetAttributes( { query: { ...query, ...newQuery } } );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\tconst htmlElementMessages = {\n\t\tmain: __(\n\t\t\t'The <main> element should be used for the primary content of your document only. '\n\t\t),\n\t\tsection: __(\n\t\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t\t),\n\t\taside: __(\n\t\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t\t),\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<EnhancedPaginationModal\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tclientId={ clientId }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<QueryInspectorControls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ htmlElementMessages[ TagName ] }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SACCC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,mBAAmB,QACb,yBAAyB;AAChC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASJ,KAAK,IAAIK,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,sBAAsB,MAAM,sBAAsB;AACzD,OAAOC,uBAAuB,MAAM,6BAA6B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAElE,MAAMC,uBAAuB,GAAG,CAAC;AAEjC,MAAMC,QAAQ,GAAG,CAAE,CAAE,oBAAoB,CAAE,CAAE;AAC7C,eAAe,SAASC,YAAYA,CAAE;EACrCC,UAAU;EACVC,aAAa;EACbC,yBAAyB;EACzBC,IAAI;EACJC;AACD,CAAC,EAAG;EACH,MAAM;IACLC,OAAO;IACPC,KAAK;IACLC,aAAa;IACbC,OAAO,EAAEC,OAAO,GAAG,KAAK;IACxBH,KAAK,EAAE;MAAEI;IAAQ,CAAC,GAAG,CAAC;EACvB,CAAC,GAAGV,UAAU;EACd,MAAM;IAAEW;EAAwC,CAAC,GAChDnC,WAAW,CAAEO,gBAAiB,CAAC;EAChC,MAA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Q,EAAGA;MAAU,CACrB;IAAC,CACgB,CAAC,eACpBZ,IAAA,CAACb,aAAa;MAAA6D,QAAA,eACbhD,IAAA,CAACJ,YAAY;QACZe,IAAI,EAAGA,IAAM;QACbC,QAAQ,EAAGA,QAAU;QACrBJ,UAAU,EAAGA,UAAY;QACzByC,QAAQ,EAAGV,WAAa;QACxB7B,yBAAyB,EAAGA;MAA2B,CACvD;IAAC,CACY,CAAC,eAChBV,IAAA,CAACZ,iBAAiB;MAAC+D,KAAK,EAAC,UAAU;MAAAH,QAAA,eAClChD,IAAA,CAACP,aAAa;QACb2D,uBAAuB;QACvBC,qBAAqB;QACrBC,KAAK,EAAG5D,EAAE,CAAE,cAAe,CAAG;QAC9B6D,OAAO,EAAG,CACT;UAAED,KAAK,EAAE5D,EAAE,CAAE,iBAAkB,CAAC;UAAE8D,KAAK,EAAE;QAAM,CAAC,EAChD;UAAEF,KAAK,EAAE,QAAQ;UAAEE,KAAK,EAAE;QAAO,CAAC,EAClC;UAAEF,KAAK,EAAE,WAAW;UAAEE,KAAK,EAAE;QAAU,CAAC,EACxC;UAAEF,KAAK,EAAE,SAAS;UAAEE,KAAK,EAAE;QAAQ,CAAC,CAClC;QACHA,KAAK,EAAGvC,OAAS;QACjBwC,QAAQ,EAAKD,KAAK,IACjB/C,aAAa,CAAE;UAAEO,OAAO,EAAEwC;QAAM,CAAE,CAClC;QACDE,IAAI,EAAGd,mBAAmB,CAAE3B,OAAO;MAAI,CACvC;IAAC,CACgB,CAAC,eACpBjB,IAAA,CAACiB,OAAO;MAAA,GAAMK;IAAgB,CAAI,CAAC;EAAA,CAClC,CAAC;AAEL","ignoreList":[]}
|
|
@@ -18,8 +18,7 @@ export default function QueryPlaceholder({
|
|
|
18
18
|
attributes,
|
|
19
19
|
clientId,
|
|
20
20
|
name,
|
|
21
|
-
openPatternSelectionModal
|
|
22
|
-
setAttributes
|
|
21
|
+
openPatternSelectionModal
|
|
23
22
|
}) {
|
|
24
23
|
const [isStartingBlank, setIsStartingBlank] = useState(false);
|
|
25
24
|
const blockProps = useBlockProps();
|
|
@@ -50,7 +49,6 @@ export default function QueryPlaceholder({
|
|
|
50
49
|
return /*#__PURE__*/_jsx(QueryVariationPicker, {
|
|
51
50
|
clientId: clientId,
|
|
52
51
|
attributes: attributes,
|
|
53
|
-
setAttributes: setAttributes,
|
|
54
52
|
icon: icon,
|
|
55
53
|
label: label
|
|
56
54
|
});
|
|
@@ -78,7 +76,6 @@ export default function QueryPlaceholder({
|
|
|
78
76
|
function QueryVariationPicker({
|
|
79
77
|
clientId,
|
|
80
78
|
attributes,
|
|
81
|
-
setAttributes,
|
|
82
79
|
icon,
|
|
83
80
|
label
|
|
84
81
|
}) {
|
|
@@ -94,16 +91,6 @@ function QueryVariationPicker({
|
|
|
94
91
|
label: label,
|
|
95
92
|
variations: scopeVariations,
|
|
96
93
|
onSelect: variation => {
|
|
97
|
-
if (variation.attributes) {
|
|
98
|
-
setAttributes({
|
|
99
|
-
...variation.attributes,
|
|
100
|
-
query: {
|
|
101
|
-
...variation.attributes.query,
|
|
102
|
-
postType: attributes.query.postType || variation.attributes.query.postType
|
|
103
|
-
},
|
|
104
|
-
namespace: attributes.namespace
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
94
|
if (variation.innerBlocks) {
|
|
108
95
|
replaceInnerBlocks(clientId, createBlocksFromInnerBlocksTemplate(variation.innerBlocks), false);
|
|
109
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","createBlocksFromInnerBlocksTemplate","store","blocksStore","useState","useBlockProps","blockEditorStore","__experimentalBlockVariationPicker","Button","Placeholder","__","useScopedBlockVariations","useBlockNameForPatterns","jsx","_jsx","jsxs","_jsxs","QueryPlaceholder","attributes","clientId","name","openPatternSelectionModal","
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","createBlocksFromInnerBlocksTemplate","store","blocksStore","useState","useBlockProps","blockEditorStore","__experimentalBlockVariationPicker","Button","Placeholder","__","useScopedBlockVariations","useBlockNameForPatterns","jsx","_jsx","jsxs","_jsxs","QueryPlaceholder","attributes","clientId","name","openPatternSelectionModal","isStartingBlank","setIsStartingBlank","blockProps","blockNameForPatterns","blockType","activeBlockVariation","hasPatterns","select","getActiveBlockVariation","getBlockType","getBlockRootClientId","getPatternsByBlockTypes","rootClientId","length","icon","src","label","title","QueryVariationPicker","children","instructions","variant","onClick","scopeVariations","replaceInnerBlocks","variations","onSelect","variation","innerBlocks"],"sources":["@wordpress/block-library/src/query/edit/query-placeholder.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useState } from '@wordpress/element';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalBlockVariationPicker,\n} from '@wordpress/block-editor';\nimport { Button, Placeholder } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useScopedBlockVariations, useBlockNameForPatterns } from '../utils';\n\nexport default function QueryPlaceholder( {\n\tattributes,\n\tclientId,\n\tname,\n\topenPatternSelectionModal,\n} ) {\n\tconst [ isStartingBlank, setIsStartingBlank ] = useState( false );\n\tconst blockProps = useBlockProps();\n\tconst blockNameForPatterns = useBlockNameForPatterns(\n\t\tclientId,\n\t\tattributes\n\t);\n\tconst { blockType, activeBlockVariation, hasPatterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockType } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tactiveBlockVariation: getActiveBlockVariation(\n\t\t\t\t\tname,\n\t\t\t\t\tattributes\n\t\t\t\t),\n\t\t\t\thasPatterns: !! getPatternsByBlockTypes(\n\t\t\t\t\tblockNameForPatterns,\n\t\t\t\t\trootClientId\n\t\t\t\t).length,\n\t\t\t};\n\t\t},\n\t\t[ name, blockNameForPatterns, clientId, attributes ]\n\t);\n\tconst icon =\n\t\tactiveBlockVariation?.icon?.src ||\n\t\tactiveBlockVariation?.icon ||\n\t\tblockType?.icon?.src;\n\tconst label = activeBlockVariation?.title || blockType?.title;\n\tif ( isStartingBlank ) {\n\t\treturn (\n\t\t\t<QueryVariationPicker\n\t\t\t\tclientId={ clientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Choose a pattern for the query loop or start blank.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ !! hasPatterns && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ openPatternSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetIsStartingBlank( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t</Placeholder>\n\t\t</div>\n\t);\n}\n\nfunction QueryVariationPicker( { clientId, attributes, icon, label } ) {\n\tconst scopeVariations = useScopedBlockVariations( attributes );\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<__experimentalBlockVariationPicker\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tvariations={ scopeVariations }\n\t\t\t\tonSelect={ ( variation ) => {\n\t\t\t\t\tif ( variation.innerBlocks ) {\n\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\tvariation.innerBlocks\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tfalse\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</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,mCAAmC,EACnCC,KAAK,IAAIC,WAAW,QACd,mBAAmB;AAC1B,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SACCC,aAAa,EACbH,KAAK,IAAII,gBAAgB,EACzBC,kCAAkC,QAC5B,yBAAyB;AAChC,SAASC,MAAM,EAAEC,WAAW,QAAQ,uBAAuB;AAC3D,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,wBAAwB,EAAEC,uBAAuB,QAAQ,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE7E,eAAe,SAASC,gBAAgBA,CAAE;EACzCC,UAAU;EACVC,QAAQ;EACRC,IAAI;EACJC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,eAAe,EAAEC,kBAAkB,CAAE,GAAGnB,QAAQ,CAAE,KAAM,CAAC;EACjE,MAAMoB,UAAU,GAAGnB,aAAa,CAAC,CAAC;EAClC,MAAMoB,oBAAoB,GAAGb,uBAAuB,CACnDO,QAAQ,EACRD,UACD,CAAC;EACD,MAAM;IAAEQ,SAAS;IAAEC,oBAAoB;IAAEC;EAAY,CAAC,GAAG7B,SAAS,CAC/D8B,MAAM,IAAM;IACb,MAAM;MAAEC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AAC,CACT,CACR,eAEDI,IAAA,CAACN,MAAM;QACNmC,OAAO,EAAC,WAAW;QACnBC,OAAO,EAAGA,CAAA,KAAM;UACfrB,kBAAkB,CAAE,IAAK,CAAC;QAC3B,CAAG;QAAAkB,QAAA,EAED/B,EAAE,CAAE,aAAc;MAAC,CACd,CAAC;IAAA,CACG;EAAC,CACV,CAAC;AAER;AAEA,SAAS8B,oBAAoBA,CAAE;EAAErB,QAAQ;EAAED,UAAU;EAAEkB,IAAI;EAAEE;AAAM,CAAC,EAAG;EACtE,MAAMO,eAAe,GAAGlC,wBAAwB,CAAEO,UAAW,CAAC;EAC9D,MAAM;IAAE4B;EAAmB,CAAC,GAAG9C,WAAW,CAAEM,gBAAiB,CAAC;EAC9D,MAAMkB,UAAU,GAAGnB,aAAa,CAAC,CAAC;EAClC,oBACCS,IAAA;IAAA,GAAUU,UAAU;IAAAiB,QAAA,eACnB3B,IAAA,CAACP,kCAAkC;MAClC6B,IAAI,EAAGA,IAAM;MACbE,KAAK,EAAGA,KAAO;MACfS,UAAU,EAAGF,eAAiB;MAC9BG,QAAQ,EAAKC,SAAS,IAAM;QAC3B,IAAKA,SAAS,CAACC,WAAW,EAAG;UAC5BJ,kBAAkB,CACjB3B,QAAQ,EACRlB,mCAAmC,CAClCgD,SAAS,CAACC,WACX,CAAC,EACD,KACD,CAAC;QACF;MACD;IAAG,CACH;EAAC,CACE,CAAC;AAER","ignoreList":[]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { ToolbarGroup,
|
|
4
|
+
import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import { settings } from '@wordpress/icons';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Internal dependencies
|
|
@@ -11,93 +10,20 @@ import { settings } from '@wordpress/icons';
|
|
|
11
10
|
import { usePatterns } from '../utils';
|
|
12
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
12
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
13
|
export default function QueryToolbar({
|
|
16
|
-
attributes: {
|
|
17
|
-
query
|
|
18
|
-
},
|
|
19
|
-
setQuery,
|
|
20
14
|
openPatternSelectionModal,
|
|
21
15
|
name,
|
|
22
16
|
clientId
|
|
23
17
|
}) {
|
|
24
18
|
const hasPatterns = !!usePatterns(clientId, name).length;
|
|
25
|
-
return /*#__PURE__*/
|
|
26
|
-
children:
|
|
27
|
-
children: /*#__PURE__*/_jsx(Dropdown, {
|
|
28
|
-
contentClassName: "block-library-query-toolbar__popover",
|
|
29
|
-
renderToggle: ({
|
|
30
|
-
onToggle
|
|
31
|
-
}) => /*#__PURE__*/_jsx(ToolbarButton, {
|
|
32
|
-
icon: settings,
|
|
33
|
-
label: __('Display settings'),
|
|
34
|
-
onClick: onToggle
|
|
35
|
-
}),
|
|
36
|
-
renderContent: () => /*#__PURE__*/_jsxs(_Fragment, {
|
|
37
|
-
children: [/*#__PURE__*/_jsx(NumberControl, {
|
|
38
|
-
__unstableInputWidth: "60px",
|
|
39
|
-
className: "block-library-query-toolbar__popover-number-control",
|
|
40
|
-
label: __('Items per Page'),
|
|
41
|
-
labelPosition: "edge",
|
|
42
|
-
min: 1,
|
|
43
|
-
max: 100,
|
|
44
|
-
onChange: value => {
|
|
45
|
-
if (isNaN(value) || value < 1 || value > 100) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
setQuery({
|
|
49
|
-
perPage: value
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
step: "1",
|
|
53
|
-
value: query.perPage,
|
|
54
|
-
isDragEnabled: false
|
|
55
|
-
}), /*#__PURE__*/_jsx(NumberControl, {
|
|
56
|
-
__unstableInputWidth: "60px",
|
|
57
|
-
className: "block-library-query-toolbar__popover-number-control",
|
|
58
|
-
label: __('Offset'),
|
|
59
|
-
labelPosition: "edge",
|
|
60
|
-
min: 0,
|
|
61
|
-
max: 100,
|
|
62
|
-
onChange: value => {
|
|
63
|
-
if (isNaN(value) || value < 0 || value > 100) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
setQuery({
|
|
67
|
-
offset: value
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
step: "1",
|
|
71
|
-
value: query.offset,
|
|
72
|
-
isDragEnabled: false
|
|
73
|
-
}), /*#__PURE__*/_jsx(NumberControl, {
|
|
74
|
-
__unstableInputWidth: "60px",
|
|
75
|
-
className: "block-library-query-toolbar__popover-number-control",
|
|
76
|
-
label: __('Max pages to show'),
|
|
77
|
-
labelPosition: "edge",
|
|
78
|
-
min: 0,
|
|
79
|
-
onChange: value => {
|
|
80
|
-
if (isNaN(value) || value < 0) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
setQuery({
|
|
84
|
-
pages: value
|
|
85
|
-
});
|
|
86
|
-
},
|
|
87
|
-
step: "1",
|
|
88
|
-
value: query.pages,
|
|
89
|
-
isDragEnabled: false,
|
|
90
|
-
help: __('Limit the pages you want to show, even if the query has more results. To show all pages use 0 (zero).')
|
|
91
|
-
})]
|
|
92
|
-
})
|
|
93
|
-
})
|
|
94
|
-
}), hasPatterns && /*#__PURE__*/_jsx(ToolbarGroup, {
|
|
19
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
20
|
+
children: hasPatterns && /*#__PURE__*/_jsx(ToolbarGroup, {
|
|
95
21
|
className: "wp-block-template-part__block-control-group",
|
|
96
22
|
children: /*#__PURE__*/_jsx(ToolbarButton, {
|
|
97
23
|
onClick: openPatternSelectionModal,
|
|
98
24
|
children: __('Replace')
|
|
99
25
|
})
|
|
100
|
-
})
|
|
26
|
+
})
|
|
101
27
|
});
|
|
102
28
|
}
|
|
103
29
|
//# sourceMappingURL=query-toolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ToolbarGroup","
|
|
1
|
+
{"version":3,"names":["ToolbarGroup","ToolbarButton","__","usePatterns","jsx","_jsx","Fragment","_Fragment","QueryToolbar","openPatternSelectionModal","name","clientId","hasPatterns","length","children","className","onClick"],"sources":["@wordpress/block-library/src/query/edit/query-toolbar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToolbarGroup, ToolbarButton } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { usePatterns } from '../utils';\n\nexport default function QueryToolbar( {\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst hasPatterns = !! usePatterns( clientId, name ).length;\n\n\treturn (\n\t\t<>\n\t\t\t{ hasPatterns && (\n\t\t\t\t<ToolbarGroup className=\"wp-block-template-part__block-control-group\">\n\t\t\t\t\t<ToolbarButton onClick={ openPatternSelectionModal }>\n\t\t\t\t\t\t{ __( 'Replace' ) }\n\t\t\t\t\t</ToolbarButton>\n\t\t\t\t</ToolbarGroup>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,EAAEC,aAAa,QAAQ,uBAAuB;AACnE,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,WAAW,QAAQ,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAEvC,eAAe,SAASC,YAAYA,CAAE;EACrCC,yBAAyB;EACzBC,IAAI;EACJC;AACD,CAAC,EAAG;EACH,MAAMC,WAAW,GAAG,CAAC,CAAET,WAAW,CAAEQ,QAAQ,EAAED,IAAK,CAAC,CAACG,MAAM;EAE3D,oBACCR,IAAA,CAAAE,SAAA;IAAAO,QAAA,EACGF,WAAW,iBACZP,IAAA,CAACL,YAAY;MAACe,SAAS,EAAC,6CAA6C;MAAAD,QAAA,eACpET,IAAA,CAACJ,aAAa;QAACe,OAAO,EAAGP,yBAA2B;QAAAK,QAAA,EACjDZ,EAAE,CAAE,SAAU;MAAC,CACH;IAAC,CACH;EACd,CACA,CAAC;AAEL","ignoreList":[]}
|
|
@@ -143,12 +143,17 @@ export const usePostTypes = () => {
|
|
|
143
143
|
export const useTaxonomies = postType => {
|
|
144
144
|
const taxonomies = useSelect(select => {
|
|
145
145
|
const {
|
|
146
|
-
getTaxonomies
|
|
146
|
+
getTaxonomies,
|
|
147
|
+
getPostType
|
|
147
148
|
} = select(coreStore);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
// Does the post type have taxonomies?
|
|
150
|
+
if (getPostType(postType)?.taxonomies?.length > 0) {
|
|
151
|
+
return getTaxonomies({
|
|
152
|
+
type: postType,
|
|
153
|
+
per_page: -1
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return [];
|
|
152
157
|
}, [postType]);
|
|
153
158
|
return useMemo(() => {
|
|
154
159
|
return taxonomies?.filter(({
|
|
@@ -207,7 +212,8 @@ export const getTransformedBlocksFromPattern = (blocks, queryBlockAttributes) =>
|
|
|
207
212
|
query: {
|
|
208
213
|
postType,
|
|
209
214
|
inherit
|
|
210
|
-
}
|
|
215
|
+
},
|
|
216
|
+
namespace
|
|
211
217
|
} = queryBlockAttributes;
|
|
212
218
|
const clonedBlocks = blocks.map(block => cloneBlock(block));
|
|
213
219
|
const queryClientIds = [];
|
|
@@ -220,6 +226,9 @@ export const getTransformedBlocksFromPattern = (blocks, queryBlockAttributes) =>
|
|
|
220
226
|
postType,
|
|
221
227
|
inherit
|
|
222
228
|
};
|
|
229
|
+
if (namespace) {
|
|
230
|
+
block.attributes.namespace = namespace;
|
|
231
|
+
}
|
|
223
232
|
queryClientIds.push(block.clientId);
|
|
224
233
|
}
|
|
225
234
|
block.innerBlocks?.forEach(innerBlock => {
|