@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.
Files changed (86) hide show
  1. package/build/blocks/legacy-widget/block.json +29 -0
  2. package/build/blocks/legacy-widget/edit/control.js +137 -167
  3. package/build/blocks/legacy-widget/edit/control.js.map +7 -1
  4. package/build/blocks/legacy-widget/edit/convert-to-blocks-button.js +51 -39
  5. package/build/blocks/legacy-widget/edit/convert-to-blocks-button.js.map +7 -1
  6. package/build/blocks/legacy-widget/edit/form.js +105 -75
  7. package/build/blocks/legacy-widget/edit/form.js.map +7 -1
  8. package/build/blocks/legacy-widget/edit/index.js +121 -131
  9. package/build/blocks/legacy-widget/edit/index.js.map +7 -1
  10. package/build/blocks/legacy-widget/edit/inspector-card.js +28 -20
  11. package/build/blocks/legacy-widget/edit/inspector-card.js.map +7 -1
  12. package/build/blocks/legacy-widget/edit/no-preview.js +29 -23
  13. package/build/blocks/legacy-widget/edit/no-preview.js.map +7 -1
  14. package/build/blocks/legacy-widget/edit/preview.js +107 -108
  15. package/build/blocks/legacy-widget/edit/preview.js.map +7 -1
  16. package/build/blocks/legacy-widget/edit/widget-type-selector.js +61 -52
  17. package/build/blocks/legacy-widget/edit/widget-type-selector.js.map +7 -1
  18. package/build/blocks/legacy-widget/index.js +49 -53
  19. package/build/blocks/legacy-widget/index.js.map +7 -1
  20. package/build/blocks/legacy-widget/transforms.js +189 -198
  21. package/build/blocks/legacy-widget/transforms.js.map +7 -1
  22. package/build/blocks/widget-group/block.json +20 -0
  23. package/build/blocks/widget-group/deprecated.js +38 -24
  24. package/build/blocks/widget-group/deprecated.js.map +7 -1
  25. package/build/blocks/widget-group/edit.js +63 -67
  26. package/build/blocks/widget-group/edit.js.map +7 -1
  27. package/build/blocks/widget-group/index.js +93 -80
  28. package/build/blocks/widget-group/index.js.map +7 -1
  29. package/build/blocks/widget-group/save.js +36 -25
  30. package/build/blocks/widget-group/save.js.map +7 -1
  31. package/build/components/index.js +36 -12
  32. package/build/components/index.js.map +7 -1
  33. package/build/components/move-to-widget-area/index.js +48 -37
  34. package/build/components/move-to-widget-area/index.js.map +7 -1
  35. package/build/index.js +67 -98
  36. package/build/index.js.map +7 -1
  37. package/build/register-legacy-widget-variations.js +42 -30
  38. package/build/register-legacy-widget-variations.js.map +7 -1
  39. package/build/utils.js +29 -29
  40. package/build/utils.js.map +7 -1
  41. package/build-module/blocks/legacy-widget/block.json +29 -0
  42. package/build-module/blocks/legacy-widget/edit/control.js +107 -158
  43. package/build-module/blocks/legacy-widget/edit/control.js.map +7 -1
  44. package/build-module/blocks/legacy-widget/edit/convert-to-blocks-button.js +33 -33
  45. package/build-module/blocks/legacy-widget/edit/convert-to-blocks-button.js.map +7 -1
  46. package/build-module/blocks/legacy-widget/edit/form.js +75 -64
  47. package/build-module/blocks/legacy-widget/edit/form.js.map +7 -1
  48. package/build-module/blocks/legacy-widget/edit/index.js +96 -122
  49. package/build-module/blocks/legacy-widget/edit/index.js.map +7 -1
  50. package/build-module/blocks/legacy-widget/edit/inspector-card.js +10 -15
  51. package/build-module/blocks/legacy-widget/edit/inspector-card.js.map +7 -1
  52. package/build-module/blocks/legacy-widget/edit/no-preview.js +11 -17
  53. package/build-module/blocks/legacy-widget/edit/no-preview.js.map +7 -1
  54. package/build-module/blocks/legacy-widget/edit/preview.js +76 -98
  55. package/build-module/blocks/legacy-widget/edit/preview.js.map +7 -1
  56. package/build-module/blocks/legacy-widget/edit/widget-type-selector.js +43 -46
  57. package/build-module/blocks/legacy-widget/edit/widget-type-selector.js.map +7 -1
  58. package/build-module/blocks/legacy-widget/index.js +12 -45
  59. package/build-module/blocks/legacy-widget/index.js.map +7 -1
  60. package/build-module/blocks/legacy-widget/transforms.js +171 -192
  61. package/build-module/blocks/legacy-widget/transforms.js.map +7 -1
  62. package/build-module/blocks/widget-group/block.json +20 -0
  63. package/build-module/blocks/widget-group/deprecated.js +20 -18
  64. package/build-module/blocks/widget-group/deprecated.js.map +7 -1
  65. package/build-module/blocks/widget-group/edit.js +53 -62
  66. package/build-module/blocks/widget-group/edit.js.map +7 -1
  67. package/build-module/blocks/widget-group/index.js +55 -71
  68. package/build-module/blocks/widget-group/index.js.map +7 -1
  69. package/build-module/blocks/widget-group/save.js +18 -19
  70. package/build-module/blocks/widget-group/save.js.map +7 -1
  71. package/build-module/components/index.js +5 -2
  72. package/build-module/components/index.js.map +7 -1
  73. package/build-module/components/move-to-widget-area/index.js +37 -32
  74. package/build-module/components/move-to-widget-area/index.js.map +7 -1
  75. package/build-module/index.js +34 -60
  76. package/build-module/index.js.map +7 -1
  77. package/build-module/register-legacy-widget-variations.js +24 -24
  78. package/build-module/register-legacy-widget-variations.js.map +7 -1
  79. package/build-module/utils.js +8 -25
  80. package/build-module/utils.js.map +7 -1
  81. package/build-style/style-rtl.css +10 -145
  82. package/build-style/style.css +10 -145
  83. package/package.json +21 -14
  84. package/src/blocks/legacy-widget/editor.scss +3 -0
  85. package/src/blocks/widget-group/editor.scss +3 -0
  86. package/src/style.scss +3 -2
@@ -1,41 +1,53 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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.default = ConvertToBlocksButton;
7
- var _data = require("@wordpress/data");
8
- var _blockEditor = require("@wordpress/block-editor");
9
- var _components = require("@wordpress/components");
10
- var _blocks = require("@wordpress/blocks");
11
- var _i18n = require("@wordpress/i18n");
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- /**
14
- * WordPress dependencies
15
- */
16
-
17
- function ConvertToBlocksButton({
18
- clientId,
19
- rawInstance
20
- }) {
21
- const {
22
- replaceBlocks
23
- } = (0, _data.useDispatch)(_blockEditor.store);
24
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarButton, {
25
- onClick: () => {
26
- if (rawInstance.title) {
27
- replaceBlocks(clientId, [(0, _blocks.createBlock)('core/heading', {
28
- content: rawInstance.title
29
- }), ...(0, _blocks.rawHandler)({
30
- HTML: rawInstance.text
31
- })]);
32
- } else {
33
- replaceBlocks(clientId, (0, _blocks.rawHandler)({
34
- HTML: rawInstance.text
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
- {"version":3,"names":["_data","require","_blockEditor","_components","_blocks","_i18n","_jsxRuntime","ConvertToBlocksButton","clientId","rawInstance","replaceBlocks","useDispatch","blockEditorStore","jsx","ToolbarButton","onClick","title","createBlock","content","rawHandler","HTML","text","children","__"],"sources":["@wordpress/widgets/src/blocks/legacy-widget/edit/convert-to-blocks-button.js"],"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"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAAqC,IAAAK,WAAA,GAAAL,OAAA;AAPrC;AACA;AACA;;AAOe,SAASM,qBAAqBA,CAAE;EAAEC,QAAQ;EAAEC;AAAY,CAAC,EAAG;EAC1E,MAAM;IAAEC;EAAc,CAAC,GAAG,IAAAC,iBAAW,EAAEC,kBAAiB,CAAC;EAEzD,oBACC,IAAAN,WAAA,CAAAO,GAAA,EAACV,WAAA,CAAAW,aAAa;IACbC,OAAO,EAAGA,CAAA,KAAM;MACf,IAAKN,WAAW,CAACO,KAAK,EAAG;QACxBN,aAAa,CAAEF,QAAQ,EAAE,CACxB,IAAAS,mBAAW,EAAE,cAAc,EAAE;UAC5BC,OAAO,EAAET,WAAW,CAACO;QACtB,CAAE,CAAC,EACH,GAAG,IAAAG,kBAAU,EAAE;UAAEC,IAAI,EAAEX,WAAW,CAACY;QAAK,CAAE,CAAC,CAC1C,CAAC;MACJ,CAAC,MAAM;QACNX,aAAa,CACZF,QAAQ,EACR,IAAAW,kBAAU,EAAE;UAAEC,IAAI,EAAEX,WAAW,CAACY;QAAK,CAAE,CACxC,CAAC;MACF;IACD,CAAG;IAAAC,QAAA,EAED,IAAAC,QAAE,EAAE,mBAAoB;EAAC,CACb,CAAC;AAElB","ignoreList":[]}
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
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
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.default = Form;
8
- var _clsx = _interopRequireDefault(require("clsx"));
9
- var _element = require("@wordpress/element");
10
- var _data = require("@wordpress/data");
11
- var _notices = require("@wordpress/notices");
12
- var _i18n = require("@wordpress/i18n");
13
- var _components = require("@wordpress/components");
14
- var _compose = require("@wordpress/compose");
15
- var _control = _interopRequireDefault(require("./control"));
16
- var _jsxRuntime = require("react/jsx-runtime");
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, _element.useRef)();
40
- const isMediumLargeViewport = (0, _compose.useViewportMatch)('small');
41
-
42
- // We only want to remount the control when the instance changes
43
- // *externally*. For example, if the user performs an undo. To do this, we
44
- // keep track of changes made to instance by the control itself and then
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 _control.default({
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('error', (0, _i18n.sprintf)(/* translators: %s: the name of the affected block. */
69
- (0, _i18n.__)('The "%s" block was affected by errors and may not function properly. Check the developer tools for more details.'), idBase || id));
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
- }, [id, idBase, instance, onChangeInstance, onChangeHasPreview, isMediumLargeViewport]);
94
+ }, [
95
+ id,
96
+ idBase,
97
+ instance,
98
+ onChangeInstance,
99
+ onChangeHasPreview,
100
+ isMediumLargeViewport
101
+ ]);
81
102
  if (isWide && isMediumLargeViewport) {
82
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
83
- className: (0, _clsx.default)({
84
- 'wp-block-legacy-widget__container': isVisible
85
- }),
86
- children: [isVisible && /*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
87
- className: "wp-block-legacy-widget__edit-form-title",
88
- children: title
89
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Popover, {
90
- focusOnMount: false,
91
- placement: "right",
92
- offset: 32,
93
- resize: false,
94
- flip: false,
95
- shift: true,
96
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
97
- ref: ref,
98
- className: "wp-block-legacy-widget__edit-form",
99
- hidden: !isVisible
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 /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
105
- ref: ref,
106
- className: "wp-block-legacy-widget__edit-form",
107
- hidden: !isVisible,
108
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
109
- className: "wp-block-legacy-widget__edit-form-title",
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
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_element","_data","_notices","_i18n","_components","_compose","_control","_jsxRuntime","Form","title","isVisible","id","idBase","instance","isWide","onChangeInstance","onChangeHasPreview","ref","useRef","isMediumLargeViewport","useViewportMatch","outgoingInstances","Set","incomingInstances","createNotice","useDispatch","noticesStore","useEffect","current","has","delete","control","Control","nextInstance","add","onError","error","window","console","sprintf","__","appendChild","element","destroy","jsxs","className","clsx","children","jsx","Popover","focusOnMount","placement","offset","resize","flip","shift","hidden"],"sources":["@wordpress/widgets/src/blocks/legacy-widget/edit/form.js"],"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"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAIA,IAAAO,QAAA,GAAAR,sBAAA,CAAAC,OAAA;AAAgC,IAAA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CW,MAAM,EAAG,CAAE9C,SAAW;IAAAqC,QAAA,eAEtB,IAAAxC,WAAA,CAAAyC,GAAA;MAAIH,SAAS,EAAC,yCAAyC;MAAAE,QAAA,EACpDtC;IAAK,CACJ;EAAC,CACD,CAAC;AAER","ignoreList":[]}
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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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
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
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.default = Edit;
8
- var _clsx = _interopRequireDefault(require("clsx"));
9
- var _blockEditor = require("@wordpress/block-editor");
10
- var _components = require("@wordpress/components");
11
- var _icons = require("@wordpress/icons");
12
- var _i18n = require("@wordpress/i18n");
13
- var _element = require("@wordpress/element");
14
- var _coreData = require("@wordpress/core-data");
15
- var _widgetTypeSelector = _interopRequireDefault(require("./widget-type-selector"));
16
- var _inspectorCard = _interopRequireDefault(require("./inspector-card"));
17
- var _form = _interopRequireDefault(require("./form"));
18
- var _preview = _interopRequireDefault(require("./preview"));
19
- var _noPreview = _interopRequireDefault(require("./no-preview"));
20
- var _convertToBlocksButton = _interopRequireDefault(require("./convert-to-blocks-button"));
21
- var _jsxRuntime = require("react/jsx-runtime");
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
- id,
37
- idBase
38
- } = props.attributes;
39
- const {
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
- attributes: {
58
- id,
59
- idBase
60
- },
61
- setAttributes
62
- }) {
63
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Placeholder, {
64
- icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockIcon, {
65
- icon: _icons.brush
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, _element.useState)(null);
113
- const widgetTypeId = id !== null && id !== void 0 ? id : idBase;
114
- const {
115
- record: widgetType,
116
- hasResolved: hasResolvedWidgetType
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 /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Placeholder, {
125
- icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockIcon, {
126
- icon: _icons.brush
127
- }),
128
- label: (0, _i18n.__)('Legacy Widget'),
129
- children: (0, _i18n.__)('Widget is missing.')
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 /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Placeholder, {
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 ? 'preview' : 'edit';
138
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
139
- children: [idBase === 'text' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockControls, {
140
- group: "other",
141
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_convertToBlocksButton.default, {
142
- clientId: 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
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.InspectorControls, {
146
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_inspectorCard.default, {
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
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_form.default, {
151
- title: widgetType.name,
152
- isVisible: mode === 'edit',
153
- id: id,
154
- idBase: idBase,
155
- instance: instance,
156
- isWide: isWide,
157
- onChangeInstance: setInstance,
158
- onChangeHasPreview: setHasPreview
159
- }), idBase && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
160
- children: [hasPreview === null && mode === 'preview' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Placeholder, {
161
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {})
162
- }), hasPreview === true && /*#__PURE__*/(0, _jsxRuntime.jsx)(_preview.default, {
163
- idBase: idBase,
164
- instance: instance,
165
- isVisible: mode === 'preview'
166
- }), hasPreview === false && mode === 'preview' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_noPreview.default, {
167
- name: widgetType.name
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