@wordpress/list-reusable-blocks 4.35.0 → 5.0.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 +6 -0
- package/build/components/import-dropdown/index.js +7 -6
- package/build/components/import-dropdown/index.js.map +1 -1
- package/build/components/import-form/index.js +24 -20
- package/build/components/import-form/index.js.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build-module/components/import-dropdown/index.js +7 -6
- package/build-module/components/import-dropdown/index.js.map +1 -1
- package/build-module/components/import-form/index.js +25 -20
- package/build-module/components/import-form/index.js.map +1 -1
- package/build-module/index.js +2 -2
- package/build-module/index.js.map +1 -1
- package/package.json +10 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 5.0.0 (2024-05-31)
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
- Increase the minimum required Node.js version to v18.12.0 matching long-term support releases ([#31270](https://github.com/WordPress/gutenberg/pull/61930)). Learn more about [Node.js releases](https://nodejs.org/en/about/previous-releases).
|
|
10
|
+
|
|
5
11
|
## 4.35.0 (2024-05-16)
|
|
6
12
|
|
|
7
13
|
## 4.34.0 (2024-05-02)
|
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
8
|
var _compose = require("@wordpress/compose");
|
|
10
9
|
var _i18n = require("@wordpress/i18n");
|
|
11
10
|
var _components = require("@wordpress/components");
|
|
12
11
|
var _importForm = _interopRequireDefault(require("../import-form"));
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
13
|
/**
|
|
14
14
|
* WordPress dependencies
|
|
15
15
|
*/
|
|
@@ -21,7 +21,7 @@ var _importForm = _interopRequireDefault(require("../import-form"));
|
|
|
21
21
|
function ImportDropdown({
|
|
22
22
|
onUpload
|
|
23
23
|
}) {
|
|
24
|
-
return (0,
|
|
24
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Dropdown, {
|
|
25
25
|
popoverProps: {
|
|
26
26
|
placement: 'bottom-start'
|
|
27
27
|
},
|
|
@@ -29,14 +29,15 @@ function ImportDropdown({
|
|
|
29
29
|
renderToggle: ({
|
|
30
30
|
isOpen,
|
|
31
31
|
onToggle
|
|
32
|
-
}) => (0,
|
|
32
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
33
33
|
"aria-expanded": isOpen,
|
|
34
34
|
onClick: onToggle,
|
|
35
|
-
variant: "primary"
|
|
36
|
-
|
|
35
|
+
variant: "primary",
|
|
36
|
+
children: (0, _i18n.__)('Import from JSON')
|
|
37
|
+
}),
|
|
37
38
|
renderContent: ({
|
|
38
39
|
onClose
|
|
39
|
-
}) => (0,
|
|
40
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_importForm.default, {
|
|
40
41
|
onUpload: (0, _compose.pipe)(onClose, onUpload)
|
|
41
42
|
})
|
|
42
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_i18n","_components","_importForm","_interopRequireDefault","
|
|
1
|
+
{"version":3,"names":["_compose","require","_i18n","_components","_importForm","_interopRequireDefault","_jsxRuntime","ImportDropdown","onUpload","jsx","Dropdown","popoverProps","placement","contentClassName","renderToggle","isOpen","onToggle","Button","onClick","variant","children","__","renderContent","onClose","default","pipe","_default","exports"],"sources":["@wordpress/list-reusable-blocks/src/components/import-dropdown/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { pipe } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport ImportForm from '../import-form';\n\nfunction ImportDropdown( { onUpload } ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\tcontentClassName=\"list-reusable-blocks-import-dropdown__content\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\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":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAwC,IAAAK,WAAA,GAAAL,OAAA;AAVxC;AACA;AACA;;AAKA;AACA;AACA;;AAGA,SAASM,cAAcA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACvC,oBACC,IAAAF,WAAA,CAAAG,GAAA,EAACN,WAAA,CAAAO,QAAQ;IACRC,YAAY,EAAG;MAAEC,SAAS,EAAE;IAAe,CAAG;IAC9CC,gBAAgB,EAAC,+CAA+C;IAChEC,YAAY,EAAGA,CAAE;MAAEC,MAAM;MAAEC;IAAS,CAAC,kBACpC,IAAAV,WAAA,CAAAG,GAAA,EAACN,WAAA,CAAAc,MAAM;MACN,iBAAgBF,MAAQ;MACxBG,OAAO,EAAGF,QAAU;MACpBG,OAAO,EAAC,SAAS;MAAAC,QAAA,EAEf,IAAAC,QAAE,EAAE,kBAAmB;IAAC,CACnB,CACN;IACHC,aAAa,EAAGA,CAAE;MAAEC;IAAQ,CAAC,kBAC5B,IAAAjB,WAAA,CAAAG,GAAA,EAACL,WAAA,CAAAoB,OAAU;MAAChB,QAAQ,EAAG,IAAAiB,aAAI,EAAEF,OAAO,EAAEf,QAAS;IAAG,CAAE;EAClD,CACH,CAAC;AAEJ;AAAC,IAAAkB,QAAA,GAAAC,OAAA,CAAAH,OAAA,GAEcjB,cAAc","ignoreList":[]}
|
|
@@ -5,12 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
8
|
var _element = require("@wordpress/element");
|
|
10
9
|
var _compose = require("@wordpress/compose");
|
|
11
10
|
var _i18n = require("@wordpress/i18n");
|
|
12
11
|
var _components = require("@wordpress/components");
|
|
13
12
|
var _import = _interopRequireDefault(require("../../utils/import"));
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
14
|
/**
|
|
15
15
|
* WordPress dependencies
|
|
16
16
|
*/
|
|
@@ -68,27 +68,31 @@ function ImportForm({
|
|
|
68
68
|
const onDismissError = () => {
|
|
69
69
|
setError(null);
|
|
70
70
|
};
|
|
71
|
-
return (0,
|
|
71
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
|
|
72
72
|
className: "list-reusable-blocks-import-form",
|
|
73
73
|
onSubmit: onSubmit,
|
|
74
|
-
ref: formRef
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
74
|
+
ref: formRef,
|
|
75
|
+
children: [error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Notice, {
|
|
76
|
+
status: "error",
|
|
77
|
+
onRemove: () => onDismissError(),
|
|
78
|
+
children: error
|
|
79
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
|
|
80
|
+
htmlFor: inputId,
|
|
81
|
+
className: "list-reusable-blocks-import-form__label",
|
|
82
|
+
children: (0, _i18n.__)('File')
|
|
83
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
84
|
+
id: inputId,
|
|
85
|
+
type: "file",
|
|
86
|
+
onChange: onChangeFile
|
|
87
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
88
|
+
type: "submit",
|
|
89
|
+
isBusy: isLoading,
|
|
90
|
+
disabled: !file || isLoading,
|
|
91
|
+
variant: "secondary",
|
|
92
|
+
className: "list-reusable-blocks-import-form__button",
|
|
93
|
+
children: (0, _i18n._x)('Import', 'button label')
|
|
94
|
+
})]
|
|
95
|
+
});
|
|
92
96
|
}
|
|
93
97
|
var _default = exports.default = (0, _compose.withInstanceId)(ImportForm);
|
|
94
98
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_compose","_i18n","_components","_import","_interopRequireDefault","ImportForm","instanceId","onUpload","inputId","formRef","useRef","isLoading","setIsLoading","useState","error","setError","file","setFile","onChangeFile","event","target","files","onSubmit","preventDefault","importReusableBlock","then","reusableBlock","catch","errors","uiMessage","message","__","onDismissError","
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","_i18n","_components","_import","_interopRequireDefault","_jsxRuntime","ImportForm","instanceId","onUpload","inputId","formRef","useRef","isLoading","setIsLoading","useState","error","setError","file","setFile","onChangeFile","event","target","files","onSubmit","preventDefault","importReusableBlock","then","reusableBlock","catch","errors","uiMessage","message","__","onDismissError","jsxs","className","ref","children","jsx","Notice","status","onRemove","htmlFor","id","type","onChange","Button","isBusy","disabled","variant","_x","_default","exports","default","withInstanceId"],"sources":["@wordpress/list-reusable-blocks/src/components/import-form/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useRef } from '@wordpress/element';\nimport { withInstanceId } from '@wordpress/compose';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, Notice } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport importReusableBlock from '../../utils/import';\n\nfunction ImportForm( { instanceId, onUpload } ) {\n\tconst inputId = 'list-reusable-blocks-import-form-' + instanceId;\n\n\tconst formRef = useRef();\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ error, setError ] = useState( null );\n\tconst [ file, setFile ] = useState( null );\n\n\tconst onChangeFile = ( event ) => {\n\t\tsetFile( event.target.files[ 0 ] );\n\t\tsetError( null );\n\t};\n\n\tconst onSubmit = ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( ! file ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsLoading( { isLoading: true } );\n\t\timportReusableBlock( file )\n\t\t\t.then( ( reusableBlock ) => {\n\t\t\t\tif ( ! formRef ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetIsLoading( false );\n\t\t\t\tonUpload( reusableBlock );\n\t\t\t} )\n\t\t\t.catch( ( errors ) => {\n\t\t\t\tif ( ! formRef ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet uiMessage;\n\t\t\t\tswitch ( errors.message ) {\n\t\t\t\t\tcase 'Invalid JSON file':\n\t\t\t\t\t\tuiMessage = __( 'Invalid JSON file' );\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Invalid pattern JSON file':\n\t\t\t\t\t\tuiMessage = __( 'Invalid pattern JSON file' );\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tuiMessage = __( 'Unknown error' );\n\t\t\t\t}\n\n\t\t\t\tsetIsLoading( false );\n\t\t\t\tsetError( uiMessage );\n\t\t\t} );\n\t};\n\n\tconst onDismissError = () => {\n\t\tsetError( null );\n\t};\n\n\treturn (\n\t\t<form\n\t\t\tclassName=\"list-reusable-blocks-import-form\"\n\t\t\tonSubmit={ onSubmit }\n\t\t\tref={ formRef }\n\t\t>\n\t\t\t{ error && (\n\t\t\t\t<Notice status=\"error\" onRemove={ () => onDismissError() }>\n\t\t\t\t\t{ error }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t\t<label\n\t\t\t\thtmlFor={ inputId }\n\t\t\t\tclassName=\"list-reusable-blocks-import-form__label\"\n\t\t\t>\n\t\t\t\t{ __( 'File' ) }\n\t\t\t</label>\n\t\t\t<input id={ inputId } type=\"file\" onChange={ onChangeFile } />\n\t\t\t<Button\n\t\t\t\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"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAKA,IAAAI,OAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAqD,IAAAM,WAAA,GAAAN,OAAA;AAXrD;AACA;AACA;;AAMA;AACA;AACA;;AAGA,SAASO,UAAUA,CAAE;EAAEC,UAAU;EAAEC;AAAS,CAAC,EAAG;EAC/C,MAAMC,OAAO,GAAG,mCAAmC,GAAGF,UAAU;EAEhE,MAAMG,OAAO,GAAG,IAAAC,eAAM,EAAC,CAAC;EACxB,MAAM,CAAEC,SAAS,EAAEC,YAAY,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EACrD,MAAM,CAAEC,KAAK,EAAEC,QAAQ,CAAE,GAAG,IAAAF,iBAAQ,EAAE,IAAK,CAAC;EAC5C,MAAM,CAAEG,IAAI,EAAEC,OAAO,CAAE,GAAG,IAAAJ,iBAAQ,EAAE,IAAK,CAAC;EAE1C,MAAMK,YAAY,GAAKC,KA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C,MAAM;MAACC,MAAM,EAAC,OAAO;MAACC,QAAQ,EAAGA,CAAA,KAAMR,cAAc,CAAC,CAAG;MAAAI,QAAA,EACvDtB;IAAK,CACA,CACR,eACD,IAAAV,WAAA,CAAAiC,GAAA;MACCI,OAAO,EAAGjC,OAAS;MACnB0B,SAAS,EAAC,yCAAyC;MAAAE,QAAA,EAEjD,IAAAL,QAAE,EAAE,MAAO;IAAC,CACR,CAAC,eACR,IAAA3B,WAAA,CAAAiC,GAAA;MAAOK,EAAE,EAAGlC,OAAS;MAACmC,IAAI,EAAC,MAAM;MAACC,QAAQ,EAAG1B;IAAc,CAAE,CAAC,eAC9D,IAAAd,WAAA,CAAAiC,GAAA,EAACpC,WAAA,CAAA4C,MAAM;MACNF,IAAI,EAAC,QAAQ;MACbG,MAAM,EAAGnC,SAAW;MACpBoC,QAAQ,EAAG,CAAE/B,IAAI,IAAIL,SAAW;MAChCqC,OAAO,EAAC,WAAW;MACnBd,SAAS,EAAC,0CAA0C;MAAAE,QAAA,EAElD,IAAAa,QAAE,EAAE,QAAQ,EAAE,cAAe;IAAC,CACzB,CAAC;EAAA,CACJ,CAAC;AAET;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,uBAAc,EAAEhD,UAAW,CAAC","ignoreList":[]}
|
package/build/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _react = require("react");
|
|
5
4
|
var _element = require("@wordpress/element");
|
|
6
5
|
var _i18n = require("@wordpress/i18n");
|
|
7
6
|
var _export = _interopRequireDefault(require("./utils/export"));
|
|
8
7
|
var _importDropdown = _interopRequireDefault(require("./components/import-dropdown"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
9
|
/**
|
|
10
10
|
* WordPress dependencies
|
|
11
11
|
*/
|
|
@@ -42,7 +42,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
42
42
|
const container = document.createElement('div');
|
|
43
43
|
container.className = 'list-reusable-blocks__container';
|
|
44
44
|
button.parentNode.insertBefore(container, button);
|
|
45
|
-
(0, _element.createRoot)(container).render((0,
|
|
45
|
+
(0, _element.createRoot)(container).render( /*#__PURE__*/(0, _jsxRuntime.jsx)(_importDropdown.default, {
|
|
46
46
|
onUpload: showNotice
|
|
47
47
|
}));
|
|
48
48
|
});
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_i18n","_export","_interopRequireDefault","_importDropdown","document","body","addEventListener","event","target","classList","contains","preventDefault","exportReusableBlock","dataset","id","button","querySelector","showNotice","notice","createElement","className","innerHTML","__","headerEnd","parentNode","insertBefore","container","createRoot","render","
|
|
1
|
+
{"version":3,"names":["_element","require","_i18n","_export","_interopRequireDefault","_importDropdown","_jsxRuntime","document","body","addEventListener","event","target","classList","contains","preventDefault","exportReusableBlock","dataset","id","button","querySelector","showNotice","notice","createElement","className","innerHTML","__","headerEnd","parentNode","insertBefore","container","createRoot","render","jsx","default","onUpload"],"sources":["@wordpress/list-reusable-blocks/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRoot } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport exportReusableBlock from './utils/export';\nimport ImportDropdown from './components/import-dropdown';\n\n// Setup Export Links.\ndocument.body.addEventListener( 'click', ( event ) => {\n\tif (\n\t\t! event.target.classList.contains( 'wp-list-reusable-blocks__export' )\n\t) {\n\t\treturn;\n\t}\n\tevent.preventDefault();\n\texportReusableBlock( event.target.dataset.id );\n} );\n\n// Setup Import Form.\ndocument.addEventListener( 'DOMContentLoaded', () => {\n\tconst button = document.querySelector( '.page-title-action' );\n\tif ( ! button ) {\n\t\treturn;\n\t}\n\n\tconst showNotice = () => {\n\t\tconst notice = document.createElement( 'div' );\n\t\tnotice.className = 'notice notice-success is-dismissible';\n\t\tnotice.innerHTML = `<p>${ __( 'Pattern imported successfully!' ) }</p>`;\n\n\t\tconst headerEnd = document.querySelector( '.wp-header-end' );\n\t\tif ( ! headerEnd ) {\n\t\t\treturn;\n\t\t}\n\t\theaderEnd.parentNode.insertBefore( notice, headerEnd );\n\t};\n\n\tconst container = document.createElement( 'div' );\n\tcontainer.className = 'list-reusable-blocks__container';\n\tbutton.parentNode.insertBefore( container, button );\n\tcreateRoot( container ).render(\n\t\t<ImportDropdown onUpload={ showNotice } />\n\t);\n} );\n"],"mappings":";;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AAA0D,IAAAK,WAAA,GAAAL,OAAA;AAV1D;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACAM,QAAQ,CAACC,IAAI,CAACC,gBAAgB,CAAE,OAAO,EAAIC,KAAK,IAAM;EACrD,IACC,CAAEA,KAAK,CAACC,MAAM,CAACC,SAAS,CAACC,QAAQ,CAAE,iCAAkC,CAAC,EACrE;IACD;EACD;EACAH,KAAK,CAACI,cAAc,CAAC,CAAC;EACtB,IAAAC,eAAmB,EAAEL,KAAK,CAACC,MAAM,CAACK,OAAO,CAACC,EAAG,CAAC;AAC/C,CAAE,CAAC;;AAEH;AACAV,QAAQ,CAACE,gBAAgB,CAAE,kBAAkB,EAAE,MAAM;EACpD,MAAMS,MAAM,GAAGX,QAAQ,CAACY,aAAa,CAAE,oBAAqB,CAAC;EAC7D,IAAK,CAAED,MAAM,EAAG;IACf;EACD;EAEA,MAAME,UAAU,GAAGA,CAAA,KAAM;IACxB,MAAMC,MAAM,GAAGd,QAAQ,CAACe,aAAa,CAAE,KAAM,CAAC;IAC9CD,MAAM,CAACE,SAAS,GAAG,sCAAsC;IACzDF,MAAM,CAACG,SAAS,GAAI,MAAM,IAAAC,QAAE,EAAE,gCAAiC,CAAG,MAAK;IAEvE,MAAMC,SAAS,GAAGnB,QAAQ,CAACY,aAAa,CAAE,gBAAiB,CAAC;IAC5D,IAAK,CAAEO,SAAS,EAAG;MAClB;IACD;IACAA,SAAS,CAACC,UAAU,CAACC,YAAY,CAAEP,MAAM,EAAEK,SAAU,CAAC;EACvD,CAAC;EAED,MAAMG,SAAS,GAAGtB,QAAQ,CAACe,aAAa,CAAE,KAAM,CAAC;EACjDO,SAAS,CAACN,SAAS,GAAG,iCAAiC;EACvDL,MAAM,CAACS,UAAU,CAACC,YAAY,CAAEC,SAAS,EAAEX,MAAO,CAAC;EACnD,IAAAY,mBAAU,EAAED,SAAU,CAAC,CAACE,MAAM,eAC7B,IAAAzB,WAAA,CAAA0B,GAAA,EAAC3B,eAAA,CAAA4B,OAAc;IAACC,QAAQ,EAAGd;EAAY,CAAE,CAC1C,CAAC;AACF,CAAE,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
1
|
/**
|
|
3
2
|
* WordPress dependencies
|
|
4
3
|
*/
|
|
@@ -10,10 +9,11 @@ import { Dropdown, Button } from '@wordpress/components';
|
|
|
10
9
|
* Internal dependencies
|
|
11
10
|
*/
|
|
12
11
|
import ImportForm from '../import-form';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
function ImportDropdown({
|
|
14
14
|
onUpload
|
|
15
15
|
}) {
|
|
16
|
-
return
|
|
16
|
+
return /*#__PURE__*/_jsx(Dropdown, {
|
|
17
17
|
popoverProps: {
|
|
18
18
|
placement: 'bottom-start'
|
|
19
19
|
},
|
|
@@ -21,14 +21,15 @@ function ImportDropdown({
|
|
|
21
21
|
renderToggle: ({
|
|
22
22
|
isOpen,
|
|
23
23
|
onToggle
|
|
24
|
-
}) =>
|
|
24
|
+
}) => /*#__PURE__*/_jsx(Button, {
|
|
25
25
|
"aria-expanded": isOpen,
|
|
26
26
|
onClick: onToggle,
|
|
27
|
-
variant: "primary"
|
|
28
|
-
|
|
27
|
+
variant: "primary",
|
|
28
|
+
children: __('Import from JSON')
|
|
29
|
+
}),
|
|
29
30
|
renderContent: ({
|
|
30
31
|
onClose
|
|
31
|
-
}) =>
|
|
32
|
+
}) => /*#__PURE__*/_jsx(ImportForm, {
|
|
32
33
|
onUpload: pipe(onClose, onUpload)
|
|
33
34
|
})
|
|
34
35
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["pipe","__","Dropdown","Button","ImportForm","
|
|
1
|
+
{"version":3,"names":["pipe","__","Dropdown","Button","ImportForm","jsx","_jsx","ImportDropdown","onUpload","popoverProps","placement","contentClassName","renderToggle","isOpen","onToggle","onClick","variant","children","renderContent","onClose"],"sources":["@wordpress/list-reusable-blocks/src/components/import-dropdown/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { pipe } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport ImportForm from '../import-form';\n\nfunction ImportDropdown( { onUpload } ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\tcontentClassName=\"list-reusable-blocks-import-dropdown__content\"\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Import from JSON' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<ImportForm onUpload={ pipe( onClose, onUpload ) } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default ImportDropdown;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,oBAAoB;AACzC,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,MAAM,QAAQ,uBAAuB;;AAExD;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAExC,SAASC,cAAcA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACvC,oBACCF,IAAA,CAACJ,QAAQ;IACRO,YAAY,EAAG;MAAEC,SAAS,EAAE;IAAe,CAAG;IAC9CC,gBAAgB,EAAC,+CAA+C;IAChEC,YAAY,EAAGA,CAAE;MAAEC,MAAM;MAAEC;IAAS,CAAC,kBACpCR,IAAA,CAACH,MAAM;MACN,iBAAgBU,MAAQ;MACxBE,OAAO,EAAGD,QAAU;MACpBE,OAAO,EAAC,SAAS;MAAAC,QAAA,EAEfhB,EAAE,CAAE,kBAAmB;IAAC,CACnB,CACN;IACHiB,aAAa,EAAGA,CAAE;MAAEC;IAAQ,CAAC,kBAC5Bb,IAAA,CAACF,UAAU;MAACI,QAAQ,EAAGR,IAAI,CAAEmB,OAAO,EAAEX,QAAS;IAAG,CAAE;EAClD,CACH,CAAC;AAEJ;AAEA,eAAeD,cAAc","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
1
|
/**
|
|
3
2
|
* WordPress dependencies
|
|
4
3
|
*/
|
|
@@ -11,6 +10,8 @@ import { Button, Notice } from '@wordpress/components';
|
|
|
11
10
|
* Internal dependencies
|
|
12
11
|
*/
|
|
13
12
|
import importReusableBlock from '../../utils/import';
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
15
|
function ImportForm({
|
|
15
16
|
instanceId,
|
|
16
17
|
onUpload
|
|
@@ -60,27 +61,31 @@ function ImportForm({
|
|
|
60
61
|
const onDismissError = () => {
|
|
61
62
|
setError(null);
|
|
62
63
|
};
|
|
63
|
-
return
|
|
64
|
+
return /*#__PURE__*/_jsxs("form", {
|
|
64
65
|
className: "list-reusable-blocks-import-form",
|
|
65
66
|
onSubmit: onSubmit,
|
|
66
|
-
ref: formRef
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
67
|
+
ref: formRef,
|
|
68
|
+
children: [error && /*#__PURE__*/_jsx(Notice, {
|
|
69
|
+
status: "error",
|
|
70
|
+
onRemove: () => onDismissError(),
|
|
71
|
+
children: error
|
|
72
|
+
}), /*#__PURE__*/_jsx("label", {
|
|
73
|
+
htmlFor: inputId,
|
|
74
|
+
className: "list-reusable-blocks-import-form__label",
|
|
75
|
+
children: __('File')
|
|
76
|
+
}), /*#__PURE__*/_jsx("input", {
|
|
77
|
+
id: inputId,
|
|
78
|
+
type: "file",
|
|
79
|
+
onChange: onChangeFile
|
|
80
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
81
|
+
type: "submit",
|
|
82
|
+
isBusy: isLoading,
|
|
83
|
+
disabled: !file || isLoading,
|
|
84
|
+
variant: "secondary",
|
|
85
|
+
className: "list-reusable-blocks-import-form__button",
|
|
86
|
+
children: _x('Import', 'button label')
|
|
87
|
+
})]
|
|
88
|
+
});
|
|
84
89
|
}
|
|
85
90
|
export default withInstanceId(ImportForm);
|
|
86
91
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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","
|
|
1
|
+
{"version":3,"names":["useState","useRef","withInstanceId","__","_x","Button","Notice","importReusableBlock","jsx","_jsx","jsxs","_jsxs","ImportForm","instanceId","onUpload","inputId","formRef","isLoading","setIsLoading","error","setError","file","setFile","onChangeFile","event","target","files","onSubmit","preventDefault","then","reusableBlock","catch","errors","uiMessage","message","onDismissError","className","ref","children","status","onRemove","htmlFor","id","type","onChange","isBusy","disabled","variant"],"sources":["@wordpress/list-reusable-blocks/src/components/import-form/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useRef } from '@wordpress/element';\nimport { withInstanceId } from '@wordpress/compose';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, Notice } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport importReusableBlock from '../../utils/import';\n\nfunction ImportForm( { instanceId, onUpload } ) {\n\tconst inputId = 'list-reusable-blocks-import-form-' + instanceId;\n\n\tconst formRef = useRef();\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst [ error, setError ] = useState( null );\n\tconst [ file, setFile ] = useState( null );\n\n\tconst onChangeFile = ( event ) => {\n\t\tsetFile( event.target.files[ 0 ] );\n\t\tsetError( null );\n\t};\n\n\tconst onSubmit = ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( ! file ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsLoading( { isLoading: true } );\n\t\timportReusableBlock( file )\n\t\t\t.then( ( reusableBlock ) => {\n\t\t\t\tif ( ! formRef ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetIsLoading( false );\n\t\t\t\tonUpload( reusableBlock );\n\t\t\t} )\n\t\t\t.catch( ( errors ) => {\n\t\t\t\tif ( ! formRef ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet uiMessage;\n\t\t\t\tswitch ( errors.message ) {\n\t\t\t\t\tcase 'Invalid JSON file':\n\t\t\t\t\t\tuiMessage = __( 'Invalid JSON file' );\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Invalid pattern JSON file':\n\t\t\t\t\t\tuiMessage = __( 'Invalid pattern JSON file' );\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tuiMessage = __( 'Unknown error' );\n\t\t\t\t}\n\n\t\t\t\tsetIsLoading( false );\n\t\t\t\tsetError( uiMessage );\n\t\t\t} );\n\t};\n\n\tconst onDismissError = () => {\n\t\tsetError( null );\n\t};\n\n\treturn (\n\t\t<form\n\t\t\tclassName=\"list-reusable-blocks-import-form\"\n\t\t\tonSubmit={ onSubmit }\n\t\t\tref={ formRef }\n\t\t>\n\t\t\t{ error && (\n\t\t\t\t<Notice status=\"error\" onRemove={ () => onDismissError() }>\n\t\t\t\t\t{ error }\n\t\t\t\t</Notice>\n\t\t\t) }\n\t\t\t<label\n\t\t\t\thtmlFor={ inputId }\n\t\t\t\tclassName=\"list-reusable-blocks-import-form__label\"\n\t\t\t>\n\t\t\t\t{ __( 'File' ) }\n\t\t\t</label>\n\t\t\t<input id={ inputId } type=\"file\" onChange={ onChangeFile } />\n\t\t\t<Button\n\t\t\t\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"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,MAAM,QAAQ,oBAAoB;AACrD,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,MAAM,EAAEC,MAAM,QAAQ,uBAAuB;;AAEtD;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,oBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAErD,SAASC,UAAUA,CAAE;EAAEC,UAA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,YAAY,CAAE,KAAM,CAAC;MACrBE,QAAQ,CAAEa,SAAU,CAAC;IACtB,CAAE,CAAC;EACL,CAAC;EAED,MAAME,cAAc,GAAGA,CAAA,KAAM;IAC5Bf,QAAQ,CAAE,IAAK,CAAC;EACjB,CAAC;EAED,oBACCT,KAAA;IACCyB,SAAS,EAAC,kCAAkC;IAC5CT,QAAQ,EAAGA,QAAU;IACrBU,GAAG,EAAGrB,OAAS;IAAAsB,QAAA,GAEbnB,KAAK,iBACNV,IAAA,CAACH,MAAM;MAACiC,MAAM,EAAC,OAAO;MAACC,QAAQ,EAAGA,CAAA,KAAML,cAAc,CAAC,CAAG;MAAAG,QAAA,EACvDnB;IAAK,CACA,CACR,eACDV,IAAA;MACCgC,OAAO,EAAG1B,OAAS;MACnBqB,SAAS,EAAC,yCAAyC;MAAAE,QAAA,EAEjDnC,EAAE,CAAE,MAAO;IAAC,CACR,CAAC,eACRM,IAAA;MAAOiC,EAAE,EAAG3B,OAAS;MAAC4B,IAAI,EAAC,MAAM;MAACC,QAAQ,EAAGrB;IAAc,CAAE,CAAC,eAC9Dd,IAAA,CAACJ,MAAM;MACNsC,IAAI,EAAC,QAAQ;MACbE,MAAM,EAAG5B,SAAW;MACpB6B,QAAQ,EAAG,CAAEzB,IAAI,IAAIJ,SAAW;MAChC8B,OAAO,EAAC,WAAW;MACnBX,SAAS,EAAC,0CAA0C;MAAAE,QAAA,EAElDlC,EAAE,CAAE,QAAQ,EAAE,cAAe;IAAC,CACzB,CAAC;EAAA,CACJ,CAAC;AAET;AAEA,eAAeF,cAAc,CAAEU,UAAW,CAAC","ignoreList":[]}
|
package/build-module/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
1
|
/**
|
|
3
2
|
* WordPress dependencies
|
|
4
3
|
*/
|
|
@@ -12,6 +11,7 @@ import exportReusableBlock from './utils/export';
|
|
|
12
11
|
import ImportDropdown from './components/import-dropdown';
|
|
13
12
|
|
|
14
13
|
// Setup Export Links.
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
document.body.addEventListener('click', event => {
|
|
16
16
|
if (!event.target.classList.contains('wp-list-reusable-blocks__export')) {
|
|
17
17
|
return;
|
|
@@ -39,7 +39,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
39
39
|
const container = document.createElement('div');
|
|
40
40
|
container.className = 'list-reusable-blocks__container';
|
|
41
41
|
button.parentNode.insertBefore(container, button);
|
|
42
|
-
createRoot(container).render(
|
|
42
|
+
createRoot(container).render( /*#__PURE__*/_jsx(ImportDropdown, {
|
|
43
43
|
onUpload: showNotice
|
|
44
44
|
}));
|
|
45
45
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createRoot","__","exportReusableBlock","ImportDropdown","document","body","addEventListener","event","target","classList","contains","preventDefault","dataset","id","button","querySelector","showNotice","notice","createElement","className","innerHTML","headerEnd","parentNode","insertBefore","container","render","onUpload"],"sources":["@wordpress/list-reusable-blocks/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRoot } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport exportReusableBlock from './utils/export';\nimport ImportDropdown from './components/import-dropdown';\n\n// Setup Export Links.\ndocument.body.addEventListener( 'click', ( event ) => {\n\tif (\n\t\t! event.target.classList.contains( 'wp-list-reusable-blocks__export' )\n\t) {\n\t\treturn;\n\t}\n\tevent.preventDefault();\n\texportReusableBlock( event.target.dataset.id );\n} );\n\n// Setup Import Form.\ndocument.addEventListener( 'DOMContentLoaded', () => {\n\tconst button = document.querySelector( '.page-title-action' );\n\tif ( ! button ) {\n\t\treturn;\n\t}\n\n\tconst showNotice = () => {\n\t\tconst notice = document.createElement( 'div' );\n\t\tnotice.className = 'notice notice-success is-dismissible';\n\t\tnotice.innerHTML = `<p>${ __( 'Pattern imported successfully!' ) }</p>`;\n\n\t\tconst headerEnd = document.querySelector( '.wp-header-end' );\n\t\tif ( ! headerEnd ) {\n\t\t\treturn;\n\t\t}\n\t\theaderEnd.parentNode.insertBefore( notice, headerEnd );\n\t};\n\n\tconst container = document.createElement( 'div' );\n\tcontainer.className = 'list-reusable-blocks__container';\n\tbutton.parentNode.insertBefore( container, button );\n\tcreateRoot( container ).render(\n\t\t<ImportDropdown onUpload={ showNotice } />\n\t);\n} );\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["createRoot","__","exportReusableBlock","ImportDropdown","jsx","_jsx","document","body","addEventListener","event","target","classList","contains","preventDefault","dataset","id","button","querySelector","showNotice","notice","createElement","className","innerHTML","headerEnd","parentNode","insertBefore","container","render","onUpload"],"sources":["@wordpress/list-reusable-blocks/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRoot } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport exportReusableBlock from './utils/export';\nimport ImportDropdown from './components/import-dropdown';\n\n// Setup Export Links.\ndocument.body.addEventListener( 'click', ( event ) => {\n\tif (\n\t\t! event.target.classList.contains( 'wp-list-reusable-blocks__export' )\n\t) {\n\t\treturn;\n\t}\n\tevent.preventDefault();\n\texportReusableBlock( event.target.dataset.id );\n} );\n\n// Setup Import Form.\ndocument.addEventListener( 'DOMContentLoaded', () => {\n\tconst button = document.querySelector( '.page-title-action' );\n\tif ( ! button ) {\n\t\treturn;\n\t}\n\n\tconst showNotice = () => {\n\t\tconst notice = document.createElement( 'div' );\n\t\tnotice.className = 'notice notice-success is-dismissible';\n\t\tnotice.innerHTML = `<p>${ __( 'Pattern imported successfully!' ) }</p>`;\n\n\t\tconst headerEnd = document.querySelector( '.wp-header-end' );\n\t\tif ( ! headerEnd ) {\n\t\t\treturn;\n\t\t}\n\t\theaderEnd.parentNode.insertBefore( notice, headerEnd );\n\t};\n\n\tconst container = document.createElement( 'div' );\n\tcontainer.className = 'list-reusable-blocks__container';\n\tbutton.parentNode.insertBefore( container, button );\n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AACL,SAAS,GAAG,iCAAiC;EACvDL,MAAM,CAACQ,UAAU,CAACC,YAAY,CAAEC,SAAS,EAAEV,MAAO,CAAC;EACnDhB,UAAU,CAAE0B,SAAU,CAAC,CAACC,MAAM,eAC7BtB,IAAA,CAACF,cAAc;IAACyB,QAAQ,EAAGV;EAAY,CAAE,CAC1C,CAAC;AACF,CAAE,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/list-reusable-blocks",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.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",
|
|
@@ -20,18 +20,19 @@
|
|
|
20
20
|
"url": "https://github.com/WordPress/gutenberg/issues"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
|
-
"node": ">=12"
|
|
23
|
+
"node": ">=18.12.0",
|
|
24
|
+
"npm": ">=8.19.2"
|
|
24
25
|
},
|
|
25
26
|
"main": "build/index.js",
|
|
26
27
|
"module": "build-module/index.js",
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"@babel/runtime": "^7.16.0",
|
|
29
|
-
"@wordpress/api-fetch": "^
|
|
30
|
-
"@wordpress/blob": "^
|
|
31
|
-
"@wordpress/components": "^
|
|
32
|
-
"@wordpress/compose": "^
|
|
33
|
-
"@wordpress/element": "^
|
|
34
|
-
"@wordpress/i18n": "^
|
|
30
|
+
"@wordpress/api-fetch": "^7.0.0",
|
|
31
|
+
"@wordpress/blob": "^4.0.0",
|
|
32
|
+
"@wordpress/components": "^28.0.0",
|
|
33
|
+
"@wordpress/compose": "^7.0.0",
|
|
34
|
+
"@wordpress/element": "^6.0.0",
|
|
35
|
+
"@wordpress/i18n": "^5.0.0",
|
|
35
36
|
"change-case": "^4.1.2"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
@@ -41,5 +42,5 @@
|
|
|
41
42
|
"publishConfig": {
|
|
42
43
|
"access": "public"
|
|
43
44
|
},
|
|
44
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "2f30cddff15723ac7017fd009fc5913b7b419400"
|
|
45
46
|
}
|