gi-component 0.0.6 → 0.0.7
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/dist/gi.css +1 -1
- package/dist/index.d.ts +66 -8
- package/dist/index.es.js +7 -6
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/packages/components/edit-table/src/edit-table.vue +5 -5
- package/packages/components/edit-table/src/type.ts +24 -23
- package/packages/components/form/src/form.vue +2 -3
- package/packages/components/form/src/type.ts +39 -32
- package/packages/components/table/src/type.ts +2 -10
- package/packages/components/tabs/src/tabs.vue +6 -16
- package/packages/types/tool.ts +14 -0
package/package.json
CHANGED
|
@@ -39,7 +39,7 @@ const props = withDefaults(defineProps<EditTableProps>(), {
|
|
|
39
39
|
const attrs = useAttrs();
|
|
40
40
|
const { b } = useBemClass();
|
|
41
41
|
|
|
42
|
-
const COMP_MAP: Record<
|
|
42
|
+
const COMP_MAP: Record<EditTableColumnItemType, any> = {
|
|
43
43
|
input: El.ElInput,
|
|
44
44
|
textarea: El.ElInput,
|
|
45
45
|
'input-number': El.ElInputNumber,
|
|
@@ -62,7 +62,8 @@ const COMP_MAP: Record<Exclude<EditTableColumnItemType, 'slot'>, any> = {
|
|
|
62
62
|
transfer: El.ElTransfer,
|
|
63
63
|
autocomplete: El.ElAutocomplete,
|
|
64
64
|
upload: El.ElUpload,
|
|
65
|
-
'input-search': InputSearch
|
|
65
|
+
'input-search': InputSearch,
|
|
66
|
+
slot: undefined,
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
const formRef = ref<FormInstance | null>();
|
|
@@ -138,11 +139,10 @@ function getComponentBindProps(item: EditTableColumnItem) {
|
|
|
138
139
|
const defaultProps: any = STATIC_PROPS.get(item.type || '') || {};
|
|
139
140
|
defaultProps.placeholder = getPlaceholder(item);
|
|
140
141
|
if (item.type === 'date-picker') {
|
|
141
|
-
defaultProps.valueFormat =
|
|
142
|
-
item?.componentProps?.type === 'datetime' ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD';
|
|
142
|
+
defaultProps.valueFormat = item?.componentProps?.type === 'datetime' ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD';
|
|
143
143
|
}
|
|
144
144
|
// 合并默认配置和自定义配置
|
|
145
|
-
return { ...defaultProps, ...item
|
|
145
|
+
return { ...defaultProps, ...(item?.componentProps || {}) };
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
/** 表单项校验规则 */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type * as El from 'element-plus';
|
|
2
2
|
import type { InputSearchInstance } from '../../input-search'
|
|
3
|
+
import type { MergeMultiple } from '../../../types/tool'
|
|
3
4
|
|
|
4
5
|
export type EditTableColumnItemType =
|
|
5
6
|
| 'input'
|
|
@@ -34,34 +35,34 @@ export interface EditTableColumnItem {
|
|
|
34
35
|
width?: number | string;
|
|
35
36
|
required?: boolean;
|
|
36
37
|
rules?: El.FormItemRule[]; // 表单校验规则
|
|
37
|
-
componentProps?:
|
|
38
|
+
componentProps?: EditTableColumnItemProps;
|
|
38
39
|
columnProps?: El.TableColumnInstance['$props'];
|
|
39
40
|
formItemProps?: El.FormItemProps;
|
|
40
41
|
slotName?: string;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
export type
|
|
44
|
-
El.InputNumberProps
|
|
45
|
-
El.InputTagProps
|
|
46
|
-
El.SelectProps
|
|
47
|
-
El.SelectV2Props
|
|
48
|
-
El.TreeInstance['$props']
|
|
49
|
-
El.CascaderProps
|
|
50
|
-
El.SliderProps
|
|
51
|
-
El.SwitchProps
|
|
52
|
-
El.RateProps
|
|
53
|
-
El.CheckboxGroupProps
|
|
54
|
-
El.CheckboxProps
|
|
55
|
-
El.RadioGroupProps
|
|
56
|
-
El.RadioProps
|
|
57
|
-
El.DatePickerProps
|
|
58
|
-
El.TimePickerDefaultProps
|
|
59
|
-
El.TimeSelectProps
|
|
60
|
-
El.ColorPickerProps
|
|
61
|
-
El.TransferProps
|
|
62
|
-
El.AutocompleteProps
|
|
63
|
-
El.UploadProps
|
|
64
|
-
InputSearchInstance['$props']
|
|
44
|
+
export type EditTableColumnItemProps = MergeMultiple<[El.InputProps,
|
|
45
|
+
El.InputNumberProps,
|
|
46
|
+
El.InputTagProps,
|
|
47
|
+
El.SelectProps,
|
|
48
|
+
El.SelectV2Props,
|
|
49
|
+
El.TreeInstance['$props'],
|
|
50
|
+
El.CascaderProps,
|
|
51
|
+
El.SliderProps,
|
|
52
|
+
El.SwitchProps,
|
|
53
|
+
El.RateProps,
|
|
54
|
+
El.CheckboxGroupProps,
|
|
55
|
+
El.CheckboxProps,
|
|
56
|
+
El.RadioGroupProps,
|
|
57
|
+
El.RadioProps,
|
|
58
|
+
El.DatePickerProps,
|
|
59
|
+
El.TimePickerDefaultProps,
|
|
60
|
+
El.TimeSelectProps,
|
|
61
|
+
El.ColorPickerProps,
|
|
62
|
+
El.TransferProps,
|
|
63
|
+
El.AutocompleteProps,
|
|
64
|
+
El.UploadProps,
|
|
65
|
+
InputSearchInstance['$props']]>
|
|
65
66
|
|
|
66
67
|
export interface EditTableProps {
|
|
67
68
|
rowKey?: string;
|
|
@@ -197,15 +197,14 @@ function getComponentBindProps(item: FormColumnItem) {
|
|
|
197
197
|
const defaultProps: any = STATIC_PROPS.get(item.type) || {};
|
|
198
198
|
defaultProps.placeholder = getPlaceholder(item);
|
|
199
199
|
if (item.type === 'date-picker') {
|
|
200
|
-
defaultProps.valueFormat =
|
|
201
|
-
item?.props?.type === 'datetime' ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD';
|
|
200
|
+
defaultProps.valueFormat = item?.props?.type === 'datetime' ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD';
|
|
202
201
|
}
|
|
203
202
|
// 如果配置了dictCode且存在对应的字典数据,设置options
|
|
204
203
|
if (item.dictCode && dictData.value[item.dictCode]) {
|
|
205
204
|
defaultProps.options = dictData.value[item.dictCode];
|
|
206
205
|
}
|
|
207
206
|
// 合并默认配置和自定义配置
|
|
208
|
-
return { ...defaultProps, ...item
|
|
207
|
+
return { ...defaultProps, ...(item?.props || {}) };
|
|
209
208
|
}
|
|
210
209
|
|
|
211
210
|
const formProps = computed(() => {
|
|
@@ -3,6 +3,7 @@ import type { FormProps as ElFormProps } from 'element-plus';
|
|
|
3
3
|
import type { VNode } from 'vue';
|
|
4
4
|
import type { GridItemProps, GridProps } from '../../grid/src/interface';
|
|
5
5
|
import type { InputSearchInstance } from '../../input-search';
|
|
6
|
+
import type { MergeMultiple } from '../../../types/tool'
|
|
6
7
|
|
|
7
8
|
export type FormColumnType =
|
|
8
9
|
| 'input'
|
|
@@ -31,37 +32,45 @@ export type FormColumnType =
|
|
|
31
32
|
| 'title'
|
|
32
33
|
| 'slot';
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
El.
|
|
39
|
-
El.
|
|
40
|
-
El.
|
|
41
|
-
El.
|
|
42
|
-
El.
|
|
43
|
-
El.
|
|
44
|
-
El.
|
|
45
|
-
El.
|
|
46
|
-
El.
|
|
47
|
-
El.
|
|
48
|
-
El.
|
|
49
|
-
El.
|
|
50
|
-
El.
|
|
51
|
-
El.
|
|
52
|
-
El.
|
|
53
|
-
El.
|
|
54
|
-
El.
|
|
55
|
-
|
|
35
|
+
/**
|
|
36
|
+
* 表单列属性类型,根据组件类型使用对应的属性类型
|
|
37
|
+
*/
|
|
38
|
+
export type FormColumnProps = MergeMultiple<[El.InputProps,
|
|
39
|
+
El.InputNumberProps,
|
|
40
|
+
El.InputTagProps,
|
|
41
|
+
El.SelectProps,
|
|
42
|
+
El.SelectV2Props,
|
|
43
|
+
El.TreeInstance['$props'],
|
|
44
|
+
El.CascaderProps,
|
|
45
|
+
El.SliderProps,
|
|
46
|
+
El.SwitchProps,
|
|
47
|
+
El.RateProps,
|
|
48
|
+
El.CheckboxGroupProps,
|
|
49
|
+
El.CheckboxProps,
|
|
50
|
+
El.RadioGroupProps,
|
|
51
|
+
El.RadioProps,
|
|
52
|
+
El.DatePickerProps,
|
|
53
|
+
El.TimePickerDefaultProps,
|
|
54
|
+
El.TimeSelectProps,
|
|
55
|
+
El.ColorPickerProps,
|
|
56
|
+
El.TransferProps,
|
|
57
|
+
El.AutocompleteProps,
|
|
58
|
+
El.UploadProps,
|
|
59
|
+
InputSearchInstance['$props']]>;
|
|
56
60
|
|
|
57
61
|
export type FormColumnItemHide<F> = boolean | ((form: F) => boolean);
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
El.
|
|
64
|
-
El.
|
|
63
|
+
/**
|
|
64
|
+
* 表单列插槽类型,根据组件类型使用对应的插槽类型
|
|
65
|
+
*/
|
|
66
|
+
export type FormColumnSlots = Partial<
|
|
67
|
+
El.InputInstance['$slots'] |
|
|
68
|
+
El.InputNumberInstance['$slots'] |
|
|
69
|
+
El.InputTagInstance['$slots'] |
|
|
70
|
+
El.AutocompleteInstance['$slots'] |
|
|
71
|
+
El.CascaderInstance['$slots'] |
|
|
72
|
+
El.DatePickerInstance['$slots']
|
|
73
|
+
>;
|
|
65
74
|
|
|
66
75
|
export interface FormColumnItem<F = any> {
|
|
67
76
|
type: FormColumnType;
|
|
@@ -70,9 +79,7 @@ export interface FormColumnItem<F = any> {
|
|
|
70
79
|
field: string;
|
|
71
80
|
fieldName?: string;
|
|
72
81
|
span?: number;
|
|
73
|
-
props?: FormColumnProps
|
|
74
|
-
options?: El.RadioProps & El.CheckboxProps & El.SelectProps;
|
|
75
|
-
};
|
|
82
|
+
props?: FormColumnProps;
|
|
76
83
|
formItemProps?: El.FormItemProps;
|
|
77
84
|
gridItemProps?: any;
|
|
78
85
|
required?: boolean;
|
|
@@ -95,4 +102,4 @@ export interface FormProps extends Partial<ElFormProps> {
|
|
|
95
102
|
searchText?: string;
|
|
96
103
|
hideFoldBtn?: boolean;
|
|
97
104
|
defaultCollapsed?: boolean | undefined;
|
|
98
|
-
}
|
|
105
|
+
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
TableProps as ElTableProps,
|
|
3
|
-
PaginationProps,
|
|
4
|
-
TableColumnCtx,
|
|
5
|
-
TableColumnInstance,
|
|
6
|
-
} from 'element-plus';
|
|
1
|
+
import type { TableProps as ElTableProps, PaginationProps, TableColumnInstance } from 'element-plus';
|
|
7
2
|
import type { ExtractPropTypes, VNode } from 'vue';
|
|
8
3
|
|
|
9
4
|
type DefaultRow = Record<PropertyKey, any>
|
|
@@ -13,10 +8,7 @@ export interface TableColumnItem<T extends DefaultRow = DefaultRow> extends Omit
|
|
|
13
8
|
render?: (scope: { $index: number; cellIndex: number; column: TableColumnItem<T>; row: T }) => VNode | VNode[] | string;
|
|
14
9
|
}
|
|
15
10
|
|
|
16
|
-
export interface TableProps
|
|
17
|
-
extends ExtractPropTypes<
|
|
18
|
-
ElTableProps<Record<string | number | symbol, any>>
|
|
19
|
-
> {
|
|
11
|
+
export interface TableProps extends ExtractPropTypes<ElTableProps<Record<string | number | symbol, any>>> {
|
|
20
12
|
columns?: TableColumnItem[];
|
|
21
13
|
pagination?: Partial<PaginationProps>;
|
|
22
14
|
}
|
|
@@ -2,19 +2,9 @@
|
|
|
2
2
|
<div :class="getClass">
|
|
3
3
|
<div :class="b('tabs__default')">
|
|
4
4
|
<slot>
|
|
5
|
-
<el-tabs
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
:stretch="props.stretch"
|
|
9
|
-
@tab-click="(p, e) => emits('tabClick', p, e)"
|
|
10
|
-
@tab-change="emits('tabChange', $event)"
|
|
11
|
-
>
|
|
12
|
-
<el-tab-pane
|
|
13
|
-
v-for="item in props.options"
|
|
14
|
-
:key="item.name"
|
|
15
|
-
:name="item.name"
|
|
16
|
-
:disabled="item?.disabled"
|
|
17
|
-
>
|
|
5
|
+
<el-tabs v-model="model" :type="props.type" :stretch="props.stretch"
|
|
6
|
+
@tab-click="(p, e) => emits('tabClick', p, e)" @tab-change="emits('tabChange', $event as any)">
|
|
7
|
+
<el-tab-pane v-for="item in props.options" :key="item.name" :name="item.name" :disabled="item?.disabled">
|
|
18
8
|
<template #label>
|
|
19
9
|
<slot name="label" :data="item">{{ item.label }}</slot>
|
|
20
10
|
</template>
|
|
@@ -113,7 +103,7 @@ const getClass = computed(() => {
|
|
|
113
103
|
}
|
|
114
104
|
|
|
115
105
|
:deep(.el-tabs--card) {
|
|
116
|
-
|
|
106
|
+
>.el-tabs__header {
|
|
117
107
|
border-bottom: none;
|
|
118
108
|
}
|
|
119
109
|
}
|
|
@@ -121,11 +111,11 @@ const getClass = computed(() => {
|
|
|
121
111
|
:deep(.el-tabs--border-card) {
|
|
122
112
|
border-bottom: none;
|
|
123
113
|
|
|
124
|
-
|
|
114
|
+
>.el-tabs__content {
|
|
125
115
|
display: none;
|
|
126
116
|
}
|
|
127
117
|
|
|
128
|
-
|
|
118
|
+
>.el-tabs__header {
|
|
129
119
|
border-bottom: none;
|
|
130
120
|
}
|
|
131
121
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// 辅助类型:获取所有类型的键的联合
|
|
2
|
+
type AllKeys<T> = T extends any ? keyof T : never;
|
|
3
|
+
|
|
4
|
+
// 辅助类型:获取属性在所有类型中的联合类型
|
|
5
|
+
type UnionType<T, K extends PropertyKey> = T extends any
|
|
6
|
+
? K extends keyof T
|
|
7
|
+
? T[K]
|
|
8
|
+
: never
|
|
9
|
+
: never;
|
|
10
|
+
|
|
11
|
+
// 合并多个类型,同名属性转为联合类型
|
|
12
|
+
export type MergeMultiple<T extends any[]> = {
|
|
13
|
+
[K in AllKeys<T[number]>]: UnionType<T[number], K>
|
|
14
|
+
};
|