@fast-form-designer/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 +21 -0
- package/README.md +416 -0
- package/dist/FastFormDesigner.vue.d.ts +27 -0
- package/dist/components/CenterCanvas.vue.d.ts +3 -0
- package/dist/components/FormItem.vue.d.ts +25 -0
- package/dist/components/FormRenderer.vue.d.ts +21 -0
- package/dist/components/FormRendererNode.vue.d.ts +26 -0
- package/dist/components/LeftPanel.vue.d.ts +7 -0
- package/dist/components/RightPanel.vue.d.ts +3 -0
- package/dist/components/SignaturePad.vue.d.ts +29 -0
- package/dist/components/VisibilityRulesDialog.vue.d.ts +22 -0
- package/dist/config/component-list.d.ts +6 -0
- package/dist/hooks/useDesigner.d.ts +15 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.es.js +7435 -0
- package/dist/index.umd.cjs +3 -0
- package/dist/style.css +1 -0
- package/dist/types/index.d.ts +108 -0
- package/dist/utils/index.d.ts +47 -0
- package/dist/utils/pca.d.ts +2 -0
- package/package.json +97 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fast Form Designer contributors
|
|
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
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
# @fast-form-designer/vue
|
|
2
|
+
|
|
3
|
+
简单、快速、实用的、基于 Vue 3 和 Element Plus 的可视化表单设计器。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- **可视化设计**:通过拖拽组件快速构建表单
|
|
8
|
+
- **丰富组件**:支持 20+ 种表单组件,涵盖基础输入、选择、布局等类型
|
|
9
|
+
- **属性配置**:可配置组件属性、校验规则、布局样式
|
|
10
|
+
- **表单配置**:支持全局表单设置(标签位置、尺寸等)
|
|
11
|
+
- **条件显隐**:支持基于字段值的动态显示/隐藏规则
|
|
12
|
+
- **实时预览**:即时预览设计效果
|
|
13
|
+
- **JSON 导入/导出**:保存和加载表单设计
|
|
14
|
+
- **表单渲染器**:独立的渲染组件,可根据 JSON 配置生成可交互表单
|
|
15
|
+
|
|
16
|
+
## 组件清单
|
|
17
|
+
|
|
18
|
+
### 基础组件
|
|
19
|
+
|
|
20
|
+
| 组件类型 | 说明 | 主要特性 |
|
|
21
|
+
| -------------- | -------- | --------------------- |
|
|
22
|
+
| `input` | 单行文本 | 占位符、可清空、禁用 |
|
|
23
|
+
| `textarea` | 多行文本 | 行数设置、占位符 |
|
|
24
|
+
| `text` | 文字展示 | 静态文本显示 |
|
|
25
|
+
| `link` | 链接 | URL、打开方式、下划线 |
|
|
26
|
+
| `input-number` | 计数器 | 数值输入 |
|
|
27
|
+
| `rate` | 评分 | 最大值、半星、可清空 |
|
|
28
|
+
| `radio` | 单选框 | 静态/远程选项 |
|
|
29
|
+
| `checkbox` | 复选框 | 静态/远程选项、多选 |
|
|
30
|
+
| `select` | 下拉框 | 可筛选、虚拟化、多选 |
|
|
31
|
+
| `switch` | 开关 | 布尔值切换 |
|
|
32
|
+
| `date` | 日期选择 | 日期格式 |
|
|
33
|
+
| `time` | 时间选择 | 时间格式 |
|
|
34
|
+
| `datetime` | 日期时间 | 日期时间组合 |
|
|
35
|
+
| `pca` | 省市区 | 省/市/区三级联动 |
|
|
36
|
+
|
|
37
|
+
### 高级组件
|
|
38
|
+
|
|
39
|
+
| 组件类型 | 说明 | 主要特性 |
|
|
40
|
+
| ----------- | -------- | -------------------------- |
|
|
41
|
+
| `cascader` | 级联选择 | 多级联动、可任选层级 |
|
|
42
|
+
| `signature` | 手写签名 | 画布高度、线宽、颜色 |
|
|
43
|
+
| `upload` | 文件上传 | 多文件、自动上传、列表类型 |
|
|
44
|
+
| `sub-form` | 子表单 | 嵌套表单、行索引、操作按钮 |
|
|
45
|
+
|
|
46
|
+
### 布局组件
|
|
47
|
+
|
|
48
|
+
| 组件类型 | 说明 | 主要特性 |
|
|
49
|
+
| ---------- | -------- | ------------------ |
|
|
50
|
+
| `group` | 分组 | 表单分组容器 |
|
|
51
|
+
| `grid` | 栅格布局 | 多列布局、间距设置 |
|
|
52
|
+
| `grid-col` | 栅格列 | 列宽(span)配置 |
|
|
53
|
+
|
|
54
|
+
## 安装
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# npm
|
|
58
|
+
npm install @fast-form-designer/vue element-plus @element-plus/icons-vue
|
|
59
|
+
|
|
60
|
+
# pnpm
|
|
61
|
+
pnpm add @fast-form-designer/vue element-plus @element-plus/icons-vue
|
|
62
|
+
|
|
63
|
+
# yarn
|
|
64
|
+
yarn add @fast-form-designer/vue element-plus @element-plus/icons-vue
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 环境要求
|
|
68
|
+
|
|
69
|
+
- Node.js: `^20.19.0` 或 `>=22.12.0`
|
|
70
|
+
- Vue: `^3.5.26`
|
|
71
|
+
- Element Plus: `^2.13.1`
|
|
72
|
+
- @element-plus/icons-vue: `^2.3.2`
|
|
73
|
+
|
|
74
|
+
## 快速开始
|
|
75
|
+
|
|
76
|
+
### 1. 全局注册 Element Plus
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
// main.ts
|
|
80
|
+
import { createApp } from 'vue'
|
|
81
|
+
import ElementPlus from 'element-plus'
|
|
82
|
+
import 'element-plus/dist/index.css'
|
|
83
|
+
import App from './App.vue'
|
|
84
|
+
|
|
85
|
+
createApp(App).use(ElementPlus).mount('#app')
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 2. 使用设计器组件
|
|
89
|
+
|
|
90
|
+
```vue
|
|
91
|
+
<template>
|
|
92
|
+
<FastFormDesigner />
|
|
93
|
+
</template>
|
|
94
|
+
|
|
95
|
+
<script setup lang="ts">
|
|
96
|
+
import FastFormDesigner from '@fast-form-designer/vue'
|
|
97
|
+
import '@fast-form-designer/vue/style.css'
|
|
98
|
+
</script>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 3. 使用表单渲染器
|
|
102
|
+
|
|
103
|
+
```vue
|
|
104
|
+
<template>
|
|
105
|
+
<FormRenderer
|
|
106
|
+
ref="rendererRef"
|
|
107
|
+
v-model="formData"
|
|
108
|
+
:schema="formSchema"
|
|
109
|
+
:disabled="false"
|
|
110
|
+
@change="handleChange"
|
|
111
|
+
/>
|
|
112
|
+
<el-button @click="handleValidate">校验</el-button>
|
|
113
|
+
<el-button @click="handleReset">重置</el-button>
|
|
114
|
+
</template>
|
|
115
|
+
|
|
116
|
+
<script setup lang="ts">
|
|
117
|
+
import { ref } from 'vue'
|
|
118
|
+
import { FormRenderer } from '@fast-form-designer/vue'
|
|
119
|
+
import '@fast-form-designer/vue/style.css'
|
|
120
|
+
import type { FormSchema, FormElement } from '@fast-form-designer/vue'
|
|
121
|
+
|
|
122
|
+
const formSchema: FormSchema = {
|
|
123
|
+
config: {
|
|
124
|
+
labelPosition: 'right',
|
|
125
|
+
labelWidth: 100,
|
|
126
|
+
size: 'default',
|
|
127
|
+
},
|
|
128
|
+
list: [
|
|
129
|
+
{
|
|
130
|
+
id: 'name',
|
|
131
|
+
type: 'input',
|
|
132
|
+
props: {
|
|
133
|
+
label: '姓名',
|
|
134
|
+
field: 'name',
|
|
135
|
+
placeholder: '请输入姓名',
|
|
136
|
+
required: true,
|
|
137
|
+
clearable: true,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: 'gender',
|
|
142
|
+
type: 'radio',
|
|
143
|
+
props: {
|
|
144
|
+
label: '性别',
|
|
145
|
+
field: 'gender',
|
|
146
|
+
required: true,
|
|
147
|
+
optionsSource: 'static',
|
|
148
|
+
options: [
|
|
149
|
+
{ label: '男', value: 'male' },
|
|
150
|
+
{ label: '女', value: 'female' },
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const formData = ref({})
|
|
158
|
+
|
|
159
|
+
const rendererRef = ref<{
|
|
160
|
+
validate: () => Promise<boolean>
|
|
161
|
+
resetFields: () => void
|
|
162
|
+
} | null>(null)
|
|
163
|
+
|
|
164
|
+
const handleChange = (element: FormElement, data: Record<string, unknown>) => {
|
|
165
|
+
console.log('字段变更:', element, data)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const handleValidate = async () => {
|
|
169
|
+
try {
|
|
170
|
+
await rendererRef.value?.validate()
|
|
171
|
+
ElMessage.success('校验通过')
|
|
172
|
+
} catch {
|
|
173
|
+
ElMessage.error('校验失败')
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const handleReset = () => {
|
|
178
|
+
rendererRef.value?.resetFields()
|
|
179
|
+
}
|
|
180
|
+
</script>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## API 参考
|
|
184
|
+
|
|
185
|
+
### FastFormDesigner Props
|
|
186
|
+
|
|
187
|
+
| 属性名 | 类型 | 默认值 | 说明 |
|
|
188
|
+
| ----------------- | ------------------ | ------------ | ---------------------- |
|
|
189
|
+
| `componentGroups` | `ComponentGroup[]` | 内置组件列表 | 自定义左侧组件面板分组 |
|
|
190
|
+
| `toolbarActions` | `ToolbarAction[]` | 内置操作按钮 | 自定义顶部工具栏按钮 |
|
|
191
|
+
|
|
192
|
+
#### ToolbarAction 类型
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
interface ToolbarAction {
|
|
196
|
+
key: string // 唯一标识
|
|
197
|
+
label: string // 按钮文字
|
|
198
|
+
type?: 'primary' | 'success' | 'warning' | 'danger' | 'info'
|
|
199
|
+
link?: boolean // 是否为链接样式
|
|
200
|
+
disabled?: boolean // 是否禁用
|
|
201
|
+
visible?: boolean // 是否显示
|
|
202
|
+
onClick?: (ctx: DesignerActionContext) => void // 点击回调
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
interface DesignerActionContext {
|
|
206
|
+
schema: FormSchema // 当前表单 schema
|
|
207
|
+
formList: FormElement[] // 表单元素列表
|
|
208
|
+
formConfig: FormConfig // 表单全局配置
|
|
209
|
+
openPreview: () => void // 打开预览对话框
|
|
210
|
+
openImport: () => void // 打开导入对话框
|
|
211
|
+
exportJson: () => void // 导出 JSON 到剪贴板
|
|
212
|
+
clearCanvas: () => void // 清空画布
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### FormRenderer Props
|
|
217
|
+
|
|
218
|
+
| 属性名 | 类型 | 默认值 | 说明 |
|
|
219
|
+
| ------------ | --------------------- | ------- | ------------------------ |
|
|
220
|
+
| `schema` | `FormSchema` | 必填 | 表单结构定义 |
|
|
221
|
+
| `modelValue` | `Record<string, any>` | `{}` | 表单数据(支持 v-model) |
|
|
222
|
+
| `disabled` | `boolean` | `false` | 是否禁用整个表单 |
|
|
223
|
+
|
|
224
|
+
### FormRenderer Events
|
|
225
|
+
|
|
226
|
+
| 事件名 | 参数 | 说明 |
|
|
227
|
+
| ------------------- | ---------------------------------------------------- | -------------------- |
|
|
228
|
+
| `update:modelValue` | `(value: Record<string, any>)` | 表单数据更新时触发 |
|
|
229
|
+
| `change` | `(element: FormElement, value: Record<string, any>)` | 任意字段值变更时触发 |
|
|
230
|
+
|
|
231
|
+
### FormRenderer Expose
|
|
232
|
+
|
|
233
|
+
| 方法名 | 类型 | 说明 |
|
|
234
|
+
| ------------- | ------------------------ | ------------ |
|
|
235
|
+
| `validate` | `() => Promise<boolean>` | 触发表单校验 |
|
|
236
|
+
| `resetFields` | `() => void` | 重置表单字段 |
|
|
237
|
+
|
|
238
|
+
## 类型定义
|
|
239
|
+
|
|
240
|
+
### FormSchema
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
interface FormSchema {
|
|
244
|
+
config: FormConfig
|
|
245
|
+
list: FormElement[]
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### FormConfig
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
interface FormConfig {
|
|
253
|
+
labelPosition: 'left' | 'right' | 'top' // 标签位置
|
|
254
|
+
labelWidth: number // 标签宽度(px)
|
|
255
|
+
size: 'large' | 'default' | 'small' // 表单尺寸
|
|
256
|
+
visibilityRules?: FieldVisibilityRule[] // 字段显隐规则
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### FormElement
|
|
261
|
+
|
|
262
|
+
```typescript
|
|
263
|
+
interface FormElement {
|
|
264
|
+
id: string // 元素唯一标识
|
|
265
|
+
type: ComponentType // 组件类型
|
|
266
|
+
props: ComponentProps // 组件属性
|
|
267
|
+
children?: FormElement[] // 子元素(用于布局组件)
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### ComponentProps(常用属性)
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
interface ComponentProps {
|
|
275
|
+
label: string // 标签文字
|
|
276
|
+
field?: string // 数据字段名
|
|
277
|
+
defaultValue?: unknown // 默认值
|
|
278
|
+
placeholder?: string // 占位文字
|
|
279
|
+
description?: string // 提示信息(Tooltip)
|
|
280
|
+
width?: '25%' | '33.33%' | '50%' | '66.66%' | '75%' | '100%'
|
|
281
|
+
required?: boolean // 是否必填
|
|
282
|
+
disabled?: boolean // 是否禁用
|
|
283
|
+
clearable?: boolean // 是否可清空
|
|
284
|
+
rules?: ValidationRule[] // 校验规则
|
|
285
|
+
options?: OptionItem[] // 选项数据(选择类组件)
|
|
286
|
+
optionsSource?: 'static' | 'remote' // 选项数据来源
|
|
287
|
+
remoteOptions?: RemoteOptionsConfig // 远程选项配置
|
|
288
|
+
// ...更多组件特定属性
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### ValidationRule
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
interface ValidationRule {
|
|
296
|
+
type: 'required' | 'email' | 'phone' | 'url' | 'ip' | 'regexp'
|
|
297
|
+
message: string // 校验失败提示
|
|
298
|
+
pattern?: string // 正则表达式(type 为 regexp 时)
|
|
299
|
+
trigger: 'blur' | 'change'
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### FieldVisibilityRule(条件显隐)
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
interface FieldVisibilityRule {
|
|
307
|
+
id: string
|
|
308
|
+
logic: 'all' | 'any' // 条件逻辑:全部满足 / 任一满足
|
|
309
|
+
conditions: FieldVisibilityCondition[]
|
|
310
|
+
actions: FieldVisibilityAction[]
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
interface FieldVisibilityCondition {
|
|
314
|
+
id: string
|
|
315
|
+
field: string // 依赖的字段
|
|
316
|
+
operator: FieldVisibilityOperator // 比较操作符
|
|
317
|
+
value?: FieldVisibilityValue // 比较值
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
type FieldVisibilityOperator =
|
|
321
|
+
| 'eq'
|
|
322
|
+
| 'neq' // 等于 / 不等于
|
|
323
|
+
| 'gt'
|
|
324
|
+
| 'gte'
|
|
325
|
+
| 'lt'
|
|
326
|
+
| 'lte' // 大于 / 大于等于 / 小于 / 小于等于
|
|
327
|
+
| 'contains'
|
|
328
|
+
| 'not_contains' // 包含 / 不包含
|
|
329
|
+
| 'in'
|
|
330
|
+
| 'not_in' // 在列表中 / 不在列表中
|
|
331
|
+
| 'is_empty'
|
|
332
|
+
| 'not_empty' // 为空 / 不为空
|
|
333
|
+
|
|
334
|
+
interface FieldVisibilityAction {
|
|
335
|
+
id: string
|
|
336
|
+
field: string // 受控字段
|
|
337
|
+
action: 'show' | 'hide' // 显示 / 隐藏
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## 远程选项配置
|
|
342
|
+
|
|
343
|
+
对于 `select`、`radio`、`checkbox`、`cascader` 等选择类组件,支持从远程 API 加载选项数据。
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
interface RemoteOptionsConfig {
|
|
347
|
+
url: string // 请求地址
|
|
348
|
+
method: 'GET' | 'POST' // 请求方法
|
|
349
|
+
paramsJson?: string // 请求参数(JSON 字符串)
|
|
350
|
+
headersJson?: string // 请求头(JSON 字符串)
|
|
351
|
+
dataPath?: string // 数据路径(如 'data.list')
|
|
352
|
+
labelKey: string // 选项文本字段名
|
|
353
|
+
valueKey: string // 选项值字段名
|
|
354
|
+
childrenKey?: string // 子选项字段名(级联选择)
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
## 主题定制
|
|
359
|
+
|
|
360
|
+
组件使用 CSS 变量实现主题定制,可通过覆盖以下变量自定义样式:
|
|
361
|
+
|
|
362
|
+
```css
|
|
363
|
+
:root {
|
|
364
|
+
--ffd-primary: var(--el-color-primary);
|
|
365
|
+
--ffd-primary-hover: var(--el-color-primary-light-3);
|
|
366
|
+
--ffd-primary-light: var(--el-color-primary-light-9);
|
|
367
|
+
--ffd-danger: var(--el-color-danger);
|
|
368
|
+
--ffd-danger-light: var(--el-color-danger-light-5);
|
|
369
|
+
--ffd-border: var(--el-border-color);
|
|
370
|
+
--ffd-border-light: var(--el-border-color-lighter);
|
|
371
|
+
--ffd-text: var(--el-text-color-primary);
|
|
372
|
+
--ffd-text-secondary: var(--el-text-color-regular);
|
|
373
|
+
--ffd-text-tertiary: var(--el-text-color-secondary);
|
|
374
|
+
--ffd-bg: var(--el-bg-color);
|
|
375
|
+
--ffd-panel-bg: var(--el-bg-color);
|
|
376
|
+
--ffd-canvas-bg: var(--el-fill-color-lighter);
|
|
377
|
+
--ffd-hover-bg: var(--el-fill-color-light);
|
|
378
|
+
--ffd-muted-bg: var(--el-fill-color-light);
|
|
379
|
+
--ffd-drag-bg: #c8ebfb;
|
|
380
|
+
--ffd-empty-text: var(--el-text-color-placeholder);
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## 开发
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
# 安装依赖
|
|
388
|
+
pnpm install
|
|
389
|
+
|
|
390
|
+
# 启动开发服务器
|
|
391
|
+
pnpm dev
|
|
392
|
+
|
|
393
|
+
# 类型检查
|
|
394
|
+
pnpm type-check
|
|
395
|
+
|
|
396
|
+
# 代码检查与修复
|
|
397
|
+
pnpm lint
|
|
398
|
+
|
|
399
|
+
# 格式化代码
|
|
400
|
+
pnpm format
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
## 构建
|
|
404
|
+
|
|
405
|
+
```bash
|
|
406
|
+
# 构建库(生成 dist 目录)
|
|
407
|
+
pnpm build
|
|
408
|
+
|
|
409
|
+
# 仅构建类型声明
|
|
410
|
+
pnpm build:types
|
|
411
|
+
|
|
412
|
+
# 仅构建打包产物
|
|
413
|
+
pnpm build:bundles
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
[MIT](./LICENSE)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ComponentGroup } from './config/component-list';
|
|
2
|
+
import type { FormConfig, FormElement, FormSchema } from './types';
|
|
3
|
+
type ToolbarAction = {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
type?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
|
|
7
|
+
link?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
visible?: boolean;
|
|
10
|
+
onClick?: (ctx: DesignerActionContext) => void;
|
|
11
|
+
};
|
|
12
|
+
type DesignerActionContext = {
|
|
13
|
+
schema: FormSchema;
|
|
14
|
+
formList: FormElement[];
|
|
15
|
+
formConfig: FormConfig;
|
|
16
|
+
openPreview: () => void;
|
|
17
|
+
openImport: () => void;
|
|
18
|
+
exportJson: () => void;
|
|
19
|
+
clearCanvas: () => void;
|
|
20
|
+
};
|
|
21
|
+
type __VLS_Props = {
|
|
22
|
+
componentGroups?: ComponentGroup[];
|
|
23
|
+
toolbarActions?: ToolbarAction[];
|
|
24
|
+
};
|
|
25
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
26
|
+
declare const _default: typeof __VLS_export;
|
|
27
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FormElement } from '../types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
element: FormElement;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
6
|
+
"init-grid": (payload: {
|
|
7
|
+
gridId: string;
|
|
8
|
+
legacyChildren: FormElement[];
|
|
9
|
+
}) => any;
|
|
10
|
+
"update-children": (payload: {
|
|
11
|
+
id: string;
|
|
12
|
+
children: FormElement[];
|
|
13
|
+
}) => any;
|
|
14
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
15
|
+
"onInit-grid"?: ((payload: {
|
|
16
|
+
gridId: string;
|
|
17
|
+
legacyChildren: FormElement[];
|
|
18
|
+
}) => any) | undefined;
|
|
19
|
+
"onUpdate-children"?: ((payload: {
|
|
20
|
+
id: string;
|
|
21
|
+
children: FormElement[];
|
|
22
|
+
}) => any) | undefined;
|
|
23
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
|
+
declare const _default: typeof __VLS_export;
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { UploadUserFile } from 'element-plus';
|
|
2
|
+
import type { FormElement, FormSchema } from '../types';
|
|
3
|
+
type FormModelValue = string | number | boolean | Array<string | number> | Array<Array<string | number>> | Array<Record<string, unknown>> | UploadUserFile[] | null | undefined;
|
|
4
|
+
type FormModel = Record<string, FormModelValue>;
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
schema: FormSchema;
|
|
7
|
+
modelValue?: FormModel;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
11
|
+
validate: () => import("element-plus").FormValidationResult | undefined;
|
|
12
|
+
resetFields: () => void | undefined;
|
|
13
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
14
|
+
change: (element: FormElement, value: FormModel) => any;
|
|
15
|
+
"update:modelValue": (value: FormModel) => any;
|
|
16
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
17
|
+
onChange?: ((element: FormElement, value: FormModel) => any) | undefined;
|
|
18
|
+
"onUpdate:modelValue"?: ((value: FormModel) => any) | undefined;
|
|
19
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
20
|
+
declare const _default: typeof __VLS_export;
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { UploadUserFile } from 'element-plus';
|
|
2
|
+
import type { FormElement } from '../types';
|
|
3
|
+
type FormModelValue = string | number | boolean | Array<string | number> | Array<Array<string | number>> | Array<Record<string, unknown>> | UploadUserFile[] | null | undefined;
|
|
4
|
+
type FormModel = Record<string, FormModelValue>;
|
|
5
|
+
type UpdateFieldPayload = {
|
|
6
|
+
element: FormElement;
|
|
7
|
+
key: string;
|
|
8
|
+
value: FormModelValue;
|
|
9
|
+
};
|
|
10
|
+
type __VLS_Props = {
|
|
11
|
+
element: FormElement;
|
|
12
|
+
model: FormModel;
|
|
13
|
+
hideLabel?: boolean;
|
|
14
|
+
formDisabled?: boolean;
|
|
15
|
+
visibleMap?: Record<string, boolean>;
|
|
16
|
+
};
|
|
17
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
18
|
+
"update-field": (payload: UpdateFieldPayload) => any;
|
|
19
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
20
|
+
"onUpdate-field"?: ((payload: UpdateFieldPayload) => any) | undefined;
|
|
21
|
+
}>, {
|
|
22
|
+
hideLabel: boolean;
|
|
23
|
+
formDisabled: boolean;
|
|
24
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
|
+
declare const _default: typeof __VLS_export;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ComponentGroup } from '../config/component-list';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
componentGroups?: ComponentGroup[];
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
modelValue?: string | null;
|
|
3
|
+
height?: number;
|
|
4
|
+
width?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
clearable?: boolean;
|
|
7
|
+
lineWidth?: number;
|
|
8
|
+
penColor?: string;
|
|
9
|
+
backgroundColor?: string;
|
|
10
|
+
outputType?: 'png' | 'jpeg';
|
|
11
|
+
quality?: number;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
14
|
+
"update:modelValue": (value: string | null) => any;
|
|
15
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
16
|
+
"onUpdate:modelValue"?: ((value: string | null) => any) | undefined;
|
|
17
|
+
}>, {
|
|
18
|
+
width: string;
|
|
19
|
+
clearable: boolean;
|
|
20
|
+
disabled: boolean;
|
|
21
|
+
height: number;
|
|
22
|
+
lineWidth: number;
|
|
23
|
+
penColor: string;
|
|
24
|
+
backgroundColor: string;
|
|
25
|
+
outputType: "png" | "jpeg";
|
|
26
|
+
quality: number;
|
|
27
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const _default: typeof __VLS_export;
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FieldVisibilityRule, OptionValue } from '../types';
|
|
2
|
+
type FieldOption = {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
kind: 'string' | 'number' | 'boolean' | 'array';
|
|
6
|
+
componentType: string;
|
|
7
|
+
options?: OptionValue[];
|
|
8
|
+
};
|
|
9
|
+
type __VLS_Props = {
|
|
10
|
+
modelValue: boolean;
|
|
11
|
+
rules: FieldVisibilityRule[];
|
|
12
|
+
fieldOptions: FieldOption[];
|
|
13
|
+
};
|
|
14
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
15
|
+
"update:modelValue": (v: boolean) => any;
|
|
16
|
+
save: (rules: FieldVisibilityRule[]) => any;
|
|
17
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
18
|
+
"onUpdate:modelValue"?: ((v: boolean) => any) | undefined;
|
|
19
|
+
onSave?: ((rules: FieldVisibilityRule[]) => any) | undefined;
|
|
20
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
|
+
declare const _default: typeof __VLS_export;
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type InjectionKey, type Ref, type ComputedRef } from 'vue';
|
|
2
|
+
import type { FormElement, FormConfig } from '../types';
|
|
3
|
+
export interface DesignerContext {
|
|
4
|
+
formList: FormElement[];
|
|
5
|
+
formConfig: FormConfig;
|
|
6
|
+
selectedId: Ref<string | undefined>;
|
|
7
|
+
selectedComponent: ComputedRef<FormElement | undefined>;
|
|
8
|
+
setSelected: (id: string | undefined) => void;
|
|
9
|
+
deleteComponent: (id: string) => void;
|
|
10
|
+
duplicateComponent: (id: string) => void;
|
|
11
|
+
clearCanvas: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const DesignerKey: InjectionKey<DesignerContext>;
|
|
14
|
+
export declare function useDesignerProvider(): DesignerContext;
|
|
15
|
+
export declare function useDesigner(): DesignerContext;
|
package/dist/index.d.ts
ADDED