@webiny/website-builder-react 0.0.0-unstable.461c047ab7 → 0.0.0-unstable.48a4e5b6c1

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 (186) hide show
  1. package/README.md +10 -2
  2. package/components/ConnectToEditor.d.ts +3 -1
  3. package/components/ConnectToEditor.js +21 -21
  4. package/components/ConnectToEditor.js.map +1 -1
  5. package/components/ContentClientContext.d.ts +3 -0
  6. package/components/ContentClientContext.js +6 -0
  7. package/components/ContentClientContext.js.map +1 -0
  8. package/components/ContentClientProvider.d.ts +12 -0
  9. package/components/ContentClientProvider.js +9 -0
  10. package/components/ContentClientProvider.js.map +1 -0
  11. package/components/ContentClientProvider.test.d.ts +1 -0
  12. package/components/ContentClientProvider.test.js +143 -0
  13. package/components/ContentClientProvider.test.js.map +1 -0
  14. package/components/DocumentFragment.d.ts +10 -3
  15. package/components/DocumentFragment.js +5 -6
  16. package/components/DocumentFragment.js.map +1 -1
  17. package/components/DocumentRenderer.d.ts +8 -3
  18. package/components/DocumentRenderer.js +55 -43
  19. package/components/DocumentRenderer.js.map +1 -1
  20. package/components/DocumentStoreProvider.d.ts +8 -1
  21. package/components/DocumentStoreProvider.js +35 -22
  22. package/components/DocumentStoreProvider.js.map +1 -1
  23. package/components/DocumentStoreProvider.test.d.ts +1 -0
  24. package/components/DocumentStoreProvider.test.js +66 -0
  25. package/components/DocumentStoreProvider.test.js.map +1 -0
  26. package/components/EditingElementRenderer/EditingElementRenderer.d.ts +7 -2
  27. package/components/EditingElementRenderer/EditingElementRenderer.js +48 -40
  28. package/components/EditingElementRenderer/EditingElementRenderer.js.map +1 -1
  29. package/components/EditingElementRenderer/EditingElementRenderer.presenter.d.ts +2 -2
  30. package/components/EditingElementRenderer/EditingElementRenderer.presenter.js +31 -36
  31. package/components/EditingElementRenderer/EditingElementRenderer.presenter.js.map +1 -1
  32. package/components/EditingElementRenderer/index.js +0 -2
  33. package/components/ElementIndexProvider.js +9 -14
  34. package/components/ElementIndexProvider.js.map +1 -1
  35. package/components/ElementRenderer.d.ts +2 -2
  36. package/components/ElementRenderer.js +25 -17
  37. package/components/ElementRenderer.js.map +1 -1
  38. package/components/ElementSlot.js +11 -11
  39. package/components/ElementSlot.js.map +1 -1
  40. package/components/ElementSlotDepthProvider.js +9 -14
  41. package/components/ElementSlotDepthProvider.js.map +1 -1
  42. package/components/FragmentsProvider.d.ts +10 -1
  43. package/components/FragmentsProvider.js +33 -25
  44. package/components/FragmentsProvider.js.map +1 -1
  45. package/components/GlobalComponent.d.ts +10 -0
  46. package/components/GlobalComponent.js +17 -0
  47. package/components/GlobalComponent.js.map +1 -0
  48. package/components/GlobalPlacement.d.ts +11 -0
  49. package/components/GlobalPlacement.js +27 -0
  50. package/components/GlobalPlacement.js.map +1 -0
  51. package/components/LayoutAreas.d.ts +19 -0
  52. package/components/LayoutAreas.js +15 -0
  53. package/components/LayoutAreas.js.map +1 -0
  54. package/components/LayoutRenderer.d.ts +14 -0
  55. package/components/LayoutRenderer.js +60 -0
  56. package/components/LayoutRenderer.js.map +1 -0
  57. package/components/LayoutRenderer.test.d.ts +1 -0
  58. package/components/LayoutRenderer.test.js +138 -0
  59. package/components/LayoutRenderer.test.js.map +1 -0
  60. package/components/LiveElementRenderer.d.ts +2 -2
  61. package/components/LiveElementRenderer.js +64 -73
  62. package/components/LiveElementRenderer.js.map +1 -1
  63. package/components/LiveElementSlot.d.ts +1 -1
  64. package/components/LiveElementSlot.js +15 -17
  65. package/components/LiveElementSlot.js.map +1 -1
  66. package/components/PageLayout.d.ts +40 -0
  67. package/components/PageLayout.js +71 -0
  68. package/components/PageLayout.js.map +1 -0
  69. package/components/PreviewElementSlot.js +29 -25
  70. package/components/PreviewElementSlot.js.map +1 -1
  71. package/components/SlotLabel.d.ts +15 -0
  72. package/components/SlotLabel.js +13 -0
  73. package/components/SlotLabel.js.map +1 -0
  74. package/components/index.d.ts +7 -0
  75. package/components/index.js +6 -2
  76. package/components/renderWithLayout.d.ts +5 -0
  77. package/components/renderWithLayout.js +7 -0
  78. package/components/renderWithLayout.js.map +1 -0
  79. package/components/useBindingsForElement.d.ts +246 -112
  80. package/components/useBindingsForElement.js +16 -14
  81. package/components/useBindingsForElement.js.map +1 -1
  82. package/components/useContentClient.d.ts +6 -0
  83. package/components/useContentClient.js +11 -0
  84. package/components/useContentClient.js.map +1 -0
  85. package/components/useDocumentState.d.ts +1 -1
  86. package/components/useDocumentState.js +7 -5
  87. package/components/useDocumentState.js.map +1 -1
  88. package/components/useIsElementSelected.d.ts +8 -0
  89. package/components/useIsElementSelected.js +22 -0
  90. package/components/useIsElementSelected.js.map +1 -0
  91. package/components/useSeededDocumentStore.d.ts +10 -0
  92. package/components/useSeededDocumentStore.js +22 -0
  93. package/components/useSeededDocumentStore.js.map +1 -0
  94. package/components/useSelectFromState.d.ts +2 -2
  95. package/components/useSelectFromState.js +29 -35
  96. package/components/useSelectFromState.js.map +1 -1
  97. package/components/useSelectFromState.test.d.ts +1 -0
  98. package/components/useSelectFromState.test.js +67 -0
  99. package/components/useSelectFromState.test.js.map +1 -0
  100. package/components/useViewportInfo.js +5 -6
  101. package/components/useViewportInfo.js.map +1 -1
  102. package/contentEntry/useContentEntryList.d.ts +22 -0
  103. package/contentEntry/useContentEntryList.js +51 -0
  104. package/contentEntry/useContentEntryList.js.map +1 -0
  105. package/createComponent.d.ts +1 -2
  106. package/createComponent.js +1 -16
  107. package/createComponent.test.d.ts +1 -0
  108. package/createComponent.test.js +118 -0
  109. package/createComponent.test.js.map +1 -0
  110. package/editorComponents/Box.d.ts +1 -1
  111. package/editorComponents/Box.js +3 -6
  112. package/editorComponents/Box.js.map +1 -1
  113. package/editorComponents/Box.manifest.d.ts +1 -1
  114. package/editorComponents/Box.manifest.js +17 -16
  115. package/editorComponents/Box.manifest.js.map +1 -1
  116. package/editorComponents/Fragment.d.ts +2 -2
  117. package/editorComponents/Fragment.js +24 -27
  118. package/editorComponents/Fragment.js.map +1 -1
  119. package/editorComponents/Fragment.manifest.js +16 -13
  120. package/editorComponents/Fragment.manifest.js.map +1 -1
  121. package/editorComponents/Grid.d.ts +3 -2
  122. package/editorComponents/Grid.js +34 -61
  123. package/editorComponents/Grid.js.map +1 -1
  124. package/editorComponents/Grid.manifest.d.ts +0 -1
  125. package/editorComponents/Grid.manifest.js +165 -168
  126. package/editorComponents/Grid.manifest.js.map +1 -1
  127. package/editorComponents/GridColumn.d.ts +1 -1
  128. package/editorComponents/GridColumn.js +3 -6
  129. package/editorComponents/GridColumn.js.map +1 -1
  130. package/editorComponents/GridColumn.manifest.js +22 -19
  131. package/editorComponents/GridColumn.manifest.js.map +1 -1
  132. package/editorComponents/Image.d.ts +2 -2
  133. package/editorComponents/Image.js +99 -119
  134. package/editorComponents/Image.js.map +1 -1
  135. package/editorComponents/Image.manifest.js +35 -33
  136. package/editorComponents/Image.manifest.js.map +1 -1
  137. package/editorComponents/LayoutContent.d.ts +6 -0
  138. package/editorComponents/LayoutContent.js +121 -0
  139. package/editorComponents/LayoutContent.js.map +1 -0
  140. package/editorComponents/LayoutContent.manifest.d.ts +10 -0
  141. package/editorComponents/LayoutContent.manifest.js +32 -0
  142. package/editorComponents/LayoutContent.manifest.js.map +1 -0
  143. package/editorComponents/LayoutContentLabel.d.ts +2 -0
  144. package/editorComponents/LayoutContentLabel.js +7 -0
  145. package/editorComponents/LayoutContentLabel.js.map +1 -0
  146. package/editorComponents/LayoutContentLabel.test.d.ts +1 -0
  147. package/editorComponents/LayoutContentLabel.test.js +23 -0
  148. package/editorComponents/LayoutContentLabel.test.js.map +1 -0
  149. package/editorComponents/Lexical.d.ts +3 -3
  150. package/editorComponents/Lexical.js +13 -25
  151. package/editorComponents/Lexical.js.map +1 -1
  152. package/editorComponents/Lexical.manifest.js +19 -16
  153. package/editorComponents/Lexical.manifest.js.map +1 -1
  154. package/editorComponents/Root.d.ts +1 -1
  155. package/editorComponents/Root.js +3 -6
  156. package/editorComponents/Root.js.map +1 -1
  157. package/editorComponents/Root.manifest.d.ts +1 -1
  158. package/editorComponents/Root.manifest.js +9 -8
  159. package/editorComponents/Root.manifest.js.map +1 -1
  160. package/editorComponents/index.d.ts +1 -1
  161. package/editorComponents/index.js +15 -3
  162. package/editorComponents/index.js.map +1 -1
  163. package/image/BackgroundImage.d.ts +33 -0
  164. package/image/BackgroundImage.js +61 -0
  165. package/image/BackgroundImage.js.map +1 -0
  166. package/image/Image.d.ts +29 -0
  167. package/image/Image.js +43 -0
  168. package/image/Image.js.map +1 -0
  169. package/image/getImageProps.d.ts +42 -0
  170. package/image/getImageProps.js +18 -0
  171. package/image/getImageProps.js.map +1 -0
  172. package/image/getImageProps.test.d.ts +1 -0
  173. package/image/getImageProps.test.js +70 -0
  174. package/image/getImageProps.test.js.map +1 -0
  175. package/image/index.d.ts +3 -0
  176. package/image/index.js +3 -0
  177. package/index.d.ts +4 -3
  178. package/index.js +2 -4
  179. package/package.json +19 -19
  180. package/types.d.ts +40 -2
  181. package/types.js +0 -3
  182. package/components/EditingElementRenderer/index.js.map +0 -1
  183. package/components/index.js.map +0 -1
  184. package/createComponent.js.map +0 -1
  185. package/index.js.map +0 -1
  186. package/types.js.map +0 -1
@@ -1,126 +1,106 @@
1
- import React, { useCallback, useEffect, useState } from "react";
1
+ import react, { useCallback, useEffect, useState } from "react";
2
2
  import { contentSdk } from "@webiny/website-builder-sdk";
3
- const SUPPORTED_IMAGE_RESIZE_WIDTHS = [100, 300, 500, 750, 1000, 1500, 2500];
4
- export const ImageComponent = props => {
5
- const image = useImage(props);
6
- if (!image.src) {
7
- return /*#__PURE__*/React.createElement(ImagePlaceholder, {
8
- style: props.styles
3
+ const SUPPORTED_IMAGE_RESIZE_WIDTHS = [
4
+ 100,
5
+ 300,
6
+ 500,
7
+ 750,
8
+ 1000,
9
+ 1500,
10
+ 2500
11
+ ];
12
+ const ImageComponent = (props)=>{
13
+ const image = useImage(props);
14
+ if (!image.src) return /*#__PURE__*/ react.createElement(ImagePlaceholder, {
15
+ style: props.styles
9
16
  });
10
- }
11
- if (image.tag === "object") {
12
- return /*#__PURE__*/React.createElement("object", {
13
- style: image.styles,
14
- title: image.title,
15
- data: image.src
17
+ if ("object" === image.tag) return /*#__PURE__*/ react.createElement("object", {
18
+ style: image.styles,
19
+ title: image.title,
20
+ data: image.src
16
21
  });
17
- }
18
- return /*#__PURE__*/React.createElement(React.Fragment, null, !image.isLoaded && /*#__PURE__*/React.createElement(ImagePlaceholder, {
19
- style: image.styles
20
- }), /*#__PURE__*/React.createElement("img", {
21
- alt: image.altText,
22
- onLoad: image.onLoad,
23
- title: image.title,
24
- src: image.src,
25
- srcSet: image.srcSet,
26
- style: image.styles
27
- }));
22
+ return /*#__PURE__*/ react.createElement(react.Fragment, null, !image.isLoaded && /*#__PURE__*/ react.createElement(ImagePlaceholder, {
23
+ style: image.styles
24
+ }), /*#__PURE__*/ react.createElement("img", {
25
+ alt: image.altText,
26
+ onLoad: image.onLoad,
27
+ title: image.title,
28
+ src: image.src,
29
+ srcSet: image.srcSet,
30
+ style: image.styles
31
+ }));
28
32
  };
29
- const ImagePlaceholder = ({
30
- style
31
- }) => {
32
- return /*#__PURE__*/React.createElement("div", {
33
- style: {
34
- display: "flex",
35
- height: "200px",
36
- backgroundColor: "#f4f4f4",
37
- justifyContent: "center",
38
- alignItems: "center",
39
- fill: "#ffffff",
40
- ...style
41
- }
42
- }, /*#__PURE__*/React.createElement("svg", {
43
- style: {
44
- width: "70px",
45
- height: "70px",
46
- filter: "drop-shadow(rgba(0, 0, 0, 0.16) 0px 1px 0px)"
47
- },
48
- xmlns: "http://www.w3.org/2000/svg",
49
- height: "24px",
50
- viewBox: "0 -960 960 960",
51
- width: "24px"
52
- }, /*#__PURE__*/React.createElement("path", {
53
- d: "M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"
54
- })));
55
- };
56
- const getSrcSet = (src, srcSetWidths) => {
57
- return srcSetWidths.map(item => `${src}?width=${item} ${item}w`).join(", ");
58
- };
59
- const useImage = ({
60
- inputs,
61
- styles
62
- }) => {
63
- const [isLoaded, setIsLoaded] = useState(contentSdk.isEditing() ? false : true);
64
- const {
65
- title = "",
66
- altText,
67
- image
68
- } = inputs;
69
- const src = image?.src;
70
- const tag = src && src.endsWith(".svg") ? "object" : "img";
71
- useEffect(() => {
72
- if (!src) {
73
- setIsLoaded(false);
74
- }
75
- }, [src]);
76
-
77
- // If a fixed image width in pixels was set, let's filter out unneeded
78
- // image resize widths. For example, if 155px was set as the fixed image
79
- // width, then we want the `srcset` attribute to only contain 100w and 300w.
80
- let srcSetWidths = [];
81
- const width = styles.width?.toString();
82
- if (width && width.endsWith("px")) {
83
- const imageWidthInt = parseInt(width);
84
- for (let i = 0; i < SUPPORTED_IMAGE_RESIZE_WIDTHS.length; i++) {
85
- const supportedResizeWidth = SUPPORTED_IMAGE_RESIZE_WIDTHS[i];
86
- if (imageWidthInt > supportedResizeWidth) {
87
- srcSetWidths.push(supportedResizeWidth);
88
- } else {
89
- srcSetWidths.push(supportedResizeWidth);
90
- break;
91
- }
92
- }
93
- } else {
94
- // If a fixed image width was not provided, we
95
- // rely on all the supported image resize widths.
96
- srcSetWidths = SUPPORTED_IMAGE_RESIZE_WIDTHS;
97
- }
98
- const srcSet = src ? getSrcSet(src, srcSetWidths) : "";
99
- const imageStyles = {
100
- maxWidth: "100%",
101
- opacity: isLoaded ? 1 : 0,
102
- transition: "opacity 0.3s ease",
103
- ...styles
104
- };
105
- const onLoad = useCallback(() => {
106
- if (contentSdk.isEditing()) {
107
- setTimeout(() => {
108
- setIsLoaded(true);
109
- }, 100);
110
- } else {
111
- setIsLoaded(true);
112
- }
113
- }, []);
114
- return {
115
- altText,
116
- isLoaded,
117
- onLoad,
118
- src: inputs.image?.src,
119
- srcSet,
120
- styles: imageStyles,
121
- tag,
122
- title
123
- };
33
+ const ImagePlaceholder = ({ style })=>/*#__PURE__*/ react.createElement("div", {
34
+ style: {
35
+ display: "flex",
36
+ height: "200px",
37
+ backgroundColor: "#f4f4f4",
38
+ justifyContent: "center",
39
+ alignItems: "center",
40
+ fill: "#ffffff",
41
+ ...style
42
+ }
43
+ }, /*#__PURE__*/ react.createElement("svg", {
44
+ style: {
45
+ width: "70px",
46
+ height: "70px",
47
+ filter: "drop-shadow(rgba(0, 0, 0, 0.16) 0px 1px 0px)"
48
+ },
49
+ xmlns: "http://www.w3.org/2000/svg",
50
+ height: "24px",
51
+ viewBox: "0 -960 960 960",
52
+ width: "24px"
53
+ }, /*#__PURE__*/ react.createElement("path", {
54
+ d: "M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"
55
+ })));
56
+ const getSrcSet = (src, srcSetWidths)=>srcSetWidths.map((item)=>`${src}?width=${item} ${item}w`).join(", ");
57
+ const useImage = ({ inputs, styles })=>{
58
+ const [isLoaded, setIsLoaded] = useState(!contentSdk.isEditing());
59
+ const { title = "", altText, image } = inputs;
60
+ const src = image?.src;
61
+ const tag = src && src.endsWith(".svg") ? "object" : "img";
62
+ useEffect(()=>{
63
+ if (!src) setIsLoaded(false);
64
+ }, [
65
+ src
66
+ ]);
67
+ let srcSetWidths = [];
68
+ const width = styles.width?.toString();
69
+ if (width && width.endsWith("px")) {
70
+ const imageWidthInt = parseInt(width);
71
+ for(let i = 0; i < SUPPORTED_IMAGE_RESIZE_WIDTHS.length; i++){
72
+ const supportedResizeWidth = SUPPORTED_IMAGE_RESIZE_WIDTHS[i];
73
+ if (imageWidthInt > supportedResizeWidth) srcSetWidths.push(supportedResizeWidth);
74
+ else {
75
+ srcSetWidths.push(supportedResizeWidth);
76
+ break;
77
+ }
78
+ }
79
+ } else srcSetWidths = SUPPORTED_IMAGE_RESIZE_WIDTHS;
80
+ const srcSet = src ? getSrcSet(src, srcSetWidths) : "";
81
+ const imageStyles = {
82
+ maxWidth: "100%",
83
+ opacity: isLoaded ? 1 : 0,
84
+ transition: "opacity 0.3s ease",
85
+ ...styles
86
+ };
87
+ const onLoad = useCallback(()=>{
88
+ if (contentSdk.isEditing()) setTimeout(()=>{
89
+ setIsLoaded(true);
90
+ }, 100);
91
+ else setIsLoaded(true);
92
+ }, []);
93
+ return {
94
+ altText,
95
+ isLoaded,
96
+ onLoad,
97
+ src: inputs.image?.src,
98
+ srcSet,
99
+ styles: imageStyles,
100
+ tag,
101
+ title
102
+ };
124
103
  };
104
+ export { ImageComponent };
125
105
 
126
106
  //# sourceMappingURL=Image.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useCallback","useEffect","useState","contentSdk","SUPPORTED_IMAGE_RESIZE_WIDTHS","ImageComponent","props","image","useImage","src","createElement","ImagePlaceholder","style","styles","tag","title","data","Fragment","isLoaded","alt","altText","onLoad","srcSet","display","height","backgroundColor","justifyContent","alignItems","fill","width","filter","xmlns","viewBox","d","getSrcSet","srcSetWidths","map","item","join","inputs","setIsLoaded","isEditing","endsWith","toString","imageWidthInt","parseInt","i","length","supportedResizeWidth","push","imageStyles","maxWidth","opacity","transition","setTimeout"],"sources":["Image.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from \"react\";\nimport type { CssProperties } from \"@webiny/website-builder-sdk\";\nimport { contentSdk } from \"@webiny/website-builder-sdk\";\nimport type { ComponentPropsWithChildren } from \"~/types\";\n\nconst SUPPORTED_IMAGE_RESIZE_WIDTHS = [100, 300, 500, 750, 1000, 1500, 2500];\n\ntype ImageProps = ComponentPropsWithChildren<{\n title: string;\n altText: string;\n image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };\n}>;\n\nexport const ImageComponent = (props: ImageProps) => {\n const image = useImage(props);\n\n if (!image.src) {\n return <ImagePlaceholder style={props.styles} />;\n }\n\n if (image.tag === \"object\") {\n return <object style={image.styles} title={image.title} data={image.src} />;\n }\n\n return (\n <>\n {!image.isLoaded && <ImagePlaceholder style={image.styles} />}\n <img\n alt={image.altText}\n onLoad={image.onLoad}\n title={image.title}\n src={image.src}\n srcSet={image.srcSet}\n style={image.styles}\n />\n </>\n );\n};\n\nconst ImagePlaceholder = ({ style }: { style: CssProperties }) => {\n return (\n <div\n style={{\n display: \"flex\",\n height: \"200px\",\n backgroundColor: \"#f4f4f4\",\n justifyContent: \"center\",\n alignItems: \"center\",\n fill: \"#ffffff\",\n ...style\n }}\n >\n <svg\n style={{\n width: \"70px\",\n height: \"70px\",\n filter: \"drop-shadow(rgba(0, 0, 0, 0.16) 0px 1px 0px)\"\n }}\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"24px\"\n viewBox=\"0 -960 960 960\"\n width=\"24px\"\n >\n <path d=\"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z\" />\n </svg>\n </div>\n );\n};\n\nconst getSrcSet = (src: string, srcSetWidths: number[]) => {\n return srcSetWidths.map(item => `${src}?width=${item} ${item}w`).join(\", \");\n};\n\nconst useImage = ({ inputs, styles }: ImageProps) => {\n const [isLoaded, setIsLoaded] = useState(contentSdk.isEditing() ? false : true);\n const { title = \"\", altText, image } = inputs;\n const src = image?.src;\n\n const tag = src && src.endsWith(\".svg\") ? \"object\" : \"img\";\n\n useEffect(() => {\n if (!src) {\n setIsLoaded(false);\n }\n }, [src]);\n\n // If a fixed image width in pixels was set, let's filter out unneeded\n // image resize widths. For example, if 155px was set as the fixed image\n // width, then we want the `srcset` attribute to only contain 100w and 300w.\n let srcSetWidths: number[] = [];\n\n const width = styles.width?.toString();\n\n if (width && width.endsWith(\"px\")) {\n const imageWidthInt = parseInt(width);\n for (let i = 0; i < SUPPORTED_IMAGE_RESIZE_WIDTHS.length; i++) {\n const supportedResizeWidth = SUPPORTED_IMAGE_RESIZE_WIDTHS[i];\n if (imageWidthInt > supportedResizeWidth) {\n srcSetWidths.push(supportedResizeWidth);\n } else {\n srcSetWidths.push(supportedResizeWidth);\n break;\n }\n }\n } else {\n // If a fixed image width was not provided, we\n // rely on all the supported image resize widths.\n srcSetWidths = SUPPORTED_IMAGE_RESIZE_WIDTHS;\n }\n\n const srcSet = src ? getSrcSet(src, srcSetWidths) : \"\";\n\n const imageStyles = {\n maxWidth: \"100%\",\n opacity: isLoaded ? 1 : 0,\n transition: \"opacity 0.3s ease\",\n ...styles\n };\n\n const onLoad = useCallback(() => {\n if (contentSdk.isEditing()) {\n setTimeout(() => {\n setIsLoaded(true);\n }, 100);\n } else {\n setIsLoaded(true);\n }\n }, []);\n\n return {\n altText,\n isLoaded,\n onLoad,\n src: inputs.image?.src,\n srcSet,\n styles: imageStyles,\n tag,\n title\n };\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE/D,SAASC,UAAU,QAAQ,6BAA6B;AAGxD,MAAMC,6BAA6B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;AAc5E,OAAO,MAAMC,cAAc,GAAIC,KAAiB,IAAK;EACjD,MAAMC,KAAK,GAAGC,QAAQ,CAACF,KAAK,CAAC;EAE7B,IAAI,CAACC,KAAK,CAACE,GAAG,EAAE;IACZ,oBAAOV,KAAA,CAAAW,aAAA,CAACC,gBAAgB;MAACC,KAAK,EAAEN,KAAK,CAACO;IAAO,CAAE,CAAC;EACpD;EAEA,IAAIN,KAAK,CAACO,GAAG,KAAK,QAAQ,EAAE;IACxB,oBAAOf,KAAA,CAAAW,aAAA;MAAQE,KAAK,EAAEL,KAAK,CAACM,MAAO;MAACE,KAAK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AC,MAAM;QACHb,YAAY,CAACc,IAAI,CAACD,oBAAoB,CAAC;QACvC;MACJ;IACJ;EACJ,CAAC,MAAM;IACH;IACA;IACAb,YAAY,GAAG/B,6BAA6B;EAChD;EAEA,MAAMkB,MAAM,GAAGb,GAAG,GAAGyB,SAAS,CAACzB,GAAG,EAAE0B,YAAY,CAAC,GAAG,EAAE;EAEtD,MAAMe,WAAW,GAAG;IAChBC,QAAQ,EAAE,MAAM;IAChBC,OAAO,EAAElC,QAAQ,GAAG,CAAC,GAAG,CAAC;IACzBmC,UAAU,EAAE,mBAAmB;IAC/B,GAAGxC;EACP,CAAC;EAED,MAAMQ,MAAM,GAAGrB,WAAW,CAAC,MAAM;IAC7B,IAAIG,UAAU,CAACsC,SAAS,CAAC,CAAC,EAAE;MACxBa,UAAU,CAAC,MAAM;QACbd,WAAW,CAAC,IAAI,CAAC;MACrB,CAAC,EAAE,GAAG,CAAC;IACX,CAAC,MAAM;MACHA,WAAW,CAAC,IAAI,CAAC;IACrB;EACJ,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACHpB,OAAO;IACPF,QAAQ;IACRG,MAAM;IACNZ,GAAG,EAAE8B,MAAM,CAAChC,KAAK,EAAEE,GAAG;IACtBa,MAAM;IACNT,MAAM,EAAEqC,WAAW;IACnBpC,GAAG;IACHC;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"editorComponents/Image.js","sources":["../../src/editorComponents/Image.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from \"react\";\nimport type { CssProperties } from \"@webiny/website-builder-sdk\";\nimport { contentSdk } from \"@webiny/website-builder-sdk\";\nimport type { ComponentProps } from \"~/types.js\";\n\nconst SUPPORTED_IMAGE_RESIZE_WIDTHS = [100, 300, 500, 750, 1000, 1500, 2500];\n\ntype ImageProps = ComponentProps<{\n title: string;\n altText: string;\n image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };\n}>;\n\nexport const ImageComponent = (props: ImageProps) => {\n const image = useImage(props);\n\n if (!image.src) {\n return <ImagePlaceholder style={props.styles} />;\n }\n\n if (image.tag === \"object\") {\n return <object style={image.styles} title={image.title} data={image.src} />;\n }\n\n return (\n <>\n {!image.isLoaded && <ImagePlaceholder style={image.styles} />}\n <img\n alt={image.altText}\n onLoad={image.onLoad}\n title={image.title}\n src={image.src}\n srcSet={image.srcSet}\n style={image.styles}\n />\n </>\n );\n};\n\nconst ImagePlaceholder = ({ style }: { style: CssProperties }) => {\n return (\n <div\n style={{\n display: \"flex\",\n height: \"200px\",\n backgroundColor: \"#f4f4f4\",\n justifyContent: \"center\",\n alignItems: \"center\",\n fill: \"#ffffff\",\n ...style\n }}\n >\n <svg\n style={{\n width: \"70px\",\n height: \"70px\",\n filter: \"drop-shadow(rgba(0, 0, 0, 0.16) 0px 1px 0px)\"\n }}\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"24px\"\n viewBox=\"0 -960 960 960\"\n width=\"24px\"\n >\n <path d=\"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z\" />\n </svg>\n </div>\n );\n};\n\nconst getSrcSet = (src: string, srcSetWidths: number[]) => {\n return srcSetWidths.map(item => `${src}?width=${item} ${item}w`).join(\", \");\n};\n\nconst useImage = ({ inputs, styles }: ImageProps) => {\n const [isLoaded, setIsLoaded] = useState(contentSdk.isEditing() ? false : true);\n const { title = \"\", altText, image } = inputs;\n const src = image?.src;\n\n const tag = src && src.endsWith(\".svg\") ? \"object\" : \"img\";\n\n useEffect(() => {\n if (!src) {\n setIsLoaded(false);\n }\n }, [src]);\n\n // If a fixed image width in pixels was set, let's filter out unneeded\n // image resize widths. For example, if 155px was set as the fixed image\n // width, then we want the `srcset` attribute to only contain 100w and 300w.\n let srcSetWidths: number[] = [];\n\n const width = styles.width?.toString();\n\n if (width && width.endsWith(\"px\")) {\n const imageWidthInt = parseInt(width);\n for (let i = 0; i < SUPPORTED_IMAGE_RESIZE_WIDTHS.length; i++) {\n const supportedResizeWidth = SUPPORTED_IMAGE_RESIZE_WIDTHS[i];\n if (imageWidthInt > supportedResizeWidth) {\n srcSetWidths.push(supportedResizeWidth);\n } else {\n srcSetWidths.push(supportedResizeWidth);\n break;\n }\n }\n } else {\n // If a fixed image width was not provided, we\n // rely on all the supported image resize widths.\n srcSetWidths = SUPPORTED_IMAGE_RESIZE_WIDTHS;\n }\n\n const srcSet = src ? getSrcSet(src, srcSetWidths) : \"\";\n\n const imageStyles = {\n maxWidth: \"100%\",\n opacity: isLoaded ? 1 : 0,\n transition: \"opacity 0.3s ease\",\n ...styles\n };\n\n const onLoad = useCallback(() => {\n if (contentSdk.isEditing()) {\n setTimeout(() => {\n setIsLoaded(true);\n }, 100);\n } else {\n setIsLoaded(true);\n }\n }, []);\n\n return {\n altText,\n isLoaded,\n onLoad,\n src: inputs.image?.src,\n srcSet,\n styles: imageStyles,\n tag,\n title\n };\n};\n"],"names":["SUPPORTED_IMAGE_RESIZE_WIDTHS","ImageComponent","props","image","useImage","ImagePlaceholder","style","getSrcSet","src","srcSetWidths","item","inputs","styles","isLoaded","setIsLoaded","useState","contentSdk","title","altText","tag","useEffect","width","imageWidthInt","parseInt","i","supportedResizeWidth","srcSet","imageStyles","onLoad","useCallback","setTimeout"],"mappings":";;AAKA,MAAMA,gCAAgC;IAAC;IAAK;IAAK;IAAK;IAAK;IAAM;IAAM;CAAK;AAcrE,MAAMC,iBAAiB,CAACC;IAC3B,MAAMC,QAAQC,SAASF;IAEvB,IAAI,CAACC,MAAM,GAAG,EACV,OAAO,WAAP,GAAO,oBAACE,kBAAAA;QAAiB,OAAOH,MAAM,MAAM;;IAGhD,IAAIC,AAAc,aAAdA,MAAM,GAAG,EACT,OAAO,WAAP,GAAO,oBAAC;QAAO,OAAOA,MAAM,MAAM;QAAE,OAAOA,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,QAAQ,CAAC,OAAO;QAC/B,MAAMC,gBAAgBC,SAASF;QAC/B,IAAK,IAAIG,IAAI,GAAGA,IAAIxB,8BAA8B,MAAM,EAAEwB,IAAK;YAC3D,MAAMC,uBAAuBzB,6BAA6B,CAACwB,EAAE;YAC7D,IAAIF,gBAAgBG,sBAChBhB,aAAa,IAAI,CAACgB;iBACf;gBACHhB,aAAa,IAAI,CAACgB;gBAClB;YACJ;QACJ;IACJ,OAGIhB,eAAeT;IAGnB,MAAM0B,SAASlB,MAAMD,UAAUC,KAAKC,gBAAgB;IAEpD,MAAMkB,cAAc;QAChB,UAAU;QACV,SAASd,WAAW,IAAI;QACxB,YAAY;QACZ,GAAGD,MAAM;IACb;IAEA,MAAMgB,SAASC,YAAY;QACvB,IAAIb,WAAW,SAAS,IACpBc,WAAW;YACPhB,YAAY;QAChB,GAAG;aAEHA,YAAY;IAEpB,GAAG,EAAE;IAEL,OAAO;QACHI;QACAL;QACAe;QACA,KAAKjB,OAAO,KAAK,EAAE;QACnBe;QACA,QAAQC;QACRR;QACAF;IACJ;AACJ"}
@@ -1,40 +1,42 @@
1
1
  "use client";
2
-
3
2
  import { createFileInput, createTextInput } from "@webiny/website-builder-sdk";
4
- import { createComponent } from "../createComponent";
5
- import { ImageComponent } from "./Image";
6
- export const Image = createComponent(ImageComponent, {
7
- name: "Webiny/Image",
8
- label: "Image",
9
- group: "basic",
10
- image: `<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px"><path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"/></svg>`,
11
- autoApplyStyles: false,
12
- inputs: [createFileInput({
13
- name: "image",
3
+ import { createComponent } from "../createComponent.js";
4
+ import { ImageComponent } from "./Image.js";
5
+ const Image = createComponent(ImageComponent, {
6
+ name: "Webiny/Image",
14
7
  label: "Image",
15
- allowedFileTypes: ["image/*"],
16
- onChange: ({
17
- inputs
18
- }) => {
19
- if (inputs.image) {
20
- inputs.title = inputs.image.name;
21
- inputs.altText = inputs.image.name;
22
- }
23
- }
24
- }), createTextInput({
25
- name: "title",
26
- label: "Title",
27
- description: "Title of the image"
28
- }), createTextInput({
29
- name: "altText",
30
- label: "Alternate Text",
31
- description: "Shown when the user has disabled images"
32
- })],
33
- defaults: {
34
- styles: {
35
- width: "100%"
8
+ aiContext: "Displays an image from the file manager with configurable title and alt text.",
9
+ group: "basic",
10
+ image: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4.86 8.86-3 3.87L9 13.14 6 17h12l-3.86-5.14z"/></svg>',
11
+ autoApplyStyles: false,
12
+ inputs: {
13
+ image: createFileInput({
14
+ label: "Image",
15
+ allowedFileTypes: [
16
+ "image/*"
17
+ ],
18
+ onChange: ({ inputs })=>{
19
+ if (inputs.image) {
20
+ inputs.title = inputs.image.name;
21
+ inputs.altText = inputs.image.name;
22
+ }
23
+ }
24
+ }),
25
+ title: createTextInput({
26
+ label: "Title",
27
+ description: "Title of the image"
28
+ }),
29
+ altText: createTextInput({
30
+ label: "Alternate Text",
31
+ description: "Shown when the user has disabled images"
32
+ })
33
+ },
34
+ defaults: {
35
+ styles: {
36
+ width: "100%"
37
+ }
36
38
  }
37
- }
38
39
  });
40
+ export { Image };
39
41
 
40
42
  //# sourceMappingURL=Image.manifest.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFileInput","createTextInput","createComponent","ImageComponent","Image","name","label","group","image","autoApplyStyles","inputs","allowedFileTypes","onChange","title","altText","description","defaults","styles","width"],"sources":["Image.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createFileInput, createTextInput } from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent\";\nimport { ImageComponent } from \"./Image\";\n\nexport const Image = createComponent(ImageComponent, {\n name: \"Webiny/Image\",\n label: \"Image\",\n group: \"basic\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\"><path d=\"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z\"/></svg>`,\n autoApplyStyles: false,\n inputs: [\n createFileInput({\n name: \"image\",\n label: \"Image\",\n allowedFileTypes: [\"image/*\"],\n onChange: ({ inputs }) => {\n if (inputs.image) {\n inputs.title = inputs.image.name;\n inputs.altText = inputs.image.name;\n }\n }\n }),\n createTextInput({\n name: \"title\",\n label: \"Title\",\n description: \"Title of the image\"\n }),\n createTextInput({\n name: \"altText\",\n label: \"Alternate Text\",\n description: \"Shown when the user has disabled images\"\n })\n ],\n defaults: {\n styles: {\n width: \"100%\"\n }\n }\n});\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,eAAe,QAAQ,6BAA6B;AAC9E,SAASC,eAAe;AACxB,SAASC,cAAc;AAEvB,OAAO,MAAMC,KAAK,GAAGF,eAAe,CAACC,cAAc,EAAE;EACjDE,IAAI,EAAE,cAAc;EACpBC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAE,0TAA0T;EACjUC,eAAe,EAAE,KAAK;EACtBC,MAAM,EAAE,CACJV,eAAe,CAAC;IACZK,IAAI,EAAE,OAAO;IACbC,KAAK,EAAE,OAAO;IACdK,gBAAgB,EAAE,CAAC,SAAS,CAAC;IAC7BC,QAAQ,EAAEA,CAAC;MAAEF;IAAO,CAAC,KAAK;MACtB,IAAIA,MAAM,CAACF,KAAK,EAAE;QACdE,MAAM,CAACG,KAAK,GAAGH,MAAM,CAACF,KAAK,CAACH,IAAI;QAChCK,MAAM,CAACI,OAAO,GAAGJ,MAAM,CAACF,KAAK,CAACH,IAAI;MACtC;IACJ;EACJ,CAAC,CAAC,EACFJ,eAAe,CAAC;IACZI,IAAI,EAAE,OAAO;IACbC,KAAK,EAAE,OAAO;IACdS,WAAW,EAAE;EACjB,CAAC,CAAC,EACFd,eAAe,CAAC;IACZI,IAAI,EAAE,SAAS;IACfC,KAAK,EAAE,gBAAgB;IACvBS,WAAW,EAAE;EACjB,CAAC,CAAC,CACL;EACDC,QAAQ,EAAE;IACNC,MAAM,EAAE;MACJC,KAAK,EAAE;IACX;EACJ;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"editorComponents/Image.manifest.js","sources":["../../src/editorComponents/Image.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createFileInput, createTextInput } from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { ImageComponent } from \"./Image.js\";\n\nexport const Image = createComponent(ImageComponent, {\n name: \"Webiny/Image\",\n label: \"Image\",\n aiContext: \"Displays an image from the file manager with configurable title and alt text.\",\n group: \"basic\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4.86 8.86-3 3.87L9 13.14 6 17h12l-3.86-5.14z\"/></svg>`,\n autoApplyStyles: false,\n inputs: {\n image: createFileInput({\n label: \"Image\",\n allowedFileTypes: [\"image/*\"],\n onChange: ({ inputs }) => {\n if (inputs.image) {\n inputs.title = inputs.image.name;\n inputs.altText = inputs.image.name;\n }\n }\n }),\n title: createTextInput({\n label: \"Title\",\n description: \"Title of the image\"\n }),\n altText: createTextInput({\n label: \"Alternate Text\",\n description: \"Shown when the user has disabled images\"\n })\n },\n defaults: {\n styles: {\n width: \"100%\"\n }\n }\n});\n"],"names":["Image","createComponent","ImageComponent","createFileInput","inputs","createTextInput"],"mappings":";;;;AAKO,MAAMA,QAAQC,gBAAgBC,gBAAgB;IACjD,MAAM;IACN,OAAO;IACP,WAAW;IACX,OAAO;IACP,OAAO;IACP,iBAAiB;IACjB,QAAQ;QACJ,OAAOC,gBAAgB;YACnB,OAAO;YACP,kBAAkB;gBAAC;aAAU;YAC7B,UAAU,CAAC,EAAEC,MAAM,EAAE;gBACjB,IAAIA,OAAO,KAAK,EAAE;oBACdA,OAAO,KAAK,GAAGA,OAAO,KAAK,CAAC,IAAI;oBAChCA,OAAO,OAAO,GAAGA,OAAO,KAAK,CAAC,IAAI;gBACtC;YACJ;QACJ;QACA,OAAOC,gBAAgB;YACnB,OAAO;YACP,aAAa;QACjB;QACA,SAASA,gBAAgB;YACrB,OAAO;YACP,aAAa;QACjB;IACJ;IACA,UAAU;QACN,QAAQ;YACJ,OAAO;QACX;IACJ;AACJ"}
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ import type { ComponentProps } from "../types.js";
3
+ export declare const MainContentComponent: ({ element }: ComponentProps) => React.JSX.Element;
4
+ export declare const NamedContentComponent: ({ inputs, element }: ComponentProps<{
5
+ area?: string;
6
+ }>) => React.JSX.Element;
@@ -0,0 +1,121 @@
1
+ import react, { useMemo } from "react";
2
+ import { observer } from "mobx-react-lite";
3
+ import { toJS } from "mobx";
4
+ import { LayoutContentArea, withGlobalElementDefaults } from "@webiny/website-builder-sdk";
5
+ import { ElementRenderer } from "../components/ElementRenderer.js";
6
+ import { ElementSlot } from "../components/ElementSlot.js";
7
+ import { DocumentStoreScope, useDocumentStore } from "../components/DocumentStoreProvider.js";
8
+ import { useSeededDocumentStore } from "../components/useSeededDocumentStore.js";
9
+ import { PageScope, ReadOnlyScope, usePageLayout } from "../components/PageLayout.js";
10
+ import { SlotLabel } from "../components/SlotLabel.js";
11
+ import { LayoutAreasProvider, getLayoutAreaContent, useLayoutAreas } from "../components/LayoutAreas.js";
12
+ import { getContentAreaLabel } from "./LayoutContentLabel.js";
13
+ import { useContentClient } from "../components/useContentClient.js";
14
+ const toPreviewDocument = (page, client)=>{
15
+ const document = {
16
+ id: page.id,
17
+ version: 1,
18
+ state: {},
19
+ extensions: {},
20
+ metadata: {},
21
+ properties: page.properties ?? {
22
+ id: page.id
23
+ },
24
+ elements: page.elements ?? {},
25
+ bindings: page.bindings ?? {}
26
+ };
27
+ const withDefaults = withGlobalElementDefaults(document, client.getComponentManifests());
28
+ return {
29
+ ...document,
30
+ elements: withDefaults.elements,
31
+ bindings: withDefaults.bindings
32
+ };
33
+ };
34
+ const PageArea = observer(({ area })=>{
35
+ const documentStore = useDocumentStore();
36
+ const slot = area.slot();
37
+ if (area.isMain()) return /*#__PURE__*/ react.createElement(SlotLabel, {
38
+ parentId: "root",
39
+ slot: slot,
40
+ label: getContentAreaLabel(area)
41
+ }, /*#__PURE__*/ react.createElement(ElementRenderer, {
42
+ id: "root"
43
+ }));
44
+ const ids = documentStore.getDocument()?.bindings.root?.inputs?.[slot]?.static;
45
+ return /*#__PURE__*/ react.createElement(SlotLabel, {
46
+ parentId: "root",
47
+ slot: slot,
48
+ label: getContentAreaLabel(area)
49
+ }, /*#__PURE__*/ react.createElement(ElementSlot, {
50
+ parentId: "root",
51
+ slot: slot,
52
+ elements: Array.isArray(ids) ? [
53
+ ...ids
54
+ ] : []
55
+ }));
56
+ });
57
+ const PreviewPageScope = ({ document, children })=>{
58
+ const store = useSeededDocumentStore(document);
59
+ return /*#__PURE__*/ react.createElement(DocumentStoreScope, {
60
+ store: store
61
+ }, children);
62
+ };
63
+ const PreviewPageContent = ({ pageJson, area })=>{
64
+ const client = useContentClient();
65
+ const document = useMemo(()=>toPreviewDocument(JSON.parse(pageJson), client), [
66
+ pageJson,
67
+ client
68
+ ]);
69
+ return /*#__PURE__*/ react.createElement(ReadOnlyScope, null, /*#__PURE__*/ react.createElement(PreviewPageScope, {
70
+ key: document.id,
71
+ document: document
72
+ }, /*#__PURE__*/ react.createElement(PageArea, {
73
+ area: area
74
+ })));
75
+ };
76
+ const Placeholder = ({ area })=>/*#__PURE__*/ react.createElement("div", {
77
+ style: {
78
+ display: "flex",
79
+ minHeight: "200px",
80
+ backgroundColor: "#f4f4f4",
81
+ border: "2px dashed #d0d0d0",
82
+ justifyContent: "center",
83
+ alignItems: "center",
84
+ color: "#6b6b6b"
85
+ }
86
+ }, getContentAreaLabel(area));
87
+ const LayoutEditorContent = observer(({ area })=>{
88
+ const documentStore = useDocumentStore();
89
+ const previewPage = documentStore.getDocument()?.previewPage;
90
+ if (previewPage) return /*#__PURE__*/ react.createElement(PreviewPageContent, {
91
+ pageJson: JSON.stringify(toJS(previewPage)),
92
+ area: area
93
+ });
94
+ return /*#__PURE__*/ react.createElement(Placeholder, {
95
+ area: area
96
+ });
97
+ });
98
+ const ContentArea = ({ area })=>{
99
+ const client = useContentClient();
100
+ const pageLayout = usePageLayout();
101
+ const layoutAreas = useLayoutAreas();
102
+ if (layoutAreas) return /*#__PURE__*/ react.createElement(PageScope, null, /*#__PURE__*/ react.createElement(LayoutAreasProvider, {
103
+ value: void 0
104
+ }, getLayoutAreaContent(layoutAreas, area)));
105
+ if (pageLayout) return /*#__PURE__*/ react.createElement(PageScope, null, /*#__PURE__*/ react.createElement(PageArea, {
106
+ area: area
107
+ }));
108
+ if (!client.isEditing()) return null;
109
+ return /*#__PURE__*/ react.createElement(LayoutEditorContent, {
110
+ area: area
111
+ });
112
+ };
113
+ const MainContentComponent = ({ element })=>/*#__PURE__*/ react.createElement(ContentArea, {
114
+ area: LayoutContentArea.fromElement(element)
115
+ });
116
+ const NamedContentComponent = ({ inputs, element })=>/*#__PURE__*/ react.createElement(ContentArea, {
117
+ area: LayoutContentArea.fromElement(element, inputs?.area)
118
+ });
119
+ export { MainContentComponent, NamedContentComponent };
120
+
121
+ //# sourceMappingURL=LayoutContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorComponents/LayoutContent.js","sources":["../../src/editorComponents/LayoutContent.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { toJS } from \"mobx\";\nimport {\n type ContentClient,\n type Document,\n LayoutContentArea,\n type PreviewPage,\n withGlobalElementDefaults\n} from \"@webiny/website-builder-sdk\";\nimport { ElementRenderer } from \"~/components/ElementRenderer.js\";\nimport { ElementSlot } from \"~/components/ElementSlot.js\";\nimport type { ComponentProps } from \"~/types.js\";\nimport { DocumentStoreScope, useDocumentStore } from \"~/components/DocumentStoreProvider.js\";\nimport { useSeededDocumentStore } from \"~/components/useSeededDocumentStore.js\";\nimport { PageScope, ReadOnlyScope, usePageLayout } from \"~/components/PageLayout.js\";\nimport { SlotLabel } from \"~/components/SlotLabel.js\";\nimport {\n getLayoutAreaContent,\n LayoutAreasProvider,\n useLayoutAreas\n} from \"~/components/LayoutAreas.js\";\nimport { getContentAreaLabel } from \"./LayoutContentLabel.js\";\nimport { useContentClient } from \"~/components/useContentClient.js\";\n\nconst toPreviewDocument = (page: PreviewPage, client: ContentClient): Document => {\n const document: Document = {\n id: page.id,\n version: 1,\n state: {},\n extensions: {},\n metadata: {},\n properties: page.properties ?? { id: page.id },\n elements: page.elements ?? {},\n bindings: page.bindings ?? {}\n };\n\n // Globals the page has no stored instance of render from their manifest defaults, as on the live site.\n const withDefaults = withGlobalElementDefaults(document, client.getComponentManifests());\n return { ...document, elements: withDefaults.elements, bindings: withDefaults.bindings };\n};\n\n/**\n * The page's content of one area. The main area is the page root, as on a page without a layout; the\n * others are slots of the page root. In the page editor, each is a place to drop content.\n */\nconst PageArea = observer(({ area }: { area: LayoutContentArea }) => {\n const documentStore = useDocumentStore();\n const slot = area.slot();\n\n // While an area is empty, its drop area in the page editor says which one it is.\n if (area.isMain()) {\n return (\n <SlotLabel parentId={\"root\"} slot={slot} label={getContentAreaLabel(area)}>\n <ElementRenderer id={\"root\"} />\n </SlotLabel>\n );\n }\n\n const ids = documentStore.getDocument()?.bindings.root?.inputs?.[slot]?.static;\n\n return (\n <SlotLabel parentId={\"root\"} slot={slot} label={getContentAreaLabel(area)}>\n <ElementSlot\n parentId={\"root\"}\n slot={slot}\n elements={Array.isArray(ids) ? [...ids] : []}\n />\n </SlotLabel>\n );\n});\n\nconst PreviewPageScope = ({\n document,\n children\n}: {\n document: Document;\n children: React.ReactNode;\n}) => {\n const store = useSeededDocumentStore(document);\n\n return <DocumentStoreScope store={store}>{children}</DocumentStoreScope>;\n};\n\n/**\n * In the layout editor, the page picked to preview the layout with: shown in place of the page content,\n * as on the live site. It can't be selected; it belongs to the page, not to the layout.\n */\nconst PreviewPageContent = ({ pageJson, area }: { pageJson: string; area: LayoutContentArea }) => {\n const client = useContentClient();\n const document = useMemo(\n () => toPreviewDocument(JSON.parse(pageJson), client),\n [pageJson, client]\n );\n\n // Keyed by page: picking another page renders it from scratch. Its elements share ids with the previous\n // page's (\"root\"), so they would otherwise keep what they had read from the previous page.\n return (\n <ReadOnlyScope>\n <PreviewPageScope key={document.id} document={document}>\n <PageArea area={area} />\n </PreviewPageScope>\n </ReadOnlyScope>\n );\n};\n\nconst Placeholder = ({ area }: { area: LayoutContentArea }) => {\n return (\n <div\n style={{\n display: \"flex\",\n minHeight: \"200px\",\n backgroundColor: \"#f4f4f4\",\n border: \"2px dashed #d0d0d0\",\n justifyContent: \"center\",\n alignItems: \"center\",\n color: \"#6b6b6b\"\n }}\n >\n {getContentAreaLabel(area)}\n </div>\n );\n};\n\nconst LayoutEditorContent = observer(({ area }: { area: LayoutContentArea }) => {\n const documentStore = useDocumentStore();\n const previewPage = documentStore.getDocument()?.previewPage;\n\n if (previewPage) {\n return <PreviewPageContent pageJson={JSON.stringify(toJS(previewPage))} area={area} />;\n }\n\n return <Placeholder area={area} />;\n});\n\n/**\n * A page content area: where a page renders its own content of that area inside a layout. In the layout\n * editor, there is no page: it shows a placeholder, or the page picked to preview the layout with.\n */\nconst ContentArea = ({ area }: { area: LayoutContentArea }) => {\n const client = useContentClient();\n const pageLayout = usePageLayout();\n const layoutAreas = useLayoutAreas();\n\n // Content from code rendered in the layout (see <LayoutRenderer>). It's not part of the layout, so\n // nothing of the layout is around it any more.\n if (layoutAreas) {\n return (\n <PageScope>\n <LayoutAreasProvider value={undefined}>\n {getLayoutAreaContent(layoutAreas, area)}\n </LayoutAreasProvider>\n </PageScope>\n );\n }\n\n if (pageLayout) {\n return (\n <PageScope>\n <PageArea area={area} />\n </PageScope>\n );\n }\n\n if (!client.isEditing()) {\n return null;\n }\n\n return <LayoutEditorContent area={area} />;\n};\n\nexport const MainContentComponent = ({ element }: ComponentProps) => {\n return <ContentArea area={LayoutContentArea.fromElement(element)} />;\n};\n\nexport const NamedContentComponent = ({ inputs, element }: ComponentProps<{ area?: string }>) => {\n return <ContentArea area={LayoutContentArea.fromElement(element, inputs?.area)} />;\n};\n"],"names":["toPreviewDocument","page","client","document","withDefaults","withGlobalElementDefaults","PageArea","observer","area","documentStore","useDocumentStore","slot","SlotLabel","getContentAreaLabel","ElementRenderer","ids","ElementSlot","Array","PreviewPageScope","children","store","useSeededDocumentStore","DocumentStoreScope","PreviewPageContent","pageJson","useContentClient","useMemo","JSON","ReadOnlyScope","Placeholder","LayoutEditorContent","previewPage","toJS","ContentArea","pageLayout","usePageLayout","layoutAreas","useLayoutAreas","PageScope","LayoutAreasProvider","undefined","getLayoutAreaContent","MainContentComponent","element","LayoutContentArea","NamedContentComponent","inputs"],"mappings":";;;;;;;;;;;;;AAyBA,MAAMA,oBAAoB,CAACC,MAAmBC;IAC1C,MAAMC,WAAqB;QACvB,IAAIF,KAAK,EAAE;QACX,SAAS;QACT,OAAO,CAAC;QACR,YAAY,CAAC;QACb,UAAU,CAAC;QACX,YAAYA,KAAK,UAAU,IAAI;YAAE,IAAIA,KAAK,EAAE;QAAC;QAC7C,UAAUA,KAAK,QAAQ,IAAI,CAAC;QAC5B,UAAUA,KAAK,QAAQ,IAAI,CAAC;IAChC;IAGA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AC/C,WAAP,GACI,oBAAC;QACG,OAAO;YACH,SAAS;YACT,WAAW;YACX,iBAAiB;YACjB,QAAQ;YACR,gBAAgB;YAChB,YAAY;YACZ,OAAO;QACX;OAECK,oBAAoBL;AAKjC,MAAMsB,sBAAsBvB,SAAS,CAAC,EAAEC,IAAI,EAA+B;IACvE,MAAMC,gBAAgBC;IACtB,MAAMqB,cAActB,cAAc,WAAW,IAAI;IAEjD,IAAIsB,aACA,OAAO,WAAP,GAAO,oBAACR,oBAAAA;QAAmB,UAAUI,KAAK,SAAS,CAACK,KAAKD;QAAe,MAAMvB;;IAGlF,OAAO,WAAP,GAAO,oBAACqB,aAAAA;QAAY,MAAMrB;;AAC9B;AAMA,MAAMyB,cAAc,CAAC,EAAEzB,IAAI,EAA+B;IACtD,MAAMN,SAASuB;IACf,MAAMS,aAAaC;IACnB,MAAMC,cAAcC;IAIpB,IAAID,aACA,OAAO,WAAP,GACI,oBAACE,WAASA,MAAAA,WAAAA,GACN,oBAACC,qBAAmBA;QAAC,OAAOC;OACvBC,qBAAqBL,aAAa5B;IAMnD,IAAI0B,YACA,OAAO,WAAP,GACI,oBAACI,WAASA,MAAAA,WAAAA,GACN,oBAAChC,UAAAA;QAAS,MAAME;;IAK5B,IAAI,CAACN,OAAO,SAAS,IACjB,OAAO;IAGX,OAAO,WAAP,GAAO,oBAAC4B,qBAAAA;QAAoB,MAAMtB;;AACtC;AAEO,MAAMkC,uBAAuB,CAAC,EAAEC,OAAO,EAAkB,GACrD,WAAP,GAAO,oBAACV,aAAAA;QAAY,MAAMW,kBAAkB,WAAW,CAACD;;AAGrD,MAAME,wBAAwB,CAAC,EAAEC,MAAM,EAAEH,OAAO,EAAqC,GACjF,WAAP,GAAO,oBAACV,aAAAA;QAAY,MAAMW,kBAAkB,WAAW,CAACD,SAASG,QAAQ"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The main page content area of a layout. Every layout starts with it, and keeps it: it can be moved and
3
+ * styled, but not deleted, renamed or inserted again.
4
+ */
5
+ export declare const LayoutContent: import("@webiny/website-builder-sdk").Component;
6
+ /**
7
+ * A named page content area, inserted in the layout editor (only there). Pages fill each named area in
8
+ * the page editor.
9
+ */
10
+ export declare const NamedContent: import("@webiny/website-builder-sdk").Component;
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { LayoutContentArea, createTextInput } from "@webiny/website-builder-sdk";
3
+ import { createComponent } from "../createComponent.js";
4
+ import { MainContentComponent, NamedContentComponent } from "./LayoutContent.js";
5
+ const LayoutContent_manifest_image = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M3 5v14h18V5H3zm16 12H5V7h14v10zM7 9h10v2H7V9zm0 4h7v2H7v-2z"/></svg>';
6
+ const LayoutContent = createComponent(MainContentComponent, {
7
+ name: LayoutContentArea.MAIN_COMPONENT,
8
+ label: "Main content",
9
+ group: "basic",
10
+ hideFromToolbar: true,
11
+ useInAiContentGeneration: false,
12
+ inputs: [],
13
+ image: LayoutContent_manifest_image
14
+ });
15
+ const NamedContent = createComponent(NamedContentComponent, {
16
+ name: LayoutContentArea.NAMED_COMPONENT,
17
+ label: "Named content",
18
+ group: "basic",
19
+ useInAiContentGeneration: false,
20
+ inputs: [
21
+ createTextInput({
22
+ name: LayoutContentArea.NAME_INPUT,
23
+ label: "Area name",
24
+ translatable: false,
25
+ description: "Shown in the page editor so authors can tell the areas apart. Renaming an area keeps the content pages added to it."
26
+ })
27
+ ],
28
+ image: LayoutContent_manifest_image
29
+ });
30
+ export { LayoutContent, NamedContent };
31
+
32
+ //# sourceMappingURL=LayoutContent.manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorComponents/LayoutContent.manifest.js","sources":["../../src/editorComponents/LayoutContent.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createTextInput, LayoutContentArea } from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { MainContentComponent, NamedContentComponent } from \"./LayoutContent.js\";\n\nconst image = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M3 5v14h18V5H3zm16 12H5V7h14v10zM7 9h10v2H7V9zm0 4h7v2H7v-2z\"/></svg>`;\n\n/**\n * The main page content area of a layout. Every layout starts with it, and keeps it: it can be moved and\n * styled, but not deleted, renamed or inserted again.\n */\nexport const LayoutContent = createComponent(MainContentComponent, {\n name: LayoutContentArea.MAIN_COMPONENT,\n label: \"Main content\",\n group: \"basic\",\n hideFromToolbar: true,\n useInAiContentGeneration: false,\n inputs: [],\n image\n});\n\n/**\n * A named page content area, inserted in the layout editor (only there). Pages fill each named area in\n * the page editor.\n */\nexport const NamedContent = createComponent(NamedContentComponent, {\n name: LayoutContentArea.NAMED_COMPONENT,\n label: \"Named content\",\n group: \"basic\",\n useInAiContentGeneration: false,\n inputs: [\n createTextInput({\n name: LayoutContentArea.NAME_INPUT,\n label: \"Area name\",\n // A label for people: pages' content of the area is stored by the area element's id.\n translatable: false,\n description:\n \"Shown in the page editor so authors can tell the areas apart. Renaming an area keeps the content pages added to it.\"\n })\n ],\n image\n});\n"],"names":["image","LayoutContent","createComponent","MainContentComponent","LayoutContentArea","NamedContent","NamedContentComponent","createTextInput"],"mappings":";;;;AAKA,MAAMA,+BAAQ;AAMP,MAAMC,gBAAgBC,gBAAgBC,sBAAsB;IAC/D,MAAMC,kBAAkB,cAAc;IACtC,OAAO;IACP,OAAO;IACP,iBAAiB;IACjB,0BAA0B;IAC1B,QAAQ,EAAE;IACVJ,OAAKA;AACT;AAMO,MAAMK,eAAeH,gBAAgBI,uBAAuB;IAC/D,MAAMF,kBAAkB,eAAe;IACvC,OAAO;IACP,OAAO;IACP,0BAA0B;IAC1B,QAAQ;QACJG,gBAAgB;YACZ,MAAMH,kBAAkB,UAAU;YAClC,OAAO;YAEP,cAAc;YACd,aACI;QACR;KACH;IACDJ,OAAKA;AACT"}
@@ -0,0 +1,2 @@
1
+ import type { LayoutContentArea } from "@webiny/website-builder-sdk";
2
+ export declare const getContentAreaLabel: (area: LayoutContentArea) => string;
@@ -0,0 +1,7 @@
1
+ const getContentAreaLabel = (area)=>{
2
+ if (area.isMain()) return "Main content";
3
+ return area.name() ?? "Named content";
4
+ };
5
+ export { getContentAreaLabel };
6
+
7
+ //# sourceMappingURL=LayoutContentLabel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorComponents/LayoutContentLabel.js","sources":["../../src/editorComponents/LayoutContentLabel.ts"],"sourcesContent":["import type { LayoutContentArea } from \"@webiny/website-builder-sdk\";\n\n// What a content area is called on the canvas. Its name is only a label: content is stored by its slot.\nexport const getContentAreaLabel = (area: LayoutContentArea) => {\n if (area.isMain()) {\n return \"Main content\";\n }\n return area.name() ?? \"Named content\";\n};\n"],"names":["getContentAreaLabel","area"],"mappings":"AAGO,MAAMA,sBAAsB,CAACC;IAChC,IAAIA,KAAK,MAAM,IACX,OAAO;IAEX,OAAOA,KAAK,IAAI,MAAM;AAC1B"}
@@ -0,0 +1 @@
1
+ export {};