@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 +1,7 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_blockEditor","_components","_icons","_i18n","_element","_coreData","_widgetTypeSelector","_inspectorCard","_form","_preview","_noPreview","_convertToBlocksButton","_jsxRuntime","Edit","props","id","idBase","attributes","isWide","blockProps","useBlockProps","className","clsx","jsx","children","Empty","NotEmpty","setAttributes","Placeholder","icon","BlockIcon","brushIcon","label","__","Flex","FlexBlock","default","selectedId","onSelect","isMulti","instance","clientId","isSelected","hasPreview","setHasPreview","useState","widgetTypeId","record","widgetType","hasResolved","hasResolvedWidgetType","useEntityRecord","setInstance","useCallback","nextInstance","Spinner","mode","jsxs","Fragment","BlockControls","group","rawInstance","raw","InspectorControls","name","description","title","isVisible","onChangeInstance","onChangeHasPreview"],"sources":["@wordpress/widgets/src/blocks/legacy-widget/edit/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tBlockControls,\n\tInspectorControls,\n\tBlockIcon,\n} from '@wordpress/block-editor';\nimport { Flex, FlexBlock, Spinner, Placeholder } from '@wordpress/components';\nimport { brush as brushIcon } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useCallback } from '@wordpress/element';\nimport { useEntityRecord } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport WidgetTypeSelector from './widget-type-selector';\nimport InspectorCard from './inspector-card';\nimport Form from './form';\nimport Preview from './preview';\nimport NoPreview from './no-preview';\nimport ConvertToBlocksButton from './convert-to-blocks-button';\n\nexport default function Edit( props ) {\n\tconst { id, idBase } = props.attributes;\n\tconst { isWide = false } = props;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( {\n\t\t\t'is-wide-widget': isWide,\n\t\t} ),\n\t} );\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ ! id && ! idBase ? (\n\t\t\t\t<Empty { ...props } />\n\t\t\t) : (\n\t\t\t\t<NotEmpty { ...props } />\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction Empty( { attributes: { id, idBase }, setAttributes } ) {\n\treturn (\n\t\t<Placeholder\n\t\t\ticon={ <BlockIcon icon={ brushIcon } /> }\n\t\t\tlabel={ __( 'Legacy Widget' ) }\n\t\t>\n\t\t\t<Flex>\n\t\t\t\t<FlexBlock>\n\t\t\t\t\t<WidgetTypeSelector\n\t\t\t\t\t\tselectedId={ id ?? idBase }\n\t\t\t\t\t\tonSelect={ ( { selectedId, isMulti } ) => {\n\t\t\t\t\t\t\tif ( ! selectedId ) {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tid: null,\n\t\t\t\t\t\t\t\t\tidBase: null,\n\t\t\t\t\t\t\t\t\tinstance: null,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else if ( isMulti ) {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tid: null,\n\t\t\t\t\t\t\t\t\tidBase: selectedId,\n\t\t\t\t\t\t\t\t\tinstance: {},\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tid: selectedId,\n\t\t\t\t\t\t\t\t\tidBase: null,\n\t\t\t\t\t\t\t\t\tinstance: null,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</FlexBlock>\n\t\t\t</Flex>\n\t\t</Placeholder>\n\t);\n}\n\nfunction NotEmpty( {\n\tattributes: { id, idBase, instance },\n\tsetAttributes,\n\tclientId,\n\tisSelected,\n\tisWide = false,\n} ) {\n\tconst [ hasPreview, setHasPreview ] = useState( null );\n\n\tconst widgetTypeId = id ?? idBase;\n\tconst { record: widgetType, hasResolved: hasResolvedWidgetType } =\n\t\tuseEntityRecord( 'root', 'widgetType', widgetTypeId );\n\n\tconst setInstance = useCallback( ( nextInstance ) => {\n\t\tsetAttributes( { instance: nextInstance } );\n\t}, [] );\n\n\tif ( ! widgetType && hasResolvedWidgetType ) {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\ticon={ <BlockIcon icon={ brushIcon } /> }\n\t\t\t\tlabel={ __( 'Legacy Widget' ) }\n\t\t\t>\n\t\t\t\t{ __( 'Widget is missing.' ) }\n\t\t\t</Placeholder>\n\t\t);\n\t}\n\n\tif ( ! hasResolvedWidgetType ) {\n\t\treturn (\n\t\t\t<Placeholder>\n\t\t\t\t<Spinner />\n\t\t\t</Placeholder>\n\t\t);\n\t}\n\n\tconst mode = idBase && ! isSelected ? 'preview' : 'edit';\n\n\treturn (\n\t\t<>\n\t\t\t{ idBase === 'text' && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<ConvertToBlocksButton\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\trawInstance={ instance.raw }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\n\t\t\t<InspectorControls>\n\t\t\t\t<InspectorCard\n\t\t\t\t\tname={ widgetType.name }\n\t\t\t\t\tdescription={ widgetType.description }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\n\t\t\t<Form\n\t\t\t\ttitle={ widgetType.name }\n\t\t\t\tisVisible={ mode === 'edit' }\n\t\t\t\tid={ id }\n\t\t\t\tidBase={ idBase }\n\t\t\t\tinstance={ instance }\n\t\t\t\tisWide={ isWide }\n\t\t\t\tonChangeInstance={ setInstance }\n\t\t\t\tonChangeHasPreview={ setHasPreview }\n\t\t\t/>\n\n\t\t\t{ idBase && (\n\t\t\t\t<>\n\t\t\t\t\t{ hasPreview === null && mode === 'preview' && (\n\t\t\t\t\t\t<Placeholder>\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t</Placeholder>\n\t\t\t\t\t) }\n\t\t\t\t\t{ hasPreview === true && (\n\t\t\t\t\t\t<Preview\n\t\t\t\t\t\t\tidBase={ idBase }\n\t\t\t\t\t\t\tinstance={ instance }\n\t\t\t\t\t\t\tisVisible={ mode === 'preview' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ hasPreview === false && mode === 'preview' && (\n\t\t\t\t\t\t<NoPreview name={ widgetType.name } />\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AAMA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAKA,IAAAO,mBAAA,GAAAR,sBAAA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EAAGhB,UAAU,CAACgB;MAAM,CAAE,CACrC;IAAA,CACA,CACF;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/blocks/legacy-widget/edit/index.js"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tBlockControls,\n\tInspectorControls,\n\tBlockIcon,\n} from '@wordpress/block-editor';\nimport { Flex, FlexBlock, Spinner, Placeholder } from '@wordpress/components';\nimport { brush as brushIcon } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useCallback } from '@wordpress/element';\nimport { useEntityRecord } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport WidgetTypeSelector from './widget-type-selector';\nimport InspectorCard from './inspector-card';\nimport Form from './form';\nimport Preview from './preview';\nimport NoPreview from './no-preview';\nimport ConvertToBlocksButton from './convert-to-blocks-button';\n\nexport default function Edit( props ) {\n\tconst { id, idBase } = props.attributes;\n\tconst { isWide = false } = props;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( {\n\t\t\t'is-wide-widget': isWide,\n\t\t} ),\n\t} );\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ ! id && ! idBase ? (\n\t\t\t\t<Empty { ...props } />\n\t\t\t) : (\n\t\t\t\t<NotEmpty { ...props } />\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction Empty( { attributes: { id, idBase }, setAttributes } ) {\n\treturn (\n\t\t<Placeholder\n\t\t\ticon={ <BlockIcon icon={ brushIcon } /> }\n\t\t\tlabel={ __( 'Legacy Widget' ) }\n\t\t>\n\t\t\t<Flex>\n\t\t\t\t<FlexBlock>\n\t\t\t\t\t<WidgetTypeSelector\n\t\t\t\t\t\tselectedId={ id ?? idBase }\n\t\t\t\t\t\tonSelect={ ( { selectedId, isMulti } ) => {\n\t\t\t\t\t\t\tif ( ! selectedId ) {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tid: null,\n\t\t\t\t\t\t\t\t\tidBase: null,\n\t\t\t\t\t\t\t\t\tinstance: null,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else if ( isMulti ) {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tid: null,\n\t\t\t\t\t\t\t\t\tidBase: selectedId,\n\t\t\t\t\t\t\t\t\tinstance: {},\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tid: selectedId,\n\t\t\t\t\t\t\t\t\tidBase: null,\n\t\t\t\t\t\t\t\t\tinstance: null,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</FlexBlock>\n\t\t\t</Flex>\n\t\t</Placeholder>\n\t);\n}\n\nfunction NotEmpty( {\n\tattributes: { id, idBase, instance },\n\tsetAttributes,\n\tclientId,\n\tisSelected,\n\tisWide = false,\n} ) {\n\tconst [ hasPreview, setHasPreview ] = useState( null );\n\n\tconst widgetTypeId = id ?? idBase;\n\tconst { record: widgetType, hasResolved: hasResolvedWidgetType } =\n\t\tuseEntityRecord( 'root', 'widgetType', widgetTypeId );\n\n\tconst setInstance = useCallback( ( nextInstance ) => {\n\t\tsetAttributes( { instance: nextInstance } );\n\t}, [] );\n\n\tif ( ! widgetType && hasResolvedWidgetType ) {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\ticon={ <BlockIcon icon={ brushIcon } /> }\n\t\t\t\tlabel={ __( 'Legacy Widget' ) }\n\t\t\t>\n\t\t\t\t{ __( 'Widget is missing.' ) }\n\t\t\t</Placeholder>\n\t\t);\n\t}\n\n\tif ( ! hasResolvedWidgetType ) {\n\t\treturn (\n\t\t\t<Placeholder>\n\t\t\t\t<Spinner />\n\t\t\t</Placeholder>\n\t\t);\n\t}\n\n\tconst mode = idBase && ! isSelected ? 'preview' : 'edit';\n\n\treturn (\n\t\t<>\n\t\t\t{ idBase === 'text' && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<ConvertToBlocksButton\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\trawInstance={ instance.raw }\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\n\t\t\t<InspectorControls>\n\t\t\t\t<InspectorCard\n\t\t\t\t\tname={ widgetType.name }\n\t\t\t\t\tdescription={ widgetType.description }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\n\t\t\t<Form\n\t\t\t\ttitle={ widgetType.name }\n\t\t\t\tisVisible={ mode === 'edit' }\n\t\t\t\tid={ id }\n\t\t\t\tidBase={ idBase }\n\t\t\t\tinstance={ instance }\n\t\t\t\tisWide={ isWide }\n\t\t\t\tonChangeInstance={ setInstance }\n\t\t\t\tonChangeHasPreview={ setHasPreview }\n\t\t\t/>\n\n\t\t\t{ idBase && (\n\t\t\t\t<>\n\t\t\t\t\t{ hasPreview === null && mode === 'preview' && (\n\t\t\t\t\t\t<Placeholder>\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t</Placeholder>\n\t\t\t\t\t) }\n\t\t\t\t\t{ hasPreview === true && (\n\t\t\t\t\t\t<Preview\n\t\t\t\t\t\t\tidBase={ idBase }\n\t\t\t\t\t\t\tinstance={ instance }\n\t\t\t\t\t\t\tisVisible={ mode === 'preview' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ hasPreview === false && mode === 'preview' && (\n\t\t\t\t\t\t<NoPreview name={ widgetType.name } />\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2CI;AAxCJ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IAEE,UACD,4EACG;AAAA,qBAAe,QAAQ,SAAS,aACjC,4CAAC,iCACA,sDAAC,6BAAQ,GACV;AAAA,MAEC,eAAe,QAChB;AAAA,QAAC,eAAAC;AAAA,QAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA,WAAY,SAAS;AAAA;AAAA,MACtB;AAAA,MAEC,eAAe,SAAS,SAAS,aAClC,4CAAC,kBAAAC,SAAA,EAAU,MAAO,WAAW,MAAO;AAAA,OAEtC;AAAA,KAEF;AAEF;",
6
+ "names": ["clsx", "brushIcon", "WidgetTypeSelector", "ConvertToBlocksButton", "InspectorCard", "Form", "Preview", "NoPreview"]
7
+ }
@@ -1,22 +1,30 @@
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 inspector_card_exports = {};
19
+ __export(inspector_card_exports, {
20
+ default: () => InspectorCard
5
21
  });
6
- exports.default = InspectorCard;
7
- var _jsxRuntime = require("react/jsx-runtime");
8
- function InspectorCard({
9
- name,
10
- description
11
- }) {
12
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
13
- className: "wp-block-legacy-widget-inspector-card",
14
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
15
- className: "wp-block-legacy-widget-inspector-card__name",
16
- children: name
17
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
18
- children: description
19
- })]
20
- });
22
+ module.exports = __toCommonJS(inspector_card_exports);
23
+ var import_jsx_runtime = require("react/jsx-runtime");
24
+ function InspectorCard({ name, description }) {
25
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wp-block-legacy-widget-inspector-card", children: [
26
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "wp-block-legacy-widget-inspector-card__name", children: name }),
27
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: description })
28
+ ] });
21
29
  }
22
- //# sourceMappingURL=inspector-card.js.map
30
+ //# sourceMappingURL=inspector-card.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["InspectorCard","name","description","_jsxRuntime","jsxs","className","children","jsx"],"sources":["@wordpress/widgets/src/blocks/legacy-widget/edit/inspector-card.js"],"sourcesContent":["export default function InspectorCard( { name, description } ) {\n\treturn (\n\t\t<div className=\"wp-block-legacy-widget-inspector-card\">\n\t\t\t<h3 className=\"wp-block-legacy-widget-inspector-card__name\">\n\t\t\t\t{ name }\n\t\t\t</h3>\n\t\t\t<span>{ description }</span>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAAe,SAASA,aAAaA,CAAE;EAAEC,IAAI;EAAEC;AAAY,CAAC,EAAG;EAC9D,oBACC,IAAAC,WAAA,CAAAC,IAAA;IAAKC,SAAS,EAAC,uCAAuC;IAAAC,QAAA,gBACrD,IAAAH,WAAA,CAAAI,GAAA;MAAIF,SAAS,EAAC,6CAA6C;MAAAC,QAAA,EACxDL;IAAI,CACH,CAAC,eACL,IAAAE,WAAA,CAAAI,GAAA;MAAAD,QAAA,EAAQJ;IAAW,CAAQ,CAAC;EAAA,CACxB,CAAC;AAER","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/blocks/legacy-widget/edit/inspector-card.js"],
4
+ "sourcesContent": ["export default function InspectorCard( { name, description } ) {\n\treturn (\n\t\t<div className=\"wp-block-legacy-widget-inspector-card\">\n\t\t\t<h3 className=\"wp-block-legacy-widget-inspector-card__name\">\n\t\t\t\t{ name }\n\t\t\t</h3>\n\t\t\t<span>{ description }</span>\n\t\t</div>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEE;AAFa,SAAR,cAAgC,EAAE,MAAM,YAAY,GAAI;AAC9D,SACC,6CAAC,SAAI,WAAU,yCACd;AAAA,gDAAC,QAAG,WAAU,+CACX,gBACH;AAAA,IACA,4CAAC,UAAO,uBAAa;AAAA,KACtB;AAEF;",
6
+ "names": []
7
+ }
@@ -1,25 +1,31 @@
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 no_preview_exports = {};
19
+ __export(no_preview_exports, {
20
+ default: () => NoPreview
5
21
  });
6
- exports.default = NoPreview;
7
- var _i18n = require("@wordpress/i18n");
8
- var _jsxRuntime = require("react/jsx-runtime");
9
- /**
10
- * WordPress dependencies
11
- */
12
-
13
- function NoPreview({
14
- name
15
- }) {
16
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
17
- className: "wp-block-legacy-widget__edit-no-preview",
18
- children: [name && /*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
19
- children: name
20
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
21
- children: (0, _i18n.__)('No preview available.')
22
- })]
23
- });
22
+ module.exports = __toCommonJS(no_preview_exports);
23
+ var import_jsx_runtime = require("react/jsx-runtime");
24
+ var import_i18n = require("@wordpress/i18n");
25
+ function NoPreview({ name }) {
26
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wp-block-legacy-widget__edit-no-preview", children: [
27
+ name && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: name }),
28
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: (0, import_i18n.__)("No preview available.") })
29
+ ] });
24
30
  }
25
- //# sourceMappingURL=no-preview.js.map
31
+ //# sourceMappingURL=no-preview.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_i18n","require","_jsxRuntime","NoPreview","name","jsxs","className","children","jsx","__"],"sources":["@wordpress/widgets/src/blocks/legacy-widget/edit/no-preview.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport default function NoPreview( { name } ) {\n\treturn (\n\t\t<div className=\"wp-block-legacy-widget__edit-no-preview\">\n\t\t\t{ name && <h3>{ name }</h3> }\n\t\t\t<p>{ __( 'No preview available.' ) }</p>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAAqC,IAAAC,WAAA,GAAAD,OAAA;AAHrC;AACA;AACA;;AAGe,SAASE,SAASA,CAAE;EAAEC;AAAK,CAAC,EAAG;EAC7C,oBACC,IAAAF,WAAA,CAAAG,IAAA;IAAKC,SAAS,EAAC,yCAAyC;IAAAC,QAAA,GACrDH,IAAI,iBAAI,IAAAF,WAAA,CAAAM,GAAA;MAAAD,QAAA,EAAMH;IAAI,CAAM,CAAC,eAC3B,IAAAF,WAAA,CAAAM,GAAA;MAAAD,QAAA,EAAK,IAAAE,QAAE,EAAE,uBAAwB;IAAC,CAAK,CAAC;EAAA,CACpC,CAAC;AAER","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/blocks/legacy-widget/edit/no-preview.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport default function NoPreview( { name } ) {\n\treturn (\n\t\t<div className=\"wp-block-legacy-widget__edit-no-preview\">\n\t\t\t{ name && <h3>{ name }</h3> }\n\t\t\t<p>{ __( 'No preview available.' ) }</p>\n\t\t</div>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOE;AAJF,kBAAmB;AAEJ,SAAR,UAA4B,EAAE,KAAK,GAAI;AAC7C,SACC,6CAAC,SAAI,WAAU,2CACZ;AAAA,YAAQ,4CAAC,QAAK,gBAAM;AAAA,IACtB,4CAAC,OAAI,8BAAI,uBAAwB,GAAG;AAAA,KACrC;AAEF;",
6
+ "names": []
7
+ }
@@ -1,124 +1,123 @@
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 preview_exports = {};
29
+ __export(preview_exports, {
30
+ default: () => Preview
6
31
  });
7
- exports.default = Preview;
8
- var _clsx = _interopRequireDefault(require("clsx"));
9
- var _compose = require("@wordpress/compose");
10
- var _element = require("@wordpress/element");
11
- var _components = require("@wordpress/components");
12
- var _i18n = require("@wordpress/i18n");
13
- var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
14
- var _jsxRuntime = require("react/jsx-runtime");
15
- /**
16
- * External dependencies
17
- */
18
-
19
- /**
20
- * WordPress dependencies
21
- */
22
-
23
- function Preview({
24
- idBase,
25
- instance,
26
- isVisible
27
- }) {
28
- const [isLoaded, setIsLoaded] = (0, _element.useState)(false);
29
- const [srcDoc, setSrcDoc] = (0, _element.useState)('');
30
- (0, _element.useEffect)(() => {
31
- const abortController = typeof window.AbortController === 'undefined' ? undefined : new window.AbortController();
32
+ module.exports = __toCommonJS(preview_exports);
33
+ var import_jsx_runtime = require("react/jsx-runtime");
34
+ var import_clsx = __toESM(require("clsx"));
35
+ var import_compose = require("@wordpress/compose");
36
+ var import_element = require("@wordpress/element");
37
+ var import_components = require("@wordpress/components");
38
+ var import_i18n = require("@wordpress/i18n");
39
+ var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
40
+ function Preview({ idBase, instance, isVisible }) {
41
+ const [isLoaded, setIsLoaded] = (0, import_element.useState)(false);
42
+ const [srcDoc, setSrcDoc] = (0, import_element.useState)("");
43
+ (0, import_element.useEffect)(() => {
44
+ const abortController = typeof window.AbortController === "undefined" ? void 0 : new window.AbortController();
32
45
  async function fetchPreviewHTML() {
33
46
  const restRoute = `/wp/v2/widget-types/${idBase}/render`;
34
- return await (0, _apiFetch.default)({
47
+ return await (0, import_api_fetch.default)({
35
48
  path: restRoute,
36
- method: 'POST',
49
+ method: "POST",
37
50
  signal: abortController?.signal,
38
- data: instance ? {
39
- instance
40
- } : {}
51
+ data: instance ? { instance } : {}
41
52
  });
42
53
  }
43
- fetchPreviewHTML().then(response => {
54
+ fetchPreviewHTML().then((response) => {
44
55
  setSrcDoc(response.preview);
45
- }).catch(error => {
46
- if ('AbortError' === error.name) {
47
- // We don't want to log aborted requests.
56
+ }).catch((error) => {
57
+ if ("AbortError" === error.name) {
48
58
  return;
49
59
  }
50
60
  throw error;
51
61
  });
52
62
  return () => abortController?.abort();
53
63
  }, [idBase, instance]);
54
-
55
- // Resize the iframe on either the load event, or when the iframe becomes visible.
56
- const ref = (0, _compose.useRefEffect)(iframe => {
57
- // Only set height if the iframe is loaded,
58
- // or it will grow to an unexpected large height in Safari if it's hidden initially.
59
- if (!isLoaded) {
60
- return;
61
- }
62
- // If the preview frame has another origin then this won't work.
63
- // One possible solution is to add custom script to call `postMessage` in the preview frame.
64
- // Or, better yet, we migrate away from iframe.
65
- function setHeight() {
66
- var _iframe$contentDocume, _iframe$contentDocume2;
67
- // Pick the maximum of these two values to account for margin collapsing.
68
- 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);
69
-
70
- // Fallback to a height of 100px if the height cannot be determined.
71
- // This ensures the block is still selectable. 100px should hopefully
72
- // be not so big that it's annoying, and not so small that nothing
73
- // can be seen.
74
- iframe.style.height = `${height !== 0 ? height : 100}px`;
75
- }
76
- const {
77
- IntersectionObserver
78
- } = iframe.ownerDocument.defaultView;
79
-
80
- // Observe for intersections that might cause a change in the height of
81
- // the iframe, e.g. a Widget Area becoming expanded.
82
- const intersectionObserver = new IntersectionObserver(([entry]) => {
83
- if (entry.isIntersecting) {
84
- setHeight();
64
+ const ref = (0, import_compose.useRefEffect)(
65
+ (iframe) => {
66
+ if (!isLoaded) {
67
+ return;
85
68
  }
86
- }, {
87
- threshold: 1
88
- });
89
- intersectionObserver.observe(iframe);
90
- iframe.addEventListener('load', setHeight);
91
- return () => {
92
- intersectionObserver.disconnect();
93
- iframe.removeEventListener('load', setHeight);
94
- };
95
- }, [isLoaded]);
96
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
97
- children: [isVisible && !isLoaded && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Placeholder, {
98
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {})
99
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
100
- className: (0, _clsx.default)('wp-block-legacy-widget__edit-preview', {
101
- 'is-offscreen': !isVisible || !isLoaded
102
- }),
103
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Disabled, {
104
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("iframe", {
105
- ref: ref,
106
- className: "wp-block-legacy-widget__edit-preview-iframe",
107
- tabIndex: "-1",
108
- title: (0, _i18n.__)('Legacy Widget Preview'),
109
- srcDoc: srcDoc,
110
- onLoad: event => {
111
- // To hide the scrollbars of the preview frame for some edge cases,
112
- // such as negative margins in the Gallery Legacy Widget.
113
- // It can't be scrolled anyway.
114
- // TODO: Ideally, this should be fixed in core.
115
- event.target.contentDocument.body.style.overflow = 'hidden';
116
- setIsLoaded(true);
117
- },
118
- height: 100
119
- })
120
- })
121
- })]
122
- });
69
+ function setHeight() {
70
+ const height = Math.max(
71
+ iframe.contentDocument.documentElement?.offsetHeight ?? 0,
72
+ iframe.contentDocument.body?.offsetHeight ?? 0
73
+ );
74
+ iframe.style.height = `${height !== 0 ? height : 100}px`;
75
+ }
76
+ const { IntersectionObserver } = iframe.ownerDocument.defaultView;
77
+ const intersectionObserver = new IntersectionObserver(
78
+ ([entry]) => {
79
+ if (entry.isIntersecting) {
80
+ setHeight();
81
+ }
82
+ },
83
+ {
84
+ threshold: 1
85
+ }
86
+ );
87
+ intersectionObserver.observe(iframe);
88
+ iframe.addEventListener("load", setHeight);
89
+ return () => {
90
+ intersectionObserver.disconnect();
91
+ iframe.removeEventListener("load", setHeight);
92
+ };
93
+ },
94
+ [isLoaded]
95
+ );
96
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
97
+ isVisible && !isLoaded && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Placeholder, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) }),
98
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
99
+ "div",
100
+ {
101
+ className: (0, import_clsx.default)("wp-block-legacy-widget__edit-preview", {
102
+ "is-offscreen": !isVisible || !isLoaded
103
+ }),
104
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Disabled, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
105
+ "iframe",
106
+ {
107
+ ref,
108
+ className: "wp-block-legacy-widget__edit-preview-iframe",
109
+ tabIndex: "-1",
110
+ title: (0, import_i18n.__)("Legacy Widget Preview"),
111
+ srcDoc,
112
+ onLoad: (event) => {
113
+ event.target.contentDocument.body.style.overflow = "hidden";
114
+ setIsLoaded(true);
115
+ },
116
+ height: 100
117
+ }
118
+ ) })
119
+ }
120
+ )
121
+ ] });
123
122
  }
124
- //# sourceMappingURL=preview.js.map
123
+ //# sourceMappingURL=preview.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_compose","_element","_components","_i18n","_apiFetch","_jsxRuntime","Preview","idBase","instance","isVisible","isLoaded","setIsLoaded","useState","srcDoc","setSrcDoc","useEffect","abortController","window","AbortController","undefined","fetchPreviewHTML","restRoute","apiFetch","path","method","signal","data","then","response","preview","catch","error","name","abort","ref","useRefEffect","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","jsxs","Fragment","children","jsx","Placeholder","Spinner","className","clsx","Disabled","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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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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqGE;AAlGF,kBAAiB;AAKjB,qBAA6B;AAC7B,qBAAoC;AACpC,wBAA+C;AAC/C,kBAAmB;AACnB,uBAAqB;AAEN,SAAR,QAA0B,EAAE,QAAQ,UAAU,UAAU,GAAI;AAClE,QAAM,CAAE,UAAU,WAAY,QAAI,yBAAU,KAAM;AAClD,QAAM,CAAE,QAAQ,SAAU,QAAI,yBAAU,EAAG;AAE3C,gCAAW,MAAM;AAChB,UAAM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AS;AAAA,EACZ;AAEA,SACC,4EAQG;AAAA,iBAAa,CAAE,YAChB,4CAAC,iCACA,sDAAC,6BAAQ,GACV;AAAA,IAED;AAAA,MAAC;AAAA;AAAA,QACA,eAAY,YAAAC,SAAM,wCAAwC;AAAA,UACzD,gBAAgB,CAAE,aAAa,CAAE;AAAA,QAClC,CAAE;AAAA,QAEF,sDAAC,8BAKA;AAAA,UAAC;AAAA;AAAA,YACA;AAAA,YACA,WAAU;AAAA,YACV,UAAS;AAAA,YACT,WAAQ,gBAAI,uBAAwB;AAAA,YACpC;AAAA,YACA,QAAS,CAAE,UAAW;AAKrB,oBAAM,OAAO,gBAAgB,KAAK,MAAM,WACvC;AAED,0BAAa,IAAK;AAAA,YACnB;AAAA,YACA,QAAS;AAAA;AAAA,QACV,GACD;AAAA;AAAA,IACD;AAAA,KACD;AAEF;",
6
+ "names": ["apiFetch", "clsx"]
7
+ }
@@ -1,61 +1,70 @@
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 widget_type_selector_exports = {};
19
+ __export(widget_type_selector_exports, {
20
+ default: () => WidgetTypeSelector
5
21
  });
6
- exports.default = WidgetTypeSelector;
7
- var _components = require("@wordpress/components");
8
- var _i18n = require("@wordpress/i18n");
9
- var _data = require("@wordpress/data");
10
- var _coreData = require("@wordpress/core-data");
11
- var _blockEditor = require("@wordpress/block-editor");
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- /**
14
- * WordPress dependencies
15
- */
16
-
17
- function WidgetTypeSelector({
18
- selectedId,
19
- onSelect
20
- }) {
21
- const widgetTypes = (0, _data.useSelect)(select => {
22
- var _select$getSettings$w;
23
- const hiddenIds = (_select$getSettings$w = select(_blockEditor.store).getSettings()?.widgetTypesToHideFromLegacyWidgetBlock) !== null && _select$getSettings$w !== void 0 ? _select$getSettings$w : [];
24
- return select(_coreData.store).getWidgetTypes({
25
- per_page: -1
26
- })?.filter(widgetType => !hiddenIds.includes(widgetType.id));
22
+ module.exports = __toCommonJS(widget_type_selector_exports);
23
+ var import_jsx_runtime = require("react/jsx-runtime");
24
+ var import_components = require("@wordpress/components");
25
+ var import_i18n = require("@wordpress/i18n");
26
+ var import_data = require("@wordpress/data");
27
+ var import_core_data = require("@wordpress/core-data");
28
+ var import_block_editor = require("@wordpress/block-editor");
29
+ function WidgetTypeSelector({ selectedId, onSelect }) {
30
+ const widgetTypes = (0, import_data.useSelect)((select) => {
31
+ const hiddenIds = select(import_block_editor.store).getSettings()?.widgetTypesToHideFromLegacyWidgetBlock ?? [];
32
+ return select(import_core_data.store).getWidgetTypes({ per_page: -1 })?.filter((widgetType) => !hiddenIds.includes(widgetType.id));
27
33
  }, []);
28
34
  if (!widgetTypes) {
29
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {});
35
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {});
30
36
  }
31
37
  if (widgetTypes.length === 0) {
32
- return (0, _i18n.__)('There are no widgets available.');
38
+ return (0, import_i18n.__)("There are no widgets available.");
33
39
  }
34
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SelectControl, {
35
- __next40pxDefaultSize: true,
36
- __nextHasNoMarginBottom: true,
37
- label: (0, _i18n.__)('Legacy widget'),
38
- value: selectedId !== null && selectedId !== void 0 ? selectedId : '',
39
- options: [{
40
- value: '',
41
- label: (0, _i18n.__)('Select widget')
42
- }, ...widgetTypes.map(widgetType => ({
43
- value: widgetType.id,
44
- label: widgetType.name
45
- }))],
46
- onChange: value => {
47
- if (value) {
48
- const selected = widgetTypes.find(widgetType => widgetType.id === value);
49
- onSelect({
50
- selectedId: selected.id,
51
- isMulti: selected.is_multi
52
- });
53
- } else {
54
- onSelect({
55
- selectedId: null
56
- });
40
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
41
+ import_components.SelectControl,
42
+ {
43
+ __next40pxDefaultSize: true,
44
+ __nextHasNoMarginBottom: true,
45
+ label: (0, import_i18n.__)("Legacy widget"),
46
+ value: selectedId ?? "",
47
+ options: [
48
+ { value: "", label: (0, import_i18n.__)("Select widget") },
49
+ ...widgetTypes.map((widgetType) => ({
50
+ value: widgetType.id,
51
+ label: widgetType.name
52
+ }))
53
+ ],
54
+ onChange: (value) => {
55
+ if (value) {
56
+ const selected = widgetTypes.find(
57
+ (widgetType) => widgetType.id === value
58
+ );
59
+ onSelect({
60
+ selectedId: selected.id,
61
+ isMulti: selected.is_multi
62
+ });
63
+ } else {
64
+ onSelect({ selectedId: null });
65
+ }
57
66
  }
58
67
  }
59
- });
68
+ );
60
69
  }
61
- //# sourceMappingURL=widget-type-selector.js.map
70
+ //# sourceMappingURL=widget-type-selector.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_components","require","_i18n","_data","_coreData","_blockEditor","_jsxRuntime","WidgetTypeSelector","selectedId","onSelect","widgetTypes","useSelect","select","_select$getSettings$w","hiddenIds","blockEditorStore","getSettings","widgetTypesToHideFromLegacyWidgetBlock","coreStore","getWidgetTypes","per_page","filter","widgetType","includes","id","jsx","Spinner","length","__","SelectControl","__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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AE,EAAE;MAAED,KAAK,EAAE,IAAAJ,QAAE,EAAE,eAAgB;IAAE,CAAC,EAC3C,GAAGlB,WAAW,CAACyB,GAAG,CAAIb,UAAU,KAAQ;MACvCW,KAAK,EAAEX,UAAU,CAACE,EAAE;MACpBQ,KAAK,EAAEV,UAAU,CAACc;IACnB,CAAC,CAAG,CAAC,CACH;IACHC,QAAQ,EAAKJ,KAAK,IAAM;MACvB,IAAKA,KAAK,EAAG;QACZ,MAAMK,QAAQ,GAAG5B,WAAW,CAAC6B,IAAI,CAC9BjB,UAAU,IAAMA,UAAU,CAACE,EAAE,KAAKS,KACrC,CAAC;QACDxB,QAAQ,CAAE;UACTD,UAAU,EAAE8B,QAAQ,CAACd,EAAE;UACvBgB,OAAO,EAAEF,QAAQ,CAACG;QACnB,CAAE,CAAC;MACJ,CAAC,MAAM;QACNhC,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": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBS;AAjBT,wBAAuC;AACvC,kBAAmB;AACnB,kBAA0B;AAC1B,uBAAmC;AACnC,0BAA0C;AAE3B,SAAR,mBAAqC,EAAE,YAAY,SAAS,GAAI;AACtE,QAAM,kBAAc,uBAAW,CAAE,WAAY;AAC5C,UAAM,YACL,OAAQ,oBAAAA,KAAiB,EAAE,YAAY,GACpC,0CAA0C,CAAC;AAC/C,WAAO,OAAQ,iBAAAC,KAAU,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,4CAAC,6BAAQ;AAAA,EACjB;AAEA,MAAK,YAAY,WAAW,GAAI;AAC/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