[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-includes/js/dist/ -> nux.js (source)

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


Generated: Sat Nov 23 20:47:33 2019 Cross-referenced by PHPXref 0.7