@wordpress/block-directory 6.2.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/auto-block-uninstaller/index.cjs.map +1 -1
- package/build/components/block-ratings/index.cjs +9 -7
- package/build/components/block-ratings/index.cjs.map +1 -1
- package/build/components/block-ratings/stars.cjs +5 -1
- package/build/components/block-ratings/stars.cjs.map +1 -1
- package/build/components/compact-list/index.cjs +14 -8
- package/build/components/compact-list/index.cjs.map +1 -1
- package/build/components/downloadable-block-list-item/index.cjs +45 -16
- package/build/components/downloadable-block-list-item/index.cjs.map +1 -1
- package/build/components/downloadable-blocks-list/index.cjs +9 -7
- package/build/components/downloadable-blocks-list/index.cjs.map +1 -1
- package/build/components/downloadable-blocks-panel/index.cjs +11 -9
- package/build/components/downloadable-blocks-panel/index.cjs.map +1 -1
- package/build/components/downloadable-blocks-panel/inserter-panel.cjs +5 -1
- package/build/components/downloadable-blocks-panel/inserter-panel.cjs.map +1 -1
- package/build/plugins/get-install-missing/index.cjs +19 -9
- package/build/plugins/get-install-missing/index.cjs.map +1 -1
- package/build/plugins/get-install-missing/install-button.cjs +5 -1
- package/build/plugins/get-install-missing/install-button.cjs.map +1 -1
- package/build/plugins/index.cjs +12 -10
- package/build/plugins/index.cjs.map +1 -1
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs +9 -7
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs.map +1 -1
- package/build/plugins/installed-blocks-pre-publish-panel/index.cjs +15 -9
- package/build/plugins/installed-blocks-pre-publish-panel/index.cjs.map +1 -1
- package/build/store/actions.cjs +14 -8
- package/build/store/actions.cjs.map +1 -1
- package/build/store/index.cjs +11 -9
- package/build/store/index.cjs.map +1 -1
- package/build/store/load-assets.cjs +8 -6
- package/build/store/load-assets.cjs.map +1 -1
- package/build/store/resolvers.cjs +9 -7
- package/build/store/resolvers.cjs.map +1 -1
- package/build-module/components/block-ratings/stars.mjs +5 -1
- package/build-module/components/block-ratings/stars.mjs.map +1 -1
- package/build-module/components/compact-list/index.mjs +5 -1
- package/build-module/components/compact-list/index.mjs.map +1 -1
- package/build-module/components/downloadable-block-list-item/index.mjs +33 -6
- package/build-module/components/downloadable-block-list-item/index.mjs.map +1 -1
- package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs +5 -1
- package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs.map +1 -1
- package/build-module/plugins/get-install-missing/index.mjs +10 -2
- package/build-module/plugins/get-install-missing/index.mjs.map +1 -1
- package/build-module/plugins/get-install-missing/install-button.mjs +5 -1
- package/build-module/plugins/get-install-missing/install-button.mjs.map +1 -1
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs +7 -3
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs.map +1 -1
- package/build-module/store/actions.mjs +5 -1
- package/build-module/store/actions.mjs.map +1 -1
- package/build-style/style-rtl.css +6 -6
- package/build-style/style.css +6 -6
- package/build-types/components/auto-block-uninstaller/index.d.ts +2 -0
- package/build-types/components/auto-block-uninstaller/index.d.ts.map +1 -0
- package/build-types/components/block-ratings/index.d.ts +5 -0
- package/build-types/components/block-ratings/index.d.ts.map +1 -0
- package/build-types/components/block-ratings/stars.d.ts +5 -0
- package/build-types/components/block-ratings/stars.d.ts.map +1 -0
- package/build-types/components/compact-list/index.d.ts +4 -0
- package/build-types/components/compact-list/index.d.ts.map +1 -0
- package/build-types/components/downloadable-block-icon/index.d.ts +5 -0
- package/build-types/components/downloadable-block-icon/index.d.ts.map +1 -0
- package/build-types/components/downloadable-block-list-item/index.d.ts +6 -0
- package/build-types/components/downloadable-block-list-item/index.d.ts.map +1 -0
- package/build-types/components/downloadable-block-notice/index.d.ts +5 -0
- package/build-types/components/downloadable-block-notice/index.d.ts.map +1 -0
- package/build-types/components/downloadable-blocks-list/index.d.ts +8 -0
- package/build-types/components/downloadable-blocks-list/index.d.ts.map +1 -0
- package/build-types/components/downloadable-blocks-panel/index.d.ts +8 -0
- package/build-types/components/downloadable-blocks-panel/index.d.ts.map +1 -0
- package/build-types/components/downloadable-blocks-panel/inserter-panel.d.ts +7 -0
- package/build-types/components/downloadable-blocks-panel/inserter-panel.d.ts.map +1 -0
- package/build-types/components/downloadable-blocks-panel/no-results.d.ts +3 -0
- package/build-types/components/downloadable-blocks-panel/no-results.d.ts.map +1 -0
- package/build-types/index.d.ts +3 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/plugins/get-install-missing/index.d.ts +3 -0
- package/build-types/plugins/get-install-missing/index.d.ts.map +1 -0
- package/build-types/plugins/get-install-missing/install-button.d.ts +6 -0
- package/build-types/plugins/get-install-missing/install-button.d.ts.map +1 -0
- package/build-types/plugins/index.d.ts +2 -0
- package/build-types/plugins/index.d.ts.map +1 -0
- package/build-types/plugins/inserter-menu-downloadable-blocks-panel/index.d.ts +3 -0
- package/build-types/plugins/inserter-menu-downloadable-blocks-panel/index.d.ts.map +1 -0
- package/build-types/plugins/installed-blocks-pre-publish-panel/index.d.ts +2 -0
- package/build-types/plugins/installed-blocks-pre-publish-panel/index.d.ts.map +1 -0
- package/build-types/store/actions.d.ts +82 -0
- package/build-types/store/actions.d.ts.map +1 -0
- package/build-types/store/index.d.ts +17 -0
- package/build-types/store/index.d.ts.map +1 -0
- package/build-types/store/load-assets.d.ts +16 -0
- package/build-types/store/load-assets.d.ts.map +1 -0
- package/build-types/store/reducer.d.ts +38 -0
- package/build-types/store/reducer.d.ts.map +1 -0
- package/build-types/store/resolvers.d.ts +4 -0
- package/build-types/store/resolvers.d.ts.map +1 -0
- package/build-types/store/selectors.d.ts +80 -0
- package/build-types/store/selectors.d.ts.map +1 -0
- package/build-types/store/utils/get-plugin-url.d.ts +9 -0
- package/build-types/store/utils/get-plugin-url.d.ts.map +1 -0
- package/package.json +23 -23
- package/src/plugins/installed-blocks-pre-publish-panel/index.jsx +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["registerPlugin","AutoBlockUninstaller","InserterMenuDownloadableBlocksPanel","InstalledBlocksPrePublishPanel","addFilter","getInstallMissing"],"sources":["../../src/plugins/index.jsx"],"sourcesContent":["import { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\nimport AutoBlockUninstaller from '../components/auto-block-uninstaller';\nimport InserterMenuDownloadableBlocksPanel from './inserter-menu-downloadable-blocks-panel';\nimport InstalledBlocksPrePublishPanel from './installed-blocks-pre-publish-panel';\nimport getInstallMissing from './get-install-missing';\n\nregisterPlugin( 'block-directory', {\n\t// The icon is explicitly set to undefined to prevent PluginPrePublishPanel\n\t// from rendering the fallback icon pluginIcon.\n\ticon: undefined,\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<AutoBlockUninstaller />\n\t\t\t\t<InserterMenuDownloadableBlocksPanel />\n\t\t\t\t<InstalledBlocksPrePublishPanel />\n\t\t\t</>\n\t\t);\n\t},\n} );\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-directory/fallback',\n\t( settings, name ) => {\n\t\tif ( name !== 'core/missing' ) {\n\t\t\treturn settings;\n\t\t}\n\t\tsettings.edit = getInstallMissing( settings.edit );\n\n\t\treturn settings;\n\t}\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["registerPlugin","AutoBlockUninstaller","InserterMenuDownloadableBlocksPanel","InstalledBlocksPrePublishPanel","addFilter","getInstallMissing"],"sources":["../../src/plugins/index.jsx"],"sourcesContent":["import { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\nimport AutoBlockUninstaller from '../components/auto-block-uninstaller';\nimport InserterMenuDownloadableBlocksPanel from './inserter-menu-downloadable-blocks-panel';\nimport InstalledBlocksPrePublishPanel from './installed-blocks-pre-publish-panel';\nimport getInstallMissing from './get-install-missing';\n\nregisterPlugin( 'block-directory', {\n\t// The icon is explicitly set to undefined to prevent PluginPrePublishPanel\n\t// from rendering the fallback icon pluginIcon.\n\ticon: undefined,\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<AutoBlockUninstaller />\n\t\t\t\t<InserterMenuDownloadableBlocksPanel />\n\t\t\t\t<InstalledBlocksPrePublishPanel />\n\t\t\t</>\n\t\t);\n\t},\n} );\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-directory/fallback',\n\t( settings, name ) => {\n\t\tif ( name !== 'core/missing' ) {\n\t\t\treturn settings;\n\t\t}\n\t\tsettings.edit = getInstallMissing( settings.edit );\n\n\t\treturn settings;\n\t}\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOAA,GAAAA,mBAAAA,eAAAA,CAAgB,mBAAmB;CAGlC,MAAM,KAAA;CACN,SAAS;EACR,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA;GACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,8CAAAA,SAAD,CAAuB,CAAA;GACvB,iBAAA,GAAA,kBAAA,IAAA,CAACC,oDAAAA,SAAD,CAAsC,CAAA;GACtC,iBAAA,GAAA,kBAAA,IAAA,CAACC,+CAAAA,SAAD,CAAiC,CAAA;EAChC,EAAA,CAAA;CAEJ;AACD,CAAE;CAEFC,GAAAA,iBAAAA,UAAAA,CACC,4BACA,6BACE,UAAU,SAAU;CACrB,IAAK,SAAS,gBACb,OAAO;CAER,SAAS,QAAA,GAAOC,gCAAAA,QAAAA,CAAmB,SAAS,IAAK;CAEjD,OAAO;AACR,CACD"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -28,8 +30,8 @@ let _wordpress_block_editor = require("@wordpress/block-editor");
|
|
|
28
30
|
let _wordpress_compose = require("@wordpress/compose");
|
|
29
31
|
let _wordpress_element = require("@wordpress/element");
|
|
30
32
|
let ______components_downloadable_blocks_panel_index_jsx = require("../../components/downloadable-blocks-panel/index.cjs");
|
|
31
|
-
______components_downloadable_blocks_panel_index_jsx = __toESM(______components_downloadable_blocks_panel_index_jsx);
|
|
32
33
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
______components_downloadable_blocks_panel_index_jsx = __toESM(______components_downloadable_blocks_panel_index_jsx);
|
|
33
35
|
// packages/block-directory/src/plugins/inserter-menu-downloadable-blocks-panel/index.jsx
|
|
34
36
|
function InserterMenuDownloadableBlocksPanel() {
|
|
35
37
|
const [debouncedFilterValue, setFilterValue] = (0, _wordpress_element.useState)("");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useState","debounce","__unstableInserterMenuExtension","DownloadableBlocksPanel"],"sources":["../../../src/plugins/inserter-menu-downloadable-blocks-panel/index.jsx"],"sourcesContent":["import { __unstableInserterMenuExtension } from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport DownloadableBlocksPanel from '../../components/downloadable-blocks-panel';\n\nfunction InserterMenuDownloadableBlocksPanel() {\n\tconst [ debouncedFilterValue, setFilterValue ] = useState( '' );\n\tconst debouncedSetFilterValue = debounce( setFilterValue, 400 );\n\n\treturn (\n\t\t<__unstableInserterMenuExtension>\n\t\t\t{ ( { onSelect, onHover, filterValue, hasItems } ) => {\n\t\t\t\tif ( debouncedFilterValue !== filterValue ) {\n\t\t\t\t\tdebouncedSetFilterValue( filterValue );\n\t\t\t\t}\n\n\t\t\t\tif ( ! debouncedFilterValue ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlocksPanel\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tfilterValue={ debouncedFilterValue }\n\t\t\t\t\t\thasLocalBlocks={ hasItems }\n\t\t\t\t\t\tisTyping={ filterValue !== debouncedFilterValue }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} }\n\t\t</__unstableInserterMenuExtension>\n\t);\n}\n\nexport default InserterMenuDownloadableBlocksPanel;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useState","debounce","__unstableInserterMenuExtension","DownloadableBlocksPanel"],"sources":["../../../src/plugins/inserter-menu-downloadable-blocks-panel/index.jsx"],"sourcesContent":["import { __unstableInserterMenuExtension } from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport DownloadableBlocksPanel from '../../components/downloadable-blocks-panel';\n\nfunction InserterMenuDownloadableBlocksPanel() {\n\tconst [ debouncedFilterValue, setFilterValue ] = useState( '' );\n\tconst debouncedSetFilterValue = debounce( setFilterValue, 400 );\n\n\treturn (\n\t\t<__unstableInserterMenuExtension>\n\t\t\t{ ( { onSelect, onHover, filterValue, hasItems } ) => {\n\t\t\t\tif ( debouncedFilterValue !== filterValue ) {\n\t\t\t\t\tdebouncedSetFilterValue( filterValue );\n\t\t\t\t}\n\n\t\t\t\tif ( ! debouncedFilterValue ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlocksPanel\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tfilterValue={ debouncedFilterValue }\n\t\t\t\t\t\thasLocalBlocks={ hasItems }\n\t\t\t\t\t\tisTyping={ filterValue !== debouncedFilterValue }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} }\n\t\t</__unstableInserterMenuExtension>\n\t);\n}\n\nexport default InserterMenuDownloadableBlocksPanel;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,sCAAsC;CAC9C,MAAM,CAAE,sBAAsB,mBAAA,GAAmBA,mBAAAA,SAAAA,CAAU,EAAG;CAC9D,MAAM,2BAAA,GAA0BC,mBAAAA,SAAAA,CAAU,gBAAgB,GAAI;CAE9D,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,iCAAD,EAAA,WACK,EAAE,UAAU,SAAS,aAAa,eAAgB;EACrD,IAAK,yBAAyB,aAC7B,wBAAyB,WAAY;EAGtC,IAAK,CAAE,sBACN,OAAO;EAGR,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,qDAAAA,SAAD;GACY;GACD;GACV,aAAc;GACd,gBAAiB;GACjB,UAAW,gBAAgB;EAC3B,CAAA;CAEH,EACgC,CAAA;AAEnC"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -28,19 +30,23 @@ let _wordpress_i18n = require("@wordpress/i18n");
|
|
|
28
30
|
let _wordpress_data = require("@wordpress/data");
|
|
29
31
|
let _wordpress_editor = require("@wordpress/editor");
|
|
30
32
|
let ______components_compact_list_index_jsx = require("../../components/compact-list/index.cjs");
|
|
31
|
-
______components_compact_list_index_jsx = __toESM(______components_compact_list_index_jsx);
|
|
32
33
|
let ______store_index_js = require("../../store/index.cjs");
|
|
33
34
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
______components_compact_list_index_jsx = __toESM(______components_compact_list_index_jsx);
|
|
34
36
|
// packages/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.jsx
|
|
35
37
|
function InstalledBlocksPrePublishPanel() {
|
|
36
38
|
const newBlockTypes = (0, _wordpress_data.useSelect)((select) => select(______store_index_js.store).getNewBlockTypes(), []);
|
|
37
39
|
if (!newBlockTypes.length) return null;
|
|
38
40
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_editor.PluginPrePublishPanel, {
|
|
39
|
-
title: (0, _wordpress_i18n.sprintf)(
|
|
41
|
+
title: (0, _wordpress_i18n.sprintf)(
|
|
42
|
+
/** translators: %d: number of blocks (number). */
|
|
43
|
+
(0, _wordpress_i18n._n)("Added: %d block", "Added: %d blocks", newBlockTypes.length),
|
|
44
|
+
newBlockTypes.length
|
|
45
|
+
),
|
|
40
46
|
initialOpen: true,
|
|
41
47
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
42
48
|
className: "installed-blocks-pre-publish-panel__copy",
|
|
43
|
-
children: (0, _wordpress_i18n.
|
|
49
|
+
children: newBlockTypes.length === 1 ? (0, _wordpress_i18n.__)("The following block has been added to your site.") : (0, _wordpress_i18n.__)("The following blocks have been added to your site.")
|
|
44
50
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(______components_compact_list_index_jsx.default, { items: newBlockTypes })]
|
|
45
51
|
});
|
|
46
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useSelect","blockDirectoryStore","PluginPrePublishPanel","sprintf","_n","CompactList"],"sources":["../../../src/plugins/installed-blocks-pre-publish-panel/index.jsx"],"sourcesContent":["import { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useSelect","blockDirectoryStore","PluginPrePublishPanel","sprintf","_n","__","CompactList"],"sources":["../../../src/plugins/installed-blocks-pre-publish-panel/index.jsx"],"sourcesContent":["import { __, _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ newBlockTypes.length === 1\n\t\t\t\t\t? __( 'The following block has been added to your site.' )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'The following blocks have been added to your site.'\n\t\t\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAwB,iCAAiC;CACxD,MAAM,iBAAA,GAAgBA,gBAAAA,UAAAA,EACnB,WAAY,OAAQC,qBAAAA,KAAoB,CAAC,CAAC,iBAAiB,GAC7D,CAAC,CACF;CAEA,IAAK,CAAE,cAAc,QACpB,OAAO;CAGR,OACC,iBAAA,GAAA,kBAAA,KAAA,CAACC,kBAAAA,uBAAD;EACC,QAAA,GAAQC,gBAAAA,QAAAA;;IAEPC,GAAAA,gBAAAA,GAAAA,CACC,mBACA,oBACA,cAAc,MACf;GACA,cAAc;EACf;EACA,aAAA;EAVD,UAAA,CAYC,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;GAAG,WAAU;GACV,UAAA,cAAc,WAAW,KAAA,GACxBC,gBAAAA,GAAAA,CAAI,kDAAmD,KAAA,GACvDA,gBAAAA,GAAAA,CACA,oDACD;EACA,CAAA,GACH,iBAAA,GAAA,kBAAA,IAAA,CAACC,wCAAAA,SAAD,EAAa,OAAQ,cAAiB,CAAA,CAChB;;AAEzB"}
|
package/build/store/actions.cjs
CHANGED
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -27,11 +29,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
29
|
let _wordpress_blocks = require("@wordpress/blocks");
|
|
28
30
|
let _wordpress_i18n = require("@wordpress/i18n");
|
|
29
31
|
let _wordpress_api_fetch = require("@wordpress/api-fetch");
|
|
30
|
-
_wordpress_api_fetch = __toESM(_wordpress_api_fetch);
|
|
31
32
|
let _wordpress_notices = require("@wordpress/notices");
|
|
32
33
|
let _wordpress_url = require("@wordpress/url");
|
|
33
34
|
let __load_assets_js = require("./load-assets.cjs");
|
|
34
35
|
let __utils_get_plugin_url_js = require("./utils/get-plugin-url.cjs");
|
|
36
|
+
_wordpress_api_fetch = __toESM(_wordpress_api_fetch);
|
|
35
37
|
__utils_get_plugin_url_js = __toESM(__utils_get_plugin_url_js);
|
|
36
38
|
// packages/block-directory/src/store/actions.js
|
|
37
39
|
/**
|
|
@@ -125,7 +127,11 @@ const installBlockType = (block) => async ({ registry, dispatch }) => {
|
|
|
125
127
|
});
|
|
126
128
|
await (0, __load_assets_js.loadAssets)();
|
|
127
129
|
if (!registry.select(_wordpress_blocks.store).getBlockTypes().some((i) => i.name === name)) throw new Error((0, _wordpress_i18n.__)("Error registering block. Try reloading the page."));
|
|
128
|
-
registry.dispatch(_wordpress_notices.store).createInfoNotice((0, _wordpress_i18n.sprintf)(
|
|
130
|
+
registry.dispatch(_wordpress_notices.store).createInfoNotice((0, _wordpress_i18n.sprintf)(
|
|
131
|
+
/** translators: %s is the block title. */
|
|
132
|
+
(0, _wordpress_i18n.__)("Block %s installed and added."),
|
|
133
|
+
block.title
|
|
134
|
+
), {
|
|
129
135
|
speak: true,
|
|
130
136
|
type: "snackbar"
|
|
131
137
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.cjs","names":["getPluginUrl","apiFetch","addQueryArgs","loadAssets","blocksStore","__","noticesStore","sprintf"],"sources":["../../src/store/actions.js"],"sourcesContent":["import {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst { id, name } = block;\n\t\tlet success = false;\n\t\tdispatch.clearErrorNotice( id );\n\t\ttry {\n\t\t\tdispatch.setIsInstalling( id, true );\n\n\t\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tlet links = {};\n\t\t\tif ( url ) {\n\t\t\t\tawait apiFetch( {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\turl,\n\t\t\t\t\tdata: { status: 'active' },\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t\t} );\n\t\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\t\tlinks = response._links;\n\t\t\t}\n\n\t\t\tdispatch.addInstalledBlockType( {\n\t\t\t\t...block,\n\t\t\t\tlinks: { ...block.links, ...links },\n\t\t\t} );\n\n\t\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\t\tconst metadataFields = [\n\t\t\t\t'api_version',\n\t\t\t\t'title',\n\t\t\t\t'category',\n\t\t\t\t'parent',\n\t\t\t\t'ancestor',\n\t\t\t\t'icon',\n\t\t\t\t'description',\n\t\t\t\t'keywords',\n\t\t\t\t'attributes',\n\t\t\t\t'provides_context',\n\t\t\t\t'uses_context',\n\t\t\t\t'selectors',\n\t\t\t\t'supports',\n\t\t\t\t'styles',\n\t\t\t\t'example',\n\t\t\t\t'variations',\n\t\t\t\t'allowed_blocks',\n\t\t\t\t'block_hooks',\n\t\t\t];\n\t\t\tawait apiFetch( {\n\t\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t\t_fields: metadataFields,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t\t.catch( () => {} )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( ! response ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t\t[ name ]: Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( response ).filter( ( [ key ] ) =>\n\t\t\t\t\t\t\t\tmetadataFields.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t),\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\tawait loadAssets();\n\t\t\tconst registeredBlocks = registry\n\t\t\t\t.select( blocksStore )\n\t\t\t\t.getBlockTypes();\n\t\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s is the block title.\n\t\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\t\tblock.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\tspeak: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\tsuccess = true;\n\t\t} catch ( error ) {\n\t\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t\t// Errors we throw are fatal.\n\t\t\tlet isFatal = error instanceof Error;\n\n\t\t\t// Specific API errors that are fatal.\n\t\t\tconst fatalAPIErrors = {\n\t\t\t\tfolder_exists: __(\n\t\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t\t),\n\t\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\t\tisFatal = true;\n\t\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t\t}\n\n\t\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\t\tspeak: true,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}\n\t\tdispatch.setIsInstalling( id, false );\n\t\treturn success;\n\t};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\ttry {\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'inactive' },\n\t\t\t} );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl,\n\t\t\t} );\n\t\t\tdispatch.removeInstalledBlockType( block );\n\t\t} catch ( error ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\terror.message || __( 'An error occurred.' )\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"actions.cjs","names":["getPluginUrl","apiFetch","addQueryArgs","unstable__bootstrapServerSideBlockDefinitions","loadAssets","blocksStore","__","noticesStore","sprintf"],"sources":["../../src/store/actions.js"],"sourcesContent":["import {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst { id, name } = block;\n\t\tlet success = false;\n\t\tdispatch.clearErrorNotice( id );\n\t\ttry {\n\t\t\tdispatch.setIsInstalling( id, true );\n\n\t\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tlet links = {};\n\t\t\tif ( url ) {\n\t\t\t\tawait apiFetch( {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\turl,\n\t\t\t\t\tdata: { status: 'active' },\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t\t} );\n\t\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\t\tlinks = response._links;\n\t\t\t}\n\n\t\t\tdispatch.addInstalledBlockType( {\n\t\t\t\t...block,\n\t\t\t\tlinks: { ...block.links, ...links },\n\t\t\t} );\n\n\t\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\t\tconst metadataFields = [\n\t\t\t\t'api_version',\n\t\t\t\t'title',\n\t\t\t\t'category',\n\t\t\t\t'parent',\n\t\t\t\t'ancestor',\n\t\t\t\t'icon',\n\t\t\t\t'description',\n\t\t\t\t'keywords',\n\t\t\t\t'attributes',\n\t\t\t\t'provides_context',\n\t\t\t\t'uses_context',\n\t\t\t\t'selectors',\n\t\t\t\t'supports',\n\t\t\t\t'styles',\n\t\t\t\t'example',\n\t\t\t\t'variations',\n\t\t\t\t'allowed_blocks',\n\t\t\t\t'block_hooks',\n\t\t\t];\n\t\t\tawait apiFetch( {\n\t\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t\t_fields: metadataFields,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t\t.catch( () => {} )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( ! response ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t\t[ name ]: Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( response ).filter( ( [ key ] ) =>\n\t\t\t\t\t\t\t\tmetadataFields.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t),\n\t\t\t\t\t} );\n\t\t\t\t} );\n\n\t\t\tawait loadAssets();\n\t\t\tconst registeredBlocks = registry\n\t\t\t\t.select( blocksStore )\n\t\t\t\t.getBlockTypes();\n\t\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s is the block title.\n\t\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\t\tblock.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\tspeak: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\tsuccess = true;\n\t\t} catch ( error ) {\n\t\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t\t// Errors we throw are fatal.\n\t\t\tlet isFatal = error instanceof Error;\n\n\t\t\t// Specific API errors that are fatal.\n\t\t\tconst fatalAPIErrors = {\n\t\t\t\tfolder_exists: __(\n\t\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t\t),\n\t\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\t\tisFatal = true;\n\t\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t\t}\n\n\t\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\t\tspeak: true,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}\n\t\tdispatch.setIsInstalling( id, false );\n\t\treturn success;\n\t};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\ttry {\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'inactive' },\n\t\t\t} );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl,\n\t\t\t} );\n\t\t\tdispatch.removeInstalledBlockType( block );\n\t\t} catch ( error ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\terror.message || __( 'An error occurred.' )\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"],"mappings":"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"}
|
package/build/store/index.cjs
CHANGED
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -26,12 +28,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
28
|
}) : target, mod));
|
|
27
29
|
let _wordpress_data = require("@wordpress/data");
|
|
28
30
|
let __reducer_js = require("./reducer.cjs");
|
|
29
|
-
__reducer_js = __toESM(__reducer_js);
|
|
30
31
|
let __selectors_js = require("./selectors.cjs");
|
|
31
|
-
__selectors_js = __toESM(__selectors_js);
|
|
32
32
|
let __actions_js = require("./actions.cjs");
|
|
33
|
-
__actions_js = __toESM(__actions_js);
|
|
34
33
|
let __resolvers_js = require("./resolvers.cjs");
|
|
34
|
+
__reducer_js = __toESM(__reducer_js);
|
|
35
|
+
__selectors_js = __toESM(__selectors_js);
|
|
36
|
+
__actions_js = __toESM(__actions_js);
|
|
35
37
|
__resolvers_js = __toESM(__resolvers_js);
|
|
36
38
|
// packages/block-directory/src/store/index.js
|
|
37
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["createReduxStore","register"],"sources":["../../src/store/index.js"],"sourcesContent":["import { createReduxStore, register } from '@wordpress/data';\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as resolvers from './resolvers';\n\n/**\n * Module Constants\n */\nconst STORE_NAME = 'core/block-directory';\n\n/**\n * Block editor data store configuration.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore\n *\n * @type {Object}\n */\nexport const storeConfig = {\n\treducer,\n\tselectors,\n\tactions,\n\tresolvers,\n};\n\n/**\n * Store definition for the block directory namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig );\n\nregister( store );\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["reducer","selectors","actions","resolvers","createReduxStore","register"],"sources":["../../src/store/index.js"],"sourcesContent":["import { createReduxStore, register } from '@wordpress/data';\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as resolvers from './resolvers';\n\n/**\n * Module Constants\n */\nconst STORE_NAME = 'core/block-directory';\n\n/**\n * Block editor data store configuration.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore\n *\n * @type {Object}\n */\nexport const storeConfig = {\n\treducer,\n\tselectors,\n\tactions,\n\tresolvers,\n};\n\n/**\n * Store definition for the block directory namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig );\n\nregister( store );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,aAAa;;;;;;;;AASnB,MAAa,cAAc;CAC1BA,SAAAA,aAAAA;CACAC,WAAAA;CACAC,SAAAA;CACAC,WAAAA;AACD;;;;;;;;AASA,MAAa,SAAA,GAAQC,gBAAAA,iBAAAA,CAAkB,YAAY,WAAY;CAE/DC,GAAAA,gBAAAA,SAAAA,CAAU,KAAM"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-assets.cjs","names":["apiFetch"],"sources":["../../src/store/load-assets.js"],"sourcesContent":["import apiFetch from '@wordpress/api-fetch';\n\n/**\n * Load an asset for a block.\n *\n * This function returns a Promise that will resolve once the asset is loaded,\n * or in the case of Stylesheets and Inline JavaScript, will resolve immediately.\n *\n * @param {HTMLElement} el A HTML Element asset to inject.\n *\n * @return {Promise} Promise which will resolve when the asset is loaded.\n */\nexport const loadAsset = ( el ) => {\n\treturn new Promise( ( resolve, reject ) => {\n\t\t/*\n\t\t * Reconstruct the passed element, this is required as inserting the Node directly\n\t\t * won't always fire the required onload events, even if the asset wasn't already loaded.\n\t\t */\n\t\tconst newNode = document.createElement( el.nodeName );\n\n\t\t[ 'id', 'rel', 'src', 'href', 'type' ].forEach( ( attr ) => {\n\t\t\tif ( el[ attr ] ) {\n\t\t\t\tnewNode[ attr ] = el[ attr ];\n\t\t\t}\n\t\t} );\n\n\t\t// Append inline <script> contents.\n\t\tif ( el.innerHTML ) {\n\t\t\tnewNode.appendChild( document.createTextNode( el.innerHTML ) );\n\t\t}\n\n\t\tnewNode.onload = () => resolve( true );\n\t\tnewNode.onerror = () => reject( new Error( 'Error loading asset.' ) );\n\n\t\tdocument.body.appendChild( newNode );\n\n\t\t// Resolve Stylesheets and Inline JavaScript immediately.\n\t\tif (\n\t\t\t'link' === newNode.nodeName.toLowerCase() ||\n\t\t\t( 'script' === newNode.nodeName.toLowerCase() && ! newNode.src )\n\t\t) {\n\t\t\tresolve();\n\t\t}\n\t} );\n};\n\n/**\n * Load the asset files for a block\n */\nexport async function loadAssets() {\n\t/*\n\t * Fetch the current URL (post-new.php, or post.php?post=1&action=edit) and compare the\n\t * JavaScript and CSS assets loaded between the pages. This imports the required assets\n\t * for the block into the current page while not requiring that we know them up-front.\n\t * In the future this can be improved by reliance upon block.json and/or a script-loader\n\t * dependency API.\n\t */\n\tconst response = await apiFetch( {\n\t\turl: document.location.href,\n\t\tparse: false,\n\t} );\n\n\tconst data = await response.text();\n\n\tconst doc = new window.DOMParser().parseFromString( data, 'text/html' );\n\n\tconst newAssets = Array.from(\n\t\tdoc.querySelectorAll( 'link[rel=\"stylesheet\"],script' )\n\t).filter( ( asset ) => asset.id && ! document.getElementById( asset.id ) );\n\n\t/*\n\t * Load each asset in order, as they may depend upon an earlier loaded script.\n\t * Stylesheets and Inline Scripts will resolve immediately upon insertion.\n\t */\n\tfor ( const newAsset of newAssets ) {\n\t\tawait loadAsset( newAsset );\n\t}\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-assets.cjs","names":["apiFetch"],"sources":["../../src/store/load-assets.js"],"sourcesContent":["import apiFetch from '@wordpress/api-fetch';\n\n/**\n * Load an asset for a block.\n *\n * This function returns a Promise that will resolve once the asset is loaded,\n * or in the case of Stylesheets and Inline JavaScript, will resolve immediately.\n *\n * @param {HTMLElement} el A HTML Element asset to inject.\n *\n * @return {Promise} Promise which will resolve when the asset is loaded.\n */\nexport const loadAsset = ( el ) => {\n\treturn new Promise( ( resolve, reject ) => {\n\t\t/*\n\t\t * Reconstruct the passed element, this is required as inserting the Node directly\n\t\t * won't always fire the required onload events, even if the asset wasn't already loaded.\n\t\t */\n\t\tconst newNode = document.createElement( el.nodeName );\n\n\t\t[ 'id', 'rel', 'src', 'href', 'type' ].forEach( ( attr ) => {\n\t\t\tif ( el[ attr ] ) {\n\t\t\t\tnewNode[ attr ] = el[ attr ];\n\t\t\t}\n\t\t} );\n\n\t\t// Append inline <script> contents.\n\t\tif ( el.innerHTML ) {\n\t\t\tnewNode.appendChild( document.createTextNode( el.innerHTML ) );\n\t\t}\n\n\t\tnewNode.onload = () => resolve( true );\n\t\tnewNode.onerror = () => reject( new Error( 'Error loading asset.' ) );\n\n\t\tdocument.body.appendChild( newNode );\n\n\t\t// Resolve Stylesheets and Inline JavaScript immediately.\n\t\tif (\n\t\t\t'link' === newNode.nodeName.toLowerCase() ||\n\t\t\t( 'script' === newNode.nodeName.toLowerCase() && ! newNode.src )\n\t\t) {\n\t\t\tresolve();\n\t\t}\n\t} );\n};\n\n/**\n * Load the asset files for a block\n */\nexport async function loadAssets() {\n\t/*\n\t * Fetch the current URL (post-new.php, or post.php?post=1&action=edit) and compare the\n\t * JavaScript and CSS assets loaded between the pages. This imports the required assets\n\t * for the block into the current page while not requiring that we know them up-front.\n\t * In the future this can be improved by reliance upon block.json and/or a script-loader\n\t * dependency API.\n\t */\n\tconst response = await apiFetch( {\n\t\turl: document.location.href,\n\t\tparse: false,\n\t} );\n\n\tconst data = await response.text();\n\n\tconst doc = new window.DOMParser().parseFromString( data, 'text/html' );\n\n\tconst newAssets = Array.from(\n\t\tdoc.querySelectorAll( 'link[rel=\"stylesheet\"],script' )\n\t).filter( ( asset ) => asset.id && ! document.getElementById( asset.id ) );\n\n\t/*\n\t * Load each asset in order, as they may depend upon an earlier loaded script.\n\t * Stylesheets and Inline Scripts will resolve immediately upon insertion.\n\t */\n\tfor ( const newAsset of newAssets ) {\n\t\tawait loadAsset( newAsset );\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAa,aAAc,OAAQ;CAClC,OAAO,IAAI,SAAW,SAAS,WAAY;EAK1C,MAAM,UAAU,SAAS,cAAe,GAAG,QAAS;EAEpD;GAAE;GAAM;GAAO;GAAO;GAAQ;EAAO,CAAC,CAAC,SAAW,SAAU;GAC3D,IAAK,GAAI,OACR,QAAS,QAAS,GAAI;EAExB,CAAE;EAGF,IAAK,GAAG,WACP,QAAQ,YAAa,SAAS,eAAgB,GAAG,SAAU,CAAE;EAG9D,QAAQ,eAAe,QAAS,IAAK;EACrC,QAAQ,gBAAgB,uBAAQ,IAAI,MAAO,sBAAuB,CAAE;EAEpE,SAAS,KAAK,YAAa,OAAQ;EAGnC,IACC,WAAW,QAAQ,SAAS,YAAY,KACtC,aAAa,QAAQ,SAAS,YAAY,KAAK,CAAE,QAAQ,KAE3D,QAAQ;CAEV,CAAE;AACH;;;;AAKA,eAAsB,aAAa;CAalC,MAAM,OAAO,OAAM,OAAA,GALIA,qBAAAA,QAAAA,CAAU;EAChC,KAAK,SAAS,SAAS;EACvB,OAAO;CACR,CAAE,EAAA,CAE0B,KAAK;CAEjC,MAAM,MAAM,IAAI,OAAO,UAAU,CAAC,CAAC,gBAAiB,MAAM,WAAY;CAEtE,MAAM,YAAY,MAAM,KACvB,IAAI,iBAAkB,iCAAgC,CACvD,CAAC,CAAC,QAAU,UAAW,MAAM,MAAM,CAAE,SAAS,eAAgB,MAAM,EAAG,CAAE;CAMzE,KAAM,MAAM,YAAY,WACvB,MAAM,UAAW,QAAS;AAE5B"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -26,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
28
|
}) : target, mod));
|
|
27
29
|
let change_case = require("change-case");
|
|
28
30
|
let _wordpress_api_fetch = require("@wordpress/api-fetch");
|
|
29
|
-
_wordpress_api_fetch = __toESM(_wordpress_api_fetch);
|
|
30
31
|
let __actions_js = require("./actions.cjs");
|
|
32
|
+
_wordpress_api_fetch = __toESM(_wordpress_api_fetch);
|
|
31
33
|
// packages/block-directory/src/store/resolvers.js
|
|
32
34
|
const getDownloadableBlocks = (filterValue) => async ({ dispatch }) => {
|
|
33
35
|
if (!filterValue) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.cjs","names":["fetchDownloadableBlocks","apiFetch","camelCase","receiveDownloadableBlocks"],"sources":["../../src/store/resolvers.js"],"sourcesContent":["import { camelCase } from 'change-case';\nimport apiFetch from '@wordpress/api-fetch';\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( result ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {\n\t\t\tdispatch( receiveDownloadableBlocks( [], filterValue ) );\n\t\t}\n\t};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolvers.cjs","names":["fetchDownloadableBlocks","apiFetch","camelCase","receiveDownloadableBlocks"],"sources":["../../src/store/resolvers.js"],"sourcesContent":["import { camelCase } from 'change-case';\nimport apiFetch from '@wordpress/api-fetch';\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( result ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {\n\t\t\tdispatch( receiveDownloadableBlocks( [], filterValue ) );\n\t\t}\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAa,yBACV,gBACF,OAAQ,EAAE,eAAgB;CACzB,IAAK,CAAE,aACN;CAGD,IAAI;EACH,UAAA,GAAUA,aAAAA,wBAAAA,CAAyB,WAAY,CAAE;EAIjD,MAAM,UAAS,OAAA,GAHOC,qBAAAA,QAAAA,CAAU,EAC/B,MAAM,qCAAsC,cAC7C,CAAE,EAAA,CACqB,KAAO,WAC7B,OAAO,YACN,OAAO,QAAS,MAAO,CAAC,CAAC,KAAO,CAAE,KAAK,WAAa,EAAA,GACnDC,YAAAA,UAAAA,CAAW,GAAI,GACf,KACD,CAAE,CACH,CACD;EAEA,UAAA,GAAUC,aAAAA,0BAAAA,CAA2B,QAAQ,WAAY,CAAE;CAC5D,QAAQ;EACP,UAAA,GAAUA,aAAAA,0BAAAA,CAA2B,CAAC,GAAG,WAAY,CAAE;CACxD;AACD"}
|
|
@@ -8,7 +8,11 @@ function Stars({ rating }) {
|
|
|
8
8
|
const halfStarCount = Math.ceil(rating - fullStarCount);
|
|
9
9
|
const emptyStarCount = 5 - (fullStarCount + halfStarCount);
|
|
10
10
|
return /* @__PURE__ */ jsxs("span", {
|
|
11
|
-
"aria-label": sprintf(
|
|
11
|
+
"aria-label": sprintf(
|
|
12
|
+
/** translators: %s: number of stars. */
|
|
13
|
+
__("%s out of 5 stars"),
|
|
14
|
+
stars
|
|
15
|
+
),
|
|
12
16
|
children: [
|
|
13
17
|
Array.from({ length: fullStarCount }).map((_, i) => /* @__PURE__ */ jsx(Icon, {
|
|
14
18
|
className: "block-directory-block-ratings__star-full",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stars.mjs","names":[],"sources":["../../../src/components/block-ratings/stars.jsx"],"sourcesContent":["import { __, sprintf } from '@wordpress/i18n';\nimport { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons';\n\nfunction Stars( { rating } ) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tconst fullStarCount = Math.floor( rating );\n\tconst halfStarCount = Math.ceil( rating - fullStarCount );\n\tconst emptyStarCount = 5 - ( fullStarCount + halfStarCount );\n\n\treturn (\n\t\t<span\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: %s: number of stars. */\n\t\t\t\t__( '%s out of 5 stars' ),\n\t\t\t\tstars\n\t\t\t) }\n\t\t>\n\t\t\t{ Array.from( { length: fullStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `full_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-full\"\n\t\t\t\t\ticon={ starFilled }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: halfStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `half_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-half-full\"\n\t\t\t\t\ticon={ starHalf }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: emptyStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `empty_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-empty\"\n\t\t\t\t\ticon={ starEmpty }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</span>\n\t);\n}\n\nexport default Stars;\n"],"mappings":";;;;AAGA,SAAS,MAAO,EAAE,UAAW;CAC5B,MAAM,QAAQ,KAAK,MAAO,SAAS,EAAI,IAAI;CAE3C,MAAM,gBAAgB,KAAK,MAAO,MAAO;CACzC,MAAM,gBAAgB,KAAK,KAAM,SAAS,aAAc;CACxD,MAAM,iBAAiB,KAAM,gBAAgB;CAE7C,OACC,qBAAC,QAAD;EACC,cAAa,
|
|
1
|
+
{"version":3,"file":"stars.mjs","names":[],"sources":["../../../src/components/block-ratings/stars.jsx"],"sourcesContent":["import { __, sprintf } from '@wordpress/i18n';\nimport { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons';\n\nfunction Stars( { rating } ) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tconst fullStarCount = Math.floor( rating );\n\tconst halfStarCount = Math.ceil( rating - fullStarCount );\n\tconst emptyStarCount = 5 - ( fullStarCount + halfStarCount );\n\n\treturn (\n\t\t<span\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: %s: number of stars. */\n\t\t\t\t__( '%s out of 5 stars' ),\n\t\t\t\tstars\n\t\t\t) }\n\t\t>\n\t\t\t{ Array.from( { length: fullStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `full_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-full\"\n\t\t\t\t\ticon={ starFilled }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: halfStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `half_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-half-full\"\n\t\t\t\t\ticon={ starHalf }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: emptyStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `empty_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-empty\"\n\t\t\t\t\ticon={ starEmpty }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</span>\n\t);\n}\n\nexport default Stars;\n"],"mappings":";;;;AAGA,SAAS,MAAO,EAAE,UAAW;CAC5B,MAAM,QAAQ,KAAK,MAAO,SAAS,EAAI,IAAI;CAE3C,MAAM,gBAAgB,KAAK,MAAO,MAAO;CACzC,MAAM,gBAAgB,KAAK,KAAM,SAAS,aAAc;CACxD,MAAM,iBAAiB,KAAM,gBAAgB;CAE7C,OACC,qBAAC,QAAD;EACC,cAAa;;GAEZ,GAAI,mBAAoB;GACxB;EACD;EALD,UAAA;GAOG,MAAM,KAAM,EAAE,QAAQ,cAAc,CAAE,CAAC,CAAC,KAAO,GAAG,MACnD,oBAAC,MAAD;IAEC,WAAU;IACV,MAAO;IACP,MAAO;GACP,GAJM,cAAe,GAIrB,CACA;GACA,MAAM,KAAM,EAAE,QAAQ,cAAc,CAAE,CAAC,CAAC,KAAO,GAAG,MACnD,oBAAC,MAAD;IAEC,WAAU;IACV,MAAO;IACP,MAAO;GACP,GAJM,cAAe,GAIrB,CACA;GACA,MAAM,KAAM,EAAE,QAAQ,eAAe,CAAE,CAAC,CAAC,KAAO,GAAG,MACpD,oBAAC,MAAD;IAEC,WAAU;IACV,MAAO;IACP,MAAO;GACP,GAJM,eAAgB,GAItB,CACA;EACG;;AAER"}
|
|
@@ -18,7 +18,11 @@ function CompactList({ items }) {
|
|
|
18
18
|
children: title
|
|
19
19
|
}), /* @__PURE__ */ jsx("div", {
|
|
20
20
|
className: "block-directory-compact-list__item-author",
|
|
21
|
-
children: sprintf(
|
|
21
|
+
children: sprintf(
|
|
22
|
+
/** translators: %s: Name of the block author. */
|
|
23
|
+
__("By %s"),
|
|
24
|
+
author
|
|
25
|
+
)
|
|
22
26
|
})]
|
|
23
27
|
})]
|
|
24
28
|
}, id))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/compact-list/index.jsx"],"sourcesContent":["import { __, sprintf } from '@wordpress/i18n';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\n\nexport default function CompactList( { items } ) {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ul className=\"block-directory-compact-list\">\n\t\t\t{ items.map( ( { icon, id, title, author } ) => (\n\t\t\t\t<li key={ id } className=\"block-directory-compact-list__item\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\n\t\t\t\t\t<div className=\"block-directory-compact-list__item-details\">\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-title\">\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-author\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Name of the block author. */\n\t\t\t\t\t\t\t\t__( 'By %s' ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"],"mappings":";;;;AAGA,SAAwB,YAAa,EAAE,SAAU;CAChD,IAAK,CAAE,MAAM,QACZ,OAAO;CAGR,OACC,oBAAC,MAAD;EAAI,WAAU;EACX,UAAA,MAAM,KAAO,EAAE,MAAM,IAAI,OAAO,aACjC,qBAAC,MAAD;GAAe,WAAU;GAAzB,UAAA,CACC,oBAAC,uBAAD;IAA8B;IAAe;GAAS,CAAA,GAEtD,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACC,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA;IACE,CAAA,GACL,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA,
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/compact-list/index.jsx"],"sourcesContent":["import { __, sprintf } from '@wordpress/i18n';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\n\nexport default function CompactList( { items } ) {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ul className=\"block-directory-compact-list\">\n\t\t\t{ items.map( ( { icon, id, title, author } ) => (\n\t\t\t\t<li key={ id } className=\"block-directory-compact-list__item\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\n\t\t\t\t\t<div className=\"block-directory-compact-list__item-details\">\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-title\">\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-author\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Name of the block author. */\n\t\t\t\t\t\t\t\t__( 'By %s' ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"],"mappings":";;;;AAGA,SAAwB,YAAa,EAAE,SAAU;CAChD,IAAK,CAAE,MAAM,QACZ,OAAO;CAGR,OACC,oBAAC,MAAD;EAAI,WAAU;EACX,UAAA,MAAM,KAAO,EAAE,MAAM,IAAI,OAAO,aACjC,qBAAC,MAAD;GAAe,WAAU;GAAzB,UAAA,CACC,oBAAC,uBAAD;IAA8B;IAAe;GAAS,CAAA,GAEtD,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACC,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA;IACE,CAAA,GACL,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA;;MAED,GAAI,OAAQ;MACZ;KACD;IACI,CAAA,CACD;GACF,CAAA,CAAA;EAfM,GAAA,EAeN,CACH;CACC,CAAA;AAEN"}
|
|
@@ -14,11 +14,33 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
// packages/block-directory/src/components/downloadable-block-list-item/index.jsx
|
|
15
15
|
function getDownloadableBlockLabel({ title, rating, ratingCount }, { hasNotice, isInstalled, isInstalling }) {
|
|
16
16
|
const stars = Math.round(rating / .5) * .5;
|
|
17
|
-
if (!isInstalled && hasNotice) return sprintf(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
if (!isInstalled && hasNotice) return sprintf(
|
|
18
|
+
/** translators: %s: block title */
|
|
19
|
+
__("Retry installing %s."),
|
|
20
|
+
decodeEntities(title)
|
|
21
|
+
);
|
|
22
|
+
if (isInstalled) return sprintf(
|
|
23
|
+
/** translators: %s: block title */
|
|
24
|
+
__("Add %s."),
|
|
25
|
+
decodeEntities(title)
|
|
26
|
+
);
|
|
27
|
+
if (isInstalling) return sprintf(
|
|
28
|
+
/** translators: %s: block title */
|
|
29
|
+
__("Installing %s."),
|
|
30
|
+
decodeEntities(title)
|
|
31
|
+
);
|
|
32
|
+
if (ratingCount < 1) return sprintf(
|
|
33
|
+
/** translators: %s: block title */
|
|
34
|
+
__("Install %s."),
|
|
35
|
+
decodeEntities(title)
|
|
36
|
+
);
|
|
37
|
+
return sprintf(
|
|
38
|
+
/** translators: 1: block title, 2: average rating, 3: total ratings count. */
|
|
39
|
+
_n("Install %1$s. %2$s stars with %3$s review.", "Install %1$s. %2$s stars with %3$s reviews.", ratingCount),
|
|
40
|
+
decodeEntities(title),
|
|
41
|
+
stars,
|
|
42
|
+
ratingCount
|
|
43
|
+
);
|
|
22
44
|
}
|
|
23
45
|
function DownloadableBlockListItem({ item, onClick }) {
|
|
24
46
|
const { author, description, icon, rating, title } = item;
|
|
@@ -65,7 +87,12 @@ function DownloadableBlockListItem({ item, onClick }) {
|
|
|
65
87
|
className: "block-directory-downloadable-block-list-item__details",
|
|
66
88
|
children: [/* @__PURE__ */ jsx("span", {
|
|
67
89
|
className: "block-directory-downloadable-block-list-item__title",
|
|
68
|
-
children: createInterpolateElement(sprintf(
|
|
90
|
+
children: createInterpolateElement(sprintf(
|
|
91
|
+
/** translators: 1: block title. 2: author name. */
|
|
92
|
+
__("%1$s <span>by %2$s</span>"),
|
|
93
|
+
decodeEntities(title),
|
|
94
|
+
author
|
|
95
|
+
), { span: /* @__PURE__ */ jsx("span", { className: "block-directory-downloadable-block-list-item__author" }) })
|
|
69
96
|
}), hasNotice ? /* @__PURE__ */ jsx(DownloadableBlockNotice, { block: item }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
70
97
|
className: "block-directory-downloadable-block-list-item__desc",
|
|
71
98
|
children: !!statusText ? statusText : decodeEntities(description)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["blockDirectoryStore","WCSpinner"],"sources":["../../../src/components/downloadable-block-list-item/index.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { Spinner as WCSpinner, Composite } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { VisuallyHidden, Tooltip } from '@wordpress/ui';\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Retry installing %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\tif ( isInstalled ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Add %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\tif ( isInstalling ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Installing %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Install %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\treturn sprintf(\n\t\t/* translators: 1: block title, 2: average rating, 3: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =\n\t\t\t\tselect( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\tconst itemLabel = getDownloadableBlockLabel( item, {\n\t\thasNotice,\n\t\tisInstalled,\n\t\tisInstalling,\n\t} );\n\n\treturn (\n\t\t<Tooltip.Root>\n\t\t\t<Tooltip.Trigger\n\t\t\t\trender={\n\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-directory-downloadable-block-list-item',\n\t\t\t\t\t\t\tisInstalling && 'is-installing'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tonClick();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\taria-label={ itemLabel }\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t\t\t\t<DownloadableBlockIcon\n\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t\t\t\t<WCSpinner />\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: 1: block title. 2: author name. */\n\t\t\t\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Composite.Item>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Tooltip.Popup>{ itemLabel }</Tooltip.Popup>\n\t\t</Tooltip.Root>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,0BACR,EAAE,OAAO,QAAQ,eACjB,EAAE,WAAW,aAAa,gBACzB;CACD,MAAM,QAAQ,KAAK,MAAO,SAAS,EAAI,IAAI;CAE3C,IAAK,CAAE,eAAe,WACrB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["blockDirectoryStore","WCSpinner"],"sources":["../../../src/components/downloadable-block-list-item/index.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { Spinner as WCSpinner, Composite } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { VisuallyHidden, Tooltip } from '@wordpress/ui';\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Retry installing %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\tif ( isInstalled ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Add %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\tif ( isInstalling ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Installing %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Install %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\treturn sprintf(\n\t\t/* translators: 1: block title, 2: average rating, 3: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =\n\t\t\t\tselect( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\tconst itemLabel = getDownloadableBlockLabel( item, {\n\t\thasNotice,\n\t\tisInstalled,\n\t\tisInstalling,\n\t} );\n\n\treturn (\n\t\t<Tooltip.Root>\n\t\t\t<Tooltip.Trigger\n\t\t\t\trender={\n\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-directory-downloadable-block-list-item',\n\t\t\t\t\t\t\tisInstalling && 'is-installing'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tonClick();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\taria-label={ itemLabel }\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t\t\t\t<DownloadableBlockIcon\n\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t\t\t\t<WCSpinner />\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: 1: block title. 2: author name. */\n\t\t\t\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Composite.Item>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Tooltip.Popup>{ itemLabel }</Tooltip.Popup>\n\t\t</Tooltip.Root>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,0BACR,EAAE,OAAO,QAAQ,eACjB,EAAE,WAAW,aAAa,gBACzB;CACD,MAAM,QAAQ,KAAK,MAAO,SAAS,EAAI,IAAI;CAE3C,IAAK,CAAE,eAAe,WACrB,OAAO;;EAEN,GAAI,sBAAuB;EAC3B,eAAgB,KAAM;CACvB;CAGD,IAAK,aACJ,OAAO;;EAEN,GAAI,SAAU;EACd,eAAgB,KAAM;CACvB;CAGD,IAAK,cACJ,OAAO;;EAEN,GAAI,gBAAiB;EACrB,eAAgB,KAAM;CACvB;CAID,IAAK,cAAc,GAClB,OAAO;;EAEN,GAAI,aAAc;EAClB,eAAgB,KAAM;CACvB;CAGD,OAAO;;EAEN,GACC,8CACA,+CACA,WACD;EACA,eAAgB,KAAM;EACtB;EACA;CACD;AACD;AAEA,SAAS,0BAA2B,EAAE,MAAM,WAAY;CACvD,MAAM,EAAE,QAAQ,aAAa,MAAM,QAAQ,UAAU;CAErD,MAAM,cAAc,CAAC,CAAE,aAAc,KAAK,IAAK;CAE/C,MAAM,EAAE,WAAW,cAAc,kBAAkB,WAChD,WAAY;EACb,MAAM,EAAE,wBAAwB,cAAc,sBAC7C,OAAQA,KAAoB;EAC7B,MAAM,SAAS,uBAAwB,KAAK,EAAG;EAC/C,MAAM,WAAW,UAAU,OAAO;EAClC,OAAO;GACN,WAAW,CAAC,CAAE;GACd,cAAc,kBAAmB,KAAK,EAAG;GACzC,eAAe,CAAE;EAClB;CACD,GACA,CAAE,IAAK,CACR;CAEA,IAAI,aAAa;CACjB,IAAK,aACJ,aAAa,GAAI,YAAa;MACxB,IAAK,cACX,aAAa,GAAI,aAAc;CAGhC,MAAM,YAAY,0BAA2B,MAAM;EAClD;EACA;EACA;CACD,CAAE;CAEF,OACC,qBAAC,QAAQ,MAAT,EAAA,UAAA,CACC,oBAAC,QAAQ,SAAT,EACC,QACC,qBAAC,UAAU,MAAX;EACC,WAAY,KACX,gDACA,gBAAgB,eACjB;EACA,wBAAA;EACA,UAAW,gBAAgB,CAAE;EAC7B,UAAY,UAAW;GACtB,MAAM,eAAe;GACrB,QAAQ;EACT;EACA,cAAa;EACb,MAAK;EACL,MAAK;EAbN,UAAA,CAeC,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACC,oBAAC,uBAAD;IACQ;IACC;GACR,CAAA,GACC,eACD,oBAAC,QAAD;IAAM,WAAU;IACf,UAAA,oBAACC,SAAD,CAAY,CAAA;GACP,CAAA,IAEN,oBAAC,cAAD,EAAuB,OAAU,CAAA,CAE9B;EACL,CAAA,GAAA,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACC,oBAAC,QAAD;IAAM,WAAU;IACb,UAAA,yBACD;;KAEC,GAAI,2BAA4B;KAChC,eAAgB,KAAM;KACtB;IACD,GACA,EACC,MACC,oBAAC,QAAD,EAAM,WAAU,uDAAwD,CAAA,EAE1E,CACD;GACK,CAAA,GACJ,YACD,oBAAC,yBAAD,EAAyB,OAAQ,KAAQ,CAAA,IAEzC,qBAAA,UAAA,EAAA,UAAA,CACC,oBAAC,QAAD;IAAM,WAAU;IACb,UAAA,CAAC,CAAE,aACF,aACA,eAAgB,WAAY;GAC1B,CAAA,GACJ,iBACD,EAAI,eAAe,iBAClB,oBAAC,gBAAD,EAAA,UACG,GAAI,eAAgB,EACP,CAAA,CAEjB,EAAA,CAAA,CAEE;EACS,CAAA,CAAA;CAEjB,CAAA,EAAA,CAAA,GACD,oBAAC,QAAQ,OAAT,EAAA,UAAiB,UAA0B,CAAA,CAC9B,EAAA,CAAA;AAEhB"}
|
|
@@ -6,7 +6,11 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
function DownloadableBlocksInserterPanel({ children, downloadableItems, hasLocalBlocks }) {
|
|
7
7
|
const count = downloadableItems.length;
|
|
8
8
|
useEffect(() => {
|
|
9
|
-
speak(sprintf(
|
|
9
|
+
speak(sprintf(
|
|
10
|
+
/** translators: %d: number of available blocks. */
|
|
11
|
+
_n("%d additional block is available to install.", "%d additional blocks are available to install.", count),
|
|
12
|
+
count
|
|
13
|
+
));
|
|
10
14
|
}, [count]);
|
|
11
15
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
12
16
|
!hasLocalBlocks && /* @__PURE__ */ jsx("p", {
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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;;GAEC,GACC,gDACA,kDACA,KACD;GACA;EACD,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"}
|
|
@@ -36,14 +36,22 @@ const ModifiedWarning = ({ originalBlock, ...props }) => {
|
|
|
36
36
|
const { canInsertBlockType, getBlockRootClientId } = select(store$1);
|
|
37
37
|
return canInsertBlockType("core/html", getBlockRootClientId(clientId));
|
|
38
38
|
}, [clientId]);
|
|
39
|
-
let messageHTML = sprintf(
|
|
39
|
+
let messageHTML = sprintf(
|
|
40
|
+
/** translators: %s: block name */
|
|
41
|
+
__("Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely."),
|
|
42
|
+
originalBlock.title || originalName
|
|
43
|
+
);
|
|
40
44
|
const actions = [/* @__PURE__ */ jsx(InstallButton, {
|
|
41
45
|
block: originalBlock,
|
|
42
46
|
attributes: props.attributes,
|
|
43
47
|
clientId: props.clientId
|
|
44
48
|
}, "install")];
|
|
45
49
|
if (hasContent && hasHTMLBlock) {
|
|
46
|
-
messageHTML = sprintf(
|
|
50
|
+
messageHTML = sprintf(
|
|
51
|
+
/** translators: %s: block name */
|
|
52
|
+
__("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."),
|
|
53
|
+
originalBlock.title || originalName
|
|
54
|
+
);
|
|
47
55
|
actions.push(/* @__PURE__ */ jsx(Button, {
|
|
48
56
|
__next40pxDefaultSize: true,
|
|
49
57
|
onClick: convertToHTML,
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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;;EAEjB,GACC,6GACD;EACA,cAAc,SAAS;CACxB;CACA,MAAM,UAAU,CACf,oBAAC,eAAD;EAEC,OAAQ;EACR,YAAa,MAAM;EACnB,UAAW,MAAM;CACjB,GAJI,SAIJ,CACF;CAEA,IAAK,cAAc,cAAe;EACjC,cAAc;;GAEb,GACC,iJACD;GACA,cAAc,SAAS;EACxB;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"}
|