PluginProbe
Gutenberg / 22.7.0
Gutenberg v22.7.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 12.6.0 All 403 releases
← All changes | build/scripts/nux/index.js +203 -23 23.6.2 → 22.7.0 View file →
@@ -44,8 +44,50 @@
44 44 module.exports = window.wp.data;
45 45 }
46 46 });
47 47
48 + // package-external:@wordpress/compose
49 + var require_compose = __commonJS({
50 + "package-external:@wordpress/compose"(exports, module) {
51 + module.exports = window.wp.compose;
52 + }
53 + });
54 +
55 + // package-external:@wordpress/components
56 + var require_components = __commonJS({
57 + "package-external:@wordpress/components"(exports, module) {
58 + module.exports = window.wp.components;
59 + }
60 + });
61 +
62 + // package-external:@wordpress/i18n
63 + var require_i18n = __commonJS({
64 + "package-external:@wordpress/i18n"(exports, module) {
65 + module.exports = window.wp.i18n;
66 + }
67 + });
68 +
69 + // package-external:@wordpress/element
70 + var require_element = __commonJS({
71 + "package-external:@wordpress/element"(exports, module) {
72 + module.exports = window.wp.element;
73 + }
74 + });
75 +
76 + // package-external:@wordpress/primitives
77 + var require_primitives = __commonJS({
78 + "package-external:@wordpress/primitives"(exports, module) {
79 + module.exports = window.wp.primitives;
80 + }
81 + });
82 +
83 + // vendor-external:react/jsx-runtime
84 + var require_jsx_runtime = __commonJS({
85 + "vendor-external:react/jsx-runtime"(exports, module) {
86 + module.exports = window.ReactJSXRuntime;
87 + }
88 + });
89 +
48 90 // packages/nux/build-module/index.mjs
49 91 var index_exports = {};
50 92 __export(index_exports, {
51 93 DotTip: () => dot_tip_default,
@@ -53,21 +95,42 @@
53 95 });
54 96 var import_deprecated = __toESM(require_deprecated(), 1);
55 97
56 98 // packages/nux/build-module/store/index.mjs
57 - var import_data = __toESM(require_data(), 1);
99 + var import_data3 = __toESM(require_data(), 1);
58 100
59 101 // packages/nux/build-module/store/reducer.mjs
60 - var DEFAULT_STATE = {
61 - guides: [],
62 - preferences: {
63 - areTipsEnabled: false,
64 - dismissedTips: {}
102 + var import_data = __toESM(require_data(), 1);
103 + function guides(state = [], action) {
104 + switch (action.type) {
105 + case "TRIGGER_GUIDE":
106 + return [...state, action.tipIds];
65 107 }
66 - };
67 - function reducer(state = DEFAULT_STATE) {
68 108 return state;
69 109 }
110 + function areTipsEnabled(state = true, action) {
111 + switch (action.type) {
112 + case "DISABLE_TIPS":
113 + return false;
114 + case "ENABLE_TIPS":
115 + return true;
116 + }
117 + return state;
118 + }
119 + function dismissedTips(state = {}, action) {
120 + switch (action.type) {
121 + case "DISMISS_TIP":
122 + return {
123 + ...state,
124 + [action.id]: true
125 + };
126 + case "ENABLE_TIPS":
127 + return {};
128 + }
129 + return state;
130 + }
131 + var preferences = (0, import_data.combineReducers)({ areTipsEnabled, dismissedTips });
132 + var reducer_default = (0, import_data.combineReducers)({ guides, preferences });
70 133
71 134 // packages/nux/build-module/store/actions.mjs
72 135 var actions_exports = {};
73 136 __export(actions_exports, {
@@ -101,32 +164,57 @@
101 164
102 165 // packages/nux/build-module/store/selectors.mjs
103 166 var selectors_exports = {};
104 167 __export(selectors_exports, {
105 - areTipsEnabled: () => areTipsEnabled,
168 + areTipsEnabled: () => areTipsEnabled2,
106 169 getAssociatedGuide: () => getAssociatedGuide,
107 170 isTipVisible: () => isTipVisible
108 171 });
109 - function getAssociatedGuide() {
110 - return null;
172 + var import_data2 = __toESM(require_data(), 1);
173 + var getAssociatedGuide = (0, import_data2.createSelector)(
174 + (state, tipId) => {
175 + for (const tipIds of state.guides) {
176 + if (tipIds.includes(tipId)) {
177 + const nonDismissedTips = tipIds.filter(
178 + (tId) => !Object.keys(
179 + state.preferences.dismissedTips
180 + ).includes(tId)
181 + );
182 + const [currentTipId = null, nextTipId = null] = nonDismissedTips;
183 + return { tipIds, currentTipId, nextTipId };
184 + }
185 + }
186 + return null;
187 + },
188 + (state) => [state.guides, state.preferences.dismissedTips]
189 + );
190 + function isTipVisible(state, tipId) {
191 + if (!state.preferences.areTipsEnabled) {
192 + return false;
193 + }
194 + if (state.preferences.dismissedTips?.hasOwnProperty(tipId)) {
195 + return false;
196 + }
197 + const associatedGuide = getAssociatedGuide(state, tipId);
198 + if (associatedGuide && associatedGuide.currentTipId !== tipId) {
199 + return false;
200 + }
201 + return true;
111 202 }
112 - function isTipVisible() {
113 - return false;
203 + function areTipsEnabled2(state) {
204 + return state.preferences.areTipsEnabled;
114 205 }
115 - function areTipsEnabled() {
116 - return false;
117 - }
118 206
119 207 // packages/nux/build-module/store/index.mjs
120 208 var STORE_NAME = "core/nux";
121 - var store = (0, import_data.createReduxStore)(STORE_NAME, {
122 - reducer,
209 + var store = (0, import_data3.createReduxStore)(STORE_NAME, {
210 + reducer: reducer_default,
123 211 actions: actions_exports,
124 212 selectors: selectors_exports,
125 213 persist: ["preferences"]
126 214 });
127 - (0, import_data.registerStore)(STORE_NAME, {
128 - reducer,
215 + (0, import_data3.registerStore)(STORE_NAME, {
216 + reducer: reducer_default,
129 217 actions: actions_exports,
130 218 selectors: selectors_exports,
131 219 persist: ["preferences"]
132 220 });
@@ -131,12 +219,104 @@
131 219 persist: ["preferences"]
132 220 });
133 221
134 222 // packages/nux/build-module/components/dot-tip/index.mjs
135 - function DotTip() {
136 - return null;
223 + var import_compose = __toESM(require_compose(), 1);
224 + var import_components = __toESM(require_components(), 1);
225 + var import_i18n = __toESM(require_i18n(), 1);
226 + var import_data4 = __toESM(require_data(), 1);
227 + var import_element = __toESM(require_element(), 1);
228 +
229 + // packages/icons/build-module/library/close.mjs
230 + var import_primitives = __toESM(require_primitives(), 1);
231 + var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
232 + var close_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z" }) });
233 +
234 + // packages/nux/build-module/components/dot-tip/index.mjs
235 + var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
236 + function onClick(event) {
237 + event.stopPropagation();
137 238 }
138 - var dot_tip_default = DotTip;
239 + function DotTip({
240 + position = "middle right",
241 + children,
242 + isVisible,
243 + hasNextTip,
244 + onDismiss,
245 + onDisable
246 + }) {
247 + const anchorParent = (0, import_element.useRef)(null);
248 + const onFocusOutsideCallback = (0, import_element.useCallback)(
249 + (event) => {
250 + if (!anchorParent.current) {
251 + return;
252 + }
253 + if (anchorParent.current.contains(event.relatedTarget)) {
254 + return;
255 + }
256 + onDisable();
257 + },
258 + [onDisable, anchorParent]
259 + );
260 + if (!isVisible) {
261 + return null;
262 + }
263 + return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
264 + import_components.Popover,
265 + {
266 + className: "nux-dot-tip",
267 + position,
268 + focusOnMount: true,
269 + role: "dialog",
270 + "aria-label": (0, import_i18n.__)("Editor tips"),
271 + onClick,
272 + onFocusOutside: onFocusOutsideCallback,
273 + children: [
274 + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children }),
275 + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
276 + import_components.Button,
277 + {
278 + __next40pxDefaultSize: true,
279 + variant: "link",
280 + onClick: onDismiss,
281 + children: hasNextTip ? (0, import_i18n.__)("See next tip") : (0, import_i18n.__)("Got it")
282 + }
283 + ) }),
284 + /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
285 + import_components.Button,
286 + {
287 + size: "small",
288 + className: "nux-dot-tip__disable",
289 + icon: close_default,
290 + label: (0, import_i18n.__)("Disable tips"),
291 + onClick: onDisable
292 + }
293 + )
294 + ]
295 + }
296 + );
297 + }
298 + var dot_tip_default = (0, import_compose.compose)(
299 + (0, import_data4.withSelect)((select, { tipId }) => {
300 + const { isTipVisible: isTipVisible2, getAssociatedGuide: getAssociatedGuide2 } = select(store);
301 + const associatedGuide = getAssociatedGuide2(tipId);
302 + return {
303 + isVisible: isTipVisible2(tipId),
304 + hasNextTip: !!(associatedGuide && associatedGuide.nextTipId)
305 + };
306 + }),
307 + (0, import_data4.withDispatch)((dispatch, { tipId }) => {
308 + const { dismissTip: dismissTip2, disableTips: disableTips2 } = dispatch(store);
309 + return {
310 + onDismiss() {
311 + dismissTip2(tipId);
312 + },
313 + onDisable() {
314 + disableTips2();
315 + }
316 + };
317 + })
318 + )(DotTip);
139 319
140 320 // packages/nux/build-module/index.mjs
141 321 (0, import_deprecated.default)("wp.nux", {
142 322 since: "5.4",