@wordpress/list-reusable-blocks 6.1.0 → 6.3.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.
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
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
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -28,8 +30,8 @@ let _wordpress_components = require("@wordpress/components");
28
30
  let _wordpress_compose = require("@wordpress/compose");
29
31
  let _wordpress_i18n = require("@wordpress/i18n");
30
32
  let ___import_form_index_tsx = require("../import-form/index.cjs");
31
- ___import_form_index_tsx = __toESM(___import_form_index_tsx);
32
33
  let react_jsx_runtime = require("react/jsx-runtime");
34
+ ___import_form_index_tsx = __toESM(___import_form_index_tsx);
33
35
  // packages/list-reusable-blocks/src/components/import-dropdown/index.tsx
34
36
  function ImportDropdown({ onUpload }) {
35
37
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Dropdown, {
@@ -1 +1 @@
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
+ {"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"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
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
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -29,8 +31,8 @@ let _wordpress_compose = require("@wordpress/compose");
29
31
  let _wordpress_element = require("@wordpress/element");
30
32
  let _wordpress_i18n = require("@wordpress/i18n");
31
33
  let ______utils_import_ts = require("../../utils/import.cjs");
32
- ______utils_import_ts = __toESM(______utils_import_ts);
33
34
  let react_jsx_runtime = require("react/jsx-runtime");
35
+ ______utils_import_ts = __toESM(______utils_import_ts);
34
36
  // packages/list-reusable-blocks/src/components/import-form/index.tsx
35
37
  function ImportForm({ instanceId, onUpload }) {
36
38
  const inputId = "list-reusable-blocks-import-form-" + instanceId;
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"index.cjs","names":["useRef","useState","importReusableBlock","__","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;EACnBC,CAAAA,GAAAA,sBAAAA,QAAAA,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
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
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
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -27,10 +29,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
29
  let _wordpress_element = require("@wordpress/element");
28
30
  let _wordpress_i18n = require("@wordpress/i18n");
29
31
  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
32
  let __utils_export_ts = require("./utils/export.cjs");
32
- __utils_export_ts = __toESM(__utils_export_ts);
33
33
  let react_jsx_runtime = require("react/jsx-runtime");
34
+ __components_import_dropdown_index_tsx = __toESM(__components_import_dropdown_index_tsx);
35
+ __utils_export_ts = __toESM(__utils_export_ts);
34
36
  // packages/list-reusable-blocks/src/index.tsx
35
37
  document.body.addEventListener("click", (event) => {
36
38
  const target = event.target;
@@ -1 +1 @@
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
+ {"version":3,"file":"index.cjs","names":["exportReusableBlock","__","createRoot","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,SACJA,CAAAA,GAAAA,kBAAAA,QAAAA,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,GAAOC,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;CAClDC,CAAAA,GAAAA,mBAAAA,WAAAA,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"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
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
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -26,10 +28,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
28
  }) : target, mod));
27
29
  let change_case = require("change-case");
28
30
  let remove_accents = require("remove-accents");
29
- remove_accents = __toESM(remove_accents);
30
31
  let _wordpress_api_fetch = require("@wordpress/api-fetch");
31
- _wordpress_api_fetch = __toESM(_wordpress_api_fetch);
32
32
  let _wordpress_blob = require("@wordpress/blob");
33
+ remove_accents = __toESM(remove_accents);
34
+ _wordpress_api_fetch = __toESM(_wordpress_api_fetch);
33
35
  // packages/list-reusable-blocks/src/utils/export.ts
34
36
  /**
35
37
  * Export a reusable block as a JSON file.
@@ -1 +1 @@
1
- {"version":3,"file":"export.cjs","names":["apiFetch","kebabCase","removeAccents"],"sources":["../../src/utils/export.ts"],"sourcesContent":["import { paramCase as kebabCase } from 'change-case';\nimport removeAccents from 'remove-accents';\nimport apiFetch from '@wordpress/api-fetch';\nimport { downloadBlob } from '@wordpress/blob';\nimport type { Post, PostType } from './types';\n\n/**\n * Export a reusable block as a JSON file.\n *\n * @param id - The ID of the reusable block to export\n */\nasync function exportReusableBlock( id: number ): Promise< void > {\n\tconst postType = await apiFetch< PostType >( {\n\t\tpath: `/wp/v2/types/wp_block`,\n\t} );\n\n\tconst post = await apiFetch< Post >( {\n\t\tpath: `/wp/v2/${ postType.rest_base }/${ id }?context=edit`,\n\t} );\n\n\tconst title = post.title.raw;\n\tconst content = post.content.raw;\n\tconst syncStatus = post.wp_pattern_sync_status;\n\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\n\tconst fileName = kebabCase( removeAccents( title ) ) + '.json';\n\n\tdownloadBlob( fileName, fileContent, 'application/json' );\n}\n\nexport default exportReusableBlock;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,eAAe,oBAAqB,IAA8B;CACjE,MAAM,WAAW,OAAA,GAAMA,qBAAAA,QAAAA,CAAsB,EAC5C,MAAM,wBACP,CAAE;CAEF,MAAM,OAAO,OAAA,GAAMA,qBAAAA,QAAAA,CAAkB,EACpC,MAAM,UAAW,SAAS,UAAW,GAAI,GAAI,eAC9C,CAAE;CAEF,MAAM,QAAQ,KAAK,MAAM;CACzB,MAAM,UAAU,KAAK,QAAQ;CAC7B,MAAM,aAAa,KAAK;CAExB,MAAM,cAAc,KAAK,UACxB;EACC,QAAQ;EACR;EACA;EACA;CACD,GACA,MACA,CACD;CAEA,MAAM,YAAA,GAAWC,YAAAA,UAAAA,EAAAA,GAAWC,eAAAA,QAAAA,CAAe,KAAM,CAAE,IAAI;CAEvD,CAAA,GAAA,gBAAA,aAAA,CAAc,UAAU,aAAa,kBAAmB;AACzD"}
1
+ {"version":3,"file":"export.cjs","names":["apiFetch","kebabCase","removeAccents","downloadBlob"],"sources":["../../src/utils/export.ts"],"sourcesContent":["import { paramCase as kebabCase } from 'change-case';\nimport removeAccents from 'remove-accents';\nimport apiFetch from '@wordpress/api-fetch';\nimport { downloadBlob } from '@wordpress/blob';\nimport type { Post, PostType } from './types';\n\n/**\n * Export a reusable block as a JSON file.\n *\n * @param id - The ID of the reusable block to export\n */\nasync function exportReusableBlock( id: number ): Promise< void > {\n\tconst postType = await apiFetch< PostType >( {\n\t\tpath: `/wp/v2/types/wp_block`,\n\t} );\n\n\tconst post = await apiFetch< Post >( {\n\t\tpath: `/wp/v2/${ postType.rest_base }/${ id }?context=edit`,\n\t} );\n\n\tconst title = post.title.raw;\n\tconst content = post.content.raw;\n\tconst syncStatus = post.wp_pattern_sync_status;\n\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\n\tconst fileName = kebabCase( removeAccents( title ) ) + '.json';\n\n\tdownloadBlob( fileName, fileContent, 'application/json' );\n}\n\nexport default exportReusableBlock;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,eAAe,oBAAqB,IAA8B;CACjE,MAAM,WAAW,OAAA,GAAMA,qBAAAA,QAAAA,CAAsB,EAC5C,MAAM,wBACP,CAAE;CAEF,MAAM,OAAO,OAAA,GAAMA,qBAAAA,QAAAA,CAAkB,EACpC,MAAM,UAAW,SAAS,UAAW,GAAI,GAAI,eAC9C,CAAE;CAEF,MAAM,QAAQ,KAAK,MAAM;CACzB,MAAM,UAAU,KAAK,QAAQ;CAC7B,MAAM,aAAa,KAAK;CAExB,MAAM,cAAc,KAAK,UACxB;EACC,QAAQ;EACR;EACA;EACA;CACD,GACA,MACA,CACD;CAEA,MAAM,YAAA,GAAWC,YAAAA,UAAAA,EAAAA,GAAWC,eAAAA,QAAAA,CAAe,KAAM,CAAE,IAAI;CAEvDC,CAAAA,GAAAA,gBAAAA,aAAAA,CAAc,UAAU,aAAa,kBAAmB;AACzD"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
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
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -25,8 +27,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
27
  enumerable: true
26
28
  }) : target, mod));
27
29
  let _wordpress_api_fetch = require("@wordpress/api-fetch");
28
- _wordpress_api_fetch = __toESM(_wordpress_api_fetch);
29
30
  let __file_ts = require("./file.cjs");
31
+ _wordpress_api_fetch = __toESM(_wordpress_api_fetch);
30
32
  // packages/list-reusable-blocks/src/utils/import.ts
31
33
  /**
32
34
  * Import a reusable block from a JSON file.
@@ -1 +1 @@
1
- {"version":3,"file":"import.cjs","names":["readTextFile","apiFetch"],"sources":["../../src/utils/import.ts"],"sourcesContent":["import apiFetch from '@wordpress/api-fetch';\nimport { readTextFile } from './file';\nimport type {\n\tParsedContent,\n\tPostType,\n\tReusableBlock,\n\tReusableBlockData,\n} from './types';\n\n/**\n * Import a reusable block from a JSON file.\n *\n * @param file - File to import\n * @return Promise returning the imported reusable block\n */\nasync function importReusableBlock( file: File ): Promise< ReusableBlock > {\n\tconst fileContent = await readTextFile( file );\n\tlet parsedContent: ParsedContent;\n\n\ttry {\n\t\tparsedContent = JSON.parse( fileContent );\n\t} catch {\n\t\tthrow new Error( 'Invalid JSON file' );\n\t}\n\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\n\tconst postType = await apiFetch< PostType >( {\n\t\tpath: `/wp/v2/types/wp_block`,\n\t} );\n\n\tconst reusableBlock = await apiFetch< ReusableBlock >( {\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} satisfies ReusableBlockData,\n\t\tmethod: 'POST',\n\t} );\n\n\treturn reusableBlock;\n}\n\nexport default importReusableBlock;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,eAAe,oBAAqB,MAAuC;CAC1E,MAAM,cAAc,OAAA,GAAMA,UAAAA,aAAAA,CAAc,IAAK;CAC7C,IAAI;CAEJ,IAAI;EACH,gBAAgB,KAAK,MAAO,WAAY;CACzC,QAAQ;EACP,MAAM,IAAI,MAAO,mBAAoB;CACtC;CAEA,IACC,cAAc,WAAW,cACzB,CAAE,cAAc,SAChB,CAAE,cAAc,WAChB,OAAO,cAAc,UAAU,YAC/B,OAAO,cAAc,YAAY,YAC/B,cAAc,cACf,OAAO,cAAc,eAAe,UAErC,MAAM,IAAI,MAAO,2BAA4B;CAG9C,MAAM,WAAW,OAAA,GAAMC,qBAAAA,QAAAA,CAAsB,EAC5C,MAAM,wBACP,CAAE;CAgBF,OAAO,OAAA,GAdqBA,qBAAAA,QAAAA,CAA2B;EACtD,MAAM,UAAW,SAAS;EAC1B,MAAM;GACL,OAAO,cAAc;GACrB,SAAS,cAAc;GACvB,QAAQ;GACR,MACC,cAAc,eAAe,aAC1B,EAAE,wBAAwB,cAAc,WAAW,IACnD,KAAA;EACL;EACA,QAAQ;CACT,CAAE;AAGH"}
1
+ {"version":3,"file":"import.cjs","names":["readTextFile","apiFetch"],"sources":["../../src/utils/import.ts"],"sourcesContent":["import apiFetch from '@wordpress/api-fetch';\nimport { readTextFile } from './file';\nimport type {\n\tParsedContent,\n\tPostType,\n\tReusableBlock,\n\tReusableBlockData,\n} from './types';\n\n/**\n * Import a reusable block from a JSON file.\n *\n * @param file - File to import\n * @return Promise returning the imported reusable block\n */\nasync function importReusableBlock( file: File ): Promise< ReusableBlock > {\n\tconst fileContent = await readTextFile( file );\n\tlet parsedContent: ParsedContent;\n\n\ttry {\n\t\tparsedContent = JSON.parse( fileContent );\n\t} catch {\n\t\tthrow new Error( 'Invalid JSON file' );\n\t}\n\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\n\tconst postType = await apiFetch< PostType >( {\n\t\tpath: `/wp/v2/types/wp_block`,\n\t} );\n\n\tconst reusableBlock = await apiFetch< ReusableBlock >( {\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} satisfies ReusableBlockData,\n\t\tmethod: 'POST',\n\t} );\n\n\treturn reusableBlock;\n}\n\nexport default importReusableBlock;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,eAAe,oBAAqB,MAAuC;CAC1E,MAAM,cAAc,OAAA,GAAMA,UAAAA,aAAAA,CAAc,IAAK;CAC7C,IAAI;CAEJ,IAAI;EACH,gBAAgB,KAAK,MAAO,WAAY;CACzC,QAAQ;EACP,MAAM,IAAI,MAAO,mBAAoB;CACtC;CAEA,IACC,cAAc,WAAW,cACzB,CAAE,cAAc,SAChB,CAAE,cAAc,WAChB,OAAO,cAAc,UAAU,YAC/B,OAAO,cAAc,YAAY,YAC/B,cAAc,cACf,OAAO,cAAc,eAAe,UAErC,MAAM,IAAI,MAAO,2BAA4B;CAG9C,MAAM,WAAW,OAAA,GAAMC,qBAAAA,QAAAA,CAAsB,EAC5C,MAAM,wBACP,CAAE;CAgBF,OAAO,OAAA,GAdqBA,qBAAAA,QAAAA,CAA2B;EACtD,MAAM,UAAW,SAAS;EAC1B,MAAM;GACL,OAAO,cAAc;GACrB,SAAS,cAAc;GACvB,QAAQ;GACR,MACC,cAAc,eAAe,aAC1B,EAAE,wBAAwB,cAAc,WAAW,IACnD,KAAA;EACL;EACA,QAAQ;CACT,CAAE;AAGH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/list-reusable-blocks",
3
- "version": "6.1.0",
3
+ "version": "6.3.0",
4
4
  "description": "Adding Export/Import support to the reusable blocks listing.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -42,14 +42,14 @@
42
42
  "wpScript": true,
43
43
  "types": "build-types",
44
44
  "dependencies": {
45
- "@wordpress/api-fetch": "^8.1.0",
46
- "@wordpress/base-styles": "^15.0.0",
47
- "@wordpress/blob": "^5.1.0",
48
- "@wordpress/components": "^44.0.0",
49
- "@wordpress/compose": "^9.1.0",
50
- "@wordpress/core-data": "^9.1.0",
51
- "@wordpress/element": "^10.1.0",
52
- "@wordpress/i18n": "^7.1.0",
45
+ "@wordpress/api-fetch": "^8.3.0",
46
+ "@wordpress/base-styles": "^15.2.0",
47
+ "@wordpress/blob": "^5.3.0",
48
+ "@wordpress/components": "^45.1.0",
49
+ "@wordpress/compose": "^9.3.0",
50
+ "@wordpress/core-data": "^9.3.0",
51
+ "@wordpress/element": "^10.3.0",
52
+ "@wordpress/i18n": "^7.3.0",
53
53
  "change-case": "^4.1.2",
54
54
  "remove-accents": "^0.5.0"
55
55
  },
@@ -66,5 +66,5 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "gitHead": "9b70363b9f93cff0583a1f3153738d383cf5a49e"
69
+ "gitHead": "7f19202f61aeba8f4bdce892a1a0df485ad76e2b"
70
70
  }