@wordpress/block-directory 5.57.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/auto-block-uninstaller/index.cjs +26 -47
- package/build/components/auto-block-uninstaller/index.cjs.map +1 -7
- package/build/components/block-ratings/index.cjs +28 -34
- package/build/components/block-ratings/index.cjs.map +1 -7
- package/build/components/block-ratings/stars.cjs +35 -71
- package/build/components/block-ratings/stars.cjs.map +1 -7
- package/build/components/compact-list/index.cjs +45 -43
- package/build/components/compact-list/index.cjs.map +1 -7
- package/build/components/downloadable-block-icon/index.cjs +20 -29
- package/build/components/downloadable-block-icon/index.cjs.map +1 -7
- package/build/components/downloadable-block-list-item/index.cjs +95 -161
- package/build/components/downloadable-block-list-item/index.cjs.map +1 -7
- package/build/components/downloadable-block-notice/index.cjs +23 -46
- package/build/components/downloadable-block-notice/index.cjs.map +1 -7
- package/build/components/downloadable-blocks-list/index.cjs +50 -70
- package/build/components/downloadable-blocks-list/index.cjs.map +1 -7
- package/build/components/downloadable-blocks-panel/index.cjs +79 -119
- package/build/components/downloadable-blocks-panel/index.cjs.map +1 -7
- package/build/components/downloadable-blocks-panel/inserter-panel.cjs +37 -61
- package/build/components/downloadable-blocks-panel/inserter-panel.cjs.map +1 -7
- package/build/components/downloadable-blocks-panel/no-results.cjs +27 -39
- package/build/components/downloadable-blocks-panel/no-results.cjs.map +1 -7
- package/build/index.cjs +11 -29
- package/build/plugins/get-install-missing/index.cjs +80 -122
- package/build/plugins/get-install-missing/index.cjs.map +1 -7
- package/build/plugins/get-install-missing/install-button.cjs +33 -70
- package/build/plugins/get-install-missing/install-button.cjs.map +1 -7
- package/build/plugins/index.cjs +45 -45
- package/build/plugins/index.cjs.map +1 -7
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs +40 -52
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs.map +1 -7
- package/build/plugins/installed-blocks-pre-publish-panel/index.cjs +38 -62
- package/build/plugins/installed-blocks-pre-publish-panel/index.cjs.map +1 -7
- package/build/store/actions.cjs +233 -205
- package/build/store/actions.cjs.map +1 -7
- package/build/store/index.cjs +56 -45
- package/build/store/index.cjs.map +1 -7
- package/build/store/load-assets.cjs +62 -63
- package/build/store/load-assets.cjs.map +1 -7
- package/build/store/reducer.cjs +90 -101
- package/build/store/reducer.cjs.map +1 -7
- package/build/store/resolvers.cjs +34 -54
- package/build/store/resolvers.cjs.map +1 -7
- package/build/store/selectors.cjs +111 -107
- package/build/store/selectors.cjs.map +1 -7
- package/build/store/utils/get-plugin-url.cjs +19 -32
- package/build/store/utils/get-plugin-url.cjs.map +1 -7
- package/build-module/components/auto-block-uninstaller/index.mjs +19 -25
- package/build-module/components/auto-block-uninstaller/index.mjs.map +1 -7
- package/build-module/components/block-ratings/index.mjs +8 -8
- package/build-module/components/block-ratings/index.mjs.map +1 -7
- package/build-module/components/block-ratings/stars.mjs +28 -49
- package/build-module/components/block-ratings/stars.mjs.map +1 -7
- package/build-module/components/compact-list/index.mjs +24 -19
- package/build-module/components/compact-list/index.mjs.map +1 -7
- package/build-module/components/downloadable-block-icon/index.mjs +14 -8
- package/build-module/components/downloadable-block-icon/index.mjs.map +1 -7
- package/build-module/components/downloadable-block-list-item/index.mjs +64 -130
- package/build-module/components/downloadable-block-list-item/index.mjs.map +1 -7
- package/build-module/components/downloadable-block-notice/index.mjs +15 -20
- package/build-module/components/downloadable-block-notice/index.mjs.map +1 -7
- package/build-module/components/downloadable-blocks-list/index.mjs +26 -43
- package/build-module/components/downloadable-blocks-list/index.mjs.map +1 -7
- package/build-module/components/downloadable-blocks-panel/index.mjs +51 -90
- package/build-module/components/downloadable-blocks-panel/index.mjs.map +1 -7
- package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs +29 -38
- package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs.map +1 -7
- package/build-module/components/downloadable-blocks-panel/no-results.mjs +21 -18
- package/build-module/components/downloadable-blocks-panel/no-results.mjs.map +1 -7
- package/build-module/index.mjs +1 -6
- package/build-module/plugins/get-install-missing/index.mjs +55 -98
- package/build-module/plugins/get-install-missing/index.mjs.map +1 -7
- package/build-module/plugins/get-install-missing/install-button.mjs +25 -47
- package/build-module/plugins/get-install-missing/install-button.mjs.map +1 -7
- package/build-module/plugins/index.mjs +16 -23
- package/build-module/plugins/index.mjs.map +1 -7
- package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs +17 -26
- package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs.map +1 -7
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs +15 -36
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs.map +1 -7
- package/build-module/store/actions.mjs +201 -170
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/index.mjs +28 -13
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/load-assets.mjs +42 -36
- package/build-module/store/load-assets.mjs.map +1 -7
- package/build-module/store/reducer.mjs +81 -74
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/resolvers.mjs +13 -26
- package/build-module/store/resolvers.mjs.map +1 -7
- package/build-module/store/selectors.mjs +99 -76
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/store/utils/get-plugin-url.mjs +14 -12
- package/build-module/store/utils/get-plugin-url.mjs.map +1 -7
- package/build-style/style-rtl.css +6 -12
- package/build-style/style.css +6 -12
- package/package.json +25 -27
- package/src/components/downloadable-block-list-item/index.jsx +2 -2
- package/src/components/downloadable-block-list-item/style.scss +6 -6
- package/src/components/downloadable-blocks-panel/index.jsx +2 -2
- package/src/components/downloadable-blocks-panel/no-results.jsx +15 -8
- package/CHANGELOG.md +0 -295
- package/build/index.cjs.map +0 -7
- package/build/lock-unlock.cjs +0 -36
- package/build/lock-unlock.cjs.map +0 -7
- package/build-module/index.mjs.map +0 -7
- package/build-module/lock-unlock.mjs +0 -11
- package/build-module/lock-unlock.mjs.map +0 -7
- package/src/lock-unlock.js +0 -7
|
@@ -1,64 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
// \0rolldown/runtime.js
|
|
1
7
|
var __create = Object.create;
|
|
2
8
|
var __defProp = Object.defineProperty;
|
|
3
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
13
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
+
key = keys[i];
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
18
22
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
let change_case = require("change-case");
|
|
28
|
+
let _wordpress_api_fetch = require("@wordpress/api-fetch");
|
|
29
|
+
_wordpress_api_fetch = __toESM(_wordpress_api_fetch);
|
|
30
|
+
let __actions_js = require("./actions.cjs");
|
|
29
31
|
// packages/block-directory/src/store/resolvers.js
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!filterValue) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
dispatch((0, import_actions.fetchDownloadableBlocks)(filterValue));
|
|
44
|
-
const results = await (0, import_api_fetch.default)({
|
|
45
|
-
path: `wp/v2/block-directory/search?term=${filterValue}`
|
|
46
|
-
});
|
|
47
|
-
const blocks = results.map(
|
|
48
|
-
(result) => Object.fromEntries(
|
|
49
|
-
Object.entries(result).map(([key, value]) => [
|
|
50
|
-
(0, import_change_case.camelCase)(key),
|
|
51
|
-
value
|
|
52
|
-
])
|
|
53
|
-
)
|
|
54
|
-
);
|
|
55
|
-
dispatch((0, import_actions.receiveDownloadableBlocks)(blocks, filterValue));
|
|
56
|
-
} catch {
|
|
57
|
-
dispatch((0, import_actions.receiveDownloadableBlocks)([], filterValue));
|
|
58
|
-
}
|
|
32
|
+
const getDownloadableBlocks = (filterValue) => async ({ dispatch }) => {
|
|
33
|
+
if (!filterValue) return;
|
|
34
|
+
try {
|
|
35
|
+
dispatch((0, __actions_js.fetchDownloadableBlocks)(filterValue));
|
|
36
|
+
const blocks = (await (0, _wordpress_api_fetch.default)({ path: `wp/v2/block-directory/search?term=${filterValue}` })).map((result) => Object.fromEntries(Object.entries(result).map(([key, value]) => [(0, change_case.camelCase)(key), value])));
|
|
37
|
+
dispatch((0, __actions_js.receiveDownloadableBlocks)(blocks, filterValue));
|
|
38
|
+
} catch {
|
|
39
|
+
dispatch((0, __actions_js.receiveDownloadableBlocks)([], filterValue));
|
|
40
|
+
}
|
|
59
41
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
//# sourceMappingURL=resolvers.cjs.map
|
|
42
|
+
exports.getDownloadableBlocks = getDownloadableBlocks;
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=resolvers.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/store/resolvers.js"],
|
|
4
|
-
"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"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA0B;AAC1B,uBAAqB;AACrB,qBAAmE;AAE5D,IAAM,wBACZ,CAAE,gBACF,OAAQ,EAAE,SAAS,MAAO;AACzB,MAAK,CAAE,aAAc;AACpB;AAAA,EACD;AAEA,MAAI;AACH,iBAAU,wCAAyB,WAAY,CAAE;AACjD,UAAM,UAAU,UAAM,iBAAAA,SAAU;AAAA,MAC/B,MAAM,qCAAsC,WAAY;AAAA,IACzD,CAAE;AACF,UAAM,SAAS,QAAQ;AAAA,MAAK,CAAE,WAC7B,OAAO;AAAA,QACN,OAAO,QAAS,MAAO,EAAE,IAAK,CAAE,CAAE,KAAK,KAAM,MAAO;AAAA,cACnD,8BAAW,GAAI;AAAA,UACf;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAEA,iBAAU,0CAA2B,QAAQ,WAAY,CAAE;AAAA,EAC5D,QAAQ;AACP,iBAAU,0CAA2B,CAAC,GAAG,WAAY,CAAE;AAAA,EACxD;AACD;",
|
|
6
|
-
"names": ["apiFetch"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"resolvers.cjs","names":["fetchDownloadableBlocks","apiFetch","camelCase","receiveDownloadableBlocks"],"sources":["../../src/store/resolvers.js"],"sourcesContent":["import { camelCase } from 'change-case';\nimport apiFetch from '@wordpress/api-fetch';\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( result ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {\n\t\t\tdispatch( receiveDownloadableBlocks( [], filterValue ) );\n\t\t}\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAa,yBACV,gBACF,OAAQ,EAAE,eAAgB;CACzB,IAAK,CAAE,aACN;CAGD,IAAI;EACH,UAAA,GAAUA,aAAAA,wBAAAA,CAAyB,WAAY,CAAE;EAIjD,MAAM,UAAS,OAAA,GAHOC,qBAAAA,QAAAA,CAAU,EAC/B,MAAM,qCAAsC,cAC7C,CAAE,EAAA,CACqB,KAAO,WAC7B,OAAO,YACN,OAAO,QAAS,MAAO,CAAC,CAAC,KAAO,CAAE,KAAK,WAAa,EAAA,GACnDC,YAAAA,UAAAA,CAAW,GAAI,GACf,KACD,CAAE,CACH,CACD;EAEA,UAAA,GAAUC,aAAAA,0BAAAA,CAA2B,QAAQ,WAAY,CAAE;CAC5D,QAAQ;EACP,UAAA,GAAUA,aAAAA,0BAAAA,CAA2B,CAAC,GAAG,WAAY,CAAE;CACxD;AACD"}
|
|
@@ -1,120 +1,124 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// packages/block-directory/src/store/selectors.js
|
|
20
|
-
var selectors_exports = {};
|
|
21
|
-
__export(selectors_exports, {
|
|
22
|
-
getDownloadableBlocks: () => getDownloadableBlocks,
|
|
23
|
-
getErrorNoticeForBlock: () => getErrorNoticeForBlock,
|
|
24
|
-
getErrorNotices: () => getErrorNotices,
|
|
25
|
-
getInstalledBlockTypes: () => getInstalledBlockTypes,
|
|
26
|
-
getNewBlockTypes: () => getNewBlockTypes,
|
|
27
|
-
getUnusedBlockTypes: () => getUnusedBlockTypes,
|
|
28
|
-
isInstalling: () => isInstalling,
|
|
29
|
-
isRequestingDownloadableBlocks: () => isRequestingDownloadableBlocks
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
30
5
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
6
|
+
let _wordpress_data = require("@wordpress/data");
|
|
7
|
+
let _wordpress_block_editor = require("@wordpress/block-editor");
|
|
8
|
+
// packages/block-directory/src/store/selectors.js
|
|
9
|
+
const EMPTY_ARRAY = [];
|
|
10
|
+
/**
|
|
11
|
+
* Returns true if application is requesting for downloadable blocks.
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} state Global application state.
|
|
14
|
+
* @param {string} filterValue Search string.
|
|
15
|
+
*
|
|
16
|
+
* @return {boolean} Whether a request is in progress for the blocks list.
|
|
17
|
+
*/
|
|
35
18
|
function isRequestingDownloadableBlocks(state, filterValue) {
|
|
36
|
-
|
|
19
|
+
return state.downloadableBlocks[filterValue]?.isRequesting ?? false;
|
|
37
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns the available uninstalled blocks.
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} state Global application state.
|
|
25
|
+
* @param {string} filterValue Search string.
|
|
26
|
+
*
|
|
27
|
+
* @return {Array} Downloadable blocks.
|
|
28
|
+
*/
|
|
38
29
|
function getDownloadableBlocks(state, filterValue) {
|
|
39
|
-
|
|
30
|
+
return state.downloadableBlocks[filterValue]?.results ?? EMPTY_ARRAY;
|
|
40
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns the block types that have been installed on the server in this
|
|
34
|
+
* session.
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} state Global application state.
|
|
37
|
+
*
|
|
38
|
+
* @return {Array} Block type items
|
|
39
|
+
*/
|
|
41
40
|
function getInstalledBlockTypes(state) {
|
|
42
|
-
|
|
41
|
+
return state.blockManagement.installedBlockTypes;
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY;
|
|
93
|
-
},
|
|
94
|
-
(state) => [
|
|
95
|
-
getInstalledBlockTypes(state),
|
|
96
|
-
select(import_block_editor.store).getClientIdsWithDescendants()
|
|
97
|
-
]
|
|
98
|
-
)
|
|
99
|
-
);
|
|
43
|
+
/**
|
|
44
|
+
* Returns block types that have been installed on the server and used in the
|
|
45
|
+
* current post.
|
|
46
|
+
*
|
|
47
|
+
* @param {Object} state Global application state.
|
|
48
|
+
*
|
|
49
|
+
* @return {Array} Block type items.
|
|
50
|
+
*/
|
|
51
|
+
const getNewBlockTypes = (0, _wordpress_data.createRegistrySelector)((select) => (0, _wordpress_data.createSelector)((state) => {
|
|
52
|
+
const installedBlockTypes = getInstalledBlockTypes(state);
|
|
53
|
+
if (!installedBlockTypes.length) return EMPTY_ARRAY;
|
|
54
|
+
const { getBlockName, getClientIdsWithDescendants } = select(_wordpress_block_editor.store);
|
|
55
|
+
const installedBlockNames = installedBlockTypes.map((blockType) => blockType.name);
|
|
56
|
+
const foundBlockNames = getClientIdsWithDescendants().flatMap((clientId) => {
|
|
57
|
+
const blockName = getBlockName(clientId);
|
|
58
|
+
return installedBlockNames.includes(blockName) ? blockName : [];
|
|
59
|
+
});
|
|
60
|
+
const newBlockTypes = installedBlockTypes.filter((blockType) => foundBlockNames.includes(blockType.name));
|
|
61
|
+
return newBlockTypes.length > 0 ? newBlockTypes : EMPTY_ARRAY;
|
|
62
|
+
}, (state) => [getInstalledBlockTypes(state), select(_wordpress_block_editor.store).getClientIdsWithDescendants()]));
|
|
63
|
+
/**
|
|
64
|
+
* Returns the block types that have been installed on the server but are not
|
|
65
|
+
* used in the current post.
|
|
66
|
+
*
|
|
67
|
+
* @param {Object} state Global application state.
|
|
68
|
+
*
|
|
69
|
+
* @return {Array} Block type items.
|
|
70
|
+
*/
|
|
71
|
+
const getUnusedBlockTypes = (0, _wordpress_data.createRegistrySelector)((select) => (0, _wordpress_data.createSelector)((state) => {
|
|
72
|
+
const installedBlockTypes = getInstalledBlockTypes(state);
|
|
73
|
+
if (!installedBlockTypes.length) return EMPTY_ARRAY;
|
|
74
|
+
const { getBlockName, getClientIdsWithDescendants } = select(_wordpress_block_editor.store);
|
|
75
|
+
const installedBlockNames = installedBlockTypes.map((blockType) => blockType.name);
|
|
76
|
+
const foundBlockNames = getClientIdsWithDescendants().flatMap((clientId) => {
|
|
77
|
+
const blockName = getBlockName(clientId);
|
|
78
|
+
return installedBlockNames.includes(blockName) ? blockName : [];
|
|
79
|
+
});
|
|
80
|
+
const unusedBlockTypes = installedBlockTypes.filter((blockType) => !foundBlockNames.includes(blockType.name));
|
|
81
|
+
return unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY;
|
|
82
|
+
}, (state) => [getInstalledBlockTypes(state), select(_wordpress_block_editor.store).getClientIdsWithDescendants()]));
|
|
83
|
+
/**
|
|
84
|
+
* Returns true if a block plugin install is in progress.
|
|
85
|
+
*
|
|
86
|
+
* @param {Object} state Global application state.
|
|
87
|
+
* @param {string} blockId Id of the block.
|
|
88
|
+
*
|
|
89
|
+
* @return {boolean} Whether this block is currently being installed.
|
|
90
|
+
*/
|
|
100
91
|
function isInstalling(state, blockId) {
|
|
101
|
-
|
|
92
|
+
return state.blockManagement.isInstalling[blockId] || false;
|
|
102
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Returns all block error notices.
|
|
96
|
+
*
|
|
97
|
+
* @param {Object} state Global application state.
|
|
98
|
+
*
|
|
99
|
+
* @return {Object} Object with error notices.
|
|
100
|
+
*/
|
|
103
101
|
function getErrorNotices(state) {
|
|
104
|
-
|
|
102
|
+
return state.errorNotices;
|
|
105
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Returns the error notice for a given block.
|
|
106
|
+
*
|
|
107
|
+
* @param {Object} state Global application state.
|
|
108
|
+
* @param {string} blockId The ID of the block plugin. eg: my-block
|
|
109
|
+
*
|
|
110
|
+
* @return {string|boolean} The error text, or false if no error.
|
|
111
|
+
*/
|
|
106
112
|
function getErrorNoticeForBlock(state, blockId) {
|
|
107
|
-
|
|
113
|
+
return state.errorNotices[blockId];
|
|
108
114
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
120
|
-
//# sourceMappingURL=selectors.cjs.map
|
|
115
|
+
exports.getDownloadableBlocks = getDownloadableBlocks;
|
|
116
|
+
exports.getErrorNoticeForBlock = getErrorNoticeForBlock;
|
|
117
|
+
exports.getErrorNotices = getErrorNotices;
|
|
118
|
+
exports.getInstalledBlockTypes = getInstalledBlockTypes;
|
|
119
|
+
exports.getNewBlockTypes = getNewBlockTypes;
|
|
120
|
+
exports.getUnusedBlockTypes = getUnusedBlockTypes;
|
|
121
|
+
exports.isInstalling = isInstalling;
|
|
122
|
+
exports.isRequestingDownloadableBlocks = isRequestingDownloadableBlocks;
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=selectors.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/store/selectors.js"],
|
|
4
|
-
"sourcesContent": ["import { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? EMPTY_ARRAY;\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\t\t\tif ( ! installedBlockTypes.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\n\t\t\tconst { getBlockName, getClientIdsWithDescendants } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst installedBlockNames = installedBlockTypes.map(\n\t\t\t\t( blockType ) => blockType.name\n\t\t\t);\n\t\t\tconst foundBlockNames = getClientIdsWithDescendants().flatMap(\n\t\t\t\t( clientId ) => {\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\treturn installedBlockNames.includes( blockName )\n\t\t\t\t\t\t? blockName\n\t\t\t\t\t\t: [];\n\t\t\t\t}\n\t\t\t);\n\t\t\tconst newBlockTypes = installedBlockTypes.filter( ( blockType ) =>\n\t\t\t\tfoundBlockNames.includes( blockType.name )\n\t\t\t);\n\n\t\t\treturn newBlockTypes.length > 0 ? newBlockTypes : EMPTY_ARRAY;\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getClientIdsWithDescendants(),\n\t\t]\n\t)\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\t\t\tif ( ! installedBlockTypes.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\n\t\t\tconst { getBlockName, getClientIdsWithDescendants } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst installedBlockNames = installedBlockTypes.map(\n\t\t\t\t( blockType ) => blockType.name\n\t\t\t);\n\t\t\tconst foundBlockNames = getClientIdsWithDescendants().flatMap(\n\t\t\t\t( clientId ) => {\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\treturn installedBlockNames.includes( blockName )\n\t\t\t\t\t\t? blockName\n\t\t\t\t\t\t: [];\n\t\t\t\t}\n\t\t\t);\n\t\t\tconst unusedBlockTypes = installedBlockTypes.filter(\n\t\t\t\t( blockType ) => ! foundBlockNames.includes( blockType.name )\n\t\t\t);\n\n\t\t\treturn unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY;\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getClientIdsWithDescendants(),\n\t\t]\n\t)\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuD;AACvD,0BAA0C;AAE1C,IAAM,cAAc,CAAC;AAUd,SAAS,+BAAgC,OAAO,aAAc;AACpE,SAAO,MAAM,mBAAoB,WAAY,GAAG,gBAAgB;AACjE;AAUO,SAAS,sBAAuB,OAAO,aAAc;AAC3D,SAAO,MAAM,mBAAoB,WAAY,GAAG,WAAW;AAC5D;AAUO,SAAS,uBAAwB,OAAQ;AAC/C,SAAO,MAAM,gBAAgB;AAC9B;AAUO,IAAM,uBAAmB;AAAA,EAAwB,CAAE,eACzD;AAAA,IACC,CAAE,UAAW;AACZ,YAAM,sBAAsB,uBAAwB,KAAM;AAC1D,UAAK,CAAE,oBAAoB,QAAS;AACnC,eAAO;AAAA,MACR;AAEA,YAAM,EAAE,cAAc,4BAA4B,IACjD,OAAQ,oBAAAA,KAAiB;AAC1B,YAAM,sBAAsB,oBAAoB;AAAA,QAC/C,CAAE,cAAe,UAAU;AAAA,MAC5B;AACA,YAAM,kBAAkB,4BAA4B,EAAE;AAAA,QACrD,CAAE,aAAc;AACf,gBAAM,YAAY,aAAc,QAAS;AACzC,iBAAO,oBAAoB,SAAU,SAAU,IAC5C,YACA,CAAC;AAAA,QACL;AAAA,MACD;AACA,YAAM,gBAAgB,oBAAoB;AAAA,QAAQ,CAAE,cACnD,gBAAgB,SAAU,UAAU,IAAK;AAAA,MAC1C;AAEA,aAAO,cAAc,SAAS,IAAI,gBAAgB;AAAA,IACnD;AAAA,IACA,CAAE,UAAW;AAAA,MACZ,uBAAwB,KAAM;AAAA,MAC9B,OAAQ,oBAAAA,KAAiB,EAAE,4BAA4B;AAAA,IACxD;AAAA,EACD;AACD;AAUO,IAAM,0BAAsB;AAAA,EAAwB,CAAE,eAC5D;AAAA,IACC,CAAE,UAAW;AACZ,YAAM,sBAAsB,uBAAwB,KAAM;AAC1D,UAAK,CAAE,oBAAoB,QAAS;AACnC,eAAO;AAAA,MACR;AAEA,YAAM,EAAE,cAAc,4BAA4B,IACjD,OAAQ,oBAAAA,KAAiB;AAC1B,YAAM,sBAAsB,oBAAoB;AAAA,QAC/C,CAAE,cAAe,UAAU;AAAA,MAC5B;AACA,YAAM,kBAAkB,4BAA4B,EAAE;AAAA,QACrD,CAAE,aAAc;AACf,gBAAM,YAAY,aAAc,QAAS;AACzC,iBAAO,oBAAoB,SAAU,SAAU,IAC5C,YACA,CAAC;AAAA,QACL;AAAA,MACD;AACA,YAAM,mBAAmB,oBAAoB;AAAA,QAC5C,CAAE,cAAe,CAAE,gBAAgB,SAAU,UAAU,IAAK;AAAA,MAC7D;AAEA,aAAO,iBAAiB,SAAS,IAAI,mBAAmB;AAAA,IACzD;AAAA,IACA,CAAE,UAAW;AAAA,MACZ,uBAAwB,KAAM;AAAA,MAC9B,OAAQ,oBAAAA,KAAiB,EAAE,4BAA4B;AAAA,IACxD;AAAA,EACD;AACD;AAUO,SAAS,aAAc,OAAO,SAAU;AAC9C,SAAO,MAAM,gBAAgB,aAAc,OAAQ,KAAK;AACzD;AASO,SAAS,gBAAiB,OAAQ;AACxC,SAAO,MAAM;AACd;AAUO,SAAS,uBAAwB,OAAO,SAAU;AACxD,SAAO,MAAM,aAAc,OAAQ;AACpC;",
|
|
6
|
-
"names": ["blockEditorStore"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"selectors.cjs","names":["createRegistrySelector","createSelector","blockEditorStore"],"sources":["../../src/store/selectors.js"],"sourcesContent":["import { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? EMPTY_ARRAY;\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\t\t\tif ( ! installedBlockTypes.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\n\t\t\tconst { getBlockName, getClientIdsWithDescendants } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst installedBlockNames = installedBlockTypes.map(\n\t\t\t\t( blockType ) => blockType.name\n\t\t\t);\n\t\t\tconst foundBlockNames = getClientIdsWithDescendants().flatMap(\n\t\t\t\t( clientId ) => {\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\treturn installedBlockNames.includes( blockName )\n\t\t\t\t\t\t? blockName\n\t\t\t\t\t\t: [];\n\t\t\t\t}\n\t\t\t);\n\t\t\tconst newBlockTypes = installedBlockTypes.filter( ( blockType ) =>\n\t\t\t\tfoundBlockNames.includes( blockType.name )\n\t\t\t);\n\n\t\t\treturn newBlockTypes.length > 0 ? newBlockTypes : EMPTY_ARRAY;\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getClientIdsWithDescendants(),\n\t\t]\n\t)\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\t\t\tif ( ! installedBlockTypes.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\n\t\t\tconst { getBlockName, getClientIdsWithDescendants } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst installedBlockNames = installedBlockTypes.map(\n\t\t\t\t( blockType ) => blockType.name\n\t\t\t);\n\t\t\tconst foundBlockNames = getClientIdsWithDescendants().flatMap(\n\t\t\t\t( clientId ) => {\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\treturn installedBlockNames.includes( blockName )\n\t\t\t\t\t\t? blockName\n\t\t\t\t\t\t: [];\n\t\t\t\t}\n\t\t\t);\n\t\t\tconst unusedBlockTypes = installedBlockTypes.filter(\n\t\t\t\t( blockType ) => ! foundBlockNames.includes( blockType.name )\n\t\t\t);\n\n\t\t\treturn unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY;\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getClientIdsWithDescendants(),\n\t\t]\n\t)\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"],"mappings":";;;;;;;;AAGA,MAAM,cAAc,CAAC;;;;;;;;;AAUrB,SAAgB,+BAAgC,OAAO,aAAc;CACpE,OAAO,MAAM,mBAAoB,YAAa,EAAE,gBAAgB;AACjE;;;;;;;;;AAUA,SAAgB,sBAAuB,OAAO,aAAc;CAC3D,OAAO,MAAM,mBAAoB,YAAa,EAAE,WAAW;AAC5D;;;;;;;;;AAUA,SAAgB,uBAAwB,OAAQ;CAC/C,OAAO,MAAM,gBAAgB;AAC9B;;;;;;;;;AAUA,MAAa,oBAAA,GAAmBA,gBAAAA,uBAAAA,EAA0B,YAAA,GACzDC,gBAAAA,eAAAA,EACG,UAAW;CACZ,MAAM,sBAAsB,uBAAwB,KAAM;CAC1D,IAAK,CAAE,oBAAoB,QAC1B,OAAO;CAGR,MAAM,EAAE,cAAc,gCACrB,OAAQC,wBAAAA,KAAiB;CAC1B,MAAM,sBAAsB,oBAAoB,KAC7C,cAAe,UAAU,IAC5B;CACA,MAAM,kBAAkB,4BAA4B,CAAC,CAAC,SACnD,aAAc;EACf,MAAM,YAAY,aAAc,QAAS;EACzC,OAAO,oBAAoB,SAAU,SAAU,IAC5C,YACA,CAAC;CACL,CACD;CACA,MAAM,gBAAgB,oBAAoB,QAAU,cACnD,gBAAgB,SAAU,UAAU,IAAK,CAC1C;CAEA,OAAO,cAAc,SAAS,IAAI,gBAAgB;AACnD,IACE,UAAW,CACZ,uBAAwB,KAAM,GAC9B,OAAQA,wBAAAA,KAAiB,CAAC,CAAC,4BAA4B,CACxD,CACD,CACD;;;;;;;;;AAUA,MAAa,uBAAA,GAAsBF,gBAAAA,uBAAAA,EAA0B,YAAA,GAC5DC,gBAAAA,eAAAA,EACG,UAAW;CACZ,MAAM,sBAAsB,uBAAwB,KAAM;CAC1D,IAAK,CAAE,oBAAoB,QAC1B,OAAO;CAGR,MAAM,EAAE,cAAc,gCACrB,OAAQC,wBAAAA,KAAiB;CAC1B,MAAM,sBAAsB,oBAAoB,KAC7C,cAAe,UAAU,IAC5B;CACA,MAAM,kBAAkB,4BAA4B,CAAC,CAAC,SACnD,aAAc;EACf,MAAM,YAAY,aAAc,QAAS;EACzC,OAAO,oBAAoB,SAAU,SAAU,IAC5C,YACA,CAAC;CACL,CACD;CACA,MAAM,mBAAmB,oBAAoB,QAC1C,cAAe,CAAE,gBAAgB,SAAU,UAAU,IAAK,CAC7D;CAEA,OAAO,iBAAiB,SAAS,IAAI,mBAAmB;AACzD,IACE,UAAW,CACZ,uBAAwB,KAAM,GAC9B,OAAQA,wBAAAA,KAAiB,CAAC,CAAC,4BAA4B,CACxD,CACD,CACD;;;;;;;;;AAUA,SAAgB,aAAc,OAAO,SAAU;CAC9C,OAAO,MAAM,gBAAgB,aAAc,YAAa;AACzD;;;;;;;;AASA,SAAgB,gBAAiB,OAAQ;CACxC,OAAO,MAAM;AACd;;;;;;;;;AAUA,SAAgB,uBAAwB,OAAO,SAAU;CACxD,OAAO,MAAM,aAAc;AAC5B"}
|
|
@@ -1,35 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// packages/block-directory/src/store/utils/get-plugin-url.js
|
|
20
|
-
var get_plugin_url_exports = {};
|
|
21
|
-
__export(get_plugin_url_exports, {
|
|
22
|
-
default: () => getPluginUrl
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
23
5
|
});
|
|
24
|
-
|
|
6
|
+
// packages/block-directory/src/store/utils/get-plugin-url.js
|
|
7
|
+
/**
|
|
8
|
+
* Get the plugin's direct API link out of a block-directory response.
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} block The block object
|
|
11
|
+
*
|
|
12
|
+
* @return {string} The plugin URL, if exists.
|
|
13
|
+
*/
|
|
25
14
|
function getPluginUrl(block) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (link && link.length) {
|
|
31
|
-
return link[0].href;
|
|
32
|
-
}
|
|
33
|
-
return false;
|
|
15
|
+
if (!block) return false;
|
|
16
|
+
const link = block.links["wp:plugin"] || block.links.self;
|
|
17
|
+
if (link && link.length) return link[0].href;
|
|
18
|
+
return false;
|
|
34
19
|
}
|
|
35
|
-
|
|
20
|
+
exports.default = getPluginUrl;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=get-plugin-url.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/store/utils/get-plugin-url.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Get the plugin's direct API link out of a block-directory response.\n *\n * @param {Object} block The block object\n *\n * @return {string} The plugin URL, if exists.\n */\nexport default function getPluginUrl( block ) {\n\tif ( ! block ) {\n\t\treturn false;\n\t}\n\tconst link = block.links[ 'wp:plugin' ] || block.links.self;\n\tif ( link && link.length ) {\n\t\treturn link[ 0 ].href;\n\t}\n\treturn false;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOe,SAAR,aAA+B,OAAQ;AAC7C,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AACA,QAAM,OAAO,MAAM,MAAO,WAAY,KAAK,MAAM,MAAM;AACvD,MAAK,QAAQ,KAAK,QAAS;AAC1B,WAAO,KAAM,CAAE,EAAE;AAAA,EAClB;AACA,SAAO;AACR;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"get-plugin-url.cjs","names":[],"sources":["../../../src/store/utils/get-plugin-url.js"],"sourcesContent":["/**\n * Get the plugin's direct API link out of a block-directory response.\n *\n * @param {Object} block The block object\n *\n * @return {string} The plugin URL, if exists.\n */\nexport default function getPluginUrl( block ) {\n\tif ( ! block ) {\n\t\treturn false;\n\t}\n\tconst link = block.links[ 'wp:plugin' ] || block.links.self;\n\tif ( link && link.length ) {\n\t\treturn link[ 0 ].href;\n\t}\n\treturn false;\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAwB,aAAc,OAAQ;CAC7C,IAAK,CAAE,OACN,OAAO;CAER,MAAM,OAAO,MAAM,MAAO,gBAAiB,MAAM,MAAM;CACvD,IAAK,QAAQ,KAAK,QACjB,OAAO,KAAM,EAAG,CAAC;CAElB,OAAO;AACR"}
|
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
// packages/block-directory/src/components/auto-block-uninstaller/index.js
|
|
2
1
|
import { unregisterBlockType } from "@wordpress/blocks";
|
|
3
2
|
import { useDispatch, useSelect } from "@wordpress/data";
|
|
4
3
|
import { useEffect } from "@wordpress/element";
|
|
5
|
-
import { store
|
|
6
|
-
import { store as
|
|
4
|
+
import { store } from "@wordpress/editor";
|
|
5
|
+
import { store as store$1 } from "../../store/index.mjs";
|
|
6
|
+
// packages/block-directory/src/components/auto-block-uninstaller/index.js
|
|
7
7
|
function AutoBlockUninstaller() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
unregisterBlockType(blockType.name);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}, [shouldRemoveBlockTypes]);
|
|
25
|
-
return null;
|
|
8
|
+
const { uninstallBlockType } = useDispatch(store$1);
|
|
9
|
+
const shouldRemoveBlockTypes = useSelect((select) => {
|
|
10
|
+
const { isAutosavingPost, isSavingPost } = select(store);
|
|
11
|
+
return isSavingPost() && !isAutosavingPost();
|
|
12
|
+
}, []);
|
|
13
|
+
const unusedBlockTypes = useSelect((select) => select(store$1).getUnusedBlockTypes(), []);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (shouldRemoveBlockTypes && unusedBlockTypes.length) unusedBlockTypes.forEach((blockType) => {
|
|
16
|
+
uninstallBlockType(blockType);
|
|
17
|
+
unregisterBlockType(blockType.name);
|
|
18
|
+
});
|
|
19
|
+
}, [shouldRemoveBlockTypes]);
|
|
20
|
+
return null;
|
|
26
21
|
}
|
|
27
|
-
export {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=index.mjs.map
|
|
22
|
+
export { AutoBlockUninstaller as default };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/auto-block-uninstaller/index.js"],
|
|
4
|
-
"sourcesContent": ["import { unregisterBlockType } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function AutoBlockUninstaller() {\n\tconst { uninstallBlockType } = useDispatch( blockDirectoryStore );\n\n\tconst shouldRemoveBlockTypes = useSelect( ( select ) => {\n\t\tconst { isAutosavingPost, isSavingPost } = select( editorStore );\n\t\treturn isSavingPost() && ! isAutosavingPost();\n\t}, [] );\n\n\tconst unusedBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getUnusedBlockTypes(),\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( shouldRemoveBlockTypes && unusedBlockTypes.length ) {\n\t\t\tunusedBlockTypes.forEach( ( blockType ) => {\n\t\t\t\tuninstallBlockType( blockType );\n\t\t\t\tunregisterBlockType( blockType.name );\n\t\t\t} );\n\t\t}\n\t}, [ shouldRemoveBlockTypes ] );\n\n\treturn null;\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,2BAA2B;AACpC,SAAS,aAAa,iBAAiB;AACvC,SAAS,iBAAiB;AAC1B,SAAS,SAAS,mBAAmB;AACrC,SAAS,SAAS,2BAA2B;AAE9B,SAAR,uBAAwC;AAC9C,QAAM,EAAE,mBAAmB,IAAI,YAAa,mBAAoB;AAEhE,QAAM,yBAAyB,UAAW,CAAE,WAAY;AACvD,UAAM,EAAE,kBAAkB,aAAa,IAAI,OAAQ,WAAY;AAC/D,WAAO,aAAa,KAAK,CAAE,iBAAiB;AAAA,EAC7C,GAAG,CAAC,CAAE;AAEN,QAAM,mBAAmB;AAAA,IACxB,CAAE,WAAY,OAAQ,mBAAoB,EAAE,oBAAoB;AAAA,IAChE,CAAC;AAAA,EACF;AAEA,YAAW,MAAM;AAChB,QAAK,0BAA0B,iBAAiB,QAAS;AACxD,uBAAiB,QAAS,CAAE,cAAe;AAC1C,2BAAoB,SAAU;AAC9B,4BAAqB,UAAU,IAAK;AAAA,MACrC,CAAE;AAAA,IACH;AAAA,EACD,GAAG,CAAE,sBAAuB,CAAE;AAE9B,SAAO;AACR;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["blockDirectoryStore","editorStore"],"sources":["../../../src/components/auto-block-uninstaller/index.js"],"sourcesContent":["import { unregisterBlockType } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function AutoBlockUninstaller() {\n\tconst { uninstallBlockType } = useDispatch( blockDirectoryStore );\n\n\tconst shouldRemoveBlockTypes = useSelect( ( select ) => {\n\t\tconst { isAutosavingPost, isSavingPost } = select( editorStore );\n\t\treturn isSavingPost() && ! isAutosavingPost();\n\t}, [] );\n\n\tconst unusedBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getUnusedBlockTypes(),\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( shouldRemoveBlockTypes && unusedBlockTypes.length ) {\n\t\t\tunusedBlockTypes.forEach( ( blockType ) => {\n\t\t\t\tuninstallBlockType( blockType );\n\t\t\t\tunregisterBlockType( blockType.name );\n\t\t\t} );\n\t\t}\n\t}, [ shouldRemoveBlockTypes ] );\n\n\treturn null;\n}\n"],"mappings":";;;;;;AAMA,SAAwB,uBAAuB;CAC9C,MAAM,EAAE,uBAAuB,YAAaA,OAAoB;CAEhE,MAAM,yBAAyB,WAAa,WAAY;EACvD,MAAM,EAAE,kBAAkB,iBAAiB,OAAQC,KAAY;EAC/D,OAAO,aAAa,KAAK,CAAE,iBAAiB;CAC7C,GAAG,CAAC,CAAE;CAEN,MAAM,mBAAmB,WACtB,WAAY,OAAQD,OAAoB,CAAC,CAAC,oBAAoB,GAChE,CAAC,CACF;CAEA,gBAAiB;EAChB,IAAK,0BAA0B,iBAAiB,QAC/C,iBAAiB,SAAW,cAAe;GAC1C,mBAAoB,SAAU;GAC9B,oBAAqB,UAAU,IAAK;EACrC,CAAE;CAEJ,GAAG,CAAE,sBAAuB,CAAE;CAE9B,OAAO;AACR"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// packages/block-directory/src/components/block-ratings/index.jsx
|
|
2
1
|
import Stars from "./stars.mjs";
|
|
3
2
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
3
|
+
// packages/block-directory/src/components/block-ratings/index.jsx
|
|
4
|
+
const BlockRatings = ({ rating }) => /* @__PURE__ */ jsx("span", {
|
|
5
|
+
className: "block-directory-block-ratings",
|
|
6
|
+
children: /* @__PURE__ */ jsx(Stars, { rating })
|
|
7
|
+
});
|
|
8
|
+
export { BlockRatings, BlockRatings as default };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/block-ratings/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import Stars from './stars';\n\nexport const BlockRatings = ( { rating } ) => (\n\t<span className=\"block-directory-block-ratings\">\n\t\t<Stars rating={ rating } />\n\t</span>\n);\n\nexport default BlockRatings;\n"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,WAAW;AAIhB;AAFK,IAAM,eAAe,CAAE,EAAE,OAAO,MACtC,oBAAC,UAAK,WAAU,iCACf,8BAAC,SAAM,QAAkB,GAC1B;AAGD,IAAO,wBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/components/block-ratings/index.jsx"],"sourcesContent":["import Stars from './stars';\n\nexport const BlockRatings = ( { rating } ) => (\n\t<span className=\"block-directory-block-ratings\">\n\t\t<Stars rating={ rating } />\n\t</span>\n);\n\nexport default BlockRatings;\n"],"mappings":";;;AAEA,MAAa,gBAAiB,EAAE,aAC/B,oBAAC,QAAD;CAAM,WAAU;CACf,UAAA,oBAAC,OAAD,EAAgB,OAAU,CAAA;AACrB,CAAA"}
|
|
@@ -1,54 +1,33 @@
|
|
|
1
|
-
// packages/block-directory/src/components/block-ratings/stars.jsx
|
|
2
1
|
import { __, sprintf } from "@wordpress/i18n";
|
|
3
2
|
import { Icon, starEmpty, starFilled, starHalf } from "@wordpress/icons";
|
|
4
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
// packages/block-directory/src/components/block-ratings/stars.jsx
|
|
5
5
|
function Stars({ rating }) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
{
|
|
31
|
-
className: "block-directory-block-ratings__star-half-full",
|
|
32
|
-
icon: starHalf,
|
|
33
|
-
size: 16
|
|
34
|
-
},
|
|
35
|
-
`half_stars_${i}`
|
|
36
|
-
)),
|
|
37
|
-
Array.from({ length: emptyStarCount }).map((_, i) => /* @__PURE__ */ jsx(
|
|
38
|
-
Icon,
|
|
39
|
-
{
|
|
40
|
-
className: "block-directory-block-ratings__star-empty",
|
|
41
|
-
icon: starEmpty,
|
|
42
|
-
size: 16
|
|
43
|
-
},
|
|
44
|
-
`empty_stars_${i}`
|
|
45
|
-
))
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
);
|
|
6
|
+
const stars = Math.round(rating / .5) * .5;
|
|
7
|
+
const fullStarCount = Math.floor(rating);
|
|
8
|
+
const halfStarCount = Math.ceil(rating - fullStarCount);
|
|
9
|
+
const emptyStarCount = 5 - (fullStarCount + halfStarCount);
|
|
10
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
11
|
+
"aria-label": sprintf(__("%s out of 5 stars"), stars),
|
|
12
|
+
children: [
|
|
13
|
+
Array.from({ length: fullStarCount }).map((_, i) => /* @__PURE__ */ jsx(Icon, {
|
|
14
|
+
className: "block-directory-block-ratings__star-full",
|
|
15
|
+
icon: starFilled,
|
|
16
|
+
size: 16
|
|
17
|
+
}, `full_stars_${i}`)),
|
|
18
|
+
Array.from({ length: halfStarCount }).map((_, i) => /* @__PURE__ */ jsx(Icon, {
|
|
19
|
+
className: "block-directory-block-ratings__star-half-full",
|
|
20
|
+
icon: starHalf,
|
|
21
|
+
size: 16
|
|
22
|
+
}, `half_stars_${i}`)),
|
|
23
|
+
Array.from({ length: emptyStarCount }).map((_, i) => /* @__PURE__ */ jsx(Icon, {
|
|
24
|
+
className: "block-directory-block-ratings__star-empty",
|
|
25
|
+
icon: starEmpty,
|
|
26
|
+
size: 16
|
|
27
|
+
}, `empty_stars_${i}`))
|
|
28
|
+
]
|
|
29
|
+
});
|
|
49
30
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=stars.mjs.map
|
|
31
|
+
export { Stars as default };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=stars.mjs.map
|