@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,155 +1,141 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
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
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var downloadable_block_list_item_exports = {};
|
|
29
|
+
__export(downloadable_block_list_item_exports, {
|
|
30
|
+
default: () => downloadable_block_list_item_default
|
|
6
31
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
* External dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* WordPress dependencies
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Internal dependencies
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
// Return the appropriate block item label, given the block data and status.
|
|
33
|
-
function getDownloadableBlockLabel({
|
|
34
|
-
title,
|
|
35
|
-
rating,
|
|
36
|
-
ratingCount
|
|
37
|
-
}, {
|
|
38
|
-
hasNotice,
|
|
39
|
-
isInstalled,
|
|
40
|
-
isInstalling
|
|
41
|
-
}) {
|
|
32
|
+
module.exports = __toCommonJS(downloadable_block_list_item_exports);
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_clsx = __toESM(require("clsx"));
|
|
35
|
+
var import_i18n = require("@wordpress/i18n");
|
|
36
|
+
var import_components = require("@wordpress/components");
|
|
37
|
+
var import_element = require("@wordpress/element");
|
|
38
|
+
var import_html_entities = require("@wordpress/html-entities");
|
|
39
|
+
var import_blocks = require("@wordpress/blocks");
|
|
40
|
+
var import_data = require("@wordpress/data");
|
|
41
|
+
var import_block_ratings = __toESM(require("../block-ratings"));
|
|
42
|
+
var import_downloadable_block_icon = __toESM(require("../downloadable-block-icon"));
|
|
43
|
+
var import_downloadable_block_notice = __toESM(require("../downloadable-block-notice"));
|
|
44
|
+
var import_store = require("../../store");
|
|
45
|
+
function getDownloadableBlockLabel({ title, rating, ratingCount }, { hasNotice, isInstalled, isInstalling }) {
|
|
42
46
|
const stars = Math.round(rating / 0.5) * 0.5;
|
|
43
47
|
if (!isInstalled && hasNotice) {
|
|
44
|
-
|
|
45
|
-
return (0, _i18n.sprintf)('Retry installing %s.', (0, _htmlEntities.decodeEntities)(title));
|
|
48
|
+
return (0, import_i18n.sprintf)("Retry installing %s.", (0, import_html_entities.decodeEntities)(title));
|
|
46
49
|
}
|
|
47
50
|
if (isInstalled) {
|
|
48
|
-
|
|
49
|
-
return (0, _i18n.sprintf)('Add %s.', (0, _htmlEntities.decodeEntities)(title));
|
|
51
|
+
return (0, import_i18n.sprintf)("Add %s.", (0, import_html_entities.decodeEntities)(title));
|
|
50
52
|
}
|
|
51
53
|
if (isInstalling) {
|
|
52
|
-
|
|
53
|
-
return (0, _i18n.sprintf)('Installing %s.', (0, _htmlEntities.decodeEntities)(title));
|
|
54
|
+
return (0, import_i18n.sprintf)("Installing %s.", (0, import_html_entities.decodeEntities)(title));
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
// No ratings yet, just use the title.
|
|
57
56
|
if (ratingCount < 1) {
|
|
58
|
-
|
|
59
|
-
return (0, _i18n.sprintf)('Install %s.', (0, _htmlEntities.decodeEntities)(title));
|
|
57
|
+
return (0, import_i18n.sprintf)("Install %s.", (0, import_html_entities.decodeEntities)(title));
|
|
60
58
|
}
|
|
61
|
-
return (0,
|
|
62
|
-
|
|
59
|
+
return (0, import_i18n.sprintf)(
|
|
60
|
+
/* translators: 1: block title, 2: average rating, 3: total ratings count. */
|
|
61
|
+
(0, import_i18n._n)(
|
|
62
|
+
"Install %1$s. %2$s stars with %3$s review.",
|
|
63
|
+
"Install %1$s. %2$s stars with %3$s reviews.",
|
|
64
|
+
ratingCount
|
|
65
|
+
),
|
|
66
|
+
(0, import_html_entities.decodeEntities)(title),
|
|
67
|
+
stars,
|
|
68
|
+
ratingCount
|
|
69
|
+
);
|
|
63
70
|
}
|
|
64
|
-
function DownloadableBlockListItem({
|
|
65
|
-
item
|
|
66
|
-
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} = (0, _data.useSelect)(select => {
|
|
82
|
-
const {
|
|
83
|
-
getErrorNoticeForBlock,
|
|
84
|
-
isInstalling: isBlockInstalling
|
|
85
|
-
} = select(_store.store);
|
|
86
|
-
const notice = getErrorNoticeForBlock(item.id);
|
|
87
|
-
const hasFatal = notice && notice.isFatal;
|
|
88
|
-
return {
|
|
89
|
-
hasNotice: !!notice,
|
|
90
|
-
isInstalling: isBlockInstalling(item.id),
|
|
91
|
-
isInstallable: !hasFatal
|
|
92
|
-
};
|
|
93
|
-
}, [item]);
|
|
94
|
-
let statusText = '';
|
|
71
|
+
function DownloadableBlockListItem({ item, onClick }) {
|
|
72
|
+
const { author, description, icon, rating, title } = item;
|
|
73
|
+
const isInstalled = !!(0, import_blocks.getBlockType)(item.name);
|
|
74
|
+
const { hasNotice, isInstalling, isInstallable } = (0, import_data.useSelect)(
|
|
75
|
+
(select) => {
|
|
76
|
+
const { getErrorNoticeForBlock, isInstalling: isBlockInstalling } = select(import_store.store);
|
|
77
|
+
const notice = getErrorNoticeForBlock(item.id);
|
|
78
|
+
const hasFatal = notice && notice.isFatal;
|
|
79
|
+
return {
|
|
80
|
+
hasNotice: !!notice,
|
|
81
|
+
isInstalling: isBlockInstalling(item.id),
|
|
82
|
+
isInstallable: !hasFatal
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
[item]
|
|
86
|
+
);
|
|
87
|
+
let statusText = "";
|
|
95
88
|
if (isInstalled) {
|
|
96
|
-
statusText = (0,
|
|
89
|
+
statusText = (0, import_i18n.__)("Installed!");
|
|
97
90
|
} else if (isInstalling) {
|
|
98
|
-
statusText = (0,
|
|
91
|
+
statusText = (0, import_i18n.__)("Installing\u2026");
|
|
99
92
|
}
|
|
100
93
|
const itemLabel = getDownloadableBlockLabel(item, {
|
|
101
94
|
hasNotice,
|
|
102
95
|
isInstalled,
|
|
103
96
|
isInstalling
|
|
104
97
|
});
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
98
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Tooltip, { placement: "top", text: itemLabel, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
99
|
+
import_components.Composite.Item,
|
|
100
|
+
{
|
|
101
|
+
className: (0, import_clsx.default)(
|
|
102
|
+
"block-directory-downloadable-block-list-item",
|
|
103
|
+
isInstalling && "is-installing"
|
|
104
|
+
),
|
|
110
105
|
accessibleWhenDisabled: true,
|
|
111
106
|
disabled: isInstalling || !isInstallable,
|
|
112
|
-
onClick: event => {
|
|
107
|
+
onClick: (event) => {
|
|
113
108
|
event.preventDefault();
|
|
114
109
|
onClick();
|
|
115
110
|
},
|
|
116
111
|
"aria-label": itemLabel,
|
|
117
112
|
type: "button",
|
|
118
113
|
role: "option",
|
|
119
|
-
children: [
|
|
120
|
-
className: "block-directory-downloadable-block-list-item__icon",
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
className: "block-directory-downloadable-block-list-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
className: "block-directory-downloadable-block-list-item__desc",
|
|
145
|
-
children: !!statusText ? statusText : (0, _htmlEntities.decodeEntities)(description)
|
|
146
|
-
}), isInstallable && !(isInstalled || isInstalling) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.VisuallyHidden, {
|
|
147
|
-
children: (0, _i18n.__)('Install block')
|
|
148
|
-
})]
|
|
149
|
-
})]
|
|
150
|
-
})]
|
|
151
|
-
})
|
|
152
|
-
});
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "block-directory-downloadable-block-list-item__icon", children: [
|
|
116
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_downloadable_block_icon.default, { icon, title }),
|
|
117
|
+
isInstalling ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block-directory-downloadable-block-list-item__spinner", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_ratings.default, { rating })
|
|
118
|
+
] }),
|
|
119
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "block-directory-downloadable-block-list-item__details", children: [
|
|
120
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block-directory-downloadable-block-list-item__title", children: (0, import_element.createInterpolateElement)(
|
|
121
|
+
(0, import_i18n.sprintf)(
|
|
122
|
+
/* translators: 1: block title. 2: author name. */
|
|
123
|
+
(0, import_i18n.__)("%1$s <span>by %2$s</span>"),
|
|
124
|
+
(0, import_html_entities.decodeEntities)(title),
|
|
125
|
+
author
|
|
126
|
+
),
|
|
127
|
+
{
|
|
128
|
+
span: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block-directory-downloadable-block-list-item__author" })
|
|
129
|
+
}
|
|
130
|
+
) }),
|
|
131
|
+
hasNotice ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_downloadable_block_notice.default, { block: item }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
132
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block-directory-downloadable-block-list-item__desc", children: !!statusText ? statusText : (0, import_html_entities.decodeEntities)(description) }),
|
|
133
|
+
isInstallable && !(isInstalled || isInstalling) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.VisuallyHidden, { children: (0, import_i18n.__)("Install block") })
|
|
134
|
+
] })
|
|
135
|
+
] })
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
) });
|
|
153
139
|
}
|
|
154
|
-
var
|
|
155
|
-
//# sourceMappingURL=index.js.map
|
|
140
|
+
var downloadable_block_list_item_default = DownloadableBlockListItem;
|
|
141
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_components","_element","_htmlEntities","_blocks","_data","_blockRatings","_downloadableBlockIcon","_downloadableBlockNotice","_store","_jsxRuntime","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","sprintf","decodeEntities","_n","DownloadableBlockListItem","item","onClick","author","description","icon","getBlockType","name","isInstallable","useSelect","select","getErrorNoticeForBlock","isBlockInstalling","blockDirectoryStore","notice","id","hasFatal","isFatal","statusText","__","itemLabel","jsx","Tooltip","placement","text","children","jsxs","Composite","Item","className","clsx","accessibleWhenDisabled","disabled","event","preventDefault","type","role","default","Spinner","createInterpolateElement","span","block","Fragment","VisuallyHidden","_default","exports"],"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tTooltip,\n\tSpinner,\n\tVisuallyHidden,\n\tComposite,\n} from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\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\t/* translators: %s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %s: block title */\n\t\treturn sprintf( 'Installing %s.', decodeEntities( title ) );\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\t/* translators: %s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\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 placement=\"top\" text={ itemLabel }>\n\t\t\t<Composite.Item\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-directory-downloadable-block-list-item',\n\t\t\t\t\tisInstalling && 'is-installing'\n\t\t\t\t) }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tonClick();\n\t\t\t\t} }\n\t\t\t\taria-label={ itemLabel }\n\t\t\t\ttype=\"button\"\n\t\t\t\trole=\"option\"\n\t\t\t>\n\t\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: 1: block title. 2: author name. */\n\t\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: (\n\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),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\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{ !! statusText\n\t\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\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</span>\n\t\t\t</Composite.Item>\n\t\t</Tooltip>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAKA,IAAAO,aAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,sBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,wBAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AAA2D,IAAAW,WAAA,GAAAX,OAAA;AA1B3D;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;;AAMA;AACA,SAASY,yBAAyBA,CACjC;EAAEC,KAAK;EAAEC,MAAM;EAAEC;AAAY,CAAC,EAC9B;EAAEC,SAAS;EAAEC,WAAW;EAAEC;AAAa,CAAC,EACvC;EACD,MAAMC,KAAK,GAAGC,IAAI,CAACC,KAAK,CAAEP,MAAM,GAAG,GAAI,CAAC,GAAG,GAAG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AAkE,cAAc;YAAAlB,QAAA,EACZ,IAAAN,QAAE,EAAE,eAAgB;UAAC,CACR,CAChB;QAAA,CACD,CACF;MAAA,CACI,CAAC;IAAA,CACQ;EAAC,CACT,CAAC;AAEZ;AAAC,IAAAyB,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEcrC,yBAAyB","ignoreList":[]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/downloadable-block-list-item/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tTooltip,\n\tSpinner,\n\tVisuallyHidden,\n\tComposite,\n} from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\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\t/* translators: %s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %s: block title */\n\t\treturn sprintf( 'Installing %s.', decodeEntities( title ) );\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\t/* translators: %s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\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\u2026' );\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 placement=\"top\" text={ itemLabel }>\n\t\t\t<Composite.Item\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-directory-downloadable-block-list-item',\n\t\t\t\t\tisInstalling && 'is-installing'\n\t\t\t\t) }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tonClick();\n\t\t\t\t} }\n\t\t\t\taria-label={ itemLabel }\n\t\t\t\ttype=\"button\"\n\t\t\t\trole=\"option\"\n\t\t\t>\n\t\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: 1: block title. 2: author name. */\n\t\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: (\n\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),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\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{ !! statusText\n\t\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t\t<Visu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AAA,kBAChC,qCAAgB,KAAM;AAAA,cACtB;AAAA,YACD;AAAA,YACA;AAAA,cACC,MACC,4CAAC,UAAK,WAAU,wDAAuD;AAAA,YAEzE;AAAA,UACD,GACD;AAAA,UACE,YACD,4CAAC,iCAAAC,SAAA,EAAwB,OAAQ,MAAO,IAExC,4EACC;AAAA,wDAAC,UAAK,WAAU,sDACb,WAAC,CAAE,aACF,iBACA,qCAAgB,WAAY,GAChC;AAAA,YACE,iBACD,EAAI,eAAe,iBAClB,4CAAC,oCACE,8BAAI,eAAgB,GACvB;AAAA,aAEH;AAAA,WAEF;AAAA;AAAA;AAAA,EACD,GACD;AAEF;AAEA,IAAO,uCAAQ;",
|
|
6
|
+
"names": ["blockDirectoryStore", "clsx", "DownloadableBlockIcon", "BlockRatings", "DownloadableBlockNotice"]
|
|
7
|
+
}
|
|
@@ -1,36 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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
|
+
var downloadable_block_notice_exports = {};
|
|
19
|
+
__export(downloadable_block_notice_exports, {
|
|
20
|
+
DownloadableBlockNotice: () => DownloadableBlockNotice,
|
|
21
|
+
default: () => downloadable_block_notice_default
|
|
5
22
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
const DownloadableBlockNotice = ({
|
|
20
|
-
block
|
|
21
|
-
}) => {
|
|
22
|
-
const errorNotice = (0, _data.useSelect)(select => select(_store.store).getErrorNoticeForBlock(block.id), [block]);
|
|
23
|
+
module.exports = __toCommonJS(downloadable_block_notice_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_i18n = require("@wordpress/i18n");
|
|
26
|
+
var import_data = require("@wordpress/data");
|
|
27
|
+
var import_store = require("../../store");
|
|
28
|
+
const DownloadableBlockNotice = ({ block }) => {
|
|
29
|
+
const errorNotice = (0, import_data.useSelect)(
|
|
30
|
+
(select) => select(import_store.store).getErrorNoticeForBlock(block.id),
|
|
31
|
+
[block]
|
|
32
|
+
);
|
|
23
33
|
if (!errorNotice) {
|
|
24
34
|
return null;
|
|
25
35
|
}
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
children: [errorNotice.message, errorNotice.isFatal ? ' ' + (0, _i18n.__)('Try reloading the page.') : null]
|
|
31
|
-
})
|
|
32
|
-
});
|
|
36
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "block-directory-downloadable-block-notice", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "block-directory-downloadable-block-notice__content", children: [
|
|
37
|
+
errorNotice.message,
|
|
38
|
+
errorNotice.isFatal ? " " + (0, import_i18n.__)("Try reloading the page.") : null
|
|
39
|
+
] }) });
|
|
33
40
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
var downloadable_block_notice_default = DownloadableBlockNotice;
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
DownloadableBlockNotice
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/downloadable-block-notice/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockDirectoryStore } from '../../store';\n\nexport const DownloadableBlockNotice = ( { block } ) => {\n\tconst errorNotice = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockDirectoryStore ).getErrorNoticeForBlock( block.id ),\n\t\t[ block ]\n\t);\n\n\tif ( ! errorNotice ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-directory-downloadable-block-notice\">\n\t\t\t<div className=\"block-directory-downloadable-block-notice__content\">\n\t\t\t\t{ errorNotice.message }\n\t\t\t\t{ errorNotice.isFatal\n\t\t\t\t\t? ' ' + __( 'Try reloading the page.' )\n\t\t\t\t\t: null }\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default DownloadableBlockNotice;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBE;AApBF,kBAAmB;AACnB,kBAA0B;AAK1B,mBAA6C;AAEtC,MAAM,0BAA0B,CAAE,EAAE,MAAM,MAAO;AACvD,QAAM,kBAAc;AAAA,IACnB,CAAE,WACD,OAAQ,aAAAA,KAAoB,EAAE,uBAAwB,MAAM,EAAG;AAAA,IAChE,CAAE,KAAM;AAAA,EACT;AAEA,MAAK,CAAE,aAAc;AACpB,WAAO;AAAA,EACR;AAEA,SACC,4CAAC,SAAI,WAAU,6CACd,uDAAC,SAAI,WAAU,sDACZ;AAAA,gBAAY;AAAA,IACZ,YAAY,UACX,UAAM,gBAAI,yBAA0B,IACpC;AAAA,KACJ,GACD;AAEF;AAEA,IAAO,oCAAQ;",
|
|
6
|
+
"names": ["blockDirectoryStore"]
|
|
7
|
+
}
|
|
@@ -1,63 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
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
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var downloadable_blocks_list_exports = {};
|
|
29
|
+
__export(downloadable_blocks_list_exports, {
|
|
30
|
+
default: () => downloadable_blocks_list_default
|
|
6
31
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Internal dependencies
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
const noop = () => {};
|
|
24
|
-
function DownloadableBlocksList({
|
|
25
|
-
items,
|
|
26
|
-
onHover = noop,
|
|
27
|
-
onSelect
|
|
28
|
-
}) {
|
|
29
|
-
const {
|
|
30
|
-
installBlockType
|
|
31
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
32
|
+
module.exports = __toCommonJS(downloadable_blocks_list_exports);
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_i18n = require("@wordpress/i18n");
|
|
35
|
+
var import_components = require("@wordpress/components");
|
|
36
|
+
var import_blocks = require("@wordpress/blocks");
|
|
37
|
+
var import_data = require("@wordpress/data");
|
|
38
|
+
var import_downloadable_block_list_item = __toESM(require("../downloadable-block-list-item"));
|
|
39
|
+
var import_store = require("../../store");
|
|
40
|
+
const noop = () => {
|
|
41
|
+
};
|
|
42
|
+
function DownloadableBlocksList({ items, onHover = noop, onSelect }) {
|
|
43
|
+
const { installBlockType } = (0, import_data.useDispatch)(import_store.store);
|
|
32
44
|
if (!items.length) {
|
|
33
45
|
return null;
|
|
34
46
|
}
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
} else {
|
|
48
|
-
installBlockType(item).then(success => {
|
|
49
|
-
if (success) {
|
|
47
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
48
|
+
import_components.Composite,
|
|
49
|
+
{
|
|
50
|
+
role: "listbox",
|
|
51
|
+
className: "block-directory-downloadable-blocks-list",
|
|
52
|
+
"aria-label": (0, import_i18n.__)("Blocks available for install"),
|
|
53
|
+
children: items.map((item) => {
|
|
54
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
55
|
+
import_downloadable_block_list_item.default,
|
|
56
|
+
{
|
|
57
|
+
onClick: () => {
|
|
58
|
+
if ((0, import_blocks.getBlockType)(item.name)) {
|
|
50
59
|
onSelect(item);
|
|
60
|
+
} else {
|
|
61
|
+
installBlockType(item).then((success) => {
|
|
62
|
+
if (success) {
|
|
63
|
+
onSelect(item);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
51
66
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
67
|
+
onHover(null);
|
|
68
|
+
},
|
|
69
|
+
onHover,
|
|
70
|
+
item
|
|
71
|
+
},
|
|
72
|
+
item.id
|
|
73
|
+
);
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
);
|
|
61
77
|
}
|
|
62
|
-
var
|
|
63
|
-
//# sourceMappingURL=index.js.map
|
|
78
|
+
var downloadable_blocks_list_default = DownloadableBlocksList;
|
|
79
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/downloadable-blocks-list/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Composite } from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockListItem from '../downloadable-block-list-item';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst noop = () => {};\n\nfunction DownloadableBlocksList( { items, onHover = noop, onSelect } ) {\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Composite\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-directory-downloadable-blocks-list\"\n\t\t\taria-label={ __( 'Blocks available for install' ) }\n\t\t>\n\t\t\t{ items.map( ( item ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlockListItem\n\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Check if the block is registered (`getBlockType`\n\t\t\t\t\t\t\t// will return an object). If so, insert the block.\n\t\t\t\t\t\t\t// This prevents installing existing plugins.\n\t\t\t\t\t\t\tif ( getBlockType( item.name ) ) {\n\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tinstallBlockType( item ).then( ( success ) => {\n\t\t\t\t\t\t\t\t\tif ( success ) {\n\t\t\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Composite>\n\t);\n}\n\nexport default DownloadableBlocksList;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BK;AA5BL,kBAAmB;AACnB,wBAA0B;AAC1B,oBAA6B;AAC7B,kBAA4B;AAK5B,0CAAsC;AACtC,mBAA6C;AAE7C,MAAM,OAAO,MAAM;AAAC;AAEpB,SAAS,uBAAwB,EAAE,OAAO,UAAU,MAAM,SAAS,GAAI;AACtE,QAAM,EAAE,iBAAiB,QAAI,yBAAa,aAAAA,KAAoB;AAE9D,MAAK,CAAE,MAAM,QAAS;AACrB,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,WAAU;AAAA,MACV,kBAAa,gBAAI,8BAA+B;AAAA,MAE9C,gBAAM,IAAK,CAAE,SAAU;AACxB,eACC;AAAA,UAAC,oCAAAC;AAAA,UAAA;AAAA,YAEA,SAAU,MAAM;AAIf,sBAAK,4BAAc,KAAK,IAAK,GAAI;AAChC,yBAAU,IAAK;AAAA,cAChB,OAAO;AACN,iCAAkB,IAAK,EAAE,KAAM,CAAE,YAAa;AAC7C,sBAAK,SAAU;AACd,6BAAU,IAAK;AAAA,kBAChB;AAAA,gBACD,CAAE;AAAA,cACH;AACA,sBAAS,IAAK;AAAA,YACf;AAAA,YACA;AAAA,YACA;AAAA;AAAA,UAjBM,KAAK;AAAA,QAkBZ;AAAA,MAEF,CAAE;AAAA;AAAA,EACH;AAEF;AAEA,IAAO,mCAAQ;",
|
|
6
|
+
"names": ["blockDirectoryStore", "DownloadableBlockListItem"]
|
|
7
|
+
}
|