@veltra/desktop 1.5.0 → 1.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/dist/components/button/button.js +2 -2
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button/style2.css +85 -92
- package/dist/components/collapse/collapse-item.js +24 -7
- package/dist/components/collapse/collapse-item.js.map +1 -1
- package/dist/components/dialog/style2.css +3 -1
- package/dist/components/layout/layout.js +22 -10
- package/dist/components/layout/layout.js.map +1 -1
- package/dist/components/table/allocate-column-widths.js +6 -3
- package/dist/components/table/allocate-column-widths.js.map +1 -1
- package/dist/components/table/node/col.js +16 -1
- package/dist/components/table/node/col.js.map +1 -1
- package/dist/components/table/use-col-resize.js +9 -1
- package/dist/components/table/use-col-resize.js.map +1 -1
- package/dist/types/collapse.d.ts +7 -1
- package/dist/types/layout.d.ts +16 -1
- package/package.json +6 -6
- package/src/components/button/button.vue +2 -2
- package/src/components/button/style.scss +8 -29
- package/src/components/collapse/__test__/collapse.test.ts +59 -0
- package/src/components/collapse/collapse-item.vue +32 -11
- package/src/components/dialog/style.scss +5 -1
- package/src/components/layout/layout.vue +19 -8
- package/src/components/table/__test__/col-width.test.ts +47 -6
- package/src/components/table/allocate-column-widths.ts +7 -4
- package/src/components/table/node/col.ts +21 -1
- package/src/components/table/use-col-resize.ts +9 -1
- package/src/types/collapse.ts +8 -1
- package/src/types/layout.ts +16 -1
|
@@ -46,7 +46,7 @@ export class ColumnNode extends TreeNode<TableColumn, ColumnNode> {
|
|
|
46
46
|
|
|
47
47
|
/** 宽度 */
|
|
48
48
|
get width(): number | undefined {
|
|
49
|
-
const
|
|
49
|
+
const width = this.data.width ?? this.derived.allocatedWidth
|
|
50
50
|
if (!width || (this.minWidth && width && width < this.minWidth)) {
|
|
51
51
|
return this.minWidth
|
|
52
52
|
}
|
|
@@ -57,6 +57,21 @@ export class ColumnNode extends TreeNode<TableColumn, ColumnNode> {
|
|
|
57
57
|
val = this.minWidth
|
|
58
58
|
}
|
|
59
59
|
this.data.width = val
|
|
60
|
+
// 显式宽度(配置/拖拽)优先于分配宽度,旧的分配结果直接作废
|
|
61
|
+
this.derived.allocatedWidth = undefined
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 列宽分配算法写入的宽度。
|
|
66
|
+
* 与用户列配置 `data.width` 隔离:分配结果不回写列配置对象,
|
|
67
|
+
* 避免列森林重建(重挂载 / v-if / columns 引用变化)时把上一次的
|
|
68
|
+
* 分配残留误判为显式 width,导致列宽被永久锁定、容器变窄后出现滚动条。
|
|
69
|
+
*/
|
|
70
|
+
get allocatedWidth(): number | undefined {
|
|
71
|
+
return this.derived.allocatedWidth
|
|
72
|
+
}
|
|
73
|
+
set allocatedWidth(val: number | undefined) {
|
|
74
|
+
this.derived.allocatedWidth = val
|
|
60
75
|
}
|
|
61
76
|
/** 最小宽度 */
|
|
62
77
|
get minWidth(): number | undefined {
|
|
@@ -102,6 +117,11 @@ export class ColumnNode extends TreeNode<TableColumn, ColumnNode> {
|
|
|
102
117
|
|
|
103
118
|
style: Record<string, number> = reactive({})
|
|
104
119
|
|
|
120
|
+
/** 派生状态(响应式),与用户列配置 data 隔离 */
|
|
121
|
+
private readonly derived = shallowReactive<{ allocatedWidth?: number }>({
|
|
122
|
+
allocatedWidth: undefined
|
|
123
|
+
})
|
|
124
|
+
|
|
105
125
|
constructor(val: TableColumn, index: number, depth: number, parent?: ColumnNode) {
|
|
106
126
|
super(isReactive(val) ? val : shallowReactive(val), index, depth, parent)
|
|
107
127
|
this.explicitWidth = val.width !== undefined
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { debounce } from '@cat-kit/core'
|
|
2
|
+
import { useResizeObserver } from '@veltra/compositions'
|
|
3
|
+
import { computed, nextTick, provide, shallowRef, watchEffect, type ShallowRef } from 'vue'
|
|
2
4
|
|
|
3
5
|
import type { ScrollExposed } from '../../types'
|
|
4
6
|
import { allocateLeafColumnWidths } from './allocate-column-widths'
|
|
@@ -53,6 +55,12 @@ export function useColResize(options: Options): UseColResizeReturned {
|
|
|
53
55
|
|
|
54
56
|
watchEffect(correctColumnStyle)
|
|
55
57
|
|
|
58
|
+
// 容器宽度变化(窗口缩放、父布局变化、纵向滚动条出现/消失等)时重新分配列宽,
|
|
59
|
+
// 直到所有未显式设宽的列回落到 minWidth。计算开销较大,用防抖合并连续的 resize 触发。
|
|
60
|
+
const debouncedCorrectColumnStyle = debounce(correctColumnStyle)
|
|
61
|
+
const containerRef = computed(() => scrollRef.value?.containerRef ?? null)
|
|
62
|
+
useResizeObserver({ targets: containerRef, onResize: debouncedCorrectColumnStyle })
|
|
63
|
+
|
|
56
64
|
function updateResizeLine(transformX: number): void {
|
|
57
65
|
if (!resizeLineRef.value) return
|
|
58
66
|
resizeLineRef.value.style.transform = `translateX(${transformX}px)`
|
package/src/types/collapse.ts
CHANGED
|
@@ -52,7 +52,7 @@ export interface CollapseItemProps {
|
|
|
52
52
|
*/
|
|
53
53
|
modelValue?: boolean
|
|
54
54
|
|
|
55
|
-
/**
|
|
55
|
+
/** 标题文本(也可通过 #header 插槽自定义整个头部) */
|
|
56
56
|
title?: string
|
|
57
57
|
|
|
58
58
|
/** 是否禁用 */
|
|
@@ -63,6 +63,13 @@ export interface CollapseItemProps {
|
|
|
63
63
|
* 在 `UCollapse` 内由父组件 `expandIcon` 统一管理。
|
|
64
64
|
*/
|
|
65
65
|
expandIcon?: Component
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 折叠动画结束后卸载内容 DOM(展开时重新挂载),减少长列表的内存与渲染成本。
|
|
69
|
+
* 注意:卸载会丢失内容区的本地组件状态。
|
|
70
|
+
* @default false
|
|
71
|
+
*/
|
|
72
|
+
destroyOnCollapse?: boolean
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
export interface CollapseItemEmits {
|
package/src/types/layout.ts
CHANGED
|
@@ -38,10 +38,25 @@ export interface LayoutProps {
|
|
|
38
38
|
* @description 注意:当为true时,gap固定且需要有一项宽度为固定像素才能够拖拽
|
|
39
39
|
*/
|
|
40
40
|
resizable?: boolean
|
|
41
|
+
/**
|
|
42
|
+
* 每列的最小宽度(px),按列索引与 cols 对应,仅 resizable 拖拽时生效。
|
|
43
|
+
* 未指定的列不限制(可被压至 0)。
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* // 三栏拖拽时,左栏不小于 120px,右栏不小于 200px
|
|
47
|
+
* :cols="['1fr', '2fr', '300px']" :col-min-sizes="[120, undefined, 200]"
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
colMinSizes?: (number | undefined)[]
|
|
41
51
|
}
|
|
42
52
|
|
|
43
53
|
/** 布局组件定义的事件 */
|
|
44
|
-
export interface LayoutEmits {
|
|
54
|
+
export interface LayoutEmits {
|
|
55
|
+
/** 开始拖拽调节某条间隔(index 为间隔左侧列的索引) */
|
|
56
|
+
(e: 'resize-start', index: number): void
|
|
57
|
+
/** 拖拽调节结束 */
|
|
58
|
+
(e: 'resize-end', index: number): void
|
|
59
|
+
}
|
|
45
60
|
|
|
46
61
|
/** 布局组件暴露的属性和方法(组件内部使用) */
|
|
47
62
|
export interface _LayoutExposed {}
|