@webiny/website-builder-react 0.0.0-unstable.0156a4c312

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/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/components/ConnectToEditor.d.ts +10 -0
  4. package/components/ConnectToEditor.js +25 -0
  5. package/components/ConnectToEditor.js.map +1 -0
  6. package/components/ContentClientContext.d.ts +3 -0
  7. package/components/ContentClientContext.js +6 -0
  8. package/components/ContentClientContext.js.map +1 -0
  9. package/components/ContentClientProvider.d.ts +12 -0
  10. package/components/ContentClientProvider.js +9 -0
  11. package/components/ContentClientProvider.js.map +1 -0
  12. package/components/ContentClientProvider.test.d.ts +1 -0
  13. package/components/ContentClientProvider.test.js +143 -0
  14. package/components/ContentClientProvider.test.js.map +1 -0
  15. package/components/DocumentFragment.d.ts +13 -0
  16. package/components/DocumentFragment.js +9 -0
  17. package/components/DocumentFragment.js.map +1 -0
  18. package/components/DocumentRenderer.d.ts +14 -0
  19. package/components/DocumentRenderer.js +59 -0
  20. package/components/DocumentRenderer.js.map +1 -0
  21. package/components/DocumentStoreProvider.d.ts +16 -0
  22. package/components/DocumentStoreProvider.js +27 -0
  23. package/components/DocumentStoreProvider.js.map +1 -0
  24. package/components/EditingElementRenderer/EditingElementRenderer.d.ts +14 -0
  25. package/components/EditingElementRenderer/EditingElementRenderer.js +55 -0
  26. package/components/EditingElementRenderer/EditingElementRenderer.js.map +1 -0
  27. package/components/EditingElementRenderer/EditingElementRenderer.presenter.d.ts +15 -0
  28. package/components/EditingElementRenderer/EditingElementRenderer.presenter.js +38 -0
  29. package/components/EditingElementRenderer/EditingElementRenderer.presenter.js.map +1 -0
  30. package/components/EditingElementRenderer/index.d.ts +1 -0
  31. package/components/EditingElementRenderer/index.js +1 -0
  32. package/components/ElementIndexProvider.d.ts +8 -0
  33. package/components/ElementIndexProvider.js +13 -0
  34. package/components/ElementIndexProvider.js.map +1 -0
  35. package/components/ElementRenderer.d.ts +8 -0
  36. package/components/ElementRenderer.js +35 -0
  37. package/components/ElementRenderer.js.map +1 -0
  38. package/components/ElementSlot.d.ts +7 -0
  39. package/components/ElementSlot.js +16 -0
  40. package/components/ElementSlot.js.map +1 -0
  41. package/components/ElementSlotDepthProvider.d.ts +8 -0
  42. package/components/ElementSlotDepthProvider.js +13 -0
  43. package/components/ElementSlotDepthProvider.js.map +1 -0
  44. package/components/FragmentsProvider.d.ts +18 -0
  45. package/components/FragmentsProvider.js +38 -0
  46. package/components/FragmentsProvider.js.map +1 -0
  47. package/components/GlobalComponent.d.ts +10 -0
  48. package/components/GlobalComponent.js +17 -0
  49. package/components/GlobalComponent.js.map +1 -0
  50. package/components/GlobalPlacement.d.ts +11 -0
  51. package/components/GlobalPlacement.js +27 -0
  52. package/components/GlobalPlacement.js.map +1 -0
  53. package/components/LayoutAreas.d.ts +19 -0
  54. package/components/LayoutAreas.js +15 -0
  55. package/components/LayoutAreas.js.map +1 -0
  56. package/components/LayoutRenderer.d.ts +14 -0
  57. package/components/LayoutRenderer.js +60 -0
  58. package/components/LayoutRenderer.js.map +1 -0
  59. package/components/LayoutRenderer.test.d.ts +1 -0
  60. package/components/LayoutRenderer.test.js +138 -0
  61. package/components/LayoutRenderer.test.js.map +1 -0
  62. package/components/LiveElementRenderer.d.ts +10 -0
  63. package/components/LiveElementRenderer.js +68 -0
  64. package/components/LiveElementRenderer.js.map +1 -0
  65. package/components/LiveElementSlot.d.ts +3 -0
  66. package/components/LiveElementSlot.js +19 -0
  67. package/components/LiveElementSlot.js.map +1 -0
  68. package/components/PageLayout.d.ts +40 -0
  69. package/components/PageLayout.js +71 -0
  70. package/components/PageLayout.js.map +1 -0
  71. package/components/PreviewElementSlot.d.ts +8 -0
  72. package/components/PreviewElementSlot.js +34 -0
  73. package/components/PreviewElementSlot.js.map +1 -0
  74. package/components/SlotLabel.d.ts +15 -0
  75. package/components/SlotLabel.js +13 -0
  76. package/components/SlotLabel.js.map +1 -0
  77. package/components/index.d.ts +11 -0
  78. package/components/index.js +10 -0
  79. package/components/renderWithLayout.d.ts +5 -0
  80. package/components/renderWithLayout.js +7 -0
  81. package/components/renderWithLayout.js.map +1 -0
  82. package/components/useBindingsForElement.d.ts +815 -0
  83. package/components/useBindingsForElement.js +21 -0
  84. package/components/useBindingsForElement.js.map +1 -0
  85. package/components/useContentClient.d.ts +6 -0
  86. package/components/useContentClient.js +11 -0
  87. package/components/useContentClient.js.map +1 -0
  88. package/components/useDocumentState.d.ts +1 -0
  89. package/components/useDocumentState.js +9 -0
  90. package/components/useDocumentState.js.map +1 -0
  91. package/components/useIsElementSelected.d.ts +8 -0
  92. package/components/useIsElementSelected.js +22 -0
  93. package/components/useIsElementSelected.js.map +1 -0
  94. package/components/useSeededDocumentStore.d.ts +10 -0
  95. package/components/useSeededDocumentStore.js +22 -0
  96. package/components/useSeededDocumentStore.js.map +1 -0
  97. package/components/useSelectFromState.d.ts +8 -0
  98. package/components/useSelectFromState.js +33 -0
  99. package/components/useSelectFromState.js.map +1 -0
  100. package/components/useViewportInfo.d.ts +1 -0
  101. package/components/useViewportInfo.js +10 -0
  102. package/components/useViewportInfo.js.map +1 -0
  103. package/contentEntry/useContentEntryList.d.ts +22 -0
  104. package/contentEntry/useContentEntryList.js +51 -0
  105. package/contentEntry/useContentEntryList.js.map +1 -0
  106. package/createComponent.d.ts +1 -0
  107. package/createComponent.js +1 -0
  108. package/createComponent.test.d.ts +1 -0
  109. package/createComponent.test.js +118 -0
  110. package/createComponent.test.js.map +1 -0
  111. package/editorComponents/Box.d.ts +3 -0
  112. package/editorComponents/Box.js +5 -0
  113. package/editorComponents/Box.js.map +1 -0
  114. package/editorComponents/Box.manifest.d.ts +1 -0
  115. package/editorComponents/Box.manifest.js +22 -0
  116. package/editorComponents/Box.manifest.js.map +1 -0
  117. package/editorComponents/Fragment.d.ts +7 -0
  118. package/editorComponents/Fragment.js +30 -0
  119. package/editorComponents/Fragment.js.map +1 -0
  120. package/editorComponents/Fragment.manifest.d.ts +1 -0
  121. package/editorComponents/Fragment.manifest.js +22 -0
  122. package/editorComponents/Fragment.manifest.js.map +1 -0
  123. package/editorComponents/Grid.d.ts +19 -0
  124. package/editorComponents/Grid.js +37 -0
  125. package/editorComponents/Grid.js.map +1 -0
  126. package/editorComponents/Grid.manifest.d.ts +4 -0
  127. package/editorComponents/Grid.manifest.js +171 -0
  128. package/editorComponents/Grid.manifest.js.map +1 -0
  129. package/editorComponents/GridColumn.d.ts +5 -0
  130. package/editorComponents/GridColumn.js +5 -0
  131. package/editorComponents/GridColumn.js.map +1 -0
  132. package/editorComponents/GridColumn.manifest.d.ts +1 -0
  133. package/editorComponents/GridColumn.manifest.js +28 -0
  134. package/editorComponents/GridColumn.manifest.js.map +1 -0
  135. package/editorComponents/Image.d.ts +15 -0
  136. package/editorComponents/Image.js +106 -0
  137. package/editorComponents/Image.js.map +1 -0
  138. package/editorComponents/Image.manifest.d.ts +1 -0
  139. package/editorComponents/Image.manifest.js +42 -0
  140. package/editorComponents/Image.manifest.js.map +1 -0
  141. package/editorComponents/LayoutContent.d.ts +6 -0
  142. package/editorComponents/LayoutContent.js +121 -0
  143. package/editorComponents/LayoutContent.js.map +1 -0
  144. package/editorComponents/LayoutContent.manifest.d.ts +10 -0
  145. package/editorComponents/LayoutContent.manifest.js +32 -0
  146. package/editorComponents/LayoutContent.manifest.js.map +1 -0
  147. package/editorComponents/LayoutContentLabel.d.ts +2 -0
  148. package/editorComponents/LayoutContentLabel.js +7 -0
  149. package/editorComponents/LayoutContentLabel.js.map +1 -0
  150. package/editorComponents/LayoutContentLabel.test.d.ts +1 -0
  151. package/editorComponents/LayoutContentLabel.test.js +23 -0
  152. package/editorComponents/LayoutContentLabel.test.js.map +1 -0
  153. package/editorComponents/Lexical.d.ts +13 -0
  154. package/editorComponents/Lexical.js +18 -0
  155. package/editorComponents/Lexical.js.map +1 -0
  156. package/editorComponents/Lexical.manifest.d.ts +1 -0
  157. package/editorComponents/Lexical.manifest.js +25 -0
  158. package/editorComponents/Lexical.manifest.js.map +1 -0
  159. package/editorComponents/Root.d.ts +3 -0
  160. package/editorComponents/Root.js +5 -0
  161. package/editorComponents/Root.js.map +1 -0
  162. package/editorComponents/Root.manifest.d.ts +1 -0
  163. package/editorComponents/Root.manifest.js +13 -0
  164. package/editorComponents/Root.manifest.js.map +1 -0
  165. package/editorComponents/index.d.ts +1 -0
  166. package/editorComponents/index.js +22 -0
  167. package/editorComponents/index.js.map +1 -0
  168. package/image/BackgroundImage.d.ts +33 -0
  169. package/image/BackgroundImage.js +61 -0
  170. package/image/BackgroundImage.js.map +1 -0
  171. package/image/Image.d.ts +29 -0
  172. package/image/Image.js +43 -0
  173. package/image/Image.js.map +1 -0
  174. package/image/getImageProps.d.ts +42 -0
  175. package/image/getImageProps.js +18 -0
  176. package/image/getImageProps.js.map +1 -0
  177. package/image/getImageProps.test.d.ts +1 -0
  178. package/image/getImageProps.test.js +70 -0
  179. package/image/getImageProps.test.js.map +1 -0
  180. package/image/index.d.ts +3 -0
  181. package/image/index.js +3 -0
  182. package/index.d.ts +5 -0
  183. package/index.js +3 -0
  184. package/package.json +40 -0
  185. package/types.d.ts +47 -0
  186. package/types.js +0 -0
@@ -0,0 +1,37 @@
1
+ import react from "react";
2
+ const GridColumnComponent = ({ inputs })=>/*#__PURE__*/ react.createElement(react.Fragment, null, inputs.children);
3
+ const GridComponent = ({ inputs, styles, breakpoint })=>{
4
+ const { gridLayout = "12", columns, columnGap, stackAtBreakpoint, reverseWhenStacked } = inputs;
5
+ const rowConfig = gridLayout.split("-").map((size)=>parseInt(size));
6
+ const rows = [];
7
+ for(let i = 0; i < columns.length; i += rowConfig.length)rows.push(columns.slice(i, i + rowConfig.length));
8
+ const cellWidthReduction = columnGap ? columnGap - columnGap / rowConfig.length : 0;
9
+ const stackColumns = breakpoint === stackAtBreakpoint;
10
+ if (stackColumns) styles.flexDirection = reverseWhenStacked ? "column-reverse" : "column";
11
+ return /*#__PURE__*/ react.createElement("div", {
12
+ style: styles
13
+ }, rows.map((columns)=>columns.map((column, i)=>/*#__PURE__*/ react.createElement(Span, {
14
+ key: i,
15
+ stackColumns: stackColumns,
16
+ size: rowConfig[i],
17
+ reductionInPx: cellWidthReduction
18
+ }, /*#__PURE__*/ react.createElement(GridColumnComponent, {
19
+ key: i,
20
+ inputs: {
21
+ children: column.children
22
+ }
23
+ })))));
24
+ };
25
+ const Span = ({ size, children, reductionInPx, stackColumns })=>{
26
+ const width = stackColumns ? "100%" : `calc(${size / 12 * 100}% - ${reductionInPx}px)`;
27
+ return /*#__PURE__*/ react.createElement("div", {
28
+ style: {
29
+ flex: `0 0 ${width}`,
30
+ maxWidth: width,
31
+ boxSizing: "border-box"
32
+ }
33
+ }, children);
34
+ };
35
+ export { GridColumnComponent, GridComponent };
36
+
37
+ //# sourceMappingURL=Grid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorComponents/Grid.js","sources":["../../src/editorComponents/Grid.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ComponentProps, ComponentPropsWithChildren } from \"~/types.js\";\n\nexport const GridColumnComponent = ({\n inputs\n}: {\n inputs: ComponentPropsWithChildren[\"inputs\"];\n}) => {\n return <>{inputs.children}</>;\n};\n\nexport interface Column {\n children: React.ReactNode;\n}\n\ntype GridProps = ComponentProps<{\n gridLayout: string;\n rowCount: number;\n rowGap: number;\n columnGap: number;\n columns: Column[];\n stackAtBreakpoint?: string;\n reverseWhenStacked?: boolean;\n}>;\n\nexport const GridComponent = ({ inputs, styles, breakpoint }: GridProps) => {\n const { gridLayout = \"12\", columns, columnGap, stackAtBreakpoint, reverseWhenStacked } = inputs;\n const rowConfig = gridLayout.split(\"-\").map(size => parseInt(size));\n const rows: Column[][] = [];\n\n // Chunk columns into rows\n for (let i = 0; i < columns.length; i += rowConfig.length) {\n rows.push(columns.slice(i, i + rowConfig.length));\n }\n\n // Number of pixels we need to subtract from each cell to ensure they fit in the grid with column gap\n const cellWidthReduction = columnGap ? columnGap - columnGap / rowConfig.length : 0;\n\n const stackColumns = breakpoint === stackAtBreakpoint;\n\n if (stackColumns) {\n styles.flexDirection = reverseWhenStacked ? \"column-reverse\" : \"column\";\n }\n\n return (\n <div style={styles}>\n {rows.map(columns => {\n return columns.map((column, i) => (\n <Span\n key={i}\n stackColumns={stackColumns}\n size={rowConfig[i]}\n reductionInPx={cellWidthReduction}\n >\n <GridColumnComponent key={i} inputs={{ children: column.children }} />\n </Span>\n ));\n })}\n </div>\n );\n};\n\ninterface SpanProps {\n size: number;\n reductionInPx: number;\n stackColumns: boolean;\n children: React.ReactNode;\n}\n\nconst Span = ({ size, children, reductionInPx, stackColumns }: SpanProps) => {\n const width = stackColumns ? \"100%\" : `calc(${(size / 12) * 100}% - ${reductionInPx}px)`;\n\n return (\n <div\n style={{\n flex: `0 0 ${width}`,\n maxWidth: width,\n boxSizing: \"border-box\"\n }}\n >\n {children}\n </div>\n );\n};\n"],"names":["GridColumnComponent","inputs","GridComponent","styles","breakpoint","gridLayout","columns","columnGap","stackAtBreakpoint","reverseWhenStacked","rowConfig","size","parseInt","rows","i","cellWidthReduction","stackColumns","column","Span","children","reductionInPx","width"],"mappings":";AAGO,MAAMA,sBAAsB,CAAC,EAChCC,MAAM,EAGT,GACU,WAAP,GAAO,0CAAGA,OAAO,QAAQ;AAiBtB,MAAMC,gBAAgB,CAAC,EAAED,MAAM,EAAEE,MAAM,EAAEC,UAAU,EAAa;IACnE,MAAM,EAAEC,aAAa,IAAI,EAAEC,OAAO,EAAEC,SAAS,EAAEC,iBAAiB,EAAEC,kBAAkB,EAAE,GAAGR;IACzF,MAAMS,YAAYL,WAAW,KAAK,CAAC,KAAK,GAAG,CAACM,CAAAA,OAAQC,SAASD;IAC7D,MAAME,OAAmB,EAAE;IAG3B,IAAK,IAAIC,IAAI,GAAGA,IAAIR,QAAQ,MAAM,EAAEQ,KAAKJ,UAAU,MAAM,CACrDG,KAAK,IAAI,CAACP,QAAQ,KAAK,CAACQ,GAAGA,IAAIJ,UAAU,MAAM;IAInD,MAAMK,qBAAqBR,YAAYA,YAAYA,YAAYG,UAAU,MAAM,GAAG;IAElF,MAAMM,eAAeZ,eAAeI;IAEpC,IAAIQ,cACAb,OAAO,aAAa,GAAGM,qBAAqB,mBAAmB;IAGnE,OAAO,WAAP,GACI,oBAAC;QAAI,OAAON;OACPU,KAAK,GAAG,CAACP,CAAAA,UACCA,QAAQ,GAAG,CAAC,CAACW,QAAQH,IAAAA,WAAAA,GACxB,oBAACI,MAAIA;gBACD,KAAKJ;gBACL,cAAcE;gBACd,MAAMN,SAAS,CAACI,EAAE;gBAClB,eAAeC;6BAEf,oBAACf,qBAAmBA;gBAAC,KAAKc;gBAAG,QAAQ;oBAAE,UAAUG,OAAO,QAAQ;gBAAC;;AAMzF;AASA,MAAMC,OAAO,CAAC,EAAEP,IAAI,EAAEQ,QAAQ,EAAEC,aAAa,EAAEJ,YAAY,EAAa;IACpE,MAAMK,QAAQL,eAAe,SAAS,CAAC,KAAK,EAAGL,OAAO,KAAM,IAAI,IAAI,EAAES,cAAc,GAAG,CAAC;IAExF,OAAO,WAAP,GACI,oBAAC;QACG,OAAO;YACH,MAAM,CAAC,IAAI,EAAEC,OAAO;YACpB,UAAUA;YACV,WAAW;QACf;OAECF;AAGb"}
@@ -0,0 +1,4 @@
1
+ export interface Column {
2
+ children: React.ReactNode;
3
+ }
4
+ export declare const Grid: import("@webiny/website-builder-sdk").Component;
@@ -0,0 +1,171 @@
1
+ "use client";
2
+ import { createBooleanInput, createElement as website_builder_sdk_createElement, createNumberInput, createObjectInput, createSelectInput, createSlotInput, createTextInput } from "@webiny/website-builder-sdk";
3
+ import { createComponent } from "../createComponent.js";
4
+ import { GridComponent } from "./Grid.js";
5
+ const Grid = createComponent(GridComponent, {
6
+ name: "Webiny/Grid",
7
+ label: "Grid",
8
+ aiContext: "Multi-column layout container. Set gridLayout to a dash-separated pattern (e.g. '6-6' for two equal columns, '8-4' for wide-narrow, '4-4-4' for three equal). Each segment becomes a GridColumn. Columns stack vertically on smaller screens when stackAtBreakpoint is set.",
9
+ image: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 20H4v-4h4v4zm0-6H4v-4h4v4zm0-6H4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4z"/></svg>',
10
+ group: "basic",
11
+ autoApplyStyles: false,
12
+ inputs: [
13
+ createTextInput({
14
+ name: "gridLayout",
15
+ label: "Grid Layout",
16
+ renderer: "Webiny/GridLayout",
17
+ onChange: ({ inputs, createElement })=>{
18
+ const rowColumnCount = inputs.gridLayout.split("-").length;
19
+ const columns = inputs.columns.length;
20
+ const remainder = columns % rowColumnCount;
21
+ if (0 !== remainder) {
22
+ const fullColumnCount = rowColumnCount * inputs.rowCount;
23
+ const toCreate = columns > fullColumnCount ? remainder : rowColumnCount - remainder;
24
+ Array.from({
25
+ length: toCreate
26
+ }).forEach(()=>{
27
+ inputs.columns.push({
28
+ children: createElement({
29
+ component: "Webiny/GridColumn"
30
+ })
31
+ });
32
+ });
33
+ }
34
+ inputs.rowCount = inputs.columns.length / rowColumnCount;
35
+ }
36
+ }),
37
+ createNumberInput({
38
+ name: "rowCount",
39
+ label: "Row Count",
40
+ defaultValue: 1,
41
+ minValue: 1,
42
+ onChange: ({ inputs, createElement })=>{
43
+ const gridLayout = inputs.gridLayout;
44
+ const columnCount = gridLayout.split("-").length;
45
+ const rowCount = Math.max(1, inputs.rowCount);
46
+ const columns = inputs.columns;
47
+ const rows = [];
48
+ for(let i = 0; i < columns.length; i += columnCount)rows.push(columns.slice(i, i + columnCount));
49
+ if (rows.length > rowCount) {
50
+ inputs.columns = columns.slice(0, columnCount * rowCount);
51
+ return;
52
+ }
53
+ const createRows = Math.max(0, rowCount - rows.length);
54
+ if (createRows <= 0) return;
55
+ const newRows = Array.from({
56
+ length: createRows * columnCount
57
+ }).map(()=>({
58
+ children: createElement({
59
+ component: "Webiny/GridColumn"
60
+ })
61
+ }));
62
+ inputs.columns.push(...newRows);
63
+ }
64
+ }),
65
+ createNumberInput({
66
+ name: "rowGap",
67
+ label: "Row Gap",
68
+ defaultValue: 0,
69
+ responsive: true,
70
+ onChange: ({ inputs, styles })=>{
71
+ const rowGap = parseInt(inputs.rowGap);
72
+ if (isNaN(rowGap)) delete styles.rowGap;
73
+ else styles.rowGap = `${inputs.rowGap}px`;
74
+ }
75
+ }),
76
+ createNumberInput({
77
+ name: "columnGap",
78
+ label: "Column Gap",
79
+ defaultValue: 0,
80
+ responsive: true,
81
+ onChange: ({ inputs, styles })=>{
82
+ const columnGap = parseInt(inputs.columnGap);
83
+ if (isNaN(columnGap)) delete styles.columnGap;
84
+ else styles.columnGap = `${inputs.columnGap}px`;
85
+ }
86
+ }),
87
+ createSelectInput({
88
+ name: "stackAtBreakpoint",
89
+ label: "Stack at breakpoint",
90
+ options: [
91
+ {
92
+ label: "Tablet",
93
+ value: "tablet"
94
+ },
95
+ {
96
+ label: "Mobile",
97
+ value: "mobile"
98
+ }
99
+ ]
100
+ }),
101
+ createBooleanInput({
102
+ name: "reverseWhenStacked",
103
+ label: "Reverse columns when stacked"
104
+ }),
105
+ createObjectInput({
106
+ name: "columns",
107
+ list: true,
108
+ hideFromUi: true,
109
+ fields: [
110
+ createSlotInput({
111
+ name: "children",
112
+ list: false,
113
+ components: [
114
+ "Webiny/GridColumn"
115
+ ]
116
+ })
117
+ ]
118
+ })
119
+ ],
120
+ defaults: {
121
+ inputs: {
122
+ gridLayout: "6-6",
123
+ columns: [
124
+ {
125
+ children: website_builder_sdk_createElement({
126
+ component: "Webiny/GridColumn",
127
+ inputs: {
128
+ children: [
129
+ website_builder_sdk_createElement({
130
+ component: "Webiny/Lexical"
131
+ })
132
+ ]
133
+ }
134
+ })
135
+ },
136
+ {
137
+ children: website_builder_sdk_createElement({
138
+ component: "Webiny/GridColumn",
139
+ inputs: {
140
+ children: [
141
+ website_builder_sdk_createElement({
142
+ component: "Webiny/Lexical"
143
+ })
144
+ ]
145
+ }
146
+ })
147
+ }
148
+ ]
149
+ },
150
+ styles: {
151
+ boxSizing: "border-box",
152
+ display: "flex",
153
+ flexDirection: "row",
154
+ flexWrap: "wrap",
155
+ justifyContent: "flex-start",
156
+ alignItems: "stretch",
157
+ width: "100%",
158
+ marginTop: "0px",
159
+ marginBottom: "0px",
160
+ marginLeft: "0px",
161
+ marginRight: "0px",
162
+ paddingTop: "5px",
163
+ paddingRight: "5px",
164
+ paddingBottom: "5px",
165
+ paddingLeft: "5px"
166
+ }
167
+ }
168
+ });
169
+ export { Grid };
170
+
171
+ //# sourceMappingURL=Grid.manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorComponents/Grid.manifest.js","sources":["../../src/editorComponents/Grid.manifest.ts"],"sourcesContent":["\"use client\";\nimport {\n createBooleanInput,\n createElement,\n createNumberInput,\n createObjectInput,\n createSelectInput,\n createSlotInput,\n createTextInput\n} from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { GridComponent } from \"./Grid.js\";\n\nexport interface Column {\n children: React.ReactNode;\n}\nexport const Grid = createComponent(GridComponent, {\n name: \"Webiny/Grid\",\n label: \"Grid\",\n aiContext:\n \"Multi-column layout container. Set gridLayout to a dash-separated pattern (e.g. '6-6' for two equal columns, '8-4' for wide-narrow, '4-4-4' for three equal). Each segment becomes a GridColumn. Columns stack vertically on smaller screens when stackAtBreakpoint is set.\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 20H4v-4h4v4zm0-6H4v-4h4v4zm0-6H4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4z\"/></svg>`,\n group: \"basic\",\n autoApplyStyles: false,\n inputs: [\n createTextInput({\n name: \"gridLayout\",\n label: \"Grid Layout\",\n renderer: \"Webiny/GridLayout\",\n onChange: ({ inputs, createElement }) => {\n const rowColumnCount = inputs.gridLayout.split(\"-\").length;\n const columns = inputs.columns.length;\n\n const remainder = columns % rowColumnCount;\n\n if (remainder !== 0) {\n const fullColumnCount = rowColumnCount * inputs.rowCount;\n const toCreate =\n columns > fullColumnCount ? remainder : rowColumnCount - remainder;\n\n Array.from({ length: toCreate }).forEach(() => {\n inputs.columns.push({\n children: createElement({\n component: \"Webiny/GridColumn\"\n })\n });\n });\n }\n\n inputs.rowCount = inputs.columns.length / rowColumnCount;\n }\n }),\n createNumberInput({\n name: \"rowCount\",\n label: \"Row Count\",\n defaultValue: 1,\n minValue: 1,\n onChange: ({ inputs, createElement }) => {\n const gridLayout = inputs.gridLayout;\n const columnCount = gridLayout.split(\"-\").length;\n const rowCount = Math.max(1, inputs.rowCount);\n const columns = inputs.columns;\n const rows: Column[][] = [];\n\n // Chunk columns into rows\n for (let i = 0; i < columns.length; i += columnCount) {\n rows.push(columns.slice(i, i + columnCount));\n }\n\n if (rows.length > rowCount) {\n inputs.columns = columns.slice(0, columnCount * rowCount);\n return;\n }\n\n const createRows = Math.max(0, rowCount - rows.length);\n\n if (createRows <= 0) {\n return;\n }\n\n const newRows = Array.from({ length: createRows * columnCount }).map(() => {\n return {\n children: createElement({\n component: \"Webiny/GridColumn\"\n })\n };\n });\n\n inputs.columns.push(...newRows);\n }\n }),\n createNumberInput({\n name: \"rowGap\",\n label: \"Row Gap\",\n defaultValue: 0,\n responsive: true,\n onChange: ({ inputs, styles }) => {\n const rowGap = parseInt(inputs.rowGap);\n if (isNaN(rowGap)) {\n delete styles.rowGap;\n } else {\n styles.rowGap = `${inputs.rowGap}px`;\n }\n }\n }),\n createNumberInput({\n name: \"columnGap\",\n label: \"Column Gap\",\n defaultValue: 0,\n responsive: true,\n onChange: ({ inputs, styles }) => {\n const columnGap = parseInt(inputs.columnGap);\n if (isNaN(columnGap)) {\n delete styles.columnGap;\n } else {\n styles.columnGap = `${inputs.columnGap}px`;\n }\n }\n }),\n createSelectInput({\n name: \"stackAtBreakpoint\",\n label: \"Stack at breakpoint\",\n options: [\n { label: \"Tablet\", value: \"tablet\" },\n { label: \"Mobile\", value: \"mobile\" }\n ]\n }),\n createBooleanInput({\n name: \"reverseWhenStacked\",\n label: \"Reverse columns when stacked\"\n }),\n createObjectInput({\n name: \"columns\",\n list: true,\n hideFromUi: true,\n fields: [\n createSlotInput({\n name: \"children\",\n list: false,\n components: [\"Webiny/GridColumn\"]\n })\n ]\n })\n ],\n defaults: {\n inputs: {\n gridLayout: \"6-6\",\n columns: [\n {\n children: createElement({\n component: \"Webiny/GridColumn\",\n inputs: {\n children: [\n createElement({\n component: \"Webiny/Lexical\"\n })\n ]\n }\n })\n },\n {\n children: createElement({\n component: \"Webiny/GridColumn\",\n inputs: {\n children: [\n createElement({\n component: \"Webiny/Lexical\"\n })\n ]\n }\n })\n }\n ]\n },\n styles: {\n boxSizing: \"border-box\",\n display: \"flex\",\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n justifyContent: \"flex-start\",\n alignItems: \"stretch\",\n width: \"100%\",\n marginTop: \"0px\",\n marginBottom: \"0px\",\n marginLeft: \"0px\",\n marginRight: \"0px\",\n paddingTop: \"5px\",\n paddingRight: \"5px\",\n paddingBottom: \"5px\",\n paddingLeft: \"5px\"\n }\n }\n});\n"],"names":["Grid","createComponent","GridComponent","createTextInput","inputs","createElement","rowColumnCount","columns","remainder","fullColumnCount","toCreate","Array","createNumberInput","gridLayout","columnCount","rowCount","Math","rows","i","createRows","newRows","styles","rowGap","parseInt","isNaN","columnGap","createSelectInput","createBooleanInput","createObjectInput","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BAAoB;gBACrC;aACH;QACL;KACH;IACD,UAAU;QACN,QAAQ;YACJ,YAAY;YACZ,SAAS;gBACL;oBACI,UAAUxB,kCAAc;wBACpB,WAAW;wBACX,QAAQ;4BACJ,UAAU;gCACNA,kCAAc;oCACV,WAAW;gCACf;6BACH;wBACL;oBACJ;gBACJ;gBACA;oBACI,UAAUA,kCAAc;wBACpB,WAAW;wBACX,QAAQ;4BACJ,UAAU;gCACNA,kCAAc;oCACV,WAAW;gCACf;6BACH;wBACL;oBACJ;gBACJ;aACH;QACL;QACA,QAAQ;YACJ,WAAW;YACX,SAAS;YACT,eAAe;YACf,UAAU;YACV,gBAAgB;YAChB,YAAY;YACZ,OAAO;YACP,WAAW;YACX,cAAc;YACd,YAAY;YACZ,aAAa;YACb,YAAY;YACZ,cAAc;YACd,eAAe;YACf,aAAa;QACjB;IACJ;AACJ"}
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import type { ComponentPropsWithChildren } from "../types.js";
3
+ export declare const GridColumnComponent: ({ inputs }: {
4
+ inputs: ComponentPropsWithChildren["inputs"];
5
+ }) => React.JSX.Element;
@@ -0,0 +1,5 @@
1
+ import react from "react";
2
+ const GridColumnComponent = ({ inputs })=>/*#__PURE__*/ react.createElement(react.Fragment, null, inputs.children);
3
+ export { GridColumnComponent };
4
+
5
+ //# sourceMappingURL=GridColumn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorComponents/GridColumn.js","sources":["../../src/editorComponents/GridColumn.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ComponentPropsWithChildren } from \"~/types.js\";\n\nexport const GridColumnComponent = ({\n inputs\n}: {\n inputs: ComponentPropsWithChildren[\"inputs\"];\n}) => {\n return <>{inputs.children}</>;\n};\n"],"names":["GridColumnComponent","inputs"],"mappings":";AAGO,MAAMA,sBAAsB,CAAC,EAChCC,MAAM,EAGT,GACU,WAAP,GAAO,0CAAGA,OAAO,QAAQ"}
@@ -0,0 +1 @@
1
+ export declare const GridColumn: import("@webiny/website-builder-sdk").Component;
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { StyleSettings } from "@webiny/website-builder-sdk";
3
+ import { createComponent } from "../createComponent.js";
4
+ import { GridColumnComponent } from "./GridColumn.js";
5
+ const GridColumn = createComponent(GridColumnComponent, {
6
+ name: "Webiny/GridColumn",
7
+ label: "Column",
8
+ aiContext: "A single cell inside a Grid. Accepts any child elements. Created automatically when a Grid's layout changes.",
9
+ image: '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M600-120q-33 0-56.5-23.5T520-200v-560q0-33 23.5-56.5T600-840h160q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H600Zm0-640v560h160v-560H600ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h160q33 0 56.5 23.5T440-760v560q0 33-23.5 56.5T360-120H200Zm0-640v560h160v-560H200Zm560 0H600h160Zm-400 0H200h160Z"/></svg>',
10
+ canDrag: false,
11
+ canDelete: false,
12
+ acceptsChildren: true,
13
+ hideFromToolbar: true,
14
+ hideStyleSettings: [
15
+ StyleSettings.Visibility
16
+ ],
17
+ defaults: {
18
+ styles: {
19
+ paddingTop: "10px",
20
+ paddingRight: "10px",
21
+ paddingBottom: "10px",
22
+ paddingLeft: "10px"
23
+ }
24
+ }
25
+ });
26
+ export { GridColumn };
27
+
28
+ //# sourceMappingURL=GridColumn.manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorComponents/GridColumn.manifest.js","sources":["../../src/editorComponents/GridColumn.manifest.ts"],"sourcesContent":["\"use client\";\nimport { StyleSettings } from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { GridColumnComponent } from \"./GridColumn.js\";\n\nexport const GridColumn = createComponent(GridColumnComponent, {\n name: \"Webiny/GridColumn\",\n label: \"Column\",\n aiContext:\n \"A single cell inside a Grid. Accepts any child elements. Created automatically when a Grid's layout changes.\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#e8eaed\"><path d=\"M600-120q-33 0-56.5-23.5T520-200v-560q0-33 23.5-56.5T600-840h160q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H600Zm0-640v560h160v-560H600ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h160q33 0 56.5 23.5T440-760v560q0 33-23.5 56.5T360-120H200Zm0-640v560h160v-560H200Zm560 0H600h160Zm-400 0H200h160Z\"/></svg>`,\n canDrag: false,\n canDelete: false,\n acceptsChildren: true,\n hideFromToolbar: true,\n hideStyleSettings: [StyleSettings.Visibility],\n defaults: {\n styles: {\n paddingTop: \"10px\",\n paddingRight: \"10px\",\n paddingBottom: \"10px\",\n paddingLeft: \"10px\"\n }\n }\n});\n"],"names":["GridColumn","createComponent","GridColumnComponent","StyleSettings"],"mappings":";;;;AAKO,MAAMA,aAAaC,gBAAgBC,qBAAqB;IAC3D,MAAM;IACN,OAAO;IACP,WACI;IACJ,OAAO;IACP,SAAS;IACT,WAAW;IACX,iBAAiB;IACjB,iBAAiB;IACjB,mBAAmB;QAACC,cAAc,UAAU;KAAC;IAC7C,UAAU;QACN,QAAQ;YACJ,YAAY;YACZ,cAAc;YACd,eAAe;YACf,aAAa;QACjB;IACJ;AACJ"}
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import type { ComponentProps } from "../types.js";
3
+ type ImageProps = ComponentProps<{
4
+ title: string;
5
+ altText: string;
6
+ image: {
7
+ id: string;
8
+ name: string;
9
+ size: number;
10
+ mimeType: string;
11
+ src: string;
12
+ };
13
+ }>;
14
+ export declare const ImageComponent: (props: ImageProps) => React.JSX.Element;
15
+ export {};
@@ -0,0 +1,106 @@
1
+ import react, { useCallback, useEffect, useState } from "react";
2
+ import { contentSdk } from "@webiny/website-builder-sdk";
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
16
+ });
17
+ if ("object" === image.tag) return /*#__PURE__*/ react.createElement("object", {
18
+ style: image.styles,
19
+ title: image.title,
20
+ data: image.src
21
+ });
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
+ }));
32
+ };
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
+ };
103
+ };
104
+ export { ImageComponent };
105
+
106
+ //# sourceMappingURL=Image.js.map
@@ -0,0 +1 @@
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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ACN,IAAI,CAACZ,KACDM,YAAY;IAEpB,GAAG;QAACN;KAAI;IAKR,IAAIC,eAAyB,EAAE;IAE/B,MAAMY,QAAQT,OAAO,KAAK,EAAE;IAE5B,IAAIS,SAASA,MAAM,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"}
@@ -0,0 +1 @@
1
+ export declare const Image: import("@webiny/website-builder-sdk").Component;
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ import { createFileInput, createTextInput } from "@webiny/website-builder-sdk";
3
+ import { createComponent } from "../createComponent.js";
4
+ import { ImageComponent } from "./Image.js";
5
+ const Image = createComponent(ImageComponent, {
6
+ name: "Webiny/Image",
7
+ label: "Image",
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
+ }
38
+ }
39
+ });
40
+ export { Image };
41
+
42
+ //# sourceMappingURL=Image.manifest.js.map
@@ -0,0 +1 @@
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