@webiny/website-builder-vue 6.4.0-beta.4 → 6.4.0-beta.6
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/LICENSE +21 -0
- package/README.md +11 -0
- package/components/ConnectToEditor.d.ts +35 -0
- package/components/ConnectToEditor.js +40 -0
- package/components/ConnectToEditor.js.map +1 -0
- package/components/DocumentFragment.d.ts +67 -0
- package/components/DocumentFragment.js +24 -0
- package/components/DocumentFragment.js.map +1 -0
- package/components/DocumentRenderer.d.ts +59 -0
- package/components/DocumentRenderer.js +68 -0
- package/components/DocumentRenderer.js.map +1 -0
- package/components/DocumentStoreProvider.d.ts +37 -0
- package/components/DocumentStoreProvider.js +32 -0
- package/components/DocumentStoreProvider.js.map +1 -0
- package/components/EditingElementRenderer/EditingElementRenderer.d.ts +22 -0
- package/components/EditingElementRenderer/EditingElementRenderer.js +53 -0
- package/components/EditingElementRenderer/EditingElementRenderer.js.map +1 -0
- package/components/EditingElementRenderer/EditingElementRenderer.presenter.d.ts +15 -0
- package/components/EditingElementRenderer/EditingElementRenderer.presenter.js +37 -0
- package/components/EditingElementRenderer/EditingElementRenderer.presenter.js.map +1 -0
- package/components/EditingElementRenderer/index.js +2 -0
- package/components/ElementIndexProvider.d.ts +19 -0
- package/components/ElementIndexProvider.js +19 -0
- package/components/ElementIndexProvider.js.map +1 -0
- package/components/ElementRenderer.d.ts +19 -0
- package/components/ElementRenderer.js +33 -0
- package/components/ElementRenderer.js.map +1 -0
- package/components/ElementSlot.d.ts +39 -0
- package/components/ElementSlot.js +36 -0
- package/components/ElementSlot.js.map +1 -0
- package/components/ElementSlotDepthProvider.d.ts +19 -0
- package/components/ElementSlotDepthProvider.js +19 -0
- package/components/ElementSlotDepthProvider.js.map +1 -0
- package/components/FragmentsProvider.d.ts +46 -0
- package/components/FragmentsProvider.js +40 -0
- package/components/FragmentsProvider.js.map +1 -0
- package/components/LiveElementRenderer.d.ts +24 -0
- package/components/LiveElementRenderer.js +74 -0
- package/components/LiveElementRenderer.js.map +1 -0
- package/components/LiveElementSlot.d.ts +21 -0
- package/components/LiveElementSlot.js +36 -0
- package/components/LiveElementSlot.js.map +1 -0
- package/components/PreviewElementSlot.d.ts +38 -0
- package/components/PreviewElementSlot.js +45 -0
- package/components/PreviewElementSlot.js.map +1 -0
- package/{src/components/index.ts → components/index.d.ts} +2 -11
- package/components/index.js +8 -0
- package/composables/useBindingsForElement.d.ts +825 -0
- package/composables/useBindingsForElement.js +24 -0
- package/composables/useBindingsForElement.js.map +1 -0
- package/composables/useDocumentState.d.ts +5 -0
- package/composables/useDocumentState.js +11 -0
- package/composables/useDocumentState.js.map +1 -0
- package/composables/useObservable.d.ts +13 -0
- package/composables/useObservable.js +14 -0
- package/composables/useObservable.js.map +1 -0
- package/{src/composables/useSelectFromState.ts → composables/useSelectFromState.d.ts} +2 -10
- package/composables/useSelectFromState.js +9 -0
- package/composables/useSelectFromState.js.map +1 -0
- package/composables/useViewport.d.ts +7 -0
- package/composables/useViewport.js +18 -0
- package/composables/useViewport.js.map +1 -0
- package/createComponent.d.ts +21 -0
- package/createComponent.js +31 -0
- package/createComponent.js.map +1 -0
- package/editorComponents/Box.d.ts +7 -0
- package/editorComponents/Box.js +4 -0
- package/editorComponents/Box.js.map +1 -0
- package/editorComponents/Box.manifest.d.ts +1 -0
- package/{src/editorComponents/Box.manifest.ts → editorComponents/Box.manifest.js} +6 -4
- package/editorComponents/Box.manifest.js.map +1 -0
- package/editorComponents/Fragment.d.ts +13 -0
- package/editorComponents/Fragment.js +39 -0
- package/editorComponents/Fragment.js.map +1 -0
- package/editorComponents/Fragment.manifest.d.ts +1 -0
- package/{src/editorComponents/Fragment.manifest.ts → editorComponents/Fragment.manifest.js} +6 -4
- package/editorComponents/Fragment.manifest.js.map +1 -0
- package/editorComponents/Grid.d.ts +24 -0
- package/editorComponents/Grid.js +33 -0
- package/editorComponents/Grid.js.map +1 -0
- package/editorComponents/Grid.manifest.d.ts +1 -0
- package/{src/editorComponents/Grid.manifest.ts → editorComponents/Grid.manifest.js} +58 -55
- package/editorComponents/Grid.manifest.js.map +1 -0
- package/editorComponents/GridColumn.d.ts +5 -0
- package/editorComponents/GridColumn.js +4 -0
- package/editorComponents/GridColumn.js.map +1 -0
- package/editorComponents/GridColumn.manifest.d.ts +1 -0
- package/{src/editorComponents/GridColumn.manifest.ts → editorComponents/GridColumn.manifest.js} +9 -5
- package/editorComponents/GridColumn.manifest.js.map +1 -0
- package/editorComponents/Image.d.ts +37 -0
- package/editorComponents/Image.js +115 -0
- package/editorComponents/Image.js.map +1 -0
- package/editorComponents/Image.manifest.d.ts +1 -0
- package/{src/editorComponents/Image.manifest.ts → editorComponents/Image.manifest.js} +17 -12
- package/editorComponents/Image.manifest.js.map +1 -0
- package/editorComponents/Lexical.d.ts +18 -0
- package/editorComponents/Lexical.js +15 -0
- package/editorComponents/Lexical.js.map +1 -0
- package/editorComponents/Lexical.manifest.d.ts +1 -0
- package/editorComponents/Lexical.manifest.js +24 -0
- package/editorComponents/Lexical.manifest.js.map +1 -0
- package/editorComponents/Root.d.ts +7 -0
- package/editorComponents/Root.js +4 -0
- package/editorComponents/Root.js.map +1 -0
- package/editorComponents/Root.manifest.d.ts +1 -0
- package/{src/editorComponents/Root.manifest.ts → editorComponents/Root.manifest.js} +5 -3
- package/editorComponents/Root.manifest.js.map +1 -0
- package/{src/editorComponents/index.ts → editorComponents/index.d.ts} +1 -3
- package/editorComponents/index.js +20 -0
- package/editorComponents/index.js.map +1 -0
- package/index.d.ts +10 -0
- package/index.js +9 -4
- package/package.json +11 -10
- package/{src/types.ts → types.d.ts} +11 -32
- package/types.js +0 -0
- package/src/components/ConnectToEditor.ts +0 -46
- package/src/components/DocumentFragment.ts +0 -43
- package/src/components/DocumentRenderer.ts +0 -102
- package/src/components/DocumentStoreProvider.ts +0 -53
- package/src/components/EditingElementRenderer/EditingElementRenderer.presenter.ts +0 -59
- package/src/components/EditingElementRenderer/EditingElementRenderer.ts +0 -70
- package/src/components/ElementIndexProvider.ts +0 -24
- package/src/components/ElementRenderer.ts +0 -42
- package/src/components/ElementSlot.ts +0 -34
- package/src/components/ElementSlotDepthProvider.ts +0 -24
- package/src/components/FragmentsProvider.ts +0 -87
- package/src/components/LiveElementRenderer.ts +0 -102
- package/src/components/LiveElementSlot.ts +0 -46
- package/src/components/PreviewElementSlot.ts +0 -43
- package/src/composables/useBindingsForElement.ts +0 -40
- package/src/composables/useDocumentState.ts +0 -13
- package/src/composables/useObservable.ts +0 -30
- package/src/composables/useViewport.ts +0 -27
- package/src/createComponent.ts +0 -55
- package/src/editorComponents/Box.ts +0 -8
- package/src/editorComponents/Fragment.ts +0 -57
- package/src/editorComponents/Grid.ts +0 -72
- package/src/editorComponents/GridColumn.ts +0 -6
- package/src/editorComponents/Image.ts +0 -144
- package/src/editorComponents/Lexical.manifest.ts +0 -24
- package/src/editorComponents/Lexical.ts +0 -23
- package/src/editorComponents/Root.ts +0 -8
- package/src/index.ts +0 -52
- package/tsconfig.build.json +0 -16
- package/tsconfig.json +0 -16
- package/webiny.config.js +0 -8
- /package/{src/components/EditingElementRenderer/index.ts → components/EditingElementRenderer/index.d.ts} +0 -0
- /package/{src/lexical.css → lexical.css} +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { toJS } from "mobx";
|
|
3
|
+
import { BindingsProcessor } from "@webiny/website-builder-sdk";
|
|
4
|
+
import { useViewport } from "./useViewport.js";
|
|
5
|
+
import { useObservable } from "./useObservable.js";
|
|
6
|
+
import { useDocumentStore } from "../components/DocumentStoreProvider.js";
|
|
7
|
+
const useBindingsForElement = (elementId, breakpoint)=>{
|
|
8
|
+
const documentStore = useDocumentStore();
|
|
9
|
+
const viewport = useViewport();
|
|
10
|
+
const elementBindings = useObservable(()=>{
|
|
11
|
+
const doc = documentStore.getDocument();
|
|
12
|
+
if (!doc) return;
|
|
13
|
+
return toJS(doc.bindings[elementId]);
|
|
14
|
+
});
|
|
15
|
+
return computed(()=>{
|
|
16
|
+
const bindings = elementBindings.value ?? {};
|
|
17
|
+
const breakpoints = viewport.value?.breakpoints?.map((bp)=>bp.name) ?? [];
|
|
18
|
+
const processor = new BindingsProcessor(breakpoints);
|
|
19
|
+
return processor.getBindings(bindings, breakpoint.value);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export { useBindingsForElement };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=useBindingsForElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composables/useBindingsForElement.js","sources":["../../src/composables/useBindingsForElement.ts"],"sourcesContent":["import { computed, type Ref } from \"vue\";\nimport { toJS } from \"mobx\";\nimport { BindingsProcessor } from \"@webiny/website-builder-sdk\";\nimport { useViewport } from \"./useViewport.js\";\nimport { useObservable } from \"./useObservable.js\";\nimport { useDocumentStore } from \"~/components/DocumentStoreProvider.js\";\n\n/**\n * Returns a Vue computed ref containing the merged bindings (inputs + styles)\n * for the given element ID at the current breakpoint.\n *\n * Re-evaluates automatically when:\n * - the MobX document store changes (via useObservable)\n * - the breakpoint ref changes\n * - the viewport breakpoints change\n */\nexport const useBindingsForElement = (elementId: string, breakpoint: Ref<string>) => {\n const documentStore = useDocumentStore();\n const viewport = useViewport();\n\n // Observe this element's bindings directly inside the MobX autorun so that\n // deep mutations from applyPatch (e.g. adding a child element) trigger a\n // re-render without needing the top-level document reference to change.\n // toJS() inside the autorun causes MobX to track all sub-properties.\n const elementBindings = useObservable(() => {\n const doc = documentStore.getDocument();\n if (!doc) {\n return undefined;\n }\n return toJS(doc.bindings[elementId]);\n });\n\n return computed(() => {\n const bindings = elementBindings.value ?? {};\n const breakpoints =\n viewport.value?.breakpoints?.map((bp: { name: string }) => bp.name) ?? [];\n const processor = new BindingsProcessor(breakpoints);\n return processor.getBindings(bindings, breakpoint.value);\n });\n};\n"],"names":["useBindingsForElement","elementId","breakpoint","documentStore","useDocumentStore","viewport","useViewport","elementBindings","useObservable","doc","toJS","computed","bindings","breakpoints","bp","processor","BindingsProcessor"],"mappings":";;;;;;AAgBO,MAAMA,wBAAwB,CAACC,WAAmBC;IACrD,MAAMC,gBAAgBC;IACtB,MAAMC,WAAWC;IAMjB,MAAMC,kBAAkBC,cAAc;QAClC,MAAMC,MAAMN,cAAc,WAAW;QACrC,IAAI,CAACM,KACD;QAEJ,OAAOC,KAAKD,IAAI,QAAQ,CAACR,UAAU;IACvC;IAEA,OAAOU,SAAS;QACZ,MAAMC,WAAWL,gBAAgB,KAAK,IAAI,CAAC;QAC3C,MAAMM,cACFR,SAAS,KAAK,EAAE,aAAa,IAAI,CAACS,KAAyBA,GAAG,IAAI,KAAK,EAAE;QAC7E,MAAMC,YAAY,IAAIC,kBAAkBH;QACxC,OAAOE,UAAU,WAAW,CAACH,UAAUV,WAAW,KAAK;IAC3D;AACJ"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a Vue computed ref containing the document's `state` object.
|
|
3
|
+
* Re-evaluates whenever the MobX document store changes.
|
|
4
|
+
*/
|
|
5
|
+
export declare const useDocumentState: () => import("vue").ComputedRef<import("@webiny/website-builder-sdk/types.js").DocumentState>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useObservable } from "./useObservable.js";
|
|
3
|
+
import { useDocumentStore } from "../components/DocumentStoreProvider.js";
|
|
4
|
+
const useDocumentState = ()=>{
|
|
5
|
+
const documentStore = useDocumentStore();
|
|
6
|
+
const document = useObservable(()=>documentStore.getDocument());
|
|
7
|
+
return computed(()=>document.value?.state ?? {});
|
|
8
|
+
};
|
|
9
|
+
export { useDocumentState };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=useDocumentState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composables/useDocumentState.js","sources":["../../src/composables/useDocumentState.ts"],"sourcesContent":["import { computed } from \"vue\";\nimport { useObservable } from \"./useObservable.js\";\nimport { useDocumentStore } from \"~/components/DocumentStoreProvider.js\";\n\n/**\n * Returns a Vue computed ref containing the document's `state` object.\n * Re-evaluates whenever the MobX document store changes.\n */\nexport const useDocumentState = () => {\n const documentStore = useDocumentStore();\n const document = useObservable(() => documentStore.getDocument());\n return computed(() => document.value?.state ?? {});\n};\n"],"names":["useDocumentState","documentStore","useDocumentStore","document","useObservable","computed"],"mappings":";;;AAQO,MAAMA,mBAAmB;IAC5B,MAAMC,gBAAgBC;IACtB,MAAMC,WAAWC,cAAc,IAAMH,cAAc,WAAW;IAC9D,OAAOI,SAAS,IAAMF,SAAS,KAAK,EAAE,SAAS,CAAC;AACpD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Ref } from "vue";
|
|
2
|
+
/**
|
|
3
|
+
* Bridges a MobX observable into a Vue shallow ref.
|
|
4
|
+
*
|
|
5
|
+
* The supplied `fn` is run inside a MobX `autorun`. Every time a MobX
|
|
6
|
+
* observable accessed by `fn` changes, the ref is updated and Vue is told
|
|
7
|
+
* to treat it as "dirty" so that all computed values and templates that
|
|
8
|
+
* depend on it re-evaluate.
|
|
9
|
+
*
|
|
10
|
+
* Must be called inside a component setup() (or equivalent) so that
|
|
11
|
+
* `onUnmounted` can clean up the MobX reaction automatically.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useObservable<T>(fn: () => T): Ref<T>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getCurrentInstance, onUnmounted, shallowRef, triggerRef } from "vue";
|
|
2
|
+
import { autorun } from "mobx";
|
|
3
|
+
function useObservable(fn) {
|
|
4
|
+
const value = shallowRef(fn());
|
|
5
|
+
const disposer = autorun(()=>{
|
|
6
|
+
value.value = fn();
|
|
7
|
+
triggerRef(value);
|
|
8
|
+
});
|
|
9
|
+
if (getCurrentInstance()) onUnmounted(()=>disposer());
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
export { useObservable };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=useObservable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composables/useObservable.js","sources":["../../src/composables/useObservable.ts"],"sourcesContent":["import { shallowRef, onUnmounted, triggerRef, getCurrentInstance, type Ref } from \"vue\";\nimport { autorun } from \"mobx\";\n\n/**\n * Bridges a MobX observable into a Vue shallow ref.\n *\n * The supplied `fn` is run inside a MobX `autorun`. Every time a MobX\n * observable accessed by `fn` changes, the ref is updated and Vue is told\n * to treat it as \"dirty\" so that all computed values and templates that\n * depend on it re-evaluate.\n *\n * Must be called inside a component setup() (or equivalent) so that\n * `onUnmounted` can clean up the MobX reaction automatically.\n */\nexport function useObservable<T>(fn: () => T): Ref<T> {\n const value = shallowRef<T>(fn());\n\n const disposer = autorun(() => {\n value.value = fn();\n // shallowRef won't trigger on the same object reference; triggerRef\n // forces Vue to re-evaluate all dependents regardless.\n triggerRef(value);\n });\n\n if (getCurrentInstance()) {\n onUnmounted(() => disposer());\n }\n\n return value as Ref<T>;\n}\n"],"names":["useObservable","fn","value","shallowRef","disposer","autorun","triggerRef","getCurrentInstance","onUnmounted"],"mappings":";;AAcO,SAASA,cAAiBC,EAAW;IACxC,MAAMC,QAAQC,WAAcF;IAE5B,MAAMG,WAAWC,QAAQ;QACrBH,MAAM,KAAK,GAAGD;QAGdK,WAAWJ;IACf;IAEA,IAAIK,sBACAC,YAAY,IAAMJ;IAGtB,OAAOF;AACX"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useObservable } from "./useObservable.js";
|
|
3
|
-
|
|
1
|
+
import { type Ref } from "vue";
|
|
4
2
|
/**
|
|
5
3
|
* Selects a slice of MobX state and exposes it as a Vue computed ref.
|
|
6
4
|
*
|
|
@@ -9,10 +7,4 @@ import { useObservable } from "./useObservable.js";
|
|
|
9
7
|
* - `selector` is then applied to the latest state value in a Vue computed,
|
|
10
8
|
* so it also re-runs when any Vue reactive value accessed inside it changes.
|
|
11
9
|
*/
|
|
12
|
-
export function useSelectFromState<TState, T>(
|
|
13
|
-
getState: () => TState,
|
|
14
|
-
selector: (state: TState) => T
|
|
15
|
-
): Ref<T> {
|
|
16
|
-
const stateRef = useObservable(getState);
|
|
17
|
-
return computed(() => selector(stateRef.value)) as unknown as Ref<T>;
|
|
18
|
-
}
|
|
10
|
+
export declare function useSelectFromState<TState, T>(getState: () => TState, selector: (state: TState) => T): Ref<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useObservable } from "./useObservable.js";
|
|
3
|
+
function useSelectFromState(getState, selector) {
|
|
4
|
+
const stateRef = useObservable(getState);
|
|
5
|
+
return computed(()=>selector(stateRef.value));
|
|
6
|
+
}
|
|
7
|
+
export { useSelectFromState };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=useSelectFromState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composables/useSelectFromState.js","sources":["../../src/composables/useSelectFromState.ts"],"sourcesContent":["import { computed, type Ref } from \"vue\";\nimport { useObservable } from \"./useObservable.js\";\n\n/**\n * Selects a slice of MobX state and exposes it as a Vue computed ref.\n *\n * - `getState` is tracked by MobX: any observable accessed inside it causes\n * re-evaluation when it changes.\n * - `selector` is then applied to the latest state value in a Vue computed,\n * so it also re-runs when any Vue reactive value accessed inside it changes.\n */\nexport function useSelectFromState<TState, T>(\n getState: () => TState,\n selector: (state: TState) => T\n): Ref<T> {\n const stateRef = useObservable(getState);\n return computed(() => selector(stateRef.value)) as unknown as Ref<T>;\n}\n"],"names":["useSelectFromState","getState","selector","stateRef","useObservable","computed"],"mappings":";;AAWO,SAASA,mBACZC,QAAsB,EACtBC,QAA8B;IAE9B,MAAMC,WAAWC,cAAcH;IAC/B,OAAOI,SAAS,IAAMH,SAASC,SAAS,KAAK;AACjD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a reactive ref that contains the current viewport info.
|
|
3
|
+
*
|
|
4
|
+
* Starts with the current value (or a sensible default on the server) and
|
|
5
|
+
* updates whenever the viewport manager fires a change-end event.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useViewport: () => import("vue").ShallowRef<import("@webiny/website-builder-sdk").ViewportInfo, import("@webiny/website-builder-sdk").ViewportInfo>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { onMounted, onUnmounted, shallowRef, triggerRef } from "vue";
|
|
2
|
+
import { viewportManager } from "@webiny/website-builder-sdk";
|
|
3
|
+
const useViewport = ()=>{
|
|
4
|
+
const viewport = shallowRef(viewportManager.getViewport());
|
|
5
|
+
let unsubscribe;
|
|
6
|
+
onMounted(()=>{
|
|
7
|
+
viewport.value = viewportManager.getViewport();
|
|
8
|
+
unsubscribe = viewportManager.onViewportChangeEnd((newViewport)=>{
|
|
9
|
+
viewport.value = newViewport;
|
|
10
|
+
triggerRef(viewport);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
onUnmounted(()=>unsubscribe?.());
|
|
14
|
+
return viewport;
|
|
15
|
+
};
|
|
16
|
+
export { useViewport };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=useViewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composables/useViewport.js","sources":["../../src/composables/useViewport.ts"],"sourcesContent":["import { shallowRef, triggerRef, onMounted, onUnmounted } from \"vue\";\nimport { viewportManager } from \"@webiny/website-builder-sdk\";\n\n/**\n * Returns a reactive ref that contains the current viewport info.\n *\n * Starts with the current value (or a sensible default on the server) and\n * updates whenever the viewport manager fires a change-end event.\n */\nexport const useViewport = () => {\n const viewport = shallowRef(viewportManager.getViewport());\n let unsubscribe: (() => void) | undefined;\n\n onMounted(() => {\n // Sync the latest value after mount (in case a resize already happened).\n viewport.value = viewportManager.getViewport();\n\n unsubscribe = viewportManager.onViewportChangeEnd(newViewport => {\n viewport.value = newViewport;\n triggerRef(viewport);\n });\n });\n\n onUnmounted(() => unsubscribe?.());\n\n return viewport;\n};\n"],"names":["useViewport","viewport","shallowRef","viewportManager","unsubscribe","onMounted","newViewport","triggerRef","onUnmounted"],"mappings":";;AASO,MAAMA,cAAc;IACvB,MAAMC,WAAWC,WAAWC,gBAAgB,WAAW;IACvD,IAAIC;IAEJC,UAAU;QAENJ,SAAS,KAAK,GAAGE,gBAAgB,WAAW;QAE5CC,cAAcD,gBAAgB,mBAAmB,CAACG,CAAAA;YAC9CL,SAAS,KAAK,GAAGK;YACjBC,WAAWN;QACf;IACJ;IAEAO,YAAY,IAAMJ;IAElB,OAAOH;AACX"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Component, ComponentManifestInput } from "@webiny/website-builder-sdk";
|
|
2
|
+
import type { ExtractInputs } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a Vue component with a Webiny Website Builder manifest so it can be
|
|
5
|
+
* registered with the SDK and rendered inside a DocumentRenderer.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createComponent, createTextInput } from "@webiny/website-builder-vue";
|
|
10
|
+
*
|
|
11
|
+
* const MyBanner = (props: ComponentProps<{ headline: string }>) =>
|
|
12
|
+
* h("div", props.inputs.headline);
|
|
13
|
+
*
|
|
14
|
+
* export const Banner = createComponent(MyBanner, {
|
|
15
|
+
* name: "My/Banner",
|
|
16
|
+
* label: "Banner",
|
|
17
|
+
* inputs: { headline: createTextInput({ label: "Headline" }) }
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function createComponent<TComponent extends (props: any) => any, TInputs extends ExtractInputs<Parameters<TComponent>[0]>>(component: TComponent, manifest: ComponentManifestInput<TInputs>): Component;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createSlotInput } from "@webiny/website-builder-sdk";
|
|
2
|
+
function createComponent(component, manifest) {
|
|
3
|
+
const inputs = [];
|
|
4
|
+
if (Array.isArray(manifest.inputs)) inputs.push(...manifest.inputs);
|
|
5
|
+
else {
|
|
6
|
+
const inputsObject = manifest.inputs ?? {};
|
|
7
|
+
Object.keys(inputsObject).forEach((name)=>{
|
|
8
|
+
inputs.push({
|
|
9
|
+
...inputsObject[name],
|
|
10
|
+
name
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if (manifest.acceptsChildren) {
|
|
15
|
+
const hasChildren = inputs.some((input)=>"children" === input.name);
|
|
16
|
+
if (!hasChildren) inputs.push(createSlotInput({
|
|
17
|
+
name: "children"
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
component,
|
|
22
|
+
manifest: {
|
|
23
|
+
...manifest,
|
|
24
|
+
tags: manifest.tags ?? [],
|
|
25
|
+
inputs
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export { createComponent };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=createComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createComponent.js","sources":["../src/createComponent.ts"],"sourcesContent":["import type {\n Component,\n ComponentInput,\n ComponentManifest,\n ComponentManifestInput,\n InputFactory\n} from \"@webiny/website-builder-sdk\";\nimport { createSlotInput } from \"@webiny/website-builder-sdk\";\nimport type { ExtractInputs } from \"~/types.js\";\n\n/**\n * Wraps a Vue component with a Webiny Website Builder manifest so it can be\n * registered with the SDK and rendered inside a DocumentRenderer.\n *\n * Usage:\n * ```ts\n * import { createComponent, createTextInput } from \"@webiny/website-builder-vue\";\n *\n * const MyBanner = (props: ComponentProps<{ headline: string }>) =>\n * h(\"div\", props.inputs.headline);\n *\n * export const Banner = createComponent(MyBanner, {\n * name: \"My/Banner\",\n * label: \"Banner\",\n * inputs: { headline: createTextInput({ label: \"Headline\" }) }\n * });\n * ```\n */\nexport function createComponent<\n TComponent extends (props: any) => any,\n TInputs extends ExtractInputs<Parameters<TComponent>[0]>\n>(component: TComponent, manifest: ComponentManifestInput<TInputs>): Component {\n const inputs: ComponentInput[] = [];\n\n if (Array.isArray(manifest.inputs)) {\n inputs.push(...manifest.inputs);\n } else {\n const inputsObject: Record<string, InputFactory<any>> = manifest.inputs ?? {};\n Object.keys(inputsObject).forEach((name: string) => {\n inputs.push({ ...inputsObject[name], name });\n });\n }\n\n if (manifest.acceptsChildren) {\n const hasChildren = inputs.some(input => input.name === \"children\");\n if (!hasChildren) {\n inputs.push(createSlotInput({ name: \"children\" }));\n }\n }\n\n return {\n component,\n manifest: { ...manifest, tags: manifest.tags ?? [], inputs } as ComponentManifest\n };\n}\n"],"names":["createComponent","component","manifest","inputs","Array","inputsObject","Object","name","hasChildren","input","createSlotInput"],"mappings":";AA4BO,SAASA,gBAGdC,SAAqB,EAAEC,QAAyC;IAC9D,MAAMC,SAA2B,EAAE;IAEnC,IAAIC,MAAM,OAAO,CAACF,SAAS,MAAM,GAC7BC,OAAO,IAAI,IAAID,SAAS,MAAM;SAC3B;QACH,MAAMG,eAAkDH,SAAS,MAAM,IAAI,CAAC;QAC5EI,OAAO,IAAI,CAACD,cAAc,OAAO,CAAC,CAACE;YAC/BJ,OAAO,IAAI,CAAC;gBAAE,GAAGE,YAAY,CAACE,KAAK;gBAAEA;YAAK;QAC9C;IACJ;IAEA,IAAIL,SAAS,eAAe,EAAE;QAC1B,MAAMM,cAAcL,OAAO,IAAI,CAACM,CAAAA,QAASA,AAAe,eAAfA,MAAM,IAAI;QACnD,IAAI,CAACD,aACDL,OAAO,IAAI,CAACO,gBAAgB;YAAE,MAAM;QAAW;IAEvD;IAEA,OAAO;QACHT;QACA,UAAU;YAAE,GAAGC,QAAQ;YAAE,MAAMA,SAAS,IAAI,IAAI,EAAE;YAAEC;QAAO;IAC/D;AACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ComponentPropsWithChildren } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A generic container that renders only its children slot.
|
|
4
|
+
*/
|
|
5
|
+
export declare const BoxComponent: (props: ComponentPropsWithChildren) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}> | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorComponents/Box.js","sources":["../../src/editorComponents/Box.ts"],"sourcesContent":["import type { ComponentPropsWithChildren } from \"~/types.js\";\n\n/**\n * A generic container that renders only its children slot.\n */\nexport const BoxComponent = (props: ComponentPropsWithChildren) => {\n return props.inputs?.children ?? null;\n};\n"],"names":["BoxComponent","props"],"mappings":"AAKO,MAAMA,eAAe,CAACC,QAClBA,MAAM,MAAM,EAAE,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Box: import("@webiny/website-builder-sdk/types.js").Component;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createComponent } from "
|
|
2
|
+
import { createComponent } from "../createComponent.js";
|
|
3
3
|
import { BoxComponent } from "./Box.js";
|
|
4
|
-
|
|
5
|
-
export const Box = createComponent(BoxComponent, {
|
|
4
|
+
const Box = createComponent(BoxComponent, {
|
|
6
5
|
name: "Webiny/Box",
|
|
7
6
|
label: "Box",
|
|
8
7
|
group: "basic",
|
|
9
|
-
image:
|
|
8
|
+
image: '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M120-120v-720h720v720H120Zm80-80h560v-560H200v560Zm0 0v-560 560Z"/></svg>',
|
|
10
9
|
acceptsChildren: true,
|
|
11
10
|
defaults: {
|
|
12
11
|
styles: {
|
|
@@ -17,3 +16,6 @@ export const Box = createComponent(BoxComponent, {
|
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
});
|
|
19
|
+
export { Box };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=Box.manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorComponents/Box.manifest.js","sources":["../../src/editorComponents/Box.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { BoxComponent } from \"./Box.js\";\n\nexport const Box = createComponent(BoxComponent, {\n name: \"Webiny/Box\",\n label: \"Box\",\n group: \"basic\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#e8eaed\"><path d=\"M120-120v-720h720v720H120Zm80-80h560v-560H200v560Zm0 0v-560 560Z\"/></svg>`,\n acceptsChildren: true,\n defaults: {\n styles: {\n paddingTop: \"5px\",\n paddingRight: \"5px\",\n paddingBottom: \"5px\",\n paddingLeft: \"5px\"\n }\n }\n});\n"],"names":["Box","createComponent","BoxComponent"],"mappings":";;;AAIO,MAAMA,MAAMC,gBAAgBC,cAAc;IAC7C,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,iBAAiB;IACjB,UAAU;QACN,QAAQ;YACJ,YAAY;YACZ,cAAc;YACd,eAAe;YACf,aAAa;QACjB;IACJ;AACJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentProps } from "../types.js";
|
|
2
|
+
type FragmentProps = ComponentProps<{
|
|
3
|
+
name: string;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* Looks up a named fixed fragment provided by the consumer's DocumentRenderer
|
|
7
|
+
* and renders it in place. Shows a placeholder in editing mode when no
|
|
8
|
+
* matching fragment is found.
|
|
9
|
+
*/
|
|
10
|
+
export declare const FragmentComponent: (props: FragmentProps) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}> | null;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { h } from "vue";
|
|
2
|
+
import { contentSdk } from "@webiny/website-builder-sdk";
|
|
3
|
+
import { useDocumentFragments } from "../components/FragmentsProvider.js";
|
|
4
|
+
const findFixed = (fragments, name)=>fragments.find((f)=>"fixed" === f.type && f.name === name);
|
|
5
|
+
const FragmentPlaceholder = (props)=>{
|
|
6
|
+
const label = props.name ? h("strong", null, [
|
|
7
|
+
` ${props.name} `
|
|
8
|
+
]) : " ";
|
|
9
|
+
return h("div", {
|
|
10
|
+
style: {
|
|
11
|
+
display: "flex",
|
|
12
|
+
height: "100px",
|
|
13
|
+
backgroundColor: "#f4f4f4",
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
fill: "#ffffff"
|
|
17
|
+
}
|
|
18
|
+
}, [
|
|
19
|
+
"This is a placeholder for",
|
|
20
|
+
label,
|
|
21
|
+
"content coming from your frontend app."
|
|
22
|
+
]);
|
|
23
|
+
};
|
|
24
|
+
const FragmentComponent = (props)=>{
|
|
25
|
+
const isEditing = contentSdk.isEditing();
|
|
26
|
+
const fragments = useDocumentFragments();
|
|
27
|
+
const fragment = findFixed(fragments, props.inputs?.name);
|
|
28
|
+
if (!fragment && isEditing) return h(FragmentPlaceholder, {
|
|
29
|
+
name: props.inputs?.name
|
|
30
|
+
});
|
|
31
|
+
if (fragment) {
|
|
32
|
+
if ("function" == typeof fragment.element) return h("div", null, fragment.element());
|
|
33
|
+
return fragment.element;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
};
|
|
37
|
+
export { FragmentComponent };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=Fragment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorComponents/Fragment.js","sources":["../../src/editorComponents/Fragment.ts"],"sourcesContent":["import { h } from \"vue\";\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\";\nimport type { DocumentFragmentConfig } from \"~/components/FragmentsProvider.js\";\n\ntype FragmentProps = ComponentProps<{ name: string }>;\n\nconst findFixed = (fragments: DocumentFragments, name: string) =>\n fragments.find(f => f.type === \"fixed\" && f.name === name) as\n | Extract<DocumentFragmentConfig, { type: \"fixed\" }>\n | undefined;\n\nconst FragmentPlaceholder = (props: { name: string }) => {\n const label = props.name ? h(\"strong\", null, [` ${props.name} `]) : \" \";\n\n return h(\n \"div\",\n {\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\", label, \"content coming from your frontend app.\"]\n );\n};\n\n/**\n * Looks up a named fixed fragment provided by the consumer's DocumentRenderer\n * and renders it in place. Shows a placeholder in editing mode when no\n * matching fragment is found.\n */\nexport const FragmentComponent = (props: FragmentProps) => {\n const isEditing = contentSdk.isEditing();\n const fragments = useDocumentFragments();\n const fragment = findFixed(fragments, props.inputs?.name);\n\n if (!fragment && isEditing) {\n return h(FragmentPlaceholder, { name: props.inputs?.name });\n }\n\n if (fragment) {\n // `element` is a Vue slot function (() => VNode[]) or a VNode.\n if (typeof fragment.element === \"function\") {\n return h(\"div\", null, fragment.element());\n }\n return fragment.element;\n }\n\n return null;\n};\n"],"names":["findFixed","fragments","name","f","FragmentPlaceholder","props","label","h","FragmentComponent","isEditing","contentSdk","useDocumentFragments","fragment"],"mappings":";;;AASA,MAAMA,YAAY,CAACC,WAA8BC,OAC7CD,UAAU,IAAI,CAACE,CAAAA,IAAKA,AAAW,YAAXA,EAAE,IAAI,IAAgBA,EAAE,IAAI,KAAKD;AAIzD,MAAME,sBAAsB,CAACC;IACzB,MAAMC,QAAQD,MAAM,IAAI,GAAGE,EAAE,UAAU,MAAM;QAAC,CAAC,CAAC,EAAEF,MAAM,IAAI,CAAC,CAAC,CAAC;KAAC,IAAI;IAEpE,OAAOE,EACH,OACA;QACI,OAAO;YACH,SAAS;YACT,QAAQ;YACR,iBAAiB;YACjB,gBAAgB;YAChB,YAAY;YACZ,MAAM;QACV;IACJ,GACA;QAAC;QAA6BD;QAAO;KAAyC;AAEtF;AAOO,MAAME,oBAAoB,CAACH;IAC9B,MAAMI,YAAYC,WAAW,SAAS;IACtC,MAAMT,YAAYU;IAClB,MAAMC,WAAWZ,UAAUC,WAAWI,MAAM,MAAM,EAAE;IAEpD,IAAI,CAACO,YAAYH,WACb,OAAOF,EAAEH,qBAAqB;QAAE,MAAMC,MAAM,MAAM,EAAE;IAAK;IAG7D,IAAIO,UAAU;QAEV,IAAI,AAA4B,cAA5B,OAAOA,SAAS,OAAO,EACvB,OAAOL,EAAE,OAAO,MAAMK,SAAS,OAAO;QAE1C,OAAOA,SAAS,OAAO;IAC3B;IAEA,OAAO;AACX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Fragment: import("@webiny/website-builder-sdk").Component;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createTextInput } from "@webiny/website-builder-sdk";
|
|
3
|
-
import { createComponent } from "
|
|
3
|
+
import { createComponent } from "../createComponent.js";
|
|
4
4
|
import { FragmentComponent } from "./Fragment.js";
|
|
5
|
-
|
|
6
|
-
export const Fragment = createComponent(FragmentComponent, {
|
|
5
|
+
const Fragment = createComponent(FragmentComponent, {
|
|
7
6
|
name: "Webiny/Fragment",
|
|
8
7
|
label: "Fragment",
|
|
9
8
|
group: "basic",
|
|
10
|
-
image:
|
|
9
|
+
image: '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M120-120v-720h720v720H120Zm80-80h560v-560H200v560Zm0 0v-560 560Z"/></svg>',
|
|
11
10
|
inputs: [
|
|
12
11
|
createTextInput({
|
|
13
12
|
name: "name",
|
|
@@ -17,3 +16,6 @@ export const Fragment = createComponent(FragmentComponent, {
|
|
|
17
16
|
})
|
|
18
17
|
]
|
|
19
18
|
});
|
|
19
|
+
export { Fragment };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=Fragment.manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorComponents/Fragment.manifest.js","sources":["../../src/editorComponents/Fragment.manifest.ts"],"sourcesContent":["\"use client\";\nimport { createTextInput } from \"@webiny/website-builder-sdk\";\nimport { createComponent } from \"~/createComponent.js\";\nimport { FragmentComponent } from \"./Fragment.js\";\n\nexport const Fragment = createComponent(FragmentComponent, {\n name: \"Webiny/Fragment\",\n label: \"Fragment\",\n group: \"basic\",\n image: `<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#e8eaed\"><path d=\"M120-120v-720h720v720H120Zm80-80h560v-560H200v560Zm0 0v-560 560Z\"/></svg>`,\n inputs: [\n createTextInput({\n name: \"name\",\n label: \"Fragment\",\n description: \"Select fragment to display.\",\n renderer: \"Webiny/FragmentSelector\"\n })\n ]\n});\n"],"names":["Fragment","createComponent","FragmentComponent","createTextInput"],"mappings":";;;;AAKO,MAAMA,WAAWC,gBAAgBC,mBAAmB;IACvD,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,QAAQ;QACJC,gBAAgB;YACZ,MAAM;YACN,OAAO;YACP,aAAa;YACb,UAAU;QACd;KACH;AACL"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ComponentProps } from "../types.js";
|
|
2
|
+
import type { VNode } from "vue";
|
|
3
|
+
interface Column {
|
|
4
|
+
children: VNode | null;
|
|
5
|
+
}
|
|
6
|
+
type GridProps = ComponentProps<{
|
|
7
|
+
gridLayout: string;
|
|
8
|
+
rowCount: number;
|
|
9
|
+
rowGap: number;
|
|
10
|
+
columnGap: number;
|
|
11
|
+
columns: Column[];
|
|
12
|
+
stackAtBreakpoint?: string;
|
|
13
|
+
reverseWhenStacked?: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Renders a flexible CSS grid with rows/columns derived from `gridLayout`
|
|
17
|
+
* (e.g. "6-6" = two equal columns, "4-8" = one-third + two-thirds, etc.).
|
|
18
|
+
*
|
|
19
|
+
* The children of each column are VNodes resolved by the SDK (ElementSlot).
|
|
20
|
+
*/
|
|
21
|
+
export declare const GridComponent: (props: GridProps) => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { h } from "vue";
|
|
2
|
+
const GridComponent = (props)=>{
|
|
3
|
+
const { inputs, styles, breakpoint } = props;
|
|
4
|
+
const { gridLayout = "12", columns = [], columnGap, stackAtBreakpoint, reverseWhenStacked } = inputs;
|
|
5
|
+
const rowConfig = gridLayout.split("-").map((s)=>parseInt(s));
|
|
6
|
+
const rows = [];
|
|
7
|
+
for(let i = 0; i < columns.length; i += rowConfig.length)rows.push(columns.slice(i, i + rowConfig.length));
|
|
8
|
+
const cellWidthReduction = columnGap ? columnGap - columnGap / rowConfig.length : 0;
|
|
9
|
+
const stackColumns = breakpoint === stackAtBreakpoint;
|
|
10
|
+
const gridStyles = {
|
|
11
|
+
...styles
|
|
12
|
+
};
|
|
13
|
+
if (stackColumns) gridStyles.flexDirection = reverseWhenStacked ? "column-reverse" : "column";
|
|
14
|
+
const cells = rows.flatMap((rowCols)=>rowCols.map((col, i)=>{
|
|
15
|
+
const width = stackColumns ? "100%" : `calc(${rowConfig[i] / 12 * 100}% - ${cellWidthReduction}px)`;
|
|
16
|
+
return h("div", {
|
|
17
|
+
key: i,
|
|
18
|
+
style: {
|
|
19
|
+
flex: `0 0 ${width}`,
|
|
20
|
+
maxWidth: width,
|
|
21
|
+
boxSizing: "border-box"
|
|
22
|
+
}
|
|
23
|
+
}, [
|
|
24
|
+
col.children
|
|
25
|
+
]);
|
|
26
|
+
}));
|
|
27
|
+
return h("div", {
|
|
28
|
+
style: gridStyles
|
|
29
|
+
}, cells);
|
|
30
|
+
};
|
|
31
|
+
export { GridComponent };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=Grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editorComponents/Grid.js","sources":["../../src/editorComponents/Grid.ts"],"sourcesContent":["import { h } from \"vue\";\nimport type { ComponentProps } from \"~/types.js\";\nimport type { VNode } from \"vue\";\n\ninterface Column {\n children: VNode | null;\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\n/**\n * Renders a flexible CSS grid with rows/columns derived from `gridLayout`\n * (e.g. \"6-6\" = two equal columns, \"4-8\" = one-third + two-thirds, etc.).\n *\n * The children of each column are VNodes resolved by the SDK (ElementSlot).\n */\nexport const GridComponent = (props: GridProps) => {\n const { inputs, styles, breakpoint } = props;\n const {\n gridLayout = \"12\",\n columns = [],\n columnGap,\n stackAtBreakpoint,\n reverseWhenStacked\n } = inputs;\n\n const rowConfig = gridLayout.split(\"-\").map(s => parseInt(s));\n const rows: Column[][] = [];\n\n for (let i = 0; i < columns.length; i += rowConfig.length) {\n rows.push(columns.slice(i, i + rowConfig.length));\n }\n\n const cellWidthReduction = columnGap ? columnGap - columnGap / rowConfig.length : 0;\n const stackColumns = breakpoint === stackAtBreakpoint;\n\n const gridStyles = { ...styles };\n if (stackColumns) {\n gridStyles.flexDirection = reverseWhenStacked ? \"column-reverse\" : \"column\";\n }\n\n const cells = rows.flatMap(rowCols =>\n rowCols.map((col, i) => {\n const width = stackColumns\n ? \"100%\"\n : `calc(${(rowConfig[i] / 12) * 100}% - ${cellWidthReduction}px)`;\n\n return h(\n \"div\",\n {\n key: i,\n style: {\n flex: `0 0 ${width}`,\n maxWidth: width,\n boxSizing: \"border-box\"\n }\n },\n [col.children]\n );\n })\n );\n\n return h(\"div\", { style: gridStyles }, cells);\n};\n"],"names":["GridComponent","props","inputs","styles","breakpoint","gridLayout","columns","columnGap","stackAtBreakpoint","reverseWhenStacked","rowConfig","s","parseInt","rows","i","cellWidthReduction","stackColumns","gridStyles","cells","rowCols","col","width","h"],"mappings":";AAwBO,MAAMA,gBAAgB,CAACC;IAC1B,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAE,GAAGH;IACvC,MAAM,EACFI,aAAa,IAAI,EACjBC,UAAU,EAAE,EACZC,SAAS,EACTC,iBAAiB,EACjBC,kBAAkB,EACrB,GAAGP;IAEJ,MAAMQ,YAAYL,WAAW,KAAK,CAAC,KAAK,GAAG,CAACM,CAAAA,IAAKC,SAASD;IAC1D,MAAME,OAAmB,EAAE;IAE3B,IAAK,IAAIC,IAAI,GAAGA,IAAIR,QAAQ,MAAM,EAAEQ,KAAKJ,UAAU,MAAM,CACrDG,KAAK,IAAI,CAACP,QAAQ,KAAK,CAACQ,GAAGA,IAAIJ,UAAU,MAAM;IAGnD,MAAMK,qBAAqBR,YAAYA,YAAYA,YAAYG,UAAU,MAAM,GAAG;IAClF,MAAMM,eAAeZ,eAAeI;IAEpC,MAAMS,aAAa;QAAE,GAAGd,MAAM;IAAC;IAC/B,IAAIa,cACAC,WAAW,aAAa,GAAGR,qBAAqB,mBAAmB;IAGvE,MAAMS,QAAQL,KAAK,OAAO,CAACM,CAAAA,UACvBA,QAAQ,GAAG,CAAC,CAACC,KAAKN;YACd,MAAMO,QAAQL,eACR,SACA,CAAC,KAAK,EAAGN,SAAS,CAACI,EAAE,GAAG,KAAM,IAAI,IAAI,EAAEC,mBAAmB,GAAG,CAAC;YAErE,OAAOO,EACH,OACA;gBACI,KAAKR;gBACL,OAAO;oBACH,MAAM,CAAC,IAAI,EAAEO,OAAO;oBACpB,UAAUA;oBACV,WAAW;gBACf;YACJ,GACA;gBAACD,IAAI,QAAQ;aAAC;QAEtB;IAGJ,OAAOE,EAAE,OAAO;QAAE,OAAOL;IAAW,GAAGC;AAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Grid: import("@webiny/website-builder-sdk").Component;
|