@webiny/website-builder-react 0.0.0-unstable.5387e5f7c8 → 0.0.0-unstable.676006d08e
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/ConnectToEditor.d.ts +3 -1
- package/components/ConnectToEditor.js +7 -5
- package/components/ConnectToEditor.js.map +1 -1
- package/components/ContentClientContext.d.ts +3 -0
- package/components/ContentClientContext.js +6 -0
- package/components/ContentClientContext.js.map +1 -0
- package/components/ContentClientProvider.d.ts +12 -0
- package/components/ContentClientProvider.js +9 -0
- package/components/ContentClientProvider.js.map +1 -0
- package/components/ContentClientProvider.test.d.ts +1 -0
- package/components/ContentClientProvider.test.js +143 -0
- package/components/ContentClientProvider.test.js.map +1 -0
- package/components/DocumentRenderer.d.ts +8 -3
- package/components/DocumentRenderer.js +22 -10
- package/components/DocumentRenderer.js.map +1 -1
- package/components/DocumentStoreProvider.d.ts +7 -0
- package/components/DocumentStoreProvider.js +24 -5
- package/components/DocumentStoreProvider.js.map +1 -1
- package/components/DocumentStoreProvider.test.d.ts +1 -0
- package/components/DocumentStoreProvider.test.js +66 -0
- package/components/DocumentStoreProvider.test.js.map +1 -0
- package/components/EditingElementRenderer/EditingElementRenderer.d.ts +5 -0
- package/components/EditingElementRenderer/EditingElementRenderer.js +21 -9
- package/components/EditingElementRenderer/EditingElementRenderer.js.map +1 -1
- package/components/EditingElementRenderer/EditingElementRenderer.presenter.d.ts +2 -2
- package/components/EditingElementRenderer/EditingElementRenderer.presenter.js +4 -3
- package/components/EditingElementRenderer/EditingElementRenderer.presenter.js.map +1 -1
- package/components/ElementIndexProvider.js.map +1 -1
- package/components/ElementRenderer.js +17 -4
- package/components/ElementRenderer.js.map +1 -1
- package/components/ElementSlot.js +5 -2
- package/components/ElementSlot.js.map +1 -1
- package/components/ElementSlotDepthProvider.js.map +1 -1
- package/components/FragmentsProvider.js +4 -3
- package/components/FragmentsProvider.js.map +1 -1
- package/components/GlobalComponent.d.ts +10 -0
- package/components/GlobalComponent.js +17 -0
- package/components/GlobalComponent.js.map +1 -0
- package/components/GlobalPlacement.d.ts +11 -0
- package/components/GlobalPlacement.js +27 -0
- package/components/GlobalPlacement.js.map +1 -0
- package/components/LayoutAreas.d.ts +19 -0
- package/components/LayoutAreas.js +15 -0
- package/components/LayoutAreas.js.map +1 -0
- package/components/LayoutRenderer.d.ts +14 -0
- package/components/LayoutRenderer.js +60 -0
- package/components/LayoutRenderer.js.map +1 -0
- package/components/LayoutRenderer.test.d.ts +1 -0
- package/components/LayoutRenderer.test.js +138 -0
- package/components/LayoutRenderer.test.js.map +1 -0
- package/components/LiveElementRenderer.js +5 -3
- package/components/LiveElementRenderer.js.map +1 -1
- package/components/PageLayout.d.ts +40 -0
- package/components/PageLayout.js +71 -0
- package/components/PageLayout.js.map +1 -0
- package/components/PreviewElementSlot.js +11 -1
- package/components/PreviewElementSlot.js.map +1 -1
- package/components/SlotLabel.d.ts +15 -0
- package/components/SlotLabel.js +13 -0
- package/components/SlotLabel.js.map +1 -0
- package/components/index.d.ts +7 -0
- package/components/index.js +6 -0
- package/components/renderWithLayout.d.ts +5 -0
- package/components/renderWithLayout.js +7 -0
- package/components/renderWithLayout.js.map +1 -0
- package/components/useBindingsForElement.d.ts +68 -3
- package/components/useContentClient.d.ts +6 -0
- package/components/useContentClient.js +11 -0
- package/components/useContentClient.js.map +1 -0
- package/components/useDocumentState.js +2 -1
- package/components/useDocumentState.js.map +1 -1
- package/components/useIsElementSelected.d.ts +8 -0
- package/components/useIsElementSelected.js +22 -0
- package/components/useIsElementSelected.js.map +1 -0
- package/components/useSeededDocumentStore.d.ts +10 -0
- package/components/useSeededDocumentStore.js +22 -0
- package/components/useSeededDocumentStore.js.map +1 -0
- package/components/useSelectFromState.d.ts +2 -1
- package/components/useSelectFromState.js +2 -2
- package/components/useSelectFromState.js.map +1 -1
- package/components/useSelectFromState.test.d.ts +1 -0
- package/components/useSelectFromState.test.js +67 -0
- package/components/useSelectFromState.test.js.map +1 -0
- package/editorComponents/Fragment.js.map +1 -1
- package/editorComponents/Grid.d.ts +1 -1
- package/editorComponents/Grid.js +3 -2
- package/editorComponents/Grid.js.map +1 -1
- package/editorComponents/Image.js.map +1 -1
- package/editorComponents/LayoutContent.d.ts +6 -0
- package/editorComponents/LayoutContent.js +121 -0
- package/editorComponents/LayoutContent.js.map +1 -0
- package/editorComponents/LayoutContent.manifest.d.ts +10 -0
- package/editorComponents/LayoutContent.manifest.js +32 -0
- package/editorComponents/LayoutContent.manifest.js.map +1 -0
- package/editorComponents/LayoutContentLabel.d.ts +2 -0
- package/editorComponents/LayoutContentLabel.js +7 -0
- package/editorComponents/LayoutContentLabel.js.map +1 -0
- package/editorComponents/LayoutContentLabel.test.d.ts +1 -0
- package/editorComponents/LayoutContentLabel.test.js +23 -0
- package/editorComponents/LayoutContentLabel.test.js.map +1 -0
- package/editorComponents/index.js +4 -1
- package/editorComponents/index.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +13 -11
- package/types.d.ts +2 -0
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,qBAAAA;QAAoB,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"}
|
|
@@ -15,5 +15,5 @@ type GridProps = ComponentProps<{
|
|
|
15
15
|
stackAtBreakpoint?: string;
|
|
16
16
|
reverseWhenStacked?: boolean;
|
|
17
17
|
}>;
|
|
18
|
-
export declare const GridComponent: ({ inputs, styles, breakpoint }: GridProps) => React.JSX.Element;
|
|
18
|
+
export declare const GridComponent: ({ inputs, styles, breakpoint, breakpoints }: GridProps) => React.JSX.Element;
|
|
19
19
|
export {};
|
package/editorComponents/Grid.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import react from "react";
|
|
2
2
|
const GridColumnComponent = ({ inputs })=>/*#__PURE__*/ react.createElement(react.Fragment, null, inputs.children);
|
|
3
|
-
const GridComponent = ({ inputs, styles, breakpoint })=>{
|
|
3
|
+
const GridComponent = ({ inputs, styles, breakpoint, breakpoints })=>{
|
|
4
4
|
const { gridLayout = "12", columns, columnGap, stackAtBreakpoint, reverseWhenStacked } = inputs;
|
|
5
5
|
const rowConfig = gridLayout.split("-").map((size)=>parseInt(size));
|
|
6
6
|
const rows = [];
|
|
7
7
|
for(let i = 0; i < columns.length; i += rowConfig.length)rows.push(columns.slice(i, i + rowConfig.length));
|
|
8
8
|
const cellWidthReduction = columnGap ? columnGap - columnGap / rowConfig.length : 0;
|
|
9
|
-
const
|
|
9
|
+
const stackFrom = stackAtBreakpoint ? breakpoints.indexOf(stackAtBreakpoint) : -1;
|
|
10
|
+
const stackColumns = -1 !== stackFrom && breakpoints.indexOf(breakpoint) >= stackFrom;
|
|
10
11
|
if (stackColumns) styles.flexDirection = reverseWhenStacked ? "column-reverse" : "column";
|
|
11
12
|
return /*#__PURE__*/ react.createElement("div", {
|
|
12
13
|
style: styles
|
|
@@ -1 +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
|
|
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, breakpoints }: 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 // Stack at the chosen breakpoint and every narrower one.\n const stackFrom = stackAtBreakpoint ? breakpoints.indexOf(stackAtBreakpoint) : -1;\n const stackColumns = stackFrom !== -1 && breakpoints.indexOf(breakpoint) >= stackFrom;\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","breakpoints","gridLayout","columns","columnGap","stackAtBreakpoint","reverseWhenStacked","rowConfig","size","parseInt","rows","i","cellWidthReduction","stackFrom","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,EAAEC,WAAW,EAAa;IAChF,MAAM,EAAEC,aAAa,IAAI,EAAEC,OAAO,EAAEC,SAAS,EAAEC,iBAAiB,EAAEC,kBAAkB,EAAE,GAAGT;IACzF,MAAMU,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;IAGlF,MAAMM,YAAYR,oBAAoBJ,YAAY,OAAO,CAACI,qBAAqB;IAC/E,MAAMS,eAAeD,AAAc,OAAdA,aAAoBZ,YAAY,OAAO,CAACD,eAAea;IAE5E,IAAIC,cACAf,OAAO,aAAa,GAAGO,qBAAqB,mBAAmB;IAGnE,OAAO,WAAP,GACI,oBAAC;QAAI,OAAOP;OACPW,KAAK,GAAG,CAACP,CAAAA,UACCA,QAAQ,GAAG,CAAC,CAACY,QAAQJ,IAAAA,WAAAA,GACxB,oBAACK,MAAAA;gBACG,KAAKL;gBACL,cAAcG;gBACd,MAAMP,SAAS,CAACI,EAAE;gBAClB,eAAeC;6BAEf,oBAAChB,qBAAAA;gBAAoB,KAAKe;gBAAG,QAAQ;oBAAE,UAAUI,OAAO,QAAQ;gBAAC;;AAMzF;AASA,MAAMC,OAAO,CAAC,EAAER,IAAI,EAAES,QAAQ,EAAEC,aAAa,EAAEJ,YAAY,EAAa;IACpE,MAAMK,QAAQL,eAAe,SAAS,CAAC,KAAK,EAAGN,OAAO,KAAM,IAAI,IAAI,EAAEU,cAAc,GAAG,CAAC;IAExF,OAAO,WAAP,GACI,oBAAC;QACG,OAAO;YACH,MAAM,CAAC,IAAI,EAAEC,OAAO;YACpB,UAAUA;YACV,WAAW;QACf;OAECF;AAGb"}
|
|
@@ -1 +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,
|
|
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,MAAM,KAAK;QAAE,MAAMA,MAAM,GAAG;;IAG3E,OAAO,WAAP,GACI,0CACK,CAACA,MAAM,QAAQ,IAAI,WAAJ,GAAI,oBAACE,kBAAAA;QAAiB,OAAOF,MAAM,MAAM;sBACzD,oBAAC;QACG,KAAKA,MAAM,OAAO;QAClB,QAAQA,MAAM,MAAM;QACpB,OAAOA,MAAM,KAAK;QAClB,KAAKA,MAAM,GAAG;QACd,QAAQA,MAAM,MAAM;QACpB,OAAOA,MAAM,MAAM;;AAInC;AAEA,MAAME,mBAAmB,CAAC,EAAEC,KAAK,EAA4B,GAClD,WAAP,GACI,oBAAC;QACG,OAAO;YACH,SAAS;YACT,QAAQ;YACR,iBAAiB;YACjB,gBAAgB;YAChB,YAAY;YACZ,MAAM;YACN,GAAGA,KAAK;QACZ;qBAEA,oBAAC;QACG,OAAO;YACH,OAAO;YACP,QAAQ;YACR,QAAQ;QACZ;QACA,OAAM;QACN,QAAO;QACP,SAAQ;QACR,OAAM;qBAEN,oBAAC;QAAK,GAAE;;AAMxB,MAAMC,YAAY,CAACC,KAAaC,eACrBA,aAAa,GAAG,CAACC,CAAAA,OAAQ,GAAGF,IAAI,OAAO,EAAEE,KAAK,CAAC,EAAEA,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC;AAG1E,MAAMN,WAAW,CAAC,EAAEO,MAAM,EAAEC,MAAM,EAAc;IAC5C,MAAM,CAACC,UAAUC,YAAY,GAAGC,UAASC,WAAW,SAAS;IAC7D,MAAM,EAAEC,QAAQ,EAAE,EAAEC,OAAO,EAAEf,KAAK,EAAE,GAAGQ;IACvC,MAAMH,MAAML,OAAO;IAEnB,MAAMgB,MAAMX,OAAOA,IAAI,QAAQ,CAAC,UAAU,WAAW;IAErDY,UAAU;QACN,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,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,MAAMG,eAAeC,0BAA0BF,UAAUD,OAAO,qBAAqB;IACrF,OAAO;QAAE,GAAGC,QAAQ;QAAE,UAAUC,aAAa,QAAQ;QAAE,UAAUA,aAAa,QAAQ;IAAC;AAC3F;AAMA,MAAME,WAAWC,SAAS,CAAC,EAAEC,IAAI,EAA+B;IAC5D,MAAMC,gBAAgBC;IACtB,MAAMC,OAAOH,KAAK,IAAI;IAGtB,IAAIA,KAAK,MAAM,IACX,OAAO,WAAP,GACI,oBAACI,WAASA;QAAC,UAAU;QAAQ,MAAMD;QAAM,OAAOE,oBAAoBL;qBAChE,oBAACM,iBAAeA;QAAC,IAAI;;IAKjC,MAAMC,MAAMN,cAAc,WAAW,IAAI,SAAS,MAAM,QAAQ,CAACE,KAAK,EAAE;IAExE,OAAO,WAAP,GACI,oBAACC,WAASA;QAAC,UAAU;QAAQ,MAAMD;QAAM,OAAOE,oBAAoBL;qBAChE,oBAACQ,aAAWA;QACR,UAAU;QACV,MAAML;QACN,UAAUM,MAAM,OAAO,CAACF,OAAO;eAAIA;SAAI,GAAG,EAAE;;AAI5D;AAEA,MAAMG,mBAAmB,CAAC,EACtBf,QAAQ,EACRgB,QAAQ,EAIX;IACG,MAAMC,QAAQC,uBAAuBlB;IAErC,OAAO,WAAP,GAAO,oBAACmB,oBAAkBA;QAAC,OAAOF;OAAQD;AAC9C;AAMA,MAAMI,qBAAqB,CAAC,EAAEC,QAAQ,EAAEhB,IAAI,EAAiD;IACzF,MAAMN,SAASuB;IACf,MAAMtB,WAAWuB,QACb,IAAM1B,kBAAkB2B,KAAK,KAAK,CAACH,WAAWtB,SAC9C;QAACsB;QAAUtB;KAAO;IAKtB,OAAO,WAAP,GACI,oBAAC0B,eAAaA,MAAAA,WAAAA,GACV,oBAACV,kBAAAA;QAAiB,KAAKf,SAAS,EAAE;QAAE,UAAUA;qBAC1C,oBAACG,UAAAA;QAAS,MAAME;;AAIhC;AAEA,MAAMqB,cAAc,CAAC,EAAErB,IAAI,EAA+B,GAC/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 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { LayoutContentArea } from "@webiny/website-builder-sdk";
|
|
3
|
+
import { getContentAreaLabel } from "./LayoutContentLabel.js";
|
|
4
|
+
const LayoutContentLabel_test_element = (id, name)=>({
|
|
5
|
+
id,
|
|
6
|
+
component: {
|
|
7
|
+
name
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
describe("getContentAreaLabel", ()=>{
|
|
11
|
+
it('labels the main content area "Main content", and a named one by its own name, with no "Named content ·" prefix', ()=>{
|
|
12
|
+
const main = LayoutContentArea.fromElement(LayoutContentLabel_test_element("content", "Webiny/LayoutContent"));
|
|
13
|
+
const named = LayoutContentArea.fromElement(LayoutContentLabel_test_element("sidebar", "Webiny/NamedContent"), "sidebar");
|
|
14
|
+
expect(getContentAreaLabel(main)).toBe("Main content");
|
|
15
|
+
expect(getContentAreaLabel(named)).toBe("sidebar");
|
|
16
|
+
});
|
|
17
|
+
it('labels a named content area without a name "Named content"', ()=>{
|
|
18
|
+
const area = LayoutContentArea.fromElement(LayoutContentLabel_test_element("area", "Webiny/NamedContent"), " ");
|
|
19
|
+
expect(getContentAreaLabel(area)).toBe("Named content");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=LayoutContentLabel.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorComponents/LayoutContentLabel.test.js","sources":["../../src/editorComponents/LayoutContentLabel.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { LayoutContentArea } from \"@webiny/website-builder-sdk\";\nimport { getContentAreaLabel } from \"./LayoutContentLabel.js\";\n\nconst element = (id: string, name: string) => ({ id, component: { name } });\n\ndescribe(\"getContentAreaLabel\", () => {\n it('labels the main content area \"Main content\", and a named one by its own name, with no \"Named content ·\" prefix', () => {\n const main = LayoutContentArea.fromElement(element(\"content\", \"Webiny/LayoutContent\"));\n const named = LayoutContentArea.fromElement(\n element(\"sidebar\", \"Webiny/NamedContent\"),\n \"sidebar\"\n );\n\n expect(getContentAreaLabel(main)).toBe(\"Main content\");\n expect(getContentAreaLabel(named)).toBe(\"sidebar\");\n });\n\n it('labels a named content area without a name \"Named content\"', () => {\n const area = LayoutContentArea.fromElement(element(\"area\", \"Webiny/NamedContent\"), \" \");\n\n expect(getContentAreaLabel(area)).toBe(\"Named content\");\n });\n});\n"],"names":["element","id","name","describe","it","main","LayoutContentArea","named","expect","getContentAreaLabel","area"],"mappings":";;;AAIA,MAAMA,kCAAU,CAACC,IAAYC,OAAkB;QAAED;QAAI,WAAW;YAAEC;QAAK;IAAE;AAEzEC,SAAS,uBAAuB;IAC5BC,GAAG,kHAAkH;QACjH,MAAMC,OAAOC,kBAAkB,WAAW,CAACN,gCAAQ,WAAW;QAC9D,MAAMO,QAAQD,kBAAkB,WAAW,CACvCN,gCAAQ,WAAW,wBACnB;QAGJQ,OAAOC,oBAAoBJ,OAAO,IAAI,CAAC;QACvCG,OAAOC,oBAAoBF,QAAQ,IAAI,CAAC;IAC5C;IAEAH,GAAG,8DAA8D;QAC7D,MAAMM,OAAOJ,kBAAkB,WAAW,CAACN,gCAAQ,QAAQ,wBAAwB;QAEnFQ,OAAOC,oBAAoBC,OAAO,IAAI,CAAC;IAC3C;AACJ"}
|
|
@@ -5,6 +5,7 @@ import { Lexical } from "./Lexical.manifest.js";
|
|
|
5
5
|
import { Root } from "./Root.manifest.js";
|
|
6
6
|
import { GridColumn } from "./GridColumn.manifest.js";
|
|
7
7
|
import { Fragment } from "./Fragment.manifest.js";
|
|
8
|
+
import { LayoutContent, NamedContent } from "./LayoutContent.manifest.js";
|
|
8
9
|
const editorComponents = [
|
|
9
10
|
Root,
|
|
10
11
|
Box,
|
|
@@ -12,7 +13,9 @@ const editorComponents = [
|
|
|
12
13
|
GridColumn,
|
|
13
14
|
Image,
|
|
14
15
|
Lexical,
|
|
15
|
-
Fragment
|
|
16
|
+
Fragment,
|
|
17
|
+
LayoutContent,
|
|
18
|
+
NamedContent
|
|
16
19
|
];
|
|
17
20
|
export { editorComponents };
|
|
18
21
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorComponents/index.js","sources":["../../src/editorComponents/index.ts"],"sourcesContent":["import { Box } from \"./Box.manifest.js\";\nimport { Grid } from \"./Grid.manifest.js\";\nimport { Image } from \"./Image.manifest.js\";\nimport { Lexical } from \"./Lexical.manifest.js\";\nimport { Root } from \"./Root.manifest.js\";\nimport { GridColumn } from \"./GridColumn.manifest.js\";\nimport { Fragment } from \"./Fragment.manifest.js\";\n\nexport const editorComponents = [Root
|
|
1
|
+
{"version":3,"file":"editorComponents/index.js","sources":["../../src/editorComponents/index.ts"],"sourcesContent":["import { Box } from \"./Box.manifest.js\";\nimport { Grid } from \"./Grid.manifest.js\";\nimport { Image } from \"./Image.manifest.js\";\nimport { Lexical } from \"./Lexical.manifest.js\";\nimport { Root } from \"./Root.manifest.js\";\nimport { GridColumn } from \"./GridColumn.manifest.js\";\nimport { Fragment } from \"./Fragment.manifest.js\";\nimport { LayoutContent, NamedContent } from \"./LayoutContent.manifest.js\";\n\nexport const editorComponents = [\n Root,\n Box,\n Grid,\n GridColumn,\n Image,\n Lexical,\n Fragment,\n LayoutContent,\n NamedContent\n];\n"],"names":["editorComponents","Root","Box","Grid","GridColumn","Image","Lexical","Fragment","LayoutContent","NamedContent"],"mappings":";;;;;;;;AASO,MAAMA,mBAAmB;IAC5BC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;CACH"}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./components/index.js";
|
|
2
2
|
export * from "./contentEntry/useContentEntryList.js";
|
|
3
3
|
export { createComponent } from "@webiny/website-builder-sdk";
|
|
4
|
-
export { createTextInput, createLongTextInput, createNumberInput, createBooleanInput, createColorInput, createFileInput, createDateInput, createLexicalInput, createSelectInput, createRadioInput, createObjectInput, createTagsInput, createSlotInput, createContentEntryInput, createInput, createElement, createTheme, contentSdk, environment, setHeadersProvider, getHeadersProvider, registerComponentGroup, getPageWithExperiment, resolveVisitorContext, assignVariant, forcedAssignment, registerAnalyticsProvider, getAnalyticsProvider, ASPECT_RATIO_PRESETS, FORCED_VARIANT_PARAM, DEFAULT_VISITOR_COOKIE, CONTROL_VARIANT_ID, type ActiveExperiment, type ActiveExperimentVariant, type VariantContent, type VariantAssignment, type VisitorContext, type DeviceType, type ExperimentTrafficSplit, type ExperimentTargeting, type ExperimentAnalyticsConfig, type ExperimentSdk, type ExperimentRenderResult, type GetPageWithExperimentOptions, type ExperimentCookie, type CssProperties, type Document, type DocumentElement, type Breakpoint, type CreateElementParams, type ContentSDKConfig, type ComponentManifest, type ComponentInput, type ContentEntryInput, type ContentEntryReference, type ContentEntryQueryConfig, type ContentEntryQueryValue, type ComponentConstraint, type WebsiteBuilderThemeInput, type AssetCrop, type AssetFocalPoint, type Asset, type AssetImage, type AssetDocument, type AssetVideo, type AssetCategory, normalizeToAsset, getAssetCategory, getAssetUrl, getAssetCropParam, type AssetUrlOptions, IMAGE_RESIZE_WIDTHS, getImageSrcSet, getImageDimensions, type ImageSrcSet, type ImageSrcSetOptions, type ImageDimensions, type AspectRatioInput, type AspectRatioPreset, StyleSettings } from "@webiny/website-builder-sdk";
|
|
4
|
+
export { createTextInput, createLongTextInput, createNumberInput, createBooleanInput, createColorInput, createFileInput, createDateInput, createLexicalInput, createSelectInput, createRadioInput, createObjectInput, createTagsInput, createSlotInput, createContentEntryInput, createInput, createElement, createTheme, contentSdk, createContentClient, environment, setHeadersProvider, getHeadersProvider, setDefaultComponentLoader, getDefaultComponentLoader, registerComponentGroup, getPageWithExperiment, resolveVisitorContext, assignVariant, forcedAssignment, registerAnalyticsProvider, getAnalyticsProvider, ASPECT_RATIO_PRESETS, FORCED_VARIANT_PARAM, DEFAULT_VISITOR_COOKIE, CONTROL_VARIANT_ID, type ActiveExperiment, type ActiveExperimentVariant, type VariantContent, type VariantAssignment, type VisitorContext, type DeviceType, type ExperimentTrafficSplit, type ExperimentTargeting, type ExperimentAnalyticsConfig, type ExperimentSdk, type ExperimentRenderResult, type GetPageWithExperimentOptions, type ExperimentCookie, type CssProperties, type Document, type PageLayout, type DocumentElement, type Breakpoint, type CreateElementParams, type ContentSDKConfig, type ContentClient, type ComponentLoader, type ComponentLoaderFactory, type ComponentLoaderFactoryParams, type ComponentManifest, type ComponentInput, type ContentEntryInput, type ContentEntryReference, type ContentEntryQueryConfig, type ContentEntryQueryValue, type ComponentConstraint, type WebsiteBuilderThemeInput, type AssetCrop, type AssetFocalPoint, type Asset, type AssetImage, type AssetDocument, type AssetVideo, type AssetCategory, normalizeToAsset, getAssetCategory, getAssetUrl, getAssetCropParam, type AssetUrlOptions, IMAGE_RESIZE_WIDTHS, getImageSrcSet, getImageDimensions, type ImageSrcSet, type ImageSrcSetOptions, type ImageDimensions, type AspectRatioInput, type AspectRatioPreset, StyleSettings } from "@webiny/website-builder-sdk";
|
|
5
5
|
export type { ComponentProps, ComponentPropsWithChildren, InferManifest, InferComponentChange, InferDescendantChange } from "./types.js";
|
package/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from "./components/index.js";
|
|
2
2
|
export * from "./contentEntry/useContentEntryList.js";
|
|
3
|
-
export { ASPECT_RATIO_PRESETS, CONTROL_VARIANT_ID, DEFAULT_VISITOR_COOKIE, FORCED_VARIANT_PARAM, IMAGE_RESIZE_WIDTHS, StyleSettings, assignVariant, contentSdk, createBooleanInput, createColorInput, createComponent, createContentEntryInput, createDateInput, createElement, createFileInput, createInput, createLexicalInput, createLongTextInput, createNumberInput, createObjectInput, createRadioInput, createSelectInput, createSlotInput, createTagsInput, createTextInput, createTheme, environment, forcedAssignment, getAnalyticsProvider, getAssetCategory, getAssetCropParam, getAssetUrl, getHeadersProvider, getImageDimensions, getImageSrcSet, getPageWithExperiment, normalizeToAsset, registerAnalyticsProvider, registerComponentGroup, resolveVisitorContext, setHeadersProvider } from "@webiny/website-builder-sdk";
|
|
3
|
+
export { ASPECT_RATIO_PRESETS, CONTROL_VARIANT_ID, DEFAULT_VISITOR_COOKIE, FORCED_VARIANT_PARAM, IMAGE_RESIZE_WIDTHS, StyleSettings, assignVariant, contentSdk, createBooleanInput, createColorInput, createComponent, createContentClient, createContentEntryInput, createDateInput, createElement, createFileInput, createInput, createLexicalInput, createLongTextInput, createNumberInput, createObjectInput, createRadioInput, createSelectInput, createSlotInput, createTagsInput, createTextInput, createTheme, environment, forcedAssignment, getAnalyticsProvider, getAssetCategory, getAssetCropParam, getAssetUrl, getDefaultComponentLoader, getHeadersProvider, getImageDimensions, getImageSrcSet, getPageWithExperiment, normalizeToAsset, registerAnalyticsProvider, registerComponentGroup, resolveVisitorContext, setDefaultComponentLoader, setHeadersProvider } from "@webiny/website-builder-sdk";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/website-builder-react",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.676006d08e",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,19 +17,21 @@
|
|
|
17
17
|
],
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@webiny/cms-sdk": "0.0.0-unstable.
|
|
21
|
-
"@webiny/website-builder-sdk": "0.0.0-unstable.
|
|
22
|
-
"
|
|
23
|
-
"mobx": "7.
|
|
24
|
-
"mobx-react-lite": "5.
|
|
25
|
-
"react": "
|
|
26
|
-
"react-dom": "
|
|
20
|
+
"@webiny/cms-sdk": "0.0.0-unstable.676006d08e",
|
|
21
|
+
"@webiny/website-builder-sdk": "0.0.0-unstable.676006d08e",
|
|
22
|
+
"lodash": "4.18.1",
|
|
23
|
+
"mobx": "7.1.7",
|
|
24
|
+
"mobx-react-lite": "5.1.3",
|
|
25
|
+
"react": "19.3.1",
|
|
26
|
+
"react-dom": "19.3.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
29
|
+
"@testing-library/react": "16.3.3",
|
|
30
|
+
"@types/lodash": "4.17.27",
|
|
31
|
+
"@types/react": "19.3.0",
|
|
32
|
+
"@webiny/build-tools": "0.0.0-unstable.676006d08e",
|
|
31
33
|
"typescript": "7.0.2",
|
|
32
|
-
"vitest": "
|
|
34
|
+
"vitest": "5.1.1"
|
|
33
35
|
},
|
|
34
36
|
"publishConfig": {
|
|
35
37
|
"access": "public"
|
package/types.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export type ComponentProps<TInputs = unknown> = {
|
|
|
5
5
|
styles: CssProperties;
|
|
6
6
|
element: DocumentElement;
|
|
7
7
|
breakpoint: string;
|
|
8
|
+
/** The theme's breakpoint names, widest first (`desktop`, `tablet`, `mobile`). */
|
|
9
|
+
breakpoints: string[];
|
|
8
10
|
};
|
|
9
11
|
export type ComponentPropsWithChildren<TInputs = unknown> = ComponentProps<TInputs & {
|
|
10
12
|
children: React.ReactNode;
|