@wordpress/block-directory 6.1.0 → 6.3.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 (106) hide show
  1. package/build/components/auto-block-uninstaller/index.cjs.map +1 -1
  2. package/build/components/block-ratings/index.cjs +9 -7
  3. package/build/components/block-ratings/index.cjs.map +1 -1
  4. package/build/components/block-ratings/stars.cjs +5 -1
  5. package/build/components/block-ratings/stars.cjs.map +1 -1
  6. package/build/components/compact-list/index.cjs +14 -8
  7. package/build/components/compact-list/index.cjs.map +1 -1
  8. package/build/components/downloadable-block-list-item/index.cjs +45 -16
  9. package/build/components/downloadable-block-list-item/index.cjs.map +1 -1
  10. package/build/components/downloadable-block-notice/index.cjs +2 -3
  11. package/build/components/downloadable-block-notice/index.cjs.map +1 -1
  12. package/build/components/downloadable-blocks-list/index.cjs +9 -7
  13. package/build/components/downloadable-blocks-list/index.cjs.map +1 -1
  14. package/build/components/downloadable-blocks-panel/index.cjs +11 -9
  15. package/build/components/downloadable-blocks-panel/index.cjs.map +1 -1
  16. package/build/components/downloadable-blocks-panel/inserter-panel.cjs +5 -1
  17. package/build/components/downloadable-blocks-panel/inserter-panel.cjs.map +1 -1
  18. package/build/plugins/get-install-missing/index.cjs +19 -9
  19. package/build/plugins/get-install-missing/index.cjs.map +1 -1
  20. package/build/plugins/get-install-missing/install-button.cjs +5 -1
  21. package/build/plugins/get-install-missing/install-button.cjs.map +1 -1
  22. package/build/plugins/index.cjs +12 -10
  23. package/build/plugins/index.cjs.map +1 -1
  24. package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs +9 -7
  25. package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs.map +1 -1
  26. package/build/plugins/installed-blocks-pre-publish-panel/index.cjs +15 -9
  27. package/build/plugins/installed-blocks-pre-publish-panel/index.cjs.map +1 -1
  28. package/build/store/actions.cjs +14 -8
  29. package/build/store/actions.cjs.map +1 -1
  30. package/build/store/index.cjs +11 -9
  31. package/build/store/index.cjs.map +1 -1
  32. package/build/store/load-assets.cjs +8 -6
  33. package/build/store/load-assets.cjs.map +1 -1
  34. package/build/store/resolvers.cjs +9 -7
  35. package/build/store/resolvers.cjs.map +1 -1
  36. package/build-module/components/block-ratings/stars.mjs +5 -1
  37. package/build-module/components/block-ratings/stars.mjs.map +1 -1
  38. package/build-module/components/compact-list/index.mjs +5 -1
  39. package/build-module/components/compact-list/index.mjs.map +1 -1
  40. package/build-module/components/downloadable-block-list-item/index.mjs +33 -6
  41. package/build-module/components/downloadable-block-list-item/index.mjs.map +1 -1
  42. package/build-module/components/downloadable-block-notice/index.mjs +3 -4
  43. package/build-module/components/downloadable-block-notice/index.mjs.map +1 -1
  44. package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs +5 -1
  45. package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs.map +1 -1
  46. package/build-module/plugins/get-install-missing/index.mjs +10 -2
  47. package/build-module/plugins/get-install-missing/index.mjs.map +1 -1
  48. package/build-module/plugins/get-install-missing/install-button.mjs +5 -1
  49. package/build-module/plugins/get-install-missing/install-button.mjs.map +1 -1
  50. package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs +7 -3
  51. package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs.map +1 -1
  52. package/build-module/store/actions.mjs +5 -1
  53. package/build-module/store/actions.mjs.map +1 -1
  54. package/build-style/style-rtl.css +7 -7
  55. package/build-style/style.css +7 -7
  56. package/build-types/components/auto-block-uninstaller/index.d.ts +2 -0
  57. package/build-types/components/auto-block-uninstaller/index.d.ts.map +1 -0
  58. package/build-types/components/block-ratings/index.d.ts +5 -0
  59. package/build-types/components/block-ratings/index.d.ts.map +1 -0
  60. package/build-types/components/block-ratings/stars.d.ts +5 -0
  61. package/build-types/components/block-ratings/stars.d.ts.map +1 -0
  62. package/build-types/components/compact-list/index.d.ts +4 -0
  63. package/build-types/components/compact-list/index.d.ts.map +1 -0
  64. package/build-types/components/downloadable-block-icon/index.d.ts +5 -0
  65. package/build-types/components/downloadable-block-icon/index.d.ts.map +1 -0
  66. package/build-types/components/downloadable-block-list-item/index.d.ts +6 -0
  67. package/build-types/components/downloadable-block-list-item/index.d.ts.map +1 -0
  68. package/build-types/components/downloadable-block-notice/index.d.ts +5 -0
  69. package/build-types/components/downloadable-block-notice/index.d.ts.map +1 -0
  70. package/build-types/components/downloadable-blocks-list/index.d.ts +8 -0
  71. package/build-types/components/downloadable-blocks-list/index.d.ts.map +1 -0
  72. package/build-types/components/downloadable-blocks-panel/index.d.ts +8 -0
  73. package/build-types/components/downloadable-blocks-panel/index.d.ts.map +1 -0
  74. package/build-types/components/downloadable-blocks-panel/inserter-panel.d.ts +7 -0
  75. package/build-types/components/downloadable-blocks-panel/inserter-panel.d.ts.map +1 -0
  76. package/build-types/components/downloadable-blocks-panel/no-results.d.ts +3 -0
  77. package/build-types/components/downloadable-blocks-panel/no-results.d.ts.map +1 -0
  78. package/build-types/index.d.ts +3 -0
  79. package/build-types/index.d.ts.map +1 -0
  80. package/build-types/plugins/get-install-missing/index.d.ts +3 -0
  81. package/build-types/plugins/get-install-missing/index.d.ts.map +1 -0
  82. package/build-types/plugins/get-install-missing/install-button.d.ts +6 -0
  83. package/build-types/plugins/get-install-missing/install-button.d.ts.map +1 -0
  84. package/build-types/plugins/index.d.ts +2 -0
  85. package/build-types/plugins/index.d.ts.map +1 -0
  86. package/build-types/plugins/inserter-menu-downloadable-blocks-panel/index.d.ts +3 -0
  87. package/build-types/plugins/inserter-menu-downloadable-blocks-panel/index.d.ts.map +1 -0
  88. package/build-types/plugins/installed-blocks-pre-publish-panel/index.d.ts +2 -0
  89. package/build-types/plugins/installed-blocks-pre-publish-panel/index.d.ts.map +1 -0
  90. package/build-types/store/actions.d.ts +82 -0
  91. package/build-types/store/actions.d.ts.map +1 -0
  92. package/build-types/store/index.d.ts +17 -0
  93. package/build-types/store/index.d.ts.map +1 -0
  94. package/build-types/store/load-assets.d.ts +16 -0
  95. package/build-types/store/load-assets.d.ts.map +1 -0
  96. package/build-types/store/reducer.d.ts +38 -0
  97. package/build-types/store/reducer.d.ts.map +1 -0
  98. package/build-types/store/resolvers.d.ts +4 -0
  99. package/build-types/store/resolvers.d.ts.map +1 -0
  100. package/build-types/store/selectors.d.ts +80 -0
  101. package/build-types/store/selectors.d.ts.map +1 -0
  102. package/build-types/store/utils/get-plugin-url.d.ts +9 -0
  103. package/build-types/store/utils/get-plugin-url.d.ts.map +1 -0
  104. package/package.json +23 -23
  105. package/src/components/downloadable-block-notice/index.jsx +0 -4
  106. package/src/plugins/installed-blocks-pre-publish-panel/index.jsx +6 -6
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -27,14 +29,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
29
  let _wordpress_plugins = require("@wordpress/plugins");
28
30
  let _wordpress_hooks = require("@wordpress/hooks");
29
31
  let ___components_auto_block_uninstaller_index_js = require("../components/auto-block-uninstaller/index.cjs");
30
- ___components_auto_block_uninstaller_index_js = __toESM(___components_auto_block_uninstaller_index_js);
31
32
  let __inserter_menu_downloadable_blocks_panel_index_jsx = require("./inserter-menu-downloadable-blocks-panel/index.cjs");
32
- __inserter_menu_downloadable_blocks_panel_index_jsx = __toESM(__inserter_menu_downloadable_blocks_panel_index_jsx);
33
33
  let __installed_blocks_pre_publish_panel_index_jsx = require("./installed-blocks-pre-publish-panel/index.cjs");
34
- __installed_blocks_pre_publish_panel_index_jsx = __toESM(__installed_blocks_pre_publish_panel_index_jsx);
35
34
  let __get_install_missing_index_jsx = require("./get-install-missing/index.cjs");
36
- __get_install_missing_index_jsx = __toESM(__get_install_missing_index_jsx);
37
35
  let react_jsx_runtime = require("react/jsx-runtime");
36
+ ___components_auto_block_uninstaller_index_js = __toESM(___components_auto_block_uninstaller_index_js);
37
+ __inserter_menu_downloadable_blocks_panel_index_jsx = __toESM(__inserter_menu_downloadable_blocks_panel_index_jsx);
38
+ __installed_blocks_pre_publish_panel_index_jsx = __toESM(__installed_blocks_pre_publish_panel_index_jsx);
39
+ __get_install_missing_index_jsx = __toESM(__get_install_missing_index_jsx);
38
40
  // packages/block-directory/src/plugins/index.jsx
39
41
  (0, _wordpress_plugins.registerPlugin)("block-directory", {
40
42
  icon: void 0,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["registerPlugin","AutoBlockUninstaller","InserterMenuDownloadableBlocksPanel","InstalledBlocksPrePublishPanel","addFilter","getInstallMissing"],"sources":["../../src/plugins/index.jsx"],"sourcesContent":["import { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\nimport AutoBlockUninstaller from '../components/auto-block-uninstaller';\nimport InserterMenuDownloadableBlocksPanel from './inserter-menu-downloadable-blocks-panel';\nimport InstalledBlocksPrePublishPanel from './installed-blocks-pre-publish-panel';\nimport getInstallMissing from './get-install-missing';\n\nregisterPlugin( 'block-directory', {\n\t// The icon is explicitly set to undefined to prevent PluginPrePublishPanel\n\t// from rendering the fallback icon pluginIcon.\n\ticon: undefined,\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<AutoBlockUninstaller />\n\t\t\t\t<InserterMenuDownloadableBlocksPanel />\n\t\t\t\t<InstalledBlocksPrePublishPanel />\n\t\t\t</>\n\t\t);\n\t},\n} );\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-directory/fallback',\n\t( settings, name ) => {\n\t\tif ( name !== 'core/missing' ) {\n\t\t\treturn settings;\n\t\t}\n\t\tsettings.edit = getInstallMissing( settings.edit );\n\n\t\treturn settings;\n\t}\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOAA,GAAAA,mBAAAA,eAAAA,CAAgB,mBAAmB;CAGlC,MAAM,KAAA;CACN,SAAS;EACR,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA;GACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,8CAAAA,SAAD,CAAuB,CAAA;GACvB,iBAAA,GAAA,kBAAA,IAAA,CAACC,oDAAAA,SAAD,CAAsC,CAAA;GACtC,iBAAA,GAAA,kBAAA,IAAA,CAACC,+CAAAA,SAAD,CAAiC,CAAA;EAChC,EAAA,CAAA;CAEJ;AACD,CAAE;CAEFC,GAAAA,iBAAAA,UAAAA,CACC,4BACA,6BACE,UAAU,SAAU;CACrB,IAAK,SAAS,gBACb,OAAO;CAER,SAAS,QAAA,GAAOC,gCAAAA,QAAAA,CAAmB,SAAS,IAAK;CAEjD,OAAO;AACR,CACD"}
1
+ {"version":3,"file":"index.cjs","names":["registerPlugin","AutoBlockUninstaller","InserterMenuDownloadableBlocksPanel","InstalledBlocksPrePublishPanel","addFilter","getInstallMissing"],"sources":["../../src/plugins/index.jsx"],"sourcesContent":["import { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\nimport AutoBlockUninstaller from '../components/auto-block-uninstaller';\nimport InserterMenuDownloadableBlocksPanel from './inserter-menu-downloadable-blocks-panel';\nimport InstalledBlocksPrePublishPanel from './installed-blocks-pre-publish-panel';\nimport getInstallMissing from './get-install-missing';\n\nregisterPlugin( 'block-directory', {\n\t// The icon is explicitly set to undefined to prevent PluginPrePublishPanel\n\t// from rendering the fallback icon pluginIcon.\n\ticon: undefined,\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<AutoBlockUninstaller />\n\t\t\t\t<InserterMenuDownloadableBlocksPanel />\n\t\t\t\t<InstalledBlocksPrePublishPanel />\n\t\t\t</>\n\t\t);\n\t},\n} );\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-directory/fallback',\n\t( settings, name ) => {\n\t\tif ( name !== 'core/missing' ) {\n\t\t\treturn settings;\n\t\t}\n\t\tsettings.edit = getInstallMissing( settings.edit );\n\n\t\treturn settings;\n\t}\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOAA,GAAAA,mBAAAA,eAAAA,CAAgB,mBAAmB;CAGlC,MAAM,KAAA;CACN,SAAS;EACR,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA;GACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,8CAAAA,SAAD,CAAuB,CAAA;GACvB,iBAAA,GAAA,kBAAA,IAAA,CAACC,oDAAAA,SAAD,CAAsC,CAAA;GACtC,iBAAA,GAAA,kBAAA,IAAA,CAACC,+CAAAA,SAAD,CAAiC,CAAA;EAChC,EAAA,CAAA;CAEJ;AACD,CAAE;CAEFC,GAAAA,iBAAAA,UAAAA,CACC,4BACA,6BACE,UAAU,SAAU;CACrB,IAAK,SAAS,gBACb,OAAO;CAER,SAAS,QAAA,GAAOC,gCAAAA,QAAAA,CAAmB,SAAS,IAAK;CAEjD,OAAO;AACR,CACD"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -28,8 +30,8 @@ let _wordpress_block_editor = require("@wordpress/block-editor");
28
30
  let _wordpress_compose = require("@wordpress/compose");
29
31
  let _wordpress_element = require("@wordpress/element");
30
32
  let ______components_downloadable_blocks_panel_index_jsx = require("../../components/downloadable-blocks-panel/index.cjs");
31
- ______components_downloadable_blocks_panel_index_jsx = __toESM(______components_downloadable_blocks_panel_index_jsx);
32
33
  let react_jsx_runtime = require("react/jsx-runtime");
34
+ ______components_downloadable_blocks_panel_index_jsx = __toESM(______components_downloadable_blocks_panel_index_jsx);
33
35
  // packages/block-directory/src/plugins/inserter-menu-downloadable-blocks-panel/index.jsx
34
36
  function InserterMenuDownloadableBlocksPanel() {
35
37
  const [debouncedFilterValue, setFilterValue] = (0, _wordpress_element.useState)("");
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["useState","debounce","__unstableInserterMenuExtension","DownloadableBlocksPanel"],"sources":["../../../src/plugins/inserter-menu-downloadable-blocks-panel/index.jsx"],"sourcesContent":["import { __unstableInserterMenuExtension } from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport DownloadableBlocksPanel from '../../components/downloadable-blocks-panel';\n\nfunction InserterMenuDownloadableBlocksPanel() {\n\tconst [ debouncedFilterValue, setFilterValue ] = useState( '' );\n\tconst debouncedSetFilterValue = debounce( setFilterValue, 400 );\n\n\treturn (\n\t\t<__unstableInserterMenuExtension>\n\t\t\t{ ( { onSelect, onHover, filterValue, hasItems } ) => {\n\t\t\t\tif ( debouncedFilterValue !== filterValue ) {\n\t\t\t\t\tdebouncedSetFilterValue( filterValue );\n\t\t\t\t}\n\n\t\t\t\tif ( ! debouncedFilterValue ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlocksPanel\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tfilterValue={ debouncedFilterValue }\n\t\t\t\t\t\thasLocalBlocks={ hasItems }\n\t\t\t\t\t\tisTyping={ filterValue !== debouncedFilterValue }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} }\n\t\t</__unstableInserterMenuExtension>\n\t);\n}\n\nexport default InserterMenuDownloadableBlocksPanel;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,sCAAsC;CAC9C,MAAM,CAAE,sBAAsB,mBAAA,GAAmBA,mBAAAA,SAAAA,CAAU,EAAG;CAC9D,MAAM,2BAAA,GAA0BC,mBAAAA,SAAAA,CAAU,gBAAgB,GAAI;CAE9D,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,iCAAD,EAAA,WACK,EAAE,UAAU,SAAS,aAAa,eAAgB;EACrD,IAAK,yBAAyB,aAC7B,wBAAyB,WAAY;EAGtC,IAAK,CAAE,sBACN,OAAO;EAGR,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,qDAAAA,SAAD;GACY;GACD;GACV,aAAc;GACd,gBAAiB;GACjB,UAAW,gBAAgB;EAC3B,CAAA;CAEH,EACgC,CAAA;AAEnC"}
1
+ {"version":3,"file":"index.cjs","names":["useState","debounce","__unstableInserterMenuExtension","DownloadableBlocksPanel"],"sources":["../../../src/plugins/inserter-menu-downloadable-blocks-panel/index.jsx"],"sourcesContent":["import { __unstableInserterMenuExtension } from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport DownloadableBlocksPanel from '../../components/downloadable-blocks-panel';\n\nfunction InserterMenuDownloadableBlocksPanel() {\n\tconst [ debouncedFilterValue, setFilterValue ] = useState( '' );\n\tconst debouncedSetFilterValue = debounce( setFilterValue, 400 );\n\n\treturn (\n\t\t<__unstableInserterMenuExtension>\n\t\t\t{ ( { onSelect, onHover, filterValue, hasItems } ) => {\n\t\t\t\tif ( debouncedFilterValue !== filterValue ) {\n\t\t\t\t\tdebouncedSetFilterValue( filterValue );\n\t\t\t\t}\n\n\t\t\t\tif ( ! debouncedFilterValue ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlocksPanel\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tfilterValue={ debouncedFilterValue }\n\t\t\t\t\t\thasLocalBlocks={ hasItems }\n\t\t\t\t\t\tisTyping={ filterValue !== debouncedFilterValue }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} }\n\t\t</__unstableInserterMenuExtension>\n\t);\n}\n\nexport default InserterMenuDownloadableBlocksPanel;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,sCAAsC;CAC9C,MAAM,CAAE,sBAAsB,mBAAA,GAAmBA,mBAAAA,SAAAA,CAAU,EAAG;CAC9D,MAAM,2BAAA,GAA0BC,mBAAAA,SAAAA,CAAU,gBAAgB,GAAI;CAE9D,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,iCAAD,EAAA,WACK,EAAE,UAAU,SAAS,aAAa,eAAgB;EACrD,IAAK,yBAAyB,aAC7B,wBAAyB,WAAY;EAGtC,IAAK,CAAE,sBACN,OAAO;EAGR,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,qDAAAA,SAAD;GACY;GACD;GACV,aAAc;GACd,gBAAiB;GACjB,UAAW,gBAAgB;EAC3B,CAAA;CAEH,EACgC,CAAA;AAEnC"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -28,19 +30,23 @@ let _wordpress_i18n = require("@wordpress/i18n");
28
30
  let _wordpress_data = require("@wordpress/data");
29
31
  let _wordpress_editor = require("@wordpress/editor");
30
32
  let ______components_compact_list_index_jsx = require("../../components/compact-list/index.cjs");
31
- ______components_compact_list_index_jsx = __toESM(______components_compact_list_index_jsx);
32
33
  let ______store_index_js = require("../../store/index.cjs");
33
34
  let react_jsx_runtime = require("react/jsx-runtime");
35
+ ______components_compact_list_index_jsx = __toESM(______components_compact_list_index_jsx);
34
36
  // packages/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.jsx
35
37
  function InstalledBlocksPrePublishPanel() {
36
38
  const newBlockTypes = (0, _wordpress_data.useSelect)((select) => select(______store_index_js.store).getNewBlockTypes(), []);
37
39
  if (!newBlockTypes.length) return null;
38
40
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_editor.PluginPrePublishPanel, {
39
- title: (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n._n)("Added: %d block", "Added: %d blocks", newBlockTypes.length), newBlockTypes.length),
41
+ title: (0, _wordpress_i18n.sprintf)(
42
+ /** translators: %d: number of blocks (number). */
43
+ (0, _wordpress_i18n._n)("Added: %d block", "Added: %d blocks", newBlockTypes.length),
44
+ newBlockTypes.length
45
+ ),
40
46
  initialOpen: true,
41
47
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
42
48
  className: "installed-blocks-pre-publish-panel__copy",
43
- children: (0, _wordpress_i18n._n)("The following block has been added to your site.", "The following blocks have been added to your site.", newBlockTypes.length)
49
+ children: newBlockTypes.length === 1 ? (0, _wordpress_i18n.__)("The following block has been added to your site.") : (0, _wordpress_i18n.__)("The following blocks have been added to your site.")
44
50
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(______components_compact_list_index_jsx.default, { items: newBlockTypes })]
45
51
  });
46
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["useSelect","blockDirectoryStore","PluginPrePublishPanel","sprintf","_n","CompactList"],"sources":["../../../src/plugins/installed-blocks-pre-publish-panel/index.jsx"],"sourcesContent":["import { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\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\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\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAwB,iCAAiC;CACxD,MAAM,iBAAA,GAAgBA,gBAAAA,UAAAA,EACnB,WAAY,OAAQC,qBAAAA,KAAoB,CAAC,CAAC,iBAAiB,GAC7D,CAAC,CACF;CAEA,IAAK,CAAE,cAAc,QACpB,OAAO;CAGR,OACC,iBAAA,GAAA,kBAAA,KAAA,CAACC,kBAAAA,uBAAD;EACC,QAAA,GAAQC,gBAAAA,QAAAA,EAAAA,GAEPC,gBAAAA,GAAAA,CACC,mBACA,oBACA,cAAc,MACf,GACA,cAAc,MACf;EACA,aAAA;EAVD,UAAA,CAYC,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;GAAG,WAAU;GACVA,WAAAA,GAAAA,gBAAAA,GAAAA,CACD,oDACA,sDACA,cAAc,MACf;EACE,CAAA,GACH,iBAAA,GAAA,kBAAA,IAAA,CAACC,wCAAAA,SAAD,EAAa,OAAQ,cAAiB,CAAA,CAChB;;AAEzB"}
1
+ {"version":3,"file":"index.cjs","names":["useSelect","blockDirectoryStore","PluginPrePublishPanel","sprintf","_n","__","CompactList"],"sources":["../../../src/plugins/installed-blocks-pre-publish-panel/index.jsx"],"sourcesContent":["import { __, _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\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\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\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ newBlockTypes.length === 1\n\t\t\t\t\t? __( 'The following block has been added to your site.' )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'The following blocks have been added to your site.'\n\t\t\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAwB,iCAAiC;CACxD,MAAM,iBAAA,GAAgBA,gBAAAA,UAAAA,EACnB,WAAY,OAAQC,qBAAAA,KAAoB,CAAC,CAAC,iBAAiB,GAC7D,CAAC,CACF;CAEA,IAAK,CAAE,cAAc,QACpB,OAAO;CAGR,OACC,iBAAA,GAAA,kBAAA,KAAA,CAACC,kBAAAA,uBAAD;EACC,QAAA,GAAQC,gBAAAA,QAAAA;;IAEPC,GAAAA,gBAAAA,GAAAA,CACC,mBACA,oBACA,cAAc,MACf;GACA,cAAc;EACf;EACA,aAAA;EAVD,UAAA,CAYC,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;GAAG,WAAU;GACV,UAAA,cAAc,WAAW,KAAA,GACxBC,gBAAAA,GAAAA,CAAI,kDAAmD,KAAA,GACvDA,gBAAAA,GAAAA,CACA,oDACD;EACA,CAAA,GACH,iBAAA,GAAA,kBAAA,IAAA,CAACC,wCAAAA,SAAD,EAAa,OAAQ,cAAiB,CAAA,CAChB;;AAEzB"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -27,11 +29,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
29
  let _wordpress_blocks = require("@wordpress/blocks");
28
30
  let _wordpress_i18n = require("@wordpress/i18n");
29
31
  let _wordpress_api_fetch = require("@wordpress/api-fetch");
30
- _wordpress_api_fetch = __toESM(_wordpress_api_fetch);
31
32
  let _wordpress_notices = require("@wordpress/notices");
32
33
  let _wordpress_url = require("@wordpress/url");
33
34
  let __load_assets_js = require("./load-assets.cjs");
34
35
  let __utils_get_plugin_url_js = require("./utils/get-plugin-url.cjs");
36
+ _wordpress_api_fetch = __toESM(_wordpress_api_fetch);
35
37
  __utils_get_plugin_url_js = __toESM(__utils_get_plugin_url_js);
36
38
  // packages/block-directory/src/store/actions.js
37
39
  /**
@@ -125,7 +127,11 @@ const installBlockType = (block) => async ({ registry, dispatch }) => {
125
127
  });
126
128
  await (0, __load_assets_js.loadAssets)();
127
129
  if (!registry.select(_wordpress_blocks.store).getBlockTypes().some((i) => i.name === name)) throw new Error((0, _wordpress_i18n.__)("Error registering block. Try reloading the page."));
128
- registry.dispatch(_wordpress_notices.store).createInfoNotice((0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Block %s installed and added."), block.title), {
130
+ registry.dispatch(_wordpress_notices.store).createInfoNotice((0, _wordpress_i18n.sprintf)(
131
+ /** translators: %s is the block title. */
132
+ (0, _wordpress_i18n.__)("Block %s installed and added."),
133
+ block.title
134
+ ), {
129
135
  speak: true,
130
136
  type: "snackbar"
131
137
  });
@@ -1 +1 @@
1
- {"version":3,"file":"actions.cjs","names":["getPluginUrl","apiFetch","addQueryArgs","loadAssets","blocksStore","__","noticesStore","sprintf"],"sources":["../../src/store/actions.js"],"sourcesContent":["import {\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';\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'ancestor',\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'selectors',\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\t'allowed_blocks',\n\t\t\t\t'block_hooks',\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,wBAAyB,aAAc;CACtD,OAAO;EAAE,MAAM;EAA6B;CAAY;AACzD;;;;;;;;;;AAWA,SAAgB,0BAA2B,oBAAoB,aAAc;CAC5E,OAAO;EACN,MAAM;EACN;EACA;CACD;AACD;;;;;;;;AASA,MAAa,oBACV,UACF,OAAQ,EAAE,UAAU,eAAgB;CACnC,MAAM,EAAE,IAAI,SAAS;CACrB,IAAI,UAAU;CACd,SAAS,iBAAkB,EAAG;CAC9B,IAAI;EACH,SAAS,gBAAiB,IAAI,IAAK;EAGnC,MAAM,OAAA,GAAMA,0BAAAA,QAAAA,CAAc,KAAM;EAChC,IAAI,QAAQ,CAAC;EACb,IAAK,KACJ,OAAA,GAAMC,qBAAAA,QAAAA,CAAU;GACf,QAAQ;GACR;GACA,MAAM,EAAE,QAAQ,SAAS;EAC1B,CAAE;OAQF,SAAQ,OAAA,GANeA,qBAAAA,QAAAA,CAAU;GAChC,QAAQ;GACR,MAAM;GACN,MAAM;IAAE,MAAM;IAAI,QAAQ;GAAS;EACpC,CAAE,EAAA,CAEe;EAGlB,SAAS,sBAAuB;GAC/B,GAAG;GACH,OAAO;IAAE,GAAG,MAAM;IAAO,GAAG;GAAM;EACnC,CAAE;EAGF,MAAM,iBAAiB;GACtB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACD;EACA,OAAA,GAAMA,qBAAAA,QAAAA,CAAU,EACf,OAAA,GAAMC,eAAAA,aAAAA,CAAc,sBAAuB,QAAS,EACnD,SAAS,eACV,CAAE,EACH,CAAE,CAAC,CAED,YAAa,CAAC,CAAE,CAAC,CACjB,MAAQ,aAAc;GACtB,IAAK,CAAE,UACN;GAED,CAAA,GAAA,kBAAA,8CAAA,CAA+C,GAC5C,OAAQ,OAAO,YAChB,OAAO,QAAS,QAAS,CAAC,CAAC,QAAU,CAAE,SACtC,eAAe,SAAU,GAAI,CAC9B,CACD,EACD,CAAE;EACH,CAAE;EAEH,OAAA,GAAMC,iBAAAA,WAAAA,CAAW;EAIjB,IAAK,CAHoB,SACvB,OAAQC,kBAAAA,KAAY,CAAC,CACrB,cACoB,CAAC,CAAC,MAAQ,MAAO,EAAE,SAAS,IAAK,GACtD,MAAM,IAAI,OAAA,GACTC,gBAAAA,GAAAA,CAAI,kDAAmD,CACxD;EAGD,SAAS,SAAUC,mBAAAA,KAAa,CAAC,CAAC,kBAAA,GACjCC,gBAAAA,QAAAA,EAAAA,GAECF,gBAAAA,GAAAA,CAAI,+BAAgC,GACpC,MAAM,KACP,GACA;GACC,OAAO;GACP,MAAM;EACP,CACD;EACA,UAAU;CACX,SAAU,OAAQ;EACjB,IAAI,UAAU,MAAM,YAAA,GAAWA,gBAAAA,GAAAA,CAAI,oBAAqB;EAGxD,IAAI,UAAU,iBAAiB;EAG/B,MAAM,iBAAiB;GACtB,gBAAA,GAAeA,gBAAAA,GAAAA,CACd,0DACD;GACA,kCAAA,GAAiCA,gBAAAA,GAAAA,CAChC,gEACD;EACD;EAEA,IAAK,eAAgB,MAAM,OAAS;GACnC,UAAU;GACV,UAAU,eAAgB,MAAM;EACjC;EAEA,SAAS,eAAgB,IAAI,SAAS,OAAQ;EAC9C,SAAS,SAAUC,mBAAAA,KAAa,CAAC,CAAC,kBAAmB,SAAS;GAC7D,OAAO;GACP,eAAe;EAChB,CAAE;CACH;CACA,SAAS,gBAAiB,IAAI,KAAM;CACpC,OAAO;AACR;;;;;;AAOD,MAAa,sBACV,UACF,OAAQ,EAAE,UAAU,eAAgB;CACnC,IAAI;EACH,MAAM,OAAA,GAAMN,0BAAAA,QAAAA,CAAc,KAAM;EAChC,OAAA,GAAMC,qBAAAA,QAAAA,CAAU;GACf,QAAQ;GACR;GACA,MAAM,EAAE,QAAQ,WAAW;EAC5B,CAAE;EACF,OAAA,GAAMA,qBAAAA,QAAAA,CAAU;GACf,QAAQ;GACR;EACD,CAAE;EACF,SAAS,yBAA0B,KAAM;CAC1C,SAAU,OAAQ;EACjB,SACE,SAAUK,mBAAAA,KAAa,CAAC,CACxB,kBACA,MAAM,YAAA,GAAWD,gBAAAA,GAAAA,CAAI,oBAAqB,CAC3C;CACF;AACD;;;;;;;;;AAUD,SAAgB,sBAAuB,MAAO;CAC7C,OAAO;EACN,MAAM;EACN;CACD;AACD;;;;;;;;;AAUA,SAAgB,yBAA0B,MAAO;CAChD,OAAO;EACN,MAAM;EACN;CACD;AACD;;;;;;;;;AAUA,SAAgB,gBAAiB,SAAS,cAAe;CACxD,OAAO;EACN,MAAM;EACN;EACA;CACD;AACD;;;;;;;;;;AAWA,SAAgB,eAAgB,SAAS,SAAS,UAAU,OAAQ;CACnE,OAAO;EACN,MAAM;EACN;EACA;EACA;CACD;AACD;;;;;;;;AASA,SAAgB,iBAAkB,SAAU;CAC3C,OAAO;EACN,MAAM;EACN;CACD;AACD"}
1
+ {"version":3,"file":"actions.cjs","names":["getPluginUrl","apiFetch","addQueryArgs","unstable__bootstrapServerSideBlockDefinitions","loadAssets","blocksStore","__","noticesStore","sprintf"],"sources":["../../src/store/actions.js"],"sourcesContent":["import {\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';\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'ancestor',\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'selectors',\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\t'allowed_blocks',\n\t\t\t\t'block_hooks',\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"],"mappings":"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"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -26,12 +28,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
28
  }) : target, mod));
27
29
  let _wordpress_data = require("@wordpress/data");
28
30
  let __reducer_js = require("./reducer.cjs");
29
- __reducer_js = __toESM(__reducer_js);
30
31
  let __selectors_js = require("./selectors.cjs");
31
- __selectors_js = __toESM(__selectors_js);
32
32
  let __actions_js = require("./actions.cjs");
33
- __actions_js = __toESM(__actions_js);
34
33
  let __resolvers_js = require("./resolvers.cjs");
34
+ __reducer_js = __toESM(__reducer_js);
35
+ __selectors_js = __toESM(__selectors_js);
36
+ __actions_js = __toESM(__actions_js);
35
37
  __resolvers_js = __toESM(__resolvers_js);
36
38
  // packages/block-directory/src/store/index.js
37
39
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["createReduxStore","register"],"sources":["../../src/store/index.js"],"sourcesContent":["import { createReduxStore, register } from '@wordpress/data';\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as resolvers from './resolvers';\n\n/**\n * Module Constants\n */\nconst STORE_NAME = 'core/block-directory';\n\n/**\n * Block editor data store configuration.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore\n *\n * @type {Object}\n */\nexport const storeConfig = {\n\treducer,\n\tselectors,\n\tactions,\n\tresolvers,\n};\n\n/**\n * Store definition for the block directory namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig );\n\nregister( store );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,aAAa;;;;;;;;AASnB,MAAa,cAAc;CAC1B,SAAA,aAAA;CACA,WAAA;CACA,SAAA;CACA,WAAA;AACD;;;;;;;;AASA,MAAa,SAAA,GAAQA,gBAAAA,iBAAAA,CAAkB,YAAY,WAAY;CAE/DC,GAAAA,gBAAAA,SAAAA,CAAU,KAAM"}
1
+ {"version":3,"file":"index.cjs","names":["reducer","selectors","actions","resolvers","createReduxStore","register"],"sources":["../../src/store/index.js"],"sourcesContent":["import { createReduxStore, register } from '@wordpress/data';\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as resolvers from './resolvers';\n\n/**\n * Module Constants\n */\nconst STORE_NAME = 'core/block-directory';\n\n/**\n * Block editor data store configuration.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore\n *\n * @type {Object}\n */\nexport const storeConfig = {\n\treducer,\n\tselectors,\n\tactions,\n\tresolvers,\n};\n\n/**\n * Store definition for the block directory namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig );\n\nregister( store );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,aAAa;;;;;;;;AASnB,MAAa,cAAc;CAC1BA,SAAAA,aAAAA;CACAC,WAAAA;CACAC,SAAAA;CACAC,WAAAA;AACD;;;;;;;;AASA,MAAa,SAAA,GAAQC,gBAAAA,iBAAAA,CAAkB,YAAY,WAAY;CAE/DC,GAAAA,gBAAAA,SAAAA,CAAU,KAAM"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -1 +1 @@
1
- {"version":3,"file":"load-assets.cjs","names":["apiFetch"],"sources":["../../src/store/load-assets.js"],"sourcesContent":["import apiFetch from '@wordpress/api-fetch';\n\n/**\n * Load an asset for a block.\n *\n * This function returns a Promise that will resolve once the asset is loaded,\n * or in the case of Stylesheets and Inline JavaScript, will resolve immediately.\n *\n * @param {HTMLElement} el A HTML Element asset to inject.\n *\n * @return {Promise} Promise which will resolve when the asset is loaded.\n */\nexport const loadAsset = ( el ) => {\n\treturn new Promise( ( resolve, reject ) => {\n\t\t/*\n\t\t * Reconstruct the passed element, this is required as inserting the Node directly\n\t\t * won't always fire the required onload events, even if the asset wasn't already loaded.\n\t\t */\n\t\tconst newNode = document.createElement( el.nodeName );\n\n\t\t[ 'id', 'rel', 'src', 'href', 'type' ].forEach( ( attr ) => {\n\t\t\tif ( el[ attr ] ) {\n\t\t\t\tnewNode[ attr ] = el[ attr ];\n\t\t\t}\n\t\t} );\n\n\t\t// Append inline <script> contents.\n\t\tif ( el.innerHTML ) {\n\t\t\tnewNode.appendChild( document.createTextNode( el.innerHTML ) );\n\t\t}\n\n\t\tnewNode.onload = () => resolve( true );\n\t\tnewNode.onerror = () => reject( new Error( 'Error loading asset.' ) );\n\n\t\tdocument.body.appendChild( newNode );\n\n\t\t// Resolve Stylesheets and Inline JavaScript immediately.\n\t\tif (\n\t\t\t'link' === newNode.nodeName.toLowerCase() ||\n\t\t\t( 'script' === newNode.nodeName.toLowerCase() && ! newNode.src )\n\t\t) {\n\t\t\tresolve();\n\t\t}\n\t} );\n};\n\n/**\n * Load the asset files for a block\n */\nexport async function loadAssets() {\n\t/*\n\t * Fetch the current URL (post-new.php, or post.php?post=1&action=edit) and compare the\n\t * JavaScript and CSS assets loaded between the pages. This imports the required assets\n\t * for the block into the current page while not requiring that we know them up-front.\n\t * In the future this can be improved by reliance upon block.json and/or a script-loader\n\t * dependency API.\n\t */\n\tconst response = await apiFetch( {\n\t\turl: document.location.href,\n\t\tparse: false,\n\t} );\n\n\tconst data = await response.text();\n\n\tconst doc = new window.DOMParser().parseFromString( data, 'text/html' );\n\n\tconst newAssets = Array.from(\n\t\tdoc.querySelectorAll( 'link[rel=\"stylesheet\"],script' )\n\t).filter( ( asset ) => asset.id && ! document.getElementById( asset.id ) );\n\n\t/*\n\t * Load each asset in order, as they may depend upon an earlier loaded script.\n\t * Stylesheets and Inline Scripts will resolve immediately upon insertion.\n\t */\n\tfor ( const newAsset of newAssets ) {\n\t\tawait loadAsset( newAsset );\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAa,aAAc,OAAQ;CAClC,OAAO,IAAI,SAAW,SAAS,WAAY;EAK1C,MAAM,UAAU,SAAS,cAAe,GAAG,QAAS;EAEpD;GAAE;GAAM;GAAO;GAAO;GAAQ;EAAO,CAAC,CAAC,SAAW,SAAU;GAC3D,IAAK,GAAI,OACR,QAAS,QAAS,GAAI;EAExB,CAAE;EAGF,IAAK,GAAG,WACP,QAAQ,YAAa,SAAS,eAAgB,GAAG,SAAU,CAAE;EAG9D,QAAQ,eAAe,QAAS,IAAK;EACrC,QAAQ,gBAAgB,uBAAQ,IAAI,MAAO,sBAAuB,CAAE;EAEpE,SAAS,KAAK,YAAa,OAAQ;EAGnC,IACC,WAAW,QAAQ,SAAS,YAAY,KACtC,aAAa,QAAQ,SAAS,YAAY,KAAK,CAAE,QAAQ,KAE3D,QAAQ;CAEV,CAAE;AACH;;;;AAKA,eAAsB,aAAa;CAalC,MAAM,OAAO,OAAM,OAAA,GALIA,qBAAAA,QAAAA,CAAU;EAChC,KAAK,SAAS,SAAS;EACvB,OAAO;CACR,CAAE,EAAA,CAE0B,KAAK;CAEjC,MAAM,MAAM,IAAI,OAAO,UAAU,CAAC,CAAC,gBAAiB,MAAM,WAAY;CAEtE,MAAM,YAAY,MAAM,KACvB,IAAI,iBAAkB,iCAAgC,CACvD,CAAC,CAAC,QAAU,UAAW,MAAM,MAAM,CAAE,SAAS,eAAgB,MAAM,EAAG,CAAE;CAMzE,KAAM,MAAM,YAAY,WACvB,MAAM,UAAW,QAAS;AAE5B"}
1
+ {"version":3,"file":"load-assets.cjs","names":["apiFetch"],"sources":["../../src/store/load-assets.js"],"sourcesContent":["import apiFetch from '@wordpress/api-fetch';\n\n/**\n * Load an asset for a block.\n *\n * This function returns a Promise that will resolve once the asset is loaded,\n * or in the case of Stylesheets and Inline JavaScript, will resolve immediately.\n *\n * @param {HTMLElement} el A HTML Element asset to inject.\n *\n * @return {Promise} Promise which will resolve when the asset is loaded.\n */\nexport const loadAsset = ( el ) => {\n\treturn new Promise( ( resolve, reject ) => {\n\t\t/*\n\t\t * Reconstruct the passed element, this is required as inserting the Node directly\n\t\t * won't always fire the required onload events, even if the asset wasn't already loaded.\n\t\t */\n\t\tconst newNode = document.createElement( el.nodeName );\n\n\t\t[ 'id', 'rel', 'src', 'href', 'type' ].forEach( ( attr ) => {\n\t\t\tif ( el[ attr ] ) {\n\t\t\t\tnewNode[ attr ] = el[ attr ];\n\t\t\t}\n\t\t} );\n\n\t\t// Append inline <script> contents.\n\t\tif ( el.innerHTML ) {\n\t\t\tnewNode.appendChild( document.createTextNode( el.innerHTML ) );\n\t\t}\n\n\t\tnewNode.onload = () => resolve( true );\n\t\tnewNode.onerror = () => reject( new Error( 'Error loading asset.' ) );\n\n\t\tdocument.body.appendChild( newNode );\n\n\t\t// Resolve Stylesheets and Inline JavaScript immediately.\n\t\tif (\n\t\t\t'link' === newNode.nodeName.toLowerCase() ||\n\t\t\t( 'script' === newNode.nodeName.toLowerCase() && ! newNode.src )\n\t\t) {\n\t\t\tresolve();\n\t\t}\n\t} );\n};\n\n/**\n * Load the asset files for a block\n */\nexport async function loadAssets() {\n\t/*\n\t * Fetch the current URL (post-new.php, or post.php?post=1&action=edit) and compare the\n\t * JavaScript and CSS assets loaded between the pages. This imports the required assets\n\t * for the block into the current page while not requiring that we know them up-front.\n\t * In the future this can be improved by reliance upon block.json and/or a script-loader\n\t * dependency API.\n\t */\n\tconst response = await apiFetch( {\n\t\turl: document.location.href,\n\t\tparse: false,\n\t} );\n\n\tconst data = await response.text();\n\n\tconst doc = new window.DOMParser().parseFromString( data, 'text/html' );\n\n\tconst newAssets = Array.from(\n\t\tdoc.querySelectorAll( 'link[rel=\"stylesheet\"],script' )\n\t).filter( ( asset ) => asset.id && ! document.getElementById( asset.id ) );\n\n\t/*\n\t * Load each asset in order, as they may depend upon an earlier loaded script.\n\t * Stylesheets and Inline Scripts will resolve immediately upon insertion.\n\t */\n\tfor ( const newAsset of newAssets ) {\n\t\tawait loadAsset( newAsset );\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAa,aAAc,OAAQ;CAClC,OAAO,IAAI,SAAW,SAAS,WAAY;EAK1C,MAAM,UAAU,SAAS,cAAe,GAAG,QAAS;EAEpD;GAAE;GAAM;GAAO;GAAO;GAAQ;EAAO,CAAC,CAAC,SAAW,SAAU;GAC3D,IAAK,GAAI,OACR,QAAS,QAAS,GAAI;EAExB,CAAE;EAGF,IAAK,GAAG,WACP,QAAQ,YAAa,SAAS,eAAgB,GAAG,SAAU,CAAE;EAG9D,QAAQ,eAAe,QAAS,IAAK;EACrC,QAAQ,gBAAgB,uBAAQ,IAAI,MAAO,sBAAuB,CAAE;EAEpE,SAAS,KAAK,YAAa,OAAQ;EAGnC,IACC,WAAW,QAAQ,SAAS,YAAY,KACtC,aAAa,QAAQ,SAAS,YAAY,KAAK,CAAE,QAAQ,KAE3D,QAAQ;CAEV,CAAE;AACH;;;;AAKA,eAAsB,aAAa;CAalC,MAAM,OAAO,OAAM,OAAA,GALIA,qBAAAA,QAAAA,CAAU;EAChC,KAAK,SAAS,SAAS;EACvB,OAAO;CACR,CAAE,EAAA,CAE0B,KAAK;CAEjC,MAAM,MAAM,IAAI,OAAO,UAAU,CAAC,CAAC,gBAAiB,MAAM,WAAY;CAEtE,MAAM,YAAY,MAAM,KACvB,IAAI,iBAAkB,iCAAgC,CACvD,CAAC,CAAC,QAAU,UAAW,MAAM,MAAM,CAAE,SAAS,eAAgB,MAAM,EAAG,CAAE;CAMzE,KAAM,MAAM,YAAY,WACvB,MAAM,UAAW,QAAS;AAE5B"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -26,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
28
  }) : target, mod));
27
29
  let change_case = require("change-case");
28
30
  let _wordpress_api_fetch = require("@wordpress/api-fetch");
29
- _wordpress_api_fetch = __toESM(_wordpress_api_fetch);
30
31
  let __actions_js = require("./actions.cjs");
32
+ _wordpress_api_fetch = __toESM(_wordpress_api_fetch);
31
33
  // packages/block-directory/src/store/resolvers.js
32
34
  const getDownloadableBlocks = (filterValue) => async ({ dispatch }) => {
33
35
  if (!filterValue) return;
@@ -1 +1 @@
1
- {"version":3,"file":"resolvers.cjs","names":["fetchDownloadableBlocks","apiFetch","camelCase","receiveDownloadableBlocks"],"sources":["../../src/store/resolvers.js"],"sourcesContent":["import { camelCase } from 'change-case';\nimport apiFetch from '@wordpress/api-fetch';\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\t\tdispatch( receiveDownloadableBlocks( [], filterValue ) );\n\t\t}\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAa,yBACV,gBACF,OAAQ,EAAE,eAAgB;CACzB,IAAK,CAAE,aACN;CAGD,IAAI;EACH,UAAA,GAAUA,aAAAA,wBAAAA,CAAyB,WAAY,CAAE;EAIjD,MAAM,UAAS,OAAA,GAHOC,qBAAAA,QAAAA,CAAU,EAC/B,MAAM,qCAAsC,cAC7C,CAAE,EAAA,CACqB,KAAO,WAC7B,OAAO,YACN,OAAO,QAAS,MAAO,CAAC,CAAC,KAAO,CAAE,KAAK,WAAa,EAAA,GACnDC,YAAAA,UAAAA,CAAW,GAAI,GACf,KACD,CAAE,CACH,CACD;EAEA,UAAA,GAAUC,aAAAA,0BAAAA,CAA2B,QAAQ,WAAY,CAAE;CAC5D,QAAQ;EACP,UAAA,GAAUA,aAAAA,0BAAAA,CAA2B,CAAC,GAAG,WAAY,CAAE;CACxD;AACD"}
1
+ {"version":3,"file":"resolvers.cjs","names":["fetchDownloadableBlocks","apiFetch","camelCase","receiveDownloadableBlocks"],"sources":["../../src/store/resolvers.js"],"sourcesContent":["import { camelCase } from 'change-case';\nimport apiFetch from '@wordpress/api-fetch';\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\t\tdispatch( receiveDownloadableBlocks( [], filterValue ) );\n\t\t}\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAa,yBACV,gBACF,OAAQ,EAAE,eAAgB;CACzB,IAAK,CAAE,aACN;CAGD,IAAI;EACH,UAAA,GAAUA,aAAAA,wBAAAA,CAAyB,WAAY,CAAE;EAIjD,MAAM,UAAS,OAAA,GAHOC,qBAAAA,QAAAA,CAAU,EAC/B,MAAM,qCAAsC,cAC7C,CAAE,EAAA,CACqB,KAAO,WAC7B,OAAO,YACN,OAAO,QAAS,MAAO,CAAC,CAAC,KAAO,CAAE,KAAK,WAAa,EAAA,GACnDC,YAAAA,UAAAA,CAAW,GAAI,GACf,KACD,CAAE,CACH,CACD;EAEA,UAAA,GAAUC,aAAAA,0BAAAA,CAA2B,QAAQ,WAAY,CAAE;CAC5D,QAAQ;EACP,UAAA,GAAUA,aAAAA,0BAAAA,CAA2B,CAAC,GAAG,WAAY,CAAE;CACxD;AACD"}
@@ -8,7 +8,11 @@ function Stars({ rating }) {
8
8
  const halfStarCount = Math.ceil(rating - fullStarCount);
9
9
  const emptyStarCount = 5 - (fullStarCount + halfStarCount);
10
10
  return /* @__PURE__ */ jsxs("span", {
11
- "aria-label": sprintf(__("%s out of 5 stars"), stars),
11
+ "aria-label": sprintf(
12
+ /** translators: %s: number of stars. */
13
+ __("%s out of 5 stars"),
14
+ stars
15
+ ),
12
16
  children: [
13
17
  Array.from({ length: fullStarCount }).map((_, i) => /* @__PURE__ */ jsx(Icon, {
14
18
  className: "block-directory-block-ratings__star-full",
@@ -1 +1 @@
1
- {"version":3,"file":"stars.mjs","names":[],"sources":["../../../src/components/block-ratings/stars.jsx"],"sourcesContent":["import { __, 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"],"mappings":";;;;AAGA,SAAS,MAAO,EAAE,UAAW;CAC5B,MAAM,QAAQ,KAAK,MAAO,SAAS,EAAI,IAAI;CAE3C,MAAM,gBAAgB,KAAK,MAAO,MAAO;CACzC,MAAM,gBAAgB,KAAK,KAAM,SAAS,aAAc;CACxD,MAAM,iBAAiB,KAAM,gBAAgB;CAE7C,OACC,qBAAC,QAAD;EACC,cAAa,QAEZ,GAAI,mBAAoB,GACxB,KACD;EALD,UAAA;GAOG,MAAM,KAAM,EAAE,QAAQ,cAAc,CAAE,CAAC,CAAC,KAAO,GAAG,MACnD,oBAAC,MAAD;IAEC,WAAU;IACV,MAAO;IACP,MAAO;GACP,GAJM,cAAe,GAIrB,CACA;GACA,MAAM,KAAM,EAAE,QAAQ,cAAc,CAAE,CAAC,CAAC,KAAO,GAAG,MACnD,oBAAC,MAAD;IAEC,WAAU;IACV,MAAO;IACP,MAAO;GACP,GAJM,cAAe,GAIrB,CACA;GACA,MAAM,KAAM,EAAE,QAAQ,eAAe,CAAE,CAAC,CAAC,KAAO,GAAG,MACpD,oBAAC,MAAD;IAEC,WAAU;IACV,MAAO;IACP,MAAO;GACP,GAJM,eAAgB,GAItB,CACA;EACG;;AAER"}
1
+ {"version":3,"file":"stars.mjs","names":[],"sources":["../../../src/components/block-ratings/stars.jsx"],"sourcesContent":["import { __, 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"],"mappings":";;;;AAGA,SAAS,MAAO,EAAE,UAAW;CAC5B,MAAM,QAAQ,KAAK,MAAO,SAAS,EAAI,IAAI;CAE3C,MAAM,gBAAgB,KAAK,MAAO,MAAO;CACzC,MAAM,gBAAgB,KAAK,KAAM,SAAS,aAAc;CACxD,MAAM,iBAAiB,KAAM,gBAAgB;CAE7C,OACC,qBAAC,QAAD;EACC,cAAa;;GAEZ,GAAI,mBAAoB;GACxB;EACD;EALD,UAAA;GAOG,MAAM,KAAM,EAAE,QAAQ,cAAc,CAAE,CAAC,CAAC,KAAO,GAAG,MACnD,oBAAC,MAAD;IAEC,WAAU;IACV,MAAO;IACP,MAAO;GACP,GAJM,cAAe,GAIrB,CACA;GACA,MAAM,KAAM,EAAE,QAAQ,cAAc,CAAE,CAAC,CAAC,KAAO,GAAG,MACnD,oBAAC,MAAD;IAEC,WAAU;IACV,MAAO;IACP,MAAO;GACP,GAJM,cAAe,GAIrB,CACA;GACA,MAAM,KAAM,EAAE,QAAQ,eAAe,CAAE,CAAC,CAAC,KAAO,GAAG,MACpD,oBAAC,MAAD;IAEC,WAAU;IACV,MAAO;IACP,MAAO;GACP,GAJM,eAAgB,GAItB,CACA;EACG;;AAER"}
@@ -18,7 +18,11 @@ function CompactList({ items }) {
18
18
  children: title
19
19
  }), /* @__PURE__ */ jsx("div", {
20
20
  className: "block-directory-compact-list__item-author",
21
- children: sprintf(__("By %s"), author)
21
+ children: sprintf(
22
+ /** translators: %s: Name of the block author. */
23
+ __("By %s"),
24
+ author
25
+ )
22
26
  })]
23
27
  })]
24
28
  }, id))
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/compact-list/index.jsx"],"sourcesContent":["import { __, sprintf } from '@wordpress/i18n';\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"],"mappings":";;;;AAGA,SAAwB,YAAa,EAAE,SAAU;CAChD,IAAK,CAAE,MAAM,QACZ,OAAO;CAGR,OACC,oBAAC,MAAD;EAAI,WAAU;EACX,UAAA,MAAM,KAAO,EAAE,MAAM,IAAI,OAAO,aACjC,qBAAC,MAAD;GAAe,WAAU;GAAzB,UAAA,CACC,oBAAC,uBAAD;IAA8B;IAAe;GAAS,CAAA,GAEtD,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACC,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA;IACE,CAAA,GACL,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA,QAED,GAAI,OAAQ,GACZ,MACD;IACI,CAAA,CACD;GACF,CAAA,CAAA;EAfM,GAAA,EAeN,CACH;CACC,CAAA;AAEN"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/compact-list/index.jsx"],"sourcesContent":["import { __, sprintf } from '@wordpress/i18n';\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"],"mappings":";;;;AAGA,SAAwB,YAAa,EAAE,SAAU;CAChD,IAAK,CAAE,MAAM,QACZ,OAAO;CAGR,OACC,oBAAC,MAAD;EAAI,WAAU;EACX,UAAA,MAAM,KAAO,EAAE,MAAM,IAAI,OAAO,aACjC,qBAAC,MAAD;GAAe,WAAU;GAAzB,UAAA,CACC,oBAAC,uBAAD;IAA8B;IAAe;GAAS,CAAA,GAEtD,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACC,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA;IACE,CAAA,GACL,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA;;MAED,GAAI,OAAQ;MACZ;KACD;IACI,CAAA,CACD;GACF,CAAA,CAAA;EAfM,GAAA,EAeN,CACH;CACC,CAAA;AAEN"}
@@ -14,11 +14,33 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
14
14
  // packages/block-directory/src/components/downloadable-block-list-item/index.jsx
15
15
  function getDownloadableBlockLabel({ title, rating, ratingCount }, { hasNotice, isInstalled, isInstalling }) {
16
16
  const stars = Math.round(rating / .5) * .5;
17
- if (!isInstalled && hasNotice) return sprintf(__("Retry installing %s."), decodeEntities(title));
18
- if (isInstalled) return sprintf(__("Add %s."), decodeEntities(title));
19
- if (isInstalling) return sprintf(__("Installing %s."), decodeEntities(title));
20
- if (ratingCount < 1) return sprintf(__("Install %s."), decodeEntities(title));
21
- return sprintf(_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);
17
+ if (!isInstalled && hasNotice) return sprintf(
18
+ /** translators: %s: block title */
19
+ __("Retry installing %s."),
20
+ decodeEntities(title)
21
+ );
22
+ if (isInstalled) return sprintf(
23
+ /** translators: %s: block title */
24
+ __("Add %s."),
25
+ decodeEntities(title)
26
+ );
27
+ if (isInstalling) return sprintf(
28
+ /** translators: %s: block title */
29
+ __("Installing %s."),
30
+ decodeEntities(title)
31
+ );
32
+ if (ratingCount < 1) return sprintf(
33
+ /** translators: %s: block title */
34
+ __("Install %s."),
35
+ decodeEntities(title)
36
+ );
37
+ return sprintf(
38
+ /** translators: 1: block title, 2: average rating, 3: total ratings count. */
39
+ _n("Install %1$s. %2$s stars with %3$s review.", "Install %1$s. %2$s stars with %3$s reviews.", ratingCount),
40
+ decodeEntities(title),
41
+ stars,
42
+ ratingCount
43
+ );
22
44
  }
23
45
  function DownloadableBlockListItem({ item, onClick }) {
24
46
  const { author, description, icon, rating, title } = item;
@@ -65,7 +87,12 @@ function DownloadableBlockListItem({ item, onClick }) {
65
87
  className: "block-directory-downloadable-block-list-item__details",
66
88
  children: [/* @__PURE__ */ jsx("span", {
67
89
  className: "block-directory-downloadable-block-list-item__title",
68
- children: createInterpolateElement(sprintf(__("%1$s <span>by %2$s</span>"), decodeEntities(title), author), { span: /* @__PURE__ */ jsx("span", { className: "block-directory-downloadable-block-list-item__author" }) })
90
+ children: createInterpolateElement(sprintf(
91
+ /** translators: 1: block title. 2: author name. */
92
+ __("%1$s <span>by %2$s</span>"),
93
+ decodeEntities(title),
94
+ author
95
+ ), { span: /* @__PURE__ */ jsx("span", { className: "block-directory-downloadable-block-list-item__author" }) })
69
96
  }), hasNotice ? /* @__PURE__ */ jsx(DownloadableBlockNotice, { block: item }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
70
97
  className: "block-directory-downloadable-block-list-item__desc",
71
98
  children: !!statusText ? statusText : decodeEntities(description)
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["blockDirectoryStore","WCSpinner"],"sources":["../../../src/components/downloadable-block-list-item/index.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { Spinner as WCSpinner, Composite } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { VisuallyHidden, Tooltip } from '@wordpress/ui';\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\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Retry installing %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\tif ( isInstalled ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Add %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\tif ( isInstalling ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Installing %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Install %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\treturn sprintf(\n\t\t/* translators: 1: block title, 2: average rating, 3: 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( { 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\tconst itemLabel = getDownloadableBlockLabel( item, {\n\t\thasNotice,\n\t\tisInstalled,\n\t\tisInstalling,\n\t} );\n\n\treturn (\n\t\t<Tooltip.Root>\n\t\t\t<Tooltip.Trigger\n\t\t\t\trender={\n\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-directory-downloadable-block-list-item',\n\t\t\t\t\t\t\tisInstalling && 'is-installing'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tonClick();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\taria-label={ itemLabel }\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t\t\t\t<DownloadableBlockIcon\n\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t\t\t\t<WCSpinner />\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: 1: block title. 2: author name. */\n\t\t\t\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tspan: (\n\t\t\t\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\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Composite.Item>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Tooltip.Popup>{ itemLabel }</Tooltip.Popup>\n\t\t</Tooltip.Root>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,0BACR,EAAE,OAAO,QAAQ,eACjB,EAAE,WAAW,aAAa,gBACzB;CACD,MAAM,QAAQ,KAAK,MAAO,SAAS,EAAI,IAAI;CAE3C,IAAK,CAAE,eAAe,WACrB,OAAO,QAEN,GAAI,sBAAuB,GAC3B,eAAgB,KAAM,CACvB;CAGD,IAAK,aACJ,OAAO,QAEN,GAAI,SAAU,GACd,eAAgB,KAAM,CACvB;CAGD,IAAK,cACJ,OAAO,QAEN,GAAI,gBAAiB,GACrB,eAAgB,KAAM,CACvB;CAID,IAAK,cAAc,GAClB,OAAO,QAEN,GAAI,aAAc,GAClB,eAAgB,KAAM,CACvB;CAGD,OAAO,QAEN,GACC,8CACA,+CACA,WACD,GACA,eAAgB,KAAM,GACtB,OACA,WACD;AACD;AAEA,SAAS,0BAA2B,EAAE,MAAM,WAAY;CACvD,MAAM,EAAE,QAAQ,aAAa,MAAM,QAAQ,UAAU;CAErD,MAAM,cAAc,CAAC,CAAE,aAAc,KAAK,IAAK;CAE/C,MAAM,EAAE,WAAW,cAAc,kBAAkB,WAChD,WAAY;EACb,MAAM,EAAE,wBAAwB,cAAc,sBAC7C,OAAQA,KAAoB;EAC7B,MAAM,SAAS,uBAAwB,KAAK,EAAG;EAC/C,MAAM,WAAW,UAAU,OAAO;EAClC,OAAO;GACN,WAAW,CAAC,CAAE;GACd,cAAc,kBAAmB,KAAK,EAAG;GACzC,eAAe,CAAE;EAClB;CACD,GACA,CAAE,IAAK,CACR;CAEA,IAAI,aAAa;CACjB,IAAK,aACJ,aAAa,GAAI,YAAa;MACxB,IAAK,cACX,aAAa,GAAI,aAAc;CAGhC,MAAM,YAAY,0BAA2B,MAAM;EAClD;EACA;EACA;CACD,CAAE;CAEF,OACC,qBAAC,QAAQ,MAAT,EAAA,UAAA,CACC,oBAAC,QAAQ,SAAT,EACC,QACC,qBAAC,UAAU,MAAX;EACC,WAAY,KACX,gDACA,gBAAgB,eACjB;EACA,wBAAA;EACA,UAAW,gBAAgB,CAAE;EAC7B,UAAY,UAAW;GACtB,MAAM,eAAe;GACrB,QAAQ;EACT;EACA,cAAa;EACb,MAAK;EACL,MAAK;EAbN,UAAA,CAeC,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACC,oBAAC,uBAAD;IACQ;IACC;GACR,CAAA,GACC,eACD,oBAAC,QAAD;IAAM,WAAU;IACf,UAAA,oBAACC,SAAD,CAAY,CAAA;GACP,CAAA,IAEN,oBAAC,cAAD,EAAuB,OAAU,CAAA,CAE9B;EACL,CAAA,GAAA,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACC,oBAAC,QAAD;IAAM,WAAU;IACb,UAAA,yBACD,QAEC,GAAI,2BAA4B,GAChC,eAAgB,KAAM,GACtB,MACD,GACA,EACC,MACC,oBAAC,QAAD,EAAM,WAAU,uDAAwD,CAAA,EAE1E,CACD;GACK,CAAA,GACJ,YACD,oBAAC,yBAAD,EAAyB,OAAQ,KAAQ,CAAA,IAEzC,qBAAA,UAAA,EAAA,UAAA,CACC,oBAAC,QAAD;IAAM,WAAU;IACb,UAAA,CAAC,CAAE,aACF,aACA,eAAgB,WAAY;GAC1B,CAAA,GACJ,iBACD,EAAI,eAAe,iBAClB,oBAAC,gBAAD,EAAA,UACG,GAAI,eAAgB,EACP,CAAA,CAEjB,EAAA,CAAA,CAEE;EACS,CAAA,CAAA;CAEjB,CAAA,EAAA,CAAA,GACD,oBAAC,QAAQ,OAAT,EAAA,UAAiB,UAA0B,CAAA,CAC9B,EAAA,CAAA;AAEhB"}
1
+ {"version":3,"file":"index.mjs","names":["blockDirectoryStore","WCSpinner"],"sources":["../../../src/components/downloadable-block-list-item/index.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { Spinner as WCSpinner, Composite } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { VisuallyHidden, Tooltip } from '@wordpress/ui';\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\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Retry installing %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\tif ( isInstalled ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Add %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\tif ( isInstalling ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Installing %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Install %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\treturn sprintf(\n\t\t/* translators: 1: block title, 2: average rating, 3: 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( { 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\tconst itemLabel = getDownloadableBlockLabel( item, {\n\t\thasNotice,\n\t\tisInstalled,\n\t\tisInstalling,\n\t} );\n\n\treturn (\n\t\t<Tooltip.Root>\n\t\t\t<Tooltip.Trigger\n\t\t\t\trender={\n\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-directory-downloadable-block-list-item',\n\t\t\t\t\t\t\tisInstalling && 'is-installing'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tonClick();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\taria-label={ itemLabel }\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t\t\t\t<DownloadableBlockIcon\n\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t\t\t\t<WCSpinner />\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: 1: block title. 2: author name. */\n\t\t\t\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tspan: (\n\t\t\t\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\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Composite.Item>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Tooltip.Popup>{ itemLabel }</Tooltip.Popup>\n\t\t</Tooltip.Root>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,0BACR,EAAE,OAAO,QAAQ,eACjB,EAAE,WAAW,aAAa,gBACzB;CACD,MAAM,QAAQ,KAAK,MAAO,SAAS,EAAI,IAAI;CAE3C,IAAK,CAAE,eAAe,WACrB,OAAO;;EAEN,GAAI,sBAAuB;EAC3B,eAAgB,KAAM;CACvB;CAGD,IAAK,aACJ,OAAO;;EAEN,GAAI,SAAU;EACd,eAAgB,KAAM;CACvB;CAGD,IAAK,cACJ,OAAO;;EAEN,GAAI,gBAAiB;EACrB,eAAgB,KAAM;CACvB;CAID,IAAK,cAAc,GAClB,OAAO;;EAEN,GAAI,aAAc;EAClB,eAAgB,KAAM;CACvB;CAGD,OAAO;;EAEN,GACC,8CACA,+CACA,WACD;EACA,eAAgB,KAAM;EACtB;EACA;CACD;AACD;AAEA,SAAS,0BAA2B,EAAE,MAAM,WAAY;CACvD,MAAM,EAAE,QAAQ,aAAa,MAAM,QAAQ,UAAU;CAErD,MAAM,cAAc,CAAC,CAAE,aAAc,KAAK,IAAK;CAE/C,MAAM,EAAE,WAAW,cAAc,kBAAkB,WAChD,WAAY;EACb,MAAM,EAAE,wBAAwB,cAAc,sBAC7C,OAAQA,KAAoB;EAC7B,MAAM,SAAS,uBAAwB,KAAK,EAAG;EAC/C,MAAM,WAAW,UAAU,OAAO;EAClC,OAAO;GACN,WAAW,CAAC,CAAE;GACd,cAAc,kBAAmB,KAAK,EAAG;GACzC,eAAe,CAAE;EAClB;CACD,GACA,CAAE,IAAK,CACR;CAEA,IAAI,aAAa;CACjB,IAAK,aACJ,aAAa,GAAI,YAAa;MACxB,IAAK,cACX,aAAa,GAAI,aAAc;CAGhC,MAAM,YAAY,0BAA2B,MAAM;EAClD;EACA;EACA;CACD,CAAE;CAEF,OACC,qBAAC,QAAQ,MAAT,EAAA,UAAA,CACC,oBAAC,QAAQ,SAAT,EACC,QACC,qBAAC,UAAU,MAAX;EACC,WAAY,KACX,gDACA,gBAAgB,eACjB;EACA,wBAAA;EACA,UAAW,gBAAgB,CAAE;EAC7B,UAAY,UAAW;GACtB,MAAM,eAAe;GACrB,QAAQ;EACT;EACA,cAAa;EACb,MAAK;EACL,MAAK;EAbN,UAAA,CAeC,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACC,oBAAC,uBAAD;IACQ;IACC;GACR,CAAA,GACC,eACD,oBAAC,QAAD;IAAM,WAAU;IACf,UAAA,oBAACC,SAAD,CAAY,CAAA;GACP,CAAA,IAEN,oBAAC,cAAD,EAAuB,OAAU,CAAA,CAE9B;EACL,CAAA,GAAA,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACC,oBAAC,QAAD;IAAM,WAAU;IACb,UAAA,yBACD;;KAEC,GAAI,2BAA4B;KAChC,eAAgB,KAAM;KACtB;IACD,GACA,EACC,MACC,oBAAC,QAAD,EAAM,WAAU,uDAAwD,CAAA,EAE1E,CACD;GACK,CAAA,GACJ,YACD,oBAAC,yBAAD,EAAyB,OAAQ,KAAQ,CAAA,IAEzC,qBAAA,UAAA,EAAA,UAAA,CACC,oBAAC,QAAD;IAAM,WAAU;IACb,UAAA,CAAC,CAAE,aACF,aACA,eAAgB,WAAY;GAC1B,CAAA,GACJ,iBACD,EAAI,eAAe,iBAClB,oBAAC,gBAAD,EAAA,UACG,GAAI,eAAgB,EACP,CAAA,CAEjB,EAAA,CAAA,CAEE;EACS,CAAA,CAAA;CAEjB,CAAA,EAAA,CAAA,GACD,oBAAC,QAAQ,OAAT,EAAA,UAAiB,UAA0B,CAAA,CAC9B,EAAA,CAAA;AAEhB"}
@@ -1,16 +1,15 @@
1
- import { __ } from "@wordpress/i18n";
2
1
  import { useSelect } from "@wordpress/data";
3
2
  import { store } from "../../store/index.mjs";
4
- import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { jsx } from "react/jsx-runtime";
5
4
  // packages/block-directory/src/components/downloadable-block-notice/index.jsx
6
5
  const DownloadableBlockNotice = ({ block }) => {
7
6
  const errorNotice = useSelect((select) => select(store).getErrorNoticeForBlock(block.id), [block]);
8
7
  if (!errorNotice) return null;
9
8
  return /* @__PURE__ */ jsx("div", {
10
9
  className: "block-directory-downloadable-block-notice",
11
- children: /* @__PURE__ */ jsxs("div", {
10
+ children: /* @__PURE__ */ jsx("div", {
12
11
  className: "block-directory-downloadable-block-notice__content",
13
- children: [errorNotice.message, errorNotice.isFatal ? " " + __("Try reloading the page.") : null]
12
+ children: errorNotice.message
14
13
  })
15
14
  });
16
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["blockDirectoryStore"],"sources":["../../../src/components/downloadable-block-notice/index.jsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport const DownloadableBlockNotice = ( { block } ) => {\n\tconst errorNotice = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockDirectoryStore ).getErrorNoticeForBlock( block.id ),\n\t\t[ block ]\n\t);\n\n\tif ( ! errorNotice ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-directory-downloadable-block-notice\">\n\t\t\t<div className=\"block-directory-downloadable-block-notice__content\">\n\t\t\t\t{ errorNotice.message }\n\t\t\t\t{ errorNotice.isFatal\n\t\t\t\t\t? ' ' + __( 'Try reloading the page.' )\n\t\t\t\t\t: null }\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default DownloadableBlockNotice;\n"],"mappings":";;;;;AAIA,MAAa,2BAA4B,EAAE,YAAa;CACvD,MAAM,cAAc,WACjB,WACD,OAAQA,KAAoB,CAAC,CAAC,uBAAwB,MAAM,EAAG,GAChE,CAAE,KAAM,CACT;CAEA,IAAK,CAAE,aACN,OAAO;CAGR,OACC,oBAAC,OAAD;EAAK,WAAU;EACd,UAAA,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACG,YAAY,SACZ,YAAY,UACX,MAAM,GAAI,yBAA0B,IACpC,IACC;;CACD,CAAA;AAEP"}
1
+ {"version":3,"file":"index.mjs","names":["blockDirectoryStore"],"sources":["../../../src/components/downloadable-block-notice/index.jsx"],"sourcesContent":["import { useSelect } from '@wordpress/data';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport const DownloadableBlockNotice = ( { block } ) => {\n\tconst errorNotice = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockDirectoryStore ).getErrorNoticeForBlock( block.id ),\n\t\t[ block ]\n\t);\n\n\tif ( ! errorNotice ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-directory-downloadable-block-notice\">\n\t\t\t<div className=\"block-directory-downloadable-block-notice__content\">\n\t\t\t\t{ errorNotice.message }\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default DownloadableBlockNotice;\n"],"mappings":";;;;AAGA,MAAa,2BAA4B,EAAE,YAAa;CACvD,MAAM,cAAc,WACjB,WACD,OAAQA,KAAoB,CAAC,CAAC,uBAAwB,MAAM,EAAG,GAChE,CAAE,KAAM,CACT;CAEA,IAAK,CAAE,aACN,OAAO;CAGR,OACC,oBAAC,OAAD;EAAK,WAAU;EACd,UAAA,oBAAC,OAAD;GAAK,WAAU;GACZ,UAAA,YAAY;EACV,CAAA;CACD,CAAA;AAEP"}
@@ -6,7 +6,11 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  function DownloadableBlocksInserterPanel({ children, downloadableItems, hasLocalBlocks }) {
7
7
  const count = downloadableItems.length;
8
8
  useEffect(() => {
9
- speak(sprintf(_n("%d additional block is available to install.", "%d additional blocks are available to install.", count), count));
9
+ speak(sprintf(
10
+ /** translators: %d: number of available blocks. */
11
+ _n("%d additional block is available to install.", "%d additional blocks are available to install.", count),
12
+ count
13
+ ));
10
14
  }, [count]);
11
15
  return /* @__PURE__ */ jsxs(Fragment, { children: [
12
16
  !hasLocalBlocks && /* @__PURE__ */ jsx("p", {