@wordpress/block-directory 6.0.0 → 6.1.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 (105) hide show
  1. package/build/components/auto-block-uninstaller/index.cjs +26 -47
  2. package/build/components/auto-block-uninstaller/index.cjs.map +1 -7
  3. package/build/components/block-ratings/index.cjs +28 -34
  4. package/build/components/block-ratings/index.cjs.map +1 -7
  5. package/build/components/block-ratings/stars.cjs +35 -71
  6. package/build/components/block-ratings/stars.cjs.map +1 -7
  7. package/build/components/compact-list/index.cjs +45 -43
  8. package/build/components/compact-list/index.cjs.map +1 -7
  9. package/build/components/downloadable-block-icon/index.cjs +20 -29
  10. package/build/components/downloadable-block-icon/index.cjs.map +1 -7
  11. package/build/components/downloadable-block-list-item/index.cjs +95 -161
  12. package/build/components/downloadable-block-list-item/index.cjs.map +1 -7
  13. package/build/components/downloadable-block-notice/index.cjs +23 -46
  14. package/build/components/downloadable-block-notice/index.cjs.map +1 -7
  15. package/build/components/downloadable-blocks-list/index.cjs +50 -70
  16. package/build/components/downloadable-blocks-list/index.cjs.map +1 -7
  17. package/build/components/downloadable-blocks-panel/index.cjs +79 -119
  18. package/build/components/downloadable-blocks-panel/index.cjs.map +1 -7
  19. package/build/components/downloadable-blocks-panel/inserter-panel.cjs +37 -61
  20. package/build/components/downloadable-blocks-panel/inserter-panel.cjs.map +1 -7
  21. package/build/components/downloadable-blocks-panel/no-results.cjs +27 -46
  22. package/build/components/downloadable-blocks-panel/no-results.cjs.map +1 -7
  23. package/build/index.cjs +11 -29
  24. package/build/plugins/get-install-missing/index.cjs +80 -122
  25. package/build/plugins/get-install-missing/index.cjs.map +1 -7
  26. package/build/plugins/get-install-missing/install-button.cjs +33 -70
  27. package/build/plugins/get-install-missing/install-button.cjs.map +1 -7
  28. package/build/plugins/index.cjs +45 -45
  29. package/build/plugins/index.cjs.map +1 -7
  30. package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs +40 -52
  31. package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs.map +1 -7
  32. package/build/plugins/installed-blocks-pre-publish-panel/index.cjs +38 -62
  33. package/build/plugins/installed-blocks-pre-publish-panel/index.cjs.map +1 -7
  34. package/build/store/actions.cjs +233 -205
  35. package/build/store/actions.cjs.map +1 -7
  36. package/build/store/index.cjs +56 -45
  37. package/build/store/index.cjs.map +1 -7
  38. package/build/store/load-assets.cjs +62 -63
  39. package/build/store/load-assets.cjs.map +1 -7
  40. package/build/store/reducer.cjs +90 -101
  41. package/build/store/reducer.cjs.map +1 -7
  42. package/build/store/resolvers.cjs +34 -54
  43. package/build/store/resolvers.cjs.map +1 -7
  44. package/build/store/selectors.cjs +111 -107
  45. package/build/store/selectors.cjs.map +1 -7
  46. package/build/store/utils/get-plugin-url.cjs +19 -32
  47. package/build/store/utils/get-plugin-url.cjs.map +1 -7
  48. package/build-module/components/auto-block-uninstaller/index.mjs +19 -25
  49. package/build-module/components/auto-block-uninstaller/index.mjs.map +1 -7
  50. package/build-module/components/block-ratings/index.mjs +8 -8
  51. package/build-module/components/block-ratings/index.mjs.map +1 -7
  52. package/build-module/components/block-ratings/stars.mjs +28 -49
  53. package/build-module/components/block-ratings/stars.mjs.map +1 -7
  54. package/build-module/components/compact-list/index.mjs +24 -19
  55. package/build-module/components/compact-list/index.mjs.map +1 -7
  56. package/build-module/components/downloadable-block-icon/index.mjs +14 -8
  57. package/build-module/components/downloadable-block-icon/index.mjs.map +1 -7
  58. package/build-module/components/downloadable-block-list-item/index.mjs +64 -130
  59. package/build-module/components/downloadable-block-list-item/index.mjs.map +1 -7
  60. package/build-module/components/downloadable-block-notice/index.mjs +15 -20
  61. package/build-module/components/downloadable-block-notice/index.mjs.map +1 -7
  62. package/build-module/components/downloadable-blocks-list/index.mjs +26 -43
  63. package/build-module/components/downloadable-blocks-list/index.mjs.map +1 -7
  64. package/build-module/components/downloadable-blocks-panel/index.mjs +52 -91
  65. package/build-module/components/downloadable-blocks-panel/index.mjs.map +1 -7
  66. package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs +29 -38
  67. package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs.map +1 -7
  68. package/build-module/components/downloadable-blocks-panel/no-results.mjs +19 -23
  69. package/build-module/components/downloadable-blocks-panel/no-results.mjs.map +1 -7
  70. package/build-module/index.mjs +1 -6
  71. package/build-module/plugins/get-install-missing/index.mjs +55 -98
  72. package/build-module/plugins/get-install-missing/index.mjs.map +1 -7
  73. package/build-module/plugins/get-install-missing/install-button.mjs +25 -47
  74. package/build-module/plugins/get-install-missing/install-button.mjs.map +1 -7
  75. package/build-module/plugins/index.mjs +16 -23
  76. package/build-module/plugins/index.mjs.map +1 -7
  77. package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs +17 -26
  78. package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs.map +1 -7
  79. package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs +15 -36
  80. package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs.map +1 -7
  81. package/build-module/store/actions.mjs +201 -170
  82. package/build-module/store/actions.mjs.map +1 -7
  83. package/build-module/store/index.mjs +28 -13
  84. package/build-module/store/index.mjs.map +1 -7
  85. package/build-module/store/load-assets.mjs +42 -36
  86. package/build-module/store/load-assets.mjs.map +1 -7
  87. package/build-module/store/reducer.mjs +81 -74
  88. package/build-module/store/reducer.mjs.map +1 -7
  89. package/build-module/store/resolvers.mjs +13 -26
  90. package/build-module/store/resolvers.mjs.map +1 -7
  91. package/build-module/store/selectors.mjs +99 -76
  92. package/build-module/store/selectors.mjs.map +1 -7
  93. package/build-module/store/utils/get-plugin-url.mjs +14 -12
  94. package/build-module/store/utils/get-plugin-url.mjs.map +1 -7
  95. package/build-style/style-rtl.css +6 -12
  96. package/build-style/style.css +6 -12
  97. package/package.json +22 -23
  98. package/src/components/downloadable-block-list-item/style.scss +6 -6
  99. package/build/index.cjs.map +0 -7
  100. package/build/lock-unlock.cjs +0 -36
  101. package/build/lock-unlock.cjs.map +0 -7
  102. package/build-module/index.mjs.map +0 -7
  103. package/build-module/lock-unlock.mjs +0 -11
  104. package/build-module/lock-unlock.mjs.map +0 -7
  105. package/src/lock-unlock.js +0 -7
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/block-ratings/stars.jsx"],
4
- "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"],
5
- "mappings": ";AAAA,SAAS,IAAI,eAAe;AAC5B,SAAS,MAAM,WAAW,YAAY,gBAAgB;AAUpD,SAQE,KARF;AARF,SAAS,MAAO,EAAE,OAAO,GAAI;AAC5B,QAAM,QAAQ,KAAK,MAAO,SAAS,GAAI,IAAI;AAE3C,QAAM,gBAAgB,KAAK,MAAO,MAAO;AACzC,QAAM,gBAAgB,KAAK,KAAM,SAAS,aAAc;AACxD,QAAM,iBAAiB,KAAM,gBAAgB;AAE7C,SACC;AAAA,IAAC;AAAA;AAAA,MACA,cAAa;AAAA;AAAA,QAEZ,GAAI,mBAAoB;AAAA,QACxB;AAAA,MACD;AAAA,MAEE;AAAA,cAAM,KAAM,EAAE,QAAQ,cAAc,CAAE,EAAE,IAAK,CAAE,GAAG,MACnD;AAAA,UAAC;AAAA;AAAA,YAEA,WAAU;AAAA,YACV,MAAO;AAAA,YACP,MAAO;AAAA;AAAA,UAHD,cAAe,CAAE;AAAA,QAIxB,CACC;AAAA,QACA,MAAM,KAAM,EAAE,QAAQ,cAAc,CAAE,EAAE,IAAK,CAAE,GAAG,MACnD;AAAA,UAAC;AAAA;AAAA,YAEA,WAAU;AAAA,YACV,MAAO;AAAA,YACP,MAAO;AAAA;AAAA,UAHD,cAAe,CAAE;AAAA,QAIxB,CACC;AAAA,QACA,MAAM,KAAM,EAAE,QAAQ,eAAe,CAAE,EAAE,IAAK,CAAE,GAAG,MACpD;AAAA,UAAC;AAAA;AAAA,YAEA,WAAU;AAAA,YACV,MAAO;AAAA,YACP,MAAO;AAAA;AAAA,UAHD,eAAgB,CAAE;AAAA,QAIzB,CACC;AAAA;AAAA;AAAA,EACH;AAEF;AAEA,IAAO,gBAAQ;",
6
- "names": []
7
- }
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,24 +1,29 @@
1
- // packages/block-directory/src/components/compact-list/index.jsx
2
1
  import { __, sprintf } from "@wordpress/i18n";
3
2
  import DownloadableBlockIcon from "../downloadable-block-icon/index.mjs";
4
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
+ // packages/block-directory/src/components/compact-list/index.jsx
5
5
  function CompactList({ items }) {
6
- if (!items.length) {
7
- return null;
8
- }
9
- return /* @__PURE__ */ jsx("ul", { className: "block-directory-compact-list", children: items.map(({ icon, id, title, author }) => /* @__PURE__ */ jsxs("li", { className: "block-directory-compact-list__item", children: [
10
- /* @__PURE__ */ jsx(DownloadableBlockIcon, { icon, title }),
11
- /* @__PURE__ */ jsxs("div", { className: "block-directory-compact-list__item-details", children: [
12
- /* @__PURE__ */ jsx("div", { className: "block-directory-compact-list__item-title", children: title }),
13
- /* @__PURE__ */ jsx("div", { className: "block-directory-compact-list__item-author", children: sprintf(
14
- /* translators: %s: Name of the block author. */
15
- __("By %s"),
16
- author
17
- ) })
18
- ] })
19
- ] }, id)) });
6
+ if (!items.length) return null;
7
+ return /* @__PURE__ */ jsx("ul", {
8
+ className: "block-directory-compact-list",
9
+ children: items.map(({ icon, id, title, author }) => /* @__PURE__ */ jsxs("li", {
10
+ className: "block-directory-compact-list__item",
11
+ children: [/* @__PURE__ */ jsx(DownloadableBlockIcon, {
12
+ icon,
13
+ title
14
+ }), /* @__PURE__ */ jsxs("div", {
15
+ className: "block-directory-compact-list__item-details",
16
+ children: [/* @__PURE__ */ jsx("div", {
17
+ className: "block-directory-compact-list__item-title",
18
+ children: title
19
+ }), /* @__PURE__ */ jsx("div", {
20
+ className: "block-directory-compact-list__item-author",
21
+ children: sprintf(__("By %s"), author)
22
+ })]
23
+ })]
24
+ }, id))
25
+ });
20
26
  }
21
- export {
22
- CompactList as default
23
- };
24
- //# sourceMappingURL=index.mjs.map
27
+ export { CompactList as default };
28
+
29
+ //# sourceMappingURL=index.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/compact-list/index.jsx"],
4
- "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"],
5
- "mappings": ";AAAA,SAAS,IAAI,eAAe;AAC5B,OAAO,2BAA2B;AAW7B,cAEA,YAFA;AATU,SAAR,YAA8B,EAAE,MAAM,GAAI;AAChD,MAAK,CAAE,MAAM,QAAS;AACrB,WAAO;AAAA,EACR;AAEA,SACC,oBAAC,QAAG,WAAU,gCACX,gBAAM,IAAK,CAAE,EAAE,MAAM,IAAI,OAAO,OAAO,MACxC,qBAAC,QAAc,WAAU,sCACxB;AAAA,wBAAC,yBAAsB,MAAc,OAAgB;AAAA,IAErD,qBAAC,SAAI,WAAU,8CACd;AAAA,0BAAC,SAAI,WAAU,4CACZ,iBACH;AAAA,MACA,oBAAC,SAAI,WAAU,6CACZ;AAAA;AAAA,QAED,GAAI,OAAQ;AAAA,QACZ;AAAA,MACD,GACD;AAAA,OACD;AAAA,OAdS,EAeV,CACC,GACH;AAEF;",
6
- "names": []
7
- }
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,12 +1,18 @@
1
- // packages/block-directory/src/components/downloadable-block-icon/index.jsx
2
1
  import { BlockIcon } from "@wordpress/block-editor";
3
2
  import { jsx } from "react/jsx-runtime";
3
+ // packages/block-directory/src/components/downloadable-block-icon/index.jsx
4
4
  function DownloadableBlockIcon({ icon }) {
5
- const className = "block-directory-downloadable-block-icon";
6
- return icon.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/) !== null ? /* @__PURE__ */ jsx("img", { className, src: icon, alt: "" }) : /* @__PURE__ */ jsx(BlockIcon, { className, icon, showColors: true });
5
+ const className = "block-directory-downloadable-block-icon";
6
+ return icon.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/) !== null ? /* @__PURE__ */ jsx("img", {
7
+ className,
8
+ src: icon,
9
+ alt: ""
10
+ }) : /* @__PURE__ */ jsx(BlockIcon, {
11
+ className,
12
+ icon,
13
+ showColors: true
14
+ });
7
15
  }
8
- var downloadable_block_icon_default = DownloadableBlockIcon;
9
- export {
10
- downloadable_block_icon_default as default
11
- };
12
- //# sourceMappingURL=index.mjs.map
16
+ export { DownloadableBlockIcon as default };
17
+
18
+ //# sourceMappingURL=index.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/downloadable-block-icon/index.jsx"],
4
- "sourcesContent": ["import { BlockIcon } from '@wordpress/block-editor';\n\nfunction DownloadableBlockIcon( { icon } ) {\n\tconst className = 'block-directory-downloadable-block-icon';\n\treturn icon.match( /\\.(jpeg|jpg|gif|png|svg)(?:\\?.*)?$/ ) !== null ? (\n\t\t<img className={ className } src={ icon } alt=\"\" />\n\t) : (\n\t\t<BlockIcon className={ className } icon={ icon } showColors />\n\t);\n}\n\nexport default DownloadableBlockIcon;\n"],
5
- "mappings": ";AAAA,SAAS,iBAAiB;AAKxB;AAHF,SAAS,sBAAuB,EAAE,KAAK,GAAI;AAC1C,QAAM,YAAY;AAClB,SAAO,KAAK,MAAO,oCAAqC,MAAM,OAC7D,oBAAC,SAAI,WAAwB,KAAM,MAAO,KAAI,IAAG,IAEjD,oBAAC,aAAU,WAAwB,MAAc,YAAU,MAAC;AAE9D;AAEA,IAAO,kCAAQ;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/downloadable-block-icon/index.jsx"],"sourcesContent":["import { BlockIcon } from '@wordpress/block-editor';\n\nfunction DownloadableBlockIcon( { icon } ) {\n\tconst className = 'block-directory-downloadable-block-icon';\n\treturn icon.match( /\\.(jpeg|jpg|gif|png|svg)(?:\\?.*)?$/ ) !== null ? (\n\t\t<img className={ className } src={ icon } alt=\"\" />\n\t) : (\n\t\t<BlockIcon className={ className } icon={ icon } showColors />\n\t);\n}\n\nexport default DownloadableBlockIcon;\n"],"mappings":";;;AAEA,SAAS,sBAAuB,EAAE,QAAS;CAC1C,MAAM,YAAY;CAClB,OAAO,KAAK,MAAO,oCAAqC,MAAM,OAC7D,oBAAC,OAAD;EAAiB;EAAY,KAAM;EAAO,KAAI;CAAI,CAAA,IAElD,oBAAC,WAAD;EAAuB;EAAmB;EAAO,YAAA;CAAY,CAAA;AAE/D"}
@@ -1,144 +1,78 @@
1
- // packages/block-directory/src/components/downloadable-block-list-item/index.jsx
2
1
  import clsx from "clsx";
3
2
  import { __, _n, sprintf } from "@wordpress/i18n";
4
- import { Spinner as WCSpinner, Composite } from "@wordpress/components";
3
+ import { Composite, Spinner } from "@wordpress/components";
5
4
  import { createInterpolateElement } from "@wordpress/element";
6
5
  import { decodeEntities } from "@wordpress/html-entities";
7
6
  import { getBlockType } from "@wordpress/blocks";
8
7
  import { useSelect } from "@wordpress/data";
9
- import { VisuallyHidden, Tooltip } from "@wordpress/ui";
8
+ import { Tooltip, VisuallyHidden } from "@wordpress/ui";
10
9
  import BlockRatings from "../block-ratings/index.mjs";
11
10
  import DownloadableBlockIcon from "../downloadable-block-icon/index.mjs";
12
11
  import DownloadableBlockNotice from "../downloadable-block-notice/index.mjs";
13
- import { store as blockDirectoryStore } from "../../store/index.mjs";
12
+ import { store } from "../../store/index.mjs";
14
13
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
14
+ // packages/block-directory/src/components/downloadable-block-list-item/index.jsx
15
15
  function getDownloadableBlockLabel({ title, rating, ratingCount }, { hasNotice, isInstalled, isInstalling }) {
16
- const stars = Math.round(rating / 0.5) * 0.5;
17
- if (!isInstalled && hasNotice) {
18
- return sprintf(
19
- /* translators: %s: block title */
20
- __("Retry installing %s."),
21
- decodeEntities(title)
22
- );
23
- }
24
- if (isInstalled) {
25
- return sprintf(
26
- /* translators: %s: block title */
27
- __("Add %s."),
28
- decodeEntities(title)
29
- );
30
- }
31
- if (isInstalling) {
32
- return sprintf(
33
- /* translators: %s: block title */
34
- __("Installing %s."),
35
- decodeEntities(title)
36
- );
37
- }
38
- if (ratingCount < 1) {
39
- return sprintf(
40
- /* translators: %s: block title */
41
- __("Install %s."),
42
- decodeEntities(title)
43
- );
44
- }
45
- return sprintf(
46
- /* translators: 1: block title, 2: average rating, 3: total ratings count. */
47
- _n(
48
- "Install %1$s. %2$s stars with %3$s review.",
49
- "Install %1$s. %2$s stars with %3$s reviews.",
50
- ratingCount
51
- ),
52
- decodeEntities(title),
53
- stars,
54
- ratingCount
55
- );
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);
56
22
  }
57
23
  function DownloadableBlockListItem({ item, onClick }) {
58
- const { author, description, icon, rating, title } = item;
59
- const isInstalled = !!getBlockType(item.name);
60
- const { hasNotice, isInstalling, isInstallable } = useSelect(
61
- (select) => {
62
- const { getErrorNoticeForBlock, isInstalling: isBlockInstalling } = select(blockDirectoryStore);
63
- const notice = getErrorNoticeForBlock(item.id);
64
- const hasFatal = notice && notice.isFatal;
65
- return {
66
- hasNotice: !!notice,
67
- isInstalling: isBlockInstalling(item.id),
68
- isInstallable: !hasFatal
69
- };
70
- },
71
- [item]
72
- );
73
- let statusText = "";
74
- if (isInstalled) {
75
- statusText = __("Installed!");
76
- } else if (isInstalling) {
77
- statusText = __("Installing…");
78
- }
79
- const itemLabel = getDownloadableBlockLabel(item, {
80
- hasNotice,
81
- isInstalled,
82
- isInstalling
83
- });
84
- return /* @__PURE__ */ jsxs(Tooltip.Root, { children: [
85
- /* @__PURE__ */ jsx(
86
- Tooltip.Trigger,
87
- {
88
- render: /* @__PURE__ */ jsxs(
89
- Composite.Item,
90
- {
91
- className: clsx(
92
- "block-directory-downloadable-block-list-item",
93
- isInstalling && "is-installing"
94
- ),
95
- accessibleWhenDisabled: true,
96
- disabled: isInstalling || !isInstallable,
97
- onClick: (event) => {
98
- event.preventDefault();
99
- onClick();
100
- },
101
- "aria-label": itemLabel,
102
- type: "button",
103
- role: "option",
104
- children: [
105
- /* @__PURE__ */ jsxs("div", { className: "block-directory-downloadable-block-list-item__icon", children: [
106
- /* @__PURE__ */ jsx(
107
- DownloadableBlockIcon,
108
- {
109
- icon,
110
- title
111
- }
112
- ),
113
- isInstalling ? /* @__PURE__ */ jsx("span", { className: "block-directory-downloadable-block-list-item__spinner", children: /* @__PURE__ */ jsx(WCSpinner, {}) }) : /* @__PURE__ */ jsx(BlockRatings, { rating })
114
- ] }),
115
- /* @__PURE__ */ jsxs("span", { className: "block-directory-downloadable-block-list-item__details", children: [
116
- /* @__PURE__ */ jsx("span", { className: "block-directory-downloadable-block-list-item__title", children: createInterpolateElement(
117
- sprintf(
118
- /* translators: 1: block title. 2: author name. */
119
- __("%1$s <span>by %2$s</span>"),
120
- decodeEntities(title),
121
- author
122
- ),
123
- {
124
- span: /* @__PURE__ */ jsx("span", { className: "block-directory-downloadable-block-list-item__author" })
125
- }
126
- ) }),
127
- hasNotice ? /* @__PURE__ */ jsx(DownloadableBlockNotice, { block: item }) : /* @__PURE__ */ jsxs(Fragment, { children: [
128
- /* @__PURE__ */ jsx("span", { className: "block-directory-downloadable-block-list-item__desc", children: !!statusText ? statusText : decodeEntities(description) }),
129
- isInstallable && !(isInstalled || isInstalling) && /* @__PURE__ */ jsx(VisuallyHidden, { children: __("Install block") })
130
- ] })
131
- ] })
132
- ]
133
- }
134
- )
135
- }
136
- ),
137
- /* @__PURE__ */ jsx(Tooltip.Popup, { children: itemLabel })
138
- ] });
24
+ const { author, description, icon, rating, title } = item;
25
+ const isInstalled = !!getBlockType(item.name);
26
+ const { hasNotice, isInstalling, isInstallable } = useSelect((select) => {
27
+ const { getErrorNoticeForBlock, isInstalling: isBlockInstalling } = select(store);
28
+ const notice = getErrorNoticeForBlock(item.id);
29
+ const hasFatal = notice && notice.isFatal;
30
+ return {
31
+ hasNotice: !!notice,
32
+ isInstalling: isBlockInstalling(item.id),
33
+ isInstallable: !hasFatal
34
+ };
35
+ }, [item]);
36
+ let statusText = "";
37
+ if (isInstalled) statusText = __("Installed!");
38
+ else if (isInstalling) statusText = __("Installing…");
39
+ const itemLabel = getDownloadableBlockLabel(item, {
40
+ hasNotice,
41
+ isInstalled,
42
+ isInstalling
43
+ });
44
+ return /* @__PURE__ */ jsxs(Tooltip.Root, { children: [/* @__PURE__ */ jsx(Tooltip.Trigger, { render: /* @__PURE__ */ jsxs(Composite.Item, {
45
+ className: clsx("block-directory-downloadable-block-list-item", isInstalling && "is-installing"),
46
+ accessibleWhenDisabled: true,
47
+ disabled: isInstalling || !isInstallable,
48
+ onClick: (event) => {
49
+ event.preventDefault();
50
+ onClick();
51
+ },
52
+ "aria-label": itemLabel,
53
+ type: "button",
54
+ role: "option",
55
+ children: [/* @__PURE__ */ jsxs("div", {
56
+ className: "block-directory-downloadable-block-list-item__icon",
57
+ children: [/* @__PURE__ */ jsx(DownloadableBlockIcon, {
58
+ icon,
59
+ title
60
+ }), isInstalling ? /* @__PURE__ */ jsx("span", {
61
+ className: "block-directory-downloadable-block-list-item__spinner",
62
+ children: /* @__PURE__ */ jsx(Spinner, {})
63
+ }) : /* @__PURE__ */ jsx(BlockRatings, { rating })]
64
+ }), /* @__PURE__ */ jsxs("span", {
65
+ className: "block-directory-downloadable-block-list-item__details",
66
+ children: [/* @__PURE__ */ jsx("span", {
67
+ 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" }) })
69
+ }), hasNotice ? /* @__PURE__ */ jsx(DownloadableBlockNotice, { block: item }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
70
+ className: "block-directory-downloadable-block-list-item__desc",
71
+ children: !!statusText ? statusText : decodeEntities(description)
72
+ }), isInstallable && !(isInstalled || isInstalling) && /* @__PURE__ */ jsx(VisuallyHidden, { children: __("Install block") })] })]
73
+ })]
74
+ }) }), /* @__PURE__ */ jsx(Tooltip.Popup, { children: itemLabel })] });
139
75
  }
140
- var downloadable_block_list_item_default = DownloadableBlockListItem;
141
- export {
142
- downloadable_block_list_item_default as default
143
- };
144
- //# sourceMappingURL=index.mjs.map
76
+ export { DownloadableBlockListItem as default };
77
+
78
+ //# sourceMappingURL=index.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/downloadable-block-list-item/index.jsx"],
4
- "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"],
5
- "mappings": "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",
6
- "names": []
7
- }
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,24 +1,19 @@
1
- // packages/block-directory/src/components/downloadable-block-notice/index.jsx
2
1
  import { __ } from "@wordpress/i18n";
3
2
  import { useSelect } from "@wordpress/data";
4
- import { store as blockDirectoryStore } from "../../store/index.mjs";
3
+ import { store } from "../../store/index.mjs";
5
4
  import { jsx, jsxs } from "react/jsx-runtime";
6
- var DownloadableBlockNotice = ({ block }) => {
7
- const errorNotice = useSelect(
8
- (select) => select(blockDirectoryStore).getErrorNoticeForBlock(block.id),
9
- [block]
10
- );
11
- if (!errorNotice) {
12
- return null;
13
- }
14
- return /* @__PURE__ */ jsx("div", { className: "block-directory-downloadable-block-notice", children: /* @__PURE__ */ jsxs("div", { className: "block-directory-downloadable-block-notice__content", children: [
15
- errorNotice.message,
16
- errorNotice.isFatal ? " " + __("Try reloading the page.") : null
17
- ] }) });
18
- };
19
- var downloadable_block_notice_default = DownloadableBlockNotice;
20
- export {
21
- DownloadableBlockNotice,
22
- downloadable_block_notice_default as default
5
+ // packages/block-directory/src/components/downloadable-block-notice/index.jsx
6
+ const DownloadableBlockNotice = ({ block }) => {
7
+ const errorNotice = useSelect((select) => select(store).getErrorNoticeForBlock(block.id), [block]);
8
+ if (!errorNotice) return null;
9
+ return /* @__PURE__ */ jsx("div", {
10
+ className: "block-directory-downloadable-block-notice",
11
+ children: /* @__PURE__ */ jsxs("div", {
12
+ className: "block-directory-downloadable-block-notice__content",
13
+ children: [errorNotice.message, errorNotice.isFatal ? " " + __("Try reloading the page.") : null]
14
+ })
15
+ });
23
16
  };
24
- //# sourceMappingURL=index.mjs.map
17
+ export { DownloadableBlockNotice, DownloadableBlockNotice as default };
18
+
19
+ //# sourceMappingURL=index.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/downloadable-block-notice/index.jsx"],
4
- "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"],
5
- "mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,2BAA2B;AAc3C,cACC,YADD;AAZK,IAAM,0BAA0B,CAAE,EAAE,MAAM,MAAO;AACvD,QAAM,cAAc;AAAA,IACnB,CAAE,WACD,OAAQ,mBAAoB,EAAE,uBAAwB,MAAM,EAAG;AAAA,IAChE,CAAE,KAAM;AAAA,EACT;AAEA,MAAK,CAAE,aAAc;AACpB,WAAO;AAAA,EACR;AAEA,SACC,oBAAC,SAAI,WAAU,6CACd,+BAAC,SAAI,WAAU,sDACZ;AAAA,gBAAY;AAAA,IACZ,YAAY,UACX,MAAM,GAAI,yBAA0B,IACpC;AAAA,KACJ,GACD;AAEF;AAEA,IAAO,oCAAQ;",
6
- "names": []
7
- }
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,51 +1,34 @@
1
- // packages/block-directory/src/components/downloadable-blocks-list/index.jsx
2
1
  import { __ } from "@wordpress/i18n";
3
2
  import { Composite } from "@wordpress/components";
4
3
  import { getBlockType } from "@wordpress/blocks";
5
4
  import { useDispatch } from "@wordpress/data";
6
5
  import DownloadableBlockListItem from "../downloadable-block-list-item/index.mjs";
7
- import { store as blockDirectoryStore } from "../../store/index.mjs";
6
+ import { store } from "../../store/index.mjs";
8
7
  import { jsx } from "react/jsx-runtime";
9
- var noop = () => {
10
- };
8
+ // packages/block-directory/src/components/downloadable-blocks-list/index.jsx
9
+ const noop = () => {};
11
10
  function DownloadableBlocksList({ items, onHover = noop, onSelect }) {
12
- const { installBlockType } = useDispatch(blockDirectoryStore);
13
- if (!items.length) {
14
- return null;
15
- }
16
- return /* @__PURE__ */ jsx(
17
- Composite,
18
- {
19
- role: "listbox",
20
- className: "block-directory-downloadable-blocks-list",
21
- "aria-label": __("Blocks available for install"),
22
- children: items.map((item) => {
23
- return /* @__PURE__ */ jsx(
24
- DownloadableBlockListItem,
25
- {
26
- onClick: () => {
27
- if (getBlockType(item.name)) {
28
- onSelect(item);
29
- } else {
30
- installBlockType(item).then((success) => {
31
- if (success) {
32
- onSelect(item);
33
- }
34
- });
35
- }
36
- onHover(null);
37
- },
38
- onHover,
39
- item
40
- },
41
- item.id
42
- );
43
- })
44
- }
45
- );
11
+ const { installBlockType } = useDispatch(store);
12
+ if (!items.length) return null;
13
+ return /* @__PURE__ */ jsx(Composite, {
14
+ role: "listbox",
15
+ className: "block-directory-downloadable-blocks-list",
16
+ "aria-label": __("Blocks available for install"),
17
+ children: items.map((item) => {
18
+ return /* @__PURE__ */ jsx(DownloadableBlockListItem, {
19
+ onClick: () => {
20
+ if (getBlockType(item.name)) onSelect(item);
21
+ else installBlockType(item).then((success) => {
22
+ if (success) onSelect(item);
23
+ });
24
+ onHover(null);
25
+ },
26
+ onHover,
27
+ item
28
+ }, item.id);
29
+ })
30
+ });
46
31
  }
47
- var downloadable_blocks_list_default = DownloadableBlocksList;
48
- export {
49
- downloadable_blocks_list_default as default
50
- };
51
- //# sourceMappingURL=index.mjs.map
32
+ export { DownloadableBlocksList as default };
33
+
34
+ //# sourceMappingURL=index.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/downloadable-blocks-list/index.jsx"],
4
- "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { Composite } from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\nimport DownloadableBlockListItem from '../downloadable-block-list-item';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst noop = () => {};\n\nfunction DownloadableBlocksList( { items, onHover = noop, onSelect } ) {\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Composite\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-directory-downloadable-blocks-list\"\n\t\t\taria-label={ __( 'Blocks available for install' ) }\n\t\t>\n\t\t\t{ items.map( ( item ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlockListItem\n\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Check if the block is registered (`getBlockType`\n\t\t\t\t\t\t\t// will return an object). If so, insert the block.\n\t\t\t\t\t\t\t// This prevents installing existing plugins.\n\t\t\t\t\t\t\tif ( getBlockType( item.name ) ) {\n\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tinstallBlockType( item ).then( ( success ) => {\n\t\t\t\t\t\t\t\t\tif ( success ) {\n\t\t\t\t\t\t\t\t\t\tonSelect( item );\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}\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Composite>\n\t);\n}\n\nexport default DownloadableBlocksList;\n"],
5
- "mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,OAAO,+BAA+B;AACtC,SAAS,SAAS,2BAA2B;AAmBxC;AAjBL,IAAM,OAAO,MAAM;AAAC;AAEpB,SAAS,uBAAwB,EAAE,OAAO,UAAU,MAAM,SAAS,GAAI;AACtE,QAAM,EAAE,iBAAiB,IAAI,YAAa,mBAAoB;AAE9D,MAAK,CAAE,MAAM,QAAS;AACrB,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,WAAU;AAAA,MACV,cAAa,GAAI,8BAA+B;AAAA,MAE9C,gBAAM,IAAK,CAAE,SAAU;AACxB,eACC;AAAA,UAAC;AAAA;AAAA,YAEA,SAAU,MAAM;AAIf,kBAAK,aAAc,KAAK,IAAK,GAAI;AAChC,yBAAU,IAAK;AAAA,cAChB,OAAO;AACN,iCAAkB,IAAK,EAAE,KAAM,CAAE,YAAa;AAC7C,sBAAK,SAAU;AACd,6BAAU,IAAK;AAAA,kBAChB;AAAA,gBACD,CAAE;AAAA,cACH;AACA,sBAAS,IAAK;AAAA,YACf;AAAA,YACA;AAAA,YACA;AAAA;AAAA,UAjBM,KAAK;AAAA,QAkBZ;AAAA,MAEF,CAAE;AAAA;AAAA,EACH;AAEF;AAEA,IAAO,mCAAQ;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"index.mjs","names":["blockDirectoryStore"],"sources":["../../../src/components/downloadable-blocks-list/index.jsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { Composite } from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\nimport DownloadableBlockListItem from '../downloadable-block-list-item';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst noop = () => {};\n\nfunction DownloadableBlocksList( { items, onHover = noop, onSelect } ) {\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Composite\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-directory-downloadable-blocks-list\"\n\t\t\taria-label={ __( 'Blocks available for install' ) }\n\t\t>\n\t\t\t{ items.map( ( item ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlockListItem\n\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Check if the block is registered (`getBlockType`\n\t\t\t\t\t\t\t// will return an object). If so, insert the block.\n\t\t\t\t\t\t\t// This prevents installing existing plugins.\n\t\t\t\t\t\t\tif ( getBlockType( item.name ) ) {\n\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tinstallBlockType( item ).then( ( success ) => {\n\t\t\t\t\t\t\t\t\tif ( success ) {\n\t\t\t\t\t\t\t\t\t\tonSelect( item );\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}\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Composite>\n\t);\n}\n\nexport default DownloadableBlocksList;\n"],"mappings":";;;;;;;;AAOA,MAAM,aAAa,CAAC;AAEpB,SAAS,uBAAwB,EAAE,OAAO,UAAU,MAAM,YAAa;CACtE,MAAM,EAAE,qBAAqB,YAAaA,KAAoB;CAE9D,IAAK,CAAE,MAAM,QACZ,OAAO;CAGR,OACC,oBAAC,WAAD;EACC,MAAK;EACL,WAAU;EACV,cAAa,GAAI,8BAA+B;EAE9C,UAAA,MAAM,KAAO,SAAU;GACxB,OACC,oBAAC,2BAAD;IAEC,eAAgB;KAIf,IAAK,aAAc,KAAK,IAAK,GAC5B,SAAU,IAAK;UAEf,iBAAkB,IAAK,CAAC,CAAC,MAAQ,YAAa;MAC7C,IAAK,SACJ,SAAU,IAAK;KAEjB,CAAE;KAEH,QAAS,IAAK;IACf;IACU;IACH;GACP,GAlBM,KAAK,EAkBX;EAEH,CAAE;CACQ,CAAA;AAEb"}