@wordpress/customize-widgets 5.32.0 → 5.32.1-next.ff1cebbba.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/build/components/block-appender/index.js +33 -27
- package/build/components/block-appender/index.js.map +7 -1
- package/build/components/block-inspector-button/index.js +51 -36
- package/build/components/block-inspector-button/index.js.map +7 -1
- package/build/components/customize-widgets/index.js +83 -61
- package/build/components/customize-widgets/index.js.map +7 -1
- package/build/components/customize-widgets/use-clear-selected-block.js +56 -63
- package/build/components/customize-widgets/use-clear-selected-block.js.map +7 -1
- package/build/components/error-boundary/index.js +46 -45
- package/build/components/error-boundary/index.js.map +7 -1
- package/build/components/focus-control/index.js +69 -57
- package/build/components/focus-control/index.js.map +7 -1
- package/build/components/focus-control/use-blocks-focus-control.js +38 -31
- package/build/components/focus-control/use-blocks-focus-control.js.map +7 -1
- package/build/components/header/index.js +110 -71
- package/build/components/header/index.js.map +7 -1
- package/build/components/inserter/index.js +77 -53
- package/build/components/inserter/index.js.map +7 -1
- package/build/components/inserter/use-inserter.js +46 -29
- package/build/components/inserter/use-inserter.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +74 -71
- package/build/components/keyboard-shortcut-help-modal/config.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +61 -44
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +155 -110
- package/build/components/keyboard-shortcut-help-modal/index.js.map +7 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +76 -56
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
- package/build/components/keyboard-shortcuts/index.js +60 -51
- package/build/components/keyboard-shortcuts/index.js.map +7 -1
- package/build/components/more-menu/index.js +151 -90
- package/build/components/more-menu/index.js.map +7 -1
- package/build/components/sidebar-block-editor/index.js +133 -105
- package/build/components/sidebar-block-editor/index.js.map +7 -1
- package/build/components/sidebar-block-editor/sidebar-adapter.js +73 -67
- package/build/components/sidebar-block-editor/sidebar-adapter.js.map +7 -1
- package/build/components/sidebar-block-editor/sidebar-editor-provider.js +51 -33
- package/build/components/sidebar-block-editor/sidebar-editor-provider.js.map +7 -1
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.js +100 -79
- package/build/components/sidebar-block-editor/use-sidebar-block-editor.js.map +7 -1
- package/build/components/sidebar-controls/index.js +45 -31
- package/build/components/sidebar-controls/index.js.map +7 -1
- package/build/components/welcome-guide/index.js +86 -58
- package/build/components/welcome-guide/index.js.map +7 -1
- package/build/controls/inserter-outer-section.js +49 -58
- package/build/controls/inserter-outer-section.js.map +7 -1
- package/build/controls/inspector-section.js +30 -36
- package/build/controls/inspector-section.js.map +7 -1
- package/build/controls/sidebar-control.js +51 -30
- package/build/controls/sidebar-control.js.map +7 -1
- package/build/controls/sidebar-section.js +71 -39
- package/build/controls/sidebar-section.js.map +7 -1
- package/build/filters/index.js +4 -6
- package/build/filters/index.js.map +7 -1
- package/build/filters/move-to-sidebar.js +77 -79
- package/build/filters/move-to-sidebar.js.map +7 -1
- package/build/filters/replace-media-upload.js +9 -11
- package/build/filters/replace-media-upload.js.map +7 -1
- package/build/filters/wide-widget-display.js +20 -25
- package/build/filters/wide-widget-display.js.map +7 -1
- package/build/index.js +81 -70
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/store/actions.js +27 -44
- package/build/store/actions.js.map +7 -1
- package/build/store/constants.js +27 -10
- package/build/store/constants.js.map +7 -1
- package/build/store/index.js +44 -40
- package/build/store/index.js.map +7 -1
- package/build/store/reducer.js +25 -19
- package/build/store/reducer.js.map +7 -1
- package/build/store/selectors.js +31 -44
- package/build/store/selectors.js.map +7 -1
- package/build/utils.js +45 -73
- package/build/utils.js.map +7 -1
- package/build-module/components/block-appender/index.js +17 -20
- package/build-module/components/block-appender/index.js.map +7 -1
- package/build-module/components/block-inspector-button/index.js +33 -30
- package/build-module/components/block-inspector-button/index.js.map +7 -1
- package/build-module/components/customize-widgets/index.js +52 -51
- package/build-module/components/customize-widgets/index.js.map +7 -1
- package/build-module/components/customize-widgets/use-clear-selected-block.js +38 -58
- package/build-module/components/customize-widgets/use-clear-selected-block.js.map +7 -1
- package/build-module/components/error-boundary/index.js +27 -37
- package/build-module/components/error-boundary/index.js.map +7 -1
- package/build-module/components/focus-control/index.js +50 -45
- package/build-module/components/focus-control/index.js.map +7 -1
- package/build-module/components/focus-control/use-blocks-focus-control.js +17 -22
- package/build-module/components/focus-control/use-blocks-focus-control.js.map +7 -1
- package/build-module/components/header/index.js +81 -63
- package/build-module/components/header/index.js.map +7 -1
- package/build-module/components/inserter/index.js +59 -47
- package/build-module/components/inserter/index.js.map +7 -1
- package/build-module/components/inserter/use-inserter.js +28 -23
- package/build-module/components/inserter/use-inserter.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +62 -75
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +33 -37
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +130 -103
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +7 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +58 -50
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
- package/build-module/components/keyboard-shortcuts/index.js +44 -44
- package/build-module/components/keyboard-shortcuts/index.js.map +7 -1
- package/build-module/components/more-menu/index.js +129 -84
- package/build-module/components/more-menu/index.js.map +7 -1
- package/build-module/components/sidebar-block-editor/index.js +109 -96
- package/build-module/components/sidebar-block-editor/index.js.map +7 -1
- package/build-module/components/sidebar-block-editor/sidebar-adapter.js +54 -59
- package/build-module/components/sidebar-block-editor/sidebar-adapter.js.map +7 -1
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js +22 -25
- package/build-module/components/sidebar-block-editor/sidebar-editor-provider.js.map +7 -1
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js +70 -70
- package/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js.map +7 -1
- package/build-module/components/sidebar-controls/index.js +24 -25
- package/build-module/components/sidebar-controls/index.js.map +7 -1
- package/build-module/components/welcome-guide/index.js +68 -52
- package/build-module/components/welcome-guide/index.js.map +7 -1
- package/build-module/controls/inserter-outer-section.js +31 -52
- package/build-module/controls/inserter-outer-section.js.map +7 -1
- package/build-module/controls/inspector-section.js +13 -32
- package/build-module/controls/inspector-section.js.map +7 -1
- package/build-module/controls/sidebar-control.js +22 -22
- package/build-module/controls/sidebar-control.js.map +7 -1
- package/build-module/controls/sidebar-section.js +43 -32
- package/build-module/controls/sidebar-section.js.map +7 -1
- package/build-module/filters/index.js +4 -7
- package/build-module/filters/index.js.map +7 -1
- package/build-module/filters/move-to-sidebar.js +83 -76
- package/build-module/filters/move-to-sidebar.js.map +7 -1
- package/build-module/filters/replace-media-upload.js +8 -7
- package/build-module/filters/replace-media-upload.js.map +7 -1
- package/build-module/filters/wide-widget-display.js +20 -22
- package/build-module/filters/wide-widget-display.js.map +7 -1
- package/build-module/index.js +53 -51
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/store/actions.js +6 -40
- package/build-module/store/actions.js.map +7 -1
- package/build-module/store/constants.js +5 -5
- package/build-module/store/constants.js.map +7 -1
- package/build-module/store/index.js +10 -30
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/reducer.js +7 -14
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/selectors.js +10 -40
- package/build-module/store/selectors.js.map +7 -1
- package/build-module/utils.js +21 -66
- package/build-module/utils.js.map +7 -1
- package/build-style/style-rtl.css +14 -149
- package/build-style/style.css +14 -149
- package/package.json +30 -23
- package/src/components/block-inspector-button/style.scss +3 -0
- package/src/components/header/style.scss +5 -0
- package/src/components/inserter/style.scss +3 -0
- package/src/components/keyboard-shortcut-help-modal/style.scss +2 -0
- package/src/components/more-menu/style.scss +2 -0
- package/src/components/sidebar-block-editor/style.scss +2 -0
- package/src/components/welcome-guide/style.scss +2 -0
- package/src/controls/style.scss +2 -0
- package/src/style.scss +10 -8
package/build/lock-unlock.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lock-unlock.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/customize-widgets'\n\t);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAiE;AAE1D,MAAM,EAAE,MAAM,OAAO,QAC3B;AAAA,EACC;AAAA,EACA;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/store/actions.js
CHANGED
|
@@ -1,50 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var actions_exports = {};
|
|
19
|
+
__export(actions_exports, {
|
|
20
|
+
setIsInserterOpened: () => setIsInserterOpened
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
/**
|
|
8
|
-
* Returns an action object used to open/close the inserter.
|
|
9
|
-
*
|
|
10
|
-
* @param {boolean|Object} value Whether the inserter should be
|
|
11
|
-
* opened (true) or closed (false).
|
|
12
|
-
* To specify an insertion point,
|
|
13
|
-
* use an object.
|
|
14
|
-
* @param {string} value.rootClientId The root client ID to insert at.
|
|
15
|
-
* @param {number} value.insertionIndex The index to insert at.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```js
|
|
19
|
-
* import { useState } from 'react';
|
|
20
|
-
* import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';
|
|
21
|
-
* import { __ } from '@wordpress/i18n';
|
|
22
|
-
* import { useDispatch } from '@wordpress/data';
|
|
23
|
-
* import { Button } from '@wordpress/components';
|
|
24
|
-
*
|
|
25
|
-
* const ExampleComponent = () => {
|
|
26
|
-
* const { setIsInserterOpened } = useDispatch( customizeWidgetsStore );
|
|
27
|
-
* const [ isOpen, setIsOpen ] = useState( false );
|
|
28
|
-
*
|
|
29
|
-
* return (
|
|
30
|
-
* <Button
|
|
31
|
-
* onClick={ () => {
|
|
32
|
-
* setIsInserterOpened( ! isOpen );
|
|
33
|
-
* setIsOpen( ! isOpen );
|
|
34
|
-
* } }
|
|
35
|
-
* >
|
|
36
|
-
* { __( 'Open/close inserter' ) }
|
|
37
|
-
* </Button>
|
|
38
|
-
* );
|
|
39
|
-
* };
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @return {Object} Action object.
|
|
43
|
-
*/
|
|
22
|
+
module.exports = __toCommonJS(actions_exports);
|
|
44
23
|
function setIsInserterOpened(value) {
|
|
45
24
|
return {
|
|
46
|
-
type:
|
|
25
|
+
type: "SET_IS_INSERTER_OPENED",
|
|
47
26
|
value
|
|
48
27
|
};
|
|
49
28
|
}
|
|
50
|
-
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
setIsInserterOpened
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/actions.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @example\n * ```js\n * import { useState } from 'react';\n * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { Button } from '@wordpress/components';\n *\n * const ExampleComponent = () => {\n * const { setIsInserterOpened } = useDispatch( customizeWidgetsStore );\n * const [ isOpen, setIsOpen ] = useState( false );\n *\n * return (\n * <Button\n * onClick={ () => {\n * setIsInserterOpened( ! isOpen );\n * setIsOpen( ! isOpen );\n * } }\n * >\n * { __( 'Open/close inserter' ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqCO,SAAS,oBAAqB,OAAQ;AAC5C,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/store/constants.js
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var constants_exports = {};
|
|
19
|
+
__export(constants_exports, {
|
|
20
|
+
STORE_NAME: () => STORE_NAME
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
22
|
+
module.exports = __toCommonJS(constants_exports);
|
|
23
|
+
const STORE_NAME = "core/customize-widgets";
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
STORE_NAME
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/constants.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Module Constants\n */\nexport const STORE_NAME = 'core/customize-widgets';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,aAAa;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/store/index.js
CHANGED
|
@@ -1,45 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var store_exports = {};
|
|
29
|
+
__export(store_exports, {
|
|
30
|
+
store: () => store
|
|
6
31
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var selectors =
|
|
11
|
-
var actions =
|
|
12
|
-
var
|
|
13
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
-
/**
|
|
16
|
-
* WordPress dependencies
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Internal dependencies
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Block editor data store configuration.
|
|
25
|
-
*
|
|
26
|
-
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registering-a-store
|
|
27
|
-
*
|
|
28
|
-
* @type {Object}
|
|
29
|
-
*/
|
|
32
|
+
module.exports = __toCommonJS(store_exports);
|
|
33
|
+
var import_data = require("@wordpress/data");
|
|
34
|
+
var import_reducer = __toESM(require("./reducer"));
|
|
35
|
+
var selectors = __toESM(require("./selectors"));
|
|
36
|
+
var actions = __toESM(require("./actions"));
|
|
37
|
+
var import_constants = require("./constants");
|
|
30
38
|
const storeConfig = {
|
|
31
|
-
reducer:
|
|
39
|
+
reducer: import_reducer.default,
|
|
32
40
|
selectors,
|
|
33
41
|
actions
|
|
34
42
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*/
|
|
43
|
-
const store = exports.store = (0, _data.createReduxStore)(_constants.STORE_NAME, storeConfig);
|
|
44
|
-
(0, _data.register)(store);
|
|
45
|
-
//# sourceMappingURL=index.js.map
|
|
43
|
+
const store = (0, import_data.createReduxStore)(import_constants.STORE_NAME, storeConfig);
|
|
44
|
+
(0, import_data.register)(store);
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
store
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
package/build/store/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport { STORE_NAME } from './constants';\n\n/**\n * Block editor data store configuration.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registering-a-store\n *\n * @type {Object}\n */\nconst storeConfig = {\n\treducer,\n\tselectors,\n\tactions,\n};\n\n/**\n * Store definition for the edit widgets namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig );\nregister( store );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA2C;AAK3C,qBAAoB;AACpB,gBAA2B;AAC3B,cAAyB;AACzB,uBAA2B;AAS3B,MAAM,cAAc;AAAA,EACnB,wBAAAA;AAAA,EACA;AAAA,EACA;AACD;AASO,MAAM,YAAQ,8BAAkB,6BAAY,WAAY;AAAA,IAC/D,sBAAU,KAAM;",
|
|
6
|
+
"names": ["reducer"]
|
|
7
|
+
}
|
package/build/store/reducer.js
CHANGED
|
@@ -1,28 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var reducer_exports = {};
|
|
19
|
+
__export(reducer_exports, {
|
|
20
|
+
default: () => reducer_default
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
/**
|
|
9
|
-
* WordPress dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Reducer tracking whether the inserter is open.
|
|
14
|
-
*
|
|
15
|
-
* @param {boolean|Object} state
|
|
16
|
-
* @param {Object} action
|
|
17
|
-
*/
|
|
22
|
+
module.exports = __toCommonJS(reducer_exports);
|
|
23
|
+
var import_data = require("@wordpress/data");
|
|
18
24
|
function blockInserterPanel(state = false, action) {
|
|
19
25
|
switch (action.type) {
|
|
20
|
-
case
|
|
26
|
+
case "SET_IS_INSERTER_OPENED":
|
|
21
27
|
return action.value;
|
|
22
28
|
}
|
|
23
29
|
return state;
|
|
24
30
|
}
|
|
25
|
-
var
|
|
31
|
+
var reducer_default = (0, import_data.combineReducers)({
|
|
26
32
|
blockInserterPanel
|
|
27
33
|
});
|
|
28
|
-
//# sourceMappingURL=reducer.js.map
|
|
34
|
+
//# sourceMappingURL=reducer.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/reducer.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer tracking whether the inserter is open.\n *\n * @param {boolean|Object} state\n * @param {Object} action\n */\nfunction blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tblockInserterPanel,\n} );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAQhC,SAAS,mBAAoB,QAAQ,OAAO,QAAS;AACpD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO,OAAO;AAAA,EAChB;AACA,SAAO;AACR;AAEA,IAAO,sBAAQ,6BAAiB;AAAA,EAC/B;AACD,CAAE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/store/selectors.js
CHANGED
|
@@ -1,55 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var selectors_exports = {};
|
|
19
|
+
__export(selectors_exports, {
|
|
20
|
+
__experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint,
|
|
21
|
+
isInserterOpened: () => isInserterOpened
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
exports.isInserterOpened = isInserterOpened;
|
|
23
|
+
module.exports = __toCommonJS(selectors_exports);
|
|
8
24
|
const EMPTY_INSERTION_POINT = {
|
|
9
|
-
rootClientId:
|
|
10
|
-
insertionIndex:
|
|
25
|
+
rootClientId: void 0,
|
|
26
|
+
insertionIndex: void 0
|
|
11
27
|
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Returns true if the inserter is opened.
|
|
15
|
-
*
|
|
16
|
-
* @param {Object} state Global application state.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```js
|
|
20
|
-
* import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';
|
|
21
|
-
* import { __ } from '@wordpress/i18n';
|
|
22
|
-
* import { useSelect } from '@wordpress/data';
|
|
23
|
-
*
|
|
24
|
-
* const ExampleComponent = () => {
|
|
25
|
-
* const { isInserterOpened } = useSelect(
|
|
26
|
-
* ( select ) => select( customizeWidgetsStore ),
|
|
27
|
-
* []
|
|
28
|
-
* );
|
|
29
|
-
*
|
|
30
|
-
* return isInserterOpened()
|
|
31
|
-
* ? __( 'Inserter is open' )
|
|
32
|
-
* : __( 'Inserter is closed.' );
|
|
33
|
-
* };
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @return {boolean} Whether the inserter is opened.
|
|
37
|
-
*/
|
|
38
28
|
function isInserterOpened(state) {
|
|
39
29
|
return !!state.blockInserterPanel;
|
|
40
30
|
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Get the insertion point for the inserter.
|
|
44
|
-
*
|
|
45
|
-
* @param {Object} state Global application state.
|
|
46
|
-
*
|
|
47
|
-
* @return {Object} The root client ID and index to insert at.
|
|
48
|
-
*/
|
|
49
31
|
function __experimentalGetInsertionPoint(state) {
|
|
50
|
-
if (typeof state.blockInserterPanel ===
|
|
32
|
+
if (typeof state.blockInserterPanel === "boolean") {
|
|
51
33
|
return EMPTY_INSERTION_POINT;
|
|
52
34
|
}
|
|
53
35
|
return state.blockInserterPanel;
|
|
54
36
|
}
|
|
55
|
-
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
__experimentalGetInsertionPoint,
|
|
40
|
+
isInserterOpened
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=selectors.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/store/selectors.js"],
|
|
4
|
+
"sourcesContent": ["const EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n};\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @example\n * ```js\n * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';\n * import { __ } from '@wordpress/i18n';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * const { isInserterOpened } = useSelect(\n * ( select ) => select( customizeWidgetsStore ),\n * []\n * );\n *\n * return isInserterOpened()\n * ? __( 'Inserter is open' )\n * : __( 'Inserter is closed.' );\n * };\n * ```\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tif ( typeof state.blockInserterPanel === 'boolean' ) {\n\t\treturn EMPTY_INSERTION_POINT;\n\t}\n\n\treturn state.blockInserterPanel;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,wBAAwB;AAAA,EAC7B,cAAc;AAAA,EACd,gBAAgB;AACjB;AA2BO,SAAS,iBAAkB,OAAQ;AACzC,SAAO,CAAC,CAAE,MAAM;AACjB;AASO,SAAS,gCAAiC,OAAQ;AACxD,MAAK,OAAO,MAAM,uBAAuB,WAAY;AACpD,WAAO;AAAA,EACR;AAEA,SAAO,MAAM;AACd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/utils.js
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var utils_exports = {};
|
|
19
|
+
__export(utils_exports, {
|
|
20
|
+
blockToWidget: () => blockToWidget,
|
|
21
|
+
settingIdToWidgetId: () => settingIdToWidgetId,
|
|
22
|
+
widgetToBlock: () => widgetToBlock
|
|
5
23
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _blocks = require("@wordpress/blocks");
|
|
10
|
-
var _widgets = require("@wordpress/widgets");
|
|
11
|
-
// @ts-check
|
|
12
|
-
/**
|
|
13
|
-
* WordPress dependencies
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Convert settingId to widgetId.
|
|
18
|
-
*
|
|
19
|
-
* @param {string} settingId The setting id.
|
|
20
|
-
* @return {string} The widget id.
|
|
21
|
-
*/
|
|
24
|
+
module.exports = __toCommonJS(utils_exports);
|
|
25
|
+
var import_blocks = require("@wordpress/blocks");
|
|
26
|
+
var import_widgets = require("@wordpress/widgets");
|
|
22
27
|
function settingIdToWidgetId(settingId) {
|
|
23
28
|
const matches = settingId.match(/^widget_(.+)(?:\[(\d+)\])$/);
|
|
24
29
|
if (matches) {
|
|
@@ -28,32 +33,16 @@ function settingIdToWidgetId(settingId) {
|
|
|
28
33
|
}
|
|
29
34
|
return settingId;
|
|
30
35
|
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Transform a block to a customizable widget.
|
|
34
|
-
*
|
|
35
|
-
* @param {WPBlock} block The block to be transformed from.
|
|
36
|
-
* @param {Object} existingWidget The widget to be extended from.
|
|
37
|
-
* @return {Object} The transformed widget.
|
|
38
|
-
*/
|
|
39
36
|
function blockToWidget(block, existingWidget = null) {
|
|
40
37
|
let widget;
|
|
41
|
-
const isValidLegacyWidgetBlock = block.name ===
|
|
38
|
+
const isValidLegacyWidgetBlock = block.name === "core/legacy-widget" && (block.attributes.id || block.attributes.instance);
|
|
42
39
|
if (isValidLegacyWidgetBlock) {
|
|
43
40
|
if (block.attributes.id) {
|
|
44
|
-
// Widget that does not extend WP_Widget.
|
|
45
41
|
widget = {
|
|
46
42
|
id: block.attributes.id
|
|
47
43
|
};
|
|
48
44
|
} else {
|
|
49
|
-
const {
|
|
50
|
-
encoded,
|
|
51
|
-
hash,
|
|
52
|
-
raw,
|
|
53
|
-
...rest
|
|
54
|
-
} = block.attributes.instance;
|
|
55
|
-
|
|
56
|
-
// Widget that extends WP_Widget.
|
|
45
|
+
const { encoded, hash, raw, ...rest } = block.attributes.instance;
|
|
57
46
|
widget = {
|
|
58
47
|
idBase: block.attributes.idBase,
|
|
59
48
|
instance: {
|
|
@@ -69,43 +58,23 @@ function blockToWidget(block, existingWidget = null) {
|
|
|
69
58
|
}
|
|
70
59
|
} else {
|
|
71
60
|
const instance = {
|
|
72
|
-
content: (0,
|
|
61
|
+
content: (0, import_blocks.serialize)(block)
|
|
73
62
|
};
|
|
74
63
|
widget = {
|
|
75
|
-
idBase:
|
|
76
|
-
widgetClass:
|
|
64
|
+
idBase: "block",
|
|
65
|
+
widgetClass: "WP_Widget_Block",
|
|
77
66
|
instance: {
|
|
78
67
|
raw_instance: instance
|
|
79
68
|
}
|
|
80
69
|
};
|
|
81
70
|
}
|
|
82
|
-
const {
|
|
83
|
-
form,
|
|
84
|
-
rendered,
|
|
85
|
-
...restExistingWidget
|
|
86
|
-
} = existingWidget || {};
|
|
71
|
+
const { form, rendered, ...restExistingWidget } = existingWidget || {};
|
|
87
72
|
return {
|
|
88
73
|
...restExistingWidget,
|
|
89
74
|
...widget
|
|
90
75
|
};
|
|
91
76
|
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Transform a widget to a block.
|
|
95
|
-
*
|
|
96
|
-
* @param {Object} widget The widget to be transformed from.
|
|
97
|
-
* @param {string} widget.id The widget id.
|
|
98
|
-
* @param {string} widget.idBase The id base of the widget.
|
|
99
|
-
* @param {number} widget.number The number/index of the widget.
|
|
100
|
-
* @param {Object} widget.instance The instance of the widget.
|
|
101
|
-
* @return {WPBlock} The transformed block.
|
|
102
|
-
*/
|
|
103
|
-
function widgetToBlock({
|
|
104
|
-
id,
|
|
105
|
-
idBase,
|
|
106
|
-
number,
|
|
107
|
-
instance
|
|
108
|
-
}) {
|
|
77
|
+
function widgetToBlock({ id, idBase, number, instance }) {
|
|
109
78
|
let block;
|
|
110
79
|
const {
|
|
111
80
|
encoded_serialized_instance: encoded,
|
|
@@ -113,15 +82,13 @@ function widgetToBlock({
|
|
|
113
82
|
raw_instance: raw,
|
|
114
83
|
...rest
|
|
115
84
|
} = instance;
|
|
116
|
-
if (idBase ===
|
|
117
|
-
|
|
118
|
-
const parsedBlocks = (0, _blocks.parse)((_raw$content = raw.content) !== null && _raw$content !== void 0 ? _raw$content : '', {
|
|
85
|
+
if (idBase === "block") {
|
|
86
|
+
const parsedBlocks = (0, import_blocks.parse)(raw.content ?? "", {
|
|
119
87
|
__unstableSkipAutop: true
|
|
120
88
|
});
|
|
121
|
-
block = parsedBlocks.length ? parsedBlocks[0] : (0,
|
|
89
|
+
block = parsedBlocks.length ? parsedBlocks[0] : (0, import_blocks.createBlock)("core/paragraph", {});
|
|
122
90
|
} else if (number) {
|
|
123
|
-
|
|
124
|
-
block = (0, _blocks.createBlock)('core/legacy-widget', {
|
|
91
|
+
block = (0, import_blocks.createBlock)("core/legacy-widget", {
|
|
125
92
|
idBase,
|
|
126
93
|
instance: {
|
|
127
94
|
encoded,
|
|
@@ -131,11 +98,16 @@ function widgetToBlock({
|
|
|
131
98
|
}
|
|
132
99
|
});
|
|
133
100
|
} else {
|
|
134
|
-
|
|
135
|
-
block = (0, _blocks.createBlock)('core/legacy-widget', {
|
|
101
|
+
block = (0, import_blocks.createBlock)("core/legacy-widget", {
|
|
136
102
|
id
|
|
137
103
|
});
|
|
138
104
|
}
|
|
139
|
-
return (0,
|
|
105
|
+
return (0, import_widgets.addWidgetIdToBlock)(block, id);
|
|
140
106
|
}
|
|
141
|
-
|
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
+
0 && (module.exports = {
|
|
109
|
+
blockToWidget,
|
|
110
|
+
settingIdToWidgetId,
|
|
111
|
+
widgetToBlock
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=utils.js.map
|
package/build/utils.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils.js"],
|
|
4
|
+
"sourcesContent": ["// @ts-check\n/**\n * WordPress dependencies\n */\nimport { serialize, parse, createBlock } from '@wordpress/blocks';\nimport { addWidgetIdToBlock } from '@wordpress/widgets';\n\n/**\n * Convert settingId to widgetId.\n *\n * @param {string} settingId The setting id.\n * @return {string} The widget id.\n */\nexport function settingIdToWidgetId( settingId ) {\n\tconst matches = settingId.match( /^widget_(.+)(?:\\[(\\d+)\\])$/ );\n\n\tif ( matches ) {\n\t\tconst idBase = matches[ 1 ];\n\t\tconst number = parseInt( matches[ 2 ], 10 );\n\n\t\treturn `${ idBase }-${ number }`;\n\t}\n\n\treturn settingId;\n}\n\n/**\n * Transform a block to a customizable widget.\n *\n * @param {WPBlock} block The block to be transformed from.\n * @param {Object} existingWidget The widget to be extended from.\n * @return {Object} The transformed widget.\n */\nexport function blockToWidget( block, existingWidget = null ) {\n\tlet widget;\n\n\tconst isValidLegacyWidgetBlock =\n\t\tblock.name === 'core/legacy-widget' &&\n\t\t( block.attributes.id || block.attributes.instance );\n\n\tif ( isValidLegacyWidgetBlock ) {\n\t\tif ( block.attributes.id ) {\n\t\t\t// Widget that does not extend WP_Widget.\n\t\t\twidget = {\n\t\t\t\tid: block.attributes.id,\n\t\t\t};\n\t\t} else {\n\t\t\tconst { encoded, hash, raw, ...rest } = block.attributes.instance;\n\n\t\t\t// Widget that extends WP_Widget.\n\t\t\twidget = {\n\t\t\t\tidBase: block.attributes.idBase,\n\t\t\t\tinstance: {\n\t\t\t\t\t...existingWidget?.instance,\n\t\t\t\t\t// Required only for the customizer.\n\t\t\t\t\tis_widget_customizer_js_value: true,\n\t\t\t\t\tencoded_serialized_instance: encoded,\n\t\t\t\t\tinstance_hash_key: hash,\n\t\t\t\t\traw_instance: raw,\n\t\t\t\t\t...rest,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t} else {\n\t\tconst instance = {\n\t\t\tcontent: serialize( block ),\n\t\t};\n\t\twidget = {\n\t\t\tidBase: 'block',\n\t\t\twidgetClass: 'WP_Widget_Block',\n\t\t\tinstance: {\n\t\t\t\traw_instance: instance,\n\t\t\t},\n\t\t};\n\t}\n\n\tconst { form, rendered, ...restExistingWidget } = existingWidget || {};\n\n\treturn {\n\t\t...restExistingWidget,\n\t\t...widget,\n\t};\n}\n\n/**\n * Transform a widget to a block.\n *\n * @param {Object} widget The widget to be transformed from.\n * @param {string} widget.id The widget id.\n * @param {string} widget.idBase The id base of the widget.\n * @param {number} widget.number The number/index of the widget.\n * @param {Object} widget.instance The instance of the widget.\n * @return {WPBlock} The transformed block.\n */\nexport function widgetToBlock( { id, idBase, number, instance } ) {\n\tlet block;\n\n\tconst {\n\t\tencoded_serialized_instance: encoded,\n\t\tinstance_hash_key: hash,\n\t\traw_instance: raw,\n\t\t...rest\n\t} = instance;\n\n\tif ( idBase === 'block' ) {\n\t\tconst parsedBlocks = parse( raw.content ?? '', {\n\t\t\t__unstableSkipAutop: true,\n\t\t} );\n\t\tblock = parsedBlocks.length\n\t\t\t? parsedBlocks[ 0 ]\n\t\t\t: createBlock( 'core/paragraph', {} );\n\t} else if ( number ) {\n\t\t// Widget that extends WP_Widget.\n\t\tblock = createBlock( 'core/legacy-widget', {\n\t\t\tidBase,\n\t\t\tinstance: {\n\t\t\t\tencoded,\n\t\t\t\thash,\n\t\t\t\traw,\n\t\t\t\t...rest,\n\t\t\t},\n\t\t} );\n\t} else {\n\t\t// Widget that does not extend WP_Widget.\n\t\tblock = createBlock( 'core/legacy-widget', {\n\t\t\tid,\n\t\t} );\n\t}\n\n\treturn addWidgetIdToBlock( block, id );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAA8C;AAC9C,qBAAmC;AAQ5B,SAAS,oBAAqB,WAAY;AAChD,QAAM,UAAU,UAAU,MAAO,4BAA6B;AAE9D,MAAK,SAAU;AACd,UAAM,SAAS,QAAS,CAAE;AAC1B,UAAM,SAAS,SAAU,QAAS,CAAE,GAAG,EAAG;AAE1C,WAAO,GAAI,MAAO,IAAK,MAAO;AAAA,EAC/B;AAEA,SAAO;AACR;AASO,SAAS,cAAe,OAAO,iBAAiB,MAAO;AAC7D,MAAI;AAEJ,QAAM,2BACL,MAAM,SAAS,yBACb,MAAM,WAAW,MAAM,MAAM,WAAW;AAE3C,MAAK,0BAA2B;AAC/B,QAAK,MAAM,WAAW,IAAK;AAE1B,eAAS;AAAA,QACR,IAAI,MAAM,WAAW;AAAA,MACtB;AAAA,IACD,OAAO;AACN,YAAM,EAAE,SAAS,MAAM,KAAK,GAAG,KAAK,IAAI,MAAM,WAAW;AAGzD,eAAS;AAAA,QACR,QAAQ,MAAM,WAAW;AAAA,QACzB,UAAU;AAAA,UACT,GAAG,gBAAgB;AAAA;AAAA,UAEnB,+BAA+B;AAAA,UAC/B,6BAA6B;AAAA,UAC7B,mBAAmB;AAAA,UACnB,cAAc;AAAA,UACd,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,IACD;AAAA,EACD,OAAO;AACN,UAAM,WAAW;AAAA,MAChB,aAAS,yBAAW,KAAM;AAAA,IAC3B;AACA,aAAS;AAAA,MACR,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,UAAU;AAAA,QACT,cAAc;AAAA,MACf;AAAA,IACD;AAAA,EACD;AAEA,QAAM,EAAE,MAAM,UAAU,GAAG,mBAAmB,IAAI,kBAAkB,CAAC;AAErE,SAAO;AAAA,IACN,GAAG;AAAA,IACH,GAAG;AAAA,EACJ;AACD;AAYO,SAAS,cAAe,EAAE,IAAI,QAAQ,QAAQ,SAAS,GAAI;AACjE,MAAI;AAEJ,QAAM;AAAA,IACL,6BAA6B;AAAA,IAC7B,mBAAmB;AAAA,IACnB,cAAc;AAAA,IACd,GAAG;AAAA,EACJ,IAAI;AAEJ,MAAK,WAAW,SAAU;AACzB,UAAM,mBAAe,qBAAO,IAAI,WAAW,IAAI;AAAA,MAC9C,qBAAqB;AAAA,IACtB,CAAE;AACF,YAAQ,aAAa,SAClB,aAAc,CAAE,QAChB,2BAAa,kBAAkB,CAAC,CAAE;AAAA,EACtC,WAAY,QAAS;AAEpB,gBAAQ,2BAAa,sBAAsB;AAAA,MAC1C;AAAA,MACA,UAAU;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MACJ;AAAA,IACD,CAAE;AAAA,EACH,OAAO;AAEN,gBAAQ,2BAAa,sBAAsB;AAAA,MAC1C;AAAA,IACD,CAAE;AAAA,EACH;AAEA,aAAO,mCAAoB,OAAO,EAAG;AACtC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|