wp/wp-includes/js/dist/token-list.js
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
     1 this["wp"] = this["wp"] || {}; this["wp"]["tokenList"] =
     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/define property getters */
     8 /******/
     8 /******/ 	!function() {
     9 /******/ 		// Check if module is in cache
     9 /******/ 		// define getter functions for harmony exports
    10 /******/ 		if(installedModules[moduleId]) {
    10 /******/ 		__webpack_require__.d = function(exports, definition) {
    11 /******/ 			return installedModules[moduleId].exports;
    11 /******/ 			for(var key in definition) {
    12 /******/ 		}
    12 /******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
    13 /******/ 		// Create a new module (and put it into the cache)
    13 /******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
    14 /******/ 		var module = installedModules[moduleId] = {
    14 /******/ 				}
    15 /******/ 			i: moduleId,
    15 /******/ 			}
    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/hasOwnProperty shorthand */
    22 /******/
    20 /******/ 	!function() {
    23 /******/ 		// Flag the module as loaded
    21 /******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
    24 /******/ 		module.l = true;
    22 /******/ 	}();
    25 /******/
    23 /******/ 	
    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 = "hwXU");
       
    86 /******/ })
       
    87 /************************************************************************/
    24 /************************************************************************/
    88 /******/ ({
    25 var __webpack_exports__ = {};
    89 
    26 
    90 /***/ "YLtl":
    27 // EXPORTS
    91 /***/ (function(module, exports) {
    28 __webpack_require__.d(__webpack_exports__, {
    92 
    29   "default": function() { return /* binding */ TokenList; }
    93 (function() { module.exports = window["lodash"]; }());
    30 });
    94 
    31 
    95 /***/ }),
    32 ;// CONCATENATED MODULE: external "lodash"
    96 
    33 var external_lodash_namespaceObject = window["lodash"];
    97 /***/ "hwXU":
    34 ;// CONCATENATED MODULE: ./node_modules/@wordpress/token-list/build-module/index.js
    98 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
    99 
       
   100 "use strict";
       
   101 __webpack_require__.r(__webpack_exports__);
       
   102 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return TokenList; });
       
   103 /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("YLtl");
       
   104 /* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_0__);
       
   105 /**
    35 /**
   106  * External dependencies
    36  * External dependencies
   107  */
    37  */
   108 
    38 
   109 /**
    39 /**
   116   /**
    46   /**
   117    * Constructs a new instance of TokenList.
    47    * Constructs a new instance of TokenList.
   118    *
    48    *
   119    * @param {string} initialValue Initial value to assign.
    49    * @param {string} initialValue Initial value to assign.
   120    */
    50    */
   121   constructor(initialValue = '') {
    51   constructor() {
       
    52     let initialValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
   122     this.value = initialValue; // Disable reason: These are type hints on the class.
    53     this.value = initialValue; // Disable reason: These are type hints on the class.
   123 
    54 
   124     /* eslint-disable no-unused-expressions */
    55     /* eslint-disable no-unused-expressions */
   125 
    56 
   126     /** @type {string} */
    57     /** @type {string} */
   134   /**
    65   /**
   135    * @param {Parameters<Array<string>['entries']>} args
    66    * @param {Parameters<Array<string>['entries']>} args
   136    */
    67    */
   137 
    68 
   138 
    69 
   139   entries(...args) {
    70   entries() {
   140     return this._valueAsArray.entries(...args);
    71     return this._valueAsArray.entries(...arguments);
   141   }
    72   }
   142   /**
    73   /**
   143    * @param {Parameters<Array<string>['forEach']>} args
    74    * @param {Parameters<Array<string>['forEach']>} args
   144    */
    75    */
   145 
    76 
   146 
    77 
   147   forEach(...args) {
    78   forEach() {
   148     return this._valueAsArray.forEach(...args);
    79     return this._valueAsArray.forEach(...arguments);
   149   }
    80   }
   150   /**
    81   /**
   151    * @param {Parameters<Array<string>['keys']>} args
    82    * @param {Parameters<Array<string>['keys']>} args
   152    */
    83    */
   153 
    84 
   154 
    85 
   155   keys(...args) {
    86   keys() {
   156     return this._valueAsArray.keys(...args);
    87     return this._valueAsArray.keys(...arguments);
   157   }
    88   }
   158   /**
    89   /**
   159    * @param {Parameters<Array<string>['values']>} args
    90    * @param {Parameters<Array<string>['values']>} args
   160    */
    91    */
   161 
    92 
   162 
    93 
   163   values(...args) {
    94   values() {
   164     return this._valueAsArray.values(...args);
    95     return this._valueAsArray.values(...arguments);
   165   }
    96   }
   166   /**
    97   /**
   167    * Returns the associated set as string.
    98    * Returns the associated set as string.
   168    *
    99    *
   169    * @see https://dom.spec.whatwg.org/#dom-domtokenlist-value
   100    * @see https://dom.spec.whatwg.org/#dom-domtokenlist-value
   184    */
   115    */
   185 
   116 
   186 
   117 
   187   set value(value) {
   118   set value(value) {
   188     value = String(value);
   119     value = String(value);
   189     this._valueAsArray = Object(lodash__WEBPACK_IMPORTED_MODULE_0__["uniq"])(Object(lodash__WEBPACK_IMPORTED_MODULE_0__["compact"])(value.split(/\s+/g)));
   120     this._valueAsArray = (0,external_lodash_namespaceObject.uniq)((0,external_lodash_namespaceObject.compact)(value.split(/\s+/g)));
   190     this._currentValue = this._valueAsArray.join(' ');
   121     this._currentValue = this._valueAsArray.join(' ');
   191   }
   122   }
   192   /**
   123   /**
   193    * Returns the number of tokens.
   124    * Returns the number of tokens.
   194    *
   125    *
   261    *
   192    *
   262    * @param {...string} items Items to add.
   193    * @param {...string} items Items to add.
   263    */
   194    */
   264 
   195 
   265 
   196 
   266   add(...items) {
   197   add() {
       
   198     for (var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++) {
       
   199       items[_key] = arguments[_key];
       
   200     }
       
   201 
   267     this.value += ' ' + items.join(' ');
   202     this.value += ' ' + items.join(' ');
   268   }
   203   }
   269   /**
   204   /**
   270    * Removes arguments passed, if they are present.
   205    * Removes arguments passed, if they are present.
   271    *
   206    *
   273    *
   208    *
   274    * @param {...string} items Items to remove.
   209    * @param {...string} items Items to remove.
   275    */
   210    */
   276 
   211 
   277 
   212 
   278   remove(...items) {
   213   remove() {
   279     this.value = Object(lodash__WEBPACK_IMPORTED_MODULE_0__["without"])(this._valueAsArray, ...items).join(' ');
   214     for (var _len2 = arguments.length, items = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
       
   215       items[_key2] = arguments[_key2];
       
   216     }
       
   217 
       
   218     this.value = (0,external_lodash_namespaceObject.without)(this._valueAsArray, ...items).join(' ');
   280   }
   219   }
   281   /**
   220   /**
   282    * If `force` is not given, "toggles" `token`, removing it if it’s present
   221    * If `force` is not given, "toggles" `token`, removing it if it’s present
   283    * and adding it if it’s not present. If `force` is true, adds token (same
   222    * and adding it if it’s not present. If `force` is true, adds token (same
   284    * as add()). If force is false, removes token (same as remove()). Returns
   223    * as add()). If force is false, removes token (same as remove()). Returns
   344     return true;
   283     return true;
   345   }
   284   }
   346 
   285 
   347 }
   286 }
   348 
   287 
   349 
   288 (window.wp = window.wp || {}).tokenList = __webpack_exports__["default"];
   350 /***/ })
   289 /******/ })()
   351 
   290 ;
   352 /******/ })["default"];