@iswangh/element-plus-kit-form 0.1.3 → 0.1.4
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 +133 -0
- package/dist/FormAction.vue.d.ts +27 -1
- package/dist/FormAction.vue.d.ts.map +1 -1
- package/dist/FormItem.vue.d.ts.map +1 -1
- package/dist/composables/index.d.ts +1 -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/config/action.d.ts +29 -0
- package/dist/config/action.d.ts.map +1 -0
- package/dist/config/component.d.ts +38 -0
- package/dist/config/component.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 +570 -340
- package/dist/style.css +1 -1
- package/dist/types/action.d.ts +52 -6
- package/dist/utils/action.d.ts +10 -0
- package/dist/utils/action.d.ts.map +1 -0
- package/dist/utils/debounce.d.ts +25 -0
- package/dist/utils/debounce.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/value.d.ts +14 -0
- package/dist/utils/value.d.ts.map +1 -1
- package/package.json +2 -5
package/dist/types/action.d.ts
CHANGED
|
@@ -11,18 +11,64 @@ export interface ActionConfigButtonItem extends Partial<ButtonProps> {
|
|
|
11
11
|
eventName: string
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* 表单操作按钮配置项
|
|
16
|
+
*
|
|
17
|
+
* 可以是标准化的按钮配置对象,也可以是预定义的按钮类型字符串
|
|
18
|
+
*/
|
|
19
|
+
export type ActionConfigButtons = ActionConfigButtonItem | 'submit' | 'cancel' | 'search' | 'reset' | 'expand'
|
|
16
20
|
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
22
|
+
* 展开规则基础配置
|
|
19
23
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
24
|
+
* **鼠标悬停自动展开**:
|
|
25
|
+
* - `autoExpandOnHover`:是否启用鼠标悬停自动展开功能
|
|
26
|
+
* - 当鼠标移入表单区域时自动展开(延迟 500ms)
|
|
27
|
+
* - 如果用户手动点击展开/收起按钮,则锁定状态,不再受鼠标移入影响
|
|
28
|
+
*
|
|
29
|
+
* **展开/收起后自动滚动**:
|
|
30
|
+
* - `scrollOnToggle`:是否在展开/收起后自动滚动到表单中心
|
|
31
|
+
* - 默认值为 false
|
|
32
|
+
* - 启用后,展开/收起动画完成后会自动滚动,使表单保持在页面中心
|
|
33
|
+
* - `scrollIntoViewOptions`:自定义滚动选项(仅在 `scrollOnToggle` 为 true 时生效)
|
|
34
|
+
* - 用于自定义 `scrollIntoView` 的行为(如 `block`、`behavior`、`inline` 等)
|
|
35
|
+
* - 默认值为 `{ behavior: 'smooth', block: 'center', inline: 'nearest' }`
|
|
36
|
+
* - 支持所有 `ScrollIntoViewOptions` 类型的选项配置
|
|
37
|
+
*/
|
|
38
|
+
export interface ExpandRuleBase {
|
|
39
|
+
/** 是否启用鼠标悬停自动展开功能 */
|
|
40
|
+
autoExpandOnHover?: boolean
|
|
41
|
+
/** 是否在展开/收起后自动滚动到表单中心 */
|
|
42
|
+
scrollOnToggle?: boolean
|
|
43
|
+
/** 滚动选项配置(用于自定义 scrollIntoView 的行为) */
|
|
44
|
+
scrollIntoViewOptions?: ScrollIntoViewOptions
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 默认展开规则(联合类型)
|
|
49
|
+
*
|
|
50
|
+
* 用于配置表单默认展开哪些字段,支持三种配置方式:
|
|
51
|
+
* - `count`:按字段数量展开(从第一个开始)
|
|
52
|
+
* - `include`:指定展示的字段(白名单,字段 prop 数组)
|
|
53
|
+
* - `exclude`:指定折叠的字段(黑名单,字段 prop 数组)
|
|
54
|
+
*
|
|
55
|
+
* **配置优先级**:`exclude` > `include` > `count`
|
|
56
|
+
*/
|
|
57
|
+
export type ExpandRule
|
|
58
|
+
= | ({ count: number } & ExpandRuleBase)
|
|
59
|
+
| ({ include: string[] } & ExpandRuleBase)
|
|
60
|
+
| ({ exclude: string[] } & ExpandRuleBase)
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 表单操作项配置
|
|
23
64
|
*/
|
|
24
65
|
export interface ActionConfig {
|
|
66
|
+
/** 是否显示操作区域(支持函数动态判断) */
|
|
25
67
|
vIf?: boolean | ((data?: any) => boolean)
|
|
68
|
+
/** 是否显示操作区域(支持函数动态判断,使用 v-show) */
|
|
26
69
|
vShow?: boolean | ((data?: any) => boolean)
|
|
70
|
+
/** 操作按钮配置数组 */
|
|
27
71
|
buttons?: ActionConfigButtons[]
|
|
72
|
+
/** 默认展开规则(仅在 buttons 包含 'expand' 时生效) */
|
|
73
|
+
expand?: ExpandRule
|
|
28
74
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ActionConfigButtons } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 判断按钮列表中是否包含指定的事件名
|
|
4
|
+
*
|
|
5
|
+
* @param buttons - 按钮配置数组
|
|
6
|
+
* @param eventName - 事件名称
|
|
7
|
+
* @returns 是否包含该事件名
|
|
8
|
+
*/
|
|
9
|
+
export declare function hasButtonEvent(buttons: ActionConfigButtons[] | string[] | undefined, eventName: string): boolean;
|
|
10
|
+
//# sourceMappingURL=action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/utils/action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAEnD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,mBAAmB,EAAE,GAAG,MAAM,EAAE,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAIhH"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file debounce.ts
|
|
3
|
+
* @description 防抖工具函数
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 防抖函数
|
|
7
|
+
*
|
|
8
|
+
* @param fn - 要防抖的函数
|
|
9
|
+
* @param delay - 延迟时间(毫秒),默认 100ms
|
|
10
|
+
* @returns 防抖后的函数
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const debouncedFn = debounce(() => {
|
|
15
|
+
* console.log('执行防抖函数')
|
|
16
|
+
* }, 300)
|
|
17
|
+
*
|
|
18
|
+
* // 频繁调用时,只会在最后一次调用后 300ms 执行
|
|
19
|
+
* debouncedFn()
|
|
20
|
+
* debouncedFn()
|
|
21
|
+
* debouncedFn() // 只有这一次会执行
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function debounce<T extends (...args: any[]) => any>(fn: T, delay?: number): (...args: Parameters<T>) => void;
|
|
25
|
+
//# sourceMappingURL=debounce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/utils/debounce.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,EAAE,EAAE,CAAC,EACL,KAAK,SAAM,GACV,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAYlC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
|
package/dist/utils/value.d.ts
CHANGED
|
@@ -10,4 +10,18 @@ export declare function isEmpty(val: any): boolean;
|
|
|
10
10
|
* @returns 是否在选项中(true 表示在选项中,不需要清理;false 表示不在,需要清理)
|
|
11
11
|
*/
|
|
12
12
|
export declare function checkValueInOptions(currentValue: any, options: any[]): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* 深拷贝值(仅对对象和数组)
|
|
15
|
+
*
|
|
16
|
+
* @param value - 要深拷贝的值
|
|
17
|
+
* @returns 深拷贝后的值
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const obj = { a: 1, b: { c: 2 } }
|
|
22
|
+
* const cloned = deepCloneValue(obj)
|
|
23
|
+
* cloned.b.c = 3 // 不会影响原对象
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function deepCloneValue<T = Record<string, unknown>>(value: T): T;
|
|
13
27
|
//# sourceMappingURL=value.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value.d.ts","sourceRoot":"","sources":["../../src/utils/value.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAEzC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO,CAa9E"}
|
|
1
|
+
{"version":3,"file":"value.d.ts","sourceRoot":"","sources":["../../src/utils/value.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAEzC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO,CAa9E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAMvE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iswangh/element-plus-kit-form",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"description": "Element Plus Kit 表单组件包",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"sideEffects": [
|
|
@@ -50,9 +50,6 @@
|
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "vite build",
|
|
52
52
|
"dev": "vite build --watch",
|
|
53
|
-
"type-check": "vue-tsc --noEmit"
|
|
54
|
-
"publish:patch": "pnpm version patch --no-git-tag-version && pnpm publish",
|
|
55
|
-
"publish:minor": "pnpm version minor --no-git-tag-version && pnpm publish",
|
|
56
|
-
"publish:major": "pnpm version major --no-git-tag-version && pnpm publish"
|
|
53
|
+
"type-check": "vue-tsc --noEmit"
|
|
57
54
|
}
|
|
58
55
|
}
|