stk-table-vue 0.6.3 → 0.6.4
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/lib/src/StkTable/StkTable.vue.d.ts +1 -1
- package/lib/src/StkTable/types/index.d.ts +2 -0
- package/lib/src/StkTable/utils/index.d.ts +2 -2
- package/lib/stk-table-vue.js +5 -6
- package/package.json +1 -1
- package/src/StkTable/StkTable.vue +6 -11
- package/src/StkTable/types/index.ts +2 -0
- package/src/StkTable/useColResize.ts +2 -1
- package/src/StkTable/utils/index.ts +3 -5
|
@@ -438,6 +438,7 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<{
|
|
|
438
438
|
width: string;
|
|
439
439
|
minWidth: string;
|
|
440
440
|
maxWidth: string;
|
|
441
|
+
sortConfig: SortConfig<any>;
|
|
441
442
|
rowHeight: number;
|
|
442
443
|
headerRowHeight: number | null;
|
|
443
444
|
headless: boolean;
|
|
@@ -475,7 +476,6 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<{
|
|
|
475
476
|
bordered: boolean | "h" | "v" | "body-v";
|
|
476
477
|
autoResize: boolean | (() => void);
|
|
477
478
|
fixedColShadow: boolean;
|
|
478
|
-
sortConfig: SortConfig<any>;
|
|
479
479
|
hideHeaderTitle: boolean | string[];
|
|
480
480
|
highlightConfig: HighlightConfig;
|
|
481
481
|
seqConfig: SeqConfig;
|
|
@@ -71,6 +71,8 @@ export type StkTableColumn<T extends Record<string, any>> = {
|
|
|
71
71
|
sortField?: keyof T;
|
|
72
72
|
/** 排序方式。按数字/字符串 */
|
|
73
73
|
sortType?: 'number' | 'string';
|
|
74
|
+
/** 配置当前列的排序规则 */
|
|
75
|
+
sortConfig?: Pick<SortConfig<T>, 'emptyToBottom' | 'stringLocaleCompare'>;
|
|
74
76
|
/** 固定列 */
|
|
75
77
|
fixed?: 'left' | 'right' | null;
|
|
76
78
|
/** private */ rowSpan?: number;
|
|
@@ -36,6 +36,6 @@ export declare function strCompare(a: string, b: string, isNumber: boolean, loca
|
|
|
36
36
|
export declare function tableSort<T extends Record<string, any>>(sortOption: SortOption<T>, order: Order, dataSource: T[], sortConfig?: SortConfig<T>): T[];
|
|
37
37
|
/** 多级表头深度 从0开始为一级*/
|
|
38
38
|
export declare function howDeepTheHeader(arr: StkTableColumn<any>[], level?: number): number;
|
|
39
|
-
/** number
|
|
40
|
-
export declare function transformWidthToStr(width?: string | number): string
|
|
39
|
+
/** number width +px */
|
|
40
|
+
export declare function transformWidthToStr(width?: string | number): string;
|
|
41
41
|
export declare function getBrowsersVersion(browserName: string): number;
|
package/lib/stk-table-vue.js
CHANGED
|
@@ -158,10 +158,8 @@ function howDeepTheHeader(arr, level = 0) {
|
|
|
158
158
|
return Math.max(...levels);
|
|
159
159
|
}
|
|
160
160
|
function transformWidthToStr(width) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
return width;
|
|
161
|
+
const numberWidth = Number(width);
|
|
162
|
+
return width + (!Number.isNaN(numberWidth) ? "px" : "");
|
|
165
163
|
}
|
|
166
164
|
function getBrowsersVersion(browserName) {
|
|
167
165
|
try {
|
|
@@ -369,7 +367,8 @@ function useColResize({
|
|
|
369
367
|
const { clientX } = e;
|
|
370
368
|
let moveX = clientX - startX;
|
|
371
369
|
const currentColWidth = getCalculatedColWidth(lastCol);
|
|
372
|
-
|
|
370
|
+
const minWidth = (lastCol == null ? void 0 : lastCol.minWidth) ?? props.colMinWidth;
|
|
371
|
+
if (currentColWidth + moveX < minWidth) {
|
|
373
372
|
moveX = -currentColWidth;
|
|
374
373
|
}
|
|
375
374
|
const offsetTableX = startOffsetTableX + moveX;
|
|
@@ -1701,7 +1700,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1701
1700
|
if (click) sortOrderIndex.value++;
|
|
1702
1701
|
sortOrderIndex.value = sortOrderIndex.value % 3;
|
|
1703
1702
|
let order = sortSwitchOrder[sortOrderIndex.value];
|
|
1704
|
-
const sortConfig = props.sortConfig;
|
|
1703
|
+
const sortConfig = { ...props.sortConfig, ...col.sortConfig };
|
|
1705
1704
|
const defaultSort = sortConfig.defaultSort;
|
|
1706
1705
|
if (!order && defaultSort) {
|
|
1707
1706
|
const colKey2 = defaultSort.key || defaultSort.dataIndex;
|
package/package.json
CHANGED
|
@@ -136,15 +136,10 @@
|
|
|
136
136
|
hover: props.showTrHoverClass && (rowKey ? rowKeyGen(row) === currentHoverRowKey : row === currentHoverRowKey),
|
|
137
137
|
[rowClassName(row, (virtual_on ? virtualScroll.startIndex : 0) + rowIndex)]: true,
|
|
138
138
|
expanded: row?.__EXPANDED__,
|
|
139
|
-
'expanded-row': row &&
|
|
139
|
+
'expanded-row': row && row.__EXPANDED_ROW__,
|
|
140
140
|
}"
|
|
141
141
|
:style="{
|
|
142
|
-
'--row-height':
|
|
143
|
-
row &&
|
|
144
|
-
(row as ExpandedRow).__EXPANDED_ROW__ &&
|
|
145
|
-
virtual_on &&
|
|
146
|
-
props.expandConfig?.height &&
|
|
147
|
-
props.expandConfig?.height + 'px',
|
|
142
|
+
'--row-height': row && row.__EXPANDED_ROW__ && virtual_on && props.expandConfig?.height && props.expandConfig?.height + 'px',
|
|
148
143
|
}"
|
|
149
144
|
@click="e => onRowClick(e, row)"
|
|
150
145
|
@dblclick="e => onRowDblclick(e, row)"
|
|
@@ -154,11 +149,11 @@
|
|
|
154
149
|
>
|
|
155
150
|
<!--这个td用于配合虚拟滚动的th对应,防止列错位-->
|
|
156
151
|
<td v-if="virtualX_on" class="vt-x-left"></td>
|
|
157
|
-
<td v-if="row &&
|
|
152
|
+
<td v-if="row && row.__EXPANDED_ROW__" :colspan="virtualX_columnPart.length">
|
|
158
153
|
<!-- TODO: support wheel -->
|
|
159
154
|
<div class="table-cell-wrapper">
|
|
160
|
-
<slot name="expand" :row="
|
|
161
|
-
{{
|
|
155
|
+
<slot name="expand" :row="row.__EXPANDED_ROW__" :col="row.__EXPANDED_COL__">
|
|
156
|
+
{{ row.__EXPANDED_ROW__?.[row.__EXPANDED_COL__.dataIndex] ?? '' }}
|
|
162
157
|
</slot>
|
|
163
158
|
</div>
|
|
164
159
|
</td>
|
|
@@ -1047,7 +1042,7 @@ function onColumnSort(col: StkTableColumn<DT> | undefined | null, click = true,
|
|
|
1047
1042
|
sortOrderIndex.value = sortOrderIndex.value % 3;
|
|
1048
1043
|
|
|
1049
1044
|
let order = sortSwitchOrder[sortOrderIndex.value];
|
|
1050
|
-
const sortConfig = props.sortConfig;
|
|
1045
|
+
const sortConfig = { ...props.sortConfig, ...col.sortConfig };
|
|
1051
1046
|
const defaultSort = sortConfig.defaultSort;
|
|
1052
1047
|
|
|
1053
1048
|
if (!order && defaultSort) {
|
|
@@ -77,6 +77,8 @@ export type StkTableColumn<T extends Record<string, any>> = {
|
|
|
77
77
|
sortField?: keyof T;
|
|
78
78
|
/** 排序方式。按数字/字符串 */
|
|
79
79
|
sortType?: 'number' | 'string';
|
|
80
|
+
/** 配置当前列的排序规则 */
|
|
81
|
+
sortConfig?: Pick<SortConfig<T>, 'emptyToBottom' | 'stringLocaleCompare'>;
|
|
80
82
|
/** 固定列 */
|
|
81
83
|
fixed?: 'left' | 'right' | null;
|
|
82
84
|
/** private */ rowSpan?: number;
|
|
@@ -139,8 +139,9 @@ export function useColResize<DT extends Record<string, any>>({
|
|
|
139
139
|
const { clientX } = e;
|
|
140
140
|
let moveX = clientX - startX;
|
|
141
141
|
const currentColWidth = getCalculatedColWidth(lastCol);
|
|
142
|
+
const minWidth = lastCol?.minWidth ?? props.colMinWidth;
|
|
142
143
|
// 移动量不小于最小列宽
|
|
143
|
-
if (currentColWidth + moveX <
|
|
144
|
+
if (currentColWidth + moveX < minWidth) {
|
|
144
145
|
moveX = -currentColWidth;
|
|
145
146
|
}
|
|
146
147
|
|
|
@@ -180,12 +180,10 @@ export function howDeepTheHeader(arr: StkTableColumn<any>[], level = 0) {
|
|
|
180
180
|
return Math.max(...levels);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
/** number
|
|
183
|
+
/** number width +px */
|
|
184
184
|
export function transformWidthToStr(width?: string | number) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
return width;
|
|
185
|
+
const numberWidth = Number(width);
|
|
186
|
+
return width + (!Number.isNaN(numberWidth) ? 'px' : '');
|
|
189
187
|
}
|
|
190
188
|
|
|
191
189
|
export function getBrowsersVersion(browserName: string) {
|