stk-table-vue 0.6.10 → 0.6.12
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/README.md +201 -201
- package/lib/stk-table-vue.js +24 -12
- package/package.json +74 -74
- package/src/StkTable/StkTable.vue +1546 -1541
- package/src/StkTable/components/DragHandle.vue +9 -9
- package/src/StkTable/components/SortIcon.vue +6 -6
- package/src/StkTable/const.ts +37 -37
- package/src/StkTable/index.ts +4 -4
- package/src/StkTable/style.less +553 -553
- package/src/StkTable/types/highlightDimOptions.ts +26 -26
- package/src/StkTable/types/index.ts +239 -239
- package/src/StkTable/useAutoResize.ts +91 -91
- package/src/StkTable/useColResize.ts +216 -216
- package/src/StkTable/useFixedCol.ts +148 -148
- package/src/StkTable/useFixedStyle.ts +75 -75
- package/src/StkTable/useGetFixedColPosition.ts +65 -65
- package/src/StkTable/useHighlight.ts +318 -318
- package/src/StkTable/useKeyboardArrowScroll.ts +112 -106
- package/src/StkTable/useThDrag.ts +102 -102
- package/src/StkTable/useTrDrag.ts +118 -118
- package/src/StkTable/useVirtualScroll.ts +447 -447
- package/src/StkTable/utils/constRefUtils.ts +29 -29
- package/src/StkTable/utils/index.ts +212 -212
- package/src/StkTable/utils/useTriggerRef.ts +33 -33
- package/src/VirtualTree.vue +622 -622
- package/src/VirtualTreeSelect.vue +367 -367
- package/src/vite-env.d.ts +10 -10
package/README.md
CHANGED
|
@@ -1,201 +1,201 @@
|
|
|
1
|
-
# StkTable (Sticky Table)
|
|
2
|
-

|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-
|
|
7
|
-
Vue3 简易虚拟滚动表格。用于实时数据展示,新数据行高亮渐暗动效。
|
|
8
|
-
|
|
9
|
-
Vue2.7支持引入源码(**ts**)使用。
|
|
10
|
-
|
|
11
|
-
[Stk Table Vue Doc](https://ja-plus.github.io/stk-table-vue/)
|
|
12
|
-
|
|
13
|
-
repo(求 star🌟):
|
|
14
|
-
- [Github](https://github.com/ja-plus/stk-table-vue)
|
|
15
|
-
- [Gitee](https://gitee.com/japlus/stk-table-vue) 🇨🇳
|
|
16
|
-
|
|
17
|
-
[<span style="font-size: 16px;font-weight: bold;">Online Demo</span>](https://stackblitz.com/edit/vitejs-vite-ad91hh?file=src%2FDemo%2Findex.vue)
|
|
18
|
-
|
|
19
|
-
## Feature TODO:
|
|
20
|
-
* [x] 高亮行,单元格。
|
|
21
|
-
- [x] 使用 `Web Animations API` 实现高亮。(`v0.3.4` 变更为默认值)
|
|
22
|
-
- [x] 支持配置高亮参数(持续时间,颜色,频率)。(`v0.2.9`)
|
|
23
|
-
- [x] `setHighlightDimRow`/`setHighlightCellRow`支持自定义高亮css类名。(`v0.2.9`)
|
|
24
|
-
* [x] 虚拟列表。
|
|
25
|
-
- [x] 纵向。
|
|
26
|
-
- [x] 横向(必须设置列宽)。
|
|
27
|
-
- [x] 支持不定行高。(`v0.6.0`)
|
|
28
|
-
* [x] 列固定。
|
|
29
|
-
- [x] 固定列阴影。
|
|
30
|
-
- [x] 多级表头固定列阴影。
|
|
31
|
-
- [x] sticky column 动态计算阴影位置。(`v0.4.0`)
|
|
32
|
-
* [x] 行展开。(`v0.5.0`)
|
|
33
|
-
* [x] 行拖动。(`v0.5.0`)
|
|
34
|
-
* [] 列筛选。
|
|
35
|
-
* [x] 斑马纹。
|
|
36
|
-
* [x] 拖动更改列顺序。
|
|
37
|
-
* [x] 拖动调整列宽。
|
|
38
|
-
* [x] 排序
|
|
39
|
-
- [x] 支持配置 `null` | `undefined` 永远排最后。
|
|
40
|
-
- [x] 支持配置 string 使用 `String.prototype.localCompare` 排序。
|
|
41
|
-
* [x] 多级表头。
|
|
42
|
-
- [] 横向虚拟滚动。
|
|
43
|
-
* [x] 支持table-layout: fixed 配置。
|
|
44
|
-
* [x] 鼠标悬浮在表格上,键盘滚动虚拟表格。
|
|
45
|
-
- [x] 键盘 `ArrowUp`/`ArrowDown`/`ArrowLeft`/`ArrowRight`/`PageUp`/ `PageDown` 按键支持。
|
|
46
|
-
* [] 非虚拟滚动时,大数据分批加载。
|
|
47
|
-
* [x] vue2.7支持(引入源码使用)。
|
|
48
|
-
- [x] `props.optimizeVue2Scroll` 优化vue2虚拟滚动流畅度。(`v0.2.0`)
|
|
49
|
-
* [x] 支持配置序号列。`StkTableColumn['type']`。(`v0.3.0`)
|
|
50
|
-
* [x] `props.cellHover`单元格悬浮样式。(`v0.3.2`)
|
|
51
|
-
* [] 惯性滚动优化。
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
## Usage
|
|
55
|
-
> npm install stk-table-vue
|
|
56
|
-
|
|
57
|
-
```html
|
|
58
|
-
<script setup>
|
|
59
|
-
import { StkTable } from 'stk-table-vue'
|
|
60
|
-
import { ref, useTemplateRef } from 'vue'
|
|
61
|
-
const stkTableRef = ref<InstanceType<typeof StkTable>>();
|
|
62
|
-
// or Vue 3.5 useTemplateRef
|
|
63
|
-
const stkTableRef = useTemplateRef('stkTableRef');
|
|
64
|
-
|
|
65
|
-
// highlight row
|
|
66
|
-
stkTableRef.value.setHighlightDimRow([rowKey],{
|
|
67
|
-
method: 'css'|'js'|'animation',// 默认 animation。
|
|
68
|
-
className: 'custom-class-name', // method css 时生效。
|
|
69
|
-
keyframe: [{backgroundColor:'#aaa'}, {backgroundColor: '#222'}],//same as https://developer.mozilla.org/zh-CN/docs/Web/API/Web_Animations_API/Keyframe_Formats
|
|
70
|
-
duration: 2000,// 动画时长。
|
|
71
|
-
});
|
|
72
|
-
// highlight cell
|
|
73
|
-
stkTableRef.value.setHighlightDimCell(rowKey, colDataIndex, {
|
|
74
|
-
method: 'css'|'animation',
|
|
75
|
-
className:'custom-class-name', // method css 时生效。
|
|
76
|
-
keyframe: [{backgroundColor:'#aaa'}, {backgroundColor: '#222'}], // method animation 时生效。
|
|
77
|
-
duration: 2000,// 动画时长。
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const columns = [
|
|
81
|
-
{title: 'name', dataIndex: 'name'},
|
|
82
|
-
{title: 'age', dataIndex: 'age'},
|
|
83
|
-
{title: 'address', dataIndex: 'address'},
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
const dataSource = [
|
|
87
|
-
{id: 1, name: 'John', age: 32, address: 'New York'},
|
|
88
|
-
{id: 2, name: 'Jim', age: 42, address: 'London'},
|
|
89
|
-
{id: 3, name: 'Joe', age: 52, address: 'Tokyo'},
|
|
90
|
-
{id: 4, name: 'Jack', age: 62, address: 'Sydney'},
|
|
91
|
-
{id: 5, name: 'Jill', age: 72, address: 'Paris'},
|
|
92
|
-
]
|
|
93
|
-
|
|
94
|
-
</script>
|
|
95
|
-
|
|
96
|
-
<template>
|
|
97
|
-
<StkTable ref='stkTableRef' row-key="id" :data-source="dataSource" :columns="columns"></StkTable>
|
|
98
|
-
</template>
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Vue2.7 Usage
|
|
103
|
-
[在vue2中使用](https://ja-plus.github.io/stk-table-vue/main/start/vue2-usage.html)
|
|
104
|
-
|
|
105
|
-
## Notice
|
|
106
|
-
注意,组件会改动 `props.columns` 中的对象。如果多个组件 `columns` 数组元素存在引用同一个 `StkTableColumn` 对象。则考虑赋值 `columns` 前进行深拷贝。
|
|
107
|
-
|
|
108
|
-
## API
|
|
109
|
-
### Props
|
|
110
|
-
[Props 表格配置](https://ja-plus.github.io/stk-table-vue/main/api/table-props.html)
|
|
111
|
-
|
|
112
|
-
### Emits
|
|
113
|
-
[Emits 事件](https://ja-plus.github.io/stk-table-vue/main/api/emits.html)
|
|
114
|
-
|
|
115
|
-
### Slots
|
|
116
|
-
[Slots 插槽](https://ja-plus.github.io/stk-table-vue/main/api/slots.html)
|
|
117
|
-
|
|
118
|
-
### Expose
|
|
119
|
-
[Expose 实例方法](https://ja-plus.github.io/stk-table-vue/main/api/expose.html)
|
|
120
|
-
|
|
121
|
-
### StkTableColumn 列配置
|
|
122
|
-
[StkTableColumn 列配置](https://ja-plus.github.io/stk-table-vue/main/api/stk-table-column.html)
|
|
123
|
-
|
|
124
|
-
### setHighlightDimCell & setHighlightDimRow
|
|
125
|
-
[高亮使用文档](https://ja-plus.github.io/stk-table-vue/main/api/expose.html#sethighlightdimcell)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
### Example
|
|
129
|
-
```vue
|
|
130
|
-
<template>
|
|
131
|
-
<StkTable
|
|
132
|
-
ref="stkTable"
|
|
133
|
-
row-key="name"
|
|
134
|
-
v-model:columns="columns"
|
|
135
|
-
:style="{height:props.height}"
|
|
136
|
-
theme='dark'
|
|
137
|
-
height='200px'
|
|
138
|
-
bordered="h"
|
|
139
|
-
:row-height="28"
|
|
140
|
-
:show-overflow="false"
|
|
141
|
-
:show-header-overflow="false"
|
|
142
|
-
:sort-remote="false"
|
|
143
|
-
col-resizable
|
|
144
|
-
header-drag
|
|
145
|
-
virtual
|
|
146
|
-
virtual-x
|
|
147
|
-
no-data-full
|
|
148
|
-
col-resizable
|
|
149
|
-
auto-resize
|
|
150
|
-
fixed-col-shadow
|
|
151
|
-
:col-min-width="10"
|
|
152
|
-
:headless="false"
|
|
153
|
-
:data-source="dataSource"
|
|
154
|
-
@current-change="onCurrentChange"
|
|
155
|
-
@row-menu="onRowMenu"
|
|
156
|
-
@header-row-menu="onHeaderRowMenu"
|
|
157
|
-
@row-click="onRowClick"
|
|
158
|
-
@row-dblclick="onRowDblclick"
|
|
159
|
-
@sort-change="handleSortChange"
|
|
160
|
-
@cell-click="onCellClick"
|
|
161
|
-
@header-cell-click="onHeaderCellClick"
|
|
162
|
-
@scroll="onTableScroll"
|
|
163
|
-
@scroll-x="onTableScrollX"
|
|
164
|
-
@col-order-change="onColOrderChange"
|
|
165
|
-
/>
|
|
166
|
-
</template>
|
|
167
|
-
<script setup>
|
|
168
|
-
import { h, defineComponent } from 'vue';
|
|
169
|
-
const columns = [
|
|
170
|
-
{
|
|
171
|
-
title: 'Name',
|
|
172
|
-
dataIndex: 'name',
|
|
173
|
-
fixed: 'left',
|
|
174
|
-
width: '200px',
|
|
175
|
-
headerClassName: 'my-th',
|
|
176
|
-
className: 'my-td',
|
|
177
|
-
sorter: true,
|
|
178
|
-
customHeaderCell: function FunctionalComponent(props){
|
|
179
|
-
return h(
|
|
180
|
-
'span',
|
|
181
|
-
{ style: 'overflow:hidden;text-overflow:ellipsis;white-space:nowrap' },
|
|
182
|
-
props.col.title + '(render) text-overflow,',
|
|
183
|
-
);
|
|
184
|
-
},
|
|
185
|
-
customCell: defineComponent({
|
|
186
|
-
setup(){
|
|
187
|
-
//...
|
|
188
|
-
return () => <div></div> // vue jsx
|
|
189
|
-
}
|
|
190
|
-
})
|
|
191
|
-
},
|
|
192
|
-
]
|
|
193
|
-
</script>
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
## Other
|
|
198
|
-
* `$*$` 兼容注释
|
|
199
|
-
|
|
200
|
-
### Planed removal APi
|
|
201
|
-
* `setHighlightDimRow` 中的 `method="js"`。观察animation Api 是否足够满足使用场景。若足够满足计划在后期移除,并且可以移除 `d3-interpolate` 依赖。
|
|
1
|
+
# StkTable (Sticky Table)
|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
Vue3 简易虚拟滚动表格。用于实时数据展示,新数据行高亮渐暗动效。
|
|
8
|
+
|
|
9
|
+
Vue2.7支持引入源码(**ts**)使用。
|
|
10
|
+
|
|
11
|
+
[Stk Table Vue Doc](https://ja-plus.github.io/stk-table-vue/)
|
|
12
|
+
|
|
13
|
+
repo(求 star🌟):
|
|
14
|
+
- [Github](https://github.com/ja-plus/stk-table-vue)
|
|
15
|
+
- [Gitee](https://gitee.com/japlus/stk-table-vue) 🇨🇳
|
|
16
|
+
|
|
17
|
+
[<span style="font-size: 16px;font-weight: bold;">Online Demo</span>](https://stackblitz.com/edit/vitejs-vite-ad91hh?file=src%2FDemo%2Findex.vue)
|
|
18
|
+
|
|
19
|
+
## Feature TODO:
|
|
20
|
+
* [x] 高亮行,单元格。
|
|
21
|
+
- [x] 使用 `Web Animations API` 实现高亮。(`v0.3.4` 变更为默认值)
|
|
22
|
+
- [x] 支持配置高亮参数(持续时间,颜色,频率)。(`v0.2.9`)
|
|
23
|
+
- [x] `setHighlightDimRow`/`setHighlightCellRow`支持自定义高亮css类名。(`v0.2.9`)
|
|
24
|
+
* [x] 虚拟列表。
|
|
25
|
+
- [x] 纵向。
|
|
26
|
+
- [x] 横向(必须设置列宽)。
|
|
27
|
+
- [x] 支持不定行高。(`v0.6.0`)
|
|
28
|
+
* [x] 列固定。
|
|
29
|
+
- [x] 固定列阴影。
|
|
30
|
+
- [x] 多级表头固定列阴影。
|
|
31
|
+
- [x] sticky column 动态计算阴影位置。(`v0.4.0`)
|
|
32
|
+
* [x] 行展开。(`v0.5.0`)
|
|
33
|
+
* [x] 行拖动。(`v0.5.0`)
|
|
34
|
+
* [] 列筛选。
|
|
35
|
+
* [x] 斑马纹。
|
|
36
|
+
* [x] 拖动更改列顺序。
|
|
37
|
+
* [x] 拖动调整列宽。
|
|
38
|
+
* [x] 排序
|
|
39
|
+
- [x] 支持配置 `null` | `undefined` 永远排最后。
|
|
40
|
+
- [x] 支持配置 string 使用 `String.prototype.localCompare` 排序。
|
|
41
|
+
* [x] 多级表头。
|
|
42
|
+
- [] 横向虚拟滚动。
|
|
43
|
+
* [x] 支持table-layout: fixed 配置。
|
|
44
|
+
* [x] 鼠标悬浮在表格上,键盘滚动虚拟表格。
|
|
45
|
+
- [x] 键盘 `ArrowUp`/`ArrowDown`/`ArrowLeft`/`ArrowRight`/`PageUp`/ `PageDown` 按键支持。
|
|
46
|
+
* [] 非虚拟滚动时,大数据分批加载。
|
|
47
|
+
* [x] vue2.7支持(引入源码使用)。
|
|
48
|
+
- [x] `props.optimizeVue2Scroll` 优化vue2虚拟滚动流畅度。(`v0.2.0`)
|
|
49
|
+
* [x] 支持配置序号列。`StkTableColumn['type']`。(`v0.3.0`)
|
|
50
|
+
* [x] `props.cellHover`单元格悬浮样式。(`v0.3.2`)
|
|
51
|
+
* [] 惯性滚动优化。
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
> npm install stk-table-vue
|
|
56
|
+
|
|
57
|
+
```html
|
|
58
|
+
<script setup>
|
|
59
|
+
import { StkTable } from 'stk-table-vue'
|
|
60
|
+
import { ref, useTemplateRef } from 'vue'
|
|
61
|
+
const stkTableRef = ref<InstanceType<typeof StkTable>>();
|
|
62
|
+
// or Vue 3.5 useTemplateRef
|
|
63
|
+
const stkTableRef = useTemplateRef('stkTableRef');
|
|
64
|
+
|
|
65
|
+
// highlight row
|
|
66
|
+
stkTableRef.value.setHighlightDimRow([rowKey],{
|
|
67
|
+
method: 'css'|'js'|'animation',// 默认 animation。
|
|
68
|
+
className: 'custom-class-name', // method css 时生效。
|
|
69
|
+
keyframe: [{backgroundColor:'#aaa'}, {backgroundColor: '#222'}],//same as https://developer.mozilla.org/zh-CN/docs/Web/API/Web_Animations_API/Keyframe_Formats
|
|
70
|
+
duration: 2000,// 动画时长。
|
|
71
|
+
});
|
|
72
|
+
// highlight cell
|
|
73
|
+
stkTableRef.value.setHighlightDimCell(rowKey, colDataIndex, {
|
|
74
|
+
method: 'css'|'animation',
|
|
75
|
+
className:'custom-class-name', // method css 时生效。
|
|
76
|
+
keyframe: [{backgroundColor:'#aaa'}, {backgroundColor: '#222'}], // method animation 时生效。
|
|
77
|
+
duration: 2000,// 动画时长。
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const columns = [
|
|
81
|
+
{title: 'name', dataIndex: 'name'},
|
|
82
|
+
{title: 'age', dataIndex: 'age'},
|
|
83
|
+
{title: 'address', dataIndex: 'address'},
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
const dataSource = [
|
|
87
|
+
{id: 1, name: 'John', age: 32, address: 'New York'},
|
|
88
|
+
{id: 2, name: 'Jim', age: 42, address: 'London'},
|
|
89
|
+
{id: 3, name: 'Joe', age: 52, address: 'Tokyo'},
|
|
90
|
+
{id: 4, name: 'Jack', age: 62, address: 'Sydney'},
|
|
91
|
+
{id: 5, name: 'Jill', age: 72, address: 'Paris'},
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<template>
|
|
97
|
+
<StkTable ref='stkTableRef' row-key="id" :data-source="dataSource" :columns="columns"></StkTable>
|
|
98
|
+
</template>
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Vue2.7 Usage
|
|
103
|
+
[在vue2中使用](https://ja-plus.github.io/stk-table-vue/main/start/vue2-usage.html)
|
|
104
|
+
|
|
105
|
+
## Notice
|
|
106
|
+
注意,组件会改动 `props.columns` 中的对象。如果多个组件 `columns` 数组元素存在引用同一个 `StkTableColumn` 对象。则考虑赋值 `columns` 前进行深拷贝。
|
|
107
|
+
|
|
108
|
+
## API
|
|
109
|
+
### Props
|
|
110
|
+
[Props 表格配置](https://ja-plus.github.io/stk-table-vue/main/api/table-props.html)
|
|
111
|
+
|
|
112
|
+
### Emits
|
|
113
|
+
[Emits 事件](https://ja-plus.github.io/stk-table-vue/main/api/emits.html)
|
|
114
|
+
|
|
115
|
+
### Slots
|
|
116
|
+
[Slots 插槽](https://ja-plus.github.io/stk-table-vue/main/api/slots.html)
|
|
117
|
+
|
|
118
|
+
### Expose
|
|
119
|
+
[Expose 实例方法](https://ja-plus.github.io/stk-table-vue/main/api/expose.html)
|
|
120
|
+
|
|
121
|
+
### StkTableColumn 列配置
|
|
122
|
+
[StkTableColumn 列配置](https://ja-plus.github.io/stk-table-vue/main/api/stk-table-column.html)
|
|
123
|
+
|
|
124
|
+
### setHighlightDimCell & setHighlightDimRow
|
|
125
|
+
[高亮使用文档](https://ja-plus.github.io/stk-table-vue/main/api/expose.html#sethighlightdimcell)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
### Example
|
|
129
|
+
```vue
|
|
130
|
+
<template>
|
|
131
|
+
<StkTable
|
|
132
|
+
ref="stkTable"
|
|
133
|
+
row-key="name"
|
|
134
|
+
v-model:columns="columns"
|
|
135
|
+
:style="{height:props.height}"
|
|
136
|
+
theme='dark'
|
|
137
|
+
height='200px'
|
|
138
|
+
bordered="h"
|
|
139
|
+
:row-height="28"
|
|
140
|
+
:show-overflow="false"
|
|
141
|
+
:show-header-overflow="false"
|
|
142
|
+
:sort-remote="false"
|
|
143
|
+
col-resizable
|
|
144
|
+
header-drag
|
|
145
|
+
virtual
|
|
146
|
+
virtual-x
|
|
147
|
+
no-data-full
|
|
148
|
+
col-resizable
|
|
149
|
+
auto-resize
|
|
150
|
+
fixed-col-shadow
|
|
151
|
+
:col-min-width="10"
|
|
152
|
+
:headless="false"
|
|
153
|
+
:data-source="dataSource"
|
|
154
|
+
@current-change="onCurrentChange"
|
|
155
|
+
@row-menu="onRowMenu"
|
|
156
|
+
@header-row-menu="onHeaderRowMenu"
|
|
157
|
+
@row-click="onRowClick"
|
|
158
|
+
@row-dblclick="onRowDblclick"
|
|
159
|
+
@sort-change="handleSortChange"
|
|
160
|
+
@cell-click="onCellClick"
|
|
161
|
+
@header-cell-click="onHeaderCellClick"
|
|
162
|
+
@scroll="onTableScroll"
|
|
163
|
+
@scroll-x="onTableScrollX"
|
|
164
|
+
@col-order-change="onColOrderChange"
|
|
165
|
+
/>
|
|
166
|
+
</template>
|
|
167
|
+
<script setup>
|
|
168
|
+
import { h, defineComponent } from 'vue';
|
|
169
|
+
const columns = [
|
|
170
|
+
{
|
|
171
|
+
title: 'Name',
|
|
172
|
+
dataIndex: 'name',
|
|
173
|
+
fixed: 'left',
|
|
174
|
+
width: '200px',
|
|
175
|
+
headerClassName: 'my-th',
|
|
176
|
+
className: 'my-td',
|
|
177
|
+
sorter: true,
|
|
178
|
+
customHeaderCell: function FunctionalComponent(props){
|
|
179
|
+
return h(
|
|
180
|
+
'span',
|
|
181
|
+
{ style: 'overflow:hidden;text-overflow:ellipsis;white-space:nowrap' },
|
|
182
|
+
props.col.title + '(render) text-overflow,',
|
|
183
|
+
);
|
|
184
|
+
},
|
|
185
|
+
customCell: defineComponent({
|
|
186
|
+
setup(){
|
|
187
|
+
//...
|
|
188
|
+
return () => <div></div> // vue jsx
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
},
|
|
192
|
+
]
|
|
193
|
+
</script>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
## Other
|
|
198
|
+
* `$*$` 兼容注释
|
|
199
|
+
|
|
200
|
+
### Planed removal APi
|
|
201
|
+
* `setHighlightDimRow` 中的 `method="js"`。观察animation Api 是否足够满足使用场景。若足够满足计划在后期移除,并且可以移除 `d3-interpolate` 依赖。
|
package/lib/stk-table-vue.js
CHANGED
|
@@ -420,7 +420,7 @@ function useColResize({
|
|
|
420
420
|
function findLastChildCol(column) {
|
|
421
421
|
var _a;
|
|
422
422
|
if ((_a = column == null ? void 0 : column.children) == null ? void 0 : _a.length) {
|
|
423
|
-
const lastChild = column.children.
|
|
423
|
+
const lastChild = column.children.slice(-1)[0];
|
|
424
424
|
return findLastChildCol(lastChild);
|
|
425
425
|
}
|
|
426
426
|
return column;
|
|
@@ -815,6 +815,8 @@ var ScrollCodes = /* @__PURE__ */ ((ScrollCodes2) => {
|
|
|
815
815
|
ScrollCodes2["ArrowLeft"] = "ArrowLeft";
|
|
816
816
|
ScrollCodes2["PageUp"] = "PageUp";
|
|
817
817
|
ScrollCodes2["PageDown"] = "PageDown";
|
|
818
|
+
ScrollCodes2["Home"] = "Home";
|
|
819
|
+
ScrollCodes2["End"] = "End";
|
|
818
820
|
return ScrollCodes2;
|
|
819
821
|
})(ScrollCodes || {});
|
|
820
822
|
const ScrollCodesValues = Object.values(ScrollCodes);
|
|
@@ -848,7 +850,7 @@ function useKeyboardArrowScroll(targetElement, { props, scrollTo, virtualScroll,
|
|
|
848
850
|
if (!ScrollCodesValues.includes(e.code)) return;
|
|
849
851
|
if (!isMouseOver) return;
|
|
850
852
|
e.preventDefault();
|
|
851
|
-
const { scrollTop, rowHeight, containerHeight } = virtualScroll.value;
|
|
853
|
+
const { scrollTop, rowHeight, containerHeight, scrollHeight } = virtualScroll.value;
|
|
852
854
|
const { scrollLeft } = virtualScrollX.value;
|
|
853
855
|
const { headless, headerRowHeight } = props;
|
|
854
856
|
const headerHeight = headless ? 0 : tableHeaders.value.length * (headerRowHeight || rowHeight);
|
|
@@ -856,15 +858,19 @@ function useKeyboardArrowScroll(targetElement, { props, scrollTo, virtualScroll,
|
|
|
856
858
|
if (e.code === "ArrowUp") {
|
|
857
859
|
scrollTo(scrollTop - rowHeight, null);
|
|
858
860
|
} else if (e.code === "ArrowRight") {
|
|
859
|
-
scrollTo(null, scrollLeft +
|
|
861
|
+
scrollTo(null, scrollLeft + 50);
|
|
860
862
|
} else if (e.code === "ArrowDown") {
|
|
861
863
|
scrollTo(scrollTop + rowHeight, null);
|
|
862
864
|
} else if (e.code === "ArrowLeft") {
|
|
863
|
-
scrollTo(null, scrollLeft -
|
|
865
|
+
scrollTo(null, scrollLeft - 50);
|
|
864
866
|
} else if (e.code === "PageUp") {
|
|
865
867
|
scrollTo(scrollTop - rowHeight * bodyPageSize + headerHeight, null);
|
|
866
868
|
} else if (e.code === "PageDown") {
|
|
867
869
|
scrollTo(scrollTop + rowHeight * bodyPageSize - headerHeight, null);
|
|
870
|
+
} else if (e.code === "Home") {
|
|
871
|
+
scrollTo(0, null);
|
|
872
|
+
} else if (e.code === "End") {
|
|
873
|
+
scrollTo(scrollHeight, null);
|
|
868
874
|
}
|
|
869
875
|
}
|
|
870
876
|
function handleMouseEnter() {
|
|
@@ -1430,7 +1436,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1430
1436
|
const sortSwitchOrder = [null, "desc", "asc"];
|
|
1431
1437
|
const tableHeaders = shallowRef([]);
|
|
1432
1438
|
const tableHeadersForCalc = shallowRef([]);
|
|
1433
|
-
const tableHeaderLast = computed(() => tableHeadersForCalc.value.
|
|
1439
|
+
const tableHeaderLast = computed(() => tableHeadersForCalc.value.slice(-1)[0] || []);
|
|
1434
1440
|
const dataSourceCopy = shallowRef(props.dataSource.slice());
|
|
1435
1441
|
const rowKeyGenComputed = computed(() => {
|
|
1436
1442
|
const { rowKey } = props;
|
|
@@ -1671,7 +1677,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1671
1677
|
const { virtualX, colResizable } = props;
|
|
1672
1678
|
tableHeaders.value.forEach((cols, depth) => {
|
|
1673
1679
|
cols.forEach((col) => {
|
|
1674
|
-
const colKey = colKeyGen.value(col);
|
|
1675
1680
|
const width = virtualX ? getCalculatedColWidth(col) + "px" : transformWidthToStr(col.width);
|
|
1676
1681
|
const style = {
|
|
1677
1682
|
width
|
|
@@ -1683,8 +1688,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1683
1688
|
style.minWidth = transformWidthToStr(col.minWidth) ?? width;
|
|
1684
1689
|
style.maxWidth = transformWidthToStr(col.maxWidth) ?? width;
|
|
1685
1690
|
}
|
|
1691
|
+
const colKey = colKeyGen.value(col);
|
|
1686
1692
|
thMap.set(colKey, Object.assign({ textAlign: col.headerAlign }, style, getFixedStyle(TagType.TH, col, depth)));
|
|
1687
|
-
tdMap.set(colKey, Object.assign({ textAlign: col.align }, style, getFixedStyle(TagType.TD, col, depth)
|
|
1693
|
+
tdMap.set(colKey, Object.assign({ textAlign: col.align }, style, getFixedStyle(TagType.TD, col, depth)));
|
|
1688
1694
|
});
|
|
1689
1695
|
});
|
|
1690
1696
|
return {
|
|
@@ -1713,6 +1719,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1713
1719
|
sortCol.value = colKey;
|
|
1714
1720
|
sortOrderIndex.value = 0;
|
|
1715
1721
|
}
|
|
1722
|
+
const prevOrder = sortSwitchOrder[sortOrderIndex.value];
|
|
1716
1723
|
if (click) sortOrderIndex.value++;
|
|
1717
1724
|
sortOrderIndex.value = sortOrderIndex.value % 3;
|
|
1718
1725
|
let order = sortSwitchOrder[sortOrderIndex.value];
|
|
@@ -1720,17 +1727,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1720
1727
|
const defaultSort = sortConfig.defaultSort;
|
|
1721
1728
|
const colKeyGenValue = colKeyGen.value;
|
|
1722
1729
|
if (!order && defaultSort) {
|
|
1723
|
-
const
|
|
1724
|
-
if (!
|
|
1730
|
+
const defaultColKey = defaultSort.key || defaultSort.dataIndex;
|
|
1731
|
+
if (!defaultColKey) {
|
|
1725
1732
|
console.error("sortConfig.defaultSort key or dataIndex is required");
|
|
1726
1733
|
return;
|
|
1727
1734
|
}
|
|
1728
|
-
|
|
1735
|
+
if (colKey === defaultColKey && prevOrder === defaultSort.order) {
|
|
1736
|
+
order = sortSwitchOrder.find((o) => o !== defaultSort.order && o);
|
|
1737
|
+
} else {
|
|
1738
|
+
order = defaultSort.order;
|
|
1739
|
+
}
|
|
1729
1740
|
sortOrderIndex.value = sortSwitchOrder.indexOf(order);
|
|
1730
|
-
sortCol.value =
|
|
1741
|
+
sortCol.value = defaultColKey;
|
|
1731
1742
|
col = null;
|
|
1732
1743
|
for (const row of tableHeaders.value) {
|
|
1733
|
-
const c = row.find((item) => colKeyGenValue(item) ===
|
|
1744
|
+
const c = row.find((item) => colKeyGenValue(item) === defaultColKey);
|
|
1734
1745
|
if (c) {
|
|
1735
1746
|
col = c;
|
|
1736
1747
|
break;
|
|
@@ -2099,6 +2110,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2099
2110
|
virtual: _ctx.virtual,
|
|
2100
2111
|
"virtual-x": _ctx.virtualX,
|
|
2101
2112
|
"vt-on": unref(virtual_on),
|
|
2113
|
+
light: _ctx.theme === "light",
|
|
2102
2114
|
dark: _ctx.theme === "dark",
|
|
2103
2115
|
headless: _ctx.headless,
|
|
2104
2116
|
"is-col-resizing": unref(isColResizing),
|