@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,116 +1,94 @@
1
- /**
2
- * External dependencies
3
- */
4
- import clsx from 'clsx';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { useRefEffect } from '@wordpress/compose';
10
- import { useEffect, useState } from '@wordpress/element';
11
- import { Disabled, Placeholder, Spinner } from '@wordpress/components';
12
- import { __ } from '@wordpress/i18n';
13
- import apiFetch from '@wordpress/api-fetch';
14
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
15
- export default function Preview({
16
- idBase,
17
- instance,
18
- isVisible
19
- }) {
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import clsx from "clsx";
3
+ import { useRefEffect } from "@wordpress/compose";
4
+ import { useEffect, useState } from "@wordpress/element";
5
+ import { Disabled, Placeholder, Spinner } from "@wordpress/components";
6
+ import { __ } from "@wordpress/i18n";
7
+ import apiFetch from "@wordpress/api-fetch";
8
+ function Preview({ idBase, instance, isVisible }) {
20
9
  const [isLoaded, setIsLoaded] = useState(false);
21
- const [srcDoc, setSrcDoc] = useState('');
10
+ const [srcDoc, setSrcDoc] = useState("");
22
11
  useEffect(() => {
23
- const abortController = typeof window.AbortController === 'undefined' ? undefined : new window.AbortController();
12
+ const abortController = typeof window.AbortController === "undefined" ? void 0 : new window.AbortController();
24
13
  async function fetchPreviewHTML() {
25
14
  const restRoute = `/wp/v2/widget-types/${idBase}/render`;
26
15
  return await apiFetch({
27
16
  path: restRoute,
28
- method: 'POST',
17
+ method: "POST",
29
18
  signal: abortController?.signal,
30
- data: instance ? {
31
- instance
32
- } : {}
19
+ data: instance ? { instance } : {}
33
20
  });
34
21
  }
35
- fetchPreviewHTML().then(response => {
22
+ fetchPreviewHTML().then((response) => {
36
23
  setSrcDoc(response.preview);
37
- }).catch(error => {
38
- if ('AbortError' === error.name) {
39
- // We don't want to log aborted requests.
24
+ }).catch((error) => {
25
+ if ("AbortError" === error.name) {
40
26
  return;
41
27
  }
42
28
  throw error;
43
29
  });
44
30
  return () => abortController?.abort();
45
31
  }, [idBase, instance]);
46
-
47
- // Resize the iframe on either the load event, or when the iframe becomes visible.
48
- const ref = useRefEffect(iframe => {
49
- // Only set height if the iframe is loaded,
50
- // or it will grow to an unexpected large height in Safari if it's hidden initially.
51
- if (!isLoaded) {
52
- return;
53
- }
54
- // If the preview frame has another origin then this won't work.
55
- // One possible solution is to add custom script to call `postMessage` in the preview frame.
56
- // Or, better yet, we migrate away from iframe.
57
- function setHeight() {
58
- var _iframe$contentDocume, _iframe$contentDocume2;
59
- // Pick the maximum of these two values to account for margin collapsing.
60
- const height = Math.max((_iframe$contentDocume = iframe.contentDocument.documentElement?.offsetHeight) !== null && _iframe$contentDocume !== void 0 ? _iframe$contentDocume : 0, (_iframe$contentDocume2 = iframe.contentDocument.body?.offsetHeight) !== null && _iframe$contentDocume2 !== void 0 ? _iframe$contentDocume2 : 0);
61
-
62
- // Fallback to a height of 100px if the height cannot be determined.
63
- // This ensures the block is still selectable. 100px should hopefully
64
- // be not so big that it's annoying, and not so small that nothing
65
- // can be seen.
66
- iframe.style.height = `${height !== 0 ? height : 100}px`;
67
- }
68
- const {
69
- IntersectionObserver
70
- } = iframe.ownerDocument.defaultView;
71
-
72
- // Observe for intersections that might cause a change in the height of
73
- // the iframe, e.g. a Widget Area becoming expanded.
74
- const intersectionObserver = new IntersectionObserver(([entry]) => {
75
- if (entry.isIntersecting) {
76
- setHeight();
32
+ const ref = useRefEffect(
33
+ (iframe) => {
34
+ if (!isLoaded) {
35
+ return;
77
36
  }
78
- }, {
79
- threshold: 1
80
- });
81
- intersectionObserver.observe(iframe);
82
- iframe.addEventListener('load', setHeight);
83
- return () => {
84
- intersectionObserver.disconnect();
85
- iframe.removeEventListener('load', setHeight);
86
- };
87
- }, [isLoaded]);
88
- return /*#__PURE__*/_jsxs(_Fragment, {
89
- children: [isVisible && !isLoaded && /*#__PURE__*/_jsx(Placeholder, {
90
- children: /*#__PURE__*/_jsx(Spinner, {})
91
- }), /*#__PURE__*/_jsx("div", {
92
- className: clsx('wp-block-legacy-widget__edit-preview', {
93
- 'is-offscreen': !isVisible || !isLoaded
94
- }),
95
- children: /*#__PURE__*/_jsx(Disabled, {
96
- children: /*#__PURE__*/_jsx("iframe", {
97
- ref: ref,
98
- className: "wp-block-legacy-widget__edit-preview-iframe",
99
- tabIndex: "-1",
100
- title: __('Legacy Widget Preview'),
101
- srcDoc: srcDoc,
102
- onLoad: event => {
103
- // To hide the scrollbars of the preview frame for some edge cases,
104
- // such as negative margins in the Gallery Legacy Widget.
105
- // It can't be scrolled anyway.
106
- // TODO: Ideally, this should be fixed in core.
107
- event.target.contentDocument.body.style.overflow = 'hidden';
108
- setIsLoaded(true);
109
- },
110
- height: 100
111
- })
112
- })
113
- })]
114
- });
37
+ function setHeight() {
38
+ const height = Math.max(
39
+ iframe.contentDocument.documentElement?.offsetHeight ?? 0,
40
+ iframe.contentDocument.body?.offsetHeight ?? 0
41
+ );
42
+ iframe.style.height = `${height !== 0 ? height : 100}px`;
43
+ }
44
+ const { IntersectionObserver } = iframe.ownerDocument.defaultView;
45
+ const intersectionObserver = new IntersectionObserver(
46
+ ([entry]) => {
47
+ if (entry.isIntersecting) {
48
+ setHeight();
49
+ }
50
+ },
51
+ {
52
+ threshold: 1
53
+ }
54
+ );
55
+ intersectionObserver.observe(iframe);
56
+ iframe.addEventListener("load", setHeight);
57
+ return () => {
58
+ intersectionObserver.disconnect();
59
+ iframe.removeEventListener("load", setHeight);
60
+ };
61
+ },
62
+ [isLoaded]
63
+ );
64
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
65
+ isVisible && !isLoaded && /* @__PURE__ */ jsx(Placeholder, { children: /* @__PURE__ */ jsx(Spinner, {}) }),
66
+ /* @__PURE__ */ jsx(
67
+ "div",
68
+ {
69
+ className: clsx("wp-block-legacy-widget__edit-preview", {
70
+ "is-offscreen": !isVisible || !isLoaded
71
+ }),
72
+ children: /* @__PURE__ */ jsx(Disabled, { children: /* @__PURE__ */ jsx(
73
+ "iframe",
74
+ {
75
+ ref,
76
+ className: "wp-block-legacy-widget__edit-preview-iframe",
77
+ tabIndex: "-1",
78
+ title: __("Legacy Widget Preview"),
79
+ srcDoc,
80
+ onLoad: (event) => {
81
+ event.target.contentDocument.body.style.overflow = "hidden";
82
+ setIsLoaded(true);
83
+ },
84
+ height: 100
85
+ }
86
+ ) })
87
+ }
88
+ )
89
+ ] });
115
90
  }
116
- //# sourceMappingURL=preview.js.map
91
+ export {
92
+ Preview as default
93
+ };
94
+ //# sourceMappingURL=preview.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["clsx","useRefEffect","useEffect","useState","Disabled","Placeholder","Spinner","__","apiFetch","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","Preview","idBase","instance","isVisible","isLoaded","setIsLoaded","srcDoc","setSrcDoc","abortController","window","AbortController","undefined","fetchPreviewHTML","restRoute","path","method","signal","data","then","response","preview","catch","error","name","abort","ref","iframe","setHeight","_iframe$contentDocume","_iframe$contentDocume2","height","Math","max","contentDocument","documentElement","offsetHeight","body","style","IntersectionObserver","ownerDocument","defaultView","intersectionObserver","entry","isIntersecting","threshold","observe","addEventListener","disconnect","removeEventListener","children","className","tabIndex","title","onLoad","event","target","overflow"],"sources":["@wordpress/widgets/src/blocks/legacy-widget/edit/preview.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useEffect, useState } from '@wordpress/element';\nimport { Disabled, Placeholder, Spinner } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\n\nexport default function Preview( { idBase, instance, isVisible } ) {\n\tconst [ isLoaded, setIsLoaded ] = useState( false );\n\tconst [ srcDoc, setSrcDoc ] = useState( '' );\n\n\tuseEffect( () => {\n\t\tconst abortController =\n\t\t\ttypeof window.AbortController === 'undefined'\n\t\t\t\t? undefined\n\t\t\t\t: new window.AbortController();\n\n\t\tasync function fetchPreviewHTML() {\n\t\t\tconst restRoute = `/wp/v2/widget-types/${ idBase }/render`;\n\t\t\treturn await apiFetch( {\n\t\t\t\tpath: restRoute,\n\t\t\t\tmethod: 'POST',\n\t\t\t\tsignal: abortController?.signal,\n\t\t\t\tdata: instance ? { instance } : {},\n\t\t\t} );\n\t\t}\n\n\t\tfetchPreviewHTML()\n\t\t\t.then( ( response ) => {\n\t\t\t\tsetSrcDoc( response.preview );\n\t\t\t} )\n\t\t\t.catch( ( error ) => {\n\t\t\t\tif ( 'AbortError' === error.name ) {\n\t\t\t\t\t// We don't want to log aborted requests.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t} );\n\n\t\treturn () => abortController?.abort();\n\t}, [ idBase, instance ] );\n\n\t// Resize the iframe on either the load event, or when the iframe becomes visible.\n\tconst ref = useRefEffect(\n\t\t( iframe ) => {\n\t\t\t// Only set height if the iframe is loaded,\n\t\t\t// or it will grow to an unexpected large height in Safari if it's hidden initially.\n\t\t\tif ( ! isLoaded ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// If the preview frame has another origin then this won't work.\n\t\t\t// One possible solution is to add custom script to call `postMessage` in the preview frame.\n\t\t\t// Or, better yet, we migrate away from iframe.\n\t\t\tfunction setHeight() {\n\t\t\t\t// Pick the maximum of these two values to account for margin collapsing.\n\t\t\t\tconst height = Math.max(\n\t\t\t\t\tiframe.contentDocument.documentElement?.offsetHeight ?? 0,\n\t\t\t\t\tiframe.contentDocument.body?.offsetHeight ?? 0\n\t\t\t\t);\n\n\t\t\t\t// Fallback to a height of 100px if the height cannot be determined.\n\t\t\t\t// This ensures the block is still selectable. 100px should hopefully\n\t\t\t\t// be not so big that it's annoying, and not so small that nothing\n\t\t\t\t// can be seen.\n\t\t\t\tiframe.style.height = `${ height !== 0 ? height : 100 }px`;\n\t\t\t}\n\n\t\t\tconst { IntersectionObserver } = iframe.ownerDocument.defaultView;\n\n\t\t\t// Observe for intersections that might cause a change in the height of\n\t\t\t// the iframe, e.g. a Widget Area becoming expanded.\n\t\t\tconst intersectionObserver = new IntersectionObserver(\n\t\t\t\t( [ entry ] ) => {\n\t\t\t\t\tif ( entry.isIntersecting ) {\n\t\t\t\t\t\tsetHeight();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tthreshold: 1,\n\t\t\t\t}\n\t\t\t);\n\t\t\tintersectionObserver.observe( iframe );\n\n\t\t\tiframe.addEventListener( 'load', setHeight );\n\n\t\t\treturn () => {\n\t\t\t\tintersectionObserver.disconnect();\n\t\t\t\tiframe.removeEventListener( 'load', setHeight );\n\t\t\t};\n\t\t},\n\t\t[ isLoaded ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ /*\n\t\t\tWhile the iframe contents are loading, we move the iframe off-screen\n\t\t\tand display a placeholder instead. This ensures that the user\n\t\t\tdoesn't see the iframe resize (which looks really janky). We have to\n\t\t\tmove the iframe off-screen instead of hiding it because web browsers\n\t\t\twill not trigger onLoad if the iframe is hidden.\n\t\t\t*/ }\n\t\t\t{ isVisible && ! isLoaded && (\n\t\t\t\t<Placeholder>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'wp-block-legacy-widget__edit-preview', {\n\t\t\t\t\t'is-offscreen': ! isVisible || ! isLoaded,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<Disabled>\n\t\t\t\t\t{ /*\n\t\t\t\t\tWe use an iframe so that the widget has an opportunity to\n\t\t\t\t\tload scripts and styles that it needs to run.\n\t\t\t\t\t*/ }\n\t\t\t\t\t<iframe\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tclassName=\"wp-block-legacy-widget__edit-preview-iframe\"\n\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\ttitle={ __( 'Legacy Widget Preview' ) }\n\t\t\t\t\t\tsrcDoc={ srcDoc }\n\t\t\t\t\t\tonLoad={ ( event ) => {\n\t\t\t\t\t\t\t// To hide the scrollbars of the preview frame for some edge cases,\n\t\t\t\t\t\t\t// such as negative margins in the Gallery Legacy Widget.\n\t\t\t\t\t\t\t// It can't be scrolled anyway.\n\t\t\t\t\t\t\t// TODO: Ideally, this should be fixed in core.\n\t\t\t\t\t\t\tevent.target.contentDocument.body.style.overflow =\n\t\t\t\t\t\t\t\t'hidden';\n\n\t\t\t\t\t\t\tsetIsLoaded( true );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\theight={ 100 }\n\t\t\t\t\t/>\n\t\t\t\t</Disabled>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,SAAS,EAAEC,QAAQ,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KAAA,CAAAF,SAAA;IAAAoD,QAAA,GAQG9C,SAAS,IAAI,CAAEC,QAAQ,iBACxBT,IAAA,CAACL,WAAW;MAAA2D,QAAA,eACXtD,IAAA,CAACJ,OAAO,IAAE;IAAC,CACC,CACb,eACDI,IAAA;MACCuD,SAAS,EAAGjE,IAAI,CAAE,sCAAsC,EAAE;QACzD,cAAc,EAAE,CAAEkB,SAAS,IAAI,CAAEC;MAClC,CAAE,CAAG;MAAA6C,QAAA,eAELtD,IAAA,CAACN,QAAQ;QAAA4D,QAAA,eAKRtD,IAAA;UACC8B,GAAG,EAAGA,GAAK;UACXyB,SAAS,EAAC,6CAA6C;UACvDC,QAAQ,EAAC,IAAI;UACbC,KAAK,EAAG5D,EAAE,CAAE,uBAAwB,CAAG;UACvCc,MAAM,EAAGA,MAAQ;UACjB+C,MAAM,EAAKC,KAAK,IAAM;YACrB;YACA;YACA;YACA;YACAA,KAAK,CAACC,MAAM,CAACtB,eAAe,CAACG,IAAI,CAACC,KAAK,CAACmB,QAAQ,GAC/C,QAAQ;YAETnD,WAAW,CAAE,IAAK,CAAC;UACpB,CAAG;UACHyB,MAAM,EAAG;QAAK,CACd;MAAC,CACO;IAAC,CACP,CAAC;EAAA,CACL,CAAC;AAEL","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/blocks/legacy-widget/edit/preview.js"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useEffect, useState } from '@wordpress/element';\nimport { Disabled, Placeholder, Spinner } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\n\nexport default function Preview( { idBase, instance, isVisible } ) {\n\tconst [ isLoaded, setIsLoaded ] = useState( false );\n\tconst [ srcDoc, setSrcDoc ] = useState( '' );\n\n\tuseEffect( () => {\n\t\tconst abortController =\n\t\t\ttypeof window.AbortController === 'undefined'\n\t\t\t\t? undefined\n\t\t\t\t: new window.AbortController();\n\n\t\tasync function fetchPreviewHTML() {\n\t\t\tconst restRoute = `/wp/v2/widget-types/${ idBase }/render`;\n\t\t\treturn await apiFetch( {\n\t\t\t\tpath: restRoute,\n\t\t\t\tmethod: 'POST',\n\t\t\t\tsignal: abortController?.signal,\n\t\t\t\tdata: instance ? { instance } : {},\n\t\t\t} );\n\t\t}\n\n\t\tfetchPreviewHTML()\n\t\t\t.then( ( response ) => {\n\t\t\t\tsetSrcDoc( response.preview );\n\t\t\t} )\n\t\t\t.catch( ( error ) => {\n\t\t\t\tif ( 'AbortError' === error.name ) {\n\t\t\t\t\t// We don't want to log aborted requests.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t} );\n\n\t\treturn () => abortController?.abort();\n\t}, [ idBase, instance ] );\n\n\t// Resize the iframe on either the load event, or when the iframe becomes visible.\n\tconst ref = useRefEffect(\n\t\t( iframe ) => {\n\t\t\t// Only set height if the iframe is loaded,\n\t\t\t// or it will grow to an unexpected large height in Safari if it's hidden initially.\n\t\t\tif ( ! isLoaded ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// If the preview frame has another origin then this won't work.\n\t\t\t// One possible solution is to add custom script to call `postMessage` in the preview frame.\n\t\t\t// Or, better yet, we migrate away from iframe.\n\t\t\tfunction setHeight() {\n\t\t\t\t// Pick the maximum of these two values to account for margin collapsing.\n\t\t\t\tconst height = Math.max(\n\t\t\t\t\tiframe.contentDocument.documentElement?.offsetHeight ?? 0,\n\t\t\t\t\tiframe.contentDocument.body?.offsetHeight ?? 0\n\t\t\t\t);\n\n\t\t\t\t// Fallback to a height of 100px if the height cannot be determined.\n\t\t\t\t// This ensures the block is still selectable. 100px should hopefully\n\t\t\t\t// be not so big that it's annoying, and not so small that nothing\n\t\t\t\t// can be seen.\n\t\t\t\tiframe.style.height = `${ height !== 0 ? height : 100 }px`;\n\t\t\t}\n\n\t\t\tconst { IntersectionObserver } = iframe.ownerDocument.defaultView;\n\n\t\t\t// Observe for intersections that might cause a change in the height of\n\t\t\t// the iframe, e.g. a Widget Area becoming expanded.\n\t\t\tconst intersectionObserver = new IntersectionObserver(\n\t\t\t\t( [ entry ] ) => {\n\t\t\t\t\tif ( entry.isIntersecting ) {\n\t\t\t\t\t\tsetHeight();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tthreshold: 1,\n\t\t\t\t}\n\t\t\t);\n\t\t\tintersectionObserver.observe( iframe );\n\n\t\t\tiframe.addEventListener( 'load', setHeight );\n\n\t\t\treturn () => {\n\t\t\t\tintersectionObserver.disconnect();\n\t\t\t\tiframe.removeEventListener( 'load', setHeight );\n\t\t\t};\n\t\t},\n\t\t[ isLoaded ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ /*\n\t\t\tWhile the iframe contents are loading, we move the iframe off-screen\n\t\t\tand display a placeholder instead. This ensures that the user\n\t\t\tdoesn't see the iframe resize (which looks really janky). We have to\n\t\t\tmove the iframe off-screen instead of hiding it because web browsers\n\t\t\twill not trigger onLoad if the iframe is hidden.\n\t\t\t*/ }\n\t\t\t{ isVisible && ! isLoaded && (\n\t\t\t\t<Placeholder>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'wp-block-legacy-widget__edit-preview', {\n\t\t\t\t\t'is-offscreen': ! isVisible || ! isLoaded,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<Disabled>\n\t\t\t\t\t{ /*\n\t\t\t\t\tWe use an iframe so that the widget has an opportunity to\n\t\t\t\t\tload scripts and styles that it needs to run.\n\t\t\t\t\t*/ }\n\t\t\t\t\t<iframe\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tclassName=\"wp-block-legacy-widget__edit-preview-iframe\"\n\t\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t\ttitle={ __( 'Legacy Widget Preview' ) }\n\t\t\t\t\t\tsrcDoc={ srcDoc }\n\t\t\t\t\t\tonLoad={ ( event ) => {\n\t\t\t\t\t\t\t// To hide the scrollbars of the preview frame for some edge cases,\n\t\t\t\t\t\t\t// such as negative margins in the Gallery Legacy Widget.\n\t\t\t\t\t\t\t// It can't be scrolled anyway.\n\t\t\t\t\t\t\t// TODO: Ideally, this should be fixed in core.\n\t\t\t\t\t\t\tevent.target.contentDocument.body.style.overflow =\n\t\t\t\t\t\t\t\t'hidden';\n\n\t\t\t\t\t\t\tsetIsLoaded( true );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\theight={ 100 }\n\t\t\t\t\t/>\n\t\t\t\t</Disabled>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": "AAqGE,mBAUG,KAVH;AAlGF,OAAO,UAAU;AAKjB,SAAS,oBAAoB;AAC7B,SAAS,WAAW,gBAAgB;AACpC,SAAS,UAAU,aAAa,eAAe;AAC/C,SAAS,UAAU;AACnB,OAAO,cAAc;AAEN,SAAR,QAA0B,EAAE,QAAQ,UAAU,UAAU,GAAI;AAClE,QAAM,CAAE,UAAU,WAAY,IAAI,SAAU,KAAM;AAClD,QAAM,CAAE,QAAQ,SAAU,IAAI,SAAU,EAAG;AAE3C,YAAW,MAAM;AAChB,UAAM,kBACL,OAAO,OAAO,oBAAoB,cAC/B,SACA,IAAI,OAAO,gBAAgB;AAE/B,mBAAe,mBAAmB;AACjC,YAAM,YAAY,uBAAwB,MAAO;AACjD,aAAO,MAAM,SAAU;AAAA,QACtB,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,QAAQ,iBAAiB;AAAA,QACzB,MAAM,WAAW,EAAE,SAAS,IAAI,CAAC;AAAA,MAClC,CAAE;AAAA,IACH;AAEA,qBAAiB,EACf,KAAM,CAAE,aAAc;AACtB,gBAAW,SAAS,OAAQ;AAAA,IAC7B,CAAE,EACD,MAAO,CAAE,UAAW;AACpB,UAAK,iBAAiB,MAAM,MA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AAa,IAAK;AAAA,YACnB;AAAA,YACA,QAAS;AAAA;AAAA,QACV,GACD;AAAA;AAAA,IACD;AAAA,KACD;AAEF;",
6
+ "names": []
7
+ }
@@ -1,54 +1,51 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { Spinner, SelectControl } from '@wordpress/components';
5
- import { __ } from '@wordpress/i18n';
6
- import { useSelect } from '@wordpress/data';
7
- import { store as coreStore } from '@wordpress/core-data';
8
- import { store as blockEditorStore } from '@wordpress/block-editor';
9
- import { jsx as _jsx } from "react/jsx-runtime";
10
- export default function WidgetTypeSelector({
11
- selectedId,
12
- onSelect
13
- }) {
14
- const widgetTypes = useSelect(select => {
15
- var _select$getSettings$w;
16
- const hiddenIds = (_select$getSettings$w = select(blockEditorStore).getSettings()?.widgetTypesToHideFromLegacyWidgetBlock) !== null && _select$getSettings$w !== void 0 ? _select$getSettings$w : [];
17
- return select(coreStore).getWidgetTypes({
18
- per_page: -1
19
- })?.filter(widgetType => !hiddenIds.includes(widgetType.id));
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Spinner, SelectControl } from "@wordpress/components";
3
+ import { __ } from "@wordpress/i18n";
4
+ import { useSelect } from "@wordpress/data";
5
+ import { store as coreStore } from "@wordpress/core-data";
6
+ import { store as blockEditorStore } from "@wordpress/block-editor";
7
+ function WidgetTypeSelector({ selectedId, onSelect }) {
8
+ const widgetTypes = useSelect((select) => {
9
+ const hiddenIds = select(blockEditorStore).getSettings()?.widgetTypesToHideFromLegacyWidgetBlock ?? [];
10
+ return select(coreStore).getWidgetTypes({ per_page: -1 })?.filter((widgetType) => !hiddenIds.includes(widgetType.id));
20
11
  }, []);
21
12
  if (!widgetTypes) {
22
- return /*#__PURE__*/_jsx(Spinner, {});
13
+ return /* @__PURE__ */ jsx(Spinner, {});
23
14
  }
24
15
  if (widgetTypes.length === 0) {
25
- return __('There are no widgets available.');
16
+ return __("There are no widgets available.");
26
17
  }
27
- return /*#__PURE__*/_jsx(SelectControl, {
28
- __next40pxDefaultSize: true,
29
- __nextHasNoMarginBottom: true,
30
- label: __('Legacy widget'),
31
- value: selectedId !== null && selectedId !== void 0 ? selectedId : '',
32
- options: [{
33
- value: '',
34
- label: __('Select widget')
35
- }, ...widgetTypes.map(widgetType => ({
36
- value: widgetType.id,
37
- label: widgetType.name
38
- }))],
39
- onChange: value => {
40
- if (value) {
41
- const selected = widgetTypes.find(widgetType => widgetType.id === value);
42
- onSelect({
43
- selectedId: selected.id,
44
- isMulti: selected.is_multi
45
- });
46
- } else {
47
- onSelect({
48
- selectedId: null
49
- });
18
+ return /* @__PURE__ */ jsx(
19
+ SelectControl,
20
+ {
21
+ __next40pxDefaultSize: true,
22
+ __nextHasNoMarginBottom: true,
23
+ label: __("Legacy widget"),
24
+ value: selectedId ?? "",
25
+ options: [
26
+ { value: "", label: __("Select widget") },
27
+ ...widgetTypes.map((widgetType) => ({
28
+ value: widgetType.id,
29
+ label: widgetType.name
30
+ }))
31
+ ],
32
+ onChange: (value) => {
33
+ if (value) {
34
+ const selected = widgetTypes.find(
35
+ (widgetType) => widgetType.id === value
36
+ );
37
+ onSelect({
38
+ selectedId: selected.id,
39
+ isMulti: selected.is_multi
40
+ });
41
+ } else {
42
+ onSelect({ selectedId: null });
43
+ }
50
44
  }
51
45
  }
52
- });
46
+ );
53
47
  }
54
- //# sourceMappingURL=widget-type-selector.js.map
48
+ export {
49
+ WidgetTypeSelector as default
50
+ };
51
+ //# sourceMappingURL=widget-type-selector.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["Spinner","SelectControl","__","useSelect","store","coreStore","blockEditorStore","jsx","_jsx","WidgetTypeSelector","selectedId","onSelect","widgetTypes","select","_select$getSettings$w","hiddenIds","getSettings","widgetTypesToHideFromLegacyWidgetBlock","getWidgetTypes","per_page","filter","widgetType","includes","id","length","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","options","map","name","onChange","selected","find","isMulti","is_multi"],"sources":["@wordpress/widgets/src/blocks/legacy-widget/edit/widget-type-selector.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Spinner, SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nexport default function WidgetTypeSelector( { selectedId, onSelect } ) {\n\tconst widgetTypes = useSelect( ( select ) => {\n\t\tconst hiddenIds =\n\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t?.widgetTypesToHideFromLegacyWidgetBlock ?? [];\n\t\treturn select( coreStore )\n\t\t\t.getWidgetTypes( { per_page: -1 } )\n\t\t\t?.filter( ( widgetType ) => ! hiddenIds.includes( widgetType.id ) );\n\t}, [] );\n\n\tif ( ! widgetTypes ) {\n\t\treturn <Spinner />;\n\t}\n\n\tif ( widgetTypes.length === 0 ) {\n\t\treturn __( 'There are no widgets available.' );\n\t}\n\n\treturn (\n\t\t<SelectControl\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t\tlabel={ __( 'Legacy widget' ) }\n\t\t\tvalue={ selectedId ?? '' }\n\t\t\toptions={ [\n\t\t\t\t{ value: '', label: __( 'Select widget' ) },\n\t\t\t\t...widgetTypes.map( ( widgetType ) => ( {\n\t\t\t\t\tvalue: widgetType.id,\n\t\t\t\t\tlabel: widgetType.name,\n\t\t\t\t} ) ),\n\t\t\t] }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tif ( value ) {\n\t\t\t\t\tconst selected = widgetTypes.find(\n\t\t\t\t\t\t( widgetType ) => widgetType.id === value\n\t\t\t\t\t);\n\t\t\t\t\tonSelect( {\n\t\t\t\t\t\tselectedId: selected.id,\n\t\t\t\t\t\tisMulti: selected.is_multi,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tonSelect( { selectedId: null } );\n\t\t\t\t}\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SA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U,WAAW,CAACkB,GAAG,CAAIT,UAAU,KAAQ;MACvCO,KAAK,EAAEP,UAAU,CAACE,EAAE;MACpBI,KAAK,EAAEN,UAAU,CAACU;IACnB,CAAC,CAAG,CAAC,CACH;IACHC,QAAQ,EAAKJ,KAAK,IAAM;MACvB,IAAKA,KAAK,EAAG;QACZ,MAAMK,QAAQ,GAAGrB,WAAW,CAACsB,IAAI,CAC9Bb,UAAU,IAAMA,UAAU,CAACE,EAAE,KAAKK,KACrC,CAAC;QACDjB,QAAQ,CAAE;UACTD,UAAU,EAAEuB,QAAQ,CAACV,EAAE;UACvBY,OAAO,EAAEF,QAAQ,CAACG;QACnB,CAAE,CAAC;MACJ,CAAC,MAAM;QACNzB,QAAQ,CAAE;UAAED,UAAU,EAAE;QAAK,CAAE,CAAC;MACjC;IACD;EAAG,CACH,CAAC;AAEJ","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/blocks/legacy-widget/edit/widget-type-selector.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Spinner, SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nexport default function WidgetTypeSelector( { selectedId, onSelect } ) {\n\tconst widgetTypes = useSelect( ( select ) => {\n\t\tconst hiddenIds =\n\t\t\tselect( blockEditorStore ).getSettings()\n\t\t\t\t?.widgetTypesToHideFromLegacyWidgetBlock ?? [];\n\t\treturn select( coreStore )\n\t\t\t.getWidgetTypes( { per_page: -1 } )\n\t\t\t?.filter( ( widgetType ) => ! hiddenIds.includes( widgetType.id ) );\n\t}, [] );\n\n\tif ( ! widgetTypes ) {\n\t\treturn <Spinner />;\n\t}\n\n\tif ( widgetTypes.length === 0 ) {\n\t\treturn __( 'There are no widgets available.' );\n\t}\n\n\treturn (\n\t\t<SelectControl\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t\tlabel={ __( 'Legacy widget' ) }\n\t\t\tvalue={ selectedId ?? '' }\n\t\t\toptions={ [\n\t\t\t\t{ value: '', label: __( 'Select widget' ) },\n\t\t\t\t...widgetTypes.map( ( widgetType ) => ( {\n\t\t\t\t\tvalue: widgetType.id,\n\t\t\t\t\tlabel: widgetType.name,\n\t\t\t\t} ) ),\n\t\t\t] }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tif ( value ) {\n\t\t\t\t\tconst selected = widgetTypes.find(\n\t\t\t\t\t\t( widgetType ) => widgetType.id === value\n\t\t\t\t\t);\n\t\t\t\t\tonSelect( {\n\t\t\t\t\t\tselectedId: selected.id,\n\t\t\t\t\t\tisMulti: selected.is_multi,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tonSelect( { selectedId: null } );\n\t\t\t\t}\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],
5
+ "mappings": "AAoBS;AAjBT,SAAS,SAAS,qBAAqB;AACvC,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,wBAAwB;AAE3B,SAAR,mBAAqC,EAAE,YAAY,SAAS,GAAI;AACtE,QAAM,cAAc,UAAW,CAAE,WAAY;AAC5C,UAAM,YACL,OAAQ,gBAAiB,EAAE,YAAY,GACpC,0CAA0C,CAAC;AAC/C,WAAO,OAAQ,SAAU,EACvB,eAAgB,EAAE,UAAU,GAAG,CAAE,GAChC,OAAQ,CAAE,eAAgB,CAAE,UAAU,SAAU,WAAW,EAAG,CAAE;AAAA,EACpE,GAAG,CAAC,CAAE;AAEN,MAAK,CAAE,aAAc;AACpB,WAAO,oBAAC,WAAQ;AAAA,EACjB;AAEA,MAAK,YAAY,WAAW,GAAI;AAC/B,WAAO,GAAI,iCAAkC;AAAA,EAC9C;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,uBAAqB;AAAA,MACrB,yBAAuB;AAAA,MACvB,OAAQ,GAAI,eAAgB;AAAA,MAC5B,OAAQ,cAAc;AAAA,MACtB,SAAU;AAAA,QACT,EAAE,OAAO,IAAI,OAAO,GAAI,eAAgB,EAAE;AAAA,QAC1C,GAAG,YAAY,IAAK,CAAE,gBAAkB;AAAA,UACvC,OAAO,WAAW;AAAA,UAClB,OAAO,WAAW;AAAA,QACnB,EAAI;AAAA,MACL;AAAA,MACA,UAAW,CAAE,UAAW;AACvB,YAAK,OAAQ;AACZ,gBAAM,WAAW,YAAY;AAAA,YAC5B,CAAE,eAAgB,WAAW,OAAO;AAAA,UACrC;AACA,mBAAU;AAAA,YACT,YAAY,SAAS;AAAA,YACrB,SAAS,SAAS;AAAA,UACnB,CAAE;AAAA,QACH,OAAO;AACN,mBAAU,EAAE,YAAY,KAAK,CAAE;AAAA,QAChC;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
6
+ "names": []
7
+ }
@@ -1,49 +1,16 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { widget as icon } from '@wordpress/icons';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- const metadata = {
10
- $schema: "https://schemas.wp.org/trunk/block.json",
11
- apiVersion: 3,
12
- name: "core/legacy-widget",
13
- title: "Legacy Widget",
14
- category: "widgets",
15
- description: "Display a legacy widget.",
16
- textdomain: "default",
17
- attributes: {
18
- id: {
19
- type: "string",
20
- "default": null
21
- },
22
- idBase: {
23
- type: "string",
24
- "default": null
25
- },
26
- instance: {
27
- type: "object",
28
- "default": null
29
- }
30
- },
31
- supports: {
32
- html: false,
33
- customClassName: false,
34
- reusable: false
35
- },
36
- editorStyle: "wp-block-legacy-widget-editor"
37
- };
38
- import edit from './edit';
39
- import transforms from './transforms';
40
- const {
41
- name
42
- } = metadata;
43
- export { metadata, name };
44
- export const settings = {
1
+ import { widget as icon } from "@wordpress/icons";
2
+ import metadata from "./block.json";
3
+ import edit from "./edit";
4
+ import transforms from "./transforms";
5
+ const { name } = metadata;
6
+ const settings = {
45
7
  icon,
46
8
  edit,
47
9
  transforms
48
10
  };
49
- //# sourceMappingURL=index.js.map
11
+ export {
12
+ metadata,
13
+ name,
14
+ settings
15
+ };
16
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["widget","icon","metadata","$schema","apiVersion","name","title","category","description","textdomain","attributes","id","type","idBase","instance","supports","html","customClassName","reusable","editorStyle","edit","transforms","settings"],"sources":["@wordpress/widgets/src/blocks/legacy-widget/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { widget as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport transforms from './transforms';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\ttransforms,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,IAAIC,IAAI,QAAQ,kBAAkB;;AAEjD;AACA;AACA;AAFA,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,EAAA;MAAAC,IAAA;MAAA;IAAA;IAAAC,MAAA;MAAAD,IAAA;MAAA;IAAA;IAAAE,QAAA;MAAAF,IAAA;MAAA;IAAA;EAAA;EAAAG,QAAA;IAAAC,IAAA;IAAAC,eAAA;IAAAC,QAAA;EAAA;EAAAC,WAAA;AAAA;AAIA,OAAOC,IAAI,MAAM,QAAQ;AACzB,OAAOC,UAAU,MAAM,cAAc;AAErC,MAAM;EAAEhB;AAAK,CAAC,GAAGH,QAAQ;AACzB,SAASA,QAAQ,EAAEG,IAAI;AAEvB,OAAO,MAAMiB,QAAQ,GAAG;EACvBrB,IAAI;EACJmB,IAAI;EACJC;AACD,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/blocks/legacy-widget/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { widget as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport transforms from './transforms';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\ttransforms,\n};\n"],
5
+ "mappings": "AAGA,SAAS,UAAU,YAAY;AAK/B,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AAEvB,MAAM,EAAE,KAAK,IAAI;AAGV,MAAM,WAAW;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AACD;",
6
+ "names": []
7
+ }