@wordpress/list-reusable-blocks 6.0.0 → 6.1.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,63 +1,51 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
2
7
  var __create = Object.create;
3
8
  var __defProp = Object.defineProperty;
4
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
11
  var __getProtoOf = Object.getPrototypeOf;
7
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
13
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
19
22
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let _wordpress_components = require("@wordpress/components");
28
+ let _wordpress_compose = require("@wordpress/compose");
29
+ let _wordpress_i18n = require("@wordpress/i18n");
30
+ let ___import_form_index_tsx = require("../import-form/index.cjs");
31
+ ___import_form_index_tsx = __toESM(___import_form_index_tsx);
32
+ let react_jsx_runtime = require("react/jsx-runtime");
30
33
  // packages/list-reusable-blocks/src/components/import-dropdown/index.tsx
31
- var import_dropdown_exports = {};
32
- __export(import_dropdown_exports, {
33
- default: () => import_dropdown_default
34
- });
35
- module.exports = __toCommonJS(import_dropdown_exports);
36
- var import_components = require("@wordpress/components");
37
- var import_compose = require("@wordpress/compose");
38
- var import_i18n = require("@wordpress/i18n");
39
- var import_import_form = __toESM(require("../import-form/index.cjs"));
40
- var import_jsx_runtime = require("react/jsx-runtime");
41
34
  function ImportDropdown({ onUpload }) {
42
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
43
- import_components.Dropdown,
44
- {
45
- popoverProps: { placement: "bottom-start" },
46
- contentClassName: "list-reusable-blocks-import-dropdown__content",
47
- renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
48
- import_components.Button,
49
- {
50
- size: "compact",
51
- className: "list-reusable-blocks-import-dropdown__button",
52
- "aria-expanded": isOpen,
53
- onClick: onToggle,
54
- variant: "primary",
55
- children: (0, import_i18n.__)("Import from JSON")
56
- }
57
- ),
58
- renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_import_form.default, { onUpload: (0, import_compose.pipe)(onClose, onUpload) })
59
- }
60
- );
35
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Dropdown, {
36
+ popoverProps: { placement: "bottom-start" },
37
+ contentClassName: "list-reusable-blocks-import-dropdown__content",
38
+ renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
39
+ size: "compact",
40
+ className: "list-reusable-blocks-import-dropdown__button",
41
+ "aria-expanded": isOpen,
42
+ onClick: onToggle,
43
+ variant: "primary",
44
+ children: (0, _wordpress_i18n.__)("Import from JSON")
45
+ }),
46
+ renderContent: ({ onClose }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___import_form_index_tsx.default, { onUpload: (0, _wordpress_compose.pipe)(onClose, onUpload) })
47
+ });
61
48
  }
62
- var import_dropdown_default = ImportDropdown;
63
- //# sourceMappingURL=index.cjs.map
49
+ exports.default = ImportDropdown;
50
+
51
+ //# sourceMappingURL=index.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/import-dropdown/index.tsx"],
4
- "sourcesContent": ["import { Button, Dropdown } from '@wordpress/components';\nimport { pipe } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport type { ImportDropdownProps } from '../../utils/types';\nimport ImportForm from '../import-form';\n\nfunction ImportDropdown( { onUpload }: ImportDropdownProps ) {\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAiC;AACjC,qBAAqB;AACrB,kBAAmB;AAEnB,yBAAuB;AAQnB;AANJ,SAAS,eAAgB,EAAE,SAAS,GAAyB;AAC5D,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,8BAAI,kBAAmB;AAAA;AAAA,MAC1B;AAAA,MAED,eAAgB,CAAE,EAAE,QAAQ,MAC3B,4CAAC,mBAAAA,SAAA,EAAW,cAAW,qBAAM,SAAS,QAAS,GAAI;AAAA;AAAA,EAErD;AAEF;AAEA,IAAO,0BAAQ;",
6
- "names": ["ImportForm"]
7
- }
1
+ {"version":3,"file":"index.cjs","names":["Dropdown","Button","__","ImportForm","pipe"],"sources":["../../../src/components/import-dropdown/index.tsx"],"sourcesContent":["import { Button, Dropdown } from '@wordpress/components';\nimport { pipe } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport type { ImportDropdownProps } from '../../utils/types';\nimport ImportForm from '../import-form';\n\nfunction ImportDropdown( { onUpload }: ImportDropdownProps ) {\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,eAAgB,EAAE,YAAkC;CAC5D,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACA,sBAAAA,UAAD;EACC,cAAe,EAAE,WAAW,eAAe;EAC3C,kBAAiB;EACjB,eAAiB,EAAE,QAAQ,eAC1B,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,QAAD;GACC,MAAK;GACL,WAAU;GACV,iBAAgB;GAChB,SAAU;GACV,SAAQ;GAENC,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,kBAAmB;EAClB,CAAA;EAET,gBAAkB,EAAE,cACnB,iBAAA,GAAA,kBAAA,IAAA,CAACC,yBAAAA,SAAD,EAAY,WAAA,GAAWC,mBAAAA,KAAAA,CAAM,SAAS,QAAS,EAAK,CAAA;CAErD,CAAA;AAEH"}
@@ -1,121 +1,108 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
2
7
  var __create = Object.create;
3
8
  var __defProp = Object.defineProperty;
4
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
11
  var __getProtoOf = Object.getPrototypeOf;
7
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
13
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
19
22
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let _wordpress_components = require("@wordpress/components");
28
+ let _wordpress_compose = require("@wordpress/compose");
29
+ let _wordpress_element = require("@wordpress/element");
30
+ let _wordpress_i18n = require("@wordpress/i18n");
31
+ let ______utils_import_ts = require("../../utils/import.cjs");
32
+ ______utils_import_ts = __toESM(______utils_import_ts);
33
+ let react_jsx_runtime = require("react/jsx-runtime");
30
34
  // packages/list-reusable-blocks/src/components/import-form/index.tsx
31
- var import_form_exports = {};
32
- __export(import_form_exports, {
33
- default: () => import_form_default
34
- });
35
- module.exports = __toCommonJS(import_form_exports);
36
- var import_components = require("@wordpress/components");
37
- var import_compose = require("@wordpress/compose");
38
- var import_element = require("@wordpress/element");
39
- var import_i18n = require("@wordpress/i18n");
40
- var import_import = __toESM(require("../../utils/import.cjs"));
41
- var import_jsx_runtime = require("react/jsx-runtime");
42
35
  function ImportForm({ instanceId, onUpload }) {
43
- const inputId = "list-reusable-blocks-import-form-" + instanceId;
44
- const formRef = (0, import_element.useRef)(null);
45
- const [isLoading, setIsLoading] = (0, import_element.useState)(false);
46
- const [error, setError] = (0, import_element.useState)(null);
47
- const [file, setFile] = (0, import_element.useState)(null);
48
- const onChangeFile = (event) => {
49
- setFile(event.target.files?.[0] || null);
50
- setError(null);
51
- };
52
- const onSubmit = (event) => {
53
- event.preventDefault();
54
- if (!file) {
55
- return;
56
- }
57
- setIsLoading(true);
58
- (0, import_import.default)(file).then((reusableBlock) => {
59
- if (!formRef.current) {
60
- return;
61
- }
62
- setIsLoading(false);
63
- onUpload(reusableBlock);
64
- }).catch((errors) => {
65
- if (!formRef.current) {
66
- return;
67
- }
68
- let uiMessage;
69
- switch (errors.message) {
70
- case "Invalid JSON file":
71
- uiMessage = (0, import_i18n.__)("Invalid JSON file");
72
- break;
73
- case "Invalid pattern JSON file":
74
- uiMessage = (0, import_i18n.__)("Invalid pattern JSON file");
75
- break;
76
- default:
77
- uiMessage = (0, import_i18n.__)("Unknown error");
78
- }
79
- setIsLoading(false);
80
- setError(uiMessage);
81
- });
82
- };
83
- const onDismissError = () => {
84
- setError(null);
85
- };
86
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
87
- "form",
88
- {
89
- className: "list-reusable-blocks-import-form",
90
- onSubmit,
91
- ref: formRef,
92
- children: [
93
- error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Notice, { status: "error", onRemove: () => onDismissError(), children: error }),
94
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
95
- "label",
96
- {
97
- htmlFor: inputId,
98
- className: "list-reusable-blocks-import-form__label",
99
- children: (0, import_i18n.__)("File")
100
- }
101
- ),
102
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { id: inputId, type: "file", onChange: onChangeFile }),
103
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
104
- import_components.Button,
105
- {
106
- __next40pxDefaultSize: true,
107
- type: "submit",
108
- isBusy: isLoading,
109
- accessibleWhenDisabled: true,
110
- disabled: !file || isLoading,
111
- variant: "secondary",
112
- className: "list-reusable-blocks-import-form__button",
113
- children: (0, import_i18n._x)("Import", "button label")
114
- }
115
- )
116
- ]
117
- }
118
- );
36
+ const inputId = "list-reusable-blocks-import-form-" + instanceId;
37
+ const formRef = (0, _wordpress_element.useRef)(null);
38
+ const [isLoading, setIsLoading] = (0, _wordpress_element.useState)(false);
39
+ const [error, setError] = (0, _wordpress_element.useState)(null);
40
+ const [file, setFile] = (0, _wordpress_element.useState)(null);
41
+ const onChangeFile = (event) => {
42
+ setFile(event.target.files?.[0] || null);
43
+ setError(null);
44
+ };
45
+ const onSubmit = (event) => {
46
+ event.preventDefault();
47
+ if (!file) return;
48
+ setIsLoading(true);
49
+ (0, ______utils_import_ts.default)(file).then((reusableBlock) => {
50
+ if (!formRef.current) return;
51
+ setIsLoading(false);
52
+ onUpload(reusableBlock);
53
+ }).catch((errors) => {
54
+ if (!formRef.current) return;
55
+ let uiMessage;
56
+ switch (errors.message) {
57
+ case "Invalid JSON file":
58
+ uiMessage = (0, _wordpress_i18n.__)("Invalid JSON file");
59
+ break;
60
+ case "Invalid pattern JSON file":
61
+ uiMessage = (0, _wordpress_i18n.__)("Invalid pattern JSON file");
62
+ break;
63
+ default: uiMessage = (0, _wordpress_i18n.__)("Unknown error");
64
+ }
65
+ setIsLoading(false);
66
+ setError(uiMessage);
67
+ });
68
+ };
69
+ const onDismissError = () => {
70
+ setError(null);
71
+ };
72
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
73
+ className: "list-reusable-blocks-import-form",
74
+ onSubmit,
75
+ ref: formRef,
76
+ children: [
77
+ error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Notice, {
78
+ status: "error",
79
+ onRemove: () => onDismissError(),
80
+ children: error
81
+ }),
82
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
83
+ htmlFor: inputId,
84
+ className: "list-reusable-blocks-import-form__label",
85
+ children: (0, _wordpress_i18n.__)("File")
86
+ }),
87
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
88
+ id: inputId,
89
+ type: "file",
90
+ onChange: onChangeFile
91
+ }),
92
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
93
+ __next40pxDefaultSize: true,
94
+ type: "submit",
95
+ isBusy: isLoading,
96
+ accessibleWhenDisabled: true,
97
+ disabled: !file || isLoading,
98
+ variant: "secondary",
99
+ className: "list-reusable-blocks-import-form__button",
100
+ children: (0, _wordpress_i18n._x)("Import", "button label")
101
+ })
102
+ ]
103
+ });
119
104
  }
120
- var import_form_default = (0, import_compose.withInstanceId)(ImportForm);
121
- //# sourceMappingURL=index.cjs.map
105
+ var import_form_default = (0, _wordpress_compose.withInstanceId)(ImportForm);
106
+ exports.default = import_form_default;
107
+
108
+ //# sourceMappingURL=index.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/import-form/index.tsx"],
4
- "sourcesContent": ["import { Button, Notice } from '@wordpress/components';\nimport { withInstanceId } from '@wordpress/compose';\nimport { useRef, useState } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport importReusableBlock from '../../utils/import';\nimport type { ImportFormProps, ReusableBlock } from '../../utils/types';\n\nfunction ImportForm( { instanceId, onUpload }: ImportFormProps ) {\n\tconst inputId = 'list-reusable-blocks-import-form-' + instanceId;\n\n\tconst formRef = useRef< HTMLFormElement >( null );\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ error, setError ] = useState< string | null >( null );\n\tconst [ file, setFile ] = useState< File | null >( null );\n\n\tconst onChangeFile = ( event: React.ChangeEvent< HTMLInputElement > ) => {\n\t\tsetFile( event.target.files?.[ 0 ] || null );\n\t\tsetError( null );\n\t};\n\n\tconst onSubmit = ( event: React.FormEvent< HTMLFormElement > ) => {\n\t\tevent.preventDefault();\n\t\tif ( ! file ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsLoading( true );\n\t\timportReusableBlock( file )\n\t\t\t.then( ( reusableBlock: ReusableBlock ) => {\n\t\t\t\tif ( ! formRef.current ) {\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: Error ) => {\n\t\t\t\tif ( ! formRef.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet uiMessage: string;\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA+B;AAC/B,qBAA+B;AAC/B,qBAAiC;AACjC,kBAAuB;AACvB,oBAAgC;AA0D9B;AAvDF,SAAS,WAAY,EAAE,YAAY,SAAS,GAAqB;AAChE,QAAM,UAAU,sCAAsC;AAEtD,QAAM,cAAU,uBAA2B,IAAK;AAChD,QAAM,CAAE,WAAW,YAAa,QAAI,yBAAU,KAAM;AACpD,QAAM,CAAE,OAAO,QAAS,QAAI,yBAA2B,IAAK;AAC5D,QAAM,CAAE,MAAM,OAAQ,QAAI,yBAAyB,IAAK;AAExD,QAAM,eAAe,CAAE,UAAkD;AACxE,YAAS,MAAM,OAAO,QAAS,CAAE,KAAK,IAAK;AAC3C,aAAU,IAAK;AAAA,EAChB;AAEA,QAAM,WAAW,CAAE,UAA+C;AACjE,UAAM,eAAe;AACrB,QAAK,CAAE,MAAO;AACb;AAAA,IACD;AACA,iBAAc,IAAK;AACnB,sBAAAA,SAAqB,IAAK,EACxB,KAAM,CAAE,kBAAkC;AAC1C,UAAK,CAAE,QAAQ,SAAU;AACxB;AAAA,MACD;AAEA,mBAAc,KAAM;AACpB,eAAU,aAAc;AAAA,IACzB,CAAE,EACD,MAAO,CAAE,WAAmB;AAC5B,UAAK,CAAE,QAAQ,SAAU;AACxB;AAAA,MACD;AAEA,UAAI;AACJ,cAAS,OAAO,SAAU;AAAA,QACzB,KAAK;AACJ,0BAAY,gBAAI,mBAAoB;AACpC;AAAA,QACD,KAAK;AACJ,0BAAY,gBAAI,2BAA4B;AAC5C;AAAA,QACD;AACC,0BAAY,gBAAI,eAAgB;AAAA,MAClC;AAEA,mBAAc,KAAM;AACpB,eAAU,SAAU;AAAA,IACrB,CAAE;AAAA,EACJ;AAEA,QAAM,iBAAiB,MAAM;AAC5B,aAAU,IAAK;AAAA,EAChB;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV;AAAA,MACA,KAAM;AAAA,MAEJ;AAAA,iBACD,4CAAC,4BAAO,QAAO,SAAQ,UAAW,MAAM,eAAe,GACpD,iBACH;AAAA,QAED;AAAA,UAAC;AAAA;AAAA,YACA,SAAU;AAAA,YACV,WAAU;AAAA,YAER,8BAAI,MAAO;AAAA;AAAA,QACd;AAAA,QACA,4CAAC,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,8BAAI,UAAU,cAAe;AAAA;AAAA,QAChC;AAAA;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,0BAAQ,+BAAgB,UAAW;",
6
- "names": ["importReusableBlock"]
7
- }
1
+ {"version":3,"file":"index.cjs","names":["useRef","useState","__","WCNotice","Button","_x","withInstanceId"],"sources":["../../../src/components/import-form/index.tsx"],"sourcesContent":["import { Button, Notice as WCNotice } from '@wordpress/components';\nimport { withInstanceId } from '@wordpress/compose';\nimport { useRef, useState } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport importReusableBlock from '../../utils/import';\nimport type { ImportFormProps, ReusableBlock } from '../../utils/types';\n\nfunction ImportForm( { instanceId, onUpload }: ImportFormProps ) {\n\tconst inputId = 'list-reusable-blocks-import-form-' + instanceId;\n\n\tconst formRef = useRef< HTMLFormElement >( null );\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ error, setError ] = useState< string | null >( null );\n\tconst [ file, setFile ] = useState< File | null >( null );\n\n\tconst onChangeFile = ( event: React.ChangeEvent< HTMLInputElement > ) => {\n\t\tsetFile( event.target.files?.[ 0 ] || null );\n\t\tsetError( null );\n\t};\n\n\tconst onSubmit = ( event: React.FormEvent< HTMLFormElement > ) => {\n\t\tevent.preventDefault();\n\t\tif ( ! file ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsLoading( true );\n\t\timportReusableBlock( file )\n\t\t\t.then( ( reusableBlock: ReusableBlock ) => {\n\t\t\t\tif ( ! formRef.current ) {\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: Error ) => {\n\t\t\t\tif ( ! formRef.current ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet uiMessage: string;\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<WCNotice status=\"error\" onRemove={ () => onDismissError() }>\n\t\t\t\t\t{ error }\n\t\t\t\t</WCNotice>\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,SAAS,WAAY,EAAE,YAAY,YAA8B;CAChE,MAAM,UAAU,sCAAsC;CAEtD,MAAM,WAAA,GAAUA,mBAAAA,OAAAA,CAA2B,IAAK;CAChD,MAAM,CAAE,WAAW,iBAAA,GAAiBC,mBAAAA,SAAAA,CAAU,KAAM;CACpD,MAAM,CAAE,OAAO,aAAA,GAAaA,mBAAAA,SAAAA,CAA2B,IAAK;CAC5D,MAAM,CAAE,MAAM,YAAA,GAAYA,mBAAAA,SAAAA,CAAyB,IAAK;CAExD,MAAM,gBAAiB,UAAkD;EACxE,QAAS,MAAM,OAAO,QAAS,MAAO,IAAK;EAC3C,SAAU,IAAK;CAChB;CAEA,MAAM,YAAa,UAA+C;EACjE,MAAM,eAAe;EACrB,IAAK,CAAE,MACN;EAED,aAAc,IAAK;EACnB,CAAA,GAAA,sBAAA,QAAA,CAAqB,IAAK,CAAC,CACzB,MAAQ,kBAAkC;GAC1C,IAAK,CAAE,QAAQ,SACd;GAGD,aAAc,KAAM;GACpB,SAAU,aAAc;EACzB,CAAE,CAAC,CACF,OAAS,WAAmB;GAC5B,IAAK,CAAE,QAAQ,SACd;GAGD,IAAI;GACJ,QAAS,OAAO,SAAhB;IACC,KAAK;KACJ,aAAA,GAAYC,gBAAAA,GAAAA,CAAI,mBAAoB;KACpC;IACD,KAAK;KACJ,aAAA,GAAYA,gBAAAA,GAAAA,CAAI,2BAA4B;KAC5C;IACD,SACC,aAAA,GAAYA,gBAAAA,GAAAA,CAAI,eAAgB;GAClC;GAEA,aAAc,KAAM;GACpB,SAAU,SAAU;EACrB,CAAE;CACJ;CAEA,MAAM,uBAAuB;EAC5B,SAAU,IAAK;CAChB;CAEA,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD;EACC,WAAU;EACC;EACX,KAAM;EAHP,UAAA;GAKG,SACD,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,QAAD;IAAU,QAAO;IAAQ,gBAAiB,eAAe;IACtD,UAAA;GACO,CAAA;GAEX,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;IACC,SAAU;IACV,WAAU;IAERD,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,MAAO;GACP,CAAA;GACP,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;IAAO,IAAK;IAAU,MAAK;IAAO,UAAW;GAAgB,CAAA;GAC7D,iBAAA,GAAA,kBAAA,IAAA,CAACE,sBAAAA,QAAD;IACC,uBAAA;IACA,MAAK;IACL,QAAS;IACT,wBAAA;IACA,UAAW,CAAE,QAAQ;IACrB,SAAQ;IACR,WAAU;IAERC,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,UAAU,cAAe;GACxB,CAAA;EACH;;AAER;AAEA,IAAA,uBAAA,GAAeC,mBAAAA,eAAAA,CAAgB,UAAW"}
package/build/index.cjs CHANGED
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
2
7
  var __create = Object.create;
3
8
  var __defProp = Object.defineProperty;
4
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -6,62 +11,50 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
11
  var __getProtoOf = Object.getPrototypeOf;
7
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
13
  var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
15
22
  };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
-
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let _wordpress_element = require("@wordpress/element");
28
+ let _wordpress_i18n = require("@wordpress/i18n");
29
+ let __components_import_dropdown_index_tsx = require("./components/import-dropdown/index.cjs");
30
+ __components_import_dropdown_index_tsx = __toESM(__components_import_dropdown_index_tsx);
31
+ let __utils_export_ts = require("./utils/export.cjs");
32
+ __utils_export_ts = __toESM(__utils_export_ts);
33
+ let react_jsx_runtime = require("react/jsx-runtime");
25
34
  // packages/list-reusable-blocks/src/index.tsx
26
- var import_element = require("@wordpress/element");
27
- var import_i18n = require("@wordpress/i18n");
28
- var import_import_dropdown = __toESM(require("./components/import-dropdown/index.cjs"));
29
- var import_export = __toESM(require("./utils/export.cjs"));
30
- var import_jsx_runtime = require("react/jsx-runtime");
31
35
  document.body.addEventListener("click", (event) => {
32
- const target = event.target;
33
- if (!target.classList.contains("wp-list-reusable-blocks__export")) {
34
- return;
35
- }
36
- event.preventDefault();
37
- const blockId = target.dataset.id;
38
- if (blockId) {
39
- (0, import_export.default)(Number(blockId));
40
- }
36
+ const target = event.target;
37
+ if (!target.classList.contains("wp-list-reusable-blocks__export")) return;
38
+ event.preventDefault();
39
+ const blockId = target.dataset.id;
40
+ if (blockId) (0, __utils_export_ts.default)(Number(blockId));
41
41
  });
42
42
  document.addEventListener("DOMContentLoaded", () => {
43
- const button = document.querySelector(".page-title-action");
44
- if (!button) {
45
- return;
46
- }
47
- const showNotice = () => {
48
- const notice = document.createElement("div");
49
- notice.className = "notice notice-success is-dismissible";
50
- notice.innerHTML = `<p>${(0, import_i18n.__)("Pattern imported successfully!")}</p>`;
51
- const headerEnd = document.querySelector(".wp-header-end");
52
- if (!headerEnd || !headerEnd.parentNode) {
53
- return;
54
- }
55
- headerEnd.parentNode.insertBefore(notice, headerEnd);
56
- };
57
- const container = document.createElement("div");
58
- container.className = "list-reusable-blocks__container";
59
- if (!button.parentNode) {
60
- return;
61
- }
62
- button.parentNode.insertBefore(container, button);
63
- (0, import_element.createRoot)(container).render(
64
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_element.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_import_dropdown.default, { onUpload: showNotice }) })
65
- );
43
+ const button = document.querySelector(".page-title-action");
44
+ if (!button) return;
45
+ const showNotice = () => {
46
+ const notice = document.createElement("div");
47
+ notice.className = "notice notice-success is-dismissible";
48
+ notice.innerHTML = `<p>${(0, _wordpress_i18n.__)("Pattern imported successfully!")}</p>`;
49
+ const headerEnd = document.querySelector(".wp-header-end");
50
+ if (!headerEnd || !headerEnd.parentNode) return;
51
+ headerEnd.parentNode.insertBefore(notice, headerEnd);
52
+ };
53
+ const container = document.createElement("div");
54
+ container.className = "list-reusable-blocks__container";
55
+ if (!button.parentNode) return;
56
+ button.parentNode.insertBefore(container, button);
57
+ (0, _wordpress_element.createRoot)(container).render(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_element.StrictMode, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__components_import_dropdown_index_tsx.default, { onUpload: showNotice }) }));
66
58
  });
67
- //# sourceMappingURL=index.cjs.map
59
+
60
+ //# sourceMappingURL=index.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/index.tsx"],
4
- "sourcesContent": ["import { createRoot, StrictMode } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport ImportDropdown from './components/import-dropdown';\nimport exportReusableBlock from './utils/export';\n\n// Setup Export Links.\ndocument.body.addEventListener( 'click', ( event: MouseEvent ) => {\n\tconst target = event.target as HTMLElement;\n\n\tif ( ! target.classList.contains( 'wp-list-reusable-blocks__export' ) ) {\n\t\treturn;\n\t}\n\n\tevent.preventDefault();\n\n\tconst blockId = target.dataset.id;\n\tif ( blockId ) {\n\t\texportReusableBlock( Number( blockId ) );\n\t}\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 || ! headerEnd.parentNode ) {\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\n\tif ( ! button.parentNode ) {\n\t\treturn;\n\t}\n\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": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qBAAuC;AACvC,kBAAmB;AACnB,6BAA2B;AAC3B,oBAAgC;AA+C7B;AA5CH,SAAS,KAAK,iBAAkB,SAAS,CAAE,UAAuB;AACjE,QAAM,SAAS,MAAM;AAErB,MAAK,CAAE,OAAO,UAAU,SAAU,iCAAkC,GAAI;AACvE;AAAA,EACD;AAEA,QAAM,eAAe;AAErB,QAAM,UAAU,OAAO,QAAQ;AAC/B,MAAK,SAAU;AACd,sBAAAA,SAAqB,OAAQ,OAAQ,CAAE;AAAA,EACxC;AACD,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,UAAO,gBAAI,gCAAiC,CAAE;AAEjE,UAAM,YAAY,SAAS,cAAe,gBAAiB;AAC3D,QAAK,CAAE,aAAa,CAAE,UAAU,YAAa;AAC5C;AAAA,IACD;AACA,cAAU,WAAW,aAAc,QAAQ,SAAU;AAAA,EACtD;AAEA,QAAM,YAAY,SAAS,cAAe,KAAM;AAChD,YAAU,YAAY;AAEtB,MAAK,CAAE,OAAO,YAAa;AAC1B;AAAA,EACD;AAEA,SAAO,WAAW,aAAc,WAAW,MAAO;AAClD,iCAAY,SAAU,EAAE;AAAA,IACvB,4CAAC,6BACA,sDAAC,uBAAAC,SAAA,EAAe,UAAW,YAAa,GACzC;AAAA,EACD;AACD,CAAE;",
6
- "names": ["exportReusableBlock", "ImportDropdown"]
7
- }
1
+ {"version":3,"file":"index.cjs","names":["__","StrictMode","ImportDropdown"],"sources":["../src/index.tsx"],"sourcesContent":["import { createRoot, StrictMode } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport ImportDropdown from './components/import-dropdown';\nimport exportReusableBlock from './utils/export';\n\n// Setup Export Links.\ndocument.body.addEventListener( 'click', ( event: MouseEvent ) => {\n\tconst target = event.target as HTMLElement;\n\n\tif ( ! target.classList.contains( 'wp-list-reusable-blocks__export' ) ) {\n\t\treturn;\n\t}\n\n\tevent.preventDefault();\n\n\tconst blockId = target.dataset.id;\n\tif ( blockId ) {\n\t\texportReusableBlock( Number( blockId ) );\n\t}\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 || ! headerEnd.parentNode ) {\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\n\tif ( ! button.parentNode ) {\n\t\treturn;\n\t}\n\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,KAAK,iBAAkB,UAAW,UAAuB;CACjE,MAAM,SAAS,MAAM;CAErB,IAAK,CAAE,OAAO,UAAU,SAAU,iCAAkC,GACnE;CAGD,MAAM,eAAe;CAErB,MAAM,UAAU,OAAO,QAAQ;CAC/B,IAAK,SACJ,CAAA,GAAA,kBAAA,QAAA,CAAqB,OAAQ,OAAQ,CAAE;AAEzC,CAAE;AAGF,SAAS,iBAAkB,0BAA0B;CACpD,MAAM,SAAS,SAAS,cAAe,oBAAqB;CAC5D,IAAK,CAAE,QACN;CAGD,MAAM,mBAAmB;EACxB,MAAM,SAAS,SAAS,cAAe,KAAM;EAC7C,OAAO,YAAY;EACnB,OAAO,YAAY,OAAA,GAAOA,gBAAAA,GAAAA,CAAI,gCAAiC,EAAG;EAElE,MAAM,YAAY,SAAS,cAAe,gBAAiB;EAC3D,IAAK,CAAE,aAAa,CAAE,UAAU,YAC/B;EAED,UAAU,WAAW,aAAc,QAAQ,SAAU;CACtD;CAEA,MAAM,YAAY,SAAS,cAAe,KAAM;CAChD,UAAU,YAAY;CAEtB,IAAK,CAAE,OAAO,YACb;CAGD,OAAO,WAAW,aAAc,WAAW,MAAO;CAClD,CAAA,GAAA,mBAAA,WAAA,CAAY,SAAU,CAAC,CAAC,OACvB,iBAAA,GAAA,kBAAA,IAAA,CAACC,mBAAAA,YAAD,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,uCAAAA,SAAD,EAAgB,UAAW,WAAc,CAAA,EAC9B,CAAA,CACb;AACD,CAAE"}
@@ -1,64 +1,56 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
2
7
  var __create = Object.create;
3
8
  var __defProp = Object.defineProperty;
4
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
11
  var __getProtoOf = Object.getPrototypeOf;
7
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
13
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
19
22
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let change_case = require("change-case");
28
+ let remove_accents = require("remove-accents");
29
+ remove_accents = __toESM(remove_accents);
30
+ let _wordpress_api_fetch = require("@wordpress/api-fetch");
31
+ _wordpress_api_fetch = __toESM(_wordpress_api_fetch);
32
+ let _wordpress_blob = require("@wordpress/blob");
30
33
  // packages/list-reusable-blocks/src/utils/export.ts
31
- var export_exports = {};
32
- __export(export_exports, {
33
- default: () => export_default
34
- });
35
- module.exports = __toCommonJS(export_exports);
36
- var import_change_case = require("change-case");
37
- var import_remove_accents = __toESM(require("remove-accents"));
38
- var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
39
- var import_blob = require("@wordpress/blob");
34
+ /**
35
+ * Export a reusable block as a JSON file.
36
+ *
37
+ * @param id - The ID of the reusable block to export
38
+ */
40
39
  async function exportReusableBlock(id) {
41
- const postType = await (0, import_api_fetch.default)({
42
- path: `/wp/v2/types/wp_block`
43
- });
44
- const post = await (0, import_api_fetch.default)({
45
- path: `/wp/v2/${postType.rest_base}/${id}?context=edit`
46
- });
47
- const title = post.title.raw;
48
- const content = post.content.raw;
49
- const syncStatus = post.wp_pattern_sync_status;
50
- const fileContent = JSON.stringify(
51
- {
52
- __file: "wp_block",
53
- title,
54
- content,
55
- syncStatus
56
- },
57
- null,
58
- 2
59
- );
60
- const fileName = (0, import_change_case.paramCase)((0, import_remove_accents.default)(title)) + ".json";
61
- (0, import_blob.downloadBlob)(fileName, fileContent, "application/json");
40
+ const postType = await (0, _wordpress_api_fetch.default)({ path: `/wp/v2/types/wp_block` });
41
+ const post = await (0, _wordpress_api_fetch.default)({ path: `/wp/v2/${postType.rest_base}/${id}?context=edit` });
42
+ const title = post.title.raw;
43
+ const content = post.content.raw;
44
+ const syncStatus = post.wp_pattern_sync_status;
45
+ const fileContent = JSON.stringify({
46
+ __file: "wp_block",
47
+ title,
48
+ content,
49
+ syncStatus
50
+ }, null, 2);
51
+ const fileName = (0, change_case.paramCase)((0, remove_accents.default)(title)) + ".json";
52
+ (0, _wordpress_blob.downloadBlob)(fileName, fileContent, "application/json");
62
53
  }
63
- var export_default = exportReusableBlock;
64
- //# sourceMappingURL=export.cjs.map
54
+ exports.default = exportReusableBlock;
55
+
56
+ //# sourceMappingURL=export.cjs.map