@wordpress/widgets 4.32.0 → 4.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/blocks/legacy-widget/block.json +29 -0
- package/build/blocks/legacy-widget/edit/control.js +137 -167
- package/build/blocks/legacy-widget/edit/control.js.map +7 -1
- package/build/blocks/legacy-widget/edit/convert-to-blocks-button.js +51 -39
- package/build/blocks/legacy-widget/edit/convert-to-blocks-button.js.map +7 -1
- package/build/blocks/legacy-widget/edit/form.js +105 -75
- package/build/blocks/legacy-widget/edit/form.js.map +7 -1
- package/build/blocks/legacy-widget/edit/index.js +121 -131
- package/build/blocks/legacy-widget/edit/index.js.map +7 -1
- package/build/blocks/legacy-widget/edit/inspector-card.js +28 -20
- package/build/blocks/legacy-widget/edit/inspector-card.js.map +7 -1
- package/build/blocks/legacy-widget/edit/no-preview.js +29 -23
- package/build/blocks/legacy-widget/edit/no-preview.js.map +7 -1
- package/build/blocks/legacy-widget/edit/preview.js +107 -108
- package/build/blocks/legacy-widget/edit/preview.js.map +7 -1
- package/build/blocks/legacy-widget/edit/widget-type-selector.js +61 -52
- package/build/blocks/legacy-widget/edit/widget-type-selector.js.map +7 -1
- package/build/blocks/legacy-widget/index.js +49 -53
- package/build/blocks/legacy-widget/index.js.map +7 -1
- package/build/blocks/legacy-widget/transforms.js +189 -198
- package/build/blocks/legacy-widget/transforms.js.map +7 -1
- package/build/blocks/widget-group/block.json +20 -0
- package/build/blocks/widget-group/deprecated.js +38 -24
- package/build/blocks/widget-group/deprecated.js.map +7 -1
- package/build/blocks/widget-group/edit.js +63 -67
- package/build/blocks/widget-group/edit.js.map +7 -1
- package/build/blocks/widget-group/index.js +93 -80
- package/build/blocks/widget-group/index.js.map +7 -1
- package/build/blocks/widget-group/save.js +36 -25
- package/build/blocks/widget-group/save.js.map +7 -1
- package/build/components/index.js +36 -12
- package/build/components/index.js.map +7 -1
- package/build/components/move-to-widget-area/index.js +48 -37
- package/build/components/move-to-widget-area/index.js.map +7 -1
- package/build/index.js +67 -98
- package/build/index.js.map +7 -1
- package/build/register-legacy-widget-variations.js +42 -30
- package/build/register-legacy-widget-variations.js.map +7 -1
- package/build/utils.js +29 -29
- package/build/utils.js.map +7 -1
- package/build-module/blocks/legacy-widget/block.json +29 -0
- package/build-module/blocks/legacy-widget/edit/control.js +107 -158
- package/build-module/blocks/legacy-widget/edit/control.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/convert-to-blocks-button.js +33 -33
- package/build-module/blocks/legacy-widget/edit/convert-to-blocks-button.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/form.js +75 -64
- package/build-module/blocks/legacy-widget/edit/form.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/index.js +96 -122
- package/build-module/blocks/legacy-widget/edit/index.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/inspector-card.js +10 -15
- package/build-module/blocks/legacy-widget/edit/inspector-card.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/no-preview.js +11 -17
- package/build-module/blocks/legacy-widget/edit/no-preview.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/preview.js +76 -98
- package/build-module/blocks/legacy-widget/edit/preview.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/widget-type-selector.js +43 -46
- package/build-module/blocks/legacy-widget/edit/widget-type-selector.js.map +7 -1
- package/build-module/blocks/legacy-widget/index.js +12 -45
- package/build-module/blocks/legacy-widget/index.js.map +7 -1
- package/build-module/blocks/legacy-widget/transforms.js +171 -192
- package/build-module/blocks/legacy-widget/transforms.js.map +7 -1
- package/build-module/blocks/widget-group/block.json +20 -0
- package/build-module/blocks/widget-group/deprecated.js +20 -18
- package/build-module/blocks/widget-group/deprecated.js.map +7 -1
- package/build-module/blocks/widget-group/edit.js +53 -62
- package/build-module/blocks/widget-group/edit.js.map +7 -1
- package/build-module/blocks/widget-group/index.js +55 -71
- package/build-module/blocks/widget-group/index.js.map +7 -1
- package/build-module/blocks/widget-group/save.js +18 -19
- package/build-module/blocks/widget-group/save.js.map +7 -1
- package/build-module/components/index.js +5 -2
- package/build-module/components/index.js.map +7 -1
- package/build-module/components/move-to-widget-area/index.js +37 -32
- package/build-module/components/move-to-widget-area/index.js.map +7 -1
- package/build-module/index.js +34 -60
- package/build-module/index.js.map +7 -1
- package/build-module/register-legacy-widget-variations.js +24 -24
- package/build-module/register-legacy-widget-variations.js.map +7 -1
- package/build-module/utils.js +8 -25
- package/build-module/utils.js.map +7 -1
- package/build-style/style-rtl.css +10 -145
- package/build-style/style.css +10 -145
- package/package.json +21 -14
- package/src/blocks/legacy-widget/editor.scss +3 -0
- package/src/blocks/widget-group/editor.scss +3 -0
- package/src/style.scss +3 -2
|
@@ -1,41 +1,53 @@
|
|
|
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 convert_to_blocks_button_exports = {};
|
|
19
|
+
__export(convert_to_blocks_button_exports, {
|
|
20
|
+
default: () => ConvertToBlocksButton
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
children: (0, _i18n.__)('Convert to blocks')
|
|
39
|
-
});
|
|
22
|
+
module.exports = __toCommonJS(convert_to_blocks_button_exports);
|
|
23
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
24
|
+
var import_data = require("@wordpress/data");
|
|
25
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
26
|
+
var import_components = require("@wordpress/components");
|
|
27
|
+
var import_blocks = require("@wordpress/blocks");
|
|
28
|
+
var import_i18n = require("@wordpress/i18n");
|
|
29
|
+
function ConvertToBlocksButton({ clientId, rawInstance }) {
|
|
30
|
+
const { replaceBlocks } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
32
|
+
import_components.ToolbarButton,
|
|
33
|
+
{
|
|
34
|
+
onClick: () => {
|
|
35
|
+
if (rawInstance.title) {
|
|
36
|
+
replaceBlocks(clientId, [
|
|
37
|
+
(0, import_blocks.createBlock)("core/heading", {
|
|
38
|
+
content: rawInstance.title
|
|
39
|
+
}),
|
|
40
|
+
...(0, import_blocks.rawHandler)({ HTML: rawInstance.text })
|
|
41
|
+
]);
|
|
42
|
+
} else {
|
|
43
|
+
replaceBlocks(
|
|
44
|
+
clientId,
|
|
45
|
+
(0, import_blocks.rawHandler)({ HTML: rawInstance.text })
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
children: (0, import_i18n.__)("Convert to blocks")
|
|
50
|
+
}
|
|
51
|
+
);
|
|
40
52
|
}
|
|
41
|
-
//# sourceMappingURL=convert-to-blocks-button.js.map
|
|
53
|
+
//# sourceMappingURL=convert-to-blocks-button.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/blocks/legacy-widget/edit/convert-to-blocks-button.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { ToolbarButton } from '@wordpress/components';\nimport { createBlock, rawHandler } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\nexport default function ConvertToBlocksButton( { clientId, rawInstance } ) {\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<ToolbarButton\n\t\t\tonClick={ () => {\n\t\t\t\tif ( rawInstance.title ) {\n\t\t\t\t\treplaceBlocks( clientId, [\n\t\t\t\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\t\t\t\tcontent: rawInstance.title,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\t...rawHandler( { HTML: rawInstance.text } ),\n\t\t\t\t\t] );\n\t\t\t\t} else {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\trawHandler( { HTML: rawInstance.text } )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Convert to blocks' ) }\n\t\t</ToolbarButton>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaE;AAVF,kBAA4B;AAC5B,0BAA0C;AAC1C,wBAA8B;AAC9B,oBAAwC;AACxC,kBAAmB;AAEJ,SAAR,sBAAwC,EAAE,UAAU,YAAY,GAAI;AAC1E,QAAM,EAAE,cAAc,QAAI,yBAAa,oBAAAA,KAAiB;AAExD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAU,MAAM;AACf,YAAK,YAAY,OAAQ;AACxB,wBAAe,UAAU;AAAA,gBACxB,2BAAa,gBAAgB;AAAA,cAC5B,SAAS,YAAY;AAAA,YACtB,CAAE;AAAA,YACF,OAAG,0BAAY,EAAE,MAAM,YAAY,KAAK,CAAE;AAAA,UAC3C,CAAE;AAAA,QACH,OAAO;AACN;AAAA,YACC;AAAA,gBACA,0BAAY,EAAE,MAAM,YAAY,KAAK,CAAE;AAAA,UACxC;AAAA,QACD;AAAA,MACD;AAAA,MAEE,8BAAI,mBAAoB;AAAA;AAAA,EAC3B;AAEF;",
|
|
6
|
+
"names": ["blockEditorStore"]
|
|
7
|
+
}
|
|
@@ -1,31 +1,44 @@
|
|
|
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 form_exports = {};
|
|
29
|
+
__export(form_exports, {
|
|
30
|
+
default: () => Form
|
|
6
31
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
/**
|
|
18
|
-
* External dependencies
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* WordPress dependencies
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Internal dependencies
|
|
27
|
-
*/
|
|
28
|
-
|
|
32
|
+
module.exports = __toCommonJS(form_exports);
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_clsx = __toESM(require("clsx"));
|
|
35
|
+
var import_element = require("@wordpress/element");
|
|
36
|
+
var import_data = require("@wordpress/data");
|
|
37
|
+
var import_notices = require("@wordpress/notices");
|
|
38
|
+
var import_i18n = require("@wordpress/i18n");
|
|
39
|
+
var import_components = require("@wordpress/components");
|
|
40
|
+
var import_compose = require("@wordpress/compose");
|
|
41
|
+
var import_control = __toESM(require("./control"));
|
|
29
42
|
function Form({
|
|
30
43
|
title,
|
|
31
44
|
isVisible,
|
|
@@ -36,24 +49,17 @@ function Form({
|
|
|
36
49
|
onChangeInstance,
|
|
37
50
|
onChangeHasPreview
|
|
38
51
|
}) {
|
|
39
|
-
const ref = (0,
|
|
40
|
-
const isMediumLargeViewport = (0,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// ignore those.
|
|
46
|
-
const outgoingInstances = (0, _element.useRef)(new Set());
|
|
47
|
-
const incomingInstances = (0, _element.useRef)(new Set());
|
|
48
|
-
const {
|
|
49
|
-
createNotice
|
|
50
|
-
} = (0, _data.useDispatch)(_notices.store);
|
|
51
|
-
(0, _element.useEffect)(() => {
|
|
52
|
+
const ref = (0, import_element.useRef)();
|
|
53
|
+
const isMediumLargeViewport = (0, import_compose.useViewportMatch)("small");
|
|
54
|
+
const outgoingInstances = (0, import_element.useRef)(/* @__PURE__ */ new Set());
|
|
55
|
+
const incomingInstances = (0, import_element.useRef)(/* @__PURE__ */ new Set());
|
|
56
|
+
const { createNotice } = (0, import_data.useDispatch)(import_notices.store);
|
|
57
|
+
(0, import_element.useEffect)(() => {
|
|
52
58
|
if (incomingInstances.current.has(instance)) {
|
|
53
59
|
incomingInstances.current.delete(instance);
|
|
54
60
|
return;
|
|
55
61
|
}
|
|
56
|
-
const control = new
|
|
62
|
+
const control = new import_control.default({
|
|
57
63
|
id,
|
|
58
64
|
idBase,
|
|
59
65
|
instance,
|
|
@@ -65,8 +71,16 @@ function Form({
|
|
|
65
71
|
onChangeHasPreview,
|
|
66
72
|
onError(error) {
|
|
67
73
|
window.console.error(error);
|
|
68
|
-
createNotice(
|
|
69
|
-
|
|
74
|
+
createNotice(
|
|
75
|
+
"error",
|
|
76
|
+
(0, import_i18n.sprintf)(
|
|
77
|
+
/* translators: %s: the name of the affected block. */
|
|
78
|
+
(0, import_i18n.__)(
|
|
79
|
+
'The "%s" block was affected by errors and may not function properly. Check the developer tools for more details.'
|
|
80
|
+
),
|
|
81
|
+
idBase || id
|
|
82
|
+
)
|
|
83
|
+
);
|
|
70
84
|
}
|
|
71
85
|
});
|
|
72
86
|
ref.current.appendChild(control.element);
|
|
@@ -77,38 +91,54 @@ function Form({
|
|
|
77
91
|
}
|
|
78
92
|
control.destroy();
|
|
79
93
|
};
|
|
80
|
-
}, [
|
|
94
|
+
}, [
|
|
95
|
+
id,
|
|
96
|
+
idBase,
|
|
97
|
+
instance,
|
|
98
|
+
onChangeInstance,
|
|
99
|
+
onChangeHasPreview,
|
|
100
|
+
isMediumLargeViewport
|
|
101
|
+
]);
|
|
81
102
|
if (isWide && isMediumLargeViewport) {
|
|
82
|
-
return
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
children:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
104
|
+
"div",
|
|
105
|
+
{
|
|
106
|
+
className: (0, import_clsx.default)({
|
|
107
|
+
"wp-block-legacy-widget__container": isVisible
|
|
108
|
+
}),
|
|
109
|
+
children: [
|
|
110
|
+
isVisible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "wp-block-legacy-widget__edit-form-title", children: title }),
|
|
111
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
112
|
+
import_components.Popover,
|
|
113
|
+
{
|
|
114
|
+
focusOnMount: false,
|
|
115
|
+
placement: "right",
|
|
116
|
+
offset: 32,
|
|
117
|
+
resize: false,
|
|
118
|
+
flip: false,
|
|
119
|
+
shift: true,
|
|
120
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
ref,
|
|
124
|
+
className: "wp-block-legacy-widget__edit-form",
|
|
125
|
+
hidden: !isVisible
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
);
|
|
103
133
|
}
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
children: title
|
|
111
|
-
}
|
|
112
|
-
|
|
134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
135
|
+
"div",
|
|
136
|
+
{
|
|
137
|
+
ref,
|
|
138
|
+
className: "wp-block-legacy-widget__edit-form",
|
|
139
|
+
hidden: !isVisible,
|
|
140
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "wp-block-legacy-widget__edit-form-title", children: title })
|
|
141
|
+
}
|
|
142
|
+
);
|
|
113
143
|
}
|
|
114
|
-
//# sourceMappingURL=form.js.map
|
|
144
|
+
//# sourceMappingURL=form.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/blocks/legacy-widget/edit/form.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Popover } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\n/**\n * Internal dependencies\n */\nimport Control from './control';\n\nexport default function Form( {\n\ttitle,\n\tisVisible,\n\tid,\n\tidBase,\n\tinstance,\n\tisWide,\n\tonChangeInstance,\n\tonChangeHasPreview,\n} ) {\n\tconst ref = useRef();\n\n\tconst isMediumLargeViewport = useViewportMatch( 'small' );\n\n\t// We only want to remount the control when the instance changes\n\t// *externally*. For example, if the user performs an undo. To do this, we\n\t// keep track of changes made to instance by the control itself and then\n\t// ignore those.\n\tconst outgoingInstances = useRef( new Set() );\n\tconst incomingInstances = useRef( new Set() );\n\n\tconst { createNotice } = useDispatch( noticesStore );\n\n\tuseEffect( () => {\n\t\tif ( incomingInstances.current.has( instance ) ) {\n\t\t\tincomingInstances.current.delete( instance );\n\t\t\treturn;\n\t\t}\n\n\t\tconst control = new Control( {\n\t\t\tid,\n\t\t\tidBase,\n\t\t\tinstance,\n\t\t\tonChangeInstance( nextInstance ) {\n\t\t\t\toutgoingInstances.current.add( instance );\n\t\t\t\tincomingInstances.current.add( nextInstance );\n\t\t\t\tonChangeInstance( nextInstance );\n\t\t\t},\n\t\t\tonChangeHasPreview,\n\t\t\tonError( error ) {\n\t\t\t\twindow.console.error( error );\n\t\t\t\tcreateNotice(\n\t\t\t\t\t'error',\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: the name of the affected block. */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The \"%s\" block was affected by errors and may not function properly. Check the developer tools for more details.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tidBase || id\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t},\n\t\t} );\n\n\t\tref.current.appendChild( control.element );\n\n\t\treturn () => {\n\t\t\tif ( outgoingInstances.current.has( instance ) ) {\n\t\t\t\toutgoingInstances.current.delete( instance );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcontrol.destroy();\n\t\t};\n\t}, [\n\t\tid,\n\t\tidBase,\n\t\tinstance,\n\t\tonChangeInstance,\n\t\tonChangeHasPreview,\n\t\tisMediumLargeViewport,\n\t] );\n\n\tif ( isWide && isMediumLargeViewport ) {\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={ clsx( {\n\t\t\t\t\t'wp-block-legacy-widget__container': isVisible,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ isVisible && (\n\t\t\t\t\t<h3 className=\"wp-block-legacy-widget__edit-form-title\">\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</h3>\n\t\t\t\t) }\n\t\t\t\t<Popover\n\t\t\t\t\tfocusOnMount={ false }\n\t\t\t\t\tplacement=\"right\"\n\t\t\t\t\toffset={ 32 }\n\t\t\t\t\tresize={ false }\n\t\t\t\t\tflip={ false }\n\t\t\t\t\tshift\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tclassName=\"wp-block-legacy-widget__edit-form\"\n\t\t\t\t\t\thidden={ ! isVisible }\n\t\t\t\t\t></div>\n\t\t\t\t</Popover>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName=\"wp-block-legacy-widget__edit-form\"\n\t\t\thidden={ ! isVisible }\n\t\t>\n\t\t\t<h3 className=\"wp-block-legacy-widget__edit-form-title\">\n\t\t\t\t{ title }\n\t\t\t</h3>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6FG;AA1FH,kBAAiB;AAIjB,qBAAkC;AAClC,kBAA4B;AAC5B,qBAAsC;AACtC,kBAA4B;AAC5B,wBAAwB;AACxB,qBAAiC;AAIjC,qBAAoB;AAEL,SAAR,KAAuB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,UAAM,uBAAO;AAEnB,QAAM,4BAAwB,iCAAkB,OAAQ;AAMxD,QAAM,wBAAoB,uBAAQ,oBAAI,IAAI,CAAE;AAC5C,QAAM,wBAAoB,uBAAQ,oBAAI,IAAI,CAAE;AAE5C,QAAM,EAAE,aAAa,QAAI,yBAAa,eAAAA,KAAa;AAEnD,gCAAW,MAAM;AAChB,QAAK,kBAAkB,QAAQ,IAAK,QAAS,GAAI;AAChD,wBAAkB,QAAQ,OAAQ,QAAS;AAC3C;AAAA,IACD;AAEA,UAAM,UAAU,IAAI,eAAAC,QAAS;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAkB,cAAe;AAChC,0BAAkB,QAAQ,IAAK,QAAS;AACxC,0BAAkB,QAAQ,IAAK,YAAa;AAC5C,yBAAkB,YAAa;AAAA,MAChC;AAAA,MACA;AAAA,MACA,QAAS,OAAQ;AAChB,eAAO,QAAQ,MAAO,KAAM;AAC5B;AAAA,UACC;AAAA,cACA;AAAA;AAAA,gBAEC;AAAA,cACC;AAAA,YACD;AAAA,YACA,UAAU;AAAA,UACX;AAAA,QACD;AAAA,MACD;AAAA,IACD,CAAE;AAEF,QAAI,QAAQ,YAAa,QAAQ,OAAQ;AAEzC,WAAO,MAAM;AACZ,UAAK,kBAAkB,QAAQ,IAAK,QAAS,GAAI;AAChD,0BAAkB,QAAQ,OAAQ,QAAS;AAC3C;AAAA,MACD;AAEA,cAAQ,QAAQ;AAAA,IACjB;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,MAAK,UAAU,uBAAwB;AACtC,WACC;AAAA,MAAC;AAAA;AAAA,QACA,eAAY,YAAAC,SAAM;AAAA,UACjB,qCAAqC;AAAA,QACtC,CAAE;AAAA,QAEA;AAAA,uBACD,4CAAC,QAAG,WAAU,2CACX,iBACH;AAAA,UAED;AAAA,YAAC;AAAA;AAAA,cACA,cAAe;AAAA,cACf,WAAU;AAAA,cACV,QAAS;AAAA,cACT,QAAS;AAAA,cACT,MAAO;AAAA,cACP,OAAK;AAAA,cAEL;AAAA,gBAAC;AAAA;AAAA,kBACA;AAAA,kBACA,WAAU;AAAA,kBACV,QAAS,CAAE;AAAA;AAAA,cACX;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IACD;AAAA,EAEF;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,WAAU;AAAA,MACV,QAAS,CAAE;AAAA,MAEX,sDAAC,QAAG,WAAU,2CACX,iBACH;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": ["noticesStore", "Control", "clsx"]
|
|
7
|
+
}
|
|
@@ -1,78 +1,70 @@
|
|
|
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 edit_exports = {};
|
|
29
|
+
__export(edit_exports, {
|
|
30
|
+
default: () => Edit
|
|
6
31
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
/**
|
|
23
|
-
* External dependencies
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* WordPress dependencies
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Internal dependencies
|
|
32
|
-
*/
|
|
33
|
-
|
|
32
|
+
module.exports = __toCommonJS(edit_exports);
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_clsx = __toESM(require("clsx"));
|
|
35
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
36
|
+
var import_components = require("@wordpress/components");
|
|
37
|
+
var import_icons = require("@wordpress/icons");
|
|
38
|
+
var import_i18n = require("@wordpress/i18n");
|
|
39
|
+
var import_element = require("@wordpress/element");
|
|
40
|
+
var import_core_data = require("@wordpress/core-data");
|
|
41
|
+
var import_widget_type_selector = __toESM(require("./widget-type-selector"));
|
|
42
|
+
var import_inspector_card = __toESM(require("./inspector-card"));
|
|
43
|
+
var import_form = __toESM(require("./form"));
|
|
44
|
+
var import_preview = __toESM(require("./preview"));
|
|
45
|
+
var import_no_preview = __toESM(require("./no-preview"));
|
|
46
|
+
var import_convert_to_blocks_button = __toESM(require("./convert-to-blocks-button"));
|
|
34
47
|
function Edit(props) {
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
isWide = false
|
|
41
|
-
} = props;
|
|
42
|
-
const blockProps = (0, _blockEditor.useBlockProps)({
|
|
43
|
-
className: (0, _clsx.default)({
|
|
44
|
-
'is-wide-widget': isWide
|
|
45
|
-
})
|
|
46
|
-
});
|
|
47
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
48
|
-
...blockProps,
|
|
49
|
-
children: !id && !idBase ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Empty, {
|
|
50
|
-
...props
|
|
51
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(NotEmpty, {
|
|
52
|
-
...props
|
|
48
|
+
const { id, idBase } = props.attributes;
|
|
49
|
+
const { isWide = false } = props;
|
|
50
|
+
const blockProps = (0, import_block_editor.useBlockProps)({
|
|
51
|
+
className: (0, import_clsx.default)({
|
|
52
|
+
"is-wide-widget": isWide
|
|
53
53
|
})
|
|
54
54
|
});
|
|
55
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...blockProps, children: !id && !idBase ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Empty, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NotEmpty, { ...props }) });
|
|
55
56
|
}
|
|
56
|
-
function Empty({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
label: (0, _i18n.__)('Legacy Widget'),
|
|
68
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Flex, {
|
|
69
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.FlexBlock, {
|
|
70
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_widgetTypeSelector.default, {
|
|
71
|
-
selectedId: id !== null && id !== void 0 ? id : idBase,
|
|
72
|
-
onSelect: ({
|
|
73
|
-
selectedId,
|
|
74
|
-
isMulti
|
|
75
|
-
}) => {
|
|
57
|
+
function Empty({ attributes: { id, idBase }, setAttributes }) {
|
|
58
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
59
|
+
import_components.Placeholder,
|
|
60
|
+
{
|
|
61
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockIcon, { icon: import_icons.brush }),
|
|
62
|
+
label: (0, import_i18n.__)("Legacy Widget"),
|
|
63
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Flex, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.FlexBlock, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
|
+
import_widget_type_selector.default,
|
|
65
|
+
{
|
|
66
|
+
selectedId: id ?? idBase,
|
|
67
|
+
onSelect: ({ selectedId, isMulti }) => {
|
|
76
68
|
if (!selectedId) {
|
|
77
69
|
setAttributes({
|
|
78
70
|
id: null,
|
|
@@ -93,80 +85,78 @@ function Empty({
|
|
|
93
85
|
});
|
|
94
86
|
}
|
|
95
87
|
}
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
}
|
|
99
|
-
|
|
88
|
+
}
|
|
89
|
+
) }) })
|
|
90
|
+
}
|
|
91
|
+
);
|
|
100
92
|
}
|
|
101
93
|
function NotEmpty({
|
|
102
|
-
attributes: {
|
|
103
|
-
id,
|
|
104
|
-
idBase,
|
|
105
|
-
instance
|
|
106
|
-
},
|
|
94
|
+
attributes: { id, idBase, instance },
|
|
107
95
|
setAttributes,
|
|
108
96
|
clientId,
|
|
109
97
|
isSelected,
|
|
110
98
|
isWide = false
|
|
111
99
|
}) {
|
|
112
|
-
const [hasPreview, setHasPreview] = (0,
|
|
113
|
-
const widgetTypeId = id
|
|
114
|
-
const {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
} = (0, _coreData.useEntityRecord)('root', 'widgetType', widgetTypeId);
|
|
118
|
-
const setInstance = (0, _element.useCallback)(nextInstance => {
|
|
119
|
-
setAttributes({
|
|
120
|
-
instance: nextInstance
|
|
121
|
-
});
|
|
100
|
+
const [hasPreview, setHasPreview] = (0, import_element.useState)(null);
|
|
101
|
+
const widgetTypeId = id ?? idBase;
|
|
102
|
+
const { record: widgetType, hasResolved: hasResolvedWidgetType } = (0, import_core_data.useEntityRecord)("root", "widgetType", widgetTypeId);
|
|
103
|
+
const setInstance = (0, import_element.useCallback)((nextInstance) => {
|
|
104
|
+
setAttributes({ instance: nextInstance });
|
|
122
105
|
}, []);
|
|
123
106
|
if (!widgetType && hasResolvedWidgetType) {
|
|
124
|
-
return
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
108
|
+
import_components.Placeholder,
|
|
109
|
+
{
|
|
110
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockIcon, { icon: import_icons.brush }),
|
|
111
|
+
label: (0, import_i18n.__)("Legacy Widget"),
|
|
112
|
+
children: (0, import_i18n.__)("Widget is missing.")
|
|
113
|
+
}
|
|
114
|
+
);
|
|
131
115
|
}
|
|
132
116
|
if (!hasResolvedWidgetType) {
|
|
133
|
-
return
|
|
134
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {})
|
|
135
|
-
});
|
|
117
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Placeholder, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) });
|
|
136
118
|
}
|
|
137
|
-
const mode = idBase && !isSelected ?
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
clientId
|
|
119
|
+
const mode = idBase && !isSelected ? "preview" : "edit";
|
|
120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
121
|
+
idBase === "text" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockControls, { group: "other", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
122
|
+
import_convert_to_blocks_button.default,
|
|
123
|
+
{
|
|
124
|
+
clientId,
|
|
143
125
|
rawInstance: instance.raw
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
126
|
+
}
|
|
127
|
+
) }),
|
|
128
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.InspectorControls, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
129
|
+
import_inspector_card.default,
|
|
130
|
+
{
|
|
147
131
|
name: widgetType.name,
|
|
148
132
|
description: widgetType.description
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
133
|
+
}
|
|
134
|
+
) }),
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
136
|
+
import_form.default,
|
|
137
|
+
{
|
|
138
|
+
title: widgetType.name,
|
|
139
|
+
isVisible: mode === "edit",
|
|
140
|
+
id,
|
|
141
|
+
idBase,
|
|
142
|
+
instance,
|
|
143
|
+
isWide,
|
|
144
|
+
onChangeInstance: setInstance,
|
|
145
|
+
onChangeHasPreview: setHasPreview
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
idBase && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
149
|
+
hasPreview === null && mode === "preview" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Placeholder, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) }),
|
|
150
|
+
hasPreview === true && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
151
|
+
import_preview.default,
|
|
152
|
+
{
|
|
153
|
+
idBase,
|
|
154
|
+
instance,
|
|
155
|
+
isVisible: mode === "preview"
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
hasPreview === false && mode === "preview" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_no_preview.default, { name: widgetType.name })
|
|
159
|
+
] })
|
|
160
|
+
] });
|
|
171
161
|
}
|
|
172
|
-
//# sourceMappingURL=index.js.map
|
|
162
|
+
//# sourceMappingURL=index.js.map
|