stk-table-vue 0.8.14 → 0.9.0-beta.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.
Files changed (38) hide show
  1. package/README.md +172 -172
  2. package/lib/src/StkTable/StkTable.vue.d.ts +19 -1
  3. package/lib/src/StkTable/useScrollbar.d.ts +57 -0
  4. package/lib/src/StkTable/utils/index.d.ts +7 -0
  5. package/lib/stk-table-vue.js +396 -205
  6. package/lib/style.css +42 -1
  7. package/package.json +74 -74
  8. package/src/StkTable/StkTable.vue +1730 -1665
  9. package/src/StkTable/components/DragHandle.vue +9 -9
  10. package/src/StkTable/components/SortIcon.vue +6 -6
  11. package/src/StkTable/components/TriangleIcon.vue +3 -3
  12. package/src/StkTable/const.ts +50 -50
  13. package/src/StkTable/index.ts +4 -4
  14. package/src/StkTable/style.less +627 -578
  15. package/src/StkTable/types/highlightDimOptions.ts +26 -26
  16. package/src/StkTable/types/index.ts +297 -297
  17. package/src/StkTable/useAutoResize.ts +91 -91
  18. package/src/StkTable/useColResize.ts +216 -216
  19. package/src/StkTable/useFixedCol.ts +150 -150
  20. package/src/StkTable/useFixedStyle.ts +75 -75
  21. package/src/StkTable/useGetFixedColPosition.ts +65 -65
  22. package/src/StkTable/useHighlight.ts +257 -257
  23. package/src/StkTable/useKeyboardArrowScroll.ts +112 -112
  24. package/src/StkTable/useMaxRowSpan.ts +55 -55
  25. package/src/StkTable/useMergeCells.ts +120 -120
  26. package/src/StkTable/useRowExpand.ts +88 -88
  27. package/src/StkTable/useScrollRowByRow.ts +113 -113
  28. package/src/StkTable/useScrollbar.ts +187 -0
  29. package/src/StkTable/useThDrag.ts +102 -102
  30. package/src/StkTable/useTrDrag.ts +113 -113
  31. package/src/StkTable/useTree.ts +161 -161
  32. package/src/StkTable/useVirtualScroll.ts +494 -494
  33. package/src/StkTable/utils/constRefUtils.ts +29 -29
  34. package/src/StkTable/utils/index.ts +287 -258
  35. package/src/StkTable/utils/useTriggerRef.ts +33 -33
  36. package/src/VirtualTree.vue +622 -622
  37. package/src/VirtualTreeSelect.vue +367 -367
  38. package/src/vite-env.d.ts +10 -10
package/README.md CHANGED
@@ -1,172 +1,172 @@
1
- <p align="center">
2
- <a href="https://ja-plus.github.io/stk-table-vue/">
3
- <img src="./docs-src/public/assets/logo.svg" width="152">
4
- </a>
5
- <h3 align='center'>Stk Table Vue</h3>
6
- <p align="center">
7
- <a href="https://www.npmjs.com/package/stk-table-vue"><img src="https://img.shields.io/npm/v/stk-table-vue"></a>
8
- <a href="https://www.npmjs.com/package/stk-table-vue"><img src="https://img.shields.io/npm/dw/stk-table-vue"></a>
9
- <a href="https://github.com/ja-plus/stk-table-vue/stargazers"><img src="https://img.shields.io/github/stars/ja-plus/stk-table-vue.svg"></a>
10
- <a href="https://raw.githubusercontent.com/ja-plus/stk-table-vue/master/LICENSE"><img src="https://img.shields.io/npm/l/stk-table-vue"></a>
11
- <a href="https://github.com/ja-plus/stk-table-vue"><img src="https://img.shields.io/npm/types/stk-table-vue"></a>
12
- </p>
13
- </p>
14
-
15
- > Stk Table Vue(Sticky Table) is a high-performance virtual list component based on Vue.
16
- >
17
- > Used for real-time data display, with data highlighting and dynamic effects
18
- >
19
- > Support Vue3 and Vue2.7
20
-
21
-
22
- ## Documentation
23
- ### [Stk Table Vue Official en](https://ja-plus.github.io/stk-table-vue/en/)
24
- ### [Stk Table Vue Official zh-CN](https://ja-plus.github.io/stk-table-vue/)
25
-
26
-
27
- ## Repo:
28
- - [Github](https://github.com/ja-plus/stk-table-vue)
29
- - [Gitee](https://gitee.com/japlus/stk-table-vue) 🇨🇳
30
-
31
- ## Demo
32
- [<span style="font-size: 16px;font-weight: bold;">Online Demo in stackblitz</span>](https://stackblitz.com/edit/vitejs-vite-ad91hh?file=src%2FDemo%2Findex.vue)
33
-
34
- ## Usage
35
- > npm install stk-table-vue
36
-
37
- ```html
38
- <script setup>
39
- import { StkTable } from 'stk-table-vue'
40
- import { ref, useTemplateRef } from 'vue'
41
- const stkTableRef = ref<InstanceType<typeof StkTable>>();
42
- // or Vue 3.5 useTemplateRef
43
- const stkTableRef = useTemplateRef('stkTableRef');
44
-
45
- // highlight row
46
- stkTableRef.value.setHighlightDimRow([rowKey],{
47
- method: 'css'|'animation',// default animation。
48
- className: 'custom-class-name', // method css。
49
- keyframe: [{backgroundColor:'#aaa'}, {backgroundColor: '#222'}],//same as https://developer.mozilla.org/zh-CN/docs/Web/API/Web_Animations_API/Keyframe_Formats
50
- duration: 2000,。
51
- });
52
- // highlight cell
53
- stkTableRef.value.setHighlightDimCell(rowKey, colDataIndex, {
54
- method: 'css'|'animation',
55
- className:'custom-class-name', // method css。
56
- keyframe: [{backgroundColor:'#aaa'}, {backgroundColor: '#222'}], // method animation。
57
- duration: 2000,。
58
- });
59
-
60
- const columns = [
61
- {title: 'name', dataIndex: 'name'},
62
- {title: 'age', dataIndex: 'age'},
63
- {title: 'address', dataIndex: 'address'},
64
- ];
65
-
66
- const dataSource = [
67
- {id: 1, name: 'John', age: 32, address: 'New York'},
68
- {id: 2, name: 'Jim', age: 42, address: 'London'},
69
- {id: 3, name: 'Joe', age: 52, address: 'Tokyo'},
70
- {id: 4, name: 'Jack', age: 62, address: 'Sydney'},
71
- {id: 5, name: 'Jill', age: 72, address: 'Paris'},
72
- ]
73
-
74
- </script>
75
-
76
- <template>
77
- <StkTable ref='stkTableRef' row-key="id" :data-source="dataSource" :columns="columns"></StkTable>
78
- </template>
79
-
80
- ```
81
-
82
- ### Vue2.7 Usage
83
- [Vue2.7 Usage](https://ja-plus.github.io/stk-table-vue/main/start/vue2-usage.html)
84
-
85
- ## API
86
- * [Props](https://ja-plus.github.io/stk-table-vue/main/api/table-props.html)
87
-
88
- * [Emits](https://ja-plus.github.io/stk-table-vue/main/api/emits.html)
89
-
90
- * [Slots](https://ja-plus.github.io/stk-table-vue/main/api/slots.html)
91
-
92
- * [Expose](https://ja-plus.github.io/stk-table-vue/main/api/expose.html)
93
-
94
- * [StkTableColumn: Define column type](https://ja-plus.github.io/stk-table-vue/main/api/stk-table-column.html)
95
-
96
- * [Highlight: setHighlightDimCell & setHighlightDimRow](https://ja-plus.github.io/stk-table-vue/main/api/expose.html#sethighlightdimcell)
97
-
98
-
99
- ### Example
100
- ```vue
101
- <template>
102
- <StkTable
103
- ref="stkTable"
104
- row-key="name"
105
- v-model:columns="columns"
106
- :style="{height:props.height}"
107
- theme='dark'
108
- height='200px'
109
- bordered="h"
110
- :row-height="28"
111
- :show-overflow="false"
112
- :show-header-overflow="false"
113
- :sort-remote="false"
114
- col-resizable
115
- header-drag
116
- virtual
117
- virtual-x
118
- no-data-full
119
- col-resizable
120
- auto-resize
121
- fixed-col-shadow
122
- :col-min-width="10"
123
- :headless="false"
124
- :data-source="dataSource"
125
- @current-change="onCurrentChange"
126
- @row-menu="onRowMenu"
127
- @header-row-menu="onHeaderRowMenu"
128
- @row-click="onRowClick"
129
- @row-dblclick="onRowDblclick"
130
- @sort-change="handleSortChange"
131
- @cell-click="onCellClick"
132
- @header-cell-click="onHeaderCellClick"
133
- @scroll="onTableScroll"
134
- @scroll-x="onTableScrollX"
135
- @col-order-change="onColOrderChange"
136
- />
137
- </template>
138
- <script setup>
139
- import { h, defineComponent } from 'vue';
140
- const columns = [
141
- {
142
- title: 'Name',
143
- dataIndex: 'name',
144
- fixed: 'left',
145
- width: '200px',
146
- headerClassName: 'my-th',
147
- className: 'my-td',
148
- sorter: true,
149
- customHeaderCell: function FunctionalComponent(props){
150
- return h(
151
- 'span',
152
- { style: 'overflow:hidden;text-overflow:ellipsis;white-space:nowrap' },
153
- props.col.title + '(render) text-overflow,',
154
- );
155
- },
156
- customCell: defineComponent({
157
- setup(){
158
- //...
159
- return () => <div></div> // vue jsx
160
- }
161
- })
162
- },
163
- ]
164
- </script>
165
- ```
166
-
167
- ## Compare
168
- Compare performance with other vue table [vue-table-compare](https://github.com/ja-plus/vue-table-compare)
169
-
170
-
171
- ## Other
172
- * `$*$`
1
+ <p align="center">
2
+ <a href="https://ja-plus.github.io/stk-table-vue/">
3
+ <img src="./docs-src/public/assets/logo.svg" width="152">
4
+ </a>
5
+ <h3 align='center'>Stk Table Vue</h3>
6
+ <p align="center">
7
+ <a href="https://www.npmjs.com/package/stk-table-vue"><img src="https://img.shields.io/npm/v/stk-table-vue"></a>
8
+ <a href="https://www.npmjs.com/package/stk-table-vue"><img src="https://img.shields.io/npm/dw/stk-table-vue"></a>
9
+ <a href="https://github.com/ja-plus/stk-table-vue/stargazers"><img src="https://img.shields.io/github/stars/ja-plus/stk-table-vue.svg"></a>
10
+ <a href="https://raw.githubusercontent.com/ja-plus/stk-table-vue/master/LICENSE"><img src="https://img.shields.io/npm/l/stk-table-vue"></a>
11
+ <a href="https://github.com/ja-plus/stk-table-vue"><img src="https://img.shields.io/npm/types/stk-table-vue"></a>
12
+ </p>
13
+ </p>
14
+
15
+ > Stk Table Vue(Sticky Table) is a high-performance virtual list component based on Vue.
16
+ >
17
+ > Used for real-time data display, with data highlighting and dynamic effects
18
+ >
19
+ > Support Vue3 and Vue2.7
20
+
21
+
22
+ ## Documentation
23
+ ### [Stk Table Vue Official en](https://ja-plus.github.io/stk-table-vue/en/)
24
+ ### [Stk Table Vue Official zh-CN](https://ja-plus.github.io/stk-table-vue/)
25
+
26
+
27
+ ## Repo:
28
+ - [Github](https://github.com/ja-plus/stk-table-vue)
29
+ - [Gitee](https://gitee.com/japlus/stk-table-vue) 🇨🇳
30
+
31
+ ## Demo
32
+ [<span style="font-size: 16px;font-weight: bold;">Online Demo in stackblitz</span>](https://stackblitz.com/edit/vitejs-vite-ad91hh?file=src%2FDemo%2Findex.vue)
33
+
34
+ ## Usage
35
+ > npm install stk-table-vue
36
+
37
+ ```html
38
+ <script setup>
39
+ import { StkTable } from 'stk-table-vue'
40
+ import { ref, useTemplateRef } from 'vue'
41
+ const stkTableRef = ref<InstanceType<typeof StkTable>>();
42
+ // or Vue 3.5 useTemplateRef
43
+ const stkTableRef = useTemplateRef('stkTableRef');
44
+
45
+ // highlight row
46
+ stkTableRef.value.setHighlightDimRow([rowKey],{
47
+ method: 'css'|'animation',// default animation。
48
+ className: 'custom-class-name', // method css。
49
+ keyframe: [{backgroundColor:'#aaa'}, {backgroundColor: '#222'}],//same as https://developer.mozilla.org/zh-CN/docs/Web/API/Web_Animations_API/Keyframe_Formats
50
+ duration: 2000,。
51
+ });
52
+ // highlight cell
53
+ stkTableRef.value.setHighlightDimCell(rowKey, colDataIndex, {
54
+ method: 'css'|'animation',
55
+ className:'custom-class-name', // method css。
56
+ keyframe: [{backgroundColor:'#aaa'}, {backgroundColor: '#222'}], // method animation。
57
+ duration: 2000,。
58
+ });
59
+
60
+ const columns = [
61
+ {title: 'name', dataIndex: 'name'},
62
+ {title: 'age', dataIndex: 'age'},
63
+ {title: 'address', dataIndex: 'address'},
64
+ ];
65
+
66
+ const dataSource = [
67
+ {id: 1, name: 'John', age: 32, address: 'New York'},
68
+ {id: 2, name: 'Jim', age: 42, address: 'London'},
69
+ {id: 3, name: 'Joe', age: 52, address: 'Tokyo'},
70
+ {id: 4, name: 'Jack', age: 62, address: 'Sydney'},
71
+ {id: 5, name: 'Jill', age: 72, address: 'Paris'},
72
+ ]
73
+
74
+ </script>
75
+
76
+ <template>
77
+ <StkTable ref='stkTableRef' row-key="id" :data-source="dataSource" :columns="columns"></StkTable>
78
+ </template>
79
+
80
+ ```
81
+
82
+ ### Vue2.7 Usage
83
+ [Vue2.7 Usage](https://ja-plus.github.io/stk-table-vue/main/start/vue2-usage.html)
84
+
85
+ ## API
86
+ * [Props](https://ja-plus.github.io/stk-table-vue/main/api/table-props.html)
87
+
88
+ * [Emits](https://ja-plus.github.io/stk-table-vue/main/api/emits.html)
89
+
90
+ * [Slots](https://ja-plus.github.io/stk-table-vue/main/api/slots.html)
91
+
92
+ * [Expose](https://ja-plus.github.io/stk-table-vue/main/api/expose.html)
93
+
94
+ * [StkTableColumn: Define column type](https://ja-plus.github.io/stk-table-vue/main/api/stk-table-column.html)
95
+
96
+ * [Highlight: setHighlightDimCell & setHighlightDimRow](https://ja-plus.github.io/stk-table-vue/main/api/expose.html#sethighlightdimcell)
97
+
98
+
99
+ ### Example
100
+ ```vue
101
+ <template>
102
+ <StkTable
103
+ ref="stkTable"
104
+ row-key="name"
105
+ v-model:columns="columns"
106
+ :style="{height:props.height}"
107
+ theme='dark'
108
+ height='200px'
109
+ bordered="h"
110
+ :row-height="28"
111
+ :show-overflow="false"
112
+ :show-header-overflow="false"
113
+ :sort-remote="false"
114
+ col-resizable
115
+ header-drag
116
+ virtual
117
+ virtual-x
118
+ no-data-full
119
+ col-resizable
120
+ auto-resize
121
+ fixed-col-shadow
122
+ :col-min-width="10"
123
+ :headless="false"
124
+ :data-source="dataSource"
125
+ @current-change="onCurrentChange"
126
+ @row-menu="onRowMenu"
127
+ @header-row-menu="onHeaderRowMenu"
128
+ @row-click="onRowClick"
129
+ @row-dblclick="onRowDblclick"
130
+ @sort-change="handleSortChange"
131
+ @cell-click="onCellClick"
132
+ @header-cell-click="onHeaderCellClick"
133
+ @scroll="onTableScroll"
134
+ @scroll-x="onTableScrollX"
135
+ @col-order-change="onColOrderChange"
136
+ />
137
+ </template>
138
+ <script setup>
139
+ import { h, defineComponent } from 'vue';
140
+ const columns = [
141
+ {
142
+ title: 'Name',
143
+ dataIndex: 'name',
144
+ fixed: 'left',
145
+ width: '200px',
146
+ headerClassName: 'my-th',
147
+ className: 'my-td',
148
+ sorter: true,
149
+ customHeaderCell: function FunctionalComponent(props){
150
+ return h(
151
+ 'span',
152
+ { style: 'overflow:hidden;text-overflow:ellipsis;white-space:nowrap' },
153
+ props.col.title + '(render) text-overflow,',
154
+ );
155
+ },
156
+ customCell: defineComponent({
157
+ setup(){
158
+ //...
159
+ return () => <div></div> // vue jsx
160
+ }
161
+ })
162
+ },
163
+ ]
164
+ </script>
165
+ ```
166
+
167
+ ## Compare
168
+ Compare performance with other vue table [vue-table-compare](https://github.com/ja-plus/vue-table-compare)
169
+
170
+
171
+ ## Other
172
+ * `$*$`
@@ -1,4 +1,5 @@
1
1
  import { AutoRowHeightConfig, ColResizableConfig, DragRowConfig, ExpandConfig, HeaderDragConfig, HighlightConfig, Order, PrivateRowDT, PrivateStkTableColumn, RowActiveOption, SeqConfig, SortConfig, SortOption, StkTableColumn, TreeConfig, UniqKey, UniqKeyProp } from './types/index';
2
+ import { ScrollbarOptions } from './useScrollbar';
2
3
 
3
4
  /** Generic stands for DataType */
4
5
  type DT = any & PrivateRowDT;
@@ -64,8 +65,8 @@ declare function __VLS_template(): {
64
65
  row: any;
65
66
  col: StkTableColumn<any> | undefined;
66
67
  }): any;
67
- empty?(_: {}): any;
68
68
  customBottom?(_: {}): any;
69
+ empty?(_: {}): any;
69
70
  };
70
71
  declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
71
72
  width?: string;
@@ -205,6 +206,13 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
205
206
  * - scrollbar:仅拖动滚动条生效
206
207
  */
207
208
  scrollRowByRow?: boolean | "scrollbar";
209
+ /**
210
+ * 自定义滚动条配置
211
+ * - false: 禁用自定义滚动条
212
+ * - true: 启用默认配置的自定义滚动条
213
+ * - ScrollbarOptions: 启用并配置自定义滚动条
214
+ */
215
+ scrollbar?: boolean | ScrollbarOptions;
208
216
  }>, {
209
217
  width: string;
210
218
  fixedMode: boolean;
@@ -257,6 +265,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
257
265
  cellFixedMode: string;
258
266
  smoothScroll: boolean;
259
267
  scrollRowByRow: boolean;
268
+ scrollbar: boolean;
260
269
  }>>, {
261
270
  /**
262
271
  * 重新计算虚拟列表宽高
@@ -574,6 +583,13 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
574
583
  * - scrollbar:仅拖动滚动条生效
575
584
  */
576
585
  scrollRowByRow?: boolean | "scrollbar";
586
+ /**
587
+ * 自定义滚动条配置
588
+ * - false: 禁用自定义滚动条
589
+ * - true: 启用默认配置的自定义滚动条
590
+ * - ScrollbarOptions: 启用并配置自定义滚动条
591
+ */
592
+ scrollbar?: boolean | ScrollbarOptions;
577
593
  }>, {
578
594
  width: string;
579
595
  fixedMode: boolean;
@@ -626,6 +642,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
626
642
  cellFixedMode: string;
627
643
  smoothScroll: boolean;
628
644
  scrollRowByRow: boolean;
645
+ scrollbar: boolean;
629
646
  }>>> & Readonly<{
630
647
  onScroll?: ((ev: Event, data: {
631
648
  startIndex: number;
@@ -690,6 +707,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
690
707
  optimizeVue2Scroll: boolean;
691
708
  rowKey: UniqKeyProp;
692
709
  headerRowHeight: number | string | null;
710
+ scrollbar: boolean | ScrollbarOptions;
693
711
  fixedMode: boolean;
694
712
  theme: "light" | "dark";
695
713
  rowHover: boolean;
@@ -0,0 +1,57 @@
1
+ import { Ref } from 'vue';
2
+
3
+ export type ScrollbarOptions = {
4
+ enabled?: boolean;
5
+ /** scroll-y width */
6
+ width?: number;
7
+ /** scroll-x height */
8
+ height?: number;
9
+ /** min scroll-y width */
10
+ minWidth?: number;
11
+ /** min scroll-x height */
12
+ minHeight?: number;
13
+ };
14
+ /**
15
+ * 自定义滚动条hooks
16
+ * @param containerRef 滚动容器的ref
17
+ * @param options 滚动条配置选项
18
+ * @returns 滚动条相关状态和方法
19
+ */
20
+ export declare function useScrollbar(containerRef: Ref<HTMLDivElement | undefined>, options?: boolean | ScrollbarOptions): {
21
+ scrollbarOptions: {
22
+ enabled: boolean;
23
+ width: number;
24
+ height: number;
25
+ minWidth: number;
26
+ minHeight: number;
27
+ };
28
+ scrollbar: Ref<{
29
+ h: number;
30
+ w: number;
31
+ top: number;
32
+ left: number;
33
+ }, {
34
+ h: number;
35
+ w: number;
36
+ top: number;
37
+ left: number;
38
+ } | {
39
+ h: number;
40
+ w: number;
41
+ top: number;
42
+ left: number;
43
+ }>;
44
+ showScrollbar: Ref<{
45
+ x: boolean;
46
+ y: boolean;
47
+ }, {
48
+ x: boolean;
49
+ y: boolean;
50
+ } | {
51
+ x: boolean;
52
+ y: boolean;
53
+ }>;
54
+ onVerticalScrollbarMouseDown: (e: MouseEvent | TouchEvent) => void;
55
+ onHorizontalScrollbarMouseDown: (e: MouseEvent | TouchEvent) => void;
56
+ updateCustomScrollbar: () => void;
57
+ };
@@ -54,3 +54,10 @@ export declare function pureCellKeyGen(rowKey: UniqKey, colKey: UniqKey): string
54
54
  export declare function getClosestTr(e: MouseEvent): HTMLTableRowElement | null;
55
55
  export declare function getClosestTrIndex(e: MouseEvent): number;
56
56
  export declare function getClosestColKey(e: MouseEvent): string | undefined;
57
+ /**
58
+ * 改进的节流函数,确保最后一个调用不会被丢弃
59
+ * @param fn 要执行的函数
60
+ * @param delay 延迟时间(毫秒)
61
+ * @returns 节流处理后的函数
62
+ */
63
+ export declare function throttle<T extends (...args: any[]) => any>(fn: T, delay: number): (...args: Parameters<T>) => void;