@qin-ui/element-plus-pro 1.2.2 → 1.2.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/api.json +1 -1
- package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -1
- package/es/components/form/components/ProForm/index.vue.d.ts.map +1 -1
- package/es/components/form/constants/index.d.ts +1 -6
- package/es/components/form/constants/index.d.ts.map +1 -1
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts +18 -0
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -0
- package/es/components/table/components/ColumnControl.vue.d.ts.map +1 -1
- package/es/components/table/components/ProTable.vue.d.ts.map +1 -1
- package/es/components/table/components/SearchForm.vue.d.ts.map +1 -1
- package/es/components/table/components/TableColumnRenderer.vue.d.ts.map +1 -1
- package/es/components/table/types/index.d.ts +2 -0
- package/es/components/table/types/index.d.ts.map +1 -1
- package/es/components/table/useTable.d.ts.map +1 -1
- package/es/element-plus-pro.css +12 -12
- package/es/index.js +201 -177
- package/es/index.js.map +1 -1
- package/es/shared/core/index.d.ts +1 -1
- package/es/shared/core/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/form/components/BaseField/index.vue +8 -8
- package/src/components/form/components/BaseFormItem/index.vue +47 -66
- package/src/components/form/components/ProForm/index.vue +4 -11
- package/src/components/form/constants/index.ts +1 -7
- package/src/components/form/hooks/useGroupFieldAttrs.ts +119 -0
- package/src/components/table/components/ColumnControl.vue +2 -1
- package/src/components/table/components/ProTable.vue +3 -23
- package/src/components/table/components/SearchForm.vue +81 -15
- package/src/components/table/components/TableColumnRenderer.vue +28 -14
- package/src/components/table/types/index.ts +2 -0
- package/src/components/table/useTable.ts +1 -10
- package/src/shared/core/index.ts +1 -1
- package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts +0 -31
- package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts.map +0 -1
- package/es/components/form/components/PathProvider/index.vue.d.ts +0 -24
- package/es/components/form/components/PathProvider/index.vue.d.ts.map +0 -1
- package/src/components/form/components/GroupedFieldAttrs/index.vue +0 -115
- package/src/components/form/components/PathProvider/index.vue +0 -19
|
@@ -17,7 +17,7 @@ const { columns } = defineProps<Props>();
|
|
|
17
17
|
|
|
18
18
|
const getColumnKey = (column: Column<D>, index: number) => {
|
|
19
19
|
const key = column.key ?? column.prop;
|
|
20
|
-
if (key === undefined || key === null) return `
|
|
20
|
+
if (key === undefined || key === null) return `__col_${index}`;
|
|
21
21
|
return Array.isArray(key) ? key.join('.') : String(key);
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -33,10 +33,11 @@ const normalizedColumns = computed(() => {
|
|
|
33
33
|
|
|
34
34
|
const getColumnProps = (column: Column<D>) => {
|
|
35
35
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
36
|
-
const { hidden, render, key, ...rest } = column;
|
|
36
|
+
const { hidden, render, key, children, ...rest } = column;
|
|
37
37
|
const prop = column.prop ? String(column.prop) : undefined;
|
|
38
38
|
return {
|
|
39
39
|
...rest,
|
|
40
|
+
label: column.label ?? (column as any).title,
|
|
40
41
|
prop,
|
|
41
42
|
columnKey: key ? String(key) : prop,
|
|
42
43
|
};
|
|
@@ -48,20 +49,33 @@ const getColumnProps = (column: Column<D>) => {
|
|
|
48
49
|
v-for="(column, index) in normalizedColumns"
|
|
49
50
|
:key="getColumnKey(column, index)"
|
|
50
51
|
>
|
|
51
|
-
|
|
52
|
+
<!-- 分组列(递归子列) -->
|
|
53
|
+
<TableColumn
|
|
54
|
+
v-if="column.children && column.children.length > 0"
|
|
55
|
+
v-bind="getColumnProps(column)"
|
|
56
|
+
>
|
|
57
|
+
<TableColumnRenderer :columns="column.children" />
|
|
58
|
+
</TableColumn>
|
|
59
|
+
|
|
60
|
+
<!-- 自定义 render 列 -->
|
|
61
|
+
<TableColumn
|
|
62
|
+
v-else-if="typeof column.render === 'function'"
|
|
63
|
+
v-bind="getColumnProps(column)"
|
|
64
|
+
>
|
|
52
65
|
<template #default="scope">
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
/>
|
|
63
|
-
</template>
|
|
66
|
+
<component
|
|
67
|
+
:is="
|
|
68
|
+
column.render?.({
|
|
69
|
+
...scope,
|
|
70
|
+
column,
|
|
71
|
+
cellValue: getCellValue(scope.row, column),
|
|
72
|
+
})
|
|
73
|
+
"
|
|
74
|
+
/>
|
|
64
75
|
</template>
|
|
65
76
|
</TableColumn>
|
|
77
|
+
|
|
78
|
+
<!-- 普通列(Element Plus 原生渲染) -->
|
|
79
|
+
<TableColumn v-else v-bind="getColumnProps(column)" />
|
|
66
80
|
</template>
|
|
67
81
|
</template>
|
|
@@ -132,16 +132,7 @@ export function useTable<
|
|
|
132
132
|
const coreTable = (coreUseTable as any)({
|
|
133
133
|
...rest,
|
|
134
134
|
dataSource: data,
|
|
135
|
-
|
|
136
|
-
// 使 setColumn 等按 key 匹配的 API 对 Element Plus 的 prop 列生效
|
|
137
|
-
columns: columns?.map(column => {
|
|
138
|
-
if (column.key !== undefined && column.key !== null) return column;
|
|
139
|
-
const prop = column.prop;
|
|
140
|
-
const fallback =
|
|
141
|
-
prop ??
|
|
142
|
-
(typeof column.columnKey === 'string' ? column.columnKey : undefined);
|
|
143
|
-
return { ...column, key: fallback };
|
|
144
|
-
}),
|
|
135
|
+
columns,
|
|
145
136
|
}) as _Table<D, T, Column<T>>;
|
|
146
137
|
|
|
147
138
|
const { dataSource, ...tableWithoutDataSource } = coreTable as any;
|
package/src/shared/core/index.ts
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { GridItemProps, FormItemProps } from '../../../../shared/ui';
|
|
2
|
-
import { Base, Field } from '../../types';
|
|
3
|
-
import { FORM_ITEM_SLOT_KEYS } from '../../constants';
|
|
4
|
-
type Props = {
|
|
5
|
-
field: Field;
|
|
6
|
-
};
|
|
7
|
-
declare function __VLS_template(): {
|
|
8
|
-
attrs: Partial<{}>;
|
|
9
|
-
slots: {
|
|
10
|
-
default?(_: {
|
|
11
|
-
gridItemProps: GridItemProps;
|
|
12
|
-
formItemProps: FormItemProps & {
|
|
13
|
-
container?: Base["formItemContainer"];
|
|
14
|
-
};
|
|
15
|
-
formItemSlots: Record<(typeof FORM_ITEM_SLOT_KEYS)[number], any>;
|
|
16
|
-
componentProps: Record<string, any>;
|
|
17
|
-
}): any;
|
|
18
|
-
};
|
|
19
|
-
refs: {};
|
|
20
|
-
rootEl: any;
|
|
21
|
-
};
|
|
22
|
-
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
23
|
-
declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
24
|
-
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
25
|
-
export default _default;
|
|
26
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
27
|
-
new (): {
|
|
28
|
-
$slots: S;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=index.vue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.vue.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/components/GroupedFieldAttrs/index.vue"],"names":[],"mappings":"AA0IA,OAAO,EACL,aAAa,EACb,aAAa,EAGd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAMtD,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AA4EF,iBAAS,cAAc;WAqBT,OAAO,IAA6B;;;2BAzFjC,aAAa;2BACb,aAAa,GAAG;gBAAE,SAAS,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAA;aAAE;2BACzD,MAAM,CAAC,CAAC,OAAO,mBAAmB,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC;4BAChD,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;YA4ER,GAAG;;;;EAe/B;AASD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe,sRAMnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAQpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { NamePath } from '../../../../shared/ui';
|
|
2
|
-
type __VLS_Props = {
|
|
3
|
-
path?: NamePath;
|
|
4
|
-
};
|
|
5
|
-
declare function __VLS_template(): {
|
|
6
|
-
attrs: Partial<{}>;
|
|
7
|
-
slots: {
|
|
8
|
-
default?(_: {
|
|
9
|
-
path: string | undefined;
|
|
10
|
-
}): any;
|
|
11
|
-
};
|
|
12
|
-
refs: {};
|
|
13
|
-
rootEl: any;
|
|
14
|
-
};
|
|
15
|
-
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
16
|
-
declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
17
|
-
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
18
|
-
export default _default;
|
|
19
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
20
|
-
new (): {
|
|
21
|
-
$slots: S;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=index.vue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.vue.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/components/PathProvider/index.vue"],"names":[],"mappings":"AAuBA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,KAAK,WAAW,GAAG;IAAE,IAAI,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAC;AAavC,iBAAS,cAAc;WAqBT,OAAO,IAA6B;;;;YAVrB,GAAG;;;;EAe/B;AASD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe,kSAMnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAQpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
/**
|
|
3
|
-
* @component GroupedFieldAttrs
|
|
4
|
-
* @description 字段属性分组器,将 field 配置对象拆分为三类属性
|
|
5
|
-
*
|
|
6
|
-
* ## 属性分发逻辑
|
|
7
|
-
*
|
|
8
|
-
* 单个 field 对象包含多种属性,需要分发到不同的渲染目标:
|
|
9
|
-
*
|
|
10
|
-
* 1. **gridItemProps** — 网格布局属性(span、xs、sm、md、lg、xl、xxl 等),传递给 GridItem
|
|
11
|
-
* 2. **formItemProps** — 表单项属性(label、rules、required 等),传递给 FormItem
|
|
12
|
-
* 3. **componentProps** — 组件属性(placeholder、clearable 等),传递给输入组件
|
|
13
|
-
* 4. **formItemSlots** — FormItem 的具名插槽(label、error 等)
|
|
14
|
-
*
|
|
15
|
-
* 分组依据:
|
|
16
|
-
* - 匹配 element-plus GridItem 的 props key → gridItemProps
|
|
17
|
-
* - 匹配 element-plus FormItem 的 props key → formItemProps
|
|
18
|
-
* - 其余所有属性 → componentProps
|
|
19
|
-
* - 属于 FORM_ITEM_SLOT_KEYS 的插槽 → formItemSlots
|
|
20
|
-
* - 其余插槽 → componentProps.slots
|
|
21
|
-
*/
|
|
22
|
-
import { computed, inject, mergeProps, toValue } from 'vue';
|
|
23
|
-
import {
|
|
24
|
-
GridItemProps,
|
|
25
|
-
FormItemProps,
|
|
26
|
-
gridItemProps,
|
|
27
|
-
formItemProps,
|
|
28
|
-
} from '../../../../shared/ui';
|
|
29
|
-
import { INJECT_CONFIG } from '../../../component-provider/constants';
|
|
30
|
-
import type { Base, Field } from '../../types';
|
|
31
|
-
import { FORM_ITEM_SLOT_KEYS } from '../../constants';
|
|
32
|
-
import { isPlainObject } from '../../../../shared/core';
|
|
33
|
-
|
|
34
|
-
const formItemPropKeys = Object.keys(formItemProps());
|
|
35
|
-
const gridItemPropKeys = Object.keys(gridItemProps());
|
|
36
|
-
|
|
37
|
-
type Props = {
|
|
38
|
-
field: Field;
|
|
39
|
-
};
|
|
40
|
-
const props = defineProps<Props>();
|
|
41
|
-
|
|
42
|
-
const config = INJECT_CONFIG['pro-form-item'];
|
|
43
|
-
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
44
|
-
|
|
45
|
-
type GroupedFieldAttrs = {
|
|
46
|
-
gridItemProps: GridItemProps;
|
|
47
|
-
formItemProps: FormItemProps & { container?: Base['formItemContainer'] };
|
|
48
|
-
formItemSlots: Record<(typeof FORM_ITEM_SLOT_KEYS)[number], any>;
|
|
49
|
-
componentProps: Record<string, any>;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// 将 field 配置按 key 分发到三类属性分组中
|
|
53
|
-
const groupedAttributes = computed<GroupedFieldAttrs>(() => {
|
|
54
|
-
let gridItemProps: Record<string, any> = {};
|
|
55
|
-
let formItemProps: Record<string, any> = {};
|
|
56
|
-
const componentProps: Record<string, any> = { slots: {} };
|
|
57
|
-
const formItemSlots: Record<string, any> = {};
|
|
58
|
-
|
|
59
|
-
if (isPlainObject(props.field)) {
|
|
60
|
-
// prettier-ignore
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
-
const { path, name, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } =
|
|
63
|
-
props.field as any;
|
|
64
|
-
const {
|
|
65
|
-
class: injectClassName,
|
|
66
|
-
style: injectStyle,
|
|
67
|
-
span: injectSpan,
|
|
68
|
-
formItemContainer: injectFormItemContainer,
|
|
69
|
-
xs,
|
|
70
|
-
sm,
|
|
71
|
-
md,
|
|
72
|
-
lg,
|
|
73
|
-
xl,
|
|
74
|
-
...injectRest
|
|
75
|
-
} = injectFormItemProps;
|
|
76
|
-
|
|
77
|
-
const initGridItemProps =
|
|
78
|
-
span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
|
|
79
|
-
|
|
80
|
-
gridItemProps = fields ? { span: span ?? 24 } : initGridItemProps;
|
|
81
|
-
formItemProps = mergeProps(
|
|
82
|
-
injectRest as any,
|
|
83
|
-
{ class: injectClassName, style: injectStyle },
|
|
84
|
-
{ class: toValue(formItemClass), style: toValue(formItemStyle) },
|
|
85
|
-
formItemDataAttrs
|
|
86
|
-
);
|
|
87
|
-
formItemProps.container = formItemContainer ?? injectFormItemContainer;
|
|
88
|
-
|
|
89
|
-
Object.keys(rest).forEach(k => {
|
|
90
|
-
if (gridItemPropKeys.includes(k)) {
|
|
91
|
-
gridItemProps[k] = rest[k];
|
|
92
|
-
} else if (formItemPropKeys.includes(k)) {
|
|
93
|
-
(formItemProps as any)[k] = rest[k];
|
|
94
|
-
} else {
|
|
95
|
-
componentProps[k] = rest[k];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
// 将 componentDataAttrs 展开到组件 props 中
|
|
99
|
-
Object.assign(componentProps, componentDataAttrs);
|
|
100
|
-
Object.keys(slots).forEach(k => {
|
|
101
|
-
if (FORM_ITEM_SLOT_KEYS.includes(k as any)) {
|
|
102
|
-
formItemSlots[k] = slots[k];
|
|
103
|
-
} else {
|
|
104
|
-
componentProps['slots'][k] = slots[k];
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return { gridItemProps, formItemProps, componentProps, formItemSlots };
|
|
110
|
-
});
|
|
111
|
-
</script>
|
|
112
|
-
|
|
113
|
-
<template>
|
|
114
|
-
<slot v-bind="groupedAttributes"></slot>
|
|
115
|
-
</template>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { computed, provide } from 'vue';
|
|
3
|
-
import { InjectionPathKey } from '../../constants';
|
|
4
|
-
import { NamePath } from '../../../../shared/ui';
|
|
5
|
-
|
|
6
|
-
const props = defineProps<{ path?: NamePath }>();
|
|
7
|
-
|
|
8
|
-
const namePath = computed(() => {
|
|
9
|
-
return Array.isArray(props.path)
|
|
10
|
-
? props.path.join('.')
|
|
11
|
-
: (props.path as string | undefined);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
provide(InjectionPathKey, namePath);
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<template>
|
|
18
|
-
<slot :path="namePath" />
|
|
19
|
-
</template>
|