@wordpress/block-library 9.48.1 → 10.0.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 +12 -0
- package/build/audio/edit.cjs +8 -1
- package/build/audio/edit.cjs.map +2 -2
- package/build/breadcrumbs/edit.cjs +1 -2
- package/build/breadcrumbs/edit.cjs.map +2 -2
- package/build/button/edit.cjs +1 -2
- package/build/button/edit.cjs.map +2 -2
- package/build/categories/edit.cjs +1 -1
- package/build/categories/edit.cjs.map +1 -1
- package/build/code/edit.cjs +1 -1
- package/build/code/edit.cjs.map +2 -2
- package/build/code/index.cjs +1 -1
- package/build/code/index.cjs.map +1 -1
- package/build/columns/utils.cjs.map +1 -1
- package/build/comments/edit/comments-legacy.cjs +1 -1
- package/build/comments/edit/comments-legacy.cjs.map +1 -1
- package/build/comments/edit/placeholder.cjs +4 -4
- package/build/comments/edit/placeholder.cjs.map +1 -1
- package/build/comments-pagination-next/edit.cjs +2 -2
- package/build/comments-pagination-next/edit.cjs.map +1 -1
- package/build/comments-pagination-previous/edit.cjs +2 -2
- package/build/comments-pagination-previous/edit.cjs.map +1 -1
- package/build/cover/deprecated.cjs +3 -3
- package/build/cover/deprecated.cjs.map +2 -2
- package/build/cover/edit/block-controls.cjs +13 -0
- package/build/cover/edit/block-controls.cjs.map +2 -2
- package/build/cover/edit/embed-video-url-input.cjs +0 -1
- package/build/cover/edit/embed-video-url-input.cjs.map +2 -2
- package/build/cover/edit/index.cjs +61 -2
- package/build/cover/edit/index.cjs.map +3 -3
- package/build/cover/edit/inspector-controls.cjs +93 -35
- package/build/cover/edit/inspector-controls.cjs.map +2 -2
- package/build/details/edit.cjs +1 -2
- package/build/details/edit.cjs.map +2 -2
- package/build/embed/embed-placeholder.cjs +1 -1
- package/build/embed/embed-placeholder.cjs.map +2 -2
- package/build/file/edit.cjs +3 -11
- package/build/file/edit.cjs.map +2 -2
- package/build/file/index.cjs +3 -1
- package/build/file/index.cjs.map +3 -3
- package/build/file/transforms.cjs +11 -32
- package/build/file/transforms.cjs.map +2 -2
- package/build/{freeform/convert-to-blocks-button.cjs → file/variations.cjs} +16 -18
- package/build/file/variations.cjs.map +7 -0
- package/build/footnotes/edit.cjs +1 -1
- package/build/footnotes/edit.cjs.map +2 -2
- package/build/form/edit.cjs +0 -2
- package/build/form/edit.cjs.map +2 -2
- package/build/form-input/edit.cjs +1 -3
- package/build/form-input/edit.cjs.map +2 -2
- package/build/freeform/edit.cjs +6 -15
- package/build/freeform/edit.cjs.map +3 -3
- package/build/freeform/migration-notice.cjs.map +2 -2
- package/build/gallery/edit.cjs +2 -2
- package/build/gallery/edit.cjs.map +2 -2
- package/build/home-link/edit.cjs +1 -2
- package/build/home-link/edit.cjs.map +2 -2
- package/build/html/index.cjs +1 -1
- package/build/html/index.cjs.map +2 -2
- package/build/html/modal.cjs +9 -6
- package/build/html/modal.cjs.map +2 -2
- package/build/icon/block.json +12 -0
- package/build/icon/edit.cjs +90 -41
- package/build/icon/edit.cjs.map +3 -3
- package/build/icon/index.cjs +3 -1
- package/build/icon/index.cjs.map +3 -3
- package/build/{tab/save.cjs → icon/variations.cjs} +14 -15
- package/build/icon/variations.cjs.map +7 -0
- package/build/image/block.json +1 -0
- package/build/image/edit.cjs +4 -3
- package/build/image/edit.cjs.map +2 -2
- package/build/image/image.cjs +91 -29
- package/build/image/image.cjs.map +2 -2
- package/build/image/index.cjs +1 -1
- package/build/image/index.cjs.map +2 -2
- package/build/image/transforms.cjs +9 -3
- package/build/image/transforms.cjs.map +2 -2
- package/build/image/use-open-image-media-editor-modal.cjs +5 -25
- package/build/image/use-open-image-media-editor-modal.cjs.map +2 -2
- package/build/index.cjs +1 -3
- package/build/index.cjs.map +2 -2
- package/build/latest-posts/edit.cjs +1 -1
- package/build/latest-posts/edit.cjs.map +1 -1
- package/build/list/ordered-list-settings.cjs +0 -1
- package/build/list/ordered-list-settings.cjs.map +2 -2
- package/build/math/edit.cjs +1 -1
- package/build/math/index.cjs +1 -1
- package/build/math/index.cjs.map +1 -1
- package/build/media-text/constants.cjs +1 -1
- package/build/media-text/constants.cjs.map +2 -2
- package/build/media-text/index.cjs +1 -1
- package/build/media-text/index.cjs.map +2 -2
- package/build/missing/edit.cjs +2 -2
- package/build/missing/edit.cjs.map +1 -1
- package/build/navigation/edit/index.cjs +19 -13
- package/build/navigation/edit/index.cjs.map +2 -2
- package/build/navigation/edit/navigation-menu-name-control.cjs +0 -1
- package/build/navigation/edit/navigation-menu-name-control.cjs.map +2 -2
- package/build/navigation/edit/navigation-menu-selector.cjs +1 -1
- package/build/navigation/edit/navigation-menu-selector.cjs.map +2 -2
- package/build/navigation/edit/placeholder/index.cjs +1 -1
- package/build/navigation/edit/placeholder/index.cjs.map +2 -2
- package/build/navigation-link/block.json +1 -1
- package/build/navigation-link/edit.cjs +1 -1
- package/build/navigation-link/edit.cjs.map +2 -2
- package/build/navigation-link/link-ui/page-creator.cjs +0 -1
- package/build/navigation-link/link-ui/page-creator.cjs.map +2 -2
- package/build/navigation-link/shared/controls.cjs +0 -2
- package/build/navigation-link/shared/controls.cjs.map +2 -2
- package/build/navigation-submenu/block.json +7 -0
- package/build/navigation-submenu/edit.cjs +1 -1
- package/build/navigation-submenu/edit.cjs.map +2 -2
- package/build/page-list/block.json +2 -5
- package/build/page-list/edit.cjs +1 -11
- package/build/page-list/edit.cjs.map +2 -2
- package/build/playlist-track/edit.cjs +0 -3
- package/build/playlist-track/edit.cjs.map +2 -2
- package/build/post-author/edit.cjs +1 -1
- package/build/post-author/edit.cjs.map +2 -2
- package/build/post-author/utils.cjs +1 -1
- package/build/post-author/utils.cjs.map +2 -2
- package/build/post-comment/edit.cjs +0 -1
- package/build/post-comment/edit.cjs.map +2 -2
- package/build/post-date/edit.cjs +2 -2
- package/build/post-date/edit.cjs.map +2 -2
- package/build/post-excerpt/edit.cjs +2 -2
- package/build/post-excerpt/edit.cjs.map +2 -2
- package/build/post-featured-image/block.json +1 -0
- package/build/post-featured-image/dimension-controls.cjs +90 -178
- package/build/post-featured-image/dimension-controls.cjs.map +3 -3
- package/build/post-featured-image/edit.cjs +47 -18
- package/build/post-featured-image/edit.cjs.map +2 -2
- package/build/post-navigation-link/edit.cjs +2 -2
- package/build/post-navigation-link/edit.cjs.map +2 -2
- package/build/post-terms/edit.cjs +0 -1
- package/build/post-terms/edit.cjs.map +2 -2
- package/build/post-time-to-read/edit.cjs +1 -1
- package/build/post-time-to-read/edit.cjs.map +1 -1
- package/build/post-title/edit.cjs +0 -1
- package/build/post-title/edit.cjs.map +2 -2
- package/build/preformatted/edit.cjs +1 -1
- package/build/preformatted/edit.cjs.map +2 -2
- package/build/pullquote/block.json +1 -3
- package/build/pullquote/deprecated.cjs +114 -9
- package/build/pullquote/deprecated.cjs.map +3 -3
- package/build/pullquote/edit.cjs +43 -61
- package/build/pullquote/edit.cjs.map +3 -3
- package/build/pullquote/save.cjs +5 -26
- package/build/pullquote/save.cjs.map +3 -3
- package/build/query/edit/enhanced-pagination-modal.cjs +10 -1
- package/build/query/edit/enhanced-pagination-modal.cjs.map +3 -3
- package/build/query/edit/inspector-controls/enhanced-pagination-control.cjs +1 -1
- package/build/query/edit/inspector-controls/enhanced-pagination-control.cjs.map +1 -1
- package/build/query/edit/inspector-controls/index.cjs +0 -1
- package/build/query/edit/inspector-controls/index.cjs.map +2 -2
- package/build/query/edit/inspector-controls/order-control.cjs +2 -2
- package/build/query/edit/inspector-controls/order-control.cjs.map +2 -2
- package/build/query/utils.cjs +2 -2
- package/build/query/utils.cjs.map +2 -2
- package/build/query-pagination-next/edit.cjs +2 -2
- package/build/query-pagination-next/edit.cjs.map +1 -1
- package/build/query-pagination-previous/edit.cjs +2 -2
- package/build/query-pagination-previous/edit.cjs.map +1 -1
- package/build/query-title/edit.cjs +1 -1
- package/build/query-title/edit.cjs.map +2 -2
- package/build/query-total/edit.cjs +1 -1
- package/build/query-total/edit.cjs.map +2 -2
- package/build/quote/index.cjs +1 -1
- package/build/quote/index.cjs.map +2 -2
- package/build/read-more/edit.cjs +1 -1
- package/build/read-more/edit.cjs.map +2 -2
- package/build/rss/edit.cjs +1 -2
- package/build/rss/edit.cjs.map +2 -2
- package/build/search/block.json +4 -0
- package/build/search/edit.cjs +244 -206
- package/build/search/edit.cjs.map +2 -2
- package/build/shortcode/edit.cjs +1 -1
- package/build/shortcode/edit.cjs.map +2 -2
- package/build/site-logo/edit.cjs +2 -1
- package/build/site-logo/edit.cjs.map +2 -2
- package/build/site-tagline/edit.cjs +1 -1
- package/build/site-tagline/edit.cjs.map +2 -2
- package/build/site-title/edit.cjs +1 -1
- package/build/site-title/edit.cjs.map +2 -2
- package/build/social-link/edit.cjs +0 -3
- package/build/social-link/edit.cjs.map +2 -2
- package/build/tab-list/block.json +33 -20
- package/build/tab-list/edit.cjs +122 -12
- package/build/tab-list/edit.cjs.map +3 -3
- package/build/tab-list/init.cjs +28 -0
- package/build/tab-list/init.cjs.map +7 -0
- package/build/tab-list/save.cjs +33 -3
- package/build/tab-list/save.cjs.map +3 -3
- package/build/tab-panel/add-tab-toolbar-control.cjs +19 -8
- package/build/tab-panel/add-tab-toolbar-control.cjs.map +2 -2
- package/build/tab-panel/block.json +2 -6
- package/build/tab-panel/edit.cjs +0 -9
- package/build/tab-panel/edit.cjs.map +2 -2
- package/build/tab-panel/remove-tab-toolbar-control.cjs +9 -14
- package/build/tab-panel/remove-tab-toolbar-control.cjs.map +2 -2
- package/build/tab-panel/save.cjs +2 -1
- package/build/tab-panel/save.cjs.map +2 -2
- package/build/tab-panels/block.json +2 -28
- package/build/tab-panels/init.cjs +28 -0
- package/build/tab-panels/init.cjs.map +7 -0
- package/build/table/edit.cjs +0 -2
- package/build/table/edit.cjs.map +2 -2
- package/build/table/index.cjs +1 -1
- package/build/table/index.cjs.map +2 -2
- package/build/tabs/block.json +3 -17
- package/build/tabs/edit.cjs +7 -21
- package/build/tabs/edit.cjs.map +3 -3
- package/build/tabs/index.cjs +6 -10
- package/build/tabs/index.cjs.map +2 -2
- package/build/tabs/use-tab-list-items-sync.cjs +53 -0
- package/build/tabs/use-tab-list-items-sync.cjs.map +7 -0
- package/build/tabs/view.cjs +22 -104
- package/build/tabs/view.cjs.map +2 -2
- package/build/template-part/edit/advanced-controls.cjs +0 -1
- package/build/template-part/edit/advanced-controls.cjs.map +2 -2
- package/build/template-part/edit/title-modal.cjs +1 -2
- package/build/template-part/edit/title-modal.cjs.map +2 -2
- package/build/terms-query/edit/inspector-controls/order-control.cjs +2 -2
- package/build/terms-query/edit/inspector-controls/order-control.cjs.map +2 -2
- package/build/utils/style-state.cjs +164 -0
- package/build/utils/style-state.cjs.map +7 -0
- package/build/utils/waveform-player.cjs +1 -1
- package/build/verse/edit.cjs +1 -1
- package/build/verse/edit.cjs.map +2 -2
- package/build/video/edit.cjs +3 -2
- package/build/video/edit.cjs.map +2 -2
- package/build/video/tracks-editor.cjs +0 -2
- package/build/video/tracks-editor.cjs.map +2 -2
- package/build-module/audio/edit.mjs +8 -2
- package/build-module/audio/edit.mjs.map +2 -2
- package/build-module/breadcrumbs/edit.mjs +1 -2
- package/build-module/breadcrumbs/edit.mjs.map +2 -2
- package/build-module/button/edit.mjs +1 -2
- package/build-module/button/edit.mjs.map +2 -2
- package/build-module/categories/edit.mjs +1 -1
- package/build-module/categories/edit.mjs.map +1 -1
- package/build-module/code/edit.mjs +1 -1
- package/build-module/code/edit.mjs.map +2 -2
- package/build-module/code/index.mjs +1 -1
- package/build-module/code/index.mjs.map +1 -1
- package/build-module/columns/utils.mjs.map +1 -1
- package/build-module/comments/edit/comments-legacy.mjs +1 -1
- package/build-module/comments/edit/comments-legacy.mjs.map +1 -1
- package/build-module/comments/edit/placeholder.mjs +4 -4
- package/build-module/comments/edit/placeholder.mjs.map +1 -1
- package/build-module/comments-pagination-next/edit.mjs +2 -2
- package/build-module/comments-pagination-next/edit.mjs.map +1 -1
- package/build-module/comments-pagination-previous/edit.mjs +2 -2
- package/build-module/comments-pagination-previous/edit.mjs.map +1 -1
- package/build-module/cover/deprecated.mjs +3 -3
- package/build-module/cover/deprecated.mjs.map +2 -2
- package/build-module/cover/edit/block-controls.mjs +15 -2
- package/build-module/cover/edit/block-controls.mjs.map +2 -2
- package/build-module/cover/edit/embed-video-url-input.mjs +0 -1
- package/build-module/cover/edit/embed-video-url-input.mjs.map +2 -2
- package/build-module/cover/edit/index.mjs +64 -3
- package/build-module/cover/edit/index.mjs.map +2 -2
- package/build-module/cover/edit/inspector-controls.mjs +98 -35
- package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
- package/build-module/details/edit.mjs +1 -2
- package/build-module/details/edit.mjs.map +2 -2
- package/build-module/embed/embed-placeholder.mjs +1 -1
- package/build-module/embed/embed-placeholder.mjs.map +2 -2
- package/build-module/file/edit.mjs +5 -13
- package/build-module/file/edit.mjs.map +2 -2
- package/build-module/file/index.mjs +3 -1
- package/build-module/file/index.mjs.map +2 -2
- package/build-module/file/transforms.mjs +11 -32
- package/build-module/file/transforms.mjs.map +2 -2
- package/build-module/file/variations.mjs +17 -0
- package/build-module/file/variations.mjs.map +7 -0
- package/build-module/footnotes/edit.mjs +1 -1
- package/build-module/footnotes/edit.mjs.map +2 -2
- package/build-module/form/edit.mjs +0 -2
- package/build-module/form/edit.mjs.map +2 -2
- package/build-module/form-input/edit.mjs +1 -3
- package/build-module/form-input/edit.mjs.map +2 -2
- package/build-module/freeform/edit.mjs +6 -15
- package/build-module/freeform/edit.mjs.map +2 -2
- package/build-module/freeform/migration-notice.mjs.map +2 -2
- package/build-module/gallery/edit.mjs +2 -2
- package/build-module/gallery/edit.mjs.map +2 -2
- package/build-module/home-link/edit.mjs +1 -2
- package/build-module/home-link/edit.mjs.map +2 -2
- package/build-module/html/index.mjs +1 -1
- package/build-module/html/index.mjs.map +2 -2
- package/build-module/html/modal.mjs +9 -6
- package/build-module/html/modal.mjs.map +2 -2
- package/build-module/icon/block.json +12 -0
- package/build-module/icon/edit.mjs +94 -42
- package/build-module/icon/edit.mjs.map +2 -2
- package/build-module/icon/index.mjs +3 -1
- package/build-module/icon/index.mjs.map +2 -2
- package/build-module/icon/variations.mjs +13 -0
- package/build-module/icon/variations.mjs.map +7 -0
- package/build-module/image/block.json +1 -0
- package/build-module/image/edit.mjs +4 -3
- package/build-module/image/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +96 -29
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/image/index.mjs +1 -1
- package/build-module/image/index.mjs.map +2 -2
- package/build-module/image/transforms.mjs +9 -3
- package/build-module/image/transforms.mjs.map +2 -2
- package/build-module/image/use-open-image-media-editor-modal.mjs +5 -25
- package/build-module/image/use-open-image-media-editor-modal.mjs.map +2 -2
- package/build-module/index.mjs +1 -3
- package/build-module/index.mjs.map +2 -2
- package/build-module/latest-posts/edit.mjs +1 -1
- package/build-module/latest-posts/edit.mjs.map +1 -1
- package/build-module/list/ordered-list-settings.mjs +0 -1
- package/build-module/list/ordered-list-settings.mjs.map +2 -2
- package/build-module/math/edit.mjs +1 -1
- package/build-module/math/index.mjs +1 -1
- package/build-module/math/index.mjs.map +1 -1
- package/build-module/media-text/constants.mjs +1 -1
- package/build-module/media-text/constants.mjs.map +2 -2
- package/build-module/media-text/index.mjs +1 -1
- package/build-module/media-text/index.mjs.map +2 -2
- package/build-module/missing/edit.mjs +2 -2
- package/build-module/missing/edit.mjs.map +1 -1
- package/build-module/navigation/edit/index.mjs +19 -13
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation/edit/navigation-menu-name-control.mjs +0 -1
- package/build-module/navigation/edit/navigation-menu-name-control.mjs.map +2 -2
- package/build-module/navigation/edit/navigation-menu-selector.mjs +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.mjs.map +2 -2
- package/build-module/navigation/edit/placeholder/index.mjs +1 -1
- package/build-module/navigation/edit/placeholder/index.mjs.map +2 -2
- package/build-module/navigation-link/block.json +1 -1
- package/build-module/navigation-link/edit.mjs +1 -1
- package/build-module/navigation-link/edit.mjs.map +2 -2
- package/build-module/navigation-link/link-ui/page-creator.mjs +0 -1
- package/build-module/navigation-link/link-ui/page-creator.mjs.map +2 -2
- package/build-module/navigation-link/shared/controls.mjs +0 -2
- package/build-module/navigation-link/shared/controls.mjs.map +2 -2
- package/build-module/navigation-submenu/block.json +7 -0
- package/build-module/navigation-submenu/edit.mjs +1 -1
- package/build-module/navigation-submenu/edit.mjs.map +2 -2
- package/build-module/page-list/block.json +2 -5
- package/build-module/page-list/edit.mjs +1 -11
- package/build-module/page-list/edit.mjs.map +2 -2
- package/build-module/playlist-track/edit.mjs +0 -3
- package/build-module/playlist-track/edit.mjs.map +2 -2
- package/build-module/post-author/edit.mjs +1 -1
- package/build-module/post-author/edit.mjs.map +2 -2
- package/build-module/post-author/utils.mjs +1 -1
- package/build-module/post-author/utils.mjs.map +2 -2
- package/build-module/post-comment/edit.mjs +0 -1
- package/build-module/post-comment/edit.mjs.map +2 -2
- package/build-module/post-date/edit.mjs +2 -2
- package/build-module/post-date/edit.mjs.map +2 -2
- package/build-module/post-excerpt/edit.mjs +2 -2
- package/build-module/post-excerpt/edit.mjs.map +2 -2
- package/build-module/post-featured-image/block.json +1 -0
- package/build-module/post-featured-image/dimension-controls.mjs +99 -187
- package/build-module/post-featured-image/dimension-controls.mjs.map +2 -2
- package/build-module/post-featured-image/edit.mjs +47 -18
- package/build-module/post-featured-image/edit.mjs.map +2 -2
- package/build-module/post-navigation-link/edit.mjs +2 -2
- package/build-module/post-navigation-link/edit.mjs.map +2 -2
- package/build-module/post-terms/edit.mjs +0 -1
- package/build-module/post-terms/edit.mjs.map +2 -2
- package/build-module/post-time-to-read/edit.mjs +1 -1
- package/build-module/post-time-to-read/edit.mjs.map +1 -1
- package/build-module/post-title/edit.mjs +0 -1
- package/build-module/post-title/edit.mjs.map +2 -2
- package/build-module/preformatted/edit.mjs +1 -1
- package/build-module/preformatted/edit.mjs.map +2 -2
- package/build-module/pullquote/block.json +1 -3
- package/build-module/pullquote/deprecated.mjs +114 -9
- package/build-module/pullquote/deprecated.mjs.map +2 -2
- package/build-module/pullquote/edit.mjs +44 -67
- package/build-module/pullquote/edit.mjs.map +2 -2
- package/build-module/pullquote/save.mjs +5 -16
- package/build-module/pullquote/save.mjs.map +2 -2
- package/build-module/query/edit/enhanced-pagination-modal.mjs +10 -1
- package/build-module/query/edit/enhanced-pagination-modal.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.mjs +1 -1
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.mjs.map +1 -1
- package/build-module/query/edit/inspector-controls/index.mjs +0 -1
- package/build-module/query/edit/inspector-controls/index.mjs.map +2 -2
- package/build-module/query/edit/inspector-controls/order-control.mjs +2 -2
- package/build-module/query/edit/inspector-controls/order-control.mjs.map +2 -2
- package/build-module/query/utils.mjs +2 -2
- package/build-module/query/utils.mjs.map +2 -2
- package/build-module/query-pagination-next/edit.mjs +2 -2
- package/build-module/query-pagination-next/edit.mjs.map +1 -1
- package/build-module/query-pagination-previous/edit.mjs +2 -2
- package/build-module/query-pagination-previous/edit.mjs.map +1 -1
- package/build-module/query-title/edit.mjs +1 -1
- package/build-module/query-title/edit.mjs.map +2 -2
- package/build-module/query-total/edit.mjs +1 -1
- package/build-module/query-total/edit.mjs.map +2 -2
- package/build-module/quote/index.mjs +1 -1
- package/build-module/quote/index.mjs.map +2 -2
- package/build-module/read-more/edit.mjs +1 -1
- package/build-module/read-more/edit.mjs.map +2 -2
- package/build-module/rss/edit.mjs +1 -2
- package/build-module/rss/edit.mjs.map +2 -2
- package/build-module/search/block.json +4 -0
- package/build-module/search/edit.mjs +244 -206
- package/build-module/search/edit.mjs.map +2 -2
- package/build-module/shortcode/edit.mjs +1 -1
- package/build-module/shortcode/edit.mjs.map +2 -2
- package/build-module/site-logo/edit.mjs +2 -1
- package/build-module/site-logo/edit.mjs.map +2 -2
- package/build-module/site-tagline/edit.mjs +1 -1
- package/build-module/site-tagline/edit.mjs.map +2 -2
- package/build-module/site-title/edit.mjs +1 -1
- package/build-module/site-title/edit.mjs.map +2 -2
- package/build-module/social-link/edit.mjs +0 -3
- package/build-module/social-link/edit.mjs.map +2 -2
- package/build-module/tab-list/block.json +33 -20
- package/build-module/tab-list/edit.mjs +128 -15
- package/build-module/tab-list/edit.mjs.map +2 -2
- package/build-module/tab-list/init.mjs +7 -0
- package/build-module/tab-list/init.mjs.map +7 -0
- package/build-module/tab-list/save.mjs +29 -4
- package/build-module/tab-list/save.mjs.map +2 -2
- package/build-module/tab-panel/add-tab-toolbar-control.mjs +19 -8
- package/build-module/tab-panel/add-tab-toolbar-control.mjs.map +2 -2
- package/build-module/tab-panel/block.json +2 -6
- package/build-module/tab-panel/edit.mjs +1 -10
- package/build-module/tab-panel/edit.mjs.map +2 -2
- package/build-module/tab-panel/remove-tab-toolbar-control.mjs +9 -14
- package/build-module/tab-panel/remove-tab-toolbar-control.mjs.map +2 -2
- package/build-module/tab-panel/save.mjs +2 -1
- package/build-module/tab-panel/save.mjs.map +2 -2
- package/build-module/tab-panels/block.json +2 -28
- package/build-module/tab-panels/init.mjs +7 -0
- package/build-module/tab-panels/init.mjs.map +7 -0
- package/build-module/table/edit.mjs +0 -2
- package/build-module/table/edit.mjs.map +2 -2
- package/build-module/table/index.mjs +1 -1
- package/build-module/table/index.mjs.map +2 -2
- package/build-module/tabs/block.json +3 -17
- package/build-module/tabs/edit.mjs +7 -21
- package/build-module/tabs/edit.mjs.map +2 -2
- package/build-module/tabs/index.mjs +6 -10
- package/build-module/tabs/index.mjs.map +2 -2
- package/build-module/tabs/use-tab-list-items-sync.mjs +32 -0
- package/build-module/tabs/use-tab-list-items-sync.mjs.map +7 -0
- package/build-module/tabs/view.mjs +22 -104
- package/build-module/tabs/view.mjs.map +2 -2
- package/build-module/template-part/edit/advanced-controls.mjs +0 -1
- package/build-module/template-part/edit/advanced-controls.mjs.map +2 -2
- package/build-module/template-part/edit/title-modal.mjs +1 -2
- package/build-module/template-part/edit/title-modal.mjs.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/order-control.mjs +2 -2
- package/build-module/terms-query/edit/inspector-controls/order-control.mjs.map +2 -2
- package/build-module/utils/style-state.mjs +132 -0
- package/build-module/utils/style-state.mjs.map +7 -0
- package/build-module/utils/waveform-player.mjs +1 -1
- package/build-module/verse/edit.mjs +1 -1
- package/build-module/verse/edit.mjs.map +2 -2
- package/build-module/video/edit.mjs +3 -3
- package/build-module/video/edit.mjs.map +2 -2
- package/build-module/video/tracks-editor.mjs +0 -2
- package/build-module/video/tracks-editor.mjs.map +2 -2
- package/build-style/editor-rtl.css +0 -19
- package/build-style/editor.css +0 -19
- package/build-style/icon/style-rtl.css +9 -0
- package/build-style/icon/style.css +9 -0
- package/build-style/style-rtl.css +11 -24
- package/build-style/style.css +11 -24
- package/build-style/{tab → tab-list}/style-rtl.css +2 -2
- package/build-style/{tab → tab-list}/style.css +2 -2
- package/build-style/tab-panel/style-rtl.css +0 -17
- package/build-style/tab-panel/style.css +0 -17
- package/package.json +48 -45
- package/src/audio/edit.js +5 -9
- package/src/avatar/index.php +2 -2
- package/src/block/index.php +2 -26
- package/src/breadcrumbs/edit.js +0 -1
- package/src/button/edit.js +0 -1
- package/src/comment-author-avatar/index.php +3 -3
- package/src/comment-author-name/index.php +1 -1
- package/src/comment-date/index.php +1 -1
- package/src/cover/edit/block-controls.js +14 -2
- package/src/cover/edit/embed-video-url-input.js +0 -1
- package/src/cover/edit/index.js +86 -0
- package/src/cover/edit/inspector-controls.js +124 -54
- package/src/cover/test/edit.js +51 -2
- package/src/details/edit.js +0 -1
- package/src/editor.scss +0 -2
- package/src/file/edit.js +3 -16
- package/src/file/index.js +2 -0
- package/src/file/transforms.js +12 -31
- package/src/file/variations.js +17 -0
- package/src/form/edit.js +0 -2
- package/src/form-input/edit.js +0 -2
- package/src/freeform/edit.js +6 -29
- package/src/freeform/migration-notice.js +2 -4
- package/src/gallery/edit.js +13 -13
- package/src/home-link/edit.js +0 -1
- package/src/html/modal.js +3 -0
- package/src/icon/README.md +3 -0
- package/src/icon/block.json +12 -0
- package/src/icon/edit.js +85 -37
- package/src/icon/index.js +3 -1
- package/src/icon/index.php +23 -0
- package/src/icon/style.scss +12 -0
- package/src/icon/variations.js +9 -0
- package/src/image/README.md +1 -0
- package/src/image/block.json +1 -0
- package/src/image/edit.js +8 -3
- package/src/image/image.js +120 -56
- package/src/image/index.php +0 -1
- package/src/image/test/use-open-image-media-editor-modal.js +20 -26
- package/src/image/transforms.js +34 -8
- package/src/image/use-open-image-media-editor-modal.js +24 -42
- package/src/index.js +4 -11
- package/src/list/ordered-list-settings.js +0 -1
- package/src/navigation/edit/index.js +25 -16
- package/src/navigation/edit/navigation-menu-name-control.js +0 -1
- package/src/navigation/index.php +58 -0
- package/src/navigation-link/README.md +1 -1
- package/src/navigation-link/block.json +1 -1
- package/src/navigation-link/link-ui/page-creator.js +0 -1
- package/src/navigation-link/shared/controls.js +0 -2
- package/src/navigation-link/test/__snapshots__/hooks.js.snap +5 -0
- package/src/navigation-submenu/README.md +5 -0
- package/src/navigation-submenu/block.json +7 -0
- package/src/page-list/README.md +1 -1
- package/src/page-list/block.json +2 -5
- package/src/page-list/edit.js +0 -11
- package/src/page-list/index.php +1 -1
- package/src/playlist-track/edit.js +0 -3
- package/src/post-comment/edit.js +0 -1
- package/src/post-date/edit.js +2 -2
- package/src/post-featured-image/README.md +1 -0
- package/src/post-featured-image/block.json +1 -0
- package/src/post-featured-image/dimension-controls.js +105 -184
- package/src/post-featured-image/edit.js +53 -22
- package/src/post-featured-image/index.php +24 -22
- package/src/post-terms/edit.js +0 -1
- package/src/post-title/edit.js +0 -1
- package/src/pullquote/README.md +1 -1
- package/src/pullquote/block.json +1 -3
- package/src/pullquote/deprecated.js +121 -9
- package/src/pullquote/edit.js +7 -31
- package/src/pullquote/save.js +2 -13
- package/src/query/edit/enhanced-pagination-modal.js +11 -1
- package/src/query/edit/inspector-controls/index.js +0 -1
- package/src/rss/edit.js +0 -1
- package/src/search/README.md +1 -0
- package/src/search/block.json +4 -0
- package/src/search/edit.js +106 -55
- package/src/search/index.php +25 -1
- package/src/site-logo/edit.js +3 -1
- package/src/social-link/edit.js +0 -3
- package/src/style.scss +1 -2
- package/src/tab-list/README.md +19 -17
- package/src/tab-list/block.json +33 -20
- package/src/tab-list/edit.js +153 -15
- package/src/tab-list/index.php +24 -33
- package/src/tab-list/init.js +6 -0
- package/src/tab-list/save.js +39 -4
- package/src/{tab → tab-list}/style.scss +2 -3
- package/src/tab-panel/README.md +0 -3
- package/src/tab-panel/add-tab-toolbar-control.js +24 -11
- package/src/tab-panel/block.json +2 -6
- package/src/tab-panel/edit.js +1 -14
- package/src/tab-panel/index.php +2 -25
- package/src/tab-panel/remove-tab-toolbar-control.js +10 -14
- package/src/tab-panel/save.js +1 -0
- package/src/tab-panel/style.scss +0 -17
- package/src/tab-panels/README.md +0 -16
- package/src/tab-panels/block.json +2 -28
- package/src/tab-panels/init.js +6 -0
- package/src/table/edit.js +0 -2
- package/src/tabs/README.md +1 -7
- package/src/tabs/block.json +3 -17
- package/src/tabs/edit.js +8 -19
- package/src/tabs/index.js +6 -10
- package/src/tabs/index.php +12 -32
- package/src/tabs/use-tab-list-items-sync.js +49 -0
- package/src/tabs/view.js +22 -110
- package/src/template-part/edit/advanced-controls.js +0 -1
- package/src/template-part/edit/title-modal.js +0 -1
- package/src/utils/style-state.js +151 -0
- package/src/utils/test/style-state.js +307 -0
- package/src/video/edit.js +9 -16
- package/src/video/tracks-editor.js +0 -2
- package/babel-plugin.cjs +0 -150
- package/build/freeform/convert-to-blocks-button.cjs.map +0 -7
- package/build/list-item/utils.cjs +0 -57
- package/build/list-item/utils.cjs.map +0 -7
- package/build/tab/block.json +0 -56
- package/build/tab/controls.cjs +0 -46
- package/build/tab/controls.cjs.map +0 -7
- package/build/tab/edit.cjs +0 -135
- package/build/tab/edit.cjs.map +0 -7
- package/build/tab/index.cjs +0 -58
- package/build/tab/index.cjs.map +0 -7
- package/build/tab/save.cjs.map +0 -7
- package/build/tabs/use-tab-list-sync.cjs +0 -190
- package/build/tabs/use-tab-list-sync.cjs.map +0 -7
- package/build-module/freeform/convert-to-blocks-button.mjs +0 -19
- package/build-module/freeform/convert-to-blocks-button.mjs.map +0 -7
- package/build-module/list-item/utils.mjs +0 -32
- package/build-module/list-item/utils.mjs.map +0 -7
- package/build-module/tab/block.json +0 -56
- package/build-module/tab/controls.mjs +0 -15
- package/build-module/tab/controls.mjs.map +0 -7
- package/build-module/tab/edit.mjs +0 -108
- package/build-module/tab/edit.mjs.map +0 -7
- package/build-module/tab/index.mjs +0 -20
- package/build-module/tab/index.mjs.map +0 -7
- package/build-module/tab/save.mjs +0 -14
- package/build-module/tab/save.mjs.map +0 -7
- package/build-module/tabs/use-tab-list-sync.mjs +0 -169
- package/build-module/tabs/use-tab-list-sync.mjs.map +0 -7
- package/build-style/tab/editor-rtl.css +0 -11
- package/build-style/tab/editor.css +0 -11
- package/build-style/tab-list/editor-rtl.css +0 -6
- package/build-style/tab-list/editor.css +0 -6
- package/build-style/tab-panels/style-rtl.css +0 -4
- package/build-style/tab-panels/style.css +0 -4
- package/src/freeform/convert-to-blocks-button.js +0 -18
- package/src/list-item/utils.js +0 -34
- package/src/tab/README.md +0 -69
- package/src/tab/block.json +0 -56
- package/src/tab/controls.js +0 -19
- package/src/tab/edit.js +0 -141
- package/src/tab/editor.scss +0 -14
- package/src/tab/index.js +0 -24
- package/src/tab/index.php +0 -70
- package/src/tab/save.js +0 -13
- package/src/tab-list/editor.scss +0 -10
- package/src/tab-panels/style.scss +0 -4
- package/src/tabs/use-tab-list-sync.js +0 -237
package/src/tabs/view.js
CHANGED
|
@@ -8,44 +8,8 @@ import {
|
|
|
8
8
|
withSyncEvent,
|
|
9
9
|
} from '@wordpress/interactivity';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
'push',
|
|
14
|
-
'pop',
|
|
15
|
-
'shift',
|
|
16
|
-
'unshift',
|
|
17
|
-
'splice',
|
|
18
|
-
'sort',
|
|
19
|
-
'reverse',
|
|
20
|
-
'copyWithin',
|
|
21
|
-
'fill',
|
|
22
|
-
] );
|
|
23
|
-
|
|
24
|
-
return new Proxy( obj, {
|
|
25
|
-
get( target, prop ) {
|
|
26
|
-
// If accessing an array mutation method, return a no-op function.
|
|
27
|
-
if ( Array.isArray( target ) && arrayMutationMethods.has( prop ) ) {
|
|
28
|
-
return () => {};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const value = target[ prop ];
|
|
32
|
-
if ( typeof value === 'object' && value !== null ) {
|
|
33
|
-
return createReadOnlyProxy( value );
|
|
34
|
-
}
|
|
35
|
-
return value;
|
|
36
|
-
},
|
|
37
|
-
set() {
|
|
38
|
-
return false;
|
|
39
|
-
},
|
|
40
|
-
deleteProperty() {
|
|
41
|
-
return false;
|
|
42
|
-
},
|
|
43
|
-
} );
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Private store for internal tabs functionality and security.
|
|
47
|
-
const { actions: privateActions, state: privateState } = store(
|
|
48
|
-
'core/tabs/private',
|
|
11
|
+
const { actions, state } = store(
|
|
12
|
+
'core/tabs',
|
|
49
13
|
{
|
|
50
14
|
state: {
|
|
51
15
|
/**
|
|
@@ -56,7 +20,7 @@ const { actions: privateActions, state: privateState } = store(
|
|
|
56
20
|
get tabsList() {
|
|
57
21
|
const context = getContext();
|
|
58
22
|
const tabsId = context?.tabsId;
|
|
59
|
-
const tabsList =
|
|
23
|
+
const tabsList = state[ tabsId ];
|
|
60
24
|
return tabsList;
|
|
61
25
|
},
|
|
62
26
|
/**
|
|
@@ -71,8 +35,8 @@ const { actions: privateActions, state: privateState } = store(
|
|
|
71
35
|
if ( ! tabId ) {
|
|
72
36
|
return null;
|
|
73
37
|
}
|
|
74
|
-
const { tabsList } =
|
|
75
|
-
const tabIndex = tabsList.findIndex( ( t ) => t
|
|
38
|
+
const { tabsList } = state;
|
|
39
|
+
const tabIndex = tabsList.findIndex( ( t ) => t === tabId );
|
|
76
40
|
return tabIndex;
|
|
77
41
|
},
|
|
78
42
|
/**
|
|
@@ -82,7 +46,7 @@ const { actions: privateActions, state: privateState } = store(
|
|
|
82
46
|
*/
|
|
83
47
|
get isActiveTab() {
|
|
84
48
|
const { activeTabIndex } = getContext();
|
|
85
|
-
const { tabIndex } =
|
|
49
|
+
const { tabIndex } = state;
|
|
86
50
|
return activeTabIndex === tabIndex;
|
|
87
51
|
},
|
|
88
52
|
/**
|
|
@@ -92,7 +56,7 @@ const { actions: privateActions, state: privateState } = store(
|
|
|
92
56
|
* @type {number}
|
|
93
57
|
*/
|
|
94
58
|
get tabIndexAttribute() {
|
|
95
|
-
return
|
|
59
|
+
return state.isActiveTab ? 0 : -1;
|
|
96
60
|
},
|
|
97
61
|
},
|
|
98
62
|
actions: {
|
|
@@ -102,26 +66,18 @@ const { actions: privateActions, state: privateState } = store(
|
|
|
102
66
|
* @param {KeyboardEvent} event The keydown event.
|
|
103
67
|
*/
|
|
104
68
|
handleTabKeyDown: withSyncEvent( ( event ) => {
|
|
105
|
-
const
|
|
106
|
-
const { isVertical } = context;
|
|
107
|
-
const { tabIndex } = privateState;
|
|
69
|
+
const { tabIndex } = state;
|
|
108
70
|
|
|
109
71
|
if ( tabIndex === null ) {
|
|
110
72
|
return;
|
|
111
73
|
}
|
|
112
74
|
|
|
113
|
-
if ( event.key === 'ArrowRight'
|
|
114
|
-
event.preventDefault();
|
|
115
|
-
privateActions.moveFocus( tabIndex + 1 );
|
|
116
|
-
} else if ( event.key === 'ArrowLeft' && ! isVertical ) {
|
|
75
|
+
if ( event.key === 'ArrowRight' ) {
|
|
117
76
|
event.preventDefault();
|
|
118
|
-
|
|
119
|
-
} else if ( event.key === '
|
|
77
|
+
actions.moveFocus( tabIndex + 1 );
|
|
78
|
+
} else if ( event.key === 'ArrowLeft' ) {
|
|
120
79
|
event.preventDefault();
|
|
121
|
-
|
|
122
|
-
} else if ( event.key === 'ArrowUp' && isVertical ) {
|
|
123
|
-
event.preventDefault();
|
|
124
|
-
privateActions.moveFocus( tabIndex - 1 );
|
|
80
|
+
actions.moveFocus( tabIndex - 1 );
|
|
125
81
|
}
|
|
126
82
|
} ),
|
|
127
83
|
/**
|
|
@@ -132,9 +88,9 @@ const { actions: privateActions, state: privateState } = store(
|
|
|
132
88
|
handleTabClick: withSyncEvent( ( event ) => {
|
|
133
89
|
event.preventDefault();
|
|
134
90
|
|
|
135
|
-
const { tabIndex } =
|
|
91
|
+
const { tabIndex } = state;
|
|
136
92
|
if ( tabIndex !== null ) {
|
|
137
|
-
|
|
93
|
+
actions.setActiveTab( tabIndex );
|
|
138
94
|
}
|
|
139
95
|
} ),
|
|
140
96
|
/**
|
|
@@ -143,7 +99,7 @@ const { actions: privateActions, state: privateState } = store(
|
|
|
143
99
|
* @param {number} tabIndex The index to move focus to.
|
|
144
100
|
*/
|
|
145
101
|
moveFocus: ( tabIndex ) => {
|
|
146
|
-
const { tabsList } =
|
|
102
|
+
const { tabsList } = state;
|
|
147
103
|
|
|
148
104
|
if ( ! tabsList || tabsList.length === 0 ) {
|
|
149
105
|
return;
|
|
@@ -156,20 +112,20 @@ const { actions: privateActions, state: privateState } = store(
|
|
|
156
112
|
newIndex = 0;
|
|
157
113
|
}
|
|
158
114
|
|
|
159
|
-
const tabId = tabsList[ newIndex ]
|
|
115
|
+
const tabId = tabsList[ newIndex ];
|
|
160
116
|
const tabElement = document.getElementById( 'tab__' + tabId );
|
|
161
117
|
if ( tabElement ) {
|
|
162
118
|
tabElement.focus();
|
|
163
119
|
}
|
|
164
120
|
},
|
|
165
121
|
/**
|
|
166
|
-
* Sets the active tab index
|
|
122
|
+
* Sets the active tab index.
|
|
167
123
|
*
|
|
168
124
|
* @param {number} tabIndex The index of the active tab.
|
|
169
125
|
* @param {boolean} scrollToTab Whether to scroll to the tab element.
|
|
170
126
|
*/
|
|
171
127
|
setActiveTab: ( tabIndex, scrollToTab = false ) => {
|
|
172
|
-
const { tabsList } =
|
|
128
|
+
const { tabsList } = state;
|
|
173
129
|
|
|
174
130
|
if ( ! tabsList || tabsList.length === 0 ) {
|
|
175
131
|
return;
|
|
@@ -186,7 +142,7 @@ const { actions: privateActions, state: privateState } = store(
|
|
|
186
142
|
context.activeTabIndex = newIndex;
|
|
187
143
|
|
|
188
144
|
if ( scrollToTab ) {
|
|
189
|
-
const tabId = tabsList[ newIndex ]
|
|
145
|
+
const tabId = tabsList[ newIndex ];
|
|
190
146
|
const tabElement = document.getElementById( tabId );
|
|
191
147
|
if ( tabElement ) {
|
|
192
148
|
setTimeout( () => {
|
|
@@ -202,17 +158,17 @@ const { actions: privateActions, state: privateState } = store(
|
|
|
202
158
|
*
|
|
203
159
|
*/
|
|
204
160
|
onTabsInit: () => {
|
|
205
|
-
const { tabsList } =
|
|
161
|
+
const { tabsList } = state;
|
|
206
162
|
if ( tabsList.length === 0 ) {
|
|
207
163
|
return;
|
|
208
164
|
}
|
|
209
165
|
|
|
210
166
|
const { hash } = window.location;
|
|
211
167
|
const tabId = hash.replace( '#', '' );
|
|
212
|
-
const tabIndex = tabsList.findIndex( ( t ) => t
|
|
168
|
+
const tabIndex = tabsList.findIndex( ( t ) => t === tabId );
|
|
213
169
|
// Check if tabIndex is a positive number and if so we'll auto activate that tab.
|
|
214
170
|
if ( tabIndex >= 0 ) {
|
|
215
|
-
|
|
171
|
+
actions.setActiveTab( tabIndex, true );
|
|
216
172
|
}
|
|
217
173
|
},
|
|
218
174
|
},
|
|
@@ -221,47 +177,3 @@ const { actions: privateActions, state: privateState } = store(
|
|
|
221
177
|
lock: true,
|
|
222
178
|
}
|
|
223
179
|
);
|
|
224
|
-
|
|
225
|
-
// Public store for third-party extensibility.
|
|
226
|
-
store( 'core/tabs', {
|
|
227
|
-
state: {
|
|
228
|
-
/**
|
|
229
|
-
* Gets a contextually aware list of tabs for the current tabs block.
|
|
230
|
-
* Public API for third-party access.
|
|
231
|
-
*
|
|
232
|
-
* @type {Array}
|
|
233
|
-
*/
|
|
234
|
-
get tabsList() {
|
|
235
|
-
return createReadOnlyProxy( privateState.tabsList );
|
|
236
|
-
},
|
|
237
|
-
/**
|
|
238
|
-
* Gets the index of the active tab element whether it
|
|
239
|
-
* is a tab label or tab panel.
|
|
240
|
-
*
|
|
241
|
-
* @type {number|null}
|
|
242
|
-
*/
|
|
243
|
-
get tabIndex() {
|
|
244
|
-
return privateState.tabIndex;
|
|
245
|
-
},
|
|
246
|
-
/**
|
|
247
|
-
* Whether the tab panel or tab label is the active tab.
|
|
248
|
-
*
|
|
249
|
-
* @type {boolean}
|
|
250
|
-
*/
|
|
251
|
-
get isActiveTab() {
|
|
252
|
-
return privateState.isActiveTab;
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
actions: {
|
|
256
|
-
/**
|
|
257
|
-
* Sets the active tab index.
|
|
258
|
-
* Public API for third-party programmatic tab activation.
|
|
259
|
-
*
|
|
260
|
-
* @param {number} tabIndex The index of the active tab.
|
|
261
|
-
* @param {boolean} scrollToTab Whether to scroll to the tab element.
|
|
262
|
-
*/
|
|
263
|
-
setActiveTab: ( tabIndex, scrollToTab = false ) => {
|
|
264
|
-
privateActions.setActiveTab( tabIndex, scrollToTab );
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
} );
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { unlock } from '../lock-unlock';
|
|
10
|
+
|
|
11
|
+
const { cleanEmptyObject, getStyleForState, setStyleForState } = unlock(
|
|
12
|
+
blockEditorPrivateApis
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
function getStateStyle( style, selectedState ) {
|
|
16
|
+
return getStyleForState( style, selectedState ) || {};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getMappedDimensions( dimensions, dimensionKeyMap = {} ) {
|
|
20
|
+
return Object.fromEntries(
|
|
21
|
+
Object.entries( dimensions ).map( ( [ key, value ] ) => [
|
|
22
|
+
dimensionKeyMap[ key ] || key,
|
|
23
|
+
value,
|
|
24
|
+
] )
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getControlledDimensions( dimensions, dimensionKeys ) {
|
|
29
|
+
if ( ! dimensionKeys ) {
|
|
30
|
+
return dimensions;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return Object.fromEntries(
|
|
34
|
+
dimensionKeys.map( ( key ) => [ key, dimensions[ key ] ] )
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function getStyleStateKey( selectedState ) {
|
|
39
|
+
return [
|
|
40
|
+
selectedState?.viewport || 'default',
|
|
41
|
+
selectedState?.pseudo || 'default',
|
|
42
|
+
].join( ':' );
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function getStateDimensions( style, selectedState ) {
|
|
46
|
+
return getStateStyle( style, selectedState )?.dimensions || {};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function getActiveDimensionValue( options = {} ) {
|
|
50
|
+
const {
|
|
51
|
+
attributes = {},
|
|
52
|
+
style = attributes?.style,
|
|
53
|
+
selectedState,
|
|
54
|
+
hasSelectedStyleState,
|
|
55
|
+
attributeKey,
|
|
56
|
+
styleKey = attributeKey,
|
|
57
|
+
rootValue,
|
|
58
|
+
} = options;
|
|
59
|
+
|
|
60
|
+
if ( hasSelectedStyleState ) {
|
|
61
|
+
return getStateDimensions( style, selectedState )?.[ styleKey ];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if ( Object.hasOwn( options, 'rootValue' ) ) {
|
|
65
|
+
return rootValue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return attributes?.[ attributeKey ];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function setStateDimensions( style, selectedState, nextDimensions ) {
|
|
72
|
+
const stateStyle = getStateStyle( style, selectedState );
|
|
73
|
+
|
|
74
|
+
return setStyleForState(
|
|
75
|
+
style,
|
|
76
|
+
selectedState,
|
|
77
|
+
cleanEmptyObject( {
|
|
78
|
+
...stateStyle,
|
|
79
|
+
dimensions: cleanEmptyObject( {
|
|
80
|
+
...stateStyle?.dimensions,
|
|
81
|
+
...nextDimensions,
|
|
82
|
+
} ),
|
|
83
|
+
} )
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function getDimensionUpdateAttributes( {
|
|
88
|
+
style,
|
|
89
|
+
selectedState,
|
|
90
|
+
hasSelectedStyleState,
|
|
91
|
+
nextDimensions,
|
|
92
|
+
dimensionKeyMap,
|
|
93
|
+
dimensionKeys,
|
|
94
|
+
} ) {
|
|
95
|
+
const controlledDimensions = getControlledDimensions(
|
|
96
|
+
nextDimensions,
|
|
97
|
+
dimensionKeys
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
if ( ! hasSelectedStyleState ) {
|
|
101
|
+
return controlledDimensions;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
style: setStateDimensions(
|
|
106
|
+
style,
|
|
107
|
+
selectedState,
|
|
108
|
+
getMappedDimensions( controlledDimensions, dimensionKeyMap )
|
|
109
|
+
),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function resetDimensions( style, keys ) {
|
|
114
|
+
const dimensionsReset = Object.fromEntries(
|
|
115
|
+
keys.map( ( key ) => [ key, undefined ] )
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
return cleanEmptyObject( {
|
|
119
|
+
...style,
|
|
120
|
+
dimensions: cleanEmptyObject( {
|
|
121
|
+
...style?.dimensions,
|
|
122
|
+
...dimensionsReset,
|
|
123
|
+
} ),
|
|
124
|
+
} );
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function resetStateDimensions( style, selectedState, keys ) {
|
|
128
|
+
return setStyleForState(
|
|
129
|
+
style,
|
|
130
|
+
selectedState,
|
|
131
|
+
resetDimensions( getStateStyle( style, selectedState ), keys )
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function getDimensionResetAttributes( {
|
|
136
|
+
attributes = {},
|
|
137
|
+
style = attributes?.style,
|
|
138
|
+
selectedState,
|
|
139
|
+
hasSelectedStyleState,
|
|
140
|
+
keys,
|
|
141
|
+
defaultAttributes = {},
|
|
142
|
+
} ) {
|
|
143
|
+
return {
|
|
144
|
+
...( hasSelectedStyleState
|
|
145
|
+
? {}
|
|
146
|
+
: { ...attributes, ...defaultAttributes } ),
|
|
147
|
+
style: hasSelectedStyleState
|
|
148
|
+
? resetStateDimensions( style, selectedState, keys )
|
|
149
|
+
: resetDimensions( style, keys ),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
getActiveDimensionValue,
|
|
6
|
+
getDimensionResetAttributes,
|
|
7
|
+
getDimensionUpdateAttributes,
|
|
8
|
+
getStyleStateKey,
|
|
9
|
+
resetDimensions,
|
|
10
|
+
resetStateDimensions,
|
|
11
|
+
setStateDimensions,
|
|
12
|
+
} from '../style-state';
|
|
13
|
+
|
|
14
|
+
describe( 'style state dimension utilities', () => {
|
|
15
|
+
it( 'resets root dimensions without changing viewport dimensions', () => {
|
|
16
|
+
const style = {
|
|
17
|
+
dimensions: {
|
|
18
|
+
aspectRatio: '1',
|
|
19
|
+
minHeight: '40px',
|
|
20
|
+
},
|
|
21
|
+
'@mobile': {
|
|
22
|
+
dimensions: {
|
|
23
|
+
aspectRatio: '2',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
expect( resetDimensions( style, [ 'aspectRatio' ] ) ).toEqual( {
|
|
29
|
+
dimensions: {
|
|
30
|
+
minHeight: '40px',
|
|
31
|
+
},
|
|
32
|
+
'@mobile': {
|
|
33
|
+
dimensions: {
|
|
34
|
+
aspectRatio: '2',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
} );
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
it( 'resets dimensions only for the selected viewport state', () => {
|
|
41
|
+
const style = {
|
|
42
|
+
dimensions: {
|
|
43
|
+
aspectRatio: '1',
|
|
44
|
+
},
|
|
45
|
+
'@mobile': {
|
|
46
|
+
dimensions: {
|
|
47
|
+
aspectRatio: '2',
|
|
48
|
+
width: '200px',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
'@tablet': {
|
|
52
|
+
dimensions: {
|
|
53
|
+
aspectRatio: '3',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
expect(
|
|
59
|
+
resetStateDimensions(
|
|
60
|
+
style,
|
|
61
|
+
{ viewport: '@mobile', pseudo: 'default' },
|
|
62
|
+
[ 'aspectRatio' ]
|
|
63
|
+
)
|
|
64
|
+
).toEqual( {
|
|
65
|
+
dimensions: {
|
|
66
|
+
aspectRatio: '1',
|
|
67
|
+
},
|
|
68
|
+
'@mobile': {
|
|
69
|
+
dimensions: {
|
|
70
|
+
width: '200px',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
'@tablet': {
|
|
74
|
+
dimensions: {
|
|
75
|
+
aspectRatio: '3',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
} );
|
|
79
|
+
} );
|
|
80
|
+
|
|
81
|
+
it( 'sets dimensions only for the selected viewport state', () => {
|
|
82
|
+
const style = {
|
|
83
|
+
'@mobile': {
|
|
84
|
+
dimensions: {
|
|
85
|
+
width: '200px',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
'@tablet': {
|
|
89
|
+
dimensions: {
|
|
90
|
+
width: '300px',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
expect(
|
|
96
|
+
setStateDimensions(
|
|
97
|
+
style,
|
|
98
|
+
{ viewport: '@mobile', pseudo: 'default' },
|
|
99
|
+
{ height: '100px' }
|
|
100
|
+
)
|
|
101
|
+
).toEqual( {
|
|
102
|
+
'@mobile': {
|
|
103
|
+
dimensions: {
|
|
104
|
+
height: '100px',
|
|
105
|
+
width: '200px',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
'@tablet': {
|
|
109
|
+
dimensions: {
|
|
110
|
+
width: '300px',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
} );
|
|
114
|
+
} );
|
|
115
|
+
|
|
116
|
+
it( 'generates a stable key for selected style states', () => {
|
|
117
|
+
expect(
|
|
118
|
+
getStyleStateKey( { viewport: '@mobile', pseudo: ':hover' } )
|
|
119
|
+
).toBe( '@mobile::hover' );
|
|
120
|
+
expect( getStyleStateKey( undefined ) ).toBe( 'default:default' );
|
|
121
|
+
} );
|
|
122
|
+
|
|
123
|
+
it( 'reads root attribute dimensions for the default state', () => {
|
|
124
|
+
expect(
|
|
125
|
+
getActiveDimensionValue( {
|
|
126
|
+
attributes: {
|
|
127
|
+
width: '200px',
|
|
128
|
+
},
|
|
129
|
+
attributeKey: 'width',
|
|
130
|
+
hasSelectedStyleState: false,
|
|
131
|
+
} )
|
|
132
|
+
).toBe( '200px' );
|
|
133
|
+
} );
|
|
134
|
+
|
|
135
|
+
it( 'reads mapped dimensions for selected style states', () => {
|
|
136
|
+
expect(
|
|
137
|
+
getActiveDimensionValue( {
|
|
138
|
+
attributes: {
|
|
139
|
+
scale: 'cover',
|
|
140
|
+
style: {
|
|
141
|
+
'@mobile': {
|
|
142
|
+
dimensions: {
|
|
143
|
+
objectFit: 'contain',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
selectedState: { viewport: '@mobile', pseudo: 'default' },
|
|
149
|
+
hasSelectedStyleState: true,
|
|
150
|
+
attributeKey: 'scale',
|
|
151
|
+
styleKey: 'objectFit',
|
|
152
|
+
} )
|
|
153
|
+
).toBe( 'contain' );
|
|
154
|
+
} );
|
|
155
|
+
|
|
156
|
+
it( 'maps root dimension attributes to selected style state dimensions', () => {
|
|
157
|
+
expect(
|
|
158
|
+
getDimensionUpdateAttributes( {
|
|
159
|
+
style: {
|
|
160
|
+
'@mobile': {
|
|
161
|
+
dimensions: {
|
|
162
|
+
width: '200px',
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
selectedState: { viewport: '@mobile', pseudo: 'default' },
|
|
167
|
+
hasSelectedStyleState: true,
|
|
168
|
+
nextDimensions: {
|
|
169
|
+
scale: 'contain',
|
|
170
|
+
},
|
|
171
|
+
dimensionKeyMap: {
|
|
172
|
+
scale: 'objectFit',
|
|
173
|
+
},
|
|
174
|
+
} )
|
|
175
|
+
).toEqual( {
|
|
176
|
+
style: {
|
|
177
|
+
'@mobile': {
|
|
178
|
+
dimensions: {
|
|
179
|
+
objectFit: 'contain',
|
|
180
|
+
width: '200px',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
} );
|
|
185
|
+
} );
|
|
186
|
+
|
|
187
|
+
it( 'clears omitted controlled root dimension attributes', () => {
|
|
188
|
+
expect(
|
|
189
|
+
getDimensionUpdateAttributes( {
|
|
190
|
+
hasSelectedStyleState: false,
|
|
191
|
+
nextDimensions: {
|
|
192
|
+
aspectRatio: '16/9',
|
|
193
|
+
width: '200px',
|
|
194
|
+
scale: 'cover',
|
|
195
|
+
},
|
|
196
|
+
dimensionKeys: [ 'aspectRatio', 'width', 'height', 'scale' ],
|
|
197
|
+
} )
|
|
198
|
+
).toEqual( {
|
|
199
|
+
aspectRatio: '16/9',
|
|
200
|
+
width: '200px',
|
|
201
|
+
height: undefined,
|
|
202
|
+
scale: 'cover',
|
|
203
|
+
} );
|
|
204
|
+
} );
|
|
205
|
+
|
|
206
|
+
it( 'clears omitted controlled selected style state dimensions', () => {
|
|
207
|
+
expect(
|
|
208
|
+
getDimensionUpdateAttributes( {
|
|
209
|
+
style: {
|
|
210
|
+
'@mobile': {
|
|
211
|
+
dimensions: {
|
|
212
|
+
height: '100px',
|
|
213
|
+
width: '200px',
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
selectedState: { viewport: '@mobile', pseudo: 'default' },
|
|
218
|
+
hasSelectedStyleState: true,
|
|
219
|
+
nextDimensions: {
|
|
220
|
+
aspectRatio: '16/9',
|
|
221
|
+
width: '200px',
|
|
222
|
+
scale: 'cover',
|
|
223
|
+
},
|
|
224
|
+
dimensionKeyMap: {
|
|
225
|
+
scale: 'objectFit',
|
|
226
|
+
},
|
|
227
|
+
dimensionKeys: [ 'aspectRatio', 'width', 'height', 'scale' ],
|
|
228
|
+
} )
|
|
229
|
+
).toEqual( {
|
|
230
|
+
style: {
|
|
231
|
+
'@mobile': {
|
|
232
|
+
dimensions: {
|
|
233
|
+
aspectRatio: '16/9',
|
|
234
|
+
objectFit: 'cover',
|
|
235
|
+
width: '200px',
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
} );
|
|
240
|
+
} );
|
|
241
|
+
|
|
242
|
+
it( 'resets selected style state dimensions without root attributes', () => {
|
|
243
|
+
expect(
|
|
244
|
+
getDimensionResetAttributes( {
|
|
245
|
+
attributes: {
|
|
246
|
+
width: '200px',
|
|
247
|
+
style: {
|
|
248
|
+
dimensions: {
|
|
249
|
+
width: '300px',
|
|
250
|
+
},
|
|
251
|
+
'@mobile': {
|
|
252
|
+
dimensions: {
|
|
253
|
+
width: '400px',
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
selectedState: { viewport: '@mobile', pseudo: 'default' },
|
|
259
|
+
hasSelectedStyleState: true,
|
|
260
|
+
keys: [ 'width' ],
|
|
261
|
+
defaultAttributes: {
|
|
262
|
+
width: undefined,
|
|
263
|
+
},
|
|
264
|
+
} )
|
|
265
|
+
).toEqual( {
|
|
266
|
+
style: {
|
|
267
|
+
dimensions: {
|
|
268
|
+
width: '300px',
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
} );
|
|
272
|
+
} );
|
|
273
|
+
|
|
274
|
+
it( 'resets default dimensions and root attributes', () => {
|
|
275
|
+
expect(
|
|
276
|
+
getDimensionResetAttributes( {
|
|
277
|
+
attributes: {
|
|
278
|
+
width: '200px',
|
|
279
|
+
style: {
|
|
280
|
+
dimensions: {
|
|
281
|
+
width: '300px',
|
|
282
|
+
},
|
|
283
|
+
'@mobile': {
|
|
284
|
+
dimensions: {
|
|
285
|
+
width: '400px',
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
hasSelectedStyleState: false,
|
|
291
|
+
keys: [ 'width' ],
|
|
292
|
+
defaultAttributes: {
|
|
293
|
+
width: undefined,
|
|
294
|
+
},
|
|
295
|
+
} )
|
|
296
|
+
).toEqual( {
|
|
297
|
+
width: undefined,
|
|
298
|
+
style: {
|
|
299
|
+
'@mobile': {
|
|
300
|
+
dimensions: {
|
|
301
|
+
width: '400px',
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
} );
|
|
306
|
+
} );
|
|
307
|
+
} );
|