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


Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref