@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,174 +1,108 @@
|
|
|
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
|
-
|
|
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 clsx = require("clsx");
|
|
28
|
+
clsx = __toESM(clsx);
|
|
29
|
+
let _wordpress_i18n = require("@wordpress/i18n");
|
|
30
|
+
let _wordpress_components = require("@wordpress/components");
|
|
31
|
+
let _wordpress_element = require("@wordpress/element");
|
|
32
|
+
let _wordpress_html_entities = require("@wordpress/html-entities");
|
|
33
|
+
let _wordpress_blocks = require("@wordpress/blocks");
|
|
34
|
+
let _wordpress_data = require("@wordpress/data");
|
|
35
|
+
let _wordpress_ui = require("@wordpress/ui");
|
|
36
|
+
let ___block_ratings_index_jsx = require("../block-ratings/index.cjs");
|
|
37
|
+
___block_ratings_index_jsx = __toESM(___block_ratings_index_jsx);
|
|
38
|
+
let ___downloadable_block_icon_index_jsx = require("../downloadable-block-icon/index.cjs");
|
|
39
|
+
___downloadable_block_icon_index_jsx = __toESM(___downloadable_block_icon_index_jsx);
|
|
40
|
+
let ___downloadable_block_notice_index_jsx = require("../downloadable-block-notice/index.cjs");
|
|
41
|
+
___downloadable_block_notice_index_jsx = __toESM(___downloadable_block_notice_index_jsx);
|
|
42
|
+
let ______store_index_js = require("../../store/index.cjs");
|
|
43
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
29
44
|
// packages/block-directory/src/components/downloadable-block-list-item/index.jsx
|
|
30
|
-
var downloadable_block_list_item_exports = {};
|
|
31
|
-
__export(downloadable_block_list_item_exports, {
|
|
32
|
-
default: () => downloadable_block_list_item_default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(downloadable_block_list_item_exports);
|
|
35
|
-
var import_clsx = __toESM(require("clsx"));
|
|
36
|
-
var import_i18n = require("@wordpress/i18n");
|
|
37
|
-
var import_components = require("@wordpress/components");
|
|
38
|
-
var import_element = require("@wordpress/element");
|
|
39
|
-
var import_html_entities = require("@wordpress/html-entities");
|
|
40
|
-
var import_blocks = require("@wordpress/blocks");
|
|
41
|
-
var import_data = require("@wordpress/data");
|
|
42
|
-
var import_ui = require("@wordpress/ui");
|
|
43
|
-
var import_block_ratings = __toESM(require("../block-ratings/index.cjs"));
|
|
44
|
-
var import_downloadable_block_icon = __toESM(require("../downloadable-block-icon/index.cjs"));
|
|
45
|
-
var import_downloadable_block_notice = __toESM(require("../downloadable-block-notice/index.cjs"));
|
|
46
|
-
var import_store = require("../../store/index.cjs");
|
|
47
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
45
|
function getDownloadableBlockLabel({ title, rating, ratingCount }, { hasNotice, isInstalled, isInstalling }) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
if (isInstalled) {
|
|
58
|
-
return (0, import_i18n.sprintf)(
|
|
59
|
-
/* translators: %s: block title */
|
|
60
|
-
(0, import_i18n.__)("Add %s."),
|
|
61
|
-
(0, import_html_entities.decodeEntities)(title)
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
if (isInstalling) {
|
|
65
|
-
return (0, import_i18n.sprintf)(
|
|
66
|
-
/* translators: %s: block title */
|
|
67
|
-
(0, import_i18n.__)("Installing %s."),
|
|
68
|
-
(0, import_html_entities.decodeEntities)(title)
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
if (ratingCount < 1) {
|
|
72
|
-
return (0, import_i18n.sprintf)(
|
|
73
|
-
/* translators: %s: block title */
|
|
74
|
-
(0, import_i18n.__)("Install %s."),
|
|
75
|
-
(0, import_html_entities.decodeEntities)(title)
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
return (0, import_i18n.sprintf)(
|
|
79
|
-
/* translators: 1: block title, 2: average rating, 3: total ratings count. */
|
|
80
|
-
(0, import_i18n._n)(
|
|
81
|
-
"Install %1$s. %2$s stars with %3$s review.",
|
|
82
|
-
"Install %1$s. %2$s stars with %3$s reviews.",
|
|
83
|
-
ratingCount
|
|
84
|
-
),
|
|
85
|
-
(0, import_html_entities.decodeEntities)(title),
|
|
86
|
-
stars,
|
|
87
|
-
ratingCount
|
|
88
|
-
);
|
|
46
|
+
const stars = Math.round(rating / .5) * .5;
|
|
47
|
+
if (!isInstalled && hasNotice) return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Retry installing %s."), (0, _wordpress_html_entities.decodeEntities)(title));
|
|
48
|
+
if (isInstalled) return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Add %s."), (0, _wordpress_html_entities.decodeEntities)(title));
|
|
49
|
+
if (isInstalling) return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Installing %s."), (0, _wordpress_html_entities.decodeEntities)(title));
|
|
50
|
+
if (ratingCount < 1) return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Install %s."), (0, _wordpress_html_entities.decodeEntities)(title));
|
|
51
|
+
return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n._n)("Install %1$s. %2$s stars with %3$s review.", "Install %1$s. %2$s stars with %3$s reviews.", ratingCount), (0, _wordpress_html_entities.decodeEntities)(title), stars, ratingCount);
|
|
89
52
|
}
|
|
90
53
|
function DownloadableBlockListItem({ item, onClick }) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
icon,
|
|
143
|
-
title
|
|
144
|
-
}
|
|
145
|
-
),
|
|
146
|
-
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 })
|
|
147
|
-
] }),
|
|
148
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "block-directory-downloadable-block-list-item__details", children: [
|
|
149
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block-directory-downloadable-block-list-item__title", children: (0, import_element.createInterpolateElement)(
|
|
150
|
-
(0, import_i18n.sprintf)(
|
|
151
|
-
/* translators: 1: block title. 2: author name. */
|
|
152
|
-
(0, import_i18n.__)("%1$s <span>by %2$s</span>"),
|
|
153
|
-
(0, import_html_entities.decodeEntities)(title),
|
|
154
|
-
author
|
|
155
|
-
),
|
|
156
|
-
{
|
|
157
|
-
span: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block-directory-downloadable-block-list-item__author" })
|
|
158
|
-
}
|
|
159
|
-
) }),
|
|
160
|
-
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: [
|
|
161
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block-directory-downloadable-block-list-item__desc", children: !!statusText ? statusText : (0, import_html_entities.decodeEntities)(description) }),
|
|
162
|
-
isInstallable && !(isInstalled || isInstalling) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.VisuallyHidden, { children: (0, import_i18n.__)("Install block") })
|
|
163
|
-
] })
|
|
164
|
-
] })
|
|
165
|
-
]
|
|
166
|
-
}
|
|
167
|
-
)
|
|
168
|
-
}
|
|
169
|
-
),
|
|
170
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tooltip.Popup, { children: itemLabel })
|
|
171
|
-
] });
|
|
54
|
+
const { author, description, icon, rating, title } = item;
|
|
55
|
+
const isInstalled = !!(0, _wordpress_blocks.getBlockType)(item.name);
|
|
56
|
+
const { hasNotice, isInstalling, isInstallable } = (0, _wordpress_data.useSelect)((select) => {
|
|
57
|
+
const { getErrorNoticeForBlock, isInstalling: isBlockInstalling } = select(______store_index_js.store);
|
|
58
|
+
const notice = getErrorNoticeForBlock(item.id);
|
|
59
|
+
const hasFatal = notice && notice.isFatal;
|
|
60
|
+
return {
|
|
61
|
+
hasNotice: !!notice,
|
|
62
|
+
isInstalling: isBlockInstalling(item.id),
|
|
63
|
+
isInstallable: !hasFatal
|
|
64
|
+
};
|
|
65
|
+
}, [item]);
|
|
66
|
+
let statusText = "";
|
|
67
|
+
if (isInstalled) statusText = (0, _wordpress_i18n.__)("Installed!");
|
|
68
|
+
else if (isInstalling) statusText = (0, _wordpress_i18n.__)("Installing…");
|
|
69
|
+
const itemLabel = getDownloadableBlockLabel(item, {
|
|
70
|
+
hasNotice,
|
|
71
|
+
isInstalled,
|
|
72
|
+
isInstalling
|
|
73
|
+
});
|
|
74
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Tooltip.Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Tooltip.Trigger, { render: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_components.Composite.Item, {
|
|
75
|
+
className: (0, clsx.default)("block-directory-downloadable-block-list-item", isInstalling && "is-installing"),
|
|
76
|
+
accessibleWhenDisabled: true,
|
|
77
|
+
disabled: isInstalling || !isInstallable,
|
|
78
|
+
onClick: (event) => {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
onClick();
|
|
81
|
+
},
|
|
82
|
+
"aria-label": itemLabel,
|
|
83
|
+
type: "button",
|
|
84
|
+
role: "option",
|
|
85
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
86
|
+
className: "block-directory-downloadable-block-list-item__icon",
|
|
87
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(___downloadable_block_icon_index_jsx.default, {
|
|
88
|
+
icon,
|
|
89
|
+
title
|
|
90
|
+
}), isInstalling ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
91
|
+
className: "block-directory-downloadable-block-list-item__spinner",
|
|
92
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Spinner, {})
|
|
93
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___block_ratings_index_jsx.default, { rating })]
|
|
94
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
95
|
+
className: "block-directory-downloadable-block-list-item__details",
|
|
96
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
97
|
+
className: "block-directory-downloadable-block-list-item__title",
|
|
98
|
+
children: (0, _wordpress_element.createInterpolateElement)((0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("%1$s <span>by %2$s</span>"), (0, _wordpress_html_entities.decodeEntities)(title), author), { span: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "block-directory-downloadable-block-list-item__author" }) })
|
|
99
|
+
}), hasNotice ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___downloadable_block_notice_index_jsx.default, { block: item }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
100
|
+
className: "block-directory-downloadable-block-list-item__desc",
|
|
101
|
+
children: !!statusText ? statusText : (0, _wordpress_html_entities.decodeEntities)(description)
|
|
102
|
+
}), isInstallable && !(isInstalled || isInstalling) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.VisuallyHidden, { children: (0, _wordpress_i18n.__)("Install block") })] })]
|
|
103
|
+
})]
|
|
104
|
+
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Tooltip.Popup, { children: itemLabel })] });
|
|
172
105
|
}
|
|
173
|
-
|
|
174
|
-
|
|
106
|
+
exports.default = DownloadableBlockListItem;
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/downloadable-block-list-item/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { Spinner, Composite } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { VisuallyHidden, Tooltip } from '@wordpress/ui';\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Retry installing %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\tif ( isInstalled ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Add %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\tif ( isInstalling ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Installing %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Install %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\treturn sprintf(\n\t\t/* translators: 1: block title, 2: average rating, 3: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =\n\t\t\t\tselect( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\tconst itemLabel = getDownloadableBlockLabel( item, {\n\t\thasNotice,\n\t\tisInstalled,\n\t\tisInstalling,\n\t} );\n\n\treturn (\n\t\t<Tooltip.Root>\n\t\t\t<Tooltip.Trigger\n\t\t\t\trender={\n\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-directory-downloadable-block-list-item',\n\t\t\t\t\t\t\tisInstalling && 'is-installing'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tonClick();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\taria-label={ itemLabel }\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t\t\t\t<DownloadableBlockIcon\n\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: 1: block title. 2: author name. */\n\t\t\t\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Composite.Item>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Tooltip.Popup>{ itemLabel }</Tooltip.Popup>\n\t\t</Tooltip.Root>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAgC;AAChC,wBAAmC;AACnC,qBAAyC;AACzC,2BAA+B;AAC/B,oBAA6B;AAC7B,kBAA0B;AAC1B,gBAAwC;AACxC,2BAAyB;AACzB,qCAAkC;AAClC,uCAAoC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,aACF,iBACA,qCAAgB,WAAY,GAChC;AAAA,kBACE,iBACD,EAAI,eAAe,iBAClB,4CAAC,4BACE,8BAAI,eAAgB,GACvB;AAAA,mBAEH;AAAA,iBAEF;AAAA;AAAA;AAAA,QACD;AAAA;AAAA,IAEF;AAAA,IACA,4CAAC,kBAAQ,OAAR,EAAgB,qBAAW;AAAA,KAC7B;AAEF;AAEA,IAAO,uCAAQ;",
|
|
6
|
-
"names": ["blockDirectoryStore", "clsx", "DownloadableBlockIcon", "BlockRatings", "DownloadableBlockNotice"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["sprintf","__","decodeEntities","_n","getBlockType","useSelect","blockDirectoryStore","Tooltip","Composite","DownloadableBlockIcon","WCSpinner","BlockRatings","createInterpolateElement","DownloadableBlockNotice","VisuallyHidden"],"sources":["../../../src/components/downloadable-block-list-item/index.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { Spinner as WCSpinner, Composite } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { VisuallyHidden, Tooltip } from '@wordpress/ui';\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Retry installing %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\tif ( isInstalled ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Add %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\tif ( isInstalling ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Installing %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s: block title */\n\t\t\t__( 'Install %s.' ),\n\t\t\tdecodeEntities( title )\n\t\t);\n\t}\n\n\treturn sprintf(\n\t\t/* translators: 1: block title, 2: average rating, 3: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =\n\t\t\t\tselect( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\tconst itemLabel = getDownloadableBlockLabel( item, {\n\t\thasNotice,\n\t\tisInstalled,\n\t\tisInstalling,\n\t} );\n\n\treturn (\n\t\t<Tooltip.Root>\n\t\t\t<Tooltip.Trigger\n\t\t\t\trender={\n\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'block-directory-downloadable-block-list-item',\n\t\t\t\t\t\t\tisInstalling && 'is-installing'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tonClick();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\taria-label={ itemLabel }\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t\t\t\t<DownloadableBlockIcon\n\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t\t\t\t<WCSpinner />\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: 1: block title. 2: author name. */\n\t\t\t\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Composite.Item>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Tooltip.Popup>{ itemLabel }</Tooltip.Popup>\n\t\t</Tooltip.Root>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,0BACR,EAAE,OAAO,QAAQ,eACjB,EAAE,WAAW,aAAa,gBACzB;CACD,MAAM,QAAQ,KAAK,MAAO,SAAS,EAAI,IAAI;CAE3C,IAAK,CAAE,eAAe,WACrB,QAAA,GAAOA,gBAAAA,QAAAA,EAAA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CACD;GACK,CAAA,GACJ,YACD,iBAAA,GAAA,kBAAA,IAAA,CAACW,uCAAAA,SAAD,EAAyB,OAAQ,KAAQ,CAAA,IAEzC,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;IAAM,WAAU;IACb,UAAA,CAAC,CAAE,aACF,cAAA,GACAX,yBAAAA,eAAAA,CAAgB,WAAY;GAC1B,CAAA,GACJ,iBACD,EAAI,eAAe,iBAClB,iBAAA,GAAA,kBAAA,IAAA,CAACY,cAAAA,gBAAD,EAAA,WAAA,GACGb,gBAAAA,GAAAA,CAAI,eAAgB,EACP,CAAA,CAEjB,EAAA,CAAA,CAEE;EACS,CAAA,CAAA;CAEjB,CAAA,EAAA,CAAA,GACD,iBAAA,GAAA,kBAAA,IAAA,CAACM,cAAAA,QAAQ,OAAT,EAAA,UAAiB,UAA0B,CAAA,CAC9B,EAAA,CAAA;AAEhB"}
|
|
@@ -1,48 +1,25 @@
|
|
|
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/components/downloadable-block-notice/index.jsx
|
|
20
|
-
var downloadable_block_notice_exports = {};
|
|
21
|
-
__export(downloadable_block_notice_exports, {
|
|
22
|
-
DownloadableBlockNotice: () => DownloadableBlockNotice,
|
|
23
|
-
default: () => downloadable_block_notice_default
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
5
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
errorNotice.isFatal ? " " + (0, import_i18n.__)("Try reloading the page.") : null
|
|
41
|
-
] }) });
|
|
6
|
+
let _wordpress_i18n = require("@wordpress/i18n");
|
|
7
|
+
let _wordpress_data = require("@wordpress/data");
|
|
8
|
+
let ______store_index_js = require("../../store/index.cjs");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
// packages/block-directory/src/components/downloadable-block-notice/index.jsx
|
|
11
|
+
const DownloadableBlockNotice = ({ block }) => {
|
|
12
|
+
const errorNotice = (0, _wordpress_data.useSelect)((select) => select(______store_index_js.store).getErrorNoticeForBlock(block.id), [block]);
|
|
13
|
+
if (!errorNotice) return null;
|
|
14
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15
|
+
className: "block-directory-downloadable-block-notice",
|
|
16
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
17
|
+
className: "block-directory-downloadable-block-notice__content",
|
|
18
|
+
children: [errorNotice.message, errorNotice.isFatal ? " " + (0, _wordpress_i18n.__)("Try reloading the page.") : null]
|
|
19
|
+
})
|
|
20
|
+
});
|
|
42
21
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
//# sourceMappingURL=index.cjs.map
|
|
22
|
+
exports.DownloadableBlockNotice = DownloadableBlockNotice;
|
|
23
|
+
exports.default = DownloadableBlockNotice;
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/downloadable-block-notice/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\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;AAAA,kBAAmB;AACnB,kBAA0B;AAC1B,mBAA6C;AAc3C;AAZK,IAAM,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
|
+
{"version":3,"file":"index.cjs","names":["useSelect","blockDirectoryStore","__"],"sources":["../../../src/components/downloadable-block-notice/index.jsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\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"],"mappings":";;;;;;;;;;AAIA,MAAa,2BAA4B,EAAE,YAAa;CACvD,MAAM,eAAA,GAAcA,gBAAAA,UAAAA,EACjB,WACD,OAAQC,qBAAAA,KAAoB,CAAC,CAAC,uBAAwB,MAAM,EAAG,GAChE,CAAE,KAAM,CACT;CAEA,IAAK,CAAE,aACN,OAAO;CAGR,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAU;EACd,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACG,YAAY,SACZ,YAAY,UACX,OAAA,GAAMC,gBAAAA,GAAAA,CAAI,yBAA0B,IACpC,IACC;;CACD,CAAA;AAEP"}
|
|
@@ -1,81 +1,61 @@
|
|
|
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
|
-
|
|
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 _wordpress_i18n = require("@wordpress/i18n");
|
|
28
|
+
let _wordpress_components = require("@wordpress/components");
|
|
29
|
+
let _wordpress_blocks = require("@wordpress/blocks");
|
|
30
|
+
let _wordpress_data = require("@wordpress/data");
|
|
31
|
+
let ___downloadable_block_list_item_index_jsx = require("../downloadable-block-list-item/index.cjs");
|
|
32
|
+
___downloadable_block_list_item_index_jsx = __toESM(___downloadable_block_list_item_index_jsx);
|
|
33
|
+
let ______store_index_js = require("../../store/index.cjs");
|
|
34
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
29
35
|
// packages/block-directory/src/components/downloadable-blocks-list/index.jsx
|
|
30
|
-
|
|
31
|
-
__export(downloadable_blocks_list_exports, {
|
|
32
|
-
default: () => downloadable_blocks_list_default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(downloadable_blocks_list_exports);
|
|
35
|
-
var import_i18n = require("@wordpress/i18n");
|
|
36
|
-
var import_components = require("@wordpress/components");
|
|
37
|
-
var import_blocks = require("@wordpress/blocks");
|
|
38
|
-
var import_data = require("@wordpress/data");
|
|
39
|
-
var import_downloadable_block_list_item = __toESM(require("../downloadable-block-list-item/index.cjs"));
|
|
40
|
-
var import_store = require("../../store/index.cjs");
|
|
41
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
-
var noop = () => {
|
|
43
|
-
};
|
|
36
|
+
const noop = () => {};
|
|
44
37
|
function DownloadableBlocksList({ items, onHover = noop, onSelect }) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
onSelect(item);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
onHover(null);
|
|
70
|
-
},
|
|
71
|
-
onHover,
|
|
72
|
-
item
|
|
73
|
-
},
|
|
74
|
-
item.id
|
|
75
|
-
);
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
);
|
|
38
|
+
const { installBlockType } = (0, _wordpress_data.useDispatch)(______store_index_js.store);
|
|
39
|
+
if (!items.length) return null;
|
|
40
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Composite, {
|
|
41
|
+
role: "listbox",
|
|
42
|
+
className: "block-directory-downloadable-blocks-list",
|
|
43
|
+
"aria-label": (0, _wordpress_i18n.__)("Blocks available for install"),
|
|
44
|
+
children: items.map((item) => {
|
|
45
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___downloadable_block_list_item_index_jsx.default, {
|
|
46
|
+
onClick: () => {
|
|
47
|
+
if ((0, _wordpress_blocks.getBlockType)(item.name)) onSelect(item);
|
|
48
|
+
else installBlockType(item).then((success) => {
|
|
49
|
+
if (success) onSelect(item);
|
|
50
|
+
});
|
|
51
|
+
onHover(null);
|
|
52
|
+
},
|
|
53
|
+
onHover,
|
|
54
|
+
item
|
|
55
|
+
}, item.id);
|
|
56
|
+
})
|
|
57
|
+
});
|
|
79
58
|
}
|
|
80
|
-
|
|
81
|
-
|
|
59
|
+
exports.default = DownloadableBlocksList;
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/downloadable-blocks-list/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { Composite } from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\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;AAAA,kBAAmB;AACnB,wBAA0B;AAC1B,oBAA6B;AAC7B,kBAA4B;AAC5B,0CAAsC;AACtC,mBAA6C;AAmBxC;AAjBL,IAAM,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
|
-
}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useDispatch","blockDirectoryStore","Composite","__","DownloadableBlockListItem","getBlockType"],"sources":["../../../src/components/downloadable-blocks-list/index.jsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { Composite } from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,aAAa,CAAC;AAEpB,SAAS,uBAAwB,EAAE,OAAO,UAAU,MAAM,YAAa;CACtE,MAAM,EAAE,sBAAA,GAAqBA,gBAAAA,YAAAA,CAAaC,qBAAAA,KAAoB;CAE9D,IAAK,CAAE,MAAM,QACZ,OAAO;CAGR,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,WAAD;EACC,MAAK;EACL,WAAU;EACV,eAAA,GAAaC,gBAAAA,GAAAA,CAAI,8BAA+B;EAE9C,UAAA,MAAM,KAAO,SAAU;GACxB,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,0CAAAA,SAAD;IAEC,eAAgB;KAIf,KAAA,GAAKC,kBAAAA,aAAAA,CAAc,KAAK,IAAK,GAC5B,SAAU,IAAK;UAEf,iBAAkB,IAAK,CAAC,CAAC,MAAQ,YAAa;MAC7C,IAAK,SACJ,SAAU,IAAK;KAEjB,CAAE;KAEH,QAAS,IAAK;IACf;IACU;IACH;GACP,GAlBM,KAAK,EAkBX;EAEH,CAAE;CACQ,CAAA;AAEb"}
|