@webiny/website-builder-react 0.0.0-unstable.e622468070 → 0.0.0-unstable.e9333b3f0b
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.
- package/components/ComponentErrorBoundary.d.ts +32 -0
- package/components/ComponentErrorBoundary.js +25 -0
- package/components/ComponentErrorBoundary.js.map +1 -0
- package/components/ConnectToEditor.js +16 -18
- package/components/ConnectToEditor.js.map +1 -1
- package/components/DocumentFragment.js +5 -7
- package/components/DocumentFragment.js.map +1 -1
- package/components/DocumentRenderer.js +37 -46
- package/components/DocumentRenderer.js.map +1 -1
- package/components/DocumentStoreProvider.js +15 -21
- package/components/DocumentStoreProvider.js.map +1 -1
- package/components/EditingElementRenderer/EditingElementRenderer.d.ts +2 -2
- package/components/EditingElementRenderer/EditingElementRenderer.js +31 -35
- package/components/EditingElementRenderer/EditingElementRenderer.js.map +1 -1
- package/components/EditingElementRenderer/EditingElementRenderer.presenter.js +29 -35
- package/components/EditingElementRenderer/EditingElementRenderer.presenter.js.map +1 -1
- package/components/EditingElementRenderer/index.js +0 -2
- package/components/ElementIndexProvider.js +9 -14
- package/components/ElementIndexProvider.js.map +1 -1
- package/components/ElementRenderer.d.ts +2 -2
- package/components/ElementRenderer.js +11 -16
- package/components/ElementRenderer.js.map +1 -1
- package/components/ElementSlot.js +6 -9
- package/components/ElementSlot.js.map +1 -1
- package/components/ElementSlotDepthProvider.js +9 -14
- package/components/ElementSlotDepthProvider.js.map +1 -1
- package/components/FragmentsProvider.js +30 -36
- package/components/FragmentsProvider.js.map +1 -1
- package/components/LiveElementRenderer.d.ts +2 -2
- package/components/LiveElementRenderer.js +58 -68
- package/components/LiveElementRenderer.js.map +1 -1
- package/components/LiveElementSlot.js +12 -14
- package/components/LiveElementSlot.js.map +1 -1
- package/components/PreviewElementSlot.js +17 -23
- package/components/PreviewElementSlot.js.map +1 -1
- package/components/index.js +0 -2
- package/components/useBindingsForElement.d.ts +80 -48
- package/components/useBindingsForElement.js +13 -11
- package/components/useBindingsForElement.js.map +1 -1
- package/components/useDocumentState.js +4 -3
- package/components/useDocumentState.js.map +1 -1
- package/components/useSelectFromState.js +29 -35
- package/components/useSelectFromState.js.map +1 -1
- package/components/useViewportInfo.js +5 -6
- package/components/useViewportInfo.js.map +1 -1
- package/contentEntry/useContentEntryList.d.ts +22 -0
- package/contentEntry/useContentEntryList.js +51 -0
- package/contentEntry/useContentEntryList.js.map +1 -0
- package/createComponent.d.ts +1 -3
- package/createComponent.js +1 -36
- package/createComponent.test.js +108 -119
- package/createComponent.test.js.map +1 -1
- package/editorComponents/Box.js +3 -6
- package/editorComponents/Box.js.map +1 -1
- package/editorComponents/Box.manifest.js +15 -14
- package/editorComponents/Box.manifest.js.map +1 -1
- package/editorComponents/Fragment.js +23 -32
- package/editorComponents/Fragment.js.map +1 -1
- package/editorComponents/Fragment.manifest.js +14 -11
- package/editorComponents/Fragment.manifest.js.map +1 -1
- package/editorComponents/Grid.js +33 -61
- package/editorComponents/Grid.js.map +1 -1
- package/editorComponents/Grid.manifest.js +163 -166
- package/editorComponents/Grid.manifest.js.map +1 -1
- package/editorComponents/GridColumn.js +3 -6
- package/editorComponents/GridColumn.js.map +1 -1
- package/editorComponents/GridColumn.manifest.js +20 -17
- package/editorComponents/GridColumn.manifest.js.map +1 -1
- package/editorComponents/Image.js +99 -119
- package/editorComponents/Image.js.map +1 -1
- package/editorComponents/Image.manifest.js +33 -32
- package/editorComponents/Image.manifest.js.map +1 -1
- package/editorComponents/Lexical.js +13 -21
- package/editorComponents/Lexical.js.map +1 -1
- package/editorComponents/Lexical.manifest.js +17 -14
- package/editorComponents/Lexical.manifest.js.map +1 -1
- package/editorComponents/Root.js +3 -6
- package/editorComponents/Root.js.map +1 -1
- package/editorComponents/Root.manifest.js +7 -6
- package/editorComponents/Root.manifest.js.map +1 -1
- package/editorComponents/index.js +10 -1
- package/editorComponents/index.js.map +1 -1
- package/image/BackgroundImage.d.ts +33 -0
- package/image/BackgroundImage.js +61 -0
- package/image/BackgroundImage.js.map +1 -0
- package/image/Image.d.ts +29 -0
- package/image/Image.js +43 -0
- package/image/Image.js.map +1 -0
- package/image/getImageProps.d.ts +42 -0
- package/image/getImageProps.js +18 -0
- package/image/getImageProps.js.map +1 -0
- package/image/getImageProps.test.d.ts +1 -0
- package/image/getImageProps.test.js +70 -0
- package/image/getImageProps.test.js.map +1 -0
- package/image/index.d.ts +3 -0
- package/image/index.js +3 -0
- package/index.d.ts +4 -3
- package/index.js +2 -4
- package/package.json +15 -14
- package/types.d.ts +37 -4
- package/types.js +0 -3
- package/components/EditingElementRenderer/index.js.map +0 -1
- package/components/index.js.map +0 -1
- package/createComponent.js.map +0 -1
- package/index.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -1,39 +1,30 @@
|
|
|
1
|
-
import
|
|
1
|
+
import react from "react";
|
|
2
2
|
import { contentSdk } from "@webiny/website-builder-sdk";
|
|
3
3
|
import { useDocumentFragments } from "../components/FragmentsProvider.js";
|
|
4
|
-
const findFixedFragmentByName = (fragments, name) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const fragments = useDocumentFragments();
|
|
12
|
-
const fragment = findFixedFragmentByName(fragments, inputs.name);
|
|
13
|
-
if (!fragment && isEditing) {
|
|
14
|
-
return /*#__PURE__*/React.createElement(FragmentPlaceholder, {
|
|
15
|
-
name: inputs.name
|
|
4
|
+
const findFixedFragmentByName = (fragments, name)=>fragments.filter((fragment)=>"fixed" === fragment.type).find((fragment)=>fragment.name === name);
|
|
5
|
+
const FragmentComponent = ({ inputs })=>{
|
|
6
|
+
const isEditing = contentSdk.isEditing();
|
|
7
|
+
const fragments = useDocumentFragments();
|
|
8
|
+
const fragment = findFixedFragmentByName(fragments, inputs.name);
|
|
9
|
+
if (!fragment && isEditing) return /*#__PURE__*/ react.createElement(FragmentPlaceholder, {
|
|
10
|
+
name: inputs.name
|
|
16
11
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, fragment.element);
|
|
20
|
-
}
|
|
21
|
-
return null;
|
|
12
|
+
if (fragment) return /*#__PURE__*/ react.createElement(react.Fragment, null, fragment.element);
|
|
13
|
+
return null;
|
|
22
14
|
};
|
|
23
|
-
const FragmentPlaceholder = ({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
}, "This is a placeholder for", fragmentName, "content coming from your frontend app.");
|
|
15
|
+
const FragmentPlaceholder = ({ name })=>{
|
|
16
|
+
const fragmentName = name ? /*#__PURE__*/ react.createElement(react.Fragment, null, "\xa0", /*#__PURE__*/ react.createElement("strong", null, name), "\xa0") : /*#__PURE__*/ react.createElement(react.Fragment, null, "\xa0");
|
|
17
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
18
|
+
style: {
|
|
19
|
+
display: "flex",
|
|
20
|
+
height: "100px",
|
|
21
|
+
backgroundColor: "#f4f4f4",
|
|
22
|
+
justifyContent: "center",
|
|
23
|
+
alignItems: "center",
|
|
24
|
+
fill: "#ffffff"
|
|
25
|
+
}
|
|
26
|
+
}, "This is a placeholder for", fragmentName, "content coming from your frontend app.");
|
|
37
27
|
};
|
|
28
|
+
export { FragmentComponent };
|
|
38
29
|
|
|
39
30
|
//# sourceMappingURL=Fragment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"editorComponents/Fragment.js","sources":["../../src/editorComponents/Fragment.tsx"],"sourcesContent":["import React from \"react\";\nimport { contentSdk } from \"@webiny/website-builder-sdk\";\nimport { useDocumentFragments } from \"~/components/FragmentsProvider.js\";\nimport type { ComponentProps } from \"~/types.js\";\nimport type { DocumentFragments } from \"~/components/FragmentsProvider.js\";\n\ntype FragmentComponentProps = ComponentProps<{\n name: string;\n}>;\n\nconst findFixedFragmentByName = (fragments: DocumentFragments, name: string) => {\n return fragments\n .filter(fragment => fragment.type === \"fixed\")\n .find(fragment => fragment.name === name);\n};\n\nexport const FragmentComponent = ({ inputs }: FragmentComponentProps) => {\n const isEditing = contentSdk.isEditing();\n const fragments = useDocumentFragments();\n const fragment = findFixedFragmentByName(fragments, inputs.name);\n\n if (!fragment && isEditing) {\n return <FragmentPlaceholder name={inputs.name} />;\n }\n\n if (fragment) {\n return <>{fragment.element}</>;\n }\n\n return null;\n};\n\nconst FragmentPlaceholder = ({ name }: { name: string }) => {\n const fragmentName = name ? (\n <>\n <strong>{name}</strong> \n </>\n ) : (\n <> </>\n );\n return (\n <div\n style={{\n display: \"flex\",\n height: \"100px\",\n backgroundColor: \"#f4f4f4\",\n justifyContent: \"center\",\n alignItems: \"center\",\n fill: \"#ffffff\"\n }}\n >\n This is a placeholder for{fragmentName}content coming from your frontend app.\n </div>\n );\n};\n"],"names":["findFixedFragmentByName","fragments","name","fragment","FragmentComponent","inputs","isEditing","contentSdk","useDocumentFragments","FragmentPlaceholder","fragmentName"],"mappings":";;;AAUA,MAAMA,0BAA0B,CAACC,WAA8BC,OACpDD,UACF,MAAM,CAACE,CAAAA,WAAYA,AAAkB,YAAlBA,SAAS,IAAI,EAChC,IAAI,CAACA,CAAAA,WAAYA,SAAS,IAAI,KAAKD;AAGrC,MAAME,oBAAoB,CAAC,EAAEC,MAAM,EAA0B;IAChE,MAAMC,YAAYC,WAAW,SAAS;IACtC,MAAMN,YAAYO;IAClB,MAAML,WAAWH,wBAAwBC,WAAWI,OAAO,IAAI;IAE/D,IAAI,CAACF,YAAYG,WACb,OAAO,WAAP,GAAO,oBAACG,qBAAmBA;QAAC,MAAMJ,OAAO,IAAI;;IAGjD,IAAIF,UACA,OAAO,WAAP,GAAO,0CAAGA,SAAS,OAAO;IAG9B,OAAO;AACX;AAEA,MAAMM,sBAAsB,CAAC,EAAEP,IAAI,EAAoB;IACnD,MAAMQ,eAAeR,OAAO,WAAPA,GACjB,0CAAE,sBACQ,oBAAC,gBAAQA,OAAc,wBAGjC,0CAAE;IAEN,OAAO,WAAP,GACI,oBAAC;QACG,OAAO;YACH,SAAS;YACT,QAAQ;YACR,iBAAiB;YACjB,gBAAgB;YAChB,YAAY;YACZ,MAAM;QACV;OACH,6BAC6BQ,cAAa;AAGnD"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
2
|
import { createTextInput } from "@webiny/website-builder-sdk";
|
|
4
3
|
import { createComponent } from "../createComponent.js";
|
|
5
4
|
import { FragmentComponent } from "./Fragment.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
label: "Fragment",
|
|
9
|
-
group: "basic",
|
|
10
|
-
image: `<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M120-120v-720h720v720H120Zm80-80h560v-560H200v560Zm0 0v-560 560Z"/></svg>`,
|
|
11
|
-
inputs: [createTextInput({
|
|
12
|
-
name: "name",
|
|
5
|
+
const Fragment = createComponent(FragmentComponent, {
|
|
6
|
+
name: "Webiny/Fragment",
|
|
13
7
|
label: "Fragment",
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
useInAiContentGeneration: false,
|
|
9
|
+
group: "basic",
|
|
10
|
+
image: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M3 3v18h18V3H3zm16 16H5V5h14v14z"/></svg>',
|
|
11
|
+
inputs: [
|
|
12
|
+
createTextInput({
|
|
13
|
+
name: "name",
|
|
14
|
+
label: "Fragment",
|
|
15
|
+
description: "Select fragment to display.",
|
|
16
|
+
renderer: "Webiny/FragmentSelector"
|
|
17
|
+
})
|
|
18
|
+
]
|
|
17
19
|
});
|
|
20
|
+
export { Fragment };
|
|
18
21
|
|
|
19
22
|
//# sourceMappingURL=Fragment.manifest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"editorComponents/Fragment.manifest.js","sources":["../../src/editorComponents/Fragment.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createTextInput } from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { FragmentComponent } from \"./Fragment.js\";\n\nexport const Fragment = createComponent(FragmentComponent, {\n name: \"Webiny/Fragment\",\n label: \"Fragment\",\n useInAiContentGeneration: false,\n group: \"basic\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M3 3v18h18V3H3zm16 16H5V5h14v14z\"/></svg>`,\n inputs: [\n createTextInput({\n name: \"name\",\n label: \"Fragment\",\n description: \"Select fragment to display.\",\n renderer: \"Webiny/FragmentSelector\"\n })\n ]\n});\n"],"names":["Fragment","createComponent","FragmentComponent","createTextInput"],"mappings":";;;;AAKO,MAAMA,WAAWC,gBAAgBC,mBAAmB;IACvD,MAAM;IACN,OAAO;IACP,0BAA0B;IAC1B,OAAO;IACP,OAAO;IACP,QAAQ;QACJC,gBAAgB;YACZ,MAAM;YACN,OAAO;YACP,aAAa;YACb,UAAU;QACd;KACH;AACL"}
|
package/editorComponents/Grid.js
CHANGED
|
@@ -1,65 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
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
|
+
})))));
|
|
6
24
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
stackAtBreakpoint,
|
|
17
|
-
reverseWhenStacked
|
|
18
|
-
} = inputs;
|
|
19
|
-
const rowConfig = gridLayout.split("-").map(size => parseInt(size));
|
|
20
|
-
const rows = [];
|
|
21
|
-
|
|
22
|
-
// Chunk columns into rows
|
|
23
|
-
for (let i = 0; i < columns.length; i += rowConfig.length) {
|
|
24
|
-
rows.push(columns.slice(i, i + rowConfig.length));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Number of pixels we need to subtract from each cell to ensure they fit in the grid with column gap
|
|
28
|
-
const cellWidthReduction = columnGap ? columnGap - columnGap / rowConfig.length : 0;
|
|
29
|
-
const stackColumns = breakpoint === stackAtBreakpoint;
|
|
30
|
-
if (stackColumns) {
|
|
31
|
-
styles.flexDirection = reverseWhenStacked ? "column-reverse" : "column";
|
|
32
|
-
}
|
|
33
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
34
|
-
style: styles
|
|
35
|
-
}, rows.map(columns => {
|
|
36
|
-
return columns.map((column, i) => /*#__PURE__*/React.createElement(Span, {
|
|
37
|
-
key: i,
|
|
38
|
-
stackColumns: stackColumns,
|
|
39
|
-
size: rowConfig[i],
|
|
40
|
-
reductionInPx: cellWidthReduction
|
|
41
|
-
}, /*#__PURE__*/React.createElement(GridColumnComponent, {
|
|
42
|
-
key: i,
|
|
43
|
-
inputs: {
|
|
44
|
-
children: column.children
|
|
45
|
-
}
|
|
46
|
-
})));
|
|
47
|
-
}));
|
|
48
|
-
};
|
|
49
|
-
const Span = ({
|
|
50
|
-
size,
|
|
51
|
-
children,
|
|
52
|
-
reductionInPx,
|
|
53
|
-
stackColumns
|
|
54
|
-
}) => {
|
|
55
|
-
const width = stackColumns ? "100%" : `calc(${size / 12 * 100}% - ${reductionInPx}px)`;
|
|
56
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
57
|
-
style: {
|
|
58
|
-
flex: `0 0 ${width}`,
|
|
59
|
-
maxWidth: width,
|
|
60
|
-
boxSizing: "border-box"
|
|
61
|
-
}
|
|
62
|
-
}, children);
|
|
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);
|
|
63
34
|
};
|
|
35
|
+
export { GridColumnComponent, GridComponent };
|
|
64
36
|
|
|
65
37
|
//# sourceMappingURL=Grid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
@@ -1,174 +1,171 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
import { createBooleanInput, createElement, createNumberInput, createObjectInput, createSelectInput, createSlotInput, createTextInput } from "@webiny/website-builder-sdk";
|
|
2
|
+
import { createBooleanInput, createElement as website_builder_sdk_createElement, createNumberInput, createObjectInput, createSelectInput, createSlotInput, createTextInput } from "@webiny/website-builder-sdk";
|
|
4
3
|
import { createComponent } from "../createComponent.js";
|
|
5
4
|
import { GridComponent } from "./Grid.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
name: "reverseWhenStacked",
|
|
120
|
-
label: "Reverse columns when stacked"
|
|
121
|
-
}), createObjectInput({
|
|
122
|
-
name: "columns",
|
|
123
|
-
list: true,
|
|
124
|
-
hideFromUi: true,
|
|
125
|
-
fields: [createSlotInput({
|
|
126
|
-
name: "children",
|
|
127
|
-
list: false,
|
|
128
|
-
components: ["Webiny/GridColumn"]
|
|
129
|
-
})]
|
|
130
|
-
})],
|
|
131
|
-
defaults: {
|
|
132
|
-
inputs: {
|
|
133
|
-
gridLayout: "6-6",
|
|
134
|
-
columns: [{
|
|
135
|
-
children: createElement({
|
|
136
|
-
component: "Webiny/GridColumn",
|
|
137
|
-
inputs: {
|
|
138
|
-
children: [createElement({
|
|
139
|
-
component: "Webiny/Lexical"
|
|
140
|
-
})]
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
}, {
|
|
144
|
-
children: createElement({
|
|
145
|
-
component: "Webiny/GridColumn",
|
|
146
|
-
inputs: {
|
|
147
|
-
children: [createElement({
|
|
148
|
-
component: "Webiny/Lexical"
|
|
149
|
-
})]
|
|
150
|
-
}
|
|
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
|
+
]
|
|
151
118
|
})
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
+
}
|
|
170
167
|
}
|
|
171
|
-
}
|
|
172
168
|
});
|
|
169
|
+
export { Grid };
|
|
173
170
|
|
|
174
171
|
//# sourceMappingURL=Grid.manifest.js.map
|