@aoao-y33/ui 0.0.2 → 0.0.5
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 +0 -11
- package/dist/button/components/button/props.d.ts +43 -0
- package/dist/button/components/button/props.d.ts.map +1 -1
- package/dist/button/utils/index.d.ts +20 -0
- package/dist/button/utils/index.d.ts.map +1 -1
- package/dist/common/utils/iconUtils.d.ts +16 -0
- package/dist/common/utils/iconUtils.d.ts.map +1 -1
- package/dist/form/components/fields/index.d.ts.map +1 -1
- package/dist/form/components/form/form.vue.d.ts.map +1 -1
- package/dist/form/components/form/props.d.ts +43 -0
- package/dist/form/components/form/props.d.ts.map +1 -1
- package/dist/form/components/form-item/props.d.ts +29 -0
- package/dist/form/components/form-item/props.d.ts.map +1 -1
- package/dist/form/hoc/useForm.d.ts +43 -0
- package/dist/form/hoc/useForm.d.ts.map +1 -1
- package/dist/form/utils/index.d.ts +65 -0
- package/dist/form/utils/index.d.ts.map +1 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22523 -12091
- package/dist/layout/utils/index.d.ts +20 -0
- package/dist/layout/utils/index.d.ts.map +1 -1
- package/dist/modal/components/form-modal/props.d.ts +36 -1
- package/dist/modal/components/form-modal/props.d.ts.map +1 -1
- package/dist/modal/components/modal/props.d.ts +43 -1
- package/dist/modal/components/modal/props.d.ts.map +1 -1
- package/dist/modal/hoc/useFormModal.d.ts +50 -0
- package/dist/modal/hoc/useFormModal.d.ts.map +1 -1
- package/dist/modal/hoc/useModal.d.ts +55 -0
- package/dist/modal/hoc/useModal.d.ts.map +1 -1
- package/dist/modal/hoc/useModalExpose.d.ts +24 -0
- package/dist/modal/hoc/useModalExpose.d.ts.map +1 -1
- package/dist/table/components/table/props.d.ts +75 -0
- package/dist/table/components/table/props.d.ts.map +1 -1
- package/dist/table/components/table-column/props.d.ts +19 -0
- package/dist/table/components/table-column/props.d.ts.map +1 -1
- package/dist/table/components/table-page/props.d.ts +31 -0
- package/dist/table/components/table-page/props.d.ts.map +1 -1
- package/dist/table/components/table-select/props.d.ts +49 -0
- package/dist/table/components/table-select/props.d.ts.map +1 -1
- package/dist/table/hoc/useTable.d.ts +41 -0
- package/dist/table/hoc/useTable.d.ts.map +1 -1
- package/dist/table/hoc/useTableExpose.d.ts +27 -0
- package/dist/table/hoc/useTableExpose.d.ts.map +1 -1
- package/dist/table/utils/index.d.ts +26 -0
- package/dist/table/utils/index.d.ts.map +1 -1
- package/package.json +13 -6
- package/dist/global.d.ts +0 -33
- package/dist/global.d.ts.map +0 -1
- package/src/button/components/button/button.vue +0 -64
- package/src/button/components/button/index.ts +0 -2
- package/src/button/components/button/props.ts +0 -75
- package/src/button/components/fields/index.ts +0 -6
- package/src/button/hoc/index.ts +0 -1
- package/src/button/hoc/useButton.ts +0 -27
- package/src/button/index.ts +0 -4
- package/src/button/utils/index.ts +0 -32
- package/src/common/index.ts +0 -1
- package/src/common/utils/iconUtils.ts +0 -21
- package/src/common/utils/index.ts +0 -1
- package/src/form/components/fields/index.ts +0 -35
- package/src/form/components/form/form.vue +0 -130
- package/src/form/components/form/index.ts +0 -6
- package/src/form/components/form/props.ts +0 -73
- package/src/form/components/form-item/form-item.vue +0 -90
- package/src/form/components/form-item/index.ts +0 -6
- package/src/form/components/form-item/props.ts +0 -50
- package/src/form/hoc/index.ts +0 -3
- package/src/form/hoc/useForm.ts +0 -106
- package/src/form/hoc/useFormExpose.ts +0 -97
- package/src/form/hoc/useFormFetch.ts +0 -103
- package/src/form/index.ts +0 -5
- package/src/form/utils/index.ts +0 -149
- package/src/global.ts +0 -40
- package/src/index.ts +0 -37
- package/src/layout/components/fields/basic/basic.vue +0 -18
- package/src/layout/components/fields/index.ts +0 -10
- package/src/layout/components/fields/side/side.vue +0 -26
- package/src/layout/components/fields/top/top.vue +0 -13
- package/src/layout/components/layout/index.ts +0 -6
- package/src/layout/components/layout/layout.vue +0 -19
- package/src/layout/components/layout/props.ts +0 -3
- package/src/layout/hoc/index.ts +0 -1
- package/src/layout/hoc/useLayout.ts +0 -32
- package/src/layout/index.ts +0 -4
- package/src/layout/utils/index.ts +0 -31
- package/src/modal/components/form-modal/form-modal.vue +0 -158
- package/src/modal/components/form-modal/index.ts +0 -5
- package/src/modal/components/form-modal/props.ts +0 -61
- package/src/modal/components/modal/index.ts +0 -6
- package/src/modal/components/modal/modal.vue +0 -127
- package/src/modal/components/modal/props.ts +0 -78
- package/src/modal/hoc/index.ts +0 -3
- package/src/modal/hoc/useFormModal.ts +0 -140
- package/src/modal/hoc/useModal.ts +0 -151
- package/src/modal/hoc/useModalExpose.ts +0 -52
- package/src/modal/index.ts +0 -3
- package/src/style/index.css +0 -21
- package/src/table/components/fields/action-column/action-column.vue +0 -34
- package/src/table/components/fields/action-column/props.ts +0 -8
- package/src/table/components/fields/index.ts +0 -6
- package/src/table/components/table/index.ts +0 -6
- package/src/table/components/table/props.ts +0 -148
- package/src/table/components/table/table.vue +0 -77
- package/src/table/components/table-column/index.ts +0 -6
- package/src/table/components/table-column/props.ts +0 -26
- package/src/table/components/table-column/table-column.vue +0 -31
- package/src/table/components/table-page/index.ts +0 -6
- package/src/table/components/table-page/props.ts +0 -48
- package/src/table/components/table-page/table-page.vue +0 -51
- package/src/table/components/table-select/index.ts +0 -6
- package/src/table/components/table-select/props.ts +0 -79
- package/src/table/components/table-select/table-select.vue +0 -70
- package/src/table/hoc/index.ts +0 -2
- package/src/table/hoc/useTable.ts +0 -206
- package/src/table/hoc/useTableExpose.ts +0 -46
- package/src/table/index.ts +0 -7
- package/src/table/utils/index.ts +0 -37
- package/tsconfig.json +0 -30
- package/vite.config.ts +0 -49
package/README.md
CHANGED
|
@@ -27,17 +27,6 @@ yarn add @aoao-y33/ui
|
|
|
27
27
|
|
|
28
28
|
## 🚀 快速开始
|
|
29
29
|
|
|
30
|
-
### 全局引入
|
|
31
|
-
|
|
32
|
-
````typescript
|
|
33
|
-
import { createApp } from 'vue'
|
|
34
|
-
import AoaoUI from '@aoao-y33/ui'
|
|
35
|
-
import App from './App.vue'
|
|
36
|
-
const app = createApp(App)
|
|
37
|
-
app.use(AoaoUI)
|
|
38
|
-
app.mount('#app')
|
|
39
|
-
````
|
|
40
|
-
|
|
41
30
|
### 按需引入
|
|
42
31
|
|
|
43
32
|
```typescript
|
|
@@ -2,20 +2,63 @@ import { buttonFields } from '../..';
|
|
|
2
2
|
import { ButtonProps } from 'element-plus';
|
|
3
3
|
import { EmitsToEventProps } from '@aoao-y33/utils';
|
|
4
4
|
import { Component } from 'vue';
|
|
5
|
+
/**
|
|
6
|
+
* AxButton 按钮组件属性接口
|
|
7
|
+
* @template E - 事件数据类型,用于控制按钮显示/隐藏的上下文数据
|
|
8
|
+
* @template T - Element Plus ButtonProps 类型扩展
|
|
9
|
+
*/
|
|
5
10
|
export interface AxButtonProps<E = any, T = ButtonProps> {
|
|
11
|
+
/** 按钮显示的文本内容 */
|
|
6
12
|
text?: string;
|
|
13
|
+
/**
|
|
14
|
+
* 按钮类型,对应预定义的按钮样式配置
|
|
15
|
+
* @see buttonFields - 预定义的按钮类型映射表
|
|
16
|
+
*/
|
|
7
17
|
type?: keyof typeof buttonFields;
|
|
18
|
+
/** Element Plus 按钮的额外属性配置 */
|
|
8
19
|
componentProps?: T;
|
|
20
|
+
/** 自定义 CSS 类名 */
|
|
9
21
|
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* 按钮图标,支持字符串(图标类名)或 Vue 组件形式
|
|
24
|
+
* @example "el-icon-search" | IconComponent
|
|
25
|
+
*/
|
|
10
26
|
icon?: string | Component;
|
|
27
|
+
/**
|
|
28
|
+
* 按钮禁用状态控制
|
|
29
|
+
* - 布尔值:直接设置禁用状态
|
|
30
|
+
* - 函数:根据上下文数据动态计算禁用状态
|
|
31
|
+
* @param data - 传入的上下文数据
|
|
32
|
+
* @returns 是否禁用
|
|
33
|
+
*/
|
|
11
34
|
disabled?: ((data: E) => boolean) | (boolean);
|
|
35
|
+
/**
|
|
36
|
+
* 按钮隐藏状态控制
|
|
37
|
+
* - 布尔值:直接设置隐藏状态
|
|
38
|
+
* - 函数:根据上下文数据动态计算隐藏状态
|
|
39
|
+
* @param data - 传入的上下文数据
|
|
40
|
+
* @returns 是否隐藏
|
|
41
|
+
*/
|
|
12
42
|
hidden?: ((data: E) => boolean) | (boolean);
|
|
43
|
+
/** 是否添加左边距,用于按钮间距控制 */
|
|
13
44
|
isMl?: boolean;
|
|
14
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* AxButton 按钮组件事件发射接口
|
|
48
|
+
* @template T - 事件携带的数据类型
|
|
49
|
+
*/
|
|
15
50
|
export interface AxButtonEmits<T = any> {
|
|
51
|
+
/** 单击事件 */
|
|
16
52
|
"click": [data: T];
|
|
53
|
+
/** 双击事件 */
|
|
17
54
|
"dblClick": [data: T];
|
|
18
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* AxButton 按钮配置选项接口
|
|
58
|
+
* 继承自 AxButtonProps 并合并事件处理属性
|
|
59
|
+
* @template E - 事件数据类型
|
|
60
|
+
* @template T - Element Plus ButtonProps 类型扩展
|
|
61
|
+
*/
|
|
19
62
|
export interface AxButtonOptions<E = any, T = ButtonProps> extends AxButtonProps<E, T>, Partial<EmitsToEventProps<AxButtonEmits<E>>> {
|
|
20
63
|
}
|
|
21
64
|
//# sourceMappingURL=props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../../src/button/components/button/props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,KAAK,CAAC;AAEnC,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,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AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,WAAW,CACrD,SAAQ,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EACvB,OAAO,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;CACnD"}
|
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* 按钮类型注册表
|
|
4
|
+
* 存储自定义按钮类型与对应组件的映射关系
|
|
5
|
+
* @example
|
|
6
|
+
* // 注册自定义按钮
|
|
7
|
+
* addButtonField('primary', CustomButtonComponent)
|
|
8
|
+
*/
|
|
2
9
|
export declare const buttonFields: Record<string, Component>;
|
|
10
|
+
/**
|
|
11
|
+
* 注册新的按钮类型
|
|
12
|
+
* 将自定义按钮组件添加到按钮类型注册表中
|
|
13
|
+
*
|
|
14
|
+
* @param type - 按钮类型标识符(唯一)
|
|
15
|
+
* @param component - 对应的 Vue 组件
|
|
16
|
+
*
|
|
17
|
+
* @warning 如果类型已存在,会输出警告信息但不会阻止注册
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* import CustomButton from './CustomButton.vue'
|
|
21
|
+
* addButtonField('custom', CustomButton)
|
|
22
|
+
*/
|
|
3
23
|
export declare const addButtonField: (type: string, component: Component) => void;
|
|
4
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/button/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/button/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,KAAK,CAAC;AAEnC;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAK,CAAC;AAExD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAG,MAAK,MAAM,EAAC,WAAU,SAAS,SAO5D,CAAA"}
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 根据图标名称获取 Element Plus 图标组件
|
|
3
|
+
*
|
|
4
|
+
* @param icon - 图标名称(需与 Element Plus Icons 中的导出名称一致)
|
|
5
|
+
* @returns 对应的图标组件,如果不存在则返回 undefined
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // 获取搜索图标
|
|
9
|
+
* const SearchIcon = getIcons('Search')
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // 在模板中使用
|
|
13
|
+
* <component :is="getIcons('HomeFilled')" />
|
|
14
|
+
*
|
|
15
|
+
* @see {@link https://element-plus.org/zh-CN/component/icon.html Element Plus Icons}
|
|
16
|
+
*/
|
|
1
17
|
export declare const getIcons: (icon: string) => any;
|
|
2
18
|
//# sourceMappingURL=iconUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iconUtils.d.ts","sourceRoot":"","sources":["../../../src/common/utils/iconUtils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,QAEpC,CAAA"}
|
|
1
|
+
{"version":3,"file":"iconUtils.d.ts","sourceRoot":"","sources":["../../../src/common/utils/iconUtils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,QAEpC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/components/fields/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/components/fields/index.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,cAAc,YAmB1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.vue.d.ts","sourceRoot":"","sources":["../../../../src/form/components/form/form.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"form.vue.d.ts","sourceRoot":"","sources":["../../../../src/form/components/form/form.vue"],"names":[],"mappings":"AAqIA,OAAO,EAA+B,KAAK,YAAY,EAAC,MAAM,cAAc,CAAC;AAE7E,OAAO,KAAK,EAAc,WAAW,EAAC,MAAM,SAAS,CAAC;AAKtD,KAAK,WAAW,GAAG,WAAW,CAAC;AA6M/B,QAAA,IAAuB,QAAQ,IAAW,EAAE,QAAQ,IAAY,CAAE;AAClE,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,GAC7C;IAAE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAO/C,QAAA,MAAM,UAAU;;;;;;;;;;;0BAjJa,MAAM;;;wBAWR,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;;;;;;kFA0I5C,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -3,19 +3,62 @@ import { AxButtonOptions, AxButtonProps } from '../../../button';
|
|
|
3
3
|
import { FetchOptions, FieldsConfig, RequestFetch } from '@aoao-y33/hooks';
|
|
4
4
|
import { EmitsToEventProps } from '@aoao-y33/utils';
|
|
5
5
|
import { AxFormItemOptions } from '../..';
|
|
6
|
+
/**
|
|
7
|
+
* AxForm 表单组件属性接口
|
|
8
|
+
* 继承自 Element Plus FormProps,扩展了自定义功能
|
|
9
|
+
* @template T - 表单数据类型,必须是对象类型
|
|
10
|
+
*/
|
|
6
11
|
export interface AxFormProps<T extends Record<string, any> = any> extends Omit<FormProps, 'model'> {
|
|
12
|
+
/** 是否使用默认配置,启用后将自动应用预设的表单样式和行为 */
|
|
7
13
|
isDefault?: boolean;
|
|
14
|
+
/** 提交按钮的配置项,用于自定义表单提交按钮的外观和行为 */
|
|
8
15
|
submitButton?: AxButtonProps;
|
|
16
|
+
/** 表单提交时的加载状态,通常在异步请求期间显示 */
|
|
9
17
|
loading?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* API 请求函数,用于表单数据提交
|
|
20
|
+
* @see RequestFetch - 请求函数类型定义
|
|
21
|
+
*/
|
|
10
22
|
api?: RequestFetch<T, any>;
|
|
23
|
+
/**
|
|
24
|
+
* API 请求配置项,包含请求参数、拦截器等配置
|
|
25
|
+
* @see FetchOptions - 请求配置选项类型
|
|
26
|
+
*/
|
|
11
27
|
apiConfig?: FetchOptions<T, any>;
|
|
12
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* AxForm 表单组件事件发射接口
|
|
31
|
+
* @template T - 表单数据类型
|
|
32
|
+
*/
|
|
13
33
|
export interface AxFormEmits<T extends Record<string, any> = Record<string, any>> {
|
|
34
|
+
/**
|
|
35
|
+
* 表单提交事件
|
|
36
|
+
* @param data - 表单提交的数据
|
|
37
|
+
*/
|
|
14
38
|
'submit': [data: T];
|
|
39
|
+
/**
|
|
40
|
+
* 表单数据变化事件
|
|
41
|
+
* @param data - 变化后的表单数据
|
|
42
|
+
*/
|
|
15
43
|
'change': [data: T];
|
|
16
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* AxForm 表单配置选项接口
|
|
47
|
+
* 继承自 AxFormProps 并合并事件处理属性和字段配置
|
|
48
|
+
* @template T - 表单数据类型
|
|
49
|
+
*/
|
|
17
50
|
export interface AxFormOptions<T extends Record<string, any> = any> extends AxFormProps<T>, Partial<EmitsToEventProps<AxFormEmits<T>>> {
|
|
51
|
+
/**
|
|
52
|
+
* 按钮配置映射表,用于配置表单中的各种按钮(提交、重置等)
|
|
53
|
+
* @see FieldsConfig - 字段配置类型
|
|
54
|
+
* @see AxButtonOptions - 按钮选项类型
|
|
55
|
+
*/
|
|
18
56
|
buttonConfig?: FieldsConfig<AxButtonOptions>;
|
|
57
|
+
/**
|
|
58
|
+
* 表单项配置映射表,用于配置表单中各个字段的属性、验证规则等
|
|
59
|
+
* @see FieldsConfig - 字段配置类型
|
|
60
|
+
* @see AxFormItemOptions - 表单项选项类型
|
|
61
|
+
*/
|
|
19
62
|
fieldConfig?: FieldsConfig<AxFormItemOptions>;
|
|
20
63
|
}
|
|
21
64
|
//# sourceMappingURL=props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../../src/form/components/form/props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC9E,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../../src/form/components/form/props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC9E,OAAO,KAAK,EAAC,iB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
|
|
1
1
|
import { FormItemProps } from 'element-plus';
|
|
2
|
+
/**
|
|
3
|
+
* AxFormItem 表单项组件属性接口
|
|
4
|
+
* 继承自 Element Plus FormItemProps,扩展了自定义字段配置功能
|
|
5
|
+
*/
|
|
2
6
|
export interface AxFormItemProps extends FormItemProps {
|
|
7
|
+
/** 字段名称,用于表单数据绑定和验证的唯一标识 */
|
|
3
8
|
fieldName: string;
|
|
9
|
+
/** 表单项的标签文本,显示在输入框左侧或上方 */
|
|
4
10
|
label?: string;
|
|
11
|
+
/**
|
|
12
|
+
* 表单项类型,决定渲染的输入组件类型
|
|
13
|
+
* @example 'input' | 'select' | 'textarea' | 'date-picker' 等
|
|
14
|
+
*/
|
|
5
15
|
type?: string;
|
|
16
|
+
/**
|
|
17
|
+
* 验证规则类型数组,用于表单字段验证
|
|
18
|
+
* @example ['required', 'email', 'phone'] 等预定义验证规则
|
|
19
|
+
*/
|
|
6
20
|
vtypes?: string[];
|
|
21
|
+
/** 字段的默认值,当表单初始化时自动填充 */
|
|
7
22
|
defaultValue?: any;
|
|
23
|
+
/**
|
|
24
|
+
* 底层组件的额外属性配置
|
|
25
|
+
* 透传给实际渲染的输入组件(如 Input、Select 等)
|
|
26
|
+
*/
|
|
8
27
|
componentProps?: Record<string, any>;
|
|
28
|
+
/** 输入框的占位符文本,提示用户输入内容 */
|
|
9
29
|
placeholder?: string;
|
|
10
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* AxFormItem 表单项配置选项接口
|
|
33
|
+
* 继承自 AxFormItemProps,增加了插槽配置能力
|
|
34
|
+
*/
|
|
11
35
|
export interface AxFormItemOptions extends AxFormItemProps {
|
|
36
|
+
/**
|
|
37
|
+
* 自定义插槽配置,用于覆盖表单项的默认渲染内容
|
|
38
|
+
* key 为插槽名称,value 为插槽内容或渲染函数
|
|
39
|
+
* @example { default: () => h('div', '自定义内容') }
|
|
40
|
+
*/
|
|
12
41
|
slots?: Record<string, any>;
|
|
13
42
|
}
|
|
14
43
|
//# sourceMappingURL=props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../../src/form/components/form-item/props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAEhD,MAAM,WAAW,eAAgB,SAAQ,aAAa;IAClD,SAAS,EAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../../src/form/components/form-item/props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,aAAa;IAClD,4BAA4B;IAC5B,SAAS,EAAC,MAAM,CAAC;IAEjB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB,yBAAyB;IACzB,YAAY,CAAC,EAAE,GAAG,CAAC;IAEnB;;;OAGG;IACH,cAAc,CAAC,EAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAEnC,yBAAyB;IACzB,WAAW,CAAC,EAAC,MAAM,CAAA;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACtD;;;;OAIG;IACH,KAAK,CAAC,EAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC7B"}
|
|
@@ -2,12 +2,55 @@ import { AxFormItemOptions, AxFormOptions, FormApi, FormFetchApi } from '..';
|
|
|
2
2
|
import { AxButtonOptions } from '../../button';
|
|
3
3
|
import { FieldsApi, StateApi } from '@aoao-y33/hooks';
|
|
4
4
|
import { Component } from 'vue';
|
|
5
|
+
/**
|
|
6
|
+
* UseForm 返回值中的 API 接口
|
|
7
|
+
* 扩展了基础表单 API,提供完整的表单控制能力
|
|
8
|
+
* @template T - 表单数据类型
|
|
9
|
+
*/
|
|
5
10
|
export interface UseFormApi<T extends Record<string, any>> extends FormApi<T> {
|
|
11
|
+
/**
|
|
12
|
+
* 表单属性状态管理器
|
|
13
|
+
* 用于动态更新表单配置(不包含 buttonConfig 和 fieldConfig)
|
|
14
|
+
*/
|
|
6
15
|
setForm: StateApi<Omit<AxFormOptions, 'buttonConfig' | 'fieldConfig'>>;
|
|
16
|
+
/** 表单请求 API,用于执行表单提交等异步操作 */
|
|
7
17
|
requestApi: FormFetchApi<T>;
|
|
18
|
+
/** 按钮组件池 API,用于管理表单中的按钮配置 */
|
|
8
19
|
buttonsApi: FieldsApi<AxButtonOptions>;
|
|
20
|
+
/** 表单项组件池 API,用于管理表单字段的配置 */
|
|
9
21
|
fieldsApi: FieldsApi<AxFormItemOptions>;
|
|
10
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* UseForm Hook 的返回类型
|
|
25
|
+
* 包含渲染组件和 API 接口的元组
|
|
26
|
+
* @template T - 表单数据类型
|
|
27
|
+
*/
|
|
11
28
|
export type UseFormReturn<T extends Record<string, any>> = [Component, UseFormApi<T>];
|
|
29
|
+
/**
|
|
30
|
+
* 表单 Hook,用于创建可配置的表单组件
|
|
31
|
+
*
|
|
32
|
+
* 该 Hook 封装了表单的核心逻辑,包括:
|
|
33
|
+
* - 表单状态管理
|
|
34
|
+
* - 按钮和表单项的动态配置
|
|
35
|
+
* - 表单验证和提交
|
|
36
|
+
* - 组件渲染
|
|
37
|
+
*
|
|
38
|
+
* @param options - 表单初始配置选项
|
|
39
|
+
* @returns [Form 组件, Form API] 元组
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const [Form, formApi] = useForm({
|
|
43
|
+
* api: submitData,
|
|
44
|
+
* fieldConfig: { /* 字段配置 *\/ },
|
|
45
|
+
* buttonConfig: { /* 按钮配置 *\/ }
|
|
46
|
+
* })
|
|
47
|
+
*
|
|
48
|
+
* // 在模板中使用
|
|
49
|
+
* <Form />
|
|
50
|
+
*
|
|
51
|
+
* // 通过 API 操作表单
|
|
52
|
+
* formApi.fieldsApi.addField('username', { label: '用户名', type: 'input' })
|
|
53
|
+
* formApi.requestApi.submit()
|
|
54
|
+
*/
|
|
12
55
|
export declare function useForm<T extends Record<string, any>>(options?: AxFormOptions<T>): UseFormReturn<T>;
|
|
13
56
|
//# sourceMappingURL=useForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../src/form/hoc/useForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,iBAAiB,EAA8B,MAAM,QAAQ,CAAC;AAE/F,OAAO,EAAE,KAAK,eAAe,EAAC,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAC,KAAK,SAAS,EAA6B,MAAM,iBAAiB,CAAC;AAE3E,OAAO,KAAK,EAAiB,aAAa,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,QAAQ,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAC,KAAK,SAAS,EAAoC,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../src/form/hoc/useForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,iBAAiB,EAA8B,MAAM,QAAQ,CAAC;AAE/F,OAAO,EAAE,KAAK,eAAe,EAAC,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAC,KAAK,SAAS,EAA6B,MAAM,iBAAiB,CAAC;AAE3E,OAAO,KAAK,EAAiB,aAAa,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,QAAQ,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAC,KAAK,SAAS,EAAoC,MAAM,KAAK,CAAC;AAEtE;;;;GAIG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IACzE;;;OAGG;IACH,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,GAAC,aAAa,CAAC,CAAC,CAAA;IAEpE,6BAA6B;IAC7B,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAE3B,6BAA6B;IAC7B,UAAU,EAAE,SAAS,CAAC,eAAe,CAAC,CAAA;IAEtC,6BAA6B;IAC7B,SAAS,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAA;CAC1C;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAE,aAAa,CAAC,CAAC,CAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAyCvG"}
|
|
@@ -1,9 +1,74 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
2
|
import { FormItemRule } from 'element-plus';
|
|
3
|
+
/**
|
|
4
|
+
* 表单项验证规则类型
|
|
5
|
+
* 支持三种形式的规则定义:
|
|
6
|
+
* - 直接的 FormItemRule 对象
|
|
7
|
+
* - 返回 FormItemRule 的函数(无参数)
|
|
8
|
+
* - 返回 FormItemRule 的函数(接收类型和标签参数)
|
|
9
|
+
*/
|
|
3
10
|
export type VFormItemRule = FormItemRule | (() => FormItemRule) | ((type: string, label?: string) => FormItemRule);
|
|
11
|
+
/**
|
|
12
|
+
* 表单字段组件注册表
|
|
13
|
+
* 存储字段类型与对应 Vue 组件的映射关系
|
|
14
|
+
* @example
|
|
15
|
+
* // 注册自定义输入组件
|
|
16
|
+
* formFields['custom-input'] = CustomInputComponent
|
|
17
|
+
*/
|
|
4
18
|
export declare const formFields: Record<string, Component>;
|
|
19
|
+
/**
|
|
20
|
+
* 表单验证规则注册表
|
|
21
|
+
* 预定义了常用的表单验证规则
|
|
22
|
+
*
|
|
23
|
+
* 内置规则包括:
|
|
24
|
+
* - required: 必填验证,根据字段类型自动显示"请输入"或"请选择"
|
|
25
|
+
* - required2: 自定义验证器实现的必填验证
|
|
26
|
+
* - phone: 手机号格式验证(11位数字,以1开头,第二位3-9)
|
|
27
|
+
* - tel: 电话号码格式验证(带可选区号)
|
|
28
|
+
* - mail: 邮箱地址格式验证
|
|
29
|
+
*/
|
|
5
30
|
export declare const formRules: Record<string, VFormItemRule>;
|
|
31
|
+
/**
|
|
32
|
+
* 注册新的表单字段组件
|
|
33
|
+
* 将自定义组件添加到表单字段注册表中
|
|
34
|
+
*
|
|
35
|
+
* @param type - 字段类型标识符(唯一)
|
|
36
|
+
* @param component - 对应的 Vue 组件
|
|
37
|
+
*
|
|
38
|
+
* @warning 如果类型已存在,会输出警告信息并阻止重复注册
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* import CustomInput from './CustomInput.vue'
|
|
42
|
+
* addFormField('custom-input', CustomInput)
|
|
43
|
+
*/
|
|
6
44
|
export declare const addFormField: (type: string, component: Component) => void;
|
|
45
|
+
/**
|
|
46
|
+
* 注册新的表单验证规则
|
|
47
|
+
* 将自定义验证规则添加到规则注册表中
|
|
48
|
+
*
|
|
49
|
+
* @param type - 规则类型标识符(唯一)
|
|
50
|
+
* @param rule - 验证规则对象或函数
|
|
51
|
+
*
|
|
52
|
+
* @throws 如果规则类型已存在,抛出错误信息
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* addFormRules('idCard', (type, label) => ({
|
|
56
|
+
* pattern: /^\d{17}[\dXx]$/,
|
|
57
|
+
* message: `${label}身份证号格式错误`
|
|
58
|
+
* }))
|
|
59
|
+
*/
|
|
7
60
|
export declare const addFormRules: (type: string, rule: any) => void;
|
|
61
|
+
/**
|
|
62
|
+
* 根据字段类型获取验证提示前缀
|
|
63
|
+
* 对于选择类组件返回"请选择",其他类型返回"请输入"
|
|
64
|
+
*
|
|
65
|
+
* @param type - 字段类型
|
|
66
|
+
* @returns 提示文本前缀
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* isTip('input') // "请输入"
|
|
70
|
+
* isTip('select') // "请选择"
|
|
71
|
+
* isTip('checkbox') // "请选择"
|
|
72
|
+
*/
|
|
8
73
|
export declare const isTip: (type: string) => "请选择" | "请输入";
|
|
9
74
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/form/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAE/C,MAAM,MAAM,aAAa,GACrB,YAAY,GACV,CAAC,MAAM,YAAY,CAAC,GACpB,CAAC,CAAC,IAAI,EAAE,MAAM,EAAC,KAAK,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/form/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GACrB,YAAY,GACV,CAAC,MAAM,YAAY,CAAC,GACpB,CAAC,CAAC,IAAI,EAAE,MAAM,EAAC,KAAK,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC,CAAA;AAErD;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAM,CAAC;AAExD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,EAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAmDlD,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,WAAW,SAAS,SAM9D,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,GAAE,MAAK,MAAM,EAAC,MAAK,GAAG,SAK9C,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,KAAK,GAAE,MAAK,MAAM,kBAK9B,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { App } from 'vue';
|
|
2
1
|
export * from './modal';
|
|
3
2
|
export * from './button';
|
|
4
3
|
export * from './form';
|
|
5
4
|
export * from './layout';
|
|
6
5
|
export * from './table';
|
|
7
6
|
export * from './common';
|
|
8
|
-
declare const _default: {
|
|
9
|
-
install(app: App): void;
|
|
10
|
-
};
|
|
11
|
-
export default _default;
|
|
12
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAC;AAM3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|