nux.js 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013
  1. this["wp"] = this["wp"] || {}; this["wp"]["nux"] =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  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 = 361);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 0:
  90. /***/ (function(module, exports) {
  91. (function() { module.exports = this["wp"]["element"]; }());
  92. /***/ }),
  93. /***/ 1:
  94. /***/ (function(module, exports) {
  95. (function() { module.exports = this["wp"]["i18n"]; }());
  96. /***/ }),
  97. /***/ 10:
  98. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99. "use strict";
  100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
  101. function _defineProperty(obj, key, value) {
  102. if (key in obj) {
  103. Object.defineProperty(obj, key, {
  104. value: value,
  105. enumerable: true,
  106. configurable: true,
  107. writable: true
  108. });
  109. } else {
  110. obj[key] = value;
  111. }
  112. return obj;
  113. }
  114. /***/ }),
  115. /***/ 17:
  116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117. "use strict";
  118. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
  119. function _arrayWithoutHoles(arr) {
  120. if (Array.isArray(arr)) {
  121. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
  122. arr2[i] = arr[i];
  123. }
  124. return arr2;
  125. }
  126. }
  127. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
  128. var iterableToArray = __webpack_require__(30);
  129. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
  130. function _nonIterableSpread() {
  131. throw new TypeError("Invalid attempt to spread non-iterable instance");
  132. }
  133. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
  134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; });
  135. function _toConsumableArray(arr) {
  136. return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || _nonIterableSpread();
  137. }
  138. /***/ }),
  139. /***/ 2:
  140. /***/ (function(module, exports) {
  141. (function() { module.exports = this["lodash"]; }());
  142. /***/ }),
  143. /***/ 23:
  144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  145. "use strict";
  146. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
  147. var arrayWithHoles = __webpack_require__(38);
  148. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
  149. function _iterableToArrayLimit(arr, i) {
  150. var _arr = [];
  151. var _n = true;
  152. var _d = false;
  153. var _e = undefined;
  154. try {
  155. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  156. _arr.push(_s.value);
  157. if (i && _arr.length === i) break;
  158. }
  159. } catch (err) {
  160. _d = true;
  161. _e = err;
  162. } finally {
  163. try {
  164. if (!_n && _i["return"] != null) _i["return"]();
  165. } finally {
  166. if (_d) throw _e;
  167. }
  168. }
  169. return _arr;
  170. }
  171. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
  172. var nonIterableRest = __webpack_require__(39);
  173. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
  174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _slicedToArray; });
  175. function _slicedToArray(arr, i) {
  176. return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(nonIterableRest["a" /* default */])();
  177. }
  178. /***/ }),
  179. /***/ 3:
  180. /***/ (function(module, exports) {
  181. (function() { module.exports = this["wp"]["components"]; }());
  182. /***/ }),
  183. /***/ 30:
  184. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  185. "use strict";
  186. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
  187. function _iterableToArray(iter) {
  188. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  189. }
  190. /***/ }),
  191. /***/ 36:
  192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  193. "use strict";
  194. var LEAF_KEY, hasWeakMap;
  195. /**
  196. * Arbitrary value used as key for referencing cache object in WeakMap tree.
  197. *
  198. * @type {Object}
  199. */
  200. LEAF_KEY = {};
  201. /**
  202. * Whether environment supports WeakMap.
  203. *
  204. * @type {boolean}
  205. */
  206. hasWeakMap = typeof WeakMap !== 'undefined';
  207. /**
  208. * Returns the first argument as the sole entry in an array.
  209. *
  210. * @param {*} value Value to return.
  211. *
  212. * @return {Array} Value returned as entry in array.
  213. */
  214. function arrayOf( value ) {
  215. return [ value ];
  216. }
  217. /**
  218. * Returns true if the value passed is object-like, or false otherwise. A value
  219. * is object-like if it can support property assignment, e.g. object or array.
  220. *
  221. * @param {*} value Value to test.
  222. *
  223. * @return {boolean} Whether value is object-like.
  224. */
  225. function isObjectLike( value ) {
  226. return !! value && 'object' === typeof value;
  227. }
  228. /**
  229. * Creates and returns a new cache object.
  230. *
  231. * @return {Object} Cache object.
  232. */
  233. function createCache() {
  234. var cache = {
  235. clear: function() {
  236. cache.head = null;
  237. },
  238. };
  239. return cache;
  240. }
  241. /**
  242. * Returns true if entries within the two arrays are strictly equal by
  243. * reference from a starting index.
  244. *
  245. * @param {Array} a First array.
  246. * @param {Array} b Second array.
  247. * @param {number} fromIndex Index from which to start comparison.
  248. *
  249. * @return {boolean} Whether arrays are shallowly equal.
  250. */
  251. function isShallowEqual( a, b, fromIndex ) {
  252. var i;
  253. if ( a.length !== b.length ) {
  254. return false;
  255. }
  256. for ( i = fromIndex; i < a.length; i++ ) {
  257. if ( a[ i ] !== b[ i ] ) {
  258. return false;
  259. }
  260. }
  261. return true;
  262. }
  263. /**
  264. * Returns a memoized selector function. The getDependants function argument is
  265. * called before the memoized selector and is expected to return an immutable
  266. * reference or array of references on which the selector depends for computing
  267. * its own return value. The memoize cache is preserved only as long as those
  268. * dependant references remain the same. If getDependants returns a different
  269. * reference(s), the cache is cleared and the selector value regenerated.
  270. *
  271. * @param {Function} selector Selector function.
  272. * @param {Function} getDependants Dependant getter returning an immutable
  273. * reference or array of reference used in
  274. * cache bust consideration.
  275. *
  276. * @return {Function} Memoized selector.
  277. */
  278. /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) {
  279. var rootCache, getCache;
  280. // Use object source as dependant if getter not provided
  281. if ( ! getDependants ) {
  282. getDependants = arrayOf;
  283. }
  284. /**
  285. * Returns the root cache. If WeakMap is supported, this is assigned to the
  286. * root WeakMap cache set, otherwise it is a shared instance of the default
  287. * cache object.
  288. *
  289. * @return {(WeakMap|Object)} Root cache object.
  290. */
  291. function getRootCache() {
  292. return rootCache;
  293. }
  294. /**
  295. * Returns the cache for a given dependants array. When possible, a WeakMap
  296. * will be used to create a unique cache for each set of dependants. This
  297. * is feasible due to the nature of WeakMap in allowing garbage collection
  298. * to occur on entries where the key object is no longer referenced. Since
  299. * WeakMap requires the key to be an object, this is only possible when the
  300. * dependant is object-like. The root cache is created as a hierarchy where
  301. * each top-level key is the first entry in a dependants set, the value a
  302. * WeakMap where each key is the next dependant, and so on. This continues
  303. * so long as the dependants are object-like. If no dependants are object-
  304. * like, then the cache is shared across all invocations.
  305. *
  306. * @see isObjectLike
  307. *
  308. * @param {Array} dependants Selector dependants.
  309. *
  310. * @return {Object} Cache object.
  311. */
  312. function getWeakMapCache( dependants ) {
  313. var caches = rootCache,
  314. isUniqueByDependants = true,
  315. i, dependant, map, cache;
  316. for ( i = 0; i < dependants.length; i++ ) {
  317. dependant = dependants[ i ];
  318. // Can only compose WeakMap from object-like key.
  319. if ( ! isObjectLike( dependant ) ) {
  320. isUniqueByDependants = false;
  321. break;
  322. }
  323. // Does current segment of cache already have a WeakMap?
  324. if ( caches.has( dependant ) ) {
  325. // Traverse into nested WeakMap.
  326. caches = caches.get( dependant );
  327. } else {
  328. // Create, set, and traverse into a new one.
  329. map = new WeakMap();
  330. caches.set( dependant, map );
  331. caches = map;
  332. }
  333. }
  334. // We use an arbitrary (but consistent) object as key for the last item
  335. // in the WeakMap to serve as our running cache.
  336. if ( ! caches.has( LEAF_KEY ) ) {
  337. cache = createCache();
  338. cache.isUniqueByDependants = isUniqueByDependants;
  339. caches.set( LEAF_KEY, cache );
  340. }
  341. return caches.get( LEAF_KEY );
  342. }
  343. // Assign cache handler by availability of WeakMap
  344. getCache = hasWeakMap ? getWeakMapCache : getRootCache;
  345. /**
  346. * Resets root memoization cache.
  347. */
  348. function clear() {
  349. rootCache = hasWeakMap ? new WeakMap() : createCache();
  350. }
  351. // eslint-disable-next-line jsdoc/check-param-names
  352. /**
  353. * The augmented selector call, considering first whether dependants have
  354. * changed before passing it to underlying memoize function.
  355. *
  356. * @param {Object} source Source object for derivation.
  357. * @param {...*} extraArgs Additional arguments to pass to selector.
  358. *
  359. * @return {*} Selector result.
  360. */
  361. function callSelector( /* source, ...extraArgs */ ) {
  362. var len = arguments.length,
  363. cache, node, i, args, dependants;
  364. // Create copy of arguments (avoid leaking deoptimization).
  365. args = new Array( len );
  366. for ( i = 0; i < len; i++ ) {
  367. args[ i ] = arguments[ i ];
  368. }
  369. dependants = getDependants.apply( null, args );
  370. cache = getCache( dependants );
  371. // If not guaranteed uniqueness by dependants (primitive type or lack
  372. // of WeakMap support), shallow compare against last dependants and, if
  373. // references have changed, destroy cache to recalculate result.
  374. if ( ! cache.isUniqueByDependants ) {
  375. if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
  376. cache.clear();
  377. }
  378. cache.lastDependants = dependants;
  379. }
  380. node = cache.head;
  381. while ( node ) {
  382. // Check whether node arguments match arguments
  383. if ( ! isShallowEqual( node.args, args, 1 ) ) {
  384. node = node.next;
  385. continue;
  386. }
  387. // At this point we can assume we've found a match
  388. // Surface matched node to head if not already
  389. if ( node !== cache.head ) {
  390. // Adjust siblings to point to each other.
  391. node.prev.next = node.next;
  392. if ( node.next ) {
  393. node.next.prev = node.prev;
  394. }
  395. node.next = cache.head;
  396. node.prev = null;
  397. cache.head.prev = node;
  398. cache.head = node;
  399. }
  400. // Return immediately
  401. return node.val;
  402. }
  403. // No cached value found. Continue to insertion phase:
  404. node = {
  405. // Generate the result from original function
  406. val: selector.apply( null, args ),
  407. };
  408. // Avoid including the source object in the cache.
  409. args[ 0 ] = null;
  410. node.args = args;
  411. // Don't need to check whether node is already head, since it would
  412. // have been returned above already if it was
  413. // Shift existing head down list
  414. if ( cache.head ) {
  415. cache.head.prev = node;
  416. node.next = cache.head;
  417. }
  418. cache.head = node;
  419. return node.val;
  420. }
  421. callSelector.getDependants = getDependants;
  422. callSelector.clear = clear;
  423. clear();
  424. return callSelector;
  425. });
  426. /***/ }),
  427. /***/ 361:
  428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  429. "use strict";
  430. __webpack_require__.r(__webpack_exports__);
  431. var actions_namespaceObject = {};
  432. __webpack_require__.r(actions_namespaceObject);
  433. __webpack_require__.d(actions_namespaceObject, "triggerGuide", function() { return triggerGuide; });
  434. __webpack_require__.d(actions_namespaceObject, "dismissTip", function() { return dismissTip; });
  435. __webpack_require__.d(actions_namespaceObject, "disableTips", function() { return disableTips; });
  436. __webpack_require__.d(actions_namespaceObject, "enableTips", function() { return enableTips; });
  437. var selectors_namespaceObject = {};
  438. __webpack_require__.r(selectors_namespaceObject);
  439. __webpack_require__.d(selectors_namespaceObject, "getAssociatedGuide", function() { return getAssociatedGuide; });
  440. __webpack_require__.d(selectors_namespaceObject, "isTipVisible", function() { return isTipVisible; });
  441. __webpack_require__.d(selectors_namespaceObject, "areTipsEnabled", function() { return selectors_areTipsEnabled; });
  442. // EXTERNAL MODULE: external {"this":["wp","data"]}
  443. var external_this_wp_data_ = __webpack_require__(4);
  444. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
  445. var defineProperty = __webpack_require__(10);
  446. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js
  447. var objectSpread = __webpack_require__(7);
  448. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
  449. var toConsumableArray = __webpack_require__(17);
  450. // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/reducer.js
  451. /**
  452. * WordPress dependencies
  453. */
  454. /**
  455. * Reducer that tracks which tips are in a guide. Each guide is represented by
  456. * an array which contains the tip identifiers contained within that guide.
  457. *
  458. * @param {Array} state Current state.
  459. * @param {Object} action Dispatched action.
  460. *
  461. * @return {Array} Updated state.
  462. */
  463. function guides() {
  464. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  465. var action = arguments.length > 1 ? arguments[1] : undefined;
  466. switch (action.type) {
  467. case 'TRIGGER_GUIDE':
  468. return [].concat(Object(toConsumableArray["a" /* default */])(state), [action.tipIds]);
  469. }
  470. return state;
  471. }
  472. /**
  473. * Reducer that tracks whether or not tips are globally enabled.
  474. *
  475. * @param {boolean} state Current state.
  476. * @param {Object} action Dispatched action.
  477. *
  478. * @return {boolean} Updated state.
  479. */
  480. function areTipsEnabled() {
  481. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  482. var action = arguments.length > 1 ? arguments[1] : undefined;
  483. switch (action.type) {
  484. case 'DISABLE_TIPS':
  485. return false;
  486. case 'ENABLE_TIPS':
  487. return true;
  488. }
  489. return state;
  490. }
  491. /**
  492. * Reducer that tracks which tips have been dismissed. If the state object
  493. * contains a tip identifier, then that tip is dismissed.
  494. *
  495. * @param {Object} state Current state.
  496. * @param {Object} action Dispatched action.
  497. *
  498. * @return {Object} Updated state.
  499. */
  500. function dismissedTips() {
  501. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  502. var action = arguments.length > 1 ? arguments[1] : undefined;
  503. switch (action.type) {
  504. case 'DISMISS_TIP':
  505. return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, action.id, true));
  506. case 'ENABLE_TIPS':
  507. return {};
  508. }
  509. return state;
  510. }
  511. var preferences = Object(external_this_wp_data_["combineReducers"])({
  512. areTipsEnabled: areTipsEnabled,
  513. dismissedTips: dismissedTips
  514. });
  515. /* harmony default export */ var reducer = (Object(external_this_wp_data_["combineReducers"])({
  516. guides: guides,
  517. preferences: preferences
  518. }));
  519. // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/actions.js
  520. /**
  521. * Returns an action object that, when dispatched, presents a guide that takes
  522. * the user through a series of tips step by step.
  523. *
  524. * @param {string[]} tipIds Which tips to show in the guide.
  525. *
  526. * @return {Object} Action object.
  527. */
  528. function triggerGuide(tipIds) {
  529. return {
  530. type: 'TRIGGER_GUIDE',
  531. tipIds: tipIds
  532. };
  533. }
  534. /**
  535. * Returns an action object that, when dispatched, dismisses the given tip. A
  536. * dismissed tip will not show again.
  537. *
  538. * @param {string} id The tip to dismiss.
  539. *
  540. * @return {Object} Action object.
  541. */
  542. function dismissTip(id) {
  543. return {
  544. type: 'DISMISS_TIP',
  545. id: id
  546. };
  547. }
  548. /**
  549. * Returns an action object that, when dispatched, prevents all tips from
  550. * showing again.
  551. *
  552. * @return {Object} Action object.
  553. */
  554. function disableTips() {
  555. return {
  556. type: 'DISABLE_TIPS'
  557. };
  558. }
  559. /**
  560. * Returns an action object that, when dispatched, makes all tips show again.
  561. *
  562. * @return {Object} Action object.
  563. */
  564. function enableTips() {
  565. return {
  566. type: 'ENABLE_TIPS'
  567. };
  568. }
  569. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
  570. var slicedToArray = __webpack_require__(23);
  571. // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js
  572. var rememo = __webpack_require__(36);
  573. // EXTERNAL MODULE: external "lodash"
  574. var external_lodash_ = __webpack_require__(2);
  575. // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/selectors.js
  576. /**
  577. * External dependencies
  578. */
  579. /**
  580. * An object containing information about a guide.
  581. *
  582. * @typedef {Object} NUX.GuideInfo
  583. * @property {string[]} tipIds Which tips the guide contains.
  584. * @property {?string} currentTipId The guide's currently showing tip.
  585. * @property {?string} nextTipId The guide's next tip to show.
  586. */
  587. /**
  588. * Returns an object describing the guide, if any, that the given tip is a part
  589. * of.
  590. *
  591. * @param {Object} state Global application state.
  592. * @param {string} tipId The tip to query.
  593. *
  594. * @return {?NUX.GuideInfo} Information about the associated guide.
  595. */
  596. var getAssociatedGuide = Object(rememo["a" /* default */])(function (state, tipId) {
  597. var _iteratorNormalCompletion = true;
  598. var _didIteratorError = false;
  599. var _iteratorError = undefined;
  600. try {
  601. for (var _iterator = state.guides[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  602. var tipIds = _step.value;
  603. if (Object(external_lodash_["includes"])(tipIds, tipId)) {
  604. var nonDismissedTips = Object(external_lodash_["difference"])(tipIds, Object(external_lodash_["keys"])(state.preferences.dismissedTips));
  605. var _nonDismissedTips = Object(slicedToArray["a" /* default */])(nonDismissedTips, 2),
  606. _nonDismissedTips$ = _nonDismissedTips[0],
  607. currentTipId = _nonDismissedTips$ === void 0 ? null : _nonDismissedTips$,
  608. _nonDismissedTips$2 = _nonDismissedTips[1],
  609. nextTipId = _nonDismissedTips$2 === void 0 ? null : _nonDismissedTips$2;
  610. return {
  611. tipIds: tipIds,
  612. currentTipId: currentTipId,
  613. nextTipId: nextTipId
  614. };
  615. }
  616. }
  617. } catch (err) {
  618. _didIteratorError = true;
  619. _iteratorError = err;
  620. } finally {
  621. try {
  622. if (!_iteratorNormalCompletion && _iterator.return != null) {
  623. _iterator.return();
  624. }
  625. } finally {
  626. if (_didIteratorError) {
  627. throw _iteratorError;
  628. }
  629. }
  630. }
  631. return null;
  632. }, function (state) {
  633. return [state.guides, state.preferences.dismissedTips];
  634. });
  635. /**
  636. * Determines whether or not the given tip is showing. Tips are hidden if they
  637. * are disabled, have been dismissed, or are not the current tip in any
  638. * guide that they have been added to.
  639. *
  640. * @param {Object} state Global application state.
  641. * @param {string} tipId The tip to query.
  642. *
  643. * @return {boolean} Whether or not the given tip is showing.
  644. */
  645. function isTipVisible(state, tipId) {
  646. if (!state.preferences.areTipsEnabled) {
  647. return false;
  648. }
  649. if (Object(external_lodash_["has"])(state.preferences.dismissedTips, [tipId])) {
  650. return false;
  651. }
  652. var associatedGuide = getAssociatedGuide(state, tipId);
  653. if (associatedGuide && associatedGuide.currentTipId !== tipId) {
  654. return false;
  655. }
  656. return true;
  657. }
  658. /**
  659. * Returns whether or not tips are globally enabled.
  660. *
  661. * @param {Object} state Global application state.
  662. *
  663. * @return {boolean} Whether tips are globally enabled.
  664. */
  665. function selectors_areTipsEnabled(state) {
  666. return state.preferences.areTipsEnabled;
  667. }
  668. // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/index.js
  669. /**
  670. * WordPress dependencies
  671. */
  672. /**
  673. * Internal dependencies
  674. */
  675. var store = Object(external_this_wp_data_["registerStore"])('core/nux', {
  676. reducer: reducer,
  677. actions: actions_namespaceObject,
  678. selectors: selectors_namespaceObject,
  679. persist: ['preferences']
  680. });
  681. /* harmony default export */ var build_module_store = (store);
  682. // EXTERNAL MODULE: external {"this":["wp","element"]}
  683. var external_this_wp_element_ = __webpack_require__(0);
  684. // EXTERNAL MODULE: external {"this":["wp","compose"]}
  685. var external_this_wp_compose_ = __webpack_require__(8);
  686. // EXTERNAL MODULE: external {"this":["wp","components"]}
  687. var external_this_wp_components_ = __webpack_require__(3);
  688. // EXTERNAL MODULE: external {"this":["wp","i18n"]}
  689. var external_this_wp_i18n_ = __webpack_require__(1);
  690. // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/components/dot-tip/index.js
  691. /**
  692. * WordPress dependencies
  693. */
  694. function getAnchorRect(anchor) {
  695. // The default getAnchorRect() excludes an element's top and bottom padding
  696. // from its calculation. We want tips to point to the outer margin of an
  697. // element, so we override getAnchorRect() to include all padding.
  698. return anchor.parentNode.getBoundingClientRect();
  699. }
  700. function onClick(event) {
  701. // Tips are often nested within buttons. We stop propagation so that clicking
  702. // on a tip doesn't result in the button being clicked.
  703. event.stopPropagation();
  704. }
  705. function DotTip(_ref) {
  706. var _ref$position = _ref.position,
  707. position = _ref$position === void 0 ? 'middle right' : _ref$position,
  708. children = _ref.children,
  709. isVisible = _ref.isVisible,
  710. hasNextTip = _ref.hasNextTip,
  711. onDismiss = _ref.onDismiss,
  712. onDisable = _ref.onDisable;
  713. var anchorParent = Object(external_this_wp_element_["useRef"])(null);
  714. var getAnchorRectCallback = Object(external_this_wp_element_["useCallback"])(function (anchor) {
  715. anchorParent.current = anchor.parentNode;
  716. return getAnchorRect(anchor);
  717. }, [anchorParent]);
  718. var onFocusOutsideCallback = Object(external_this_wp_element_["useCallback"])(function (event) {
  719. if (!anchorParent.current) {
  720. return;
  721. }
  722. if (anchorParent.current.contains(event.relatedTarget)) {
  723. return;
  724. }
  725. onDisable();
  726. }, [onDisable, anchorParent]);
  727. if (!isVisible) {
  728. return null;
  729. }
  730. return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Popover"], {
  731. className: "nux-dot-tip",
  732. position: position,
  733. noArrow: true,
  734. focusOnMount: "container",
  735. getAnchorRect: getAnchorRectCallback,
  736. role: "dialog",
  737. "aria-label": Object(external_this_wp_i18n_["__"])('Editor tips'),
  738. onClick: onClick,
  739. onFocusOutside: onFocusOutsideCallback
  740. }, Object(external_this_wp_element_["createElement"])("p", null, children), Object(external_this_wp_element_["createElement"])("p", null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], {
  741. isLink: true,
  742. onClick: onDismiss
  743. }, hasNextTip ? Object(external_this_wp_i18n_["__"])('See next tip') : Object(external_this_wp_i18n_["__"])('Got it'))), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], {
  744. className: "nux-dot-tip__disable",
  745. icon: "no-alt",
  746. label: Object(external_this_wp_i18n_["__"])('Disable tips'),
  747. onClick: onDisable
  748. }));
  749. }
  750. /* harmony default export */ var dot_tip = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select, _ref2) {
  751. var tipId = _ref2.tipId;
  752. var _select = select('core/nux'),
  753. isTipVisible = _select.isTipVisible,
  754. getAssociatedGuide = _select.getAssociatedGuide;
  755. var associatedGuide = getAssociatedGuide(tipId);
  756. return {
  757. isVisible: isTipVisible(tipId),
  758. hasNextTip: !!(associatedGuide && associatedGuide.nextTipId)
  759. };
  760. }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref3) {
  761. var tipId = _ref3.tipId;
  762. var _dispatch = dispatch('core/nux'),
  763. dismissTip = _dispatch.dismissTip,
  764. disableTips = _dispatch.disableTips;
  765. return {
  766. onDismiss: function onDismiss() {
  767. dismissTip(tipId);
  768. },
  769. onDisable: function onDisable() {
  770. disableTips();
  771. }
  772. };
  773. }))(DotTip));
  774. // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/index.js
  775. /* concated harmony reexport DotTip */__webpack_require__.d(__webpack_exports__, "DotTip", function() { return dot_tip; });
  776. /**
  777. * Internal dependencies
  778. */
  779. /***/ }),
  780. /***/ 38:
  781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  782. "use strict";
  783. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; });
  784. function _arrayWithHoles(arr) {
  785. if (Array.isArray(arr)) return arr;
  786. }
  787. /***/ }),
  788. /***/ 39:
  789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  790. "use strict";
  791. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; });
  792. function _nonIterableRest() {
  793. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  794. }
  795. /***/ }),
  796. /***/ 4:
  797. /***/ (function(module, exports) {
  798. (function() { module.exports = this["wp"]["data"]; }());
  799. /***/ }),
  800. /***/ 7:
  801. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  802. "use strict";
  803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectSpread; });
  804. /* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
  805. function _objectSpread(target) {
  806. for (var i = 1; i < arguments.length; i++) {
  807. var source = arguments[i] != null ? arguments[i] : {};
  808. var ownKeys = Object.keys(source);
  809. if (typeof Object.getOwnPropertySymbols === 'function') {
  810. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  811. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  812. }));
  813. }
  814. ownKeys.forEach(function (key) {
  815. Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]);
  816. });
  817. }
  818. return target;
  819. }
  820. /***/ }),
  821. /***/ 8:
  822. /***/ (function(module, exports) {
  823. (function() { module.exports = this["wp"]["compose"]; }());
  824. /***/ })
  825. /******/ });