@wordpress/block-directory 5.32.0 → 5.32.1-next.b8c8708f3.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.js +37 -31
- package/build/components/auto-block-uninstaller/index.js.map +7 -1
- package/build/components/block-ratings/index.js +40 -22
- package/build/components/block-ratings/index.js.map +7 -1
- package/build/components/block-ratings/stars.js +66 -40
- package/build/components/block-ratings/stars.js.map +7 -1
- package/build/components/compact-list/index.js +47 -46
- package/build/components/compact-list/index.js.map +7 -1
- package/build/components/downloadable-block-icon/index.js +28 -26
- package/build/components/downloadable-block-icon/index.js.map +7 -1
- package/build/components/downloadable-block-list-item/index.js +113 -127
- package/build/components/downloadable-block-list-item/index.js.map +7 -1
- package/build/components/downloadable-block-notice/index.js +41 -31
- package/build/components/downloadable-block-notice/index.js.map +7 -1
- package/build/components/downloadable-blocks-list/index.js +72 -56
- package/build/components/downloadable-blocks-list/index.js.map +7 -1
- package/build/components/downloadable-blocks-panel/index.js +108 -95
- package/build/components/downloadable-blocks-panel/index.js.map +7 -1
- package/build/components/downloadable-blocks-panel/inserter-panel.js +52 -38
- package/build/components/downloadable-blocks-panel/inserter-panel.js.map +7 -1
- package/build/components/downloadable-blocks-panel/no-results.js +37 -30
- package/build/components/downloadable-blocks-panel/no-results.js.map +7 -1
- package/build/index.js +27 -12
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/plugins/get-install-missing/index.js +123 -102
- package/build/plugins/get-install-missing/index.js.map +7 -1
- package/build/plugins/get-install-missing/install-button.js +68 -50
- package/build/plugins/get-install-missing/install-button.js.map +7 -1
- package/build/plugins/index.js +46 -29
- package/build/plugins/index.js.map +7 -1
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.js +55 -42
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.js.map +7 -1
- package/build/plugins/installed-blocks-pre-publish-panel/index.js +65 -34
- package/build/plugins/installed-blocks-pre-publish-panel/index.js.map +7 -1
- package/build/store/actions.js +142 -188
- package/build/store/actions.js.map +7 -1
- package/build/store/index.js +48 -46
- package/build/store/index.js.map +7 -1
- package/build/store/load-assets.js +48 -55
- package/build/store/load-assets.js.map +7 -1
- package/build/store/reducer.js +48 -54
- package/build/store/reducer.js.map +7 -1
- package/build/store/resolvers.js +52 -31
- package/build/store/resolvers.js.map +7 -1
- package/build/store/selectors.js +100 -127
- package/build/store/selectors.js.map +7 -1
- package/build/store/utils/get-plugin-url.js +23 -14
- package/build/store/utils/get-plugin-url.js.map +7 -1
- package/build-module/components/auto-block-uninstaller/index.js +18 -24
- package/build-module/components/auto-block-uninstaller/index.js.map +7 -1
- package/build-module/components/block-ratings/index.js +9 -15
- package/build-module/components/block-ratings/index.js.map +7 -1
- package/build-module/components/block-ratings/stars.js +48 -34
- package/build-module/components/block-ratings/stars.js.map +7 -1
- package/build-module/components/compact-list/index.js +19 -39
- package/build-module/components/compact-list/index.js.map +7 -1
- package/build-module/components/downloadable-block-icon/index.js +10 -20
- package/build-module/components/downloadable-block-icon/index.js.map +7 -1
- package/build-module/components/downloadable-block-list-item/index.js +89 -120
- package/build-module/components/downloadable-block-list-item/index.js.map +7 -1
- package/build-module/components/downloadable-block-notice/index.js +19 -24
- package/build-module/components/downloadable-block-notice/index.js.map +7 -1
- package/build-module/components/downloadable-blocks-list/index.js +44 -49
- package/build-module/components/downloadable-blocks-list/index.js.map +7 -1
- package/build-module/components/downloadable-blocks-panel/index.js +81 -89
- package/build-module/components/downloadable-blocks-panel/index.js.map +7 -1
- package/build-module/components/downloadable-blocks-panel/inserter-panel.js +33 -31
- package/build-module/components/downloadable-blocks-panel/inserter-panel.js.map +7 -1
- package/build-module/components/downloadable-blocks-panel/no-results.js +19 -24
- package/build-module/components/downloadable-blocks-panel/no-results.js.map +7 -1
- package/build-module/index.js +6 -6
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/plugins/get-install-missing/index.js +99 -95
- package/build-module/plugins/get-install-missing/index.js.map +7 -1
- package/build-module/plugins/get-install-missing/install-button.js +50 -44
- package/build-module/plugins/get-install-missing/install-button.js.map +7 -1
- package/build-module/plugins/index.js +24 -25
- package/build-module/plugins/index.js.map +7 -1
- package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.js +26 -34
- package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.js.map +7 -1
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.js +38 -28
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.js.map +7 -1
- package/build-module/store/actions.js +100 -168
- package/build-module/store/actions.js.map +7 -1
- package/build-module/store/index.js +13 -36
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/load-assets.js +15 -47
- package/build-module/store/load-assets.js.map +7 -1
- package/build-module/store/reducer.js +27 -49
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/resolvers.js +16 -19
- package/build-module/store/resolvers.js.map +7 -1
- package/build-module/store/selectors.js +77 -121
- package/build-module/store/selectors.js.map +7 -1
- package/build-module/store/utils/get-plugin-url.js +6 -10
- package/build-module/store/utils/get-plugin-url.js.map +7 -1
- package/build-style/style-rtl.css +9 -142
- package/build-style/style.css +9 -142
- package/package.json +28 -21
- package/src/components/block-ratings/style.scss +2 -0
- package/src/components/compact-list/style.scss +3 -0
- package/src/components/downloadable-block-icon/style.scss +3 -0
- package/src/components/downloadable-block-list-item/style.scss +4 -0
- package/src/components/downloadable-block-notice/style.scss +3 -0
- package/src/components/downloadable-blocks-panel/style.scss +3 -1
- package/src/style.scss +8 -7
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { combineReducers } from '@wordpress/data';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Reducer returning an array of downloadable blocks.
|
|
8
|
-
*
|
|
9
|
-
* @param {Object} state Current state.
|
|
10
|
-
* @param {Object} action Dispatched action.
|
|
11
|
-
*
|
|
12
|
-
* @return {Object} Updated state.
|
|
13
|
-
*/
|
|
14
|
-
export const downloadableBlocks = (state = {}, action) => {
|
|
1
|
+
import { combineReducers } from "@wordpress/data";
|
|
2
|
+
const downloadableBlocks = (state = {}, action) => {
|
|
15
3
|
switch (action.type) {
|
|
16
|
-
case
|
|
4
|
+
case "FETCH_DOWNLOADABLE_BLOCKS":
|
|
17
5
|
return {
|
|
18
6
|
...state,
|
|
19
7
|
[action.filterValue]: {
|
|
20
8
|
isRequesting: true
|
|
21
9
|
}
|
|
22
10
|
};
|
|
23
|
-
case
|
|
11
|
+
case "RECEIVE_DOWNLOADABLE_BLOCKS":
|
|
24
12
|
return {
|
|
25
13
|
...state,
|
|
26
14
|
[action.filterValue]: {
|
|
@@ -31,31 +19,27 @@ export const downloadableBlocks = (state = {}, action) => {
|
|
|
31
19
|
}
|
|
32
20
|
return state;
|
|
33
21
|
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Reducer managing the installation and deletion of blocks.
|
|
37
|
-
*
|
|
38
|
-
* @param {Object} state Current state.
|
|
39
|
-
* @param {Object} action Dispatched action.
|
|
40
|
-
*
|
|
41
|
-
* @return {Object} Updated state.
|
|
42
|
-
*/
|
|
43
|
-
export const blockManagement = (state = {
|
|
22
|
+
const blockManagement = (state = {
|
|
44
23
|
installedBlockTypes: [],
|
|
45
24
|
isInstalling: {}
|
|
46
25
|
}, action) => {
|
|
47
26
|
switch (action.type) {
|
|
48
|
-
case
|
|
27
|
+
case "ADD_INSTALLED_BLOCK_TYPE":
|
|
49
28
|
return {
|
|
50
29
|
...state,
|
|
51
|
-
installedBlockTypes: [
|
|
30
|
+
installedBlockTypes: [
|
|
31
|
+
...state.installedBlockTypes,
|
|
32
|
+
action.item
|
|
33
|
+
]
|
|
52
34
|
};
|
|
53
|
-
case
|
|
35
|
+
case "REMOVE_INSTALLED_BLOCK_TYPE":
|
|
54
36
|
return {
|
|
55
37
|
...state,
|
|
56
|
-
installedBlockTypes: state.installedBlockTypes.filter(
|
|
38
|
+
installedBlockTypes: state.installedBlockTypes.filter(
|
|
39
|
+
(blockType) => blockType.name !== action.item.name
|
|
40
|
+
)
|
|
57
41
|
};
|
|
58
|
-
case
|
|
42
|
+
case "SET_INSTALLING_BLOCK":
|
|
59
43
|
return {
|
|
60
44
|
...state,
|
|
61
45
|
isInstalling: {
|
|
@@ -66,18 +50,9 @@ export const blockManagement = (state = {
|
|
|
66
50
|
}
|
|
67
51
|
return state;
|
|
68
52
|
};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Reducer returning an object of error notices.
|
|
72
|
-
*
|
|
73
|
-
* @param {Object} state Current state.
|
|
74
|
-
* @param {Object} action Dispatched action.
|
|
75
|
-
*
|
|
76
|
-
* @return {Object} Updated state.
|
|
77
|
-
*/
|
|
78
|
-
export const errorNotices = (state = {}, action) => {
|
|
53
|
+
const errorNotices = (state = {}, action) => {
|
|
79
54
|
switch (action.type) {
|
|
80
|
-
case
|
|
55
|
+
case "SET_ERROR_NOTICE":
|
|
81
56
|
return {
|
|
82
57
|
...state,
|
|
83
58
|
[action.blockId]: {
|
|
@@ -85,18 +60,21 @@ export const errorNotices = (state = {}, action) => {
|
|
|
85
60
|
isFatal: action.isFatal
|
|
86
61
|
}
|
|
87
62
|
};
|
|
88
|
-
case
|
|
89
|
-
const {
|
|
90
|
-
[action.blockId]: blockId,
|
|
91
|
-
...restState
|
|
92
|
-
} = state;
|
|
63
|
+
case "CLEAR_ERROR_NOTICE":
|
|
64
|
+
const { [action.blockId]: blockId, ...restState } = state;
|
|
93
65
|
return restState;
|
|
94
66
|
}
|
|
95
67
|
return state;
|
|
96
68
|
};
|
|
97
|
-
|
|
69
|
+
var reducer_default = combineReducers({
|
|
98
70
|
downloadableBlocks,
|
|
99
71
|
blockManagement,
|
|
100
72
|
errorNotices
|
|
101
73
|
});
|
|
102
|
-
|
|
74
|
+
export {
|
|
75
|
+
blockManagement,
|
|
76
|
+
reducer_default as default,
|
|
77
|
+
downloadableBlocks,
|
|
78
|
+
errorNotices
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=reducer.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/reducer.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning an array of downloadable blocks.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const downloadableBlocks = ( state = {}, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'FETCH_DOWNLOADABLE_BLOCKS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.filterValue ]: {\n\t\t\t\t\tisRequesting: true,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'RECEIVE_DOWNLOADABLE_BLOCKS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.filterValue ]: {\n\t\t\t\t\tresults: action.downloadableBlocks,\n\t\t\t\t\tisRequesting: false,\n\t\t\t\t},\n\t\t\t};\n\t}\n\treturn state;\n};\n\n/**\n * Reducer managing the installation and deletion of blocks.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const blockManagement = (\n\tstate = {\n\t\tinstalledBlockTypes: [],\n\t\tisInstalling: {},\n\t},\n\taction\n) => {\n\tswitch ( action.type ) {\n\t\tcase 'ADD_INSTALLED_BLOCK_TYPE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tinstalledBlockTypes: [\n\t\t\t\t\t...state.installedBlockTypes,\n\t\t\t\t\taction.item,\n\t\t\t\t],\n\t\t\t};\n\t\tcase 'REMOVE_INSTALLED_BLOCK_TYPE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tinstalledBlockTypes: state.installedBlockTypes.filter(\n\t\t\t\t\t( blockType ) => blockType.name !== action.item.name\n\t\t\t\t),\n\t\t\t};\n\t\tcase 'SET_INSTALLING_BLOCK':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisInstalling: {\n\t\t\t\t\t...state.isInstalling,\n\t\t\t\t\t[ action.blockId ]: action.isInstalling,\n\t\t\t\t},\n\t\t\t};\n\t}\n\treturn state;\n};\n\n/**\n * Reducer returning an object of error notices.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const errorNotices = ( state = {}, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'SET_ERROR_NOTICE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.blockId ]: {\n\t\t\t\t\tmessage: action.message,\n\t\t\t\t\tisFatal: action.isFatal,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'CLEAR_ERROR_NOTICE':\n\t\t\tconst { [ action.blockId ]: blockId, ...restState } = state;\n\t\t\treturn restState;\n\t}\n\treturn state;\n};\n\nexport default combineReducers( {\n\tdownloadableBlocks,\n\tblockManagement,\n\terrorNotices,\n} );\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,uBAAuB;AAUzB,MAAM,qBAAqB,CAAE,QAAQ,CAAC,GAAG,WAAY;AAC3D,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,WAAY,GAAG;AAAA,UACvB,cAAc;AAAA,QACf;AAAA,MACD;AAAA,IACD,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,WAAY,GAAG;AAAA,UACvB,SAAS,OAAO;AAAA,UAChB,cAAc;AAAA,QACf;AAAA,MACD;AAAA,EACF;AACA,SAAO;AACR;AAUO,MAAM,kBAAkB,CAC9B,QAAQ;AAAA,EACP,qBAAqB,CAAC;AAAA,EACtB,cAAc,CAAC;AAChB,GACA,WACI;AACJ,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,qBAAqB;AAAA,UACpB,GAAG,MAAM;AAAA,UACT,OAAO;AAAA,QACR;AAAA,MACD;AAAA,IACD,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,qBAAqB,MAAM,oBAAoB;AAAA,UAC9C,CAAE,cAAe,UAAU,SAAS,OAAO,KAAK;AAAA,QACjD;AAAA,MACD;AAAA,IACD,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,cAAc;AAAA,UACb,GAAG,MAAM;AAAA,UACT,CAAE,OAAO,OAAQ,GAAG,OAAO;AAAA,QAC5B;AAAA,MACD;AAAA,EACF;AACA,SAAO;AACR;AAUO,MAAM,eAAe,CAAE,QAAQ,CAAC,GAAG,WAAY;AACrD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,OAAO,OAAQ,GAAG;AAAA,UACnB,SAAS,OAAO;AAAA,UAChB,SAAS,OAAO;AAAA,QACjB;AAAA,MACD;AAAA,IACD,KAAK;AACJ,YAAM,EAAE,CAAE,OAAO,OAAQ,GAAG,SAAS,GAAG,UAAU,IAAI;AACtD,aAAO;AAAA,EACT;AACA,SAAO;AACR;AAEA,IAAO,kBAAQ,gBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AACD,CAAE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import apiFetch from '@wordpress/api-fetch';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';
|
|
15
|
-
export const getDownloadableBlocks = filterValue => async ({
|
|
16
|
-
dispatch
|
|
17
|
-
}) => {
|
|
1
|
+
import { camelCase } from "change-case";
|
|
2
|
+
import apiFetch from "@wordpress/api-fetch";
|
|
3
|
+
import { fetchDownloadableBlocks, receiveDownloadableBlocks } from "./actions";
|
|
4
|
+
const getDownloadableBlocks = (filterValue) => async ({ dispatch }) => {
|
|
18
5
|
if (!filterValue) {
|
|
19
6
|
return;
|
|
20
7
|
}
|
|
@@ -23,10 +10,20 @@ export const getDownloadableBlocks = filterValue => async ({
|
|
|
23
10
|
const results = await apiFetch({
|
|
24
11
|
path: `wp/v2/block-directory/search?term=${filterValue}`
|
|
25
12
|
});
|
|
26
|
-
const blocks = results.map(
|
|
13
|
+
const blocks = results.map(
|
|
14
|
+
(result) => Object.fromEntries(
|
|
15
|
+
Object.entries(result).map(([key, value]) => [
|
|
16
|
+
camelCase(key),
|
|
17
|
+
value
|
|
18
|
+
])
|
|
19
|
+
)
|
|
20
|
+
);
|
|
27
21
|
dispatch(receiveDownloadableBlocks(blocks, filterValue));
|
|
28
22
|
} catch {
|
|
29
23
|
dispatch(receiveDownloadableBlocks([], filterValue));
|
|
30
24
|
}
|
|
31
25
|
};
|
|
32
|
-
|
|
26
|
+
export {
|
|
27
|
+
getDownloadableBlocks
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=resolvers.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/resolvers.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\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": "AAGA,SAAS,iBAAiB;AAK1B,OAAO,cAAc;AAKrB,SAAS,yBAAyB,iCAAiC;AAE5D,MAAM,wBACZ,CAAE,gBACF,OAAQ,EAAE,SAAS,MAAO;AACzB,MAAK,CAAE,aAAc;AACpB;AAAA,EACD;AAEA,MAAI;AACH,aAAU,wBAAyB,WAAY,CAAE;AACjD,UAAM,UAAU,MAAM,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,UACnD,UAAW,GAAI;AAAA,UACf;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAEA,aAAU,0BAA2B,QAAQ,WAAY,CAAE;AAAA,EAC5D,QAAQ;AACP,aAAU,0BAA2B,CAAC,GAAG,WAAY,CAAE;AAAA,EACxD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,132 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { createSelector, createRegistrySelector } from '@wordpress/data';
|
|
5
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
1
|
+
import { createSelector, createRegistrySelector } from "@wordpress/data";
|
|
2
|
+
import { store as blockEditorStore } from "@wordpress/block-editor";
|
|
6
3
|
const EMPTY_ARRAY = [];
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Returns true if application is requesting for downloadable blocks.
|
|
10
|
-
*
|
|
11
|
-
* @param {Object} state Global application state.
|
|
12
|
-
* @param {string} filterValue Search string.
|
|
13
|
-
*
|
|
14
|
-
* @return {boolean} Whether a request is in progress for the blocks list.
|
|
15
|
-
*/
|
|
16
|
-
export function isRequestingDownloadableBlocks(state, filterValue) {
|
|
17
|
-
var _state$downloadableBl;
|
|
18
|
-
return (_state$downloadableBl = state.downloadableBlocks[filterValue]?.isRequesting) !== null && _state$downloadableBl !== void 0 ? _state$downloadableBl : false;
|
|
4
|
+
function isRequestingDownloadableBlocks(state, filterValue) {
|
|
5
|
+
return state.downloadableBlocks[filterValue]?.isRequesting ?? false;
|
|
19
6
|
}
|
|
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
|
-
*/
|
|
29
|
-
export function getDownloadableBlocks(state, filterValue) {
|
|
30
|
-
var _state$downloadableBl2;
|
|
31
|
-
return (_state$downloadableBl2 = state.downloadableBlocks[filterValue]?.results) !== null && _state$downloadableBl2 !== void 0 ? _state$downloadableBl2 : EMPTY_ARRAY;
|
|
7
|
+
function getDownloadableBlocks(state, filterValue) {
|
|
8
|
+
return state.downloadableBlocks[filterValue]?.results ?? EMPTY_ARRAY;
|
|
32
9
|
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Returns the block types that have been installed on the server in this
|
|
36
|
-
* session.
|
|
37
|
-
*
|
|
38
|
-
* @param {Object} state Global application state.
|
|
39
|
-
*
|
|
40
|
-
* @return {Array} Block type items
|
|
41
|
-
*/
|
|
42
|
-
export function getInstalledBlockTypes(state) {
|
|
10
|
+
function getInstalledBlockTypes(state) {
|
|
43
11
|
return state.blockManagement.installedBlockTypes;
|
|
44
12
|
}
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
* @param {string} blockId Id of the block.
|
|
103
|
-
*
|
|
104
|
-
* @return {boolean} Whether this block is currently being installed.
|
|
105
|
-
*/
|
|
106
|
-
export function isInstalling(state, blockId) {
|
|
13
|
+
const getNewBlockTypes = createRegistrySelector(
|
|
14
|
+
(select) => createSelector(
|
|
15
|
+
(state) => {
|
|
16
|
+
const installedBlockTypes = getInstalledBlockTypes(state);
|
|
17
|
+
if (!installedBlockTypes.length) {
|
|
18
|
+
return EMPTY_ARRAY;
|
|
19
|
+
}
|
|
20
|
+
const { getBlockName, getClientIdsWithDescendants } = select(blockEditorStore);
|
|
21
|
+
const installedBlockNames = installedBlockTypes.map(
|
|
22
|
+
(blockType) => blockType.name
|
|
23
|
+
);
|
|
24
|
+
const foundBlockNames = getClientIdsWithDescendants().flatMap(
|
|
25
|
+
(clientId) => {
|
|
26
|
+
const blockName = getBlockName(clientId);
|
|
27
|
+
return installedBlockNames.includes(blockName) ? blockName : [];
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
const newBlockTypes = installedBlockTypes.filter(
|
|
31
|
+
(blockType) => foundBlockNames.includes(blockType.name)
|
|
32
|
+
);
|
|
33
|
+
return newBlockTypes.length > 0 ? newBlockTypes : EMPTY_ARRAY;
|
|
34
|
+
},
|
|
35
|
+
(state) => [
|
|
36
|
+
getInstalledBlockTypes(state),
|
|
37
|
+
select(blockEditorStore).getClientIdsWithDescendants()
|
|
38
|
+
]
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
const getUnusedBlockTypes = createRegistrySelector(
|
|
42
|
+
(select) => createSelector(
|
|
43
|
+
(state) => {
|
|
44
|
+
const installedBlockTypes = getInstalledBlockTypes(state);
|
|
45
|
+
if (!installedBlockTypes.length) {
|
|
46
|
+
return EMPTY_ARRAY;
|
|
47
|
+
}
|
|
48
|
+
const { getBlockName, getClientIdsWithDescendants } = select(blockEditorStore);
|
|
49
|
+
const installedBlockNames = installedBlockTypes.map(
|
|
50
|
+
(blockType) => blockType.name
|
|
51
|
+
);
|
|
52
|
+
const foundBlockNames = getClientIdsWithDescendants().flatMap(
|
|
53
|
+
(clientId) => {
|
|
54
|
+
const blockName = getBlockName(clientId);
|
|
55
|
+
return installedBlockNames.includes(blockName) ? blockName : [];
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
const unusedBlockTypes = installedBlockTypes.filter(
|
|
59
|
+
(blockType) => !foundBlockNames.includes(blockType.name)
|
|
60
|
+
);
|
|
61
|
+
return unusedBlockTypes.length > 0 ? unusedBlockTypes : EMPTY_ARRAY;
|
|
62
|
+
},
|
|
63
|
+
(state) => [
|
|
64
|
+
getInstalledBlockTypes(state),
|
|
65
|
+
select(blockEditorStore).getClientIdsWithDescendants()
|
|
66
|
+
]
|
|
67
|
+
)
|
|
68
|
+
);
|
|
69
|
+
function isInstalling(state, blockId) {
|
|
107
70
|
return state.blockManagement.isInstalling[blockId] || false;
|
|
108
71
|
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Returns all block error notices.
|
|
112
|
-
*
|
|
113
|
-
* @param {Object} state Global application state.
|
|
114
|
-
*
|
|
115
|
-
* @return {Object} Object with error notices.
|
|
116
|
-
*/
|
|
117
|
-
export function getErrorNotices(state) {
|
|
72
|
+
function getErrorNotices(state) {
|
|
118
73
|
return state.errorNotices;
|
|
119
74
|
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Returns the error notice for a given block.
|
|
123
|
-
*
|
|
124
|
-
* @param {Object} state Global application state.
|
|
125
|
-
* @param {string} blockId The ID of the block plugin. eg: my-block
|
|
126
|
-
*
|
|
127
|
-
* @return {string|boolean} The error text, or false if no error.
|
|
128
|
-
*/
|
|
129
|
-
export function getErrorNoticeForBlock(state, blockId) {
|
|
75
|
+
function getErrorNoticeForBlock(state, blockId) {
|
|
130
76
|
return state.errorNotices[blockId];
|
|
131
77
|
}
|
|
132
|
-
|
|
78
|
+
export {
|
|
79
|
+
getDownloadableBlocks,
|
|
80
|
+
getErrorNoticeForBlock,
|
|
81
|
+
getErrorNotices,
|
|
82
|
+
getInstalledBlockTypes,
|
|
83
|
+
getNewBlockTypes,
|
|
84
|
+
getUnusedBlockTypes,
|
|
85
|
+
isInstalling,
|
|
86
|
+
isRequestingDownloadableBlocks
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=selectors.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/selectors.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { 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": "AAGA,SAAS,gBAAgB,8BAA8B;AACvD,SAAS,SAAS,wBAAwB;AAE1C,MAAM,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,MAAM,mBAAmB;AAAA,EAAwB,CAAE,WACzD;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,gBAAiB;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,gBAAiB,EAAE,4BAA4B;AAAA,IACxD;AAAA,EACD;AACD;AAUO,MAAM,sBAAsB;AAAA,EAAwB,CAAE,WAC5D;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,gBAAiB;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,gBAAiB,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": []
|
|
7
|
+
}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
* Get the plugin's direct API link out of a block-directory response.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} block The block object
|
|
5
|
-
*
|
|
6
|
-
* @return {string} The plugin URL, if exists.
|
|
7
|
-
*/
|
|
8
|
-
export default function getPluginUrl(block) {
|
|
1
|
+
function getPluginUrl(block) {
|
|
9
2
|
if (!block) {
|
|
10
3
|
return false;
|
|
11
4
|
}
|
|
12
|
-
const link = block.links[
|
|
5
|
+
const link = block.links["wp:plugin"] || block.links.self;
|
|
13
6
|
if (link && link.length) {
|
|
14
7
|
return link[0].href;
|
|
15
8
|
}
|
|
16
9
|
return false;
|
|
17
10
|
}
|
|
18
|
-
|
|
11
|
+
export {
|
|
12
|
+
getPluginUrl as default
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=get-plugin-url.js.map
|
|
@@ -1 +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": "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
|
+
}
|