@wordpress/list-reusable-blocks 5.31.1-next.f56bd8138.0 → 5.32.1-next.47f435fc9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,36 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var file_exports = {};
19
+ __export(file_exports, {
20
+ readTextFile: () => readTextFile
5
21
  });
6
- exports.readTextFile = readTextFile;
7
- /**
8
- * Reads the textual content of the given file.
9
- *
10
- * @param {File} file File.
11
- * @return {Promise<string>} Content of the file.
12
- */
22
+ module.exports = __toCommonJS(file_exports);
13
23
  function readTextFile(file) {
14
24
  const reader = new window.FileReader();
15
- return new Promise(resolve => {
25
+ return new Promise((resolve) => {
16
26
  reader.onload = () => {
17
27
  resolve(reader.result);
18
28
  };
19
29
  reader.readAsText(file);
20
30
  });
21
31
  }
22
- //# sourceMappingURL=file.js.map
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ readTextFile
35
+ });
36
+ //# sourceMappingURL=file.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["readTextFile","file","reader","window","FileReader","Promise","resolve","onload","result","readAsText"],"sources":["@wordpress/list-reusable-blocks/src/utils/file.js"],"sourcesContent":["/**\n * Reads the textual content of the given file.\n *\n * @param {File} file File.\n * @return {Promise<string>} Content of the file.\n */\nexport function readTextFile( file ) {\n\tconst reader = new window.FileReader();\n\treturn new Promise( ( resolve ) => {\n\t\treader.onload = () => {\n\t\t\tresolve( reader.result );\n\t\t};\n\t\treader.readAsText( file );\n\t} );\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAYA,CAAEC,IAAI,EAAG;EACpC,MAAMC,MAAM,GAAG,IAAIC,MAAM,CAACC,UAAU,CAAC,CAAC;EACtC,OAAO,IAAIC,OAAO,CAAIC,OAAO,IAAM;IAClCJ,MAAM,CAACK,MAAM,GAAG,MAAM;MACrBD,OAAO,CAAEJ,MAAM,CAACM,MAAO,CAAC;IACzB,CAAC;IACDN,MAAM,CAACO,UAAU,CAAER,IAAK,CAAC;EAC1B,CAAE,CAAC;AACJ","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/file.js"],
4
+ "sourcesContent": ["/**\n * Reads the textual content of the given file.\n *\n * @param {File} file File.\n * @return {Promise<string>} Content of the file.\n */\nexport function readTextFile( file ) {\n\tconst reader = new window.FileReader();\n\treturn new Promise( ( resolve ) => {\n\t\treader.onload = () => {\n\t\t\tresolve( reader.result );\n\t\t};\n\t\treader.readAsText( file );\n\t} );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,SAAS,aAAc,MAAO;AACpC,QAAM,SAAS,IAAI,OAAO,WAAW;AACrC,SAAO,IAAI,QAAS,CAAE,YAAa;AAClC,WAAO,SAAS,MAAM;AACrB,cAAS,OAAO,MAAO;AAAA,IACxB;AACA,WAAO,WAAY,IAAK;AAAA,EACzB,CAAE;AACH;",
6
+ "names": []
7
+ }
@@ -1,53 +1,60 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var import_exports = {};
29
+ __export(import_exports, {
30
+ default: () => import_default
6
31
  });
7
- exports.default = void 0;
8
- var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
9
- var _file = require("./file");
10
- /**
11
- * WordPress dependencies
12
- */
13
-
14
- /**
15
- * Internal dependencies
16
- */
17
-
18
- /**
19
- * Import a reusable block from a JSON file.
20
- *
21
- * @param {File} file File.
22
- * @return {Promise} Promise returning the imported reusable block.
23
- */
32
+ module.exports = __toCommonJS(import_exports);
33
+ var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
34
+ var import_file = require("./file");
24
35
  async function importReusableBlock(file) {
25
- const fileContent = await (0, _file.readTextFile)(file);
36
+ const fileContent = await (0, import_file.readTextFile)(file);
26
37
  let parsedContent;
27
38
  try {
28
39
  parsedContent = JSON.parse(fileContent);
29
40
  } catch (e) {
30
- throw new Error('Invalid JSON file');
41
+ throw new Error("Invalid JSON file");
31
42
  }
32
- if (parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || typeof parsedContent.title !== 'string' || typeof parsedContent.content !== 'string' || parsedContent.syncStatus && typeof parsedContent.syncStatus !== 'string') {
33
- throw new Error('Invalid pattern JSON file');
43
+ if (parsedContent.__file !== "wp_block" || !parsedContent.title || !parsedContent.content || typeof parsedContent.title !== "string" || typeof parsedContent.content !== "string" || parsedContent.syncStatus && typeof parsedContent.syncStatus !== "string") {
44
+ throw new Error("Invalid pattern JSON file");
34
45
  }
35
- const postType = await (0, _apiFetch.default)({
36
- path: `/wp/v2/types/wp_block`
37
- });
38
- const reusableBlock = await (0, _apiFetch.default)({
46
+ const postType = await (0, import_api_fetch.default)({ path: `/wp/v2/types/wp_block` });
47
+ const reusableBlock = await (0, import_api_fetch.default)({
39
48
  path: `/wp/v2/${postType.rest_base}`,
40
49
  data: {
41
50
  title: parsedContent.title,
42
51
  content: parsedContent.content,
43
- status: 'publish',
44
- meta: parsedContent.syncStatus === 'unsynced' ? {
45
- wp_pattern_sync_status: parsedContent.syncStatus
46
- } : undefined
52
+ status: "publish",
53
+ meta: parsedContent.syncStatus === "unsynced" ? { wp_pattern_sync_status: parsedContent.syncStatus } : void 0
47
54
  },
48
- method: 'POST'
55
+ method: "POST"
49
56
  });
50
57
  return reusableBlock;
51
58
  }
52
- var _default = exports.default = importReusableBlock;
53
- //# sourceMappingURL=import.js.map
59
+ var import_default = importReusableBlock;
60
+ //# sourceMappingURL=import.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_apiFetch","_interopRequireDefault","require","_file","importReusableBlock","file","fileContent","readTextFile","parsedContent","JSON","parse","e","Error","__file","title","content","syncStatus","postType","apiFetch","path","reusableBlock","rest_base","data","status","meta","wp_pattern_sync_status","undefined","method","_default","exports","default"],"sources":["@wordpress/list-reusable-blocks/src/utils/import.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { readTextFile } from './file';\n\n/**\n * Import a reusable block from a JSON file.\n *\n * @param {File} file File.\n * @return {Promise} Promise returning the imported reusable block.\n */\nasync function importReusableBlock( file ) {\n\tconst fileContent = await readTextFile( file );\n\tlet parsedContent;\n\ttry {\n\t\tparsedContent = JSON.parse( fileContent );\n\t} catch ( e ) {\n\t\tthrow new Error( 'Invalid JSON file' );\n\t}\n\tif (\n\t\tparsedContent.__file !== 'wp_block' ||\n\t\t! parsedContent.title ||\n\t\t! parsedContent.content ||\n\t\ttypeof parsedContent.title !== 'string' ||\n\t\ttypeof parsedContent.content !== 'string' ||\n\t\t( parsedContent.syncStatus &&\n\t\t\ttypeof parsedContent.syncStatus !== 'string' )\n\t) {\n\t\tthrow new Error( 'Invalid pattern JSON file' );\n\t}\n\tconst postType = await apiFetch( { path: `/wp/v2/types/wp_block` } );\n\tconst reusableBlock = await apiFetch( {\n\t\tpath: `/wp/v2/${ postType.rest_base }`,\n\t\tdata: {\n\t\t\ttitle: parsedContent.title,\n\t\t\tcontent: parsedContent.content,\n\t\t\tstatus: 'publish',\n\t\t\tmeta:\n\t\t\t\tparsedContent.syncStatus === 'unsynced'\n\t\t\t\t\t? { wp_pattern_sync_status: parsedContent.syncStatus }\n\t\t\t\t\t: undefined,\n\t\t},\n\t\tmethod: 'POST',\n\t} );\n\n\treturn reusableBlock;\n}\n\nexport default importReusableBlock;\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;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"version": 3,
3
+ "sources": ["../../src/utils/import.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { readTextFile } from './file';\n\n/**\n * Import a reusable block from a JSON file.\n *\n * @param {File} file File.\n * @return {Promise} Promise returning the imported reusable block.\n */\nasync function importReusableBlock( file ) {\n\tconst fileContent = await readTextFile( file );\n\tlet parsedContent;\n\ttry {\n\t\tparsedContent = JSON.parse( fileContent );\n\t} catch ( e ) {\n\t\tthrow new Error( 'Invalid JSON file' );\n\t}\n\tif (\n\t\tparsedContent.__file !== 'wp_block' ||\n\t\t! parsedContent.title ||\n\t\t! parsedContent.content ||\n\t\ttypeof parsedContent.title !== 'string' ||\n\t\ttypeof parsedContent.content !== 'string' ||\n\t\t( parsedContent.syncStatus &&\n\t\t\ttypeof parsedContent.syncStatus !== 'string' )\n\t) {\n\t\tthrow new Error( 'Invalid pattern JSON file' );\n\t}\n\tconst postType = await apiFetch( { path: `/wp/v2/types/wp_block` } );\n\tconst reusableBlock = await apiFetch( {\n\t\tpath: `/wp/v2/${ postType.rest_base }`,\n\t\tdata: {\n\t\t\ttitle: parsedContent.title,\n\t\t\tcontent: parsedContent.content,\n\t\t\tstatus: 'publish',\n\t\t\tmeta:\n\t\t\t\tparsedContent.syncStatus === 'unsynced'\n\t\t\t\t\t? { wp_pattern_sync_status: parsedContent.syncStatus }\n\t\t\t\t\t: undefined,\n\t\t},\n\t\tmethod: 'POST',\n\t} );\n\n\treturn reusableBlock;\n}\n\nexport default importReusableBlock;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAqB;AAKrB,kBAA6B;AAQ7B,eAAe,oBAAqB,MAAO;AAC1C,QAAM,cAAc,UAAM,0BAAc,IAAK;AAC7C,MAAI;AACJ,MAAI;AACH,oBAAgB,KAAK,MAAO,WAAY;AAAA,EACzC,SAAU,GAAI;AACb,UAAM,IAAI,MAAO,mBAAoB;AAAA,EACtC;AACA,MACC,cAAc,WAAW,cACzB,CAAE,cAAc,SAChB,CAAE,cAAc,WAChB,OAAO,cAAc,UAAU,YAC/B,OAAO,cAAc,YAAY,YAC/B,cAAc,cACf,OAAO,cAAc,eAAe,UACpC;AACD,UAAM,IAAI,MAAO,2BAA4B;AAAA,EAC9C;AACA,QAAM,WAAW,UAAM,iBAAAA,SAAU,EAAE,MAAM,wBAAwB,CAAE;AACnE,QAAM,gBAAgB,UAAM,iBAAAA,SAAU;AAAA,IACrC,MAAM,UAAW,SAAS,SAAU;AAAA,IACpC,MAAM;AAAA,MACL,OAAO,cAAc;AAAA,MACrB,SAAS,cAAc;AAAA,MACvB,QAAQ;AAAA,MACR,MACC,cAAc,eAAe,aAC1B,EAAE,wBAAwB,cAAc,WAAW,IACnD;AAAA,IACL;AAAA,IACA,QAAQ;AAAA,EACT,CAAE;AAEF,SAAO;AACR;AAEA,IAAO,iBAAQ;",
6
+ "names": ["apiFetch"]
7
+ }
@@ -1,40 +1,31 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { pipe } from '@wordpress/compose';
5
- import { __ } from '@wordpress/i18n';
6
- import { Dropdown, Button } from '@wordpress/components';
7
-
8
- /**
9
- * Internal dependencies
10
- */
11
- import ImportForm from '../import-form';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- function ImportDropdown({
14
- onUpload
15
- }) {
16
- return /*#__PURE__*/_jsx(Dropdown, {
17
- popoverProps: {
18
- placement: 'bottom-start'
19
- },
20
- contentClassName: "list-reusable-blocks-import-dropdown__content",
21
- renderToggle: ({
22
- isOpen,
23
- onToggle
24
- }) => /*#__PURE__*/_jsx(Button, {
25
- size: "compact",
26
- className: "list-reusable-blocks-import-dropdown__button",
27
- "aria-expanded": isOpen,
28
- onClick: onToggle,
29
- variant: "primary",
30
- children: __('Import from JSON')
31
- }),
32
- renderContent: ({
33
- onClose
34
- }) => /*#__PURE__*/_jsx(ImportForm, {
35
- onUpload: pipe(onClose, onUpload)
36
- })
37
- });
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { pipe } from "@wordpress/compose";
3
+ import { __ } from "@wordpress/i18n";
4
+ import { Dropdown, Button } from "@wordpress/components";
5
+ import ImportForm from "../import-form";
6
+ function ImportDropdown({ onUpload }) {
7
+ return /* @__PURE__ */ jsx(
8
+ Dropdown,
9
+ {
10
+ popoverProps: { placement: "bottom-start" },
11
+ contentClassName: "list-reusable-blocks-import-dropdown__content",
12
+ renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ jsx(
13
+ Button,
14
+ {
15
+ size: "compact",
16
+ className: "list-reusable-blocks-import-dropdown__button",
17
+ "aria-expanded": isOpen,
18
+ onClick: onToggle,
19
+ variant: "primary",
20
+ children: __("Import from JSON")
21
+ }
22
+ ),
23
+ renderContent: ({ onClose }) => /* @__PURE__ */ jsx(ImportForm, { onUpload: pipe(onClose, onUpload) })
24
+ }
25
+ );
38
26
  }
39
- export default ImportDropdown;
40
- //# sourceMappingURL=index.js.map
27
+ var import_dropdown_default = ImportDropdown;
28
+ export {
29
+ import_dropdown_default as default
30
+ };
31
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["pipe","__","Dropdown","Button","ImportForm","jsx","_jsx","ImportDropdown","onUpload","popoverProps","placement","contentClassName","renderToggle","isOpen","onToggle","size","className","onClick","variant","children","renderContent","onClose"],"sources":["@wordpress/list-reusable-blocks/src/components/import-dropdown/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { pipe } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport ImportForm from '../import-form';\n\nfunction ImportDropdown( { onUpload } ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\tcontentClassName=\"list-reusable-blocks-import-dropdown__content\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tclassName=\"list-reusable-blocks-import-dropdown__button\"\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Import from JSON' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<ImportForm onUpload={ pipe( onClose, onUpload ) } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default ImportDropdown;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,oBAAoB;AACzC,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,MAAM,QAAQ,uBAAuB;;AAExD;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAExC,SAASC,cAAcA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACvC,oBACCF,IAAA,CAACJ,QAAQ;IACRO,YAAY,EAAG;MAAEC,SAAS,EAAE;IAAe,CAAG;IAC9CC,gBAAgB,EAAC,+CAA+C;IAChEC,YAAY,EAAGA,CAAE;MAAEC,MAAM;MAAEC;IAAS,CAAC,kBACpCR,IAAA,CAACH,MAAM;MACNY,IAAI,EAAC,SAAS;MACdC,SAAS,EAAC,8CAA8C;MACxD,iBAAgBH,MAAQ;MACxBI,OAAO,EAAGH,QAAU;MACpBI,OAAO,EAAC,SAAS;MAAAC,QAAA,EAEflB,EAAE,CAAE,kBAAmB;IAAC,CACnB,CACN;IACHmB,aAAa,EAAGA,CAAE;MAAEC;IAAQ,CAAC,kBAC5Bf,IAAA,CAACF,UAAU;MAACI,QAAQ,EAAGR,IAAI,CAAEqB,OAAO,EAAEb,QAAS;IAAG,CAAE;EAClD,CACH,CAAC;AAEJ;AAEA,eAAeD,cAAc","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/import-dropdown/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { pipe } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport ImportForm from '../import-form';\n\nfunction ImportDropdown( { onUpload } ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\tcontentClassName=\"list-reusable-blocks-import-dropdown__content\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tclassName=\"list-reusable-blocks-import-dropdown__button\"\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Import from JSON' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<ImportForm onUpload={ pipe( onClose, onUpload ) } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default ImportDropdown;\n"],
5
+ "mappings": "AAkBI;AAfJ,SAAS,YAAY;AACrB,SAAS,UAAU;AACnB,SAAS,UAAU,cAAc;AAKjC,OAAO,gBAAgB;AAEvB,SAAS,eAAgB,EAAE,SAAS,GAAI;AACvC,SACC;AAAA,IAAC;AAAA;AAAA,MACA,cAAe,EAAE,WAAW,eAAe;AAAA,MAC3C,kBAAiB;AAAA,MACjB,cAAe,CAAE,EAAE,QAAQ,SAAS,MACnC;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,WAAU;AAAA,UACV,iBAAgB;AAAA,UAChB,SAAU;AAAA,UACV,SAAQ;AAAA,UAEN,aAAI,kBAAmB;AAAA;AAAA,MAC1B;AAAA,MAED,eAAgB,CAAE,EAAE,QAAQ,MAC3B,oBAAC,cAAW,UAAW,KAAM,SAAS,QAAS,GAAI;AAAA;AAAA,EAErD;AAEF;AAEA,IAAO,0BAAQ;",
6
+ "names": []
7
+ }
@@ -1,57 +1,45 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useState, useRef } from '@wordpress/element';
5
- import { withInstanceId } from '@wordpress/compose';
6
- import { __, _x } from '@wordpress/i18n';
7
- import { Button, Notice } from '@wordpress/components';
8
-
9
- /**
10
- * Internal dependencies
11
- */
12
- import importReusableBlock from '../../utils/import';
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- function ImportForm({
15
- instanceId,
16
- onUpload
17
- }) {
18
- const inputId = 'list-reusable-blocks-import-form-' + instanceId;
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState, useRef } from "@wordpress/element";
3
+ import { withInstanceId } from "@wordpress/compose";
4
+ import { __, _x } from "@wordpress/i18n";
5
+ import { Button, Notice } from "@wordpress/components";
6
+ import importReusableBlock from "../../utils/import";
7
+ function ImportForm({ instanceId, onUpload }) {
8
+ const inputId = "list-reusable-blocks-import-form-" + instanceId;
19
9
  const formRef = useRef();
20
10
  const [isLoading, setIsLoading] = useState(false);
21
11
  const [error, setError] = useState(null);
22
12
  const [file, setFile] = useState(null);
23
- const onChangeFile = event => {
13
+ const onChangeFile = (event) => {
24
14
  setFile(event.target.files[0]);
25
15
  setError(null);
26
16
  };
27
- const onSubmit = event => {
17
+ const onSubmit = (event) => {
28
18
  event.preventDefault();
29
19
  if (!file) {
30
20
  return;
31
21
  }
32
- setIsLoading({
33
- isLoading: true
34
- });
35
- importReusableBlock(file).then(reusableBlock => {
22
+ setIsLoading({ isLoading: true });
23
+ importReusableBlock(file).then((reusableBlock) => {
36
24
  if (!formRef) {
37
25
  return;
38
26
  }
39
27
  setIsLoading(false);
40
28
  onUpload(reusableBlock);
41
- }).catch(errors => {
29
+ }).catch((errors) => {
42
30
  if (!formRef) {
43
31
  return;
44
32
  }
45
33
  let uiMessage;
46
34
  switch (errors.message) {
47
- case 'Invalid JSON file':
48
- uiMessage = __('Invalid JSON file');
35
+ case "Invalid JSON file":
36
+ uiMessage = __("Invalid JSON file");
49
37
  break;
50
- case 'Invalid pattern JSON file':
51
- uiMessage = __('Invalid pattern JSON file');
38
+ case "Invalid pattern JSON file":
39
+ uiMessage = __("Invalid pattern JSON file");
52
40
  break;
53
41
  default:
54
- uiMessage = __('Unknown error');
42
+ uiMessage = __("Unknown error");
55
43
  }
56
44
  setIsLoading(false);
57
45
  setError(uiMessage);
@@ -60,33 +48,42 @@ function ImportForm({
60
48
  const onDismissError = () => {
61
49
  setError(null);
62
50
  };
63
- return /*#__PURE__*/_jsxs("form", {
64
- className: "list-reusable-blocks-import-form",
65
- onSubmit: onSubmit,
66
- ref: formRef,
67
- children: [error && /*#__PURE__*/_jsx(Notice, {
68
- status: "error",
69
- onRemove: () => onDismissError(),
70
- children: error
71
- }), /*#__PURE__*/_jsx("label", {
72
- htmlFor: inputId,
73
- className: "list-reusable-blocks-import-form__label",
74
- children: __('File')
75
- }), /*#__PURE__*/_jsx("input", {
76
- id: inputId,
77
- type: "file",
78
- onChange: onChangeFile
79
- }), /*#__PURE__*/_jsx(Button, {
80
- __next40pxDefaultSize: true,
81
- type: "submit",
82
- isBusy: isLoading,
83
- accessibleWhenDisabled: true,
84
- disabled: !file || isLoading,
85
- variant: "secondary",
86
- className: "list-reusable-blocks-import-form__button",
87
- children: _x('Import', 'button label')
88
- })]
89
- });
51
+ return /* @__PURE__ */ jsxs(
52
+ "form",
53
+ {
54
+ className: "list-reusable-blocks-import-form",
55
+ onSubmit,
56
+ ref: formRef,
57
+ children: [
58
+ error && /* @__PURE__ */ jsx(Notice, { status: "error", onRemove: () => onDismissError(), children: error }),
59
+ /* @__PURE__ */ jsx(
60
+ "label",
61
+ {
62
+ htmlFor: inputId,
63
+ className: "list-reusable-blocks-import-form__label",
64
+ children: __("File")
65
+ }
66
+ ),
67
+ /* @__PURE__ */ jsx("input", { id: inputId, type: "file", onChange: onChangeFile }),
68
+ /* @__PURE__ */ jsx(
69
+ Button,
70
+ {
71
+ __next40pxDefaultSize: true,
72
+ type: "submit",
73
+ isBusy: isLoading,
74
+ accessibleWhenDisabled: true,
75
+ disabled: !file || isLoading,
76
+ variant: "secondary",
77
+ className: "list-reusable-blocks-import-form__button",
78
+ children: _x("Import", "button label")
79
+ }
80
+ )
81
+ ]
82
+ }
83
+ );
90
84
  }
91
- export default withInstanceId(ImportForm);
92
- //# sourceMappingURL=index.js.map
85
+ var import_form_default = withInstanceId(ImportForm);
86
+ export {
87
+ import_form_default as default
88
+ };
89
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["useState","useRef","withInstanceId","__","_x","Button","Notice","importReusableBlock","jsx","_jsx","jsxs","_jsxs","ImportForm","instanceId","onUpload","inputId","formRef","isLoading","setIsLoading","error","setError","file","setFile","onChangeFile","event","target","files","onSubmit","preventDefault","then","reusableBlock","catch","errors","uiMessage","message","onDismissError","className","ref","children","status","onRemove","htmlFor","id","type","onChange","__next40pxDefaultSize","isBusy","accessibleWhenDisabled","disabled","variant"],"sources":["@wordpress/list-reusable-blocks/src/components/import-form/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useRef } from '@wordpress/element';\nimport { withInstanceId } from '@wordpress/compose';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, Notice } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport importReusableBlock from '../../utils/import';\n\nfunction ImportForm( { instanceId, onUpload } ) {\n\tconst inputId = 'list-reusable-blocks-import-form-' + instanceId;\n\n\tconst formRef = useRef();\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ error, setError ] = useState( null );\n\tconst [ file, setFile ] = useState( null );\n\n\tconst onChangeFile = ( event ) => {\n\t\tsetFile( event.target.files[ 0 ] );\n\t\tsetError( null );\n\t};\n\n\tconst onSubmit = ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( ! file ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsLoading( { isLoading: true } );\n\t\timportReusableBlock( file )\n\t\t\t.then( ( reusableBlock ) => {\n\t\t\t\tif ( ! formRef ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetIsLoading( false );\n\t\t\t\tonUpload( reusableBlock );\n\t\t\t} )\n\t\t\t.catch( ( errors ) => {\n\t\t\t\tif ( ! formRef ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet uiMessage;\n\t\t\t\tswitch ( errors.message ) {\n\t\t\t\t\tcase 'Invalid JSON file':\n\t\t\t\t\t\tuiMessage = __( 'Invalid JSON file' );\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Invalid pattern JSON file':\n\t\t\t\t\t\tuiMessage = __( 'Invalid pattern JSON file' );\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tuiMessage = __( 'Unknown error' );\n\t\t\t\t}\n\n\t\t\t\tsetIsLoading( false );\n\t\t\t\tsetError( uiMessage );\n\t\t\t} );\n\t};\n\n\tconst onDismissError = () => {\n\t\tsetError( null );\n\t};\n\n\treturn (\n\t\t<form\n\t\t\tclassName=\"list-reusable-blocks-import-form\"\n\t\t\tonSubmit={ onSubmit }\n\t\t\tref={ formRef }\n\t\t>\n\t\t\t{ error && (\n\t\t\t\t<Notice status=\"error\" onRemove={ () => onDismissError() }>\n\t\t\t\t\t{ error }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t\t<label\n\t\t\t\thtmlFor={ inputId }\n\t\t\t\tclassName=\"list-reusable-blocks-import-form__label\"\n\t\t\t>\n\t\t\t\t{ __( 'File' ) }\n\t\t\t</label>\n\t\t\t<input id={ inputId } type=\"file\" onChange={ onChangeFile } />\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\ttype=\"submit\"\n\t\t\t\tisBusy={ isLoading }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tdisabled={ ! file || isLoading }\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tclassName=\"list-reusable-blocks-import-form__button\"\n\t\t\t>\n\t\t\t\t{ _x( 'Import', 'button label' ) }\n\t\t\t</Button>\n\t\t</form>\n\t);\n}\n\nexport default withInstanceId( ImportForm );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,MAAM,QAAQ,oBAAoB;AACrD,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,MAAM,EAAEC,MAAM,QAAQ,uBAAuB;;AAEtD;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,oBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAErD,SAASC,UAAUA,CAAE;EAAEC,UAAU;EAAEC;AAAS,CAAC,EAAG;EAC/C,MAAMC,OAAO,GAAG,mCAAmC,GAAGF,UAAU;EAEhE,MAAMG,OAAO,GAAGf,MAAM,CAAC,CAAC;EACxB,MAAM,CAAEgB,SAAS,EAAEC,YAAY,CAAE,GAAGlB,QAAQ,CAAE,KAAM,CAAC;EACrD,MAAM,CAAEmB,KAAK,EAAEC,QAAQ,CAAE,GAAGpB,QAAQ,CAAE,IAAK,CAAC;EAC5C,MAAM,CAAEqB,IAAI,EAAEC,OAAO,CAAE,GAAGtB,QAAQ,CAAE,IAAK,CAAC;EAE1C,MAAMuB,YAAY,GAAKC,KAAK,IAAM;IACjCF,OAAO,CAAEE,KAAK,CAACC,MAAM,CAACC,KAAK,CAAE,CAAC,CAAG,CAAC;IAClCN,QAAQ,CAAE,IAAK,CAAC;EACjB,CAAC;EAED,MAAMO,QAAQ,GAAKH,KAAK,IAAM;IAC7BA,KAAK,CAACI,cAAc,CAAC,CAAC;IACtB,IAAK,CAAEP,IAAI,EAAG;MACb;IACD;IACAH,YAAY,CAAE;MAAED,SAA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CAAC,eAC9Dd,IAAA,CAACJ,MAAM;MACNwC,qBAAqB;MACrBF,IAAI,EAAC,QAAQ;MACbG,MAAM,EAAG7B,SAAW;MACpB8B,sBAAsB;MACtBC,QAAQ,EAAG,CAAE3B,IAAI,IAAIJ,SAAW;MAChCgC,OAAO,EAAC,WAAW;MACnBb,SAAS,EAAC,0CAA0C;MAAAE,QAAA,EAElDlC,EAAE,CAAE,QAAQ,EAAE,cAAe;IAAC,CACzB,CAAC;EAAA,CACJ,CAAC;AAET;AAEA,eAAeF,cAAc,CAAEU,UAAW,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/import-form/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useRef } from '@wordpress/element';\nimport { withInstanceId } from '@wordpress/compose';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, Notice } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport importReusableBlock from '../../utils/import';\n\nfunction ImportForm( { instanceId, onUpload } ) {\n\tconst inputId = 'list-reusable-blocks-import-form-' + instanceId;\n\n\tconst formRef = useRef();\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ error, setError ] = useState( null );\n\tconst [ file, setFile ] = useState( null );\n\n\tconst onChangeFile = ( event ) => {\n\t\tsetFile( event.target.files[ 0 ] );\n\t\tsetError( null );\n\t};\n\n\tconst onSubmit = ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( ! file ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsLoading( { isLoading: true } );\n\t\timportReusableBlock( file )\n\t\t\t.then( ( reusableBlock ) => {\n\t\t\t\tif ( ! formRef ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetIsLoading( false );\n\t\t\t\tonUpload( reusableBlock );\n\t\t\t} )\n\t\t\t.catch( ( errors ) => {\n\t\t\t\tif ( ! formRef ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet uiMessage;\n\t\t\t\tswitch ( errors.message ) {\n\t\t\t\t\tcase 'Invalid JSON file':\n\t\t\t\t\t\tuiMessage = __( 'Invalid JSON file' );\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Invalid pattern JSON file':\n\t\t\t\t\t\tuiMessage = __( 'Invalid pattern JSON file' );\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tuiMessage = __( 'Unknown error' );\n\t\t\t\t}\n\n\t\t\t\tsetIsLoading( false );\n\t\t\t\tsetError( uiMessage );\n\t\t\t} );\n\t};\n\n\tconst onDismissError = () => {\n\t\tsetError( null );\n\t};\n\n\treturn (\n\t\t<form\n\t\t\tclassName=\"list-reusable-blocks-import-form\"\n\t\t\tonSubmit={ onSubmit }\n\t\t\tref={ formRef }\n\t\t>\n\t\t\t{ error && (\n\t\t\t\t<Notice status=\"error\" onRemove={ () => onDismissError() }>\n\t\t\t\t\t{ error }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t\t<label\n\t\t\t\thtmlFor={ inputId }\n\t\t\t\tclassName=\"list-reusable-blocks-import-form__label\"\n\t\t\t>\n\t\t\t\t{ __( 'File' ) }\n\t\t\t</label>\n\t\t\t<input id={ inputId } type=\"file\" onChange={ onChangeFile } />\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\ttype=\"submit\"\n\t\t\t\tisBusy={ isLoading }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tdisabled={ ! file || isLoading }\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tclassName=\"list-reusable-blocks-import-form__button\"\n\t\t\t>\n\t\t\t\t{ _x( 'Import', 'button label' ) }\n\t\t\t</Button>\n\t\t</form>\n\t);\n}\n\nexport default withInstanceId( ImportForm );\n"],
5
+ "mappings": "AAoEE,SAME,KANF;AAjEF,SAAS,UAAU,cAAc;AACjC,SAAS,sBAAsB;AAC/B,SAAS,IAAI,UAAU;AACvB,SAAS,QAAQ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,WAAU;AAAA,YAER,aAAI,MAAO;AAAA;AAAA,QACd;AAAA,QACA,oBAAC,WAAM,IAAK,SAAU,MAAK,QAAO,UAAW,cAAe;AAAA,QAC5D;AAAA,UAAC;AAAA;AAAA,YACA,uBAAqB;AAAA,YACrB,MAAK;AAAA,YACL,QAAS;AAAA,YACT,wBAAsB;AAAA,YACtB,UAAW,CAAE,QAAQ;AAAA,YACrB,SAAQ;AAAA,YACR,WAAU;AAAA,YAER,aAAI,UAAU,cAAe;AAAA;AAAA,QAChC;AAAA;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,sBAAQ,eAAgB,UAAW;",
6
+ "names": []
7
+ }
@@ -1,48 +1,35 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createRoot, StrictMode } from '@wordpress/element';
5
- import { __ } from '@wordpress/i18n';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import exportReusableBlock from './utils/export';
11
- import ImportDropdown from './components/import-dropdown';
12
-
13
- // Setup Export Links.
14
- import { jsx as _jsx } from "react/jsx-runtime";
15
- document.body.addEventListener('click', event => {
16
- if (!event.target.classList.contains('wp-list-reusable-blocks__export')) {
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createRoot, StrictMode } from "@wordpress/element";
3
+ import { __ } from "@wordpress/i18n";
4
+ import exportReusableBlock from "./utils/export";
5
+ import ImportDropdown from "./components/import-dropdown";
6
+ document.body.addEventListener("click", (event) => {
7
+ if (!event.target.classList.contains("wp-list-reusable-blocks__export")) {
17
8
  return;
18
9
  }
19
10
  event.preventDefault();
20
11
  exportReusableBlock(event.target.dataset.id);
21
12
  });
22
-
23
- // Setup Import Form.
24
- document.addEventListener('DOMContentLoaded', () => {
25
- const button = document.querySelector('.page-title-action');
13
+ document.addEventListener("DOMContentLoaded", () => {
14
+ const button = document.querySelector(".page-title-action");
26
15
  if (!button) {
27
16
  return;
28
17
  }
29
18
  const showNotice = () => {
30
- const notice = document.createElement('div');
31
- notice.className = 'notice notice-success is-dismissible';
32
- notice.innerHTML = `<p>${__('Pattern imported successfully!')}</p>`;
33
- const headerEnd = document.querySelector('.wp-header-end');
19
+ const notice = document.createElement("div");
20
+ notice.className = "notice notice-success is-dismissible";
21
+ notice.innerHTML = `<p>${__("Pattern imported successfully!")}</p>`;
22
+ const headerEnd = document.querySelector(".wp-header-end");
34
23
  if (!headerEnd) {
35
24
  return;
36
25
  }
37
26
  headerEnd.parentNode.insertBefore(notice, headerEnd);
38
27
  };
39
- const container = document.createElement('div');
40
- container.className = 'list-reusable-blocks__container';
28
+ const container = document.createElement("div");
29
+ container.className = "list-reusable-blocks__container";
41
30
  button.parentNode.insertBefore(container, button);
42
- createRoot(container).render(/*#__PURE__*/_jsx(StrictMode, {
43
- children: /*#__PURE__*/_jsx(ImportDropdown, {
44
- onUpload: showNotice
45
- })
46
- }));
31
+ createRoot(container).render(
32
+ /* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsx(ImportDropdown, { onUpload: showNotice }) })
33
+ );
47
34
  });
48
- //# sourceMappingURL=index.js.map
35
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createRoot","StrictMode","__","exportReusableBlock","ImportDropdown","jsx","_jsx","document","body","addEventListener","event","target","classList","contains","preventDefault","dataset","id","button","querySelector","showNotice","notice","createElement","className","innerHTML","headerEnd","parentNode","insertBefore","container","render","children","onUpload"],"sources":["@wordpress/list-reusable-blocks/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRoot, StrictMode } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport exportReusableBlock from './utils/export';\nimport ImportDropdown from './components/import-dropdown';\n\n// Setup Export Links.\ndocument.body.addEventListener( 'click', ( event ) => {\n\tif (\n\t\t! event.target.classList.contains( 'wp-list-reusable-blocks__export' )\n\t) {\n\t\treturn;\n\t}\n\tevent.preventDefault();\n\texportReusableBlock( event.target.dataset.id );\n} );\n\n// Setup Import Form.\ndocument.addEventListener( 'DOMContentLoaded', () => {\n\tconst button = document.querySelector( '.page-title-action' );\n\tif ( ! button ) {\n\t\treturn;\n\t}\n\n\tconst showNotice = () => {\n\t\tconst notice = document.createElement( 'div' );\n\t\tnotice.className = 'notice notice-success is-dismissible';\n\t\tnotice.innerHTML = `<p>${ __( 'Pattern imported successfully!' ) }</p>`;\n\n\t\tconst headerEnd = document.querySelector( '.wp-header-end' );\n\t\tif ( ! headerEnd ) {\n\t\t\treturn;\n\t\t}\n\t\theaderEnd.parentNode.insertBefore( notice, headerEnd );\n\t};\n\n\tconst container = document.createElement( 'div' );\n\tcontainer.className = 'list-reusable-blocks__container';\n\tbutton.parentNode.insertBefore( container, button );\n\tcreateRoot( container ).render(\n\t\t<StrictMode>\n\t\t\t<ImportDropdown onUpload={ showNotice } />\n\t\t</StrictMode>\n\t);\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,UAAU,QAAQ,oBAAoB;AAC3D,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,gBAAgB;AAChD,OAAOC,cAAc,MAAM,8BAA8B;;AAEzD;AAAA,SAAAC,GAAA,IAAAC,IAAA;AACAC,QAAQ,CAACC,IAAI,CAACC,gBAAgB,CAAE,OAAO,EAAIC,KAAK,IAAM;EACrD,IACC,CAAEA,KAAK,CAACC,MAAM,CAACC,SAAS,CAACC,QAAQ,CAAE,iCAAkC,CAAC,EACrE;IACD;EACD;EACAH,KAAK,CAACI,cAAc,CAAC,CAAC;EACtBX,mBAAmB,CAAEO,KAAK,CAACC,MAAM,CAACI,OAAO,CAACC,EAAG,CAAC;AAC/C,CAAE,CAAC;;AAEH;AACAT,QAAQ,CAACE,gBAAgB,CAAE,kBAAkB,EAAE,MAAM;EACpD,MAAMQ,MAAM,GAAGV,QAAQ,CAACW,aAAa,CAAE,oBAAqB,CAAC;EAC7D,IAAK,CAAED,MAAM,EAAG;IACf;EACD;EAEA,MAAME,UAAU,GAAGA,CAAA,KAAM;IACxB,MAAMC,MAAM,GAAGb,QAAQ,CAACc,aAAa,CAAE,KAAM,CAAC;IAC9CD,MAAM,CAACE,SAAS,GAAG,sCAAsC;IACzDF,MAAM,CAACG,SAAS,GAAG,MAAOrB,EAAE,CAAE,gCAAiC,CAAC,MAAO;IAEvE,MAAMsB,SAAS,GAAGjB,QAAQ,CAACW,aAAa,CAAE,gBAAiB,CAAC;IAC5D,IAAK,CAAEM,SAAS,EAAG;MAClB;IACD;IACAA,SAAS,CAACC,UAAU,CAACC,YAAY,CAAEN,MAAM,EAAEI,SAAU,CAAC;EACvD,CAAC;EAED,MAAMG,SAAS,GAAGpB,QAAQ,CAACc,aAAa,CAAE,KAAM,CAAC;EACjDM,SAAS,CAACL,SAAS,GAAG,iCAAiC;EACvDL,MAAM,CAACQ,UAAU,CAACC,YAAY,CAAEC,SAAS,EAAEV,MAAO,CAAC;EACnDjB,UAAU,CAAE2B,SAAU,CAAC,CAACC,MAAM,cAC7BtB,IAAA,CAACL,UAAU;IAAA4B,QAAA,eACVvB,IAAA,CAACF,cAAc;MAAC0B,QAAQ,EAAGX;IAAY,CAAE;EAAC,CAC/B,CACb,CAAC;AACF,CAAE,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createRoot, StrictMode } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport exportReusableBlock from './utils/export';\nimport ImportDropdown from './components/import-dropdown';\n\n// Setup Export Links.\ndocument.body.addEventListener( 'click', ( event ) => {\n\tif (\n\t\t! event.target.classList.contains( 'wp-list-reusable-blocks__export' )\n\t) {\n\t\treturn;\n\t}\n\tevent.preventDefault();\n\texportReusableBlock( event.target.dataset.id );\n} );\n\n// Setup Import Form.\ndocument.addEventListener( 'DOMContentLoaded', () => {\n\tconst button = document.querySelector( '.page-title-action' );\n\tif ( ! button ) {\n\t\treturn;\n\t}\n\n\tconst showNotice = () => {\n\t\tconst notice = document.createElement( 'div' );\n\t\tnotice.className = 'notice notice-success is-dismissible';\n\t\tnotice.innerHTML = `<p>${ __( 'Pattern imported successfully!' ) }</p>`;\n\n\t\tconst headerEnd = document.querySelector( '.wp-header-end' );\n\t\tif ( ! headerEnd ) {\n\t\t\treturn;\n\t\t}\n\t\theaderEnd.parentNode.insertBefore( notice, headerEnd );\n\t};\n\n\tconst container = document.createElement( 'div' );\n\tcontainer.className = 'list-reusable-blocks__container';\n\tbutton.parentNode.insertBefore( container, button );\n\tcreateRoot( container ).render(\n\t\t<StrictMode>\n\t\t\t<ImportDropdown onUpload={ showNotice } />\n\t\t</StrictMode>\n\t);\n} );\n"],
5
+ "mappings": "AA+CG;AA5CH,SAAS,YAAY,kBAAkB;AACvC,SAAS,UAAU;AAKnB,OAAO,yBAAyB;AAChC,OAAO,oBAAoB;AAG3B,SAAS,KAAK,iBAAkB,SAAS,CAAE,UAAW;AACrD,MACC,CAAE,MAAM,OAAO,UAAU,SAAU,iCAAkC,GACpE;AACD;AAAA,EACD;AACA,QAAM,eAAe;AACrB,sBAAqB,MAAM,OAAO,QAAQ,EAAG;AAC9C,CAAE;AAGF,SAAS,iBAAkB,oBAAoB,MAAM;AACpD,QAAM,SAAS,SAAS,cAAe,oBAAqB;AAC5D,MAAK,CAAE,QAAS;AACf;AAAA,EACD;AAEA,QAAM,aAAa,MAAM;AACxB,UAAM,SAAS,SAAS,cAAe,KAAM;AAC7C,WAAO,YAAY;AACnB,WAAO,YAAY,MAAO,GAAI,gCAAiC,CAAE;AAEjE,UAAM,YAAY,SAAS,cAAe,gBAAiB;AAC3D,QAAK,CAAE,WAAY;AAClB;AAAA,IACD;AACA,cAAU,WAAW,aAAc,QAAQ,SAAU;AAAA,EACtD;AAEA,QAAM,YAAY,SAAS,cAAe,KAAM;AAChD,YAAU,YAAY;AACtB,SAAO,WAAW,aAAc,WAAW,MAAO;AAClD,aAAY,SAAU,EAAE;AAAA,IACvB,oBAAC,cACA,8BAAC,kBAAe,UAAW,YAAa,GACzC;AAAA,EACD;AACD,CAAE;",
6
+ "names": []
7
+ }
@@ -1,41 +1,29 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { paramCase as kebabCase } from 'change-case';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import apiFetch from '@wordpress/api-fetch';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { downloadBlob } from '@wordpress/blob';
15
-
16
- /**
17
- * Export a reusable block as a JSON file.
18
- *
19
- * @param {number} id
20
- */
1
+ import { paramCase as kebabCase } from "change-case";
2
+ import apiFetch from "@wordpress/api-fetch";
3
+ import { downloadBlob } from "@wordpress/blob";
21
4
  async function exportReusableBlock(id) {
22
- const postType = await apiFetch({
23
- path: `/wp/v2/types/wp_block`
24
- });
5
+ const postType = await apiFetch({ path: `/wp/v2/types/wp_block` });
25
6
  const post = await apiFetch({
26
7
  path: `/wp/v2/${postType.rest_base}/${id}?context=edit`
27
8
  });
28
9
  const title = post.title.raw;
29
10
  const content = post.content.raw;
30
11
  const syncStatus = post.wp_pattern_sync_status;
31
- const fileContent = JSON.stringify({
32
- __file: 'wp_block',
33
- title,
34
- content,
35
- syncStatus
36
- }, null, 2);
37
- const fileName = kebabCase(title) + '.json';
38
- downloadBlob(fileName, fileContent, 'application/json');
12
+ const fileContent = JSON.stringify(
13
+ {
14
+ __file: "wp_block",
15
+ title,
16
+ content,
17
+ syncStatus
18
+ },
19
+ null,
20
+ 2
21
+ );
22
+ const fileName = kebabCase(title) + ".json";
23
+ downloadBlob(fileName, fileContent, "application/json");
39
24
  }
40
- export default exportReusableBlock;
41
- //# sourceMappingURL=export.js.map
25
+ var export_default = exportReusableBlock;
26
+ export {
27
+ export_default as default
28
+ };
29
+ //# sourceMappingURL=export.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["paramCase","kebabCase","apiFetch","downloadBlob","exportReusableBlock","id","postType","path","post","rest_base","title","raw","content","syncStatus","wp_pattern_sync_status","fileContent","JSON","stringify","__file","fileName"],"sources":["@wordpress/list-reusable-blocks/src/utils/export.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { downloadBlob } from '@wordpress/blob';\n\n/**\n * Export a reusable block as a JSON file.\n *\n * @param {number} id\n */\nasync function exportReusableBlock( id ) {\n\tconst postType = await apiFetch( { path: `/wp/v2/types/wp_block` } );\n\tconst post = await apiFetch( {\n\t\tpath: `/wp/v2/${ postType.rest_base }/${ id }?context=edit`,\n\t} );\n\tconst title = post.title.raw;\n\tconst content = post.content.raw;\n\tconst syncStatus = post.wp_pattern_sync_status;\n\tconst fileContent = JSON.stringify(\n\t\t{\n\t\t\t__file: 'wp_block',\n\t\t\ttitle,\n\t\t\tcontent,\n\t\t\tsyncStatus,\n\t\t},\n\t\tnull,\n\t\t2\n\t);\n\tconst fileName = kebabCase( title ) + '.json';\n\n\tdownloadBlob( fileName, fileContent, 'application/json' );\n}\n\nexport default exportReusableBlock;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAS,QAAQ,aAAa;;AAEpD;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,sBAAsB;;AAE3C;AACA;AACA;AACA,SAASC,YAAY,QAAQ,iBAAiB;;AAE9C;AACA;AACA;AACA;AACA;AACA,eAAeC,mBAAmBA,CAAEC,EAAE,EAAG;EACxC,MAAMC,QAAQ,GAAG,MAAMJ,QAAQ,CAAE;IAAEK,IAAI,EAAE;EAAwB,CAAE,CAAC;EACpE,MAAMC,IAAI,GAAG,MAAMN,QAAQ,CAAE;IAC5BK,IAAI,EAAE,UAAWD,QAAQ,CAACG,SAAS,IAAMJ,EAAE;EAC5C,CAAE,CAAC;EACH,MAAMK,KAAK,GAAGF,IAAI,CAACE,KAAK,CAACC,GAAG;EAC5B,MAAMC,OAAO,GAAGJ,IAAI,CAACI,OAAO,CAACD,GAAG;EAChC,MAAME,UAAU,GAAGL,IAAI,CAACM,sBAAsB;EAC9C,MAAMC,WAAW,GAAGC,IAAI,CAACC,SAAS,CACjC;IACCC,MAAM,EAAE,UAAU;IAClBR,KAAK;IACLE,OAAO;IACPC;EACD,CAAC,EACD,IAAI,EACJ,CACD,CAAC;EACD,MAAMM,QAAQ,GAAGlB,SAAS,CAAES,KAAM,CAAC,GAAG,OAAO;EAE7CP,YAAY,CAAEgB,QAAQ,EAAEJ,WAAW,EAAE,kBAAmB,CAAC;AAC1D;AAEA,eAAeX,mBAAmB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/export.js"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { downloadBlob } from '@wordpress/blob';\n\n/**\n * Export a reusable block as a JSON file.\n *\n * @param {number} id\n */\nasync function exportReusableBlock( id ) {\n\tconst postType = await apiFetch( { path: `/wp/v2/types/wp_block` } );\n\tconst post = await apiFetch( {\n\t\tpath: `/wp/v2/${ postType.rest_base }/${ id }?context=edit`,\n\t} );\n\tconst title = post.title.raw;\n\tconst content = post.content.raw;\n\tconst syncStatus = post.wp_pattern_sync_status;\n\tconst fileContent = JSON.stringify(\n\t\t{\n\t\t\t__file: 'wp_block',\n\t\t\ttitle,\n\t\t\tcontent,\n\t\t\tsyncStatus,\n\t\t},\n\t\tnull,\n\t\t2\n\t);\n\tconst fileName = kebabCase( title ) + '.json';\n\n\tdownloadBlob( fileName, fileContent, 'application/json' );\n}\n\nexport default exportReusableBlock;\n"],
5
+ "mappings": "AAGA,SAAS,aAAa,iBAAiB;AAKvC,OAAO,cAAc;AAKrB,SAAS,oBAAoB;AAO7B,eAAe,oBAAqB,IAAK;AACxC,QAAM,WAAW,MAAM,SAAU,EAAE,MAAM,wBAAwB,CAAE;AACnE,QAAM,OAAO,MAAM,SAAU;AAAA,IAC5B,MAAM,UAAW,SAAS,SAAU,IAAK,EAAG;AAAA,EAC7C,CAAE;AACF,QAAM,QAAQ,KAAK,MAAM;AACzB,QAAM,UAAU,KAAK,QAAQ;AAC7B,QAAM,aAAa,KAAK;AACxB,QAAM,cAAc,KAAK;AAAA,IACxB;AAAA,MACC,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,QAAM,WAAW,UAAW,KAAM,IAAI;AAEtC,eAAc,UAAU,aAAa,kBAAmB;AACzD;AAEA,IAAO,iBAAQ;",
6
+ "names": []
7
+ }