[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

   1  this["wp"] = this["wp"] || {}; this["wp"]["listReusableBlocks"] =
   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 = 478);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 0:
  91  /***/ (function(module, exports) {
  92  
  93  (function() { module.exports = window["wp"]["element"]; }());
  94  
  95  /***/ }),
  96  
  97  /***/ 1:
  98  /***/ (function(module, exports) {
  99  
 100  (function() { module.exports = window["wp"]["i18n"]; }());
 101  
 102  /***/ }),
 103  
 104  /***/ 12:
 105  /***/ (function(module, exports) {
 106  
 107  (function() { module.exports = window["wp"]["compose"]; }());
 108  
 109  /***/ }),
 110  
 111  /***/ 16:
 112  /***/ (function(module, exports) {
 113  
 114  (function() { module.exports = window["regeneratorRuntime"]; }());
 115  
 116  /***/ }),
 117  
 118  /***/ 18:
 119  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 120  
 121  "use strict";
 122  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; });
 123  function _assertThisInitialized(self) {
 124    if (self === void 0) {
 125      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
 126    }
 127  
 128    return self;
 129  }
 130  
 131  /***/ }),
 132  
 133  /***/ 19:
 134  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 135  
 136  "use strict";
 137  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; });
 138  function _getPrototypeOf(o) {
 139    _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
 140      return o.__proto__ || Object.getPrototypeOf(o);
 141    };
 142    return _getPrototypeOf(o);
 143  }
 144  
 145  /***/ }),
 146  
 147  /***/ 2:
 148  /***/ (function(module, exports) {
 149  
 150  (function() { module.exports = window["lodash"]; }());
 151  
 152  /***/ }),
 153  
 154  /***/ 25:
 155  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 156  
 157  "use strict";
 158  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
 159  function _classCallCheck(instance, Constructor) {
 160    if (!(instance instanceof Constructor)) {
 161      throw new TypeError("Cannot call a class as a function");
 162    }
 163  }
 164  
 165  /***/ }),
 166  
 167  /***/ 26:
 168  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 169  
 170  "use strict";
 171  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; });
 172  function _defineProperties(target, props) {
 173    for (var i = 0; i < props.length; i++) {
 174      var descriptor = props[i];
 175      descriptor.enumerable = descriptor.enumerable || false;
 176      descriptor.configurable = true;
 177      if ("value" in descriptor) descriptor.writable = true;
 178      Object.defineProperty(target, descriptor.key, descriptor);
 179    }
 180  }
 181  
 182  function _createClass(Constructor, protoProps, staticProps) {
 183    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
 184    if (staticProps) _defineProperties(Constructor, staticProps);
 185    return Constructor;
 186  }
 187  
 188  /***/ }),
 189  
 190  /***/ 28:
 191  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 192  
 193  "use strict";
 194  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; });
 195  /* harmony import */ var _babel_runtime_helpers_esm_setPrototypeOf__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(52);
 196  
 197  function _inherits(subClass, superClass) {
 198    if (typeof superClass !== "function" && superClass !== null) {
 199      throw new TypeError("Super expression must either be null or a function");
 200    }
 201  
 202    subClass.prototype = Object.create(superClass && superClass.prototype, {
 203      constructor: {
 204        value: subClass,
 205        writable: true,
 206        configurable: true
 207      }
 208    });
 209    if (superClass) Object(_babel_runtime_helpers_esm_setPrototypeOf__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(subClass, superClass);
 210  }
 211  
 212  /***/ }),
 213  
 214  /***/ 29:
 215  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 216  
 217  "use strict";
 218  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; });
 219  /* harmony import */ var _babel_runtime_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(42);
 220  /* harmony import */ var _babel_runtime_helpers_esm_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(18);
 221  
 222  
 223  function _possibleConstructorReturn(self, call) {
 224    if (call && (Object(_babel_runtime_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) {
 225      return call;
 226    }
 227  
 228    return Object(_babel_runtime_helpers_esm_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self);
 229  }
 230  
 231  /***/ }),
 232  
 233  /***/ 3:
 234  /***/ (function(module, exports) {
 235  
 236  (function() { module.exports = window["wp"]["components"]; }());
 237  
 238  /***/ }),
 239  
 240  /***/ 42:
 241  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 242  
 243  "use strict";
 244  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; });
 245  function _typeof(obj) {
 246    "@babel/helpers - typeof";
 247  
 248    if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
 249      _typeof = function _typeof(obj) {
 250        return typeof obj;
 251      };
 252    } else {
 253      _typeof = function _typeof(obj) {
 254        return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
 255      };
 256    }
 257  
 258    return _typeof(obj);
 259  }
 260  
 261  /***/ }),
 262  
 263  /***/ 47:
 264  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 265  
 266  "use strict";
 267  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; });
 268  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
 269    try {
 270      var info = gen[key](arg);
 271      var value = info.value;
 272    } catch (error) {
 273      reject(error);
 274      return;
 275    }
 276  
 277    if (info.done) {
 278      resolve(value);
 279    } else {
 280      Promise.resolve(value).then(_next, _throw);
 281    }
 282  }
 283  
 284  function _asyncToGenerator(fn) {
 285    return function () {
 286      var self = this,
 287          args = arguments;
 288      return new Promise(function (resolve, reject) {
 289        var gen = fn.apply(self, args);
 290  
 291        function _next(value) {
 292          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
 293        }
 294  
 295        function _throw(err) {
 296          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
 297        }
 298  
 299        _next(undefined);
 300      });
 301    };
 302  }
 303  
 304  /***/ }),
 305  
 306  /***/ 478:
 307  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 308  
 309  "use strict";
 310  // ESM COMPAT FLAG
 311  __webpack_require__.r(__webpack_exports__);
 312  
 313  // EXTERNAL MODULE: external ["wp","element"]
 314  var external_wp_element_ = __webpack_require__(0);
 315  
 316  // EXTERNAL MODULE: external ["wp","i18n"]
 317  var external_wp_i18n_ = __webpack_require__(1);
 318  
 319  // EXTERNAL MODULE: external "regeneratorRuntime"
 320  var external_regeneratorRuntime_ = __webpack_require__(16);
 321  var external_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_regeneratorRuntime_);
 322  
 323  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
 324  var asyncToGenerator = __webpack_require__(47);
 325  
 326  // EXTERNAL MODULE: external "lodash"
 327  var external_lodash_ = __webpack_require__(2);
 328  
 329  // EXTERNAL MODULE: external ["wp","apiFetch"]
 330  var external_wp_apiFetch_ = __webpack_require__(50);
 331  var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_);
 332  
 333  // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/file.js
 334  /**
 335   * Downloads a file.
 336   *
 337   * @param {string} fileName    File Name.
 338   * @param {string} content     File Content.
 339   * @param {string} contentType File mime type.
 340   */
 341  function download(fileName, content, contentType) {
 342    var file = new window.Blob([content], {
 343      type: contentType
 344    }); // IE11 can't use the click to download technique
 345    // we use a specific IE11 technique instead.
 346  
 347    if (window.navigator.msSaveOrOpenBlob) {
 348      window.navigator.msSaveOrOpenBlob(file, fileName);
 349    } else {
 350      var a = document.createElement('a');
 351      a.href = URL.createObjectURL(file);
 352      a.download = fileName;
 353      a.style.display = 'none';
 354      document.body.appendChild(a);
 355      a.click();
 356      document.body.removeChild(a);
 357    }
 358  }
 359  /**
 360   * Reads the textual content of the given file.
 361   *
 362   * @param  {File} file        File.
 363   * @return {Promise<string>}  Content of the file.
 364   */
 365  
 366  function readTextFile(file) {
 367    var reader = new window.FileReader();
 368    return new Promise(function (resolve) {
 369      reader.onload = function () {
 370        resolve(reader.result);
 371      };
 372  
 373      reader.readAsText(file);
 374    });
 375  }
 376  
 377  // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/export.js
 378  
 379  
 380  
 381  /**
 382   * External dependencies
 383   */
 384  
 385  /**
 386   * WordPress dependencies
 387   */
 388  
 389  
 390  /**
 391   * Internal dependencies
 392   */
 393  
 394  
 395  /**
 396   * Export a reusable block as a JSON file.
 397   *
 398   * @param {number} id
 399   */
 400  
 401  function exportReusableBlock(_x) {
 402    return _exportReusableBlock.apply(this, arguments);
 403  }
 404  
 405  function _exportReusableBlock() {
 406    _exportReusableBlock = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee(id) {
 407      var postType, post, title, content, fileContent, fileName;
 408      return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
 409        while (1) {
 410          switch (_context.prev = _context.next) {
 411            case 0:
 412              _context.next = 2;
 413              return external_wp_apiFetch_default()({
 414                path: "/wp/v2/types/wp_block"
 415              });
 416  
 417            case 2:
 418              postType = _context.sent;
 419              _context.next = 5;
 420              return external_wp_apiFetch_default()({
 421                path: "/wp/v2/".concat(postType.rest_base, "/").concat(id, "?context=edit")
 422              });
 423  
 424            case 5:
 425              post = _context.sent;
 426              title = post.title.raw;
 427              content = post.content.raw;
 428              fileContent = JSON.stringify({
 429                __file: 'wp_block',
 430                title: title,
 431                content: content
 432              }, null, 2);
 433              fileName = Object(external_lodash_["kebabCase"])(title) + '.json';
 434              download(fileName, fileContent, 'application/json');
 435  
 436            case 11:
 437            case "end":
 438              return _context.stop();
 439          }
 440        }
 441      }, _callee);
 442    }));
 443    return _exportReusableBlock.apply(this, arguments);
 444  }
 445  
 446  /* harmony default export */ var utils_export = (exportReusableBlock);
 447  
 448  // EXTERNAL MODULE: external ["wp","components"]
 449  var external_wp_components_ = __webpack_require__(3);
 450  
 451  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
 452  var classCallCheck = __webpack_require__(25);
 453  
 454  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
 455  var createClass = __webpack_require__(26);
 456  
 457  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
 458  var assertThisInitialized = __webpack_require__(18);
 459  
 460  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
 461  var inherits = __webpack_require__(28);
 462  
 463  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
 464  var possibleConstructorReturn = __webpack_require__(29);
 465  
 466  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
 467  var getPrototypeOf = __webpack_require__(19);
 468  
 469  // EXTERNAL MODULE: external ["wp","compose"]
 470  var external_wp_compose_ = __webpack_require__(12);
 471  
 472  // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/import.js
 473  
 474  
 475  
 476  /**
 477   * External dependencies
 478   */
 479  
 480  /**
 481   * WordPress dependencies
 482   */
 483  
 484  
 485  /**
 486   * Internal dependencies
 487   */
 488  
 489  
 490  /**
 491   * Import a reusable block from a JSON file.
 492   *
 493   * @param {File}     file File.
 494   * @return {Promise} Promise returning the imported reusable block.
 495   */
 496  
 497  function importReusableBlock(_x) {
 498    return _importReusableBlock.apply(this, arguments);
 499  }
 500  
 501  function _importReusableBlock() {
 502    _importReusableBlock = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee(file) {
 503      var fileContent, parsedContent, postType, reusableBlock;
 504      return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
 505        while (1) {
 506          switch (_context.prev = _context.next) {
 507            case 0:
 508              _context.next = 2;
 509              return readTextFile(file);
 510  
 511            case 2:
 512              fileContent = _context.sent;
 513              _context.prev = 3;
 514              parsedContent = JSON.parse(fileContent);
 515              _context.next = 10;
 516              break;
 517  
 518            case 7:
 519              _context.prev = 7;
 520              _context.t0 = _context["catch"](3);
 521              throw new Error('Invalid JSON file');
 522  
 523            case 10:
 524              if (!(parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || !Object(external_lodash_["isString"])(parsedContent.title) || !Object(external_lodash_["isString"])(parsedContent.content))) {
 525                _context.next = 12;
 526                break;
 527              }
 528  
 529              throw new Error('Invalid Reusable Block JSON file');
 530  
 531            case 12:
 532              _context.next = 14;
 533              return external_wp_apiFetch_default()({
 534                path: "/wp/v2/types/wp_block"
 535              });
 536  
 537            case 14:
 538              postType = _context.sent;
 539              _context.next = 17;
 540              return external_wp_apiFetch_default()({
 541                path: "/wp/v2/".concat(postType.rest_base),
 542                data: {
 543                  title: parsedContent.title,
 544                  content: parsedContent.content,
 545                  status: 'publish'
 546                },
 547                method: 'POST'
 548              });
 549  
 550            case 17:
 551              reusableBlock = _context.sent;
 552              return _context.abrupt("return", reusableBlock);
 553  
 554            case 19:
 555            case "end":
 556              return _context.stop();
 557          }
 558        }
 559      }, _callee, null, [[3, 7]]);
 560    }));
 561    return _importReusableBlock.apply(this, arguments);
 562  }
 563  
 564  /* harmony default export */ var utils_import = (importReusableBlock);
 565  
 566  // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-form/index.js
 567  
 568  
 569  
 570  
 571  
 572  
 573  
 574  
 575  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; }
 576  
 577  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
 578  
 579  /**
 580   * WordPress dependencies
 581   */
 582  
 583  
 584  
 585  
 586  /**
 587   * Internal dependencies
 588   */
 589  
 590  
 591  
 592  var import_form_ImportForm = /*#__PURE__*/function (_Component) {
 593    Object(inherits["a" /* default */])(ImportForm, _Component);
 594  
 595    var _super = _createSuper(ImportForm);
 596  
 597    function ImportForm() {
 598      var _this;
 599  
 600      Object(classCallCheck["a" /* default */])(this, ImportForm);
 601  
 602      _this = _super.apply(this, arguments);
 603      _this.state = {
 604        isLoading: false,
 605        error: null,
 606        file: null
 607      };
 608      _this.isStillMounted = true;
 609      _this.onChangeFile = _this.onChangeFile.bind(Object(assertThisInitialized["a" /* default */])(_this));
 610      _this.onSubmit = _this.onSubmit.bind(Object(assertThisInitialized["a" /* default */])(_this));
 611      return _this;
 612    }
 613  
 614    Object(createClass["a" /* default */])(ImportForm, [{
 615      key: "componentWillUnmount",
 616      value: function componentWillUnmount() {
 617        this.isStillMounted = false;
 618      }
 619    }, {
 620      key: "onChangeFile",
 621      value: function onChangeFile(event) {
 622        this.setState({
 623          file: event.target.files[0],
 624          error: null
 625        });
 626      }
 627    }, {
 628      key: "onSubmit",
 629      value: function onSubmit(event) {
 630        var _this2 = this;
 631  
 632        event.preventDefault();
 633        var file = this.state.file;
 634        var onUpload = this.props.onUpload;
 635  
 636        if (!file) {
 637          return;
 638        }
 639  
 640        this.setState({
 641          isLoading: true
 642        });
 643        utils_import(file).then(function (reusableBlock) {
 644          if (!_this2.isStillMounted) {
 645            return;
 646          }
 647  
 648          _this2.setState({
 649            isLoading: false
 650          });
 651  
 652          onUpload(reusableBlock);
 653        }).catch(function (error) {
 654          if (!_this2.isStillMounted) {
 655            return;
 656          }
 657  
 658          var uiMessage;
 659  
 660          switch (error.message) {
 661            case 'Invalid JSON file':
 662              uiMessage = Object(external_wp_i18n_["__"])('Invalid JSON file');
 663              break;
 664  
 665            case 'Invalid Reusable Block JSON file':
 666              uiMessage = Object(external_wp_i18n_["__"])('Invalid Reusable Block JSON file');
 667              break;
 668  
 669            default:
 670              uiMessage = Object(external_wp_i18n_["__"])('Unknown error');
 671          }
 672  
 673          _this2.setState({
 674            isLoading: false,
 675            error: uiMessage
 676          });
 677        });
 678      }
 679    }, {
 680      key: "onDismissError",
 681      value: function onDismissError() {
 682        this.setState({
 683          error: null
 684        });
 685      }
 686    }, {
 687      key: "render",
 688      value: function render() {
 689        var _this3 = this;
 690  
 691        var instanceId = this.props.instanceId;
 692        var _this$state = this.state,
 693            file = _this$state.file,
 694            isLoading = _this$state.isLoading,
 695            error = _this$state.error;
 696        var inputId = 'list-reusable-blocks-import-form-' + instanceId;
 697        return Object(external_wp_element_["createElement"])("form", {
 698          className: "list-reusable-blocks-import-form",
 699          onSubmit: this.onSubmit
 700        }, error && Object(external_wp_element_["createElement"])(external_wp_components_["Notice"], {
 701          status: "error",
 702          onRemove: function onRemove() {
 703            return _this3.onDismissError();
 704          }
 705        }, error), Object(external_wp_element_["createElement"])("label", {
 706          htmlFor: inputId,
 707          className: "list-reusable-blocks-import-form__label"
 708        }, Object(external_wp_i18n_["__"])('File')), Object(external_wp_element_["createElement"])("input", {
 709          id: inputId,
 710          type: "file",
 711          onChange: this.onChangeFile
 712        }), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
 713          type: "submit",
 714          isBusy: isLoading,
 715          disabled: !file || isLoading,
 716          isSecondary: true,
 717          className: "list-reusable-blocks-import-form__button"
 718        }, Object(external_wp_i18n_["_x"])('Import', 'button label')));
 719      }
 720    }]);
 721  
 722    return ImportForm;
 723  }(external_wp_element_["Component"]);
 724  
 725  /* harmony default export */ var import_form = (Object(external_wp_compose_["withInstanceId"])(import_form_ImportForm));
 726  
 727  // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-dropdown/index.js
 728  
 729  
 730  /**
 731   * External dependencies
 732   */
 733  
 734  /**
 735   * WordPress dependencies
 736   */
 737  
 738  
 739  
 740  /**
 741   * Internal dependencies
 742   */
 743  
 744  
 745  
 746  function ImportDropdown(_ref) {
 747    var onUpload = _ref.onUpload;
 748    return Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
 749      position: "bottom right",
 750      contentClassName: "list-reusable-blocks-import-dropdown__content",
 751      renderToggle: function renderToggle(_ref2) {
 752        var isOpen = _ref2.isOpen,
 753            onToggle = _ref2.onToggle;
 754        return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
 755          "aria-expanded": isOpen,
 756          onClick: onToggle,
 757          isPrimary: true
 758        }, Object(external_wp_i18n_["__"])('Import from JSON'));
 759      },
 760      renderContent: function renderContent(_ref3) {
 761        var onClose = _ref3.onClose;
 762        return Object(external_wp_element_["createElement"])(import_form, {
 763          onUpload: Object(external_lodash_["flow"])(onClose, onUpload)
 764        });
 765      }
 766    });
 767  }
 768  
 769  /* harmony default export */ var import_dropdown = (ImportDropdown);
 770  
 771  // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/index.js
 772  
 773  
 774  /**
 775   * WordPress dependencies
 776   */
 777  
 778  
 779  /**
 780   * Internal dependencies
 781   */
 782  
 783  
 784   // Setup Export Links
 785  
 786  document.body.addEventListener('click', function (event) {
 787    if (!event.target.classList.contains('wp-list-reusable-blocks__export')) {
 788      return;
 789    }
 790  
 791    event.preventDefault();
 792    utils_export(event.target.dataset.id);
 793  }); // Setup Import Form
 794  
 795  document.addEventListener('DOMContentLoaded', function () {
 796    var button = document.querySelector('.page-title-action');
 797  
 798    if (!button) {
 799      return;
 800    }
 801  
 802    var showNotice = function showNotice() {
 803      var notice = document.createElement('div');
 804      notice.className = 'notice notice-success is-dismissible';
 805      notice.innerHTML = "<p>".concat(Object(external_wp_i18n_["__"])('Reusable block imported successfully!'), "</p>");
 806      var headerEnd = document.querySelector('.wp-header-end');
 807  
 808      if (!headerEnd) {
 809        return;
 810      }
 811  
 812      headerEnd.parentNode.insertBefore(notice, headerEnd);
 813    };
 814  
 815    var container = document.createElement('div');
 816    container.className = 'list-reusable-blocks__container';
 817    button.parentNode.insertBefore(container, button);
 818    Object(external_wp_element_["render"])(Object(external_wp_element_["createElement"])(import_dropdown, {
 819      onUpload: showNotice
 820    }), container);
 821  });
 822  
 823  
 824  /***/ }),
 825  
 826  /***/ 50:
 827  /***/ (function(module, exports) {
 828  
 829  (function() { module.exports = window["wp"]["apiFetch"]; }());
 830  
 831  /***/ }),
 832  
 833  /***/ 52:
 834  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 835  
 836  "use strict";
 837  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _setPrototypeOf; });
 838  function _setPrototypeOf(o, p) {
 839    _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
 840      o.__proto__ = p;
 841      return o;
 842    };
 843  
 844    return _setPrototypeOf(o, p);
 845  }
 846  
 847  /***/ })
 848  
 849  /******/ });


Generated: Mon Mar 1 01:00:03 2021 Cross-referenced by PHPXref 0.7.1