1 this["wp"] = this["wp"] || {}; this["wp"]["nux"] = |
1 /******/ (function() { // webpackBootstrap |
2 /******/ (function(modules) { // webpackBootstrap |
2 /******/ "use strict"; |
3 /******/ // The module cache |
3 /******/ // The require scope |
4 /******/ var installedModules = {}; |
4 /******/ var __webpack_require__ = {}; |
5 /******/ |
5 /******/ |
6 /******/ // The require function |
6 /************************************************************************/ |
7 /******/ function __webpack_require__(moduleId) { |
7 /******/ /* webpack/runtime/compat get default export */ |
8 /******/ |
8 /******/ !function() { |
9 /******/ // Check if module is in cache |
9 /******/ // getDefaultExport function for compatibility with non-harmony modules |
10 /******/ if(installedModules[moduleId]) { |
10 /******/ __webpack_require__.n = function(module) { |
11 /******/ return installedModules[moduleId].exports; |
11 /******/ var getter = module && module.__esModule ? |
12 /******/ } |
12 /******/ function() { return module['default']; } : |
13 /******/ // Create a new module (and put it into the cache) |
13 /******/ function() { return module; }; |
14 /******/ var module = installedModules[moduleId] = { |
14 /******/ __webpack_require__.d(getter, { a: getter }); |
15 /******/ i: moduleId, |
15 /******/ return getter; |
16 /******/ l: false, |
|
17 /******/ exports: {} |
|
18 /******/ }; |
16 /******/ }; |
19 /******/ |
17 /******/ }(); |
20 /******/ // Execute the module function |
18 /******/ |
21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
19 /******/ /* webpack/runtime/define property getters */ |
22 /******/ |
20 /******/ !function() { |
23 /******/ // Flag the module as loaded |
21 /******/ // define getter functions for harmony exports |
24 /******/ module.l = true; |
22 /******/ __webpack_require__.d = function(exports, definition) { |
25 /******/ |
23 /******/ for(var key in definition) { |
26 /******/ // Return the exports of the module |
24 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
27 /******/ return module.exports; |
25 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
28 /******/ } |
26 /******/ } |
29 /******/ |
27 /******/ } |
30 /******/ |
28 /******/ }; |
31 /******/ // expose the modules object (__webpack_modules__) |
29 /******/ }(); |
32 /******/ __webpack_require__.m = modules; |
30 /******/ |
33 /******/ |
31 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
34 /******/ // expose the module cache |
32 /******/ !function() { |
35 /******/ __webpack_require__.c = installedModules; |
33 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
36 /******/ |
34 /******/ }(); |
37 /******/ // define getter function for harmony exports |
35 /******/ |
38 /******/ __webpack_require__.d = function(exports, name, getter) { |
36 /******/ /* webpack/runtime/make namespace object */ |
39 /******/ if(!__webpack_require__.o(exports, name)) { |
37 /******/ !function() { |
40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
38 /******/ // define __esModule on exports |
41 /******/ } |
39 /******/ __webpack_require__.r = function(exports) { |
42 /******/ }; |
40 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
43 /******/ |
41 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
44 /******/ // define __esModule on exports |
42 /******/ } |
45 /******/ __webpack_require__.r = function(exports) { |
43 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
44 /******/ }; |
47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
45 /******/ }(); |
48 /******/ } |
46 /******/ |
49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
50 /******/ }; |
|
51 /******/ |
|
52 /******/ // create a fake namespace object |
|
53 /******/ // mode & 1: value is a module id, require it |
|
54 /******/ // mode & 2: merge all properties of value into the ns |
|
55 /******/ // mode & 4: return value when already ns object |
|
56 /******/ // mode & 8|1: behave like require |
|
57 /******/ __webpack_require__.t = function(value, mode) { |
|
58 /******/ if(mode & 1) value = __webpack_require__(value); |
|
59 /******/ if(mode & 8) return value; |
|
60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
|
61 /******/ var ns = Object.create(null); |
|
62 /******/ __webpack_require__.r(ns); |
|
63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
|
64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
|
65 /******/ return ns; |
|
66 /******/ }; |
|
67 /******/ |
|
68 /******/ // getDefaultExport function for compatibility with non-harmony modules |
|
69 /******/ __webpack_require__.n = function(module) { |
|
70 /******/ var getter = module && module.__esModule ? |
|
71 /******/ function getDefault() { return module['default']; } : |
|
72 /******/ function getModuleExports() { return module; }; |
|
73 /******/ __webpack_require__.d(getter, 'a', getter); |
|
74 /******/ return getter; |
|
75 /******/ }; |
|
76 /******/ |
|
77 /******/ // Object.prototype.hasOwnProperty.call |
|
78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
|
79 /******/ |
|
80 /******/ // __webpack_public_path__ |
|
81 /******/ __webpack_require__.p = ""; |
|
82 /******/ |
|
83 /******/ |
|
84 /******/ // Load entry module and return exports |
|
85 /******/ return __webpack_require__(__webpack_require__.s = "51Wn"); |
|
86 /******/ }) |
|
87 /************************************************************************/ |
47 /************************************************************************/ |
88 /******/ ({ |
48 var __webpack_exports__ = {}; |
89 |
|
90 /***/ "1ZqX": |
|
91 /***/ (function(module, exports) { |
|
92 |
|
93 (function() { module.exports = window["wp"]["data"]; }()); |
|
94 |
|
95 /***/ }), |
|
96 |
|
97 /***/ "51Wn": |
|
98 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
99 |
|
100 "use strict"; |
|
101 // ESM COMPAT FLAG |
49 // ESM COMPAT FLAG |
102 __webpack_require__.r(__webpack_exports__); |
50 __webpack_require__.r(__webpack_exports__); |
103 |
51 |
104 // EXPORTS |
52 // EXPORTS |
105 __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; }); |
53 __webpack_require__.d(__webpack_exports__, { |
106 __webpack_require__.d(__webpack_exports__, "DotTip", function() { return /* reexport */ dot_tip; }); |
54 "DotTip": function() { return /* reexport */ dot_tip; }, |
|
55 "store": function() { return /* reexport */ store; } |
|
56 }); |
107 |
57 |
108 // NAMESPACE OBJECT: ./node_modules/@wordpress/nux/build-module/store/actions.js |
58 // NAMESPACE OBJECT: ./node_modules/@wordpress/nux/build-module/store/actions.js |
109 var actions_namespaceObject = {}; |
59 var actions_namespaceObject = {}; |
110 __webpack_require__.r(actions_namespaceObject); |
60 __webpack_require__.r(actions_namespaceObject); |
111 __webpack_require__.d(actions_namespaceObject, "triggerGuide", function() { return triggerGuide; }); |
61 __webpack_require__.d(actions_namespaceObject, { |
112 __webpack_require__.d(actions_namespaceObject, "dismissTip", function() { return dismissTip; }); |
62 "disableTips": function() { return disableTips; }, |
113 __webpack_require__.d(actions_namespaceObject, "disableTips", function() { return disableTips; }); |
63 "dismissTip": function() { return dismissTip; }, |
114 __webpack_require__.d(actions_namespaceObject, "enableTips", function() { return enableTips; }); |
64 "enableTips": function() { return enableTips; }, |
|
65 "triggerGuide": function() { return triggerGuide; } |
|
66 }); |
115 |
67 |
116 // NAMESPACE OBJECT: ./node_modules/@wordpress/nux/build-module/store/selectors.js |
68 // NAMESPACE OBJECT: ./node_modules/@wordpress/nux/build-module/store/selectors.js |
117 var selectors_namespaceObject = {}; |
69 var selectors_namespaceObject = {}; |
118 __webpack_require__.r(selectors_namespaceObject); |
70 __webpack_require__.r(selectors_namespaceObject); |
119 __webpack_require__.d(selectors_namespaceObject, "getAssociatedGuide", function() { return getAssociatedGuide; }); |
71 __webpack_require__.d(selectors_namespaceObject, { |
120 __webpack_require__.d(selectors_namespaceObject, "isTipVisible", function() { return isTipVisible; }); |
72 "areTipsEnabled": function() { return selectors_areTipsEnabled; }, |
121 __webpack_require__.d(selectors_namespaceObject, "areTipsEnabled", function() { return selectors_areTipsEnabled; }); |
73 "getAssociatedGuide": function() { return getAssociatedGuide; }, |
122 |
74 "isTipVisible": function() { return isTipVisible; } |
123 // EXTERNAL MODULE: external ["wp","deprecated"] |
75 }); |
124 var external_wp_deprecated_ = __webpack_require__("NMb1"); |
76 |
125 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_); |
77 ;// CONCATENATED MODULE: external ["wp","deprecated"] |
126 |
78 var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; |
127 // EXTERNAL MODULE: external ["wp","data"] |
79 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); |
128 var external_wp_data_ = __webpack_require__("1ZqX"); |
80 ;// CONCATENATED MODULE: external ["wp","data"] |
129 |
81 var external_wp_data_namespaceObject = window["wp"]["data"]; |
130 // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/reducer.js |
82 ;// CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/reducer.js |
131 /** |
83 /** |
132 * WordPress dependencies |
84 * WordPress dependencies |
133 */ |
85 */ |
134 |
86 |
135 /** |
87 /** |
136 * Reducer that tracks which tips are in a guide. Each guide is represented by |
88 * Reducer that tracks which tips are in a guide. Each guide is represented by |
137 * an array which contains the tip identifiers contained within that guide. |
89 * an array which contains the tip identifiers contained within that guide. |
138 * |
90 * |
139 * @param {Array} state Current state. |
91 * @param {Array} state Current state. |
140 * @param {Object} action Dispatched action. |
92 * @param {Object} action Dispatched action. |
141 * |
93 * |
142 * @return {Array} Updated state. |
94 * @return {Array} Updated state. |
143 */ |
95 */ |
144 |
96 |
145 function guides(state = [], action) { |
97 function guides() { |
|
98 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
99 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
100 |
146 switch (action.type) { |
101 switch (action.type) { |
147 case 'TRIGGER_GUIDE': |
102 case 'TRIGGER_GUIDE': |
148 return [...state, action.tipIds]; |
103 return [...state, action.tipIds]; |
149 } |
104 } |
150 |
105 |
151 return state; |
106 return state; |
152 } |
107 } |
153 /** |
108 /** |
154 * Reducer that tracks whether or not tips are globally enabled. |
109 * Reducer that tracks whether or not tips are globally enabled. |
155 * |
110 * |
156 * @param {boolean} state Current state. |
111 * @param {boolean} state Current state. |
157 * @param {Object} action Dispatched action. |
112 * @param {Object} action Dispatched action. |
158 * |
113 * |
159 * @return {boolean} Updated state. |
114 * @return {boolean} Updated state. |
160 */ |
115 */ |
161 |
116 |
162 function areTipsEnabled(state = true, action) { |
117 function areTipsEnabled() { |
|
118 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; |
|
119 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
120 |
163 switch (action.type) { |
121 switch (action.type) { |
164 case 'DISABLE_TIPS': |
122 case 'DISABLE_TIPS': |
165 return false; |
123 return false; |
166 |
124 |
167 case 'ENABLE_TIPS': |
125 case 'ENABLE_TIPS': |
254 return { |
215 return { |
255 type: 'ENABLE_TIPS' |
216 type: 'ENABLE_TIPS' |
256 }; |
217 }; |
257 } |
218 } |
258 |
219 |
259 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js |
220 ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js |
260 var rememo = __webpack_require__("pPDe"); |
|
261 |
|
262 // EXTERNAL MODULE: external "lodash" |
|
263 var external_lodash_ = __webpack_require__("YLtl"); |
|
264 |
|
265 // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/selectors.js |
|
266 /** |
|
267 * External dependencies |
|
268 */ |
|
269 |
|
270 |
|
271 /** |
|
272 * An object containing information about a guide. |
|
273 * |
|
274 * @typedef {Object} NUXGuideInfo |
|
275 * @property {string[]} tipIds Which tips the guide contains. |
|
276 * @property {?string} currentTipId The guide's currently showing tip. |
|
277 * @property {?string} nextTipId The guide's next tip to show. |
|
278 */ |
|
279 |
|
280 /** |
|
281 * Returns an object describing the guide, if any, that the given tip is a part |
|
282 * of. |
|
283 * |
|
284 * @param {Object} state Global application state. |
|
285 * @param {string} tipId The tip to query. |
|
286 * |
|
287 * @return {?NUXGuideInfo} Information about the associated guide. |
|
288 */ |
|
289 |
|
290 const getAssociatedGuide = Object(rememo["a" /* default */])((state, tipId) => { |
|
291 for (const tipIds of state.guides) { |
|
292 if (Object(external_lodash_["includes"])(tipIds, tipId)) { |
|
293 const nonDismissedTips = Object(external_lodash_["difference"])(tipIds, Object(external_lodash_["keys"])(state.preferences.dismissedTips)); |
|
294 const [currentTipId = null, nextTipId = null] = nonDismissedTips; |
|
295 return { |
|
296 tipIds, |
|
297 currentTipId, |
|
298 nextTipId |
|
299 }; |
|
300 } |
|
301 } |
|
302 |
|
303 return null; |
|
304 }, state => [state.guides, state.preferences.dismissedTips]); |
|
305 /** |
|
306 * Determines whether or not the given tip is showing. Tips are hidden if they |
|
307 * are disabled, have been dismissed, or are not the current tip in any |
|
308 * guide that they have been added to. |
|
309 * |
|
310 * @param {Object} state Global application state. |
|
311 * @param {string} tipId The tip to query. |
|
312 * |
|
313 * @return {boolean} Whether or not the given tip is showing. |
|
314 */ |
|
315 |
|
316 function isTipVisible(state, tipId) { |
|
317 if (!state.preferences.areTipsEnabled) { |
|
318 return false; |
|
319 } |
|
320 |
|
321 if (Object(external_lodash_["has"])(state.preferences.dismissedTips, [tipId])) { |
|
322 return false; |
|
323 } |
|
324 |
|
325 const associatedGuide = getAssociatedGuide(state, tipId); |
|
326 |
|
327 if (associatedGuide && associatedGuide.currentTipId !== tipId) { |
|
328 return false; |
|
329 } |
|
330 |
|
331 return true; |
|
332 } |
|
333 /** |
|
334 * Returns whether or not tips are globally enabled. |
|
335 * |
|
336 * @param {Object} state Global application state. |
|
337 * |
|
338 * @return {boolean} Whether tips are globally enabled. |
|
339 */ |
|
340 |
|
341 function selectors_areTipsEnabled(state) { |
|
342 return state.preferences.areTipsEnabled; |
|
343 } |
|
344 |
|
345 // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/index.js |
|
346 /** |
|
347 * WordPress dependencies |
|
348 */ |
|
349 |
|
350 /** |
|
351 * Internal dependencies |
|
352 */ |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 const STORE_NAME = 'core/nux'; |
|
358 /** |
|
359 * Store definition for the nux namespace. |
|
360 * |
|
361 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
|
362 * |
|
363 * @type {Object} |
|
364 */ |
|
365 |
|
366 const store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, { |
|
367 reducer: reducer, |
|
368 actions: actions_namespaceObject, |
|
369 selectors: selectors_namespaceObject, |
|
370 persist: ['preferences'] |
|
371 }); // Once we build a more generic persistence plugin that works across types of stores |
|
372 // we'd be able to replace this with a register call. |
|
373 |
|
374 Object(external_wp_data_["registerStore"])(STORE_NAME, { |
|
375 reducer: reducer, |
|
376 actions: actions_namespaceObject, |
|
377 selectors: selectors_namespaceObject, |
|
378 persist: ['preferences'] |
|
379 }); |
|
380 |
|
381 // EXTERNAL MODULE: external ["wp","element"] |
|
382 var external_wp_element_ = __webpack_require__("GRId"); |
|
383 |
|
384 // EXTERNAL MODULE: external ["wp","compose"] |
|
385 var external_wp_compose_ = __webpack_require__("K9lf"); |
|
386 |
|
387 // EXTERNAL MODULE: external ["wp","components"] |
|
388 var external_wp_components_ = __webpack_require__("tI+e"); |
|
389 |
|
390 // EXTERNAL MODULE: external ["wp","i18n"] |
|
391 var external_wp_i18n_ = __webpack_require__("l3Sj"); |
|
392 |
|
393 // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/close.js |
|
394 var library_close = __webpack_require__("w95h"); |
|
395 |
|
396 // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/components/dot-tip/index.js |
|
397 |
|
398 |
|
399 /** |
|
400 * WordPress dependencies |
|
401 */ |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 function onClick(event) { |
|
410 // Tips are often nested within buttons. We stop propagation so that clicking |
|
411 // on a tip doesn't result in the button being clicked. |
|
412 event.stopPropagation(); |
|
413 } |
|
414 |
|
415 function DotTip({ |
|
416 position = 'middle right', |
|
417 children, |
|
418 isVisible, |
|
419 hasNextTip, |
|
420 onDismiss, |
|
421 onDisable |
|
422 }) { |
|
423 const anchorParent = Object(external_wp_element_["useRef"])(null); |
|
424 const onFocusOutsideCallback = Object(external_wp_element_["useCallback"])(event => { |
|
425 if (!anchorParent.current) { |
|
426 return; |
|
427 } |
|
428 |
|
429 if (anchorParent.current.contains(event.relatedTarget)) { |
|
430 return; |
|
431 } |
|
432 |
|
433 onDisable(); |
|
434 }, [onDisable, anchorParent]); |
|
435 |
|
436 if (!isVisible) { |
|
437 return null; |
|
438 } |
|
439 |
|
440 return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], { |
|
441 className: "nux-dot-tip", |
|
442 position: position, |
|
443 noArrow: true, |
|
444 focusOnMount: "container", |
|
445 shouldAnchorIncludePadding: true, |
|
446 role: "dialog", |
|
447 "aria-label": Object(external_wp_i18n_["__"])('Editor tips'), |
|
448 onClick: onClick, |
|
449 onFocusOutside: onFocusOutsideCallback |
|
450 }, Object(external_wp_element_["createElement"])("p", null, children), Object(external_wp_element_["createElement"])("p", null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
|
451 isLink: true, |
|
452 onClick: onDismiss |
|
453 }, hasNextTip ? Object(external_wp_i18n_["__"])('See next tip') : Object(external_wp_i18n_["__"])('Got it'))), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
|
454 className: "nux-dot-tip__disable", |
|
455 icon: library_close["a" /* default */], |
|
456 label: Object(external_wp_i18n_["__"])('Disable tips'), |
|
457 onClick: onDisable |
|
458 })); |
|
459 } |
|
460 /* harmony default export */ var dot_tip = (Object(external_wp_compose_["compose"])(Object(external_wp_data_["withSelect"])((select, { |
|
461 tipId |
|
462 }) => { |
|
463 const { |
|
464 isTipVisible, |
|
465 getAssociatedGuide |
|
466 } = select('core/nux'); |
|
467 const associatedGuide = getAssociatedGuide(tipId); |
|
468 return { |
|
469 isVisible: isTipVisible(tipId), |
|
470 hasNextTip: !!(associatedGuide && associatedGuide.nextTipId) |
|
471 }; |
|
472 }), Object(external_wp_data_["withDispatch"])((dispatch, { |
|
473 tipId |
|
474 }) => { |
|
475 const { |
|
476 dismissTip, |
|
477 disableTips |
|
478 } = dispatch('core/nux'); |
|
479 return { |
|
480 onDismiss() { |
|
481 dismissTip(tipId); |
|
482 }, |
|
483 |
|
484 onDisable() { |
|
485 disableTips(); |
|
486 } |
|
487 |
|
488 }; |
|
489 }))(DotTip)); |
|
490 |
|
491 // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/index.js |
|
492 /** |
|
493 * WordPress dependencies |
|
494 */ |
|
495 |
|
496 |
|
497 |
|
498 external_wp_deprecated_default()('wp.nux', { |
|
499 since: '5.4', |
|
500 hint: 'wp.components.Guide can be used to show a user guide.' |
|
501 }); |
|
502 |
|
503 |
|
504 /***/ }), |
|
505 |
|
506 /***/ "GRId": |
|
507 /***/ (function(module, exports) { |
|
508 |
|
509 (function() { module.exports = window["wp"]["element"]; }()); |
|
510 |
|
511 /***/ }), |
|
512 |
|
513 /***/ "K9lf": |
|
514 /***/ (function(module, exports) { |
|
515 |
|
516 (function() { module.exports = window["wp"]["compose"]; }()); |
|
517 |
|
518 /***/ }), |
|
519 |
|
520 /***/ "NMb1": |
|
521 /***/ (function(module, exports) { |
|
522 |
|
523 (function() { module.exports = window["wp"]["deprecated"]; }()); |
|
524 |
|
525 /***/ }), |
|
526 |
|
527 /***/ "Tqx9": |
|
528 /***/ (function(module, exports) { |
|
529 |
|
530 (function() { module.exports = window["wp"]["primitives"]; }()); |
|
531 |
|
532 /***/ }), |
|
533 |
|
534 /***/ "YLtl": |
|
535 /***/ (function(module, exports) { |
|
536 |
|
537 (function() { module.exports = window["lodash"]; }()); |
|
538 |
|
539 /***/ }), |
|
540 |
|
541 /***/ "l3Sj": |
|
542 /***/ (function(module, exports) { |
|
543 |
|
544 (function() { module.exports = window["wp"]["i18n"]; }()); |
|
545 |
|
546 /***/ }), |
|
547 |
|
548 /***/ "pPDe": |
|
549 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
550 |
|
551 "use strict"; |
|
552 |
221 |
553 |
222 |
554 var LEAF_KEY, hasWeakMap; |
223 var LEAF_KEY, hasWeakMap; |
555 |
224 |
556 /** |
225 /** |
820 callSelector.getDependants = getDependants; |
489 callSelector.getDependants = getDependants; |
821 callSelector.clear = clear; |
490 callSelector.clear = clear; |
822 clear(); |
491 clear(); |
823 |
492 |
824 return callSelector; |
493 return callSelector; |
|
494 } |
|
495 |
|
496 ;// CONCATENATED MODULE: external "lodash" |
|
497 var external_lodash_namespaceObject = window["lodash"]; |
|
498 ;// CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/selectors.js |
|
499 /** |
|
500 * External dependencies |
|
501 */ |
|
502 |
|
503 |
|
504 /** |
|
505 * An object containing information about a guide. |
|
506 * |
|
507 * @typedef {Object} NUXGuideInfo |
|
508 * @property {string[]} tipIds Which tips the guide contains. |
|
509 * @property {?string} currentTipId The guide's currently showing tip. |
|
510 * @property {?string} nextTipId The guide's next tip to show. |
|
511 */ |
|
512 |
|
513 /** |
|
514 * Returns an object describing the guide, if any, that the given tip is a part |
|
515 * of. |
|
516 * |
|
517 * @param {Object} state Global application state. |
|
518 * @param {string} tipId The tip to query. |
|
519 * |
|
520 * @return {?NUXGuideInfo} Information about the associated guide. |
|
521 */ |
|
522 |
|
523 const getAssociatedGuide = rememo((state, tipId) => { |
|
524 for (const tipIds of state.guides) { |
|
525 if ((0,external_lodash_namespaceObject.includes)(tipIds, tipId)) { |
|
526 const nonDismissedTips = (0,external_lodash_namespaceObject.difference)(tipIds, (0,external_lodash_namespaceObject.keys)(state.preferences.dismissedTips)); |
|
527 const [currentTipId = null, nextTipId = null] = nonDismissedTips; |
|
528 return { |
|
529 tipIds, |
|
530 currentTipId, |
|
531 nextTipId |
|
532 }; |
|
533 } |
|
534 } |
|
535 |
|
536 return null; |
|
537 }, state => [state.guides, state.preferences.dismissedTips]); |
|
538 /** |
|
539 * Determines whether or not the given tip is showing. Tips are hidden if they |
|
540 * are disabled, have been dismissed, or are not the current tip in any |
|
541 * guide that they have been added to. |
|
542 * |
|
543 * @param {Object} state Global application state. |
|
544 * @param {string} tipId The tip to query. |
|
545 * |
|
546 * @return {boolean} Whether or not the given tip is showing. |
|
547 */ |
|
548 |
|
549 function isTipVisible(state, tipId) { |
|
550 if (!state.preferences.areTipsEnabled) { |
|
551 return false; |
|
552 } |
|
553 |
|
554 if ((0,external_lodash_namespaceObject.has)(state.preferences.dismissedTips, [tipId])) { |
|
555 return false; |
|
556 } |
|
557 |
|
558 const associatedGuide = getAssociatedGuide(state, tipId); |
|
559 |
|
560 if (associatedGuide && associatedGuide.currentTipId !== tipId) { |
|
561 return false; |
|
562 } |
|
563 |
|
564 return true; |
|
565 } |
|
566 /** |
|
567 * Returns whether or not tips are globally enabled. |
|
568 * |
|
569 * @param {Object} state Global application state. |
|
570 * |
|
571 * @return {boolean} Whether tips are globally enabled. |
|
572 */ |
|
573 |
|
574 function selectors_areTipsEnabled(state) { |
|
575 return state.preferences.areTipsEnabled; |
|
576 } |
|
577 |
|
578 ;// CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/index.js |
|
579 /** |
|
580 * WordPress dependencies |
|
581 */ |
|
582 |
|
583 /** |
|
584 * Internal dependencies |
|
585 */ |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 const STORE_NAME = 'core/nux'; |
|
591 /** |
|
592 * Store definition for the nux namespace. |
|
593 * |
|
594 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
|
595 * |
|
596 * @type {Object} |
|
597 */ |
|
598 |
|
599 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { |
|
600 reducer: reducer, |
|
601 actions: actions_namespaceObject, |
|
602 selectors: selectors_namespaceObject, |
|
603 persist: ['preferences'] |
|
604 }); // Once we build a more generic persistence plugin that works across types of stores |
|
605 // we'd be able to replace this with a register call. |
|
606 |
|
607 (0,external_wp_data_namespaceObject.registerStore)(STORE_NAME, { |
|
608 reducer: reducer, |
|
609 actions: actions_namespaceObject, |
|
610 selectors: selectors_namespaceObject, |
|
611 persist: ['preferences'] |
825 }); |
612 }); |
826 |
613 |
827 |
614 ;// CONCATENATED MODULE: external ["wp","element"] |
828 /***/ }), |
615 var external_wp_element_namespaceObject = window["wp"]["element"]; |
829 |
616 ;// CONCATENATED MODULE: external ["wp","compose"] |
830 /***/ "tI+e": |
617 var external_wp_compose_namespaceObject = window["wp"]["compose"]; |
831 /***/ (function(module, exports) { |
618 ;// CONCATENATED MODULE: external ["wp","components"] |
832 |
619 var external_wp_components_namespaceObject = window["wp"]["components"]; |
833 (function() { module.exports = window["wp"]["components"]; }()); |
620 ;// CONCATENATED MODULE: external ["wp","i18n"] |
834 |
621 var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
835 /***/ }), |
622 ;// CONCATENATED MODULE: external ["wp","primitives"] |
836 |
623 var external_wp_primitives_namespaceObject = window["wp"]["primitives"]; |
837 /***/ "w95h": |
624 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close.js |
838 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
839 |
|
840 "use strict"; |
|
841 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId"); |
|
842 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
|
843 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9"); |
|
844 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
|
845 |
625 |
846 |
626 |
847 /** |
627 /** |
848 * WordPress dependencies |
628 * WordPress dependencies |
849 */ |
629 */ |
850 |
630 |
851 const close = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
631 const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
852 xmlns: "http://www.w3.org/2000/svg", |
632 xmlns: "http://www.w3.org/2000/svg", |
853 viewBox: "0 0 24 24" |
633 viewBox: "0 0 24 24" |
854 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
634 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
855 d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z" |
635 d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z" |
856 })); |
636 })); |
857 /* harmony default export */ __webpack_exports__["a"] = (close); |
637 /* harmony default export */ var library_close = (close_close); |
858 |
638 |
859 |
639 ;// CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/components/dot-tip/index.js |
860 /***/ }) |
640 |
861 |
641 |
862 /******/ }); |
642 /** |
|
643 * WordPress dependencies |
|
644 */ |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 /** |
|
652 * Internal dependencies |
|
653 */ |
|
654 |
|
655 |
|
656 |
|
657 function onClick(event) { |
|
658 // Tips are often nested within buttons. We stop propagation so that clicking |
|
659 // on a tip doesn't result in the button being clicked. |
|
660 event.stopPropagation(); |
|
661 } |
|
662 |
|
663 function DotTip(_ref) { |
|
664 let { |
|
665 position = 'middle right', |
|
666 children, |
|
667 isVisible, |
|
668 hasNextTip, |
|
669 onDismiss, |
|
670 onDisable |
|
671 } = _ref; |
|
672 const anchorParent = (0,external_wp_element_namespaceObject.useRef)(null); |
|
673 const onFocusOutsideCallback = (0,external_wp_element_namespaceObject.useCallback)(event => { |
|
674 if (!anchorParent.current) { |
|
675 return; |
|
676 } |
|
677 |
|
678 if (anchorParent.current.contains(event.relatedTarget)) { |
|
679 return; |
|
680 } |
|
681 |
|
682 onDisable(); |
|
683 }, [onDisable, anchorParent]); |
|
684 |
|
685 if (!isVisible) { |
|
686 return null; |
|
687 } |
|
688 |
|
689 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { |
|
690 className: "nux-dot-tip", |
|
691 position: position, |
|
692 noArrow: true, |
|
693 focusOnMount: "container", |
|
694 shouldAnchorIncludePadding: true, |
|
695 role: "dialog", |
|
696 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Editor tips'), |
|
697 onClick: onClick, |
|
698 onFocusOutside: onFocusOutsideCallback |
|
699 }, (0,external_wp_element_namespaceObject.createElement)("p", null, children), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
|
700 variant: "link", |
|
701 onClick: onDismiss |
|
702 }, hasNextTip ? (0,external_wp_i18n_namespaceObject.__)('See next tip') : (0,external_wp_i18n_namespaceObject.__)('Got it'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
|
703 className: "nux-dot-tip__disable", |
|
704 icon: library_close, |
|
705 label: (0,external_wp_i18n_namespaceObject.__)('Disable tips'), |
|
706 onClick: onDisable |
|
707 })); |
|
708 } |
|
709 /* harmony default export */ var dot_tip = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => { |
|
710 let { |
|
711 tipId |
|
712 } = _ref2; |
|
713 const { |
|
714 isTipVisible, |
|
715 getAssociatedGuide |
|
716 } = select(store); |
|
717 const associatedGuide = getAssociatedGuide(tipId); |
|
718 return { |
|
719 isVisible: isTipVisible(tipId), |
|
720 hasNextTip: !!(associatedGuide && associatedGuide.nextTipId) |
|
721 }; |
|
722 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref3) => { |
|
723 let { |
|
724 tipId |
|
725 } = _ref3; |
|
726 const { |
|
727 dismissTip, |
|
728 disableTips |
|
729 } = dispatch(store); |
|
730 return { |
|
731 onDismiss() { |
|
732 dismissTip(tipId); |
|
733 }, |
|
734 |
|
735 onDisable() { |
|
736 disableTips(); |
|
737 } |
|
738 |
|
739 }; |
|
740 }))(DotTip)); |
|
741 |
|
742 ;// CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/index.js |
|
743 /** |
|
744 * WordPress dependencies |
|
745 */ |
|
746 |
|
747 |
|
748 |
|
749 external_wp_deprecated_default()('wp.nux', { |
|
750 since: '5.4', |
|
751 hint: 'wp.components.Guide can be used to show a user guide.', |
|
752 version: '6.2' |
|
753 }); |
|
754 |
|
755 (window.wp = window.wp || {}).nux = __webpack_exports__; |
|
756 /******/ })() |
|
757 ; |