@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
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
import { AxTableOptions } from '..';
|
|
2
2
|
import { AxFormItemOptions } from '../../form';
|
|
3
3
|
import { AxButtonOptions } from '../../button';
|
|
4
|
+
/**
|
|
5
|
+
* 表格 Hook,用于创建功能完整的高级表格组件
|
|
6
|
+
*
|
|
7
|
+
* 该 Hook 封装了表格的核心逻辑,包括:
|
|
8
|
+
* - 表格数据展示和分页
|
|
9
|
+
* - 搜索表单(支持动态字段配置)
|
|
10
|
+
* - 工具栏按钮(新增、删除、导出等)
|
|
11
|
+
* - 表格列配置(支持动态列)
|
|
12
|
+
* - 折叠/展开搜索区域
|
|
13
|
+
* - 数据请求和状态管理
|
|
14
|
+
*
|
|
15
|
+
* @param options - 表格初始配置选项
|
|
16
|
+
* @returns [Table 组件, Table API] 元组
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const [Table, tableApi] = useTable({
|
|
20
|
+
* api: getUserList,
|
|
21
|
+
* columnConfig: {
|
|
22
|
+
* username: { label: '用户名', prop: 'username' },
|
|
23
|
+
* email: { label: '邮箱', prop: 'email' }
|
|
24
|
+
* },
|
|
25
|
+
* searchConfig: {
|
|
26
|
+
* fieldConfig: {
|
|
27
|
+
* keyword: { label: '关键词', type: 'input' }
|
|
28
|
+
* },
|
|
29
|
+
* over: 2 // 超过2个字段显示折叠按钮
|
|
30
|
+
* },
|
|
31
|
+
* toolConfig: {
|
|
32
|
+
* add: { text: '新增', onClick: handleAdd }
|
|
33
|
+
* },
|
|
34
|
+
* pageConfig: { pageSize: 10 }
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* // 在模板中使用
|
|
38
|
+
* <Table />
|
|
39
|
+
*
|
|
40
|
+
* // 通过 API 操作表格
|
|
41
|
+
* tableApi.requestApi.fetch() // 刷新数据
|
|
42
|
+
* tableApi.setTable({ data: [] }) // 更新表格属性
|
|
43
|
+
* tableApi.toolsApi.addField(...) // 动态添加工具栏按钮
|
|
44
|
+
*/
|
|
4
45
|
export declare function useTable<T extends Record<string, any>, R extends Record<string, any> = any>(options?: AxTableOptions<T, R>): readonly [import('vue').DefineComponent<{}, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
5
46
|
[key: string]: any;
|
|
6
47
|
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTable.d.ts","sourceRoot":"","sources":["../../../src/table/hoc/useTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,KAAK,cAAc,EAEtB,MAAM,SAAS,CAAC;AAIjB,OAAO,EAAa,KAAK,iBAAiB,EAA8B,MAAM,QAAQ,CAAC;AACvF,OAAO,EAAW,KAAK,eAAe,EAAC,MAAM,UAAU,CAAC;AAExD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useTable.d.ts","sourceRoot":"","sources":["../../../src/table/hoc/useTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,KAAK,cAAc,EAEtB,MAAM,SAAS,CAAC;AAIjB,OAAO,EAAa,KAAK,iBAAiB,EAA8B,MAAM,QAAQ,CAAC;AACvF,OAAO,EAAW,KAAK,eAAe,EAAC,MAAM,UAAU,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsJ9H"}
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
2
|
import { AxTableInstance } from '..';
|
|
3
|
+
/**
|
|
4
|
+
* TableApi 类型定义
|
|
5
|
+
* 由 useTableExpose 函数返回的 API 对象类型
|
|
6
|
+
*/
|
|
3
7
|
export type TableApi = ReturnType<typeof useTableExpose>;
|
|
8
|
+
/**
|
|
9
|
+
* 表格暴露 API Hook,用于获取和控制表格实例的方法
|
|
10
|
+
*
|
|
11
|
+
* 该 Hook 提供了访问底层表格实例的能力,包括:
|
|
12
|
+
* - 获取 Element Plus 原生 ElTable 实例
|
|
13
|
+
* - 可调用 ElTable 的所有方法(如 clearSort、clearFilter、toggleRowSelection 等)
|
|
14
|
+
*
|
|
15
|
+
* @param table - 表格组件的 Ref 引用,指向 AxTableInstance 实例
|
|
16
|
+
* @returns 包含表格控制方法的 API 对象
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const tableRef = ref<AxTableInstance>();
|
|
20
|
+
* const tableApi = useTableExpose(tableRef);
|
|
21
|
+
*
|
|
22
|
+
* // 获取原生 ElTable 实例
|
|
23
|
+
* const elTable = tableApi.getElTable()
|
|
24
|
+
*
|
|
25
|
+
* // 调用 ElTable 的原生方法
|
|
26
|
+
* elTable?.clearSort() // 清除排序
|
|
27
|
+
* elTable?.clearFilter() // 清除筛选
|
|
28
|
+
* elTable?.toggleAllSelection() // 切换全选状态
|
|
29
|
+
* elTable?.setCurrentRow(row) // 设置当前行
|
|
30
|
+
*/
|
|
4
31
|
export declare function useTableExpose(table: Ref<AxTableInstance>): {
|
|
5
32
|
getElTable: () => import('element-plus').TableInstance;
|
|
6
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableExpose.d.ts","sourceRoot":"","sources":["../../../src/table/hoc/useTableExpose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;AAExD,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,eAAe,CAAC;;
|
|
1
|
+
{"version":3,"file":"useTableExpose.d.ts","sourceRoot":"","sources":["../../../src/table/hoc/useTableExpose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,eAAe,CAAC;;EAazD"}
|
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* 表格列组件注册表
|
|
4
|
+
* 存储表格列类型与对应 Vue 组件的映射关系
|
|
5
|
+
* 用于扩展表格列的自定义渲染方式
|
|
6
|
+
* @example
|
|
7
|
+
* // 注册自定义列类型
|
|
8
|
+
* addTableColumnField('custom-render', CustomColumnComponent)
|
|
9
|
+
*/
|
|
2
10
|
export declare const tableColumnFields: Record<string, Component>;
|
|
11
|
+
/**
|
|
12
|
+
* 注册新的表格列类型组件
|
|
13
|
+
* 将自定义列组件添加到表格列类型注册表中
|
|
14
|
+
*
|
|
15
|
+
* @param type - 列类型标识符(唯一)
|
|
16
|
+
* @param component - 对应的 Vue 组件,用于渲染该类型的列内容
|
|
17
|
+
*
|
|
18
|
+
* @warning 如果类型已存在,会输出警告信息并阻止重复注册
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* import StatusColumn from './StatusColumn.vue'
|
|
22
|
+
* addTableColumnField('status', StatusColumn)
|
|
23
|
+
*
|
|
24
|
+
* // 在表格列配置中使用
|
|
25
|
+
* columnConfig: {
|
|
26
|
+
* status: { type: 'status', label: '状态' }
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
3
29
|
export declare const addTableColumnField: (type: string, component: Component) => void;
|
|
4
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/table/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,KAAK,CAAC;AAEnC,eAAO,MAAM,iBAAiB,EAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAI,CAAC;AAE5D,eAAO,MAAM,mBAAmB,GAAE,MAAK,MAAM,EAAC,WAAU,SAAS,SAMhE,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/table/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,KAAK,CAAC;AAEnC;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,EAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAI,CAAC;AAE5D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,GAAE,MAAK,MAAM,EAAC,WAAU,SAAS,SAMhE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,37 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aoao-y33/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "elementPlus二次封装组件",
|
|
6
|
+
|
|
6
7
|
"main": "./dist/index.js",
|
|
7
8
|
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js"
|
|
13
13
|
},
|
|
14
|
+
"./global": {
|
|
15
|
+
"types": "./global.d.ts"
|
|
16
|
+
},
|
|
14
17
|
"./dist/index.css": {
|
|
15
18
|
"import": "./dist/index.css"
|
|
16
19
|
}
|
|
17
20
|
},
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
18
22
|
"sideEffects": [
|
|
19
23
|
"*.css",
|
|
20
24
|
"*.less",
|
|
21
25
|
"*.scss"
|
|
22
26
|
],
|
|
23
27
|
"scripts": {
|
|
24
|
-
"build":
|
|
28
|
+
"build":"vue-tsc && vite build",
|
|
25
29
|
"ins": "pnpm install",
|
|
26
|
-
"pub": "npm publish
|
|
30
|
+
"pub": "npm publish --access public"
|
|
27
31
|
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
28
35
|
"keywords": [],
|
|
29
36
|
"author": "",
|
|
30
37
|
"license": "ISC",
|
|
31
38
|
"packageManager": "pnpm@10.32.1",
|
|
32
39
|
"dependencies": {
|
|
33
|
-
"@aoao-y33/hooks": "
|
|
34
|
-
"@aoao-y33/utils": "
|
|
40
|
+
"@aoao-y33/hooks": "^0.0.3",
|
|
41
|
+
"@aoao-y33/utils": "^0.0.2",
|
|
35
42
|
"@element-plus/icons-vue": "^2.3.2",
|
|
36
43
|
"element-plus": "^2.14.0"
|
|
37
44
|
},
|
package/dist/global.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AxButton } from './button';
|
|
2
|
-
import { AxForm, AxFormItem } from './form';
|
|
3
|
-
import { AxLayout } from './layout';
|
|
4
|
-
import { AxModal } from './modal';
|
|
5
|
-
import { AxTable, AxTablePage, AxTableSelect, AxTableColumn } from './table';
|
|
6
|
-
declare module 'vue' {
|
|
7
|
-
interface GlobalComponents {
|
|
8
|
-
AxButton: typeof AxButton;
|
|
9
|
-
AxForm: typeof AxForm;
|
|
10
|
-
AxFormItem: typeof AxFormItem;
|
|
11
|
-
AxLayout: typeof AxLayout;
|
|
12
|
-
AxModal: typeof AxModal;
|
|
13
|
-
AxTable: typeof AxTable;
|
|
14
|
-
AxTablePage: typeof AxTablePage;
|
|
15
|
-
AxTableSelect: typeof AxTableSelect;
|
|
16
|
-
AxTableColumn: typeof AxTableColumn;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
declare module 'vue' {
|
|
20
|
-
interface GlobalComponents {
|
|
21
|
-
'ax-button': typeof AxButton;
|
|
22
|
-
'ax-form': typeof AxForm;
|
|
23
|
-
'ax-form-item': typeof AxFormItem;
|
|
24
|
-
'ax-layout': typeof AxLayout;
|
|
25
|
-
'ax-modal': typeof AxModal;
|
|
26
|
-
'ax-table': typeof AxTable;
|
|
27
|
-
'ax-table-page': typeof AxTablePage;
|
|
28
|
-
'ax-table-select': typeof AxTableSelect;
|
|
29
|
-
'ax-table-column': typeof AxTableColumn;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=global.d.ts.map
|
package/dist/global.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../src/global.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEjF,OAAO,QAAQ,KAAK,CAAC;IACjB,UAAiB,gBAAgB;QAC7B,QAAQ,EAAE,OAAO,QAAQ,CAAA;QACzB,MAAM,EAAE,OAAO,MAAM,CAAA;QACrB,UAAU,EAAE,OAAO,UAAU,CAAA;QAC7B,QAAQ,EAAE,OAAO,QAAQ,CAAA;QACzB,OAAO,EAAE,OAAO,OAAO,CAAA;QACvB,OAAO,EAAE,OAAO,OAAO,CAAA;QACvB,WAAW,EAAE,OAAO,WAAW,CAAA;QAC/B,aAAa,EAAE,OAAO,aAAa,CAAA;QACnC,aAAa,EAAE,OAAO,aAAa,CAAA;KACtC;CACJ;AAGD,OAAO,QAAQ,KAAK,CAAC;IACjB,UAAiB,gBAAgB;QAC7B,WAAW,EAAE,OAAO,QAAQ,CAAA;QAC5B,SAAS,EAAE,OAAO,MAAM,CAAA;QACxB,cAAc,EAAE,OAAO,UAAU,CAAA;QACjC,WAAW,EAAE,OAAO,QAAQ,CAAA;QAC5B,UAAU,EAAE,OAAO,OAAO,CAAA;QAC1B,UAAU,EAAE,OAAO,OAAO,CAAA;QAC1B,eAAe,EAAE,OAAO,WAAW,CAAA;QACnC,iBAAiB,EAAE,OAAO,aAAa,CAAA;QACvC,iBAAiB,EAAE,OAAO,aAAa,CAAA;KAC1C;CACJ;AAED,OAAO,EAAE,CAAA"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import {buttonFields} from "@/button/utils";
|
|
3
|
-
import type {AxButtonProps, AxButtonEmits} from "./props";
|
|
4
|
-
import {computed, inject, useSlots} from "vue";
|
|
5
|
-
import {getIcons} from "@/common";
|
|
6
|
-
defineOptions({name: 'AxButton'})
|
|
7
|
-
const {
|
|
8
|
-
type = 'default',
|
|
9
|
-
text = '',
|
|
10
|
-
className = '',
|
|
11
|
-
disabled = false,
|
|
12
|
-
hidden = false,
|
|
13
|
-
icon='',
|
|
14
|
-
isMl=true,
|
|
15
|
-
componentProps = {}
|
|
16
|
-
} = defineProps<AxButtonProps>()
|
|
17
|
-
const emits = defineEmits<AxButtonEmits>()
|
|
18
|
-
const slots = useSlots();
|
|
19
|
-
const clickData = inject('clickData', null);
|
|
20
|
-
const ButtonField = computed(() => {
|
|
21
|
-
return buttonFields[type]
|
|
22
|
-
})
|
|
23
|
-
const onClick = (e: Event) => {
|
|
24
|
-
emits('click', clickData ? clickData : e)
|
|
25
|
-
}
|
|
26
|
-
const onDblClick = (e: Event) => {
|
|
27
|
-
emits('dblClick', clickData ? clickData : e)
|
|
28
|
-
}
|
|
29
|
-
const getDisabled = () => {
|
|
30
|
-
if (typeof disabled === "function") {
|
|
31
|
-
return disabled(clickData)
|
|
32
|
-
}
|
|
33
|
-
return disabled
|
|
34
|
-
}
|
|
35
|
-
const getHidden = () => {
|
|
36
|
-
if (typeof hidden === "function") {
|
|
37
|
-
return hidden(clickData)
|
|
38
|
-
}
|
|
39
|
-
return hidden
|
|
40
|
-
}
|
|
41
|
-
const Icon = computed(()=>{
|
|
42
|
-
if(typeof icon === 'string'){
|
|
43
|
-
return getIcons(icon)
|
|
44
|
-
}
|
|
45
|
-
return icon||null;
|
|
46
|
-
})
|
|
47
|
-
</script>
|
|
48
|
-
<template>
|
|
49
|
-
<ButtonField v-bind="componentProps"
|
|
50
|
-
@click="onClick"
|
|
51
|
-
@dblclick="onDblClick"
|
|
52
|
-
:class="[className,{'ml-0!':!isMl}]"
|
|
53
|
-
:disabled="getDisabled()"
|
|
54
|
-
v-if="!getHidden()"
|
|
55
|
-
:icon="Icon"
|
|
56
|
-
>
|
|
57
|
-
<template v-if="!slots.default">
|
|
58
|
-
<span>{{ text }}</span>
|
|
59
|
-
</template>
|
|
60
|
-
<template v-else>
|
|
61
|
-
<slot></slot>
|
|
62
|
-
</template>
|
|
63
|
-
</ButtonField>
|
|
64
|
-
</template>
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {buttonFields} from "@/button";
|
|
2
|
-
import type {ButtonProps} from "element-plus";
|
|
3
|
-
import type {EmitsToEventProps} from '@aoao-y33/utils';
|
|
4
|
-
import type {Component} from "vue";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* AxButton 按钮组件属性接口
|
|
8
|
-
* @template E - 事件数据类型,用于控制按钮显示/隐藏的上下文数据
|
|
9
|
-
* @template T - Element Plus ButtonProps 类型扩展
|
|
10
|
-
*/
|
|
11
|
-
export interface AxButtonProps<E = any, T = ButtonProps> {
|
|
12
|
-
/** 按钮显示的文本内容 */
|
|
13
|
-
text?: string
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 按钮类型,对应预定义的按钮样式配置
|
|
17
|
-
* @see buttonFields - 预定义的按钮类型映射表
|
|
18
|
-
*/
|
|
19
|
-
type?: keyof typeof buttonFields
|
|
20
|
-
|
|
21
|
-
/** Element Plus 按钮的额外属性配置 */
|
|
22
|
-
componentProps?: T
|
|
23
|
-
|
|
24
|
-
/** 自定义 CSS 类名 */
|
|
25
|
-
className?: string,
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 按钮图标,支持字符串(图标类名)或 Vue 组件形式
|
|
29
|
-
* @example "el-icon-search" | IconComponent
|
|
30
|
-
*/
|
|
31
|
-
icon?:string|Component,
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 按钮禁用状态控制
|
|
35
|
-
* - 布尔值:直接设置禁用状态
|
|
36
|
-
* - 函数:根据上下文数据动态计算禁用状态
|
|
37
|
-
* @param data - 传入的上下文数据
|
|
38
|
-
* @returns 是否禁用
|
|
39
|
-
*/
|
|
40
|
-
disabled?: ((data: E) => boolean) | (boolean)
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 按钮隐藏状态控制
|
|
44
|
-
* - 布尔值:直接设置隐藏状态
|
|
45
|
-
* - 函数:根据上下文数据动态计算隐藏状态
|
|
46
|
-
* @param data - 传入的上下文数据
|
|
47
|
-
* @returns 是否隐藏
|
|
48
|
-
*/
|
|
49
|
-
hidden?: ((data: E) => boolean) | (boolean)
|
|
50
|
-
|
|
51
|
-
/** 是否添加左边距,用于按钮间距控制 */
|
|
52
|
-
isMl?:boolean
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* AxButton 按钮组件事件发射接口
|
|
57
|
-
* @template T - 事件携带的数据类型
|
|
58
|
-
*/
|
|
59
|
-
export interface AxButtonEmits<T = any> {
|
|
60
|
-
/** 单击事件 */
|
|
61
|
-
"click": [data: T]
|
|
62
|
-
/** 双击事件 */
|
|
63
|
-
"dblClick": [data: T]
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* AxButton 按钮配置选项接口
|
|
68
|
-
* 继承自 AxButtonProps 并合并事件处理属性
|
|
69
|
-
* @template E - 事件数据类型
|
|
70
|
-
* @template T - Element Plus ButtonProps 类型扩展
|
|
71
|
-
*/
|
|
72
|
-
export interface AxButtonOptions<E = any, T = ButtonProps>
|
|
73
|
-
extends AxButtonProps<E, T>,
|
|
74
|
-
Partial<EmitsToEventProps<AxButtonEmits<E>>> {
|
|
75
|
-
}
|
package/src/button/hoc/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useButton';
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {AxButton, type AxButtonOptions} from "@/button";
|
|
2
|
-
import {useState} from "@aoao-y33/hooks";
|
|
3
|
-
import {defineComponent, h} from "vue";
|
|
4
|
-
import type {ButtonProps} from "element-plus";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 按钮高阶函数 - 用于创建可动态配置的按钮组件
|
|
8
|
-
*
|
|
9
|
-
* @template E - 事件类型,默认为 any
|
|
10
|
-
* @template T - 按钮属性类型,默认为 ButtonProps
|
|
11
|
-
* @param options - 按钮初始配置选项
|
|
12
|
-
* @returns 返回一个元组 [Button组件, setButton更新函数]
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const [MyButton, setButton] = useButton({ text: '点击' });
|
|
16
|
-
* // 后续可以通过 setButton 动态更新按钮属性
|
|
17
|
-
* setButton({ text: '新文本', disabled: true });
|
|
18
|
-
*/
|
|
19
|
-
export function useButton<E=any,T=ButtonProps>(options:AxButtonOptions<E,T>={}){
|
|
20
|
-
const [props,setButton] = useState(options);
|
|
21
|
-
const Button = defineComponent({
|
|
22
|
-
setup(){
|
|
23
|
-
return ()=>h(AxButton as any,{...props.value})
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
return [Button,setButton] as const;
|
|
27
|
-
}
|
package/src/button/index.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type {Component} from "vue";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 按钮类型注册表
|
|
5
|
-
* 存储自定义按钮类型与对应组件的映射关系
|
|
6
|
-
* @example
|
|
7
|
-
* // 注册自定义按钮
|
|
8
|
-
* addButtonField('primary', CustomButtonComponent)
|
|
9
|
-
*/
|
|
10
|
-
export const buttonFields:Record<string, Component>= {};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 注册新的按钮类型
|
|
14
|
-
* 将自定义按钮组件添加到按钮类型注册表中
|
|
15
|
-
*
|
|
16
|
-
* @param type - 按钮类型标识符(唯一)
|
|
17
|
-
* @param component - 对应的 Vue 组件
|
|
18
|
-
*
|
|
19
|
-
* @warning 如果类型已存在,会输出警告信息但不会阻止注册
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* import CustomButton from './CustomButton.vue'
|
|
23
|
-
* addButtonField('custom', CustomButton)
|
|
24
|
-
*/
|
|
25
|
-
export const addButtonField =(type:string,component:Component)=>{
|
|
26
|
-
// 检查是否已存在相同类型的按钮
|
|
27
|
-
for (type in buttonFields){
|
|
28
|
-
console.warn(`[AxButton] Button type ${type} already exists`)
|
|
29
|
-
}
|
|
30
|
-
// 注册新的按钮类型
|
|
31
|
-
buttonFields[type] = component;
|
|
32
|
-
}
|
package/src/common/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './utils';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as Icons from '@element-plus/icons-vue';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 根据图标名称获取 Element Plus 图标组件
|
|
5
|
-
*
|
|
6
|
-
* @param icon - 图标名称(需与 Element Plus Icons 中的导出名称一致)
|
|
7
|
-
* @returns 对应的图标组件,如果不存在则返回 undefined
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // 获取搜索图标
|
|
11
|
-
* const SearchIcon = getIcons('Search')
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* // 在模板中使用
|
|
15
|
-
* <component :is="getIcons('HomeFilled')" />
|
|
16
|
-
*
|
|
17
|
-
* @see {@link https://element-plus.org/zh-CN/component/icon.html Element Plus Icons}
|
|
18
|
-
*/
|
|
19
|
-
export const getIcons = (icon: string) => {
|
|
20
|
-
return (Icons as any)[icon];
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './iconUtils';
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ElInput,
|
|
3
|
-
ElSelect,
|
|
4
|
-
ElCascader,
|
|
5
|
-
ElRadioGroup,
|
|
6
|
-
ElCheckboxGroup,
|
|
7
|
-
ElColorPicker,
|
|
8
|
-
ElColorPickerPanel,
|
|
9
|
-
ElDatePicker, ElTimePicker, ElInputNumber,
|
|
10
|
-
ElInputOtp,
|
|
11
|
-
ElSwitch, ElRate, ElSlider, ElUpload,
|
|
12
|
-
ElSelectV2, ElTransfer, ElTreeSelect,
|
|
13
|
-
} from "element-plus";
|
|
14
|
-
import {addFormField} from "@/form";
|
|
15
|
-
|
|
16
|
-
export const initFormFields = () => {
|
|
17
|
-
addFormField('text', ElInput);
|
|
18
|
-
addFormField('select', ElSelect);
|
|
19
|
-
addFormField('cascade', ElCascader);
|
|
20
|
-
addFormField('radio', ElRadioGroup);
|
|
21
|
-
addFormField('checkbox', ElCheckboxGroup);
|
|
22
|
-
addFormField("color", ElColorPicker);
|
|
23
|
-
addFormField("date", ElDatePicker);
|
|
24
|
-
addFormField("time", ElTimePicker);
|
|
25
|
-
addFormField("number", ElInputNumber);
|
|
26
|
-
addFormField("color-panel", ElColorPickerPanel);
|
|
27
|
-
addFormField("otp", ElInputOtp);
|
|
28
|
-
addFormField("rate", ElRate);
|
|
29
|
-
addFormField("switch", ElSwitch);
|
|
30
|
-
addFormField("slider", ElSlider);
|
|
31
|
-
addFormField("upload", ElUpload);
|
|
32
|
-
addFormField("transfer", ElTransfer);
|
|
33
|
-
addFormField("select-v2", ElSelectV2);
|
|
34
|
-
addFormField("tree", ElTreeSelect);
|
|
35
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import {ElForm, ElFormItem, vLoading, type FormInstance} from "element-plus";
|
|
3
|
-
import {AxButton} from "@/button";
|
|
4
|
-
import type {AxFormEmits, AxFormProps} from "./props";
|
|
5
|
-
import {useDefineProps, useFetch} from "@aoao-y33/hooks";
|
|
6
|
-
import {computed, provide, reactive, type Ref, ref, useSlots, watch} from "vue";
|
|
7
|
-
|
|
8
|
-
defineOptions({name: 'AxForm'})
|
|
9
|
-
const {
|
|
10
|
-
isDefault = true,
|
|
11
|
-
submitButton = {},
|
|
12
|
-
loading = false,
|
|
13
|
-
api = null,
|
|
14
|
-
apiConfig = {},
|
|
15
|
-
...props
|
|
16
|
-
} = defineProps<AxFormProps>();
|
|
17
|
-
|
|
18
|
-
const emits = defineEmits<AxFormEmits>()
|
|
19
|
-
|
|
20
|
-
const slots = useSlots();
|
|
21
|
-
|
|
22
|
-
const formProps = useDefineProps(props);
|
|
23
|
-
|
|
24
|
-
const defaultButton = useDefineProps(submitButton, {
|
|
25
|
-
text: "提交",
|
|
26
|
-
icon: "CircleCheckFilled",
|
|
27
|
-
componentProps: {
|
|
28
|
-
type: "primary",
|
|
29
|
-
nativeType: "submit",
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
const formData = reactive({});
|
|
34
|
-
|
|
35
|
-
provide("formData", formData);
|
|
36
|
-
|
|
37
|
-
provide("clickData", formData);
|
|
38
|
-
|
|
39
|
-
const defaultData = reactive({});
|
|
40
|
-
|
|
41
|
-
provide("defaultData", defaultData);
|
|
42
|
-
|
|
43
|
-
const [, requestApi] = useFetch(api, apiConfig)
|
|
44
|
-
|
|
45
|
-
watch(() => formData, () => {
|
|
46
|
-
emits("change", formData);
|
|
47
|
-
}, {immediate: true})
|
|
48
|
-
|
|
49
|
-
const formRef = ref<FormInstance>() as Ref<FormInstance>;
|
|
50
|
-
|
|
51
|
-
const _loading = computed(() => {
|
|
52
|
-
return Boolean(loading || requestApi.getConfig().loading);
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const onSubmit = () => {
|
|
56
|
-
formRef.value?.validate().then(async (res) => {
|
|
57
|
-
if (res) {
|
|
58
|
-
if (requestApi.getReady()) {
|
|
59
|
-
await requestApi.load(formData);
|
|
60
|
-
} else {
|
|
61
|
-
emits("submit", formData);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const getElForm = () => {
|
|
69
|
-
return formRef.value
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const getValues = () => {
|
|
73
|
-
return Object.assign({}, formData);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const getValue = (fieldName: string) => {
|
|
77
|
-
return (formData as Record<string, any>)[fieldName]
|
|
78
|
-
}
|
|
79
|
-
const getFields = () => {
|
|
80
|
-
return Object.keys(formData);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const getDefaultValues = () => {
|
|
84
|
-
return Object.assign({}, defaultData);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const setValues = (values: Record<string, any>) => {
|
|
88
|
-
Object.assign(formData, values);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const resetValues = () => {
|
|
92
|
-
Object.assign(formData, defaultData);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const clearValues = () => {
|
|
96
|
-
Object.keys(formData).forEach(fieldName => {
|
|
97
|
-
(formData as Record<string, any>)[fieldName] = undefined;
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
defineExpose({
|
|
102
|
-
getElForm,
|
|
103
|
-
getValues,
|
|
104
|
-
getValue,
|
|
105
|
-
getFields,
|
|
106
|
-
getDefaultValues,
|
|
107
|
-
setValues,
|
|
108
|
-
resetValues,
|
|
109
|
-
clearValues,
|
|
110
|
-
...requestApi
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
</script>
|
|
114
|
-
<template>
|
|
115
|
-
<ElForm v-bind="formProps"
|
|
116
|
-
:model="formData"
|
|
117
|
-
ref="formRef"
|
|
118
|
-
@submit.prevent
|
|
119
|
-
v-loading="_loading">
|
|
120
|
-
<slot></slot>
|
|
121
|
-
<ElFormItem
|
|
122
|
-
v-if="slots.button||isDefault"
|
|
123
|
-
:label="labelWidth=='auto'?' ':''">
|
|
124
|
-
<ax-button v-if="isDefault"
|
|
125
|
-
v-bind="defaultButton"
|
|
126
|
-
@click="onSubmit"></ax-button>
|
|
127
|
-
<slot name="button"/>
|
|
128
|
-
</ElFormItem>
|
|
129
|
-
</ElForm>
|
|
130
|
-
</template>
|