@daxiangme/form-vue 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,2 @@
1
+ MIT License. See the workspace root LICENSE for the complete text.
2
+
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # @daxiangme/form-vue
2
+
3
+ Vue 3 + Element Plus 的 DX Form 设计器和运行渲染器。
4
+
5
+ ```bash
6
+ pnpm add @daxiangme/form-core @daxiangme/form-vue vue element-plus
7
+ ```
8
+
9
+ 样式顺序固定为:
10
+
11
+ ```ts
12
+ import 'element-plus/dist/index.css'
13
+ import 'element-plus/theme-chalk/dark/css-vars.css'
14
+ import '@daxiangme/form-vue/style.css'
15
+ ```
16
+
17
+ ```vue
18
+ <script setup lang="ts">
19
+ import { ref } from 'vue'
20
+ import { createEmptyDesignerDocument, type DesignerRuntimeValueStore } from '@daxiangme/form-core'
21
+ import { FormDesigner, FormRenderer } from '@daxiangme/form-vue'
22
+
23
+ const document = ref(createEmptyDesignerDocument('form-1'))
24
+ const value = ref<DesignerRuntimeValueStore>({ fields: {}, collections: {} })
25
+ </script>
26
+
27
+ <template>
28
+ <FormDesigner v-model="document" @save-request="saveDocument" />
29
+ <FormRenderer v-model="value" :document="document" mode="CREATE" />
30
+ </template>
31
+ ```
32
+
33
+ `FormDesigner` 只发出保存和导出请求,不代替宿主调用业务接口。`FormRenderer` 的文件、目录、OCR、扫码、定位、远程验证和导航能力都通过 `FormRuntimeAdapters` 显式注入;缺少端口时操作失败关闭。
34
+
35
+ 深色模式直接跟随 Element Plus 的 `html.dark`,包内不维护第二套主题状态。
36
+
37
+ `FormDesigner` 会占满直接父容器;消费方需要为该父容器提供确定高度,但不要求父容器使用 Flex 布局。
@@ -0,0 +1,377 @@
1
+ import { ComponentOptionsMixin } from 'vue';
2
+ import { ComponentProvideOptions } from 'vue';
3
+ import { ComputedRef } from 'vue';
4
+ import { CreateComponentPublicInstanceWithMixins } from 'vue';
5
+ import { DefineComponent } from 'vue';
6
+ import { DesignerDevice } from '@daxiangme/form-core';
7
+ import { DesignerDiagnostic } from '@daxiangme/form-core';
8
+ import { DesignerDocument } from '@daxiangme/form-core';
9
+ import { DesignerDropTarget } from '@daxiangme/form-core';
10
+ import { DesignerInitialDataModel } from '@daxiangme/form-core';
11
+ import { DesignerLayoutNode } from '@daxiangme/form-core';
12
+ import { DesignerOverlayModule } from '@daxiangme/form-core';
13
+ import { DesignerRuntimeAdapters } from '@daxiangme/form-core';
14
+ import { DesignerRuntimeMode } from '@daxiangme/form-core';
15
+ import { DesignerRuntimeValueStore } from '@daxiangme/form-core';
16
+ import { DesignerSubmissionProjection } from '@daxiangme/form-core';
17
+ import { FormRuntimeAdapterContext } from '@daxiangme/form-core';
18
+ import { GlobalComponents } from 'vue';
19
+ import { GlobalDirectives } from 'vue';
20
+ import { Plugin as Plugin_2 } from 'vue';
21
+ import { PublicProps } from 'vue';
22
+ import { Ref } from 'vue';
23
+
24
+ declare const __VLS_component: DefineComponent<__VLS_Props, {
25
+ markClean: () => void;
26
+ dirty: Readonly<Ref<boolean, boolean>>;
27
+ replaceDocument: typeof replaceDocument;
28
+ currentDocument: typeof currentDocument;
29
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
30
+ "update:modelValue": (document: DesignerDocument) => any;
31
+ diagnostics: (items: DesignerDiagnostic[]) => any;
32
+ "dirty-change": (dirty: boolean) => any;
33
+ "save-request": (document: DesignerDocument) => any;
34
+ "export-request": (document: DesignerDocument) => any;
35
+ }, string, PublicProps, Readonly<__VLS_Props> & Readonly<{
36
+ "onUpdate:modelValue"?: ((document: DesignerDocument) => any) | undefined;
37
+ onDiagnostics?: ((items: DesignerDiagnostic[]) => any) | undefined;
38
+ "onDirty-change"?: ((dirty: boolean) => any) | undefined;
39
+ "onSave-request"?: ((document: DesignerDocument) => any) | undefined;
40
+ "onExport-request"?: ((document: DesignerDocument) => any) | undefined;
41
+ }>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
42
+ workspaceRef: HTMLDivElement;
43
+ canvasRef: CreateComponentPublicInstanceWithMixins<Readonly<{
44
+ document: DesignerDocument;
45
+ selectedNodeId: string;
46
+ device: DesignerDevice;
47
+ viewportWidth?: number;
48
+ zoom: number;
49
+ gridVisible: boolean;
50
+ activeModule?: DesignerOverlayModule;
51
+ }> & Readonly<{
52
+ onSelect?: ((nodeId: string) => any) | undefined;
53
+ onRemove?: ((nodeId: string) => any) | undefined;
54
+ onDrop?: ((payload: string, target: DesignerDropTarget) => any) | undefined;
55
+ onDuplicate?: ((nodeId: string) => any) | undefined;
56
+ onReorder?: ((containerId: string | null, slotCode: string, nodes: DesignerLayoutNode[]) => any) | undefined;
57
+ "onDrag-start"?: (() => any) | undefined;
58
+ "onDrag-end"?: (() => any) | undefined;
59
+ "onUpdate:zoom"?: ((zoom: number) => any) | undefined;
60
+ }>, {
61
+ fitToWidth: () => void;
62
+ captureViewport: () => {
63
+ horizontal: number;
64
+ vertical: number;
65
+ };
66
+ restoreViewport: (position: {
67
+ horizontal: number;
68
+ vertical: number;
69
+ }) => Promise<void>;
70
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
71
+ select: (nodeId: string) => any;
72
+ remove: (nodeId: string) => any;
73
+ drop: (payload: string, target: DesignerDropTarget) => any;
74
+ duplicate: (nodeId: string) => any;
75
+ reorder: (containerId: string | null, slotCode: string, nodes: DesignerLayoutNode[]) => any;
76
+ "drag-start": () => any;
77
+ "drag-end": () => any;
78
+ "update:zoom": (zoom: number) => any;
79
+ }, PublicProps, {}, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
80
+ canvasRef: HTMLElement;
81
+ stageRef: HTMLDivElement;
82
+ surfaceRef: unknown;
83
+ }, HTMLElement, ComponentProvideOptions, {
84
+ P: {};
85
+ B: {};
86
+ D: {};
87
+ C: {};
88
+ M: {};
89
+ Defaults: {};
90
+ }, Readonly<{
91
+ document: DesignerDocument;
92
+ selectedNodeId: string;
93
+ device: DesignerDevice;
94
+ viewportWidth?: number;
95
+ zoom: number;
96
+ gridVisible: boolean;
97
+ activeModule?: DesignerOverlayModule;
98
+ }> & Readonly<{
99
+ onSelect?: ((nodeId: string) => any) | undefined;
100
+ onRemove?: ((nodeId: string) => any) | undefined;
101
+ onDrop?: ((payload: string, target: DesignerDropTarget) => any) | undefined;
102
+ onDuplicate?: ((nodeId: string) => any) | undefined;
103
+ onReorder?: ((containerId: string | null, slotCode: string, nodes: DesignerLayoutNode[]) => any) | undefined;
104
+ "onDrag-start"?: (() => any) | undefined;
105
+ "onDrag-end"?: (() => any) | undefined;
106
+ "onUpdate:zoom"?: ((zoom: number) => any) | undefined;
107
+ }>, {
108
+ fitToWidth: () => void;
109
+ captureViewport: () => {
110
+ horizontal: number;
111
+ vertical: number;
112
+ };
113
+ restoreViewport: (position: {
114
+ horizontal: number;
115
+ vertical: number;
116
+ }) => Promise<void>;
117
+ }, {}, {}, {}, {}> | null;
118
+ importInputRef: HTMLInputElement;
119
+ }, HTMLElement>;
120
+
121
+ declare const __VLS_component_2: DefineComponent<__VLS_Props_4, {
122
+ busy: ComputedRef<boolean>;
123
+ requestClose: typeof requestClose;
124
+ requestConfirm: typeof requestConfirm;
125
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
126
+ "update:modelValue": (args_0: boolean) => any;
127
+ confirm: () => any;
128
+ cancel: () => any;
129
+ closed: () => any;
130
+ }, string, PublicProps, Readonly<__VLS_Props_4> & Readonly<{
131
+ "onUpdate:modelValue"?: ((args_0: boolean) => any) | undefined;
132
+ onConfirm?: (() => any) | undefined;
133
+ onCancel?: (() => any) | undefined;
134
+ onClosed?: (() => any) | undefined;
135
+ }>, {
136
+ title: string;
137
+ dialogClass: string;
138
+ width: string | number;
139
+ maxHeight: string | number;
140
+ loading: boolean;
141
+ confirmLoading: boolean;
142
+ confirmDisabled: boolean;
143
+ showFooter: boolean;
144
+ showCancel: boolean;
145
+ showConfirm: boolean;
146
+ showClose: boolean;
147
+ cancelText: string;
148
+ confirmText: string;
149
+ destroyOnClose: boolean;
150
+ closeOnClickModal: boolean;
151
+ closeOnPressEscape: boolean;
152
+ alignCenter: boolean;
153
+ draggable: boolean;
154
+ dragOverflow: boolean;
155
+ flushContentVertical: boolean;
156
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
157
+
158
+ declare type __VLS_Props = {
159
+ modelValue: DesignerDocument;
160
+ initialDataModel?: DesignerInitialDataModel;
161
+ adapters?: DesignerRuntimeAdapters;
162
+ adapterContext?: FormRuntimeAdapterContext;
163
+ /** @deprecated 请使用 adapters。 */
164
+ runtimeAdapters?: DesignerRuntimeAdapters;
165
+ };
166
+
167
+ declare type __VLS_Props_2 = {
168
+ document: DesignerDocument;
169
+ modelValue?: DesignerRuntimeValueStore;
170
+ mode?: Exclude<DesignerRuntimeMode, 'DESIGN'>;
171
+ device?: DesignerDevice;
172
+ adapters?: DesignerRuntimeAdapters;
173
+ adapterContext?: FormRuntimeAdapterContext;
174
+ activeModule?: string;
175
+ /** @deprecated 请使用 activeModule。 */
176
+ initialOverlayCode?: string;
177
+ overlayOnly?: boolean;
178
+ showToolbar?: boolean;
179
+ };
180
+
181
+ declare type __VLS_Props_3 = {
182
+ /** 随包发布的 Remix Icon 名称,例如 `ri:add-line`。 */
183
+ icon?: string;
184
+ };
185
+
186
+ declare type __VLS_Props_4 = {
187
+ modelValue: boolean;
188
+ title?: string;
189
+ dialogClass?: string;
190
+ width?: string | number;
191
+ maxHeight?: string | number;
192
+ loading?: boolean;
193
+ confirmLoading?: boolean;
194
+ confirmDisabled?: boolean;
195
+ showFooter?: boolean;
196
+ showCancel?: boolean;
197
+ showConfirm?: boolean;
198
+ showClose?: boolean;
199
+ cancelText?: string;
200
+ confirmText?: string;
201
+ destroyOnClose?: boolean;
202
+ closeOnClickModal?: boolean;
203
+ closeOnPressEscape?: boolean;
204
+ alignCenter?: boolean;
205
+ draggable?: boolean;
206
+ dragOverflow?: boolean;
207
+ flushContentVertical?: boolean;
208
+ };
209
+
210
+ declare function __VLS_template(): {
211
+ attrs: Partial<{}>;
212
+ slots: {
213
+ 'header-leading'?(_: {}): any;
214
+ };
215
+ refs: {
216
+ workspaceRef: HTMLDivElement;
217
+ canvasRef: CreateComponentPublicInstanceWithMixins<Readonly<{
218
+ document: DesignerDocument;
219
+ selectedNodeId: string;
220
+ device: DesignerDevice;
221
+ viewportWidth?: number;
222
+ zoom: number;
223
+ gridVisible: boolean;
224
+ activeModule?: DesignerOverlayModule;
225
+ }> & Readonly<{
226
+ onSelect?: ((nodeId: string) => any) | undefined;
227
+ onRemove?: ((nodeId: string) => any) | undefined;
228
+ onDrop?: ((payload: string, target: DesignerDropTarget) => any) | undefined;
229
+ onDuplicate?: ((nodeId: string) => any) | undefined;
230
+ onReorder?: ((containerId: string | null, slotCode: string, nodes: DesignerLayoutNode[]) => any) | undefined;
231
+ "onDrag-start"?: (() => any) | undefined;
232
+ "onDrag-end"?: (() => any) | undefined;
233
+ "onUpdate:zoom"?: ((zoom: number) => any) | undefined;
234
+ }>, {
235
+ fitToWidth: () => void;
236
+ captureViewport: () => {
237
+ horizontal: number;
238
+ vertical: number;
239
+ };
240
+ restoreViewport: (position: {
241
+ horizontal: number;
242
+ vertical: number;
243
+ }) => Promise<void>;
244
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
245
+ select: (nodeId: string) => any;
246
+ remove: (nodeId: string) => any;
247
+ drop: (payload: string, target: DesignerDropTarget) => any;
248
+ duplicate: (nodeId: string) => any;
249
+ reorder: (containerId: string | null, slotCode: string, nodes: DesignerLayoutNode[]) => any;
250
+ "drag-start": () => any;
251
+ "drag-end": () => any;
252
+ "update:zoom": (zoom: number) => any;
253
+ }, PublicProps, {}, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
254
+ canvasRef: HTMLElement;
255
+ stageRef: HTMLDivElement;
256
+ surfaceRef: unknown;
257
+ }, HTMLElement, ComponentProvideOptions, {
258
+ P: {};
259
+ B: {};
260
+ D: {};
261
+ C: {};
262
+ M: {};
263
+ Defaults: {};
264
+ }, Readonly<{
265
+ document: DesignerDocument;
266
+ selectedNodeId: string;
267
+ device: DesignerDevice;
268
+ viewportWidth?: number;
269
+ zoom: number;
270
+ gridVisible: boolean;
271
+ activeModule?: DesignerOverlayModule;
272
+ }> & Readonly<{
273
+ onSelect?: ((nodeId: string) => any) | undefined;
274
+ onRemove?: ((nodeId: string) => any) | undefined;
275
+ onDrop?: ((payload: string, target: DesignerDropTarget) => any) | undefined;
276
+ onDuplicate?: ((nodeId: string) => any) | undefined;
277
+ onReorder?: ((containerId: string | null, slotCode: string, nodes: DesignerLayoutNode[]) => any) | undefined;
278
+ "onDrag-start"?: (() => any) | undefined;
279
+ "onDrag-end"?: (() => any) | undefined;
280
+ "onUpdate:zoom"?: ((zoom: number) => any) | undefined;
281
+ }>, {
282
+ fitToWidth: () => void;
283
+ captureViewport: () => {
284
+ horizontal: number;
285
+ vertical: number;
286
+ };
287
+ restoreViewport: (position: {
288
+ horizontal: number;
289
+ vertical: number;
290
+ }) => Promise<void>;
291
+ }, {}, {}, {}, {}> | null;
292
+ importInputRef: HTMLInputElement;
293
+ };
294
+ rootEl: HTMLElement;
295
+ };
296
+
297
+ declare function __VLS_template_2(): {
298
+ attrs: Partial<{}>;
299
+ slots: {
300
+ default?(_: {}): any;
301
+ footer?(_: {
302
+ busy: boolean;
303
+ close: typeof requestClose;
304
+ confirm: typeof requestConfirm;
305
+ }): any;
306
+ };
307
+ refs: {};
308
+ rootEl: any;
309
+ };
310
+
311
+ declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
312
+
313
+ declare type __VLS_TemplateResult_2 = ReturnType<typeof __VLS_template_2>;
314
+
315
+ declare type __VLS_WithTemplateSlots<T, S> = T & {
316
+ new (): {
317
+ $slots: S;
318
+ };
319
+ };
320
+
321
+ declare type __VLS_WithTemplateSlots_2<T, S> = T & {
322
+ new (): {
323
+ $slots: S;
324
+ };
325
+ };
326
+
327
+ /** 返回与 Vue 代理隔离的当前文档。 */
328
+ declare function currentDocument(): DesignerDocument;
329
+
330
+ /** Vue 3 全局安装入口;按需使用时可以直接导入具名组件。 */
331
+ declare const DaxiangFormVue: Plugin_2;
332
+ export { DaxiangFormVue }
333
+ export default DaxiangFormVue;
334
+
335
+ /** 设计画布的受控视口档位。 */
336
+ export declare type DesignerCanvasViewportPreset = 'FIT' | 'PC_1920' | 'PC_1440' | 'PC_1280' | 'PC_1024' | 'MOBILE_440' | 'MOBILE_375';
337
+
338
+ export declare const FormDesigner: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
339
+
340
+ export declare const FormIcon: DefineComponent<__VLS_Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_3> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
341
+
342
+ export declare const FormModalShell: __VLS_WithTemplateSlots_2<typeof __VLS_component_2, __VLS_TemplateResult_2["slots"]>;
343
+
344
+ export declare const FormRenderer: DefineComponent<__VLS_Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
345
+ "update:modelValue": (value: DesignerRuntimeValueStore) => any;
346
+ submit: (projection: DesignerSubmissionProjection) => any;
347
+ reset: (value: DesignerRuntimeValueStore) => any;
348
+ "runtime-warning": (message: string) => any;
349
+ action: (action: "SUBMIT" | "RESET" | "PRINT") => any;
350
+ "overlay-closed": () => any;
351
+ "overlay-open-failed": (message: string) => any;
352
+ }, string, PublicProps, Readonly<__VLS_Props_2> & Readonly<{
353
+ "onUpdate:modelValue"?: ((value: DesignerRuntimeValueStore) => any) | undefined;
354
+ onSubmit?: ((projection: DesignerSubmissionProjection) => any) | undefined;
355
+ onReset?: ((value: DesignerRuntimeValueStore) => any) | undefined;
356
+ "onRuntime-warning"?: ((message: string) => any) | undefined;
357
+ onAction?: ((action: "SUBMIT" | "RESET" | "PRINT") => any) | undefined;
358
+ "onOverlay-closed"?: (() => any) | undefined;
359
+ "onOverlay-open-failed"?: ((message: string) => any) | undefined;
360
+ }>, {
361
+ mode: Exclude<DesignerRuntimeMode, "DESIGN">;
362
+ device: DesignerDevice;
363
+ adapterContext: FormRuntimeAdapterContext;
364
+ activeModule: string;
365
+ initialOverlayCode: string;
366
+ overlayOnly: boolean;
367
+ showToolbar: boolean;
368
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
369
+
370
+ /** 替换文档时重新执行一次性参数判定,并刷新只读来源索引。 */
371
+ declare function replaceDocument(document: DesignerDocument, keepHistory?: boolean): void;
372
+
373
+ declare function requestClose(): void;
374
+
375
+ declare function requestConfirm(): void;
376
+
377
+ export { }