[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> list-reusable-blocks.js (source)

   1  /******/ (() => { // webpackBootstrap
   2  /******/     "use strict";
   3  /******/     // The require scope
   4  /******/     var __webpack_require__ = {};
   5  /******/     
   6  /************************************************************************/
   7  /******/     /* webpack/runtime/compat get default export */
   8  /******/     (() => {
   9  /******/         // getDefaultExport function for compatibility with non-harmony modules
  10  /******/         __webpack_require__.n = (module) => {
  11  /******/             var getter = module && module.__esModule ?
  12  /******/                 () => (module['default']) :
  13  /******/                 () => (module);
  14  /******/             __webpack_require__.d(getter, { a: getter });
  15  /******/             return getter;
  16  /******/         };
  17  /******/     })();
  18  /******/     
  19  /******/     /* webpack/runtime/define property getters */
  20  /******/     (() => {
  21  /******/         // define getter functions for harmony exports
  22  /******/         __webpack_require__.d = (exports, definition) => {
  23  /******/             for(var key in definition) {
  24  /******/                 if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  25  /******/                     Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  26  /******/                 }
  27  /******/             }
  28  /******/         };
  29  /******/     })();
  30  /******/     
  31  /******/     /* webpack/runtime/hasOwnProperty shorthand */
  32  /******/     (() => {
  33  /******/         __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  34  /******/     })();
  35  /******/     
  36  /******/     /* webpack/runtime/make namespace object */
  37  /******/     (() => {
  38  /******/         // define __esModule on exports
  39  /******/         __webpack_require__.r = (exports) => {
  40  /******/             if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  41  /******/                 Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  42  /******/             }
  43  /******/             Object.defineProperty(exports, '__esModule', { value: true });
  44  /******/         };
  45  /******/     })();
  46  /******/     
  47  /************************************************************************/
  48  var __webpack_exports__ = {};
  49  // ESM COMPAT FLAG
  50  __webpack_require__.r(__webpack_exports__);
  51  
  52  ;// CONCATENATED MODULE: external "React"
  53  const external_React_namespaceObject = window["React"];
  54  ;// CONCATENATED MODULE: external ["wp","element"]
  55  const external_wp_element_namespaceObject = window["wp"]["element"];
  56  ;// CONCATENATED MODULE: external ["wp","i18n"]
  57  const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  58  ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
  59  /******************************************************************************
  60  Copyright (c) Microsoft Corporation.
  61  
  62  Permission to use, copy, modify, and/or distribute this software for any
  63  purpose with or without fee is hereby granted.
  64  
  65  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  66  REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  67  AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  68  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  69  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  70  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  71  PERFORMANCE OF THIS SOFTWARE.
  72  ***************************************************************************** */
  73  /* global Reflect, Promise, SuppressedError, Symbol */
  74  
  75  var extendStatics = function(d, b) {
  76    extendStatics = Object.setPrototypeOf ||
  77        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  78        function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  79    return extendStatics(d, b);
  80  };
  81  
  82  function __extends(d, b) {
  83    if (typeof b !== "function" && b !== null)
  84        throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  85    extendStatics(d, b);
  86    function __() { this.constructor = d; }
  87    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  88  }
  89  
  90  var __assign = function() {
  91    __assign = Object.assign || function __assign(t) {
  92        for (var s, i = 1, n = arguments.length; i < n; i++) {
  93            s = arguments[i];
  94            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  95        }
  96        return t;
  97    }
  98    return __assign.apply(this, arguments);
  99  }
 100  
 101  function __rest(s, e) {
 102    var t = {};
 103    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
 104        t[p] = s[p];
 105    if (s != null && typeof Object.getOwnPropertySymbols === "function")
 106        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
 107            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
 108                t[p[i]] = s[p[i]];
 109        }
 110    return t;
 111  }
 112  
 113  function __decorate(decorators, target, key, desc) {
 114    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
 115    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
 116    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
 117    return c > 3 && r && Object.defineProperty(target, key, r), r;
 118  }
 119  
 120  function __param(paramIndex, decorator) {
 121    return function (target, key) { decorator(target, key, paramIndex); }
 122  }
 123  
 124  function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
 125    function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
 126    var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
 127    var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
 128    var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
 129    var _, done = false;
 130    for (var i = decorators.length - 1; i >= 0; i--) {
 131        var context = {};
 132        for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
 133        for (var p in contextIn.access) context.access[p] = contextIn.access[p];
 134        context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
 135        var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
 136        if (kind === "accessor") {
 137            if (result === void 0) continue;
 138            if (result === null || typeof result !== "object") throw new TypeError("Object expected");
 139            if (_ = accept(result.get)) descriptor.get = _;
 140            if (_ = accept(result.set)) descriptor.set = _;
 141            if (_ = accept(result.init)) initializers.unshift(_);
 142        }
 143        else if (_ = accept(result)) {
 144            if (kind === "field") initializers.unshift(_);
 145            else descriptor[key] = _;
 146        }
 147    }
 148    if (target) Object.defineProperty(target, contextIn.name, descriptor);
 149    done = true;
 150  };
 151  
 152  function __runInitializers(thisArg, initializers, value) {
 153    var useValue = arguments.length > 2;
 154    for (var i = 0; i < initializers.length; i++) {
 155        value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
 156    }
 157    return useValue ? value : void 0;
 158  };
 159  
 160  function __propKey(x) {
 161    return typeof x === "symbol" ? x : "".concat(x);
 162  };
 163  
 164  function __setFunctionName(f, name, prefix) {
 165    if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
 166    return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
 167  };
 168  
 169  function __metadata(metadataKey, metadataValue) {
 170    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
 171  }
 172  
 173  function __awaiter(thisArg, _arguments, P, generator) {
 174    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
 175    return new (P || (P = Promise))(function (resolve, reject) {
 176        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
 177        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
 178        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
 179        step((generator = generator.apply(thisArg, _arguments || [])).next());
 180    });
 181  }
 182  
 183  function __generator(thisArg, body) {
 184    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
 185    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
 186    function verb(n) { return function (v) { return step([n, v]); }; }
 187    function step(op) {
 188        if (f) throw new TypeError("Generator is already executing.");
 189        while (g && (g = 0, op[0] && (_ = 0)), _) try {
 190            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
 191            if (y = 0, t) op = [op[0] & 2, t.value];
 192            switch (op[0]) {
 193                case 0: case 1: t = op; break;
 194                case 4: _.label++; return { value: op[1], done: false };
 195                case 5: _.label++; y = op[1]; op = [0]; continue;
 196                case 7: op = _.ops.pop(); _.trys.pop(); continue;
 197                default:
 198                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
 199                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
 200                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
 201                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
 202                    if (t[2]) _.ops.pop();
 203                    _.trys.pop(); continue;
 204            }
 205            op = body.call(thisArg, _);
 206        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
 207        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
 208    }
 209  }
 210  
 211  var __createBinding = Object.create ? (function(o, m, k, k2) {
 212    if (k2 === undefined) k2 = k;
 213    var desc = Object.getOwnPropertyDescriptor(m, k);
 214    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
 215        desc = { enumerable: true, get: function() { return m[k]; } };
 216    }
 217    Object.defineProperty(o, k2, desc);
 218  }) : (function(o, m, k, k2) {
 219    if (k2 === undefined) k2 = k;
 220    o[k2] = m[k];
 221  });
 222  
 223  function __exportStar(m, o) {
 224    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
 225  }
 226  
 227  function __values(o) {
 228    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
 229    if (m) return m.call(o);
 230    if (o && typeof o.length === "number") return {
 231        next: function () {
 232            if (o && i >= o.length) o = void 0;
 233            return { value: o && o[i++], done: !o };
 234        }
 235    };
 236    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
 237  }
 238  
 239  function __read(o, n) {
 240    var m = typeof Symbol === "function" && o[Symbol.iterator];
 241    if (!m) return o;
 242    var i = m.call(o), r, ar = [], e;
 243    try {
 244        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
 245    }
 246    catch (error) { e = { error: error }; }
 247    finally {
 248        try {
 249            if (r && !r.done && (m = i["return"])) m.call(i);
 250        }
 251        finally { if (e) throw e.error; }
 252    }
 253    return ar;
 254  }
 255  
 256  /** @deprecated */
 257  function __spread() {
 258    for (var ar = [], i = 0; i < arguments.length; i++)
 259        ar = ar.concat(__read(arguments[i]));
 260    return ar;
 261  }
 262  
 263  /** @deprecated */
 264  function __spreadArrays() {
 265    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
 266    for (var r = Array(s), k = 0, i = 0; i < il; i++)
 267        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
 268            r[k] = a[j];
 269    return r;
 270  }
 271  
 272  function __spreadArray(to, from, pack) {
 273    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
 274        if (ar || !(i in from)) {
 275            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
 276            ar[i] = from[i];
 277        }
 278    }
 279    return to.concat(ar || Array.prototype.slice.call(from));
 280  }
 281  
 282  function __await(v) {
 283    return this instanceof __await ? (this.v = v, this) : new __await(v);
 284  }
 285  
 286  function __asyncGenerator(thisArg, _arguments, generator) {
 287    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
 288    var g = generator.apply(thisArg, _arguments || []), i, q = [];
 289    return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
 290    function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
 291    function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
 292    function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
 293    function fulfill(value) { resume("next", value); }
 294    function reject(value) { resume("throw", value); }
 295    function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
 296  }
 297  
 298  function __asyncDelegator(o) {
 299    var i, p;
 300    return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
 301    function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
 302  }
 303  
 304  function __asyncValues(o) {
 305    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
 306    var m = o[Symbol.asyncIterator], i;
 307    return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
 308    function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
 309    function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
 310  }
 311  
 312  function __makeTemplateObject(cooked, raw) {
 313    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
 314    return cooked;
 315  };
 316  
 317  var __setModuleDefault = Object.create ? (function(o, v) {
 318    Object.defineProperty(o, "default", { enumerable: true, value: v });
 319  }) : function(o, v) {
 320    o["default"] = v;
 321  };
 322  
 323  function __importStar(mod) {
 324    if (mod && mod.__esModule) return mod;
 325    var result = {};
 326    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
 327    __setModuleDefault(result, mod);
 328    return result;
 329  }
 330  
 331  function __importDefault(mod) {
 332    return (mod && mod.__esModule) ? mod : { default: mod };
 333  }
 334  
 335  function __classPrivateFieldGet(receiver, state, kind, f) {
 336    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
 337    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
 338    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
 339  }
 340  
 341  function __classPrivateFieldSet(receiver, state, value, kind, f) {
 342    if (kind === "m") throw new TypeError("Private method is not writable");
 343    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
 344    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
 345    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
 346  }
 347  
 348  function __classPrivateFieldIn(state, receiver) {
 349    if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
 350    return typeof state === "function" ? receiver === state : state.has(receiver);
 351  }
 352  
 353  function __addDisposableResource(env, value, async) {
 354    if (value !== null && value !== void 0) {
 355      if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
 356      var dispose;
 357      if (async) {
 358          if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
 359          dispose = value[Symbol.asyncDispose];
 360      }
 361      if (dispose === void 0) {
 362          if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
 363          dispose = value[Symbol.dispose];
 364      }
 365      if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
 366      env.stack.push({ value: value, dispose: dispose, async: async });
 367    }
 368    else if (async) {
 369      env.stack.push({ async: true });
 370    }
 371    return value;
 372  }
 373  
 374  var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
 375    var e = new Error(message);
 376    return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
 377  };
 378  
 379  function __disposeResources(env) {
 380    function fail(e) {
 381      env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
 382      env.hasError = true;
 383    }
 384    function next() {
 385      while (env.stack.length) {
 386        var rec = env.stack.pop();
 387        try {
 388          var result = rec.dispose && rec.dispose.call(rec.value);
 389          if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
 390        }
 391        catch (e) {
 392            fail(e);
 393        }
 394      }
 395      if (env.hasError) throw env.error;
 396    }
 397    return next();
 398  }
 399  
 400  /* harmony default export */ const tslib_es6 = ({
 401    __extends,
 402    __assign,
 403    __rest,
 404    __decorate,
 405    __param,
 406    __metadata,
 407    __awaiter,
 408    __generator,
 409    __createBinding,
 410    __exportStar,
 411    __values,
 412    __read,
 413    __spread,
 414    __spreadArrays,
 415    __spreadArray,
 416    __await,
 417    __asyncGenerator,
 418    __asyncDelegator,
 419    __asyncValues,
 420    __makeTemplateObject,
 421    __importStar,
 422    __importDefault,
 423    __classPrivateFieldGet,
 424    __classPrivateFieldSet,
 425    __classPrivateFieldIn,
 426    __addDisposableResource,
 427    __disposeResources,
 428  });
 429  
 430  ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
 431  /**
 432   * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
 433   */
 434  var SUPPORTED_LOCALE = {
 435      tr: {
 436          regexp: /\u0130|\u0049|\u0049\u0307/g,
 437          map: {
 438              İ: "\u0069",
 439              I: "\u0131",
 440              İ: "\u0069",
 441          },
 442      },
 443      az: {
 444          regexp: /\u0130/g,
 445          map: {
 446              İ: "\u0069",
 447              I: "\u0131",
 448              İ: "\u0069",
 449          },
 450      },
 451      lt: {
 452          regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
 453          map: {
 454              I: "\u0069\u0307",
 455              J: "\u006A\u0307",
 456              Į: "\u012F\u0307",
 457              Ì: "\u0069\u0307\u0300",
 458              Í: "\u0069\u0307\u0301",
 459              Ĩ: "\u0069\u0307\u0303",
 460          },
 461      },
 462  };
 463  /**
 464   * Localized lower case.
 465   */
 466  function localeLowerCase(str, locale) {
 467      var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
 468      if (lang)
 469          return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
 470      return lowerCase(str);
 471  }
 472  /**
 473   * Lower case as a function.
 474   */
 475  function lowerCase(str) {
 476      return str.toLowerCase();
 477  }
 478  
 479  ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
 480  
 481  // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
 482  var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
 483  // Remove all non-word characters.
 484  var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
 485  /**
 486   * Normalize the string into something other libraries can manipulate easier.
 487   */
 488  function noCase(input, options) {
 489      if (options === void 0) { options = {}; }
 490      var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
 491      var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
 492      var start = 0;
 493      var end = result.length;
 494      // Trim the delimiter from around the output string.
 495      while (result.charAt(start) === "\0")
 496          start++;
 497      while (result.charAt(end - 1) === "\0")
 498          end--;
 499      // Transform each token independently.
 500      return result.slice(start, end).split("\0").map(transform).join(delimiter);
 501  }
 502  /**
 503   * Replace `re` in the input string with the replacement value.
 504   */
 505  function replace(input, re, value) {
 506      if (re instanceof RegExp)
 507          return input.replace(re, value);
 508      return re.reduce(function (input, re) { return input.replace(re, value); }, input);
 509  }
 510  
 511  ;// CONCATENATED MODULE: ./node_modules/dot-case/dist.es2015/index.js
 512  
 513  
 514  function dotCase(input, options) {
 515      if (options === void 0) { options = {}; }
 516      return noCase(input, __assign({ delimiter: "." }, options));
 517  }
 518  
 519  ;// CONCATENATED MODULE: ./node_modules/param-case/dist.es2015/index.js
 520  
 521  
 522  function paramCase(input, options) {
 523      if (options === void 0) { options = {}; }
 524      return dotCase(input, __assign({ delimiter: "-" }, options));
 525  }
 526  
 527  ;// CONCATENATED MODULE: external ["wp","apiFetch"]
 528  const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
 529  var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
 530  ;// CONCATENATED MODULE: external ["wp","blob"]
 531  const external_wp_blob_namespaceObject = window["wp"]["blob"];
 532  ;// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/export.js
 533  /**
 534   * External dependencies
 535   */
 536  
 537  
 538  /**
 539   * WordPress dependencies
 540   */
 541  
 542  
 543  /**
 544   * Internal dependencies
 545   */
 546  
 547  
 548  /**
 549   * Export a reusable block as a JSON file.
 550   *
 551   * @param {number} id
 552   */
 553  async function exportReusableBlock(id) {
 554    const postType = await external_wp_apiFetch_default()({
 555      path: `/wp/v2/types/wp_block`
 556    });
 557    const post = await external_wp_apiFetch_default()({
 558      path: `/wp/v2/$postType.rest_base}/$id}?context=edit`
 559    });
 560    const title = post.title.raw;
 561    const content = post.content.raw;
 562    const syncStatus = post.wp_pattern_sync_status;
 563    const fileContent = JSON.stringify({
 564      __file: 'wp_block',
 565      title,
 566      content,
 567      syncStatus
 568    }, null, 2);
 569    const fileName = paramCase(title) + '.json';
 570    (0,external_wp_blob_namespaceObject.downloadBlob)(fileName, fileContent, 'application/json');
 571  }
 572  /* harmony default export */ const utils_export = (exportReusableBlock);
 573  
 574  ;// CONCATENATED MODULE: external ["wp","compose"]
 575  const external_wp_compose_namespaceObject = window["wp"]["compose"];
 576  ;// CONCATENATED MODULE: external ["wp","components"]
 577  const external_wp_components_namespaceObject = window["wp"]["components"];
 578  ;// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/file.js
 579  /**
 580   * Reads the textual content of the given file.
 581   *
 582   * @param {File} file File.
 583   * @return {Promise<string>}  Content of the file.
 584   */
 585  function readTextFile(file) {
 586    const reader = new window.FileReader();
 587    return new Promise(resolve => {
 588      reader.onload = () => {
 589        resolve(reader.result);
 590      };
 591      reader.readAsText(file);
 592    });
 593  }
 594  
 595  ;// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/import.js
 596  /**
 597   * WordPress dependencies
 598   */
 599  
 600  
 601  /**
 602   * Internal dependencies
 603   */
 604  
 605  
 606  /**
 607   * Import a reusable block from a JSON file.
 608   *
 609   * @param {File} file File.
 610   * @return {Promise} Promise returning the imported reusable block.
 611   */
 612  async function importReusableBlock(file) {
 613    const fileContent = await readTextFile(file);
 614    let parsedContent;
 615    try {
 616      parsedContent = JSON.parse(fileContent);
 617    } catch (e) {
 618      throw new Error('Invalid JSON file');
 619    }
 620    if (parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || typeof parsedContent.title !== 'string' || typeof parsedContent.content !== 'string' || parsedContent.syncStatus && typeof parsedContent.syncStatus !== 'string') {
 621      throw new Error('Invalid pattern JSON file');
 622    }
 623    const postType = await external_wp_apiFetch_default()({
 624      path: `/wp/v2/types/wp_block`
 625    });
 626    const reusableBlock = await external_wp_apiFetch_default()({
 627      path: `/wp/v2/$postType.rest_base}`,
 628      data: {
 629        title: parsedContent.title,
 630        content: parsedContent.content,
 631        status: 'publish',
 632        meta: parsedContent.syncStatus === 'unsynced' ? {
 633          wp_pattern_sync_status: parsedContent.syncStatus
 634        } : undefined
 635      },
 636      method: 'POST'
 637    });
 638    return reusableBlock;
 639  }
 640  /* harmony default export */ const utils_import = (importReusableBlock);
 641  
 642  ;// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-form/index.js
 643  
 644  /**
 645   * WordPress dependencies
 646   */
 647  
 648  
 649  
 650  
 651  
 652  /**
 653   * Internal dependencies
 654   */
 655  
 656  function ImportForm({
 657    instanceId,
 658    onUpload
 659  }) {
 660    const inputId = 'list-reusable-blocks-import-form-' + instanceId;
 661    const formRef = (0,external_wp_element_namespaceObject.useRef)();
 662    const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false);
 663    const [error, setError] = (0,external_wp_element_namespaceObject.useState)(null);
 664    const [file, setFile] = (0,external_wp_element_namespaceObject.useState)(null);
 665    const onChangeFile = event => {
 666      setFile(event.target.files[0]);
 667      setError(null);
 668    };
 669    const onSubmit = event => {
 670      event.preventDefault();
 671      if (!file) {
 672        return;
 673      }
 674      setIsLoading({
 675        isLoading: true
 676      });
 677      utils_import(file).then(reusableBlock => {
 678        if (!formRef) {
 679          return;
 680        }
 681        setIsLoading(false);
 682        onUpload(reusableBlock);
 683      }).catch(errors => {
 684        if (!formRef) {
 685          return;
 686        }
 687        let uiMessage;
 688        switch (errors.message) {
 689          case 'Invalid JSON file':
 690            uiMessage = (0,external_wp_i18n_namespaceObject.__)('Invalid JSON file');
 691            break;
 692          case 'Invalid pattern JSON file':
 693            uiMessage = (0,external_wp_i18n_namespaceObject.__)('Invalid pattern JSON file');
 694            break;
 695          default:
 696            uiMessage = (0,external_wp_i18n_namespaceObject.__)('Unknown error');
 697        }
 698        setIsLoading(false);
 699        setError(uiMessage);
 700      });
 701    };
 702    const onDismissError = () => {
 703      setError(null);
 704    };
 705    return (0,external_React_namespaceObject.createElement)("form", {
 706      className: "list-reusable-blocks-import-form",
 707      onSubmit: onSubmit,
 708      ref: formRef
 709    }, error && (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, {
 710      status: "error",
 711      onRemove: () => onDismissError()
 712    }, error), (0,external_React_namespaceObject.createElement)("label", {
 713      htmlFor: inputId,
 714      className: "list-reusable-blocks-import-form__label"
 715    }, (0,external_wp_i18n_namespaceObject.__)('File')), (0,external_React_namespaceObject.createElement)("input", {
 716      id: inputId,
 717      type: "file",
 718      onChange: onChangeFile
 719    }), (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
 720      type: "submit",
 721      isBusy: isLoading,
 722      disabled: !file || isLoading,
 723      variant: "secondary",
 724      className: "list-reusable-blocks-import-form__button"
 725    }, (0,external_wp_i18n_namespaceObject._x)('Import', 'button label')));
 726  }
 727  /* harmony default export */ const import_form = ((0,external_wp_compose_namespaceObject.withInstanceId)(ImportForm));
 728  
 729  ;// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-dropdown/index.js
 730  
 731  /**
 732   * WordPress dependencies
 733   */
 734  
 735  
 736  
 737  
 738  /**
 739   * Internal dependencies
 740   */
 741  
 742  function ImportDropdown({
 743    onUpload
 744  }) {
 745    return (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
 746      popoverProps: {
 747        placement: 'bottom-start'
 748      },
 749      contentClassName: "list-reusable-blocks-import-dropdown__content",
 750      renderToggle: ({
 751        isOpen,
 752        onToggle
 753      }) => (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
 754        "aria-expanded": isOpen,
 755        onClick: onToggle,
 756        variant: "primary"
 757      }, (0,external_wp_i18n_namespaceObject.__)('Import from JSON')),
 758      renderContent: ({
 759        onClose
 760      }) => (0,external_React_namespaceObject.createElement)(import_form, {
 761        onUpload: (0,external_wp_compose_namespaceObject.pipe)(onClose, onUpload)
 762      })
 763    });
 764  }
 765  /* harmony default export */ const import_dropdown = (ImportDropdown);
 766  
 767  ;// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/index.js
 768  
 769  /**
 770   * WordPress dependencies
 771   */
 772  
 773  
 774  
 775  /**
 776   * Internal dependencies
 777   */
 778  
 779  
 780  
 781  // Setup Export Links.
 782  document.body.addEventListener('click', event => {
 783    if (!event.target.classList.contains('wp-list-reusable-blocks__export')) {
 784      return;
 785    }
 786    event.preventDefault();
 787    utils_export(event.target.dataset.id);
 788  });
 789  
 790  // Setup Import Form.
 791  document.addEventListener('DOMContentLoaded', () => {
 792    const button = document.querySelector('.page-title-action');
 793    if (!button) {
 794      return;
 795    }
 796    const showNotice = () => {
 797      const notice = document.createElement('div');
 798      notice.className = 'notice notice-success is-dismissible';
 799      notice.innerHTML = `<p>${(0,external_wp_i18n_namespaceObject.__)('Pattern imported successfully!')}</p>`;
 800      const headerEnd = document.querySelector('.wp-header-end');
 801      if (!headerEnd) {
 802        return;
 803      }
 804      headerEnd.parentNode.insertBefore(notice, headerEnd);
 805    };
 806    const container = document.createElement('div');
 807    container.className = 'list-reusable-blocks__container';
 808    button.parentNode.insertBefore(container, button);
 809    (0,external_wp_element_namespaceObject.createRoot)(container).render((0,external_React_namespaceObject.createElement)(import_dropdown, {
 810      onUpload: showNotice
 811    }));
 812  });
 813  
 814  (window.wp = window.wp || {}).listReusableBlocks = __webpack_exports__;
 815  /******/ })()
 816  ;


Generated : Thu Mar 28 08:20:01 2024 Cross-referenced by PHPXref