@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.
Files changed (157) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +82 -75
  3. package/dist/index.css +9 -3
  4. package/dist/index.js +22 -11
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.css +1 -1
  7. package/dist/index.min.js +2038 -1
  8. package/dist/index.min.js.map +1 -0
  9. package/es/.dts-output-manifest.json +1 -0
  10. package/es/.dts.tsbuildinfo +1 -0
  11. package/es/components/LGrid.d.ts +0 -1
  12. package/es/components/LGrid.js +3 -3
  13. package/es/components/LGrid.js.map +1 -1
  14. package/es/components/LGridItem.d.ts +0 -1
  15. package/es/components/LGridItem.d.ts.map +1 -1
  16. package/es/components/LGridItem.js +4 -2
  17. package/es/components/LGridItem.js.map +1 -1
  18. package/es/components/LLayoutEditor.d.ts +5 -5
  19. package/es/components/LLayoutEditor.d.ts.map +1 -1
  20. package/es/components/LLayoutEditor.js +2 -2
  21. package/es/components/LLayoutEditor.js.map +1 -1
  22. package/es/components/LLayoutWorkspace.js +1 -1
  23. package/es/components/LLayoutWorkspace.js.map +1 -1
  24. package/es/components/LLayoutWorkspace.vue_vue_type_script_setup_true_lang.js +8 -5
  25. package/es/components/LLayoutWorkspace.vue_vue_type_script_setup_true_lang.js.map +1 -1
  26. package/es/components/LMaterialDragSource.d.ts +0 -1
  27. package/es/components/LMaterialDragSource.js +1 -1
  28. package/es/components/LMaterialRenderer.d.ts +0 -1
  29. package/es/components/LMaterialRenderer.js +1 -1
  30. package/es/components/LMetricCard.d.ts +0 -1
  31. package/es/components/LMetricCard.js +1 -1
  32. package/es/components/LTrendCard.d.ts +0 -1
  33. package/es/components/LTrendCard.js +1 -1
  34. package/es/components/index.d.ts +0 -1
  35. package/es/components/index.js +3 -3
  36. package/es/components/material-renderer.d.ts +0 -1
  37. package/es/components/material-renderer.d.ts.map +1 -1
  38. package/es/components/material-renderer.js +10 -3
  39. package/es/components/material-renderer.js.map +1 -1
  40. package/es/composables/index.d.ts +0 -1
  41. package/es/composables/index.js +1 -1
  42. package/es/composables/useLayoutEditor.d.ts +0 -1
  43. package/es/composables/useLayoutEditor.js +1 -1
  44. package/es/index.d.ts +0 -1
  45. package/es/index.js +3 -5
  46. package/es/style/css.js +1 -1
  47. package/es/style/index.css +1 -0
  48. package/es/style/index.js +1 -1
  49. package/es/style/workspace.css +18 -2
  50. package/es/types.d.ts +0 -1
  51. package/es/types.js +1 -1
  52. package/esm/components/LGrid.d.ts.map +1 -0
  53. package/esm/components/LGrid.js +91 -0
  54. package/esm/components/LGrid.js.map +1 -0
  55. package/esm/components/LGridItem.d.ts.map +1 -0
  56. package/esm/components/LGridItem.js +54 -0
  57. package/esm/components/LGridItem.js.map +1 -0
  58. package/esm/components/LLayoutEditor.d.ts +50 -0
  59. package/esm/components/LLayoutEditor.d.ts.map +1 -0
  60. package/esm/components/LLayoutEditor.js +81 -0
  61. package/esm/components/LLayoutEditor.js.map +1 -0
  62. package/esm/components/LLayoutWorkspace.js +17 -0
  63. package/esm/components/LLayoutWorkspace.js.map +1 -0
  64. package/esm/components/LLayoutWorkspace.vue_vue_type_script_setup_true_lang.js +2220 -0
  65. package/esm/components/LLayoutWorkspace.vue_vue_type_script_setup_true_lang.js.map +1 -0
  66. package/esm/components/LMaterialDragSource.d.ts.map +1 -0
  67. package/esm/components/LMaterialDragSource.js +92 -0
  68. package/esm/components/LMaterialDragSource.js.map +1 -0
  69. package/esm/components/LMaterialRenderer.d.ts.map +1 -0
  70. package/esm/components/LMaterialRenderer.js +48 -0
  71. package/esm/components/LMaterialRenderer.js.map +1 -0
  72. package/esm/components/LMetricCard.d.ts.map +1 -0
  73. package/esm/components/LMetricCard.js +39 -0
  74. package/esm/components/LMetricCard.js.map +1 -0
  75. package/esm/components/LTrendCard.d.ts.map +1 -0
  76. package/esm/components/LTrendCard.js +36 -0
  77. package/esm/components/LTrendCard.js.map +1 -0
  78. package/esm/components/index.d.ts.map +1 -0
  79. package/esm/components/index.js +19 -0
  80. package/esm/components/material-renderer.d.ts.map +1 -0
  81. package/esm/components/material-renderer.js +103 -0
  82. package/esm/components/material-renderer.js.map +1 -0
  83. package/esm/composables/index.d.ts.map +1 -0
  84. package/esm/composables/index.js +12 -0
  85. package/esm/composables/useLayoutEditor.d.ts.map +1 -0
  86. package/esm/composables/useLayoutEditor.js +22 -0
  87. package/esm/composables/useLayoutEditor.js.map +1 -0
  88. package/esm/index.d.ts.map +1 -0
  89. package/esm/index.js +22 -0
  90. package/esm/style/css.js +1 -0
  91. package/esm/style/index.js +1 -0
  92. package/{es → esm}/style/index.less +1 -1
  93. package/esm/style/workspace.css +2379 -0
  94. package/esm/types.d.ts.map +1 -0
  95. package/esm/types.js +10 -0
  96. package/lib/components/LGrid.cjs +3 -3
  97. package/lib/components/LGrid.cjs.map +1 -1
  98. package/lib/components/LGrid.d.cts +2 -0
  99. package/lib/components/LGrid.d.cts.map +1 -0
  100. package/lib/components/LGridItem.cjs +4 -2
  101. package/lib/components/LGridItem.cjs.map +1 -1
  102. package/lib/components/LGridItem.d.cts +51 -0
  103. package/lib/components/LGridItem.d.cts.map +1 -0
  104. package/lib/components/LLayoutEditor.cjs +2 -2
  105. package/lib/components/LLayoutEditor.cjs.map +1 -1
  106. package/lib/components/{LLayoutEditor.d.ts → LLayoutEditor.d.cts} +5 -5
  107. package/lib/components/LLayoutEditor.d.cts.map +1 -0
  108. package/lib/components/LLayoutWorkspace.cjs +1 -1
  109. package/lib/components/LLayoutWorkspace.cjs.map +1 -1
  110. package/lib/components/LLayoutWorkspace.vue_vue_type_script_setup_true_lang.cjs +8 -5
  111. package/lib/components/LLayoutWorkspace.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  112. package/lib/components/LMaterialDragSource.cjs +1 -1
  113. package/lib/components/LMaterialDragSource.d.cts +54 -0
  114. package/lib/components/LMaterialDragSource.d.cts.map +1 -0
  115. package/lib/components/LMaterialRenderer.cjs +1 -1
  116. package/lib/components/LMaterialRenderer.d.cts +62 -0
  117. package/lib/components/LMaterialRenderer.d.cts.map +1 -0
  118. package/lib/components/LMetricCard.cjs +1 -1
  119. package/lib/components/LMetricCard.d.cts +28 -0
  120. package/lib/components/LMetricCard.d.cts.map +1 -0
  121. package/lib/components/LTrendCard.cjs +1 -1
  122. package/lib/components/LTrendCard.d.cts +16 -0
  123. package/lib/components/LTrendCard.d.cts.map +1 -0
  124. package/lib/components/index.cjs +1 -1
  125. package/lib/components/index.d.cts +9 -0
  126. package/lib/components/index.d.cts.map +1 -0
  127. package/lib/components/material-renderer.cjs +10 -3
  128. package/lib/components/material-renderer.cjs.map +1 -1
  129. package/lib/components/material-renderer.d.cts +25 -0
  130. package/lib/components/material-renderer.d.cts.map +1 -0
  131. package/lib/composables/index.cjs +1 -1
  132. package/lib/composables/index.d.cts +1 -0
  133. package/lib/composables/index.d.cts.map +1 -0
  134. package/lib/composables/useLayoutEditor.cjs +1 -1
  135. package/lib/composables/useLayoutEditor.d.cts +2 -0
  136. package/lib/composables/useLayoutEditor.d.cts.map +1 -0
  137. package/lib/index.cjs +1 -1
  138. package/lib/index.d.cts +6 -0
  139. package/lib/index.d.cts.map +1 -0
  140. package/lib/style/index.css +0 -1
  141. package/lib/style/workspace.css +9 -1
  142. package/lib/types.cjs +1 -1
  143. package/lib/types.d.cts +25 -0
  144. package/lib/types.d.cts.map +1 -0
  145. package/package.json +25 -18
  146. /package/{lib → esm}/components/LGrid.d.ts +0 -0
  147. /package/{lib → esm}/components/LGridItem.d.ts +0 -0
  148. /package/{lib → esm}/components/LMaterialDragSource.d.ts +0 -0
  149. /package/{lib → esm}/components/LMaterialRenderer.d.ts +0 -0
  150. /package/{lib → esm}/components/LMetricCard.d.ts +0 -0
  151. /package/{lib → esm}/components/LTrendCard.d.ts +0 -0
  152. /package/{lib → esm}/components/index.d.ts +0 -0
  153. /package/{lib → esm}/components/material-renderer.d.ts +0 -0
  154. /package/{lib → esm}/composables/index.d.ts +0 -0
  155. /package/{lib → esm}/composables/useLayoutEditor.d.ts +0 -0
  156. /package/{lib → esm}/index.d.ts +0 -0
  157. /package/{lib → esm}/types.d.ts +0 -0
@@ -52,4 +52,3 @@ export declare const LMaterialDragSource: import("vue").DefineComponent<import("
52
52
  placement: Partial<LayoutPlacement>;
53
53
  material: MaterialDefinition<import("@composy/layout-core").JsonRecord>;
54
54
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
55
- //# sourceMappingURL=LMaterialDragSource.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * ***********************************
3
3
  * @composy/layout-vue v0.0.1 *
4
4
  * Built with rollup *
5
- * Build time: 2024-08-17 11:47:09 *
5
+ * Build time: 2024-10-12 17:52:50 *
6
6
  * Build mode: production *
7
7
  * Minified: No *
8
8
  * ***********************************
@@ -60,4 +60,3 @@ export declare const LMaterialRenderer: import("vue").DefineComponent<import("vu
60
60
  breakpointId: string;
61
61
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
62
62
  export type { LayoutRenderTarget };
63
- //# sourceMappingURL=LMaterialRenderer.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * ***********************************
3
3
  * @composy/layout-vue v0.0.1 *
4
4
  * Built with rollup *
5
- * Build time: 2024-08-17 11:47:09 *
5
+ * Build time: 2024-10-12 17:52:50 *
6
6
  * Build mode: production *
7
7
  * Minified: No *
8
8
  * ***********************************
@@ -26,4 +26,3 @@ export declare const LMetricCard: import("vue").DefineComponent<import("vue").Ex
26
26
  title: string;
27
27
  value: string | number;
28
28
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
29
- //# sourceMappingURL=LMetricCard.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * ***********************************
3
3
  * @composy/layout-vue v0.0.1 *
4
4
  * Built with rollup *
5
- * Build time: 2024-08-17 11:47:09 *
5
+ * Build time: 2024-10-12 17:52:50 *
6
6
  * Build mode: production *
7
7
  * Minified: No *
8
8
  * ***********************************
@@ -14,4 +14,3 @@ export declare const LTrendCard: import("vue").DefineComponent<import("vue").Ext
14
14
  }>> & Readonly<{}>, {
15
15
  title: string;
16
16
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
17
- //# sourceMappingURL=LTrendCard.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * ***********************************
3
3
  * @composy/layout-vue v0.0.1 *
4
4
  * Built with rollup *
5
- * Build time: 2024-08-17 11:47:09 *
5
+ * Build time: 2024-10-12 17:52:50 *
6
6
  * Build mode: production *
7
7
  * Minified: No *
8
8
  * ***********************************
@@ -7,4 +7,3 @@ export { LMaterialDragSource } from './LMaterialDragSource';
7
7
  export { LMetricCard } from './LMetricCard';
8
8
  export { LTrendCard } from './LTrendCard';
9
9
  export type { LayoutRenderTarget, VueMaterialSource } from './material-renderer';
10
- //# sourceMappingURL=index.d.ts.map
@@ -2,18 +2,18 @@
2
2
  * ***********************************
3
3
  * @composy/layout-vue v0.0.1 *
4
4
  * Built with rollup *
5
- * Build time: 2024-08-17 11:47:09 *
5
+ * Build time: 2024-10-12 17:52:50 *
6
6
  * Build mode: production *
7
7
  * Minified: No *
8
8
  * ***********************************
9
9
  */
10
10
  import { LGrid } from "./LGrid.js";
11
11
  import { LGridItem } from "./LGridItem.js";
12
- import { LMaterialRenderer } from "./LMaterialRenderer.js";
13
12
  import { LLayoutEditor } from "./LLayoutEditor.js";
13
+ import { LMaterialDragSource } from "./LMaterialDragSource.js";
14
+ import { LMaterialRenderer } from "./LMaterialRenderer.js";
14
15
  import { LMetricCard } from "./LMetricCard.js";
15
16
  import { LTrendCard } from "./LTrendCard.js";
16
17
  import LLayoutWorkspace_default from "./LLayoutWorkspace.js";
17
- import { LMaterialDragSource } from "./LMaterialDragSource.js";
18
18
  export { LGrid, LGridItem, LLayoutEditor, LLayoutWorkspace_default as LLayoutWorkspace, LMaterialDragSource, LMaterialRenderer, LMetricCard, LTrendCard };
19
19
  /*! End of @composy/layout-vue | Powered by @composy/builder */
@@ -23,4 +23,3 @@ export declare function renderMaterialFallback(materials: VueMaterialSource, ite
23
23
  * renderer is present (and vice versa).
24
24
  */
25
25
  export declare function renderMaterialForTarget(materials: VueMaterialSource, item: LayoutNode, target: LayoutRenderTarget, placement?: LayoutPlacement, breakpointId?: string): VNode | undefined;
26
- //# sourceMappingURL=material-renderer.d.ts.map
@@ -1 +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;AAE9D;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,cAAc,CAAA;AAUvD,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"}
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"}
@@ -2,7 +2,7 @@
2
2
  * ***********************************
3
3
  * @composy/layout-vue v0.0.1 *
4
4
  * Built with rollup *
5
- * Build time: 2024-08-17 11:47:09 *
5
+ * Build time: 2024-10-12 17:52:50 *
6
6
  * Build mode: production *
7
7
  * Minified: No *
8
8
  * ***********************************
@@ -10,9 +10,16 @@
10
10
  import { h } from "vue";
11
11
  import { createMaterialRegistry } from "@composy/layout-core";
12
12
  //#region src/components/material-renderer.ts
13
+ const registryCache = /* @__PURE__ */ new WeakMap();
13
14
  function resolveRegistry(source) {
14
15
  if (!source) return void 0;
15
- if (Array.isArray(source)) return createMaterialRegistry(source);
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
+ }
16
23
  return source;
17
24
  }
18
25
  function resolveMaterialDefinition(materials, type) {
@@ -88,7 +95,7 @@ function renderMaterialForTarget(materials, item, target, placement, breakpointI
88
95
  }, breakpointId);
89
96
  }
90
97
  function sanitizeMarkup(value) {
91
- return value.replace(/<script\b[^>]*>[\s\S]*?<\/script\s*>/gi, "").replace(/\s+on[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+(?:href|src)\s*=\s*("|')\s*javascript:[^"']*\1/gi, "");
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);
92
99
  }
93
100
  //#endregion
94
101
  export { renderMaterialFallback, renderMaterialForTarget, resolveMaterialDefinition };
@@ -1 +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\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)) return createMaterialRegistry(source)\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(/<script\\b[^>]*>[\\s\\S]*?<\\/script\\s*>/gi, '')\n .replace(/\\s+on[a-z]+\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s>]+)/gi, '')\n .replace(/\\s+(?:href|src)\\s*=\\s*(\"|')\\s*javascript:[^\"']*\\1/gi, '')\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAS,gBACP,QAC8B;CAC9B,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,IAAI,MAAM,QAAQ,MAAM,GAAG,OAAO,uBAAuB,MAAM;CAC/D,OAAO;AACT;AAEO,SAAS,0BACd,WACA,MACgC;CAChC,OAAO,gBAAgB,SAAS,CAAA,EAAG,IAAI,IAAI;AAC7C;AAMO,SAAS,uBACd,WACA,MACA,WACA,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;IACvB,MAAM,KAAK,MAAM;IAGjB,IAAI,MAAM,mBAAmB,IAAI,GAAG,gBAAgB;GACtD;EACF,CAAC;CACL;CAEA,MAAM,eAAe,UAAU,WAAW;CAC1C,IAAI,cAAc,QAAQ;EACxB,MAAM,WAAW,aAAa,OAAO;GACnC;GACA,WAAW,aACT,KAAK,OAAO,iBAAiB;IAAE,GAAG;IAAG,GAAG;IAAG,GAAG;IAAG,GAAG;GAAE;GACxD;EACF,CAAC;EACD,IAAI,OAAO,aAAa,UACtB,OAAO,EAAE,OAAO,EAAE,WAAW,eAAe,QAAQ,EAAE,CAAC;EACzD,OAAO;CACT;CACA,IAAI,cAAc,SAAS,OAAO,EAAE,aAAa,SAAS,KAAK;CAI/D,OAAO,uBACL,WACA,MACA,aAAa,KAAK,OAAO,iBAAiB;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE,GACnE,YACF;AACF;AAEA,SAAS,eAAe,OAAuB;CAC7C,OAAO,MACJ,QAAQ,0CAA0C,EAAE,CAAA,CACpD,QAAQ,mDAAmD,EAAE,CAAA,CAC7D,QAAQ,uDAAuD,EAAE;AACtE"}
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":";;;;;;;;;;;;AAWA,MAAM,gCAAgB,IAAI,QAAkC;AAS5D,SAAS,gBACP,QAC8B;CAC9B,IAAI,CAAC,QA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,IAAI,WAAW,OAAO;EACpB,MAAM,WAAW,UAAU,WAAW;EACtC,IAAI,UAAU,WAAW,OAAO,EAAE,SAAS,WAAoB,KAAK;CACtE,OAAO;EACL,MAAM,WAAW,UAAU,WAAW;EACtC,IAAI,UAAU,SACZ,OAAO,EAAE,SAAS,SAAS;GACzB,GAAG;GAGH,eAAe;GACf,iBAAgB,UAAS;IACvB,MAAM,KAAK,MAAM;IAGjB,IAAI,MAAM,mBAAmB,IAAI,GAAG,gBAAgB;GACtD;GACA,iBAAgB,UAAS;IACvB,MAAM,KAAK,MAAM;IAGjB,IAAI,MAAM,mBAAmB,IAAI,GAAG,gBAAgB;GACtD;EACF,CAAC;CACL;CAEA,MAAM,eAAe,UAAU,WAAW;CAC1C,IAAI,cAAc,QAAQ;EACxB,MAAM,WAAW,aAAa,OAAO;GACnC;GACA,WAAW,aACT,KAAK,OAAO,iBAAiB;IAAE,GAAG;IAAG,GAAG;IAAG,GAAG;IAAG,GAAG;GAAE;GACxD;EACF,CAAC;EACD,IAAI,OAAO,aAAa,UACtB,OAAO,EAAE,OAAO,EAAE,WAAW,eAAe,QAAQ,EAAE,CAAC;EACzD,OAAO;CACT;CACA,IAAI,cAAc,SAAS,OAAO,EAAE,aAAa,SAAS,KAAK;CAI/D,OAAO,uBACL,WACA,MACA,aAAa,KAAK,OAAO,iBAAiB;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE,GACnE,YACF;AACF;AAEA,SAAS,eAAe,OAAuB;CAC7C,OAAO,MACJ,QACC,kIACA,EACF,CAAA,CACC,QACC,iEACA,EACF,CAAA,CACC,QAAQ,mDAAmD,EAAE,CAAA,CAC7D,QACC,qFACA,UAAU,+BAA+B,KAAK,KAAK,IAAI,KAAK,KAC9D;AACJ"}
@@ -1,2 +1 @@
1
1
  export { useLayoutEditor } from './useLayoutEditor';
2
- //# sourceMappingURL=index.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * ***********************************
3
3
  * @composy/layout-vue v0.0.1 *
4
4
  * Built with rollup *
5
- * Build time: 2024-08-17 11:47:09 *
5
+ * Build time: 2024-10-12 17:52:50 *
6
6
  * Build mode: production *
7
7
  * Minified: No *
8
8
  * ***********************************
@@ -1,3 +1,2 @@
1
1
  import type { LayoutEditorOptions } from '@composy/layout-editor';
2
2
  export declare function useLayoutEditor(options: LayoutEditorOptions): import("vue").ShallowRef<import("@composy/layout-editor").LayoutEditor, import("@composy/layout-editor").LayoutEditor>;
3
- //# sourceMappingURL=useLayoutEditor.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * ***********************************
3
3
  * @composy/layout-vue v0.0.1 *
4
4
  * Built with rollup *
5
- * Build time: 2024-08-17 11:47:09 *
5
+ * Build time: 2024-10-12 17:52:50 *
6
6
  * Build mode: production *
7
7
  * Minified: No *
8
8
  * ***********************************
package/es/index.d.ts CHANGED
@@ -4,4 +4,3 @@ export type * from './types';
4
4
  export type { LayoutRenderTarget, VueMaterialSource, } from './components/material-renderer';
5
5
  export type { LayoutDocument, LayoutNode, LayoutPlacement, MaterialDefinition, } from '@composy/layout-core';
6
6
  export type { LayoutEditor, LayoutEditorEngine, LayoutEditorOptions, } from '@composy/layout-editor';
7
- //# sourceMappingURL=index.d.ts.map
package/es/index.js CHANGED
@@ -2,21 +2,19 @@
2
2
  * ***********************************
3
3
  * @composy/layout-vue v0.0.1 *
4
4
  * Built with rollup *
5
- * Build time: 2024-08-17 11:47:09 *
5
+ * Build time: 2024-10-12 17:52:50 *
6
6
  * Build mode: production *
7
7
  * Minified: No *
8
8
  * ***********************************
9
9
  */
10
10
  import { LGrid } from "./components/LGrid.js";
11
11
  import { LGridItem } from "./components/LGridItem.js";
12
- import { LMaterialRenderer } from "./components/LMaterialRenderer.js";
13
12
  import { LLayoutEditor } from "./components/LLayoutEditor.js";
13
+ import { LMaterialDragSource } from "./components/LMaterialDragSource.js";
14
+ import { LMaterialRenderer } from "./components/LMaterialRenderer.js";
14
15
  import { LMetricCard } from "./components/LMetricCard.js";
15
16
  import { LTrendCard } from "./components/LTrendCard.js";
16
17
  import LLayoutWorkspace_default from "./components/LLayoutWorkspace.js";
17
- import { LMaterialDragSource } from "./components/LMaterialDragSource.js";
18
- import "./components/index.js";
19
18
  import { useLayoutEditor } from "./composables/useLayoutEditor.js";
20
- import "./composables/index.js";
21
19
  export { LGrid, LGridItem, LLayoutEditor, LLayoutWorkspace_default as LLayoutWorkspace, LMaterialDragSource, LMaterialRenderer, LMetricCard, LTrendCard, useLayoutEditor };
22
20
  /*! End of @composy/layout-vue | Powered by @composy/builder */
package/es/style/css.js CHANGED
@@ -1 +1 @@
1
- import './index.less';
1
+ import './index.css';
@@ -0,0 +1 @@
1
+
package/es/style/index.js CHANGED
@@ -1 +1 @@
1
- import './index.less';
1
+ import './index.css';
@@ -120,6 +120,7 @@ button:focus-visible {
120
120
  }
121
121
 
122
122
  .topbar-center__shell {
123
+ min-width: -moz-max-content;
123
124
  min-width: max-content;
124
125
  padding: 4px 6px;
125
126
  display: flex;
@@ -858,7 +859,9 @@ button:focus-visible {
858
859
  color: var(--ink);
859
860
  text-align: left;
860
861
  cursor: grab;
861
- user-select: none;
862
+ -webkit-user-select: none;
863
+ -moz-user-select: none;
864
+ user-select: none;
862
865
  touch-action: none;
863
866
  box-shadow: 0 4px 14px rgb(48 65 95 / 6%);
864
867
  transition: 140ms ease;
@@ -1382,6 +1385,15 @@ body > .ui-draggable-dragging[data-layout-material] {
1382
1385
  flex: 1 0 auto;
1383
1386
  }
1384
1387
 
1388
+ /* The editor keeps a native runtime container mounted for fast framework
1389
+ * switching. Vue mode renders the adapter grid in the same stage, so the
1390
+ * native container must stay out of layout flow until Web Component mode is
1391
+ * selected. */
1392
+ .runtime-preview-stage[data-preview-framework="vue"] > .runtime-preview-grid,
1393
+ .vanilla-runtime-stage[data-preview-framework="vue"] > .runtime-preview-grid {
1394
+ display: none !important;
1395
+ }
1396
+
1385
1397
  .layout-item-shell,
1386
1398
  .layout-card {
1387
1399
  position: relative;
@@ -1670,13 +1682,16 @@ body > .ui-draggable-dragging[data-layout-material] {
1670
1682
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
1671
1683
  font-size: 11px;
1672
1684
  line-height: 1.65;
1673
- tab-size: 2;
1685
+ -moz-tab-size: 2;
1686
+ -o-tab-size: 2;
1687
+ tab-size: 2;
1674
1688
  white-space: pre;
1675
1689
  scrollbar-width: thin;
1676
1690
  }
1677
1691
 
1678
1692
  .code-block code {
1679
1693
  display: block;
1694
+ min-width: -moz-max-content;
1680
1695
  min-width: max-content;
1681
1696
  color: inherit;
1682
1697
  }
@@ -2368,3 +2383,4 @@ body > .ui-draggable-dragging[data-layout-material] {
2368
2383
  background: #27345c !important;
2369
2384
  color: #c5ceff !important;
2370
2385
  }
2386
+
package/es/types.d.ts CHANGED
@@ -23,4 +23,3 @@ export interface LLayoutEditorProps {
23
23
  export interface LLayoutEditorExpose {
24
24
  editor: LayoutEditor;
25
25
  }
26
- //# sourceMappingURL=types.d.ts.map
package/es/types.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * ***********************************
3
3
  * @composy/layout-vue v0.0.1 *
4
4
  * Built with rollup *
5
- * Build time: 2024-08-17 11:47:09 *
5
+ * Build time: 2024-10-12 17:52:50 *
6
6
  * Build mode: production *
7
7
  * Minified: No *
8
8
  * ***********************************
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LGrid.d.ts","sourceRoot":"","sources":["../../src/components/LGrid.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAM1C,eAAO,MAAM,KAAK,gSA8FhB,CAAA"}
@@ -0,0 +1,91 @@
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 { computed, defineComponent, h, onBeforeUnmount, onMounted, ref, watch } from "vue";
12
+ import { resolveGridStyle, resolveItemStyle } from "@composy/layout-runtime";
13
+ //#region src/components/LGrid.ts
14
+ const LGrid = defineComponent({
15
+ name: "LGrid",
16
+ props: {
17
+ document: {
18
+ type: Object,
19
+ required: true
20
+ },
21
+ breakpoint: {
22
+ type: String,
23
+ default: void 0
24
+ },
25
+ readonly: {
26
+ type: Boolean,
27
+ default: false
28
+ },
29
+ materials: {
30
+ type: [Object, Array],
31
+ default: void 0
32
+ },
33
+ target: {
34
+ type: String,
35
+ default: "vue"
36
+ }
37
+ },
38
+ setup(props, { slots, expose }) {
39
+ const root = ref();
40
+ const activeBreakpoint = ref(props.breakpoint ?? props.document.defaultBreakpointId);
41
+ const resolved = computed(() => props.document.breakpoints.find((bp) => bp.id === activeBreakpoint.value) ?? props.document.breakpoints[0]);
42
+ const gridStyle = computed(() => resolveGridStyle(props.document, resolved.value.id));
43
+ const resize = () => {
44
+ if (props.breakpoint || !root.value) return;
45
+ const width = root.value.getBoundingClientRect().width;
46
+ const match = props.document.breakpoints.find((bp) => (bp.minWidth === void 0 || width >= bp.minWidth) && (bp.maxWidth === void 0 || width < bp.maxWidth));
47
+ activeBreakpoint.value = match?.id ?? props.document.defaultBreakpointId;
48
+ };
49
+ let observer;
50
+ onMounted(() => {
51
+ if (typeof ResizeObserver !== "undefined" && root.value) {
52
+ observer = new ResizeObserver(resize);
53
+ observer.observe(root.value);
54
+ }
55
+ resize();
56
+ });
57
+ onBeforeUnmount(() => observer?.disconnect());
58
+ watch(() => [props.breakpoint, props.document.defaultBreakpointId], ([value, defaultBreakpoint]) => {
59
+ activeBreakpoint.value = value ?? defaultBreakpoint;
60
+ });
61
+ expose({ getBreakpoint: () => activeBreakpoint.value });
62
+ return () => h("div", {
63
+ ref: root,
64
+ class: "ldesign-layout-grid",
65
+ style: gridStyle.value,
66
+ dir: gridStyle.value.direction
67
+ }, props.document.items.map((item) => {
68
+ const placement = item.layout[activeBreakpoint.value];
69
+ if (!placement || placement.hidden) return null;
70
+ return h("div", {
71
+ class: "ldesign-layout-item",
72
+ "data-layout-item-id": item.id,
73
+ "data-layout-type": item.type,
74
+ style: resolveItemStyle(item, activeBreakpoint.value),
75
+ tabindex: props.readonly ? void 0 : 0
76
+ }, slots.item?.({
77
+ item,
78
+ placement,
79
+ breakpointId: activeBreakpoint.value
80
+ }) ?? slots.default?.({
81
+ item,
82
+ placement,
83
+ breakpointId: activeBreakpoint.value
84
+ }) ?? renderMaterialForTarget(props.materials, item, props.target, placement, activeBreakpoint.value));
85
+ }));
86
+ }
87
+ });
88
+ //#endregion
89
+ export { LGrid };
90
+ /*! End of @composy/layout-vue | Powered by @composy/builder */
91
+ //# sourceMappingURL=LGrid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LGrid.js","names":[],"sources":["../../src/components/LGrid.ts"],"sourcesContent":["import {\n computed,\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n ref,\n type PropType,\n watch,\n} from 'vue'\nimport { resolveGridStyle, resolveItemStyle } from '@composy/layout-runtime'\nimport type { LGridProps } from '../types'\nimport {\n renderMaterialForTarget,\n type VueMaterialSource,\n} from './material-renderer'\n\nexport const LGrid = defineComponent<LGridProps>({\n name: 'LGrid',\n props: {\n document: { type: Object, required: true },\n breakpoint: { type: String, default: undefined },\n readonly: { type: Boolean, default: false },\n materials: {\n type: [Object, Array] as PropType<VueMaterialSource>,\n default: undefined,\n },\n target: { type: String, default: 'vue' },\n },\n setup(props, { slots, expose }) {\n const root = ref<HTMLElement>()\n const activeBreakpoint = ref(\n props.breakpoint ?? props.document.defaultBreakpointId\n )\n const resolved = computed(\n () =>\n props.document.breakpoints.find(\n bp => bp.id === activeBreakpoint.value\n ) ?? props.document.breakpoints[0]\n )\n const gridStyle = computed(() =>\n resolveGridStyle(props.document, resolved.value.id)\n )\n const resize = () => {\n if (props.breakpoint || !root.value) return\n const width = root.value.getBoundingClientRect().width\n const match = props.document.breakpoints.find(\n bp =>\n (bp.minWidth === undefined || width >= bp.minWidth) &&\n (bp.maxWidth === undefined || width < bp.maxWidth)\n )\n activeBreakpoint.value = match?.id ?? props.document.defaultBreakpointId\n }\n let observer: ResizeObserver | undefined\n onMounted(() => {\n if (typeof ResizeObserver !== 'undefined' && root.value) {\n observer = new ResizeObserver(resize)\n observer.observe(root.value)\n }\n resize()\n })\n onBeforeUnmount(() => observer?.disconnect())\n watch(\n () => [props.breakpoint, props.document.defaultBreakpointId],\n ([value, defaultBreakpoint]) => {\n activeBreakpoint.value = value ?? defaultBreakpoint\n }\n )\n expose({ getBreakpoint: () => activeBreakpoint.value })\n return () =>\n h(\n 'div',\n {\n ref: root,\n class: 'ldesign-layout-grid',\n style: gridStyle.value,\n dir: gridStyle.value.direction,\n },\n props.document.items.map(item => {\n const placement = item.layout[activeBreakpoint.value]\n if (!placement || placement.hidden) return null\n return h(\n 'div',\n {\n class: 'ldesign-layout-item',\n 'data-layout-item-id': item.id,\n 'data-layout-type': item.type,\n style: resolveItemStyle(item, activeBreakpoint.value),\n tabindex: props.readonly ? undefined : 0,\n },\n slots.item?.({\n item,\n placement,\n breakpointId: activeBreakpoint.value,\n }) ??\n slots.default?.({\n item,\n placement,\n breakpointId: activeBreakpoint.value,\n }) ??\n renderMaterialForTarget(\n props.materials as VueMaterialSource,\n item,\n props.target as 'vue' | 'webcomponent',\n placement,\n activeBreakpoint.value\n )\n )\n })\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;AAiBO,MAAM,QAAQ,gBAA4B;CAC/C,MAAM;CACN,OAAO;EACL,UAAU;GAAE,MAAM;GAAQ,UAAU;EAAK;EACzC,YAAY;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;EAC/C,UAAU;GAAE,MAAM;GAAS,SAAS;EAAM;EAC1C,WAAW;GACT,MAAM,CAAC,QAAQ,KAAK;GACpB,SAAS,KAAA;EACX;EACA,QAAQ;GAAE,MAAM;GAAQ,SAAS;EAAM;CACzC;CACA,MAAM,OAAO,EAAE,OAA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iBAAiB,KAAK;IACpD,UAAU,MAAM,WAAW,KAAA,IAAY;GACzC,GACA,MAAM,OAAO;IACX;IACA;IACA,cAAc,iBAAiB;GACjC,CAAC,KACC,MAAM,UAAU;IACd;IACA;IACA,cAAc,iBAAiB;GACjC,CAAC,KACD,wBACE,MAAM,WACN,MACA,MAAM,QACN,WACA,iBAAiB,KACnB,CACJ;EACF,CAAC,CACH;CACJ;AACF,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LGridItem.d.ts","sourceRoot":"","sources":["../../src/components/LGridItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEvE,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAA;AAE5B,eAAO,MAAM,SAAS;;cAGM,MAAM,UAAU;;;;cACX,MAAM,eAAe;;;;;;;;cAGvB,QAAQ,CAAC,iBAAiB,CAAC;;;;;;;;;;;cAJ9B,MAAM,UAAU;;;;cACX,MAAM,eAAe;;;;;;;;cAGvB,QAAQ,CAAC,iBAAiB,CAAC;;;;;;;;;;4EA6BxD,CAAA"}
@@ -0,0 +1,54 @@
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
+ import { resolveItemStyle } from "@composy/layout-runtime";
13
+ //#region src/components/LGridItem.ts
14
+ const LGridItem = defineComponent({
15
+ name: "LGridItem",
16
+ props: {
17
+ item: {
18
+ type: Object,
19
+ required: true
20
+ },
21
+ placement: {
22
+ type: Object,
23
+ required: true
24
+ },
25
+ breakpointId: {
26
+ type: String,
27
+ required: true
28
+ },
29
+ materials: {
30
+ type: [Object, Array],
31
+ default: void 0
32
+ },
33
+ target: {
34
+ type: String,
35
+ default: "vue"
36
+ }
37
+ },
38
+ setup(props, { slots }) {
39
+ return () => h("div", {
40
+ class: "ldesign-layout-item",
41
+ "data-layout-item-id": props.item.id,
42
+ "data-layout-type": props.item.type,
43
+ style: resolveItemStyle(props.item, props.breakpointId)
44
+ }, slots.default?.({
45
+ item: props.item,
46
+ placement: props.placement,
47
+ breakpointId: props.breakpointId
48
+ }) ?? renderMaterialForTarget(props.materials, props.item, props.target, props.placement, props.breakpointId));
49
+ }
50
+ });
51
+ //#endregion
52
+ export { LGridItem };
53
+ /*! End of @composy/layout-vue | Powered by @composy/builder */
54
+ //# sourceMappingURL=LGridItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LGridItem.js","names":[],"sources":["../../src/components/LGridItem.ts"],"sourcesContent":["import { defineComponent, h, type PropType } from 'vue'\nimport type { LayoutNode, LayoutPlacement } from '@composy/layout-core'\nimport { resolveItemStyle } from '@composy/layout-runtime'\nimport {\n renderMaterialForTarget,\n type VueMaterialSource,\n} from './material-renderer'\n\nexport const LGridItem = defineComponent({\n name: 'LGridItem',\n props: {\n item: { type: Object as () => LayoutNode, required: true },\n placement: { type: Object as () => LayoutPlacement, required: true },\n breakpointId: { type: String, required: true },\n materials: {\n type: [Object, Array] as PropType<VueMaterialSource>,\n default: undefined,\n },\n target: { type: String, default: 'vue' },\n },\n setup(props, { slots }) {\n return () =>\n h(\n 'div',\n {\n class: 'ldesign-layout-item',\n 'data-layout-item-id': props.item.id,\n 'data-layout-type': props.item.type,\n style: resolveItemStyle(props.item, props.breakpointId),\n },\n slots.default?.({\n item: props.item,\n placement: props.placement,\n breakpointId: props.breakpointId,\n }) ??\n renderMaterialForTarget(\n props.materials as VueMaterialSource,\n props.item,\n props.target as 'vue' | 'webcomponent',\n props.placement,\n props.breakpointId\n )\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;AAQO,MAAM,YAAY,gBAAgB;CACvC,MAAM;CACN,OAAO;EACL,MAAM;GAAE,MAAM;GAA4B,UAAU;EAAK;EACzD,WAAW;GAAE,MAAM;GAAiC,UAAU;EAAK;EACnE,cAAc;GAAE,MAAM;GAAQ,UAAU;EAAK;EAC7C,WAAW;GACT,MAAM,CAAC,QAAQ,KAAK;GACpB,SAAS,KAAA;EACX;EACA,QAAQ;GAAE,MAAM;GAAQ,SAAS;EAAM;CACzC;CACA,MAAM,OAAO,EAAE,SAAS;EACtB,aACE,EACE,OACA;GACE,OAAO;GACP,uBAAuB,MAAM,KAAK;GAClC,oBAAoB,MAAM,KAAK;GAC/B,OAAO,iBAAiB,MAAM,MAAM,MAAM,YAAY;EACxD,GACA,MAAM,UAAU;GACd,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,cAAc,MAAM;EACtB,CAAC,KACC,wBACE,MAAM,WACN,MAAM,MACN,MAAM,QACN,MAAM,WACN,MAAM,YACR,CACJ;CACJ;AACF,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { type PropType } from 'vue';
2
+ import type { LayoutDocument, MaterialDefinition, MaterialRegistry } from '@composy/layout-core';
3
+ import type { LayoutEditorEngine, LayoutEditorOptions } from '@composy/layout-editor';
4
+ export declare const LLayoutEditor: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
5
+ document: {
6
+ type: () => LayoutDocument;
7
+ required: true;
8
+ };
9
+ engine: {
10
+ type: () => LayoutEditorEngine;
11
+ required: true;
12
+ };
13
+ mode: {
14
+ type: () => "edit" | "preview" | "readonly";
15
+ default: string;
16
+ };
17
+ preview: () => LayoutEditorOptions["preview"];
18
+ materials: {
19
+ type: PropType<MaterialRegistry | readonly MaterialDefinition[]>;
20
+ default: any;
21
+ };
22
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
23
+ [key: string]: any;
24
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "update:document" | "ready")[], "change" | "update:document" | "ready", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
25
+ document: {
26
+ type: () => LayoutDocument;
27
+ required: true;
28
+ };
29
+ engine: {
30
+ type: () => LayoutEditorEngine;
31
+ required: true;
32
+ };
33
+ mode: {
34
+ type: () => "edit" | "preview" | "readonly";
35
+ default: string;
36
+ };
37
+ preview: () => LayoutEditorOptions["preview"];
38
+ materials: {
39
+ type: PropType<MaterialRegistry | readonly MaterialDefinition[]>;
40
+ default: any;
41
+ };
42
+ }>> & Readonly<{
43
+ onChange?: (...args: any[]) => any;
44
+ "onUpdate:document"?: (...args: any[]) => any;
45
+ onReady?: (...args: any[]) => any;
46
+ }>, {
47
+ mode: "edit" | "preview" | "readonly";
48
+ materials: MaterialRegistry | readonly MaterialDefinition<import("@composy/layout-core").JsonRecord>[];
49
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
50
+ //# sourceMappingURL=LLayoutEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LLayoutEditor.d.ts","sourceRoot":"","sources":["../../src/components/LLayoutEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,QAAQ,EAEd,MAAM,KAAK,CAAA;AAEZ,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,wBAAwB,CAAA;AAE/B,eAAO,MAAM,aAAa;;cAGM,MAAM,cAAc;;;;cACtB,MAAM,kBAAkB;;;;cAEhC,MAAM,MAAM,GAAG,SAAS,GAAG,UAAU;;;aAGpC,MAAM,mBAAmB,CAAC,SAAS,CAAC;;cAE5B,QAAQ,CAC/B,gBAAgB,GAAG,SAAS,kBAAkB,EAAE,CACjD;;;;;;;cAVyB,MAAM,cAAc;;;;cACtB,MAAM,kBAAkB;;;;cAEhC,MAAM,MAAM,GAAG,SAAS,GAAG,UAAU;;;aAGpC,MAAM,mBAAmB,CAAC,SAAS,CAAC;;cAE5B,QAAQ,CAC/B,gBAAgB,GAAG,SAAS,kBAAkB,EAAE,CACjD;;;;;;;;;;4EA0DL,CAAA"}