@wx-design/components 0.5.2 → 0.6.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wx-design/components",
3
- "version": "0.5.2",
3
+ "version": "0.6.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -3,18 +3,33 @@ import type {
3
3
  InputProps,
4
4
  InputNumberProps,
5
5
  DatePickerProps,
6
- PopoverProps
6
+ PopoverProps,
7
+ CheckboxProps,
7
8
  } from "element-plus";
8
9
 
9
10
  export interface SabColumnSlots<D = VxeTableDataRow> {
10
11
  /**
11
12
  * 自定义显示内容模板
12
13
  */
13
- default: ((params: VxeColumnSlotTypes.DefaultSlotParams<D>) => any) | string;
14
+ default:
15
+ | ((
16
+ params: VxeColumnSlotTypes.DefaultSlotParams<D> & {
17
+ column: SabColumnProps<D>;
18
+ },
19
+ editorProps: SabCellEditorParams
20
+ ) => any)
21
+ | string;
14
22
  /**
15
23
  * 自定义表头内容的模板
16
24
  */
17
- header: ((params: VxeColumnSlotTypes.HeaderSlotParams<D>) => any) | string;
25
+ header:
26
+ | ((
27
+ params: VxeColumnSlotTypes.HeaderSlotParams<D> & {
28
+ column: SabColumnProps<D>;
29
+ },
30
+ editorProps: SabCellEditorParams
31
+ ) => any)
32
+ | string;
18
33
  /**
19
34
  * 自定义表尾内容的模板
20
35
  */
@@ -44,7 +59,9 @@ export interface SabColumnSlots<D = VxeTableDataRow> {
44
59
  */
45
60
  edit:
46
61
  | ((
47
- params: VxeColumnSlotTypes.EditSlotParams<D>,
62
+ params: VxeColumnSlotTypes.EditSlotParams<D> & {
63
+ column: SabColumnProps<D>;
64
+ },
48
65
  editorProps: SabCellEditorParams
49
66
  ) => any)
50
67
  | string;
@@ -60,7 +77,7 @@ export interface SabColumnSlots<D = VxeTableDataRow> {
60
77
  }
61
78
 
62
79
  // 单选框属性
63
- export type SabCellSelectProps<D = any> = {
80
+ export type SabCellSelectProps<D = VxeTableDataRow> = {
64
81
  // 禁用状态
65
82
  disabled?: boolean;
66
83
  // 只读模式
@@ -75,9 +92,28 @@ export type SabCellSelectProps<D = any> = {
75
92
  valueKey?: string;
76
93
  // 用于禁用状态的字段名,默认 disabled
77
94
  disabledKey?: string;
95
+ // select 变更时影响的 row.value 字段
96
+ effectValueField?: string;
78
97
  // 动态获取单元格选项
79
- dynamicOptions?: (params: VxeColumnSlotTypes.DefaultSlotParams) => Promise<any[]>;
98
+ dynamicOptions?: (
99
+ params: VxeColumnSlotTypes.DefaultSlotParams
100
+ ) => Promise<any[]>;
101
+ // 渲染选项展示
102
+ renderOption?(option: D): any;
103
+ // 渲染选项的label
104
+ renderOptionLabel?(option: D): string;
105
+ };
106
+
107
+ // 动态单元格配置
108
+ export type DynamicCellProps<D = VxeTableDataRow> = {
109
+ // 动态设置单元格类型
110
+ getSabCellType?(
111
+ scope:
112
+ | VxeColumnSlotTypes.DefaultSlotParams<D>
113
+ | VxeColumnSlotTypes.EditSlotParams<D>
114
+ ): SabCellType;
80
115
  };
116
+
81
117
  // 单元格编辑器参数
82
118
  export type SabCellEditorParams =
83
119
  | Partial<InputProps>
@@ -85,23 +121,34 @@ export type SabCellEditorParams =
85
121
  | Partial<DatePickerProps>
86
122
  | Partial<SabCellSelectProps>
87
123
  | Partial<PopoverProps>
124
+ | Partial<CheckboxProps>
125
+ | Partial<SabPopoverParams>
126
+ | Partial<DynamicCellProps>;
88
127
 
89
128
  // 弹出层配置
90
- export type SabPopoverParams = {
91
- // 触发弹出的元素,默认icon
92
- trigger?: "cell" | 'icon',
129
+ export type SabPopoverParams = Partial<PopoverProps> & {
93
130
  // 触发事件,默认 click
94
- triggerEvent?: "click" | "hover" | "focus" | "contextmenu",
131
+ // 如果 popType === dialog 则只支持 click
132
+ trigger?: "click" | "hover" | "focus" | "contextmenu";
95
133
  // 弹出类型
96
- popType?: 'popover' | 'dialog',
97
- // 是否展示弹出按钮
98
- showButton?: boolean
99
- }
134
+ popType?: "popover";
135
+ // 是否隐藏弹出按钮
136
+ hideButton?: boolean;
137
+ };
100
138
 
101
139
  // 表格列设置
102
140
  export type SabColumnProps<D = VxeTableDataRow> = VxeColumnProps<D> & {
103
141
  // 单元格类型
104
- sabCellType?: 'input' | 'input-number' | 'select' | 'date-picker' | 'image' | 'color' | 'boolean' | 'popover';
142
+ sabCellType?:
143
+ | "input"
144
+ | "input-number"
145
+ | "select"
146
+ | "date-picker"
147
+ | "image"
148
+ | "color"
149
+ | "boolean"
150
+ | "popover"
151
+ | "dynamic";
105
152
  // 附加的单元格编辑器参数
106
153
  editorProps?: Partial<SabCellEditorParams>;
107
154
  // 单元格是否可编辑
@@ -118,7 +165,7 @@ export type SabColumnProps<D = VxeTableDataRow> = VxeColumnProps<D> & {
118
165
  // 启用弹出层
119
166
  enablePopover?: boolean;
120
167
  // 弹出层配置
121
- popoverConfig?: SabPopoverParams
168
+ popoverConfig?: SabPopoverParams;
122
169
  // 字段名
123
170
  field?: keyof D;
124
171
  };
@@ -18,8 +18,6 @@ export type SabTableProps<D = VxeTableDataRow> = VxeTableProps<D> & {
18
18
  showToolbar?: boolean;
19
19
  // 点击未选中行的单元格自动取消选择选中行
20
20
  autoClearSelected?: boolean;
21
- // TODO: 单元格弹出层配置
22
- popoverConfig?: SabPopoverParams;
23
21
  // 自动列宽赋值,允许在column中 width 覆盖
24
22
  autoColumnWidth?: boolean;
25
23
  }
@@ -1,76 +0,0 @@
1
- export declare const mockData: ({
2
- id: number;
3
- name: string;
4
- nickname: string;
5
- role: string;
6
- sex: string;
7
- sex2: string[];
8
- num1: number;
9
- age: number;
10
- address: string;
11
- date12: string;
12
- date13: string;
13
- avater: string;
14
- color: string;
15
- isok: boolean;
16
- } | {
17
- id: number;
18
- name: string;
19
- nickname: string;
20
- role: string;
21
- sex: string;
22
- sex2: string[];
23
- num1: number;
24
- age: number;
25
- address: string;
26
- date12: string;
27
- date13: string;
28
- color: string;
29
- isok: boolean;
30
- avater?: undefined;
31
- } | {
32
- id: number;
33
- name: string;
34
- nickname: string;
35
- role: string;
36
- sex: string;
37
- sex2: string[];
38
- num1: number;
39
- age: number;
40
- address: string;
41
- date12: string;
42
- date13: string;
43
- color: string;
44
- avater?: undefined;
45
- isok?: undefined;
46
- } | {
47
- id: number;
48
- name: string;
49
- nickname: string;
50
- role: string;
51
- sex: string;
52
- sex2: string[];
53
- num1: number;
54
- age: number;
55
- address: string;
56
- date12: string;
57
- date13: string;
58
- avater?: undefined;
59
- color?: undefined;
60
- isok?: undefined;
61
- } | {
62
- id: number;
63
- name: string;
64
- nickname: string;
65
- role: string;
66
- sex: string;
67
- sex2: string[];
68
- num1: number;
69
- age: number;
70
- address: string;
71
- date12: string;
72
- date13: string;
73
- avater: string;
74
- color?: undefined;
75
- isok?: undefined;
76
- })[];
@@ -1,76 +0,0 @@
1
- export declare const mockData: ({
2
- id: number;
3
- name: string;
4
- nickname: string;
5
- role: string;
6
- sex: string;
7
- sex2: string[];
8
- num1: number;
9
- age: number;
10
- address: string;
11
- date12: string;
12
- date13: string;
13
- avater: string;
14
- color: string;
15
- isok: boolean;
16
- } | {
17
- id: number;
18
- name: string;
19
- nickname: string;
20
- role: string;
21
- sex: string;
22
- sex2: string[];
23
- num1: number;
24
- age: number;
25
- address: string;
26
- date12: string;
27
- date13: string;
28
- color: string;
29
- isok: boolean;
30
- avater?: undefined;
31
- } | {
32
- id: number;
33
- name: string;
34
- nickname: string;
35
- role: string;
36
- sex: string;
37
- sex2: string[];
38
- num1: number;
39
- age: number;
40
- address: string;
41
- date12: string;
42
- date13: string;
43
- color: string;
44
- avater?: undefined;
45
- isok?: undefined;
46
- } | {
47
- id: number;
48
- name: string;
49
- nickname: string;
50
- role: string;
51
- sex: string;
52
- sex2: string[];
53
- num1: number;
54
- age: number;
55
- address: string;
56
- date12: string;
57
- date13: string;
58
- avater?: undefined;
59
- color?: undefined;
60
- isok?: undefined;
61
- } | {
62
- id: number;
63
- name: string;
64
- nickname: string;
65
- role: string;
66
- sex: string;
67
- sex2: string[];
68
- num1: number;
69
- age: number;
70
- address: string;
71
- date12: string;
72
- date13: string;
73
- avater: string;
74
- color?: undefined;
75
- isok?: undefined;
76
- })[];