@daxiangme/form-vue 0.1.0 → 0.1.1
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 +20 -1
- package/README.md +112 -11
- package/dist/index.d.ts +38 -0
- package/dist/index.js +5725 -6372
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +11 -2
package/LICENSE
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
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,18 @@
|
|
|
1
1
|
# @daxiangme/form-vue
|
|
2
2
|
|
|
3
|
-
Vue 3 + Element Plus
|
|
3
|
+
> Visual Form Designer and Schema-Driven Renderer for Vue 3 + Element Plus
|
|
4
|
+
|
|
5
|
+
`@daxiangme/form-vue` 是 Form Builder 的唯一推荐使用入口,提供可嵌入的拖拽式设计器、Schema 驱动运行渲染器、弹窗与抽屉模块、字段规则和声明式事件流。
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## 安装
|
|
4
10
|
|
|
5
11
|
```bash
|
|
6
|
-
pnpm add @daxiangme/form-
|
|
12
|
+
pnpm add @daxiangme/form-vue vue element-plus
|
|
7
13
|
```
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
按以下顺序引入样式:
|
|
10
16
|
|
|
11
17
|
```ts
|
|
12
18
|
import 'element-plus/dist/index.css'
|
|
@@ -14,24 +20,119 @@ import 'element-plus/theme-chalk/dark/css-vars.css'
|
|
|
14
20
|
import '@daxiangme/form-vue/style.css'
|
|
15
21
|
```
|
|
16
22
|
|
|
23
|
+
## 注册组件
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createApp } from 'vue'
|
|
27
|
+
import ElementPlus from 'element-plus'
|
|
28
|
+
import { DaxiangFormVue } from '@daxiangme/form-vue'
|
|
29
|
+
|
|
30
|
+
import App from './App.vue'
|
|
31
|
+
|
|
32
|
+
createApp(App).use(ElementPlus).use(DaxiangFormVue).mount('#app')
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 设计表单
|
|
36
|
+
|
|
17
37
|
```vue
|
|
18
38
|
<script setup lang="ts">
|
|
19
39
|
import { ref } from 'vue'
|
|
20
|
-
import {
|
|
21
|
-
|
|
40
|
+
import {
|
|
41
|
+
FormDesigner,
|
|
42
|
+
createDemoDesignerDocument,
|
|
43
|
+
type DesignerDocument,
|
|
44
|
+
} from '@daxiangme/form-vue'
|
|
45
|
+
|
|
46
|
+
const document = ref<DesignerDocument>(createDemoDesignerDocument('purchase-application'))
|
|
22
47
|
|
|
23
|
-
|
|
48
|
+
function handleSave(nextDocument: DesignerDocument) {
|
|
49
|
+
document.value = nextDocument
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<div class="designer-host">
|
|
55
|
+
<FormDesigner v-model="document" @save-request="handleSave" />
|
|
56
|
+
</div>
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<style scoped>
|
|
60
|
+
.designer-host {
|
|
61
|
+
height: 100vh;
|
|
62
|
+
}
|
|
63
|
+
</style>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`FormDesigner` 使用受控 `modelValue`,负责编辑文档并发出保存、导出与诊断事件;业务持久化由宿主决定。
|
|
67
|
+
|
|
68
|
+
## 渲染表单
|
|
69
|
+
|
|
70
|
+
```vue
|
|
71
|
+
<script setup lang="ts">
|
|
72
|
+
import { ref } from 'vue'
|
|
73
|
+
import {
|
|
74
|
+
FormRenderer,
|
|
75
|
+
createDemoDesignerDocument,
|
|
76
|
+
type DesignerRuntimeValueStore,
|
|
77
|
+
type DesignerSubmissionProjection,
|
|
78
|
+
} from '@daxiangme/form-vue'
|
|
79
|
+
|
|
80
|
+
const document = createDemoDesignerDocument('purchase-application')
|
|
24
81
|
const value = ref<DesignerRuntimeValueStore>({ fields: {}, collections: {} })
|
|
82
|
+
|
|
83
|
+
function handleSubmit(projection: DesignerSubmissionProjection) {
|
|
84
|
+
console.info(projection)
|
|
85
|
+
}
|
|
25
86
|
</script>
|
|
26
87
|
|
|
27
88
|
<template>
|
|
28
|
-
<
|
|
29
|
-
<FormRenderer v-model="value" :document="document" mode="CREATE" />
|
|
89
|
+
<FormRenderer v-model="value" :document="document" mode="CREATE" @submit="handleSubmit" />
|
|
30
90
|
</template>
|
|
31
91
|
```
|
|
32
92
|
|
|
33
|
-
`
|
|
93
|
+
`FormRenderer` 使用同一份文档渲染新增、编辑、只读和详情状态,并输出稳定的提交投影。
|
|
94
|
+
|
|
95
|
+
## 模块、规则与事件
|
|
96
|
+
|
|
97
|
+
主表单、弹窗与抽屉共用同一份 `DesignerDocument 1.0`。字段高级配置集中管理状态条件、公式与联动、验证规则、提交策略和组件事件;事件使用可视化步骤与条件分支表达。
|
|
98
|
+
|
|
99
|
+

|
|
100
|
+
|
|
101
|
+

|
|
102
|
+
|
|
103
|
+

|
|
104
|
+
|
|
105
|
+
## 运行效果与主题
|
|
106
|
+
|
|
107
|
+
弹窗和抽屉在运行态使用真实 Element Plus 外壳。组件默认消费 Element Plus CSS Variables,深色模式直接跟随宿主的 `html.dark`。
|
|
108
|
+
|
|
109
|
+

|
|
110
|
+
|
|
111
|
+

|
|
112
|
+
|
|
113
|
+
## 宿主能力 Adapter
|
|
114
|
+
|
|
115
|
+
基础设计与渲染不要求额外安装 Adapter。上传、目录、数据源、远程验证、OCR、扫码、定位、导航和业务动作需要宿主通过 `FormRuntimeAdapters` 注入相应端口;缺少端口时保留配置和静态外观,真实动作会明确失败关闭。
|
|
116
|
+
|
|
117
|
+
主包同时导出常用文档门面和运行类型:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import {
|
|
121
|
+
createEmptyDesignerDocument,
|
|
122
|
+
decodeDesignerDocument,
|
|
123
|
+
diagnoseDesignerDocument,
|
|
124
|
+
serializeDesignerDocument,
|
|
125
|
+
type DesignerDocument,
|
|
126
|
+
type FormRuntimeAdapters,
|
|
127
|
+
} from '@daxiangme/form-vue'
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## 高级扩展与内部架构
|
|
131
|
+
|
|
132
|
+
内部依赖固定为 `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 应用无需单独安装它们。
|
|
133
|
+
|
|
134
|
+
当前版本支持 Vue 3、Element Plus 与现代 ESM 浏览器工程,不承诺 CommonJS、SSR 或其他 UI 框架。
|
|
34
135
|
|
|
35
|
-
|
|
136
|
+
## License
|
|
36
137
|
|
|
37
|
-
|
|
138
|
+
[MIT](https://github.com/daxiangme/form-builder/blob/v0.1.1/LICENSE) © 2026 daxiangme
|
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,14 @@ import { ComponentOptionsMixin } from 'vue';
|
|
|
2
2
|
import { ComponentProvideOptions } from 'vue';
|
|
3
3
|
import { ComputedRef } from 'vue';
|
|
4
4
|
import { CreateComponentPublicInstanceWithMixins } from 'vue';
|
|
5
|
+
import { createDemoDesignerDocument } from '@daxiangme/form-core';
|
|
6
|
+
import { createEmptyDesignerDocument } from '@daxiangme/form-core';
|
|
7
|
+
import { decodeDesignerDocument } from '@daxiangme/form-core';
|
|
5
8
|
import { DefineComponent } from 'vue';
|
|
6
9
|
import { DesignerDevice } from '@daxiangme/form-core';
|
|
7
10
|
import { DesignerDiagnostic } from '@daxiangme/form-core';
|
|
8
11
|
import { DesignerDocument } from '@daxiangme/form-core';
|
|
12
|
+
import { DesignerDocumentDecodeResult } from '@daxiangme/form-core';
|
|
9
13
|
import { DesignerDropTarget } from '@daxiangme/form-core';
|
|
10
14
|
import { DesignerInitialDataModel } from '@daxiangme/form-core';
|
|
11
15
|
import { DesignerLayoutNode } from '@daxiangme/form-core';
|
|
@@ -14,12 +18,16 @@ import { DesignerRuntimeAdapters } from '@daxiangme/form-core';
|
|
|
14
18
|
import { DesignerRuntimeMode } from '@daxiangme/form-core';
|
|
15
19
|
import { DesignerRuntimeValueStore } from '@daxiangme/form-core';
|
|
16
20
|
import { DesignerSubmissionProjection } from '@daxiangme/form-core';
|
|
21
|
+
import { DesignerValidationResult } from '@daxiangme/form-core';
|
|
22
|
+
import { diagnoseDesignerDocument } from '@daxiangme/form-core';
|
|
17
23
|
import { FormRuntimeAdapterContext } from '@daxiangme/form-core';
|
|
24
|
+
import { FormRuntimeAdapters } from '@daxiangme/form-core';
|
|
18
25
|
import { GlobalComponents } from 'vue';
|
|
19
26
|
import { GlobalDirectives } from 'vue';
|
|
20
27
|
import { Plugin as Plugin_2 } from 'vue';
|
|
21
28
|
import { PublicProps } from 'vue';
|
|
22
29
|
import { Ref } from 'vue';
|
|
30
|
+
import { serializeDesignerDocument } from '@daxiangme/form-core';
|
|
23
31
|
|
|
24
32
|
declare const __VLS_component: DefineComponent<__VLS_Props, {
|
|
25
33
|
markClean: () => void;
|
|
@@ -324,6 +332,10 @@ declare type __VLS_WithTemplateSlots_2<T, S> = T & {
|
|
|
324
332
|
};
|
|
325
333
|
};
|
|
326
334
|
|
|
335
|
+
export { createDemoDesignerDocument }
|
|
336
|
+
|
|
337
|
+
export { createEmptyDesignerDocument }
|
|
338
|
+
|
|
327
339
|
/** 返回与 Vue 代理隔离的当前文档。 */
|
|
328
340
|
declare function currentDocument(): DesignerDocument;
|
|
329
341
|
|
|
@@ -332,9 +344,29 @@ declare const DaxiangFormVue: Plugin_2;
|
|
|
332
344
|
export { DaxiangFormVue }
|
|
333
345
|
export default DaxiangFormVue;
|
|
334
346
|
|
|
347
|
+
export { decodeDesignerDocument }
|
|
348
|
+
|
|
335
349
|
/** 设计画布的受控视口档位。 */
|
|
336
350
|
export declare type DesignerCanvasViewportPreset = 'FIT' | 'PC_1920' | 'PC_1440' | 'PC_1280' | 'PC_1024' | 'MOBILE_440' | 'MOBILE_375';
|
|
337
351
|
|
|
352
|
+
export { DesignerDiagnostic }
|
|
353
|
+
|
|
354
|
+
export { DesignerDocument }
|
|
355
|
+
|
|
356
|
+
export { DesignerDocumentDecodeResult }
|
|
357
|
+
|
|
358
|
+
export { DesignerRuntimeAdapters }
|
|
359
|
+
|
|
360
|
+
export { DesignerRuntimeMode }
|
|
361
|
+
|
|
362
|
+
export { DesignerRuntimeValueStore }
|
|
363
|
+
|
|
364
|
+
export { DesignerSubmissionProjection }
|
|
365
|
+
|
|
366
|
+
export { DesignerValidationResult }
|
|
367
|
+
|
|
368
|
+
export { diagnoseDesignerDocument }
|
|
369
|
+
|
|
338
370
|
export declare const FormDesigner: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
339
371
|
|
|
340
372
|
export declare const FormIcon: DefineComponent<__VLS_Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_3> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
@@ -367,6 +399,10 @@ overlayOnly: boolean;
|
|
|
367
399
|
showToolbar: boolean;
|
|
368
400
|
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
369
401
|
|
|
402
|
+
export { FormRuntimeAdapterContext }
|
|
403
|
+
|
|
404
|
+
export { FormRuntimeAdapters }
|
|
405
|
+
|
|
370
406
|
/** 替换文档时重新执行一次性参数判定,并刷新只读来源索引。 */
|
|
371
407
|
declare function replaceDocument(document: DesignerDocument, keepHistory?: boolean): void;
|
|
372
408
|
|
|
@@ -374,4 +410,6 @@ declare function requestClose(): void;
|
|
|
374
410
|
|
|
375
411
|
declare function requestConfirm(): void;
|
|
376
412
|
|
|
413
|
+
export { serializeDesignerDocument }
|
|
414
|
+
|
|
377
415
|
export { }
|