@webiny/website-builder-react 6.6.0-alpha.11 → 6.6.0-alpha.13
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/DocumentStoreProvider.js.map +1 -1
- package/components/DocumentStoreProvider.test.js.map +1 -1
- package/components/ElementIndexProvider.js.map +1 -1
- package/components/ElementRenderer.js.map +1 -1
- package/components/ElementSlotDepthProvider.js.map +1 -1
- package/components/FragmentsProvider.js.map +1 -1
- package/components/GlobalPlacement.js.map +1 -1
- package/components/LayoutAreas.js.map +1 -1
- package/components/PageLayout.js.map +1 -1
- package/components/SlotLabel.js.map +1 -1
- package/components/useBindingsForElement.d.ts +68 -3
- package/components/useDocumentState.js +2 -1
- package/components/useDocumentState.js.map +1 -1
- 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.js.map +1 -1
- package/editorComponents/Image.js.map +1 -1
- package/editorComponents/LayoutContent.js.map +1 -1
- package/editorComponents/LayoutContent.manifest.js.map +1 -1
- package/package.json +9 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/DocumentStoreProvider.js","sources":["../../src/components/DocumentStoreProvider.tsx"],"sourcesContent":["\"use client\";\nimport React, { useContext, useLayoutEffect, useMemo, useRef } from \"react\";\nimport type { DocumentStore } from \"@webiny/website-builder-sdk\";\nimport { type Document } from \"@webiny/website-builder-sdk\";\nimport { useContentClient } from \"./useContentClient.js\";\n\nconst DocumentStoreContext = React.createContext<DocumentStore | undefined>(undefined);\n\nexport const DocumentStoreProvider = ({\n id,\n document,\n children\n}: {\n id: string;\n document?: Document;\n children: React.ReactNode;\n}) => {\n const client = useContentClient();\n const stores = client.getDocumentStoreManager();\n const store = useMemo(() => stores.getStore(id), [stores, id]);\n\n // The document last put into the store (the store keeps an observable copy of it).\n const applied = useRef<Document | undefined>(undefined);\n\n // The first document goes in during render, so the children's first render reads it (nothing\n // has subscribed to the store yet).\n if (document && !store.getDocument()) {\n store.setDocument(document);\n applied.current = document;\n }\n\n // A new document goes in after the render: setting it during render would update the\n // subscribed children while this component renders. Before paint, so the old one never shows.\n useLayoutEffect(() => {\n if (document && document !== applied.current) {\n store.setDocument(document);\n applied.current = document;\n }\n }, [store, document]);\n\n return <DocumentStoreContext.Provider value={store}>{children}</DocumentStoreContext.Provider>;\n};\n\n/**\n * Render children from an existing store, e.g. to switch from a layout back to the page it's rendered around.\n */\nexport const DocumentStoreScope = ({\n store,\n children\n}: {\n store: DocumentStore;\n children: React.ReactNode;\n}) => {\n return <DocumentStoreContext.Provider value={store}>{children}</DocumentStoreContext.Provider>;\n};\n\nexport const useDocumentStore = (): DocumentStore => {\n const store = useContext(DocumentStoreContext);\n if (!store) {\n throw new Error(\"useDocumentStore must be used within a DocumentStoreProvider\");\n }\n return store;\n};\n"],"names":["DocumentStoreContext","React","undefined","DocumentStoreProvider","id","document","children","client","useContentClient","stores","store","useMemo","applied","useRef","useLayoutEffect","DocumentStoreScope","useDocumentStore","useContext","Error"],"mappings":";;;AAMA,MAAMA,uBAAuB,
|
|
1
|
+
{"version":3,"file":"components/DocumentStoreProvider.js","sources":["../../src/components/DocumentStoreProvider.tsx"],"sourcesContent":["\"use client\";\nimport React, { useContext, useLayoutEffect, useMemo, useRef } from \"react\";\nimport type { DocumentStore } from \"@webiny/website-builder-sdk\";\nimport { type Document } from \"@webiny/website-builder-sdk\";\nimport { useContentClient } from \"./useContentClient.js\";\n\nconst DocumentStoreContext = React.createContext<DocumentStore | undefined>(undefined);\n\nexport const DocumentStoreProvider = ({\n id,\n document,\n children\n}: {\n id: string;\n document?: Document;\n children: React.ReactNode;\n}) => {\n const client = useContentClient();\n const stores = client.getDocumentStoreManager();\n const store = useMemo(() => stores.getStore(id), [stores, id]);\n\n // The document last put into the store (the store keeps an observable copy of it).\n const applied = useRef<Document | undefined>(undefined);\n\n // The first document goes in during render, so the children's first render reads it (nothing\n // has subscribed to the store yet).\n if (document && !store.getDocument()) {\n store.setDocument(document);\n applied.current = document;\n }\n\n // A new document goes in after the render: setting it during render would update the\n // subscribed children while this component renders. Before paint, so the old one never shows.\n useLayoutEffect(() => {\n if (document && document !== applied.current) {\n store.setDocument(document);\n applied.current = document;\n }\n }, [store, document]);\n\n return <DocumentStoreContext.Provider value={store}>{children}</DocumentStoreContext.Provider>;\n};\n\n/**\n * Render children from an existing store, e.g. to switch from a layout back to the page it's rendered around.\n */\nexport const DocumentStoreScope = ({\n store,\n children\n}: {\n store: DocumentStore;\n children: React.ReactNode;\n}) => {\n return <DocumentStoreContext.Provider value={store}>{children}</DocumentStoreContext.Provider>;\n};\n\nexport const useDocumentStore = (): DocumentStore => {\n const store = useContext(DocumentStoreContext);\n if (!store) {\n throw new Error(\"useDocumentStore must be used within a DocumentStoreProvider\");\n }\n return store;\n};\n"],"names":["DocumentStoreContext","React","undefined","DocumentStoreProvider","id","document","children","client","useContentClient","stores","store","useMemo","applied","useRef","useLayoutEffect","DocumentStoreScope","useDocumentStore","useContext","Error"],"mappings":";;;AAMA,MAAMA,uBAAuB,WAAvBA,GAAuBC,MAAAA,aAAmB,CAA4BC;AAErE,MAAMC,wBAAwB,CAAC,EAClCC,EAAE,EACFC,QAAQ,EACRC,QAAQ,EAKX;IACG,MAAMC,SAASC;IACf,MAAMC,SAASF,OAAO,uBAAuB;IAC7C,MAAMG,QAAQC,QAAQ,IAAMF,OAAO,QAAQ,CAACL,KAAK;QAACK;QAAQL;KAAG;IAG7D,MAAMQ,UAAUC,OAA6BX;IAI7C,IAAIG,YAAY,CAACK,MAAM,WAAW,IAAI;QAClCA,MAAM,WAAW,CAACL;QAClBO,QAAQ,OAAO,GAAGP;IACtB;IAIAS,gBAAgB;QACZ,IAAIT,YAAYA,aAAaO,QAAQ,OAAO,EAAE;YAC1CF,MAAM,WAAW,CAACL;YAClBO,QAAQ,OAAO,GAAGP;QACtB;IACJ,GAAG;QAACK;QAAOL;KAAS;IAEpB,OAAO,WAAP,GAAO,oBAACL,qBAAqB,QAAQ;QAAC,OAAOU;OAAQJ;AACzD;AAKO,MAAMS,qBAAqB,CAAC,EAC/BL,KAAK,EACLJ,QAAQ,EAIX,GACU,WAAP,GAAO,oBAACN,qBAAqB,QAAQ;QAAC,OAAOU;OAAQJ;AAGlD,MAAMU,mBAAmB;IAC5B,MAAMN,QAAQO,WAAWjB;IACzB,IAAI,CAACU,OACD,MAAM,IAAIQ,MAAM;IAEpB,OAAOR;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/DocumentStoreProvider.test.js","sources":["../../src/components/DocumentStoreProvider.test.tsx"],"sourcesContent":["// @vitest-environment jsdom\nimport React from \"react\";\nimport { act, cleanup, render, screen } from \"@testing-library/react\";\nimport { describe, it, expect, afterEach, vi } from \"vitest\";\nimport { createContentClient, type Document } from \"@webiny/website-builder-sdk\";\nimport { ContentClientProvider } from \"./ContentClientProvider.js\";\nimport { DocumentStoreProvider } from \"./DocumentStoreProvider.js\";\nimport { useDocumentState } from \"./useDocumentState.js\";\n\nconst createDocument = (title: string): Document => {\n return {\n id: \"page-1\",\n version: 1,\n state: { title },\n properties: { id: \"page-1\", path: \"/\" },\n extensions: {},\n metadata: {} as Document[\"metadata\"],\n bindings: {},\n elements: {}\n };\n};\n\nconst Title = () => {\n const state = useDocumentState();\n return <span>{String(state.title)}</span>;\n};\n\ndescribe(\"DocumentStoreProvider\", () => {\n const client = createContentClient({\n apiHost: \"https://a.example.com\",\n apiKey: \"key-a\",\n apiTenant: \"tenant-a\"\n });\n\n const page = (document: Document) => (\n <ContentClientProvider client={client}>\n <DocumentStoreProvider id={\"page-1\"} document={document}>\n <Title />\n </DocumentStoreProvider>\n </ContentClientProvider>\n );\n\n afterEach(() => {\n cleanup();\n vi.restoreAllMocks();\n });\n\n // Regression: the document went into the store during render, so the subscribed children were\n // updated while the provider rendered (React: \"Cannot update a component while rendering a\n // different component\").\n it(\"shows a new document without updating its children during render\", async () => {\n const consoleError = vi.spyOn(console, \"error\");\n const { rerender } = render(page(createDocument(\"First\")));\n expect(screen.getByText(\"First\")).toBeTruthy();\n\n await act(async () => {\n rerender(page(createDocument(\"Second\")));\n });\n\n expect(screen.getByText(\"Second\")).toBeTruthy();\n expect(consoleError).not.toHaveBeenCalled();\n });\n\n it(\"doesn't touch the store when it renders again with the same document\", async () => {\n const document = createDocument(\"Same\");\n const { rerender } = render(page(document));\n const store = client.getDocumentStoreManager().getStore(\"page-1\");\n const setDocument = vi.spyOn(store, \"setDocument\");\n\n await act(async () => {\n rerender(page(document));\n });\n\n expect(setDocument).not.toHaveBeenCalled();\n expect(screen.getByText(\"Same\")).toBeTruthy();\n });\n});\n"],"names":["createDocument","title","Title","state","useDocumentState","String","describe","client","createContentClient","page","document","ContentClientProvider","DocumentStoreProvider","afterEach","cleanup","vi","it","consoleError","console","rerender","render","expect","screen","act","store","setDocument"],"mappings":";;;;;;;AASA,MAAMA,iBAAiB,CAACC,QACb;QACH,IAAI;QACJ,SAAS;QACT,OAAO;YAAEA;QAAM;QACf,YAAY;YAAE,IAAI;YAAU,MAAM;QAAI;QACtC,YAAY,CAAC;QACb,UAAU,CAAC;QACX,UAAU,CAAC;QACX,UAAU,CAAC;IACf;AAGJ,MAAMC,QAAQ;IACV,MAAMC,QAAQC;IACd,OAAO,WAAP,GAAO,oBAAC,cAAMC,OAAOF,MAAM,KAAK;AACpC;AAEAG,SAAS,yBAAyB;IAC9B,MAAMC,SAASC,oBAAoB;QAC/B,SAAS;QACT,QAAQ;QACR,WAAW;IACf;IAEA,MAAMC,OAAO,CAACC,WAAAA,WAAAA,GACV,oBAACC,uBAAqBA;YAAC,QAAQJ;yBAC3B,oBAACK,uBAAqBA;YAAC,IAAI;YAAU,UAAUF;yBAC3C,oBAACR,
|
|
1
|
+
{"version":3,"file":"components/DocumentStoreProvider.test.js","sources":["../../src/components/DocumentStoreProvider.test.tsx"],"sourcesContent":["// @vitest-environment jsdom\nimport React from \"react\";\nimport { act, cleanup, render, screen } from \"@testing-library/react\";\nimport { describe, it, expect, afterEach, vi } from \"vitest\";\nimport { createContentClient, type Document } from \"@webiny/website-builder-sdk\";\nimport { ContentClientProvider } from \"./ContentClientProvider.js\";\nimport { DocumentStoreProvider } from \"./DocumentStoreProvider.js\";\nimport { useDocumentState } from \"./useDocumentState.js\";\n\nconst createDocument = (title: string): Document => {\n return {\n id: \"page-1\",\n version: 1,\n state: { title },\n properties: { id: \"page-1\", path: \"/\" },\n extensions: {},\n metadata: {} as Document[\"metadata\"],\n bindings: {},\n elements: {}\n };\n};\n\nconst Title = () => {\n const state = useDocumentState();\n return <span>{String(state.title)}</span>;\n};\n\ndescribe(\"DocumentStoreProvider\", () => {\n const client = createContentClient({\n apiHost: \"https://a.example.com\",\n apiKey: \"key-a\",\n apiTenant: \"tenant-a\"\n });\n\n const page = (document: Document) => (\n <ContentClientProvider client={client}>\n <DocumentStoreProvider id={\"page-1\"} document={document}>\n <Title />\n </DocumentStoreProvider>\n </ContentClientProvider>\n );\n\n afterEach(() => {\n cleanup();\n vi.restoreAllMocks();\n });\n\n // Regression: the document went into the store during render, so the subscribed children were\n // updated while the provider rendered (React: \"Cannot update a component while rendering a\n // different component\").\n it(\"shows a new document without updating its children during render\", async () => {\n const consoleError = vi.spyOn(console, \"error\");\n const { rerender } = render(page(createDocument(\"First\")));\n expect(screen.getByText(\"First\")).toBeTruthy();\n\n await act(async () => {\n rerender(page(createDocument(\"Second\")));\n });\n\n expect(screen.getByText(\"Second\")).toBeTruthy();\n expect(consoleError).not.toHaveBeenCalled();\n });\n\n it(\"doesn't touch the store when it renders again with the same document\", async () => {\n const document = createDocument(\"Same\");\n const { rerender } = render(page(document));\n const store = client.getDocumentStoreManager().getStore(\"page-1\");\n const setDocument = vi.spyOn(store, \"setDocument\");\n\n await act(async () => {\n rerender(page(document));\n });\n\n expect(setDocument).not.toHaveBeenCalled();\n expect(screen.getByText(\"Same\")).toBeTruthy();\n });\n});\n"],"names":["createDocument","title","Title","state","useDocumentState","String","describe","client","createContentClient","page","document","ContentClientProvider","DocumentStoreProvider","afterEach","cleanup","vi","it","consoleError","console","rerender","render","expect","screen","act","store","setDocument"],"mappings":";;;;;;;AASA,MAAMA,iBAAiB,CAACC,QACb;QACH,IAAI;QACJ,SAAS;QACT,OAAO;YAAEA;QAAM;QACf,YAAY;YAAE,IAAI;YAAU,MAAM;QAAI;QACtC,YAAY,CAAC;QACb,UAAU,CAAC;QACX,UAAU,CAAC;QACX,UAAU,CAAC;IACf;AAGJ,MAAMC,QAAQ;IACV,MAAMC,QAAQC;IACd,OAAO,WAAP,GAAO,oBAAC,cAAMC,OAAOF,MAAM,KAAK;AACpC;AAEAG,SAAS,yBAAyB;IAC9B,MAAMC,SAASC,oBAAoB;QAC/B,SAAS;QACT,QAAQ;QACR,WAAW;IACf;IAEA,MAAMC,OAAO,CAACC,WAAAA,WAAAA,GACV,oBAACC,uBAAqBA;YAAC,QAAQJ;yBAC3B,oBAACK,uBAAqBA;YAAC,IAAI;YAAU,UAAUF;yBAC3C,oBAACR,OAAAA;IAKbW,UAAU;QACNC;QACAC,GAAG,eAAe;IACtB;IAKAC,GAAG,oEAAoE;QACnE,MAAMC,eAAeF,GAAG,KAAK,CAACG,SAAS;QACvC,MAAM,EAAEC,QAAQ,EAAE,GAAGC,OAAOX,KAAKT,eAAe;QAChDqB,OAAOC,OAAO,SAAS,CAAC,UAAU,UAAU;QAE5C,MAAMC,IAAI;YACNJ,SAASV,KAAKT,eAAe;QACjC;QAEAqB,OAAOC,OAAO,SAAS,CAAC,WAAW,UAAU;QAC7CD,OAAOJ,cAAc,GAAG,CAAC,gBAAgB;IAC7C;IAEAD,GAAG,wEAAwE;QACvE,MAAMN,WAAWV,eAAe;QAChC,MAAM,EAAEmB,QAAQ,EAAE,GAAGC,OAAOX,KAAKC;QACjC,MAAMc,QAAQjB,OAAO,uBAAuB,GAAG,QAAQ,CAAC;QACxD,MAAMkB,cAAcV,GAAG,KAAK,CAACS,OAAO;QAEpC,MAAMD,IAAI;YACNJ,SAASV,KAAKC;QAClB;QAEAW,OAAOI,aAAa,GAAG,CAAC,gBAAgB;QACxCJ,OAAOC,OAAO,SAAS,CAAC,SAAS,UAAU;IAC/C;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/ElementIndexProvider.js","sources":["../../src/components/ElementIndexProvider.tsx"],"sourcesContent":["\"use client\";\nimport React from \"react\";\n\nconst ElementIndexContext = React.createContext<number>(0);\n\ninterface ElementIndexProviderProps {\n index: number;\n children: React.ReactNode;\n}\n\nexport const ElementIndexProvider = ({ children, index }: ElementIndexProviderProps) => {\n return <ElementIndexContext.Provider value={index}>{children}</ElementIndexContext.Provider>;\n};\n\nexport const useElementIndex = () => {\n const context = React.useContext(ElementIndexContext);\n\n return context ?? 0;\n};\n"],"names":["ElementIndexContext","React","ElementIndexProvider","children","index","useElementIndex","context"],"mappings":";;AAGA,MAAMA,sBAAsB,
|
|
1
|
+
{"version":3,"file":"components/ElementIndexProvider.js","sources":["../../src/components/ElementIndexProvider.tsx"],"sourcesContent":["\"use client\";\nimport React from \"react\";\n\nconst ElementIndexContext = React.createContext<number>(0);\n\ninterface ElementIndexProviderProps {\n index: number;\n children: React.ReactNode;\n}\n\nexport const ElementIndexProvider = ({ children, index }: ElementIndexProviderProps) => {\n return <ElementIndexContext.Provider value={index}>{children}</ElementIndexContext.Provider>;\n};\n\nexport const useElementIndex = () => {\n const context = React.useContext(ElementIndexContext);\n\n return context ?? 0;\n};\n"],"names":["ElementIndexContext","React","ElementIndexProvider","children","index","useElementIndex","context"],"mappings":";;AAGA,MAAMA,sBAAsB,WAAtBA,GAAsBC,MAAAA,aAAmB,CAAS;AAOjD,MAAMC,uBAAuB,CAAC,EAAEC,QAAQ,EAAEC,KAAK,EAA6B,GACxE,WAAP,GAAO,oBAACJ,oBAAoB,QAAQ;QAAC,OAAOI;OAAQD;AAGjD,MAAME,kBAAkB;IAC3B,MAAMC,UAAUL,MAAAA,UAAgB,CAACD;IAEjC,OAAOM,WAAW;AACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/ElementRenderer.js","sources":["../../src/components/ElementRenderer.tsx"],"sourcesContent":["\"use client\";\nimport React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { environment, GlobalElementId } from \"@webiny/website-builder-sdk\";\nimport { EditingElementRenderer } from \"./EditingElementRenderer/EditingElementRenderer.js\";\nimport { LiveElementRenderer } from \"./LiveElementRenderer.js\";\nimport { useDocumentStore } from \"./DocumentStoreProvider.js\";\nimport { PageScope, useIsReadOnlyScope, usePageLayout } from \"./PageLayout.js\";\nimport { GlobalPlacement } from \"./GlobalPlacement.js\";\nimport { useContentClient } from \"./useContentClient.js\";\n\ninterface ElementRendererProps {\n id: string;\n}\n\nexport const ElementRenderer = observer((props: ElementRendererProps) => {\n const documentStore = useDocumentStore();\n const client = useContentClient();\n const pageLayout = usePageLayout();\n const readOnly = useIsReadOnlyScope();\n const isEditing = environment.isEditing() && !readOnly;\n\n // A global's instance comes with the page, also when a layout renders it.\n if (pageLayout && GlobalElementId.isGlobal(props.id)) {\n return (\n <PageScope>\n <ElementRenderer id={props.id} />\n </PageScope>\n );\n }\n\n const element = documentStore.getElement(props.id);\n\n if (!element) {\n return null;\n }\n\n if (GlobalElementId.isPlacement(element, client.getComponentManifests())) {\n return <GlobalPlacement placement={element} />;\n }\n\n // A layout's root only holds the page: on the page, there's nothing to select. Its content areas can\n // be selected, like the layout's other elements, to show where each of the page's areas sits.\n const isLayoutRoot = pageLayout && props.id === \"root\";\n\n if (isEditing && !isLayoutRoot) {\n return <EditingElementRenderer element={element} />;\n } else {\n return <LiveElementRenderer element={element} />;\n }\n});\n"],"names":["ElementRenderer","observer","props","documentStore","useDocumentStore","client","useContentClient","pageLayout","usePageLayout","readOnly","useIsReadOnlyScope","isEditing","environment","GlobalElementId","PageScope","element","GlobalPlacement","isLayoutRoot","EditingElementRenderer","LiveElementRenderer"],"mappings":";;;;;;;;;;AAeO,MAAMA,kBAAkBC,SAAS,CAACC;IACrC,MAAMC,gBAAgBC;IACtB,MAAMC,SAASC;IACf,MAAMC,aAAaC;IACnB,MAAMC,WAAWC;IACjB,MAAMC,YAAYC,YAAY,SAAS,MAAM,CAACH;IAG9C,IAAIF,cAAcM,gBAAgB,QAAQ,CAACX,MAAM,EAAE,GAC/C,OAAO,WAAP,GACI,oBAACY,WAASA,MAAAA,WAAAA,GACN,oBAACd,
|
|
1
|
+
{"version":3,"file":"components/ElementRenderer.js","sources":["../../src/components/ElementRenderer.tsx"],"sourcesContent":["\"use client\";\nimport React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { environment, GlobalElementId } from \"@webiny/website-builder-sdk\";\nimport { EditingElementRenderer } from \"./EditingElementRenderer/EditingElementRenderer.js\";\nimport { LiveElementRenderer } from \"./LiveElementRenderer.js\";\nimport { useDocumentStore } from \"./DocumentStoreProvider.js\";\nimport { PageScope, useIsReadOnlyScope, usePageLayout } from \"./PageLayout.js\";\nimport { GlobalPlacement } from \"./GlobalPlacement.js\";\nimport { useContentClient } from \"./useContentClient.js\";\n\ninterface ElementRendererProps {\n id: string;\n}\n\nexport const ElementRenderer = observer((props: ElementRendererProps) => {\n const documentStore = useDocumentStore();\n const client = useContentClient();\n const pageLayout = usePageLayout();\n const readOnly = useIsReadOnlyScope();\n const isEditing = environment.isEditing() && !readOnly;\n\n // A global's instance comes with the page, also when a layout renders it.\n if (pageLayout && GlobalElementId.isGlobal(props.id)) {\n return (\n <PageScope>\n <ElementRenderer id={props.id} />\n </PageScope>\n );\n }\n\n const element = documentStore.getElement(props.id);\n\n if (!element) {\n return null;\n }\n\n if (GlobalElementId.isPlacement(element, client.getComponentManifests())) {\n return <GlobalPlacement placement={element} />;\n }\n\n // A layout's root only holds the page: on the page, there's nothing to select. Its content areas can\n // be selected, like the layout's other elements, to show where each of the page's areas sits.\n const isLayoutRoot = pageLayout && props.id === \"root\";\n\n if (isEditing && !isLayoutRoot) {\n return <EditingElementRenderer element={element} />;\n } else {\n return <LiveElementRenderer element={element} />;\n }\n});\n"],"names":["ElementRenderer","observer","props","documentStore","useDocumentStore","client","useContentClient","pageLayout","usePageLayout","readOnly","useIsReadOnlyScope","isEditing","environment","GlobalElementId","PageScope","element","GlobalPlacement","isLayoutRoot","EditingElementRenderer","LiveElementRenderer"],"mappings":";;;;;;;;;;AAeO,MAAMA,kBAAkBC,SAAS,CAACC;IACrC,MAAMC,gBAAgBC;IACtB,MAAMC,SAASC;IACf,MAAMC,aAAaC;IACnB,MAAMC,WAAWC;IACjB,MAAMC,YAAYC,YAAY,SAAS,MAAM,CAACH;IAG9C,IAAIF,cAAcM,gBAAgB,QAAQ,CAACX,MAAM,EAAE,GAC/C,OAAO,WAAP,GACI,oBAACY,WAASA,MAAAA,WAAAA,GACN,oBAACd,iBAAAA;QAAgB,IAAIE,MAAM,EAAE;;IAKzC,MAAMa,UAAUZ,cAAc,UAAU,CAACD,MAAM,EAAE;IAEjD,IAAI,CAACa,SACD,OAAO;IAGX,IAAIF,gBAAgB,WAAW,CAACE,SAASV,OAAO,qBAAqB,KACjE,OAAO,WAAP,GAAO,oBAACW,iBAAeA;QAAC,WAAWD;;IAKvC,MAAME,eAAeV,cAAcL,AAAa,WAAbA,MAAM,EAAE;IAE3C,IAAIS,aAAa,CAACM,cACd,OAAO,WAAP,GAAO,oBAACC,wBAAsBA;QAAC,SAASH;;SAExC,OAAO,WAAP,GAAO,oBAACI,qBAAmBA;QAAC,SAASJ;;AAE7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/ElementSlotDepthProvider.js","sources":["../../src/components/ElementSlotDepthProvider.tsx"],"sourcesContent":["\"use client\";\nimport React from \"react\";\n\nconst ElementSlotDepthContext = React.createContext<number>(0);\n\ninterface ElementSlotDepthProviderProps {\n depth: number;\n children: React.ReactNode;\n}\n\nexport const ElementSlotDepthProvider = ({ children, depth }: ElementSlotDepthProviderProps) => {\n return (\n <ElementSlotDepthContext.Provider value={depth}>\n {children}\n </ElementSlotDepthContext.Provider>\n );\n};\n\nexport const useElementSlotDepth = () => {\n const context = React.useContext(ElementSlotDepthContext);\n\n return context ?? 0;\n};\n"],"names":["ElementSlotDepthContext","React","ElementSlotDepthProvider","children","depth","useElementSlotDepth","context"],"mappings":";;AAGA,MAAMA,0BAA0B,
|
|
1
|
+
{"version":3,"file":"components/ElementSlotDepthProvider.js","sources":["../../src/components/ElementSlotDepthProvider.tsx"],"sourcesContent":["\"use client\";\nimport React from \"react\";\n\nconst ElementSlotDepthContext = React.createContext<number>(0);\n\ninterface ElementSlotDepthProviderProps {\n depth: number;\n children: React.ReactNode;\n}\n\nexport const ElementSlotDepthProvider = ({ children, depth }: ElementSlotDepthProviderProps) => {\n return (\n <ElementSlotDepthContext.Provider value={depth}>\n {children}\n </ElementSlotDepthContext.Provider>\n );\n};\n\nexport const useElementSlotDepth = () => {\n const context = React.useContext(ElementSlotDepthContext);\n\n return context ?? 0;\n};\n"],"names":["ElementSlotDepthContext","React","ElementSlotDepthProvider","children","depth","useElementSlotDepth","context"],"mappings":";;AAGA,MAAMA,0BAA0B,WAA1BA,GAA0BC,MAAAA,aAAmB,CAAS;AAOrD,MAAMC,2BAA2B,CAAC,EAAEC,QAAQ,EAAEC,KAAK,EAAiC,GAChF,WAAP,GACI,oBAACJ,wBAAwB,QAAQ;QAAC,OAAOI;OACpCD;AAKN,MAAME,sBAAsB;IAC/B,MAAMC,UAAUL,MAAAA,UAAgB,CAACD;IAEjC,OAAOM,WAAW;AACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/FragmentsProvider.js","sources":["../../src/components/FragmentsProvider.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect } from \"react\";\nimport { useContentClient } from \"./useContentClient.js\";\n\ntype FragmentConfig =\n | {\n type: \"fixed\";\n name: string;\n element: React.ReactNode;\n }\n | { type: \"component\"; component: string; inputs: Record<string, any> };\n\nexport type DocumentFragments = FragmentConfig[];\n\nconst FragmentsContext = React.createContext<DocumentFragments | undefined>(undefined);\n\ninterface FragmentsProviderProps {\n fragments: DocumentFragments;\n children: React.ReactNode;\n}\n\nexport const FragmentsProvider = ({ fragments, children }: FragmentsProviderProps) => {\n const client = useContentClient();\n\n useEffect(() => {\n if (client.isEditing()) {\n // Extract serializable data\n const fragmentsData = fragments.map(fragment => {\n if (fragment.type === \"fixed\") {\n return {\n type: \"fixed\",\n name: fragment.name\n };\n }\n\n return {\n type: \"component\",\n component: fragment.component,\n inputs: fragment.inputs\n };\n });\n\n client\n .getEditingSdk()!\n .messenger.send(\"document.fragments\", { fragments: fragmentsData });\n }\n }, [fragments.length]);\n\n return <FragmentsContext.Provider value={fragments}>{children}</FragmentsContext.Provider>;\n};\n\nexport const useDocumentFragments = () => {\n const context = React.useContext(FragmentsContext);\n if (!context) {\n return [];\n }\n\n return context;\n};\n"],"names":["FragmentsContext","React","undefined","FragmentsProvider","fragments","children","client","useContentClient","useEffect","fragmentsData","fragment","useDocumentFragments","context"],"mappings":";;;AAcA,MAAMA,mBAAmB,
|
|
1
|
+
{"version":3,"file":"components/FragmentsProvider.js","sources":["../../src/components/FragmentsProvider.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect } from \"react\";\nimport { useContentClient } from \"./useContentClient.js\";\n\ntype FragmentConfig =\n | {\n type: \"fixed\";\n name: string;\n element: React.ReactNode;\n }\n | { type: \"component\"; component: string; inputs: Record<string, any> };\n\nexport type DocumentFragments = FragmentConfig[];\n\nconst FragmentsContext = React.createContext<DocumentFragments | undefined>(undefined);\n\ninterface FragmentsProviderProps {\n fragments: DocumentFragments;\n children: React.ReactNode;\n}\n\nexport const FragmentsProvider = ({ fragments, children }: FragmentsProviderProps) => {\n const client = useContentClient();\n\n useEffect(() => {\n if (client.isEditing()) {\n // Extract serializable data\n const fragmentsData = fragments.map(fragment => {\n if (fragment.type === \"fixed\") {\n return {\n type: \"fixed\",\n name: fragment.name\n };\n }\n\n return {\n type: \"component\",\n component: fragment.component,\n inputs: fragment.inputs\n };\n });\n\n client\n .getEditingSdk()!\n .messenger.send(\"document.fragments\", { fragments: fragmentsData });\n }\n }, [fragments.length]);\n\n return <FragmentsContext.Provider value={fragments}>{children}</FragmentsContext.Provider>;\n};\n\nexport const useDocumentFragments = () => {\n const context = React.useContext(FragmentsContext);\n if (!context) {\n return [];\n }\n\n return context;\n};\n"],"names":["FragmentsContext","React","undefined","FragmentsProvider","fragments","children","client","useContentClient","useEffect","fragmentsData","fragment","useDocumentFragments","context"],"mappings":";;;AAcA,MAAMA,mBAAmB,WAAnBA,GAAmBC,MAAAA,aAAmB,CAAgCC;AAOrE,MAAMC,oBAAoB,CAAC,EAAEC,SAAS,EAAEC,QAAQ,EAA0B;IAC7E,MAAMC,SAASC;IAEfC,UAAU;QACN,IAAIF,OAAO,SAAS,IAAI;YAEpB,MAAMG,gBAAgBL,UAAU,GAAG,CAACM,CAAAA;gBAChC,IAAIA,AAAkB,YAAlBA,SAAS,IAAI,EACb,OAAO;oBACH,MAAM;oBACN,MAAMA,SAAS,IAAI;gBACvB;gBAGJ,OAAO;oBACH,MAAM;oBACN,WAAWA,SAAS,SAAS;oBAC7B,QAAQA,SAAS,MAAM;gBAC3B;YACJ;YAEAJ,OACK,aAAa,GACb,SAAS,CAAC,IAAI,CAAC,sBAAsB;gBAAE,WAAWG;YAAc;QACzE;IACJ,GAAG;QAACL,UAAU,MAAM;KAAC;IAErB,OAAO,WAAP,GAAO,oBAACJ,iBAAiB,QAAQ;QAAC,OAAOI;OAAYC;AACzD;AAEO,MAAMM,uBAAuB;IAChC,MAAMC,UAAUX,MAAAA,UAAgB,CAACD;IACjC,IAAI,CAACY,SACD,OAAO,EAAE;IAGb,OAAOA;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/GlobalPlacement.js","sources":["../../src/components/GlobalPlacement.tsx"],"sourcesContent":["\"use client\";\nimport React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { type DocumentElement, environment, GlobalElementId } from \"@webiny/website-builder-sdk\";\nimport { EditingElementRenderer } from \"./EditingElementRenderer/EditingElementRenderer.js\";\nimport { LiveElementRenderer } from \"./LiveElementRenderer.js\";\nimport { useDocumentStore } from \"./DocumentStoreProvider.js\";\nimport { PageScope, useIsReadOnlyScope } from \"./PageLayout.js\";\n\ninterface GlobalPlacementProps {\n placement: DocumentElement;\n}\n\nconst PlacedInstance = observer(({ placement }: GlobalPlacementProps) => {\n const documentStore = useDocumentStore();\n const readOnly = useIsReadOnlyScope();\n const instance = documentStore.getElement(\n GlobalElementId.fromName(placement.component.name).toString()\n );\n\n if (!instance) {\n return null;\n }\n\n // In the editor, the placement is what's selected, moved and deleted; it shows the instance's values.\n if (environment.isEditing() && !readOnly) {\n return <EditingElementRenderer element={placement} instance={instance} />;\n }\n\n return <LiveElementRenderer element={instance} />;\n});\n\n/**\n * Render a placement of a global component: the global's single instance, at the placement's place.\n * In a layout rendered around a page, the instance comes with the page.\n */\nexport const GlobalPlacement = ({ placement }: GlobalPlacementProps) => {\n return (\n <PageScope>\n <PlacedInstance placement={placement} />\n </PageScope>\n );\n};\n"],"names":["PlacedInstance","observer","placement","documentStore","useDocumentStore","readOnly","useIsReadOnlyScope","instance","GlobalElementId","environment","EditingElementRenderer","LiveElementRenderer","GlobalPlacement","PageScope"],"mappings":";;;;;;;;AAaA,MAAMA,iBAAiBC,SAAS,CAAC,EAAEC,SAAS,EAAwB;IAChE,MAAMC,gBAAgBC;IACtB,MAAMC,WAAWC;IACjB,MAAMC,WAAWJ,cAAc,UAAU,CACrCK,gBAAgB,QAAQ,CAACN,UAAU,SAAS,CAAC,IAAI,EAAE,QAAQ;IAG/D,IAAI,CAACK,UACD,OAAO;IAIX,IAAIE,YAAY,SAAS,MAAM,CAACJ,UAC5B,OAAO,WAAP,GAAO,oBAACK,wBAAsBA;QAAC,SAASR;QAAW,UAAUK;;IAGjE,OAAO,WAAP,GAAO,oBAACI,qBAAmBA;QAAC,SAASJ;;AACzC;AAMO,MAAMK,kBAAkB,CAAC,EAAEV,SAAS,EAAwB,GACxD,WAAP,GACI,oBAACW,WAASA,MAAAA,WAAAA,GACN,oBAACb,
|
|
1
|
+
{"version":3,"file":"components/GlobalPlacement.js","sources":["../../src/components/GlobalPlacement.tsx"],"sourcesContent":["\"use client\";\nimport React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { type DocumentElement, environment, GlobalElementId } from \"@webiny/website-builder-sdk\";\nimport { EditingElementRenderer } from \"./EditingElementRenderer/EditingElementRenderer.js\";\nimport { LiveElementRenderer } from \"./LiveElementRenderer.js\";\nimport { useDocumentStore } from \"./DocumentStoreProvider.js\";\nimport { PageScope, useIsReadOnlyScope } from \"./PageLayout.js\";\n\ninterface GlobalPlacementProps {\n placement: DocumentElement;\n}\n\nconst PlacedInstance = observer(({ placement }: GlobalPlacementProps) => {\n const documentStore = useDocumentStore();\n const readOnly = useIsReadOnlyScope();\n const instance = documentStore.getElement(\n GlobalElementId.fromName(placement.component.name).toString()\n );\n\n if (!instance) {\n return null;\n }\n\n // In the editor, the placement is what's selected, moved and deleted; it shows the instance's values.\n if (environment.isEditing() && !readOnly) {\n return <EditingElementRenderer element={placement} instance={instance} />;\n }\n\n return <LiveElementRenderer element={instance} />;\n});\n\n/**\n * Render a placement of a global component: the global's single instance, at the placement's place.\n * In a layout rendered around a page, the instance comes with the page.\n */\nexport const GlobalPlacement = ({ placement }: GlobalPlacementProps) => {\n return (\n <PageScope>\n <PlacedInstance placement={placement} />\n </PageScope>\n );\n};\n"],"names":["PlacedInstance","observer","placement","documentStore","useDocumentStore","readOnly","useIsReadOnlyScope","instance","GlobalElementId","environment","EditingElementRenderer","LiveElementRenderer","GlobalPlacement","PageScope"],"mappings":";;;;;;;;AAaA,MAAMA,iBAAiBC,SAAS,CAAC,EAAEC,SAAS,EAAwB;IAChE,MAAMC,gBAAgBC;IACtB,MAAMC,WAAWC;IACjB,MAAMC,WAAWJ,cAAc,UAAU,CACrCK,gBAAgB,QAAQ,CAACN,UAAU,SAAS,CAAC,IAAI,EAAE,QAAQ;IAG/D,IAAI,CAACK,UACD,OAAO;IAIX,IAAIE,YAAY,SAAS,MAAM,CAACJ,UAC5B,OAAO,WAAP,GAAO,oBAACK,wBAAsBA;QAAC,SAASR;QAAW,UAAUK;;IAGjE,OAAO,WAAP,GAAO,oBAACI,qBAAmBA;QAAC,SAASJ;;AACzC;AAMO,MAAMK,kBAAkB,CAAC,EAAEV,SAAS,EAAwB,GACxD,WAAP,GACI,oBAACW,WAASA,MAAAA,WAAAA,GACN,oBAACb,gBAAAA;QAAe,WAAWE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/LayoutAreas.js","sources":["../../src/components/LayoutAreas.tsx"],"sourcesContent":["\"use client\";\nimport React, { useContext } from \"react\";\nimport type { LayoutContentArea } from \"@webiny/website-builder-sdk\";\n\nexport interface LayoutAreasValue {\n // What goes in the layout's Main content.\n main: React.ReactNode;\n // What goes in each named content area, by the area's name.\n areas: Record<string, React.ReactNode>;\n}\n\nconst LayoutAreasContext = React.createContext<LayoutAreasValue | undefined>(undefined);\n\n/**\n * Set while <LayoutRenderer> renders a layout around content from code (e.g. a CMS entry): its content areas\n * render that content, not a page's.\n */\nexport const LayoutAreasProvider = ({\n value,\n children\n}: {\n value: LayoutAreasValue | undefined;\n children: React.ReactNode;\n}) => {\n return <LayoutAreasContext.Provider value={value}>{children}</LayoutAreasContext.Provider>;\n};\n\nexport const useLayoutAreas = () => {\n return useContext(LayoutAreasContext);\n};\n\n/**\n * The content of one area. An area with no name, or a name nothing was given for, stays empty.\n */\nexport const getLayoutAreaContent = (value: LayoutAreasValue, area: LayoutContentArea) => {\n if (area.isMain()) {\n return value.main;\n }\n\n const name = area.name();\n return name ? (value.areas[name] ?? null) : null;\n};\n"],"names":["LayoutAreasContext","React","undefined","LayoutAreasProvider","value","children","useLayoutAreas","useContext","getLayoutAreaContent","area","name"],"mappings":";;AAWA,MAAMA,qBAAqB,
|
|
1
|
+
{"version":3,"file":"components/LayoutAreas.js","sources":["../../src/components/LayoutAreas.tsx"],"sourcesContent":["\"use client\";\nimport React, { useContext } from \"react\";\nimport type { LayoutContentArea } from \"@webiny/website-builder-sdk\";\n\nexport interface LayoutAreasValue {\n // What goes in the layout's Main content.\n main: React.ReactNode;\n // What goes in each named content area, by the area's name.\n areas: Record<string, React.ReactNode>;\n}\n\nconst LayoutAreasContext = React.createContext<LayoutAreasValue | undefined>(undefined);\n\n/**\n * Set while <LayoutRenderer> renders a layout around content from code (e.g. a CMS entry): its content areas\n * render that content, not a page's.\n */\nexport const LayoutAreasProvider = ({\n value,\n children\n}: {\n value: LayoutAreasValue | undefined;\n children: React.ReactNode;\n}) => {\n return <LayoutAreasContext.Provider value={value}>{children}</LayoutAreasContext.Provider>;\n};\n\nexport const useLayoutAreas = () => {\n return useContext(LayoutAreasContext);\n};\n\n/**\n * The content of one area. An area with no name, or a name nothing was given for, stays empty.\n */\nexport const getLayoutAreaContent = (value: LayoutAreasValue, area: LayoutContentArea) => {\n if (area.isMain()) {\n return value.main;\n }\n\n const name = area.name();\n return name ? (value.areas[name] ?? null) : null;\n};\n"],"names":["LayoutAreasContext","React","undefined","LayoutAreasProvider","value","children","useLayoutAreas","useContext","getLayoutAreaContent","area","name"],"mappings":";;AAWA,MAAMA,qBAAqB,WAArBA,GAAqBC,MAAAA,aAAmB,CAA+BC;AAMtE,MAAMC,sBAAsB,CAAC,EAChCC,KAAK,EACLC,QAAQ,EAIX,GACU,WAAP,GAAO,oBAACL,mBAAmB,QAAQ;QAAC,OAAOI;OAAQC;AAGhD,MAAMC,iBAAiB,IACnBC,WAAWP;AAMf,MAAMQ,uBAAuB,CAACJ,OAAyBK;IAC1D,IAAIA,KAAK,MAAM,IACX,OAAOL,MAAM,IAAI;IAGrB,MAAMM,OAAOD,KAAK,IAAI;IACtB,OAAOC,OAAQN,MAAM,KAAK,CAACM,KAAK,IAAI,OAAQ;AAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/PageLayout.js","sources":["../../src/components/PageLayout.tsx"],"sourcesContent":["\"use client\";\nimport React, { useContext, useMemo } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { toJS } from \"mobx\";\nimport type {\n Document,\n DocumentStore,\n PageLayout as PageLayoutData\n} from \"@webiny/website-builder-sdk\";\nimport { DocumentStoreScope, useDocumentStore } from \"./DocumentStoreProvider.js\";\nimport { ElementRenderer } from \"./ElementRenderer.js\";\nimport { useSeededDocumentStore } from \"./useSeededDocumentStore.js\";\nimport { type DocumentLayout, renderWithLayout } from \"./renderWithLayout.js\";\n\ninterface PageLayoutContextValue {\n // The store of the page the layout is rendered around.\n pageStore: DocumentStore;\n}\n\nconst PageLayoutContext = React.createContext<PageLayoutContextValue | undefined>(undefined);\n\n/**\n * Set while rendering the elements of a page's layout. They belong to the layout, not to the page: in the\n * page editor, they can be selected (to override their inputs on the page), but not moved or dropped into.\n */\nexport const usePageLayout = () => {\n return useContext(PageLayoutContext);\n};\n\n/**\n * Render from the page again, from within its layout: the page content, and the instances of the global\n * components the layout places (they come with the page, and the page editor edits them there).\n */\nexport const PageScope = ({ children }: { children: React.ReactNode }) => {\n const pageLayout = usePageLayout();\n if (!pageLayout) {\n return <>{children}</>;\n }\n\n return (\n <PageLayoutContext.Provider value={undefined}>\n <DocumentStoreScope store={pageLayout.pageStore}>{children}</DocumentStoreScope>\n </PageLayoutContext.Provider>\n );\n};\n\nconst ReadOnlyContext = React.createContext(false);\n\n/**\n * Everything inside renders as on the live site, even in the editor: it can't be selected or dropped into\n * (e.g., the page previewed inside a layout in the layout editor).\n */\nexport const ReadOnlyScope = ({ children }: { children: React.ReactNode }) => {\n return <ReadOnlyContext.Provider value={true}>{children}</ReadOnlyContext.Provider>;\n};\n\nexport const useIsReadOnlyScope = () => {\n return useContext(ReadOnlyContext);\n};\n\n/**\n * The layout comes complete: on the live site the backend merges the page's overrides of the layout's\n * elements into it, and the page editor sends it to the preview the same way.\n */\nconst toLayoutDocument = (layout: PageLayoutData): Document => {\n return {\n id: layout.id,\n version: 1,\n state: {},\n properties: { id: layout.id },\n metadata: { documentType: \"layout\" },\n extensions: {},\n elements: layout.elements ?? {},\n bindings: layout.bindings ?? {}\n };\n};\n\nconst PageLayoutRenderer = ({ layoutJson }: { layoutJson: string }) => {\n const pageStore = useDocumentStore();\n const context = useMemo(() => ({ pageStore }), [pageStore]);\n // The layout comes with the page's overrides merged in, so it is different for every page: each render\n // gets its own store, never one shared by layout id across pages (or across requests on the server).\n const document = useMemo<Document>(() => JSON.parse(layoutJson), [layoutJson]);\n // A changed layout (e.g. patched in the page editor) goes into the same store.\n const layoutStore = useSeededDocumentStore(document);\n\n return (\n <PageLayoutContext.Provider value={context}>\n <DocumentStoreScope store={layoutStore}>\n <ElementRenderer id={\"root\"} />\n </DocumentStoreScope>\n </PageLayoutContext.Provider>\n );\n};\n\n/**\n * Render the page in its layout: the one picked in the page settings, built in the layout editor, or\n * else the `layout` the frontend passes to <DocumentRenderer>.\n */\nexport const PageWithLayout = observer(({ layout }: { layout?: DocumentLayout }) => {\n const pageStore = useDocumentStore();\n const page = pageStore.getDocument();\n // In the page editor, the layout is patched in place: reading all of it re-renders on any change.\n const layoutJson = page?.layout ? JSON.stringify(toLayoutDocument(toJS(page.layout))) : null;\n\n if (layoutJson) {\n return <PageLayoutRenderer layoutJson={layoutJson} />;\n }\n\n return renderWithLayout(<ElementRenderer id={\"root\"} />, layout);\n});\n"],"names":["PageLayoutContext","React","undefined","usePageLayout","useContext","PageScope","children","pageLayout","DocumentStoreScope","ReadOnlyContext","ReadOnlyScope","useIsReadOnlyScope","toLayoutDocument","layout","PageLayoutRenderer","layoutJson","pageStore","useDocumentStore","context","useMemo","document","JSON","layoutStore","useSeededDocumentStore","ElementRenderer","PageWithLayout","observer","page","toJS","renderWithLayout"],"mappings":";;;;;;;;AAmBA,MAAMA,oBAAoB,
|
|
1
|
+
{"version":3,"file":"components/PageLayout.js","sources":["../../src/components/PageLayout.tsx"],"sourcesContent":["\"use client\";\nimport React, { useContext, useMemo } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { toJS } from \"mobx\";\nimport type {\n Document,\n DocumentStore,\n PageLayout as PageLayoutData\n} from \"@webiny/website-builder-sdk\";\nimport { DocumentStoreScope, useDocumentStore } from \"./DocumentStoreProvider.js\";\nimport { ElementRenderer } from \"./ElementRenderer.js\";\nimport { useSeededDocumentStore } from \"./useSeededDocumentStore.js\";\nimport { type DocumentLayout, renderWithLayout } from \"./renderWithLayout.js\";\n\ninterface PageLayoutContextValue {\n // The store of the page the layout is rendered around.\n pageStore: DocumentStore;\n}\n\nconst PageLayoutContext = React.createContext<PageLayoutContextValue | undefined>(undefined);\n\n/**\n * Set while rendering the elements of a page's layout. They belong to the layout, not to the page: in the\n * page editor, they can be selected (to override their inputs on the page), but not moved or dropped into.\n */\nexport const usePageLayout = () => {\n return useContext(PageLayoutContext);\n};\n\n/**\n * Render from the page again, from within its layout: the page content, and the instances of the global\n * components the layout places (they come with the page, and the page editor edits them there).\n */\nexport const PageScope = ({ children }: { children: React.ReactNode }) => {\n const pageLayout = usePageLayout();\n if (!pageLayout) {\n return <>{children}</>;\n }\n\n return (\n <PageLayoutContext.Provider value={undefined}>\n <DocumentStoreScope store={pageLayout.pageStore}>{children}</DocumentStoreScope>\n </PageLayoutContext.Provider>\n );\n};\n\nconst ReadOnlyContext = React.createContext(false);\n\n/**\n * Everything inside renders as on the live site, even in the editor: it can't be selected or dropped into\n * (e.g., the page previewed inside a layout in the layout editor).\n */\nexport const ReadOnlyScope = ({ children }: { children: React.ReactNode }) => {\n return <ReadOnlyContext.Provider value={true}>{children}</ReadOnlyContext.Provider>;\n};\n\nexport const useIsReadOnlyScope = () => {\n return useContext(ReadOnlyContext);\n};\n\n/**\n * The layout comes complete: on the live site the backend merges the page's overrides of the layout's\n * elements into it, and the page editor sends it to the preview the same way.\n */\nconst toLayoutDocument = (layout: PageLayoutData): Document => {\n return {\n id: layout.id,\n version: 1,\n state: {},\n properties: { id: layout.id },\n metadata: { documentType: \"layout\" },\n extensions: {},\n elements: layout.elements ?? {},\n bindings: layout.bindings ?? {}\n };\n};\n\nconst PageLayoutRenderer = ({ layoutJson }: { layoutJson: string }) => {\n const pageStore = useDocumentStore();\n const context = useMemo(() => ({ pageStore }), [pageStore]);\n // The layout comes with the page's overrides merged in, so it is different for every page: each render\n // gets its own store, never one shared by layout id across pages (or across requests on the server).\n const document = useMemo<Document>(() => JSON.parse(layoutJson), [layoutJson]);\n // A changed layout (e.g. patched in the page editor) goes into the same store.\n const layoutStore = useSeededDocumentStore(document);\n\n return (\n <PageLayoutContext.Provider value={context}>\n <DocumentStoreScope store={layoutStore}>\n <ElementRenderer id={\"root\"} />\n </DocumentStoreScope>\n </PageLayoutContext.Provider>\n );\n};\n\n/**\n * Render the page in its layout: the one picked in the page settings, built in the layout editor, or\n * else the `layout` the frontend passes to <DocumentRenderer>.\n */\nexport const PageWithLayout = observer(({ layout }: { layout?: DocumentLayout }) => {\n const pageStore = useDocumentStore();\n const page = pageStore.getDocument();\n // In the page editor, the layout is patched in place: reading all of it re-renders on any change.\n const layoutJson = page?.layout ? JSON.stringify(toLayoutDocument(toJS(page.layout))) : null;\n\n if (layoutJson) {\n return <PageLayoutRenderer layoutJson={layoutJson} />;\n }\n\n return renderWithLayout(<ElementRenderer id={\"root\"} />, layout);\n});\n"],"names":["PageLayoutContext","React","undefined","usePageLayout","useContext","PageScope","children","pageLayout","DocumentStoreScope","ReadOnlyContext","ReadOnlyScope","useIsReadOnlyScope","toLayoutDocument","layout","PageLayoutRenderer","layoutJson","pageStore","useDocumentStore","context","useMemo","document","JSON","layoutStore","useSeededDocumentStore","ElementRenderer","PageWithLayout","observer","page","toJS","renderWithLayout"],"mappings":";;;;;;;;AAmBA,MAAMA,oBAAoB,WAApBA,GAAoBC,MAAAA,aAAmB,CAAqCC;AAM3E,MAAMC,gBAAgB,IAClBC,WAAWJ;AAOf,MAAMK,YAAY,CAAC,EAAEC,QAAQ,EAAiC;IACjE,MAAMC,aAAaJ;IACnB,IAAI,CAACI,YACD,OAAO,WAAP,GAAO,0CAAGD;IAGd,OAAO,WAAP,GACI,oBAACN,kBAAkB,QAAQ;QAAC,OAAOE;qBAC/B,oBAACM,oBAAkBA;QAAC,OAAOD,WAAW,SAAS;OAAGD;AAG9D;AAEA,MAAMG,kBAAkB,WAAlBA,GAAkBR,MAAAA,aAAmB,CAAC;AAMrC,MAAMS,gBAAgB,CAAC,EAAEJ,QAAQ,EAAiC,GAC9D,WAAP,GAAO,oBAACG,gBAAgB,QAAQ;QAAC,OAAO;OAAOH;AAG5C,MAAMK,qBAAqB,IACvBP,WAAWK;AAOtB,MAAMG,mBAAmB,CAACC,SACf;QACH,IAAIA,OAAO,EAAE;QACb,SAAS;QACT,OAAO,CAAC;QACR,YAAY;YAAE,IAAIA,OAAO,EAAE;QAAC;QAC5B,UAAU;YAAE,cAAc;QAAS;QACnC,YAAY,CAAC;QACb,UAAUA,OAAO,QAAQ,IAAI,CAAC;QAC9B,UAAUA,OAAO,QAAQ,IAAI,CAAC;IAClC;AAGJ,MAAMC,qBAAqB,CAAC,EAAEC,UAAU,EAA0B;IAC9D,MAAMC,YAAYC;IAClB,MAAMC,UAAUC,QAAQ,IAAO;YAAEH;QAAU,IAAI;QAACA;KAAU;IAG1D,MAAMI,WAAWD,QAAkB,IAAME,KAAK,KAAK,CAACN,aAAa;QAACA;KAAW;IAE7E,MAAMO,cAAcC,uBAAuBH;IAE3C,OAAO,WAAP,GACI,oBAACpB,kBAAkB,QAAQ;QAAC,OAAOkB;qBAC/B,oBAACV,oBAAkBA;QAAC,OAAOc;qBACvB,oBAACE,iBAAeA;QAAC,IAAI;;AAIrC;AAMO,MAAMC,iBAAiBC,SAAS,CAAC,EAAEb,MAAM,EAA+B;IAC3E,MAAMG,YAAYC;IAClB,MAAMU,OAAOX,UAAU,WAAW;IAElC,MAAMD,aAAaY,MAAM,SAASN,KAAK,SAAS,CAACT,iBAAiBgB,KAAKD,KAAK,MAAM,MAAM;IAExF,IAAIZ,YACA,OAAO,WAAP,GAAO,oBAACD,oBAAAA;QAAmB,YAAYC;;IAG3C,OAAOc,iBAAiB,WAADA,GAAC,oBAACL,iBAAeA;QAAC,IAAI;QAAYX;AAC7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/SlotLabel.js","sources":["../../src/components/SlotLabel.tsx"],"sourcesContent":["\"use client\";\nimport React, { useContext } from \"react\";\n\ninterface SlotLabelValue {\n parentId: string;\n slot: string;\n label: string;\n}\n\nconst SlotLabelContext = React.createContext<SlotLabelValue | undefined>(undefined);\n\n/**\n * Name one slot in the editor: while it's empty, its drop area shows the label (e.g., the page content\n * area of a layout it belongs to). Other slots rendered inside are not labeled.\n */\nexport const SlotLabel = ({\n children,\n ...value\n}: SlotLabelValue & { children: React.ReactNode }) => {\n return <SlotLabelContext.Provider value={value}>{children}</SlotLabelContext.Provider>;\n};\n\nexport const useSlotLabel = (parentId: string, slot: string) => {\n const value = useContext(SlotLabelContext);\n return value && value.parentId === parentId && value.slot === slot ? value.label : undefined;\n};\n"],"names":["SlotLabelContext","React","undefined","SlotLabel","children","value","useSlotLabel","parentId","slot","useContext"],"mappings":";;AASA,MAAMA,mBAAmB,
|
|
1
|
+
{"version":3,"file":"components/SlotLabel.js","sources":["../../src/components/SlotLabel.tsx"],"sourcesContent":["\"use client\";\nimport React, { useContext } from \"react\";\n\ninterface SlotLabelValue {\n parentId: string;\n slot: string;\n label: string;\n}\n\nconst SlotLabelContext = React.createContext<SlotLabelValue | undefined>(undefined);\n\n/**\n * Name one slot in the editor: while it's empty, its drop area shows the label (e.g., the page content\n * area of a layout it belongs to). Other slots rendered inside are not labeled.\n */\nexport const SlotLabel = ({\n children,\n ...value\n}: SlotLabelValue & { children: React.ReactNode }) => {\n return <SlotLabelContext.Provider value={value}>{children}</SlotLabelContext.Provider>;\n};\n\nexport const useSlotLabel = (parentId: string, slot: string) => {\n const value = useContext(SlotLabelContext);\n return value && value.parentId === parentId && value.slot === slot ? value.label : undefined;\n};\n"],"names":["SlotLabelContext","React","undefined","SlotLabel","children","value","useSlotLabel","parentId","slot","useContext"],"mappings":";;AASA,MAAMA,mBAAmB,WAAnBA,GAAmBC,MAAAA,aAAmB,CAA6BC;AAMlE,MAAMC,YAAY,CAAC,EACtBC,QAAQ,EACR,GAAGC,OAC0C,GACtC,WAAP,GAAO,oBAACL,iBAAiB,QAAQ;QAAC,OAAOK;OAAQD;AAG9C,MAAME,eAAe,CAACC,UAAkBC;IAC3C,MAAMH,QAAQI,WAAWT;IACzB,OAAOK,SAASA,MAAM,QAAQ,KAAKE,YAAYF,MAAM,IAAI,KAAKG,OAAOH,MAAM,KAAK,GAAGH;AACvF"}
|
|
@@ -21,6 +21,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
21
21
|
animationRangeStart?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.AnimationRangeStart<string | number> | undefined> | undefined;
|
|
22
22
|
animationTimeline?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.AnimationTimeline | undefined> | undefined;
|
|
23
23
|
animationTimingFunction?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.AnimationTimingFunction | undefined> | undefined;
|
|
24
|
+
animationTrigger?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.AnimationTrigger | undefined> | undefined;
|
|
24
25
|
appearance?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Appearance | undefined> | undefined;
|
|
25
26
|
backdropFilter?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BackdropFilter | undefined> | undefined;
|
|
26
27
|
backfaceVisibility?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BackfaceVisibility | undefined> | undefined;
|
|
@@ -35,6 +36,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
35
36
|
backgroundRepeat?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BackgroundRepeat | undefined> | undefined;
|
|
36
37
|
backgroundSize?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BackgroundSize<string | number> | undefined> | undefined;
|
|
37
38
|
baselineShift?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BaselineShift<string | number> | undefined> | undefined;
|
|
39
|
+
baselineSource?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BaselineSource | undefined> | undefined;
|
|
38
40
|
blockSize?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BlockSize<string | number> | undefined> | undefined;
|
|
39
41
|
borderBlockEndColor?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderBlockEndColor | undefined> | undefined;
|
|
40
42
|
borderBlockEndStyle?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderBlockEndStyle | undefined> | undefined;
|
|
@@ -65,6 +67,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
65
67
|
borderRightColor?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderRightColor | undefined> | undefined;
|
|
66
68
|
borderRightStyle?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderRightStyle | undefined> | undefined;
|
|
67
69
|
borderRightWidth?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderRightWidth<string | number> | undefined> | undefined;
|
|
70
|
+
borderShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderShape | undefined> | undefined;
|
|
68
71
|
borderSpacing?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderSpacing<string | number> | undefined> | undefined;
|
|
69
72
|
borderTopColor?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderTopColor | undefined> | undefined;
|
|
70
73
|
borderTopLeftRadius?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderTopLeftRadius<string | number> | undefined> | undefined;
|
|
@@ -78,6 +81,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
78
81
|
breakBefore?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BreakBefore | undefined> | undefined;
|
|
79
82
|
breakInside?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BreakInside | undefined> | undefined;
|
|
80
83
|
captionSide?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CaptionSide | undefined> | undefined;
|
|
84
|
+
caretAnimation?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CaretAnimation | undefined> | undefined;
|
|
81
85
|
caretColor?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CaretColor | undefined> | undefined;
|
|
82
86
|
caretShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CaretShape | undefined> | undefined;
|
|
83
87
|
clear?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Clear | undefined> | undefined;
|
|
@@ -90,11 +94,13 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
90
94
|
columnCount?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ColumnCount | undefined> | undefined;
|
|
91
95
|
columnFill?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ColumnFill | undefined> | undefined;
|
|
92
96
|
columnGap?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ColumnGap<string | number> | undefined> | undefined;
|
|
97
|
+
columnHeight?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ColumnHeight<string | number> | undefined> | undefined;
|
|
93
98
|
columnRuleColor?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ColumnRuleColor | undefined> | undefined;
|
|
94
99
|
columnRuleStyle?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ColumnRuleStyle | undefined> | undefined;
|
|
95
100
|
columnRuleWidth?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ColumnRuleWidth<string | number> | undefined> | undefined;
|
|
96
101
|
columnSpan?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ColumnSpan | undefined> | undefined;
|
|
97
102
|
columnWidth?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ColumnWidth<string | number> | undefined> | undefined;
|
|
103
|
+
columnWrap?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ColumnWrap | undefined> | undefined;
|
|
98
104
|
contain?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Contain | undefined> | undefined;
|
|
99
105
|
containIntrinsicBlockSize?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ContainIntrinsicBlockSize<string | number> | undefined> | undefined;
|
|
100
106
|
containIntrinsicHeight?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ContainIntrinsicHeight<string | number> | undefined> | undefined;
|
|
@@ -104,6 +110,14 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
104
110
|
containerType?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ContainerType | undefined> | undefined;
|
|
105
111
|
content?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Content | undefined> | undefined;
|
|
106
112
|
contentVisibility?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ContentVisibility | undefined> | undefined;
|
|
113
|
+
cornerBottomLeftShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerBottomLeftShape | undefined> | undefined;
|
|
114
|
+
cornerBottomRightShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerBottomRightShape | undefined> | undefined;
|
|
115
|
+
cornerEndEndShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerEndEndShape | undefined> | undefined;
|
|
116
|
+
cornerEndStartShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerEndStartShape | undefined> | undefined;
|
|
117
|
+
cornerStartEndShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerStartEndShape | undefined> | undefined;
|
|
118
|
+
cornerStartStartShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerStartStartShape | undefined> | undefined;
|
|
119
|
+
cornerTopLeftShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerTopLeftShape | undefined> | undefined;
|
|
120
|
+
cornerTopRightShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerTopRightShape | undefined> | undefined;
|
|
107
121
|
counterIncrement?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CounterIncrement | undefined> | undefined;
|
|
108
122
|
counterReset?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CounterReset | undefined> | undefined;
|
|
109
123
|
counterSet?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CounterSet | undefined> | undefined;
|
|
@@ -114,6 +128,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
114
128
|
direction?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Direction | undefined> | undefined;
|
|
115
129
|
display?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Display | undefined> | undefined;
|
|
116
130
|
dominantBaseline?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.DominantBaseline | undefined> | undefined;
|
|
131
|
+
dynamicRangeLimit?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.DynamicRangeLimit | undefined> | undefined;
|
|
117
132
|
emptyCells?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.EmptyCells | undefined> | undefined;
|
|
118
133
|
fieldSizing?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.FieldSizing | undefined> | undefined;
|
|
119
134
|
fill?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Fill | undefined> | undefined;
|
|
@@ -123,6 +138,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
123
138
|
flexBasis?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.FlexBasis<string | number> | undefined> | undefined;
|
|
124
139
|
flexDirection?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.FlexDirection | undefined> | undefined;
|
|
125
140
|
flexGrow?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.FlexGrow | undefined> | undefined;
|
|
141
|
+
flexLineCount?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.FlexLineCount | undefined> | undefined;
|
|
126
142
|
flexShrink?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.FlexShrink | undefined> | undefined;
|
|
127
143
|
flexWrap?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.FlexWrap | undefined> | undefined;
|
|
128
144
|
float?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Float | undefined> | undefined;
|
|
@@ -154,6 +170,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
154
170
|
fontWeight?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.FontWeight | undefined> | undefined;
|
|
155
171
|
fontWidth?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.FontWidth | undefined> | undefined;
|
|
156
172
|
forcedColorAdjust?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ForcedColorAdjust | undefined> | undefined;
|
|
173
|
+
frameSizing?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.FrameSizing | undefined> | undefined;
|
|
157
174
|
gridAutoColumns?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.GridAutoColumns<string | number> | undefined> | undefined;
|
|
158
175
|
gridAutoFlow?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.GridAutoFlow | undefined> | undefined;
|
|
159
176
|
gridAutoRows?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.GridAutoRows<string | number> | undefined> | undefined;
|
|
@@ -179,6 +196,9 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
179
196
|
insetBlockStart?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.InsetBlockStart<string | number> | undefined> | undefined;
|
|
180
197
|
insetInlineEnd?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.InsetInlineEnd<string | number> | undefined> | undefined;
|
|
181
198
|
insetInlineStart?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.InsetInlineStart<string | number> | undefined> | undefined;
|
|
199
|
+
interactivity?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Interactivity | undefined> | undefined;
|
|
200
|
+
interestDelayEnd?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.InterestDelayEnd<string & {}> | undefined> | undefined;
|
|
201
|
+
interestDelayStart?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.InterestDelayStart<string & {}> | undefined> | undefined;
|
|
182
202
|
interpolateSize?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.InterpolateSize | undefined> | undefined;
|
|
183
203
|
isolation?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Isolation | undefined> | undefined;
|
|
184
204
|
justifyContent?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.JustifyContent | undefined> | undefined;
|
|
@@ -191,6 +211,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
191
211
|
lineBreak?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.LineBreak | undefined> | undefined;
|
|
192
212
|
lineHeight?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.LineHeight<string | number> | undefined> | undefined;
|
|
193
213
|
lineHeightStep?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.LineHeightStep<string | number> | undefined> | undefined;
|
|
214
|
+
linkParameters?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.LinkParameters | undefined> | undefined;
|
|
194
215
|
listStyleImage?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ListStyleImage | undefined> | undefined;
|
|
195
216
|
listStylePosition?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ListStylePosition | undefined> | undefined;
|
|
196
217
|
listStyleType?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ListStyleType | undefined> | undefined;
|
|
@@ -276,6 +297,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
276
297
|
paddingTop?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.PaddingTop<string | number> | undefined> | undefined;
|
|
277
298
|
page?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Page | undefined> | undefined;
|
|
278
299
|
paintOrder?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.PaintOrder | undefined> | undefined;
|
|
300
|
+
pathLength?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.PathLength | undefined> | undefined;
|
|
279
301
|
perspective?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Perspective<string | number> | undefined> | undefined;
|
|
280
302
|
perspectiveOrigin?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.PerspectiveOrigin<string | number> | undefined> | undefined;
|
|
281
303
|
pointerEvents?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.PointerEvents | undefined> | undefined;
|
|
@@ -288,6 +310,8 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
288
310
|
printColorAdjust?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.PrintColorAdjust | undefined> | undefined;
|
|
289
311
|
quotes?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Quotes | undefined> | undefined;
|
|
290
312
|
r?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.R<string | number> | undefined> | undefined;
|
|
313
|
+
readingFlow?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ReadingFlow | undefined> | undefined;
|
|
314
|
+
readingOrder?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ReadingOrder | undefined> | undefined;
|
|
291
315
|
resize?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Resize | undefined> | undefined;
|
|
292
316
|
right?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Right<string | number> | undefined> | undefined;
|
|
293
317
|
rotate?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Rotate | undefined> | undefined;
|
|
@@ -299,6 +323,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
299
323
|
rx?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Rx<string | number> | undefined> | undefined;
|
|
300
324
|
ry?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Ry<string | number> | undefined> | undefined;
|
|
301
325
|
scale?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Scale | undefined> | undefined;
|
|
326
|
+
scrollAxisLock?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollAxisLock | undefined> | undefined;
|
|
302
327
|
scrollBehavior?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollBehavior | undefined> | undefined;
|
|
303
328
|
scrollInitialTarget?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollInitialTarget | undefined> | undefined;
|
|
304
329
|
scrollMarginBlockEnd?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollMarginBlockEnd<string | number> | undefined> | undefined;
|
|
@@ -309,6 +334,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
309
334
|
scrollMarginLeft?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollMarginLeft<string | number> | undefined> | undefined;
|
|
310
335
|
scrollMarginRight?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollMarginRight<string | number> | undefined> | undefined;
|
|
311
336
|
scrollMarginTop?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollMarginTop<string | number> | undefined> | undefined;
|
|
337
|
+
scrollMarkerGroup?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollMarkerGroup | undefined> | undefined;
|
|
312
338
|
scrollPaddingBlockEnd?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollPaddingBlockEnd<string | number> | undefined> | undefined;
|
|
313
339
|
scrollPaddingBlockStart?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollPaddingBlockStart<string | number> | undefined> | undefined;
|
|
314
340
|
scrollPaddingBottom?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollPaddingBottom<string | number> | undefined> | undefined;
|
|
@@ -324,6 +350,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
324
350
|
scrollSnapMarginTop?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollMarginTop<string | number> | undefined> | undefined;
|
|
325
351
|
scrollSnapStop?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollSnapStop | undefined> | undefined;
|
|
326
352
|
scrollSnapType?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollSnapType | undefined> | undefined;
|
|
353
|
+
scrollTargetGroup?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollTargetGroup | undefined> | undefined;
|
|
327
354
|
scrollTimelineAxis?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollTimelineAxis | undefined> | undefined;
|
|
328
355
|
scrollTimelineName?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollTimelineName | undefined> | undefined;
|
|
329
356
|
scrollbarColor?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollbarColor | undefined> | undefined;
|
|
@@ -356,12 +383,13 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
356
383
|
textBoxTrim?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextBoxTrim | undefined> | undefined;
|
|
357
384
|
textCombineUpright?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextCombineUpright | undefined> | undefined;
|
|
358
385
|
textDecorationColor?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextDecorationColor | undefined> | undefined;
|
|
386
|
+
textDecorationInset?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextDecorationInset<string | number> | undefined> | undefined;
|
|
359
387
|
textDecorationLine?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextDecorationLine | undefined> | undefined;
|
|
360
|
-
textDecorationSkip?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextDecorationSkip | undefined> | undefined;
|
|
361
388
|
textDecorationSkipInk?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextDecorationSkipInk | undefined> | undefined;
|
|
362
389
|
textDecorationStyle?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextDecorationStyle | undefined> | undefined;
|
|
363
390
|
textDecorationThickness?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextDecorationThickness<string | number> | undefined> | undefined;
|
|
364
391
|
textEmphasisPosition?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextEmphasisPosition | undefined> | undefined;
|
|
392
|
+
textFit?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextFit | undefined> | undefined;
|
|
365
393
|
textIndent?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextIndent<string | number> | undefined> | undefined;
|
|
366
394
|
textJustify?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextJustify | undefined> | undefined;
|
|
367
395
|
textOrientation?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextOrientation | undefined> | undefined;
|
|
@@ -375,6 +403,12 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
375
403
|
textWrapMode?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextWrapMode | undefined> | undefined;
|
|
376
404
|
textWrapStyle?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextWrapStyle | undefined> | undefined;
|
|
377
405
|
timelineScope?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TimelineScope | undefined> | undefined;
|
|
406
|
+
timelineTriggerActivationRangeEnd?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TimelineTriggerActivationRangeEnd<string | number> | undefined> | undefined;
|
|
407
|
+
timelineTriggerActivationRangeStart?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TimelineTriggerActivationRangeStart<string | number> | undefined> | undefined;
|
|
408
|
+
timelineTriggerActiveRangeEnd?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TimelineTriggerActiveRangeEnd<string | number> | undefined> | undefined;
|
|
409
|
+
timelineTriggerActiveRangeStart?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TimelineTriggerActiveRangeStart<string | number> | undefined> | undefined;
|
|
410
|
+
timelineTriggerName?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TimelineTriggerName | undefined> | undefined;
|
|
411
|
+
timelineTriggerSource?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TimelineTriggerSource | undefined> | undefined;
|
|
378
412
|
top?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Top<string | number> | undefined> | undefined;
|
|
379
413
|
touchAction?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TouchAction | undefined> | undefined;
|
|
380
414
|
transform?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Transform | undefined> | undefined;
|
|
@@ -387,6 +421,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
387
421
|
transitionProperty?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TransitionProperty | undefined> | undefined;
|
|
388
422
|
transitionTimingFunction?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TransitionTimingFunction | undefined> | undefined;
|
|
389
423
|
translate?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Translate<string | number> | undefined> | undefined;
|
|
424
|
+
triggerScope?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TriggerScope | undefined> | undefined;
|
|
390
425
|
unicodeBidi?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.UnicodeBidi | undefined> | undefined;
|
|
391
426
|
userSelect?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.UserSelect | undefined> | undefined;
|
|
392
427
|
vectorEffect?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.VectorEffect | undefined> | undefined;
|
|
@@ -396,12 +431,14 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
396
431
|
viewTimelineName?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ViewTimelineName | undefined> | undefined;
|
|
397
432
|
viewTransitionClass?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ViewTransitionClass | undefined> | undefined;
|
|
398
433
|
viewTransitionName?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ViewTransitionName | undefined> | undefined;
|
|
434
|
+
viewTransitionScope?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ViewTransitionScope | undefined> | undefined;
|
|
399
435
|
visibility?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Visibility | undefined> | undefined;
|
|
400
436
|
whiteSpace?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WhiteSpace | undefined> | undefined;
|
|
401
437
|
whiteSpaceCollapse?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WhiteSpaceCollapse | undefined> | undefined;
|
|
402
438
|
widows?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Widows | undefined> | undefined;
|
|
403
439
|
width?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Width<string | number> | undefined> | undefined;
|
|
404
440
|
willChange?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WillChange | undefined> | undefined;
|
|
441
|
+
windowDrag?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WindowDrag | undefined> | undefined;
|
|
405
442
|
wordBreak?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WordBreak | undefined> | undefined;
|
|
406
443
|
wordSpacing?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WordSpacing<string | number> | undefined> | undefined;
|
|
407
444
|
wordWrap?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WordWrap | undefined> | undefined;
|
|
@@ -425,12 +462,22 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
425
462
|
caret?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Caret | undefined> | undefined;
|
|
426
463
|
containIntrinsicSize?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ContainIntrinsicSize<string | number> | undefined> | undefined;
|
|
427
464
|
container?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Container | undefined> | undefined;
|
|
465
|
+
cornerBlockEndShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerBlockEndShape | undefined> | undefined;
|
|
466
|
+
cornerBlockStartShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerBlockStartShape | undefined> | undefined;
|
|
467
|
+
cornerBottomShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerBottomShape | undefined> | undefined;
|
|
468
|
+
cornerInlineEndShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerInlineEndShape | undefined> | undefined;
|
|
469
|
+
cornerInlineStartShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerInlineStartShape | undefined> | undefined;
|
|
470
|
+
cornerLeftShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerLeftShape | undefined> | undefined;
|
|
471
|
+
cornerRightShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerRightShape | undefined> | undefined;
|
|
472
|
+
cornerShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerShape | undefined> | undefined;
|
|
473
|
+
cornerTopShape?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.CornerTopShape | undefined> | undefined;
|
|
428
474
|
gridArea?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.GridArea | undefined> | undefined;
|
|
429
475
|
gridColumn?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.GridColumn | undefined> | undefined;
|
|
430
476
|
gridRow?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.GridRow | undefined> | undefined;
|
|
431
477
|
gridTemplate?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.GridTemplate | undefined> | undefined;
|
|
432
478
|
insetBlock?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.InsetBlock<string | number> | undefined> | undefined;
|
|
433
479
|
insetInline?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.InsetInline<string | number> | undefined> | undefined;
|
|
480
|
+
interestDelay?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.InterestDelay<string & {}> | undefined> | undefined;
|
|
434
481
|
lineClamp?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.LineClamp | undefined> | undefined;
|
|
435
482
|
marginBlock?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.MarginBlock<string | number> | undefined> | undefined;
|
|
436
483
|
marginInline?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.MarginInline<string | number> | undefined> | undefined;
|
|
@@ -450,6 +497,9 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
450
497
|
scrollSnapMargin?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollMargin<string | number> | undefined> | undefined;
|
|
451
498
|
scrollTimeline?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollTimeline | undefined> | undefined;
|
|
452
499
|
textWrap?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextWrap | undefined> | undefined;
|
|
500
|
+
timelineTrigger?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TimelineTrigger | undefined> | undefined;
|
|
501
|
+
timelineTriggerActivationRange?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TimelineTriggerActivationRange<string | number> | undefined> | undefined;
|
|
502
|
+
timelineTriggerActiveRange?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TimelineTriggerActiveRange<string | number> | undefined> | undefined;
|
|
453
503
|
viewTimeline?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ViewTimeline | undefined> | undefined;
|
|
454
504
|
MozAnimationDelay?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.AnimationDelay<string & {}> | undefined> | undefined;
|
|
455
505
|
MozAnimationDirection?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.AnimationDirection | undefined> | undefined;
|
|
@@ -499,6 +549,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
499
549
|
MozTransform?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Transform | undefined> | undefined;
|
|
500
550
|
MozTransformOrigin?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TransformOrigin<string | number> | undefined> | undefined;
|
|
501
551
|
MozTransformStyle?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TransformStyle | undefined> | undefined;
|
|
552
|
+
MozUserFocus?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.MozUserFocus | undefined> | undefined;
|
|
502
553
|
MozUserModify?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.MozUserModify | undefined> | undefined;
|
|
503
554
|
MozUserSelect?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.UserSelect | undefined> | undefined;
|
|
504
555
|
MozWindowDragging?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.MozWindowDragging | undefined> | undefined;
|
|
@@ -581,12 +632,21 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
581
632
|
WebkitBackgroundClip?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BackgroundClip | undefined> | undefined;
|
|
582
633
|
WebkitBackgroundOrigin?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BackgroundOrigin | undefined> | undefined;
|
|
583
634
|
WebkitBackgroundSize?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BackgroundSize<string | number> | undefined> | undefined;
|
|
635
|
+
WebkitBorderAfterColor?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderAfterColor | undefined> | undefined;
|
|
636
|
+
WebkitBorderAfterStyle?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderAfterStyle | undefined> | undefined;
|
|
637
|
+
WebkitBorderAfterWidth?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderAfterWidth<string | number> | undefined> | undefined;
|
|
584
638
|
WebkitBorderBeforeColor?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderBeforeColor | undefined> | undefined;
|
|
585
639
|
WebkitBorderBeforeStyle?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderBeforeStyle | undefined> | undefined;
|
|
586
640
|
WebkitBorderBeforeWidth?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderBeforeWidth<string | number> | undefined> | undefined;
|
|
587
641
|
WebkitBorderBottomLeftRadius?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderBottomLeftRadius<string | number> | undefined> | undefined;
|
|
588
642
|
WebkitBorderBottomRightRadius?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderBottomRightRadius<string | number> | undefined> | undefined;
|
|
643
|
+
WebkitBorderEndColor?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderEndColor | undefined> | undefined;
|
|
644
|
+
WebkitBorderEndStyle?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderEndStyle | undefined> | undefined;
|
|
645
|
+
WebkitBorderEndWidth?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderEndWidth<string | number> | undefined> | undefined;
|
|
589
646
|
WebkitBorderImageSlice?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderImageSlice | undefined> | undefined;
|
|
647
|
+
WebkitBorderStartColor?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderStartColor | undefined> | undefined;
|
|
648
|
+
WebkitBorderStartStyle?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderStartStyle | undefined> | undefined;
|
|
649
|
+
WebkitBorderStartWidth?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderStartWidth<string | number> | undefined> | undefined;
|
|
590
650
|
WebkitBorderTopLeftRadius?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderTopLeftRadius<string | number> | undefined> | undefined;
|
|
591
651
|
WebkitBorderTopRightRadius?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderTopRightRadius<string | number> | undefined> | undefined;
|
|
592
652
|
WebkitBoxDecorationBreak?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BoxDecorationBreak | undefined> | undefined;
|
|
@@ -619,6 +679,8 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
619
679
|
WebkitLineClamp?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitLineClamp | undefined> | undefined;
|
|
620
680
|
WebkitLogicalHeight?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BlockSize<string | number> | undefined> | undefined;
|
|
621
681
|
WebkitLogicalWidth?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.InlineSize<string | number> | undefined> | undefined;
|
|
682
|
+
WebkitMarginAfter?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.MarginBlockEnd<string | number> | undefined> | undefined;
|
|
683
|
+
WebkitMarginBefore?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.MarginBlockStart<string | number> | undefined> | undefined;
|
|
622
684
|
WebkitMarginEnd?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.MarginInlineEnd<string | number> | undefined> | undefined;
|
|
623
685
|
WebkitMarginStart?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.MarginInlineStart<string | number> | undefined> | undefined;
|
|
624
686
|
WebkitMaskAttachment?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitMaskAttachment | undefined> | undefined;
|
|
@@ -653,7 +715,6 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
653
715
|
WebkitTextCombine?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextCombineUpright | undefined> | undefined;
|
|
654
716
|
WebkitTextDecorationColor?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextDecorationColor | undefined> | undefined;
|
|
655
717
|
WebkitTextDecorationLine?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextDecorationLine | undefined> | undefined;
|
|
656
|
-
WebkitTextDecorationSkip?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextDecorationSkip | undefined> | undefined;
|
|
657
718
|
WebkitTextDecorationStyle?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextDecorationStyle | undefined> | undefined;
|
|
658
719
|
WebkitTextEmphasisColor?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextEmphasisColor | undefined> | undefined;
|
|
659
720
|
WebkitTextEmphasisPosition?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextEmphasisPosition | undefined> | undefined;
|
|
@@ -689,9 +750,12 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
689
750
|
msScrollSnapY?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.MsScrollSnapY | undefined> | undefined;
|
|
690
751
|
msTransition?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Transition<string & {}> | undefined> | undefined;
|
|
691
752
|
WebkitAnimation?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Animation<string & {}> | undefined> | undefined;
|
|
753
|
+
WebkitBorderAfter?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderAfter<string | number> | undefined> | undefined;
|
|
692
754
|
WebkitBorderBefore?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderBefore<string | number> | undefined> | undefined;
|
|
755
|
+
WebkitBorderEnd?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderEnd<string | number> | undefined> | undefined;
|
|
693
756
|
WebkitBorderImage?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderImage | undefined> | undefined;
|
|
694
757
|
WebkitBorderRadius?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BorderRadius<string | number> | undefined> | undefined;
|
|
758
|
+
WebkitBorderStart?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.WebkitBorderStart<string | number> | undefined> | undefined;
|
|
695
759
|
WebkitColumnRule?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ColumnRule<string | number> | undefined> | undefined;
|
|
696
760
|
WebkitColumns?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Columns<string | number> | undefined> | undefined;
|
|
697
761
|
WebkitFlex?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Flex<string | number> | undefined> | undefined;
|
|
@@ -732,6 +796,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
732
796
|
scrollSnapPointsY?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollSnapPointsY | undefined> | undefined;
|
|
733
797
|
scrollSnapTypeX?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollSnapTypeX | undefined> | undefined;
|
|
734
798
|
scrollSnapTypeY?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ScrollSnapTypeY | undefined> | undefined;
|
|
799
|
+
textDecorationSkip?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextDecorationSkip | undefined> | undefined;
|
|
735
800
|
KhtmlBoxAlign?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BoxAlign | undefined> | undefined;
|
|
736
801
|
KhtmlBoxDirection?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BoxDirection | undefined> | undefined;
|
|
737
802
|
KhtmlBoxFlex?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BoxFlex | undefined> | undefined;
|
|
@@ -775,7 +840,6 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
775
840
|
MozTransitionDuration?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TransitionDuration<string & {}> | undefined> | undefined;
|
|
776
841
|
MozTransitionProperty?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TransitionProperty | undefined> | undefined;
|
|
777
842
|
MozTransitionTimingFunction?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TransitionTimingFunction | undefined> | undefined;
|
|
778
|
-
MozUserFocus?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.MozUserFocus | undefined> | undefined;
|
|
779
843
|
MozUserInput?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.MozUserInput | undefined> | undefined;
|
|
780
844
|
msImeMode?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ImeMode | undefined> | undefined;
|
|
781
845
|
OAnimation?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.Animation<string & {}> | undefined> | undefined;
|
|
@@ -808,6 +872,7 @@ export declare const useBindingsForElement: (elementId: string, breakpoint: stri
|
|
|
808
872
|
WebkitBoxOrdinalGroup?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BoxOrdinalGroup | undefined> | undefined;
|
|
809
873
|
WebkitBoxOrient?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BoxOrient | undefined> | undefined;
|
|
810
874
|
WebkitBoxPack?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.BoxPack | undefined> | undefined;
|
|
875
|
+
WebkitTextDecorationSkip?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.TextDecorationSkip | undefined> | undefined;
|
|
811
876
|
colorInterpolation?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ColorInterpolation | undefined> | undefined;
|
|
812
877
|
colorRendering?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.ColorRendering | undefined> | undefined;
|
|
813
878
|
glyphOrientationVertical?: import("@webiny/website-builder-sdk").StyleValueBinding<import("csstype").Property.GlyphOrientationVertical | undefined> | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { toJS } from "mobx";
|
|
1
2
|
import { useDocumentStore } from "./DocumentStoreProvider.js";
|
|
2
3
|
import { useSelectFromState } from "./useSelectFromState.js";
|
|
3
4
|
const useDocumentState = ()=>{
|
|
4
5
|
const documentStore = useDocumentStore();
|
|
5
|
-
return useSelectFromState(()=>documentStore.getDocument(), (document)=>document.state ?? {});
|
|
6
|
+
return useSelectFromState(()=>documentStore.getDocument(), (document)=>toJS(document.state) ?? {});
|
|
6
7
|
};
|
|
7
8
|
export { useDocumentState };
|
|
8
9
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/useDocumentState.js","sources":["../../src/components/useDocumentState.ts"],"sourcesContent":["import { useDocumentStore } from \"./DocumentStoreProvider.js\";\nimport { useSelectFromState } from \"./useSelectFromState.js\";\n\nexport const useDocumentState = () => {\n const documentStore = useDocumentStore();\n return useSelectFromState(\n () => documentStore.getDocument()!,\n document => document.state ?? {}\n );\n};\n"],"names":["useDocumentState","documentStore","useDocumentStore","useSelectFromState","document"],"mappings":"
|
|
1
|
+
{"version":3,"file":"components/useDocumentState.js","sources":["../../src/components/useDocumentState.ts"],"sourcesContent":["import { toJS } from \"mobx\";\nimport { useDocumentStore } from \"./DocumentStoreProvider.js\";\nimport { useSelectFromState } from \"./useSelectFromState.js\";\n\nexport const useDocumentState = () => {\n const documentStore = useDocumentStore();\n return useSelectFromState(\n () => documentStore.getDocument()!,\n // The state's values (`toJS` reads them all), not the observable object: the store changes\n // values in place, so the object itself stays the same when a value changes.\n document => toJS(document.state) ?? {}\n );\n};\n"],"names":["useDocumentState","documentStore","useDocumentStore","useSelectFromState","document","toJS"],"mappings":";;;AAIO,MAAMA,mBAAmB;IAC5B,MAAMC,gBAAgBC;IACtB,OAAOC,mBACH,IAAMF,cAAc,WAAW,IAG/BG,CAAAA,WAAYC,KAAKD,SAAS,KAAK,KAAK,CAAC;AAE7C"}
|
|
@@ -2,7 +2,8 @@ type Equals<T> = (a: T, b: T) => boolean;
|
|
|
2
2
|
/**
|
|
3
3
|
* Subscribe to part of the document state.
|
|
4
4
|
* @param selector Pick the slice of state you care about.
|
|
5
|
-
* @param equals (optional) comparator, defaults to
|
|
5
|
+
* @param equals (optional) comparator, defaults to a strict structural compare
|
|
6
|
+
* (`lodash/isEqual`), cheap enough to run for every subscribed element
|
|
6
7
|
*/
|
|
7
8
|
export declare function useSelectFromState<TState, T>(getState: () => TState, selector: (doc: TState) => T, deps?: React.DependencyList, equals?: Equals<T>): T;
|
|
8
9
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import isEqual from "lodash/isEqual.js";
|
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { reaction } from "mobx";
|
|
4
|
-
function useSelectFromState(getState, selector, deps = [], equals =
|
|
4
|
+
function useSelectFromState(getState, selector, deps = [], equals = isEqual) {
|
|
5
5
|
const initialValue = useMemo(()=>selector(getState()), deps);
|
|
6
6
|
const [value, setValue] = useState(initialValue);
|
|
7
7
|
useEffect(()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/useSelectFromState.js","sources":["../../src/components/useSelectFromState.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"components/useSelectFromState.js","sources":["../../src/components/useSelectFromState.ts"],"sourcesContent":["import isEqual from \"lodash/isEqual.js\";\nimport { useState, useEffect, useMemo } from \"react\";\nimport type { IReactionDisposer } from \"mobx\";\nimport { reaction } from \"mobx\";\n\ntype Equals<T> = (a: T, b: T) => boolean;\n\n/**\n * Subscribe to part of the document state.\n * @param selector Pick the slice of state you care about.\n * @param equals (optional) comparator, defaults to a strict structural compare\n * (`lodash/isEqual`), cheap enough to run for every subscribed element\n */\nexport function useSelectFromState<TState, T>(\n getState: () => TState,\n selector: (doc: TState) => T,\n deps: React.DependencyList = [],\n equals: Equals<T> = isEqual\n): T {\n // Pull the initial slice synchronously\n const initialValue = useMemo(() => selector(getState()), deps);\n const [value, setValue] = useState<T>(initialValue);\n\n useEffect(() => {\n setValue(selector(getState())); // reset state on dep change\n }, deps);\n\n useEffect(() => {\n // reaction tracks selector(doc) and only fires when newVal !== oldVal\n const disposer: IReactionDisposer = reaction(\n () => {\n const state = getState();\n\n return selector(state);\n },\n (newValue, oldValue) => {\n if (!equals(oldValue, newValue)) {\n setValue(newValue);\n }\n },\n {\n // use your comparator to decide if newValue “really” changed\n equals,\n // we already set initial via useState\n fireImmediately: false\n }\n );\n\n return () => {\n // clean up when the component unmounts\n disposer();\n };\n }, [getState, selector, equals, ...deps]);\n\n return value;\n}\n"],"names":["useSelectFromState","getState","selector","deps","equals","isEqual","initialValue","useMemo","value","setValue","useState","useEffect","disposer","reaction","state","newValue","oldValue"],"mappings":";;;AAaO,SAASA,mBACZC,QAAsB,EACtBC,QAA4B,EAC5BC,OAA6B,EAAE,EAC/BC,SAAoBC,OAAO;IAG3B,MAAMC,eAAeC,QAAQ,IAAML,SAASD,aAAaE;IACzD,MAAM,CAACK,OAAOC,SAAS,GAAGC,SAAYJ;IAEtCK,UAAU;QACNF,SAASP,SAASD;IACtB,GAAGE;IAEHQ,UAAU;QAEN,MAAMC,WAA8BC,SAChC;YACI,MAAMC,QAAQb;YAEd,OAAOC,SAASY;QACpB,GACA,CAACC,UAAUC;YACP,IAAI,CAACZ,OAAOY,UAAUD,WAClBN,SAASM;QAEjB,GACA;YAEIX;YAEA,iBAAiB;QACrB;QAGJ,OAAO;YAEHQ;QACJ;IACJ,GAAG;QAACX;QAAUC;QAAUE;WAAWD;KAAK;IAExC,OAAOK;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { act, renderHook } from "@testing-library/react";
|
|
3
|
+
import { observable, runInAction } from "mobx";
|
|
4
|
+
import { useSelectFromState } from "./useSelectFromState.js";
|
|
5
|
+
function subscribe(state, elementId) {
|
|
6
|
+
let renders = 0;
|
|
7
|
+
const hook = renderHook(()=>{
|
|
8
|
+
renders++;
|
|
9
|
+
return useSelectFromState(()=>state, (current)=>({
|
|
10
|
+
...current.bindings[elementId]
|
|
11
|
+
}), [
|
|
12
|
+
elementId
|
|
13
|
+
]);
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
hook,
|
|
17
|
+
renders: ()=>renders
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
describe("useSelectFromState", ()=>{
|
|
21
|
+
it("returns the new slice when its value changes", ()=>{
|
|
22
|
+
const state = observable({
|
|
23
|
+
bindings: {
|
|
24
|
+
a: {
|
|
25
|
+
value: "one"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const { hook } = subscribe(state, "a");
|
|
30
|
+
act(()=>runInAction(()=>state.bindings.a.value = "two"));
|
|
31
|
+
expect(hook.result.current).toEqual({
|
|
32
|
+
value: "two"
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
it("returns the new slice when only the value's type changes", ()=>{
|
|
36
|
+
const state = observable({
|
|
37
|
+
bindings: {
|
|
38
|
+
a: {
|
|
39
|
+
value: 1
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const { hook } = subscribe(state, "a");
|
|
44
|
+
act(()=>runInAction(()=>state.bindings.a.value = "1"));
|
|
45
|
+
expect(hook.result.current).toEqual({
|
|
46
|
+
value: "1"
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
it("doesn't re-render when another element's bindings change", ()=>{
|
|
50
|
+
const state = observable({
|
|
51
|
+
bindings: {
|
|
52
|
+
a: {
|
|
53
|
+
value: "one"
|
|
54
|
+
},
|
|
55
|
+
b: {
|
|
56
|
+
value: "x"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const { renders } = subscribe(state, "a");
|
|
61
|
+
const before = renders();
|
|
62
|
+
act(()=>runInAction(()=>state.bindings.b.value = "y"));
|
|
63
|
+
expect(renders()).toBe(before);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=useSelectFromState.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components/useSelectFromState.test.js","sources":["../../src/components/useSelectFromState.test.ts"],"sourcesContent":["// @vitest-environment jsdom\nimport { describe, expect, it } from \"vitest\";\nimport { act, renderHook } from \"@testing-library/react\";\nimport { observable, runInAction } from \"mobx\";\nimport { useSelectFromState } from \"./useSelectFromState.js\";\n\ninterface TestState {\n bindings: Record<string, { value: unknown }>;\n}\n\nfunction subscribe(state: TestState, elementId: string) {\n let renders = 0;\n const hook = renderHook(() => {\n renders++;\n return useSelectFromState(\n () => state,\n current => ({ ...current.bindings[elementId] }),\n [elementId]\n );\n });\n return { hook, renders: () => renders };\n}\n\ndescribe(\"useSelectFromState\", () => {\n it(\"returns the new slice when its value changes\", () => {\n const state = observable<TestState>({ bindings: { a: { value: \"one\" } } });\n const { hook } = subscribe(state, \"a\");\n\n act(() => runInAction(() => (state.bindings.a.value = \"two\")));\n\n expect(hook.result.current).toEqual({ value: \"two\" });\n });\n\n // The default comparator is strict: a loose one (`deep-equal`'s default, `1 == \"1\"`) kept the\n // old value when only the type changed, e.g. a radio input's value from 1 to \"1\".\n it(\"returns the new slice when only the value's type changes\", () => {\n const state = observable<TestState>({ bindings: { a: { value: 1 } } });\n const { hook } = subscribe(state, \"a\");\n\n act(() => runInAction(() => (state.bindings.a.value = \"1\")));\n\n expect(hook.result.current).toEqual({ value: \"1\" });\n });\n\n it(\"doesn't re-render when another element's bindings change\", () => {\n const state = observable<TestState>({\n bindings: { a: { value: \"one\" }, b: { value: \"x\" } }\n });\n const { renders } = subscribe(state, \"a\");\n const before = renders();\n\n act(() => runInAction(() => (state.bindings.b.value = \"y\")));\n\n expect(renders()).toBe(before);\n });\n});\n"],"names":["subscribe","state","elementId","renders","hook","renderHook","useSelectFromState","current","describe","it","observable","act","runInAction","expect","before"],"mappings":";;;;AAUA,SAASA,UAAUC,KAAgB,EAAEC,SAAiB;IAClD,IAAIC,UAAU;IACd,MAAMC,OAAOC,WAAW;QACpBF;QACA,OAAOG,mBACH,IAAML,OACNM,CAAAA,UAAY;gBAAE,GAAGA,QAAQ,QAAQ,CAACL,UAAU;YAAC,IAC7C;YAACA;SAAU;IAEnB;IACA,OAAO;QAAEE;QAAM,SAAS,IAAMD;IAAQ;AAC1C;AAEAK,SAAS,sBAAsB;IAC3BC,GAAG,gDAAgD;QAC/C,MAAMR,QAAQS,WAAsB;YAAE,UAAU;gBAAE,GAAG;oBAAE,OAAO;gBAAM;YAAE;QAAE;QACxE,MAAM,EAAEN,IAAI,EAAE,GAAGJ,UAAUC,OAAO;QAElCU,IAAI,IAAMC,YAAY,IAAOX,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG;QAEtDY,OAAOT,KAAK,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;YAAE,OAAO;QAAM;IACvD;IAIAK,GAAG,4DAA4D;QAC3D,MAAMR,QAAQS,WAAsB;YAAE,UAAU;gBAAE,GAAG;oBAAE,OAAO;gBAAE;YAAE;QAAE;QACpE,MAAM,EAAEN,IAAI,EAAE,GAAGJ,UAAUC,OAAO;QAElCU,IAAI,IAAMC,YAAY,IAAOX,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG;QAEtDY,OAAOT,KAAK,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;YAAE,OAAO;QAAI;IACrD;IAEAK,GAAG,4DAA4D;QAC3D,MAAMR,QAAQS,WAAsB;YAChC,UAAU;gBAAE,GAAG;oBAAE,OAAO;gBAAM;gBAAG,GAAG;oBAAE,OAAO;gBAAI;YAAE;QACvD;QACA,MAAM,EAAEP,OAAO,EAAE,GAAGH,UAAUC,OAAO;QACrC,MAAMa,SAASX;QAEfQ,IAAI,IAAMC,YAAY,IAAOX,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG;QAEtDY,OAAOV,WAAW,IAAI,CAACW;IAC3B;AACJ"}
|
|
@@ -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"}
|
|
@@ -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, 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,
|
|
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"}
|
|
@@ -1 +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,
|
|
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"}
|
|
@@ -1 +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,
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/website-builder-react",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,20 +17,21 @@
|
|
|
17
17
|
],
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@webiny/cms-sdk": "6.6.0-alpha.
|
|
21
|
-
"@webiny/website-builder-sdk": "6.6.0-alpha.
|
|
22
|
-
"
|
|
23
|
-
"mobx": "7.1.
|
|
24
|
-
"mobx-react-lite": "5.1.
|
|
20
|
+
"@webiny/cms-sdk": "6.6.0-alpha.13",
|
|
21
|
+
"@webiny/website-builder-sdk": "6.6.0-alpha.13",
|
|
22
|
+
"lodash": "4.18.1",
|
|
23
|
+
"mobx": "7.1.7",
|
|
24
|
+
"mobx-react-lite": "5.1.3",
|
|
25
25
|
"react": "19.3.1",
|
|
26
26
|
"react-dom": "19.3.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@testing-library/react": "16.3.3",
|
|
30
|
+
"@types/lodash": "4.17.27",
|
|
30
31
|
"@types/react": "19.3.0",
|
|
31
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
32
|
+
"@webiny/build-tools": "6.6.0-alpha.13",
|
|
32
33
|
"typescript": "7.0.2",
|
|
33
|
-
"vitest": "5.
|
|
34
|
+
"vitest": "5.1.1"
|
|
34
35
|
},
|
|
35
36
|
"publishConfig": {
|
|
36
37
|
"access": "public"
|