stk-table-vue 0.6.8 → 0.6.10

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 CHANGED
@@ -1,211 +1,201 @@
1
- # StkTable (Sticky Table)
2
- ![NPM License](https://img.shields.io/npm/l/stk-table-vue)
3
- ![NPM Version](https://img.shields.io/npm/v/stk-table-vue)
4
- ![NPM Type Definitions](https://img.shields.io/npm/types/stk-table-vue)
5
- ![NPM Downloads](https://img.shields.io/npm/dw/stk-table-vue)
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
- ## Special Example
197
- ### 鼠标悬浮表头时,不展示title
198
- * `StkTableColumn` 中的 `title` 字段置为 "" 空字符串。这样th中就没有title了。
199
- * 使用 `StkTableColumn` 中的 `customHeaderCell` 属性中,自定义表头渲染。
200
- ### Filter过滤器
201
- * 暂不支持。用户可以自行通过 `customHeaderCell` 实现功能。
202
-
203
- ## Tips
204
- ### props.fixedMode
205
- * **低版本浏览器** 需要设置 `props.width`(default: width=fit-content不生效)。否则列宽不设宽度会变为0。
206
-
207
- ## Other
208
- * `$*$` 兼容注释
209
-
210
- ### Planed removal APi
211
- * `setHighlightDimRow` 中的 `method="js"`。观察animation Api 是否足够满足使用场景。若足够满足计划在后期移除,并且可以移除 `d3-interpolate` 依赖。
1
+ # StkTable (Sticky Table)
2
+ ![NPM License](https://img.shields.io/npm/l/stk-table-vue)
3
+ ![NPM Version](https://img.shields.io/npm/v/stk-table-vue)
4
+ ![NPM Type Definitions](https://img.shields.io/npm/types/stk-table-vue)
5
+ ![NPM Downloads](https://img.shields.io/npm/dw/stk-table-vue)
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` 依赖。