@wordpress/block-directory 5.57.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 (109) 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 -39
  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 +51 -90
  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 +21 -18
  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 +25 -27
  98. package/src/components/downloadable-block-list-item/index.jsx +2 -2
  99. package/src/components/downloadable-block-list-item/style.scss +6 -6
  100. package/src/components/downloadable-blocks-panel/index.jsx +2 -2
  101. package/src/components/downloadable-blocks-panel/no-results.jsx +15 -8
  102. package/CHANGELOG.md +0 -295
  103. package/build/index.cjs.map +0 -7
  104. package/build/lock-unlock.cjs +0 -36
  105. package/build/lock-unlock.cjs.map +0 -7
  106. package/build-module/index.mjs.map +0 -7
  107. package/build-module/lock-unlock.mjs +0 -11
  108. package/build-module/lock-unlock.mjs.map +0 -7
  109. package/src/lock-unlock.js +0 -7
@@ -1,99 +1,60 @@
1
- // packages/block-directory/src/components/downloadable-blocks-panel/index.jsx
2
1
  import { __ } from "@wordpress/i18n";
3
2
  import { Spinner } from "@wordpress/components";
4
- import { store as coreStore } from "@wordpress/core-data";
3
+ import { store } from "@wordpress/core-data";
5
4
  import { useSelect } from "@wordpress/data";
6
5
  import { getBlockType } from "@wordpress/blocks";
7
6
  import DownloadableBlocksList from "../downloadable-blocks-list/index.mjs";
8
7
  import DownloadableBlocksInserterPanel from "./inserter-panel.mjs";
9
8
  import DownloadableBlocksNoResults from "./no-results.mjs";
10
- import { store as blockDirectoryStore } from "../../store/index.mjs";
9
+ import { store as store$1 } from "../../store/index.mjs";
11
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
- var EMPTY_ARRAY = [];
13
- var useDownloadableBlocks = (filterValue) => useSelect(
14
- (select) => {
15
- const {
16
- getDownloadableBlocks,
17
- isRequestingDownloadableBlocks,
18
- getInstalledBlockTypes
19
- } = select(blockDirectoryStore);
20
- const hasPermission = select(coreStore).canUser(
21
- "read",
22
- "block-directory/search"
23
- );
24
- let downloadableBlocks = EMPTY_ARRAY;
25
- if (hasPermission) {
26
- downloadableBlocks = getDownloadableBlocks(filterValue);
27
- const installedBlockTypes = getInstalledBlockTypes();
28
- const installableBlocks = downloadableBlocks.filter(
29
- ({ name }) => {
30
- const isJustInstalled = installedBlockTypes.some(
31
- (blockType) => blockType.name === name
32
- );
33
- const isPreviouslyInstalled = getBlockType(name);
34
- return isJustInstalled || !isPreviouslyInstalled;
35
- }
36
- );
37
- if (installableBlocks.length !== downloadableBlocks.length) {
38
- downloadableBlocks = installableBlocks;
39
- }
40
- if (downloadableBlocks.length === 0) {
41
- downloadableBlocks = EMPTY_ARRAY;
42
- }
43
- }
44
- return {
45
- hasPermission,
46
- downloadableBlocks,
47
- isLoading: isRequestingDownloadableBlocks(filterValue)
48
- };
49
- },
50
- [filterValue]
51
- );
52
- function DownloadableBlocksPanel({
53
- onSelect,
54
- onHover,
55
- hasLocalBlocks,
56
- isTyping,
57
- filterValue
58
- }) {
59
- const { hasPermission, downloadableBlocks, isLoading } = useDownloadableBlocks(filterValue);
60
- if (hasPermission === void 0 || isLoading || isTyping) {
61
- return /* @__PURE__ */ jsxs(Fragment, { children: [
62
- hasPermission && !hasLocalBlocks && /* @__PURE__ */ jsxs(Fragment, { children: [
63
- /* @__PURE__ */ jsx("p", { className: "block-directory-downloadable-blocks-panel__no-local", children: __(
64
- "No results available from your installed blocks."
65
- ) }),
66
- /* @__PURE__ */ jsx("div", { className: "block-editor-inserter__quick-inserter-separator" })
67
- ] }),
68
- /* @__PURE__ */ jsx("div", { className: "block-directory-downloadable-blocks-panel has-blocks-loading", children: /* @__PURE__ */ jsx(Spinner, {}) })
69
- ] });
70
- }
71
- if (false === hasPermission) {
72
- if (!hasLocalBlocks) {
73
- return /* @__PURE__ */ jsx(DownloadableBlocksNoResults, {});
74
- }
75
- return null;
76
- }
77
- if (downloadableBlocks.length === 0) {
78
- return hasLocalBlocks ? null : /* @__PURE__ */ jsx(DownloadableBlocksNoResults, {});
79
- }
80
- return /* @__PURE__ */ jsx(
81
- DownloadableBlocksInserterPanel,
82
- {
83
- downloadableItems: downloadableBlocks,
84
- hasLocalBlocks,
85
- children: /* @__PURE__ */ jsx(
86
- DownloadableBlocksList,
87
- {
88
- items: downloadableBlocks,
89
- onSelect,
90
- onHover
91
- }
92
- )
93
- }
94
- );
11
+ // packages/block-directory/src/components/downloadable-blocks-panel/index.jsx
12
+ const EMPTY_ARRAY = [];
13
+ const useDownloadableBlocks = (filterValue) => useSelect((select) => {
14
+ const { getDownloadableBlocks, isRequestingDownloadableBlocks, getInstalledBlockTypes } = select(store$1);
15
+ const hasPermission = select(store).canUser("read", "block-directory/search");
16
+ let downloadableBlocks = EMPTY_ARRAY;
17
+ if (hasPermission) {
18
+ downloadableBlocks = getDownloadableBlocks(filterValue);
19
+ const installedBlockTypes = getInstalledBlockTypes();
20
+ const installableBlocks = downloadableBlocks.filter(({ name }) => {
21
+ const isJustInstalled = installedBlockTypes.some((blockType) => blockType.name === name);
22
+ const isPreviouslyInstalled = getBlockType(name);
23
+ return isJustInstalled || !isPreviouslyInstalled;
24
+ });
25
+ if (installableBlocks.length !== downloadableBlocks.length) downloadableBlocks = installableBlocks;
26
+ if (downloadableBlocks.length === 0) downloadableBlocks = EMPTY_ARRAY;
27
+ }
28
+ return {
29
+ hasPermission,
30
+ downloadableBlocks,
31
+ isLoading: isRequestingDownloadableBlocks(filterValue)
32
+ };
33
+ }, [filterValue]);
34
+ function DownloadableBlocksPanel({ onSelect, onHover, hasLocalBlocks, isTyping, filterValue }) {
35
+ const { hasPermission, downloadableBlocks, isLoading } = useDownloadableBlocks(filterValue);
36
+ if (hasPermission === void 0 || isLoading || isTyping) return /* @__PURE__ */ jsxs(Fragment, { children: [hasPermission && !hasLocalBlocks && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("p", {
37
+ className: "block-directory-downloadable-blocks-panel__no-local",
38
+ children: __("No results available from your installed blocks.")
39
+ }), /* @__PURE__ */ jsx("div", { className: "block-editor-inserter__quick-inserter-separator" })] }), /* @__PURE__ */ jsx("div", {
40
+ className: "block-directory-downloadable-blocks-panel has-blocks-loading",
41
+ children: /* @__PURE__ */ jsx(Spinner, {})
42
+ })] });
43
+ if (false === hasPermission) {
44
+ if (!hasLocalBlocks) return /* @__PURE__ */ jsx(DownloadableBlocksNoResults, {});
45
+ return null;
46
+ }
47
+ if (downloadableBlocks.length === 0) return hasLocalBlocks ? null : /* @__PURE__ */ jsx(DownloadableBlocksNoResults, {});
48
+ return /* @__PURE__ */ jsx(DownloadableBlocksInserterPanel, {
49
+ downloadableItems: downloadableBlocks,
50
+ hasLocalBlocks,
51
+ children: /* @__PURE__ */ jsx(DownloadableBlocksList, {
52
+ items: downloadableBlocks,
53
+ onSelect,
54
+ onHover
55
+ })
56
+ });
95
57
  }
96
- export {
97
- DownloadableBlocksPanel as default
98
- };
99
- //# sourceMappingURL=index.mjs.map
58
+ export { DownloadableBlocksPanel as default };
59
+
60
+ //# sourceMappingURL=index.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/downloadable-blocks-panel/index.jsx"],
4
- "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { getBlockType } from '@wordpress/blocks';\nimport DownloadableBlocksList from '../downloadable-blocks-list';\nimport DownloadableBlocksInserterPanel from './inserter-panel';\nimport DownloadableBlocksNoResults from './no-results';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst EMPTY_ARRAY = [];\n\nconst useDownloadableBlocks = ( filterValue ) =>\n\tuseSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetDownloadableBlocks,\n\t\t\t\tisRequestingDownloadableBlocks,\n\t\t\t\tgetInstalledBlockTypes,\n\t\t\t} = select( blockDirectoryStore );\n\n\t\t\tconst hasPermission = select( coreStore ).canUser(\n\t\t\t\t'read',\n\t\t\t\t'block-directory/search'\n\t\t\t);\n\n\t\t\tlet downloadableBlocks = EMPTY_ARRAY;\n\t\t\tif ( hasPermission ) {\n\t\t\t\tdownloadableBlocks = getDownloadableBlocks( filterValue );\n\n\t\t\t\t// Filter out blocks that are already installed.\n\t\t\t\tconst installedBlockTypes = getInstalledBlockTypes();\n\t\t\t\tconst installableBlocks = downloadableBlocks.filter(\n\t\t\t\t\t( { name } ) => {\n\t\t\t\t\t\t// Check if the block has just been installed, in which case it\n\t\t\t\t\t\t// should still show in the list to avoid suddenly disappearing.\n\t\t\t\t\t\t// `installedBlockTypes` only returns blocks stored in state\n\t\t\t\t\t\t// immediately after installation, not all installed blocks.\n\t\t\t\t\t\tconst isJustInstalled = installedBlockTypes.some(\n\t\t\t\t\t\t\t( blockType ) => blockType.name === name\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst isPreviouslyInstalled = getBlockType( name );\n\t\t\t\t\t\treturn isJustInstalled || ! isPreviouslyInstalled;\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\t// Keep identity of the `downloadableBlocks` array if nothing was filtered out\n\t\t\t\tif ( installableBlocks.length !== downloadableBlocks.length ) {\n\t\t\t\t\tdownloadableBlocks = installableBlocks;\n\t\t\t\t}\n\n\t\t\t\t// Return identical empty array when there are no blocks\n\t\t\t\tif ( downloadableBlocks.length === 0 ) {\n\t\t\t\t\tdownloadableBlocks = EMPTY_ARRAY;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\thasPermission,\n\t\t\t\tdownloadableBlocks,\n\t\t\t\tisLoading: isRequestingDownloadableBlocks( filterValue ),\n\t\t\t};\n\t\t},\n\t\t[ filterValue ]\n\t);\n\nexport default function DownloadableBlocksPanel( {\n\tonSelect,\n\tonHover,\n\thasLocalBlocks,\n\tisTyping,\n\tfilterValue,\n} ) {\n\tconst { hasPermission, downloadableBlocks, isLoading } =\n\t\tuseDownloadableBlocks( filterValue );\n\n\tif ( hasPermission === undefined || isLoading || isTyping ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasPermission && ! hasLocalBlocks && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'No results available from your installed blocks.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel has-blocks-loading\">\n\t\t\t\t\t<Spinner />\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif ( false === hasPermission ) {\n\t\tif ( ! hasLocalBlocks ) {\n\t\t\treturn <DownloadableBlocksNoResults />;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tif ( downloadableBlocks.length === 0 ) {\n\t\treturn hasLocalBlocks ? null : <DownloadableBlocksNoResults />;\n\t}\n\n\treturn (\n\t\t<DownloadableBlocksInserterPanel\n\t\t\tdownloadableItems={ downloadableBlocks }\n\t\t\thasLocalBlocks={ hasLocalBlocks }\n\t\t>\n\t\t\t<DownloadableBlocksList\n\t\t\t\titems={ downloadableBlocks }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tonHover={ onHover }\n\t\t\t/>\n\t\t</DownloadableBlocksInserterPanel>\n\t);\n}\n"],
5
- "mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,eAAe;AACxB,SAAS,SAAS,iBAAiB;AACnC,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,OAAO,4BAA4B;AACnC,OAAO,qCAAqC;AAC5C,OAAO,iCAAiC;AACxC,SAAS,SAAS,2BAA2B;AAwExC,mBACC,KADD;AAtEL,IAAM,cAAc,CAAC;AAErB,IAAM,wBAAwB,CAAE,gBAC/B;AAAA,EACC,CAAE,WAAY;AACb,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAI,OAAQ,mBAAoB;AAEhC,UAAM,gBAAgB,OAAQ,SAAU,EAAE;AAAA,MACzC;AAAA,MACA;AAAA,IACD;AAEA,QAAI,qBAAqB;AACzB,QAAK,eAAgB;AACpB,2BAAqB,sBAAuB,WAAY;AAGxD,YAAM,sBAAsB,uBAAuB;AACnD,YAAM,oBAAoB,mBAAmB;AAAA,QAC5C,CAAE,EAAE,KAAK,MAAO;AAKf,gBAAM,kBAAkB,oBAAoB;AAAA,YAC3C,CAAE,cAAe,UAAU,SAAS;AAAA,UACrC;AACA,gBAAM,wBAAwB,aAAc,IAAK;AACjD,iBAAO,mBAAmB,CAAE;AAAA,QAC7B;AAAA,MACD;AAGA,UAAK,kBAAkB,WAAW,mBAAmB,QAAS;AAC7D,6BAAqB;AAAA,MACtB;AAGA,UAAK,mBAAmB,WAAW,GAAI;AACtC,6BAAqB;AAAA,MACtB;AAAA,IACD;AAEA,WAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA,WAAW,+BAAgC,WAAY;AAAA,IACxD;AAAA,EACD;AAAA,EACA,CAAE,WAAY;AACf;AAEc,SAAR,wBAA0C;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,eAAe,oBAAoB,UAAU,IACpD,sBAAuB,WAAY;AAEpC,MAAK,kBAAkB,UAAa,aAAa,UAAW;AAC3D,WACC,iCACG;AAAA,uBAAiB,CAAE,kBACpB,iCACC;AAAA,4BAAC,OAAE,WAAU,uDACV;AAAA,UACD;AAAA,QACD,GACD;AAAA,QACA,oBAAC,SAAI,WAAU,mDAAkD;AAAA,SAClE;AAAA,MAED,oBAAC,SAAI,WAAU,gEACd,8BAAC,WAAQ,GACV;AAAA,OACD;AAAA,EAEF;AAEA,MAAK,UAAU,eAAgB;AAC9B,QAAK,CAAE,gBAAiB;AACvB,aAAO,oBAAC,+BAA4B;AAAA,IACrC;AAEA,WAAO;AAAA,EACR;AAEA,MAAK,mBAAmB,WAAW,GAAI;AACtC,WAAO,iBAAiB,OAAO,oBAAC,+BAA4B;AAAA,EAC7D;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,mBAAoB;AAAA,MACpB;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ;AAAA,UACR;AAAA,UACA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"index.mjs","names":["blockDirectoryStore","coreStore","WCSpinner"],"sources":["../../../src/components/downloadable-blocks-panel/index.jsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { Spinner as WCSpinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { getBlockType } from '@wordpress/blocks';\nimport DownloadableBlocksList from '../downloadable-blocks-list';\nimport DownloadableBlocksInserterPanel from './inserter-panel';\nimport DownloadableBlocksNoResults from './no-results';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst EMPTY_ARRAY = [];\n\nconst useDownloadableBlocks = ( filterValue ) =>\n\tuseSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetDownloadableBlocks,\n\t\t\t\tisRequestingDownloadableBlocks,\n\t\t\t\tgetInstalledBlockTypes,\n\t\t\t} = select( blockDirectoryStore );\n\n\t\t\tconst hasPermission = select( coreStore ).canUser(\n\t\t\t\t'read',\n\t\t\t\t'block-directory/search'\n\t\t\t);\n\n\t\t\tlet downloadableBlocks = EMPTY_ARRAY;\n\t\t\tif ( hasPermission ) {\n\t\t\t\tdownloadableBlocks = getDownloadableBlocks( filterValue );\n\n\t\t\t\t// Filter out blocks that are already installed.\n\t\t\t\tconst installedBlockTypes = getInstalledBlockTypes();\n\t\t\t\tconst installableBlocks = downloadableBlocks.filter(\n\t\t\t\t\t( { name } ) => {\n\t\t\t\t\t\t// Check if the block has just been installed, in which case it\n\t\t\t\t\t\t// should still show in the list to avoid suddenly disappearing.\n\t\t\t\t\t\t// `installedBlockTypes` only returns blocks stored in state\n\t\t\t\t\t\t// immediately after installation, not all installed blocks.\n\t\t\t\t\t\tconst isJustInstalled = installedBlockTypes.some(\n\t\t\t\t\t\t\t( blockType ) => blockType.name === name\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst isPreviouslyInstalled = getBlockType( name );\n\t\t\t\t\t\treturn isJustInstalled || ! isPreviouslyInstalled;\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\t// Keep identity of the `downloadableBlocks` array if nothing was filtered out\n\t\t\t\tif ( installableBlocks.length !== downloadableBlocks.length ) {\n\t\t\t\t\tdownloadableBlocks = installableBlocks;\n\t\t\t\t}\n\n\t\t\t\t// Return identical empty array when there are no blocks\n\t\t\t\tif ( downloadableBlocks.length === 0 ) {\n\t\t\t\t\tdownloadableBlocks = EMPTY_ARRAY;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\thasPermission,\n\t\t\t\tdownloadableBlocks,\n\t\t\t\tisLoading: isRequestingDownloadableBlocks( filterValue ),\n\t\t\t};\n\t\t},\n\t\t[ filterValue ]\n\t);\n\nexport default function DownloadableBlocksPanel( {\n\tonSelect,\n\tonHover,\n\thasLocalBlocks,\n\tisTyping,\n\tfilterValue,\n} ) {\n\tconst { hasPermission, downloadableBlocks, isLoading } =\n\t\tuseDownloadableBlocks( filterValue );\n\n\tif ( hasPermission === undefined || isLoading || isTyping ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasPermission && ! hasLocalBlocks && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'No results available from your installed blocks.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel has-blocks-loading\">\n\t\t\t\t\t<WCSpinner />\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif ( false === hasPermission ) {\n\t\tif ( ! hasLocalBlocks ) {\n\t\t\treturn <DownloadableBlocksNoResults />;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tif ( downloadableBlocks.length === 0 ) {\n\t\treturn hasLocalBlocks ? null : <DownloadableBlocksNoResults />;\n\t}\n\n\treturn (\n\t\t<DownloadableBlocksInserterPanel\n\t\t\tdownloadableItems={ downloadableBlocks }\n\t\t\thasLocalBlocks={ hasLocalBlocks }\n\t\t>\n\t\t\t<DownloadableBlocksList\n\t\t\t\titems={ downloadableBlocks }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tonHover={ onHover }\n\t\t\t/>\n\t\t</DownloadableBlocksInserterPanel>\n\t);\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,cAAc,CAAC;AAErB,MAAM,yBAA0B,gBAC/B,WACG,WAAY;CACb,MAAM,EACL,uBACA,gCACA,2BACG,OAAQA,OAAoB;CAEhC,MAAM,gBAAgB,OAAQC,KAAU,CAAC,CAAC,QACzC,QACA,wBACD;CAEA,IAAI,qBAAqB;CACzB,IAAK,eAAgB;EACpB,qBAAqB,sBAAuB,WAAY;EAGxD,MAAM,sBAAsB,uBAAuB;EACnD,MAAM,oBAAoB,mBAAmB,QAC1C,EAAE,WAAY;GAKf,MAAM,kBAAkB,oBAAoB,MACzC,cAAe,UAAU,SAAS,IACrC;GACA,MAAM,wBAAwB,aAAc,IAAK;GACjD,OAAO,mBAAmB,CAAE;EAC7B,CACD;EAGA,IAAK,kBAAkB,WAAW,mBAAmB,QACpD,qBAAqB;EAItB,IAAK,mBAAmB,WAAW,GAClC,qBAAqB;CAEvB;CAEA,OAAO;EACN;EACA;EACA,WAAW,+BAAgC,WAAY;CACxD;AACD,GACA,CAAE,WAAY,CACf;AAED,SAAwB,wBAAyB,EAChD,UACA,SACA,gBACA,UACA,eACG;CACH,MAAM,EAAE,eAAe,oBAAoB,cAC1C,sBAAuB,WAAY;CAEpC,IAAK,kBAAkB,KAAA,KAAa,aAAa,UAChD,OACC,qBAAA,UAAA,EAAA,UAAA,CACG,iBAAiB,CAAE,kBACpB,qBAAA,UAAA,EAAA,UAAA,CACC,oBAAC,KAAD;EAAG,WAAU;EACV,UAAA,GACD,kDACD;CACE,CAAA,GACH,oBAAC,OAAD,EAAK,WAAU,kDAAmD,CAAA,CACjE,EAAA,CAAA,GAEH,oBAAC,OAAD;EAAK,WAAU;EACd,UAAA,oBAACC,SAAD,CAAY,CAAA;CACR,CAAA,CACJ,EAAA,CAAA;CAIJ,IAAK,UAAU,eAAgB;EAC9B,IAAK,CAAE,gBACN,OAAO,oBAAC,6BAAD,CAA8B,CAAA;EAGtC,OAAO;CACR;CAEA,IAAK,mBAAmB,WAAW,GAClC,OAAO,iBAAiB,OAAO,oBAAC,6BAAD,CAA8B,CAAA;CAG9D,OACC,oBAAC,iCAAD;EACC,mBAAoB;EACH;EAEjB,UAAA,oBAAC,wBAAD;GACC,OAAQ;GACG;GACD;EACV,CAAA;CAC+B,CAAA;AAEnC"}
@@ -1,43 +1,34 @@
1
- // packages/block-directory/src/components/downloadable-blocks-panel/inserter-panel.jsx
2
1
  import { __, _n, sprintf } from "@wordpress/i18n";
3
2
  import { useEffect } from "@wordpress/element";
4
3
  import { speak } from "@wordpress/a11y";
5
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
- function DownloadableBlocksInserterPanel({
7
- children,
8
- downloadableItems,
9
- hasLocalBlocks
10
- }) {
11
- const count = downloadableItems.length;
12
- useEffect(() => {
13
- speak(
14
- sprintf(
15
- /* translators: %d: number of available blocks. */
16
- _n(
17
- "%d additional block is available to install.",
18
- "%d additional blocks are available to install.",
19
- count
20
- ),
21
- count
22
- )
23
- );
24
- }, [count]);
25
- return /* @__PURE__ */ jsxs(Fragment, { children: [
26
- !hasLocalBlocks && /* @__PURE__ */ jsx("p", { className: "block-directory-downloadable-blocks-panel__no-local", children: __("No results available from your installed blocks.") }),
27
- /* @__PURE__ */ jsx("div", { className: "block-editor-inserter__quick-inserter-separator" }),
28
- /* @__PURE__ */ jsxs("div", { className: "block-directory-downloadable-blocks-panel", children: [
29
- /* @__PURE__ */ jsxs("div", { className: "block-directory-downloadable-blocks-panel__header", children: [
30
- /* @__PURE__ */ jsx("h2", { className: "block-directory-downloadable-blocks-panel__title", children: __("Available to install") }),
31
- /* @__PURE__ */ jsx("p", { className: "block-directory-downloadable-blocks-panel__description", children: __(
32
- "Select a block to install and add it to your post."
33
- ) })
34
- ] }),
35
- children
36
- ] })
37
- ] });
5
+ // packages/block-directory/src/components/downloadable-blocks-panel/inserter-panel.jsx
6
+ function DownloadableBlocksInserterPanel({ children, downloadableItems, hasLocalBlocks }) {
7
+ const count = downloadableItems.length;
8
+ useEffect(() => {
9
+ speak(sprintf(_n("%d additional block is available to install.", "%d additional blocks are available to install.", count), count));
10
+ }, [count]);
11
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
12
+ !hasLocalBlocks && /* @__PURE__ */ jsx("p", {
13
+ className: "block-directory-downloadable-blocks-panel__no-local",
14
+ children: __("No results available from your installed blocks.")
15
+ }),
16
+ /* @__PURE__ */ jsx("div", { className: "block-editor-inserter__quick-inserter-separator" }),
17
+ /* @__PURE__ */ jsxs("div", {
18
+ className: "block-directory-downloadable-blocks-panel",
19
+ children: [/* @__PURE__ */ jsxs("div", {
20
+ className: "block-directory-downloadable-blocks-panel__header",
21
+ children: [/* @__PURE__ */ jsx("h2", {
22
+ className: "block-directory-downloadable-blocks-panel__title",
23
+ children: __("Available to install")
24
+ }), /* @__PURE__ */ jsx("p", {
25
+ className: "block-directory-downloadable-blocks-panel__description",
26
+ children: __("Select a block to install and add it to your post.")
27
+ })]
28
+ }), children]
29
+ })
30
+ ] });
38
31
  }
39
- var inserter_panel_default = DownloadableBlocksInserterPanel;
40
- export {
41
- inserter_panel_default as default
42
- };
43
- //# sourceMappingURL=inserter-panel.mjs.map
32
+ export { DownloadableBlocksInserterPanel as default };
33
+
34
+ //# sourceMappingURL=inserter-panel.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/downloadable-blocks-panel/inserter-panel.jsx"],
4
- "sourcesContent": ["import { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\nfunction DownloadableBlocksInserterPanel( {\n\tchildren,\n\tdownloadableItems,\n\thasLocalBlocks,\n} ) {\n\tconst count = downloadableItems.length;\n\tuseEffect( () => {\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of available blocks. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d additional block is available to install.',\n\t\t\t\t\t'%d additional blocks are available to install.',\n\t\t\t\t\tcount\n\t\t\t\t),\n\t\t\t\tcount\n\t\t\t)\n\t\t);\n\t}, [ count ] );\n\n\treturn (\n\t\t<>\n\t\t\t{ ! hasLocalBlocks && (\n\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t{ __( 'No results available from your installed blocks.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\n\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\n\t\t\t<div className=\"block-directory-downloadable-blocks-panel\">\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel__header\">\n\t\t\t\t\t<h2 className=\"block-directory-downloadable-blocks-panel__title\">\n\t\t\t\t\t\t{ __( 'Available to install' ) }\n\t\t\t\t\t</h2>\n\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__description\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select a block to install and add it to your post.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default DownloadableBlocksInserterPanel;\n"],
5
- "mappings": ";AAAA,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AAuBpB,mBAEE,KAQA,YAVF;AArBF,SAAS,gCAAiC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,QAAQ,kBAAkB;AAChC,YAAW,MAAM;AAChB;AAAA,MACC;AAAA;AAAA,QAEC;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,EACD,GAAG,CAAE,KAAM,CAAE;AAEb,SACC,iCACG;AAAA,KAAE,kBACH,oBAAC,OAAE,WAAU,uDACV,aAAI,kDAAmD,GAC1D;AAAA,IAGD,oBAAC,SAAI,WAAU,mDAAkD;AAAA,IAEjE,qBAAC,SAAI,WAAU,6CACd;AAAA,2BAAC,SAAI,WAAU,qDACd;AAAA,4BAAC,QAAG,WAAU,oDACX,aAAI,sBAAuB,GAC9B;AAAA,QACA,oBAAC,OAAE,WAAU,0DACV;AAAA,UACD;AAAA,QACD,GACD;AAAA,SACD;AAAA,MACE;AAAA,OACH;AAAA,KACD;AAEF;AAEA,IAAO,yBAAQ;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"inserter-panel.mjs","names":[],"sources":["../../../src/components/downloadable-blocks-panel/inserter-panel.jsx"],"sourcesContent":["import { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\nfunction DownloadableBlocksInserterPanel( {\n\tchildren,\n\tdownloadableItems,\n\thasLocalBlocks,\n} ) {\n\tconst count = downloadableItems.length;\n\tuseEffect( () => {\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of available blocks. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d additional block is available to install.',\n\t\t\t\t\t'%d additional blocks are available to install.',\n\t\t\t\t\tcount\n\t\t\t\t),\n\t\t\t\tcount\n\t\t\t)\n\t\t);\n\t}, [ count ] );\n\n\treturn (\n\t\t<>\n\t\t\t{ ! hasLocalBlocks && (\n\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t{ __( 'No results available from your installed blocks.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\n\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\n\t\t\t<div className=\"block-directory-downloadable-blocks-panel\">\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel__header\">\n\t\t\t\t\t<h2 className=\"block-directory-downloadable-blocks-panel__title\">\n\t\t\t\t\t\t{ __( 'Available to install' ) }\n\t\t\t\t\t</h2>\n\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__description\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select a block to install and add it to your post.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default DownloadableBlocksInserterPanel;\n"],"mappings":";;;;;AAIA,SAAS,gCAAiC,EACzC,UACA,mBACA,kBACG;CACH,MAAM,QAAQ,kBAAkB;CAChC,gBAAiB;EAChB,MACC,QAEC,GACC,gDACA,kDACA,KACD,GACA,KACD,CACD;CACD,GAAG,CAAE,KAAM,CAAE;CAEb,OACC,qBAAA,UAAA,EAAA,UAAA;EACG,CAAE,kBACH,oBAAC,KAAD;GAAG,WAAU;GACV,UAAA,GAAI,kDAAmD;EACvD,CAAA;EAGJ,oBAAC,OAAD,EAAK,WAAU,kDAAmD,CAAA;EAElE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACC,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACC,oBAAC,MAAD;KAAI,WAAU;KACX,UAAA,GAAI,sBAAuB;IAC1B,CAAA,GACJ,oBAAC,KAAD;KAAG,WAAU;KACV,UAAA,GACD,oDACD;IACE,CAAA,CACC;GACH,CAAA,GAAA,QACE;;CACJ,EAAA,CAAA;AAEJ"}
@@ -1,22 +1,25 @@
1
- // packages/block-directory/src/components/downloadable-blocks-panel/no-results.jsx
2
1
  import { __ } from "@wordpress/i18n";
3
- import { Tip, ExternalLink } from "@wordpress/components";
2
+ import { tip } from "@wordpress/icons";
3
+ import { Notice } from "@wordpress/ui";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ // packages/block-directory/src/components/downloadable-blocks-panel/no-results.jsx
5
6
  function DownloadableBlocksNoResults() {
6
- return /* @__PURE__ */ jsxs(Fragment, { children: [
7
- /* @__PURE__ */ jsx("div", { className: "block-editor-inserter__no-results", children: /* @__PURE__ */ jsx("p", { children: __("No results found.") }) }),
8
- /* @__PURE__ */ jsx("div", { className: "block-editor-inserter__tips", children: /* @__PURE__ */ jsxs(Tip, { children: [
9
- __("Interested in creating your own block?"),
10
- /* @__PURE__ */ jsx("br", {}),
11
- /* @__PURE__ */ jsxs(ExternalLink, { href: "https://developer.wordpress.org/block-editor/", children: [
12
- __("Get started here"),
13
- "."
14
- ] })
15
- ] }) })
16
- ] });
7
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
8
+ className: "block-editor-inserter__no-results",
9
+ children: /* @__PURE__ */ jsx("p", { children: __("No results found.") })
10
+ }), /* @__PURE__ */ jsx("div", {
11
+ className: "block-editor-inserter__tips",
12
+ children: /* @__PURE__ */ jsxs(Notice.Root, {
13
+ intent: "info",
14
+ icon: tip,
15
+ children: [/* @__PURE__ */ jsx(Notice.Description, { children: __("Interested in creating your own block?") }), /* @__PURE__ */ jsx(Notice.Actions, { children: /* @__PURE__ */ jsxs(Notice.ActionLink, {
16
+ href: "https://developer.wordpress.org/block-editor/",
17
+ openInNewTab: true,
18
+ children: [__("Get started here"), "."]
19
+ }) })]
20
+ })
21
+ })] });
17
22
  }
18
- var no_results_default = DownloadableBlocksNoResults;
19
- export {
20
- no_results_default as default
21
- };
22
- //# sourceMappingURL=no-results.mjs.map
23
+ export { DownloadableBlocksNoResults as default };
24
+
25
+ //# sourceMappingURL=no-results.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/downloadable-blocks-panel/no-results.jsx"],
4
- "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { Tip, ExternalLink } from '@wordpress/components';\n\nfunction DownloadableBlocksNoResults() {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"block-editor-inserter__no-results\">\n\t\t\t\t<p>{ __( 'No results found.' ) }</p>\n\t\t\t</div>\n\t\t\t<div className=\"block-editor-inserter__tips\">\n\t\t\t\t<Tip>\n\t\t\t\t\t{ __( 'Interested in creating your own block?' ) }\n\t\t\t\t\t<br />\n\t\t\t\t\t<ExternalLink href=\"https://developer.wordpress.org/block-editor/\">\n\t\t\t\t\t\t{ __( 'Get started here' ) }.\n\t\t\t\t\t</ExternalLink>\n\t\t\t\t</Tip>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default DownloadableBlocksNoResults;\n"],
5
- "mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,KAAK,oBAAoB;AAIhC,mBAEE,KAMC,YARH;AAFF,SAAS,8BAA8B;AACtC,SACC,iCACC;AAAA,wBAAC,SAAI,WAAU,qCACd,8BAAC,OAAI,aAAI,mBAAoB,GAAG,GACjC;AAAA,IACA,oBAAC,SAAI,WAAU,+BACd,+BAAC,OACE;AAAA,SAAI,wCAAyC;AAAA,MAC/C,oBAAC,QAAG;AAAA,MACJ,qBAAC,gBAAa,MAAK,iDAChB;AAAA,WAAI,kBAAmB;AAAA,QAAG;AAAA,SAC7B;AAAA,OACD,GACD;AAAA,KACD;AAEF;AAEA,IAAO,qBAAQ;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"no-results.mjs","names":[],"sources":["../../../src/components/downloadable-blocks-panel/no-results.jsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { tip } from '@wordpress/icons';\nimport { Notice } from '@wordpress/ui';\n\nfunction DownloadableBlocksNoResults() {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"block-editor-inserter__no-results\">\n\t\t\t\t<p>{ __( 'No results found.' ) }</p>\n\t\t\t</div>\n\t\t\t<div className=\"block-editor-inserter__tips\">\n\t\t\t\t<Notice.Root intent=\"info\" icon={ tip }>\n\t\t\t\t\t<Notice.Description>\n\t\t\t\t\t\t{ __( 'Interested in creating your own block?' ) }\n\t\t\t\t\t</Notice.Description>\n\t\t\t\t\t<Notice.Actions>\n\t\t\t\t\t\t<Notice.ActionLink\n\t\t\t\t\t\t\thref=\"https://developer.wordpress.org/block-editor/\"\n\t\t\t\t\t\t\topenInNewTab\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Get started here' ) }.\n\t\t\t\t\t\t</Notice.ActionLink>\n\t\t\t\t\t</Notice.Actions>\n\t\t\t\t</Notice.Root>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default DownloadableBlocksNoResults;\n"],"mappings":";;;;;AAIA,SAAS,8BAA8B;CACtC,OACC,qBAAA,UAAA,EAAA,UAAA,CACC,oBAAC,OAAD;EAAK,WAAU;EACd,UAAA,oBAAC,KAAD,EAAA,UAAK,GAAI,mBAAoB,EAAM,CAAA;CAC/B,CAAA,GACL,oBAAC,OAAD;EAAK,WAAU;EACd,UAAA,qBAAC,OAAO,MAAR;GAAa,QAAO;GAAO,MAAO;GAAlC,UAAA,CACC,oBAAC,OAAO,aAAR,EAAA,UACG,GAAI,wCAAyC,EAC5B,CAAA,GACpB,oBAAC,OAAO,SAAR,EAAA,UACC,qBAAC,OAAO,YAAR;IACC,MAAK;IACL,cAAA;IAFD,UAAA,CAIG,GAAI,kBAAmB,GAAG,GACV;GACJ,CAAA,EAAA,CAAA,CACJ;;CACT,CAAA,CACJ,EAAA,CAAA;AAEJ"}
@@ -1,7 +1,2 @@
1
- // packages/block-directory/src/index.js
2
1
  import "./plugins/index.mjs";
3
- import { store } from "./store/index.mjs";
4
- export {
5
- store
6
- };
7
- //# sourceMappingURL=index.mjs.map
2
+ export { store } from "./store/index.mjs";
@@ -1,107 +1,64 @@
1
- // packages/block-directory/src/plugins/get-install-missing/index.jsx
2
1
  import { __, sprintf } from "@wordpress/i18n";
3
2
  import { Button } from "@wordpress/components";
4
3
  import { createBlock } from "@wordpress/blocks";
5
4
  import { RawHTML } from "@wordpress/element";
6
5
  import { useDispatch, useSelect } from "@wordpress/data";
7
- import { store as coreStore } from "@wordpress/core-data";
8
- import {
9
- Warning,
10
- useBlockProps,
11
- store as blockEditorStore
12
- } from "@wordpress/block-editor";
6
+ import { store } from "@wordpress/core-data";
7
+ import { Warning, store as store$1, useBlockProps } from "@wordpress/block-editor";
13
8
  import InstallButton from "./install-button.mjs";
14
- import { store as blockDirectoryStore } from "../../store/index.mjs";
9
+ import { store as store$2 } from "../../store/index.mjs";
15
10
  import { jsx, jsxs } from "react/jsx-runtime";
16
- var getInstallMissing = (OriginalComponent) => (props) => {
17
- const { originalName } = props.attributes;
18
- const { block, hasPermission } = useSelect(
19
- (select) => {
20
- const { getDownloadableBlocks } = select(blockDirectoryStore);
21
- const blocks = getDownloadableBlocks(
22
- "block:" + originalName
23
- ).filter(({ name }) => originalName === name);
24
- return {
25
- hasPermission: select(coreStore).canUser(
26
- "read",
27
- "block-directory/search"
28
- ),
29
- block: blocks.length && blocks[0]
30
- };
31
- },
32
- [originalName]
33
- );
34
- if (!hasPermission || !block) {
35
- return /* @__PURE__ */ jsx(OriginalComponent, { ...props });
36
- }
37
- return /* @__PURE__ */ jsx(ModifiedWarning, { ...props, originalBlock: block });
38
- };
39
- var ModifiedWarning = ({ originalBlock, ...props }) => {
40
- const { originalName, originalUndelimitedContent, clientId } = props.attributes;
41
- const { replaceBlock } = useDispatch(blockEditorStore);
42
- const convertToHTML = () => {
43
- replaceBlock(
44
- props.clientId,
45
- createBlock("core/html", {}, [], [originalUndelimitedContent])
46
- );
47
- };
48
- const hasContent = !!originalUndelimitedContent;
49
- const hasHTMLBlock = useSelect(
50
- (select) => {
51
- const { canInsertBlockType, getBlockRootClientId } = select(blockEditorStore);
52
- return canInsertBlockType(
53
- "core/html",
54
- getBlockRootClientId(clientId)
55
- );
56
- },
57
- [clientId]
58
- );
59
- let messageHTML = sprintf(
60
- /* translators: %s: block name */
61
- __(
62
- "Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely."
63
- ),
64
- originalBlock.title || originalName
65
- );
66
- const actions = [
67
- /* @__PURE__ */ jsx(
68
- InstallButton,
69
- {
70
- block: originalBlock,
71
- attributes: props.attributes,
72
- clientId: props.clientId
73
- },
74
- "install"
75
- )
76
- ];
77
- if (hasContent && hasHTMLBlock) {
78
- messageHTML = sprintf(
79
- /* translators: %s: block name */
80
- __(
81
- "Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely."
82
- ),
83
- originalBlock.title || originalName
84
- );
85
- actions.push(
86
- /* @__PURE__ */ jsx(
87
- Button,
88
- {
89
- __next40pxDefaultSize: true,
90
- onClick: convertToHTML,
91
- variant: "tertiary",
92
- children: __("Keep as HTML")
93
- },
94
- "convert"
95
- )
96
- );
97
- }
98
- return /* @__PURE__ */ jsxs("div", { ...useBlockProps(), children: [
99
- /* @__PURE__ */ jsx(Warning, { actions, children: messageHTML }),
100
- /* @__PURE__ */ jsx(RawHTML, { children: originalUndelimitedContent })
101
- ] });
11
+ // packages/block-directory/src/plugins/get-install-missing/index.jsx
12
+ const getInstallMissing = (OriginalComponent) => (props) => {
13
+ const { originalName } = props.attributes;
14
+ const { block, hasPermission } = useSelect((select) => {
15
+ const { getDownloadableBlocks } = select(store$2);
16
+ const blocks = getDownloadableBlocks("block:" + originalName).filter(({ name }) => originalName === name);
17
+ return {
18
+ hasPermission: select(store).canUser("read", "block-directory/search"),
19
+ block: blocks.length && blocks[0]
20
+ };
21
+ }, [originalName]);
22
+ if (!hasPermission || !block) return /* @__PURE__ */ jsx(OriginalComponent, { ...props });
23
+ return /* @__PURE__ */ jsx(ModifiedWarning, {
24
+ ...props,
25
+ originalBlock: block
26
+ });
102
27
  };
103
- var get_install_missing_default = getInstallMissing;
104
- export {
105
- get_install_missing_default as default
28
+ const ModifiedWarning = ({ originalBlock, ...props }) => {
29
+ const { originalName, originalUndelimitedContent, clientId } = props.attributes;
30
+ const { replaceBlock } = useDispatch(store$1);
31
+ const convertToHTML = () => {
32
+ replaceBlock(props.clientId, createBlock("core/html", {}, [], [originalUndelimitedContent]));
33
+ };
34
+ const hasContent = !!originalUndelimitedContent;
35
+ const hasHTMLBlock = useSelect((select) => {
36
+ const { canInsertBlockType, getBlockRootClientId } = select(store$1);
37
+ return canInsertBlockType("core/html", getBlockRootClientId(clientId));
38
+ }, [clientId]);
39
+ let messageHTML = sprintf(__("Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely."), originalBlock.title || originalName);
40
+ const actions = [/* @__PURE__ */ jsx(InstallButton, {
41
+ block: originalBlock,
42
+ attributes: props.attributes,
43
+ clientId: props.clientId
44
+ }, "install")];
45
+ if (hasContent && hasHTMLBlock) {
46
+ messageHTML = sprintf(__("Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely."), originalBlock.title || originalName);
47
+ actions.push(/* @__PURE__ */ jsx(Button, {
48
+ __next40pxDefaultSize: true,
49
+ onClick: convertToHTML,
50
+ variant: "tertiary",
51
+ children: __("Keep as HTML")
52
+ }, "convert"));
53
+ }
54
+ return /* @__PURE__ */ jsxs("div", {
55
+ ...useBlockProps(),
56
+ children: [/* @__PURE__ */ jsx(Warning, {
57
+ actions,
58
+ children: messageHTML
59
+ }), /* @__PURE__ */ jsx(RawHTML, { children: originalUndelimitedContent })]
60
+ });
106
61
  };
107
- //# sourceMappingURL=index.mjs.map
62
+ export { getInstallMissing as default };
63
+
64
+ //# sourceMappingURL=index.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/get-install-missing/index.jsx"],
4
- "sourcesContent": ["import { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { RawHTML } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport InstallButton from './install-button';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst getInstallMissing = ( OriginalComponent ) => ( props ) => {\n\tconst { originalName } = props.attributes;\n\tconst { block, hasPermission } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getDownloadableBlocks } = select( blockDirectoryStore );\n\t\t\tconst blocks = getDownloadableBlocks(\n\t\t\t\t'block:' + originalName\n\t\t\t).filter( ( { name } ) => originalName === name );\n\t\t\treturn {\n\t\t\t\thasPermission: select( coreStore ).canUser(\n\t\t\t\t\t'read',\n\t\t\t\t\t'block-directory/search'\n\t\t\t\t),\n\t\t\t\tblock: blocks.length && blocks[ 0 ],\n\t\t\t};\n\t\t},\n\t\t[ originalName ]\n\t);\n\n\t// The user can't install blocks, or the block isn't available for download.\n\tif ( ! hasPermission || ! block ) {\n\t\treturn <OriginalComponent { ...props } />;\n\t}\n\n\treturn <ModifiedWarning { ...props } originalBlock={ block } />;\n};\n\nconst ModifiedWarning = ( { originalBlock, ...props } ) => {\n\tconst { originalName, originalUndelimitedContent, clientId } =\n\t\tprops.attributes;\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\tconst convertToHTML = () => {\n\t\treplaceBlock(\n\t\t\tprops.clientId,\n\t\t\tcreateBlock( 'core/html', {}, [], [ originalUndelimitedContent ] )\n\t\t);\n\t};\n\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst hasHTMLBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn canInsertBlockType(\n\t\t\t\t'core/html',\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tlet messageHTML = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__(\n\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'\n\t\t),\n\t\toriginalBlock.title || originalName\n\t);\n\tconst actions = [\n\t\t<InstallButton\n\t\t\tkey=\"install\"\n\t\t\tblock={ originalBlock }\n\t\t\tattributes={ props.attributes }\n\t\t\tclientId={ props.clientId }\n\t\t/>,\n\t];\n\n\tif ( hasContent && hasHTMLBlock ) {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'\n\t\t\t),\n\t\t\toriginalBlock.title || originalName\n\t\t);\n\t\tactions.push(\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tkey=\"convert\"\n\t\t\t\tonClick={ convertToHTML }\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t>\n\t\t\t\t{ __( 'Keep as HTML' ) }\n\t\t\t</Button>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div { ...useBlockProps() }>\n\t\t\t<Warning actions={ actions }>{ messageHTML }</Warning>\n\t\t\t<RawHTML>{ originalUndelimitedContent }</RawHTML>\n\t\t</div>\n\t);\n};\n\nexport default getInstallMissing;\n"],
5
- "mappings": ";AAAA,SAAS,IAAI,eAAe;AAC5B,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,iBAAiB;AACnC;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,OAAO,mBAAmB;AAC1B,SAAS,SAAS,2BAA2B;AAuBpC,cAoEP,YApEO;AArBT,IAAM,oBAAoB,CAAE,sBAAuB,CAAE,UAAW;AAC/D,QAAM,EAAE,aAAa,IAAI,MAAM;AAC/B,QAAM,EAAE,OAAO,cAAc,IAAI;AAAA,IAChC,CAAE,WAAY;AACb,YAAM,EAAE,sBAAsB,IAAI,OAAQ,mBAAoB;AAC9D,YAAM,SAAS;AAAA,QACd,WAAW;AAAA,MACZ,EAAE,OAAQ,CAAE,EAAE,KAAK,MAAO,iBAAiB,IAAK;AAChD,aAAO;AAAA,QACN,eAAe,OAAQ,SAAU,EAAE;AAAA,UAClC;AAAA,UACA;AAAA,QACD;AAAA,QACA,OAAO,OAAO,UAAU,OAAQ,CAAE;AAAA,MACnC;AAAA,IACD;AAAA,IACA,CAAE,YAAa;AAAA,EAChB;AAGA,MAAK,CAAE,iBAAiB,CAAE,OAAQ;AACjC,WAAO,oBAAC,qBAAoB,GAAG,OAAQ;AAAA,EACxC;AAEA,SAAO,oBAAC,mBAAkB,GAAG,OAAQ,eAAgB,OAAQ;AAC9D;AAEA,IAAM,kBAAkB,CAAE,EAAE,eAAe,GAAG,MAAM,MAAO;AAC1D,QAAM,EAAE,cAAc,4BAA4B,SAAS,IAC1D,MAAM;AACP,QAAM,EAAE,aAAa,IAAI,YAAa,gBAAiB;AACvD,QAAM,gBAAgB,MAAM;AAC3B;AAAA,MACC,MAAM;AAAA,MACN,YAAa,aAAa,CAAC,GAAG,CAAC,GAAG,CAAE,0BAA2B,CAAE;AAAA,IAClE;AAAA,EACD;AAEA,QAAM,aAAa,CAAC,CAAE;AACtB,QAAM,eAAe;AAAA,IACpB,CAAE,WAAY;AACb,YAAM,EAAE,oBAAoB,qBAAqB,IAChD,OAAQ,gBAAiB;AAE1B,aAAO;AAAA,QACN;AAAA,QACA,qBAAsB,QAAS;AAAA,MAChC;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,MAAI,cAAc;AAAA;AAAA,IAEjB;AAAA,MACC;AAAA,IACD;AAAA,IACA,cAAc,SAAS;AAAA,EACxB;AACA,QAAM,UAAU;AAAA,IACf;AAAA,MAAC;AAAA;AAAA,QAEA,OAAQ;AAAA,QACR,YAAa,MAAM;AAAA,QACnB,UAAW,MAAM;AAAA;AAAA,MAHb;AAAA,IAIL;AAAA,EACD;AAEA,MAAK,cAAc,cAAe;AACjC,kBAAc;AAAA;AAAA,MAEb;AAAA,QACC;AAAA,MACD;AAAA,MACA,cAAc,SAAS;AAAA,IACxB;AACA,YAAQ;AAAA,MACP;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UAErB,SAAU;AAAA,UACV,SAAQ;AAAA,UAEN,aAAI,cAAe;AAAA;AAAA,QAJjB;AAAA,MAKL;AAAA,IACD;AAAA,EACD;AAEA,SACC,qBAAC,SAAM,GAAG,cAAc,GACvB;AAAA,wBAAC,WAAQ,SAAsB,uBAAa;AAAA,IAC5C,oBAAC,WAAU,sCAA4B;AAAA,KACxC;AAEF;AAEA,IAAO,8BAAQ;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"index.mjs","names":["blockDirectoryStore","coreStore","blockEditorStore"],"sources":["../../../src/plugins/get-install-missing/index.jsx"],"sourcesContent":["import { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { RawHTML } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport InstallButton from './install-button';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst getInstallMissing = ( OriginalComponent ) => ( props ) => {\n\tconst { originalName } = props.attributes;\n\tconst { block, hasPermission } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getDownloadableBlocks } = select( blockDirectoryStore );\n\t\t\tconst blocks = getDownloadableBlocks(\n\t\t\t\t'block:' + originalName\n\t\t\t).filter( ( { name } ) => originalName === name );\n\t\t\treturn {\n\t\t\t\thasPermission: select( coreStore ).canUser(\n\t\t\t\t\t'read',\n\t\t\t\t\t'block-directory/search'\n\t\t\t\t),\n\t\t\t\tblock: blocks.length && blocks[ 0 ],\n\t\t\t};\n\t\t},\n\t\t[ originalName ]\n\t);\n\n\t// The user can't install blocks, or the block isn't available for download.\n\tif ( ! hasPermission || ! block ) {\n\t\treturn <OriginalComponent { ...props } />;\n\t}\n\n\treturn <ModifiedWarning { ...props } originalBlock={ block } />;\n};\n\nconst ModifiedWarning = ( { originalBlock, ...props } ) => {\n\tconst { originalName, originalUndelimitedContent, clientId } =\n\t\tprops.attributes;\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\tconst convertToHTML = () => {\n\t\treplaceBlock(\n\t\t\tprops.clientId,\n\t\t\tcreateBlock( 'core/html', {}, [], [ originalUndelimitedContent ] )\n\t\t);\n\t};\n\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst hasHTMLBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn canInsertBlockType(\n\t\t\t\t'core/html',\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tlet messageHTML = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__(\n\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'\n\t\t),\n\t\toriginalBlock.title || originalName\n\t);\n\tconst actions = [\n\t\t<InstallButton\n\t\t\tkey=\"install\"\n\t\t\tblock={ originalBlock }\n\t\t\tattributes={ props.attributes }\n\t\t\tclientId={ props.clientId }\n\t\t/>,\n\t];\n\n\tif ( hasContent && hasHTMLBlock ) {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'\n\t\t\t),\n\t\t\toriginalBlock.title || originalName\n\t\t);\n\t\tactions.push(\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tkey=\"convert\"\n\t\t\t\tonClick={ convertToHTML }\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t>\n\t\t\t\t{ __( 'Keep as HTML' ) }\n\t\t\t</Button>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div { ...useBlockProps() }>\n\t\t\t<Warning actions={ actions }>{ messageHTML }</Warning>\n\t\t\t<RawHTML>{ originalUndelimitedContent }</RawHTML>\n\t\t</div>\n\t);\n};\n\nexport default getInstallMissing;\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,qBAAsB,uBAAyB,UAAW;CAC/D,MAAM,EAAE,iBAAiB,MAAM;CAC/B,MAAM,EAAE,OAAO,kBAAkB,WAC9B,WAAY;EACb,MAAM,EAAE,0BAA0B,OAAQA,OAAoB;EAC9D,MAAM,SAAS,sBACd,WAAW,YACZ,CAAC,CAAC,QAAU,EAAE,WAAY,iBAAiB,IAAK;EAChD,OAAO;GACN,eAAe,OAAQC,KAAU,CAAC,CAAC,QAClC,QACA,wBACD;GACA,OAAO,OAAO,UAAU,OAAQ;EACjC;CACD,GACA,CAAE,YAAa,CAChB;CAGA,IAAK,CAAE,iBAAiB,CAAE,OACzB,OAAO,oBAAC,mBAAD,EAAmB,GAAK,MAAS,CAAA;CAGzC,OAAO,oBAAC,iBAAD;EAAiB,GAAK;EAAQ,eAAgB;CAAS,CAAA;AAC/D;AAEA,MAAM,mBAAoB,EAAE,eAAe,GAAG,YAAa;CAC1D,MAAM,EAAE,cAAc,4BAA4B,aACjD,MAAM;CACP,MAAM,EAAE,iBAAiB,YAAaC,OAAiB;CACvD,MAAM,sBAAsB;EAC3B,aACC,MAAM,UACN,YAAa,aAAa,CAAC,GAAG,CAAC,GAAG,CAAE,0BAA2B,CAAE,CAClE;CACD;CAEA,MAAM,aAAa,CAAC,CAAE;CACtB,MAAM,eAAe,WAClB,WAAY;EACb,MAAM,EAAE,oBAAoB,yBAC3B,OAAQA,OAAiB;EAE1B,OAAO,mBACN,aACA,qBAAsB,QAAS,CAChC;CACD,GACA,CAAE,QAAS,CACZ;CAEA,IAAI,cAAc,QAEjB,GACC,6GACD,GACA,cAAc,SAAS,YACxB;CACA,MAAM,UAAU,CACf,oBAAC,eAAD;EAEC,OAAQ;EACR,YAAa,MAAM;EACnB,UAAW,MAAM;CACjB,GAJI,SAIJ,CACF;CAEA,IAAK,cAAc,cAAe;EACjC,cAAc,QAEb,GACC,iJACD,GACA,cAAc,SAAS,YACxB;EACA,QAAQ,KACP,oBAAC,QAAD;GACC,uBAAA;GAEA,SAAU;GACV,SAAQ;GAEN,UAAA,GAAI,cAAe;EACd,GALH,SAKG,CACT;CACD;CAEA,OACC,qBAAC,OAAD;EAAK,GAAK,cAAc;EAAxB,UAAA,CACC,oBAAC,SAAD;GAAmB;GAAY,UAAA;EAAsB,CAAA,GACrD,oBAAC,SAAD,EAAA,UAAW,2BAAqC,CAAA,CAC5C;;AAEP"}
@@ -1,53 +1,31 @@
1
- // packages/block-directory/src/plugins/get-install-missing/install-button.jsx
2
1
  import { __, sprintf } from "@wordpress/i18n";
3
2
  import { Button } from "@wordpress/components";
4
3
  import { createBlock, getBlockType, parse } from "@wordpress/blocks";
5
- import { useSelect, useDispatch } from "@wordpress/data";
6
- import { store as blockEditorStore } from "@wordpress/block-editor";
7
- import { store as blockDirectoryStore } from "../../store/index.mjs";
4
+ import { useDispatch, useSelect } from "@wordpress/data";
5
+ import { store } from "@wordpress/block-editor";
6
+ import { store as store$1 } from "../../store/index.mjs";
8
7
  import { jsx } from "react/jsx-runtime";
8
+ // packages/block-directory/src/plugins/get-install-missing/install-button.jsx
9
9
  function InstallButton({ attributes, block, clientId }) {
10
- const isInstallingBlock = useSelect(
11
- (select) => select(blockDirectoryStore).isInstalling(block.id),
12
- [block.id]
13
- );
14
- const { installBlockType } = useDispatch(blockDirectoryStore);
15
- const { replaceBlock } = useDispatch(blockEditorStore);
16
- return /* @__PURE__ */ jsx(
17
- Button,
18
- {
19
- __next40pxDefaultSize: true,
20
- onClick: () => installBlockType(block).then((success) => {
21
- if (success) {
22
- const blockType = getBlockType(block.name);
23
- const [originalBlock] = parse(
24
- attributes.originalContent
25
- );
26
- if (originalBlock && blockType) {
27
- replaceBlock(
28
- clientId,
29
- createBlock(
30
- blockType.name,
31
- originalBlock.attributes,
32
- originalBlock.innerBlocks
33
- )
34
- );
35
- }
36
- }
37
- }),
38
- accessibleWhenDisabled: true,
39
- disabled: isInstallingBlock,
40
- isBusy: isInstallingBlock,
41
- variant: "primary",
42
- children: sprintf(
43
- /* translators: %s: block name */
44
- __("Install %s"),
45
- block.title
46
- )
47
- }
48
- );
10
+ const isInstallingBlock = useSelect((select) => select(store$1).isInstalling(block.id), [block.id]);
11
+ const { installBlockType } = useDispatch(store$1);
12
+ const { replaceBlock } = useDispatch(store);
13
+ return /* @__PURE__ */ jsx(Button, {
14
+ __next40pxDefaultSize: true,
15
+ onClick: () => installBlockType(block).then((success) => {
16
+ if (success) {
17
+ const blockType = getBlockType(block.name);
18
+ const [originalBlock] = parse(attributes.originalContent);
19
+ if (originalBlock && blockType) replaceBlock(clientId, createBlock(blockType.name, originalBlock.attributes, originalBlock.innerBlocks));
20
+ }
21
+ }),
22
+ accessibleWhenDisabled: true,
23
+ disabled: isInstallingBlock,
24
+ isBusy: isInstallingBlock,
25
+ variant: "primary",
26
+ children: sprintf(__("Install %s"), block.title)
27
+ });
49
28
  }
50
- export {
51
- InstallButton as default
52
- };
53
- //# sourceMappingURL=install-button.mjs.map
29
+ export { InstallButton as default };
30
+
31
+ //# sourceMappingURL=install-button.mjs.map