PluginProbe
Gutenberg / 23.2.1
Gutenberg v23.2.1
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / scripts / notices / index.js

index.js in Gutenberg 23.2.1, at build/scripts/notices/index.js

287 lines 9.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2 var wp;
3 (wp ||= {}).notices = (() => {
4 var __create = Object.create;
5 var __defProp = Object.defineProperty;
6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7 var __getOwnPropNames = Object.getOwnPropertyNames;
8 var __getProtoOf = Object.getPrototypeOf;
9 var __hasOwnProp = Object.prototype.hasOwnProperty;
10 var __commonJS = (cb, mod) => function __require() {
11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12 };
13 var __export = (target, all) => {
14 for (var name in all)
15 __defProp(target, name, { get: all[name], enumerable: true });
16 };
17 var __copyProps = (to, from, except, desc) => {
18 if (from && typeof from === "object" || typeof from === "function") {
19 for (let key of __getOwnPropNames(from))
20 if (!__hasOwnProp.call(to, key) && key !== except)
21 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22 }
23 return to;
24 };
25 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26 // If the importer is in node compatibility mode or this is not an ESM
27 // file that has been converted to a CommonJS file using a Babel-
28 // compatible transform (i.e. "__esModule" has not been set), then set
29 // "default" to the CommonJS "module.exports" for node compatibility.
30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31 mod
32 ));
33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
35 // package-external:@wordpress/data
36 var require_data = __commonJS({
37 "package-external:@wordpress/data"(exports, module) {
38 module.exports = window.wp.data;
39 }
40 });
41
42 // package-external:@wordpress/components
43 var require_components = __commonJS({
44 "package-external:@wordpress/components"(exports, module) {
45 module.exports = window.wp.components;
46 }
47 });
48
49 // vendor-external:react/jsx-runtime
50 var require_jsx_runtime = __commonJS({
51 "vendor-external:react/jsx-runtime"(exports, module) {
52 module.exports = window.ReactJSXRuntime;
53 }
54 });
55
56 // packages/notices/build-module/index.mjs
57 var index_exports = {};
58 __export(index_exports, {
59 InlineNotices: () => InlineNotices,
60 SnackbarNotices: () => SnackbarNotices,
61 store: () => store
62 });
63
64 // packages/notices/build-module/store/index.mjs
65 var import_data2 = __toESM(require_data(), 1);
66
67 // packages/notices/build-module/store/reducer.mjs
68 var import_data = __toESM(require_data(), 1);
69 var notices = (0, import_data.keyedReducer)("context")((state = [], action) => {
70 switch (action.type) {
71 case "CREATE_NOTICE":
72 return [
73 ...state.filter(({ id }) => id !== action.notice.id),
74 action.notice
75 ];
76 case "REMOVE_NOTICE":
77 return state.filter(({ id }) => id !== action.id);
78 case "REMOVE_NOTICES":
79 return state.filter(({ id }) => !action.ids.includes(id));
80 case "REMOVE_ALL_NOTICES":
81 return state.filter(({ type }) => type !== action.noticeType);
82 default:
83 return state;
84 }
85 });
86 var reducer_default = notices;
87
88 // packages/notices/build-module/store/actions.mjs
89 var actions_exports = {};
90 __export(actions_exports, {
91 createErrorNotice: () => createErrorNotice,
92 createInfoNotice: () => createInfoNotice,
93 createNotice: () => createNotice,
94 createSuccessNotice: () => createSuccessNotice,
95 createWarningNotice: () => createWarningNotice,
96 removeAllNotices: () => removeAllNotices,
97 removeNotice: () => removeNotice,
98 removeNotices: () => removeNotices
99 });
100
101 // packages/notices/build-module/store/constants.mjs
102 var DEFAULT_CONTEXT = "global";
103 var DEFAULT_STATUS = "info";
104
105 // packages/notices/build-module/store/actions.mjs
106 var uniqueId = 0;
107 function createNotice(status = DEFAULT_STATUS, content, options = {}) {
108 const {
109 speak = true,
110 isDismissible = true,
111 context = DEFAULT_CONTEXT,
112 id = `${context}${++uniqueId}`,
113 actions = [],
114 type = "default",
115 __unstableHTML,
116 icon = null,
117 explicitDismiss = false,
118 onDismiss
119 } = options;
120 content = String(content);
121 return {
122 type: "CREATE_NOTICE",
123 context,
124 notice: {
125 id,
126 status,
127 content,
128 spokenMessage: speak ? content : null,
129 __unstableHTML,
130 isDismissible,
131 actions,
132 type,
133 icon,
134 explicitDismiss,
135 onDismiss
136 }
137 };
138 }
139 function createSuccessNotice(content, options) {
140 return createNotice("success", content, options);
141 }
142 function createInfoNotice(content, options) {
143 return createNotice("info", content, options);
144 }
145 function createErrorNotice(content, options) {
146 return createNotice("error", content, options);
147 }
148 function createWarningNotice(content, options) {
149 return createNotice("warning", content, options);
150 }
151 function removeNotice(id, context = DEFAULT_CONTEXT) {
152 return {
153 type: "REMOVE_NOTICE",
154 id,
155 context
156 };
157 }
158 function removeAllNotices(noticeType = "default", context = DEFAULT_CONTEXT) {
159 return {
160 type: "REMOVE_ALL_NOTICES",
161 noticeType,
162 context
163 };
164 }
165 function removeNotices(ids, context = DEFAULT_CONTEXT) {
166 return {
167 type: "REMOVE_NOTICES",
168 ids,
169 context
170 };
171 }
172
173 // packages/notices/build-module/store/selectors.mjs
174 var selectors_exports = {};
175 __export(selectors_exports, {
176 getNotices: () => getNotices
177 });
178 var DEFAULT_NOTICES = [];
179 function getNotices(state, context = DEFAULT_CONTEXT) {
180 return state[context] || DEFAULT_NOTICES;
181 }
182
183 // packages/notices/build-module/store/index.mjs
184 var store = (0, import_data2.createReduxStore)("core/notices", {
185 reducer: reducer_default,
186 actions: actions_exports,
187 selectors: selectors_exports
188 });
189 (0, import_data2.register)(store);
190
191 // node_modules/clsx/dist/clsx.mjs
192 function r(e) {
193 var t, f, n = "";
194 if ("string" == typeof e || "number" == typeof e) n += e;
195 else if ("object" == typeof e) if (Array.isArray(e)) {
196 var o = e.length;
197 for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
198 } else for (f in e) e[f] && (n && (n += " "), n += f);
199 return n;
200 }
201 function clsx() {
202 for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
203 return n;
204 }
205 var clsx_default = clsx;
206
207 // packages/notices/build-module/components/inline-notices/index.mjs
208 var import_components = __toESM(require_components(), 1);
209 var import_data3 = __toESM(require_data(), 1);
210 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
211 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='2c1d02983b']")) {
212 const style = document.createElement("style");
213 style.setAttribute("data-wp-hash", "2c1d02983b");
214 style.appendChild(document.createTextNode(".components-notices__dismissible,.components-notices__pinned{color:#1e1e1e}.components-notices__dismissible .components-notice,.components-notices__pinned .components-notice{border-bottom:1px solid #0003;box-sizing:border-box;min-height:64px;padding:0 12px}.components-notices__dismissible .components-notice .components-notice__dismiss,.components-notices__pinned .components-notice .components-notice__dismiss{margin-top:12px}"));
215 document.head.appendChild(style);
216 }
217 function InlineNotices({
218 children,
219 pinnedNoticesClassName,
220 dismissibleNoticesClassName,
221 context
222 }) {
223 const notices2 = (0, import_data3.useSelect)(
224 (select) => select(store).getNotices(context),
225 [context]
226 );
227 const { removeNotice: removeNotice2 } = (0, import_data3.useDispatch)(store);
228 const dismissibleNotices = notices2.filter(
229 ({ isDismissible, type }) => isDismissible && type === "default"
230 );
231 const nonDismissibleNotices = notices2.filter(
232 ({ isDismissible, type }) => !isDismissible && type === "default"
233 );
234 return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
235 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
236 import_components.NoticeList,
237 {
238 notices: nonDismissibleNotices,
239 className: clsx_default(
240 "components-notices__pinned",
241 pinnedNoticesClassName
242 )
243 }
244 ),
245 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
246 import_components.NoticeList,
247 {
248 notices: dismissibleNotices,
249 className: clsx_default(
250 "components-notices__dismissible",
251 dismissibleNoticesClassName
252 ),
253 onRemove: (id) => removeNotice2(id, context),
254 children
255 }
256 )
257 ] });
258 }
259
260 // packages/notices/build-module/components/snackbar-notices/index.mjs
261 var import_components2 = __toESM(require_components(), 1);
262 var import_data4 = __toESM(require_data(), 1);
263 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
264 var MAX_VISIBLE_NOTICES = -3;
265 function SnackbarNotices({
266 className,
267 context
268 }) {
269 const notices2 = (0, import_data4.useSelect)(
270 (select) => select(store).getNotices(context),
271 [context]
272 );
273 const { removeNotice: removeNotice2 } = (0, import_data4.useDispatch)(store);
274 const snackbarNotices = notices2.filter(({ type }) => type === "snackbar").slice(MAX_VISIBLE_NOTICES);
275 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
276 import_components2.SnackbarList,
277 {
278 notices: snackbarNotices,
279 className: clsx_default("components-notices__snackbar", className),
280 onRemove: (id) => removeNotice2(id, context)
281 }
282 );
283 }
284 return __toCommonJS(index_exports);
285 })();
286 //# sourceMappingURL=index.js.map
287