@composy/layout-vue 0.0.1 → 0.0.2
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/CHANGELOG.md +57 -0
- package/README.md +82 -75
- package/dist/index.css +9 -3
- package/dist/index.js +22 -11
- package/dist/index.js.map +1 -1
- package/dist/index.min.css +1 -1
- package/dist/index.min.js +2038 -1
- package/dist/index.min.js.map +1 -0
- package/es/.dts-output-manifest.json +1 -0
- package/es/.dts.tsbuildinfo +1 -0
- package/es/components/LGrid.d.ts +0 -1
- package/es/components/LGrid.js +3 -3
- package/es/components/LGrid.js.map +1 -1
- package/es/components/LGridItem.d.ts +0 -1
- package/es/components/LGridItem.d.ts.map +1 -1
- package/es/components/LGridItem.js +4 -2
- package/es/components/LGridItem.js.map +1 -1
- package/es/components/LLayoutEditor.d.ts +5 -5
- package/es/components/LLayoutEditor.d.ts.map +1 -1
- package/es/components/LLayoutEditor.js +2 -2
- package/es/components/LLayoutEditor.js.map +1 -1
- package/es/components/LLayoutWorkspace.js +1 -1
- package/es/components/LLayoutWorkspace.js.map +1 -1
- package/es/components/LLayoutWorkspace.vue_vue_type_script_setup_true_lang.js +8 -5
- package/es/components/LLayoutWorkspace.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/es/components/LMaterialDragSource.d.ts +0 -1
- package/es/components/LMaterialDragSource.js +1 -1
- package/es/components/LMaterialRenderer.d.ts +0 -1
- package/es/components/LMaterialRenderer.js +1 -1
- package/es/components/LMetricCard.d.ts +0 -1
- package/es/components/LMetricCard.js +1 -1
- package/es/components/LTrendCard.d.ts +0 -1
- package/es/components/LTrendCard.js +1 -1
- package/es/components/index.d.ts +0 -1
- package/es/components/index.js +3 -3
- package/es/components/material-renderer.d.ts +0 -1
- package/es/components/material-renderer.d.ts.map +1 -1
- package/es/components/material-renderer.js +10 -3
- package/es/components/material-renderer.js.map +1 -1
- package/es/composables/index.d.ts +0 -1
- package/es/composables/index.js +1 -1
- package/es/composables/useLayoutEditor.d.ts +0 -1
- package/es/composables/useLayoutEditor.js +1 -1
- package/es/index.d.ts +0 -1
- package/es/index.js +3 -5
- package/es/style/css.js +1 -1
- package/es/style/index.css +1 -0
- package/es/style/index.js +1 -1
- package/es/style/workspace.css +18 -2
- package/es/types.d.ts +0 -1
- package/es/types.js +1 -1
- package/esm/components/LGrid.d.ts.map +1 -0
- package/esm/components/LGrid.js +91 -0
- package/esm/components/LGrid.js.map +1 -0
- package/esm/components/LGridItem.d.ts.map +1 -0
- package/esm/components/LGridItem.js +54 -0
- package/esm/components/LGridItem.js.map +1 -0
- package/esm/components/LLayoutEditor.d.ts +50 -0
- package/esm/components/LLayoutEditor.d.ts.map +1 -0
- package/esm/components/LLayoutEditor.js +81 -0
- package/esm/components/LLayoutEditor.js.map +1 -0
- package/esm/components/LLayoutWorkspace.js +17 -0
- package/esm/components/LLayoutWorkspace.js.map +1 -0
- package/esm/components/LLayoutWorkspace.vue_vue_type_script_setup_true_lang.js +2220 -0
- package/esm/components/LLayoutWorkspace.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/esm/components/LMaterialDragSource.d.ts.map +1 -0
- package/esm/components/LMaterialDragSource.js +92 -0
- package/esm/components/LMaterialDragSource.js.map +1 -0
- package/esm/components/LMaterialRenderer.d.ts.map +1 -0
- package/esm/components/LMaterialRenderer.js +48 -0
- package/esm/components/LMaterialRenderer.js.map +1 -0
- package/esm/components/LMetricCard.d.ts.map +1 -0
- package/esm/components/LMetricCard.js +39 -0
- package/esm/components/LMetricCard.js.map +1 -0
- package/esm/components/LTrendCard.d.ts.map +1 -0
- package/esm/components/LTrendCard.js +36 -0
- package/esm/components/LTrendCard.js.map +1 -0
- package/esm/components/index.d.ts.map +1 -0
- package/esm/components/index.js +19 -0
- package/esm/components/material-renderer.d.ts.map +1 -0
- package/esm/components/material-renderer.js +103 -0
- package/esm/components/material-renderer.js.map +1 -0
- package/esm/composables/index.d.ts.map +1 -0
- package/esm/composables/index.js +12 -0
- package/esm/composables/useLayoutEditor.d.ts.map +1 -0
- package/esm/composables/useLayoutEditor.js +22 -0
- package/esm/composables/useLayoutEditor.js.map +1 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +22 -0
- package/esm/style/css.js +1 -0
- package/esm/style/index.js +1 -0
- package/{es → esm}/style/index.less +1 -1
- package/esm/style/workspace.css +2379 -0
- package/esm/types.d.ts.map +1 -0
- package/esm/types.js +10 -0
- package/lib/components/LGrid.cjs +3 -3
- package/lib/components/LGrid.cjs.map +1 -1
- package/lib/components/LGrid.d.cts +2 -0
- package/lib/components/LGrid.d.cts.map +1 -0
- package/lib/components/LGridItem.cjs +4 -2
- package/lib/components/LGridItem.cjs.map +1 -1
- package/lib/components/LGridItem.d.cts +51 -0
- package/lib/components/LGridItem.d.cts.map +1 -0
- package/lib/components/LLayoutEditor.cjs +2 -2
- package/lib/components/LLayoutEditor.cjs.map +1 -1
- package/lib/components/{LLayoutEditor.d.ts → LLayoutEditor.d.cts} +5 -5
- package/lib/components/LLayoutEditor.d.cts.map +1 -0
- package/lib/components/LLayoutWorkspace.cjs +1 -1
- package/lib/components/LLayoutWorkspace.cjs.map +1 -1
- package/lib/components/LLayoutWorkspace.vue_vue_type_script_setup_true_lang.cjs +8 -5
- package/lib/components/LLayoutWorkspace.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/lib/components/LMaterialDragSource.cjs +1 -1
- package/lib/components/LMaterialDragSource.d.cts +54 -0
- package/lib/components/LMaterialDragSource.d.cts.map +1 -0
- package/lib/components/LMaterialRenderer.cjs +1 -1
- package/lib/components/LMaterialRenderer.d.cts +62 -0
- package/lib/components/LMaterialRenderer.d.cts.map +1 -0
- package/lib/components/LMetricCard.cjs +1 -1
- package/lib/components/LMetricCard.d.cts +28 -0
- package/lib/components/LMetricCard.d.cts.map +1 -0
- package/lib/components/LTrendCard.cjs +1 -1
- package/lib/components/LTrendCard.d.cts +16 -0
- package/lib/components/LTrendCard.d.cts.map +1 -0
- package/lib/components/index.cjs +1 -1
- package/lib/components/index.d.cts +9 -0
- package/lib/components/index.d.cts.map +1 -0
- package/lib/components/material-renderer.cjs +10 -3
- package/lib/components/material-renderer.cjs.map +1 -1
- package/lib/components/material-renderer.d.cts +25 -0
- package/lib/components/material-renderer.d.cts.map +1 -0
- package/lib/composables/index.cjs +1 -1
- package/lib/composables/index.d.cts +1 -0
- package/lib/composables/index.d.cts.map +1 -0
- package/lib/composables/useLayoutEditor.cjs +1 -1
- package/lib/composables/useLayoutEditor.d.cts +2 -0
- package/lib/composables/useLayoutEditor.d.cts.map +1 -0
- package/lib/index.cjs +1 -1
- package/lib/index.d.cts +6 -0
- package/lib/index.d.cts.map +1 -0
- package/lib/style/index.css +0 -1
- package/lib/style/workspace.css +9 -1
- package/lib/types.cjs +1 -1
- package/lib/types.d.cts +25 -0
- package/lib/types.d.cts.map +1 -0
- package/package.json +25 -18
- /package/{lib → esm}/components/LGrid.d.ts +0 -0
- /package/{lib → esm}/components/LGridItem.d.ts +0 -0
- /package/{lib → esm}/components/LMaterialDragSource.d.ts +0 -0
- /package/{lib → esm}/components/LMaterialRenderer.d.ts +0 -0
- /package/{lib → esm}/components/LMetricCard.d.ts +0 -0
- /package/{lib → esm}/components/LTrendCard.d.ts +0 -0
- /package/{lib → esm}/components/index.d.ts +0 -0
- /package/{lib → esm}/components/material-renderer.d.ts +0 -0
- /package/{lib → esm}/composables/index.d.ts +0 -0
- /package/{lib → esm}/composables/useLayoutEditor.d.ts +0 -0
- /package/{lib → esm}/index.d.ts +0 -0
- /package/{lib → esm}/types.d.ts +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/layout-vue v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-10-12 17:52:50 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
import { defineComponent, h, onBeforeUnmount, onMounted } from "vue";
|
|
11
|
+
//#region src/components/LMaterialDragSource.ts
|
|
12
|
+
const LMaterialDragSource = defineComponent({
|
|
13
|
+
name: "LMaterialDragSource",
|
|
14
|
+
props: {
|
|
15
|
+
/** Backwards-compatible shorthand when no full material definition is supplied. */
|
|
16
|
+
type: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: void 0
|
|
19
|
+
},
|
|
20
|
+
material: {
|
|
21
|
+
type: Object,
|
|
22
|
+
default: void 0
|
|
23
|
+
},
|
|
24
|
+
props: {
|
|
25
|
+
type: Object,
|
|
26
|
+
default: () => ({})
|
|
27
|
+
},
|
|
28
|
+
placement: {
|
|
29
|
+
type: Object,
|
|
30
|
+
default: void 0
|
|
31
|
+
},
|
|
32
|
+
editor: {
|
|
33
|
+
type: Object,
|
|
34
|
+
required: true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
setup(props, { slots }) {
|
|
38
|
+
let unregister = () => {};
|
|
39
|
+
let element;
|
|
40
|
+
const definition = props.material;
|
|
41
|
+
const materialType = definition?.type ?? props.type;
|
|
42
|
+
if (!materialType) throw new Error("LMaterialDragSource requires type or material.");
|
|
43
|
+
const materialProps = {
|
|
44
|
+
...definition?.defaults ?? {},
|
|
45
|
+
...props.props
|
|
46
|
+
};
|
|
47
|
+
const input = () => ({
|
|
48
|
+
type: materialType,
|
|
49
|
+
props: materialProps,
|
|
50
|
+
placement: {
|
|
51
|
+
x: props.placement?.x ?? 0,
|
|
52
|
+
y: props.placement?.y ?? 0,
|
|
53
|
+
w: props.placement?.w ?? definition?.defaultLayout?.w ?? definition?.size?.default.w ?? 1,
|
|
54
|
+
h: props.placement?.h ?? definition?.defaultLayout?.h ?? definition?.size?.default.h ?? 1
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const start = (event) => {
|
|
58
|
+
props.editor.beginExternalDrag({
|
|
59
|
+
...input(),
|
|
60
|
+
element: event.currentTarget,
|
|
61
|
+
dataTransfer: event.dataTransfer ?? void 0
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const end = () => props.editor.endExternalDrag();
|
|
65
|
+
onMounted(() => {
|
|
66
|
+
if (element) unregister = props.editor.registerExternalDragSource({
|
|
67
|
+
...input(),
|
|
68
|
+
element
|
|
69
|
+
});
|
|
70
|
+
if (typeof document !== "undefined") document.addEventListener("dragend", end);
|
|
71
|
+
});
|
|
72
|
+
onBeforeUnmount(() => {
|
|
73
|
+
unregister();
|
|
74
|
+
if (typeof document !== "undefined") document.removeEventListener("dragend", end);
|
|
75
|
+
});
|
|
76
|
+
return () => h("div", {
|
|
77
|
+
ref: (value) => {
|
|
78
|
+
element = value;
|
|
79
|
+
},
|
|
80
|
+
class: "ldesign-layout-material-drag-source grid-stack-item",
|
|
81
|
+
"data-material-type": materialType,
|
|
82
|
+
"data-material-category": definition?.category,
|
|
83
|
+
"data-material-title": definition?.title ?? definition?.label,
|
|
84
|
+
"aria-label": `\u6DFB\u52A0${definition?.title ?? definition?.label ?? materialType}`,
|
|
85
|
+
onDragstart: start
|
|
86
|
+
}, slots.default?.() ?? definition?.title ?? definition?.label ?? materialType);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
//#endregion
|
|
90
|
+
export { LMaterialDragSource };
|
|
91
|
+
/*! End of @composy/layout-vue | Powered by @composy/builder */
|
|
92
|
+
//# sourceMappingURL=LMaterialDragSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LMaterialDragSource.js","names":[],"sources":["../../src/components/LMaterialDragSource.ts"],"sourcesContent":["import { defineComponent, h, onBeforeUnmount, onMounted } from 'vue'\nimport type { LayoutPlacement, MaterialDefinition } from '@composy/layout-core'\nimport type { LayoutEditor } from '@composy/layout-editor'\n\nexport const LMaterialDragSource = defineComponent({\n name: 'LMaterialDragSource',\n props: {\n /** Backwards-compatible shorthand when no full material definition is supplied. */\n type: { type: String, default: undefined },\n material: { type: Object as () => MaterialDefinition, default: undefined },\n props: { type: Object, default: () => ({}) },\n placement: {\n type: Object as () => Partial<LayoutPlacement>,\n default: undefined,\n },\n editor: { type: Object as () => LayoutEditor, required: true },\n },\n setup(props, { slots }) {\n let unregister = () => {}\n let element: HTMLElement | undefined\n const definition = props.material\n const materialType = definition?.type ?? props.type\n if (!materialType)\n throw new Error('LMaterialDragSource requires type or material.')\n const materialProps = {\n ...(definition?.defaults ?? {}),\n ...(props.props as Record<string, unknown>),\n }\n const input = () => ({\n type: materialType,\n props: materialProps,\n placement: {\n x: props.placement?.x ?? 0,\n y: props.placement?.y ?? 0,\n w:\n props.placement?.w ??\n definition?.defaultLayout?.w ??\n definition?.size?.default.w ??\n 1,\n h:\n props.placement?.h ??\n definition?.defaultLayout?.h ??\n definition?.size?.default.h ??\n 1,\n },\n })\n const start = (event: DragEvent) => {\n props.editor.beginExternalDrag({\n ...input(),\n element: event.currentTarget as HTMLElement,\n dataTransfer: event.dataTransfer ?? undefined,\n })\n }\n const end = () => props.editor.endExternalDrag()\n onMounted(() => {\n if (element)\n unregister = props.editor.registerExternalDragSource({\n ...input(),\n element,\n })\n if (typeof document !== 'undefined')\n document.addEventListener('dragend', end)\n })\n onBeforeUnmount(() => {\n unregister()\n if (typeof document !== 'undefined')\n document.removeEventListener('dragend', end)\n })\n return () =>\n h(\n 'div',\n {\n ref: (value: unknown) => {\n element = value as HTMLElement\n },\n class: 'ldesign-layout-material-drag-source grid-stack-item',\n 'data-material-type': materialType,\n 'data-material-category': definition?.category,\n 'data-material-title': definition?.title ?? definition?.label,\n 'aria-label': `添加${definition?.title ?? definition?.label ?? materialType}`,\n onDragstart: start,\n },\n slots.default?.() ??\n definition?.title ??\n definition?.label ??\n materialType\n )\n },\n})\n"],"mappings":";;;;;;;;;;;AAIO,MAAM,sBAAsB,gBAAgB;CACjD,MAAM;CACN,OAAO;;EAEL,MAAM;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;EACzC,UAAU;GAAE,MAAM;GAAoC,SAAS,KAAA;EAAU;EACzE,OAAO;GAAE,MAAM;GAAQ,gBAAgB,CAAC;EAAG;EAC3C,WAAW;GACT,MAAM;GACN,SAAS,KAAA;EACX;EACA,QAAQ;GAAE,MAAM;GAA8B,UAAU;EAAK;CAC/D;CACA,MAAM,OAAO,EAAE,SAAS;EACtB,IAAI,mBAAmB,CAAC;EACxB,IAAI;EACJ,MAAM,aAAa,MAAM;EACzB,MAAM,eAAe,YAAY,QAAQ,MAAM;EAC/C,IAAI,CAAC,cACH,MAAM,IAAI,MAAM,gDAAgD;EAClE,MAAM,gBAAgB;GACpB,GAAI,YAAY,YAAY,CAAC;GAC7B,GAAI,MAAM;EACZ;EACA,MAAM,eAAe;GACnB,MAAM;GACN,OAAO;GACP,WAAW;IACT,GAAG,MAAM,WAAW,KAAK;IACzB,GAAG,MAAM,WAAW,KAAK;IACzB,GACE,MAAM,WAAW,KACjB,YAAY,eAAe,KAC3B,YAAY,MAAM,QAAQ,KAC1B;IACF,GACE,MAAM,WAAW,KACjB,YAAY,eAAe,KAC3B,YAAY,MAAM,QAAQ,KAC1B;GACJ;EACF;EACA,MAAM,SAAS,UAAqB;GAClC,MAAM,OAAO,kBAAkB;IAC7B,GAAG,MAAM;IACT,SAAS,MAAM;IACf,cAAc,MAAM,gBAAgB,KAAA;GACtC,CAAC;EACH;EACA,MAAM,YAAY,MAAM,OAAO,gBAAgB;EAC/C,gBAAgB;GACd,IAAI,SACF,aAAa,MAAM,OAAO,2BAA2B;IACnD,GAAG,MAAM;IACT;GACF,CAAC;GACH,IAAI,OAAO,aAAa,aACtB,SAAS,iBAAiB,WAAW,GAAG;EAC5C,CAAC;EACD,sBAAsB;GACpB,WAAW;GACX,IAAI,OAAO,aAAa,aACtB,SAAS,oBAAoB,WAAW,GAAG;EAC/C,CAAC;EACD,aACE,EACE,OACA;GACE,MAAM,UAAmB;IACvB,UAAU;GACZ;GACA,OAAO;GACP,sBAAsB;GACtB,0BAA0B,YAAY;GACtC,uBAAuB,YAAY,SAAS,YAAY;GACxD,cAAc,eAAK,YAAY,SAAS,YAAY,SAAS;GAC7D,aAAa;EACf,GACA,MAAM,UAAU,KACd,YAAY,SACZ,YAAY,SACZ,YACJ;CACJ;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LMaterialRenderer.d.ts","sourceRoot":"","sources":["../../src/components/LMaterialRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACvE,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAA;AAE5B;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;;cAGF,QAAQ,CAAC,UAAU,CAAC;;;;cAEjB,QAAQ,CAAC,iBAAiB,CAAC;;;;cAIpC,QAAQ,CAAC,kBAAkB,CAAC;;;;cAI5B,QAAQ,CAAC,eAAe,CAAC;;;;;;;;;;;cAVnB,QAAQ,CAAC,UAAU,CAAC;;;;cAEjB,QAAQ,CAAC,iBAAiB,CAAC;;;;cAIpC,QAAQ,CAAC,kBAAkB,CAAC;;;;cAI5B,QAAQ,CAAC,eAAe,CAAC;;;;;;;;;;;;4EAkB7C,CAAA;AAEF,YAAY,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/layout-vue v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-10-12 17:52:50 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
import { renderMaterialForTarget } from "./material-renderer.js";
|
|
11
|
+
import { defineComponent, h } from "vue";
|
|
12
|
+
//#region src/components/LMaterialRenderer.ts
|
|
13
|
+
const LMaterialRenderer = defineComponent({
|
|
14
|
+
name: "LMaterialRenderer",
|
|
15
|
+
props: {
|
|
16
|
+
item: {
|
|
17
|
+
type: Object,
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
materials: {
|
|
21
|
+
type: [Object, Array],
|
|
22
|
+
default: void 0
|
|
23
|
+
},
|
|
24
|
+
target: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: "vue"
|
|
27
|
+
},
|
|
28
|
+
placement: {
|
|
29
|
+
type: Object,
|
|
30
|
+
default: void 0
|
|
31
|
+
},
|
|
32
|
+
breakpointId: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: "desktop"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
setup(props, { attrs }) {
|
|
38
|
+
return () => {
|
|
39
|
+
const rendered = renderMaterialForTarget(props.materials, props.item, props.target, props.placement, props.breakpointId);
|
|
40
|
+
if (!rendered) return null;
|
|
41
|
+
return h(rendered, attrs);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
//#endregion
|
|
46
|
+
export { LMaterialRenderer };
|
|
47
|
+
/*! End of @composy/layout-vue | Powered by @composy/builder */
|
|
48
|
+
//# sourceMappingURL=LMaterialRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LMaterialRenderer.js","names":[],"sources":["../../src/components/LMaterialRenderer.ts"],"sourcesContent":["import { defineComponent, h, type PropType } from 'vue'\nimport type { LayoutNode, LayoutPlacement } from '@composy/layout-core'\nimport {\n renderMaterialForTarget,\n type LayoutRenderTarget,\n type VueMaterialSource,\n} from './material-renderer'\n\n/**\n * A target-aware renderer for one registered layout material.\n *\n * `LGrid` owns the placement shell; this component owns the renderer lookup.\n * Consumers can therefore use the same item renderer in an editor, a preview,\n * a modal or their own grid implementation without duplicating framework\n * branching logic.\n */\nexport const LMaterialRenderer = defineComponent({\n name: 'LMaterialRenderer',\n props: {\n item: { type: Object as PropType<LayoutNode>, required: true },\n materials: {\n type: [Object, Array] as PropType<VueMaterialSource>,\n default: undefined,\n },\n target: {\n type: String as PropType<LayoutRenderTarget>,\n default: 'vue',\n },\n placement: {\n type: Object as PropType<LayoutPlacement>,\n default: undefined,\n },\n breakpointId: { type: String, default: 'desktop' },\n },\n setup(props, { attrs }) {\n return () => {\n const rendered = renderMaterialForTarget(\n props.materials,\n props.item,\n props.target,\n props.placement,\n props.breakpointId\n )\n if (!rendered) return null\n return h(rendered, attrs)\n }\n },\n})\n\nexport type { LayoutRenderTarget }\n"],"mappings":";;;;;;;;;;;;AAgBO,MAAM,oBAAoB,gBAAgB;CAC/C,MAAM;CACN,OAAO;EACL,MAAM;GAAE,MAAM;GAAgC,UAAU;EAAK;EAC7D,WAAW;GACT,MAAM,CAAC,QAAQ,KAAK;GACpB,SAAS,KAAA;EACX;EACA,QAAQ;GACN,MAAM;GACN,SAAS;EACX;EACA,WAAW;GACT,MAAM;GACN,SAAS,KAAA;EACX;EACA,cAAc;GAAE,MAAM;GAAQ,SAAS;EAAU;CACnD;CACA,MAAM,OAAO,EAAE,SAAS;EACtB,aAAa;GACX,MAAM,WAAW,wBACf,MAAM,WACN,MAAM,MACN,MAAM,QACN,MAAM,WACN,MAAM,YACR;GACA,IAAI,CAAC,UAAU,OAAO;GACtB,OAAO,EAAE,UAAU,KAAK;EAC1B;CACF;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LMetricCard.d.ts","sourceRoot":"","sources":["../../src/components/LMetricCard.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;4EA2BtB,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/layout-vue v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-10-12 17:52:50 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
import { defineComponent, h } from "vue";
|
|
11
|
+
//#region src/components/LMetricCard.ts
|
|
12
|
+
const LMetricCard = defineComponent({
|
|
13
|
+
name: "LMetricCard",
|
|
14
|
+
props: {
|
|
15
|
+
title: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: "数据指标"
|
|
18
|
+
},
|
|
19
|
+
value: {
|
|
20
|
+
type: [String, Number],
|
|
21
|
+
default: void 0
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
setup(props) {
|
|
25
|
+
return () => h("article", {
|
|
26
|
+
class: "layout-card",
|
|
27
|
+
"data-layout-card": ""
|
|
28
|
+
}, [
|
|
29
|
+
h("div", { class: "layout-card__meta" }, [h("span", { class: "layout-card__type" }, "数据指标"), h("span", { class: "layout-card__status" }, "已配置")]),
|
|
30
|
+
h("h3", { class: "layout-card__title" }, props.title),
|
|
31
|
+
props.value === void 0 ? null : h("strong", { class: "layout-card__value" }, Number(props.value).toLocaleString("zh-CN")),
|
|
32
|
+
h("div", { class: "layout-card__footer" }, [h("span", null, "实时数据"), h("span", { class: "layout-card__spark" }, "趋势稳定")])
|
|
33
|
+
]);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
//#endregion
|
|
37
|
+
export { LMetricCard };
|
|
38
|
+
/*! End of @composy/layout-vue | Powered by @composy/builder */
|
|
39
|
+
//# sourceMappingURL=LMetricCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LMetricCard.js","names":[],"sources":["../../src/components/LMetricCard.ts"],"sourcesContent":["import { defineComponent, h } from 'vue'\n\n/**\n * Reference Vue material used by the layout examples and as a small,\n * framework-native registration contract for consumers.\n */\nexport const LMetricCard = defineComponent({\n name: 'LMetricCard',\n props: {\n title: { type: String, default: '数据指标' },\n value: { type: [String, Number], default: undefined },\n },\n setup(props) {\n return () =>\n h('article', { class: 'layout-card', 'data-layout-card': '' }, [\n h('div', { class: 'layout-card__meta' }, [\n h('span', { class: 'layout-card__type' }, '数据指标'),\n h('span', { class: 'layout-card__status' }, '已配置'),\n ]),\n h('h3', { class: 'layout-card__title' }, props.title),\n props.value === undefined\n ? null\n : h(\n 'strong',\n { class: 'layout-card__value' },\n Number(props.value).toLocaleString('zh-CN')\n ),\n h('div', { class: 'layout-card__footer' }, [\n h('span', null, '实时数据'),\n h('span', { class: 'layout-card__spark' }, '趋势稳定'),\n ]),\n ])\n },\n})\n"],"mappings":";;;;;;;;;;;AAMO,MAAM,cAAc,gBAAgB;CACzC,MAAM;CACN,OAAO;EACL,OAAO;GAAE,MAAM;GAAQ,SAAS;EAAO;EACvC,OAAO;GAAE,MAAM,CAAC,QAAQ,MAAM;GAAG,SAAS,KAAA;EAAU;CACtD;CACA,MAAM,OAAO;EACX,aACE,EAAE,WAAW;GAAE,OAAO;GAAe,oBAAoB;EAAG,GAAG;GAC7D,EAAE,OAAO,EAAE,OAAO,oBAAoB,GAAG,CACvC,EAAE,QAAQ,EAAE,OAAO,oBAAoB,GAAG,MAAM,GAChD,EAAE,QAAQ,EAAE,OAAO,sBAAsB,GAAG,KAAK,CACnD,CAAC;GACD,EAAE,MAAM,EAAE,OAAO,qBAAqB,GAAG,MAAM,KAAK;GACpD,MAAM,UAAU,KAAA,IACZ,OACA,EACE,UACA,EAAE,OAAO,qBAAqB,GAC9B,OAAO,MAAM,KAAK,CAAA,CAAE,eAAe,OAAO,CAC5C;GACJ,EAAE,OAAO,EAAE,OAAO,sBAAsB,GAAG,CACzC,EAAE,QAAQ,MAAM,MAAM,GACtB,EAAE,QAAQ,EAAE,OAAO,qBAAqB,GAAG,MAAM,CACnD,CAAC;EACH,CAAC;CACL;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LTrendCard.d.ts","sourceRoot":"","sources":["../../src/components/LTrendCard.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;4EAwBrB,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/layout-vue v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-10-12 17:52:50 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
import { defineComponent, h } from "vue";
|
|
11
|
+
//#region src/components/LTrendCard.ts
|
|
12
|
+
const LTrendCard = defineComponent({
|
|
13
|
+
name: "LTrendCard",
|
|
14
|
+
props: { title: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: "趋势图表"
|
|
17
|
+
} },
|
|
18
|
+
setup(props) {
|
|
19
|
+
return () => h("article", {
|
|
20
|
+
class: "layout-card",
|
|
21
|
+
"data-layout-card": ""
|
|
22
|
+
}, [
|
|
23
|
+
h("div", { class: "layout-card__meta" }, [h("span", { class: "layout-card__type" }, "趋势图表"), h("span", { class: "layout-card__status" }, "已配置")]),
|
|
24
|
+
h("h3", { class: "layout-card__title" }, props.title),
|
|
25
|
+
h("span", {
|
|
26
|
+
class: "layout-card__chart",
|
|
27
|
+
"aria-hidden": "true"
|
|
28
|
+
}, Array.from({ length: 5 }, (_, index) => h("i", { key: index }))),
|
|
29
|
+
h("div", { class: "layout-card__footer" }, [h("span", null, "实时数据"), h("span", { class: "layout-card__spark" }, "趋势稳定")])
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
//#endregion
|
|
34
|
+
export { LTrendCard };
|
|
35
|
+
/*! End of @composy/layout-vue | Powered by @composy/builder */
|
|
36
|
+
//# sourceMappingURL=LTrendCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LTrendCard.js","names":[],"sources":["../../src/components/LTrendCard.ts"],"sourcesContent":["import { defineComponent, h } from 'vue'\n\n/** Reference Vue chart material for renderer registration examples. */\nexport const LTrendCard = defineComponent({\n name: 'LTrendCard',\n props: {\n title: { type: String, default: '趋势图表' },\n },\n setup(props) {\n return () =>\n h('article', { class: 'layout-card', 'data-layout-card': '' }, [\n h('div', { class: 'layout-card__meta' }, [\n h('span', { class: 'layout-card__type' }, '趋势图表'),\n h('span', { class: 'layout-card__status' }, '已配置'),\n ]),\n h('h3', { class: 'layout-card__title' }, props.title),\n h(\n 'span',\n { class: 'layout-card__chart', 'aria-hidden': 'true' },\n Array.from({ length: 5 }, (_, index) => h('i', { key: index }))\n ),\n h('div', { class: 'layout-card__footer' }, [\n h('span', null, '实时数据'),\n h('span', { class: 'layout-card__spark' }, '趋势稳定'),\n ]),\n ])\n },\n})\n"],"mappings":";;;;;;;;;;;AAGO,MAAM,aAAa,gBAAgB;CACxC,MAAM;CACN,OAAO,EACL,OAAO;EAAE,MAAM;EAAQ,SAAS;CAAO,EACzC;CACA,MAAM,OAAO;EACX,aACE,EAAE,WAAW;GAAE,OAAO;GAAe,oBAAoB;EAAG,GAAG;GAC7D,EAAE,OAAO,EAAE,OAAO,oBAAoB,GAAG,CACvC,EAAE,QAAQ,EAAE,OAAO,oBAAoB,GAAG,MAAM,GAChD,EAAE,QAAQ,EAAE,OAAO,sBAAsB,GAAG,KAAK,CACnD,CAAC;GACD,EAAE,MAAM,EAAE,OAAO,qBAAqB,GAAG,MAAM,KAAK;GACpD,EACE,QACA;IAAE,OAAO;IAAsB,eAAe;GAAO,GACrD,MAAM,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAG,UAAU,EAAE,KAAK,EAAE,KAAK,MAAM,CAAC,CAAC,CAChE;GACA,EAAE,OAAO,EAAE,OAAO,sBAAsB,GAAG,CACzC,EAAE,QAAQ,MAAM,MAAM,GACtB,EAAE,QAAQ,EAAE,OAAO,qBAAqB,GAAG,MAAM,CACnD,CAAC;EACH,CAAC;CACL;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/layout-vue v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-10-12 17:52:50 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
import { LGrid } from "./LGrid.js";
|
|
11
|
+
import { LGridItem } from "./LGridItem.js";
|
|
12
|
+
import { LMaterialRenderer } from "./LMaterialRenderer.js";
|
|
13
|
+
import { LLayoutEditor } from "./LLayoutEditor.js";
|
|
14
|
+
import { LMetricCard } from "./LMetricCard.js";
|
|
15
|
+
import { LTrendCard } from "./LTrendCard.js";
|
|
16
|
+
import LLayoutWorkspace_default from "./LLayoutWorkspace.js";
|
|
17
|
+
import { LMaterialDragSource } from "./LMaterialDragSource.js";
|
|
18
|
+
export { LGrid, LGridItem, LLayoutEditor, LLayoutWorkspace_default as LLayoutWorkspace, LMaterialDragSource, LMaterialRenderer, LMetricCard, LTrendCard };
|
|
19
|
+
/*! End of @composy/layout-vue | Powered by @composy/builder */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"material-renderer.d.ts","sourceRoot":"","sources":["../../src/components/material-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,KAAK,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAA;AAC7B,MAAM,MAAM,iBAAiB,GAC3B,gBAAgB,GAAG,SAAS,kBAAkB,EAAE,GAAG,SAAS,CAAA;AAI9D;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,cAAc,CAAA;AAgBvD,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,iBAAiB,EAC5B,IAAI,EAAE,MAAM,GACX,kBAAkB,GAAG,SAAS,CAEhC;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,iBAAiB,EAC5B,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,eAAe,EAC1B,YAAY,EAAE,MAAM,GACnB,KAAK,GAAG,SAAS,CA0BnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,iBAAiB,EAC5B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,kBAAkB,EAC1B,SAAS,CAAC,EAAE,eAAe,EAC3B,YAAY,SAAY,GACvB,KAAK,GAAG,SAAS,CAoDnB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/layout-vue v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-10-12 17:52:50 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
import { h } from "vue";
|
|
11
|
+
import { createMaterialRegistry } from "@composy/layout-core";
|
|
12
|
+
//#region src/components/material-renderer.ts
|
|
13
|
+
const registryCache = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
function resolveRegistry(source) {
|
|
15
|
+
if (!source) return void 0;
|
|
16
|
+
if (Array.isArray(source)) {
|
|
17
|
+
const cached = registryCache.get(source);
|
|
18
|
+
if (cached) return cached;
|
|
19
|
+
const registry = createMaterialRegistry(source);
|
|
20
|
+
registryCache.set(source, registry);
|
|
21
|
+
return registry;
|
|
22
|
+
}
|
|
23
|
+
return source;
|
|
24
|
+
}
|
|
25
|
+
function resolveMaterialDefinition(materials, type) {
|
|
26
|
+
return resolveRegistry(materials)?.get(type);
|
|
27
|
+
}
|
|
28
|
+
function renderMaterialFallback(materials, item, placement, breakpointId) {
|
|
29
|
+
const material = resolveMaterialDefinition(materials, item.type);
|
|
30
|
+
const context = {
|
|
31
|
+
item,
|
|
32
|
+
placement,
|
|
33
|
+
breakpointId
|
|
34
|
+
};
|
|
35
|
+
const vueRenderer = material?.renderers?.vue;
|
|
36
|
+
if (vueRenderer?.component) return h(vueRenderer.component, {
|
|
37
|
+
...item.props ?? {},
|
|
38
|
+
...vueRenderer.tagName ? { is: vueRenderer.tagName } : {}
|
|
39
|
+
});
|
|
40
|
+
const webComponentRenderer = material?.renderers?.webcomponent;
|
|
41
|
+
if (webComponentRenderer?.tagName) return h(webComponentRenderer.tagName, {
|
|
42
|
+
...item.props ?? {},
|
|
43
|
+
materialProps: { ...item.props ?? {} }
|
|
44
|
+
});
|
|
45
|
+
const htmlRenderer = material?.renderers?.html;
|
|
46
|
+
if (htmlRenderer?.render) {
|
|
47
|
+
const rendered = htmlRenderer.render(context);
|
|
48
|
+
if (typeof rendered === "string") return h("div", { innerHTML: sanitizeMarkup(rendered) });
|
|
49
|
+
return rendered;
|
|
50
|
+
}
|
|
51
|
+
if (htmlRenderer?.tagName) return h(htmlRenderer.tagName, { ...item.props ?? {} });
|
|
52
|
+
}
|
|
53
|
+
function renderMaterialForTarget(materials, item, target, placement, breakpointId = "desktop") {
|
|
54
|
+
const material = resolveMaterialDefinition(materials, item.type);
|
|
55
|
+
const props = { ...item.props ?? {} };
|
|
56
|
+
if (target === "vue") {
|
|
57
|
+
const renderer = material?.renderers?.vue;
|
|
58
|
+
if (renderer?.component) return h(renderer.component, props);
|
|
59
|
+
} else {
|
|
60
|
+
const renderer = material?.renderers?.webcomponent;
|
|
61
|
+
if (renderer?.tagName) return h(renderer.tagName, {
|
|
62
|
+
...props,
|
|
63
|
+
materialProps: props,
|
|
64
|
+
onVnodeMounted: (vnode) => {
|
|
65
|
+
const el = vnode.el;
|
|
66
|
+
if (el && "materialProps" in el) el.materialProps = props;
|
|
67
|
+
},
|
|
68
|
+
onVnodeUpdated: (vnode) => {
|
|
69
|
+
const el = vnode.el;
|
|
70
|
+
if (el && "materialProps" in el) el.materialProps = props;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const htmlRenderer = material?.renderers?.html;
|
|
75
|
+
if (htmlRenderer?.render) {
|
|
76
|
+
const rendered = htmlRenderer.render({
|
|
77
|
+
item,
|
|
78
|
+
placement: placement ?? item.layout[breakpointId] ?? {
|
|
79
|
+
x: 0,
|
|
80
|
+
y: 0,
|
|
81
|
+
w: 1,
|
|
82
|
+
h: 1
|
|
83
|
+
},
|
|
84
|
+
breakpointId
|
|
85
|
+
});
|
|
86
|
+
if (typeof rendered === "string") return h("div", { innerHTML: sanitizeMarkup(rendered) });
|
|
87
|
+
return rendered;
|
|
88
|
+
}
|
|
89
|
+
if (htmlRenderer?.tagName) return h(htmlRenderer.tagName, props);
|
|
90
|
+
return renderMaterialFallback(materials, item, placement ?? item.layout[breakpointId] ?? {
|
|
91
|
+
x: 0,
|
|
92
|
+
y: 0,
|
|
93
|
+
w: 1,
|
|
94
|
+
h: 1
|
|
95
|
+
}, breakpointId);
|
|
96
|
+
}
|
|
97
|
+
function sanitizeMarkup(value) {
|
|
98
|
+
return value.replace(/<(?:script|style|iframe|object|embed|foreignObject)\b[^>]*>[\s\S]*?<\/(?:script|style|iframe|object|embed|foreignObject)\s*>/gi, "").replace(/<(?:script|style|iframe|object|embed|foreignObject)\b[^>]*>/gi, "").replace(/\s+on[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+(?:href|src|xlink:href|formaction|srcdoc)\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, (match) => /javascript:|data:text\/html/i.test(match) ? "" : match);
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { renderMaterialFallback, renderMaterialForTarget, resolveMaterialDefinition };
|
|
102
|
+
/*! End of @composy/layout-vue | Powered by @composy/builder */
|
|
103
|
+
//# sourceMappingURL=material-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"material-renderer.js","names":[],"sources":["../../src/components/material-renderer.ts"],"sourcesContent":["import { h, type VNode } from 'vue'\nimport {\n createMaterialRegistry,\n type LayoutNode,\n type LayoutPlacement,\n type MaterialDefinition,\n type MaterialRegistry,\n} from '@composy/layout-core'\nexport type VueMaterialSource =\n MaterialRegistry | readonly MaterialDefinition[] | undefined\n\nconst registryCache = new WeakMap<object, MaterialRegistry>()\n\n/**\n * The runtime target used by the layout renderer. It intentionally contains\n * only the two targets supported by the workspace today: a Vue component or a\n * registered native custom element.\n */\nexport type LayoutRenderTarget = 'vue' | 'webcomponent'\n\nfunction resolveRegistry(\n source: VueMaterialSource\n): MaterialRegistry | undefined {\n if (!source) return undefined\n if (Array.isArray(source)) {\n const cached = registryCache.get(source)\n if (cached) return cached\n const registry = createMaterialRegistry(source)\n registryCache.set(source, registry)\n return registry\n }\n return source as MaterialRegistry\n}\n\nexport function resolveMaterialDefinition(\n materials: VueMaterialSource,\n type: string\n): MaterialDefinition | undefined {\n return resolveRegistry(materials)?.get(type)\n}\n\n/**\n * Render the framework-specific fallback declared by a material.\n * A host-provided item slot always takes precedence over this helper.\n */\nexport function renderMaterialFallback(\n materials: VueMaterialSource,\n item: LayoutNode,\n placement: LayoutPlacement,\n breakpointId: string\n): VNode | undefined {\n const material = resolveMaterialDefinition(materials, item.type)\n const context = { item, placement, breakpointId }\n const vueRenderer = material?.renderers?.vue\n if (vueRenderer?.component) {\n return h(vueRenderer.component as never, {\n ...(item.props ?? {}),\n ...(vueRenderer.tagName ? { is: vueRenderer.tagName } : {}),\n })\n }\n const webComponentRenderer = material?.renderers?.webcomponent\n if (webComponentRenderer?.tagName)\n return h(webComponentRenderer.tagName, {\n ...(item.props ?? {}),\n materialProps: { ...(item.props ?? {}) },\n })\n const htmlRenderer = material?.renderers?.html\n if (htmlRenderer?.render) {\n const rendered = htmlRenderer.render(context)\n if (typeof rendered === 'string')\n return h('div', { innerHTML: sanitizeMarkup(rendered) })\n return rendered as VNode | undefined\n }\n if (htmlRenderer?.tagName)\n return h(htmlRenderer.tagName, { ...(item.props ?? {}) })\n return undefined\n}\n\n/**\n * Render the registered renderer for a concrete target.\n *\n * Keeping this decision in one place is important: grid items, preview\n * surfaces and integrations must not each invent their own component lookup.\n * A material can still provide the legacy html renderer as a final fallback,\n * but a Vue target never silently prefers a web component when its Vue\n * renderer is present (and vice versa).\n */\nexport function renderMaterialForTarget(\n materials: VueMaterialSource,\n item: LayoutNode,\n target: LayoutRenderTarget,\n placement?: LayoutPlacement,\n breakpointId = 'desktop'\n): VNode | undefined {\n const material = resolveMaterialDefinition(materials, item.type)\n const props = { ...(item.props ?? {}) }\n\n if (target === 'vue') {\n const renderer = material?.renderers?.vue\n if (renderer?.component) return h(renderer.component as never, props)\n } else {\n const renderer = material?.renderers?.webcomponent\n if (renderer?.tagName)\n return h(renderer.tagName, {\n ...props,\n // Workspace-provided custom elements use this property to render the\n // same registered material props as the editor/runtime adapters.\n materialProps: props,\n onVnodeMounted: vnode => {\n const el = vnode.el as unknown as Element & {\n materialProps?: Record<string, unknown>\n }\n if (el && 'materialProps' in el) el.materialProps = props\n },\n onVnodeUpdated: vnode => {\n const el = vnode.el as unknown as Element & {\n materialProps?: Record<string, unknown>\n }\n if (el && 'materialProps' in el) el.materialProps = props\n },\n })\n }\n\n const htmlRenderer = material?.renderers?.html\n if (htmlRenderer?.render) {\n const rendered = htmlRenderer.render({\n item,\n placement: placement ??\n item.layout[breakpointId] ?? { x: 0, y: 0, w: 1, h: 1 },\n breakpointId,\n })\n if (typeof rendered === 'string')\n return h('div', { innerHTML: sanitizeMarkup(rendered) })\n return rendered as VNode | undefined\n }\n if (htmlRenderer?.tagName) return h(htmlRenderer.tagName, props)\n\n // Preserve the historical behavior for incomplete third-party definitions\n // so registering only one renderer does not make an item disappear.\n return renderMaterialFallback(\n materials,\n item,\n placement ?? item.layout[breakpointId] ?? { x: 0, y: 0, w: 1, h: 1 },\n breakpointId\n )\n}\n\nfunction sanitizeMarkup(value: string): string {\n return value\n .replace(\n /<(?:script|style|iframe|object|embed|foreignObject)\\b[^>]*>[\\s\\S]*?<\\/(?:script|style|iframe|object|embed|foreignObject)\\s*>/gi,\n ''\n )\n .replace(\n /<(?:script|style|iframe|object|embed|foreignObject)\\b[^>]*>/gi,\n ''\n )\n .replace(/\\s+on[a-z]+\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s>]+)/gi, '')\n .replace(\n /\\s+(?:href|src|xlink:href|formaction|srcdoc)\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s>]+)/gi,\n match => (/javascript:|data:text\\/html/i.test(match) ? '' : match)\n )\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composables/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/layout-vue v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-10-12 17:52:50 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
import { useLayoutEditor } from "./useLayoutEditor.js";
|
|
11
|
+
export { useLayoutEditor };
|
|
12
|
+
/*! End of @composy/layout-vue | Powered by @composy/builder */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLayoutEditor.d.ts","sourceRoot":"","sources":["../../src/composables/useLayoutEditor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAEjE,wBAAgB,eAAe,CAAC,OAAO,EAAE,mBAAmB,0HAK3D"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/layout-vue v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-10-12 17:52:50 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
import { onBeforeUnmount, onMounted, shallowRef } from "vue";
|
|
11
|
+
import { createLayoutEditor } from "@composy/layout-editor";
|
|
12
|
+
//#region src/composables/useLayoutEditor.ts
|
|
13
|
+
function useLayoutEditor(options) {
|
|
14
|
+
const editor = shallowRef(createLayoutEditor(options));
|
|
15
|
+
onMounted(() => editor.value.mount());
|
|
16
|
+
onBeforeUnmount(() => editor.value.destroy());
|
|
17
|
+
return editor;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { useLayoutEditor };
|
|
21
|
+
/*! End of @composy/layout-vue | Powered by @composy/builder */
|
|
22
|
+
//# sourceMappingURL=useLayoutEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLayoutEditor.js","names":[],"sources":["../../src/composables/useLayoutEditor.ts"],"sourcesContent":["import { onBeforeUnmount, onMounted, shallowRef } from 'vue'\nimport { createLayoutEditor } from '@composy/layout-editor'\nimport type { LayoutEditorOptions } from '@composy/layout-editor'\n\nexport function useLayoutEditor(options: LayoutEditorOptions) {\n const editor = shallowRef(createLayoutEditor(options))\n onMounted(() => editor.value.mount())\n onBeforeUnmount(() => editor.value.destroy())\n return editor\n}\n"],"mappings":";;;;;;;;;;;;AAIO,SAAS,gBAAgB,SAA8B;CAC5D,MAAM,SAAS,WAAW,mBAAmB,OAAO,CAAC;CACrD,gBAAgB,OAAO,MAAM,MAAM,CAAC;CACpC,sBAAsB,OAAO,MAAM,QAAQ,CAAC;CAC5C,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,UAAU,GACX,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,mBAAmB,SAAS,CAAA;AAC5B,YAAY,EACV,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,gCAAgC,CAAA;AACvC,YAAY,EACV,cAAc,EACd,UAAU,EACV,eAAe,EACf,kBAAkB,GACnB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,wBAAwB,CAAA"}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/layout-vue v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-10-12 17:52:50 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
import { LGrid } from "./components/LGrid.js";
|
|
11
|
+
import { LGridItem } from "./components/LGridItem.js";
|
|
12
|
+
import { LMaterialRenderer } from "./components/LMaterialRenderer.js";
|
|
13
|
+
import { LLayoutEditor } from "./components/LLayoutEditor.js";
|
|
14
|
+
import { LMetricCard } from "./components/LMetricCard.js";
|
|
15
|
+
import { LTrendCard } from "./components/LTrendCard.js";
|
|
16
|
+
import LLayoutWorkspace_default from "./components/LLayoutWorkspace.js";
|
|
17
|
+
import { LMaterialDragSource } from "./components/LMaterialDragSource.js";
|
|
18
|
+
import "./components/index.js";
|
|
19
|
+
import { useLayoutEditor } from "./composables/useLayoutEditor.js";
|
|
20
|
+
import "./composables/index.js";
|
|
21
|
+
export { LGrid, LGridItem, LLayoutEditor, LLayoutWorkspace_default as LLayoutWorkspace, LMaterialDragSource, LMaterialRenderer, LMetricCard, LTrendCard, useLayoutEditor };
|
|
22
|
+
/*! End of @composy/layout-vue | Powered by @composy/builder */
|
package/esm/style/css.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.less';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.less';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
// @ldesign styles
|
|
1
|
+
// @ldesign styles
|