@wordpress/block-directory 4.11.0 → 4.12.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-ratings/index.js +7 -10
  3. package/build/components/block-ratings/index.js.map +1 -1
  4. package/build/components/block-ratings/stars.js +3 -4
  5. package/build/components/block-ratings/stars.js.map +1 -1
  6. package/build/components/compact-list/index.js +23 -28
  7. package/build/components/compact-list/index.js.map +1 -1
  8. package/build/components/downloadable-block-icon/index.js +3 -4
  9. package/build/components/downloadable-block-icon/index.js.map +1 -1
  10. package/build/components/downloadable-block-list-item/index.js +14 -17
  11. package/build/components/downloadable-block-list-item/index.js.map +1 -1
  12. package/build/components/downloadable-block-notice/index.js +3 -4
  13. package/build/components/downloadable-block-notice/index.js.map +1 -1
  14. package/build/components/downloadable-blocks-list/index.js +5 -6
  15. package/build/components/downloadable-blocks-list/index.js.map +1 -1
  16. package/build/components/downloadable-blocks-panel/index.js +13 -16
  17. package/build/components/downloadable-blocks-panel/index.js.map +1 -1
  18. package/build/components/downloadable-blocks-panel/inserter-panel.js +5 -6
  19. package/build/components/downloadable-blocks-panel/inserter-panel.js.map +1 -1
  20. package/build/plugins/get-install-missing/index.js +7 -11
  21. package/build/plugins/get-install-missing/index.js.map +1 -1
  22. package/build/plugins/get-install-missing/install-button.js +5 -6
  23. package/build/plugins/get-install-missing/install-button.js.map +1 -1
  24. package/build/plugins/inserter-menu-downloadable-blocks-panel/index.js +7 -9
  25. package/build/plugins/inserter-menu-downloadable-blocks-panel/index.js.map +1 -1
  26. package/build/plugins/installed-blocks-pre-publish-panel/index.js +2 -2
  27. package/build/plugins/installed-blocks-pre-publish-panel/index.js.map +1 -1
  28. package/build/store/actions.js +10 -17
  29. package/build/store/actions.js.map +1 -1
  30. package/build/store/reducer.js +6 -15
  31. package/build/store/reducer.js.map +1 -1
  32. package/build/store/resolvers.js +4 -9
  33. package/build/store/resolvers.js.map +1 -1
  34. package/build/store/selectors.js +4 -4
  35. package/build/store/selectors.js.map +1 -1
  36. package/build/store/utils/has-block-type.js +4 -9
  37. package/build/store/utils/has-block-type.js.map +1 -1
  38. package/build-module/components/block-ratings/index.js +7 -10
  39. package/build-module/components/block-ratings/index.js.map +1 -1
  40. package/build-module/components/block-ratings/stars.js +3 -4
  41. package/build-module/components/block-ratings/stars.js.map +1 -1
  42. package/build-module/components/compact-list/index.js +23 -28
  43. package/build-module/components/compact-list/index.js.map +1 -1
  44. package/build-module/components/downloadable-block-icon/index.js +3 -4
  45. package/build-module/components/downloadable-block-icon/index.js.map +1 -1
  46. package/build-module/components/downloadable-block-list-item/index.js +14 -17
  47. package/build-module/components/downloadable-block-list-item/index.js.map +1 -1
  48. package/build-module/components/downloadable-block-notice/index.js +3 -4
  49. package/build-module/components/downloadable-block-notice/index.js.map +1 -1
  50. package/build-module/components/downloadable-blocks-list/index.js +5 -6
  51. package/build-module/components/downloadable-blocks-list/index.js.map +1 -1
  52. package/build-module/components/downloadable-blocks-panel/index.js +13 -16
  53. package/build-module/components/downloadable-blocks-panel/index.js.map +1 -1
  54. package/build-module/components/downloadable-blocks-panel/inserter-panel.js +5 -6
  55. package/build-module/components/downloadable-blocks-panel/inserter-panel.js.map +1 -1
  56. package/build-module/plugins/get-install-missing/index.js +7 -11
  57. package/build-module/plugins/get-install-missing/index.js.map +1 -1
  58. package/build-module/plugins/get-install-missing/install-button.js +5 -6
  59. package/build-module/plugins/get-install-missing/install-button.js.map +1 -1
  60. package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.js +7 -9
  61. package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.js.map +1 -1
  62. package/build-module/plugins/installed-blocks-pre-publish-panel/index.js +2 -2
  63. package/build-module/plugins/installed-blocks-pre-publish-panel/index.js.map +1 -1
  64. package/build-module/store/actions.js +10 -17
  65. package/build-module/store/actions.js.map +1 -1
  66. package/build-module/store/reducer.js +6 -15
  67. package/build-module/store/reducer.js.map +1 -1
  68. package/build-module/store/resolvers.js +4 -9
  69. package/build-module/store/resolvers.js.map +1 -1
  70. package/build-module/store/selectors.js +4 -4
  71. package/build-module/store/selectors.js.map +1 -1
  72. package/build-module/store/utils/has-block-type.js +4 -9
  73. package/build-module/store/utils/has-block-type.js.map +1 -1
  74. package/package.json +20 -20
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.js"],"names":["PluginPrePublishPanel","window","wp","editPost","InstalledBlocksPrePublishPanel","newBlockTypes","select","blockDirectoryStore","getNewBlockTypes","length","blockDefault"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;;;AAEA;AACA;AACA,MAAM;AAAEA,EAAAA;AAAF,sCAA4BC,MAA5B,0DAA4B,QAAQC,EAApC,+CAA4B,WAAYC,QAAxC,qEAAoD,EAA1D;;AAEe,SAASC,8BAAT,GAA0C;AACxD,QAAMC,aAAa,GAAG,qBACnBC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAA8BC,gBAA9B,EADO,EAErB,EAFqB,CAAtB;;AAKA,MAAK,CAAEH,aAAa,CAACI,MAArB,EAA8B;AAC7B,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,qBAAD;AACC,IAAA,IAAI,EAAGC,mBADR;AAEC,IAAA,KAAK,EAAG,oBACP;AACA,kBACC,iBADD,EAEC,kBAFD,EAGCL,aAAa,CAACI,MAHf,CAFO,EAOPJ,aAAa,CAACI,MAPP,CAFT;AAWC,IAAA,WAAW,EAAG;AAXf,KAaC;AAAG,IAAA,SAAS,EAAC;AAAb,KACG,cACD,kDADC,EAED,oDAFC,EAGDJ,aAAa,CAACI,MAHb,CADH,CAbD,EAoBC,4BAAC,oBAAD;AAAa,IAAA,KAAK,EAAGJ;AAArB,IApBD,CADD;AAwBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { blockDefault } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\n// We shouldn't import the edit-post package directly\n// because it would include the wp-edit-post in all pages loading the block-directory script.\nconst { PluginPrePublishPanel } = window?.wp?.editPost ?? {};\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ticon={ blockDefault }\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen={ true }\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ _n(\n\t\t\t\t\t'The following block has been added to your site.',\n\t\t\t\t\t'The following blocks have been added to your site.',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.js"],"names":["PluginPrePublishPanel","window","wp","editPost","InstalledBlocksPrePublishPanel","newBlockTypes","select","blockDirectoryStore","getNewBlockTypes","length","blockDefault"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;;;AAEA;AACA;AACA,MAAM;AAAEA,EAAAA;AAAF,2BAA4BC,MAAM,EAAEC,EAAR,EAAYC,QAAxC,qEAAoD,EAA1D;;AAEe,SAASC,8BAAT,GAA0C;AACxD,QAAMC,aAAa,GAAG,qBACnBC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAA8BC,gBAA9B,EADO,EAErB,EAFqB,CAAtB;;AAKA,MAAK,CAAEH,aAAa,CAACI,MAArB,EAA8B;AAC7B,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,qBAAD;AACC,IAAA,IAAI,EAAGC,mBADR;AAEC,IAAA,KAAK,EAAG,oBACP;AACA,kBACC,iBADD,EAEC,kBAFD,EAGCL,aAAa,CAACI,MAHf,CAFO,EAOPJ,aAAa,CAACI,MAPP,CAFT;AAWC,IAAA,WAAW,EAAG;AAXf,KAaC;AAAG,IAAA,SAAS,EAAC;AAAb,KACG,cACD,kDADC,EAED,oDAFC,EAGDJ,aAAa,CAACI,MAHb,CADH,CAbD,EAoBC,4BAAC,oBAAD;AAAa,IAAA,KAAK,EAAGJ;AAArB,IApBD,CADD;AAwBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { blockDefault } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\n// We shouldn't import the edit-post package directly\n// because it would include the wp-edit-post in all pages loading the block-directory script.\nconst { PluginPrePublishPanel } = window?.wp?.editPost ?? {};\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ticon={ blockDefault }\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen={ true }\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ _n(\n\t\t\t\t\t'The following block has been added to your site.',\n\t\t\t\t\t'The following blocks have been added to your site.',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"]}
@@ -78,11 +78,10 @@ function receiveDownloadableBlocks(downloadableBlocks, filterValue) {
78
78
  */
79
79
 
80
80
 
81
- const installBlockType = block => async _ref => {
82
- let {
83
- registry,
84
- dispatch
85
- } = _ref;
81
+ const installBlockType = block => async ({
82
+ registry,
83
+ dispatch
84
+ }) => {
86
85
  const {
87
86
  id,
88
87
  name
@@ -135,10 +134,7 @@ const installBlockType = block => async _ref => {
135
134
  }
136
135
 
137
136
  (0, _blocks.unstable__bootstrapServerSideBlockDefinitions)({
138
- [name]: Object.fromEntries(Object.entries(response).filter(_ref2 => {
139
- let [key] = _ref2;
140
- return metadataFields.includes(key);
141
- }))
137
+ [name]: Object.fromEntries(Object.entries(response).filter(([key]) => metadataFields.includes(key)))
142
138
  });
143
139
  });
144
140
  await (0, _loadAssets.loadAssets)();
@@ -188,12 +184,10 @@ const installBlockType = block => async _ref => {
188
184
 
189
185
  exports.installBlockType = installBlockType;
190
186
 
191
- const uninstallBlockType = block => async _ref3 => {
192
- let {
193
- registry,
194
- dispatch
195
- } = _ref3;
196
-
187
+ const uninstallBlockType = block => async ({
188
+ registry,
189
+ dispatch
190
+ }) => {
197
191
  try {
198
192
  const url = (0, _getPluginUrl.default)(block);
199
193
  await (0, _apiFetch.default)({
@@ -274,8 +268,7 @@ function setIsInstalling(blockId, isInstalling) {
274
268
  */
275
269
 
276
270
 
277
- function setErrorNotice(blockId, message) {
278
- let isFatal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
271
+ function setErrorNotice(blockId, message, isFatal = false) {
279
272
  return {
280
273
  type: 'SET_ERROR_NOTICE',
281
274
  blockId,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/store/actions.js"],"names":["fetchDownloadableBlocks","filterValue","type","receiveDownloadableBlocks","downloadableBlocks","installBlockType","block","registry","dispatch","id","name","success","clearErrorNotice","setIsInstalling","url","links","method","data","status","response","path","slug","_links","addInstalledBlockType","metadataFields","_fields","catch","then","Object","fromEntries","entries","filter","key","includes","registeredBlocks","select","blocksStore","getBlockTypes","some","i","Error","noticesStore","createInfoNotice","title","speak","error","message","isFatal","fatalAPIErrors","folder_exists","unable_to_connect_to_filesystem","code","setErrorNotice","createErrorNotice","isDismissible","uninstallBlockType","removeInstalledBlockType","item","blockId","isInstalling"],"mappings":";;;;;;;;;;;;;;;;;AAGA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,uBAAT,CAAkCC,WAAlC,EAAgD;AACtD,SAAO;AAAEC,IAAAA,IAAI,EAAE,2BAAR;AAAqCD,IAAAA;AAArC,GAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,yBAAT,CAAoCC,kBAApC,EAAwDH,WAAxD,EAAsE;AAC5E,SAAO;AACNC,IAAAA,IAAI,EAAE,6BADA;AAENE,IAAAA,kBAFM;AAGNH,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMI,gBAAgB,GAC1BC,KAAF,IACA,cAAoC;AAAA,MAA5B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;AACnC,QAAM;AAAEC,IAAAA,EAAF;AAAMC,IAAAA;AAAN,MAAeJ,KAArB;AACA,MAAIK,OAAO,GAAG,KAAd;AACAH,EAAAA,QAAQ,CAACI,gBAAT,CAA2BH,EAA3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;AAENuD,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASD,wBAAT,CAAmCC,IAAnC,EAA0C;AAChD,SAAO;AACNvD,IAAAA,IAAI,EAAE,6BADA;AAENuD,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAAS5C,eAAT,CAA0B6C,OAA1B,EAAmCC,YAAnC,EAAkD;AACxD,SAAO;AACNzD,IAAAA,IAAI,EAAE,sBADA;AAENwD,IAAAA,OAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASP,cAAT,CAAyBM,OAAzB,EAAkCZ,OAAlC,EAA6D;AAAA,MAAlBC,OAAkB,uEAAR,KAAQ;AACnE,SAAO;AACN7C,IAAAA,IAAI,EAAE,kBADA;AAENwD,IAAAA,OAFM;AAGNZ,IAAAA,OAHM;AAINC,IAAAA;AAJM,GAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASnC,gBAAT,CAA2B8C,OAA3B,EAAqC;AAC3C,SAAO;AACNxD,IAAAA,IAAI,EAAE,oBADA;AAENwD,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst { id, name } = block;\n\t\tlet success = false;\n\t\tdispatch.clearErrorNotice( id );\n\t\ttry {\n\t\t\tdispatch.setIsInstalling( id, true );\n\n\t\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tlet links = {};\n\t\t\tif ( url ) {\n\t\t\t\tawait apiFetch( {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\turl,\n\t\t\t\t\tdata: { status: 'active' },\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t\t} );\n\t\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\t\tlinks = response._links;\n\t\t\t}\n\n\t\t\tdispatch.addInstalledBlockType( {\n\t\t\t\t...block,\n\t\t\t\tlinks: { ...block.links, ...links },\n\t\t\t} );\n\n\t\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\t\tconst metadataFields = [\n\t\t\t\t'api_version',\n\t\t\t\t'title',\n\t\t\t\t'category',\n\t\t\t\t'parent',\n\t\t\t\t'icon',\n\t\t\t\t'description',\n\t\t\t\t'keywords',\n\t\t\t\t'attributes',\n\t\t\t\t'provides_context',\n\t\t\t\t'uses_context',\n\t\t\t\t'supports',\n\t\t\t\t'styles',\n\t\t\t\t'example',\n\t\t\t\t'variations',\n\t\t\t];\n\t\t\tawait apiFetch( {\n\t\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t\t_fields: metadataFields,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t\t.catch( () => {} )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( ! response ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t\t[ name ]: Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( response ).filter( ( [ key ] ) =>\n\t\t\t\t\t\t\t\tmetadataFields.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t),\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\tawait loadAssets();\n\t\t\tconst registeredBlocks = registry\n\t\t\t\t.select( blocksStore )\n\t\t\t\t.getBlockTypes();\n\t\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s is the block title.\n\t\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\t\tblock.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\tspeak: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\tsuccess = true;\n\t\t} catch ( error ) {\n\t\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t\t// Errors we throw are fatal.\n\t\t\tlet isFatal = error instanceof Error;\n\n\t\t\t// Specific API errors that are fatal.\n\t\t\tconst fatalAPIErrors = {\n\t\t\t\tfolder_exists: __(\n\t\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t\t),\n\t\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\t\tisFatal = true;\n\t\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t\t}\n\n\t\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\t\tspeak: true,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}\n\t\tdispatch.setIsInstalling( id, false );\n\t\treturn success;\n\t};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\ttry {\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'inactive' },\n\t\t\t} );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl,\n\t\t\t} );\n\t\t\tdispatch.removeInstalledBlockType( block );\n\t\t} catch ( error ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\terror.message || __( 'An error occurred.' )\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/store/actions.js"],"names":["fetchDownloadableBlocks","filterValue","type","receiveDownloadableBlocks","downloadableBlocks","installBlockType","block","registry","dispatch","id","name","success","clearErrorNotice","setIsInstalling","url","links","method","data","status","response","path","slug","_links","addInstalledBlockType","metadataFields","_fields","catch","then","Object","fromEntries","entries","filter","key","includes","registeredBlocks","select","blocksStore","getBlockTypes","some","i","Error","noticesStore","createInfoNotice","title","speak","error","message","isFatal","fatalAPIErrors","folder_exists","unable_to_connect_to_filesystem","code","setErrorNotice","createErrorNotice","isDismissible","uninstallBlockType","removeInstalledBlockType","item","blockId","isInstalling"],"mappings":";;;;;;;;;;;;;;;;;AAGA;;AAIA;;AACA;;AACA;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AAAA,OAFM;AAGNZ,IAAAA,OAHM;AAINC,IAAAA;AAJM,GAAP;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASnC,gBAAT,CAA2B8C,OAA3B,EAAqC;AAC3C,SAAO;AACNxD,IAAAA,IAAI,EAAE,oBADA;AAENwD,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst { id, name } = block;\n\t\tlet success = false;\n\t\tdispatch.clearErrorNotice( id );\n\t\ttry {\n\t\t\tdispatch.setIsInstalling( id, true );\n\n\t\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tlet links = {};\n\t\t\tif ( url ) {\n\t\t\t\tawait apiFetch( {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\turl,\n\t\t\t\t\tdata: { status: 'active' },\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t\t} );\n\t\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\t\tlinks = response._links;\n\t\t\t}\n\n\t\t\tdispatch.addInstalledBlockType( {\n\t\t\t\t...block,\n\t\t\t\tlinks: { ...block.links, ...links },\n\t\t\t} );\n\n\t\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\t\tconst metadataFields = [\n\t\t\t\t'api_version',\n\t\t\t\t'title',\n\t\t\t\t'category',\n\t\t\t\t'parent',\n\t\t\t\t'icon',\n\t\t\t\t'description',\n\t\t\t\t'keywords',\n\t\t\t\t'attributes',\n\t\t\t\t'provides_context',\n\t\t\t\t'uses_context',\n\t\t\t\t'supports',\n\t\t\t\t'styles',\n\t\t\t\t'example',\n\t\t\t\t'variations',\n\t\t\t];\n\t\t\tawait apiFetch( {\n\t\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t\t_fields: metadataFields,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t\t.catch( () => {} )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( ! response ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t\t[ name ]: Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( response ).filter( ( [ key ] ) =>\n\t\t\t\t\t\t\t\tmetadataFields.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t),\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\tawait loadAssets();\n\t\t\tconst registeredBlocks = registry\n\t\t\t\t.select( blocksStore )\n\t\t\t\t.getBlockTypes();\n\t\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s is the block title.\n\t\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\t\tblock.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\tspeak: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\tsuccess = true;\n\t\t} catch ( error ) {\n\t\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t\t// Errors we throw are fatal.\n\t\t\tlet isFatal = error instanceof Error;\n\n\t\t\t// Specific API errors that are fatal.\n\t\t\tconst fatalAPIErrors = {\n\t\t\t\tfolder_exists: __(\n\t\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t\t),\n\t\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\t\tisFatal = true;\n\t\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t\t}\n\n\t\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\t\tspeak: true,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}\n\t\tdispatch.setIsInstalling( id, false );\n\t\treturn success;\n\t};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\ttry {\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'inactive' },\n\t\t\t} );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl,\n\t\t\t} );\n\t\t\tdispatch.removeInstalledBlockType( block );\n\t\t} catch ( error ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\terror.message || __( 'An error occurred.' )\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"]}
@@ -19,10 +19,7 @@ var _data = require("@wordpress/data");
19
19
  *
20
20
  * @return {Object} Updated state.
21
21
  */
22
- const downloadableBlocks = function () {
23
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
24
- let action = arguments.length > 1 ? arguments[1] : undefined;
25
-
22
+ const downloadableBlocks = (state = {}, action) => {
26
23
  switch (action.type) {
27
24
  case 'FETCH_DOWNLOADABLE_BLOCKS':
28
25
  return { ...state,
@@ -54,13 +51,10 @@ const downloadableBlocks = function () {
54
51
 
55
52
  exports.downloadableBlocks = downloadableBlocks;
56
53
 
57
- const blockManagement = function () {
58
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
59
- installedBlockTypes: [],
60
- isInstalling: {}
61
- };
62
- let action = arguments.length > 1 ? arguments[1] : undefined;
63
-
54
+ const blockManagement = (state = {
55
+ installedBlockTypes: [],
56
+ isInstalling: {}
57
+ }, action) => {
64
58
  switch (action.type) {
65
59
  case 'ADD_INSTALLED_BLOCK_TYPE':
66
60
  return { ...state,
@@ -94,10 +88,7 @@ const blockManagement = function () {
94
88
 
95
89
  exports.blockManagement = blockManagement;
96
90
 
97
- const errorNotices = function () {
98
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
99
- let action = arguments.length > 1 ? arguments[1] : undefined;
100
-
91
+ const errorNotices = (state = {}, action) => {
101
92
  switch (action.type) {
102
93
  case 'SET_ERROR_NOTICE':
103
94
  return { ...state,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/store/reducer.js"],"names":["downloadableBlocks","state","action","type","filterValue","isRequesting","results","blockManagement","installedBlockTypes","isInstalling","item","filter","blockType","name","blockId","errorNotices","message","isFatal","restState"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,kBAAkB,GAAG,YAA0B;AAAA,MAAxBC,KAAwB,uEAAhB,EAAgB;AAAA,MAAZC,MAAY;;AAC3D,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,2BAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,WAAT,GAAwB;AACvBC,UAAAA,YAAY,EAAE;AADS;AAFlB,OAAP;;AAMD,SAAK,6BAAL;AACC,aAAO,EACN,GAAGJ,KADG;AAEN,SAAEC,MAAM,CAACE,WAAT,GAAwB;AACvBE,UAAAA,OAAO,EAAEJ,MAAM,CAACF,kBADO;AAEvBK,UAAAA,YAAY,EAAE;AAFS;AAFlB,OAAP;AATF;;AAiBA,SAAOJ,KAAP;AACA,CAnBM;AAqBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMM,eAAe,GAAG,YAM1B;AAAA,MALJN,KAKI,uEALI;AACPO,IAAAA,mBAAmB,EAAE,EADd;AAEPC,IAAAA,YAAY,EAAE;AAFP,GAKJ;AAAA,MADJP,MACI;;AACJ,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,0BAAL;AACC,aAAO,EACN,GAAGF,KADG;AAENO,QAAAA,mBAAmB,EAAE,CACpB,GAAGP,KAAK,CAACO,mBADW,EAEpBN,MAAM,CAACQ,IAFa;AAFf,OAAP;;AAOD,SAAK,6BAAL;AACC,aAAO,EACN,GAAGT,KADG;AAENO,QAAAA,mBAAmB,EAAEP,KAAK,CAACO,mBAAN,CAA0BG,MAA1B,CAClBC,SAAF,IAAiBA,SAAS,CAACC,IAAV,KAAmBX,MAAM,CAACQ,IAAP,CAAYG,IAD5B;AAFf,OAAP;;AAMD,SAAK,sBAAL;AACC,aAAO,EACN,GAAGZ,KADG;AAENQ,QAAAA,YAAY,EAAE,EACb,GAAGR,KAAK,CAACQ,YADI;AAEb,WAAEP,MAAM,CAACY,OAAT,GAAoBZ,MAAM,CAACO;AAFd;AAFR,OAAP;AAjBF;;AAyBA,SAAOR,KAAP;AACA,CAjCM;AAmCP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMc,YAAY,GAAG,YAA0B;AAAA,MAAxBd,KAAwB,uEAAhB,EAAgB;AAAA,MAAZC,MAAY;;AACrD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,kBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACY,OAAT,GAAoB;AACnBE,UAAAA,OAAO,EAAEd,MAAM,CAACc,OADG;AAEnBC,UAAAA,OAAO,EAAEf,MAAM,CAACe;AAFG;AAFd,OAAP;;AAOD,SAAK,oBAAL;AACC,YAAM;AAAE,SAAEf,MAAM,CAACY,OAAT,GAAoBA,OAAtB;AAA+B,WAAGI;AAAlC,UAAgDjB,KAAtD;AACA,aAAOiB,SAAP;AAXF;;AAaA,SAAOjB,KAAP;AACA,CAfM;;;;eAiBQ,2BAAiB;AAC/BD,EAAAA,kBAD+B;AAE/BO,EAAAA,eAF+B;AAG/BQ,EAAAA;AAH+B,CAAjB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning an array of downloadable blocks.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const downloadableBlocks = ( state = {}, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'FETCH_DOWNLOADABLE_BLOCKS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.filterValue ]: {\n\t\t\t\t\tisRequesting: true,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'RECEIVE_DOWNLOADABLE_BLOCKS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.filterValue ]: {\n\t\t\t\t\tresults: action.downloadableBlocks,\n\t\t\t\t\tisRequesting: false,\n\t\t\t\t},\n\t\t\t};\n\t}\n\treturn state;\n};\n\n/**\n * Reducer managing the installation and deletion of blocks.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const blockManagement = (\n\tstate = {\n\t\tinstalledBlockTypes: [],\n\t\tisInstalling: {},\n\t},\n\taction\n) => {\n\tswitch ( action.type ) {\n\t\tcase 'ADD_INSTALLED_BLOCK_TYPE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tinstalledBlockTypes: [\n\t\t\t\t\t...state.installedBlockTypes,\n\t\t\t\t\taction.item,\n\t\t\t\t],\n\t\t\t};\n\t\tcase 'REMOVE_INSTALLED_BLOCK_TYPE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tinstalledBlockTypes: state.installedBlockTypes.filter(\n\t\t\t\t\t( blockType ) => blockType.name !== action.item.name\n\t\t\t\t),\n\t\t\t};\n\t\tcase 'SET_INSTALLING_BLOCK':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisInstalling: {\n\t\t\t\t\t...state.isInstalling,\n\t\t\t\t\t[ action.blockId ]: action.isInstalling,\n\t\t\t\t},\n\t\t\t};\n\t}\n\treturn state;\n};\n\n/**\n * Reducer returning an object of error notices.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const errorNotices = ( state = {}, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'SET_ERROR_NOTICE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.blockId ]: {\n\t\t\t\t\tmessage: action.message,\n\t\t\t\t\tisFatal: action.isFatal,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'CLEAR_ERROR_NOTICE':\n\t\t\tconst { [ action.blockId ]: blockId, ...restState } = state;\n\t\t\treturn restState;\n\t}\n\treturn state;\n};\n\nexport default combineReducers( {\n\tdownloadableBlocks,\n\tblockManagement,\n\terrorNotices,\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/store/reducer.js"],"names":["downloadableBlocks","state","action","type","filterValue","isRequesting","results","blockManagement","installedBlockTypes","isInstalling","item","filter","blockType","name","blockId","errorNotices","message","isFatal","restState"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,kBAAkB,GAAG,CAAEC,KAAK,GAAG,EAAV,EAAcC,MAAd,KAA0B;AAC3D,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,2BAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,WAAT,GAAwB;AACvBC,UAAAA,YAAY,EAAE;AADS;AAFlB,OAAP;;AAMD,SAAK,6BAAL;AACC,aAAO,EACN,GAAGJ,KADG;AAEN,SAAEC,MAAM,CAACE,WAAT,GAAwB;AACvBE,UAAAA,OAAO,EAAEJ,MAAM,CAACF,kBADO;AAEvBK,UAAAA,YAAY,EAAE;AAFS;AAFlB,OAAP;AATF;;AAiBA,SAAOJ,KAAP;AACA,CAnBM;AAqBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMM,eAAe,GAAG,CAC9BN,KAAK,GAAG;AACPO,EAAAA,mBAAmB,EAAE,EADd;AAEPC,EAAAA,YAAY,EAAE;AAFP,CADsB,EAK9BP,MAL8B,KAM1B;AACJ,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,0BAAL;AACC,aAAO,EACN,GAAGF,KADG;AAENO,QAAAA,mBAAmB,EAAE,CACpB,GAAGP,KAAK,CAACO,mBADW,EAEpBN,MAAM,CAACQ,IAFa;AAFf,OAAP;;AAOD,SAAK,6BAAL;AACC,aAAO,EACN,GAAGT,KADG;AAENO,QAAAA,mBAAmB,EAAEP,KAAK,CAACO,mBAAN,CAA0BG,MAA1B,CAClBC,SAAF,IAAiBA,SAAS,CAACC,IAAV,KAAmBX,MAAM,CAACQ,IAAP,CAAYG,IAD5B;AAFf,OAAP;;AAMD,SAAK,sBAAL;AACC,aAAO,EACN,GAAGZ,KADG;AAENQ,QAAAA,YAAY,EAAE,EACb,GAAGR,KAAK,CAACQ,YADI;AAEb,WAAEP,MAAM,CAACY,OAAT,GAAoBZ,MAAM,CAACO;AAFd;AAFR,OAAP;AAjBF;;AAyBA,SAAOR,KAAP;AACA,CAjCM;AAmCP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMc,YAAY,GAAG,CAAEd,KAAK,GAAG,EAAV,EAAcC,MAAd,KAA0B;AACrD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,kBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACY,OAAT,GAAoB;AACnBE,UAAAA,OAAO,EAAEd,MAAM,CAACc,OADG;AAEnBC,UAAAA,OAAO,EAAEf,MAAM,CAACe;AAFG;AAFd,OAAP;;AAOD,SAAK,oBAAL;AACC,YAAM;AAAE,SAAEf,MAAM,CAACY,OAAT,GAAoBA,OAAtB;AAA+B,WAAGI;AAAlC,UAAgDjB,KAAtD;AACA,aAAOiB,SAAP;AAXF;;AAaA,SAAOjB,KAAP;AACA,CAfM;;;;eAiBQ,2BAAiB;AAC/BD,EAAAA,kBAD+B;AAE/BO,EAAAA,eAF+B;AAG/BQ,EAAAA;AAH+B,CAAjB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning an array of downloadable blocks.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const downloadableBlocks = ( state = {}, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'FETCH_DOWNLOADABLE_BLOCKS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.filterValue ]: {\n\t\t\t\t\tisRequesting: true,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'RECEIVE_DOWNLOADABLE_BLOCKS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.filterValue ]: {\n\t\t\t\t\tresults: action.downloadableBlocks,\n\t\t\t\t\tisRequesting: false,\n\t\t\t\t},\n\t\t\t};\n\t}\n\treturn state;\n};\n\n/**\n * Reducer managing the installation and deletion of blocks.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const blockManagement = (\n\tstate = {\n\t\tinstalledBlockTypes: [],\n\t\tisInstalling: {},\n\t},\n\taction\n) => {\n\tswitch ( action.type ) {\n\t\tcase 'ADD_INSTALLED_BLOCK_TYPE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tinstalledBlockTypes: [\n\t\t\t\t\t...state.installedBlockTypes,\n\t\t\t\t\taction.item,\n\t\t\t\t],\n\t\t\t};\n\t\tcase 'REMOVE_INSTALLED_BLOCK_TYPE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tinstalledBlockTypes: state.installedBlockTypes.filter(\n\t\t\t\t\t( blockType ) => blockType.name !== action.item.name\n\t\t\t\t),\n\t\t\t};\n\t\tcase 'SET_INSTALLING_BLOCK':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisInstalling: {\n\t\t\t\t\t...state.isInstalling,\n\t\t\t\t\t[ action.blockId ]: action.isInstalling,\n\t\t\t\t},\n\t\t\t};\n\t}\n\treturn state;\n};\n\n/**\n * Reducer returning an object of error notices.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const errorNotices = ( state = {}, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'SET_ERROR_NOTICE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.blockId ]: {\n\t\t\t\t\tmessage: action.message,\n\t\t\t\t\tisFatal: action.isFatal,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'CLEAR_ERROR_NOTICE':\n\t\t\tconst { [ action.blockId ]: blockId, ...restState } = state;\n\t\t\treturn restState;\n\t}\n\treturn state;\n};\n\nexport default combineReducers( {\n\tdownloadableBlocks,\n\tblockManagement,\n\terrorNotices,\n} );\n"]}
@@ -24,11 +24,9 @@ var _actions = require("./actions");
24
24
  /**
25
25
  * Internal dependencies
26
26
  */
27
- const getDownloadableBlocks = filterValue => async _ref => {
28
- let {
29
- dispatch
30
- } = _ref;
31
-
27
+ const getDownloadableBlocks = filterValue => async ({
28
+ dispatch
29
+ }) => {
32
30
  if (!filterValue) {
33
31
  return;
34
32
  }
@@ -38,10 +36,7 @@ const getDownloadableBlocks = filterValue => async _ref => {
38
36
  const results = await (0, _apiFetch.default)({
39
37
  path: `wp/v2/block-directory/search?term=${filterValue}`
40
38
  });
41
- const blocks = results.map(result => Object.fromEntries(Object.entries(result).map(_ref2 => {
42
- let [key, value] = _ref2;
43
- return [(0, _changeCase.camelCase)(key), value];
44
- })));
39
+ const blocks = results.map(result => Object.fromEntries(Object.entries(result).map(([key, value]) => [(0, _changeCase.camelCase)(key), value])));
45
40
  dispatch((0, _actions.receiveDownloadableBlocks)(blocks, filterValue));
46
41
  } catch {}
47
42
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/store/resolvers.js"],"names":["getDownloadableBlocks","filterValue","dispatch","results","path","blocks","map","result","Object","fromEntries","entries","key","value"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAGO,MAAMA,qBAAqB,GAC/BC,WAAF,IACA,cAA0B;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;;AACzB,MAAK,CAAED,WAAP,EAAqB;AACpB;AACA;;AAED,MAAI;AACHC,IAAAA,QAAQ,CAAE,sCAAyBD,WAAzB,CAAF,CAAR;AACA,UAAME,OAAO,GAAG,MAAM,uBAAU;AAC/BC,MAAAA,IAAI,EAAG,qCAAqCH,WAAa;AAD1B,KAAV,CAAtB;AAGA,UAAMI,MAAM,GAAGF,OAAO,CAACG,GAAR,CAAeC,MAAF,IAC3BC,MAAM,CAACC,WAAP,CACCD,MAAM,CAACE,OAAP,CAAgBH,MAAhB,EAAyBD,GAAzB,CAA8B;AAAA,UAAE,CAAEK,GAAF,EAAOC,KAAP,CAAF;AAAA,aAAsB,CACnD,2BAAWD,GAAX,CADmD,EAEnDC,KAFmD,CAAtB;AAAA,KAA9B,CADD,CADc,CAAf;AASAV,IAAAA,QAAQ,CAAE,wCAA2BG,MAA3B,EAAmCJ,WAAnC,CAAF,CAAR;AACA,GAfD,CAeE,MAAM,CAAE;AACV,CAvBK","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( result ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {}\n\t};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/store/resolvers.js"],"names":["getDownloadableBlocks","filterValue","dispatch","results","path","blocks","map","result","Object","fromEntries","entries","key","value"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAGO,MAAMA,qBAAqB,GAC/BC,WAAF,IACA,OAAQ;AAAEC,EAAAA;AAAF,CAAR,KAA0B;AACzB,MAAK,CAAED,WAAP,EAAqB;AACpB;AACA;;AAED,MAAI;AACHC,IAAAA,QAAQ,CAAE,sCAAyBD,WAAzB,CAAF,CAAR;AACA,UAAME,OAAO,GAAG,MAAM,uBAAU;AAC/BC,MAAAA,IAAI,EAAG,qCAAqCH,WAAa;AAD1B,KAAV,CAAtB;AAGA,UAAMI,MAAM,GAAGF,OAAO,CAACG,GAAR,CAAeC,MAAF,IAC3BC,MAAM,CAACC,WAAP,CACCD,MAAM,CAACE,OAAP,CAAgBH,MAAhB,EAAyBD,GAAzB,CAA8B,CAAE,CAAEK,GAAF,EAAOC,KAAP,CAAF,KAAsB,CACnD,2BAAWD,GAAX,CADmD,EAEnDC,KAFmD,CAApD,CADD,CADc,CAAf;AASAV,IAAAA,QAAQ,CAAE,wCAA2BG,MAA3B,EAAmCJ,WAAnC,CAAF,CAAR;AACA,GAfD,CAeE,MAAM,CAAE;AACV,CAvBK","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( result ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {}\n\t};\n"]}
@@ -36,9 +36,9 @@ var _hasBlockType = _interopRequireDefault(require("./utils/has-block-type"));
36
36
  * @return {boolean} Whether a request is in progress for the blocks list.
37
37
  */
38
38
  function isRequestingDownloadableBlocks(state, filterValue) {
39
- var _state$downloadableBl, _state$downloadableBl2;
39
+ var _state$downloadableBl;
40
40
 
41
- return (_state$downloadableBl = (_state$downloadableBl2 = state.downloadableBlocks[filterValue]) === null || _state$downloadableBl2 === void 0 ? void 0 : _state$downloadableBl2.isRequesting) !== null && _state$downloadableBl !== void 0 ? _state$downloadableBl : false;
41
+ return (_state$downloadableBl = state.downloadableBlocks[filterValue]?.isRequesting) !== null && _state$downloadableBl !== void 0 ? _state$downloadableBl : false;
42
42
  }
43
43
  /**
44
44
  * Returns the available uninstalled blocks.
@@ -51,9 +51,9 @@ function isRequestingDownloadableBlocks(state, filterValue) {
51
51
 
52
52
 
53
53
  function getDownloadableBlocks(state, filterValue) {
54
- var _state$downloadableBl3, _state$downloadableBl4;
54
+ var _state$downloadableBl2;
55
55
 
56
- return (_state$downloadableBl3 = (_state$downloadableBl4 = state.downloadableBlocks[filterValue]) === null || _state$downloadableBl4 === void 0 ? void 0 : _state$downloadableBl4.results) !== null && _state$downloadableBl3 !== void 0 ? _state$downloadableBl3 : [];
56
+ return (_state$downloadableBl2 = state.downloadableBlocks[filterValue]?.results) !== null && _state$downloadableBl2 !== void 0 ? _state$downloadableBl2 : [];
57
57
  }
58
58
  /**
59
59
  * Returns the block types that have been installed on the server in this
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/store/selectors.js"],"names":["isRequestingDownloadableBlocks","state","filterValue","downloadableBlocks","isRequesting","getDownloadableBlocks","results","getInstalledBlockTypes","blockManagement","installedBlockTypes","getNewBlockTypes","select","usedBlockTree","blockEditorStore","getBlocks","filter","blockType","getUnusedBlockTypes","isInstalling","blockId","getErrorNotices","errorNotices","getErrorNoticeForBlock"],"mappings":";;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,8BAAT,CAAyCC,KAAzC,EAAgDC,WAAhD,EAA8D;AAAA;;AACpE,4DAAOD,KAAK,CAACE,kBAAN,CAA0BD,WAA1B,CAAP,2DAAO,uBAAyCE,YAAhD,yEAAgE,KAAhE;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,qBAAT,CAAgCJ,KAAhC,EAAuCC,WAAvC,EAAqD;AAAA;;AAC3D,6DAAOD,KAAK,CAACE,kBAAN,CAA0BD,WAA1B,CAAP,2DAAO,uBAAyCI,OAAhD,2EAA2D,EAA3D;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,sBAAT,CAAiCN,KAAjC,EAAyC;AAC/C,SAAOA,KAAK,CAACO,eAAN,CAAsBC,mBAA7B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,gBAAgB,GAAG,kCAC7BC,MAAF,IAAgBV,KAAF,IAAa;AAC1B,QAAMW,aAAa,GAAGD,MAAM,CAAEE,kBAAF,CAAN,CAA2BC,SAA3B,EAAtB;AACA,QAAML,mBAAmB,GAAGF,sBAAsB,CAAEN,KAAF,CAAlD;AAEA,SAAOQ,mBAAmB,CAACM,MAApB,CAA8BC,SAAF,IAClC,2BAAcA,SAAd,EAAyBJ,aAAzB,CADM,CAAP;AAGA,CAR8B,CAAzB;AAWP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMK,mBAAmB,GAAG,kCAChCN,MAAF,IAAgBV,KAAF,IAAa;AAC1B,QAAMW,aAAa,GAAGD,MAAM,CAAEE,kBAAF,CAAN,CAA2BC,SAA3B,EAAtB;AACA,QAAML,mBAAmB,GAAGF,sBAAsB,CAAEN,KAAF,CAAlD;AAEA,SAAOQ,mBAAmB,CAACM,MAApB,CACJC,SAAF,IAAiB,CAAE,2BAAcA,SAAd,EAAyBJ,aAAzB,CADb,CAAP;AAGA,CARiC,CAA5B;AAWP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASM,YAAT,CAAuBjB,KAAvB,EAA8BkB,OAA9B,EAAwC;AAC9C,SAAOlB,KAAK,CAACO,eAAN,CAAsBU,YAAtB,CAAoCC,OAApC,KAAiD,KAAxD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,eAAT,CAA0BnB,KAA1B,EAAkC;AACxC,SAAOA,KAAK,CAACoB,YAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,sBAAT,CAAiCrB,KAAjC,EAAwCkB,OAAxC,EAAkD;AACxD,SAAOlB,KAAK,CAACoB,YAAN,CAAoBF,OAApB,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport hasBlockType from './utils/has-block-type';\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? [];\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\treturn installedBlockTypes.filter( ( blockType ) =>\n\t\t\thasBlockType( blockType, usedBlockTree )\n\t\t);\n\t}\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\treturn installedBlockTypes.filter(\n\t\t\t( blockType ) => ! hasBlockType( blockType, usedBlockTree )\n\t\t);\n\t}\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/store/selectors.js"],"names":["isRequestingDownloadableBlocks","state","filterValue","downloadableBlocks","isRequesting","getDownloadableBlocks","results","getInstalledBlockTypes","blockManagement","installedBlockTypes","getNewBlockTypes","select","usedBlockTree","blockEditorStore","getBlocks","filter","blockType","getUnusedBlockTypes","isInstalling","blockId","getErrorNotices","errorNotices","getErrorNoticeForBlock"],"mappings":";;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,8BAAT,CAAyCC,KAAzC,EAAgDC,WAAhD,EAA8D;AAAA;;AACpE,kCAAOD,KAAK,CAACE,kBAAN,CAA0BD,WAA1B,GAAyCE,YAAhD,yEAAgE,KAAhE;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,qBAAT,CAAgCJ,KAAhC,EAAuCC,WAAvC,EAAqD;AAAA;;AAC3D,mCAAOD,KAAK,CAACE,kBAAN,CAA0BD,WAA1B,GAAyCI,OAAhD,2EAA2D,EAA3D;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,sBAAT,CAAiCN,KAAjC,EAAyC;AAC/C,SAAOA,KAAK,CAACO,eAAN,CAAsBC,mBAA7B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,gBAAgB,GAAG,kCAC7BC,MAAF,IAAgBV,KAAF,IAAa;AAC1B,QAAMW,aAAa,GAAGD,MAAM,CAAEE,kBAAF,CAAN,CAA2BC,SAA3B,EAAtB;AACA,QAAML,mBAAmB,GAAGF,sBAAsB,CAAEN,KAAF,CAAlD;AAEA,SAAOQ,mBAAmB,CAACM,MAApB,CAA8BC,SAAF,IAClC,2BAAcA,SAAd,EAAyBJ,aAAzB,CADM,CAAP;AAGA,CAR8B,CAAzB;AAWP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMK,mBAAmB,GAAG,kCAChCN,MAAF,IAAgBV,KAAF,IAAa;AAC1B,QAAMW,aAAa,GAAGD,MAAM,CAAEE,kBAAF,CAAN,CAA2BC,SAA3B,EAAtB;AACA,QAAML,mBAAmB,GAAGF,sBAAsB,CAAEN,KAAF,CAAlD;AAEA,SAAOQ,mBAAmB,CAACM,MAApB,CACJC,SAAF,IAAiB,CAAE,2BAAcA,SAAd,EAAyBJ,aAAzB,CADb,CAAP;AAGA,CARiC,CAA5B;AAWP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASM,YAAT,CAAuBjB,KAAvB,EAA8BkB,OAA9B,EAAwC;AAC9C,SAAOlB,KAAK,CAACO,eAAN,CAAsBU,YAAtB,CAAoCC,OAApC,KAAiD,KAAxD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,eAAT,CAA0BnB,KAA1B,EAAkC;AACxC,SAAOA,KAAK,CAACoB,YAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,sBAAT,CAAiCrB,KAAjC,EAAwCkB,OAAxC,EAAkD;AACxD,SAAOlB,KAAK,CAACoB,YAAN,CAAoBF,OAApB,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport hasBlockType from './utils/has-block-type';\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? [];\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\treturn installedBlockTypes.filter( ( blockType ) =>\n\t\t\thasBlockType( blockType, usedBlockTree )\n\t\t);\n\t}\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\treturn installedBlockTypes.filter(\n\t\t\t( blockType ) => ! hasBlockType( blockType, usedBlockTree )\n\t\t);\n\t}\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"]}
@@ -14,19 +14,14 @@ exports.default = hasBlockType;
14
14
  *
15
15
  * @return {boolean} Whether the blockType is found.
16
16
  */
17
- function hasBlockType(blockType) {
18
- let blocks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
19
-
17
+ function hasBlockType(blockType, blocks = []) {
20
18
  if (!blocks.length) {
21
19
  return false;
22
20
  }
23
21
 
24
- if (blocks.some(_ref => {
25
- let {
26
- name
27
- } = _ref;
28
- return name === blockType.name;
29
- })) {
22
+ if (blocks.some(({
23
+ name
24
+ }) => name === blockType.name)) {
30
25
  return true;
31
26
  }
32
27
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/store/utils/has-block-type.js"],"names":["hasBlockType","blockType","blocks","length","some","name","i","innerBlocks"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,YAAT,CAAuBC,SAAvB,EAAgD;AAAA,MAAdC,MAAc,uEAAL,EAAK;;AAC9D,MAAK,CAAEA,MAAM,CAACC,MAAd,EAAuB;AACtB,WAAO,KAAP;AACA;;AACD,MAAKD,MAAM,CAACE,IAAP,CAAa;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WAAgBA,IAAI,KAAKJ,SAAS,CAACI,IAAnC;AAAA,GAAb,CAAL,EAA8D;AAC7D,WAAO,IAAP;AACA;;AACD,OAAM,IAAIC,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGJ,MAAM,CAACC,MAA5B,EAAoCG,CAAC,EAArC,EAA0C;AACzC,QAAKN,YAAY,CAAEC,SAAF,EAAaC,MAAM,CAAEI,CAAF,CAAN,CAAYC,WAAzB,CAAjB,EAA0D;AACzD,aAAO,IAAP;AACA;AACD;;AAED,SAAO,KAAP;AACA","sourcesContent":["/**\n * Check if a block list contains a specific block type. Recursively searches\n * through `innerBlocks` if they exist.\n *\n * @param {Object} blockType A block object to search for.\n * @param {Object[]} blocks The list of blocks to look through.\n *\n * @return {boolean} Whether the blockType is found.\n */\nexport default function hasBlockType( blockType, blocks = [] ) {\n\tif ( ! blocks.length ) {\n\t\treturn false;\n\t}\n\tif ( blocks.some( ( { name } ) => name === blockType.name ) ) {\n\t\treturn true;\n\t}\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( hasBlockType( blockType, blocks[ i ].innerBlocks ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/store/utils/has-block-type.js"],"names":["hasBlockType","blockType","blocks","length","some","name","i","innerBlocks"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,YAAT,CAAuBC,SAAvB,EAAkCC,MAAM,GAAG,EAA3C,EAAgD;AAC9D,MAAK,CAAEA,MAAM,CAACC,MAAd,EAAuB;AACtB,WAAO,KAAP;AACA;;AACD,MAAKD,MAAM,CAACE,IAAP,CAAa,CAAE;AAAEC,IAAAA;AAAF,GAAF,KAAgBA,IAAI,KAAKJ,SAAS,CAACI,IAAhD,CAAL,EAA8D;AAC7D,WAAO,IAAP;AACA;;AACD,OAAM,IAAIC,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGJ,MAAM,CAACC,MAA5B,EAAoCG,CAAC,EAArC,EAA0C;AACzC,QAAKN,YAAY,CAAEC,SAAF,EAAaC,MAAM,CAAEI,CAAF,CAAN,CAAYC,WAAzB,CAAjB,EAA0D;AACzD,aAAO,IAAP;AACA;AACD;;AAED,SAAO,KAAP;AACA","sourcesContent":["/**\n * Check if a block list contains a specific block type. Recursively searches\n * through `innerBlocks` if they exist.\n *\n * @param {Object} blockType A block object to search for.\n * @param {Object[]} blocks The list of blocks to look through.\n *\n * @return {boolean} Whether the blockType is found.\n */\nexport default function hasBlockType( blockType, blocks = [] ) {\n\tif ( ! blocks.length ) {\n\t\treturn false;\n\t}\n\tif ( blocks.some( ( { name } ) => name === blockType.name ) ) {\n\t\treturn true;\n\t}\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( hasBlockType( blockType, blocks[ i ].innerBlocks ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n"]}
@@ -4,15 +4,12 @@ import { createElement } from "@wordpress/element";
4
4
  * Internal dependencies
5
5
  */
6
6
  import Stars from './stars';
7
- export const BlockRatings = _ref => {
8
- let {
9
- rating
10
- } = _ref;
11
- return createElement("span", {
12
- className: "block-directory-block-ratings"
13
- }, createElement(Stars, {
14
- rating: rating
15
- }));
16
- };
7
+ export const BlockRatings = ({
8
+ rating
9
+ }) => createElement("span", {
10
+ className: "block-directory-block-ratings"
11
+ }, createElement(Stars, {
12
+ rating: rating
13
+ }));
17
14
  export default BlockRatings;
18
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/block-ratings/index.js"],"names":["Stars","BlockRatings","rating"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,KAAP,MAAkB,SAAlB;AAEA,OAAO,MAAMC,YAAY,GAAG;AAAA,MAAE;AAAEC,IAAAA;AAAF,GAAF;AAAA,SAC3B;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,cAAC,KAAD;AAAO,IAAA,MAAM,EAAGA;AAAhB,IADD,CAD2B;AAAA,CAArB;AAMP,eAAeD,YAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport Stars from './stars';\n\nexport const BlockRatings = ( { rating } ) => (\n\t<span className=\"block-directory-block-ratings\">\n\t\t<Stars rating={ rating } />\n\t</span>\n);\n\nexport default BlockRatings;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/components/block-ratings/index.js"],"names":["Stars","BlockRatings","rating"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,KAAP,MAAkB,SAAlB;AAEA,OAAO,MAAMC,YAAY,GAAG,CAAE;AAAEC,EAAAA;AAAF,CAAF,KAC3B;AAAM,EAAA,SAAS,EAAC;AAAhB,GACC,cAAC,KAAD;AAAO,EAAA,MAAM,EAAGA;AAAhB,EADD,CADM;AAMP,eAAeD,YAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport Stars from './stars';\n\nexport const BlockRatings = ( { rating } ) => (\n\t<span className=\"block-directory-block-ratings\">\n\t\t<Stars rating={ rating } />\n\t</span>\n);\n\nexport default BlockRatings;\n"]}
@@ -6,10 +6,9 @@ import { createElement } from "@wordpress/element";
6
6
  import { __, sprintf } from '@wordpress/i18n';
7
7
  import { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons';
8
8
 
9
- function Stars(_ref) {
10
- let {
11
- rating
12
- } = _ref;
9
+ function Stars({
10
+ rating
11
+ }) {
13
12
  const stars = Math.round(rating / 0.5) * 0.5;
14
13
  const fullStarCount = Math.floor(rating);
15
14
  const halfStarCount = Math.ceil(rating - fullStarCount);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/block-ratings/stars.js"],"names":["__","sprintf","Icon","starEmpty","starFilled","starHalf","Stars","rating","stars","Math","round","fullStarCount","floor","halfStarCount","ceil","emptyStarCount","Array","from","length","map","_","i"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,IAAT,EAAeC,SAAf,EAA0BC,UAA1B,EAAsCC,QAAtC,QAAsD,kBAAtD;;AAEA,SAASC,KAAT,OAA6B;AAAA,MAAb;AAAEC,IAAAA;AAAF,GAAa;AAC5B,QAAMC,KAAK,GAAGC,IAAI,CAACC,KAAL,CAAYH,MAAM,GAAG,GAArB,IAA6B,GAA3C;AAEA,QAAMI,aAAa,GAAGF,IAAI,CAACG,KAAL,CAAYL,MAAZ,CAAtB;AACA,QAAMM,aAAa,GAAGJ,IAAI,CAACK,IAAL,CAAWP,MAAM,GAAGI,aAApB,CAAtB;AACA,QAAMI,cAAc,GAAG,KAAMJ,aAAa,GAAGE,aAAtB,CAAvB;AAEA,SACC;AACC,kBAAaZ,OAAO;AACnB;AACAD,IAAAA,EAAE,CAAE,mBAAF,CAFiB,EAGnBQ,KAHmB;AADrB,KAOGQ,KAAK,CAACC,IAAN,CAAY;AAAEC,IAAAA,MAAM,EAAEP;AAAV,GAAZ,EAAwCQ,GAAxC,CAA6C,CAAEC,CAAF,EAAKC,CAAL,KAC9C,cAAC,IAAD;AACC,IAAA,GAAG,EAAI,cAAcA,CAAG,EADzB;AAEC,IAAA,SAAS,EAAC,0CAFX;AAGC,IAAA,IAAI,EAAGjB,UAHR;AAIC,IAAA,IAAI,EAAG;AAJR,IADC,CAPH,EAeGY,KAAK,CAACC,IAAN,CAAY;AAAEC,IAAAA,MAAM,EAAEL;AAAV,GAAZ,EAAwCM,GAAxC,CAA6C,CAAEC,CAAF,EAAKC,CAAL,KAC9C,cAAC,IAAD;AACC,IAAA,GAAG,EAAI,cAAcA,CAAG,EADzB;AAEC,IAAA,SAAS,EAAC,+CAFX;AAGC,IAAA,IAAI,EAAGhB,QAHR;AAIC,IAAA,IAAI,EAAG;AAJR,IADC,CAfH,EAuBGW,KAAK,CAACC,IAAN,CAAY;AAAEC,IAAAA,MAAM,EAAEH;AAAV,GAAZ,EAAyCI,GAAzC,CAA8C,CAAEC,CAAF,EAAKC,CAAL,KAC/C,cAAC,IAAD;AACC,IAAA,GAAG,EAAI,eAAeA,CAAG,EAD1B;AAEC,IAAA,SAAS,EAAC,2CAFX;AAGC,IAAA,IAAI,EAAGlB,SAHR;AAIC,IAAA,IAAI,EAAG;AAJR,IADC,CAvBH,CADD;AAkCA;;AAED,eAAeG,KAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons';\n\nfunction Stars( { rating } ) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tconst fullStarCount = Math.floor( rating );\n\tconst halfStarCount = Math.ceil( rating - fullStarCount );\n\tconst emptyStarCount = 5 - ( fullStarCount + halfStarCount );\n\n\treturn (\n\t\t<span\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: %s: number of stars. */\n\t\t\t\t__( '%s out of 5 stars' ),\n\t\t\t\tstars\n\t\t\t) }\n\t\t>\n\t\t\t{ Array.from( { length: fullStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `full_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-full\"\n\t\t\t\t\ticon={ starFilled }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: halfStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `half_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-half-full\"\n\t\t\t\t\ticon={ starHalf }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: emptyStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `empty_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-empty\"\n\t\t\t\t\ticon={ starEmpty }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</span>\n\t);\n}\n\nexport default Stars;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/components/block-ratings/stars.js"],"names":["__","sprintf","Icon","starEmpty","starFilled","starHalf","Stars","rating","stars","Math","round","fullStarCount","floor","halfStarCount","ceil","emptyStarCount","Array","from","length","map","_","i"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,IAAT,EAAeC,SAAf,EAA0BC,UAA1B,EAAsCC,QAAtC,QAAsD,kBAAtD;;AAEA,SAASC,KAAT,CAAgB;AAAEC,EAAAA;AAAF,CAAhB,EAA6B;AAC5B,QAAMC,KAAK,GAAGC,IAAI,CAACC,KAAL,CAAYH,MAAM,GAAG,GAArB,IAA6B,GAA3C;AAEA,QAAMI,aAAa,GAAGF,IAAI,CAACG,K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, starEmpty, starFilled, starHalf } from '@wordpress/icons';\n\nfunction Stars( { rating } ) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tconst fullStarCount = Math.floor( rating );\n\tconst halfStarCount = Math.ceil( rating - fullStarCount );\n\tconst emptyStarCount = 5 - ( fullStarCount + halfStarCount );\n\n\treturn (\n\t\t<span\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: %s: number of stars. */\n\t\t\t\t__( '%s out of 5 stars' ),\n\t\t\t\tstars\n\t\t\t) }\n\t\t>\n\t\t\t{ Array.from( { length: fullStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `full_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-full\"\n\t\t\t\t\ticon={ starFilled }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: halfStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `half_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-half-full\"\n\t\t\t\t\ticon={ starHalf }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: emptyStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `empty_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-empty\"\n\t\t\t\t\ticon={ starEmpty }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</span>\n\t);\n}\n\nexport default Stars;\n"]}
@@ -9,39 +9,34 @@ import { __, sprintf } from '@wordpress/i18n';
9
9
  */
10
10
 
11
11
  import DownloadableBlockIcon from '../downloadable-block-icon';
12
- export default function CompactList(_ref) {
13
- let {
14
- items
15
- } = _ref;
16
-
12
+ export default function CompactList({
13
+ items
14
+ }) {
17
15
  if (!items.length) {
18
16
  return null;
19
17
  }
20
18
 
21
19
  return createElement("ul", {
22
20
  className: "block-directory-compact-list"
23
- }, items.map(_ref2 => {
24
- let {
25
- icon,
26
- id,
27
- title,
28
- author
29
- } = _ref2;
30
- return createElement("li", {
31
- key: id,
32
- className: "block-directory-compact-list__item"
33
- }, createElement(DownloadableBlockIcon, {
34
- icon: icon,
35
- title: title
36
- }), createElement("div", {
37
- className: "block-directory-compact-list__item-details"
38
- }, createElement("div", {
39
- className: "block-directory-compact-list__item-title"
40
- }, title), createElement("div", {
41
- className: "block-directory-compact-list__item-author"
42
- }, sprintf(
43
- /* translators: %s: Name of the block author. */
44
- __('By %s'), author))));
45
- }));
21
+ }, items.map(({
22
+ icon,
23
+ id,
24
+ title,
25
+ author
26
+ }) => createElement("li", {
27
+ key: id,
28
+ className: "block-directory-compact-list__item"
29
+ }, createElement(DownloadableBlockIcon, {
30
+ icon: icon,
31
+ title: title
32
+ }), createElement("div", {
33
+ className: "block-directory-compact-list__item-details"
34
+ }, createElement("div", {
35
+ className: "block-directory-compact-list__item-title"
36
+ }, title), createElement("div", {
37
+ className: "block-directory-compact-list__item-author"
38
+ }, sprintf(
39
+ /* translators: %s: Name of the block author. */
40
+ __('By %s'), author))))));
46
41
  }
47
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/compact-list/index.js"],"names":["__","sprintf","DownloadableBlockIcon","CompactList","items","length","map","icon","id","title","author"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AAEA,eAAe,SAASC,WAAT,OAAkC;AAAA,MAAZ;AAAEC,IAAAA;AAAF,GAAY;;AAChD,MAAK,CAAEA,KAAK,CAACC,MAAb,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGD,KAAK,CAACE,GAAN,CAAW;AAAA,QAAE;AAAEC,MAAAA,IAAF;AAAQC,MAAAA,EAAR;AAAYC,MAAAA,KAAZ;AAAmBC,MAAAA;AAAnB,KAAF;AAAA,WACZ;AAAI,MAAA,GAAG,EAAGF,EAAV;AAAe,MAAA,SAAS,EAAC;AAAzB,OACC,cAAC,qBAAD;AAAuB,MAAA,IAAI,EAAGD,IAA9B;AAAqC,MAAA,KAAK,EAAGE;AAA7C,MADD,EAGC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC;AAAK,MAAA,SAAS,EAAC;AAAf,OACGA,KADH,CADD,EAIC;AAAK,MAAA,SAAS,EAAC;AAAf,OACGR,OAAO;AACR;AACAD,IAAAA,EAAE,CAAE,OAAF,CAFM,EAGRU,MAHQ,CADV,CAJD,CAHD,CADY;AAAA,GAAX,CADH,CADD;AAsBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockIcon from '../downloadable-block-icon';\n\nexport default function CompactList( { items } ) {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ul className=\"block-directory-compact-list\">\n\t\t\t{ items.map( ( { icon, id, title, author } ) => (\n\t\t\t\t<li key={ id } className=\"block-directory-compact-list__item\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\n\t\t\t\t\t<div className=\"block-directory-compact-list__item-details\">\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-title\">\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-author\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Name of the block author. */\n\t\t\t\t\t\t\t\t__( 'By %s' ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/components/compact-list/index.js"],"names":["__","sprintf","DownloadableBlockIcon","CompactList","items","length","map","icon","id","title","author"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AAEA,eAAe,SAASC,WAAT,CAAsB;AAAEC,EAAAA;AAAF,CAAtB,EAAkC;AAChD,MAAK,CAAEA,KAAK,CAACC,MAAb,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGD,KAAK,CAACE,GAAN,CAAW,CAAE;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,EAAR;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA;AAAnB,GAAF,KACZ;AAAI,IAAA,GAAG,EAAGF,EAAV;AAAe,IAAA,SAAS,EAAC;AAAzB,KACC,cAAC,qBAAD;AAAuB,IAAA,IAAI,EAAGD,IAA9B;AAAqC,IAAA,KAAK,EAAGE;AAA7C,IADD,EAGC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGA,KADH,CADD,EAIC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGR,OAAO;AACR;AACAD,EAAAA,EAAE,CAAE,OAAF,CAFM,EAGRU,MAHQ,CADV,CAJD,CAHD,CADC,CADH,CADD;AAsBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockIcon from '../downloadable-block-icon';\n\nexport default function CompactList( { items } ) {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ul className=\"block-directory-compact-list\">\n\t\t\t{ items.map( ( { icon, id, title, author } ) => (\n\t\t\t\t<li key={ id } className=\"block-directory-compact-list__item\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\n\t\t\t\t\t<div className=\"block-directory-compact-list__item-details\">\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-title\">\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-author\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Name of the block author. */\n\t\t\t\t\t\t\t\t__( 'By %s' ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"]}
@@ -5,10 +5,9 @@ import { createElement } from "@wordpress/element";
5
5
  */
6
6
  import { BlockIcon } from '@wordpress/block-editor';
7
7
 
8
- function DownloadableBlockIcon(_ref) {
9
- let {
10
- icon
11
- } = _ref;
8
+ function DownloadableBlockIcon({
9
+ icon
10
+ }) {
12
11
  const className = 'block-directory-downloadable-block-icon';
13
12
  return icon.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/) !== null ? createElement("img", {
14
13
  className: className,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-block-icon/index.js"],"names":["BlockIcon","DownloadableBlockIcon","icon","className","match"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,yBAA1B;;AAEA,SAASC,qBAAT,OAA2C;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AAC1C,QAAMC,SAAS,GAAG,yCAAlB;AACA,SAAOD,IAAI,CAACE,KAAL,CAAY,oCAAZ,MAAuD,IAAvD,GACN;AAAK,IAAA,SAAS,EAAGD,SAAjB;AAA6B,IAAA,GAAG,EAAGD,IAAnC;AAA0C,IAAA,GAAG,EAAC;AAA9C,IADM,GAGN,cAAC,SAAD;AAAW,IAAA,SAAS,EAAGC,SAAvB;AAAmC,IAAA,IAAI,EAAGD,IAA1C;AAAiD,IAAA,UAAU;AAA3D,IAHD;AAKA;;AAED,eAAeD,qBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockIcon } from '@wordpress/block-editor';\n\nfunction DownloadableBlockIcon( { icon } ) {\n\tconst className = 'block-directory-downloadable-block-icon';\n\treturn icon.match( /\\.(jpeg|jpg|gif|png|svg)(?:\\?.*)?$/ ) !== null ? (\n\t\t<img className={ className } src={ icon } alt=\"\" />\n\t) : (\n\t\t<BlockIcon className={ className } icon={ icon } showColors />\n\t);\n}\n\nexport default DownloadableBlockIcon;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-block-icon/index.js"],"names":["BlockIcon","DownloadableBlockIcon","icon","className","match"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,yBAA1B;;AAEA,SAASC,qBAAT,CAAgC;AAAEC,EAAAA;AAAF,CAAhC,EAA2C;AAC1C,QAAMC,SAAS,GAAG,yCAAlB;AACA,SAAOD,IAAI,CAACE,KAAL,CAAY,oCAAZ,MAAuD,IAAvD,GACN;AAAK,IAAA,SAAS,EAAGD,SAAjB;AAA6B,IAAA,GAAG,EAAGD,IAAnC;AAA0C,IAAA,GAAG,EAAC;AAA9C,IADM,GAGN,cAAC,SAAD;AAAW,IAAA,SAAS,EAAGC,SAAvB;AAAmC,IAAA,IAAI,EAAGD,IAA1C;AAAiD,IAAA,UAAU;AAA3D,IAHD;AAKA;;AAED,eAAeD,qBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockIcon } from '@wordpress/block-editor';\n\nfunction DownloadableBlockIcon( { icon } ) {\n\tconst className = 'block-directory-downloadable-block-icon';\n\treturn icon.match( /\\.(jpeg|jpg|gif|png|svg)(?:\\?.*)?$/ ) !== null ? (\n\t\t<img className={ className } src={ icon } alt=\"\" />\n\t) : (\n\t\t<BlockIcon className={ className } icon={ icon } showColors />\n\t);\n}\n\nexport default DownloadableBlockIcon;\n"]}
@@ -19,17 +19,15 @@ import DownloadableBlockIcon from '../downloadable-block-icon';
19
19
  import DownloadableBlockNotice from '../downloadable-block-notice';
20
20
  import { store as blockDirectoryStore } from '../../store'; // Return the appropriate block item label, given the block data and status.
21
21
 
22
- function getDownloadableBlockLabel(_ref, _ref2) {
23
- let {
24
- title,
25
- rating,
26
- ratingCount
27
- } = _ref;
28
- let {
29
- hasNotice,
30
- isInstalled,
31
- isInstalling
32
- } = _ref2;
22
+ function getDownloadableBlockLabel({
23
+ title,
24
+ rating,
25
+ ratingCount
26
+ }, {
27
+ hasNotice,
28
+ isInstalled,
29
+ isInstalling
30
+ }) {
33
31
  const stars = Math.round(rating / 0.5) * 0.5;
34
32
 
35
33
  if (!isInstalled && hasNotice) {
@@ -58,12 +56,11 @@ function getDownloadableBlockLabel(_ref, _ref2) {
58
56
  _n('Install %1$s. %2$s stars with %3$s review.', 'Install %1$s. %2$s stars with %3$s reviews.', ratingCount), decodeEntities(title), stars, ratingCount);
59
57
  }
60
58
 
61
- function DownloadableBlockListItem(_ref3) {
62
- let {
63
- composite,
64
- item,
65
- onClick
66
- } = _ref3;
59
+ function DownloadableBlockListItem({
60
+ composite,
61
+ item,
62
+ onClick
63
+ }) {
67
64
  const {
68
65
  author,
69
66
  description,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"names":["__","_n","sprintf","Button","Spinner","VisuallyHidden","__unstableCompositeItem","CompositeItem","createInterpolateElement","decodeEntities","getBlockType","useSelect","BlockRatings","DownloadableBlockIcon","DownloadableBlockNotice","store","blockDirectoryStore","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","DownloadableBlockListItem","composite","item","onClick","author","description","icon","name","isInstallable","select","getErrorNoticeForBlock","isBlockInstalling","notice","id","hasFatal","isFatal","statusText","event","preventDefault","span"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,E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D,GAEClC,cAAc,CAAEuB,WAAF,CAHlB,CADD,EAMGG,aAAa,IACd,EAAIb,WAAW,IAAIC,YAAnB,CADC,IAEA,cAAC,cAAD,QACGvB,EAAE,CAAE,eAAF,CADL,CARH,CAnBF,CA9BD,CADD;AAmEA;;AAED,eAAe2B,yBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tSpinner,\n\tVisuallyHidden,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Installing %s.', decodeEntities( title ) );\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\n\t}\n\n\treturn sprintf(\n\t\t/* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { composite, item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =\n\t\t\t\tselect( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\treturn (\n\t\t<CompositeItem\n\t\t\t__experimentalIsFocusable\n\t\t\trole=\"option\"\n\t\t\tas={ Button }\n\t\t\t{ ...composite }\n\t\t\tclassName=\"block-directory-downloadable-block-list-item\"\n\t\t\tonClick={ ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t\tisBusy={ isInstalling }\n\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\tlabel={ getDownloadableBlockLabel( item, {\n\t\t\t\thasNotice,\n\t\t\t\tisInstalled,\n\t\t\t\tisInstalling,\n\t\t\t} ) }\n\t\t\tshowTooltip={ true }\n\t\t\ttooltipPosition=\"top center\"\n\t\t>\n\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</span>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</CompositeItem>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"names":["__","_n","sprintf","Button","Spinner","VisuallyHidden","__unstableCompositeItem","CompositeItem","createInterpolateElement","decodeEntities","getBlockType","useSelect","BlockRatings","DownloadableBlockIcon","DownloadableBlockNotice","store","blockDirectoryStore","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","DownloadableBlockListItem","composite","item","onClick","author","description","icon","name","isInstallable","select","getErrorNoticeForBlock","isBlockInstalling","notice","id","hasFatal","isFatal","statusText","event","preventDefault","span"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SACCC,MADD,EAECC,OAFD,EAGCC,cAHD,EAICC,uBAAuB,IAAIC,aAJ5B,QAKO,uBALP;AAMA,SAASC,wBAAT,QAAyC,oBAAzC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,YAAT,QAA6B,mBAA7B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,SAASC,KAAK,IAAIC,mBAAlB,QAA6C,aAA7C,C,CAEA;;AACA,SAASC,yBAAT,CACC;AAAEC,EAAAA,KAAF;AAASC,EAAAA,MAAT;AAAiBC,EAAAA;AAAjB,CADD,EAEC;AAAEC,EAAAA,SAAF;AAAaC,EAAAA,WAAb;AAA0BC,EAAAA;AAA1B,CAFD,EAGE;AACD,QAAMC,KAAK,GAAGC,IAAI,CAACC,KAAL,CAAYP,MAAM,GAAG,GAArB,IAA6B,GAA3C;;AAEA,MAAK,CAAEG,WAAF,IAAiBD,SAAtB,EAAkC;AACjC;AACA,WAAOnB,OAAO,CAAE,sBAAF,EAA0BO,cAAc,CAAES,KAAF,CAAxC,CAAd;AACA;;AAED,MAAKI,WAAL,EAAmB;AAClB;AACA,WAAOpB,OAAO,CA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;AACN;AACAF,EAAAA,EAAE,CAAE,2BAAF,CAFI,EAGNS,cAAc,CAAES,KAAF,CAHR,EAINa,MAJM,CADkB,EAOzB;AACCe,IAAAA,IAAI,EACH;AAAM,MAAA,SAAS,EAAC;AAAhB;AAFF,GAPyB,CAD3B,CADD,EAgBGzB,SAAS,GACV,cAAC,uBAAD;AAAyB,IAAA,KAAK,EAAGQ;AAAjC,IADU,GAGV,8BACC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACG,CAAC,CAAEc,UAAH,GACCA,UADD,GAEClC,cAAc,CAAEuB,WAAF,CAHlB,CADD,EAMGG,aAAa,IACd,EAAIb,WAAW,IAAIC,YAAnB,CADC,IAEA,cAAC,cAAD,QACGvB,EAAE,CAAE,eAAF,CADL,CARH,CAnBF,CA9BD,CADD;AAmEA;;AAED,eAAe2B,yBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tSpinner,\n\tVisuallyHidden,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Installing %s.', decodeEntities( title ) );\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\n\t}\n\n\treturn sprintf(\n\t\t/* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { composite, item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =\n\t\t\t\tselect( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\treturn (\n\t\t<CompositeItem\n\t\t\t__experimentalIsFocusable\n\t\t\trole=\"option\"\n\t\t\tas={ Button }\n\t\t\t{ ...composite }\n\t\t\tclassName=\"block-directory-downloadable-block-list-item\"\n\t\t\tonClick={ ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t\tisBusy={ isInstalling }\n\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\tlabel={ getDownloadableBlockLabel( item, {\n\t\t\t\thasNotice,\n\t\t\t\tisInstalled,\n\t\t\t\tisInstalling,\n\t\t\t} ) }\n\t\t\tshowTooltip={ true }\n\t\t\ttooltipPosition=\"top center\"\n\t\t>\n\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</span>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</CompositeItem>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"]}