PluginProbe
Gutenberg / 24.1.0
Gutenberg v24.1.0
24.1.0 24.0.0 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 All 404 releases
← All changes | build/scripts/notices/index.js +25 -35 23.0.1 → 24.1.0 View file →
@@ -1,4 +1,5 @@
1 +(function() {
1 2 "use strict";
2 3 var wp;
3 4 (wp ||= {}).notices = (() => {
4 5 var __create = Object.create;
@@ -61,29 +62,13 @@
61 62 store: () => store
62 63 });
63 64
64 65 // packages/notices/build-module/store/index.mjs
65 - var import_data = __toESM(require_data(), 1);
66 + var import_data2 = __toESM(require_data(), 1);
66 67
67 - // packages/notices/build-module/store/utils/on-sub-key.mjs
68 - var onSubKey = (actionProperty) => (reducer) => (state = {}, action) => {
69 - const key = action[actionProperty];
70 - if (key === void 0) {
71 - return state;
72 - }
73 - const nextKeyState = reducer(state[key], action);
74 - if (nextKeyState === state[key]) {
75 - return state;
76 - }
77 - return {
78 - ...state,
79 - [key]: nextKeyState
80 - };
81 - };
82 - var on_sub_key_default = onSubKey;
83 -
84 68 // packages/notices/build-module/store/reducer.mjs
85 - var notices = on_sub_key_default("context")((state = [], action) => {
69 + var import_data = __toESM(require_data(), 1);
70 + var notices = (0, import_data.keyedReducer)("context")((state = [], action) => {
86 71 switch (action.type) {
87 72 case "CREATE_NOTICE":
88 73 return [
89 74 ...state.filter(({ id }) => id !== action.notice.id),
@@ -196,14 +181,14 @@
196 181 return state[context] || DEFAULT_NOTICES;
197 182 }
198 183
199 184 // packages/notices/build-module/store/index.mjs
200 - var store = (0, import_data.createReduxStore)("core/notices", {
185 + var store = (0, import_data2.createReduxStore)("core/notices", {
201 186 reducer: reducer_default,
202 187 actions: actions_exports,
203 188 selectors: selectors_exports
204 189 });
205 - (0, import_data.register)(store);
190 + (0, import_data2.register)(store);
206 191
207 192 // node_modules/clsx/dist/clsx.mjs
208 193 function r(e) {
209 194 var t, f, n = "";
@@ -221,27 +206,25 @@
221 206 var clsx_default = clsx;
222 207
223 208 // packages/notices/build-module/components/inline-notices/index.mjs
224 209 var import_components = __toESM(require_components(), 1);
225 - var import_data2 = __toESM(require_data(), 1);
210 + var import_data3 = __toESM(require_data(), 1);
226 211 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
227 - if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='2c1d02983b']")) {
228 - const style = document.createElement("style");
229 - style.setAttribute("data-wp-hash", "2c1d02983b");
230 - 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}"));
231 - document.head.appendChild(style);
212 + function hasRenderableChildren(children) {
213 + return children !== null && children !== void 0 && children !== false && children !== "";
232 214 }
233 215 function InlineNotices({
234 216 children,
217 + className,
235 218 pinnedNoticesClassName,
236 219 dismissibleNoticesClassName,
237 220 context
238 221 }) {
239 - const notices2 = (0, import_data2.useSelect)(
222 + const notices2 = (0, import_data3.useSelect)(
240 223 (select) => select(store).getNotices(context),
241 224 [context]
242 225 );
243 - const { removeNotice: removeNotice2 } = (0, import_data2.useDispatch)(store);
226 + const { removeNotice: removeNotice2 } = (0, import_data3.useDispatch)(store);
244 227 const dismissibleNotices = notices2.filter(
245 228 ({ isDismissible, type }) => isDismissible && type === "default"
246 229 );
247 230 const nonDismissibleNotices = notices2.filter(
@@ -246,10 +229,15 @@
246 229 );
247 230 const nonDismissibleNotices = notices2.filter(
248 231 ({ isDismissible, type }) => !isDismissible && type === "default"
249 232 );
250 - return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
251 - /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
233 + const hasPinnedNotices = nonDismissibleNotices.length > 0;
234 + const hasDismissibleNotices = dismissibleNotices.length > 0 || hasRenderableChildren(children);
235 + if (!hasPinnedNotices && !hasDismissibleNotices) {
236 + return null;
237 + }
238 + return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: clsx_default("notices-inline-notices-wrapper", className), children: [
239 + hasPinnedNotices && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
252 240 import_components.NoticeList,
253 241 {
254 242 notices: nonDismissibleNotices,
255 243 className: clsx_default(
@@ -257,9 +245,9 @@
257 245 pinnedNoticesClassName
258 246 )
259 247 }
260 248 ),
261 - /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
249 + hasDismissibleNotices && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
262 250 import_components.NoticeList,
263 251 {
264 252 notices: dismissibleNotices,
265 253 className: clsx_default(
@@ -274,9 +262,9 @@
274 262 }
275 263
276 264 // packages/notices/build-module/components/snackbar-notices/index.mjs
277 265 var import_components2 = __toESM(require_components(), 1);
278 - var import_data3 = __toESM(require_data(), 1);
266 + var import_data4 = __toESM(require_data(), 1);
279 267 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
280 268 var MAX_VISIBLE_NOTICES = -3;
281 269 function SnackbarNotices({
282 270 className,
@@ -281,13 +269,13 @@
281 269 function SnackbarNotices({
282 270 className,
283 271 context
284 272 }) {
285 - const notices2 = (0, import_data3.useSelect)(
273 + const notices2 = (0, import_data4.useSelect)(
286 274 (select) => select(store).getNotices(context),
287 275 [context]
288 276 );
289 - const { removeNotice: removeNotice2 } = (0, import_data3.useDispatch)(store);
277 + const { removeNotice: removeNotice2 } = (0, import_data4.useDispatch)(store);
290 278 const snackbarNotices = notices2.filter(({ type }) => type === "snackbar").slice(MAX_VISIBLE_NOTICES);
291 279 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
292 280 import_components2.SnackbarList,
293 281 {
@@ -297,6 +285,8 @@
297 285 }
298 286 );
299 287 }
300 288 return __toCommonJS(index_exports);
289 +})();
290 +(window.wp ||= {}).notices = wp.notices;
301 291 })();
302 292 //# sourceMappingURL=index.js.map