@wordpress/list-reusable-blocks 4.11.0 → 4.12.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.
- package/CHANGELOG.md +2 -0
- package/build/components/import-dropdown/index.js +16 -23
- package/build/components/import-dropdown/index.js.map +1 -1
- package/build/components/import-form/index.js +4 -5
- package/build/components/import-form/index.js.map +1 -1
- package/build-module/components/import-dropdown/index.js +16 -23
- package/build-module/components/import-dropdown/index.js.map +1 -1
- package/build-module/components/import-form/index.js +4 -5
- package/build-module/components/import-form/index.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -24,34 +24,27 @@ var _importForm = _interopRequireDefault(require("../import-form"));
|
|
|
24
24
|
/**
|
|
25
25
|
* Internal dependencies
|
|
26
26
|
*/
|
|
27
|
-
function ImportDropdown(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} = _ref;
|
|
27
|
+
function ImportDropdown({
|
|
28
|
+
onUpload
|
|
29
|
+
}) {
|
|
31
30
|
return (0, _element.createElement)(_components.Dropdown, {
|
|
32
31
|
popoverProps: {
|
|
33
32
|
placement: 'bottom-start'
|
|
34
33
|
},
|
|
35
34
|
contentClassName: "list-reusable-blocks-import-dropdown__content",
|
|
36
|
-
renderToggle:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
onClose
|
|
50
|
-
} = _ref3;
|
|
51
|
-
return (0, _element.createElement)(_importForm.default, {
|
|
52
|
-
onUpload: (0, _compose.pipe)(onClose, onUpload)
|
|
53
|
-
});
|
|
54
|
-
}
|
|
35
|
+
renderToggle: ({
|
|
36
|
+
isOpen,
|
|
37
|
+
onToggle
|
|
38
|
+
}) => (0, _element.createElement)(_components.Button, {
|
|
39
|
+
"aria-expanded": isOpen,
|
|
40
|
+
onClick: onToggle,
|
|
41
|
+
variant: "primary"
|
|
42
|
+
}, (0, _i18n.__)('Import from JSON')),
|
|
43
|
+
renderContent: ({
|
|
44
|
+
onClose
|
|
45
|
+
}) => (0, _element.createElement)(_importForm.default, {
|
|
46
|
+
onUpload: (0, _compose.pipe)(onClose, onUpload)
|
|
47
|
+
})
|
|
55
48
|
});
|
|
56
49
|
}
|
|
57
50
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/components/import-dropdown/index.js"],"names":["ImportDropdown","onUpload","placement","isOpen","onToggle","onClose"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGA,SAASA,cAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/components/import-dropdown/index.js"],"names":["ImportDropdown","onUpload","placement","isOpen","onToggle","onClose"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGA,SAASA,cAAT,CAAyB;AAAEC,EAAAA;AAAF,CAAzB,EAAwC;AACvC,SACC,4BAAC,oBAAD;AACC,IAAA,YAAY,EAAG;AAAEC,MAAAA,SAAS,EAAE;AAAb,KADhB;AAEC,IAAA,gBAAgB,EAAC,+CAFlB;AAGC,IAAA,YAAY,EAAG,CAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV,KAAF,KACd,4BAAC,kBAAD;AACC,uBAAgBD,MADjB;AAEC,MAAA,OAAO,EAAGC,QAFX;AAGC,MAAA,OAAO,EAAC;AAHT,OAKG,cAAI,kBAAJ,CALH,CAJF;AAYC,IAAA,aAAa,EAAG,CAAE;AAAEC,MAAAA;AAAF,KAAF,KACf,4BAAC,mBAAD;AAAY,MAAA,QAAQ,EAAG,mBAAMA,OAAN,EAAeJ,QAAf;AAAvB;AAbF,IADD;AAkBA;;eAEcD,c","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\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"]}
|
|
@@ -24,11 +24,10 @@ var _import = _interopRequireDefault(require("../../utils/import"));
|
|
|
24
24
|
/**
|
|
25
25
|
* Internal dependencies
|
|
26
26
|
*/
|
|
27
|
-
function ImportForm(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} = _ref;
|
|
27
|
+
function ImportForm({
|
|
28
|
+
instanceId,
|
|
29
|
+
onUpload
|
|
30
|
+
}) {
|
|
32
31
|
const inputId = 'list-reusable-blocks-import-form-' + instanceId;
|
|
33
32
|
const formRef = (0, _element.useRef)();
|
|
34
33
|
const [isLoading, setIsLoading] = (0, _element.useState)(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/components/import-form/index.js"],"names":["ImportForm","instanceId","onUpload","inputId","formRef","isLoading","setIsLoading","error","setError","file","setFile","onChangeFile","event","target","files","onSubmit","preventDefault","then","reusableBlock","catch","errors","uiMessage","message","onDismissError"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGA,SAASA,UAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/components/import-form/index.js"],"names":["ImportForm","instanceId","onUpload","inputId","formRef","isLoading","setIsLoading","error","setError","file","setFile","onChangeFile","event","target","files","onSubmit","preventDefault","then","reusableBlock","catch","errors","uiMessage","message","onDismissError"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGA,SAASA,UAAT,CAAqB;AAAEC,EAAAA,UAAF;AAAcC,EAAAA;AAAd,CAArB,EAAgD;AAC/C,QAAMC,OAAO,GAAG,sCAAsCF,UAAtD;AAEA,QAAMG,OAAO,GAAG,sBAAhB;AACA,QAAM,CAAEC,SAAF,EAAaC,YAAb,IAA8B,uBAAU,KAAV,CAApC;AACA,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAU,IAAV,CAA5B;AACA,QAAM,CAAEC,IAAF,EAAQC,OAAR,IAAoB,uBAAU,IAAV,CAA1B;;AAEA,QAAMC,YAAY,GAAKC,KAAF,IAAa;AACjCF,IAAAA,OAAO,CAAEE,KAAK,CAACC,MAAN,CAAaC,KAAb,CAAoB,CAApB,CAAF,CAAP;AACAN,IAAAA,QAAQ,CAAE,IAAF,CAAR;AACA,GAHD;;AAKA,QAAMO,QAAQ,GAAKH,KAAF,IAAa;AAC7BA,IAAAA,KAAK,CAACI,cAAN;;AACA,QAAK,CAAEP,IAAP,EAAc;AACb;AACA;;AACDH,IAAAA,YAAY,CAAE;AAAED,MAAAA,SAAS,EAAE;AAAb,KAAF,CAAZ;AACA,yBAAqBI,IAArB,EACEQ,IADF,CACUC,aAAF,IAAqB;AAC3B,UAAK,CAAEd,OAAP,EAAiB;AAChB;AACA;;AAEDE,MAAAA,YAAY,CAAE,KAAF,CAAZ;AACAJ,MAAAA,QAAQ,CAAEgB,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BA;;eAEc,6BAAgBL,UAAhB,C","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 Reusable block JSON file':\n\t\t\t\t\t\tuiMessage = __( 'Invalid Reusable block 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\ttype=\"submit\"\n\t\t\t\tisBusy={ isLoading }\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"]}
|
|
@@ -12,34 +12,27 @@ import { Dropdown, Button } from '@wordpress/components';
|
|
|
12
12
|
|
|
13
13
|
import ImportForm from '../import-form';
|
|
14
14
|
|
|
15
|
-
function ImportDropdown(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} = _ref;
|
|
15
|
+
function ImportDropdown({
|
|
16
|
+
onUpload
|
|
17
|
+
}) {
|
|
19
18
|
return createElement(Dropdown, {
|
|
20
19
|
popoverProps: {
|
|
21
20
|
placement: 'bottom-start'
|
|
22
21
|
},
|
|
23
22
|
contentClassName: "list-reusable-blocks-import-dropdown__content",
|
|
24
|
-
renderToggle:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
onClose
|
|
38
|
-
} = _ref3;
|
|
39
|
-
return createElement(ImportForm, {
|
|
40
|
-
onUpload: pipe(onClose, onUpload)
|
|
41
|
-
});
|
|
42
|
-
}
|
|
23
|
+
renderToggle: ({
|
|
24
|
+
isOpen,
|
|
25
|
+
onToggle
|
|
26
|
+
}) => createElement(Button, {
|
|
27
|
+
"aria-expanded": isOpen,
|
|
28
|
+
onClick: onToggle,
|
|
29
|
+
variant: "primary"
|
|
30
|
+
}, __('Import from JSON')),
|
|
31
|
+
renderContent: ({
|
|
32
|
+
onClose
|
|
33
|
+
}) => createElement(ImportForm, {
|
|
34
|
+
onUpload: pipe(onClose, onUpload)
|
|
35
|
+
})
|
|
43
36
|
});
|
|
44
37
|
}
|
|
45
38
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/components/import-dropdown/index.js"],"names":["pipe","__","Dropdown","Button","ImportForm","ImportDropdown","onUpload","placement","isOpen","onToggle","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,oBAArB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,uBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,gBAAvB;;AAEA,SAASC,cAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/components/import-dropdown/index.js"],"names":["pipe","__","Dropdown","Button","ImportForm","ImportDropdown","onUpload","placement","isOpen","onToggle","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,oBAArB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,uBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,gBAAvB;;AAEA,SAASC,cAAT,CAAyB;AAAEC,EAAAA;AAAF,CAAzB,EAAwC;AACvC,SACC,cAAC,QAAD;AACC,IAAA,YAAY,EAAG;AAAEC,MAAAA,SAAS,EAAE;AAAb,KADhB;AAEC,IAAA,gBAAgB,EAAC,+CAFlB;AAGC,IAAA,YAAY,EAAG,CAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV,KAAF,KACd,cAAC,MAAD;AACC,uBAAgBD,MADjB;AAEC,MAAA,OAAO,EAAGC,QAFX;AAGC,MAAA,OAAO,EAAC;AAHT,OAKGR,EAAE,CAAE,kBAAF,CALL,CAJF;AAYC,IAAA,aAAa,EAAG,CAAE;AAAES,MAAAA;AAAF,KAAF,KACf,cAAC,UAAD;AAAY,MAAA,QAAQ,EAAGV,IAAI,CAAEU,OAAF,EAAWJ,QAAX;AAA3B;AAbF,IADD;AAkBA;;AAED,eAAeD,cAAf","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\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"]}
|
|
@@ -13,11 +13,10 @@ import { Button, Notice } from '@wordpress/components';
|
|
|
13
13
|
|
|
14
14
|
import importReusableBlock from '../../utils/import';
|
|
15
15
|
|
|
16
|
-
function ImportForm(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} = _ref;
|
|
16
|
+
function ImportForm({
|
|
17
|
+
instanceId,
|
|
18
|
+
onUpload
|
|
19
|
+
}) {
|
|
21
20
|
const inputId = 'list-reusable-blocks-import-form-' + instanceId;
|
|
22
21
|
const formRef = useRef();
|
|
23
22
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/components/import-form/index.js"],"names":["useState","useRef","withInstanceId","__","_x","Button","Notice","importReusableBlock","ImportForm","instanceId","onUpload","inputId","formRef","isLoading","setIsLoading","error","setError","file","setFile","onChangeFile","event","target","files","onSubmit","preventDefault","then","reusableBlock","catch","errors","uiMessage","message","onDismissError"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,MAAnB,QAAiC,oBAAjC;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,uBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,oBAAhC;;AAEA,SAASC,UAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/list-reusable-blocks/src/components/import-form/index.js"],"names":["useState","useRef","withInstanceId","__","_x","Button","Notice","importReusableBlock","ImportForm","instanceId","onUpload","inputId","formRef","isLoading","setIsLoading","error","setError","file","setFile","onChangeFile","event","target","files","onSubmit","preventDefault","then","reusableBlock","catch","errors","uiMessage","message","onDismissError"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,MAAnB,QAAiC,oBAAjC;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,uBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,oBAAhC;;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;;AACD;AACC0B,UAAAA,SAAS,GAAG1B,EAAE,CAAE,eAAF,CAAd;AARF;;AAWAW,MAAAA,YAAY,CAAE,KAAF,CAAZ;AACAE,MAAAA,QAAQ,CAAEa,SAAF,CAAR;AACA,KA5BF;AA6BA,GAnCD;;AAqCA,QAAME,cAAc,GAAG,MAAM;AAC5Bf,IAAAA,QAAQ,CAAE,IAAF,CAAR;AACA,GAFD;;AAIA,SACC;AACC,IAAA,SAAS,EAAC,kCADX;AAEC,IAAA,QAAQ,EAAGO,QAFZ;AAGC,IAAA,GAAG,EAAGX;AAHP,KAKGG,KAAK,IACN,cAAC,MAAD;AAAQ,IAAA,MAAM,EAAC,OAAf;AAAuB,IAAA,QAAQ,EAAG,MAAMgB,cAAc;AAAtD,KACGhB,KADH,CANF,EAUC;AACC,IAAA,OAAO,EAAGJ,OADX;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGR,EAAE,CAAE,MAAF,CAJL,CAVD,EAgBC;AAAO,IAAA,EAAE,EAAGQ,OAAZ;AAAsB,IAAA,IAAI,EAAC,MAA3B;AAAkC,IAAA,QAAQ,EAAGQ;AAA7C,IAhBD,EAiBC,cAAC,MAAD;AACC,IAAA,IAAI,EAAC,QADN;AAEC,IAAA,MAAM,EAAGN,SAFV;AAGC,IAAA,QAAQ,EAAG,CAAEI,IAAF,IAAUJ,SAHtB;AAIC,IAAA,OAAO,EAAC,WAJT;AAKC,IAAA,SAAS,EAAC;AALX,KAOGT,EAAE,CAAE,QAAF,EAAY,cAAZ,CAPL,CAjBD,CADD;AA6BA;;AAED,eAAeF,cAAc,CAAEM,UAAF,CAA7B","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 Reusable block JSON file':\n\t\t\t\t\t\tuiMessage = __( 'Invalid Reusable block 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\ttype=\"submit\"\n\t\t\t\tisBusy={ isLoading }\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/list-reusable-blocks",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.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",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"module": "build-module/index.js",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/runtime": "^7.16.0",
|
|
29
|
-
"@wordpress/api-fetch": "^6.
|
|
30
|
-
"@wordpress/components": "^25.
|
|
31
|
-
"@wordpress/compose": "^6.
|
|
32
|
-
"@wordpress/element": "^5.
|
|
33
|
-
"@wordpress/i18n": "^4.
|
|
29
|
+
"@wordpress/api-fetch": "^6.32.0",
|
|
30
|
+
"@wordpress/components": "^25.1.0",
|
|
31
|
+
"@wordpress/compose": "^6.12.0",
|
|
32
|
+
"@wordpress/element": "^5.12.0",
|
|
33
|
+
"@wordpress/i18n": "^4.35.0",
|
|
34
34
|
"change-case": "^4.1.2"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "a92f606309b1541b834ff9b0a76ed2a466fc45ed"
|
|
44
44
|
}
|