@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,2220 @@
|
|
|
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 { LMaterialRenderer } from "./LMaterialRenderer.js";
|
|
12
|
+
import { LMetricCard } from "./LMetricCard.js";
|
|
13
|
+
import { LTrendCard } from "./LTrendCard.js";
|
|
14
|
+
import { Fragment, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderList, resolveDynamicComponent, toDisplayString, unref, vModelText, vShow, watch, withCtx, withDirectives, withKeys, withModifiers } from "vue";
|
|
15
|
+
import { createLayoutRuntime } from "@composy/layout-runtime";
|
|
16
|
+
import { createLayoutDocument, createMaterialRegistry, responsiveWebBreakpoints } from "@composy/layout-core";
|
|
17
|
+
import { createLayoutEditor } from "@composy/layout-editor";
|
|
18
|
+
import { GridStack } from "gridstack";
|
|
19
|
+
import "gridstack/dist/gridstack.min.css";
|
|
20
|
+
import { createElement, icons } from "lucide";
|
|
21
|
+
import { ArrowLeftRight, ArrowUpDown, ChartNoAxesColumnIncreasing, ChartSpline, ChevronDown, Code2, Copy, CopyCheck, Download, Eye, Filter, Grid2X2, Hand, Lock, Maximize2, Monitor, Moon, MousePointer2, Move, PanelsTopLeft, Pencil, Plus, Redo2, RotateCcw, Scan, Search, Smartphone, Sun, Tablet, Trash2, Undo2, Unlock, X, ZoomIn, ZoomOut } from "lucide-vue-next";
|
|
22
|
+
import { compileLayout } from "@composy/layout-compiler";
|
|
23
|
+
import { createGridStackEditorEngine } from "@composy/layout-gridstack";
|
|
24
|
+
//#region src/components/LLayoutWorkspace.vue?vue&type=script&setup=true&lang.ts
|
|
25
|
+
const _hoisted_1 = ["data-theme", "data-development-framework"];
|
|
26
|
+
const _hoisted_2 = { class: "topbar" };
|
|
27
|
+
const _hoisted_3 = { class: "brand" };
|
|
28
|
+
const _hoisted_4 = {
|
|
29
|
+
class: "brand-mark",
|
|
30
|
+
"aria-hidden": "true"
|
|
31
|
+
};
|
|
32
|
+
const _hoisted_5 = ["aria-expanded", "title"];
|
|
33
|
+
const _hoisted_6 = {
|
|
34
|
+
key: 0,
|
|
35
|
+
class: "custom-select__menu development-mode__menu",
|
|
36
|
+
role: "listbox"
|
|
37
|
+
};
|
|
38
|
+
const _hoisted_7 = ["aria-selected", "onClick"];
|
|
39
|
+
const _hoisted_8 = {
|
|
40
|
+
class: "topbar-center",
|
|
41
|
+
"aria-hidden": "true",
|
|
42
|
+
style: { "display": "none" }
|
|
43
|
+
};
|
|
44
|
+
const _hoisted_9 = {
|
|
45
|
+
class: "route-tabs",
|
|
46
|
+
"aria-label": "工作区模式"
|
|
47
|
+
};
|
|
48
|
+
const _hoisted_10 = [
|
|
49
|
+
"aria-current",
|
|
50
|
+
"aria-label",
|
|
51
|
+
"title",
|
|
52
|
+
"onClick"
|
|
53
|
+
];
|
|
54
|
+
const _hoisted_11 = {
|
|
55
|
+
class: "breakpoint-tabs",
|
|
56
|
+
"aria-label": "画布尺寸"
|
|
57
|
+
};
|
|
58
|
+
const _hoisted_12 = [
|
|
59
|
+
"aria-pressed",
|
|
60
|
+
"aria-label",
|
|
61
|
+
"title",
|
|
62
|
+
"onClick"
|
|
63
|
+
];
|
|
64
|
+
const _hoisted_13 = { class: "actions" };
|
|
65
|
+
const _hoisted_14 = ["disabled"];
|
|
66
|
+
const _hoisted_15 = ["disabled"];
|
|
67
|
+
const _hoisted_16 = ["disabled"];
|
|
68
|
+
const _hoisted_17 = [
|
|
69
|
+
"aria-label",
|
|
70
|
+
"title",
|
|
71
|
+
"disabled"
|
|
72
|
+
];
|
|
73
|
+
const _hoisted_18 = [
|
|
74
|
+
"aria-label",
|
|
75
|
+
"title",
|
|
76
|
+
"disabled"
|
|
77
|
+
];
|
|
78
|
+
const _hoisted_19 = [
|
|
79
|
+
"aria-label",
|
|
80
|
+
"title",
|
|
81
|
+
"disabled"
|
|
82
|
+
];
|
|
83
|
+
const _hoisted_20 = ["aria-label", "title"];
|
|
84
|
+
const _hoisted_21 = [
|
|
85
|
+
"aria-pressed",
|
|
86
|
+
"aria-label",
|
|
87
|
+
"title"
|
|
88
|
+
];
|
|
89
|
+
const _hoisted_22 = { class: "workspace" };
|
|
90
|
+
const _hoisted_23 = {
|
|
91
|
+
class: "materials panel-scroll",
|
|
92
|
+
"data-layout-panel": "materials",
|
|
93
|
+
"aria-label": "物料面板"
|
|
94
|
+
};
|
|
95
|
+
const _hoisted_24 = { class: "panel-heading" };
|
|
96
|
+
const _hoisted_25 = { class: "panel-count" };
|
|
97
|
+
const _hoisted_26 = { class: "material-toolbar" };
|
|
98
|
+
const _hoisted_27 = { class: "material-search" };
|
|
99
|
+
const _hoisted_28 = ["onKeydown"];
|
|
100
|
+
const _hoisted_29 = ["aria-expanded", "title"];
|
|
101
|
+
const _hoisted_30 = {
|
|
102
|
+
key: 0,
|
|
103
|
+
class: "custom-select__menu",
|
|
104
|
+
role: "listbox"
|
|
105
|
+
};
|
|
106
|
+
const _hoisted_31 = ["aria-selected"];
|
|
107
|
+
const _hoisted_32 = ["aria-selected", "onClick"];
|
|
108
|
+
const _hoisted_33 = { class: "material-result-summary" };
|
|
109
|
+
const _hoisted_34 = { key: 0 };
|
|
110
|
+
const _hoisted_35 = {
|
|
111
|
+
key: 0,
|
|
112
|
+
class: "material-empty"
|
|
113
|
+
};
|
|
114
|
+
const _hoisted_36 = [
|
|
115
|
+
"data-material-type",
|
|
116
|
+
"data-layout-material",
|
|
117
|
+
"data-layout-props",
|
|
118
|
+
"aria-label",
|
|
119
|
+
"onClick",
|
|
120
|
+
"onKeydown"
|
|
121
|
+
];
|
|
122
|
+
const _hoisted_37 = {
|
|
123
|
+
class: "material-icon material-icon--metric",
|
|
124
|
+
"aria-hidden": "true"
|
|
125
|
+
};
|
|
126
|
+
const _hoisted_38 = { class: "material-copy" };
|
|
127
|
+
const _hoisted_39 = { class: "material-card-meta" };
|
|
128
|
+
const _hoisted_40 = { class: "material-size" };
|
|
129
|
+
const _hoisted_41 = { class: "material-renderer-badges" };
|
|
130
|
+
const _hoisted_42 = ["title"];
|
|
131
|
+
const _hoisted_43 = { class: "material-card-actions" };
|
|
132
|
+
const _hoisted_44 = ["onClick"];
|
|
133
|
+
const _hoisted_45 = {
|
|
134
|
+
class: "material-add",
|
|
135
|
+
"aria-hidden": "true"
|
|
136
|
+
};
|
|
137
|
+
const _hoisted_50 = {
|
|
138
|
+
class: "canvas panel-scroll",
|
|
139
|
+
"data-layout-panel": "canvas",
|
|
140
|
+
"aria-label": "布局画布"
|
|
141
|
+
};
|
|
142
|
+
const _hoisted_51 = {
|
|
143
|
+
class: "canvas-toolbar",
|
|
144
|
+
"aria-label": "画布操作"
|
|
145
|
+
};
|
|
146
|
+
const _hoisted_52 = ["aria-expanded"];
|
|
147
|
+
const _hoisted_53 = {
|
|
148
|
+
key: 0,
|
|
149
|
+
class: "custom-select__menu",
|
|
150
|
+
role: "listbox"
|
|
151
|
+
};
|
|
152
|
+
const _hoisted_54 = [
|
|
153
|
+
"aria-selected",
|
|
154
|
+
"aria-label",
|
|
155
|
+
"onClick"
|
|
156
|
+
];
|
|
157
|
+
const _hoisted_55 = { class: "custom-select__option-meta" };
|
|
158
|
+
const _hoisted_56 = ["aria-label", "title"];
|
|
159
|
+
const _hoisted_57 = { class: "canvas-toolbar__group" };
|
|
160
|
+
const _hoisted_58 = {
|
|
161
|
+
class: "canvas-zoom-label",
|
|
162
|
+
"aria-live": "polite"
|
|
163
|
+
};
|
|
164
|
+
const _hoisted_59 = [
|
|
165
|
+
"data-canvas-width",
|
|
166
|
+
"data-canvas-height",
|
|
167
|
+
"data-canvas-orientation"
|
|
168
|
+
];
|
|
169
|
+
const _hoisted_60 = {
|
|
170
|
+
class: "editor-stage",
|
|
171
|
+
"aria-label": "可视化编辑画布"
|
|
172
|
+
};
|
|
173
|
+
const _hoisted_61 = { class: "stage-header" };
|
|
174
|
+
const _hoisted_62 = { class: "stage-badge" };
|
|
175
|
+
const _hoisted_63 = {
|
|
176
|
+
class: "preview-stage",
|
|
177
|
+
"aria-label": "组件预览画布"
|
|
178
|
+
};
|
|
179
|
+
const _hoisted_64 = ["aria-label", "onClick"];
|
|
180
|
+
const _hoisted_65 = ["data-preview-framework"];
|
|
181
|
+
const _hoisted_66 = { class: "stage-header" };
|
|
182
|
+
const _hoisted_67 = { class: "stage-badge" };
|
|
183
|
+
const _hoisted_68 = ["data-preview-framework"];
|
|
184
|
+
const _hoisted_69 = { class: "stage-header" };
|
|
185
|
+
const _hoisted_70 = { class: "stage-badge" };
|
|
186
|
+
const _hoisted_71 = {
|
|
187
|
+
class: "inspectors panel-scroll",
|
|
188
|
+
"data-layout-panel": "inspector",
|
|
189
|
+
"aria-label": "代码检查面板"
|
|
190
|
+
};
|
|
191
|
+
const _hoisted_72 = { class: "inspector-heading" };
|
|
192
|
+
const _hoisted_73 = ["aria-label", "title"];
|
|
193
|
+
const _hoisted_74 = {
|
|
194
|
+
class: "code-block",
|
|
195
|
+
"data-code-output": ""
|
|
196
|
+
};
|
|
197
|
+
const _hoisted_75 = ["innerHTML"];
|
|
198
|
+
const _hoisted_76 = { class: "code-status" };
|
|
199
|
+
const _hoisted_77 = ["data-preview-framework", "data-theme"];
|
|
200
|
+
const _hoisted_78 = { class: "preview-dialog__panel" };
|
|
201
|
+
const _hoisted_79 = { class: "preview-dialog__header" };
|
|
202
|
+
const _hoisted_80 = { class: "preview-dialog__header-meta" };
|
|
203
|
+
const _hoisted_81 = { class: "stage-badge" };
|
|
204
|
+
const _hoisted_82 = { class: "preview-dialog__body" };
|
|
205
|
+
const _hoisted_83 = { class: "preview-dialog__canvas" };
|
|
206
|
+
const _hoisted_84 = [
|
|
207
|
+
"data-material-code-framework",
|
|
208
|
+
"data-material-code-type",
|
|
209
|
+
"data-theme"
|
|
210
|
+
];
|
|
211
|
+
const _hoisted_85 = { class: "preview-dialog__panel material-code-dialog__panel" };
|
|
212
|
+
const _hoisted_86 = { class: "preview-dialog__header" };
|
|
213
|
+
const _hoisted_87 = { id: "material-code-title" };
|
|
214
|
+
const _hoisted_88 = { class: "material-code-dialog__subtitle" };
|
|
215
|
+
const _hoisted_89 = { class: "preview-dialog__header-meta" };
|
|
216
|
+
const _hoisted_90 = { class: "stage-badge" };
|
|
217
|
+
const _hoisted_91 = { class: "preview-dialog__body material-code-dialog__body" };
|
|
218
|
+
const _hoisted_92 = { class: "code-block material-code-dialog__code" };
|
|
219
|
+
const _hoisted_93 = ["innerHTML"];
|
|
220
|
+
const _hoisted_94 = { class: "preview-dialog__footer" };
|
|
221
|
+
const _hoisted_95 = { class: "material-code-dialog__actions" };
|
|
222
|
+
const _hoisted_96 = ["aria-label", "title"];
|
|
223
|
+
var LLayoutWorkspace_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
224
|
+
__name: "LLayoutWorkspace",
|
|
225
|
+
props: {
|
|
226
|
+
document: {
|
|
227
|
+
type: Object,
|
|
228
|
+
required: false
|
|
229
|
+
},
|
|
230
|
+
materials: {
|
|
231
|
+
type: [Object, Array],
|
|
232
|
+
required: false
|
|
233
|
+
},
|
|
234
|
+
theme: {
|
|
235
|
+
type: String,
|
|
236
|
+
required: false
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
emits: ["update:document", "change"],
|
|
240
|
+
setup(__props, { emit: __emit }) {
|
|
241
|
+
const workspaceProps = __props;
|
|
242
|
+
const workspaceEmit = __emit;
|
|
243
|
+
const routes = [
|
|
244
|
+
{
|
|
245
|
+
id: "editor",
|
|
246
|
+
label: "编辑",
|
|
247
|
+
description: "可视化编辑工作区"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
id: "vanilla",
|
|
251
|
+
label: "原生",
|
|
252
|
+
description: "原生运行时渲染"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
id: "runtime",
|
|
256
|
+
label: "预览",
|
|
257
|
+
description: "网格布局运行时预览"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
id: "vue",
|
|
261
|
+
label: "组件",
|
|
262
|
+
description: "组件适配器"
|
|
263
|
+
}
|
|
264
|
+
];
|
|
265
|
+
const breakpointIcons = {
|
|
266
|
+
desktop: Monitor,
|
|
267
|
+
tablet: Tablet,
|
|
268
|
+
mobile: Smartphone
|
|
269
|
+
};
|
|
270
|
+
const routeIcons = {
|
|
271
|
+
editor: Grid2X2,
|
|
272
|
+
vanilla: Code2,
|
|
273
|
+
runtime: Eye,
|
|
274
|
+
vue: PanelsTopLeft
|
|
275
|
+
};
|
|
276
|
+
const developmentFrameworks = [{
|
|
277
|
+
id: "webcomponent",
|
|
278
|
+
label: "原生",
|
|
279
|
+
description: "原生 Web Component 物料",
|
|
280
|
+
icon: Code2
|
|
281
|
+
}, {
|
|
282
|
+
id: "vue",
|
|
283
|
+
label: "Vue 3",
|
|
284
|
+
description: "Vue 3 组件物料",
|
|
285
|
+
icon: PanelsTopLeft
|
|
286
|
+
}];
|
|
287
|
+
function developmentFrameworkLabel(framework) {
|
|
288
|
+
if (framework === "webcomponent") return "原生";
|
|
289
|
+
return "Vue 3";
|
|
290
|
+
}
|
|
291
|
+
function escapeHtml(value) {
|
|
292
|
+
return value.replace(/[&<>'"]/g, (character) => ({
|
|
293
|
+
"&": "&",
|
|
294
|
+
"<": "<",
|
|
295
|
+
">": ">",
|
|
296
|
+
"'": "'",
|
|
297
|
+
"\"": """
|
|
298
|
+
})[character] ?? character);
|
|
299
|
+
}
|
|
300
|
+
function itemTitle(item) {
|
|
301
|
+
return String(item.props?.title ?? item.id);
|
|
302
|
+
}
|
|
303
|
+
function materialLabel(type) {
|
|
304
|
+
return materials.get(type)?.title ?? materials.get(type)?.label ?? type;
|
|
305
|
+
}
|
|
306
|
+
function formatMarkup(value) {
|
|
307
|
+
const tokens = value.replace(/></g, ">\n<").split("\n");
|
|
308
|
+
let depth = 0;
|
|
309
|
+
return tokens.map((token) => {
|
|
310
|
+
const line = token.trim();
|
|
311
|
+
if (!line) return "";
|
|
312
|
+
if (line.startsWith("</")) depth = Math.max(0, depth - 1);
|
|
313
|
+
const formatted = `${" ".repeat(depth)}${line}`;
|
|
314
|
+
if (line.startsWith("<") && !line.startsWith("</") && !line.startsWith("<!") && !line.startsWith("<?") && !line.endsWith("/>") && !/^<(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)\b/i.test(line)) depth += 1;
|
|
315
|
+
return formatted;
|
|
316
|
+
}).filter(Boolean).join("\n");
|
|
317
|
+
}
|
|
318
|
+
function formatCss(value) {
|
|
319
|
+
let depth = 0;
|
|
320
|
+
return value.replace(/\s*\{\s*/g, " {\n").replace(/\s*;\s*/g, ";\n").replace(/\s*\}\s*/g, "\n}\n").split("\n").map((line) => line.trim()).filter(Boolean).map((line) => {
|
|
321
|
+
if (line.startsWith("}")) depth = Math.max(0, depth - 1);
|
|
322
|
+
const formatted = `${" ".repeat(depth)}${line}`;
|
|
323
|
+
if (line.endsWith("{")) depth += 1;
|
|
324
|
+
return formatted;
|
|
325
|
+
}).join("\n");
|
|
326
|
+
}
|
|
327
|
+
function breakpointLabel(id) {
|
|
328
|
+
return id === "desktop" ? "桌面" : id === "tablet" ? "平板" : "手机";
|
|
329
|
+
}
|
|
330
|
+
function lucideMarkup(name) {
|
|
331
|
+
if (typeof document === "undefined") return "";
|
|
332
|
+
const element = createElement(icons[name]);
|
|
333
|
+
element.setAttribute("width", "13");
|
|
334
|
+
element.setAttribute("height", "13");
|
|
335
|
+
element.setAttribute("stroke-width", "1.9");
|
|
336
|
+
element.setAttribute("aria-hidden", "true");
|
|
337
|
+
return element.outerHTML;
|
|
338
|
+
}
|
|
339
|
+
function renderCardMarkup(item, options = {}) {
|
|
340
|
+
const type = materialLabel(item.type);
|
|
341
|
+
const title = escapeHtml(itemTitle(item));
|
|
342
|
+
const value = item.props?.value;
|
|
343
|
+
const valueMarkup = value === void 0 ? `<span class="layout-card__chart" aria-hidden="true"><i></i><i></i><i></i><i></i><i></i></span>` : `<strong class="layout-card__value">${escapeHtml(new Intl.NumberFormat("zh-CN").format(Number(value)))}</strong>`;
|
|
344
|
+
return `<article class="layout-card" data-layout-card data-layout-type="${escapeHtml(item.type)}">
|
|
345
|
+
${options.interactive ? `<div class="layout-card__actions" data-layout-actions>
|
|
346
|
+
<button class="layout-card__action" type="button" data-layout-action="copy" aria-disabled="false" aria-label="\u590D\u5236\u7269\u6599" title="\u590D\u5236\u7269\u6599">${lucideMarkup("Copy")}</button>
|
|
347
|
+
<button class="layout-card__action" type="button" data-layout-action="delete" aria-disabled="false" aria-label="\u5220\u9664\u7269\u6599" title="\u5220\u9664\u7269\u6599">${lucideMarkup("Trash2")}</button>
|
|
348
|
+
<button class="layout-card__action" type="button" data-layout-action="lock" aria-disabled="false" aria-label="${item.state?.locked ? "解锁物料" : "锁定物料"}" title="${item.state?.locked ? "解锁物料" : "锁定物料"}">${lucideMarkup(item.state?.locked ? "Unlock" : "Lock")}</button>
|
|
349
|
+
</div>` : ""}
|
|
350
|
+
<div class="layout-card__meta"><span class="layout-card__type">${escapeHtml(type)}</span><span class="layout-card__status">\u5DF2\u914D\u7F6E</span></div>
|
|
351
|
+
<h3 class="layout-card__title">${title}</h3>
|
|
352
|
+
${valueMarkup}
|
|
353
|
+
<div class="layout-card__footer"><span>\u5B9E\u65F6\u6570\u636E</span><span class="layout-card__spark">\u8D8B\u52BF\u7A33\u5B9A</span></div>
|
|
354
|
+
</article>`;
|
|
355
|
+
}
|
|
356
|
+
function renderExportMaterialMarkup(item) {
|
|
357
|
+
const tagName = (materials.get(item.type)?.renderers?.webcomponent)?.tagName;
|
|
358
|
+
if (!tagName || !/^[a-z][a-z0-9.-]*$/i.test(tagName)) return renderCardMarkup(item);
|
|
359
|
+
const attributes = Object.entries(item.props ?? {}).filter(([, value]) => value !== void 0 && value !== null).filter(([, value]) => typeof value !== "object" && typeof value !== "function").map(([key, value]) => `${key.replace(/[^a-zA-Z0-9:_.-]/g, "-")}="${escapeHtml(String(value))}"`).join(" ");
|
|
360
|
+
return `<${tagName}${attributes ? ` ${attributes}` : ""}></${tagName}>`;
|
|
361
|
+
}
|
|
362
|
+
function ensureWorkspaceMaterialElement(tagName, type) {
|
|
363
|
+
if (typeof customElements === "undefined" || !/^[a-z][a-z0-9.-]*$/i.test(tagName) || customElements.get(tagName)) return;
|
|
364
|
+
class LayoutMaterialElement extends HTMLElement {
|
|
365
|
+
constructor() {
|
|
366
|
+
super(...arguments);
|
|
367
|
+
this.props = {};
|
|
368
|
+
}
|
|
369
|
+
static get observedAttributes() {
|
|
370
|
+
return ["title", "value"];
|
|
371
|
+
}
|
|
372
|
+
get materialProps() {
|
|
373
|
+
return { ...this.props };
|
|
374
|
+
}
|
|
375
|
+
set materialProps(value) {
|
|
376
|
+
this.props = { ...value ?? {} };
|
|
377
|
+
this.render();
|
|
378
|
+
}
|
|
379
|
+
connectedCallback() {
|
|
380
|
+
this.render();
|
|
381
|
+
}
|
|
382
|
+
attributeChangedCallback() {
|
|
383
|
+
if (!Object.keys(this.props).length) this.render();
|
|
384
|
+
}
|
|
385
|
+
attributeProps() {
|
|
386
|
+
const result = {};
|
|
387
|
+
for (const attribute of Array.from(this.attributes)) {
|
|
388
|
+
if (attribute.name === "class" || attribute.name === "style") continue;
|
|
389
|
+
result[attribute.name] = attribute.name === "value" && attribute.value !== "" && !Number.isNaN(Number(attribute.value)) ? Number(attribute.value) : attribute.value;
|
|
390
|
+
}
|
|
391
|
+
return result;
|
|
392
|
+
}
|
|
393
|
+
render() {
|
|
394
|
+
const props = Object.keys(this.props).length ? this.props : this.attributeProps();
|
|
395
|
+
this.style.display = "block";
|
|
396
|
+
this.style.width = "100%";
|
|
397
|
+
this.style.height = "100%";
|
|
398
|
+
this.innerHTML = renderCardMarkup({
|
|
399
|
+
id: `native-${type}`,
|
|
400
|
+
type,
|
|
401
|
+
layout: {},
|
|
402
|
+
props
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
customElements.define(tagName, LayoutMaterialElement);
|
|
407
|
+
}
|
|
408
|
+
function setNativeRuntimeCard(shell, item) {
|
|
409
|
+
const tagName = (materials.get(item.type)?.renderers?.webcomponent)?.tagName;
|
|
410
|
+
shell.className = "layout-item-shell";
|
|
411
|
+
shell.dataset.layoutType = item.type;
|
|
412
|
+
shell.dataset.materialRenderer = "webcomponent";
|
|
413
|
+
if (!tagName || !/^[a-z][a-z0-9.-]*$/i.test(tagName)) {
|
|
414
|
+
shell.innerHTML = renderCardMarkup(item);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
ensureWorkspaceMaterialElement(tagName, item.type);
|
|
418
|
+
const element = shell.ownerDocument.createElement(tagName);
|
|
419
|
+
element.materialProps = { ...item.props ?? {} };
|
|
420
|
+
shell.replaceChildren(element);
|
|
421
|
+
}
|
|
422
|
+
function setRuntimeCard(shell, item) {
|
|
423
|
+
if (activeDevelopmentFramework.value === "webcomponent") {
|
|
424
|
+
setNativeRuntimeCard(shell, item);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
shell.className = "layout-item-shell";
|
|
428
|
+
shell.dataset.layoutType = item.type;
|
|
429
|
+
shell.dataset.materialRenderer = "vue";
|
|
430
|
+
shell.innerHTML = renderCardMarkup(item);
|
|
431
|
+
}
|
|
432
|
+
function parseRoute(value) {
|
|
433
|
+
const id = value.replace(/^#\/?/, "");
|
|
434
|
+
return routes.some((route) => route.id === id) ? id : "editor";
|
|
435
|
+
}
|
|
436
|
+
const builtinMaterials = [{
|
|
437
|
+
type: "metric",
|
|
438
|
+
order: 1,
|
|
439
|
+
title: "数据指标",
|
|
440
|
+
category: "data",
|
|
441
|
+
categoryLabel: "数据组件",
|
|
442
|
+
description: "数值与摘要",
|
|
443
|
+
keywords: [
|
|
444
|
+
"指标",
|
|
445
|
+
"数值",
|
|
446
|
+
"KPI"
|
|
447
|
+
],
|
|
448
|
+
tags: ["数据", "卡片"],
|
|
449
|
+
defaultLayout: {
|
|
450
|
+
w: 4,
|
|
451
|
+
h: 8
|
|
452
|
+
},
|
|
453
|
+
size: {
|
|
454
|
+
default: {
|
|
455
|
+
w: 4,
|
|
456
|
+
h: 8
|
|
457
|
+
},
|
|
458
|
+
min: {
|
|
459
|
+
w: 2,
|
|
460
|
+
h: 4
|
|
461
|
+
},
|
|
462
|
+
max: {
|
|
463
|
+
w: 12,
|
|
464
|
+
h: 20
|
|
465
|
+
},
|
|
466
|
+
step: {
|
|
467
|
+
w: 1,
|
|
468
|
+
h: 1
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
constraints: {
|
|
472
|
+
movable: true,
|
|
473
|
+
resizable: true
|
|
474
|
+
},
|
|
475
|
+
defaults: {
|
|
476
|
+
title: "新建指标",
|
|
477
|
+
value: 0
|
|
478
|
+
},
|
|
479
|
+
renderers: {
|
|
480
|
+
html: {
|
|
481
|
+
kind: "html",
|
|
482
|
+
tagName: "article"
|
|
483
|
+
},
|
|
484
|
+
webcomponent: {
|
|
485
|
+
kind: "webcomponent",
|
|
486
|
+
tagName: "ldesign-metric-card"
|
|
487
|
+
},
|
|
488
|
+
vue: {
|
|
489
|
+
kind: "vue",
|
|
490
|
+
package: "@composy/layout-vue",
|
|
491
|
+
exportName: "LMetricCard",
|
|
492
|
+
component: LMetricCard
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}, {
|
|
496
|
+
type: "chart",
|
|
497
|
+
order: 2,
|
|
498
|
+
title: "趋势图表",
|
|
499
|
+
category: "visual",
|
|
500
|
+
categoryLabel: "可视化组件",
|
|
501
|
+
description: "变化与走向",
|
|
502
|
+
keywords: [
|
|
503
|
+
"趋势",
|
|
504
|
+
"图表",
|
|
505
|
+
"分析"
|
|
506
|
+
],
|
|
507
|
+
tags: ["可视化", "卡片"],
|
|
508
|
+
defaultLayout: {
|
|
509
|
+
w: 4,
|
|
510
|
+
h: 10
|
|
511
|
+
},
|
|
512
|
+
size: {
|
|
513
|
+
default: {
|
|
514
|
+
w: 4,
|
|
515
|
+
h: 10
|
|
516
|
+
},
|
|
517
|
+
min: {
|
|
518
|
+
w: 3,
|
|
519
|
+
h: 6
|
|
520
|
+
},
|
|
521
|
+
max: {
|
|
522
|
+
w: 12,
|
|
523
|
+
h: 24
|
|
524
|
+
},
|
|
525
|
+
step: {
|
|
526
|
+
w: 1,
|
|
527
|
+
h: 1
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
constraints: {
|
|
531
|
+
movable: true,
|
|
532
|
+
resizable: true
|
|
533
|
+
},
|
|
534
|
+
defaults: { title: "营收趋势" },
|
|
535
|
+
renderers: {
|
|
536
|
+
html: {
|
|
537
|
+
kind: "html",
|
|
538
|
+
tagName: "article"
|
|
539
|
+
},
|
|
540
|
+
webcomponent: {
|
|
541
|
+
kind: "webcomponent",
|
|
542
|
+
tagName: "ldesign-trend-card"
|
|
543
|
+
},
|
|
544
|
+
vue: {
|
|
545
|
+
kind: "vue",
|
|
546
|
+
package: "@composy/layout-vue",
|
|
547
|
+
exportName: "LTrendCard",
|
|
548
|
+
component: LTrendCard
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}];
|
|
552
|
+
function resolveWorkspaceMaterials(input) {
|
|
553
|
+
if (!input) return createMaterialRegistry(builtinMaterials);
|
|
554
|
+
if (!Array.isArray(input)) return input;
|
|
555
|
+
return createMaterialRegistry(input);
|
|
556
|
+
}
|
|
557
|
+
const materials = resolveWorkspaceMaterials(workspaceProps.materials);
|
|
558
|
+
const initial = workspaceProps.document ?? createLayoutDocument({
|
|
559
|
+
id: "layout-alpha-demo",
|
|
560
|
+
breakpoints: responsiveWebBreakpoints.map((item) => ({ ...item })),
|
|
561
|
+
defaultBreakpointId: "desktop",
|
|
562
|
+
items: [
|
|
563
|
+
{
|
|
564
|
+
id: "sales",
|
|
565
|
+
type: "metric",
|
|
566
|
+
props: {
|
|
567
|
+
title: "月度销售额",
|
|
568
|
+
value: 12840
|
|
569
|
+
},
|
|
570
|
+
layout: {
|
|
571
|
+
desktop: {
|
|
572
|
+
x: 0,
|
|
573
|
+
y: 0,
|
|
574
|
+
w: 4,
|
|
575
|
+
h: 10
|
|
576
|
+
},
|
|
577
|
+
tablet: {
|
|
578
|
+
x: 0,
|
|
579
|
+
y: 0,
|
|
580
|
+
w: 4,
|
|
581
|
+
h: 10
|
|
582
|
+
},
|
|
583
|
+
mobile: {
|
|
584
|
+
x: 0,
|
|
585
|
+
y: 0,
|
|
586
|
+
w: 4,
|
|
587
|
+
h: 8
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
id: "orders",
|
|
593
|
+
type: "metric",
|
|
594
|
+
props: {
|
|
595
|
+
title: "待处理订单",
|
|
596
|
+
value: 86
|
|
597
|
+
},
|
|
598
|
+
layout: {
|
|
599
|
+
desktop: {
|
|
600
|
+
x: 4,
|
|
601
|
+
y: 0,
|
|
602
|
+
w: 4,
|
|
603
|
+
h: 10
|
|
604
|
+
},
|
|
605
|
+
tablet: {
|
|
606
|
+
x: 4,
|
|
607
|
+
y: 0,
|
|
608
|
+
w: 4,
|
|
609
|
+
h: 10
|
|
610
|
+
},
|
|
611
|
+
mobile: {
|
|
612
|
+
x: 0,
|
|
613
|
+
y: 8,
|
|
614
|
+
w: 4,
|
|
615
|
+
h: 8
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
id: "revenue",
|
|
621
|
+
type: "chart",
|
|
622
|
+
props: { title: "营收预测" },
|
|
623
|
+
layout: {
|
|
624
|
+
desktop: {
|
|
625
|
+
x: 8,
|
|
626
|
+
y: 0,
|
|
627
|
+
w: 4,
|
|
628
|
+
h: 18
|
|
629
|
+
},
|
|
630
|
+
tablet: {
|
|
631
|
+
x: 0,
|
|
632
|
+
y: 10,
|
|
633
|
+
w: 8,
|
|
634
|
+
h: 14
|
|
635
|
+
},
|
|
636
|
+
mobile: {
|
|
637
|
+
x: 0,
|
|
638
|
+
y: 16,
|
|
639
|
+
w: 4,
|
|
640
|
+
h: 12
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
]
|
|
645
|
+
});
|
|
646
|
+
const editorGrid = ref();
|
|
647
|
+
const canvasViewport = ref();
|
|
648
|
+
const runtimePreview = ref();
|
|
649
|
+
const vanillaRuntime = ref();
|
|
650
|
+
const previewDialogRuntime = ref();
|
|
651
|
+
const materialQuery = ref("");
|
|
652
|
+
const activeMaterialCategory = ref();
|
|
653
|
+
const activeDevelopmentFramework = ref("vue");
|
|
654
|
+
const materialElements = /* @__PURE__ */ new Map();
|
|
655
|
+
const materialSourceDisposers = /* @__PURE__ */ new Map();
|
|
656
|
+
const materialCategories = computed(() => materials.getCategories());
|
|
657
|
+
const activeMaterialCategoryLabel = computed(() => {
|
|
658
|
+
if (!activeMaterialCategory.value) return "全部分类";
|
|
659
|
+
return materialCategories.value.find((category) => category.id === activeMaterialCategory.value)?.label ?? "全部分类";
|
|
660
|
+
});
|
|
661
|
+
const activeDevelopmentFrameworkLabel = computed(() => developmentFrameworkLabel(activeDevelopmentFramework.value));
|
|
662
|
+
const materialCategoryFilter = computed({
|
|
663
|
+
get: () => activeMaterialCategory.value ?? "",
|
|
664
|
+
set: (value) => {
|
|
665
|
+
activeMaterialCategory.value = value || void 0;
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
const hasMaterialFilters = computed(() => Boolean(materialQuery.value.trim()) || Boolean(activeMaterialCategory.value));
|
|
669
|
+
const visibleMaterials = computed(() => materials.search({
|
|
670
|
+
query: materialQuery.value,
|
|
671
|
+
category: activeMaterialCategory.value,
|
|
672
|
+
framework: activeDevelopmentFramework.value
|
|
673
|
+
}));
|
|
674
|
+
const layout = ref(structuredClone(initial));
|
|
675
|
+
const selected = ref();
|
|
676
|
+
const selectedIds = ref([]);
|
|
677
|
+
const activeBreakpoint = ref("desktop");
|
|
678
|
+
const canvasOrientation = ref("landscape");
|
|
679
|
+
const deviceMenuOpen = ref(false);
|
|
680
|
+
const categoryMenuOpen = ref(false);
|
|
681
|
+
const developmentModeMenuOpen = ref(false);
|
|
682
|
+
const copied = ref(false);
|
|
683
|
+
const previewMode = ref(false);
|
|
684
|
+
const previewDialogOpen = ref(false);
|
|
685
|
+
const materialCodeDialog = ref();
|
|
686
|
+
const materialCodeCopied = ref(false);
|
|
687
|
+
const activeRoute = ref("editor");
|
|
688
|
+
const theme = ref(workspaceProps.theme ?? "light");
|
|
689
|
+
const canvasZoom = ref(1);
|
|
690
|
+
const canvasPan = ref({
|
|
691
|
+
x: 0,
|
|
692
|
+
y: 0
|
|
693
|
+
});
|
|
694
|
+
const canvasTool = ref("select");
|
|
695
|
+
const canvasPanning = ref(false);
|
|
696
|
+
const canvasSpacePressed = ref(false);
|
|
697
|
+
const canvasPanOrigin = ref({
|
|
698
|
+
x: 0,
|
|
699
|
+
y: 0,
|
|
700
|
+
panX: 0,
|
|
701
|
+
panY: 0
|
|
702
|
+
});
|
|
703
|
+
let editor;
|
|
704
|
+
let vanillaRuntimeInstance;
|
|
705
|
+
let previewDialogRuntimeInstance;
|
|
706
|
+
let previousGridStackRenderCallback;
|
|
707
|
+
let interactionPreviewFrame;
|
|
708
|
+
const disposers = [];
|
|
709
|
+
const currentDocument = computed(() => layout.value);
|
|
710
|
+
const canvasSize = computed(() => {
|
|
711
|
+
return {
|
|
712
|
+
desktop: {
|
|
713
|
+
landscape: {
|
|
714
|
+
width: 1200,
|
|
715
|
+
height: 760
|
|
716
|
+
},
|
|
717
|
+
portrait: {
|
|
718
|
+
width: 760,
|
|
719
|
+
height: 1200
|
|
720
|
+
}
|
|
721
|
+
},
|
|
722
|
+
tablet: {
|
|
723
|
+
landscape: {
|
|
724
|
+
width: 1024,
|
|
725
|
+
height: 768
|
|
726
|
+
},
|
|
727
|
+
portrait: {
|
|
728
|
+
width: 768,
|
|
729
|
+
height: 1024
|
|
730
|
+
}
|
|
731
|
+
},
|
|
732
|
+
mobile: {
|
|
733
|
+
landscape: {
|
|
734
|
+
width: 844,
|
|
735
|
+
height: 390
|
|
736
|
+
},
|
|
737
|
+
portrait: {
|
|
738
|
+
width: 390,
|
|
739
|
+
height: 844
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}[activeBreakpoint.value]?.[canvasOrientation.value] ?? {
|
|
743
|
+
width: 1200,
|
|
744
|
+
height: 760
|
|
745
|
+
};
|
|
746
|
+
});
|
|
747
|
+
const activeBreakpointIcon = computed(() => breakpointIcons[activeBreakpoint.value] ?? Monitor);
|
|
748
|
+
computed(() => JSON.stringify(currentDocument.value, null, 2));
|
|
749
|
+
const compiledResult = computed(() => compileLayout(currentDocument.value, {
|
|
750
|
+
target: "html-css",
|
|
751
|
+
breakpointId: activeBreakpoint.value,
|
|
752
|
+
materials,
|
|
753
|
+
materialCompiler: {
|
|
754
|
+
supports: () => true,
|
|
755
|
+
compile: (item) => renderExportMaterialMarkup(item)
|
|
756
|
+
}
|
|
757
|
+
}));
|
|
758
|
+
const compiled = computed(() => formatCss(compiledResult.value.css ?? ""));
|
|
759
|
+
const htmlSource = computed(() => {
|
|
760
|
+
const result = compiledResult.value;
|
|
761
|
+
return `<style>
|
|
762
|
+
${compiled.value}
|
|
763
|
+
</style>
|
|
764
|
+
|
|
765
|
+
${formatMarkup(result.html ?? "")}`;
|
|
766
|
+
});
|
|
767
|
+
computed(() => `<script setup lang="ts">
|
|
768
|
+
import { LGrid } from '@composy/layout-vue'
|
|
769
|
+
import type { LayoutDocument } from '@composy/layout-core'
|
|
770
|
+
|
|
771
|
+
const layoutDocument: LayoutDocument = ${JSON.stringify(currentDocument.value, null, 2)}
|
|
772
|
+
<\/script>
|
|
773
|
+
|
|
774
|
+
<template>
|
|
775
|
+
<LGrid :document="layoutDocument" breakpoint="${activeBreakpoint.value}">
|
|
776
|
+
<template #item="{ item }">
|
|
777
|
+
<article class="layout-card">
|
|
778
|
+
<div class="layout-card__meta">
|
|
779
|
+
<span class="layout-card__type">{{ item.type === 'metric' ? '\u6570\u636E\u6307\u6807' : '\u8D8B\u52BF\u56FE\u8868' }}</span>
|
|
780
|
+
<span class="layout-card__status">\u5DF2\u914D\u7F6E</span>
|
|
781
|
+
</div>
|
|
782
|
+
<h3 class="layout-card__title">{{ item.props.title }}</h3>
|
|
783
|
+
<strong v-if="item.props.value !== undefined" class="layout-card__value">
|
|
784
|
+
{{ Number(item.props.value).toLocaleString('zh-CN') }}
|
|
785
|
+
</strong>
|
|
786
|
+
<span v-else class="layout-card__chart" aria-hidden="true">
|
|
787
|
+
|
|
788
|
+
<i v-for="bar in 5" :key="bar" />
|
|
789
|
+
</span>
|
|
790
|
+
<div class="layout-card__footer"><span>\u5B9E\u65F6\u6570\u636E</span><span class="layout-card__spark">\u8D8B\u52BF\u7A33\u5B9A</span></div>
|
|
791
|
+
</article>
|
|
792
|
+
</template>
|
|
793
|
+
</LGrid>
|
|
794
|
+
</template>`);
|
|
795
|
+
computed(() => `import { Grid } from '@composy/layout-react'
|
|
796
|
+
import type { LayoutDocument } from '@composy/layout-core'
|
|
797
|
+
|
|
798
|
+
const layoutDocument: LayoutDocument = ${JSON.stringify(currentDocument.value, null, 2)}
|
|
799
|
+
|
|
800
|
+
export function LayoutPreview() {
|
|
801
|
+
return (
|
|
802
|
+
<Grid document={layoutDocument} breakpoint="${activeBreakpoint.value}">
|
|
803
|
+
{({ item }) => (
|
|
804
|
+
<article className="layout-card">
|
|
805
|
+
<div className="layout-card__meta">
|
|
806
|
+
<span className="layout-card__type">{item.type === 'metric' ? '\u6570\u636E\u6307\u6807' : '\u8D8B\u52BF\u56FE\u8868'}</span>
|
|
807
|
+
<span className="layout-card__status">\u5DF2\u914D\u7F6E</span>
|
|
808
|
+
</div>
|
|
809
|
+
<h3 className="layout-card__title">{String(item.props.title)}</h3>
|
|
810
|
+
{item.props.value !== undefined ? (
|
|
811
|
+
<strong className="layout-card__value">{Number(item.props.value).toLocaleString('zh-CN')}</strong>
|
|
812
|
+
) : (
|
|
813
|
+
<span className="layout-card__chart" aria-hidden="true">{[1, 2, 3, 4, 5].map(bar => <i key={bar} />)}</span>
|
|
814
|
+
)}
|
|
815
|
+
<div className="layout-card__footer"><span>\u5B9E\u65F6\u6570\u636E</span><span className="layout-card__spark">\u8D8B\u52BF\u7A33\u5B9A</span></div>
|
|
816
|
+
</article>
|
|
817
|
+
)}
|
|
818
|
+
</Grid>
|
|
819
|
+
)
|
|
820
|
+
}`);
|
|
821
|
+
const generatedVueSource = computed(() => {
|
|
822
|
+
const imports = /* @__PURE__ */ new Map();
|
|
823
|
+
const bindings = [];
|
|
824
|
+
const usedLocals = /* @__PURE__ */ new Set(["LGrid"]);
|
|
825
|
+
for (const material of materials.getAll()) {
|
|
826
|
+
const renderer = material.renderers?.vue;
|
|
827
|
+
if (!renderer?.package || !renderer.exportName) continue;
|
|
828
|
+
const exportName = renderer.exportName.trim();
|
|
829
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(exportName)) continue;
|
|
830
|
+
let localName = exportName;
|
|
831
|
+
let suffix = 2;
|
|
832
|
+
while (usedLocals.has(localName)) localName = `${exportName}${suffix++}`;
|
|
833
|
+
usedLocals.add(localName);
|
|
834
|
+
const packageImports = imports.get(renderer.package) ?? [];
|
|
835
|
+
packageImports.push(localName === exportName ? exportName : `${exportName} as ${localName}`);
|
|
836
|
+
imports.set(renderer.package, packageImports);
|
|
837
|
+
bindings.push(` ${JSON.stringify(material.type)}: ${localName}`);
|
|
838
|
+
}
|
|
839
|
+
const importLines = ["import { LGrid } from '@composy/layout-vue'", ...[...imports.entries()].map(([packageName, exports]) => `import { ${exports.join(", ")} } from '${packageName}'`)].join("\n");
|
|
840
|
+
const componentMap = bindings.length ? `const materialComponents = {
|
|
841
|
+
${bindings.join(",\n")}
|
|
842
|
+
} as const` : "const materialComponents: Record<string, never> = {}";
|
|
843
|
+
return `<script setup lang="ts">
|
|
844
|
+
${importLines}
|
|
845
|
+
import type { LayoutDocument } from '@composy/layout-core'
|
|
846
|
+
|
|
847
|
+
const layoutDocument: LayoutDocument = ${JSON.stringify(currentDocument.value, null, 2)}
|
|
848
|
+
const breakpoint = '${activeBreakpoint.value}'
|
|
849
|
+
${componentMap}
|
|
850
|
+
<\/script>
|
|
851
|
+
|
|
852
|
+
<template>
|
|
853
|
+
<LGrid :document="layoutDocument" :breakpoint="breakpoint">
|
|
854
|
+
<template #item="{ item }">
|
|
855
|
+
<component
|
|
856
|
+
:is="materialComponents[item.type as keyof typeof materialComponents]"
|
|
857
|
+
v-bind="item.props"
|
|
858
|
+
/>
|
|
859
|
+
</template>
|
|
860
|
+
</LGrid>
|
|
861
|
+
</template>
|
|
862
|
+
|
|
863
|
+
<style scoped>
|
|
864
|
+
/* LGrid renders the ldesign-layout-grid CSS Grid container. */
|
|
865
|
+
${compiled.value}
|
|
866
|
+
</style>`;
|
|
867
|
+
});
|
|
868
|
+
computed(() => `import type { LayoutDocument, LayoutNode } from '@composy/layout-core'
|
|
869
|
+
|
|
870
|
+
const layoutDocument: LayoutDocument = ${JSON.stringify(currentDocument.value, null, 2)}
|
|
871
|
+
const breakpoint = '${activeBreakpoint.value}'
|
|
872
|
+
const itemClass = (item: LayoutNode) => \`ldesign-layout-item-\${item.id.replace(/[^a-zA-Z0-9_-]/g, '-') }\`
|
|
873
|
+
|
|
874
|
+
export function LayoutPreview() {
|
|
875
|
+
return (
|
|
876
|
+
<section className="ldesign-layout-grid">
|
|
877
|
+
{layoutDocument.items.map(item => (
|
|
878
|
+
<article key={item.id} className={\`\${itemClass(item)} layout-card\`}>
|
|
879
|
+
<div className="layout-card__meta"><span className="layout-card__type">{item.type === 'metric' ? '\u6570\u636E\u6307\u6807' : '\u8D8B\u52BF\u56FE\u8868'}</span><span className="layout-card__status">\u5DF2\u914D\u7F6E</span></div>
|
|
880
|
+
<h3 className="layout-card__title">{String(item.props.title)}</h3>
|
|
881
|
+
{item.props.value !== undefined ? <strong className="layout-card__value">{Number(item.props.value).toLocaleString('zh-CN')}</strong> : <span className="layout-card__chart" aria-hidden="true">{[1, 2, 3, 4, 5].map(bar => <i key={bar} />)}</span>}
|
|
882
|
+
<div className="layout-card__footer"><span>\u5B9E\u65F6\u6570\u636E</span><span className="layout-card__spark">\u8D8B\u52BF\u7A33\u5B9A</span></div>
|
|
883
|
+
</article>
|
|
884
|
+
))}
|
|
885
|
+
</section>
|
|
886
|
+
)
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/* CSS Grid styles are emitted separately by the compiler. */`.replace(/<span className="layout-card__type">[\s\S]*?<\/span>/g, "<span className=\"layout-card__type\">{item.type}</span>").replace(/<span className="layout-card__status">[\s\S]*?<\/span>/g, "<span className=\"layout-card__status\">已配置</span>").replace(/<div className="layout-card__footer">[\s\S]*?<\/div>/g, "<div className=\"layout-card__footer\"><span>实时数据</span><span className=\"layout-card__spark\">稳定</span></div>"));
|
|
890
|
+
const activeCode = computed(() => activeDevelopmentFramework.value === "vue" ? generatedVueSource.value : htmlSource.value);
|
|
891
|
+
const activeCodeLabel = computed(() => activeDevelopmentFramework.value === "vue" ? "Vue组件代码" : "原生代码");
|
|
892
|
+
const activeCodeExtension = computed(() => activeDevelopmentFramework.value === "vue" ? "vue" : "html");
|
|
893
|
+
function materialCodeProps(material) {
|
|
894
|
+
return { ...material.defaults ?? {} };
|
|
895
|
+
}
|
|
896
|
+
function materialVueCode(material) {
|
|
897
|
+
const renderer = material.renderers?.vue;
|
|
898
|
+
const exportedName = renderer?.exportName?.trim();
|
|
899
|
+
const componentName = (exportedName && /^[A-Za-z_$][\w$]*$/.test(exportedName) ? exportedName : void 0) ?? renderer?.component?.name ?? material.type.replace(/[^A-Za-z0-9_$]/g, "");
|
|
900
|
+
const importLine = renderer?.package && exportedName && /^[A-Za-z_$][\w$]*$/.test(exportedName) ? `import { ${componentName} } from '${renderer.package}'` : `// Vue \u7EC4\u4EF6\u7531\u7269\u6599\u6CE8\u518C\u8868\u63D0\u4F9B\uFF1A${componentName}`;
|
|
901
|
+
const props = materialCodeProps(material);
|
|
902
|
+
const bindings = Object.entries(props).filter(([, value]) => value !== void 0 && value !== null).map(([key, value]) => ` :${key}='${JSON.stringify(value)}'`).join("\n");
|
|
903
|
+
return `<script setup lang="ts">
|
|
904
|
+
${importLine}
|
|
905
|
+
<\/script>
|
|
906
|
+
|
|
907
|
+
<!-- \u6CE8\u518C\u8868\u7269\u6599\uFF1A${material.type} -->
|
|
908
|
+
<template>
|
|
909
|
+
<${componentName}${bindings ? `
|
|
910
|
+
${bindings}
|
|
911
|
+
` : ""}/>
|
|
912
|
+
</template>`;
|
|
913
|
+
}
|
|
914
|
+
function materialWebComponentCode(material) {
|
|
915
|
+
const tagName = (material.renderers?.webcomponent)?.tagName ?? `ldesign-${material.type.replace(/[^a-z0-9-]/gi, "-")}`;
|
|
916
|
+
const attributes = Object.entries(materialCodeProps(material)).filter(([, value]) => value !== void 0 && value !== null).map(([key, value]) => `${key}="${String(value).replace(/"/g, """)}"`).join("\n ");
|
|
917
|
+
return `<!-- \u6CE8\u518C\u8868\u7269\u6599\uFF1A${material.type} -->
|
|
918
|
+
<!-- Web Component \u6807\u7B7E\uFF1A${tagName} -->
|
|
919
|
+
<${tagName}${attributes ? `
|
|
920
|
+
${attributes}` : ""}></${tagName}>`;
|
|
921
|
+
}
|
|
922
|
+
const materialCode = computed(() => {
|
|
923
|
+
const material = materialCodeDialog.value;
|
|
924
|
+
if (!material) return "";
|
|
925
|
+
return activeDevelopmentFramework.value === "vue" ? materialVueCode(material) : materialWebComponentCode(material);
|
|
926
|
+
});
|
|
927
|
+
const highlightedMaterialCode = computed(() => highlightCode(materialCode.value));
|
|
928
|
+
const materialCodeLineCount = computed(() => materialCode.value.split("\n").length);
|
|
929
|
+
function highlightCode(value) {
|
|
930
|
+
const fragments = [];
|
|
931
|
+
const stash = (value2, className) => {
|
|
932
|
+
return `__LDS_TOKEN_${fragments.push(`<span class="code-token-${className}">${value2}</span>`) - 1}__`;
|
|
933
|
+
};
|
|
934
|
+
let code = escapeHtml(value);
|
|
935
|
+
code = code.replace(/(".*?"|'.*?'|`.*?`)/g, (match) => stash(match, "string"));
|
|
936
|
+
code = code.replace(/(\/\/[^\n]*|\/\*[\s\S]*?\*\/)/g, (match) => stash(match, "comment"));
|
|
937
|
+
code = code.replace(/(^|[;{\n]\s*)([A-Za-z_$][\w$-]*)(?=\s*:)/g, (_, prefix, name) => `${prefix}${stash(name, "property")}`);
|
|
938
|
+
code = code.replace(/\b(import|from|const|let|function|return|export|as|type|class|extends|new|true|false|null|undefined)\b/g, (match) => stash(match, /^(?:true|false|null|undefined)$/.test(match) ? "constant" : "keyword"));
|
|
939
|
+
code = code.replace(/(<\/?[A-Za-z][^&]*>)/g, (match) => stash(match, "tag"));
|
|
940
|
+
let previous = "";
|
|
941
|
+
while (previous !== code && /__LDS_TOKEN_\d+__/.test(code)) {
|
|
942
|
+
previous = code;
|
|
943
|
+
code = code.replace(/__LDS_TOKEN_(\d+)__/g, (_, index) => fragments[Number(index)] ?? "");
|
|
944
|
+
}
|
|
945
|
+
return code;
|
|
946
|
+
}
|
|
947
|
+
const highlightedCode = computed(() => highlightCode(activeCode.value));
|
|
948
|
+
const activeCodeLineCount = computed(() => activeCode.value.split("\n").length);
|
|
949
|
+
const canvasSceneStyle = computed(() => ({
|
|
950
|
+
width: `${canvasSize.value.width}px`,
|
|
951
|
+
minHeight: `${canvasSize.value.height}px`,
|
|
952
|
+
"--canvas-height": `${canvasSize.value.height}px`,
|
|
953
|
+
"--canvas-grid-height": `${Math.max(180, canvasSize.value.height)}px`,
|
|
954
|
+
transform: `translate3d(${canvasPan.value.x}px, ${canvasPan.value.y}px, 0) scale(${canvasZoom.value})`
|
|
955
|
+
}));
|
|
956
|
+
const canvasZoomLabel = computed(() => `${Math.round(canvasZoom.value * 100)}%`);
|
|
957
|
+
const selectedItem = computed(() => layout.value.items.find((item) => item.id === selected.value));
|
|
958
|
+
const selectedLocked = computed(() => Boolean(selectedItem.value?.state?.locked));
|
|
959
|
+
const selectedMovable = computed(() => selectedItem.value?.constraints?.movable !== false);
|
|
960
|
+
const selectedResizable = computed(() => selectedItem.value?.constraints?.resizable !== false);
|
|
961
|
+
function add(type) {
|
|
962
|
+
if (!editor) return;
|
|
963
|
+
const node = editor.addItem({ type });
|
|
964
|
+
editor.updateItem(node.id, (item) => {
|
|
965
|
+
for (const bp of Object.values(item.layout)) bp.y = 30;
|
|
966
|
+
return item;
|
|
967
|
+
});
|
|
968
|
+
editor.select(node.id);
|
|
969
|
+
}
|
|
970
|
+
function materialProps(type) {
|
|
971
|
+
return JSON.stringify(materials.get(type)?.defaults ?? {});
|
|
972
|
+
}
|
|
973
|
+
function openMaterialCode(type) {
|
|
974
|
+
const material = materials.get(type);
|
|
975
|
+
if (!material) return;
|
|
976
|
+
materialCodeDialog.value = material;
|
|
977
|
+
materialCodeCopied.value = false;
|
|
978
|
+
closeFilterMenus();
|
|
979
|
+
}
|
|
980
|
+
function closeMaterialCode() {
|
|
981
|
+
materialCodeDialog.value = void 0;
|
|
982
|
+
materialCodeCopied.value = false;
|
|
983
|
+
}
|
|
984
|
+
async function copyMaterialCode() {
|
|
985
|
+
if (!materialCode.value || typeof navigator === "undefined") return;
|
|
986
|
+
try {
|
|
987
|
+
await navigator.clipboard.writeText(materialCode.value);
|
|
988
|
+
materialCodeCopied.value = true;
|
|
989
|
+
window.setTimeout(() => {
|
|
990
|
+
materialCodeCopied.value = false;
|
|
991
|
+
}, 1500);
|
|
992
|
+
} catch {
|
|
993
|
+
materialCodeCopied.value = false;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
function handleMaterialClick(type) {
|
|
997
|
+
add(type);
|
|
998
|
+
}
|
|
999
|
+
function toggleFilterMenu(menu) {
|
|
1000
|
+
categoryMenuOpen.value = menu === "category" ? !categoryMenuOpen.value : false;
|
|
1001
|
+
deviceMenuOpen.value = menu === "device" ? !deviceMenuOpen.value : false;
|
|
1002
|
+
developmentModeMenuOpen.value = false;
|
|
1003
|
+
}
|
|
1004
|
+
function toggleDevelopmentModeMenu() {
|
|
1005
|
+
developmentModeMenuOpen.value = !developmentModeMenuOpen.value;
|
|
1006
|
+
categoryMenuOpen.value = false;
|
|
1007
|
+
deviceMenuOpen.value = false;
|
|
1008
|
+
}
|
|
1009
|
+
function closeFilterMenus() {
|
|
1010
|
+
categoryMenuOpen.value = false;
|
|
1011
|
+
deviceMenuOpen.value = false;
|
|
1012
|
+
developmentModeMenuOpen.value = false;
|
|
1013
|
+
}
|
|
1014
|
+
function handleFilterMenuKeydown(event) {
|
|
1015
|
+
if (event.key !== "Escape") return;
|
|
1016
|
+
if (!categoryMenuOpen.value && !developmentModeMenuOpen.value && !deviceMenuOpen.value) return;
|
|
1017
|
+
closeFilterMenus();
|
|
1018
|
+
event.target?.blur();
|
|
1019
|
+
}
|
|
1020
|
+
function handleFilterOutsidePointerdown(event) {
|
|
1021
|
+
const target = event.target;
|
|
1022
|
+
if (!(target instanceof Element)) return;
|
|
1023
|
+
if (target.closest("[data-layout-filter-menu]")) return;
|
|
1024
|
+
closeFilterMenus();
|
|
1025
|
+
}
|
|
1026
|
+
function selectMaterialCategory(category) {
|
|
1027
|
+
materialCategoryFilter.value = category;
|
|
1028
|
+
closeFilterMenus();
|
|
1029
|
+
}
|
|
1030
|
+
function selectDevelopmentFramework(framework) {
|
|
1031
|
+
activeDevelopmentFramework.value = framework;
|
|
1032
|
+
if (typeof window !== "undefined") window.localStorage.setItem("layout-development-framework", framework);
|
|
1033
|
+
closeFilterMenus();
|
|
1034
|
+
nextTick(() => {
|
|
1035
|
+
syncVanillaRuntime();
|
|
1036
|
+
syncPreviewDialogRuntime();
|
|
1037
|
+
if (previewMode.value && editor) {
|
|
1038
|
+
editor.setMode("edit");
|
|
1039
|
+
nextTick(() => editor?.setMode("preview"));
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
function resetMaterialFilters() {
|
|
1044
|
+
materialQuery.value = "";
|
|
1045
|
+
activeMaterialCategory.value = void 0;
|
|
1046
|
+
closeFilterMenus();
|
|
1047
|
+
}
|
|
1048
|
+
function materialIcon(type) {
|
|
1049
|
+
return type === "chart" ? ChartSpline : ChartNoAxesColumnIncreasing;
|
|
1050
|
+
}
|
|
1051
|
+
function setMaterialElement(type, value) {
|
|
1052
|
+
if (value instanceof HTMLElement) materialElements.set(type, value);
|
|
1053
|
+
else materialElements.delete(type);
|
|
1054
|
+
}
|
|
1055
|
+
function syncMaterialSources() {
|
|
1056
|
+
if (!editor) return;
|
|
1057
|
+
const visibleTypes = new Set(visibleMaterials.value.map((material) => material.type));
|
|
1058
|
+
for (const material of visibleMaterials.value) {
|
|
1059
|
+
const element = materialElements.get(material.type);
|
|
1060
|
+
if (!element || materialSourceDisposers.has(material.type)) continue;
|
|
1061
|
+
const size = material.defaultLayout ?? material.size?.default;
|
|
1062
|
+
const dispose = editor.registerExternalDragSource({
|
|
1063
|
+
element,
|
|
1064
|
+
type: material.type,
|
|
1065
|
+
props: { ...material.defaults ?? {} },
|
|
1066
|
+
placement: {
|
|
1067
|
+
x: 0,
|
|
1068
|
+
y: 0,
|
|
1069
|
+
w: size?.w ?? 1,
|
|
1070
|
+
h: size?.h ?? 1
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
materialSourceDisposers.set(material.type, dispose);
|
|
1074
|
+
}
|
|
1075
|
+
for (const [type, dispose] of materialSourceDisposers) if (!visibleTypes.has(type)) {
|
|
1076
|
+
dispose();
|
|
1077
|
+
materialSourceDisposers.delete(type);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
watch([
|
|
1081
|
+
materialQuery,
|
|
1082
|
+
activeMaterialCategory,
|
|
1083
|
+
activeDevelopmentFramework
|
|
1084
|
+
], () => nextTick(syncMaterialSources));
|
|
1085
|
+
function removeSelected() {
|
|
1086
|
+
editor?.handleKeyboard({ key: "Delete" });
|
|
1087
|
+
}
|
|
1088
|
+
function toggleSelectedLock() {
|
|
1089
|
+
if (!editor || !selected.value) return;
|
|
1090
|
+
if (selectedLocked.value) editor.unlockItem(selected.value);
|
|
1091
|
+
else editor.lockItem(selected.value);
|
|
1092
|
+
}
|
|
1093
|
+
function toggleSelectedConstraint(key) {
|
|
1094
|
+
if (!editor || !selected.value) return;
|
|
1095
|
+
editor.updateItem(selected.value, (item) => {
|
|
1096
|
+
item.constraints = {
|
|
1097
|
+
...item.constraints ?? {},
|
|
1098
|
+
[key]: item.constraints?.[key] === false
|
|
1099
|
+
};
|
|
1100
|
+
return item;
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
function undo() {
|
|
1104
|
+
editor?.undo();
|
|
1105
|
+
}
|
|
1106
|
+
function redo() {
|
|
1107
|
+
editor?.redo();
|
|
1108
|
+
}
|
|
1109
|
+
function togglePreview() {
|
|
1110
|
+
const nextMode = previewMode.value ? "edit" : "preview";
|
|
1111
|
+
editor?.setMode(nextMode);
|
|
1112
|
+
navigate(nextMode === "preview" ? "runtime" : "editor");
|
|
1113
|
+
}
|
|
1114
|
+
function openPreviewDialog() {
|
|
1115
|
+
previewDialogOpen.value = true;
|
|
1116
|
+
nextTick(syncPreviewDialogRuntime);
|
|
1117
|
+
}
|
|
1118
|
+
function closePreviewDialog() {
|
|
1119
|
+
previewDialogOpen.value = false;
|
|
1120
|
+
previewDialogRuntimeInstance?.destroy();
|
|
1121
|
+
previewDialogRuntimeInstance = void 0;
|
|
1122
|
+
}
|
|
1123
|
+
function syncPreviewDialogRuntime() {
|
|
1124
|
+
if (activeDevelopmentFramework.value !== "webcomponent" || !previewDialogOpen.value || !previewDialogRuntime.value) {
|
|
1125
|
+
previewDialogRuntimeInstance?.destroy();
|
|
1126
|
+
previewDialogRuntimeInstance = void 0;
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
const runtimeDocument = editor?.exportRuntimeDocument() ?? layout.value;
|
|
1130
|
+
if (!previewDialogRuntimeInstance) {
|
|
1131
|
+
previewDialogRuntimeInstance = createLayoutRuntime({
|
|
1132
|
+
container: previewDialogRuntime.value,
|
|
1133
|
+
document: runtimeDocument,
|
|
1134
|
+
materials,
|
|
1135
|
+
observeResize: false,
|
|
1136
|
+
renderItem: ({ shell, item }) => {
|
|
1137
|
+
const render = () => setNativeRuntimeCard(shell, item);
|
|
1138
|
+
render();
|
|
1139
|
+
return { update: render };
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
previewDialogRuntimeInstance.mount();
|
|
1143
|
+
} else previewDialogRuntimeInstance.update(runtimeDocument);
|
|
1144
|
+
previewDialogRuntimeInstance.setBreakpoint(activeBreakpoint.value);
|
|
1145
|
+
}
|
|
1146
|
+
watch([
|
|
1147
|
+
previewDialogOpen,
|
|
1148
|
+
activeDevelopmentFramework,
|
|
1149
|
+
activeBreakpoint,
|
|
1150
|
+
layout
|
|
1151
|
+
], () => nextTick(syncPreviewDialogRuntime));
|
|
1152
|
+
function syncVanillaRuntime() {
|
|
1153
|
+
if (activeDevelopmentFramework.value !== "webcomponent" || activeRoute.value !== "vanilla" || !vanillaRuntime.value || !editor) {
|
|
1154
|
+
vanillaRuntimeInstance?.destroy();
|
|
1155
|
+
vanillaRuntimeInstance = void 0;
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
const document2 = editor.exportRuntimeDocument();
|
|
1159
|
+
if (!vanillaRuntimeInstance) {
|
|
1160
|
+
vanillaRuntimeInstance = createLayoutRuntime({
|
|
1161
|
+
container: vanillaRuntime.value,
|
|
1162
|
+
document: document2,
|
|
1163
|
+
materials,
|
|
1164
|
+
observeResize: false,
|
|
1165
|
+
renderItem: ({ shell, item }) => {
|
|
1166
|
+
const render = () => {
|
|
1167
|
+
setRuntimeCard(shell, item);
|
|
1168
|
+
};
|
|
1169
|
+
render();
|
|
1170
|
+
return { update: render };
|
|
1171
|
+
}
|
|
1172
|
+
});
|
|
1173
|
+
vanillaRuntimeInstance.mount();
|
|
1174
|
+
} else vanillaRuntimeInstance.update(document2);
|
|
1175
|
+
vanillaRuntimeInstance.setBreakpoint(activeBreakpoint.value);
|
|
1176
|
+
}
|
|
1177
|
+
function navigate(route) {
|
|
1178
|
+
activeRoute.value = route;
|
|
1179
|
+
if (typeof window !== "undefined") window.location.hash = `/${route}`;
|
|
1180
|
+
if (route === "runtime") {
|
|
1181
|
+
if (editor?.getMode() === "preview") editor.setMode("edit");
|
|
1182
|
+
editor?.setMode("preview");
|
|
1183
|
+
const clearEditorWidgets = () => {
|
|
1184
|
+
if (activeRoute.value !== "runtime") return;
|
|
1185
|
+
editorGrid.value?.querySelectorAll(".grid-stack-item").forEach((element) => element.remove());
|
|
1186
|
+
};
|
|
1187
|
+
clearEditorWidgets();
|
|
1188
|
+
nextTick(clearEditorWidgets);
|
|
1189
|
+
} else if (previewMode.value) editor?.setMode("edit");
|
|
1190
|
+
nextTick(syncVanillaRuntime);
|
|
1191
|
+
}
|
|
1192
|
+
function select(id) {
|
|
1193
|
+
editor?.select(id);
|
|
1194
|
+
}
|
|
1195
|
+
function changeBreakpoint(id) {
|
|
1196
|
+
activeBreakpoint.value = id;
|
|
1197
|
+
canvasOrientation.value = id === "mobile" ? "portrait" : "landscape";
|
|
1198
|
+
editor?.setBreakpoint(id);
|
|
1199
|
+
vanillaRuntimeInstance?.setBreakpoint(id);
|
|
1200
|
+
deviceMenuOpen.value = false;
|
|
1201
|
+
}
|
|
1202
|
+
function selectBreakpoint(id) {
|
|
1203
|
+
changeBreakpoint(id);
|
|
1204
|
+
}
|
|
1205
|
+
function toggleCanvasOrientation() {
|
|
1206
|
+
canvasOrientation.value = canvasOrientation.value === "portrait" ? "landscape" : "portrait";
|
|
1207
|
+
}
|
|
1208
|
+
function clampCanvasZoom(value) {
|
|
1209
|
+
return Math.min(2, Math.max(.5, Math.round(value * 20) / 20));
|
|
1210
|
+
}
|
|
1211
|
+
function setCanvasZoom(value, anchor) {
|
|
1212
|
+
const viewport = canvasViewport.value;
|
|
1213
|
+
const previousZoom = canvasZoom.value;
|
|
1214
|
+
const nextZoom = clampCanvasZoom(value);
|
|
1215
|
+
if (!viewport || previousZoom === nextZoom) return;
|
|
1216
|
+
const rect = viewport.getBoundingClientRect();
|
|
1217
|
+
const anchorX = anchor?.x ?? rect.left + rect.width / 2;
|
|
1218
|
+
const anchorY = anchor?.y ?? rect.top + rect.height / 2;
|
|
1219
|
+
const localX = (anchorX - rect.left - canvasPan.value.x) / previousZoom;
|
|
1220
|
+
const localY = (anchorY - rect.top - canvasPan.value.y) / previousZoom;
|
|
1221
|
+
canvasZoom.value = nextZoom;
|
|
1222
|
+
canvasPan.value = {
|
|
1223
|
+
x: anchorX - rect.left - localX * nextZoom,
|
|
1224
|
+
y: anchorY - rect.top - localY * nextZoom
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
function zoomCanvas(direction) {
|
|
1228
|
+
setCanvasZoom(canvasZoom.value + direction * .1);
|
|
1229
|
+
}
|
|
1230
|
+
function resetCanvasView() {
|
|
1231
|
+
canvasZoom.value = 1;
|
|
1232
|
+
canvasPan.value = {
|
|
1233
|
+
x: 0,
|
|
1234
|
+
y: 0
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
function resetCanvasPan() {
|
|
1238
|
+
canvasPan.value = {
|
|
1239
|
+
x: 0,
|
|
1240
|
+
y: 0
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
function toggleTheme() {
|
|
1244
|
+
theme.value = theme.value === "light" ? "dark" : "light";
|
|
1245
|
+
if (typeof window !== "undefined") window.localStorage.setItem("layout-theme", theme.value);
|
|
1246
|
+
}
|
|
1247
|
+
function handleCanvasWheel(event) {
|
|
1248
|
+
event.preventDefault();
|
|
1249
|
+
const direction = event.deltaY < 0 ? 1 : -1;
|
|
1250
|
+
setCanvasZoom(canvasZoom.value + direction * .08, {
|
|
1251
|
+
x: event.clientX,
|
|
1252
|
+
y: event.clientY
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
function handleCanvasPointerDown(event) {
|
|
1256
|
+
if (!(canvasTool.value === "pan" || canvasSpacePressed.value || event.button === 1) || event.button === 2) return;
|
|
1257
|
+
event.preventDefault();
|
|
1258
|
+
event.stopPropagation();
|
|
1259
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
1260
|
+
canvasPanning.value = true;
|
|
1261
|
+
canvasPanOrigin.value = {
|
|
1262
|
+
x: event.clientX,
|
|
1263
|
+
y: event.clientY,
|
|
1264
|
+
panX: canvasPan.value.x,
|
|
1265
|
+
panY: canvasPan.value.y
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
function handleCanvasPointerMove(event) {
|
|
1269
|
+
if (!canvasPanning.value) return;
|
|
1270
|
+
const origin = canvasPanOrigin.value;
|
|
1271
|
+
canvasPan.value = {
|
|
1272
|
+
x: origin.panX + event.clientX - origin.x,
|
|
1273
|
+
y: origin.panY + event.clientY - origin.y
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
function finishCanvasPan(event) {
|
|
1277
|
+
if (!canvasPanning.value) return;
|
|
1278
|
+
canvasPanning.value = false;
|
|
1279
|
+
if (event) event.currentTarget.releasePointerCapture?.(event.pointerId);
|
|
1280
|
+
}
|
|
1281
|
+
function handleCanvasKeydown(event) {
|
|
1282
|
+
if (event.code === "Space") canvasSpacePressed.value = true;
|
|
1283
|
+
}
|
|
1284
|
+
function handleCanvasKeyup(event) {
|
|
1285
|
+
if (event.code === "Space") canvasSpacePressed.value = false;
|
|
1286
|
+
}
|
|
1287
|
+
function handleWorkspaceKeydown(event) {
|
|
1288
|
+
if (!editor || event.defaultPrevented) return;
|
|
1289
|
+
const root = editorGrid.value?.closest("[data-layout-workspace]");
|
|
1290
|
+
if (!root || !(event.target instanceof Node) || !root.contains(event.target)) return;
|
|
1291
|
+
const key = event.key.toLowerCase();
|
|
1292
|
+
if (!((event.ctrlKey || event.metaKey) && [
|
|
1293
|
+
"c",
|
|
1294
|
+
"v",
|
|
1295
|
+
"x",
|
|
1296
|
+
"d"
|
|
1297
|
+
].includes(key)) && !["delete", "backspace"].includes(key)) return;
|
|
1298
|
+
editor.handleKeyboard({
|
|
1299
|
+
key: event.key,
|
|
1300
|
+
shiftKey: event.shiftKey,
|
|
1301
|
+
ctrlKey: event.ctrlKey,
|
|
1302
|
+
metaKey: event.metaKey,
|
|
1303
|
+
altKey: event.altKey,
|
|
1304
|
+
preventDefault: () => event.preventDefault()
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
async function copyActiveCode() {
|
|
1308
|
+
const value = activeCode.value;
|
|
1309
|
+
try {
|
|
1310
|
+
if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(value);
|
|
1311
|
+
else {
|
|
1312
|
+
const textarea = document.createElement("textarea");
|
|
1313
|
+
textarea.value = value;
|
|
1314
|
+
textarea.style.position = "fixed";
|
|
1315
|
+
textarea.style.opacity = "0";
|
|
1316
|
+
document.body.appendChild(textarea);
|
|
1317
|
+
textarea.select();
|
|
1318
|
+
document.execCommand("copy");
|
|
1319
|
+
textarea.remove();
|
|
1320
|
+
}
|
|
1321
|
+
copied.value = true;
|
|
1322
|
+
window.setTimeout(() => {
|
|
1323
|
+
copied.value = false;
|
|
1324
|
+
}, 1600);
|
|
1325
|
+
} catch {
|
|
1326
|
+
copied.value = false;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
function downloadActiveCode() {
|
|
1330
|
+
const blob = new Blob([activeCode.value], { type: "text/plain;charset=utf-8" });
|
|
1331
|
+
const url = URL.createObjectURL(blob);
|
|
1332
|
+
const anchor = document.createElement("a");
|
|
1333
|
+
anchor.href = url;
|
|
1334
|
+
anchor.download = `layout-${activeDevelopmentFramework.value}.${activeCodeExtension.value}`;
|
|
1335
|
+
anchor.click();
|
|
1336
|
+
URL.revokeObjectURL(url);
|
|
1337
|
+
}
|
|
1338
|
+
function handleEditorGridAction(event) {
|
|
1339
|
+
const target = event.target;
|
|
1340
|
+
if (!(target instanceof Element)) return;
|
|
1341
|
+
const action = target.closest("[data-layout-action]");
|
|
1342
|
+
const widget = target.closest(".grid-stack-item");
|
|
1343
|
+
if (!action || !widget || action.dataset.layoutActionPointer === "true") {
|
|
1344
|
+
if (action?.dataset.layoutActionPointer === "true") delete action.dataset.layoutActionPointer;
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
if (event.type === "pointerdown") {
|
|
1348
|
+
action.dataset.layoutActionPointer = "true";
|
|
1349
|
+
event.preventDefault();
|
|
1350
|
+
}
|
|
1351
|
+
const id = widget.getAttribute("gs-id") ?? widget.getAttribute("data-layout-item-id");
|
|
1352
|
+
if (!id || !editor) return;
|
|
1353
|
+
editor.select(id);
|
|
1354
|
+
const kind = action.dataset.layoutAction;
|
|
1355
|
+
if (kind === "copy") editor.copySelection();
|
|
1356
|
+
else if (kind === "delete") editor.removeItem(id);
|
|
1357
|
+
else if (kind === "lock") if (layout.value.items.find((item) => item.id === id)?.state?.locked) editor.unlockItem(id);
|
|
1358
|
+
else editor.lockItem(id);
|
|
1359
|
+
}
|
|
1360
|
+
function syncSelection() {
|
|
1361
|
+
const root = editorGrid.value;
|
|
1362
|
+
if (!root) return;
|
|
1363
|
+
root.querySelectorAll(".grid-stack-item").forEach((item) => {
|
|
1364
|
+
const id = item.getAttribute("gs-id") ?? item.getAttribute("data-layout-item-id") ?? "";
|
|
1365
|
+
const node = layout.value.items.find((candidate) => candidate.id === id);
|
|
1366
|
+
const active = selectedIds.value.includes(id);
|
|
1367
|
+
item.classList.toggle("is-selected", active);
|
|
1368
|
+
item.tabIndex = 0;
|
|
1369
|
+
item.setAttribute("role", "button");
|
|
1370
|
+
if (node) item.setAttribute("aria-label", `${itemTitle(node)}\uFF0C${materialLabel(node.type)}`);
|
|
1371
|
+
item.setAttribute("aria-pressed", String(active));
|
|
1372
|
+
item.setAttribute("aria-selected", String(active));
|
|
1373
|
+
item.setAttribute("aria-disabled", String(Boolean(node?.state?.locked)));
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
function syncInteractionPreview() {
|
|
1377
|
+
if (interactionPreviewFrame !== void 0) return;
|
|
1378
|
+
const flush = () => {
|
|
1379
|
+
interactionPreviewFrame = void 0;
|
|
1380
|
+
if (!editor) return;
|
|
1381
|
+
layout.value = editor.exportRuntimeDocument();
|
|
1382
|
+
queueMicrotask(syncSelection);
|
|
1383
|
+
};
|
|
1384
|
+
if (typeof window === "undefined") flush();
|
|
1385
|
+
else interactionPreviewFrame = window.requestAnimationFrame(flush);
|
|
1386
|
+
}
|
|
1387
|
+
onMounted(() => {
|
|
1388
|
+
if (typeof window !== "undefined") {
|
|
1389
|
+
const savedTheme = window.localStorage.getItem("layout-theme");
|
|
1390
|
+
if (savedTheme === "light" || savedTheme === "dark") theme.value = savedTheme;
|
|
1391
|
+
const savedFramework = window.localStorage.getItem("layout-development-framework");
|
|
1392
|
+
if (savedFramework === "webcomponent" || savedFramework === "vue") activeDevelopmentFramework.value = savedFramework;
|
|
1393
|
+
}
|
|
1394
|
+
if (!editorGrid.value) return;
|
|
1395
|
+
previousGridStackRenderCallback = GridStack.renderCB;
|
|
1396
|
+
GridStack.renderCB = (element, widget) => {
|
|
1397
|
+
if (element && widget?.content !== void 0) element.innerHTML = String(widget.content);
|
|
1398
|
+
};
|
|
1399
|
+
const engine = createGridStackEditorEngine({
|
|
1400
|
+
container: editorGrid.value,
|
|
1401
|
+
gridOptions: {
|
|
1402
|
+
acceptWidgets: true,
|
|
1403
|
+
animate: false
|
|
1404
|
+
},
|
|
1405
|
+
createGrid: (options) => GridStack.init(options, editorGrid.value),
|
|
1406
|
+
renderItem: ({ item }) => renderCardMarkup(item, { interactive: true })
|
|
1407
|
+
});
|
|
1408
|
+
editor = createLayoutEditor({
|
|
1409
|
+
document: initial,
|
|
1410
|
+
engine,
|
|
1411
|
+
materials,
|
|
1412
|
+
preview: runtimePreview.value ? {
|
|
1413
|
+
container: runtimePreview.value,
|
|
1414
|
+
renderItem: ({ shell, item }) => {
|
|
1415
|
+
const render = () => {
|
|
1416
|
+
setRuntimeCard(shell, item);
|
|
1417
|
+
};
|
|
1418
|
+
render();
|
|
1419
|
+
return { update: render };
|
|
1420
|
+
}
|
|
1421
|
+
} : void 0
|
|
1422
|
+
});
|
|
1423
|
+
editor.on("document:change", (event) => {
|
|
1424
|
+
layout.value = event.document;
|
|
1425
|
+
workspaceEmit("update:document", event.document);
|
|
1426
|
+
workspaceEmit("change", event.document);
|
|
1427
|
+
queueMicrotask(syncSelection);
|
|
1428
|
+
syncVanillaRuntime();
|
|
1429
|
+
});
|
|
1430
|
+
editor.on("interaction:move", syncInteractionPreview);
|
|
1431
|
+
editor.on("interaction:resize", syncInteractionPreview);
|
|
1432
|
+
editor.on("selection:change", (event) => {
|
|
1433
|
+
selected.value = event.primaryId;
|
|
1434
|
+
selectedIds.value = [...event.selectedIds];
|
|
1435
|
+
syncSelection();
|
|
1436
|
+
});
|
|
1437
|
+
editor.on("mode:change", (event) => {
|
|
1438
|
+
previewMode.value = event.mode === "preview";
|
|
1439
|
+
if (event.mode === "preview" && activeRoute.value !== "runtime") activeRoute.value = "runtime";
|
|
1440
|
+
if (event.mode === "edit" && activeRoute.value === "runtime") activeRoute.value = "editor";
|
|
1441
|
+
nextTick(syncVanillaRuntime);
|
|
1442
|
+
});
|
|
1443
|
+
editor.mount();
|
|
1444
|
+
editorGrid.value.addEventListener("pointerdown", handleEditorGridAction, true);
|
|
1445
|
+
editorGrid.value.addEventListener("click", handleEditorGridAction, true);
|
|
1446
|
+
disposers.push(() => editorGrid.value?.removeEventListener("pointerdown", handleEditorGridAction, true));
|
|
1447
|
+
disposers.push(() => editorGrid.value?.removeEventListener("click", handleEditorGridAction, true));
|
|
1448
|
+
nextTick(syncMaterialSources);
|
|
1449
|
+
syncSelection();
|
|
1450
|
+
if (typeof window !== "undefined") {
|
|
1451
|
+
activeRoute.value = parseRoute(window.location.hash);
|
|
1452
|
+
const onHashChange = () => {
|
|
1453
|
+
const next = parseRoute(window.location.hash);
|
|
1454
|
+
if (next !== activeRoute.value) navigate(next);
|
|
1455
|
+
else if (next === "runtime" && editor?.getMode() !== "preview") editor.setMode("preview");
|
|
1456
|
+
else if (next !== "runtime" && editor?.getMode() === "preview") editor.setMode("edit");
|
|
1457
|
+
};
|
|
1458
|
+
window.addEventListener("hashchange", onHashChange);
|
|
1459
|
+
disposers.push(() => window.removeEventListener("hashchange", onHashChange));
|
|
1460
|
+
window.addEventListener("keydown", handleCanvasKeydown);
|
|
1461
|
+
window.addEventListener("keyup", handleCanvasKeyup);
|
|
1462
|
+
window.addEventListener("keydown", handleWorkspaceKeydown);
|
|
1463
|
+
document.addEventListener("pointerdown", handleFilterOutsidePointerdown);
|
|
1464
|
+
document.addEventListener("keydown", handleFilterMenuKeydown);
|
|
1465
|
+
disposers.push(() => window.removeEventListener("keydown", handleCanvasKeydown));
|
|
1466
|
+
disposers.push(() => window.removeEventListener("keyup", handleCanvasKeyup));
|
|
1467
|
+
disposers.push(() => window.removeEventListener("keydown", handleWorkspaceKeydown));
|
|
1468
|
+
disposers.push(() => document.removeEventListener("pointerdown", handleFilterOutsidePointerdown));
|
|
1469
|
+
disposers.push(() => document.removeEventListener("keydown", handleFilterMenuKeydown));
|
|
1470
|
+
}
|
|
1471
|
+
if (activeRoute.value === "runtime") editor.setMode("preview");
|
|
1472
|
+
syncVanillaRuntime();
|
|
1473
|
+
});
|
|
1474
|
+
onBeforeUnmount(() => {
|
|
1475
|
+
if (interactionPreviewFrame !== void 0 && typeof window !== "undefined") window.cancelAnimationFrame(interactionPreviewFrame);
|
|
1476
|
+
interactionPreviewFrame = void 0;
|
|
1477
|
+
materialSourceDisposers.forEach((dispose) => dispose());
|
|
1478
|
+
materialSourceDisposers.clear();
|
|
1479
|
+
disposers.splice(0).forEach((dispose) => dispose());
|
|
1480
|
+
vanillaRuntimeInstance?.destroy();
|
|
1481
|
+
vanillaRuntimeInstance = void 0;
|
|
1482
|
+
previewDialogRuntimeInstance?.destroy();
|
|
1483
|
+
previewDialogRuntimeInstance = void 0;
|
|
1484
|
+
editor?.destroy();
|
|
1485
|
+
if (previousGridStackRenderCallback) {
|
|
1486
|
+
GridStack.renderCB = previousGridStackRenderCallback;
|
|
1487
|
+
previousGridStackRenderCallback = void 0;
|
|
1488
|
+
}
|
|
1489
|
+
});
|
|
1490
|
+
return (_ctx, _cache) => {
|
|
1491
|
+
return openBlock(), createElementBlock("main", {
|
|
1492
|
+
class: "layout-demo",
|
|
1493
|
+
"data-layout-workspace": "",
|
|
1494
|
+
"data-theme": theme.value,
|
|
1495
|
+
"data-development-framework": activeDevelopmentFramework.value
|
|
1496
|
+
}, [
|
|
1497
|
+
createElementVNode("header", _hoisted_2, [
|
|
1498
|
+
createElementVNode("div", _hoisted_3, [
|
|
1499
|
+
createElementVNode("span", _hoisted_4, [createVNode(unref(Grid2X2), {
|
|
1500
|
+
size: 18,
|
|
1501
|
+
"stroke-width": 1.8
|
|
1502
|
+
})]),
|
|
1503
|
+
_cache[20] || (_cache[20] = createElementVNode("div", { class: "brand-copy" }, [createElementVNode("strong", null, "布局工作台"), createElementVNode("span", null, "所见即所得 · 网格布局")], -1)),
|
|
1504
|
+
createElementVNode("div", {
|
|
1505
|
+
class: normalizeClass(["development-mode custom-select", { "is-open": developmentModeMenuOpen.value }]),
|
|
1506
|
+
"data-layout-filter-menu": "",
|
|
1507
|
+
onPointerdown: _cache[0] || (_cache[0] = withModifiers(() => {}, ["stop"]))
|
|
1508
|
+
}, [createElementVNode("button", {
|
|
1509
|
+
class: "custom-select__trigger",
|
|
1510
|
+
type: "button",
|
|
1511
|
+
"aria-haspopup": "listbox",
|
|
1512
|
+
"aria-expanded": developmentModeMenuOpen.value,
|
|
1513
|
+
"aria-label": "开发框架",
|
|
1514
|
+
title: `\u5F53\u524D\u5F00\u53D1\u6846\u67B6\uFF1A${activeDevelopmentFrameworkLabel.value}`,
|
|
1515
|
+
onClick: withModifiers(toggleDevelopmentModeMenu, ["stop"])
|
|
1516
|
+
}, [
|
|
1517
|
+
(openBlock(), createBlock(resolveDynamicComponent(developmentFrameworks.find((framework) => framework.id === activeDevelopmentFramework.value)?.icon ?? unref(PanelsTopLeft)), {
|
|
1518
|
+
size: 14,
|
|
1519
|
+
"stroke-width": 1.9,
|
|
1520
|
+
"aria-hidden": "true"
|
|
1521
|
+
})),
|
|
1522
|
+
createElementVNode("span", null, toDisplayString(activeDevelopmentFrameworkLabel.value), 1),
|
|
1523
|
+
createVNode(unref(ChevronDown), {
|
|
1524
|
+
size: 12,
|
|
1525
|
+
"stroke-width": 1.9,
|
|
1526
|
+
"aria-hidden": "true"
|
|
1527
|
+
})
|
|
1528
|
+
], 8, _hoisted_5), developmentModeMenuOpen.value ? (openBlock(), createElementBlock("div", _hoisted_6, [(openBlock(), createElementBlock(Fragment, null, renderList(developmentFrameworks, (framework) => {
|
|
1529
|
+
return createElementVNode("button", {
|
|
1530
|
+
key: framework.id,
|
|
1531
|
+
class: "custom-select__option",
|
|
1532
|
+
type: "button",
|
|
1533
|
+
"aria-selected": activeDevelopmentFramework.value === framework.id,
|
|
1534
|
+
onClick: ($event) => selectDevelopmentFramework(framework.id)
|
|
1535
|
+
}, [(openBlock(), createBlock(resolveDynamicComponent(framework.icon), {
|
|
1536
|
+
size: 14,
|
|
1537
|
+
"stroke-width": 1.8,
|
|
1538
|
+
"aria-hidden": "true"
|
|
1539
|
+
})), createElementVNode("span", null, [createElementVNode("strong", null, toDisplayString(framework.label), 1), createElementVNode("small", null, toDisplayString(framework.description), 1)])], 8, _hoisted_7);
|
|
1540
|
+
}), 64))])) : createCommentVNode("v-if", true)], 34)
|
|
1541
|
+
]),
|
|
1542
|
+
createElementVNode("div", _hoisted_8, [createElementVNode("nav", _hoisted_9, [(openBlock(), createElementBlock(Fragment, null, renderList(routes, (demoRoute) => {
|
|
1543
|
+
return createElementVNode("button", {
|
|
1544
|
+
key: demoRoute.id,
|
|
1545
|
+
type: "button",
|
|
1546
|
+
"aria-current": activeRoute.value === demoRoute.id ? "page" : void 0,
|
|
1547
|
+
"aria-label": `${demoRoute.label}\u6A21\u5F0F`,
|
|
1548
|
+
title: demoRoute.description,
|
|
1549
|
+
onClick: ($event) => navigate(demoRoute.id)
|
|
1550
|
+
}, [(openBlock(), createBlock(resolveDynamicComponent(routeIcons[demoRoute.id]), {
|
|
1551
|
+
class: "route-icon",
|
|
1552
|
+
size: 15,
|
|
1553
|
+
"stroke-width": 1.8,
|
|
1554
|
+
"aria-hidden": "true"
|
|
1555
|
+
})), createElementVNode("span", null, toDisplayString(demoRoute.label), 1)], 8, _hoisted_10);
|
|
1556
|
+
}), 64))]), createElementVNode("div", _hoisted_11, [(openBlock(true), createElementBlock(Fragment, null, renderList(layout.value.breakpoints, (breakpoint) => {
|
|
1557
|
+
return openBlock(), createElementBlock("button", {
|
|
1558
|
+
key: breakpoint.id,
|
|
1559
|
+
class: "breakpoint-tab",
|
|
1560
|
+
type: "button",
|
|
1561
|
+
"aria-pressed": activeBreakpoint.value === breakpoint.id,
|
|
1562
|
+
"aria-label": `\u5207\u6362\u5230${breakpointLabel(breakpoint.id)}\u753B\u5E03`,
|
|
1563
|
+
title: `${breakpointLabel(breakpoint.id)}\u753B\u5E03`,
|
|
1564
|
+
onClick: ($event) => changeBreakpoint(breakpoint.id)
|
|
1565
|
+
}, [(openBlock(), createBlock(resolveDynamicComponent(breakpointIcons[breakpoint.id] ?? unref(Monitor)), {
|
|
1566
|
+
size: 14,
|
|
1567
|
+
"stroke-width": 1.8,
|
|
1568
|
+
"aria-hidden": "true"
|
|
1569
|
+
})), createElementVNode("span", null, toDisplayString(breakpointLabel(breakpoint.id)), 1)], 8, _hoisted_12);
|
|
1570
|
+
}), 128)), createCommentVNode("v-if", true)])]),
|
|
1571
|
+
createElementVNode("div", _hoisted_13, [
|
|
1572
|
+
createElementVNode("button", {
|
|
1573
|
+
class: "icon-button",
|
|
1574
|
+
type: "button",
|
|
1575
|
+
"aria-label": "撤销",
|
|
1576
|
+
title: "撤销",
|
|
1577
|
+
disabled: !unref(editor)?.canUndo(),
|
|
1578
|
+
onClick: undo
|
|
1579
|
+
}, [createVNode(unref(Undo2), {
|
|
1580
|
+
size: 16,
|
|
1581
|
+
"stroke-width": 1.9,
|
|
1582
|
+
"aria-hidden": "true"
|
|
1583
|
+
})], 8, _hoisted_14),
|
|
1584
|
+
createElementVNode("button", {
|
|
1585
|
+
class: "icon-button",
|
|
1586
|
+
type: "button",
|
|
1587
|
+
"aria-label": "重做",
|
|
1588
|
+
title: "重做",
|
|
1589
|
+
disabled: !unref(editor)?.canRedo(),
|
|
1590
|
+
onClick: redo
|
|
1591
|
+
}, [createVNode(unref(Redo2), {
|
|
1592
|
+
size: 16,
|
|
1593
|
+
"stroke-width": 1.9,
|
|
1594
|
+
"aria-hidden": "true"
|
|
1595
|
+
})], 8, _hoisted_15),
|
|
1596
|
+
createElementVNode("button", {
|
|
1597
|
+
class: "icon-button",
|
|
1598
|
+
type: "button",
|
|
1599
|
+
"aria-label": "删除选中组件",
|
|
1600
|
+
title: "删除选中组件",
|
|
1601
|
+
disabled: !selected.value,
|
|
1602
|
+
onClick: removeSelected
|
|
1603
|
+
}, [createVNode(unref(Trash2), {
|
|
1604
|
+
size: 16,
|
|
1605
|
+
"stroke-width": 1.9,
|
|
1606
|
+
"aria-hidden": "true"
|
|
1607
|
+
})], 8, _hoisted_16),
|
|
1608
|
+
createElementVNode("button", {
|
|
1609
|
+
class: "icon-button",
|
|
1610
|
+
type: "button",
|
|
1611
|
+
"aria-label": selectedLocked.value ? "解锁选中组件" : "锁定选中组件",
|
|
1612
|
+
title: selectedLocked.value ? "解锁选中组件" : "锁定选中组件",
|
|
1613
|
+
disabled: !selected.value,
|
|
1614
|
+
onClick: toggleSelectedLock
|
|
1615
|
+
}, [(openBlock(), createBlock(resolveDynamicComponent(selectedLocked.value ? unref(Unlock) : unref(Lock)), {
|
|
1616
|
+
size: 16,
|
|
1617
|
+
"stroke-width": 1.9,
|
|
1618
|
+
"aria-hidden": "true"
|
|
1619
|
+
}))], 8, _hoisted_17),
|
|
1620
|
+
createElementVNode("button", {
|
|
1621
|
+
class: "icon-button",
|
|
1622
|
+
type: "button",
|
|
1623
|
+
"aria-label": selectedMovable.value ? "禁止移动" : "允许移动",
|
|
1624
|
+
title: selectedMovable.value ? "禁止移动" : "允许移动",
|
|
1625
|
+
disabled: !selected.value || selectedLocked.value,
|
|
1626
|
+
onClick: _cache[1] || (_cache[1] = ($event) => toggleSelectedConstraint("movable"))
|
|
1627
|
+
}, [createVNode(unref(Move), {
|
|
1628
|
+
size: 16,
|
|
1629
|
+
"stroke-width": 1.9,
|
|
1630
|
+
"aria-hidden": "true"
|
|
1631
|
+
})], 8, _hoisted_18),
|
|
1632
|
+
createElementVNode("button", {
|
|
1633
|
+
class: "icon-button",
|
|
1634
|
+
type: "button",
|
|
1635
|
+
"aria-label": selectedResizable.value ? "禁止调整大小" : "允许调整大小",
|
|
1636
|
+
title: selectedResizable.value ? "禁止调整大小" : "允许调整大小",
|
|
1637
|
+
disabled: !selected.value || selectedLocked.value,
|
|
1638
|
+
onClick: _cache[2] || (_cache[2] = ($event) => toggleSelectedConstraint("resizable"))
|
|
1639
|
+
}, [createVNode(unref(Maximize2), {
|
|
1640
|
+
size: 16,
|
|
1641
|
+
"stroke-width": 1.9,
|
|
1642
|
+
"aria-hidden": "true"
|
|
1643
|
+
})], 8, _hoisted_19),
|
|
1644
|
+
createElementVNode("button", {
|
|
1645
|
+
class: "icon-button theme-button",
|
|
1646
|
+
type: "button",
|
|
1647
|
+
"aria-label": theme.value === "dark" ? "切换到亮色主题" : "切换到暗色主题",
|
|
1648
|
+
title: theme.value === "dark" ? "切换到亮色主题" : "切换到暗色主题",
|
|
1649
|
+
onClick: toggleTheme
|
|
1650
|
+
}, [(openBlock(), createBlock(resolveDynamicComponent(theme.value === "dark" ? unref(Sun) : unref(Moon)), {
|
|
1651
|
+
size: 16,
|
|
1652
|
+
"stroke-width": 1.9,
|
|
1653
|
+
"aria-hidden": "true"
|
|
1654
|
+
}))], 8, _hoisted_20),
|
|
1655
|
+
createElementVNode("button", {
|
|
1656
|
+
class: "preview-open-button",
|
|
1657
|
+
type: "button",
|
|
1658
|
+
"aria-label": "打开实时预览",
|
|
1659
|
+
title: "打开实时预览",
|
|
1660
|
+
onClick: openPreviewDialog
|
|
1661
|
+
}, [createVNode(unref(Eye), {
|
|
1662
|
+
size: 15,
|
|
1663
|
+
"stroke-width": 1.9,
|
|
1664
|
+
"aria-hidden": "true"
|
|
1665
|
+
}), _cache[21] || (_cache[21] = createElementVNode("span", null, "实时预览", -1))]),
|
|
1666
|
+
createElementVNode("button", {
|
|
1667
|
+
class: "mode-button",
|
|
1668
|
+
type: "button",
|
|
1669
|
+
"aria-pressed": previewMode.value,
|
|
1670
|
+
"aria-label": previewMode.value ? "返回编辑模式" : "进入预览模式",
|
|
1671
|
+
title: previewMode.value ? "返回编辑模式" : "进入预览模式",
|
|
1672
|
+
onClick: togglePreview
|
|
1673
|
+
}, [(openBlock(), createBlock(resolveDynamicComponent(previewMode.value ? unref(Pencil) : unref(Eye)), {
|
|
1674
|
+
size: 16,
|
|
1675
|
+
"stroke-width": 1.9,
|
|
1676
|
+
"aria-hidden": "true"
|
|
1677
|
+
})), createElementVNode("span", null, toDisplayString(previewMode.value ? "编辑" : "预览"), 1)], 8, _hoisted_21)
|
|
1678
|
+
])
|
|
1679
|
+
]),
|
|
1680
|
+
createElementVNode("section", _hoisted_22, [
|
|
1681
|
+
createElementVNode("aside", _hoisted_23, [
|
|
1682
|
+
createElementVNode("div", _hoisted_24, [_cache[22] || (_cache[22] = createElementVNode("div", null, [createElementVNode("span", { class: "eyebrow" }, "工作区"), createElementVNode("h2", null, "物料")], -1)), createElementVNode("span", _hoisted_25, toDisplayString(unref(materials).getAll().length), 1)]),
|
|
1683
|
+
createElementVNode("div", _hoisted_26, [
|
|
1684
|
+
createElementVNode("label", _hoisted_27, [createVNode(unref(Search), {
|
|
1685
|
+
size: 15,
|
|
1686
|
+
"stroke-width": 1.8,
|
|
1687
|
+
"aria-hidden": "true"
|
|
1688
|
+
}), withDirectives(createElementVNode("input", {
|
|
1689
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => materialQuery.value = $event),
|
|
1690
|
+
type: "search",
|
|
1691
|
+
placeholder: "搜索物料",
|
|
1692
|
+
"aria-label": "搜索物料"
|
|
1693
|
+
}, null, 512), [[vModelText, materialQuery.value]])]),
|
|
1694
|
+
createElementVNode("div", {
|
|
1695
|
+
class: "material-filter-row",
|
|
1696
|
+
"data-layout-filter-menu": "",
|
|
1697
|
+
onKeydown: withKeys(withModifiers(handleFilterMenuKeydown, ["stop", "prevent"]), ["esc"])
|
|
1698
|
+
}, [createElementVNode("div", {
|
|
1699
|
+
class: normalizeClass(["material-select custom-select", { "is-open": categoryMenuOpen.value }]),
|
|
1700
|
+
onPointerdown: _cache[6] || (_cache[6] = withModifiers(() => {}, ["stop"]))
|
|
1701
|
+
}, [createElementVNode("button", {
|
|
1702
|
+
class: "custom-select__trigger",
|
|
1703
|
+
type: "button",
|
|
1704
|
+
"aria-haspopup": "listbox",
|
|
1705
|
+
"aria-expanded": categoryMenuOpen.value,
|
|
1706
|
+
"aria-label": "物料分类",
|
|
1707
|
+
title: `\u7269\u6599\u5206\u7C7B\uFF1A${activeMaterialCategoryLabel.value}`,
|
|
1708
|
+
onClick: _cache[4] || (_cache[4] = withModifiers(($event) => toggleFilterMenu("category"), ["stop"]))
|
|
1709
|
+
}, [
|
|
1710
|
+
createVNode(unref(Filter), {
|
|
1711
|
+
size: 13,
|
|
1712
|
+
"stroke-width": 1.9,
|
|
1713
|
+
"aria-hidden": "true"
|
|
1714
|
+
}),
|
|
1715
|
+
createElementVNode("span", null, toDisplayString(activeMaterialCategoryLabel.value), 1),
|
|
1716
|
+
createVNode(unref(ChevronDown), {
|
|
1717
|
+
size: 12,
|
|
1718
|
+
"stroke-width": 1.9,
|
|
1719
|
+
"aria-hidden": "true"
|
|
1720
|
+
})
|
|
1721
|
+
], 8, _hoisted_29), categoryMenuOpen.value ? (openBlock(), createElementBlock("div", _hoisted_30, [createElementVNode("button", {
|
|
1722
|
+
class: "custom-select__option",
|
|
1723
|
+
type: "button",
|
|
1724
|
+
"aria-selected": !materialCategoryFilter.value,
|
|
1725
|
+
onClick: _cache[5] || (_cache[5] = ($event) => selectMaterialCategory(""))
|
|
1726
|
+
}, " 全部分类 ", 8, _hoisted_31), (openBlock(true), createElementBlock(Fragment, null, renderList(materialCategories.value, (category) => {
|
|
1727
|
+
return openBlock(), createElementBlock("button", {
|
|
1728
|
+
key: category.id,
|
|
1729
|
+
class: "custom-select__option",
|
|
1730
|
+
type: "button",
|
|
1731
|
+
"aria-selected": materialCategoryFilter.value === category.id,
|
|
1732
|
+
onClick: ($event) => selectMaterialCategory(category.id)
|
|
1733
|
+
}, toDisplayString(category.label), 9, _hoisted_32);
|
|
1734
|
+
}), 128))])) : createCommentVNode("v-if", true)], 34), hasMaterialFilters.value ? (openBlock(), createElementBlock("button", {
|
|
1735
|
+
key: 0,
|
|
1736
|
+
class: "material-filter-reset",
|
|
1737
|
+
type: "button",
|
|
1738
|
+
"aria-label": "清除物料筛选",
|
|
1739
|
+
title: "清除筛选",
|
|
1740
|
+
onClick: resetMaterialFilters
|
|
1741
|
+
}, [createVNode(unref(X), {
|
|
1742
|
+
size: 13,
|
|
1743
|
+
"stroke-width": 1.9,
|
|
1744
|
+
"aria-hidden": "true"
|
|
1745
|
+
})])) : createCommentVNode("v-if", true)], 40, _hoisted_28),
|
|
1746
|
+
createElementVNode("div", _hoisted_33, [createElementVNode("span", null, toDisplayString(visibleMaterials.value.length) + " / " + toDisplayString(unref(materials).getAll().length) + " 个物料", 1), hasMaterialFilters.value ? (openBlock(), createElementBlock("span", _hoisted_34, "已筛选")) : createCommentVNode("v-if", true)])
|
|
1747
|
+
]),
|
|
1748
|
+
!visibleMaterials.value.length ? (openBlock(), createElementBlock("div", _hoisted_35, [
|
|
1749
|
+
createVNode(unref(Search), {
|
|
1750
|
+
size: 17,
|
|
1751
|
+
"stroke-width": 1.7,
|
|
1752
|
+
"aria-hidden": "true"
|
|
1753
|
+
}),
|
|
1754
|
+
_cache[23] || (_cache[23] = createElementVNode("strong", null, "没有匹配的物料", -1)),
|
|
1755
|
+
_cache[24] || (_cache[24] = createElementVNode("span", null, "试试更换关键词或分类", -1)),
|
|
1756
|
+
hasMaterialFilters.value ? (openBlock(), createElementBlock("button", {
|
|
1757
|
+
key: 0,
|
|
1758
|
+
type: "button",
|
|
1759
|
+
onClick: resetMaterialFilters
|
|
1760
|
+
}, " 清除筛选 ")) : createCommentVNode("v-if", true)
|
|
1761
|
+
])) : createCommentVNode("v-if", true),
|
|
1762
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(visibleMaterials.value, (material) => {
|
|
1763
|
+
return openBlock(), createElementBlock("div", {
|
|
1764
|
+
key: material.type,
|
|
1765
|
+
ref_for: true,
|
|
1766
|
+
ref: (element) => setMaterialElement(material.type, element),
|
|
1767
|
+
class: "material-source grid-stack-item",
|
|
1768
|
+
role: "button",
|
|
1769
|
+
tabindex: "0",
|
|
1770
|
+
"data-material-type": material.type,
|
|
1771
|
+
"data-layout-material": material.type,
|
|
1772
|
+
"data-layout-props": materialProps(material.type),
|
|
1773
|
+
"aria-label": `\u6DFB\u52A0${material.title ?? material.label ?? material.type}`,
|
|
1774
|
+
onClick: ($event) => handleMaterialClick(material.type),
|
|
1775
|
+
onKeydown: [withKeys(($event) => add(material.type), ["enter"]), withKeys(withModifiers(($event) => add(material.type), ["prevent"]), ["space"])]
|
|
1776
|
+
}, [
|
|
1777
|
+
createElementVNode("span", _hoisted_37, [(openBlock(), createBlock(resolveDynamicComponent(materialIcon(material.type)), {
|
|
1778
|
+
size: 18,
|
|
1779
|
+
"stroke-width": 1.8
|
|
1780
|
+
}))]),
|
|
1781
|
+
createElementVNode("span", _hoisted_38, [createElementVNode("strong", null, toDisplayString(material.title ?? material.label ?? material.type), 1), createElementVNode("small", null, toDisplayString(material.description ?? material.categoryLabel ?? "布局组件"), 1)]),
|
|
1782
|
+
createElementVNode("span", _hoisted_39, [createElementVNode("span", _hoisted_40, toDisplayString(material.defaultLayout?.w ?? material.size?.default.w ?? 1) + " × " + toDisplayString(material.defaultLayout?.h ?? material.size?.default.h ?? 1), 1), createElementVNode("span", _hoisted_41, [createElementVNode("span", {
|
|
1783
|
+
class: normalizeClass(["material-renderer-badge", { "material-renderer-badge--vue": activeDevelopmentFramework.value === "vue" }]),
|
|
1784
|
+
title: `\u5F53\u524D\u5F00\u53D1\u76EE\u6807\uFF1A${activeDevelopmentFrameworkLabel.value}`
|
|
1785
|
+
}, [(openBlock(), createBlock(resolveDynamicComponent(activeDevelopmentFramework.value === "vue" ? unref(PanelsTopLeft) : unref(Code2)), {
|
|
1786
|
+
size: 11,
|
|
1787
|
+
"stroke-width": 1.8,
|
|
1788
|
+
"aria-hidden": "true"
|
|
1789
|
+
})), createElementVNode("span", null, toDisplayString(activeDevelopmentFrameworkLabel.value), 1)], 10, _hoisted_42)])]),
|
|
1790
|
+
createElementVNode("span", _hoisted_43, [createElementVNode("button", {
|
|
1791
|
+
class: "material-code-button",
|
|
1792
|
+
type: "button",
|
|
1793
|
+
"aria-label": "查看当前物料代码",
|
|
1794
|
+
title: "查看当前物料代码",
|
|
1795
|
+
onPointerdown: _cache[7] || (_cache[7] = withModifiers(() => {}, ["stop"])),
|
|
1796
|
+
onClick: withModifiers(($event) => openMaterialCode(material.type), ["stop"])
|
|
1797
|
+
}, [createVNode(unref(Code2), {
|
|
1798
|
+
size: 14,
|
|
1799
|
+
"stroke-width": 1.8,
|
|
1800
|
+
"aria-hidden": "true"
|
|
1801
|
+
})], 40, _hoisted_44), createElementVNode("span", _hoisted_45, [createVNode(unref(Plus), {
|
|
1802
|
+
size: 16,
|
|
1803
|
+
"stroke-width": 1.8
|
|
1804
|
+
})])])
|
|
1805
|
+
], 40, _hoisted_36);
|
|
1806
|
+
}), 128)),
|
|
1807
|
+
createCommentVNode("v-if", true),
|
|
1808
|
+
createCommentVNode("v-if", true)
|
|
1809
|
+
]),
|
|
1810
|
+
createElementVNode("section", _hoisted_50, [createElementVNode("div", _hoisted_51, [
|
|
1811
|
+
createElementVNode("div", {
|
|
1812
|
+
class: normalizeClass(["canvas-device-control custom-select", { "is-open": deviceMenuOpen.value }]),
|
|
1813
|
+
onPointerdown: _cache[15] || (_cache[15] = withModifiers(() => {}, ["stop"]))
|
|
1814
|
+
}, [createElementVNode("button", {
|
|
1815
|
+
class: "custom-select__trigger",
|
|
1816
|
+
type: "button",
|
|
1817
|
+
"aria-haspopup": "listbox",
|
|
1818
|
+
"aria-expanded": deviceMenuOpen.value,
|
|
1819
|
+
"aria-label": "设备画布",
|
|
1820
|
+
onClick: _cache[14] || (_cache[14] = withModifiers(($event) => toggleFilterMenu("device"), ["stop"]))
|
|
1821
|
+
}, [
|
|
1822
|
+
(openBlock(), createBlock(resolveDynamicComponent(activeBreakpointIcon.value), {
|
|
1823
|
+
size: 13,
|
|
1824
|
+
"stroke-width": 1.9,
|
|
1825
|
+
"aria-hidden": "true"
|
|
1826
|
+
})),
|
|
1827
|
+
createElementVNode("span", null, toDisplayString(breakpointLabel(activeBreakpoint.value)), 1),
|
|
1828
|
+
createVNode(unref(ChevronDown), {
|
|
1829
|
+
size: 12,
|
|
1830
|
+
"stroke-width": 1.9,
|
|
1831
|
+
"aria-hidden": "true"
|
|
1832
|
+
})
|
|
1833
|
+
], 8, _hoisted_52), deviceMenuOpen.value ? (openBlock(), createElementBlock("div", _hoisted_53, [(openBlock(true), createElementBlock(Fragment, null, renderList(layout.value.breakpoints, (breakpoint) => {
|
|
1834
|
+
return openBlock(), createElementBlock("button", {
|
|
1835
|
+
key: breakpoint.id,
|
|
1836
|
+
class: "custom-select__option",
|
|
1837
|
+
type: "button",
|
|
1838
|
+
"aria-selected": activeBreakpoint.value === breakpoint.id,
|
|
1839
|
+
"aria-label": `${breakpointLabel(breakpoint.id)} / ${breakpoint.columns} \u5217`,
|
|
1840
|
+
onClick: ($event) => selectBreakpoint(breakpoint.id)
|
|
1841
|
+
}, [
|
|
1842
|
+
(openBlock(), createBlock(resolveDynamicComponent(breakpointIcons[breakpoint.id] ?? unref(Monitor)), {
|
|
1843
|
+
size: 13,
|
|
1844
|
+
"stroke-width": 1.8,
|
|
1845
|
+
"aria-hidden": "true"
|
|
1846
|
+
})),
|
|
1847
|
+
createElementVNode("span", null, toDisplayString(breakpointLabel(breakpoint.id)), 1),
|
|
1848
|
+
createElementVNode("span", _hoisted_55, toDisplayString(breakpoint.columns) + " 列", 1)
|
|
1849
|
+
], 8, _hoisted_54);
|
|
1850
|
+
}), 128))])) : createCommentVNode("v-if", true)], 34),
|
|
1851
|
+
createElementVNode("button", {
|
|
1852
|
+
class: "orientation-button",
|
|
1853
|
+
type: "button",
|
|
1854
|
+
"aria-label": canvasOrientation.value === "portrait" ? "切换为横屏" : "切换为竖屏",
|
|
1855
|
+
title: canvasOrientation.value === "portrait" ? "切换为横屏" : "切换为竖屏",
|
|
1856
|
+
onClick: toggleCanvasOrientation
|
|
1857
|
+
}, [(openBlock(), createBlock(resolveDynamicComponent(canvasOrientation.value === "portrait" ? unref(ArrowLeftRight) : unref(ArrowUpDown)), {
|
|
1858
|
+
size: 14,
|
|
1859
|
+
"stroke-width": 1.9,
|
|
1860
|
+
"aria-hidden": "true"
|
|
1861
|
+
}))], 8, _hoisted_56),
|
|
1862
|
+
_cache[27] || (_cache[27] = createElementVNode("span", {
|
|
1863
|
+
class: "canvas-toolbar__device-divider",
|
|
1864
|
+
"aria-hidden": "true"
|
|
1865
|
+
}, null, -1)),
|
|
1866
|
+
createElementVNode("div", _hoisted_57, [createElementVNode("button", {
|
|
1867
|
+
class: normalizeClass(["canvas-tool-button", { active: canvasTool.value === "select" }]),
|
|
1868
|
+
type: "button",
|
|
1869
|
+
"aria-label": "选择组件",
|
|
1870
|
+
title: "选择组件",
|
|
1871
|
+
onClick: _cache[16] || (_cache[16] = ($event) => canvasTool.value = "select")
|
|
1872
|
+
}, [createVNode(unref(MousePointer2), {
|
|
1873
|
+
size: 15,
|
|
1874
|
+
"stroke-width": 1.9,
|
|
1875
|
+
"aria-hidden": "true"
|
|
1876
|
+
})], 2), createElementVNode("button", {
|
|
1877
|
+
class: normalizeClass(["canvas-tool-button", { active: canvasTool.value === "pan" }]),
|
|
1878
|
+
type: "button",
|
|
1879
|
+
"aria-label": "移动画布",
|
|
1880
|
+
title: "移动画布(也可按住空格拖动)",
|
|
1881
|
+
onClick: _cache[17] || (_cache[17] = ($event) => canvasTool.value = canvasTool.value === "pan" ? "select" : "pan")
|
|
1882
|
+
}, [createVNode(unref(Hand), {
|
|
1883
|
+
size: 15,
|
|
1884
|
+
"stroke-width": 1.9,
|
|
1885
|
+
"aria-hidden": "true"
|
|
1886
|
+
})], 2)]),
|
|
1887
|
+
_cache[28] || (_cache[28] = createElementVNode("div", {
|
|
1888
|
+
class: "canvas-toolbar__divider",
|
|
1889
|
+
"aria-hidden": "true"
|
|
1890
|
+
}, null, -1)),
|
|
1891
|
+
createElementVNode("button", {
|
|
1892
|
+
class: "canvas-tool-button",
|
|
1893
|
+
type: "button",
|
|
1894
|
+
"aria-label": "缩小画布",
|
|
1895
|
+
title: "缩小画布",
|
|
1896
|
+
onClick: _cache[18] || (_cache[18] = ($event) => zoomCanvas(-1))
|
|
1897
|
+
}, [createVNode(unref(ZoomOut), {
|
|
1898
|
+
size: 15,
|
|
1899
|
+
"stroke-width": 1.9,
|
|
1900
|
+
"aria-hidden": "true"
|
|
1901
|
+
})]),
|
|
1902
|
+
createElementVNode("span", _hoisted_58, toDisplayString(canvasZoomLabel.value), 1),
|
|
1903
|
+
createElementVNode("button", {
|
|
1904
|
+
class: "canvas-tool-button",
|
|
1905
|
+
type: "button",
|
|
1906
|
+
"aria-label": "放大画布",
|
|
1907
|
+
title: "放大画布",
|
|
1908
|
+
onClick: _cache[19] || (_cache[19] = ($event) => zoomCanvas(1))
|
|
1909
|
+
}, [createVNode(unref(ZoomIn), {
|
|
1910
|
+
size: 15,
|
|
1911
|
+
"stroke-width": 1.9,
|
|
1912
|
+
"aria-hidden": "true"
|
|
1913
|
+
})]),
|
|
1914
|
+
createElementVNode("button", {
|
|
1915
|
+
class: "canvas-tool-button",
|
|
1916
|
+
type: "button",
|
|
1917
|
+
"aria-label": "适配画布",
|
|
1918
|
+
title: "适配画布",
|
|
1919
|
+
onClick: resetCanvasView
|
|
1920
|
+
}, [createVNode(unref(Scan), {
|
|
1921
|
+
size: 15,
|
|
1922
|
+
"stroke-width": 1.9,
|
|
1923
|
+
"aria-hidden": "true"
|
|
1924
|
+
})]),
|
|
1925
|
+
createElementVNode("button", {
|
|
1926
|
+
class: "canvas-tool-button",
|
|
1927
|
+
type: "button",
|
|
1928
|
+
"aria-label": "重置画布位置",
|
|
1929
|
+
title: "重置画布位置",
|
|
1930
|
+
onClick: resetCanvasPan
|
|
1931
|
+
}, [createVNode(unref(RotateCcw), {
|
|
1932
|
+
size: 15,
|
|
1933
|
+
"stroke-width": 1.9,
|
|
1934
|
+
"aria-hidden": "true"
|
|
1935
|
+
})])
|
|
1936
|
+
]), createElementVNode("div", {
|
|
1937
|
+
ref_key: "canvasViewport",
|
|
1938
|
+
ref: canvasViewport,
|
|
1939
|
+
class: normalizeClass(["canvas-viewport", {
|
|
1940
|
+
"is-panning": canvasPanning.value,
|
|
1941
|
+
"is-pan-tool": canvasTool.value === "pan"
|
|
1942
|
+
}]),
|
|
1943
|
+
onWheel: handleCanvasWheel,
|
|
1944
|
+
onPointerdownCapture: handleCanvasPointerDown,
|
|
1945
|
+
onPointermove: handleCanvasPointerMove,
|
|
1946
|
+
onPointerup: finishCanvasPan,
|
|
1947
|
+
onPointercancel: finishCanvasPan
|
|
1948
|
+
}, [createElementVNode("div", {
|
|
1949
|
+
class: normalizeClass(["canvas-scene", `is-${canvasOrientation.value}`]),
|
|
1950
|
+
"data-canvas-width": canvasSize.value.width,
|
|
1951
|
+
"data-canvas-height": canvasSize.value.height,
|
|
1952
|
+
"data-canvas-orientation": canvasOrientation.value,
|
|
1953
|
+
style: normalizeStyle(canvasSceneStyle.value)
|
|
1954
|
+
}, [
|
|
1955
|
+
withDirectives(createElementVNode("section", _hoisted_60, [createElementVNode("header", _hoisted_61, [_cache[30] || (_cache[30] = createElementVNode("div", null, [createElementVNode("span", { class: "stage-kicker" }, "编辑模式"), createElementVNode("h2", null, "拖拽布局")], -1)), createElementVNode("span", _hoisted_62, [_cache[29] || (_cache[29] = createElementVNode("i", { "aria-hidden": "true" }, null, -1)), createTextVNode(toDisplayString(breakpointLabel(activeBreakpoint.value)), 1)])]), createElementVNode("div", {
|
|
1956
|
+
ref_key: "editorGrid",
|
|
1957
|
+
ref: editorGrid,
|
|
1958
|
+
class: "grid-stack layout-editor-grid",
|
|
1959
|
+
role: "grid",
|
|
1960
|
+
"aria-label": "网格布局编辑器",
|
|
1961
|
+
"aria-multiselectable": "true"
|
|
1962
|
+
}, null, 512)], 512), [[vShow, activeRoute.value === "editor" && !previewMode.value]]),
|
|
1963
|
+
withDirectives(createElementVNode("section", _hoisted_63, [_cache[31] || (_cache[31] = createElementVNode("header", { class: "stage-header" }, [createElementVNode("div", null, [createElementVNode("span", { class: "stage-kicker" }, "预览模式"), createElementVNode("h2", null, "组件渲染")]), createElementVNode("span", { class: "stage-badge" }, [createElementVNode("i", { "aria-hidden": "true" }), createTextVNode("同步布局")])], -1)), createVNode(unref(LGrid), {
|
|
1964
|
+
document: layout.value,
|
|
1965
|
+
breakpoint: activeBreakpoint.value,
|
|
1966
|
+
materials: unref(materials),
|
|
1967
|
+
target: activeDevelopmentFramework.value
|
|
1968
|
+
}, {
|
|
1969
|
+
item: withCtx(({ item }) => [createElementVNode("button", {
|
|
1970
|
+
class: normalizeClass(["widget layout-item-shell layout-item-shell--interactive", { selected: selected.value === item.id }]),
|
|
1971
|
+
type: "button",
|
|
1972
|
+
"aria-label": `${itemTitle(item)}\uFF0C${materialLabel(item.type)}`,
|
|
1973
|
+
onClick: ($event) => select(item.id)
|
|
1974
|
+
}, [createVNode(unref(LMaterialRenderer), mergeProps({
|
|
1975
|
+
item,
|
|
1976
|
+
materials: unref(materials),
|
|
1977
|
+
target: activeDevelopmentFramework.value
|
|
1978
|
+
}, item.props), null, 16, [
|
|
1979
|
+
"item",
|
|
1980
|
+
"materials",
|
|
1981
|
+
"target"
|
|
1982
|
+
])], 10, _hoisted_64)]),
|
|
1983
|
+
_: 1
|
|
1984
|
+
}, 8, [
|
|
1985
|
+
"document",
|
|
1986
|
+
"breakpoint",
|
|
1987
|
+
"materials",
|
|
1988
|
+
"target"
|
|
1989
|
+
])], 512), [[vShow, activeRoute.value === "vue"]]),
|
|
1990
|
+
withDirectives(createElementVNode("section", {
|
|
1991
|
+
class: "runtime-preview-stage",
|
|
1992
|
+
"data-preview-framework": activeDevelopmentFramework.value,
|
|
1993
|
+
"aria-label": "运行时预览画布"
|
|
1994
|
+
}, [
|
|
1995
|
+
createElementVNode("header", _hoisted_66, [_cache[33] || (_cache[33] = createElementVNode("div", null, [createElementVNode("span", { class: "stage-kicker" }, "预览模式"), createElementVNode("h2", null, "运行时预览")], -1)), createElementVNode("span", _hoisted_67, [_cache[32] || (_cache[32] = createElementVNode("i", { "aria-hidden": "true" }, null, -1)), createTextVNode(toDisplayString(activeDevelopmentFrameworkLabel.value) + " · 只读", 1)])]),
|
|
1996
|
+
activeDevelopmentFramework.value === "vue" ? (openBlock(), createBlock(unref(LGrid), {
|
|
1997
|
+
key: 0,
|
|
1998
|
+
document: layout.value,
|
|
1999
|
+
breakpoint: activeBreakpoint.value,
|
|
2000
|
+
materials: unref(materials),
|
|
2001
|
+
target: activeDevelopmentFramework.value
|
|
2002
|
+
}, {
|
|
2003
|
+
item: withCtx(({ item }) => [createVNode(unref(LMaterialRenderer), mergeProps({
|
|
2004
|
+
item,
|
|
2005
|
+
materials: unref(materials),
|
|
2006
|
+
target: activeDevelopmentFramework.value,
|
|
2007
|
+
class: "preview-dialog__card"
|
|
2008
|
+
}, item.props), null, 16, [
|
|
2009
|
+
"item",
|
|
2010
|
+
"materials",
|
|
2011
|
+
"target"
|
|
2012
|
+
])]),
|
|
2013
|
+
_: 1
|
|
2014
|
+
}, 8, [
|
|
2015
|
+
"document",
|
|
2016
|
+
"breakpoint",
|
|
2017
|
+
"materials",
|
|
2018
|
+
"target"
|
|
2019
|
+
])) : createCommentVNode("v-if", true),
|
|
2020
|
+
withDirectives(createElementVNode("div", {
|
|
2021
|
+
ref_key: "runtimePreview",
|
|
2022
|
+
ref: runtimePreview,
|
|
2023
|
+
class: "runtime-preview-grid",
|
|
2024
|
+
"data-preview-renderer": "webcomponent"
|
|
2025
|
+
}, null, 512), [[vShow, activeDevelopmentFramework.value === "webcomponent"]])
|
|
2026
|
+
], 8, _hoisted_65), [[vShow, activeRoute.value === "runtime" && previewMode.value]]),
|
|
2027
|
+
withDirectives(createElementVNode("section", {
|
|
2028
|
+
class: "vanilla-runtime-stage",
|
|
2029
|
+
"data-preview-framework": activeDevelopmentFramework.value,
|
|
2030
|
+
"aria-label": "原生运行时画布"
|
|
2031
|
+
}, [
|
|
2032
|
+
createElementVNode("header", _hoisted_69, [_cache[35] || (_cache[35] = createElementVNode("div", null, [createElementVNode("span", { class: "stage-kicker" }, "预览模式"), createElementVNode("h2", null, "原生运行时")], -1)), createElementVNode("span", _hoisted_70, [_cache[34] || (_cache[34] = createElementVNode("i", { "aria-hidden": "true" }, null, -1)), createTextVNode(toDisplayString(activeDevelopmentFrameworkLabel.value) + " · 只读", 1)])]),
|
|
2033
|
+
activeDevelopmentFramework.value === "vue" ? (openBlock(), createBlock(unref(LGrid), {
|
|
2034
|
+
key: 0,
|
|
2035
|
+
document: layout.value,
|
|
2036
|
+
breakpoint: activeBreakpoint.value,
|
|
2037
|
+
materials: unref(materials),
|
|
2038
|
+
target: activeDevelopmentFramework.value
|
|
2039
|
+
}, {
|
|
2040
|
+
item: withCtx(({ item }) => [createVNode(unref(LMaterialRenderer), mergeProps({
|
|
2041
|
+
item,
|
|
2042
|
+
materials: unref(materials),
|
|
2043
|
+
target: activeDevelopmentFramework.value,
|
|
2044
|
+
class: "preview-dialog__card"
|
|
2045
|
+
}, item.props), null, 16, [
|
|
2046
|
+
"item",
|
|
2047
|
+
"materials",
|
|
2048
|
+
"target"
|
|
2049
|
+
])]),
|
|
2050
|
+
_: 1
|
|
2051
|
+
}, 8, [
|
|
2052
|
+
"document",
|
|
2053
|
+
"breakpoint",
|
|
2054
|
+
"materials",
|
|
2055
|
+
"target"
|
|
2056
|
+
])) : createCommentVNode("v-if", true),
|
|
2057
|
+
withDirectives(createElementVNode("div", {
|
|
2058
|
+
ref_key: "vanillaRuntime",
|
|
2059
|
+
ref: vanillaRuntime,
|
|
2060
|
+
class: "runtime-preview-grid",
|
|
2061
|
+
"data-preview-renderer": "webcomponent"
|
|
2062
|
+
}, null, 512), [[vShow, activeDevelopmentFramework.value === "webcomponent"]])
|
|
2063
|
+
], 8, _hoisted_68), [[vShow, activeRoute.value === "vanilla"]])
|
|
2064
|
+
], 14, _hoisted_59)], 34)]),
|
|
2065
|
+
createElementVNode("aside", _hoisted_71, [
|
|
2066
|
+
createElementVNode("div", _hoisted_72, [
|
|
2067
|
+
createElementVNode("div", null, [_cache[36] || (_cache[36] = createElementVNode("span", { class: "eyebrow" }, "实时输出", -1)), createElementVNode("h2", null, toDisplayString(activeCodeLabel.value), 1)]),
|
|
2068
|
+
createElementVNode("button", {
|
|
2069
|
+
class: "copy-code-button",
|
|
2070
|
+
type: "button",
|
|
2071
|
+
"aria-label": copied.value ? "代码已复制" : "复制当前代码",
|
|
2072
|
+
title: copied.value ? "代码已复制" : "复制当前代码",
|
|
2073
|
+
onClick: copyActiveCode
|
|
2074
|
+
}, [(openBlock(), createBlock(resolveDynamicComponent(copied.value ? unref(CopyCheck) : unref(Copy)), {
|
|
2075
|
+
size: 15,
|
|
2076
|
+
"stroke-width": 1.8,
|
|
2077
|
+
"aria-hidden": "true"
|
|
2078
|
+
}))], 8, _hoisted_73),
|
|
2079
|
+
createElementVNode("button", {
|
|
2080
|
+
class: "download-code-button",
|
|
2081
|
+
type: "button",
|
|
2082
|
+
"aria-label": "下载当前代码",
|
|
2083
|
+
title: "下载当前代码",
|
|
2084
|
+
onClick: downloadActiveCode
|
|
2085
|
+
}, [createVNode(unref(Download), {
|
|
2086
|
+
size: 15,
|
|
2087
|
+
"stroke-width": 1.8,
|
|
2088
|
+
"aria-hidden": "true"
|
|
2089
|
+
})])
|
|
2090
|
+
]),
|
|
2091
|
+
createElementVNode("pre", _hoisted_74, [createElementVNode("code", { innerHTML: highlightedCode.value }, null, 8, _hoisted_75)]),
|
|
2092
|
+
createElementVNode("div", _hoisted_76, [_cache[37] || (_cache[37] = createElementVNode("span", {
|
|
2093
|
+
class: "code-status__dot",
|
|
2094
|
+
"aria-hidden": "true"
|
|
2095
|
+
}, null, -1)), createElementVNode("span", null, "已根据当前布局、" + toDisplayString(breakpointLabel(activeBreakpoint.value)) + "断点实时生成 · 共 " + toDisplayString(activeCodeLineCount.value) + " 行,可滚动查看完整输出", 1)])
|
|
2096
|
+
])
|
|
2097
|
+
]),
|
|
2098
|
+
createVNode(Transition, { name: "preview-dialog" }, {
|
|
2099
|
+
default: withCtx(() => [previewDialogOpen.value ? (openBlock(), createElementBlock("div", {
|
|
2100
|
+
key: 0,
|
|
2101
|
+
class: "preview-dialog",
|
|
2102
|
+
"data-preview-framework": activeDevelopmentFramework.value,
|
|
2103
|
+
"data-theme": theme.value,
|
|
2104
|
+
role: "dialog",
|
|
2105
|
+
"aria-modal": "true",
|
|
2106
|
+
"aria-labelledby": "layout-preview-title"
|
|
2107
|
+
}, [createElementVNode("button", {
|
|
2108
|
+
class: "preview-dialog__backdrop",
|
|
2109
|
+
type: "button",
|
|
2110
|
+
"aria-label": "关闭实时预览",
|
|
2111
|
+
onClick: closePreviewDialog
|
|
2112
|
+
}), createElementVNode("section", _hoisted_78, [
|
|
2113
|
+
createElementVNode("header", _hoisted_79, [_cache[39] || (_cache[39] = createElementVNode("div", null, [createElementVNode("span", { class: "stage-kicker" }, "真实渲染"), createElementVNode("h2", { id: "layout-preview-title" }, "实时预览")], -1)), createElementVNode("div", _hoisted_80, [createElementVNode("span", _hoisted_81, [_cache[38] || (_cache[38] = createElementVNode("i", { "aria-hidden": "true" }, null, -1)), createTextVNode(toDisplayString(breakpointLabel(activeBreakpoint.value)), 1)]), createElementVNode("button", {
|
|
2114
|
+
class: "icon-button",
|
|
2115
|
+
type: "button",
|
|
2116
|
+
"aria-label": "关闭实时预览",
|
|
2117
|
+
title: "关闭实时预览",
|
|
2118
|
+
onClick: closePreviewDialog
|
|
2119
|
+
}, [createVNode(unref(X), {
|
|
2120
|
+
size: 16,
|
|
2121
|
+
"stroke-width": 1.9,
|
|
2122
|
+
"aria-hidden": "true"
|
|
2123
|
+
})])])]),
|
|
2124
|
+
createElementVNode("div", _hoisted_82, [createElementVNode("div", _hoisted_83, [activeDevelopmentFramework.value === "vue" ? (openBlock(), createBlock(unref(LGrid), {
|
|
2125
|
+
key: 0,
|
|
2126
|
+
document: layout.value,
|
|
2127
|
+
breakpoint: activeBreakpoint.value,
|
|
2128
|
+
materials: unref(materials),
|
|
2129
|
+
target: activeDevelopmentFramework.value
|
|
2130
|
+
}, {
|
|
2131
|
+
item: withCtx(({ item }) => [createVNode(unref(LMaterialRenderer), mergeProps({
|
|
2132
|
+
item,
|
|
2133
|
+
materials: unref(materials),
|
|
2134
|
+
target: activeDevelopmentFramework.value,
|
|
2135
|
+
class: "preview-dialog__card"
|
|
2136
|
+
}, item.props), null, 16, [
|
|
2137
|
+
"item",
|
|
2138
|
+
"materials",
|
|
2139
|
+
"target"
|
|
2140
|
+
])]),
|
|
2141
|
+
_: 1
|
|
2142
|
+
}, 8, [
|
|
2143
|
+
"document",
|
|
2144
|
+
"breakpoint",
|
|
2145
|
+
"materials",
|
|
2146
|
+
"target"
|
|
2147
|
+
])) : (openBlock(), createElementBlock("div", {
|
|
2148
|
+
key: 1,
|
|
2149
|
+
ref_key: "previewDialogRuntime",
|
|
2150
|
+
ref: previewDialogRuntime,
|
|
2151
|
+
class: "runtime-preview-grid preview-dialog__runtime-grid",
|
|
2152
|
+
"data-preview-renderer": "webcomponent"
|
|
2153
|
+
}, null, 512))])]),
|
|
2154
|
+
createElementVNode("footer", { class: "preview-dialog__footer" }, [_cache[40] || (_cache[40] = createElementVNode("span", null, "此处展示当前布局的真实 CSS Grid 渲染结果", -1)), createElementVNode("button", {
|
|
2155
|
+
class: "preview-dialog__close-button",
|
|
2156
|
+
type: "button",
|
|
2157
|
+
onClick: closePreviewDialog
|
|
2158
|
+
}, " 关闭预览 ")])
|
|
2159
|
+
])], 8, _hoisted_77)) : createCommentVNode("v-if", true)]),
|
|
2160
|
+
_: 1
|
|
2161
|
+
}),
|
|
2162
|
+
createVNode(Transition, { name: "preview-dialog" }, {
|
|
2163
|
+
default: withCtx(() => [materialCodeDialog.value ? (openBlock(), createElementBlock("div", {
|
|
2164
|
+
key: 0,
|
|
2165
|
+
class: "preview-dialog material-code-dialog",
|
|
2166
|
+
"data-material-code-dialog": "true",
|
|
2167
|
+
"data-material-code-framework": activeDevelopmentFramework.value,
|
|
2168
|
+
"data-material-code-type": materialCodeDialog.value.type,
|
|
2169
|
+
"data-theme": theme.value,
|
|
2170
|
+
role: "dialog",
|
|
2171
|
+
"aria-modal": "true",
|
|
2172
|
+
"aria-labelledby": "material-code-title"
|
|
2173
|
+
}, [createElementVNode("button", {
|
|
2174
|
+
class: "preview-dialog__backdrop",
|
|
2175
|
+
type: "button",
|
|
2176
|
+
"aria-label": "关闭物料代码",
|
|
2177
|
+
onClick: closeMaterialCode
|
|
2178
|
+
}), createElementVNode("section", _hoisted_85, [
|
|
2179
|
+
createElementVNode("header", _hoisted_86, [createElementVNode("div", null, [
|
|
2180
|
+
_cache[41] || (_cache[41] = createElementVNode("span", { class: "stage-kicker" }, "注册表物料", -1)),
|
|
2181
|
+
createElementVNode("h2", _hoisted_87, toDisplayString(materialCodeDialog.value.title ?? materialCodeDialog.value.label ?? materialCodeDialog.value.type), 1),
|
|
2182
|
+
createElementVNode("p", _hoisted_88, toDisplayString(activeDevelopmentFramework.value === "vue" ? "Vue 3 真实组件用法" : "原生 Web Component 标签用法"), 1)
|
|
2183
|
+
]), createElementVNode("div", _hoisted_89, [createElementVNode("span", _hoisted_90, [_cache[42] || (_cache[42] = createElementVNode("i", { "aria-hidden": "true" }, null, -1)), createTextVNode(toDisplayString(activeDevelopmentFrameworkLabel.value), 1)]), createElementVNode("button", {
|
|
2184
|
+
class: "icon-button",
|
|
2185
|
+
type: "button",
|
|
2186
|
+
"aria-label": "关闭物料代码",
|
|
2187
|
+
title: "关闭物料代码",
|
|
2188
|
+
onClick: closeMaterialCode
|
|
2189
|
+
}, [createVNode(unref(X), {
|
|
2190
|
+
size: 16,
|
|
2191
|
+
"stroke-width": 1.9,
|
|
2192
|
+
"aria-hidden": "true"
|
|
2193
|
+
})])])]),
|
|
2194
|
+
createElementVNode("div", _hoisted_91, [createElementVNode("pre", _hoisted_92, [createElementVNode("code", { innerHTML: highlightedMaterialCode.value }, null, 8, _hoisted_93)])]),
|
|
2195
|
+
createElementVNode("footer", _hoisted_94, [createElementVNode("span", null, "来自当前注册表的 " + toDisplayString(activeDevelopmentFramework.value === "vue" ? "组件导出" : "自定义元素标签") + ",共 " + toDisplayString(materialCodeLineCount.value) + " 行", 1), createElementVNode("div", _hoisted_95, [createElementVNode("button", {
|
|
2196
|
+
class: "copy-code-button",
|
|
2197
|
+
type: "button",
|
|
2198
|
+
"aria-label": materialCodeCopied.value ? "代码已复制" : "复制物料代码",
|
|
2199
|
+
title: materialCodeCopied.value ? "代码已复制" : "复制物料代码",
|
|
2200
|
+
onClick: copyMaterialCode
|
|
2201
|
+
}, [(openBlock(), createBlock(resolveDynamicComponent(materialCodeCopied.value ? unref(CopyCheck) : unref(Copy)), {
|
|
2202
|
+
size: 15,
|
|
2203
|
+
"stroke-width": 1.8,
|
|
2204
|
+
"aria-hidden": "true"
|
|
2205
|
+
}))], 8, _hoisted_96), createElementVNode("button", {
|
|
2206
|
+
class: "preview-dialog__close-button",
|
|
2207
|
+
type: "button",
|
|
2208
|
+
onClick: closeMaterialCode
|
|
2209
|
+
}, " 关闭 ")])])
|
|
2210
|
+
])], 8, _hoisted_84)) : createCommentVNode("v-if", true)]),
|
|
2211
|
+
_: 1
|
|
2212
|
+
})
|
|
2213
|
+
], 8, _hoisted_1);
|
|
2214
|
+
};
|
|
2215
|
+
}
|
|
2216
|
+
});
|
|
2217
|
+
//#endregion
|
|
2218
|
+
export { LLayoutWorkspace_vue_vue_type_script_setup_true_lang_default as default };
|
|
2219
|
+
/*! End of @composy/layout-vue | Powered by @composy/builder */
|
|
2220
|
+
//# sourceMappingURL=LLayoutWorkspace.vue_vue_type_script_setup_true_lang.js.map
|