stk-table-vue 0.6.0 → 0.6.2
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 +8 -8
- package/lib/src/StkTable/StkTable.vue.d.ts +95 -16
- package/lib/src/StkTable/useThDrag.d.ts +1 -1
- package/lib/stk-table-vue.js +101 -20
- package/package.json +64 -64
- package/src/StkTable/StkTable.vue +125 -19
- package/src/StkTable/useThDrag.ts +2 -2
package/README.md
CHANGED
|
@@ -295,12 +295,12 @@ export type StkProps = {
|
|
|
295
295
|
* 低版本浏览器只能为'relative',
|
|
296
296
|
*/
|
|
297
297
|
cellFixedMode?: 'sticky' | 'relative';
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
298
|
+
/**
|
|
299
|
+
* 是否平滑滚动
|
|
300
|
+
* - default: chrome < 85 ? true : false
|
|
301
|
+
* - false: 使用 wheel 事件滚动。为了防止滚动过快导致白屏。
|
|
302
|
+
* - true: 不使用 wheel 事件滚动。滚轮滚动时更加平滑。滚动过快时会白屏。
|
|
303
|
+
*/
|
|
304
304
|
smoothScroll?: boolean;
|
|
305
305
|
};
|
|
306
306
|
```
|
|
@@ -398,11 +398,11 @@ export type StkProps = {
|
|
|
398
398
|
* ```(dragStartKey: string, targetRowKey: string)```
|
|
399
399
|
*/
|
|
400
400
|
(e: 'row-order-change', dragStartKey: string, targetRowKey: string): void;
|
|
401
|
-
|
|
401
|
+
/**
|
|
402
402
|
* 列宽变动时触发
|
|
403
403
|
*/
|
|
404
404
|
(e: 'col-resize', cols: StkTableColumn<DT>): void;
|
|
405
|
-
|
|
405
|
+
/**
|
|
406
406
|
* 展开行触发
|
|
407
407
|
* ```( data: { expanded: boolean; row: DT; col: StkTableColumn<DT> })```
|
|
408
408
|
*/
|
|
@@ -185,37 +185,116 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<{
|
|
|
185
185
|
*/
|
|
186
186
|
smoothScroll?: boolean | undefined;
|
|
187
187
|
}, {
|
|
188
|
-
/**
|
|
188
|
+
/**
|
|
189
|
+
* 重新计算虚拟列表宽高
|
|
190
|
+
*
|
|
191
|
+
* en: calc virtual scroll x & y info
|
|
192
|
+
* @see {@link initVirtualScroll}
|
|
193
|
+
*/
|
|
189
194
|
initVirtualScroll: (height?: number | undefined) => void;
|
|
190
|
-
/**
|
|
195
|
+
/**
|
|
196
|
+
* 重新计算虚拟列表宽度
|
|
197
|
+
*
|
|
198
|
+
* en: calc virtual scroll x
|
|
199
|
+
* @see {@link initVirtualScrollX}
|
|
200
|
+
*/
|
|
191
201
|
initVirtualScrollX: () => void;
|
|
192
|
-
/**
|
|
202
|
+
/**
|
|
203
|
+
* 重新计算虚拟列表高度
|
|
204
|
+
*
|
|
205
|
+
* en: calc virtual scroll y
|
|
206
|
+
* @see {@link initVirtualScrollY}
|
|
207
|
+
*/
|
|
193
208
|
initVirtualScrollY: (height?: number | undefined) => void;
|
|
194
|
-
/**
|
|
209
|
+
/**
|
|
210
|
+
* 选中一行
|
|
211
|
+
*
|
|
212
|
+
* en:select a row
|
|
213
|
+
* @see {@link setCurrentRow}
|
|
214
|
+
*/
|
|
195
215
|
setCurrentRow: typeof setCurrentRow;
|
|
196
|
-
/**
|
|
216
|
+
/**
|
|
217
|
+
* 取消选中单元格
|
|
218
|
+
*
|
|
219
|
+
* en: set highlight active cell (props.cellActive=true)
|
|
220
|
+
* @see {@link setSelectedCell}
|
|
221
|
+
*/
|
|
197
222
|
setSelectedCell: typeof setSelectedCell;
|
|
198
|
-
/**
|
|
223
|
+
/**
|
|
224
|
+
* 设置高亮单元格
|
|
225
|
+
*
|
|
226
|
+
* en: Set highlight cell
|
|
227
|
+
* @see {@link setHighlightDimCell}
|
|
228
|
+
*/
|
|
199
229
|
setHighlightDimCell: (rowKeyValue: import('./types/index').UniqKey, dataIndex: string, option?: import('./types/highlightDimOptions').HighlightDimCellOption) => void;
|
|
200
|
-
/**
|
|
230
|
+
/**
|
|
231
|
+
* 设置高亮行
|
|
232
|
+
*
|
|
233
|
+
* en: Set highlight row
|
|
234
|
+
* @see {@link setHighlightDimRow}
|
|
235
|
+
*/
|
|
201
236
|
setHighlightDimRow: (rowKeyValues: import('./types/index').UniqKey[], option?: import('./types/highlightDimOptions').HighlightDimRowOption) => void;
|
|
202
|
-
/**
|
|
237
|
+
/**
|
|
238
|
+
* 表格排序列dataIndex
|
|
239
|
+
*
|
|
240
|
+
* en: Table sort column dataIndex
|
|
241
|
+
*/
|
|
203
242
|
sortCol: import('vue').Ref<string | number | symbol | undefined, string | number | symbol | undefined>;
|
|
204
|
-
/**
|
|
243
|
+
/**
|
|
244
|
+
* 表格排序列顺序
|
|
245
|
+
*
|
|
246
|
+
* en: get current sort info
|
|
247
|
+
* @see {@link getSortColumns}
|
|
248
|
+
*/
|
|
205
249
|
getSortColumns: typeof getSortColumns;
|
|
206
|
-
/**
|
|
250
|
+
/**
|
|
251
|
+
* 设置表头排序状态
|
|
252
|
+
*
|
|
253
|
+
* en: Set the sort status of the table header
|
|
254
|
+
* @see {@link setSorter}
|
|
255
|
+
*/
|
|
207
256
|
setSorter: typeof setSorter;
|
|
208
|
-
/**
|
|
257
|
+
/**
|
|
258
|
+
* 重置sorter状态
|
|
259
|
+
*
|
|
260
|
+
* en: Reset the sorter status
|
|
261
|
+
* @see {@link resetSorter}
|
|
262
|
+
*/
|
|
209
263
|
resetSorter: typeof resetSorter;
|
|
210
|
-
/**
|
|
264
|
+
/**
|
|
265
|
+
* 滚动至
|
|
266
|
+
*
|
|
267
|
+
* en: Scroll to
|
|
268
|
+
* @see {@link scrollTo}
|
|
269
|
+
*/
|
|
211
270
|
scrollTo: typeof scrollTo;
|
|
212
|
-
/**
|
|
271
|
+
/**
|
|
272
|
+
* 获取表格数据
|
|
273
|
+
*
|
|
274
|
+
* en: Get table data
|
|
275
|
+
* @see {@link getTableData}
|
|
276
|
+
*/
|
|
213
277
|
getTableData: typeof getTableData;
|
|
214
|
-
/**
|
|
278
|
+
/**
|
|
279
|
+
* 设置展开的行
|
|
280
|
+
*
|
|
281
|
+
* en: Set expanded rows
|
|
282
|
+
* @see {@link setRowExpand}
|
|
283
|
+
*/
|
|
215
284
|
setRowExpand: typeof setRowExpand;
|
|
216
|
-
/**
|
|
285
|
+
/**
|
|
286
|
+
* 不定行高时,如果行高有变化,则调用此方法更新行高。
|
|
287
|
+
*
|
|
288
|
+
* en: When the row height is not fixed, call this method to update the row height if the row height changes.
|
|
289
|
+
* @see {@link setAutoHeight}
|
|
290
|
+
*/
|
|
217
291
|
setAutoHeight: (rowKey: import('./types/index').UniqKey, height?: number | null | undefined) => void;
|
|
218
|
-
/**
|
|
292
|
+
/**
|
|
293
|
+
* 清除所有行高
|
|
294
|
+
*
|
|
295
|
+
* en: Clear all row heights
|
|
296
|
+
* @see {@link clearAllAutoHeight}
|
|
297
|
+
*/
|
|
219
298
|
clearAllAutoHeight: () => void;
|
|
220
299
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
221
300
|
[x: string]: any;
|
|
@@ -14,6 +14,6 @@ export declare function useThDrag<DT extends Record<string, any>>({ props, emits
|
|
|
14
14
|
onThDragOver: (e: DragEvent) => void;
|
|
15
15
|
onThDrop: (e: DragEvent) => void;
|
|
16
16
|
/** 是否可拖拽 */
|
|
17
|
-
isHeaderDraggable:
|
|
17
|
+
isHeaderDraggable: (col: StkTableColumn<DT>) => boolean;
|
|
18
18
|
};
|
|
19
19
|
export {};
|
package/lib/stk-table-vue.js
CHANGED
|
@@ -879,7 +879,7 @@ function useThDrag({ props, emits, colKeyGen }) {
|
|
|
879
879
|
return {
|
|
880
880
|
draggable,
|
|
881
881
|
mode: "insert",
|
|
882
|
-
disabled: () =>
|
|
882
|
+
disabled: () => false,
|
|
883
883
|
...headerDrag
|
|
884
884
|
};
|
|
885
885
|
});
|
|
@@ -939,7 +939,7 @@ function useThDrag({ props, emits, colKeyGen }) {
|
|
|
939
939
|
onThDragOver,
|
|
940
940
|
onThDrop,
|
|
941
941
|
/** 是否可拖拽 */
|
|
942
|
-
isHeaderDraggable: dragConfig.value.disabled
|
|
942
|
+
isHeaderDraggable: (col) => !dragConfig.value.disabled(col)
|
|
943
943
|
};
|
|
944
944
|
}
|
|
945
945
|
const TR_DRAGGING_CLASS = "tr-dragging";
|
|
@@ -1675,7 +1675,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1675
1675
|
return col.title || "";
|
|
1676
1676
|
}
|
|
1677
1677
|
function onColumnSort(col, click = true, options = {}) {
|
|
1678
|
-
if (!(col == null ? void 0 : col.sorter))
|
|
1678
|
+
if (!(col == null ? void 0 : col.sorter) && click) {
|
|
1679
|
+
return;
|
|
1680
|
+
}
|
|
1679
1681
|
options = { force: false, emit: false, ...options };
|
|
1680
1682
|
if (sortCol.value !== col.dataIndex) {
|
|
1681
1683
|
sortCol.value = col.dataIndex;
|
|
@@ -1887,7 +1889,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1887
1889
|
if (!sortOrder) return [];
|
|
1888
1890
|
return [{ dataIndex: sortCol.value, order: sortOrder }];
|
|
1889
1891
|
}
|
|
1890
|
-
function toggleExpandRow(row, col
|
|
1892
|
+
function toggleExpandRow(row, col) {
|
|
1891
1893
|
const isExpand = (row == null ? void 0 : row.__EXPANDED__) === col ? !(row == null ? void 0 : row.__EXPANDED__) : true;
|
|
1892
1894
|
setRowExpand(row, isExpand, { col });
|
|
1893
1895
|
}
|
|
@@ -1933,37 +1935,116 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1933
1935
|
}
|
|
1934
1936
|
}
|
|
1935
1937
|
__expose({
|
|
1936
|
-
/**
|
|
1938
|
+
/**
|
|
1939
|
+
* 重新计算虚拟列表宽高
|
|
1940
|
+
*
|
|
1941
|
+
* en: calc virtual scroll x & y info
|
|
1942
|
+
* @see {@link initVirtualScroll}
|
|
1943
|
+
*/
|
|
1937
1944
|
initVirtualScroll,
|
|
1938
|
-
/**
|
|
1945
|
+
/**
|
|
1946
|
+
* 重新计算虚拟列表宽度
|
|
1947
|
+
*
|
|
1948
|
+
* en: calc virtual scroll x
|
|
1949
|
+
* @see {@link initVirtualScrollX}
|
|
1950
|
+
*/
|
|
1939
1951
|
initVirtualScrollX,
|
|
1940
|
-
/**
|
|
1952
|
+
/**
|
|
1953
|
+
* 重新计算虚拟列表高度
|
|
1954
|
+
*
|
|
1955
|
+
* en: calc virtual scroll y
|
|
1956
|
+
* @see {@link initVirtualScrollY}
|
|
1957
|
+
*/
|
|
1941
1958
|
initVirtualScrollY,
|
|
1942
|
-
/**
|
|
1959
|
+
/**
|
|
1960
|
+
* 选中一行
|
|
1961
|
+
*
|
|
1962
|
+
* en:select a row
|
|
1963
|
+
* @see {@link setCurrentRow}
|
|
1964
|
+
*/
|
|
1943
1965
|
setCurrentRow,
|
|
1944
|
-
/**
|
|
1966
|
+
/**
|
|
1967
|
+
* 取消选中单元格
|
|
1968
|
+
*
|
|
1969
|
+
* en: set highlight active cell (props.cellActive=true)
|
|
1970
|
+
* @see {@link setSelectedCell}
|
|
1971
|
+
*/
|
|
1945
1972
|
setSelectedCell,
|
|
1946
|
-
/**
|
|
1973
|
+
/**
|
|
1974
|
+
* 设置高亮单元格
|
|
1975
|
+
*
|
|
1976
|
+
* en: Set highlight cell
|
|
1977
|
+
* @see {@link setHighlightDimCell}
|
|
1978
|
+
*/
|
|
1947
1979
|
setHighlightDimCell,
|
|
1948
|
-
/**
|
|
1980
|
+
/**
|
|
1981
|
+
* 设置高亮行
|
|
1982
|
+
*
|
|
1983
|
+
* en: Set highlight row
|
|
1984
|
+
* @see {@link setHighlightDimRow}
|
|
1985
|
+
*/
|
|
1949
1986
|
setHighlightDimRow,
|
|
1950
|
-
/**
|
|
1987
|
+
/**
|
|
1988
|
+
* 表格排序列dataIndex
|
|
1989
|
+
*
|
|
1990
|
+
* en: Table sort column dataIndex
|
|
1991
|
+
*/
|
|
1951
1992
|
sortCol,
|
|
1952
|
-
/**
|
|
1993
|
+
/**
|
|
1994
|
+
* 表格排序列顺序
|
|
1995
|
+
*
|
|
1996
|
+
* en: get current sort info
|
|
1997
|
+
* @see {@link getSortColumns}
|
|
1998
|
+
*/
|
|
1953
1999
|
getSortColumns,
|
|
1954
|
-
/**
|
|
2000
|
+
/**
|
|
2001
|
+
* 设置表头排序状态
|
|
2002
|
+
*
|
|
2003
|
+
* en: Set the sort status of the table header
|
|
2004
|
+
* @see {@link setSorter}
|
|
2005
|
+
*/
|
|
1955
2006
|
setSorter,
|
|
1956
|
-
/**
|
|
2007
|
+
/**
|
|
2008
|
+
* 重置sorter状态
|
|
2009
|
+
*
|
|
2010
|
+
* en: Reset the sorter status
|
|
2011
|
+
* @see {@link resetSorter}
|
|
2012
|
+
*/
|
|
1957
2013
|
resetSorter,
|
|
1958
|
-
/**
|
|
2014
|
+
/**
|
|
2015
|
+
* 滚动至
|
|
2016
|
+
*
|
|
2017
|
+
* en: Scroll to
|
|
2018
|
+
* @see {@link scrollTo}
|
|
2019
|
+
*/
|
|
1959
2020
|
scrollTo,
|
|
1960
|
-
/**
|
|
2021
|
+
/**
|
|
2022
|
+
* 获取表格数据
|
|
2023
|
+
*
|
|
2024
|
+
* en: Get table data
|
|
2025
|
+
* @see {@link getTableData}
|
|
2026
|
+
*/
|
|
1961
2027
|
getTableData,
|
|
1962
|
-
/**
|
|
2028
|
+
/**
|
|
2029
|
+
* 设置展开的行
|
|
2030
|
+
*
|
|
2031
|
+
* en: Set expanded rows
|
|
2032
|
+
* @see {@link setRowExpand}
|
|
2033
|
+
*/
|
|
1963
2034
|
setRowExpand,
|
|
1964
|
-
/**
|
|
2035
|
+
/**
|
|
2036
|
+
* 不定行高时,如果行高有变化,则调用此方法更新行高。
|
|
2037
|
+
*
|
|
2038
|
+
* en: When the row height is not fixed, call this method to update the row height if the row height changes.
|
|
2039
|
+
* @see {@link setAutoHeight}
|
|
2040
|
+
*/
|
|
1965
2041
|
setAutoHeight,
|
|
1966
|
-
/**
|
|
2042
|
+
/**
|
|
2043
|
+
* 清除所有行高
|
|
2044
|
+
*
|
|
2045
|
+
* en: Clear all row heights
|
|
2046
|
+
* @see {@link clearAllAutoHeight}
|
|
2047
|
+
*/
|
|
1967
2048
|
clearAllAutoHeight
|
|
1968
2049
|
});
|
|
1969
2050
|
return (_ctx, _cache) => {
|
package/package.json
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "stk-table-vue",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "Simple realtime virtual table for vue3 and vue2.7",
|
|
5
|
-
"main": "./lib/stk-table-vue.js",
|
|
6
|
-
"types": "./lib/src/StkTable/index.d.ts",
|
|
7
|
-
"packageManager": "pnpm@8.14.3",
|
|
8
|
-
"directories": {
|
|
9
|
-
"test": "test"
|
|
10
|
-
},
|
|
11
|
-
"type": "module",
|
|
12
|
-
"scripts": {
|
|
13
|
-
"dev": "vite",
|
|
14
|
-
"build": "vite build",
|
|
15
|
-
"test": "vitest"
|
|
16
|
-
},
|
|
17
|
-
"keywords": [
|
|
18
|
-
"virtual table",
|
|
19
|
-
"vue",
|
|
20
|
-
"vue2",
|
|
21
|
-
"vue3",
|
|
22
|
-
"highlight",
|
|
23
|
-
"sticky",
|
|
24
|
-
"virtual",
|
|
25
|
-
"table",
|
|
26
|
-
"list"
|
|
27
|
-
],
|
|
28
|
-
"files": [
|
|
29
|
-
"lib",
|
|
30
|
-
"src"
|
|
31
|
-
],
|
|
32
|
-
"author": "japlus",
|
|
33
|
-
"repository": {
|
|
34
|
-
"type": "git",
|
|
35
|
-
"url": "https://github.com/ja-plus/stk-table-vue"
|
|
36
|
-
},
|
|
37
|
-
"license": "MIT",
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@types/d3-interpolate": "^3.0.4",
|
|
40
|
-
"@types/node": "^20.12.10",
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "^7.7.0",
|
|
42
|
-
"@typescript-eslint/parser": "^7.7.0",
|
|
43
|
-
"@vitejs/plugin-vue": "^5.1.4",
|
|
44
|
-
"@vue/test-utils": "2.4.4",
|
|
45
|
-
"eslint": "^8.57.0",
|
|
46
|
-
"eslint-config-prettier": "^9.1.0",
|
|
47
|
-
"eslint-plugin-html": "^8.1.0",
|
|
48
|
-
"eslint-plugin-prettier": "^5.1.3",
|
|
49
|
-
"eslint-plugin-vue": "^9.25.0",
|
|
50
|
-
"happy-dom": "^12.10.3",
|
|
51
|
-
"less": "^4.2.0",
|
|
52
|
-
"postcss-discard-comments": "^6.0.2",
|
|
53
|
-
"postcss-preset-env": "^9.5.11",
|
|
54
|
-
"prettier": "^3.2.5",
|
|
55
|
-
"typescript": "^5.4.5",
|
|
56
|
-
"vite": "^5.4.10",
|
|
57
|
-
"vite-plugin-dts": "^4.3.0",
|
|
58
|
-
"vitest": "^2.1.3",
|
|
59
|
-
"vue": "^3.5.12",
|
|
60
|
-
"vue-eslint-parser": "^9.4.2"
|
|
61
|
-
},
|
|
62
|
-
"dependencies": {
|
|
63
|
-
"d3-interpolate": "^3.0.1"
|
|
64
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "stk-table-vue",
|
|
3
|
+
"version": "0.6.2",
|
|
4
|
+
"description": "Simple realtime virtual table for vue3 and vue2.7",
|
|
5
|
+
"main": "./lib/stk-table-vue.js",
|
|
6
|
+
"types": "./lib/src/StkTable/index.d.ts",
|
|
7
|
+
"packageManager": "pnpm@8.14.3",
|
|
8
|
+
"directories": {
|
|
9
|
+
"test": "test"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "vite",
|
|
14
|
+
"build": "vite build",
|
|
15
|
+
"test": "vitest"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"virtual table",
|
|
19
|
+
"vue",
|
|
20
|
+
"vue2",
|
|
21
|
+
"vue3",
|
|
22
|
+
"highlight",
|
|
23
|
+
"sticky",
|
|
24
|
+
"virtual",
|
|
25
|
+
"table",
|
|
26
|
+
"list"
|
|
27
|
+
],
|
|
28
|
+
"files": [
|
|
29
|
+
"lib",
|
|
30
|
+
"src"
|
|
31
|
+
],
|
|
32
|
+
"author": "japlus",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/ja-plus/stk-table-vue"
|
|
36
|
+
},
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/d3-interpolate": "^3.0.4",
|
|
40
|
+
"@types/node": "^20.12.10",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^7.7.0",
|
|
42
|
+
"@typescript-eslint/parser": "^7.7.0",
|
|
43
|
+
"@vitejs/plugin-vue": "^5.1.4",
|
|
44
|
+
"@vue/test-utils": "2.4.4",
|
|
45
|
+
"eslint": "^8.57.0",
|
|
46
|
+
"eslint-config-prettier": "^9.1.0",
|
|
47
|
+
"eslint-plugin-html": "^8.1.0",
|
|
48
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
49
|
+
"eslint-plugin-vue": "^9.25.0",
|
|
50
|
+
"happy-dom": "^12.10.3",
|
|
51
|
+
"less": "^4.2.0",
|
|
52
|
+
"postcss-discard-comments": "^6.0.2",
|
|
53
|
+
"postcss-preset-env": "^9.5.11",
|
|
54
|
+
"prettier": "^3.2.5",
|
|
55
|
+
"typescript": "^5.4.5",
|
|
56
|
+
"vite": "^5.4.10",
|
|
57
|
+
"vite-plugin-dts": "^4.3.0",
|
|
58
|
+
"vitest": "^2.1.3",
|
|
59
|
+
"vue": "^3.5.12",
|
|
60
|
+
"vue-eslint-parser": "^9.4.2"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"d3-interpolate": "^3.0.1"
|
|
64
|
+
}
|
|
65
65
|
}
|
|
@@ -466,101 +466,121 @@ const props = withDefaults(
|
|
|
466
466
|
const emits = defineEmits<{
|
|
467
467
|
/**
|
|
468
468
|
* 排序变更触发。defaultSort.dataIndex 找不到时,col 将返回null。
|
|
469
|
+
*
|
|
469
470
|
* ```(col: StkTableColumn<DT> | null, order: Order, data: DT[], sortConfig: SortConfig<DT>)```
|
|
470
471
|
*/
|
|
471
472
|
(e: 'sort-change', col: StkTableColumn<DT> | null, order: Order, data: DT[], sortConfig: SortConfig<DT>): void;
|
|
472
473
|
/**
|
|
473
474
|
* 一行点击事件
|
|
475
|
+
*
|
|
474
476
|
* ```(ev: MouseEvent, row: DT)```
|
|
475
477
|
*/
|
|
476
478
|
(e: 'row-click', ev: MouseEvent, row: DT): void;
|
|
477
479
|
/**
|
|
478
480
|
* 选中一行触发。ev返回null表示不是点击事件触发的
|
|
481
|
+
*
|
|
479
482
|
* ```(ev: MouseEvent | null, row: DT | undefined, data: { select: boolean })```
|
|
480
483
|
*/
|
|
481
484
|
(e: 'current-change', ev: MouseEvent | null, row: DT | undefined, data: { select: boolean }): void;
|
|
482
485
|
/**
|
|
483
486
|
* 选中单元格触发。ev返回null表示不是点击事件触发的
|
|
487
|
+
*
|
|
484
488
|
* ```(ev: MouseEvent | null, data: { select: boolean; row: DT | undefined; col: StkTableColumn<DT> | null })```
|
|
485
489
|
*/
|
|
486
490
|
(e: 'cell-selected', ev: MouseEvent | null, data: { select: boolean; row: DT | undefined; col: StkTableColumn<DT> | undefined }): void;
|
|
487
491
|
/**
|
|
488
492
|
* 行双击事件
|
|
493
|
+
*
|
|
489
494
|
* ```(ev: MouseEvent, row: DT)```
|
|
490
495
|
*/
|
|
491
496
|
(e: 'row-dblclick', ev: MouseEvent, row: DT): void;
|
|
492
497
|
/**
|
|
493
498
|
* 表头右键事件
|
|
499
|
+
*
|
|
494
500
|
* ```(ev: MouseEvent)```
|
|
495
501
|
*/
|
|
496
502
|
(e: 'header-row-menu', ev: MouseEvent): void;
|
|
497
503
|
/**
|
|
498
504
|
* 表体行右键点击事件
|
|
505
|
+
*
|
|
499
506
|
* ```(ev: MouseEvent, row: DT)```
|
|
500
507
|
*/
|
|
501
508
|
(e: 'row-menu', ev: MouseEvent, row: DT): void;
|
|
502
509
|
/**
|
|
503
510
|
* 单元格点击事件
|
|
511
|
+
*
|
|
504
512
|
* ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
|
|
505
513
|
*/
|
|
506
514
|
(e: 'cell-click', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
|
|
507
515
|
/**
|
|
508
516
|
* 单元格鼠标进入事件
|
|
517
|
+
*
|
|
509
518
|
* ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
|
|
510
519
|
*/
|
|
511
520
|
(e: 'cell-mouseenter', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
|
|
512
521
|
/**
|
|
513
522
|
* 单元格鼠标移出事件
|
|
523
|
+
*
|
|
514
524
|
* ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
|
|
515
525
|
*/
|
|
516
526
|
(e: 'cell-mouseleave', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
|
|
517
527
|
/**
|
|
518
528
|
* 单元格悬浮事件
|
|
529
|
+
*
|
|
519
530
|
* ```(ev: MouseEvent, row: DT, col: StkTableColumn<DT>)```
|
|
520
531
|
*/
|
|
521
532
|
(e: 'cell-mouseover', ev: MouseEvent, row: DT, col: StkTableColumn<DT>): void;
|
|
522
533
|
/**
|
|
523
534
|
* 表头单元格点击事件
|
|
535
|
+
*
|
|
524
536
|
* ```(ev: MouseEvent, col: StkTableColumn<DT>)```
|
|
525
537
|
*/
|
|
526
538
|
(e: 'header-cell-click', ev: MouseEvent, col: StkTableColumn<DT>): void;
|
|
527
539
|
/**
|
|
528
540
|
* 表格滚动事件
|
|
541
|
+
*
|
|
529
542
|
* ```(ev: Event, data: { startIndex: number; endIndex: number })```
|
|
530
543
|
*/
|
|
531
544
|
(e: 'scroll', ev: Event, data: { startIndex: number; endIndex: number }): void;
|
|
532
545
|
/**
|
|
533
546
|
* 表格横向滚动事件
|
|
547
|
+
*
|
|
534
548
|
* ```(ev: Event)```
|
|
535
549
|
*/
|
|
536
550
|
(e: 'scroll-x', ev: Event): void;
|
|
537
551
|
/**
|
|
538
552
|
* 表头列拖动事件
|
|
553
|
+
*
|
|
539
554
|
* ```(dragStartKey: string, targetColKey: string)```
|
|
540
555
|
*/
|
|
541
556
|
(e: 'col-order-change', dragStartKey: string, targetColKey: string): void;
|
|
542
557
|
/**
|
|
543
558
|
* 表头列拖动开始
|
|
559
|
+
*
|
|
544
560
|
* ```(dragStartKey: string)```
|
|
545
561
|
*/
|
|
546
562
|
(e: 'th-drag-start', dragStartKey: string): void;
|
|
547
563
|
/**
|
|
548
564
|
* 表头列拖动drop
|
|
565
|
+
*
|
|
549
566
|
* ```(targetColKey: string)```
|
|
550
567
|
*/
|
|
551
568
|
(e: 'th-drop', targetColKey: string): void;
|
|
552
569
|
/**
|
|
553
570
|
* 行拖动事件
|
|
571
|
+
*
|
|
554
572
|
* ```(dragStartKey: string, targetRowKey: string)```
|
|
555
573
|
*/
|
|
556
574
|
(e: 'row-order-change', dragStartKey: string, targetRowKey: string): void;
|
|
557
575
|
/**
|
|
558
576
|
* 列宽变动时触发
|
|
577
|
+
*
|
|
559
578
|
* ```(cols: StkTableColumn<DT>)```
|
|
560
579
|
*/
|
|
561
580
|
(e: 'col-resize', cols: StkTableColumn<DT>): void;
|
|
562
581
|
/**
|
|
563
582
|
* 展开行触发
|
|
583
|
+
*
|
|
564
584
|
* ```( data: { expanded: boolean; row: DT; col: StkTableColumn<DT> })```
|
|
565
585
|
*/
|
|
566
586
|
(e: 'toggle-row-expand', data: { expanded: boolean; row: DT; col: StkTableColumn<DT> | null }): void;
|
|
@@ -980,7 +1000,14 @@ function getHeaderTitle(col: StkTableColumn<DT>): string {
|
|
|
980
1000
|
* @param options.emit 是否触发回调
|
|
981
1001
|
*/
|
|
982
1002
|
function onColumnSort(col: StkTableColumn<DT> | undefined | null, click = true, options: { force?: boolean; emit?: boolean } = {}) {
|
|
983
|
-
if (!col
|
|
1003
|
+
if (!col) {
|
|
1004
|
+
console.warn('onColumnSort: col is not found');
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
if (!col.sorter && click) {
|
|
1008
|
+
// 点击表头触发的排序,如果列没有配置sorter则不处理。setSorter 触发的排序则保持通行。
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
984
1011
|
options = { force: false, emit: false, ...options };
|
|
985
1012
|
if (sortCol.value !== col.dataIndex) {
|
|
986
1013
|
// 改变排序的列时,重置排序
|
|
@@ -1271,8 +1298,8 @@ function getSortColumns(): Partial<SortState<DT>>[] {
|
|
|
1271
1298
|
return [{ dataIndex: sortCol.value, order: sortOrder }];
|
|
1272
1299
|
}
|
|
1273
1300
|
|
|
1274
|
-
/** click expended icon to
|
|
1275
|
-
function toggleExpandRow(row: DT, col: StkTableColumn<DT
|
|
1301
|
+
/** click expended icon to toggle expand row */
|
|
1302
|
+
function toggleExpandRow(row: DT, col: StkTableColumn<DT>) {
|
|
1276
1303
|
const isExpand = row?.__EXPANDED__ === col ? !row?.__EXPANDED__ : true;
|
|
1277
1304
|
setRowExpand(row, isExpand, { col });
|
|
1278
1305
|
}
|
|
@@ -1334,37 +1361,116 @@ function setRowExpand(rowKeyOrRow: string | undefined | DT, expand?: boolean, da
|
|
|
1334
1361
|
}
|
|
1335
1362
|
|
|
1336
1363
|
defineExpose({
|
|
1337
|
-
/**
|
|
1364
|
+
/**
|
|
1365
|
+
* 重新计算虚拟列表宽高
|
|
1366
|
+
*
|
|
1367
|
+
* en: calc virtual scroll x & y info
|
|
1368
|
+
* @see {@link initVirtualScroll}
|
|
1369
|
+
*/
|
|
1338
1370
|
initVirtualScroll,
|
|
1339
|
-
/**
|
|
1371
|
+
/**
|
|
1372
|
+
* 重新计算虚拟列表宽度
|
|
1373
|
+
*
|
|
1374
|
+
* en: calc virtual scroll x
|
|
1375
|
+
* @see {@link initVirtualScrollX}
|
|
1376
|
+
*/
|
|
1340
1377
|
initVirtualScrollX,
|
|
1341
|
-
/**
|
|
1378
|
+
/**
|
|
1379
|
+
* 重新计算虚拟列表高度
|
|
1380
|
+
*
|
|
1381
|
+
* en: calc virtual scroll y
|
|
1382
|
+
* @see {@link initVirtualScrollY}
|
|
1383
|
+
*/
|
|
1342
1384
|
initVirtualScrollY,
|
|
1343
|
-
/**
|
|
1385
|
+
/**
|
|
1386
|
+
* 选中一行
|
|
1387
|
+
*
|
|
1388
|
+
* en:select a row
|
|
1389
|
+
* @see {@link setCurrentRow}
|
|
1390
|
+
*/
|
|
1344
1391
|
setCurrentRow,
|
|
1345
|
-
/**
|
|
1392
|
+
/**
|
|
1393
|
+
* 取消选中单元格
|
|
1394
|
+
*
|
|
1395
|
+
* en: set highlight active cell (props.cellActive=true)
|
|
1396
|
+
* @see {@link setSelectedCell}
|
|
1397
|
+
*/
|
|
1346
1398
|
setSelectedCell,
|
|
1347
|
-
/**
|
|
1399
|
+
/**
|
|
1400
|
+
* 设置高亮单元格
|
|
1401
|
+
*
|
|
1402
|
+
* en: Set highlight cell
|
|
1403
|
+
* @see {@link setHighlightDimCell}
|
|
1404
|
+
*/
|
|
1348
1405
|
setHighlightDimCell,
|
|
1349
|
-
/**
|
|
1406
|
+
/**
|
|
1407
|
+
* 设置高亮行
|
|
1408
|
+
*
|
|
1409
|
+
* en: Set highlight row
|
|
1410
|
+
* @see {@link setHighlightDimRow}
|
|
1411
|
+
*/
|
|
1350
1412
|
setHighlightDimRow,
|
|
1351
|
-
/**
|
|
1413
|
+
/**
|
|
1414
|
+
* 表格排序列dataIndex
|
|
1415
|
+
*
|
|
1416
|
+
* en: Table sort column dataIndex
|
|
1417
|
+
*/
|
|
1352
1418
|
sortCol,
|
|
1353
|
-
/**
|
|
1419
|
+
/**
|
|
1420
|
+
* 表格排序列顺序
|
|
1421
|
+
*
|
|
1422
|
+
* en: get current sort info
|
|
1423
|
+
* @see {@link getSortColumns}
|
|
1424
|
+
*/
|
|
1354
1425
|
getSortColumns,
|
|
1355
|
-
/**
|
|
1426
|
+
/**
|
|
1427
|
+
* 设置表头排序状态
|
|
1428
|
+
*
|
|
1429
|
+
* en: Set the sort status of the table header
|
|
1430
|
+
* @see {@link setSorter}
|
|
1431
|
+
*/
|
|
1356
1432
|
setSorter,
|
|
1357
|
-
/**
|
|
1433
|
+
/**
|
|
1434
|
+
* 重置sorter状态
|
|
1435
|
+
*
|
|
1436
|
+
* en: Reset the sorter status
|
|
1437
|
+
* @see {@link resetSorter}
|
|
1438
|
+
*/
|
|
1358
1439
|
resetSorter,
|
|
1359
|
-
/**
|
|
1440
|
+
/**
|
|
1441
|
+
* 滚动至
|
|
1442
|
+
*
|
|
1443
|
+
* en: Scroll to
|
|
1444
|
+
* @see {@link scrollTo}
|
|
1445
|
+
*/
|
|
1360
1446
|
scrollTo,
|
|
1361
|
-
/**
|
|
1447
|
+
/**
|
|
1448
|
+
* 获取表格数据
|
|
1449
|
+
*
|
|
1450
|
+
* en: Get table data
|
|
1451
|
+
* @see {@link getTableData}
|
|
1452
|
+
*/
|
|
1362
1453
|
getTableData,
|
|
1363
|
-
/**
|
|
1454
|
+
/**
|
|
1455
|
+
* 设置展开的行
|
|
1456
|
+
*
|
|
1457
|
+
* en: Set expanded rows
|
|
1458
|
+
* @see {@link setRowExpand}
|
|
1459
|
+
*/
|
|
1364
1460
|
setRowExpand,
|
|
1365
|
-
/**
|
|
1461
|
+
/**
|
|
1462
|
+
* 不定行高时,如果行高有变化,则调用此方法更新行高。
|
|
1463
|
+
*
|
|
1464
|
+
* en: When the row height is not fixed, call this method to update the row height if the row height changes.
|
|
1465
|
+
* @see {@link setAutoHeight}
|
|
1466
|
+
*/
|
|
1366
1467
|
setAutoHeight,
|
|
1367
|
-
/**
|
|
1468
|
+
/**
|
|
1469
|
+
* 清除所有行高
|
|
1470
|
+
*
|
|
1471
|
+
* en: Clear all row heights
|
|
1472
|
+
* @see {@link clearAllAutoHeight}
|
|
1473
|
+
*/
|
|
1368
1474
|
clearAllAutoHeight,
|
|
1369
1475
|
});
|
|
1370
1476
|
</script>
|
|
@@ -19,7 +19,7 @@ export function useThDrag<DT extends Record<string, any>>({ props, emits, colKey
|
|
|
19
19
|
return {
|
|
20
20
|
draggable,
|
|
21
21
|
mode: 'insert',
|
|
22
|
-
disabled: () =>
|
|
22
|
+
disabled: () => false,
|
|
23
23
|
...headerDrag,
|
|
24
24
|
};
|
|
25
25
|
});
|
|
@@ -97,6 +97,6 @@ export function useThDrag<DT extends Record<string, any>>({ props, emits, colKey
|
|
|
97
97
|
onThDragOver,
|
|
98
98
|
onThDrop,
|
|
99
99
|
/** 是否可拖拽 */
|
|
100
|
-
isHeaderDraggable: dragConfig.value.disabled,
|
|
100
|
+
isHeaderDraggable: (col: StkTableColumn<DT>) => !dragConfig.value.disabled(col),
|
|
101
101
|
};
|
|
102
102
|
}
|