@veltra/desktop 1.7.12 → 1.7.13
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/components/batch-edit/helper.d.ts +1 -2
- package/dist/components/condition-editor/core/evaluator.d.ts +4 -5
- package/dist/components/contextmenu/api.d.ts +1 -2
- package/dist/components/contextmenu/di.d.ts +2 -3
- package/dist/components/loading/directive.d.ts +1 -2
- package/dist/components/message/message.d.ts +1 -2
- package/dist/components/message-confirm/message-confirm.d.ts +1 -2
- package/dist/components/notification/notification.d.ts +1 -2
- package/dist/components/table/node/col.js +19 -0
- package/dist/components/table/node/col.js.map +1 -1
- package/dist/components/table/table-cell.js +2 -0
- package/dist/components/table/table-cell.js.map +1 -1
- package/dist/components/table/table-foot.js +2 -0
- package/dist/components/table/table-foot.js.map +1 -1
- package/dist/components/table/table-head.js +1 -0
- package/dist/components/table/table-head.js.map +1 -1
- package/dist/components/table/table-row.js +2 -0
- package/dist/components/table/table-row.js.map +1 -1
- package/dist/components/table/use-columns.d.ts +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/install.d.ts +3 -3
- package/dist/types/action.d.ts +7 -8
- package/dist/types/animation.d.ts +4 -5
- package/dist/types/auto-complete.d.ts +4 -5
- package/dist/types/badge.d.ts +4 -5
- package/dist/types/batch-edit.d.ts +9 -10
- package/dist/types/breadcrumb.d.ts +6 -7
- package/dist/types/button.d.ts +5 -6
- package/dist/types/calendar.d.ts +7 -8
- package/dist/types/card.d.ts +7 -8
- package/dist/types/cascade.d.ts +6 -7
- package/dist/types/check-tag.d.ts +4 -5
- package/dist/types/checkbox-group.d.ts +3 -4
- package/dist/types/checkbox.d.ts +5 -6
- package/dist/types/code-editor.d.ts +5 -6
- package/dist/types/collapse.d.ts +6 -7
- package/dist/types/condition-editor.d.ts +11 -12
- package/dist/types/contextmenu.d.ts +5 -6
- package/dist/types/css-transition.d.ts +4 -5
- package/dist/types/date-panel.d.ts +3 -4
- package/dist/types/date-picker.d.ts +5 -6
- package/dist/types/date-range-picker.d.ts +6 -7
- package/dist/types/dialog.d.ts +5 -6
- package/dist/types/drawer.d.ts +6 -7
- package/dist/types/dropdown.d.ts +4 -5
- package/dist/types/dual-nav.d.ts +6 -7
- package/dist/types/empty.d.ts +4 -5
- package/dist/types/expression-editor.d.ts +6 -7
- package/dist/types/file-picker.d.ts +4 -5
- package/dist/types/file-viewer.d.ts +6 -7
- package/dist/types/float-button.d.ts +5 -6
- package/dist/types/form-item.d.ts +3 -4
- package/dist/types/form.d.ts +4 -5
- package/dist/types/gantt-chart.d.ts +4 -5
- package/dist/types/grid-input.d.ts +4 -5
- package/dist/types/grid.d.ts +7 -8
- package/dist/types/group-input.d.ts +4 -5
- package/dist/types/group-nav.d.ts +3 -4
- package/dist/types/icon.d.ts +3 -4
- package/dist/types/image-cropper.d.ts +9 -10
- package/dist/types/index.d.ts +2 -2
- package/dist/types/input.d.ts +4 -5
- package/dist/types/layout.d.ts +4 -5
- package/dist/types/list.d.ts +4 -5
- package/dist/types/loading.d.ts +5 -6
- package/dist/types/message-confirm.d.ts +8 -9
- package/dist/types/message.d.ts +8 -9
- package/dist/types/multi-auto-complete.d.ts +4 -5
- package/dist/types/multi-select.d.ts +4 -5
- package/dist/types/multi-tree-select.d.ts +4 -5
- package/dist/types/nav.d.ts +5 -6
- package/dist/types/node-render.d.ts +2 -3
- package/dist/types/notification.d.ts +8 -9
- package/dist/types/number-input.d.ts +3 -4
- package/dist/types/number-range-input.d.ts +4 -5
- package/dist/types/number.d.ts +3 -4
- package/dist/types/paginator.d.ts +4 -5
- package/dist/types/palette.d.ts +7 -8
- package/dist/types/password-input.d.ts +4 -5
- package/dist/types/pop-confirm.d.ts +4 -5
- package/dist/types/pop.d.ts +4 -5
- package/dist/types/progress-nodes.d.ts +4 -5
- package/dist/types/progress.d.ts +4 -5
- package/dist/types/quick-batch-edit.d.ts +4 -5
- package/dist/types/radio-group.d.ts +4 -5
- package/dist/types/radio.d.ts +4 -5
- package/dist/types/rich-text-editor.d.ts +6 -7
- package/dist/types/scroll.d.ts +5 -6
- package/dist/types/segment.d.ts +5 -6
- package/dist/types/select.d.ts +4 -5
- package/dist/types/slider.d.ts +4 -5
- package/dist/types/steps.d.ts +5 -6
- package/dist/types/switch.d.ts +4 -5
- package/dist/types/table-editor.d.ts +4 -5
- package/dist/types/table.d.ts +23 -13
- package/dist/types/tabs.d.ts +13 -14
- package/dist/types/tag.d.ts +3 -4
- package/dist/types/text-editor.d.ts +5 -6
- package/dist/types/text.d.ts +4 -5
- package/dist/types/textarea.d.ts +4 -5
- package/dist/types/theme.d.ts +3 -4
- package/dist/types/tip.d.ts +6 -7
- package/dist/types/tree-select.d.ts +4 -5
- package/dist/types/tree.d.ts +6 -6
- package/dist/types/watermark.d.ts +4 -5
- package/package.json +5 -5
- package/src/components/table/__test__/column-style.test.ts +67 -0
- package/src/components/table/node/col.ts +30 -1
- package/src/components/table/table-cell.vue +7 -2
- package/src/components/table/table-foot.vue +2 -0
- package/src/components/table/table-head.tsx +1 -0
- package/src/components/table/table-row.tsx +2 -0
- package/src/types/table.ts +12 -0
package/dist/types/textarea.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DeconstructValue, FormComponentProps } from "@veltra/utils";
|
|
2
2
|
//#region src/types/textarea.d.ts
|
|
3
3
|
/** textarea组件属性 */
|
|
4
|
-
interface TextareaProps extends FormComponentProps {
|
|
4
|
+
export interface TextareaProps extends FormComponentProps {
|
|
5
5
|
/**
|
|
6
6
|
* 文本域的值
|
|
7
7
|
*/
|
|
@@ -52,7 +52,7 @@ interface TextareaProps extends FormComponentProps {
|
|
|
52
52
|
autosize?: boolean;
|
|
53
53
|
}
|
|
54
54
|
/** textarea组件定义的事件 */
|
|
55
|
-
interface TextareaEmits {
|
|
55
|
+
export interface TextareaEmits {
|
|
56
56
|
/**modelValue值改变时触发 */
|
|
57
57
|
(e: 'update:modelValue', value: string): void;
|
|
58
58
|
/**当 modelValue 改变时,并且文本框失去焦点或用户按Enter时触发 */
|
|
@@ -65,9 +65,8 @@ interface TextareaEmits {
|
|
|
65
65
|
(e: 'clear'): void;
|
|
66
66
|
}
|
|
67
67
|
/** textarea组件暴露的属性和方法(组件内部使用) */
|
|
68
|
-
interface _TextareaExposed {}
|
|
68
|
+
export interface _TextareaExposed {}
|
|
69
69
|
/** textarea组件暴露的属性和方法(组件外部使用, 引用的值会被自动解构) */
|
|
70
|
-
type TextareaExposed = DeconstructValue<_TextareaExposed>;
|
|
70
|
+
export type TextareaExposed = DeconstructValue<_TextareaExposed>;
|
|
71
71
|
//#endregion
|
|
72
|
-
export { TextareaEmits, TextareaExposed, TextareaProps, _TextareaExposed };
|
|
73
72
|
//# sourceMappingURL=textarea.d.ts.map
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import { DeconstructValue } from "@veltra/utils";
|
|
|
2
2
|
import { UITheme } from "@veltra/styles/theme";
|
|
3
3
|
//#region src/types/theme.d.ts
|
|
4
4
|
/** 主题组件属性 */
|
|
5
|
-
interface ThemeProps {
|
|
5
|
+
export interface ThemeProps {
|
|
6
6
|
/** 指定要编辑的主题实例,默认跟随当前已加载主题 */
|
|
7
7
|
theme?: UITheme;
|
|
8
8
|
}
|
|
9
9
|
/** 主题组件暴露的属性和方法(组件内部使用) */
|
|
10
|
-
interface _ThemeExposed {
|
|
10
|
+
export interface _ThemeExposed {
|
|
11
11
|
/** 恢复到当前基线主题 */
|
|
12
12
|
reset: () => void;
|
|
13
13
|
/** 导出当前主题 */
|
|
@@ -18,7 +18,6 @@ interface _ThemeExposed {
|
|
|
18
18
|
applyDarkPreset: () => void;
|
|
19
19
|
}
|
|
20
20
|
/** 主题组件暴露的属性和方法 */
|
|
21
|
-
type ThemeExposed = DeconstructValue<_ThemeExposed>;
|
|
21
|
+
export type ThemeExposed = DeconstructValue<_ThemeExposed>;
|
|
22
22
|
//#endregion
|
|
23
|
-
export { ThemeExposed, ThemeProps, _ThemeExposed };
|
|
24
23
|
//# sourceMappingURL=theme.d.ts.map
|
package/dist/types/tip.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CSSProperties } from "vue";
|
|
2
2
|
import { DeconstructValue } from "@veltra/utils";
|
|
3
3
|
//#region src/types/tip.d.ts
|
|
4
|
-
type TipDirection = 'top' | 'bottom' | 'left' | 'right';
|
|
5
|
-
type TipAlign = 'center' | 'start' | 'end';
|
|
4
|
+
export type TipDirection = 'top' | 'bottom' | 'left' | 'right';
|
|
5
|
+
export type TipAlign = 'center' | 'start' | 'end';
|
|
6
6
|
/** tip提示组件组件属性 */
|
|
7
|
-
interface TipProps {
|
|
7
|
+
export interface TipProps {
|
|
8
8
|
/** 控制显影 */
|
|
9
9
|
visible?: boolean;
|
|
10
10
|
/**提示内容 */
|
|
@@ -45,13 +45,12 @@ interface TipProps {
|
|
|
45
45
|
showDelay?: number;
|
|
46
46
|
}
|
|
47
47
|
/** tip提示组件组件定义的事件 */
|
|
48
|
-
interface TipEmits {
|
|
48
|
+
export interface TipEmits {
|
|
49
49
|
(e: 'update:visible', value: boolean): void;
|
|
50
50
|
}
|
|
51
51
|
/** tip提示组件组件暴露的属性和方法(组件内部使用) */
|
|
52
|
-
interface _TipExposed {}
|
|
52
|
+
export interface _TipExposed {}
|
|
53
53
|
/** tip提示组件组件暴露的属性和方法(组件外部使用, 引用的值会被自动解构) */
|
|
54
|
-
type TipExposed = DeconstructValue<_TipExposed>;
|
|
54
|
+
export type TipExposed = DeconstructValue<_TipExposed>;
|
|
55
55
|
//#endregion
|
|
56
|
-
export { TipAlign, TipDirection, TipEmits, TipExposed, TipProps, _TipExposed };
|
|
57
56
|
//# sourceMappingURL=tip.d.ts.map
|
|
@@ -3,7 +3,7 @@ import { CSSProperties } from "vue";
|
|
|
3
3
|
import { DeconstructValue, FormComponentProps } from "@veltra/utils";
|
|
4
4
|
//#region src/types/tree-select.d.ts
|
|
5
5
|
/** 树形选择器组件属性 */
|
|
6
|
-
interface TreeSelectProps extends FormComponentProps, Omit<TreeProps, 'selected' | 'checked' | 'selectable' | 'checkable'> {
|
|
6
|
+
export interface TreeSelectProps extends FormComponentProps, Omit<TreeProps, 'selected' | 'checked' | 'selectable' | 'checkable'> {
|
|
7
7
|
modelValue?: string | number;
|
|
8
8
|
/** 自定义占位文字 */
|
|
9
9
|
placeholder?: string;
|
|
@@ -31,7 +31,7 @@ interface TreeSelectProps extends FormComponentProps, Omit<TreeProps, 'selected'
|
|
|
31
31
|
contentClass?: unknown;
|
|
32
32
|
}
|
|
33
33
|
/** 树形选择器组件定义的事件 */
|
|
34
|
-
interface TreeSelectEmits {
|
|
34
|
+
export interface TreeSelectEmits {
|
|
35
35
|
(e: 'clear'): void;
|
|
36
36
|
(e: 'update:modelValue', value?: string | number): void;
|
|
37
37
|
(e: 'change', selectedData?: Record<string, any>): void;
|
|
@@ -42,9 +42,8 @@ interface TreeSelectEmits {
|
|
|
42
42
|
(e: 'update:text', text?: string): void;
|
|
43
43
|
}
|
|
44
44
|
/** 树形选择器组件暴露的属性和方法(组件内部使用) */
|
|
45
|
-
interface _TreeSelectExposed {}
|
|
45
|
+
export interface _TreeSelectExposed {}
|
|
46
46
|
/** 树形选择器组件暴露的属性和方法(组件外部使用, 引用的值会被自动解构) */
|
|
47
|
-
type TreeSelectExposed = DeconstructValue<_TreeSelectExposed>;
|
|
47
|
+
export type TreeSelectExposed = DeconstructValue<_TreeSelectExposed>;
|
|
48
48
|
//#endregion
|
|
49
|
-
export { TreeSelectEmits, TreeSelectExposed, TreeSelectProps, _TreeSelectExposed };
|
|
50
49
|
//# sourceMappingURL=tree-select.d.ts.map
|
package/dist/types/tree.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ interface TreeNode$1<Data extends Record<string, any> = Record<string, any>> ext
|
|
|
20
20
|
bubbleSet: (setter: (node: TreeNode$1<Data>) => void) => void;
|
|
21
21
|
}
|
|
22
22
|
/** 树组件属性 */
|
|
23
|
-
interface TreeProps {
|
|
23
|
+
export interface TreeProps {
|
|
24
24
|
/** 是否展开所有节点 */
|
|
25
25
|
expandAll?: boolean;
|
|
26
26
|
/** 是否在点击节点的时候展开或者收缩节点 */
|
|
@@ -62,7 +62,7 @@ interface TreeProps {
|
|
|
62
62
|
/** 使选中项或多选项出现在滚动视图中 */
|
|
63
63
|
scrollToView?: boolean;
|
|
64
64
|
}
|
|
65
|
-
interface TreeEmit {
|
|
65
|
+
export interface TreeEmit {
|
|
66
66
|
/** 节点展开/折叠事件 */
|
|
67
67
|
(e: 'expand', node: TreeNode$1): void;
|
|
68
68
|
/** 节点点击事件 */
|
|
@@ -76,7 +76,7 @@ interface TreeEmit {
|
|
|
76
76
|
/** 选中项同步完成事件 */
|
|
77
77
|
(e: 'selected-synced', selected?: Record<string, any>): void;
|
|
78
78
|
}
|
|
79
|
-
interface TreeNodeProps {
|
|
79
|
+
export interface TreeNodeProps {
|
|
80
80
|
node: TreeNode$1;
|
|
81
81
|
/**
|
|
82
82
|
* 虚拟项索引:对应 `nodes` 数组中的绝对位置。
|
|
@@ -86,7 +86,7 @@ interface TreeNodeProps {
|
|
|
86
86
|
measureElement?: (index: number, el: Element | null) => void;
|
|
87
87
|
}
|
|
88
88
|
/** 树组件暴露的属性和方法(组件内部使用) */
|
|
89
|
-
interface _TreeExposed {
|
|
89
|
+
export interface _TreeExposed {
|
|
90
90
|
/** 滚动到目标元素 */
|
|
91
91
|
scrollTo: (index: number) => void;
|
|
92
92
|
/**
|
|
@@ -112,7 +112,7 @@ interface _TreeExposed {
|
|
|
112
112
|
collapseAll(): void;
|
|
113
113
|
}
|
|
114
114
|
/** 树组件暴露的属性和方法(组件外部使用, 引用的值会被自动解构) */
|
|
115
|
-
type TreeExposed = DeconstructValue<_TreeExposed>;
|
|
115
|
+
export type TreeExposed = DeconstructValue<_TreeExposed>;
|
|
116
116
|
//#endregion
|
|
117
|
-
export {
|
|
117
|
+
export { TreeNode$1 as TreeNode };
|
|
118
118
|
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DeconstructValue } from "@veltra/utils";
|
|
2
2
|
//#region src/types/watermark.d.ts
|
|
3
3
|
/** watermark组件属性 */
|
|
4
|
-
interface WatermarkProps {
|
|
4
|
+
export interface WatermarkProps {
|
|
5
5
|
/** 文字 */
|
|
6
6
|
text?: string;
|
|
7
7
|
/** 图片 */
|
|
@@ -14,11 +14,10 @@ interface WatermarkProps {
|
|
|
14
14
|
fontSize?: number;
|
|
15
15
|
}
|
|
16
16
|
/** watermark组件定义的事件 */
|
|
17
|
-
interface WatermarkEmits {}
|
|
17
|
+
export interface WatermarkEmits {}
|
|
18
18
|
/** watermark组件暴露的属性和方法(组件内部使用) */
|
|
19
|
-
interface _WatermarkExposed {}
|
|
19
|
+
export interface _WatermarkExposed {}
|
|
20
20
|
/** watermark组件暴露的属性和方法(组件外部使用, 引用的值会被自动解构) */
|
|
21
|
-
type WatermarkExposed = DeconstructValue<_WatermarkExposed>;
|
|
21
|
+
export type WatermarkExposed = DeconstructValue<_WatermarkExposed>;
|
|
22
22
|
//#endregion
|
|
23
|
-
export { WatermarkEmits, WatermarkExposed, WatermarkProps, _WatermarkExposed };
|
|
24
23
|
//# sourceMappingURL=watermark.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veltra/desktop",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.13",
|
|
4
4
|
"homepage": "https://github.com/cabinet-fe/ultra-ui#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/cabinet-fe/ultra-ui/issues"
|
|
@@ -80,12 +80,12 @@
|
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"@cat-kit/core": ">=1.2.1",
|
|
82
82
|
"@cat-kit/fe": ">=1.2.1",
|
|
83
|
-
"@veltra/compositions": "^1.7.
|
|
84
|
-
"@veltra/directives": "^1.7.
|
|
83
|
+
"@veltra/compositions": "^1.7.13",
|
|
84
|
+
"@veltra/directives": "^1.7.13",
|
|
85
85
|
"@veltra/icons": "^1.5.0",
|
|
86
86
|
"@veltra/sheet-core": "^2.5.6",
|
|
87
|
-
"@veltra/styles": "^1.7.
|
|
88
|
-
"@veltra/utils": "^1.7.
|
|
87
|
+
"@veltra/styles": "^1.7.13",
|
|
88
|
+
"@veltra/utils": "^1.7.13",
|
|
89
89
|
"vue": ">=3.5.42"
|
|
90
90
|
},
|
|
91
91
|
"peerDependenciesMeta": {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { ColumnNode } from '../node/col'
|
|
4
|
+
|
|
5
|
+
describe('ColumnNode column styles', () => {
|
|
6
|
+
it('headerAlign 未指定时回退到 align', () => {
|
|
7
|
+
const column = new ColumnNode({ key: 'a', name: 'A', align: 'center' }, 0, 0)
|
|
8
|
+
|
|
9
|
+
expect(column.headerAlign).toBe('center')
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('headerAlign 显式指定时优先于 align', () => {
|
|
13
|
+
const column = new ColumnNode(
|
|
14
|
+
{ key: 'a', name: 'A', align: 'center', headerAlign: 'right' },
|
|
15
|
+
0,
|
|
16
|
+
0
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
expect(column.headerAlign).toBe('right')
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('headerCellStyle 未指定 headerStyle 时回退到 style', () => {
|
|
23
|
+
const column = new ColumnNode(
|
|
24
|
+
{ key: 'a', name: 'A', style: { color: 'red', fontSize: 14 } },
|
|
25
|
+
0,
|
|
26
|
+
0
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
expect(column.cellStyle).toEqual({ color: 'red', fontSize: '14px' })
|
|
30
|
+
expect(column.headerCellStyle).toEqual({ color: 'red', fontSize: '14px' })
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('headerCellStyle 显式指定 headerStyle 时优先于 style', () => {
|
|
34
|
+
const column = new ColumnNode(
|
|
35
|
+
{
|
|
36
|
+
key: 'a',
|
|
37
|
+
name: 'A',
|
|
38
|
+
style: { color: 'red', fontSize: 12 },
|
|
39
|
+
headerStyle: { color: 'blue', fontSize: 16 }
|
|
40
|
+
},
|
|
41
|
+
0,
|
|
42
|
+
0
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
expect(column.cellStyle).toEqual({ color: 'red', fontSize: '12px' })
|
|
46
|
+
expect(column.headerCellStyle).toEqual({ color: 'blue', fontSize: '16px' })
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('fontSize 数字转为 px,字符串原样保留', () => {
|
|
50
|
+
const column = new ColumnNode({ key: 'a', name: 'A', style: { fontSize: 18 } }, 0, 0)
|
|
51
|
+
const columnWithUnit = new ColumnNode(
|
|
52
|
+
{ key: 'b', name: 'B', style: { fontSize: '1.2rem' } },
|
|
53
|
+
0,
|
|
54
|
+
0
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
expect(column.cellStyle).toEqual({ fontSize: '18px' })
|
|
58
|
+
expect(columnWithUnit.cellStyle).toEqual({ fontSize: '1.2rem' })
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('未配置样式时 getter 返回 undefined', () => {
|
|
62
|
+
const column = new ColumnNode({ key: 'a', name: 'A' }, 0, 0)
|
|
63
|
+
|
|
64
|
+
expect(column.cellStyle).toBeUndefined()
|
|
65
|
+
expect(column.headerCellStyle).toBeUndefined()
|
|
66
|
+
})
|
|
67
|
+
})
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import { TreeNode } from '@cat-kit/core'
|
|
2
|
+
import { withUnit } from '@veltra/utils'
|
|
2
3
|
import { isReactive, reactive, shallowReactive } from 'vue'
|
|
3
4
|
|
|
4
|
-
import type { TableColumn, TableColumnAlign } from '../../../types'
|
|
5
|
+
import type { TableColumn, TableColumnAlign, TableColumnStyle } from '../../../types'
|
|
6
|
+
|
|
7
|
+
function normalizeColumnStyle(style?: TableColumnStyle): Record<string, string> | undefined {
|
|
8
|
+
if (!style) return undefined
|
|
9
|
+
|
|
10
|
+
const result: Record<string, string> = {}
|
|
11
|
+
|
|
12
|
+
if (style.color !== undefined) {
|
|
13
|
+
result.color = style.color
|
|
14
|
+
}
|
|
15
|
+
if (style.fontSize !== undefined) {
|
|
16
|
+
const fontSize = withUnit(style.fontSize, 'px')
|
|
17
|
+
if (fontSize !== undefined) {
|
|
18
|
+
result.fontSize = fontSize
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return Object.keys(result).length ? result : undefined
|
|
23
|
+
}
|
|
5
24
|
|
|
6
25
|
export class ColumnNode extends TreeNode<TableColumn, ColumnNode> {
|
|
7
26
|
declare children?: ColumnNode[] | undefined
|
|
@@ -44,6 +63,16 @@ export class ColumnNode extends TreeNode<TableColumn, ColumnNode> {
|
|
|
44
63
|
this.data.headerAlign = val
|
|
45
64
|
}
|
|
46
65
|
|
|
66
|
+
/** 表体/表尾单元格样式 */
|
|
67
|
+
get cellStyle(): Record<string, string> | undefined {
|
|
68
|
+
return normalizeColumnStyle(this.data.style)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** 表头单元格样式 */
|
|
72
|
+
get headerCellStyle(): Record<string, string> | undefined {
|
|
73
|
+
return normalizeColumnStyle(this.data.headerStyle ?? this.data.style)
|
|
74
|
+
}
|
|
75
|
+
|
|
47
76
|
/** 宽度 */
|
|
48
77
|
get width(): number | undefined {
|
|
49
78
|
const width = this.data.width ?? this.derived.allocatedWidth
|
|
@@ -24,13 +24,18 @@ defineOptions({ name: 'UTableCell' })
|
|
|
24
24
|
* 父组件 `TableRow` 已经持有注入上下文,直接把 `cellClass` 传下来即可;
|
|
25
25
|
* 这里变成「完全受控」的纯渲染单元。
|
|
26
26
|
*/
|
|
27
|
-
const { left, right } = defineProps<{
|
|
27
|
+
const { left, right, cellStyle } = defineProps<{
|
|
28
28
|
cellClass: string
|
|
29
29
|
left?: number
|
|
30
30
|
right?: number
|
|
31
|
+
cellStyle?: Record<string, string>
|
|
31
32
|
rowspan?: number
|
|
32
33
|
colspan?: number
|
|
33
34
|
}>()
|
|
34
35
|
|
|
35
|
-
const style = computed(() => ({
|
|
36
|
+
const style = computed(() => ({
|
|
37
|
+
...cellStyle,
|
|
38
|
+
left: withUnit(left, 'px'),
|
|
39
|
+
right: withUnit(right, 'px')
|
|
40
|
+
}))
|
|
36
41
|
</script>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
v-if="leafColumns[0]"
|
|
6
6
|
:class="getCellClass(leafColumns[0])"
|
|
7
7
|
:style="{
|
|
8
|
+
...leafColumns[0].cellStyle,
|
|
8
9
|
right: withUnit(leafColumns[0].style.right, 'px'),
|
|
9
10
|
left: withUnit(leafColumns[0].style.left, 'px')
|
|
10
11
|
}"
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
:class="getCellClass(column)"
|
|
17
18
|
:key="column.key"
|
|
18
19
|
:style="{
|
|
20
|
+
...column.cellStyle,
|
|
19
21
|
right: withUnit(column.style.right, 'px'),
|
|
20
22
|
left: withUnit(column.style.left, 'px')
|
|
21
23
|
}"
|
|
@@ -26,6 +26,7 @@ const TableHead: DefineComponent = defineComponent({
|
|
|
26
26
|
colspan={column.leafs}
|
|
27
27
|
rowspan={column.children?.length ? undefined : headers.value.length - headerIndex}
|
|
28
28
|
style={{
|
|
29
|
+
...column.headerCellStyle,
|
|
29
30
|
left: withUnit(column.style.left, 'px'),
|
|
30
31
|
right: withUnit(column.style.right, 'px')
|
|
31
32
|
}}
|
|
@@ -99,6 +99,7 @@ export const UTableRow: DefineComponent<{ row: ITableRow; index: number }> = def
|
|
|
99
99
|
cellClass={getCellClass(_expandColumn)}
|
|
100
100
|
left={_expandColumn.style.left}
|
|
101
101
|
right={_expandColumn.style.right}
|
|
102
|
+
cellStyle={_expandColumn.cellStyle}
|
|
102
103
|
key={row.uid + _expandColumn.key}
|
|
103
104
|
{...tableProps.mergeCell?.(expandCtx)}
|
|
104
105
|
>
|
|
@@ -156,6 +157,7 @@ export const UTableRow: DefineComponent<{ row: ITableRow; index: number }> = def
|
|
|
156
157
|
cellClass={getCellClass(column)}
|
|
157
158
|
left={column.style.left}
|
|
158
159
|
right={column.style.right}
|
|
160
|
+
cellStyle={column.cellStyle}
|
|
159
161
|
key={row.uid + column.key}
|
|
160
162
|
// @ts-ignore
|
|
161
163
|
onClick={(e) => handleCellClick(row, column, e)}
|
package/src/types/table.ts
CHANGED
|
@@ -4,6 +4,11 @@ import type { ShallowRef, Slots, VNode } from 'vue'
|
|
|
4
4
|
|
|
5
5
|
export type TableColumnAlign = 'left' | 'center' | 'right'
|
|
6
6
|
|
|
7
|
+
export interface TableColumnStyle {
|
|
8
|
+
color?: string
|
|
9
|
+
fontSize?: number | string
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
/**
|
|
8
13
|
* 合计上下文
|
|
9
14
|
*/
|
|
@@ -46,6 +51,10 @@ export interface TableColumn {
|
|
|
46
51
|
* @default 'left'
|
|
47
52
|
*/
|
|
48
53
|
align?: TableColumnAlign
|
|
54
|
+
/** 表体/表尾单元格样式 */
|
|
55
|
+
style?: TableColumnStyle
|
|
56
|
+
/** 表头单元格样式,未指定时取 style */
|
|
57
|
+
headerStyle?: TableColumnStyle
|
|
49
58
|
/** 列渲染 */
|
|
50
59
|
render?: (scope: TableColumnRenderContext) => RenderReturn
|
|
51
60
|
/** 子列 */
|
|
@@ -164,6 +173,9 @@ export interface TableColumnNode extends TreeNode<TableColumn> {
|
|
|
164
173
|
key: string
|
|
165
174
|
name: string
|
|
166
175
|
align: TableColumnAlign
|
|
176
|
+
headerAlign: TableColumnAlign
|
|
177
|
+
cellStyle?: Record<string, string>
|
|
178
|
+
headerCellStyle?: Record<string, string>
|
|
167
179
|
width: number | undefined
|
|
168
180
|
minWidth: number | undefined
|
|
169
181
|
fixed: 'left' | 'right' | undefined
|