@iswangh/element-plus-kit-form 0.1.3 → 0.2.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 +151 -18
- package/dist/FormAction.vue.d.ts +30 -4
- package/dist/FormAction.vue.d.ts.map +1 -1
- package/dist/FormItem.vue.d.ts +4 -18
- package/dist/FormItem.vue.d.ts.map +1 -1
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/index.d.ts.map +1 -1
- package/dist/composables/useAutoExpandOnHover.d.ts +15 -0
- package/dist/composables/useAutoExpandOnHover.d.ts.map +1 -0
- package/dist/composables/useChangeEventState.d.ts +5 -27
- package/dist/composables/useChangeEventState.d.ts.map +1 -1
- package/dist/composables/useClearState.d.ts +17 -0
- package/dist/composables/useClearState.d.ts.map +1 -0
- package/dist/config/action.d.ts +34 -0
- package/dist/config/action.d.ts.map +1 -0
- package/dist/config/comp.d.ts +48 -0
- package/dist/config/comp.d.ts.map +1 -0
- package/dist/config/form.d.ts +6 -0
- package/dist/config/form.d.ts.map +1 -0
- package/dist/config/index.d.ts +4 -65
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/scroll.d.ts +7 -0
- package/dist/config/scroll.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1197 -382
- package/dist/style.css +1 -1
- package/dist/types/action.d.ts +58 -11
- package/dist/types/common.d.ts +5 -4
- package/dist/types/comp.d.ts +93 -0
- package/dist/types/el.d.ts +8 -8
- package/dist/types/form-item.d.ts +31 -92
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/layout.d.ts +6 -0
- package/dist/types/options.d.ts +15 -31
- package/dist/types/scope.d.ts +34 -0
- package/dist/utils/action.d.ts +10 -0
- package/dist/utils/action.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/lodash.d.ts +6 -0
- package/dist/utils/lodash.d.ts.map +1 -0
- package/dist/utils/options.d.ts.map +1 -1
- package/dist/utils/value.d.ts +13 -5
- package/dist/utils/value.d.ts.map +1 -1
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -24,13 +24,13 @@ const formItems: FormItems = [
|
|
|
24
24
|
{
|
|
25
25
|
prop: 'username',
|
|
26
26
|
label: '用户名',
|
|
27
|
-
|
|
27
|
+
compType: 'input',
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
prop: 'email',
|
|
31
31
|
label: '邮箱',
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
compType: 'input',
|
|
33
|
+
compProps: {
|
|
34
34
|
type: 'email',
|
|
35
35
|
},
|
|
36
36
|
},
|
|
@@ -77,7 +77,7 @@ import '@iswangh/element-plus-kit-form/style.css'
|
|
|
77
77
|
| --- | --- | --- | --- |
|
|
78
78
|
| model | 表单数据对象 | `Record<string, any>` | `{}` |
|
|
79
79
|
| formItems | 表单项配置数组 | `FormItems` | `[]` |
|
|
80
|
-
|
|
|
80
|
+
| rowProps | 行布局属性(ElRow 属性) | `RowProps` | `{}` |
|
|
81
81
|
| actionConfig | 操作按钮配置 | `ActionConfig` | `{}` |
|
|
82
82
|
|
|
83
83
|
**继承 Element Plus Form 属性**:组件继承所有 `ElForm` 的属性,如 `rules`、`labelPosition`、`size` 等。
|
|
@@ -87,19 +87,22 @@ import '@iswangh/element-plus-kit-form/style.css'
|
|
|
87
87
|
| 事件名 | 说明 | 参数 |
|
|
88
88
|
| --- | --- | --- |
|
|
89
89
|
| validate | 表单项验证事件 | `(prop: FormItemProp, isValid: boolean, message: string)` |
|
|
90
|
-
| change | 表单项值变化事件 | `(extendedParams:
|
|
90
|
+
| change | 表单项值变化事件 | `(extendedParams: FormItemEventExtendedParams, value: any)` |
|
|
91
91
|
| action | 操作按钮点击事件 | `(eventName: string)` |
|
|
92
92
|
| search | 搜索按钮点击事件 | - |
|
|
93
93
|
| reset | 重置按钮点击事件 | - |
|
|
94
94
|
| submit | 提交按钮点击事件 | - |
|
|
95
95
|
| cancel | 取消按钮点击事件 | - |
|
|
96
|
+
| expand | 展开状态变化事件 | `(value: boolean)` |
|
|
96
97
|
|
|
97
98
|
### Slots
|
|
98
99
|
|
|
99
100
|
| 插槽名 | 说明 | 作用域参数 |
|
|
100
101
|
| --- | --- | --- |
|
|
102
|
+
| `{prop}` | 自定义组件插槽,当 `compType` 为 `custom` 时使用 | `FormItemSlotScope` |
|
|
101
103
|
| `form-item-{prop}` | 表单项插槽,用于自定义表单项内容 | `FormItemSlotScope` |
|
|
102
104
|
| `{prop}-{slotName}` | 动态组件插槽,如 `username-prefix`、`email-suffix` | `FormItemSlotScope` |
|
|
105
|
+
| `expand-toggle` | 展开/折叠按钮插槽,用于自定义按钮 | `{ expanded: boolean, toggle: (value?: boolean) => void }` |
|
|
103
106
|
|
|
104
107
|
### FormItem 配置
|
|
105
108
|
|
|
@@ -109,11 +112,15 @@ import '@iswangh/element-plus-kit-form/style.css'
|
|
|
109
112
|
interface FormItem<C extends FormItemComp = FormItemComp> {
|
|
110
113
|
prop: string // 表单字段名(必填)
|
|
111
114
|
label: string // 标签文本
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
compType: FormItemComp // 组件类型(必填)
|
|
116
|
+
compProps?: FormItemCompProps<C> // 组件属性配置
|
|
117
|
+
// 对于支持 options 的组件(如 select、cascader、radio、checkbox 等),compProps.options 支持三种模式:
|
|
118
|
+
// 1. 静态数组:options: [{ label: '选项1', value: '1' }]
|
|
119
|
+
// 2. 函数模式:options: (formData) => [{ label: '选项1', value: '1' }]
|
|
120
|
+
// 3. 对象模式:options: { loader: (formData) => [...], deps: ['field1'], immediate: true }
|
|
114
121
|
vIf?: boolean | ((data?: any) => boolean) // 条件渲染(v-if)
|
|
115
122
|
vShow?: boolean | ((data?: any) => boolean) // 显示/隐藏(v-show)
|
|
116
|
-
|
|
123
|
+
colProps?: ColProps // 列布局属性(ElCol 属性)
|
|
117
124
|
// ... 其他 ElFormItem 属性
|
|
118
125
|
}
|
|
119
126
|
```
|
|
@@ -152,8 +159,8 @@ const formItems: FormItems = [
|
|
|
152
159
|
{
|
|
153
160
|
prop: 'username',
|
|
154
161
|
label: '用户名',
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
compType: 'input',
|
|
163
|
+
compProps: {
|
|
157
164
|
placeholder: '请输入用户名',
|
|
158
165
|
clearable: true,
|
|
159
166
|
},
|
|
@@ -164,8 +171,8 @@ const formItems: FormItems = [
|
|
|
164
171
|
{
|
|
165
172
|
prop: 'age',
|
|
166
173
|
label: '年龄',
|
|
167
|
-
|
|
168
|
-
|
|
174
|
+
compType: 'input-number',
|
|
175
|
+
compProps: {
|
|
169
176
|
min: 0,
|
|
170
177
|
max: 120,
|
|
171
178
|
step: 1,
|
|
@@ -176,8 +183,8 @@ const formItems: FormItems = [
|
|
|
176
183
|
{
|
|
177
184
|
prop: 'gender',
|
|
178
185
|
label: '性别',
|
|
179
|
-
|
|
180
|
-
|
|
186
|
+
compType: 'select',
|
|
187
|
+
compProps: {
|
|
181
188
|
options: [
|
|
182
189
|
{ label: '男', value: 'male' },
|
|
183
190
|
{ label: '女', value: 'female' },
|
|
@@ -196,6 +203,7 @@ interface ActionConfig {
|
|
|
196
203
|
vIf?: boolean | ((data?: any) => boolean) // 是否显示操作区域
|
|
197
204
|
vShow?: boolean | ((data?: any) => boolean) // 显示/隐藏操作区域
|
|
198
205
|
buttons?: ActionConfigButtons[] // 按钮列表
|
|
206
|
+
expand?: ExpandRule // 默认展开规则(仅在 buttons 包含 'expand' 时生效)
|
|
199
207
|
}
|
|
200
208
|
```
|
|
201
209
|
|
|
@@ -207,6 +215,7 @@ interface ActionConfig {
|
|
|
207
215
|
- `'reset'` - 重置按钮
|
|
208
216
|
- `'search'` - 搜索按钮
|
|
209
217
|
- `'cancel'` - 取消按钮
|
|
218
|
+
- `'expand'` - 展开/折叠按钮(仅在 `inline` 模式下可用)
|
|
210
219
|
|
|
211
220
|
#### 自定义按钮
|
|
212
221
|
|
|
@@ -244,12 +253,12 @@ const formItems: FormItems = [
|
|
|
244
253
|
{
|
|
245
254
|
prop: 'username',
|
|
246
255
|
label: '用户名',
|
|
247
|
-
|
|
256
|
+
compType: 'input',
|
|
248
257
|
},
|
|
249
258
|
{
|
|
250
259
|
prop: 'email',
|
|
251
260
|
label: '邮箱',
|
|
252
|
-
|
|
261
|
+
compType: 'input',
|
|
253
262
|
// 只有当用户名存在时才显示邮箱字段
|
|
254
263
|
vIf: (data) => !!data?.username,
|
|
255
264
|
},
|
|
@@ -277,7 +286,7 @@ const formItems: FormItems = [
|
|
|
277
286
|
{
|
|
278
287
|
prop: 'email',
|
|
279
288
|
label: '邮箱',
|
|
280
|
-
|
|
289
|
+
compType: 'input',
|
|
281
290
|
rules: [
|
|
282
291
|
{ required: true, message: '请输入邮箱', trigger: 'blur' },
|
|
283
292
|
{ type: 'email', message: '请输入正确的邮箱格式', trigger: 'blur' },
|
|
@@ -299,7 +308,7 @@ const formItems: FormItems = [
|
|
|
299
308
|
</template>
|
|
300
309
|
|
|
301
310
|
<script setup lang="ts">
|
|
302
|
-
const onChange = (extendedParams:
|
|
311
|
+
const onChange = (extendedParams: FormItemEventExtendedParams, value: any) => {
|
|
303
312
|
console.log('字段变化:', extendedParams.prop, value)
|
|
304
313
|
}
|
|
305
314
|
|
|
@@ -309,6 +318,130 @@ const onSubmit = () => {
|
|
|
309
318
|
</script>
|
|
310
319
|
```
|
|
311
320
|
|
|
321
|
+
### 展开/折叠功能
|
|
322
|
+
|
|
323
|
+
表单支持展开/折叠功能,可以控制表单项的显示和隐藏,适用于字段较多的表单场景。
|
|
324
|
+
|
|
325
|
+
**重要说明**:
|
|
326
|
+
- 展开/折叠功能仅在 `inline` 模式下可用(`inline: true`)
|
|
327
|
+
- 通过 `actionConfig.buttons` 包含 `'expand'` 来启用展开/折叠功能
|
|
328
|
+
- 通过 `actionConfig.expand` 配置展开规则
|
|
329
|
+
|
|
330
|
+
#### 基础用法
|
|
331
|
+
|
|
332
|
+
```vue
|
|
333
|
+
<template>
|
|
334
|
+
<WForm
|
|
335
|
+
:model="form"
|
|
336
|
+
:form-items="formItems"
|
|
337
|
+
inline
|
|
338
|
+
:action-config="{
|
|
339
|
+
buttons: ['expand', 'search', 'reset'],
|
|
340
|
+
expand: {
|
|
341
|
+
count: 3, // 默认展开前 3 个字段
|
|
342
|
+
},
|
|
343
|
+
}"
|
|
344
|
+
/>
|
|
345
|
+
</template>
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
#### 配置说明
|
|
349
|
+
|
|
350
|
+
展开规则通过 `actionConfig.expand` 配置,支持三种配置方式:
|
|
351
|
+
|
|
352
|
+
| 配置方式 | 说明 | 类型 | 示例 |
|
|
353
|
+
| --- | --- | --- | --- |
|
|
354
|
+
| `count` | 按字段数量展开(从第一个开始) | `{ count: number }` | `{ count: 3 }` |
|
|
355
|
+
| `include` | 指定展示的字段(白名单,字段 prop 数组) | `{ include: string[] }` | `{ include: ['field1', 'field2'] }` |
|
|
356
|
+
| `exclude` | 指定折叠的字段(黑名单,字段 prop 数组) | `{ exclude: string[] }` | `{ exclude: ['field3', 'field4'] }` |
|
|
357
|
+
|
|
358
|
+
**配置优先级**:`exclude` > `include` > `count`
|
|
359
|
+
|
|
360
|
+
#### 展开规则高级配置
|
|
361
|
+
|
|
362
|
+
展开规则还支持以下高级配置:
|
|
363
|
+
|
|
364
|
+
| 配置项 | 说明 | 类型 | 默认值 |
|
|
365
|
+
| --- | --- | --- | --- |
|
|
366
|
+
| `autoExpandOnHover` | 是否启用鼠标悬停自动展开功能 | `boolean` | `false` |
|
|
367
|
+
| `scrollOnToggle` | 是否在展开/收起后自动滚动到表单中心 | `boolean` | `false` |
|
|
368
|
+
| `scrollIntoViewOptions` | 自定义滚动选项(仅在 `scrollOnToggle` 为 true 时生效) | `ScrollIntoViewOptions` | `{ behavior: 'smooth', block: 'center', inline: 'nearest' }` |
|
|
369
|
+
|
|
370
|
+
**使用示例**:
|
|
371
|
+
|
|
372
|
+
```typescript
|
|
373
|
+
const actionConfig: ActionConfig = {
|
|
374
|
+
buttons: ['expand', 'search', 'reset'],
|
|
375
|
+
expand: {
|
|
376
|
+
count: 3, // 默认展开前 3 个字段
|
|
377
|
+
autoExpandOnHover: true, // 鼠标悬停时自动展开
|
|
378
|
+
scrollOnToggle: true, // 展开/收起后自动滚动
|
|
379
|
+
},
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
#### 受控模式
|
|
384
|
+
|
|
385
|
+
使用 `v-model:expanded` 实现受控模式:
|
|
386
|
+
|
|
387
|
+
```vue
|
|
388
|
+
<template>
|
|
389
|
+
<WForm
|
|
390
|
+
v-model:expanded="isExpanded"
|
|
391
|
+
:model="form"
|
|
392
|
+
:form-items="formItems"
|
|
393
|
+
inline
|
|
394
|
+
:action-config="{
|
|
395
|
+
buttons: ['expand', 'search', 'reset'],
|
|
396
|
+
expand: { count: 3 },
|
|
397
|
+
}"
|
|
398
|
+
/>
|
|
399
|
+
<el-button @click="formRef?.toggleExpand(true)">展开</el-button>
|
|
400
|
+
<el-button @click="formRef?.toggleExpand(false)">折叠</el-button>
|
|
401
|
+
</template>
|
|
402
|
+
|
|
403
|
+
<script setup lang="ts">
|
|
404
|
+
const isExpanded = ref(false)
|
|
405
|
+
const formRef = ref<InstanceType<typeof WForm>>()
|
|
406
|
+
|
|
407
|
+
// 或者使用组件暴露的方法
|
|
408
|
+
function toggle() {
|
|
409
|
+
formRef.value?.toggleExpand() // 切换
|
|
410
|
+
formRef.value?.toggleExpand(true) // 展开
|
|
411
|
+
formRef.value?.toggleExpand(false) // 折叠
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// 或者直接使用 v-model:expanded
|
|
415
|
+
function toggleExpanded() {
|
|
416
|
+
isExpanded.value = !isExpanded.value
|
|
417
|
+
}
|
|
418
|
+
</script>
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
#### 自定义按钮
|
|
422
|
+
|
|
423
|
+
使用 `expand-toggle` 插槽自定义展开/折叠按钮:
|
|
424
|
+
|
|
425
|
+
```vue
|
|
426
|
+
<template>
|
|
427
|
+
<WForm
|
|
428
|
+
:model="form"
|
|
429
|
+
:form-items="formItems"
|
|
430
|
+
inline
|
|
431
|
+
:action-config="{
|
|
432
|
+
buttons: ['expand', 'search', 'reset'],
|
|
433
|
+
expand: { count: 3 },
|
|
434
|
+
}"
|
|
435
|
+
>
|
|
436
|
+
<template #expand-toggle="{ expanded, toggle }">
|
|
437
|
+
<el-button type="success" :icon="expanded ? ArrowUp : ArrowDown" @click="toggle()">
|
|
438
|
+
{{ expanded ? '收起高级搜索' : '展开高级搜索' }}
|
|
439
|
+
</el-button>
|
|
440
|
+
</template>
|
|
441
|
+
</WForm>
|
|
442
|
+
</template>
|
|
443
|
+
```
|
|
444
|
+
|
|
312
445
|
## 🔗 相关链接
|
|
313
446
|
|
|
314
447
|
- [主包文档](../kit/README.md)
|
package/dist/FormAction.vue.d.ts
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
import { Slot } from 'vue';
|
|
2
|
-
import {
|
|
2
|
+
import { FormActionConfig } from './types';
|
|
3
3
|
interface Props {
|
|
4
4
|
inline?: boolean;
|
|
5
5
|
actionSlot?: Slot;
|
|
6
|
-
config?:
|
|
6
|
+
config?: FormActionConfig;
|
|
7
|
+
/** 展开/折叠状态(仅在 buttons 包含 'expand' 时有效) */
|
|
8
|
+
expanded?: boolean;
|
|
9
|
+
/** 是否启用鼠标悬停自动展开 */
|
|
10
|
+
autoExpandOnHover?: boolean;
|
|
11
|
+
/** 鼠标移入事件处理函数(用于空白区域和展开图标) */
|
|
12
|
+
onMouseEnter?: () => void;
|
|
13
|
+
/** 鼠标移出事件处理函数(用于空白区域和展开图标) */
|
|
14
|
+
onMouseLeave?: () => void;
|
|
7
15
|
}
|
|
8
|
-
declare
|
|
16
|
+
declare function __VLS_template(): {
|
|
17
|
+
attrs: Partial<{}>;
|
|
18
|
+
slots: {
|
|
19
|
+
default?(_: {}): any;
|
|
20
|
+
};
|
|
21
|
+
refs: {};
|
|
22
|
+
rootEl: any;
|
|
23
|
+
};
|
|
24
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
25
|
+
declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
|
|
9
26
|
inline: boolean;
|
|
10
27
|
config: () => {};
|
|
28
|
+
expanded: boolean;
|
|
11
29
|
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
12
30
|
action: (payload: {
|
|
13
31
|
eventName: string;
|
|
@@ -16,15 +34,18 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
16
34
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
|
|
17
35
|
inline: boolean;
|
|
18
36
|
config: () => {};
|
|
37
|
+
expanded: boolean;
|
|
19
38
|
}>>> & Readonly<{
|
|
20
39
|
onAction?: ((payload: {
|
|
21
40
|
eventName: string;
|
|
22
41
|
data?: any;
|
|
23
42
|
}) => any) | undefined;
|
|
24
43
|
}>, {
|
|
44
|
+
expanded: boolean;
|
|
25
45
|
inline: boolean;
|
|
26
|
-
config:
|
|
46
|
+
config: FormActionConfig;
|
|
27
47
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
48
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
28
49
|
export default _default;
|
|
29
50
|
type __VLS_WithDefaults<P, D> = {
|
|
30
51
|
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
|
|
@@ -40,6 +61,11 @@ type __VLS_TypePropsToOption<T> = {
|
|
|
40
61
|
required: true;
|
|
41
62
|
};
|
|
42
63
|
};
|
|
64
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
65
|
+
new (): {
|
|
66
|
+
$slots: S;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
43
69
|
type __VLS_PrettifyLocal<T> = {
|
|
44
70
|
[K in keyof T]: T[K];
|
|
45
71
|
} & {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormAction.vue.d.ts","sourceRoot":"","sources":["../src/FormAction.vue"],"names":[],"mappings":"AACA;
|
|
1
|
+
{"version":3,"file":"FormAction.vue.d.ts","sourceRoot":"","sources":["../src/FormAction.vue"],"names":[],"mappings":"AACA;AAkKA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,KAAK,EAAwB,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAMrE,UAAU,KAAK;IACb,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,IAAI,CAAA;IACjB,MAAM,CAAC,EAAE,gBAAgB,CAAA;IACzB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,mBAAmB;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;IACzB,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;CAC1B;AAwGD,iBAAS,cAAc;WAsHT,OAAO,IAA6B;;yBAVpB,GAAG;;;;EAehC;AAoBD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;mBArPiB,MAAM;eAAS,GAAG;;;;;;;;mBAAlB,MAAM;eAAS,GAAG;;;cAV3C,OAAO;YAJT,OAAO;YAEP,gBAAgB;4EAwQzB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAEpG,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAC9B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAC7C,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KAAC,CAAC,GAC5C,CAAC,CAAC,CAAC,CAAC;CACP,CAAC;AACF,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,uBAAuB,CAAC,CAAC,IAAI;KAChC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACpC;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAC9D;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CACzD,CAAC;AACF,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC;AACF,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|
package/dist/FormItem.vue.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ interface ProcessedSlot {
|
|
|
8
8
|
interface FormSlots {
|
|
9
9
|
formItemSlots: ProcessedSlot[];
|
|
10
10
|
dynamicComponentSlots: Map<string, ProcessedSlot[]>;
|
|
11
|
+
customComponentSlots: Map<string, ProcessedSlot[]>;
|
|
11
12
|
}
|
|
12
13
|
interface Props {
|
|
13
14
|
formItem: FormItem;
|
|
@@ -20,34 +21,24 @@ type __VLS_Props = Props;
|
|
|
20
21
|
type __VLS_PublicProps = {
|
|
21
22
|
modelValue?: any;
|
|
22
23
|
} & __VLS_Props;
|
|
23
|
-
declare
|
|
24
|
-
attrs: Partial<{}>;
|
|
25
|
-
slots: Partial<Record<string, (_: {
|
|
26
|
-
value: unknown;
|
|
27
|
-
form: Record<string, any>;
|
|
28
|
-
formItem: FormItem<import('./types').FormItemComp>;
|
|
29
|
-
}) => any>>;
|
|
30
|
-
refs: {};
|
|
31
|
-
rootEl: any;
|
|
32
|
-
};
|
|
33
|
-
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
34
|
-
declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<__VLS_PublicProps>, {
|
|
24
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<__VLS_PublicProps>, {
|
|
35
25
|
formData: () => {};
|
|
36
26
|
formSlots: () => {
|
|
37
27
|
formItemSlots: never[];
|
|
38
28
|
dynamicComponentSlots: Map<any, any>;
|
|
29
|
+
customComponentSlots: Map<any, any>;
|
|
39
30
|
};
|
|
40
31
|
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<__VLS_PublicProps>, {
|
|
41
32
|
formData: () => {};
|
|
42
33
|
formSlots: () => {
|
|
43
34
|
formItemSlots: never[];
|
|
44
35
|
dynamicComponentSlots: Map<any, any>;
|
|
36
|
+
customComponentSlots: Map<any, any>;
|
|
45
37
|
};
|
|
46
38
|
}>>> & Readonly<{}>, {
|
|
47
39
|
formData: Record<string, any>;
|
|
48
40
|
formSlots: FormSlots;
|
|
49
41
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
50
|
-
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
51
42
|
export default _default;
|
|
52
43
|
type __VLS_WithDefaults<P, D> = {
|
|
53
44
|
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
|
|
@@ -63,11 +54,6 @@ type __VLS_TypePropsToOption<T> = {
|
|
|
63
54
|
required: true;
|
|
64
55
|
};
|
|
65
56
|
};
|
|
66
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
67
|
-
new (): {
|
|
68
|
-
$slots: S;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
57
|
type __VLS_PrettifyLocal<T> = {
|
|
72
58
|
[K in keyof T]: T[K];
|
|
73
59
|
} & {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormItem.vue.d.ts","sourceRoot":"","sources":["../src/FormItem.vue"],"names":[],"mappings":"AACA;
|
|
1
|
+
{"version":3,"file":"FormItem.vue.d.ts","sourceRoot":"","sources":["../src/FormItem.vue"],"names":[],"mappings":"AACA;AAsaA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAA6D,MAAM,SAAS,CAAA;AAOlG,UAAU,aAAa;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,IAAI,CAAA;CACb;AAED,UAAU,SAAS;IACjB,aAAa,EAAE,aAAa,EAAE,CAAA;IAC9B,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAA;IACnD,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAA;CACnD;AAED,UAAU,KAAK;IACb,QAAQ,EAAE,QAAQ,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAA;IAC1D,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB;AAQD,KAAK,WAAW,GAAG,KAAK,CAAC;AAmWzB,KAAK,iBAAiB,GAAG;IACzB,UAAU,CAAC,EAAE,GAAG,CAAC;CAChB,GAAG,WAAW,CAAC;;;;;;;;;;;;;;;;cAhXH,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;eAElB,SAAS;;AAggBvB,wBAUG;AAEH,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAC9B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAC7C,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KAAC,CAAC,GAC5C,CAAC,CAAC,CAAC,CAAC;CACP,CAAC;AACF,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,uBAAuB,CAAC,CAAC,IAAI;KAChC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACpC;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAC9D;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CACzD,CAAC;AACF,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composables/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composables/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComputedRef, Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* 鼠标悬停自动展开组合式函数
|
|
4
|
+
*
|
|
5
|
+
* @param isExpanded - 展开/折叠状态
|
|
6
|
+
* @param autoExpandOnHover - 是否启用鼠标悬停自动展开
|
|
7
|
+
* @param onToggleExpanded - 切换展开/折叠状态的回调函数
|
|
8
|
+
* @returns 鼠标事件处理函数和记录手动操作状态的函数
|
|
9
|
+
*/
|
|
10
|
+
export declare function useAutoExpandOnHover(isExpanded: Ref<boolean>, autoExpandOnHover: ComputedRef<boolean> | Ref<boolean>, onToggleExpanded: (value: boolean) => void): {
|
|
11
|
+
onMouseEnter: () => void;
|
|
12
|
+
onMouseLeave: () => void;
|
|
13
|
+
recordManualToggle: () => void;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useAutoExpandOnHover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutoExpandOnHover.d.ts","sourceRoot":"","sources":["../../src/composables/useAutoExpandOnHover.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAG3C;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,EACxB,iBAAiB,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,EACtD,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;;;;EAkF3C"}
|
|
@@ -3,33 +3,11 @@
|
|
|
3
3
|
* 用于区分不同类型的值变化,防止重复触发 change 事件
|
|
4
4
|
*/
|
|
5
5
|
export declare function useChangeEventState(): {
|
|
6
|
-
/** 是否正在清理 */
|
|
7
|
-
readonly isClearing: boolean;
|
|
8
6
|
/** 是否用户交互 */
|
|
9
|
-
readonly
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
startClearing(value: any): void;
|
|
15
|
-
/**
|
|
16
|
-
* 结束清理操作(在 nextTick 中调用)
|
|
17
|
-
*/
|
|
18
|
-
endClearing(): void;
|
|
19
|
-
/**
|
|
20
|
-
* 开始用户交互
|
|
21
|
-
*/
|
|
22
|
-
startUserInteraction(): void;
|
|
23
|
-
/**
|
|
24
|
-
* 结束用户交互(在 nextTick 中调用)
|
|
25
|
-
*/
|
|
26
|
-
endUserInteraction(): void;
|
|
27
|
-
/**
|
|
28
|
-
* 判断是否是清理操作
|
|
29
|
-
* @param oldValue - 旧值
|
|
30
|
-
* @param newValue - 新值
|
|
31
|
-
* @param isEmpty - 检查值是否为空的函数
|
|
32
|
-
*/
|
|
33
|
-
isClearingOperation(oldValue: any, newValue: any, isEmpty: (val: any) => boolean): boolean;
|
|
7
|
+
readonly isUser: boolean;
|
|
8
|
+
/** 开始用户交互 */
|
|
9
|
+
start(): void;
|
|
10
|
+
/** 结束用户交互(在 nextTick 中调用) */
|
|
11
|
+
end(): void;
|
|
34
12
|
};
|
|
35
13
|
//# sourceMappingURL=useChangeEventState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChangeEventState.d.ts","sourceRoot":"","sources":["../../src/composables/useChangeEventState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useChangeEventState.d.ts","sourceRoot":"","sources":["../../src/composables/useChangeEventState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,mBAAmB;IAI/B,aAAa;;IAKb,aAAa;;IAKb,6BAA6B;;EAKhC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 清理状态管理组合式函数
|
|
3
|
+
* 用于管理依赖变更时的清理操作,支持用户在 change 事件中设置默认值
|
|
4
|
+
*/
|
|
5
|
+
export declare function useClearState(): {
|
|
6
|
+
/** 是否正在处理依赖变更 */
|
|
7
|
+
readonly changing: boolean;
|
|
8
|
+
/** 用户是否在 change 事件中设置了值 */
|
|
9
|
+
readonly hasUserValue: boolean;
|
|
10
|
+
/** 开始依赖变更处理 */
|
|
11
|
+
start(): void;
|
|
12
|
+
/** 结束依赖变更处理 */
|
|
13
|
+
end(): void;
|
|
14
|
+
/** 标记用户在 change 事件中设置了值 */
|
|
15
|
+
markValue(): void;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useClearState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClearState.d.ts","sourceRoot":"","sources":["../../src/composables/useClearState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,aAAa;IAKzB,iBAAiB;;IAKjB,2BAA2B;;IAK3B,eAAe;;IAMf,eAAe;;IAMf,2BAA2B;;EAK9B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FormActionButtonItem, FormActionConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 表单动作按钮默认配置
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_FORM_ACTION_BUTTONS: Record<string, Partial<Omit<FormActionButtonItem, 'eventName'>>>;
|
|
6
|
+
/**
|
|
7
|
+
* 表单动作默认配置
|
|
8
|
+
*/
|
|
9
|
+
export declare const FORM_ACTION_DEFAULT_CONFIG: {
|
|
10
|
+
/**
|
|
11
|
+
* 获取动作默认属性
|
|
12
|
+
*/
|
|
13
|
+
getDefaults(inline?: boolean, actionConfig?: FormActionConfig): {
|
|
14
|
+
vIf: import('../types').Condition;
|
|
15
|
+
vShow: import('../types').Condition;
|
|
16
|
+
buttons: string[] | import('../types').FormActionButtons[];
|
|
17
|
+
expand?: import('../types').FormExpandRule;
|
|
18
|
+
autoExpandOnError: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 获取动作按钮列表
|
|
22
|
+
*/
|
|
23
|
+
getActionButtons(inline?: boolean): string[];
|
|
24
|
+
/**
|
|
25
|
+
* 构建动作属性
|
|
26
|
+
*/
|
|
27
|
+
buildActionProps(inline?: boolean): {
|
|
28
|
+
buttons: string[];
|
|
29
|
+
vIf: boolean | undefined;
|
|
30
|
+
autoExpandOnError: boolean;
|
|
31
|
+
vShow: boolean;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/config/action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAGtE;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAMxG,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B;IACrC;;OAEG;yBACkB,OAAO,iBAAiB,gBAAgB;;;;;;;IAI7D;;OAEG;8BACuB,OAAO;IAGjC;;OAEG;8BACuB,OAAO;;;;;;CAQlC,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { FormItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 需要从 FormItem 中排除的自定义属性键名
|
|
4
|
+
* 这些属性不会传递给 el-form-item 组件
|
|
5
|
+
*/
|
|
6
|
+
export declare const FORM_ITEM_EXCLUDED_KEYS: readonly ["compType", "compProps", "vIf", "vShow"];
|
|
7
|
+
/**
|
|
8
|
+
* 拓展的组件映射
|
|
9
|
+
* 导出以便在类型文件中使用 typeof 提取类型
|
|
10
|
+
*/
|
|
11
|
+
export declare const EXPAND_COMP_MAP: {
|
|
12
|
+
readonly custom: "div";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* 表单组件类型映射配置
|
|
16
|
+
*
|
|
17
|
+
* 使用显式类型注解避免类型推断超出编译器序列化限制
|
|
18
|
+
* 类型提示通过 keyof 提取键名,不依赖完整的类型定义
|
|
19
|
+
*
|
|
20
|
+
* 注意:虽然这里使用 Record<string, any>,但实际的类型定义
|
|
21
|
+
* 通过类型工具在 comp.d.ts 中从 EL_COMP_MAP 和 EXPAND_COMP_MAP 提取
|
|
22
|
+
*/
|
|
23
|
+
export declare const FORM_ITEM_COMP_MAP: Record<string, any>;
|
|
24
|
+
/**
|
|
25
|
+
* 动态组件默认配置
|
|
26
|
+
*/
|
|
27
|
+
export declare const COMP_DEFAULT_CONFIG: {
|
|
28
|
+
/**
|
|
29
|
+
* 获取组件默认属性
|
|
30
|
+
*/
|
|
31
|
+
getDefaults(formItem: FormItem): {
|
|
32
|
+
[x: string]: any;
|
|
33
|
+
options?: any[] | import('../types').OptionsLoader | import('../types').OptionsConfig | undefined;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* 判断组件类型
|
|
37
|
+
*/
|
|
38
|
+
getCompType(comp: string): "input" | "select" | "picker" | "other";
|
|
39
|
+
/**
|
|
40
|
+
* 动态生成 placeholder
|
|
41
|
+
*/
|
|
42
|
+
generatePlaceholder(formItem: FormItem, type: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* 构建组件属性
|
|
45
|
+
*/
|
|
46
|
+
buildCompProps(formItem: FormItem, type: string): Record<string, any>;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=comp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comp.d.ts","sourceRoot":"","sources":["../../src/config/comp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGxC;;;GAGG;AACH,eAAO,MAAM,uBAAuB,oDAAqD,CAAA;AAEzF;;;GAGG;AACH,eAAO,MAAM,eAAe;;CAA6B,CAAA;AA+BzD;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAwD,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAE1G;;GAEG;AACH,eAAO,MAAM,mBAAmB;IAC9B;;OAEG;0BACmB,QAAQ;;;;IAe9B;;OAEG;sBACe,MAAM;IAoBxB;;OAEG;kCAC2B,QAAQ,QAAQ,MAAM;IAkBpD;;OAEG;6BACsB,QAAQ,QAAQ,MAAM;CAYhD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../src/config/form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG7C;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAIf,OAAO,CAAC,SAAS,CAAC,CAAA"}
|