@aspire-ui/element-component-pro 1.0.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/README.md +203 -0
- package/dist/ProForm/FormActions.vue.d.ts +98 -0
- package/dist/ProForm/ProForm.vue.d.ts +223 -0
- package/dist/ProForm/ProFormItem.vue.d.ts +39 -0
- package/dist/ProForm/index.d.ts +7 -0
- package/dist/ProForm/useForm.d.ts +28 -0
- package/dist/element-component-pro.es.js +444 -0
- package/dist/element-component-pro.es.js.map +1 -0
- package/dist/element-component-pro.umd.js +3 -0
- package/dist/element-component-pro.umd.js.map +1 -0
- package/dist/index.d.ts +769 -0
- package/dist/style.css +1 -0
- package/dist/types/index.d.ts +178 -0
- package/package.json +49 -0
- package/src/ProForm/FormActions.vue +76 -0
- package/src/ProForm/ProForm.vue +423 -0
- package/src/ProForm/ProFormItem.vue +250 -0
- package/src/ProForm/index.ts +6 -0
- package/src/ProForm/useForm.ts +114 -0
- package/src/index.ts +32 -0
- package/src/shims-vue.d.ts +5 -0
- package/src/types/index.ts +179 -0
- package/src/vite-env.d.ts +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# Element Component Pro
|
|
2
|
+
|
|
3
|
+
基于 Element UI 的二次封装组件库,参考 VbenAdmin 的 Ant Design 版本,提供 Pro 系列增强组件。
|
|
4
|
+
|
|
5
|
+
## 技术栈
|
|
6
|
+
|
|
7
|
+
- **Vue 2.7** - 支持 Composition API 和 `<script setup>` 语法糖
|
|
8
|
+
- **TypeScript** - 完整类型支持
|
|
9
|
+
- **Element UI** - 基础 UI 组件
|
|
10
|
+
|
|
11
|
+
## 组件列表
|
|
12
|
+
|
|
13
|
+
| 组件 | 说明 |
|
|
14
|
+
|------|------|
|
|
15
|
+
| ProTable | 增强表格,集成搜索、工具栏、分页 |
|
|
16
|
+
| ProForm | Schema 驱动的表单,支持栅格布局 |
|
|
17
|
+
| ProCard | 卡片容器 |
|
|
18
|
+
| ProDescriptions | 详情描述列表 |
|
|
19
|
+
|
|
20
|
+
## 安装
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install element-component-pro element-ui vue
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 使用
|
|
27
|
+
|
|
28
|
+
### 全局注册
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import Vue from 'vue'
|
|
32
|
+
import ElementUI from 'element-ui'
|
|
33
|
+
import 'element-ui/lib/theme-chalk/index.css'
|
|
34
|
+
import ElementComponentPro from 'element-component-pro'
|
|
35
|
+
|
|
36
|
+
Vue.use(ElementUI)
|
|
37
|
+
Vue.use(ElementComponentPro)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 按需引入
|
|
41
|
+
|
|
42
|
+
```vue
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
import { ProTable, ProForm } from 'element-component-pro'
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<ProTable :columns="columns" :request="fetchData" />
|
|
49
|
+
</template>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## ProTable
|
|
53
|
+
|
|
54
|
+
```vue
|
|
55
|
+
<template>
|
|
56
|
+
<ProTable
|
|
57
|
+
ref="tableRef"
|
|
58
|
+
:columns="columns"
|
|
59
|
+
:request="fetchTableData"
|
|
60
|
+
show-search
|
|
61
|
+
show-tool-bar
|
|
62
|
+
show-pagination
|
|
63
|
+
/>
|
|
64
|
+
</template>
|
|
65
|
+
|
|
66
|
+
<script setup lang="ts">
|
|
67
|
+
import { ref } from 'vue'
|
|
68
|
+
import { ProTable } from 'element-component-pro'
|
|
69
|
+
import type { ProColumn } from 'element-component-pro'
|
|
70
|
+
|
|
71
|
+
const columns: ProColumn[] = [
|
|
72
|
+
{ title: 'ID', dataIndex: 'id', width: 80, valueType: 'index' },
|
|
73
|
+
{ title: '姓名', dataIndex: 'name', width: 120 },
|
|
74
|
+
{
|
|
75
|
+
title: '状态',
|
|
76
|
+
dataIndex: 'status',
|
|
77
|
+
valueType: 'select',
|
|
78
|
+
valueEnum: { 1: { text: '启用' }, 0: { text: '禁用' } },
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
const fetchTableData = async (params) => {
|
|
83
|
+
const res = await api.getList(params)
|
|
84
|
+
return { data: res.list, total: res.total }
|
|
85
|
+
}
|
|
86
|
+
</script>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## ProForm
|
|
90
|
+
|
|
91
|
+
参考 [Vben Admin Form](https://doc.vvbin.cn/components/form.html),支持 Schema 驱动、useForm、render/slot、动态显示等。
|
|
92
|
+
|
|
93
|
+
### 基础用法
|
|
94
|
+
|
|
95
|
+
```vue
|
|
96
|
+
<template>
|
|
97
|
+
<ProForm
|
|
98
|
+
:schemas="schemas"
|
|
99
|
+
:initial-values="{ name: '' }"
|
|
100
|
+
:base-col-props="{ span: 8 }"
|
|
101
|
+
@submit="handleSubmit"
|
|
102
|
+
/>
|
|
103
|
+
</template>
|
|
104
|
+
|
|
105
|
+
<script setup lang="ts">
|
|
106
|
+
import { ProForm } from 'element-component-pro'
|
|
107
|
+
import type { ProFormSchema } from 'element-component-pro'
|
|
108
|
+
|
|
109
|
+
const schemas: ProFormSchema[] = [
|
|
110
|
+
{ field: 'name', label: '姓名', component: 'input', required: true, colProps: { span: 8 } },
|
|
111
|
+
{
|
|
112
|
+
field: 'status',
|
|
113
|
+
label: '状态',
|
|
114
|
+
component: 'select',
|
|
115
|
+
componentProps: {
|
|
116
|
+
options: [
|
|
117
|
+
{ label: '启用', value: 1 },
|
|
118
|
+
{ label: '禁用', value: 0 },
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
colProps: { span: 8 },
|
|
122
|
+
},
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
const handleSubmit = (values) => {
|
|
126
|
+
console.log(values)
|
|
127
|
+
}
|
|
128
|
+
</script>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### useForm 方式(参考 Vben Admin)
|
|
132
|
+
|
|
133
|
+
```vue
|
|
134
|
+
<template>
|
|
135
|
+
<ProForm @register="register" @submit="handleSubmit" />
|
|
136
|
+
</template>
|
|
137
|
+
|
|
138
|
+
<script setup lang="ts">
|
|
139
|
+
import { ProForm, useForm } from 'element-component-pro'
|
|
140
|
+
|
|
141
|
+
const [register, formActions] = useForm({
|
|
142
|
+
schemas: [...],
|
|
143
|
+
labelWidth: '120px',
|
|
144
|
+
actionColOptions: { span: 24 },
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
// 支持 ref/computed 响应式 props
|
|
148
|
+
const formProps = ref({ schemas: [...] })
|
|
149
|
+
const [register2] = useForm(formProps)
|
|
150
|
+
|
|
151
|
+
const handleSubmit = (values) => {
|
|
152
|
+
console.log(values)
|
|
153
|
+
}
|
|
154
|
+
</script>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**useForm 方法(与 Vben Admin 对齐):**
|
|
158
|
+
|
|
159
|
+
| 方法 | 说明 |
|
|
160
|
+
|------|------|
|
|
161
|
+
| getFieldsValue | 获取表单值 |
|
|
162
|
+
| setFieldsValue | 设置表单字段值 |
|
|
163
|
+
| resetFields | 重置表单 |
|
|
164
|
+
| validate | 校验整个表单 |
|
|
165
|
+
| validateFields | 校验指定表单项 |
|
|
166
|
+
| submit | 提交表单 |
|
|
167
|
+
| scrollToField | 滚动到对应字段 |
|
|
168
|
+
| clearValidate | 清空校验 |
|
|
169
|
+
| updateSchema | 更新 schema |
|
|
170
|
+
| appendSchemaByField | 插入 schema |
|
|
171
|
+
| removeSchemaByField | 删除 schema |
|
|
172
|
+
| setProps | 设置表单 Props |
|
|
173
|
+
|
|
174
|
+
### Schema 高级特性
|
|
175
|
+
|
|
176
|
+
- **render**: 自定义渲染
|
|
177
|
+
- **slot**: 使用具名插槽自定义
|
|
178
|
+
- **ifShow** / **show**: 动态显示(ifShow 不渲染 DOM)
|
|
179
|
+
- **dynamicDisabled**: 动态禁用
|
|
180
|
+
- **dynamicRules**: 动态校验规则
|
|
181
|
+
- **componentProps**: 支持函数,可获取 formModel、formActionType
|
|
182
|
+
|
|
183
|
+
## 示例与文档
|
|
184
|
+
|
|
185
|
+
- **示例**:运行 `npm run dev` 后访问开发预览,包含 ProForm 基础、useForm、高级特性等示例
|
|
186
|
+
- **ProForm 文档**:[docs/ProForm.md](./docs/ProForm.md)
|
|
187
|
+
|
|
188
|
+
## 开发
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# 安装依赖
|
|
192
|
+
npm install
|
|
193
|
+
|
|
194
|
+
# 开发预览
|
|
195
|
+
npm run dev
|
|
196
|
+
|
|
197
|
+
# 构建
|
|
198
|
+
npm run build
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
MIT
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ColEx } from '../types';
|
|
2
|
+
|
|
3
|
+
declare function __VLS_template(): {
|
|
4
|
+
submitBefore?(_: {}): any;
|
|
5
|
+
resetBefore?(_: {}): any;
|
|
6
|
+
actions?(_: {}): any;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
9
|
+
showActionButtonGroup?: boolean;
|
|
10
|
+
showSubmitButton?: boolean;
|
|
11
|
+
showResetButton?: boolean;
|
|
12
|
+
submitButtonText?: string;
|
|
13
|
+
resetButtonText?: string;
|
|
14
|
+
submitButtonIcon?: string;
|
|
15
|
+
resetButtonIcon?: string;
|
|
16
|
+
submitLoading?: boolean;
|
|
17
|
+
showAdvancedButton?: boolean;
|
|
18
|
+
hasMoreFields?: boolean;
|
|
19
|
+
collapsed?: boolean;
|
|
20
|
+
actionColOptions?: ColEx;
|
|
21
|
+
}>, {
|
|
22
|
+
showActionButtonGroup: boolean;
|
|
23
|
+
showSubmitButton: boolean;
|
|
24
|
+
showResetButton: boolean;
|
|
25
|
+
submitButtonText: string;
|
|
26
|
+
resetButtonText: string;
|
|
27
|
+
submitButtonIcon: string;
|
|
28
|
+
resetButtonIcon: string;
|
|
29
|
+
submitLoading: boolean;
|
|
30
|
+
showAdvancedButton: boolean;
|
|
31
|
+
hasMoreFields: boolean;
|
|
32
|
+
collapsed: boolean;
|
|
33
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
34
|
+
submit: () => void;
|
|
35
|
+
reset: () => void;
|
|
36
|
+
toggle: () => void;
|
|
37
|
+
}, string, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
38
|
+
showActionButtonGroup?: boolean;
|
|
39
|
+
showSubmitButton?: boolean;
|
|
40
|
+
showResetButton?: boolean;
|
|
41
|
+
submitButtonText?: string;
|
|
42
|
+
resetButtonText?: string;
|
|
43
|
+
submitButtonIcon?: string;
|
|
44
|
+
resetButtonIcon?: string;
|
|
45
|
+
submitLoading?: boolean;
|
|
46
|
+
showAdvancedButton?: boolean;
|
|
47
|
+
hasMoreFields?: boolean;
|
|
48
|
+
collapsed?: boolean;
|
|
49
|
+
actionColOptions?: ColEx;
|
|
50
|
+
}>, {
|
|
51
|
+
showActionButtonGroup: boolean;
|
|
52
|
+
showSubmitButton: boolean;
|
|
53
|
+
showResetButton: boolean;
|
|
54
|
+
submitButtonText: string;
|
|
55
|
+
resetButtonText: string;
|
|
56
|
+
submitButtonIcon: string;
|
|
57
|
+
resetButtonIcon: string;
|
|
58
|
+
submitLoading: boolean;
|
|
59
|
+
showAdvancedButton: boolean;
|
|
60
|
+
hasMoreFields: boolean;
|
|
61
|
+
collapsed: boolean;
|
|
62
|
+
}>>>, {
|
|
63
|
+
showActionButtonGroup: boolean;
|
|
64
|
+
showSubmitButton: boolean;
|
|
65
|
+
showResetButton: boolean;
|
|
66
|
+
submitButtonText: string;
|
|
67
|
+
resetButtonText: string;
|
|
68
|
+
submitButtonIcon: string;
|
|
69
|
+
resetButtonIcon: string;
|
|
70
|
+
submitLoading: boolean;
|
|
71
|
+
showAdvancedButton: boolean;
|
|
72
|
+
hasMoreFields: boolean;
|
|
73
|
+
collapsed: boolean;
|
|
74
|
+
}>;
|
|
75
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
76
|
+
export default _default;
|
|
77
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
78
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
79
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
80
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
81
|
+
} : {
|
|
82
|
+
type: import('vue').PropType<T[K]>;
|
|
83
|
+
required: true;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
type __VLS_WithDefaults<P, D> = {
|
|
87
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
88
|
+
default: D[K];
|
|
89
|
+
}> : P[K];
|
|
90
|
+
};
|
|
91
|
+
type __VLS_Prettify<T> = {
|
|
92
|
+
[K in keyof T]: T[K];
|
|
93
|
+
} & {};
|
|
94
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
95
|
+
new (): {
|
|
96
|
+
$scopedSlots: S;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { ProFormSchema, ProFormProps, FormActionType, ColEx, ScrollToFieldOptions, FormListeners } from '../types';
|
|
2
|
+
|
|
3
|
+
declare function __VLS_template(): Partial<Record<string, (_: {
|
|
4
|
+
model: Record<string, unknown>;
|
|
5
|
+
schema: {
|
|
6
|
+
field: string;
|
|
7
|
+
label: string;
|
|
8
|
+
component?: "input" | "select" | "date-picker" | "date-range" | "input-number" | "switch" | "cascader" | "checkbox" | "radio" | undefined;
|
|
9
|
+
componentProps?: (Record<string, unknown> | ((params: import('..').RenderCallbackParams & {
|
|
10
|
+
formActionType?: FormActionType;
|
|
11
|
+
}) => Record<string, unknown>)) | undefined;
|
|
12
|
+
placeholder?: string | undefined;
|
|
13
|
+
defaultValue?: unknown;
|
|
14
|
+
required?: boolean | undefined;
|
|
15
|
+
rules?: Array<Record<string, unknown>> | undefined;
|
|
16
|
+
colProps?: {
|
|
17
|
+
span?: number | undefined;
|
|
18
|
+
offset?: number | undefined;
|
|
19
|
+
pull?: number | undefined;
|
|
20
|
+
push?: number | undefined;
|
|
21
|
+
xs?: number | undefined;
|
|
22
|
+
sm?: number | undefined;
|
|
23
|
+
md?: number | undefined;
|
|
24
|
+
lg?: number | undefined;
|
|
25
|
+
xl?: number | undefined;
|
|
26
|
+
} | undefined;
|
|
27
|
+
hidden?: boolean | undefined;
|
|
28
|
+
render?: ((params: import('..').RenderCallbackParams) => import('vue').VNode | import('vue').VNode[] | string) | undefined;
|
|
29
|
+
slot?: string | undefined;
|
|
30
|
+
show?: boolean | ((params: import('..').RenderCallbackParams) => boolean) | undefined;
|
|
31
|
+
ifShow?: boolean | ((params: import('..').RenderCallbackParams) => boolean) | undefined;
|
|
32
|
+
dynamicDisabled?: boolean | ((params: import('..').RenderCallbackParams) => boolean) | undefined;
|
|
33
|
+
dynamicRules?: (Array<Record<string, unknown>> | ((params: import('..').RenderCallbackParams) => Array<Record<string, unknown>>)) | undefined;
|
|
34
|
+
dependencies?: string[] | undefined;
|
|
35
|
+
helpMessage?: string | string[] | undefined;
|
|
36
|
+
helpComponentProps?: Record<string, unknown> | undefined;
|
|
37
|
+
};
|
|
38
|
+
field: string;
|
|
39
|
+
values: Record<string, unknown>;
|
|
40
|
+
}) => any>> & {
|
|
41
|
+
formHeader?(_: {}): any;
|
|
42
|
+
submitBefore?(_: {}): any;
|
|
43
|
+
resetBefore?(_: {}): any;
|
|
44
|
+
advanceBefore?(_: {}): any;
|
|
45
|
+
advanceAfter?(_: {}): any;
|
|
46
|
+
actions?(_: {}): any;
|
|
47
|
+
formFooter?(_: {}): any;
|
|
48
|
+
};
|
|
49
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
50
|
+
schemas?: ProFormSchema[];
|
|
51
|
+
initialValues?: Record<string, unknown>;
|
|
52
|
+
labelWidth?: string;
|
|
53
|
+
labelPosition?: "left" | "right" | "top";
|
|
54
|
+
gutter?: number;
|
|
55
|
+
size?: "medium" | "small" | "large";
|
|
56
|
+
disabled?: boolean;
|
|
57
|
+
baseColProps?: ColEx;
|
|
58
|
+
baseRowStyle?: Record<string, string | number>;
|
|
59
|
+
autoSetPlaceholder?: boolean;
|
|
60
|
+
showSubmitButton?: boolean;
|
|
61
|
+
showResetButton?: boolean;
|
|
62
|
+
submitButtonText?: string;
|
|
63
|
+
resetButtonText?: string;
|
|
64
|
+
submitButtonIcon?: string;
|
|
65
|
+
resetButtonIcon?: string;
|
|
66
|
+
showActionButtonGroup?: boolean;
|
|
67
|
+
actionColOptions?: ColEx;
|
|
68
|
+
showAdvancedButton?: boolean;
|
|
69
|
+
autoAdvancedLine?: number;
|
|
70
|
+
alwaysShowLines?: number;
|
|
71
|
+
submitFunc?: () => Promise<void>;
|
|
72
|
+
resetFunc?: () => Promise<void>;
|
|
73
|
+
submitOnReset?: boolean;
|
|
74
|
+
formListeners?: FormListeners;
|
|
75
|
+
}>, {
|
|
76
|
+
labelWidth: string;
|
|
77
|
+
labelPosition: string;
|
|
78
|
+
gutter: number;
|
|
79
|
+
size: string;
|
|
80
|
+
autoSetPlaceholder: boolean;
|
|
81
|
+
showSubmitButton: boolean;
|
|
82
|
+
showResetButton: boolean;
|
|
83
|
+
submitButtonText: string;
|
|
84
|
+
resetButtonText: string;
|
|
85
|
+
submitButtonIcon: string;
|
|
86
|
+
resetButtonIcon: string;
|
|
87
|
+
showActionButtonGroup: boolean;
|
|
88
|
+
showAdvancedButton: boolean;
|
|
89
|
+
autoAdvancedLine: number;
|
|
90
|
+
alwaysShowLines: number;
|
|
91
|
+
baseColProps: () => {
|
|
92
|
+
xs: number;
|
|
93
|
+
sm: number;
|
|
94
|
+
md: number;
|
|
95
|
+
lg: number;
|
|
96
|
+
xl: number;
|
|
97
|
+
};
|
|
98
|
+
actionColOptions: () => {
|
|
99
|
+
xs: number;
|
|
100
|
+
sm: number;
|
|
101
|
+
md: number;
|
|
102
|
+
lg: number;
|
|
103
|
+
xl: number;
|
|
104
|
+
};
|
|
105
|
+
submitOnReset: boolean;
|
|
106
|
+
}>, {
|
|
107
|
+
getFieldsValue: () => Record<string, unknown>;
|
|
108
|
+
setFieldsValue: (values: Record<string, unknown>) => Promise<void>;
|
|
109
|
+
resetFields: () => Promise<void>;
|
|
110
|
+
validate: (nameList?: string[]) => Promise<unknown>;
|
|
111
|
+
validateFields: (nameList?: string[]) => Promise<unknown>;
|
|
112
|
+
submit: () => Promise<void>;
|
|
113
|
+
scrollToField: (name: string, options?: ScrollToFieldOptions) => Promise<void>;
|
|
114
|
+
clearValidate: (name?: string | string[]) => void;
|
|
115
|
+
updateSchema: (data: Partial<ProFormSchema> | Partial<ProFormSchema>[]) => Promise<void>;
|
|
116
|
+
appendSchemaByField: (schema: ProFormSchema, prefixField?: string, first?: boolean) => Promise<void>;
|
|
117
|
+
removeSchemaByField: (field: string | string[]) => Promise<void>;
|
|
118
|
+
setProps: (props: Partial<ProFormProps>) => Promise<void>;
|
|
119
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
120
|
+
submit: (values: Record<string, unknown>) => void;
|
|
121
|
+
reset: () => void;
|
|
122
|
+
register: (formAction: FormActionType) => void;
|
|
123
|
+
}, string, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
124
|
+
schemas?: ProFormSchema[];
|
|
125
|
+
initialValues?: Record<string, unknown>;
|
|
126
|
+
labelWidth?: string;
|
|
127
|
+
labelPosition?: "left" | "right" | "top";
|
|
128
|
+
gutter?: number;
|
|
129
|
+
size?: "medium" | "small" | "large";
|
|
130
|
+
disabled?: boolean;
|
|
131
|
+
baseColProps?: ColEx;
|
|
132
|
+
baseRowStyle?: Record<string, string | number>;
|
|
133
|
+
autoSetPlaceholder?: boolean;
|
|
134
|
+
showSubmitButton?: boolean;
|
|
135
|
+
showResetButton?: boolean;
|
|
136
|
+
submitButtonText?: string;
|
|
137
|
+
resetButtonText?: string;
|
|
138
|
+
submitButtonIcon?: string;
|
|
139
|
+
resetButtonIcon?: string;
|
|
140
|
+
showActionButtonGroup?: boolean;
|
|
141
|
+
actionColOptions?: ColEx;
|
|
142
|
+
showAdvancedButton?: boolean;
|
|
143
|
+
autoAdvancedLine?: number;
|
|
144
|
+
alwaysShowLines?: number;
|
|
145
|
+
submitFunc?: () => Promise<void>;
|
|
146
|
+
resetFunc?: () => Promise<void>;
|
|
147
|
+
submitOnReset?: boolean;
|
|
148
|
+
formListeners?: FormListeners;
|
|
149
|
+
}>, {
|
|
150
|
+
labelWidth: string;
|
|
151
|
+
labelPosition: string;
|
|
152
|
+
gutter: number;
|
|
153
|
+
size: string;
|
|
154
|
+
autoSetPlaceholder: boolean;
|
|
155
|
+
showSubmitButton: boolean;
|
|
156
|
+
showResetButton: boolean;
|
|
157
|
+
submitButtonText: string;
|
|
158
|
+
resetButtonText: string;
|
|
159
|
+
submitButtonIcon: string;
|
|
160
|
+
resetButtonIcon: string;
|
|
161
|
+
showActionButtonGroup: boolean;
|
|
162
|
+
showAdvancedButton: boolean;
|
|
163
|
+
autoAdvancedLine: number;
|
|
164
|
+
alwaysShowLines: number;
|
|
165
|
+
baseColProps: () => {
|
|
166
|
+
xs: number;
|
|
167
|
+
sm: number;
|
|
168
|
+
md: number;
|
|
169
|
+
lg: number;
|
|
170
|
+
xl: number;
|
|
171
|
+
};
|
|
172
|
+
actionColOptions: () => {
|
|
173
|
+
xs: number;
|
|
174
|
+
sm: number;
|
|
175
|
+
md: number;
|
|
176
|
+
lg: number;
|
|
177
|
+
xl: number;
|
|
178
|
+
};
|
|
179
|
+
submitOnReset: boolean;
|
|
180
|
+
}>>>, {
|
|
181
|
+
showActionButtonGroup: boolean;
|
|
182
|
+
showSubmitButton: boolean;
|
|
183
|
+
showResetButton: boolean;
|
|
184
|
+
submitButtonText: string;
|
|
185
|
+
resetButtonText: string;
|
|
186
|
+
submitButtonIcon: string;
|
|
187
|
+
resetButtonIcon: string;
|
|
188
|
+
showAdvancedButton: boolean;
|
|
189
|
+
actionColOptions: ColEx;
|
|
190
|
+
labelWidth: string;
|
|
191
|
+
labelPosition: "left" | "right" | "top";
|
|
192
|
+
gutter: number;
|
|
193
|
+
size: "medium" | "small" | "large";
|
|
194
|
+
baseColProps: ColEx;
|
|
195
|
+
autoSetPlaceholder: boolean;
|
|
196
|
+
autoAdvancedLine: number;
|
|
197
|
+
alwaysShowLines: number;
|
|
198
|
+
submitOnReset: boolean;
|
|
199
|
+
}>;
|
|
200
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
201
|
+
export default _default;
|
|
202
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
203
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
204
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
205
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
206
|
+
} : {
|
|
207
|
+
type: import('vue').PropType<T[K]>;
|
|
208
|
+
required: true;
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
type __VLS_WithDefaults<P, D> = {
|
|
212
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
213
|
+
default: D[K];
|
|
214
|
+
}> : P[K];
|
|
215
|
+
};
|
|
216
|
+
type __VLS_Prettify<T> = {
|
|
217
|
+
[K in keyof T]: T[K];
|
|
218
|
+
} & {};
|
|
219
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
220
|
+
new (): {
|
|
221
|
+
$scopedSlots: S;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ProFormSchema } from '../types';
|
|
2
|
+
|
|
3
|
+
declare function __VLS_template(): {
|
|
4
|
+
default?(_: {
|
|
5
|
+
model: Record<string, unknown>;
|
|
6
|
+
schema: ProFormSchema;
|
|
7
|
+
field: string;
|
|
8
|
+
values: Record<string, unknown>;
|
|
9
|
+
}): any;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
12
|
+
schema: ProFormSchema;
|
|
13
|
+
formModel: Record<string, unknown>;
|
|
14
|
+
formDisabled?: boolean;
|
|
15
|
+
autoPlaceholder?: boolean;
|
|
16
|
+
formActionType?: import('../types').FormActionType;
|
|
17
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
18
|
+
schema: ProFormSchema;
|
|
19
|
+
formModel: Record<string, unknown>;
|
|
20
|
+
formDisabled?: boolean;
|
|
21
|
+
autoPlaceholder?: boolean;
|
|
22
|
+
formActionType?: import('../types').FormActionType;
|
|
23
|
+
}>>>, {}>;
|
|
24
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
25
|
+
export default _default;
|
|
26
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
27
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
28
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
29
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
30
|
+
} : {
|
|
31
|
+
type: import('vue').PropType<T[K]>;
|
|
32
|
+
required: true;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
36
|
+
new (): {
|
|
37
|
+
$scopedSlots: S;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { default as ProForm } from './ProForm.vue';
|
|
2
|
+
import { default as ProFormItem } from './ProFormItem.vue';
|
|
3
|
+
import { default as FormActions } from './FormActions.vue';
|
|
4
|
+
import { useForm } from './useForm';
|
|
5
|
+
|
|
6
|
+
export { ProForm, ProFormItem, FormActions, useForm };
|
|
7
|
+
export default ProForm;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { ProFormSchema, ProFormProps, FormActionType } from '../types';
|
|
3
|
+
|
|
4
|
+
export interface UseFormProps extends ProFormProps {
|
|
5
|
+
schemas?: ProFormSchema[];
|
|
6
|
+
}
|
|
7
|
+
/** 支持 ref/computed 的 props(参考 Vben Admin:参数 props 内的值可以是 computed 或者 ref 类型) */
|
|
8
|
+
export type UseFormPropsReactive = UseFormProps | Ref<UseFormProps | undefined>;
|
|
9
|
+
export interface UseFormReturn {
|
|
10
|
+
/** 用于 @register,接收表单实例的 formAction */
|
|
11
|
+
register: (formAction: FormActionType) => void;
|
|
12
|
+
formAction: {
|
|
13
|
+
value: FormActionType | null;
|
|
14
|
+
};
|
|
15
|
+
getFieldsValue: () => Record<string, unknown>;
|
|
16
|
+
setFieldsValue: (values: Record<string, unknown>) => Promise<void>;
|
|
17
|
+
resetFields: () => Promise<void>;
|
|
18
|
+
validate: (nameList?: string[]) => Promise<unknown>;
|
|
19
|
+
validateFields: (nameList?: string[]) => Promise<unknown>;
|
|
20
|
+
submit: () => Promise<void>;
|
|
21
|
+
scrollToField: (name: string, options?: import('../types').ScrollToFieldOptions) => Promise<void>;
|
|
22
|
+
clearValidate: (name?: string | string[]) => void;
|
|
23
|
+
updateSchema: (data: Partial<ProFormSchema> | Partial<ProFormSchema>[]) => Promise<void>;
|
|
24
|
+
appendSchemaByField: (schema: ProFormSchema, prefixField?: string, first?: boolean) => Promise<void>;
|
|
25
|
+
removeSchemaByField: (field: string | string[]) => Promise<void>;
|
|
26
|
+
setProps: (props: Partial<ProFormProps>) => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export declare function useForm(props?: UseFormPropsReactive): [UseFormReturn['register'], Omit<UseFormReturn, 'register'>];
|