PluginProbe
MyBookTable Bookstore by Stormhill Media / trunk
MyBookTable Bookstore by Stormhill Media vtrunk
3.6.5 trunk
mybooktable / js / blocks.js

blocks.js in MyBookTable Bookstore by Stormhill Media trunk, at js/blocks.js

224 lines 34.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function(modules) { // webpackBootstrap
2 /******/ // The module cache
3 /******/ var installedModules = {};
4 /******/
5 /******/ // The require function
6 /******/ function __webpack_require__(moduleId) {
7 /******/
8 /******/ // Check if module is in cache
9 /******/ if(installedModules[moduleId]) {
10 /******/ return installedModules[moduleId].exports;
11 /******/ }
12 /******/ // Create a new module (and put it into the cache)
13 /******/ var module = installedModules[moduleId] = {
14 /******/ i: moduleId,
15 /******/ l: false,
16 /******/ exports: {}
17 /******/ };
18 /******/
19 /******/ // Execute the module function
20 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21 /******/
22 /******/ // Flag the module as loaded
23 /******/ module.l = true;
24 /******/
25 /******/ // Return the exports of the module
26 /******/ return module.exports;
27 /******/ }
28 /******/
29 /******/
30 /******/ // expose the modules object (__webpack_modules__)
31 /******/ __webpack_require__.m = modules;
32 /******/
33 /******/ // expose the module cache
34 /******/ __webpack_require__.c = installedModules;
35 /******/
36 /******/ // define getter function for harmony exports
37 /******/ __webpack_require__.d = function(exports, name, getter) {
38 /******/ if(!__webpack_require__.o(exports, name)) {
39 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
40 /******/ }
41 /******/ };
42 /******/
43 /******/ // define __esModule on exports
44 /******/ __webpack_require__.r = function(exports) {
45 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47 /******/ }
48 /******/ Object.defineProperty(exports, '__esModule', { value: true });
49 /******/ };
50 /******/
51 /******/ // create a fake namespace object
52 /******/ // mode & 1: value is a module id, require it
53 /******/ // mode & 2: merge all properties of value into the ns
54 /******/ // mode & 4: return value when already ns object
55 /******/ // mode & 8|1: behave like require
56 /******/ __webpack_require__.t = function(value, mode) {
57 /******/ if(mode & 1) value = __webpack_require__(value);
58 /******/ if(mode & 8) return value;
59 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60 /******/ var ns = Object.create(null);
61 /******/ __webpack_require__.r(ns);
62 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64 /******/ return ns;
65 /******/ };
66 /******/
67 /******/ // getDefaultExport function for compatibility with non-harmony modules
68 /******/ __webpack_require__.n = function(module) {
69 /******/ var getter = module && module.__esModule ?
70 /******/ function getDefault() { return module['default']; } :
71 /******/ function getModuleExports() { return module; };
72 /******/ __webpack_require__.d(getter, 'a', getter);
73 /******/ return getter;
74 /******/ };
75 /******/
76 /******/ // Object.prototype.hasOwnProperty.call
77 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78 /******/
79 /******/ // __webpack_public_path__
80 /******/ __webpack_require__.p = "";
81 /******/
82 /******/
83 /******/ // Load entry module and return exports
84 /******/ return __webpack_require__(__webpack_require__.s = "./src/blocks/index.tsx");
85 /******/ })
86 /************************************************************************/
87 /******/ ({
88
89 /***/ "./src/blocks/index.scss":
90 /*!*******************************!*\
91 !*** ./src/blocks/index.scss ***!
92 \*******************************/
93 /*! no static exports found */
94 /***/ (function(module, exports, __webpack_require__) {
95
96 eval("// extracted by mini-css-extract-plugin\n\n//# sourceURL=webpack:///./src/blocks/index.scss?");
97
98 /***/ }),
99
100 /***/ "./src/blocks/index.tsx":
101 /*!******************************!*\
102 !*** ./src/blocks/index.tsx ***!
103 \******************************/
104 /*! no exports provided */
105 /***/ (function(module, __webpack_exports__, __webpack_require__) {
106
107 "use strict";
108 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash */ \"lodash\");\n/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ \"@wordpress/i18n\");\n/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/url */ \"@wordpress/url\");\n/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/api-fetch */ \"@wordpress/api-fetch\");\n/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ \"./src/blocks/utils.tsx\");\n/* harmony import */ var _shortcodes__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shortcodes */ \"./src/blocks/shortcodes.tsx\");\n\n\n\n\n\n\nObject(_shortcodes__WEBPACK_IMPORTED_MODULE_5__[\"registerShortcodeBlock\"])({\n name: 'all-books',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('All Books', 'mybooktable'),\n icon: 'book-alt',\n description: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('List all your books in an embedded book listing.', 'mybooktable'),\n inspectorAttributes: [\n {\n name: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Display Settings', 'mybooktable'),\n attributes: [\n {\n name: 'gridview',\n type: 'checkbox',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Force Grid View Display?', 'mybooktable'),\n description: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Shows book covers in a responsive grid. (requires Professional or Developer Upgrade)', 'mybooktable'),\n default: false,\n },\n {\n name: 'show_header',\n type: 'checkbox',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Show Header?', 'mybooktable'),\n description: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Shows the taxonomy title and description above the book listing', 'mybooktable'),\n default: true,\n },\n {\n name: 'max_books',\n type: 'number',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Max Books to Display', 'mybooktable'),\n description: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Sets the maximum number of books that will be shown (Leave blank for no maximum)', 'mybooktable'),\n default: '',\n },\n ],\n },\n ],\n toShortcode: attributes => {\n const header = attributes.show_header ? '' : ' header=\"hidden\"';\n const gridview = attributes.gridview ? ' gridview=\"true\"' : '';\n const maxBooks = attributes.max_books ? ` max_books=\"${attributes.max_books}\"` : '';\n return `[mybooktable${header}${gridview}${maxBooks}]`;\n },\n});\nfunction registerTaxonomyShortcodeBlock(options) {\n Object(_shortcodes__WEBPACK_IMPORTED_MODULE_5__[\"registerShortcodeBlock\"])({\n name: `book-${options.taxonomy}`,\n title: options.title,\n icon: options.icon,\n description: options.description,\n data: _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_3___default()({ path: Object(_wordpress_url__WEBPACK_IMPORTED_MODULE_2__[\"addQueryArgs\"])(`/wp/v2/mbt_${options.taxonomy}`, { per_page: -1 }) }),\n preview: (attributes, data, edit) => {\n const term = data ? lodash__WEBPACK_IMPORTED_MODULE_0___default.a.find(data, { slug: attributes[options.taxonomy] }) : null;\n return wp.element.createElement(\"div\", { className: \"attribute\" },\n wp.element.createElement(\"span\", { className: \"name\" }, options.singular),\n term ? wp.element.createElement(\"span\", { className: \"value\", onClick: edit }, term.name) : wp.element.createElement(\"span\", { className: \"no-value\" }, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('None', 'mybooktable')));\n },\n attributes: [\n {\n name: options.taxonomy,\n type: 'dropdown',\n title: options.singular,\n choices: (attributes, data) => data ? data.map(term => ({ label: term.name, value: term.slug })) : [],\n default: '',\n },\n ],\n inspectorAttributes: [\n {\n name: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Display Settings', 'mybooktable'),\n attributes: [\n {\n name: 'gridview',\n type: 'checkbox',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Force Grid View Display?', 'mybooktable'),\n description: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Shows book covers in a responsive grid. (requires Professional or Developer Upgrade)', 'mybooktable'),\n default: false,\n },\n {\n name: 'show_header',\n type: 'checkbox',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Show Header?', 'mybooktable'),\n description: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Shows the taxonomy title and description above the book listing', 'mybooktable'),\n default: true,\n },\n {\n name: 'max_books',\n type: 'number',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Max Books to Display', 'mybooktable'),\n description: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Sets the maximum number of books that will be shown (Leave blank for no maximum)', 'mybooktable'),\n default: '',\n },\n ],\n },\n ],\n toShortcode: attributes => {\n if (!attributes[options.taxonomy]) {\n return '';\n }\n const header = attributes.show_header ? '' : ' header=\"hidden\"';\n const gridview = attributes.gridview ? ' gridview=\"true\"' : '';\n const maxBooks = attributes.max_books ? ` max_books=\"${attributes.max_books}\"` : '';\n return `[mybooktable ${options.taxonomy}=\"${attributes[options.taxonomy]}\"${header}${gridview}${maxBooks}]`;\n },\n });\n}\nregisterTaxonomyShortcodeBlock({\n taxonomy: 'series',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])(`All Books in Series`, 'mybooktable'),\n description: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])(`List all the books in a given series in an embedded book listing.`, 'mybooktable'),\n singular: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])(`Series`, 'mybooktable'),\n icon: 'admin-page',\n});\nregisterTaxonomyShortcodeBlock({\n taxonomy: 'genre',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])(`All Books in Genre`, 'mybooktable'),\n description: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])(`List all the books in a given genre in an embedded book listing.`, 'mybooktable'),\n singular: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])(`Genre`, 'mybooktable'),\n icon: 'category',\n});\nregisterTaxonomyShortcodeBlock({\n taxonomy: 'tag',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])(`All Books with Tag`, 'mybooktable'),\n description: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])(`List all the books with a given tag in an embedded book listing.`, 'mybooktable'),\n singular: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])(`Tag`, 'mybooktable'),\n icon: 'tag',\n});\nregisterTaxonomyShortcodeBlock({\n taxonomy: 'author',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])(`All Books by Author`, 'mybooktable'),\n description: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])(`List all the books written by a given author in an embedded book listing.`, 'mybooktable'),\n singular: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])(`Author`, 'mybooktable'),\n icon: 'admin-users',\n});\nObject(_shortcodes__WEBPACK_IMPORTED_MODULE_5__[\"registerShortcodeBlock\"])({\n name: 'single-book',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Single Book', 'mybooktable'),\n icon: 'book-alt',\n description: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Show a given book in an embedded book listing.', 'mybooktable'),\n data: _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_3___default()({ path: Object(_wordpress_url__WEBPACK_IMPORTED_MODULE_2__[\"addQueryArgs\"])('/wp/v2/mbt_book', { per_page: -1 }) }),\n preview: (attributes, data, edit) => {\n const book = data ? lodash__WEBPACK_IMPORTED_MODULE_0___default.a.find(data, { slug: attributes.book }) : null;\n return wp.element.createElement(\"div\", { className: \"attribute\" },\n wp.element.createElement(\"span\", { className: \"name\" }, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Book', 'mybooktable')),\n book ? wp.element.createElement(\"span\", { className: \"value\", onClick: edit }, book.title.rendered) : wp.element.createElement(\"span\", { className: \"no-value\" }, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('None', 'mybooktable')));\n },\n attributes: [\n {\n name: 'book',\n type: 'dropdown',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Book', 'mybooktable'),\n choices: (attributes, data) => data ? data.map(book => ({ label: book.title.rendered, value: book.slug })) : [],\n default: '',\n },\n ],\n inspectorAttributes: [\n {\n name: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Display Settings', 'mybooktable'),\n attributes: [\n {\n name: 'display',\n type: 'dropdown',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Display Style', 'mybooktable'),\n choices: [\n { label: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Default', 'mybooktable'), value: 'default' },\n { label: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Summary', 'mybooktable'), value: 'summary' },\n { label: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Buy Buttons', 'mybooktable'), value: 'buybuttons' },\n { label: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Cover and Buy Buttons', 'mybooktable'), value: 'cover+buybuttons' },\n ],\n noEmptyOption: true,\n default: 'default',\n },\n {\n name: 'buybutton_shadowbox',\n type: 'checkbox',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Force Shadow Box for Buy Buttons?', 'mybooktable'),\n default: false,\n },\n ],\n },\n ],\n toShortcode: attributes => {\n if (!attributes.book) {\n return '';\n }\n const display = attributes.display !== 'default' ? ` display=\"${attributes.display}\"` : '';\n const buybuttonShadowbox = attributes.buybutton_shadowbox ? ' buybutton_shadowbox=\"true\"' : '';\n return `[mybooktable book=\"${attributes.book}\"${display}${buybuttonShadowbox}]`;\n },\n});\nObject(_shortcodes__WEBPACK_IMPORTED_MODULE_5__[\"registerShortcodeBlock\"])({\n name: 'term-list',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('All Terms in Taxonomy', 'mybooktable'),\n icon: 'list-view',\n description: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('This allows you to display all of the different items in a MyBookTable taxonomy.', 'mybooktable'),\n preview: (attributes, data, edit) => {\n return wp.element.createElement(\"div\", { className: \"attribute\" },\n wp.element.createElement(\"span\", { className: \"name\" }, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Taxonomy', 'mybooktable')),\n attributes.taxonomy ? wp.element.createElement(\"span\", { className: \"value\", onClick: edit }, Object(_utils__WEBPACK_IMPORTED_MODULE_4__[\"capitalize\"])(attributes.taxonomy)) : wp.element.createElement(\"span\", { className: \"no-value\" }, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('None', 'mybooktable')));\n },\n attributes: [\n {\n name: 'taxonomy',\n type: 'dropdown',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Taxonomy', 'mybooktable'),\n choices: [\n { label: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Series', 'mybooktable'), value: 'series' },\n { label: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Genres', 'mybooktable'), value: 'genres' },\n { label: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Tags', 'mybooktable'), value: 'tags' },\n { label: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Authors', 'mybooktable'), value: 'authors' },\n ],\n default: '',\n },\n ],\n inspectorAttributes: [\n {\n name: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Display Settings', 'mybooktable'),\n attributes: [\n {\n name: 'display',\n type: 'dropdown',\n title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Display Style', 'mybooktable'),\n choices: [\n { label: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Listing', 'mybooktable'), value: 'listing' },\n { label: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Menu Bar', 'mybooktable'), value: 'bar' },\n { label: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Simple', 'mybooktable'), value: 'simple' },\n ],\n noEmptyOption: true,\n default: 'listing',\n },\n ],\n },\n ],\n toShortcode: attributes => {\n if (!attributes.taxonomy) {\n return '';\n }\n return `[mybooktable list=\"${attributes.taxonomy}\" display=\"${attributes.display}\"]`;\n },\n});\n\n\n//# sourceURL=webpack:///./src/blocks/index.tsx?");
109
110 /***/ }),
111
112 /***/ "./src/blocks/shortcodes.tsx":
113 /*!***********************************!*\
114 !*** ./src/blocks/shortcodes.tsx ***!
115 \***********************************/
116 /*! exports provided: registerShortcodeBlock */
117 /***/ (function(module, __webpack_exports__, __webpack_require__) {
118
119 "use strict";
120 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"registerShortcodeBlock\", function() { return registerShortcodeBlock; });\n/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash */ \"lodash\");\n/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ \"@wordpress/i18n\");\n/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/blocks */ \"@wordpress/blocks\");\n/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blocks__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _wordpress_editor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/editor */ \"@wordpress/editor\");\n/* harmony import */ var _wordpress_editor__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_editor__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/element */ \"@wordpress/element\");\n/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/components */ \"@wordpress/components\");\n/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./utils */ \"./src/blocks/utils.tsx\");\n/* harmony import */ var _index_scss__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./index.scss */ \"./src/blocks/index.scss\");\n/* harmony import */ var _index_scss__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_index_scss__WEBPACK_IMPORTED_MODULE_7__);\n\n\n\n\n\n\n\n\nclass ShortcodeBlockEditor extends _wordpress_element__WEBPACK_IMPORTED_MODULE_4__[\"Component\"] {\n constructor(props) {\n super(props);\n this.state = {\n loading: false,\n data: null,\n };\n this.toggleEdit = this.toggleEdit.bind(this);\n this.attributeChange = lodash__WEBPACK_IMPORTED_MODULE_0___default.a.memoize(this.attributeChange.bind(this));\n this.renderAttribute = this.renderAttribute.bind(this);\n }\n componentDidMount() {\n if (this.props.options.data) {\n this.setState({ loading: true });\n this.props.options.data.then(data => this.setState({ data, loading: false }));\n }\n }\n toggleEdit() {\n this.props.setAttributes({ editMode: !this.props.attributes.editMode });\n }\n attributeChange(attribute) {\n if (attribute.type === 'checkbox') {\n return () => this.props.setAttributes({ [attribute.name]: !this.props.attributes[attribute.name] });\n }\n else if (attribute.type === 'number') {\n return (value) => {\n const numberValue = Math.floor(Number(value));\n return this.props.setAttributes({ [attribute.name]: numberValue <= 0 ? '' : numberValue.toString() });\n };\n }\n else {\n return (value) => this.props.setAttributes({ [attribute.name]: value });\n }\n }\n renderAttribute(attribute) {\n const { attributes } = this.props;\n const { data } = this.state;\n if (attribute.type === 'dropdown') {\n const choices = lodash__WEBPACK_IMPORTED_MODULE_0___default.a.isFunction(attribute.choices) ? attribute.choices(attributes, data) : attribute.choices;\n return wp.element.createElement(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__[\"SelectControl\"], { key: attribute.name, label: attribute.title, help: attribute.description, value: attributes[attribute.name], options: (attribute.noEmptyOption ? [] : [{ label: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('-- Choose One --', 'mybooktable'), value: '' }]).concat(choices), onChange: this.attributeChange(attribute) });\n }\n else if (attribute.type === 'checkbox') {\n return wp.element.createElement(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__[\"ToggleControl\"], { key: attribute.name, label: attribute.title, help: attribute.description, checked: attributes[attribute.name], onChange: this.attributeChange(attribute) });\n }\n else if (attribute.type === 'radio') {\n return wp.element.createElement(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__[\"RadioControl\"], { key: attribute.name, label: attribute.title, help: attribute.description, value: attributes[attribute.name], options: attribute.choices, onChange: this.attributeChange(attribute) });\n }\n else if (attribute.type === 'textarea') {\n return wp.element.createElement(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__[\"TextareaControl\"], { key: attribute.name, label: attribute.title, help: attribute.description, value: attributes[attribute.name], onChange: this.attributeChange(attribute) });\n }\n else if (attribute.type === 'text') {\n return wp.element.createElement(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__[\"TextControl\"], { key: attribute.name, label: attribute.title, help: attribute.description, value: attributes[attribute.name], onChange: this.attributeChange(attribute) });\n }\n else if (attribute.type === 'number') {\n return wp.element.createElement(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__[\"TextControl\"], { key: attribute.name, label: attribute.title, help: attribute.description, type: \"number\", value: attributes[attribute.name], onChange: this.attributeChange(attribute) });\n }\n return Object(_utils__WEBPACK_IMPORTED_MODULE_6__[\"assertNever\"])(attribute);\n }\n render() {\n const { attributes, options } = this.props;\n const { loading, data } = this.state;\n return wp.element.createElement(_wordpress_element__WEBPACK_IMPORTED_MODULE_4__[\"Fragment\"], null,\n options.attributes && wp.element.createElement(_wordpress_editor__WEBPACK_IMPORTED_MODULE_3__[\"BlockControls\"], null,\n wp.element.createElement(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__[\"Toolbar\"], { controls: [{ icon: 'edit', title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Edit'), onClick: this.toggleEdit, isActive: attributes.editMode }] })),\n options.inspectorAttributes && wp.element.createElement(_wordpress_editor__WEBPACK_IMPORTED_MODULE_3__[\"InspectorControls\"], null, options.inspectorAttributes.map(section => wp.element.createElement(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__[\"PanelBody\"], { title: section.name, key: section.name }, section.attributes.map(this.renderAttribute)))),\n wp.element.createElement(\"div\", { className: `mbt-shortcode-block-editor ${options.name}` },\n wp.element.createElement(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__[\"Placeholder\"], null,\n wp.element.createElement(\"div\", { className: \"header\" },\n wp.element.createElement(\"div\", { className: \"logo\" }),\n wp.element.createElement(\"div\", null,\n wp.element.createElement(\"h2\", null, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('MyBookTable', 'mybooktable')),\n wp.element.createElement(\"h1\", null, options.title))),\n attributes.editMode && options.attributes && wp.element.createElement(_wordpress_element__WEBPACK_IMPORTED_MODULE_4__[\"Fragment\"], null,\n wp.element.createElement(\"div\", { className: \"description\" }, options.description),\n wp.element.createElement(\"div\", { className: \"attributes\" }, loading ? wp.element.createElement(\"div\", { className: \"spinner-holder\" },\n wp.element.createElement(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__[\"Spinner\"], null)) : options.attributes.map(this.renderAttribute)),\n wp.element.createElement(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__[\"Button\"], { isDefault: true, onClick: this.toggleEdit }, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('Done', 'mybooktable'))),\n !attributes.editMode && options.preview && wp.element.createElement(\"div\", { className: \"preview\" }, options.preview(attributes, data, this.toggleEdit)))));\n }\n}\nfunction getAttributeDataType(attribute) {\n if (attribute.type === 'dropdown') {\n return 'string';\n }\n else if (attribute.type === 'checkbox') {\n return 'boolean';\n }\n else if (attribute.type === 'radio') {\n return 'string';\n }\n else if (attribute.type === 'textarea') {\n return 'string';\n }\n else if (attribute.type === 'text') {\n return 'string';\n }\n else if (attribute.type === 'number') {\n return 'string';\n }\n return Object(_utils__WEBPACK_IMPORTED_MODULE_6__[\"assertNever\"])(attribute);\n}\nfunction registerShortcodeBlock(options) {\n const attributes = lodash__WEBPACK_IMPORTED_MODULE_0___default.a.flatten((options.inspectorAttributes || []).map(section => section.attributes)).concat(options.attributes || []);\n Object(_wordpress_blocks__WEBPACK_IMPORTED_MODULE_2__[\"registerBlockType\"])('mybooktable/' + options.name, {\n title: options.title,\n icon: options.icon,\n category: 'mybooktable',\n keywords: [Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__[\"__\"])('MyBookTable', 'mybooktable')],\n description: options.description,\n attributes: lodash__WEBPACK_IMPORTED_MODULE_0___default.a.assign(lodash__WEBPACK_IMPORTED_MODULE_0___default.a.fromPairs(attributes.map(attribute => [attribute.name, { type: getAttributeDataType(attribute), default: attribute.default }])), { editMode: { type: 'boolean', default: true } }),\n edit: (props) => wp.element.createElement(ShortcodeBlockEditor, { attributes: props.attributes, setAttributes: props.setAttributes, options: options }),\n save: (props) => wp.element.createElement(_wordpress_element__WEBPACK_IMPORTED_MODULE_4__[\"RawHTML\"], null, options.toShortcode(props.attributes)),\n });\n}\n\n\n//# sourceURL=webpack:///./src/blocks/shortcodes.tsx?");
121
122 /***/ }),
123
124 /***/ "./src/blocks/utils.tsx":
125 /*!******************************!*\
126 !*** ./src/blocks/utils.tsx ***!
127 \******************************/
128 /*! exports provided: assertNever, capitalize */
129 /***/ (function(module, __webpack_exports__, __webpack_require__) {
130
131 "use strict";
132 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"assertNever\", function() { return assertNever; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"capitalize\", function() { return capitalize; });\nfunction assertNever(value) {\n throw new Error(`Unexpected value ${value}`);\n}\nfunction capitalize(str) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n\n//# sourceURL=webpack:///./src/blocks/utils.tsx?");
133
134 /***/ }),
135
136 /***/ "@wordpress/api-fetch":
137 /*!******************************!*\
138 !*** external "wp.apiFetch" ***!
139 \******************************/
140 /*! no static exports found */
141 /***/ (function(module, exports) {
142
143 eval("module.exports = wp.apiFetch;\n\n//# sourceURL=webpack:///external_%22wp.apiFetch%22?");
144
145 /***/ }),
146
147 /***/ "@wordpress/blocks":
148 /*!****************************!*\
149 !*** external "wp.blocks" ***!
150 \****************************/
151 /*! no static exports found */
152 /***/ (function(module, exports) {
153
154 eval("module.exports = wp.blocks;\n\n//# sourceURL=webpack:///external_%22wp.blocks%22?");
155
156 /***/ }),
157
158 /***/ "@wordpress/components":
159 /*!********************************!*\
160 !*** external "wp.components" ***!
161 \********************************/
162 /*! no static exports found */
163 /***/ (function(module, exports) {
164
165 eval("module.exports = wp.components;\n\n//# sourceURL=webpack:///external_%22wp.components%22?");
166
167 /***/ }),
168
169 /***/ "@wordpress/editor":
170 /*!****************************!*\
171 !*** external "wp.editor" ***!
172 \****************************/
173 /*! no static exports found */
174 /***/ (function(module, exports) {
175
176 eval("module.exports = wp.editor;\n\n//# sourceURL=webpack:///external_%22wp.editor%22?");
177
178 /***/ }),
179
180 /***/ "@wordpress/element":
181 /*!*****************************!*\
182 !*** external "wp.element" ***!
183 \*****************************/
184 /*! no static exports found */
185 /***/ (function(module, exports) {
186
187 eval("module.exports = wp.element;\n\n//# sourceURL=webpack:///external_%22wp.element%22?");
188
189 /***/ }),
190
191 /***/ "@wordpress/i18n":
192 /*!**************************!*\
193 !*** external "wp.i18n" ***!
194 \**************************/
195 /*! no static exports found */
196 /***/ (function(module, exports) {
197
198 eval("module.exports = wp.i18n;\n\n//# sourceURL=webpack:///external_%22wp.i18n%22?");
199
200 /***/ }),
201
202 /***/ "@wordpress/url":
203 /*!*************************!*\
204 !*** external "wp.url" ***!
205 \*************************/
206 /*! no static exports found */
207 /***/ (function(module, exports) {
208
209 eval("module.exports = wp.url;\n\n//# sourceURL=webpack:///external_%22wp.url%22?");
210
211 /***/ }),
212
213 /***/ "lodash":
214 /*!*************************!*\
215 !*** external "lodash" ***!
216 \*************************/
217 /*! no static exports found */
218 /***/ (function(module, exports) {
219
220 eval("module.exports = lodash;\n\n//# sourceURL=webpack:///external_%22lodash%22?");
221
222 /***/ })
223
224 /******/ });