@daxiangme/form-vue 0.1.0 → 0.1.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/LICENSE CHANGED
@@ -1,2 +1,21 @@
1
- MIT License. See the workspace root LICENSE for the complete text.
1
+ MIT License
2
2
 
3
+ Copyright (c) 2026 daxiangme
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,12 +1,26 @@
1
1
  # @daxiangme/form-vue
2
2
 
3
- Vue 3 + Element Plus 的 DX Form 设计器和运行渲染器。
3
+ > Visual Form Designer and Schema-Driven Renderer for Vue 3 + Element Plus
4
+
5
+ `@daxiangme/form-vue` 是 Form Builder 的唯一推荐使用入口,提供可嵌入的拖拽式设计器、Schema 驱动运行渲染器、弹窗与抽屉模块、字段规则和声明式事件流。
6
+
7
+ ![Form Builder 设计器总览](https://raw.githubusercontent.com/daxiangme/form-builder/v0.1.1/docs/assets/screenshots/designer-overview.png)
8
+
9
+ ## 安装
10
+
11
+ 已有 Vue 3 和 Element Plus 的应用只需要安装主包:
12
+
13
+ ```bash
14
+ pnpm add @daxiangme/form-vue
15
+ ```
16
+
17
+ 主包要求 Vue `^3.5.0` 和 Element Plus `^2.11.0`。新建工程或尚未安装这两个 Peer Dependencies 时,可以一次性安装:
4
18
 
5
19
  ```bash
6
- pnpm add @daxiangme/form-core @daxiangme/form-vue vue element-plus
20
+ pnpm add @daxiangme/form-vue vue element-plus
7
21
  ```
8
22
 
9
- 样式顺序固定为:
23
+ 按以下顺序引入样式:
10
24
 
11
25
  ```ts
12
26
  import 'element-plus/dist/index.css'
@@ -14,24 +28,119 @@ import 'element-plus/theme-chalk/dark/css-vars.css'
14
28
  import '@daxiangme/form-vue/style.css'
15
29
  ```
16
30
 
31
+ ## 注册组件
32
+
33
+ ```ts
34
+ import { createApp } from 'vue'
35
+ import ElementPlus from 'element-plus'
36
+ import { DaxiangFormVue } from '@daxiangme/form-vue'
37
+
38
+ import App from './App.vue'
39
+
40
+ createApp(App).use(ElementPlus).use(DaxiangFormVue).mount('#app')
41
+ ```
42
+
43
+ ## 设计表单
44
+
45
+ ```vue
46
+ <script setup lang="ts">
47
+ import { ref } from 'vue'
48
+ import {
49
+ FormDesigner,
50
+ createDemoDesignerDocument,
51
+ type DesignerDocument,
52
+ } from '@daxiangme/form-vue'
53
+
54
+ const document = ref<DesignerDocument>(createDemoDesignerDocument('purchase-application'))
55
+
56
+ function handleSave(nextDocument: DesignerDocument) {
57
+ document.value = nextDocument
58
+ }
59
+ </script>
60
+
61
+ <template>
62
+ <div class="designer-host">
63
+ <FormDesigner v-model="document" @save-request="handleSave" />
64
+ </div>
65
+ </template>
66
+
67
+ <style scoped>
68
+ .designer-host {
69
+ height: 100vh;
70
+ }
71
+ </style>
72
+ ```
73
+
74
+ `FormDesigner` 使用受控 `modelValue`,负责编辑文档并发出保存、导出与诊断事件;业务持久化由宿主决定。
75
+
76
+ ## 渲染表单
77
+
17
78
  ```vue
18
79
  <script setup lang="ts">
19
80
  import { ref } from 'vue'
20
- import { createEmptyDesignerDocument, type DesignerRuntimeValueStore } from '@daxiangme/form-core'
21
- import { FormDesigner, FormRenderer } from '@daxiangme/form-vue'
81
+ import {
82
+ FormRenderer,
83
+ createDemoDesignerDocument,
84
+ type DesignerRuntimeValueStore,
85
+ type DesignerSubmissionProjection,
86
+ } from '@daxiangme/form-vue'
22
87
 
23
- const document = ref(createEmptyDesignerDocument('form-1'))
88
+ const document = createDemoDesignerDocument('purchase-application')
24
89
  const value = ref<DesignerRuntimeValueStore>({ fields: {}, collections: {} })
90
+
91
+ function handleSubmit(projection: DesignerSubmissionProjection) {
92
+ console.info(projection)
93
+ }
25
94
  </script>
26
95
 
27
96
  <template>
28
- <FormDesigner v-model="document" @save-request="saveDocument" />
29
- <FormRenderer v-model="value" :document="document" mode="CREATE" />
97
+ <FormRenderer v-model="value" :document="document" mode="CREATE" @submit="handleSubmit" />
30
98
  </template>
31
99
  ```
32
100
 
33
- `FormDesigner` 只发出保存和导出请求,不代替宿主调用业务接口。`FormRenderer` 的文件、目录、OCR、扫码、定位、远程验证和导航能力都通过 `FormRuntimeAdapters` 显式注入;缺少端口时操作失败关闭。
101
+ `FormRenderer` 使用同一份文档渲染新增、编辑、只读和详情状态,并输出稳定的提交投影。
102
+
103
+ ## 模块、规则与事件
104
+
105
+ 主表单、弹窗与抽屉共用同一份 `DesignerDocument 1.0`。字段高级配置集中管理状态条件、公式与联动、验证规则、提交策略和组件事件;事件使用可视化步骤与条件分支表达。
106
+
107
+ ![弹窗与抽屉模块设计](https://raw.githubusercontent.com/daxiangme/form-builder/v0.1.1/docs/assets/screenshots/overlay-module-designer.png)
108
+
109
+ ![字段高级配置](https://raw.githubusercontent.com/daxiangme/form-builder/v0.1.1/docs/assets/screenshots/advanced-field-config.png)
110
+
111
+ ![声明式事件流](https://raw.githubusercontent.com/daxiangme/form-builder/v0.1.1/docs/assets/screenshots/event-flow-designer.png)
112
+
113
+ ## 运行效果与主题
114
+
115
+ 弹窗和抽屉在运行态使用真实 Element Plus 外壳。组件默认消费 Element Plus CSS Variables,深色模式直接跟随宿主的 `html.dark`。
116
+
117
+ ![表单运行预览](https://raw.githubusercontent.com/daxiangme/form-builder/v0.1.1/docs/assets/screenshots/runtime-preview.png)
118
+
119
+ ![Element Plus 深色主题](https://raw.githubusercontent.com/daxiangme/form-builder/v0.1.1/docs/assets/screenshots/dark-theme.png)
120
+
121
+ ## 宿主能力 Adapter
122
+
123
+ 基础设计与渲染不要求额外安装 Adapter。上传、目录、数据源、远程验证、OCR、扫码、定位、导航和业务动作需要宿主通过 `FormRuntimeAdapters` 注入相应端口;缺少端口时保留配置和静态外观,真实动作会明确失败关闭。
124
+
125
+ 主包同时导出常用文档门面和运行类型:
126
+
127
+ ```ts
128
+ import {
129
+ createEmptyDesignerDocument,
130
+ decodeDesignerDocument,
131
+ diagnoseDesignerDocument,
132
+ serializeDesignerDocument,
133
+ type DesignerDocument,
134
+ type FormRuntimeAdapters,
135
+ } from '@daxiangme/form-vue'
136
+ ```
137
+
138
+ ## 高级扩展与内部架构
139
+
140
+ 内部依赖固定为 `form-vue -> form-core <- form-adapter`。纯 TypeScript 文档内核和宿主适配工厂继续以 [`@daxiangme/form-core`](https://www.npmjs.com/package/@daxiangme/form-core) 与 [`@daxiangme/form-adapter`](https://www.npmjs.com/package/@daxiangme/form-adapter) 提供给高级集成方;普通 Vue 应用无需单独安装它们。
141
+
142
+ 当前版本支持 Vue 3、Element Plus 与现代 ESM 浏览器工程,不承诺 CommonJS、SSR 或其他 UI 框架。
34
143
 
35
- 深色模式直接跟随 Element Plus 的 `html.dark`,包内不维护第二套主题状态。
144
+ ## License
36
145
 
37
- `FormDesigner` 会占满直接父容器;消费方需要为该父容器提供确定高度,但不要求父容器使用 Flex 布局。
146
+ [MIT](https://github.com/daxiangme/form-builder/blob/v0.1.1/LICENSE) © 2026 daxiangme
package/dist/index.d.ts CHANGED
@@ -2,11 +2,19 @@ import { ComponentOptionsMixin } from 'vue';
2
2
  import { ComponentProvideOptions } from 'vue';
3
3
  import { ComputedRef } from 'vue';
4
4
  import { CreateComponentPublicInstanceWithMixins } from 'vue';
5
+ import { createDefaultDesignerFieldBehavior } from '@daxiangme/form-core';
6
+ import { createDemoDesignerDocument } from '@daxiangme/form-core';
7
+ import { createEmptyDesignerDocument } from '@daxiangme/form-core';
8
+ import { decodeDesignerDocument } from '@daxiangme/form-core';
5
9
  import { DefineComponent } from 'vue';
10
+ import { DesignerAppearance } from '@daxiangme/form-core';
6
11
  import { DesignerDevice } from '@daxiangme/form-core';
7
12
  import { DesignerDiagnostic } from '@daxiangme/form-core';
8
13
  import { DesignerDocument } from '@daxiangme/form-core';
14
+ import { DesignerDocumentDecodeResult } from '@daxiangme/form-core';
9
15
  import { DesignerDropTarget } from '@daxiangme/form-core';
16
+ import { DesignerField } from '@daxiangme/form-core';
17
+ import { DesignerFieldId } from '@daxiangme/form-core';
10
18
  import { DesignerInitialDataModel } from '@daxiangme/form-core';
11
19
  import { DesignerLayoutNode } from '@daxiangme/form-core';
12
20
  import { DesignerOverlayModule } from '@daxiangme/form-core';
@@ -14,12 +22,20 @@ import { DesignerRuntimeAdapters } from '@daxiangme/form-core';
14
22
  import { DesignerRuntimeMode } from '@daxiangme/form-core';
15
23
  import { DesignerRuntimeValueStore } from '@daxiangme/form-core';
16
24
  import { DesignerSubmissionProjection } from '@daxiangme/form-core';
25
+ import { DesignerValidationResult } from '@daxiangme/form-core';
26
+ import { diagnoseDesignerDocument } from '@daxiangme/form-core';
27
+ import { FormDesignerCatalogs } from '@daxiangme/form-core';
28
+ import { FormDesignerHostCapabilities } from '@daxiangme/form-core';
29
+ import { FormFieldAccessLevel } from '@daxiangme/form-core';
30
+ import { FormFieldAccessMap } from '@daxiangme/form-core';
17
31
  import { FormRuntimeAdapterContext } from '@daxiangme/form-core';
32
+ import { FormRuntimeAdapters } from '@daxiangme/form-core';
18
33
  import { GlobalComponents } from 'vue';
19
34
  import { GlobalDirectives } from 'vue';
20
35
  import { Plugin as Plugin_2 } from 'vue';
21
36
  import { PublicProps } from 'vue';
22
37
  import { Ref } from 'vue';
38
+ import { serializeDesignerDocument } from '@daxiangme/form-core';
23
39
 
24
40
  declare const __VLS_component: DefineComponent<__VLS_Props, {
25
41
  markClean: () => void;
@@ -158,6 +174,7 @@ flushContentVertical: boolean;
158
174
  declare type __VLS_Props = {
159
175
  modelValue: DesignerDocument;
160
176
  initialDataModel?: DesignerInitialDataModel;
177
+ catalogs?: FormDesignerCatalogs;
161
178
  adapters?: DesignerRuntimeAdapters;
162
179
  adapterContext?: FormRuntimeAdapterContext;
163
180
  /** @deprecated 请使用 adapters。 */
@@ -168,6 +185,7 @@ declare type __VLS_Props_2 = {
168
185
  document: DesignerDocument;
169
186
  modelValue?: DesignerRuntimeValueStore;
170
187
  mode?: Exclude<DesignerRuntimeMode, 'DESIGN'>;
188
+ fieldAccess?: FormFieldAccessMap;
171
189
  device?: DesignerDevice;
172
190
  adapters?: DesignerRuntimeAdapters;
173
191
  adapterContext?: FormRuntimeAdapterContext;
@@ -324,6 +342,12 @@ declare type __VLS_WithTemplateSlots_2<T, S> = T & {
324
342
  };
325
343
  };
326
344
 
345
+ export { createDefaultDesignerFieldBehavior }
346
+
347
+ export { createDemoDesignerDocument }
348
+
349
+ export { createEmptyDesignerDocument }
350
+
327
351
  /** 返回与 Vue 代理隔离的当前文档。 */
328
352
  declare function currentDocument(): DesignerDocument;
329
353
 
@@ -332,11 +356,49 @@ declare const DaxiangFormVue: Plugin_2;
332
356
  export { DaxiangFormVue }
333
357
  export default DaxiangFormVue;
334
358
 
359
+ export { decodeDesignerDocument }
360
+
361
+ export { DesignerAppearance }
362
+
335
363
  /** 设计画布的受控视口档位。 */
336
364
  export declare type DesignerCanvasViewportPreset = 'FIT' | 'PC_1920' | 'PC_1440' | 'PC_1280' | 'PC_1024' | 'MOBILE_440' | 'MOBILE_375';
337
365
 
366
+ export { DesignerDiagnostic }
367
+
368
+ export { DesignerDocument }
369
+
370
+ export { DesignerDocumentDecodeResult }
371
+
372
+ export { DesignerField }
373
+
374
+ export { DesignerFieldId }
375
+
376
+ export { DesignerInitialDataModel }
377
+
378
+ export { DesignerLayoutNode }
379
+
380
+ export { DesignerRuntimeAdapters }
381
+
382
+ export { DesignerRuntimeMode }
383
+
384
+ export { DesignerRuntimeValueStore }
385
+
386
+ export { DesignerSubmissionProjection }
387
+
388
+ export { DesignerValidationResult }
389
+
390
+ export { diagnoseDesignerDocument }
391
+
338
392
  export declare const FormDesigner: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
339
393
 
394
+ export { FormDesignerCatalogs }
395
+
396
+ export { FormDesignerHostCapabilities }
397
+
398
+ export { FormFieldAccessLevel }
399
+
400
+ export { FormFieldAccessMap }
401
+
340
402
  export declare const FormIcon: DefineComponent<__VLS_Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_3> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
341
403
 
342
404
  export declare const FormModalShell: __VLS_WithTemplateSlots_2<typeof __VLS_component_2, __VLS_TemplateResult_2["slots"]>;
@@ -367,6 +429,10 @@ overlayOnly: boolean;
367
429
  showToolbar: boolean;
368
430
  }, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
369
431
 
432
+ export { FormRuntimeAdapterContext }
433
+
434
+ export { FormRuntimeAdapters }
435
+
370
436
  /** 替换文档时重新执行一次性参数判定,并刷新只读来源索引。 */
371
437
  declare function replaceDocument(document: DesignerDocument, keepHistory?: boolean): void;
372
438
 
@@ -374,4 +440,6 @@ declare function requestClose(): void;
374
440
 
375
441
  declare function requestConfirm(): void;
376
442
 
443
+ export { serializeDesignerDocument }
444
+
377
445
  export { }