@wordpress/block-library 8.18.0 → 8.19.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 +2 -0
- package/README.md +1 -1
- package/build/block/edit.js +53 -2
- package/build/block/edit.js.map +1 -1
- package/build/button/edit.js +7 -4
- package/build/button/edit.js.map +1 -1
- package/build/button/index.js +11 -2
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +10 -4
- package/build/button/save.js.map +1 -1
- package/build/buttons/edit.js +12 -3
- package/build/buttons/edit.js.map +1 -1
- package/build/code/edit.js +8 -2
- package/build/code/edit.js.map +1 -1
- package/build/code/index.js +7 -1
- package/build/code/index.js.map +1 -1
- package/build/column/edit.native.js +5 -5
- package/build/column/edit.native.js.map +1 -1
- package/build/column/index.js +1 -0
- package/build/column/index.js.map +1 -1
- package/build/columns/index.js +2 -0
- package/build/columns/index.js.map +1 -1
- package/build/file/edit.native.js +1 -1
- package/build/file/edit.native.js.map +1 -1
- package/build/file/index.js +2 -1
- package/build/file/index.js.map +1 -1
- package/build/file/utils/index.js +1 -15
- package/build/file/utils/index.js.map +1 -1
- package/build/file/view.js +14 -1
- package/build/file/view.js.map +1 -1
- package/build/footnotes/edit.js +14 -5
- package/build/footnotes/edit.js.map +1 -1
- package/build/gallery/edit.js +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/group/edit.js +0 -1
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +5 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/edit.js +0 -1
- package/build/heading/edit.js.map +1 -1
- package/build/heading/index.js +2 -0
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +3 -6
- package/build/heading/transforms.js.map +1 -1
- package/build/image/deprecated.js +191 -7
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.js +27 -12
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +75 -40
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +7 -4
- package/build/image/index.js.map +1 -1
- package/build/image/{view-interactivity.js → view.js} +1 -1
- package/build/image/view.js.map +1 -0
- package/build/list/deprecated.js +93 -1
- package/build/list/deprecated.js.map +1 -1
- package/build/list/edit.js +10 -10
- package/build/list/edit.js.map +1 -1
- package/build/list/ordered-list-settings.js +10 -10
- package/build/list/ordered-list-settings.js.map +1 -1
- package/build/list/save.js +4 -2
- package/build/list/save.js.map +1 -1
- package/build/list/utils.js +21 -2
- package/build/list/utils.js.map +1 -1
- package/build/navigation/constants.js +1 -1
- package/build/navigation/constants.js.map +1 -1
- package/build/navigation/index.js +4 -2
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/view.js +168 -82
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +3 -9
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/transforms.js +24 -0
- package/build/navigation-link/transforms.js.map +1 -1
- package/build/page-list/edit.js +2 -1
- package/build/page-list/edit.js.map +1 -1
- package/build/post-comments-form/edit.js +10 -2
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-comments-form/form.js +5 -3
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-content/edit.js +8 -7
- package/build/post-content/edit.js.map +1 -1
- package/build/post-content/index.js +3 -0
- package/build/post-content/index.js.map +1 -1
- package/build/post-featured-image/overlay.js +2 -1
- package/build/post-featured-image/overlay.js.map +1 -1
- package/build/post-terms/use-post-terms.js +3 -2
- package/build/post-terms/use-post-terms.js.map +1 -1
- package/build/preformatted/edit.js +4 -1
- package/build/preformatted/edit.js.map +1 -1
- package/build/preformatted/index.js +1 -1
- package/build/preformatted/index.js.map +1 -1
- package/build/pullquote/deprecated.js +6 -7
- package/build/pullquote/deprecated.js.map +1 -1
- package/build/query/edit/enhanced-pagination-modal.js +56 -0
- package/build/query/edit/enhanced-pagination-modal.js.map +1 -0
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js +42 -0
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
- package/build/query/edit/inspector-controls/index.js +8 -25
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +8 -2
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/utils.js +19 -0
- package/build/query/utils.js.map +1 -1
- package/build/query/view.js +4 -5
- package/build/query/view.js.map +1 -1
- package/build/search/index.js +1 -0
- package/build/search/index.js.map +1 -1
- package/build/search/view.js +81 -150
- package/build/search/view.js.map +1 -1
- package/build/social-link/edit.native.js +3 -1
- package/build/social-link/edit.native.js.map +1 -1
- package/build/table/edit.js +7 -7
- package/build/table/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +2 -130
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/hooks.js +145 -0
- package/build/table-of-contents/hooks.js.map +1 -0
- package/build/table-of-contents/index.js +2 -1
- package/build/table-of-contents/index.js.map +1 -1
- package/build/verse/edit.js +4 -1
- package/build/verse/edit.js.map +1 -1
- package/build/verse/index.js +1 -1
- package/build/verse/index.js.map +1 -1
- package/build-module/block/edit.js +54 -3
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/edit.js +7 -4
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/index.js +11 -2
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +10 -4
- package/build-module/button/save.js.map +1 -1
- package/build-module/buttons/edit.js +12 -3
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/code/edit.js +8 -2
- package/build-module/code/edit.js.map +1 -1
- package/build-module/code/index.js +7 -1
- package/build-module/code/index.js.map +1 -1
- package/build-module/column/edit.native.js +5 -5
- package/build-module/column/edit.native.js.map +1 -1
- package/build-module/column/index.js +1 -0
- package/build-module/column/index.js.map +1 -1
- package/build-module/columns/index.js +2 -0
- package/build-module/columns/index.js.map +1 -1
- package/build-module/file/edit.native.js +1 -1
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/file/index.js +2 -1
- package/build-module/file/index.js.map +1 -1
- package/build-module/file/utils/index.js +0 -13
- package/build-module/file/utils/index.js.map +1 -1
- package/build-module/file/view.js +14 -2
- package/build-module/file/view.js.map +1 -1
- package/build-module/footnotes/edit.js +14 -5
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/gallery/edit.js +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/group/edit.js +0 -1
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +5 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/edit.js +0 -1
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/heading/index.js +2 -0
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +3 -6
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/deprecated.js +191 -7
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.js +27 -12
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +77 -42
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +7 -4
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/{view-interactivity.js → view.js} +1 -1
- package/build-module/image/view.js.map +1 -0
- package/build-module/list/deprecated.js +95 -3
- package/build-module/list/deprecated.js.map +1 -1
- package/build-module/list/edit.js +10 -10
- package/build-module/list/edit.js.map +1 -1
- package/build-module/list/ordered-list-settings.js +10 -10
- package/build-module/list/ordered-list-settings.js.map +1 -1
- package/build-module/list/save.js +4 -2
- package/build-module/list/save.js.map +1 -1
- package/build-module/list/utils.js +20 -2
- package/build-module/list/utils.js.map +1 -1
- package/build-module/navigation/constants.js +1 -1
- package/build-module/navigation/constants.js.map +1 -1
- package/build-module/navigation/index.js +4 -2
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/view.js +168 -83
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +3 -9
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/transforms.js +24 -0
- package/build-module/navigation-link/transforms.js.map +1 -1
- package/build-module/page-list/edit.js +2 -1
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-comments-form/edit.js +10 -2
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +5 -3
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-content/edit.js +8 -7
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-content/index.js +3 -0
- package/build-module/post-content/index.js.map +1 -1
- package/build-module/post-featured-image/overlay.js +2 -1
- package/build-module/post-featured-image/overlay.js.map +1 -1
- package/build-module/post-terms/use-post-terms.js +3 -2
- package/build-module/post-terms/use-post-terms.js.map +1 -1
- package/build-module/preformatted/edit.js +4 -1
- package/build-module/preformatted/edit.js.map +1 -1
- package/build-module/preformatted/index.js +1 -1
- package/build-module/preformatted/index.js.map +1 -1
- package/build-module/pullquote/deprecated.js +6 -7
- package/build-module/pullquote/deprecated.js.map +1 -1
- package/build-module/query/edit/enhanced-pagination-modal.js +50 -0
- package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -0
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +35 -0
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
- package/build-module/query/edit/inspector-controls/index.js +9 -26
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +8 -2
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/utils.js +17 -0
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query/view.js +4 -5
- package/build-module/query/view.js.map +1 -1
- package/build-module/search/index.js +1 -0
- package/build-module/search/index.js.map +1 -1
- package/build-module/search/view.js +81 -151
- package/build-module/search/view.js.map +1 -1
- package/build-module/social-link/edit.native.js +3 -1
- package/build-module/social-link/edit.native.js.map +1 -1
- package/build-module/table/edit.js +7 -7
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +3 -131
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +137 -0
- package/build-module/table-of-contents/hooks.js.map +1 -0
- package/build-module/table-of-contents/index.js +2 -1
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-module/verse/edit.js +4 -1
- package/build-module/verse/edit.js.map +1 -1
- package/build-module/verse/index.js +1 -1
- package/build-module/verse/index.js.map +1 -1
- package/build-style/cover/style-rtl.css +9 -0
- package/build-style/cover/style.css +9 -0
- package/build-style/editor-rtl.css +15 -9
- package/build-style/editor.css +15 -9
- package/build-style/file/style-rtl.css +5 -0
- package/build-style/file/style.css +5 -0
- package/build-style/heading/style-rtl.css +13 -0
- package/build-style/heading/style.css +13 -0
- package/build-style/navigation-link/editor-rtl.css +0 -9
- package/build-style/navigation-link/editor.css +0 -9
- package/build-style/paragraph/editor-rtl.css +5 -0
- package/build-style/paragraph/editor.css +5 -0
- package/build-style/paragraph/style-rtl.css +5 -0
- package/build-style/paragraph/style.css +5 -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/query/editor-rtl.css +10 -0
- package/build-style/query/editor.css +10 -0
- package/build-style/query/style-rtl.css +1 -1
- package/build-style/query/style.css +1 -1
- package/build-style/reset-rtl.css +27 -27
- package/build-style/reset.css +27 -27
- package/build-style/style-rtl.css +35 -0
- package/build-style/style.css +35 -0
- package/package.json +32 -33
- package/src/audio/test/__snapshots__/edit.native.js.snap +78 -106
- package/src/avatar/index.php +2 -2
- package/src/block/edit.js +58 -2
- package/src/block/test/edit.native.js +2 -3
- package/src/button/block.json +11 -2
- package/src/button/edit.js +27 -11
- package/src/button/save.js +10 -4
- package/src/buttons/edit.js +13 -3
- package/src/buttons/test/edit.native.js +28 -24
- package/src/calendar/index.php +2 -2
- package/src/code/block.json +2 -1
- package/src/code/edit.js +13 -1
- package/src/code/index.js +5 -0
- package/src/column/block.json +1 -0
- package/src/column/edit.native.js +4 -4
- package/src/columns/block.json +2 -0
- package/src/columns/test/__snapshots__/edit.native.js.snap +14 -0
- package/src/columns/test/edit.native.js +47 -17
- package/src/comment-template/index.php +1 -1
- package/src/comments-pagination-next/index.php +1 -1
- package/src/comments-pagination-previous/index.php +1 -1
- package/src/cover/style.scss +12 -1
- package/src/cover/test/edit.js +7 -7
- package/src/cover/test/edit.native.js +18 -27
- package/src/embed/test/index.native.js +30 -45
- package/src/file/block.json +2 -1
- package/src/file/edit.native.js +1 -1
- package/src/file/index.php +19 -21
- package/src/file/style.scss +6 -1
- package/src/file/test/__snapshots__/edit.native.js.snap +162 -218
- package/src/file/utils/index.js +0 -15
- package/src/file/view.js +14 -5
- package/src/footnotes/edit.js +16 -2
- package/src/gallery/edit.js +1 -1
- package/src/gallery/index.php +1 -1
- package/src/group/block.json +5 -0
- package/src/group/edit.js +0 -1
- package/src/heading/block.json +2 -0
- package/src/heading/edit.js +0 -1
- package/src/heading/style.scss +4 -0
- package/src/heading/transforms.js +1 -6
- package/src/image/block.json +7 -4
- package/src/image/deprecated.js +210 -7
- package/src/image/edit.js +43 -29
- package/src/image/image.js +86 -43
- package/src/image/index.php +251 -28
- package/src/latest-posts/index.php +1 -1
- package/src/list/deprecated.js +84 -3
- package/src/list/edit.js +6 -3
- package/src/list/ordered-list-settings.js +20 -5
- package/src/list/save.js +10 -1
- package/src/list/test/edit.native.js +2 -4
- package/src/list/utils.js +22 -1
- package/src/navigation/block.json +4 -2
- package/src/navigation/constants.js +1 -0
- package/src/navigation/index.php +85 -123
- package/src/navigation/view.js +192 -96
- package/src/navigation-link/edit.js +21 -36
- package/src/navigation-link/editor.scss +0 -8
- package/src/navigation-link/transforms.js +22 -0
- package/src/page-list/edit.js +2 -1
- package/src/paragraph/editor.scss +5 -0
- package/src/paragraph/style.scss +5 -0
- package/src/pattern/index.php +2 -2
- package/src/post-comments-form/edit.js +10 -0
- package/src/post-comments-form/form.js +7 -1
- package/src/post-content/block.json +3 -0
- package/src/post-content/edit.js +14 -6
- package/src/post-excerpt/index.php +2 -2
- package/src/post-featured-image/index.php +2 -2
- package/src/post-featured-image/overlay.js +1 -0
- package/src/post-navigation-link/index.php +5 -1
- package/src/post-navigation-link/style.scss +4 -0
- package/src/post-template/index.php +1 -1
- package/src/post-terms/index.php +5 -2
- package/src/post-terms/use-post-terms.js +4 -2
- package/src/preformatted/edit.js +5 -0
- package/src/preformatted/index.js +1 -1
- package/src/pullquote/deprecated.js +8 -13
- package/src/query/edit/enhanced-pagination-modal.js +65 -0
- package/src/query/edit/inspector-controls/enhanced-pagination-control.js +49 -0
- package/src/query/edit/inspector-controls/index.js +9 -45
- package/src/query/edit/query-content.js +8 -0
- package/src/query/editor.scss +10 -0
- package/src/query/index.php +29 -16
- package/src/query/style.scss +2 -2
- package/src/query/utils.js +22 -0
- package/src/query/view.js +5 -5
- package/src/query-pagination-next/index.php +1 -1
- package/src/query-pagination-previous/index.php +1 -1
- package/src/reset.scss +1 -1
- package/src/search/block.json +1 -0
- package/src/search/index.php +45 -4
- package/src/search/test/__snapshots__/edit.native.js.snap +265 -363
- package/src/search/view.js +70 -169
- package/src/social-link/edit.native.js +1 -1
- package/src/social-link/editor.native.scss +4 -0
- package/src/table/edit.js +21 -19
- package/src/table-of-contents/block.json +2 -1
- package/src/table-of-contents/edit.js +5 -162
- package/src/table-of-contents/hooks.js +156 -0
- package/src/verse/edit.js +5 -0
- package/src/verse/index.js +1 -1
- package/src/verse/test/edit.native.js +2 -3
- package/build/file/view-interactivity.js +0 -22
- package/build/file/view-interactivity.js.map +0 -1
- package/build/image/view-interactivity.js.map +0 -1
- package/build/navigation/view-interactivity.js +0 -172
- package/build/navigation/view-interactivity.js.map +0 -1
- package/build/navigation/view-modal.js +0 -115
- package/build/navigation/view-modal.js.map +0 -1
- package/build-module/file/view-interactivity.js +0 -18
- package/build-module/file/view-interactivity.js.map +0 -1
- package/build-module/image/view-interactivity.js.map +0 -1
- package/build-module/navigation/view-interactivity.js +0 -169
- package/build-module/navigation/view-interactivity.js.map +0 -1
- package/build-module/navigation/view-modal.js +0 -112
- package/build-module/navigation/view-modal.js.map +0 -1
- package/src/file/view-interactivity.js +0 -18
- package/src/navigation/view-interactivity.js +0 -196
- package/src/navigation/view-modal.js +0 -127
- /package/src/image/{view-interactivity.js → view.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useMemo","store","coreStore","blockEditorStore","decodeEntities","cloneBlock","blocksStore","getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","getValueFromObjectPath","object","path","normalizedPath","split","value","forEach","fieldName","mapToIHasNameAndId","map","usePostTypes","postTypes","select","getPostTypes","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","getActiveBlockVariation","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","hasActiveVariationPatterns","getBlockRootClientId","getPatternsByBlockTypes","rootClientId","activePatterns","useScopedBlockVariations","blockVariations","getBlockVariations","variations","isNotConnected","variation","namespace","connectedVariations","usePatterns"],"sources":["@wordpress/block-library/src/query/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as a string of properties, separated by dots,\n * for example: \"parent.child\".\n *\n * @param {Object} object Input object.\n * @param {string} path Path to the object property.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path ) => {\n\tconst normalizedPath = path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Hook that returns whether a specific post type is hierarchical.\n *\n * @param {string} postType The post type to check.\n * @return {boolean} Whether a specific post type is hierarchical.\n */\nexport function useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\n/**\n * Hook that returns the query properties' names defined by the active\n * block variation, to determine which block's filters to show.\n *\n * @param {Object} attributes Block attributes.\n * @return {string[]} An array of the query attributes.\n */\nexport function useAllowedControls( attributes ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.allowedControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific patterns for this variation.\n * If there are, these patterns are going to be the only ones suggested to\n * the user in setup and replace flow, without including the default ones\n * for Query Loop.\n *\n * If there are no such patterns, the default ones for Query Loop are going\n * to be suggested.\n *\n * @param {string} clientId The block's client ID.\n * @param {Object} attributes The block's attributes.\n * @return {string} The block name to be used in the patterns suggestions.\n */\nexport function useBlockNameForPatterns( clientId, attributes ) {\n\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.name,\n\t\t[ attributes ]\n\t);\n\tconst blockName = `core/query/${ activeVariationName }`;\n\tconst hasActiveVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst activePatterns = getPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t\treturn activePatterns.length > 0;\n\t\t},\n\t\t[ clientId, activeVariationName, blockName ]\n\t);\n\treturn hasActiveVariationPatterns ? blockName : 'core/query';\n}\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific scoped `block` variations connected with\n * this variation.\n *\n * If there are, these variations are going to be the only ones suggested\n * to the user in setup flow when clicking to `start blank`, without including\n * the default ones for Query Loop.\n *\n * If there are no such scoped `block` variations, the default ones for Query\n * Loop are going to be suggested.\n *\n * The way we determine such variations is with the convention that they have the `namespace`\n * attribute defined as an array. This array should contain the names(`name` property) of any\n * variations they want to be connected to.\n * For example, if we have a `Query Loop` scoped `inserter` variation with the name `products`,\n * we can connect a scoped `block` variation by setting its `namespace` attribute to `['products']`.\n * If the user selects this variation, the `namespace` attribute will be overridden by the\n * main `inserter` variation.\n *\n * @param {Object} attributes The block's attributes.\n * @return {WPBlockVariation[]} The block variations to be suggested in setup flow, when clicking to `start blank`.\n */\nexport function useScopedBlockVariations( attributes ) {\n\tconst { activeVariationName, blockVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockVariations } =\n\t\t\t\tselect( blocksStore );\n\t\t\treturn {\n\t\t\t\tactiveVariationName: getActiveBlockVariation(\n\t\t\t\t\t'core/query',\n\t\t\t\t\tattributes\n\t\t\t\t)?.name,\n\t\t\t\tblockVariations: getBlockVariations( 'core/query', 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ attributes ]\n\t);\n\tconst variations = useMemo( () => {\n\t\t// Filter out the variations that have defined a `namespace` attribute,\n\t\t// which means they are 'connected' to specific variations of the block.\n\t\tconst isNotConnected = ( variation ) =>\n\t\t\t! variation.attributes?.namespace;\n\t\tif ( ! activeVariationName ) {\n\t\t\treturn blockVariations.filter( isNotConnected );\n\t\t}\n\t\tconst connectedVariations = blockVariations.filter( ( variation ) =>\n\t\t\tvariation.attributes?.namespace?.includes( activeVariationName )\n\t\t);\n\t\tif ( !! connectedVariations.length ) {\n\t\t\treturn connectedVariations;\n\t\t}\n\t\treturn blockVariations.filter( isNotConnected );\n\t}, [ activeVariationName, blockVariations ] );\n\treturn variations;\n}\n\n/**\n * Hook that returns the block patterns for a specific block type.\n *\n * @param {string} clientId The block's client ID.\n * @param {string} name The block type name.\n * @return {Object[]} An array of valid block patterns.\n */\nexport const usePatterns = ( clientId, name ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn getPatternsByBlockTypes( name, rootClientId );\n\t\t},\n\t\t[ name, clientId ]\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,EAAEJ,KAAK,IAAIK,WAAW,QAAQ,mBAAmB;;AAEpE;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAKC,QAAQ,IAAM;EAC9C,MAAMC,OAAO,GAAGD,QAAQ,EAAEE,MAAM,CAC/B,CAAEC,WAAW,EAAEC,MAAM,KAAM;IAC1B,MAAM;MAAEC,OAAO;MAAEC,SAAS;MAAEC;IAAM,CAAC,GAAGJ,WAAW;IACjDE,OAAO,CAAED,MAAM,CAACI,EAAE,CAAE,GAAGJ,MAAM;IAC7BE,SAAS,CAAEF,MAAM,CAACK,IAAI,CAAE,GAAGL,MAAM;IACjCG,KAAK,CAACG,IAAI,CAAEN,MAAM,CAACK,IAAK,CAAC;IACzB,OAAON,WAAW;EACnB,CAAC,EACD;IAAEE,OAAO,EAAE,CAAC,CAAC;IAAEC,SAAS,EAAE,CAAC,CAAC;IAAEC,KAAK,EAAE;EAAG,CACzC,CAAC;EACD,OAAO;IACNP,QAAQ;IACR,GAAGC;EACJ,CAAC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMU,sBAAsB,GAAGA,CAAEC,MAAM,EAAEC,IAAI,KAAM;EACzD,MAAMC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EjE,IAAI,EAAEuD,QAAQ,CACjB,CAAC;AACF,CAAC"}
|
|
1
|
+
{"version":3,"names":["useSelect","useMemo","store","coreStore","blockEditorStore","decodeEntities","cloneBlock","blocksStore","getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","getValueFromObjectPath","object","path","normalizedPath","split","value","forEach","fieldName","mapToIHasNameAndId","map","usePostTypes","postTypes","select","getPostTypes","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","getActiveBlockVariation","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","hasActiveVariationPatterns","getBlockRootClientId","getPatternsByBlockTypes","rootClientId","activePatterns","useScopedBlockVariations","blockVariations","getBlockVariations","variations","isNotConnected","variation","namespace","connectedVariations","usePatterns","useContainsThirdPartyBlocks","getClientIdsOfDescendants","getBlockName","some","descendantClientId","startsWith"],"sources":["@wordpress/block-library/src/query/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as a string of properties, separated by dots,\n * for example: \"parent.child\".\n *\n * @param {Object} object Input object.\n * @param {string} path Path to the object property.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path ) => {\n\tconst normalizedPath = path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Hook that returns whether a specific post type is hierarchical.\n *\n * @param {string} postType The post type to check.\n * @return {boolean} Whether a specific post type is hierarchical.\n */\nexport function useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\n/**\n * Hook that returns the query properties' names defined by the active\n * block variation, to determine which block's filters to show.\n *\n * @param {Object} attributes Block attributes.\n * @return {string[]} An array of the query attributes.\n */\nexport function useAllowedControls( attributes ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.allowedControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific patterns for this variation.\n * If there are, these patterns are going to be the only ones suggested to\n * the user in setup and replace flow, without including the default ones\n * for Query Loop.\n *\n * If there are no such patterns, the default ones for Query Loop are going\n * to be suggested.\n *\n * @param {string} clientId The block's client ID.\n * @param {Object} attributes The block's attributes.\n * @return {string} The block name to be used in the patterns suggestions.\n */\nexport function useBlockNameForPatterns( clientId, attributes ) {\n\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.name,\n\t\t[ attributes ]\n\t);\n\tconst blockName = `core/query/${ activeVariationName }`;\n\tconst hasActiveVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst activePatterns = getPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t\treturn activePatterns.length > 0;\n\t\t},\n\t\t[ clientId, activeVariationName, blockName ]\n\t);\n\treturn hasActiveVariationPatterns ? blockName : 'core/query';\n}\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific scoped `block` variations connected with\n * this variation.\n *\n * If there are, these variations are going to be the only ones suggested\n * to the user in setup flow when clicking to `start blank`, without including\n * the default ones for Query Loop.\n *\n * If there are no such scoped `block` variations, the default ones for Query\n * Loop are going to be suggested.\n *\n * The way we determine such variations is with the convention that they have the `namespace`\n * attribute defined as an array. This array should contain the names(`name` property) of any\n * variations they want to be connected to.\n * For example, if we have a `Query Loop` scoped `inserter` variation with the name `products`,\n * we can connect a scoped `block` variation by setting its `namespace` attribute to `['products']`.\n * If the user selects this variation, the `namespace` attribute will be overridden by the\n * main `inserter` variation.\n *\n * @param {Object} attributes The block's attributes.\n * @return {WPBlockVariation[]} The block variations to be suggested in setup flow, when clicking to `start blank`.\n */\nexport function useScopedBlockVariations( attributes ) {\n\tconst { activeVariationName, blockVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockVariations } =\n\t\t\t\tselect( blocksStore );\n\t\t\treturn {\n\t\t\t\tactiveVariationName: getActiveBlockVariation(\n\t\t\t\t\t'core/query',\n\t\t\t\t\tattributes\n\t\t\t\t)?.name,\n\t\t\t\tblockVariations: getBlockVariations( 'core/query', 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ attributes ]\n\t);\n\tconst variations = useMemo( () => {\n\t\t// Filter out the variations that have defined a `namespace` attribute,\n\t\t// which means they are 'connected' to specific variations of the block.\n\t\tconst isNotConnected = ( variation ) =>\n\t\t\t! variation.attributes?.namespace;\n\t\tif ( ! activeVariationName ) {\n\t\t\treturn blockVariations.filter( isNotConnected );\n\t\t}\n\t\tconst connectedVariations = blockVariations.filter( ( variation ) =>\n\t\t\tvariation.attributes?.namespace?.includes( activeVariationName )\n\t\t);\n\t\tif ( !! connectedVariations.length ) {\n\t\t\treturn connectedVariations;\n\t\t}\n\t\treturn blockVariations.filter( isNotConnected );\n\t}, [ activeVariationName, blockVariations ] );\n\treturn variations;\n}\n\n/**\n * Hook that returns the block patterns for a specific block type.\n *\n * @param {string} clientId The block's client ID.\n * @param {string} name The block type name.\n * @return {Object[]} An array of valid block patterns.\n */\nexport const usePatterns = ( clientId, name ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn getPatternsByBlockTypes( name, rootClientId );\n\t\t},\n\t\t[ name, clientId ]\n\t);\n};\n\n/**\n * Hook that returns whether the Query Loop with the given `clientId` contains\n * any third-party block.\n *\n * @param {string} clientId The block's client ID.\n * @return {boolean} True if it contains third-party blocks.\n */\nexport const useContainsThirdPartyBlocks = ( clientId ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getClientIdsOfDescendants, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn getClientIdsOfDescendants( clientId ).some(\n\t\t\t\t( descendantClientId ) =>\n\t\t\t\t\t! getBlockName( descendantClientId ).startsWith( 'core/' )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,EAAEJ,KAAK,IAAIK,WAAW,QAAQ,mBAAmB;;AAEpE;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAKC,QAAQ,IAAM;EAC9C,MAAMC,OAAO,GAAGD,QAAQ,EAAEE,MAAM,CAC/B,CAAEC,WAAW,EAAEC,MAAM,KAAM;IAC1B,MAAM;MAAEC,OAAO;MAAEC,SAAS;MAAEC;IAAM,CAAC,GAAGJ,WAAW;IACjDE,OAAO,CAAED,MAAM,CAACI,EAAE,CAAE,GAAGJ,MAAM;IAC7BE,SAAS,CAAEF,MAAM,CAACK,IAAI,CAAE,GAAGL,MAAM;IACjCG,KAAK,CA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EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMK,WAAW,GAAGA,CAAEpB,QAAQ,EAAEvD,IAAI,KAAM;EAChD,OAAOlB,SAAS,CACbgC,MAAM,IAAM;IACb,MAAM;MAAEiD,oBAAoB;MAAEC;IAAwB,CAAC,GACtDlD,MAAM,CAAE5B,gBAAiB,CAAC;IAC3B,MAAM+E,YAAY,GAAGF,oBAAoB,CAAER,QAAS,CAAC;IACrD,OAAOS,uBAAuB,CAAEhE,IAAI,EAAEiE,YAAa,CAAC;EACrD,CAAC,EACD,CAAEjE,IAAI,EAAEuD,QAAQ,CACjB,CAAC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMqB,2BAA2B,GAAKrB,QAAQ,IAAM;EAC1D,OAAOzE,SAAS,CACbgC,MAAM,IAAM;IACb,MAAM;MAAE+D,yBAAyB;MAAEC;IAAa,CAAC,GAChDhE,MAAM,CAAE5B,gBAAiB,CAAC;IAE3B,OAAO2F,yBAAyB,CAAEtB,QAAS,CAAC,CAACwB,IAAI,CAC9CC,kBAAkB,IACnB,CAAEF,YAAY,CAAEE,kBAAmB,CAAC,CAACC,UAAU,CAAE,OAAQ,CAC3D,CAAC;EACF,CAAC,EACD,CAAE1B,QAAQ,CACX,CAAC;AACF,CAAC"}
|
|
@@ -31,8 +31,7 @@ store({
|
|
|
31
31
|
navigate: async ({
|
|
32
32
|
event,
|
|
33
33
|
ref,
|
|
34
|
-
context
|
|
35
|
-
state
|
|
34
|
+
context
|
|
36
35
|
}) => {
|
|
37
36
|
if (isValidLink(ref) && isValidEvent(event)) {
|
|
38
37
|
event.preventDefault();
|
|
@@ -40,9 +39,9 @@ store({
|
|
|
40
39
|
|
|
41
40
|
// Don't announce the navigation immediately, wait 300 ms.
|
|
42
41
|
const timeout = setTimeout(() => {
|
|
43
|
-
context.core.query.message =
|
|
42
|
+
context.core.query.message = context.core.query.loadingText;
|
|
44
43
|
context.core.query.animation = 'start';
|
|
45
|
-
},
|
|
44
|
+
}, 400);
|
|
46
45
|
await navigate(ref.href);
|
|
47
46
|
|
|
48
47
|
// Dismiss loading message if it hasn't been added yet.
|
|
@@ -51,7 +50,7 @@ store({
|
|
|
51
50
|
// Announce that the page has been loaded. If the message is the
|
|
52
51
|
// same, we use a no-break space similar to the @wordpress/a11y
|
|
53
52
|
// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26
|
|
54
|
-
context.core.query.message =
|
|
53
|
+
context.core.query.message = context.core.query.loadedText + (context.core.query.message === context.core.query.loadedText ? '\u00A0' : '');
|
|
55
54
|
context.core.query.animation = 'finish';
|
|
56
55
|
|
|
57
56
|
// Focus the first anchor of the Query block.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","navigate","prefetch","isValidLink","ref","window","HTMLAnchorElement","href","target","origin","location","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","selectors","core","query","startAnimation","context","animation","finishAnimation","actions","
|
|
1
|
+
{"version":3,"names":["store","navigate","prefetch","isValidLink","ref","window","HTMLAnchorElement","href","target","origin","location","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","selectors","core","query","startAnimation","context","animation","finishAnimation","actions","preventDefault","id","closest","dataset","wpNavigationId","timeout","setTimeout","message","loadingText","clearTimeout","loadedText","document","querySelector","focus"],"sources":["@wordpress/block-library/src/query/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store, navigate, prefetch } from '@wordpress/interactivity';\n\nconst isValidLink = ( ref ) =>\n\tref &&\n\tref instanceof window.HTMLAnchorElement &&\n\tref.href &&\n\t( ! ref.target || ref.target === '_self' ) &&\n\tref.origin === window.location.origin;\n\nconst isValidEvent = ( event ) =>\n\tevent.button === 0 && // left clicks only\n\t! event.metaKey && // open in new tab (mac)\n\t! event.ctrlKey && // open in new tab (windows)\n\t! event.altKey && // download\n\t! event.shiftKey &&\n\t! event.defaultPrevented;\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tstartAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'start',\n\t\t\t\tfinishAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'finish',\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tnavigate: async ( { event, ref, context } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\tconst id = ref.closest( '[data-wp-navigation-id]' )\n\t\t\t\t\t\t\t.dataset.wpNavigationId;\n\n\t\t\t\t\t\t// Don't announce the navigation immediately, wait 300 ms.\n\t\t\t\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\t\tcontext.core.query.loadingText;\n\t\t\t\t\t\t\tcontext.core.query.animation = 'start';\n\t\t\t\t\t\t}, 400 );\n\n\t\t\t\t\t\tawait navigate( ref.href );\n\n\t\t\t\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\t\t\t\tclearTimeout( timeout );\n\n\t\t\t\t\t\t// Announce that the page has been loaded. If the message is the\n\t\t\t\t\t\t// same, we use a no-break space similar to the @wordpress/a11y\n\t\t\t\t\t\t// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26\n\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\tcontext.core.query.loadedText +\n\t\t\t\t\t\t\t( context.core.query.message ===\n\t\t\t\t\t\t\tcontext.core.query.loadedText\n\t\t\t\t\t\t\t\t? '\\u00A0'\n\t\t\t\t\t\t\t\t: '' );\n\n\t\t\t\t\t\tcontext.core.query.animation = 'finish';\n\n\t\t\t\t\t\t// Focus the first anchor of the Query block.\n\t\t\t\t\t\tdocument\n\t\t\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t\t\t`[data-wp-navigation-id=${ id }] a[href]`\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t?.focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tprefetch: async ( { ref } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) ) {\n\t\t\t\t\t\tawait prefetch( ref.href );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,0BAA0B;AAEpE,MAAMC,WAAW,GAAKC,GAAG,IACxBA,GAAG,IACHA,GAAG,YAAYC,MAAM,CAACC,iBAAiB,IACvCF,GAAG,CAACG,IAAI,KACN,CAAEH,GAAG,CAACI,MAAM,IAAIJ,GAAG,CAACI,MAAM,KAAK,OAAO,CAAE,IAC1CJ,GAAG,CAACK,MAAM,KAAKJ,MAAM,CAACK,QAAQ,CAACD,MAAM;AAEtC,MAAME,YAAY,GAAKC,KAAK,IAC3BA,KAAK,CAACC,MAAM,KAAK,CAAC;AAAI;AACtB,CAAED,KAAK,CAACE,OAAO;AAAI;AACnB,CAAEF,KAAK,CAACG,OAAO;AAAI;AACnB,CAAEH,KAAK,CAACI,MAAM;AAAI;AAClB,CAAEJ,KAAK,CAACK,QAAQ,IAChB,CAAEL,KAAK,CAACM,gBAAgB;AAEzBlB,KAAK,CAAE;EACNmB,SAAS,EAAE;IACVC,IAAI,EAAE;MACLC,KAAK,EAAE;QACNC,cAAc,EAAEA,CAAE;UAAEC;QAAQ,CAAC,KAC5BA,OAAO,CAACH,IAAI,CAACC,KAAK,CAACG,SAAS,KAAK,OAAO;QACzCC,eAAe,EAAEA,CAAE;UAAEF;QAAQ,CAAC,KAC7BA,OAAO,CAACH,IAAI,CAACC,KAAK,CAACG,SAAS,KAAK;MACnC;IACD;E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MAAMF,QAAQ,CAAEE,GAAG,CAACG,IAAK,CAAC;UAC3B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","search","icon","initBlock","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","label","type","__experimentalRole","showLabel","placeholder","width","widthUnit","buttonText","buttonPosition","buttonUseIcon","query","buttonBehavior","isSearchFieldHidden","supports","align","color","gradients","__experimentalSkipSerialization","__experimentalDefaultControls","background","text","typography","__experimentalSelector","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalBorder","radius","html","viewScript","editorStyle","style","edit","variations","settings","example","viewportWidth","init"],"sources":["@wordpress/block-library/src/search/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { search as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: { buttonText: __( 'Search' ), label: __( 'Search' ) },\n\t\tviewportWidth: 400,\n\t},\n\tvariations,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,MAAM,IAAIC,IAAI,QAAQ,kBAAkB;;AAEjD;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,KAAA;MAAAC,IAAA;MAAAC,kBAAA;IAAA;IAAAC,SAAA;MAAAF,IAAA;MAAA;IAAA;IAAAG,WAAA;MAAAH,IAAA;MAAA;MAAAC,kBAAA;IAAA;IAAAG,KAAA;MAAAJ,IAAA;IAAA;IAAAK,SAAA;MAAAL,IAAA;IAAA;IAAAM,UAAA;MAAAN,IAAA;MAAAC,kBAAA;IAAA;IAAAM,cAAA;MAAAP,IAAA;MAAA;IAAA;IAAAQ,aAAA;MAAAR,IAAA;MAAA;IAAA;IAAAS,KAAA;MAAAT,IAAA;MAAA;IAAA;IAAAU,cAAA;MAAAV,IAAA;MAAA;IAAA;IAAAW,mBAAA;MAAAX,IAAA;MAAA;IAAA;EAAA;EAAAY,QAAA;IAAAC,KAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,+BAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,UAAA;
|
|
1
|
+
{"version":3,"names":["__","search","icon","initBlock","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","label","type","__experimentalRole","showLabel","placeholder","width","widthUnit","buttonText","buttonPosition","buttonUseIcon","query","buttonBehavior","isSearchFieldHidden","supports","align","color","gradients","__experimentalSkipSerialization","__experimentalDefaultControls","background","text","interactivity","typography","__experimentalSelector","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalBorder","radius","html","viewScript","editorStyle","style","edit","variations","settings","example","viewportWidth","init"],"sources":["@wordpress/block-library/src/search/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { search as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: { buttonText: __( 'Search' ), label: __( 'Search' ) },\n\t\tviewport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;QAAAH,KAAA;QAAAkB,MAAA;QAAA5B,KAAA;MAAA;IAAA;IAAA6B,IAAA;EAAA;EAAAC,UAAA;EAAAC,WAAA;EAAAC,KAAA;AAAA;AAE5C,OAAOC,IAAI,MAAM,QAAQ;AACzB,OAAOC,UAAU,MAAM,cAAc;AAErC,MAAM;EAAE9C;AAAK,CAAC,GAAGH,QAAQ;AAEzB,SAASA,QAAQ,EAAEG,IAAI;AAEvB,OAAO,MAAM+C,QAAQ,GAAG;EACvBpD,IAAI;EACJqD,OAAO,EAAE;IACR1C,UAAU,EAAE;MAAEQ,UAAU,EAAErB,EAAE,CAAE,QAAS,CAAC;MAAEc,KAAK,EAAEd,EAAE,CAAE,QAAS;IAAE,CAAC;IACjEwD,aAAa,EAAE;EAChB,CAAC;EACDH,UAAU;EACVD;AACD,CAAC;AAED,OAAO,MAAMK,IAAI,GAAGA,CAAA,KAAMtD,SAAS,CAAE;EAAEI,IAAI;EAAEH,QAAQ;EAAEkD;AAAS,CAAE,CAAC"}
|
|
@@ -1,156 +1,86 @@
|
|
|
1
|
-
/*eslint-env browser*/
|
|
2
|
-
|
|
3
|
-
/** @type {?HTMLFormElement} */
|
|
4
|
-
let expandedSearchBlock = null;
|
|
5
|
-
const hiddenClass = 'wp-block-search__searchfield-hidden';
|
|
6
|
-
|
|
7
1
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @param {HTMLElement} element
|
|
2
|
+
* WordPress dependencies
|
|
11
3
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
import { store as wpStore } from '@wordpress/interactivity';
|
|
5
|
+
wpStore({
|
|
6
|
+
selectors: {
|
|
7
|
+
core: {
|
|
8
|
+
search: {
|
|
9
|
+
ariaLabel: ({
|
|
10
|
+
context
|
|
11
|
+
}) => {
|
|
12
|
+
const {
|
|
13
|
+
ariaLabelCollapsed,
|
|
14
|
+
ariaLabelExpanded
|
|
15
|
+
} = context.core.search;
|
|
16
|
+
return context.core.search.isSearchInputVisible ? ariaLabelExpanded : ariaLabelCollapsed;
|
|
17
|
+
},
|
|
18
|
+
ariaControls: ({
|
|
19
|
+
context
|
|
20
|
+
}) => {
|
|
21
|
+
return context.core.search.isSearchInputVisible ? null : context.core.search.inputId;
|
|
22
|
+
},
|
|
23
|
+
type: ({
|
|
24
|
+
context
|
|
25
|
+
}) => {
|
|
26
|
+
return context.core.search.isSearchInputVisible ? 'submit' : 'button';
|
|
27
|
+
},
|
|
28
|
+
tabindex: ({
|
|
29
|
+
context
|
|
30
|
+
}) => {
|
|
31
|
+
return context.core.search.isSearchInputVisible ? '0' : '-1';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
actions: {
|
|
37
|
+
core: {
|
|
38
|
+
search: {
|
|
39
|
+
openSearchInput: ({
|
|
40
|
+
context,
|
|
41
|
+
event,
|
|
42
|
+
ref
|
|
43
|
+
}) => {
|
|
44
|
+
if (!context.core.search.isSearchInputVisible) {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
context.core.search.isSearchInputVisible = true;
|
|
47
|
+
ref.parentElement.querySelector('input').focus();
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
closeSearchInput: ({
|
|
51
|
+
context
|
|
52
|
+
}) => {
|
|
53
|
+
context.core.search.isSearchInputVisible = false;
|
|
54
|
+
},
|
|
55
|
+
handleSearchKeydown: store => {
|
|
56
|
+
const {
|
|
57
|
+
actions,
|
|
58
|
+
event,
|
|
59
|
+
ref
|
|
60
|
+
} = store;
|
|
61
|
+
// If Escape close the menu.
|
|
62
|
+
if (event?.key === 'Escape') {
|
|
63
|
+
actions.core.search.closeSearchInput(store);
|
|
64
|
+
ref.querySelector('button').focus();
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
handleSearchFocusout: store => {
|
|
68
|
+
const {
|
|
69
|
+
actions,
|
|
70
|
+
event,
|
|
71
|
+
ref
|
|
72
|
+
} = store;
|
|
73
|
+
// If focus is outside search form, and in the document, close menu
|
|
74
|
+
// event.target === The element losing focus
|
|
75
|
+
// event.relatedTarget === The element receiving focus (if any)
|
|
76
|
+
// When focusout is outside the document,
|
|
77
|
+
// `window.document.activeElement` doesn't change.
|
|
78
|
+
if (!ref.contains(event.relatedTarget) && event.target !== window.document.activeElement) {
|
|
79
|
+
actions.core.search.closeSearchInput(store);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
15
84
|
}
|
|
16
|
-
const ariaLabel = element.dataset.toggledAriaLabel;
|
|
17
|
-
element.dataset.toggledAriaLabel = element.ariaLabel;
|
|
18
|
-
element.ariaLabel = ariaLabel;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Gets search input.
|
|
23
|
-
*
|
|
24
|
-
* @param {HTMLFormElement} block Search block.
|
|
25
|
-
* @return {HTMLInputElement} Search input.
|
|
26
|
-
*/
|
|
27
|
-
function getSearchInput(block) {
|
|
28
|
-
return block.querySelector('.wp-block-search__input');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Gets search button.
|
|
33
|
-
*
|
|
34
|
-
* @param {HTMLFormElement} block Search block.
|
|
35
|
-
* @return {HTMLButtonElement} Search button.
|
|
36
|
-
*/
|
|
37
|
-
function getSearchButton(block) {
|
|
38
|
-
return block.querySelector('.wp-block-search__button');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Handles keydown event to collapse an expanded Search block (when pressing Escape key).
|
|
43
|
-
*
|
|
44
|
-
* @param {KeyboardEvent} event
|
|
45
|
-
*/
|
|
46
|
-
function handleKeydownEvent(event) {
|
|
47
|
-
if (!expandedSearchBlock) {
|
|
48
|
-
// In case the event listener wasn't removed in time.
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (event.key === 'Escape') {
|
|
52
|
-
const block = expandedSearchBlock; // This is nullified by collapseExpandedSearchBlock().
|
|
53
|
-
collapseExpandedSearchBlock();
|
|
54
|
-
getSearchButton(block).focus();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Handles keyup event to collapse an expanded Search block (e.g. when tabbing out of expanded Search block).
|
|
60
|
-
*
|
|
61
|
-
* @param {KeyboardEvent} event
|
|
62
|
-
*/
|
|
63
|
-
function handleKeyupEvent(event) {
|
|
64
|
-
if (!expandedSearchBlock) {
|
|
65
|
-
// In case the event listener wasn't removed in time.
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (event.target.closest('.wp-block-search') !== expandedSearchBlock) {
|
|
69
|
-
collapseExpandedSearchBlock();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Expands search block.
|
|
75
|
-
*
|
|
76
|
-
* Inverse of what is done in collapseExpandedSearchBlock().
|
|
77
|
-
*
|
|
78
|
-
* @param {HTMLFormElement} block Search block.
|
|
79
|
-
*/
|
|
80
|
-
function expandSearchBlock(block) {
|
|
81
|
-
// Make sure only one is open at a time.
|
|
82
|
-
if (expandedSearchBlock) {
|
|
83
|
-
collapseExpandedSearchBlock();
|
|
84
|
-
}
|
|
85
|
-
const searchField = getSearchInput(block);
|
|
86
|
-
const searchButton = getSearchButton(block);
|
|
87
|
-
searchButton.type = 'submit';
|
|
88
|
-
searchField.ariaHidden = 'false';
|
|
89
|
-
searchField.tabIndex = 0;
|
|
90
|
-
searchButton.ariaExpanded = 'true';
|
|
91
|
-
searchButton.removeAttribute('aria-controls'); // Note: Seemingly not reflected with searchButton.ariaControls.
|
|
92
|
-
toggleAriaLabel(searchButton);
|
|
93
|
-
block.classList.remove(hiddenClass);
|
|
94
|
-
searchField.focus(); // Note that Chrome seems to do this automatically.
|
|
95
|
-
|
|
96
|
-
// The following two must be inverse of what is done in collapseExpandedSearchBlock().
|
|
97
|
-
document.addEventListener('keydown', handleKeydownEvent, {
|
|
98
|
-
passive: true
|
|
99
|
-
});
|
|
100
|
-
document.addEventListener('keyup', handleKeyupEvent, {
|
|
101
|
-
passive: true
|
|
102
|
-
});
|
|
103
|
-
expandedSearchBlock = block;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Collapses the expanded search block.
|
|
108
|
-
*
|
|
109
|
-
* Inverse of what is done in expandSearchBlock().
|
|
110
|
-
*/
|
|
111
|
-
function collapseExpandedSearchBlock() {
|
|
112
|
-
if (!expandedSearchBlock) {
|
|
113
|
-
throw new Error('Expected expandedSearchBlock to be defined.');
|
|
114
|
-
}
|
|
115
|
-
const block = expandedSearchBlock;
|
|
116
|
-
const searchField = getSearchInput(block);
|
|
117
|
-
const searchButton = getSearchButton(block);
|
|
118
|
-
searchButton.type = 'button';
|
|
119
|
-
searchField.ariaHidden = 'true';
|
|
120
|
-
searchField.tabIndex = -1;
|
|
121
|
-
searchButton.ariaExpanded = 'false';
|
|
122
|
-
searchButton.setAttribute('aria-controls', searchField.id); // Note: Seemingly not reflected with searchButton.ariaControls.
|
|
123
|
-
toggleAriaLabel(searchButton);
|
|
124
|
-
block.classList.add(hiddenClass);
|
|
125
|
-
|
|
126
|
-
// The following two must be inverse of what is done in expandSearchBlock().
|
|
127
|
-
document.removeEventListener('keydown', handleKeydownEvent, {
|
|
128
|
-
passive: true
|
|
129
|
-
});
|
|
130
|
-
document.removeEventListener('keyup', handleKeyupEvent, {
|
|
131
|
-
passive: true
|
|
132
|
-
});
|
|
133
|
-
expandedSearchBlock = null;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Listen for click events anywhere on the document so this script can be loaded asynchronously in the head.
|
|
137
|
-
document.addEventListener('click', event => {
|
|
138
|
-
// Get the ancestor expandable Search block of the clicked element.
|
|
139
|
-
const block = event.target.closest('.wp-block-search__button-behavior-expand');
|
|
140
|
-
|
|
141
|
-
/*
|
|
142
|
-
* If there is already an expanded search block and either the current click was not for a Search block or it was
|
|
143
|
-
* for another block, then collapse the currently-expanded block.
|
|
144
|
-
*/
|
|
145
|
-
if (expandedSearchBlock && block !== expandedSearchBlock) {
|
|
146
|
-
collapseExpandedSearchBlock();
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// If the click was on or inside a collapsed Search block, expand it.
|
|
150
|
-
if (block instanceof HTMLFormElement && block.classList.contains(hiddenClass)) {
|
|
151
|
-
expandSearchBlock(block);
|
|
152
|
-
}
|
|
153
|
-
}, {
|
|
154
|
-
passive: true
|
|
155
85
|
});
|
|
156
86
|
//# sourceMappingURL=view.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["store","wpStore","selectors","core","search","ariaLabel","context","ariaLabelCollapsed","ariaLabelExpanded","isSearchInputVisible","ariaControls","inputId","type","tabindex","actions","openSearchInput","event","ref","preventDefault","parentElement","querySelector","focus","closeSearchInput","handleSearchKeydown","key","handleSearchFocusout","contains","relatedTarget","target","window","document","activeElement"],"sources":["@wordpress/block-library/src/search/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as wpStore } from '@wordpress/interactivity';\n\nwpStore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tsearch: {\n\t\t\t\tariaLabel: ( { context } ) => {\n\t\t\t\t\tconst { ariaLabelCollapsed, ariaLabelExpanded } =\n\t\t\t\t\t\tcontext.core.search;\n\t\t\t\t\treturn context.core.search.isSearchInputVisible\n\t\t\t\t\t\t? ariaLabelExpanded\n\t\t\t\t\t\t: ariaLabelCollapsed;\n\t\t\t\t},\n\t\t\t\tariaControls: ( { context } ) => {\n\t\t\t\t\treturn context.core.search.isSearchInputVisible\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: context.core.search.inputId;\n\t\t\t\t},\n\t\t\t\ttype: ( { context } ) => {\n\t\t\t\t\treturn context.core.search.isSearchInputVisible\n\t\t\t\t\t\t? 'submit'\n\t\t\t\t\t\t: 'button';\n\t\t\t\t},\n\t\t\t\ttabindex: ( { context } ) => {\n\t\t\t\t\treturn context.core.search.isSearchInputVisible\n\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t: '-1';\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tsearch: {\n\t\t\t\topenSearchInput: ( { context, event, ref } ) => {\n\t\t\t\t\tif ( ! context.core.search.isSearchInputVisible ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tcontext.core.search.isSearchInputVisible = true;\n\t\t\t\t\t\tref.parentElement.querySelector( 'input' ).focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcloseSearchInput: ( { context } ) => {\n\t\t\t\t\tcontext.core.search.isSearchInputVisible = false;\n\t\t\t\t},\n\t\t\t\thandleSearchKeydown: ( store ) => {\n\t\t\t\t\tconst { actions, event, ref } = store;\n\t\t\t\t\t// If Escape close the menu.\n\t\t\t\t\tif ( event?.key === 'Escape' ) {\n\t\t\t\t\t\tactions.core.search.closeSearchInput( store );\n\t\t\t\t\t\tref.querySelector( 'button' ).focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleSearchFocusout: ( store ) => {\n\t\t\t\t\tconst { actions, event, ref } = store;\n\t\t\t\t\t// If focus is outside search form, and in the document, close menu\n\t\t\t\t\t// event.target === The element losing focus\n\t\t\t\t\t// event.relatedTarget === The element receiving focus (if any)\n\t\t\t\t\t// When focusout is outside the document,\n\t\t\t\t\t// `window.document.activeElement` doesn't change.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! ref.contains( event.relatedTarget ) &&\n\t\t\t\t\t\tevent.target !== window.document.activeElement\n\t\t\t\t\t) {\n\t\t\t\t\t\tactions.core.search.closeSearchInput( store );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,OAAO,QAAQ,0BAA0B;AAE3DA,OAAO,CAAE;EACRC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CAAC,KAAM;UACpCA,OAAO,CAACH,IAAI,CAACC,MAAM,CAACK,oBAAoB,GAAG,KAAK;QACjD,CAAC;QACDc,mBAAmB,EAAIvB,KAAK,IAAM;UACjC,MAAM;YAAEc,OAAO;YAAEE,KAAK;YAAEC;UAAI,CAAC,GAAGjB,KAAK;UACrC;UACA,IAAKgB,KAAK,EAAEQ,GAAG,KAAK,QAAQ,EAAG;YAC9BV,OAAO,CAACX,IAAI,CAACC,MAAM,CAACkB,gBAAgB,CAAEtB,KAAM,CAAC;YAC7CiB,GAAG,CAACG,aAAa,CAAE,QAAS,CAAC,CAACC,KAAK,CAAC,CAAC;UACtC;QACD,CAAC;QACDI,oBAAoB,EAAIzB,KAAK,IAAM;UAClC,MAAM;YAAEc,OAAO;YAAEE,KAAK;YAAEC;UAAI,CAAC,GAAGjB,KAAK;UACrC;UACA;UACA;UACA;UACA;UACA,IACC,CAAEiB,GAAG,CAACS,QAAQ,CAAEV,KAAK,CAACW,aAAc,CAAC,IACrCX,KAAK,CAACY,MAAM,KAAKC,MAAM,CAACC,QAAQ,CAACC,aAAa,EAC7C;YACDjB,OAAO,CAACX,IAAI,CAACC,MAAM,CAACkB,gBAAgB,CAAEtB,KAAM,CAAC;UAC9C;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
|
|
@@ -122,7 +122,9 @@ const SocialLinkEdit = ({
|
|
|
122
122
|
__('%s has URL set'), socialLinkName) : sprintf(
|
|
123
123
|
// translators: %s: social link name e.g: "Instagram".
|
|
124
124
|
__('%s has no URL set'), socialLinkName);
|
|
125
|
-
return createElement(View,
|
|
125
|
+
return createElement(View, {
|
|
126
|
+
style: styles.container
|
|
127
|
+
}, isSelected && createElement(Fragment, null, createElement(BlockControls, null, createElement(ToolbarGroup, null, createElement(ToolbarButton, {
|
|
126
128
|
title: sprintf(
|
|
127
129
|
// translators: %s: social link name e.g: "Instagram".
|
|
128
130
|
__('Add link to %s'), socialLinkName),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","Animated","Easing","TouchableWithoutFeedback","BlockControls","store","blockEditorStore","useEffect","useState","useRef","useCallback","ToolbarGroup","ToolbarButton","LinkSettingsNavigation","compose","usePreferredColorSchemeStyle","__","sprintf","link","Icon","withSelect","getIconBySite","getNameBySite","styles","DEFAULT_ACTIVE_ICON_STYLES","backgroundColor","color","DEFAULT_INACTIVE_ICON_STYLES","ANIMATION_DELAY","ANIMATION_DURATION","linkSettingsOptions","url","label","placeholder","autoFocus","linkLabel","footer","SocialLinkEdit","attributes","setAttributes","isSelected","onFocus","name","service","isLinkSheetVisible","setIsLinkSheetVisible","hasUrl","setHasUrl","activeIcon","inactiveIcon","inactiveIconDark","animatedValue","Value","current","IconComponent","socialLinkName","setValue","animateColors","interpolationColors","interpolate","inputRange","outputRange","stroke","sequence","delay","timing","toValue","duration","easing","circle","useNativeDriver","start","onCloseSettingsSheet","onOpenSettingsSheet","onEmptyURL","onIconPress","accessibilityHint","createElement","Fragment","title","icon","onClick","isActive","isVisible","rel","onClose","options","withBottomSheet","onPress","accessibilityRole","accessibilityLabel","style","iconContainer","animated","select","clientId","getBlock","block","substring"],"sources":["@wordpress/block-library/src/social-link/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Animated, Easing, TouchableWithoutFeedback } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect, useState, useRef, useCallback } from '@wordpress/element';\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tLinkSettingsNavigation,\n} from '@wordpress/components';\nimport { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { link, Icon } from '@wordpress/icons';\nimport { withSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { getIconBySite, getNameBySite } from './social-list';\nimport styles from './editor.scss';\n\nconst DEFAULT_ACTIVE_ICON_STYLES = {\n\tbackgroundColor: '#f0f0f0',\n\tcolor: '#444',\n};\nconst DEFAULT_INACTIVE_ICON_STYLES = {\n\tbackgroundColor: '#0000003f',\n\tcolor: '#fff',\n};\nconst ANIMATION_DELAY = 300;\nconst ANIMATION_DURATION = 400;\n\nconst linkSettingsOptions = {\n\turl: {\n\t\tlabel: __( 'URL' ),\n\t\tplaceholder: __( 'Add URL' ),\n\t\tautoFocus: true,\n\t},\n\tlinkLabel: {\n\t\tlabel: __( 'Link label' ),\n\t\tplaceholder: __( 'None' ),\n\t},\n\tfooter: {\n\t\tlabel: __( 'Briefly describe the link to help screen reader user' ),\n\t},\n};\n\nconst SocialLinkEdit = ( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tonFocus,\n\tname,\n} ) => {\n\tconst { url, service = name } = attributes;\n\tconst [ isLinkSheetVisible, setIsLinkSheetVisible ] = useState( false );\n\tconst [ hasUrl, setHasUrl ] = useState( !! url );\n\tconst activeIcon =\n\t\tstyles[ `wp-social-link-${ service }` ] ||\n\t\tstyles[ `wp-social-link` ] ||\n\t\tDEFAULT_ACTIVE_ICON_STYLES;\n\tconst inactiveIcon =\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.inactiveIcon,\n\t\t\tstyles.inactiveIconDark\n\t\t) || DEFAULT_INACTIVE_ICON_STYLES;\n\n\tconst animatedValue = useRef( new Animated.Value( 0 ) ).current;\n\n\tconst IconComponent = getIconBySite( service )();\n\tconst socialLinkName = getNameBySite( service );\n\n\t// When new social icon is added link sheet is opened automatically.\n\tuseEffect( () => {\n\t\tif ( isSelected && ! url ) {\n\t\t\tsetIsLinkSheetVisible( true );\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! url ) {\n\t\t\tsetHasUrl( false );\n\t\t\tanimatedValue.setValue( 0 );\n\t\t} else if ( url ) {\n\t\t\tanimateColors();\n\t\t}\n\t}, [ url ] );\n\n\tconst interpolationColors = {\n\t\tbackgroundColor: animatedValue.interpolate( {\n\t\t\tinputRange: [ 0, 1 ],\n\t\t\toutputRange: [\n\t\t\t\tinactiveIcon.backgroundColor,\n\t\t\t\tactiveIcon.backgroundColor,\n\t\t\t],\n\t\t} ),\n\t\tcolor: animatedValue.interpolate( {\n\t\t\tinputRange: [ 0, 1 ],\n\t\t\toutputRange: [ inactiveIcon.color, activeIcon.color ],\n\t\t} ),\n\t\tstroke: '',\n\t};\n\n\tconst { backgroundColor, color, stroke } = hasUrl\n\t\t? activeIcon\n\t\t: interpolationColors;\n\n\tfunction animateColors() {\n\t\tAnimated.sequence( [\n\t\t\tAnimated.delay( ANIMATION_DELAY ),\n\t\t\tAnimated.timing( animatedValue, {\n\t\t\t\ttoValue: 1,\n\t\t\t\tduration: ANIMATION_DURATION,\n\t\t\t\teasing: Easing.circle,\n\t\t\t\tuseNativeDriver: false,\n\t\t\t} ),\n\t\t] ).start( () => setHasUrl( true ) );\n\t}\n\n\tconst onCloseSettingsSheet = useCallback( () => {\n\t\tsetIsLinkSheetVisible( false );\n\t}, [] );\n\n\tconst onOpenSettingsSheet = useCallback( () => {\n\t\tsetIsLinkSheetVisible( true );\n\t}, [] );\n\n\tconst onEmptyURL = useCallback( () => {\n\t\tanimatedValue.setValue( 0 );\n\t\tsetHasUrl( false );\n\t}, [ animatedValue ] );\n\n\tfunction onIconPress() {\n\t\tif ( isSelected ) {\n\t\t\tsetIsLinkSheetVisible( true );\n\t\t} else {\n\t\t\tonFocus();\n\t\t}\n\t}\n\n\tconst accessibilityHint = url\n\t\t? sprintf(\n\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t__( '%s has URL set' ),\n\t\t\t\tsocialLinkName\n\t\t )\n\t\t: sprintf(\n\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t__( '%s has no URL set' ),\n\t\t\t\tsocialLinkName\n\t\t );\n\n\treturn (\n\t\t<View>\n\t\t\t{ isSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t\t\t\t\t\t__( 'Add link to %s' ),\n\t\t\t\t\t\t\t\t\tsocialLinkName\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\t\t\tonClick={ onOpenSettingsSheet }\n\t\t\t\t\t\t\t\tisActive={ url }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<LinkSettingsNavigation\n\t\t\t\t\t\tisVisible={ isLinkSheetVisible }\n\t\t\t\t\t\turl={ attributes.url }\n\t\t\t\t\t\tlabel={ attributes.label }\n\t\t\t\t\t\trel={ attributes.rel }\n\t\t\t\t\t\tonEmptyURL={ onEmptyURL }\n\t\t\t\t\t\tonClose={ onCloseSettingsSheet }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\toptions={ linkSettingsOptions }\n\t\t\t\t\t\twithBottomSheet\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t<TouchableWithoutFeedback\n\t\t\t\tonPress={ onIconPress }\n\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t\t__( '%s social icon' ),\n\t\t\t\t\tsocialLinkName\n\t\t\t\t) }\n\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t>\n\t\t\t\t<Animated.View\n\t\t\t\t\tstyle={ [ styles.iconContainer, { backgroundColor } ] }\n\t\t\t\t>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tanimated\n\t\t\t\t\t\ticon={ IconComponent }\n\t\t\t\t\t\tstyle={ { stroke, color } }\n\t\t\t\t\t/>\n\t\t\t\t</Animated.View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t</View>\n\t);\n};\n\nexport default compose( [\n\twithSelect( ( select, { clientId } ) => {\n\t\tconst { getBlock } = select( blockEditorStore );\n\n\t\tconst block = getBlock( clientId );\n\t\tconst name = block?.name.substring( 17 );\n\n\t\treturn {\n\t\t\tname,\n\t\t};\n\t} ),\n] )( SocialLinkEdit );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,wBAAwB,QAAQ,cAAc;;AAE/E;AACA;AACA;AACA,SACCC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,WAAW,QAAQ,oBAAoB;AAC7E,SACCC,YAAY,EACZC,aAAa,EACbC,sBAAsB,QAChB,uBAAuB;AAC9B,SAASC,OAAO,EAAEC,4BAA4B,QAAQ,oBAAoB;AAC1E,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,IAAI,EAAEC,IAAI,QAAQ,kBAAkB;AAC7C,SAASC,UAAU,QAAQ,iBAAiB;AAC5C;AACA;AACA;AACA,SAASC,aAAa,EAAEC,aAAa,QAAQ,eAAe;AAC5D,OAAOC,MAAM,MAAM,eAAe;AAElC,MAAMC,0BAA0B,GAAG;EAClCC,eAAe,EAAE,SAAS;EAC1BC,KAAK,EAAE;AACR,CAAC;AACD,MAAMC,4BAA4B,GAAG;EACpCF,eAAe,EAAE,WAAW;EAC5BC,KAAK,EAAE;AACR,CAAC;AACD,MAAME,eAAe,GAAG,GAAG;AAC3B,MAAMC,kBAAkB,GAAG,GAAG;AAE9B,MAAMC,mBAAmB,GAAG;EAC3BC,GAAG,EAAE;IACJC,KAAK,EAAEhB,EAAE,CAAE,KAAM,CAAC;IAClBiB,WAAW,EAAEjB,EAAE,CAAE,SAAU,CAAC;IAC5BkB,SAAS,EAAE;EACZ,CAAC;EACDC,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BAAqB;IAC/ByD,eAAe;EAAA,CACf,CACA,CACF,EAEDV,aAAA,CAAC1E,wBAAwB;IACxBqF,OAAO,EAAGb,WAAa;IACvBc,iBAAiB,EAAG,QAAU;IAC9BC,kBAAkB,EAAGzE,OAAO;IAC3B;IACAD,EAAE,CAAE,gBAAiB,CAAC,EACtBuC,cACD,CAAG;IACHqB,iBAAiB,EAAGA;EAAmB,GAEvCC,aAAA,CAAC5E,QAAQ,CAACD,IAAI;IACb2F,KAAK,EAAG,CAAEpE,MAAM,CAACqE,aAAa,EAAE;MAAEnE;IAAgB,CAAC;EAAI,GAEvDoD,aAAA,CAAC1D,IAAI;IACJ0E,QAAQ;IACRb,IAAI,EAAG1B,aAAe;IACtBqC,KAAK,EAAG;MAAE7B,MAAM;MAAEpC;IAAM;EAAG,CAC3B,CACa,CACU,CACrB,CAAC;AAET,CAAC;AAED,eAAeZ,OAAO,CAAE,CACvBM,UAAU,CAAE,CAAE0E,MAAM,EAAE;EAAEC;AAAS,CAAC,KAAM;EACvC,MAAM;IAAEC;EAAS,CAAC,GAAGF,MAAM,CAAExF,gBAAiB,CAAC;EAE/C,MAAM2F,KAAK,GAAGD,QAAQ,CAAED,QAAS,CAAC;EAClC,MAAMrD,IAAI,GAAGuD,KAAK,EAAEvD,IAAI,CAACwD,SAAS,CAAE,EAAG,CAAC;EAExC,OAAO;IACNxD;EACD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAEL,cAAe,CAAC"}
|
|
1
|
+
{"version":3,"names":["View","Animated","Easing","TouchableWithoutFeedback","BlockControls","store","blockEditorStore","useEffect","useState","useRef","useCallback","ToolbarGroup","ToolbarButton","LinkSettingsNavigation","compose","usePreferredColorSchemeStyle","__","sprintf","link","Icon","withSelect","getIconBySite","getNameBySite","styles","DEFAULT_ACTIVE_ICON_STYLES","backgroundColor","color","DEFAULT_INACTIVE_ICON_STYLES","ANIMATION_DELAY","ANIMATION_DURATION","linkSettingsOptions","url","label","placeholder","autoFocus","linkLabel","footer","SocialLinkEdit","attributes","setAttributes","isSelected","onFocus","name","service","isLinkSheetVisible","setIsLinkSheetVisible","hasUrl","setHasUrl","activeIcon","inactiveIcon","inactiveIconDark","animatedValue","Value","current","IconComponent","socialLinkName","setValue","animateColors","interpolationColors","interpolate","inputRange","outputRange","stroke","sequence","delay","timing","toValue","duration","easing","circle","useNativeDriver","start","onCloseSettingsSheet","onOpenSettingsSheet","onEmptyURL","onIconPress","accessibilityHint","createElement","style","container","Fragment","title","icon","onClick","isActive","isVisible","rel","onClose","options","withBottomSheet","onPress","accessibilityRole","accessibilityLabel","iconContainer","animated","select","clientId","getBlock","block","substring"],"sources":["@wordpress/block-library/src/social-link/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Animated, Easing, TouchableWithoutFeedback } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect, useState, useRef, useCallback } from '@wordpress/element';\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tLinkSettingsNavigation,\n} from '@wordpress/components';\nimport { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { link, Icon } from '@wordpress/icons';\nimport { withSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { getIconBySite, getNameBySite } from './social-list';\nimport styles from './editor.scss';\n\nconst DEFAULT_ACTIVE_ICON_STYLES = {\n\tbackgroundColor: '#f0f0f0',\n\tcolor: '#444',\n};\nconst DEFAULT_INACTIVE_ICON_STYLES = {\n\tbackgroundColor: '#0000003f',\n\tcolor: '#fff',\n};\nconst ANIMATION_DELAY = 300;\nconst ANIMATION_DURATION = 400;\n\nconst linkSettingsOptions = {\n\turl: {\n\t\tlabel: __( 'URL' ),\n\t\tplaceholder: __( 'Add URL' ),\n\t\tautoFocus: true,\n\t},\n\tlinkLabel: {\n\t\tlabel: __( 'Link label' ),\n\t\tplaceholder: __( 'None' ),\n\t},\n\tfooter: {\n\t\tlabel: __( 'Briefly describe the link to help screen reader user' ),\n\t},\n};\n\nconst SocialLinkEdit = ( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tonFocus,\n\tname,\n} ) => {\n\tconst { url, service = name } = attributes;\n\tconst [ isLinkSheetVisible, setIsLinkSheetVisible ] = useState( false );\n\tconst [ hasUrl, setHasUrl ] = useState( !! url );\n\tconst activeIcon =\n\t\tstyles[ `wp-social-link-${ service }` ] ||\n\t\tstyles[ `wp-social-link` ] ||\n\t\tDEFAULT_ACTIVE_ICON_STYLES;\n\tconst inactiveIcon =\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.inactiveIcon,\n\t\t\tstyles.inactiveIconDark\n\t\t) || DEFAULT_INACTIVE_ICON_STYLES;\n\n\tconst animatedValue = useRef( new Animated.Value( 0 ) ).current;\n\n\tconst IconComponent = getIconBySite( service )();\n\tconst socialLinkName = getNameBySite( service );\n\n\t// When new social icon is added link sheet is opened automatically.\n\tuseEffect( () => {\n\t\tif ( isSelected && ! url ) {\n\t\t\tsetIsLinkSheetVisible( true );\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! url ) {\n\t\t\tsetHasUrl( false );\n\t\t\tanimatedValue.setValue( 0 );\n\t\t} else if ( url ) {\n\t\t\tanimateColors();\n\t\t}\n\t}, [ url ] );\n\n\tconst interpolationColors = {\n\t\tbackgroundColor: animatedValue.interpolate( {\n\t\t\tinputRange: [ 0, 1 ],\n\t\t\toutputRange: [\n\t\t\t\tinactiveIcon.backgroundColor,\n\t\t\t\tactiveIcon.backgroundColor,\n\t\t\t],\n\t\t} ),\n\t\tcolor: animatedValue.interpolate( {\n\t\t\tinputRange: [ 0, 1 ],\n\t\t\toutputRange: [ inactiveIcon.color, activeIcon.color ],\n\t\t} ),\n\t\tstroke: '',\n\t};\n\n\tconst { backgroundColor, color, stroke } = hasUrl\n\t\t? activeIcon\n\t\t: interpolationColors;\n\n\tfunction animateColors() {\n\t\tAnimated.sequence( [\n\t\t\tAnimated.delay( ANIMATION_DELAY ),\n\t\t\tAnimated.timing( animatedValue, {\n\t\t\t\ttoValue: 1,\n\t\t\t\tduration: ANIMATION_DURATION,\n\t\t\t\teasing: Easing.circle,\n\t\t\t\tuseNativeDriver: false,\n\t\t\t} ),\n\t\t] ).start( () => setHasUrl( true ) );\n\t}\n\n\tconst onCloseSettingsSheet = useCallback( () => {\n\t\tsetIsLinkSheetVisible( false );\n\t}, [] );\n\n\tconst onOpenSettingsSheet = useCallback( () => {\n\t\tsetIsLinkSheetVisible( true );\n\t}, [] );\n\n\tconst onEmptyURL = useCallback( () => {\n\t\tanimatedValue.setValue( 0 );\n\t\tsetHasUrl( false );\n\t}, [ animatedValue ] );\n\n\tfunction onIconPress() {\n\t\tif ( isSelected ) {\n\t\t\tsetIsLinkSheetVisible( true );\n\t\t} else {\n\t\t\tonFocus();\n\t\t}\n\t}\n\n\tconst accessibilityHint = url\n\t\t? sprintf(\n\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t__( '%s has URL set' ),\n\t\t\t\tsocialLinkName\n\t\t )\n\t\t: sprintf(\n\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t__( '%s has no URL set' ),\n\t\t\t\tsocialLinkName\n\t\t );\n\n\treturn (\n\t\t<View style={ styles.container }>\n\t\t\t{ isSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t\t\t\t\t\t__( 'Add link to %s' ),\n\t\t\t\t\t\t\t\t\tsocialLinkName\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\t\t\tonClick={ onOpenSettingsSheet }\n\t\t\t\t\t\t\t\tisActive={ url }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<LinkSettingsNavigation\n\t\t\t\t\t\tisVisible={ isLinkSheetVisible }\n\t\t\t\t\t\turl={ attributes.url }\n\t\t\t\t\t\tlabel={ attributes.label }\n\t\t\t\t\t\trel={ attributes.rel }\n\t\t\t\t\t\tonEmptyURL={ onEmptyURL }\n\t\t\t\t\t\tonClose={ onCloseSettingsSheet }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\toptions={ linkSettingsOptions }\n\t\t\t\t\t\twithBottomSheet\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t<TouchableWithoutFeedback\n\t\t\t\tonPress={ onIconPress }\n\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t\t__( '%s social icon' ),\n\t\t\t\t\tsocialLinkName\n\t\t\t\t) }\n\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t>\n\t\t\t\t<Animated.View\n\t\t\t\t\tstyle={ [ styles.iconContainer, { backgroundColor } ] }\n\t\t\t\t>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tanimated\n\t\t\t\t\t\ticon={ IconComponent }\n\t\t\t\t\t\tstyle={ { stroke, color } }\n\t\t\t\t\t/>\n\t\t\t\t</Animated.View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t</View>\n\t);\n};\n\nexport default compose( [\n\twithSelect( ( select, { clientId } ) => {\n\t\tconst { getBlock } = select( blockEditorStore );\n\n\t\tconst block = getBlock( clientId );\n\t\tconst name = block?.name.substring( 17 );\n\n\t\treturn {\n\t\t\tname,\n\t\t};\n\t} ),\n] )( SocialLinkEdit );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,QAAQ,EAAEC,MAA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,aAAA,CAAC5E,QAAQ,CAACD,IAAI;IACb8E,KAAK,EAAG,CAAEvD,MAAM,CAACsE,aAAa,EAAE;MAAEpE;IAAgB,CAAC;EAAI,GAEvDoD,aAAA,CAAC1D,IAAI;IACJ2E,QAAQ;IACRZ,IAAI,EAAG5B,aAAe;IACtBwB,KAAK,EAAG;MAAEhB,MAAM;MAAEpC;IAAM;EAAG,CAC3B,CACa,CACU,CACrB,CAAC;AAET,CAAC;AAED,eAAeZ,OAAO,CAAE,CACvBM,UAAU,CAAE,CAAE2E,MAAM,EAAE;EAAEC;AAAS,CAAC,KAAM;EACvC,MAAM;IAAEC;EAAS,CAAC,GAAGF,MAAM,CAAEzF,gBAAiB,CAAC;EAE/C,MAAM4F,KAAK,GAAGD,QAAQ,CAAED,QAAS,CAAC;EAClC,MAAMtD,IAAI,GAAGwD,KAAK,EAAExD,IAAI,CAACyD,SAAS,CAAE,EAAG,CAAC;EAExC,OAAO;IACNzD;EACD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAEL,cAAe,CAAC"}
|
|
@@ -295,7 +295,7 @@ function TableEdit({
|
|
|
295
295
|
}, [isSelected]);
|
|
296
296
|
useEffect(() => {
|
|
297
297
|
if (hasTableCreated) {
|
|
298
|
-
tableRef?.current?.querySelector('td[contentEditable="true"]')?.focus();
|
|
298
|
+
tableRef?.current?.querySelector('td div[contentEditable="true"]')?.focus();
|
|
299
299
|
setHasTableCreated(false);
|
|
300
300
|
}
|
|
301
301
|
}, [hasTableCreated]);
|
|
@@ -345,15 +345,15 @@ function TableEdit({
|
|
|
345
345
|
align,
|
|
346
346
|
colspan,
|
|
347
347
|
rowspan
|
|
348
|
-
}, columnIndex) => createElement(
|
|
349
|
-
tagName: CellTag,
|
|
348
|
+
}, columnIndex) => createElement(CellTag, {
|
|
350
349
|
key: columnIndex,
|
|
351
|
-
className: classnames({
|
|
352
|
-
[`has-text-align-${align}`]: align
|
|
353
|
-
}, 'wp-block-table__cell-content'),
|
|
354
350
|
scope: CellTag === 'th' ? scope : undefined,
|
|
355
351
|
colSpan: colspan,
|
|
356
352
|
rowSpan: rowspan,
|
|
353
|
+
className: classnames({
|
|
354
|
+
[`has-text-align-${align}`]: align
|
|
355
|
+
}, 'wp-block-table__cell-content')
|
|
356
|
+
}, createElement(RichText, {
|
|
357
357
|
value: content,
|
|
358
358
|
onChange: onChange,
|
|
359
359
|
onFocus: () => {
|
|
@@ -366,7 +366,7 @@ function TableEdit({
|
|
|
366
366
|
},
|
|
367
367
|
"aria-label": cellAriaLabel[name],
|
|
368
368
|
placeholder: placeholder[name]
|
|
369
|
-
}))))));
|
|
369
|
+
})))))));
|
|
370
370
|
const isEmpty = !sections.length;
|
|
371
371
|
return createElement("figure", {
|
|
372
372
|
...useBlockProps({
|