stk-table-vue 0.8.13 → 0.8.15

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 (36) hide show
  1. package/README.md +172 -180
  2. package/lib/src/StkTable/StkTable.vue.d.ts +7 -2
  3. package/lib/src/StkTable/utils/index.d.ts +3 -0
  4. package/lib/stk-table-vue.js +222 -139
  5. package/lib/style.css +9 -2
  6. package/package.json +74 -72
  7. package/src/StkTable/StkTable.vue +1665 -1653
  8. package/src/StkTable/components/DragHandle.vue +9 -9
  9. package/src/StkTable/components/SortIcon.vue +6 -6
  10. package/src/StkTable/components/TriangleIcon.vue +3 -3
  11. package/src/StkTable/const.ts +50 -50
  12. package/src/StkTable/index.ts +4 -4
  13. package/src/StkTable/style.less +579 -580
  14. package/src/StkTable/types/highlightDimOptions.ts +26 -26
  15. package/src/StkTable/types/index.ts +297 -297
  16. package/src/StkTable/useAutoResize.ts +91 -91
  17. package/src/StkTable/useColResize.ts +216 -216
  18. package/src/StkTable/useFixedCol.ts +150 -148
  19. package/src/StkTable/useFixedStyle.ts +75 -75
  20. package/src/StkTable/useGetFixedColPosition.ts +65 -65
  21. package/src/StkTable/useHighlight.ts +257 -257
  22. package/src/StkTable/useKeyboardArrowScroll.ts +112 -112
  23. package/src/StkTable/useMaxRowSpan.ts +55 -55
  24. package/src/StkTable/useMergeCells.ts +120 -123
  25. package/src/StkTable/useRowExpand.ts +88 -88
  26. package/src/StkTable/useScrollRowByRow.ts +114 -79
  27. package/src/StkTable/useThDrag.ts +102 -102
  28. package/src/StkTable/useTrDrag.ts +113 -118
  29. package/src/StkTable/useTree.ts +161 -161
  30. package/src/StkTable/useVirtualScroll.ts +494 -494
  31. package/src/StkTable/utils/constRefUtils.ts +29 -29
  32. package/src/StkTable/utils/index.ts +258 -242
  33. package/src/StkTable/utils/useTriggerRef.ts +33 -33
  34. package/src/VirtualTree.vue +622 -622
  35. package/src/VirtualTreeSelect.vue +367 -367
  36. package/src/vite-env.d.ts +10 -10
package/README.md CHANGED
@@ -1,180 +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
- ## Compare
35
- Compare performance with other vue table [vue-table-compare](https://github.com/ja-plus/vue-table-compare)
36
-
37
-
38
-
39
- ## Usage
40
- > npm install stk-table-vue
41
-
42
- ```html
43
- <script setup>
44
- import { StkTable } from 'stk-table-vue'
45
- import { ref, useTemplateRef } from 'vue'
46
- const stkTableRef = ref<InstanceType<typeof StkTable>>();
47
- // or Vue 3.5 useTemplateRef
48
- const stkTableRef = useTemplateRef('stkTableRef');
49
-
50
- // highlight row
51
- stkTableRef.value.setHighlightDimRow([rowKey],{
52
- method: 'css'|'animation',// default animation。
53
- className: 'custom-class-name', // method css。
54
- keyframe: [{backgroundColor:'#aaa'}, {backgroundColor: '#222'}],//same as https://developer.mozilla.org/zh-CN/docs/Web/API/Web_Animations_API/Keyframe_Formats
55
- duration: 2000,。
56
- });
57
- // highlight cell
58
- stkTableRef.value.setHighlightDimCell(rowKey, colDataIndex, {
59
- method: 'css'|'animation',
60
- className:'custom-class-name', // method css。
61
- keyframe: [{backgroundColor:'#aaa'}, {backgroundColor: '#222'}], // method animation。
62
- duration: 2000,。
63
- });
64
-
65
- const columns = [
66
- {title: 'name', dataIndex: 'name'},
67
- {title: 'age', dataIndex: 'age'},
68
- {title: 'address', dataIndex: 'address'},
69
- ];
70
-
71
- const dataSource = [
72
- {id: 1, name: 'John', age: 32, address: 'New York'},
73
- {id: 2, name: 'Jim', age: 42, address: 'London'},
74
- {id: 3, name: 'Joe', age: 52, address: 'Tokyo'},
75
- {id: 4, name: 'Jack', age: 62, address: 'Sydney'},
76
- {id: 5, name: 'Jill', age: 72, address: 'Paris'},
77
- ]
78
-
79
- </script>
80
-
81
- <template>
82
- <StkTable ref='stkTableRef' row-key="id" :data-source="dataSource" :columns="columns"></StkTable>
83
- </template>
84
-
85
- ```
86
-
87
- ### Vue2.7 Usage
88
- [Vue2.7 Usage](https://ja-plus.github.io/stk-table-vue/main/start/vue2-usage.html)
89
-
90
- ## API
91
- ### Props
92
- [Props 表格配置](https://ja-plus.github.io/stk-table-vue/main/api/table-props.html)
93
-
94
- ### Emits
95
- [Emits 事件](https://ja-plus.github.io/stk-table-vue/main/api/emits.html)
96
-
97
- ### Slots
98
- [Slots 插槽](https://ja-plus.github.io/stk-table-vue/main/api/slots.html)
99
-
100
- ### Expose
101
- [Expose 实例方法](https://ja-plus.github.io/stk-table-vue/main/api/expose.html)
102
-
103
- ### StkTableColumn 列配置
104
- [StkTableColumn 列配置](https://ja-plus.github.io/stk-table-vue/main/api/stk-table-column.html)
105
-
106
- ### setHighlightDimCell & setHighlightDimRow
107
- [Highlight 高亮](https://ja-plus.github.io/stk-table-vue/main/api/expose.html#sethighlightdimcell)
108
-
109
-
110
- ### Example
111
- ```vue
112
- <template>
113
- <StkTable
114
- ref="stkTable"
115
- row-key="name"
116
- v-model:columns="columns"
117
- :style="{height:props.height}"
118
- theme='dark'
119
- height='200px'
120
- bordered="h"
121
- :row-height="28"
122
- :show-overflow="false"
123
- :show-header-overflow="false"
124
- :sort-remote="false"
125
- col-resizable
126
- header-drag
127
- virtual
128
- virtual-x
129
- no-data-full
130
- col-resizable
131
- auto-resize
132
- fixed-col-shadow
133
- :col-min-width="10"
134
- :headless="false"
135
- :data-source="dataSource"
136
- @current-change="onCurrentChange"
137
- @row-menu="onRowMenu"
138
- @header-row-menu="onHeaderRowMenu"
139
- @row-click="onRowClick"
140
- @row-dblclick="onRowDblclick"
141
- @sort-change="handleSortChange"
142
- @cell-click="onCellClick"
143
- @header-cell-click="onHeaderCellClick"
144
- @scroll="onTableScroll"
145
- @scroll-x="onTableScrollX"
146
- @col-order-change="onColOrderChange"
147
- />
148
- </template>
149
- <script setup>
150
- import { h, defineComponent } from 'vue';
151
- const columns = [
152
- {
153
- title: 'Name',
154
- dataIndex: 'name',
155
- fixed: 'left',
156
- width: '200px',
157
- headerClassName: 'my-th',
158
- className: 'my-td',
159
- sorter: true,
160
- customHeaderCell: function FunctionalComponent(props){
161
- return h(
162
- 'span',
163
- { style: 'overflow:hidden;text-overflow:ellipsis;white-space:nowrap' },
164
- props.col.title + '(render) text-overflow,',
165
- );
166
- },
167
- customCell: defineComponent({
168
- setup(){
169
- //...
170
- return () => <div></div> // vue jsx
171
- }
172
- })
173
- },
174
- ]
175
- </script>
176
- ```
177
-
178
-
179
- ## Other
180
- * `$*$`
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
+ * `$*$`
@@ -4,6 +4,8 @@ import { AutoRowHeightConfig, ColResizableConfig, DragRowConfig, ExpandConfig, H
4
4
  type DT = any & PrivateRowDT;
5
5
  /**
6
6
  * 选中一行
7
+ *
8
+ * en: Select a row
7
9
  * @param {string} rowKeyOrRow selected rowKey, undefined to unselect
8
10
  * @param {boolean} option.silent if set true not emit `current-change`. default:false
9
11
  * @param {boolean} option.deep if set true, deep search in children. default:false
@@ -381,7 +383,10 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
381
383
  })) | (UniqKey | (PrivateRowDT & {
382
384
  children?: (PrivateRowDT & /*elided*/ any)[];
383
385
  }))[], option?: {
384
- expand?: boolean;
386
+ expand? /**
387
+ * 是否可变行高
388
+ * - 设置为 `true` 时, `props.rowHeight` 将表示为期望行高,用于计算。不再影响实际行高。
389
+ */: boolean;
385
390
  }) => void;
386
391
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
387
392
  "sort-change": (col: StkTableColumn<any> | null, order: Order, data: any[], sortConfig: SortConfig<any>) => void;
@@ -680,6 +685,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
680
685
  minWidth: string;
681
686
  maxWidth: string;
682
687
  sortConfig: SortConfig<DT>;
688
+ colKey: UniqKeyProp;
683
689
  rowHeight: number;
684
690
  headless: boolean;
685
691
  autoRowHeight: boolean | AutoRowHeightConfig<DT>;
@@ -687,7 +693,6 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
687
693
  optimizeVue2Scroll: boolean;
688
694
  rowKey: UniqKeyProp;
689
695
  headerRowHeight: number | string | null;
690
- colKey: UniqKeyProp;
691
696
  fixedMode: boolean;
692
697
  theme: "light" | "dark";
693
698
  rowHover: boolean;
@@ -51,3 +51,6 @@ export declare function howDeepTheHeader(arr: StkTableColumn<any>[], level?: num
51
51
  export declare function transformWidthToStr(width?: string | number): string | undefined;
52
52
  export declare function getBrowsersVersion(browserName: string): number;
53
53
  export declare function pureCellKeyGen(rowKey: UniqKey, colKey: UniqKey): string;
54
+ export declare function getClosestTr(e: MouseEvent): HTMLTableRowElement | null;
55
+ export declare function getClosestTrIndex(e: MouseEvent): number;
56
+ export declare function getClosestColKey(e: MouseEvent): string | undefined;