@94ai/nf-table 8.3.6 → 8.3.8
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/index.d.ts +92 -0
- package/lib/nf-table.cjs.js +212 -0
- package/lib/nf-table.esm-bundler.js +212 -0
- package/lib/nf-table.vue.d.ts +22 -0
- package/package/nf-column-check-drawer.vue +1 -1
- package/package/nf-table.vue +1853 -1633
- package/package.json +9 -9
package/lib/index.d.ts
CHANGED
|
@@ -310,6 +310,18 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
310
310
|
type: import("vue-demi").PropType<Record<string, any>>;
|
|
311
311
|
default: () => {};
|
|
312
312
|
};
|
|
313
|
+
dragIndicatorPaddingLeft: {
|
|
314
|
+
type: import("vue-demi").PropType<number>;
|
|
315
|
+
default: number;
|
|
316
|
+
};
|
|
317
|
+
dragIndicatorPaddingRight: {
|
|
318
|
+
type: import("vue-demi").PropType<number>;
|
|
319
|
+
default: number;
|
|
320
|
+
};
|
|
321
|
+
fixedRightDragEnabled: {
|
|
322
|
+
type: import("vue-demi").PropType<boolean>;
|
|
323
|
+
default: boolean;
|
|
324
|
+
};
|
|
313
325
|
}>>, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
314
326
|
background: {
|
|
315
327
|
type: import("vue-demi").PropType<string>;
|
|
@@ -621,6 +633,18 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
621
633
|
type: import("vue-demi").PropType<Record<string, any>>;
|
|
622
634
|
default: () => {};
|
|
623
635
|
};
|
|
636
|
+
dragIndicatorPaddingLeft: {
|
|
637
|
+
type: import("vue-demi").PropType<number>;
|
|
638
|
+
default: number;
|
|
639
|
+
};
|
|
640
|
+
dragIndicatorPaddingRight: {
|
|
641
|
+
type: import("vue-demi").PropType<number>;
|
|
642
|
+
default: number;
|
|
643
|
+
};
|
|
644
|
+
fixedRightDragEnabled: {
|
|
645
|
+
type: import("vue-demi").PropType<boolean>;
|
|
646
|
+
default: boolean;
|
|
647
|
+
};
|
|
624
648
|
}>>, {
|
|
625
649
|
fieldsChange: (event: string[]) => void;
|
|
626
650
|
"update:showColumn": (event: string[] | undefined) => void;
|
|
@@ -628,6 +652,13 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
628
652
|
data: Record<string, any>;
|
|
629
653
|
callback: Function;
|
|
630
654
|
}) => void;
|
|
655
|
+
fixedColumnDragEnd: (event: {
|
|
656
|
+
width: number;
|
|
657
|
+
oldWidth: number;
|
|
658
|
+
prop?: string | undefined;
|
|
659
|
+
column?: any;
|
|
660
|
+
nativeEvent?: Event | undefined;
|
|
661
|
+
}) => void;
|
|
631
662
|
}, {
|
|
632
663
|
background: string;
|
|
633
664
|
columns: any;
|
|
@@ -705,6 +736,9 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
705
736
|
virtualized: boolean;
|
|
706
737
|
virtualTableData: Record<string, any>[];
|
|
707
738
|
virtualProps: Record<string, any>;
|
|
739
|
+
dragIndicatorPaddingLeft: number;
|
|
740
|
+
dragIndicatorPaddingRight: number;
|
|
741
|
+
fixedRightDragEnabled: boolean;
|
|
708
742
|
}, true, import("vue/types/v3-component-options").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, any>> & Readonly<Readonly<import("vue-demi").ExtractPropTypes<{
|
|
709
743
|
background: {
|
|
710
744
|
type: import("vue-demi").PropType<string>;
|
|
@@ -1016,6 +1050,18 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
1016
1050
|
type: import("vue-demi").PropType<Record<string, any>>;
|
|
1017
1051
|
default: () => {};
|
|
1018
1052
|
};
|
|
1053
|
+
dragIndicatorPaddingLeft: {
|
|
1054
|
+
type: import("vue-demi").PropType<number>;
|
|
1055
|
+
default: number;
|
|
1056
|
+
};
|
|
1057
|
+
dragIndicatorPaddingRight: {
|
|
1058
|
+
type: import("vue-demi").PropType<number>;
|
|
1059
|
+
default: number;
|
|
1060
|
+
};
|
|
1061
|
+
fixedRightDragEnabled: {
|
|
1062
|
+
type: import("vue-demi").PropType<boolean>;
|
|
1063
|
+
default: boolean;
|
|
1064
|
+
};
|
|
1019
1065
|
}>>> & import("vue-demi").ShallowUnwrapRef<{
|
|
1020
1066
|
clearFilter: () => void;
|
|
1021
1067
|
sort: (prop: any, order: any) => void;
|
|
@@ -1426,6 +1472,18 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
1426
1472
|
type: import("vue-demi").PropType<Record<string, any>>;
|
|
1427
1473
|
default: () => {};
|
|
1428
1474
|
};
|
|
1475
|
+
dragIndicatorPaddingLeft: {
|
|
1476
|
+
type: import("vue-demi").PropType<number>;
|
|
1477
|
+
default: number;
|
|
1478
|
+
};
|
|
1479
|
+
dragIndicatorPaddingRight: {
|
|
1480
|
+
type: import("vue-demi").PropType<number>;
|
|
1481
|
+
default: number;
|
|
1482
|
+
};
|
|
1483
|
+
fixedRightDragEnabled: {
|
|
1484
|
+
type: import("vue-demi").PropType<boolean>;
|
|
1485
|
+
default: boolean;
|
|
1486
|
+
};
|
|
1429
1487
|
}>>, any, any, any, import("vue-demi").ComponentComputedOptions, import("vue-demi").ComponentMethodOptions> & import("vue/types/v3-component-options").ComponentOptionsBase<Readonly<import("vue-demi").ExtractPropTypes<{
|
|
1430
1488
|
background: {
|
|
1431
1489
|
type: import("vue-demi").PropType<string>;
|
|
@@ -1737,6 +1795,18 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
1737
1795
|
type: import("vue-demi").PropType<Record<string, any>>;
|
|
1738
1796
|
default: () => {};
|
|
1739
1797
|
};
|
|
1798
|
+
dragIndicatorPaddingLeft: {
|
|
1799
|
+
type: import("vue-demi").PropType<number>;
|
|
1800
|
+
default: number;
|
|
1801
|
+
};
|
|
1802
|
+
dragIndicatorPaddingRight: {
|
|
1803
|
+
type: import("vue-demi").PropType<number>;
|
|
1804
|
+
default: number;
|
|
1805
|
+
};
|
|
1806
|
+
fixedRightDragEnabled: {
|
|
1807
|
+
type: import("vue-demi").PropType<boolean>;
|
|
1808
|
+
default: boolean;
|
|
1809
|
+
};
|
|
1740
1810
|
}>>, {
|
|
1741
1811
|
clearFilter: () => void;
|
|
1742
1812
|
sort: (prop: any, order: any) => void;
|
|
@@ -1843,6 +1913,13 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
1843
1913
|
data: Record<string, any>;
|
|
1844
1914
|
callback: Function;
|
|
1845
1915
|
}) => void;
|
|
1916
|
+
fixedColumnDragEnd: (event: {
|
|
1917
|
+
width: number;
|
|
1918
|
+
oldWidth: number;
|
|
1919
|
+
prop?: string | undefined;
|
|
1920
|
+
column?: any;
|
|
1921
|
+
nativeEvent?: Event | undefined;
|
|
1922
|
+
}) => void;
|
|
1846
1923
|
}, string, {
|
|
1847
1924
|
background: string;
|
|
1848
1925
|
columns: any;
|
|
@@ -1920,6 +1997,9 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
1920
1997
|
virtualized: boolean;
|
|
1921
1998
|
virtualTableData: Record<string, any>[];
|
|
1922
1999
|
virtualProps: Record<string, any>;
|
|
2000
|
+
dragIndicatorPaddingLeft: number;
|
|
2001
|
+
dragIndicatorPaddingRight: number;
|
|
2002
|
+
fixedRightDragEnabled: boolean;
|
|
1923
2003
|
}> & {
|
|
1924
2004
|
props: {
|
|
1925
2005
|
background: {
|
|
@@ -2232,6 +2312,18 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
|
|
|
2232
2312
|
type: import("vue-demi").PropType<Record<string, any>>;
|
|
2233
2313
|
default: () => {};
|
|
2234
2314
|
};
|
|
2315
|
+
dragIndicatorPaddingLeft: {
|
|
2316
|
+
type: import("vue-demi").PropType<number>;
|
|
2317
|
+
default: number;
|
|
2318
|
+
};
|
|
2319
|
+
dragIndicatorPaddingRight: {
|
|
2320
|
+
type: import("vue-demi").PropType<number>;
|
|
2321
|
+
default: number;
|
|
2322
|
+
};
|
|
2323
|
+
fixedRightDragEnabled: {
|
|
2324
|
+
type: import("vue-demi").PropType<boolean>;
|
|
2325
|
+
default: boolean;
|
|
2326
|
+
};
|
|
2235
2327
|
};
|
|
2236
2328
|
} & (new () => {
|
|
2237
2329
|
$scopedSlots: Partial<Record<any, (_: {
|
package/lib/nf-table.cjs.js
CHANGED
|
@@ -9408,6 +9408,24 @@ __sfc_main.props = {
|
|
|
9408
9408
|
required: false,
|
|
9409
9409
|
type: Object,
|
|
9410
9410
|
default: () => ({})
|
|
9411
|
+
},
|
|
9412
|
+
dragIndicatorPaddingLeft: {
|
|
9413
|
+
key: "dragIndicatorPaddingLeft",
|
|
9414
|
+
required: false,
|
|
9415
|
+
type: Number,
|
|
9416
|
+
default: 120
|
|
9417
|
+
},
|
|
9418
|
+
dragIndicatorPaddingRight: {
|
|
9419
|
+
key: "dragIndicatorPaddingRight",
|
|
9420
|
+
required: false,
|
|
9421
|
+
type: Number,
|
|
9422
|
+
default: 120
|
|
9423
|
+
},
|
|
9424
|
+
fixedRightDragEnabled: {
|
|
9425
|
+
key: "fixedRightDragEnabled",
|
|
9426
|
+
required: false,
|
|
9427
|
+
type: Boolean,
|
|
9428
|
+
default: false
|
|
9411
9429
|
}
|
|
9412
9430
|
};
|
|
9413
9431
|
__sfc_main.setup = (__props, __ctx) => {
|
|
@@ -9976,6 +9994,199 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9976
9994
|
resizeTable();
|
|
9977
9995
|
await ((_b = (_a2 = props.tableEvents)["header-dragend"]) == null ? void 0 : _b.call(_a2, newWidth, oldWidth, column, event));
|
|
9978
9996
|
};
|
|
9997
|
+
let opFixedRightCleanup = null;
|
|
9998
|
+
const initOpFixedRightResizer = async () => {
|
|
9999
|
+
var _a2, _b, _c;
|
|
10000
|
+
await vueDemi.nextTick();
|
|
10001
|
+
opFixedRightCleanup == null ? void 0 : opFixedRightCleanup();
|
|
10002
|
+
opFixedRightCleanup = null;
|
|
10003
|
+
if (!props.fixedRightDragEnabled)
|
|
10004
|
+
return;
|
|
10005
|
+
const tableEl = (_a2 = elTableRef.value) == null ? void 0 : _a2.$el;
|
|
10006
|
+
if (!tableEl)
|
|
10007
|
+
return;
|
|
10008
|
+
const visibleColumns = tableColumns.value.filter((col) => isShow(col));
|
|
10009
|
+
const opCol = visibleColumns.find((col) => {
|
|
10010
|
+
var _a3;
|
|
10011
|
+
return (col.prop || ((_a3 = col.attr) == null ? void 0 : _a3.prop)) === props.operationPropKey;
|
|
10012
|
+
});
|
|
10013
|
+
if (!opCol || ((_b = opCol == null ? void 0 : opCol.attr) == null ? void 0 : _b.fixed) !== "right")
|
|
10014
|
+
return;
|
|
10015
|
+
const fixedRightHeader = tableEl.querySelector(".el-table__fixed-right .el-table__fixed-header-wrapper thead tr");
|
|
10016
|
+
if (!fixedRightHeader)
|
|
10017
|
+
return;
|
|
10018
|
+
const fixedIndex = visibleColumns.findIndex((col) => {
|
|
10019
|
+
var _a3;
|
|
10020
|
+
return ((_a3 = col == null ? void 0 : col.attr) == null ? void 0 : _a3.fixed) === "right";
|
|
10021
|
+
});
|
|
10022
|
+
if (fixedIndex < 0)
|
|
10023
|
+
return;
|
|
10024
|
+
const th = fixedRightHeader.querySelectorAll("th")[fixedIndex];
|
|
10025
|
+
if (!th)
|
|
10026
|
+
return;
|
|
10027
|
+
const fixedRightRoot = tableEl.querySelector(".el-table__fixed-right");
|
|
10028
|
+
if (!fixedRightRoot)
|
|
10029
|
+
return;
|
|
10030
|
+
const oldOverlay = fixedRightRoot.querySelector('[data-nf-fixed-right-overlay="true"]');
|
|
10031
|
+
if (oldOverlay)
|
|
10032
|
+
oldOverlay.remove();
|
|
10033
|
+
const overlay = document.createElement("div");
|
|
10034
|
+
overlay.setAttribute("data-nf-fixed-right-overlay", "true");
|
|
10035
|
+
overlay.style.position = "relative";
|
|
10036
|
+
overlay.style.width = "100%";
|
|
10037
|
+
overlay.style.height = "100%";
|
|
10038
|
+
overlay.style.pointerEvents = "none";
|
|
10039
|
+
overlay.style.zIndex = "30";
|
|
10040
|
+
fixedRightRoot.appendChild(overlay);
|
|
10041
|
+
const mainHeader = tableEl.querySelector(".el-table__header-wrapper thead tr");
|
|
10042
|
+
const cleanupHideAfter = [];
|
|
10043
|
+
const hideNativeAfter = (el) => {
|
|
10044
|
+
if (!el)
|
|
10045
|
+
return;
|
|
10046
|
+
el.classList.add("nf-table-hide-after");
|
|
10047
|
+
cleanupHideAfter.push(el);
|
|
10048
|
+
};
|
|
10049
|
+
const lastNormalIndex = fixedIndex - 1;
|
|
10050
|
+
if (mainHeader) {
|
|
10051
|
+
const mainThs = mainHeader.querySelectorAll("th");
|
|
10052
|
+
if (lastNormalIndex >= 0 && lastNormalIndex < mainThs.length) {
|
|
10053
|
+
hideNativeAfter(mainThs[lastNormalIndex]);
|
|
10054
|
+
}
|
|
10055
|
+
}
|
|
10056
|
+
hideNativeAfter(th);
|
|
10057
|
+
const handle = document.createElement("div");
|
|
10058
|
+
handle.setAttribute("data-nf-fixed-op-resizer", "true");
|
|
10059
|
+
handle.style.position = "absolute";
|
|
10060
|
+
handle.style.left = "-8px";
|
|
10061
|
+
handle.style.top = "0";
|
|
10062
|
+
handle.style.bottom = "0";
|
|
10063
|
+
handle.style.width = "16px";
|
|
10064
|
+
handle.style.cursor = "col-resize";
|
|
10065
|
+
handle.style.zIndex = "10";
|
|
10066
|
+
handle.style.background = "transparent";
|
|
10067
|
+
handle.style.pointerEvents = "auto";
|
|
10068
|
+
overlay.appendChild(handle);
|
|
10069
|
+
let indicatorLine = null;
|
|
10070
|
+
const columnProp = opCol.prop || ((_c = opCol.attr) == null ? void 0 : _c.prop);
|
|
10071
|
+
const createIndicatorLine = (rect) => {
|
|
10072
|
+
const line = document.createElement("div");
|
|
10073
|
+
line.id = "nf-fixed-right-indicator-line";
|
|
10074
|
+
const tableRect = rect || tableEl.getBoundingClientRect();
|
|
10075
|
+
line.style.cssText = `
|
|
10076
|
+
position: fixed;
|
|
10077
|
+
top: ${tableRect.top}px;
|
|
10078
|
+
left: 0;
|
|
10079
|
+
height: ${tableRect.height}px;
|
|
10080
|
+
width: 2px;
|
|
10081
|
+
background: #409EFF;
|
|
10082
|
+
z-index: 10000;
|
|
10083
|
+
pointer-events: none;
|
|
10084
|
+
display: none;
|
|
10085
|
+
transform: translateX(0px);
|
|
10086
|
+
will-change: transform;
|
|
10087
|
+
`;
|
|
10088
|
+
document.body.appendChild(line);
|
|
10089
|
+
return line;
|
|
10090
|
+
};
|
|
10091
|
+
let pending = false;
|
|
10092
|
+
let cachedRect = null;
|
|
10093
|
+
const onPointerMove = (e) => {
|
|
10094
|
+
e.preventDefault();
|
|
10095
|
+
if (!cachedRect)
|
|
10096
|
+
cachedRect = tableEl.getBoundingClientRect();
|
|
10097
|
+
const tableRect = cachedRect;
|
|
10098
|
+
const leftBound = tableRect.left + (props.dragIndicatorPaddingLeft || 0);
|
|
10099
|
+
const rightBound = tableRect.right - (props.dragIndicatorPaddingRight || 0);
|
|
10100
|
+
let dragX = e.clientX;
|
|
10101
|
+
if (dragX < leftBound)
|
|
10102
|
+
dragX = leftBound;
|
|
10103
|
+
if (dragX > rightBound)
|
|
10104
|
+
dragX = rightBound;
|
|
10105
|
+
if (indicatorLine) {
|
|
10106
|
+
if (!pending) {
|
|
10107
|
+
pending = true;
|
|
10108
|
+
requestAnimationFrame(() => {
|
|
10109
|
+
indicatorLine.style.display = "block";
|
|
10110
|
+
indicatorLine.style.transform = `translateX(${dragX}px)`;
|
|
10111
|
+
pending = false;
|
|
10112
|
+
});
|
|
10113
|
+
}
|
|
10114
|
+
}
|
|
10115
|
+
};
|
|
10116
|
+
const onPointerUp = async (e) => {
|
|
10117
|
+
document.removeEventListener("pointermove", onPointerMove);
|
|
10118
|
+
document.removeEventListener("pointerup", onPointerUp);
|
|
10119
|
+
const dragMask = document.getElementById("nf-fixed-right-drag-mask");
|
|
10120
|
+
dragMask && dragMask.remove();
|
|
10121
|
+
if (indicatorLine) {
|
|
10122
|
+
indicatorLine.remove();
|
|
10123
|
+
indicatorLine = null;
|
|
10124
|
+
}
|
|
10125
|
+
try {
|
|
10126
|
+
handle.releasePointerCapture && handle.releasePointerCapture(e.pointerId);
|
|
10127
|
+
} catch {
|
|
10128
|
+
}
|
|
10129
|
+
try {
|
|
10130
|
+
const tableRect = cachedRect || tableEl.getBoundingClientRect();
|
|
10131
|
+
cachedRect = null;
|
|
10132
|
+
const leftBound = tableRect.left + (props.dragIndicatorPaddingLeft || 0);
|
|
10133
|
+
const rightBound = tableRect.right - (props.dragIndicatorPaddingRight || 0);
|
|
10134
|
+
const clampX = Math.min(Math.max(e.clientX, leftBound), rightBound);
|
|
10135
|
+
const rawWidth = tableRect.right - clampX;
|
|
10136
|
+
const minWidth = getMinWidth(opCol);
|
|
10137
|
+
const finalWidthNum = Math.max(rawWidth, minWidth);
|
|
10138
|
+
if (props.dragCached && columnProp) {
|
|
10139
|
+
const columnCachedData = await commonUtils.CachedManager.asyncCachedGet(`${cStorageKey.value}$drag-column-width`) || {};
|
|
10140
|
+
columnCachedData[columnProp] = finalWidthNum;
|
|
10141
|
+
await commonUtils.CachedManager.asyncCachedSet(`${cStorageKey.value}$drag-column-width`, columnCachedData);
|
|
10142
|
+
}
|
|
10143
|
+
const oldWidth = th.getBoundingClientRect().width;
|
|
10144
|
+
emit("fixedColumnDragEnd", {
|
|
10145
|
+
width: finalWidthNum,
|
|
10146
|
+
oldWidth,
|
|
10147
|
+
prop: columnProp,
|
|
10148
|
+
column: opCol,
|
|
10149
|
+
nativeEvent: e
|
|
10150
|
+
});
|
|
10151
|
+
} catch (error) {
|
|
10152
|
+
console.error("更新列宽失败:", error);
|
|
10153
|
+
}
|
|
10154
|
+
};
|
|
10155
|
+
const onPointerDown = (e) => {
|
|
10156
|
+
e.preventDefault();
|
|
10157
|
+
indicatorLine = createIndicatorLine();
|
|
10158
|
+
const mask = document.createElement("div");
|
|
10159
|
+
mask.id = "nf-fixed-right-drag-mask";
|
|
10160
|
+
mask.style.cssText = "position:fixed;inset:0;cursor:col-resize;z-index:9999;";
|
|
10161
|
+
document.body.appendChild(mask);
|
|
10162
|
+
try {
|
|
10163
|
+
handle.setPointerCapture && handle.setPointerCapture(e.pointerId);
|
|
10164
|
+
} catch {
|
|
10165
|
+
}
|
|
10166
|
+
document.addEventListener("pointermove", onPointerMove, {
|
|
10167
|
+
passive: false
|
|
10168
|
+
});
|
|
10169
|
+
document.addEventListener("pointerup", onPointerUp);
|
|
10170
|
+
};
|
|
10171
|
+
handle.addEventListener("pointerdown", onPointerDown);
|
|
10172
|
+
opFixedRightCleanup = () => {
|
|
10173
|
+
try {
|
|
10174
|
+
handle.removeEventListener("pointerdown", onPointerDown);
|
|
10175
|
+
handle.remove();
|
|
10176
|
+
cleanupHideAfter.forEach((el) => el.classList.remove("nf-table-hide-after"));
|
|
10177
|
+
} catch {
|
|
10178
|
+
}
|
|
10179
|
+
};
|
|
10180
|
+
};
|
|
10181
|
+
vueDemi.watch(() => {
|
|
10182
|
+
var _a2;
|
|
10183
|
+
return [tableColumns.value.length, (_a2 = localShowColumn.value) == null ? void 0 : _a2.length, elTableRefKey.value];
|
|
10184
|
+
}, () => {
|
|
10185
|
+
initOpFixedRightResizer();
|
|
10186
|
+
});
|
|
10187
|
+
vueDemi.watch(() => props.fixedRightDragEnabled, () => {
|
|
10188
|
+
initOpFixedRightResizer();
|
|
10189
|
+
});
|
|
9979
10190
|
async function clearDragCached() {
|
|
9980
10191
|
await commonUtils.CachedManager.asyncCachedSet(`${cStorageKey.value}$drag-column-width`, null);
|
|
9981
10192
|
}
|
|
@@ -10104,6 +10315,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
10104
10315
|
});
|
|
10105
10316
|
if (cInitSearchApi.value)
|
|
10106
10317
|
onNfSearchFormSearch();
|
|
10318
|
+
initOpFixedRightResizer();
|
|
10107
10319
|
});
|
|
10108
10320
|
const nfTableBorder = window.nfTableBorder;
|
|
10109
10321
|
const nfSearchFormModel = vueDemi.computed({
|
|
@@ -9406,6 +9406,24 @@ __sfc_main.props = {
|
|
|
9406
9406
|
required: false,
|
|
9407
9407
|
type: Object,
|
|
9408
9408
|
default: () => ({})
|
|
9409
|
+
},
|
|
9410
|
+
dragIndicatorPaddingLeft: {
|
|
9411
|
+
key: "dragIndicatorPaddingLeft",
|
|
9412
|
+
required: false,
|
|
9413
|
+
type: Number,
|
|
9414
|
+
default: 120
|
|
9415
|
+
},
|
|
9416
|
+
dragIndicatorPaddingRight: {
|
|
9417
|
+
key: "dragIndicatorPaddingRight",
|
|
9418
|
+
required: false,
|
|
9419
|
+
type: Number,
|
|
9420
|
+
default: 120
|
|
9421
|
+
},
|
|
9422
|
+
fixedRightDragEnabled: {
|
|
9423
|
+
key: "fixedRightDragEnabled",
|
|
9424
|
+
required: false,
|
|
9425
|
+
type: Boolean,
|
|
9426
|
+
default: false
|
|
9409
9427
|
}
|
|
9410
9428
|
};
|
|
9411
9429
|
__sfc_main.setup = (__props, __ctx) => {
|
|
@@ -9974,6 +9992,199 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
9974
9992
|
resizeTable();
|
|
9975
9993
|
await ((_b = (_a2 = props.tableEvents)["header-dragend"]) == null ? void 0 : _b.call(_a2, newWidth, oldWidth, column, event));
|
|
9976
9994
|
};
|
|
9995
|
+
let opFixedRightCleanup = null;
|
|
9996
|
+
const initOpFixedRightResizer = async () => {
|
|
9997
|
+
var _a2, _b, _c;
|
|
9998
|
+
await nextTick();
|
|
9999
|
+
opFixedRightCleanup == null ? void 0 : opFixedRightCleanup();
|
|
10000
|
+
opFixedRightCleanup = null;
|
|
10001
|
+
if (!props.fixedRightDragEnabled)
|
|
10002
|
+
return;
|
|
10003
|
+
const tableEl = (_a2 = elTableRef.value) == null ? void 0 : _a2.$el;
|
|
10004
|
+
if (!tableEl)
|
|
10005
|
+
return;
|
|
10006
|
+
const visibleColumns = tableColumns.value.filter((col) => isShow(col));
|
|
10007
|
+
const opCol = visibleColumns.find((col) => {
|
|
10008
|
+
var _a3;
|
|
10009
|
+
return (col.prop || ((_a3 = col.attr) == null ? void 0 : _a3.prop)) === props.operationPropKey;
|
|
10010
|
+
});
|
|
10011
|
+
if (!opCol || ((_b = opCol == null ? void 0 : opCol.attr) == null ? void 0 : _b.fixed) !== "right")
|
|
10012
|
+
return;
|
|
10013
|
+
const fixedRightHeader = tableEl.querySelector(".el-table__fixed-right .el-table__fixed-header-wrapper thead tr");
|
|
10014
|
+
if (!fixedRightHeader)
|
|
10015
|
+
return;
|
|
10016
|
+
const fixedIndex = visibleColumns.findIndex((col) => {
|
|
10017
|
+
var _a3;
|
|
10018
|
+
return ((_a3 = col == null ? void 0 : col.attr) == null ? void 0 : _a3.fixed) === "right";
|
|
10019
|
+
});
|
|
10020
|
+
if (fixedIndex < 0)
|
|
10021
|
+
return;
|
|
10022
|
+
const th = fixedRightHeader.querySelectorAll("th")[fixedIndex];
|
|
10023
|
+
if (!th)
|
|
10024
|
+
return;
|
|
10025
|
+
const fixedRightRoot = tableEl.querySelector(".el-table__fixed-right");
|
|
10026
|
+
if (!fixedRightRoot)
|
|
10027
|
+
return;
|
|
10028
|
+
const oldOverlay = fixedRightRoot.querySelector('[data-nf-fixed-right-overlay="true"]');
|
|
10029
|
+
if (oldOverlay)
|
|
10030
|
+
oldOverlay.remove();
|
|
10031
|
+
const overlay = document.createElement("div");
|
|
10032
|
+
overlay.setAttribute("data-nf-fixed-right-overlay", "true");
|
|
10033
|
+
overlay.style.position = "relative";
|
|
10034
|
+
overlay.style.width = "100%";
|
|
10035
|
+
overlay.style.height = "100%";
|
|
10036
|
+
overlay.style.pointerEvents = "none";
|
|
10037
|
+
overlay.style.zIndex = "30";
|
|
10038
|
+
fixedRightRoot.appendChild(overlay);
|
|
10039
|
+
const mainHeader = tableEl.querySelector(".el-table__header-wrapper thead tr");
|
|
10040
|
+
const cleanupHideAfter = [];
|
|
10041
|
+
const hideNativeAfter = (el) => {
|
|
10042
|
+
if (!el)
|
|
10043
|
+
return;
|
|
10044
|
+
el.classList.add("nf-table-hide-after");
|
|
10045
|
+
cleanupHideAfter.push(el);
|
|
10046
|
+
};
|
|
10047
|
+
const lastNormalIndex = fixedIndex - 1;
|
|
10048
|
+
if (mainHeader) {
|
|
10049
|
+
const mainThs = mainHeader.querySelectorAll("th");
|
|
10050
|
+
if (lastNormalIndex >= 0 && lastNormalIndex < mainThs.length) {
|
|
10051
|
+
hideNativeAfter(mainThs[lastNormalIndex]);
|
|
10052
|
+
}
|
|
10053
|
+
}
|
|
10054
|
+
hideNativeAfter(th);
|
|
10055
|
+
const handle = document.createElement("div");
|
|
10056
|
+
handle.setAttribute("data-nf-fixed-op-resizer", "true");
|
|
10057
|
+
handle.style.position = "absolute";
|
|
10058
|
+
handle.style.left = "-8px";
|
|
10059
|
+
handle.style.top = "0";
|
|
10060
|
+
handle.style.bottom = "0";
|
|
10061
|
+
handle.style.width = "16px";
|
|
10062
|
+
handle.style.cursor = "col-resize";
|
|
10063
|
+
handle.style.zIndex = "10";
|
|
10064
|
+
handle.style.background = "transparent";
|
|
10065
|
+
handle.style.pointerEvents = "auto";
|
|
10066
|
+
overlay.appendChild(handle);
|
|
10067
|
+
let indicatorLine = null;
|
|
10068
|
+
const columnProp = opCol.prop || ((_c = opCol.attr) == null ? void 0 : _c.prop);
|
|
10069
|
+
const createIndicatorLine = (rect) => {
|
|
10070
|
+
const line = document.createElement("div");
|
|
10071
|
+
line.id = "nf-fixed-right-indicator-line";
|
|
10072
|
+
const tableRect = rect || tableEl.getBoundingClientRect();
|
|
10073
|
+
line.style.cssText = `
|
|
10074
|
+
position: fixed;
|
|
10075
|
+
top: ${tableRect.top}px;
|
|
10076
|
+
left: 0;
|
|
10077
|
+
height: ${tableRect.height}px;
|
|
10078
|
+
width: 2px;
|
|
10079
|
+
background: #409EFF;
|
|
10080
|
+
z-index: 10000;
|
|
10081
|
+
pointer-events: none;
|
|
10082
|
+
display: none;
|
|
10083
|
+
transform: translateX(0px);
|
|
10084
|
+
will-change: transform;
|
|
10085
|
+
`;
|
|
10086
|
+
document.body.appendChild(line);
|
|
10087
|
+
return line;
|
|
10088
|
+
};
|
|
10089
|
+
let pending = false;
|
|
10090
|
+
let cachedRect = null;
|
|
10091
|
+
const onPointerMove = (e) => {
|
|
10092
|
+
e.preventDefault();
|
|
10093
|
+
if (!cachedRect)
|
|
10094
|
+
cachedRect = tableEl.getBoundingClientRect();
|
|
10095
|
+
const tableRect = cachedRect;
|
|
10096
|
+
const leftBound = tableRect.left + (props.dragIndicatorPaddingLeft || 0);
|
|
10097
|
+
const rightBound = tableRect.right - (props.dragIndicatorPaddingRight || 0);
|
|
10098
|
+
let dragX = e.clientX;
|
|
10099
|
+
if (dragX < leftBound)
|
|
10100
|
+
dragX = leftBound;
|
|
10101
|
+
if (dragX > rightBound)
|
|
10102
|
+
dragX = rightBound;
|
|
10103
|
+
if (indicatorLine) {
|
|
10104
|
+
if (!pending) {
|
|
10105
|
+
pending = true;
|
|
10106
|
+
requestAnimationFrame(() => {
|
|
10107
|
+
indicatorLine.style.display = "block";
|
|
10108
|
+
indicatorLine.style.transform = `translateX(${dragX}px)`;
|
|
10109
|
+
pending = false;
|
|
10110
|
+
});
|
|
10111
|
+
}
|
|
10112
|
+
}
|
|
10113
|
+
};
|
|
10114
|
+
const onPointerUp = async (e) => {
|
|
10115
|
+
document.removeEventListener("pointermove", onPointerMove);
|
|
10116
|
+
document.removeEventListener("pointerup", onPointerUp);
|
|
10117
|
+
const dragMask = document.getElementById("nf-fixed-right-drag-mask");
|
|
10118
|
+
dragMask && dragMask.remove();
|
|
10119
|
+
if (indicatorLine) {
|
|
10120
|
+
indicatorLine.remove();
|
|
10121
|
+
indicatorLine = null;
|
|
10122
|
+
}
|
|
10123
|
+
try {
|
|
10124
|
+
handle.releasePointerCapture && handle.releasePointerCapture(e.pointerId);
|
|
10125
|
+
} catch {
|
|
10126
|
+
}
|
|
10127
|
+
try {
|
|
10128
|
+
const tableRect = cachedRect || tableEl.getBoundingClientRect();
|
|
10129
|
+
cachedRect = null;
|
|
10130
|
+
const leftBound = tableRect.left + (props.dragIndicatorPaddingLeft || 0);
|
|
10131
|
+
const rightBound = tableRect.right - (props.dragIndicatorPaddingRight || 0);
|
|
10132
|
+
const clampX = Math.min(Math.max(e.clientX, leftBound), rightBound);
|
|
10133
|
+
const rawWidth = tableRect.right - clampX;
|
|
10134
|
+
const minWidth = getMinWidth(opCol);
|
|
10135
|
+
const finalWidthNum = Math.max(rawWidth, minWidth);
|
|
10136
|
+
if (props.dragCached && columnProp) {
|
|
10137
|
+
const columnCachedData = await CachedManager.asyncCachedGet(`${cStorageKey.value}$drag-column-width`) || {};
|
|
10138
|
+
columnCachedData[columnProp] = finalWidthNum;
|
|
10139
|
+
await CachedManager.asyncCachedSet(`${cStorageKey.value}$drag-column-width`, columnCachedData);
|
|
10140
|
+
}
|
|
10141
|
+
const oldWidth = th.getBoundingClientRect().width;
|
|
10142
|
+
emit("fixedColumnDragEnd", {
|
|
10143
|
+
width: finalWidthNum,
|
|
10144
|
+
oldWidth,
|
|
10145
|
+
prop: columnProp,
|
|
10146
|
+
column: opCol,
|
|
10147
|
+
nativeEvent: e
|
|
10148
|
+
});
|
|
10149
|
+
} catch (error) {
|
|
10150
|
+
console.error("更新列宽失败:", error);
|
|
10151
|
+
}
|
|
10152
|
+
};
|
|
10153
|
+
const onPointerDown = (e) => {
|
|
10154
|
+
e.preventDefault();
|
|
10155
|
+
indicatorLine = createIndicatorLine();
|
|
10156
|
+
const mask = document.createElement("div");
|
|
10157
|
+
mask.id = "nf-fixed-right-drag-mask";
|
|
10158
|
+
mask.style.cssText = "position:fixed;inset:0;cursor:col-resize;z-index:9999;";
|
|
10159
|
+
document.body.appendChild(mask);
|
|
10160
|
+
try {
|
|
10161
|
+
handle.setPointerCapture && handle.setPointerCapture(e.pointerId);
|
|
10162
|
+
} catch {
|
|
10163
|
+
}
|
|
10164
|
+
document.addEventListener("pointermove", onPointerMove, {
|
|
10165
|
+
passive: false
|
|
10166
|
+
});
|
|
10167
|
+
document.addEventListener("pointerup", onPointerUp);
|
|
10168
|
+
};
|
|
10169
|
+
handle.addEventListener("pointerdown", onPointerDown);
|
|
10170
|
+
opFixedRightCleanup = () => {
|
|
10171
|
+
try {
|
|
10172
|
+
handle.removeEventListener("pointerdown", onPointerDown);
|
|
10173
|
+
handle.remove();
|
|
10174
|
+
cleanupHideAfter.forEach((el) => el.classList.remove("nf-table-hide-after"));
|
|
10175
|
+
} catch {
|
|
10176
|
+
}
|
|
10177
|
+
};
|
|
10178
|
+
};
|
|
10179
|
+
watch(() => {
|
|
10180
|
+
var _a2;
|
|
10181
|
+
return [tableColumns.value.length, (_a2 = localShowColumn.value) == null ? void 0 : _a2.length, elTableRefKey.value];
|
|
10182
|
+
}, () => {
|
|
10183
|
+
initOpFixedRightResizer();
|
|
10184
|
+
});
|
|
10185
|
+
watch(() => props.fixedRightDragEnabled, () => {
|
|
10186
|
+
initOpFixedRightResizer();
|
|
10187
|
+
});
|
|
9977
10188
|
async function clearDragCached() {
|
|
9978
10189
|
await CachedManager.asyncCachedSet(`${cStorageKey.value}$drag-column-width`, null);
|
|
9979
10190
|
}
|
|
@@ -10102,6 +10313,7 @@ __sfc_main.setup = (__props, __ctx) => {
|
|
|
10102
10313
|
});
|
|
10103
10314
|
if (cInitSearchApi.value)
|
|
10104
10315
|
onNfSearchFormSearch();
|
|
10316
|
+
initOpFixedRightResizer();
|
|
10105
10317
|
});
|
|
10106
10318
|
const nfTableBorder = window.nfTableBorder;
|
|
10107
10319
|
const nfSearchFormModel = computed({
|
package/lib/nf-table.vue.d.ts
CHANGED
|
@@ -79,6 +79,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
79
79
|
virtualized?: boolean | undefined;
|
|
80
80
|
virtualTableData?: Record<string, any>[] | undefined;
|
|
81
81
|
virtualProps?: Record<string, any> | undefined;
|
|
82
|
+
dragIndicatorPaddingLeft?: number | undefined;
|
|
83
|
+
dragIndicatorPaddingRight?: number | undefined;
|
|
84
|
+
fixedRightDragEnabled?: boolean | undefined;
|
|
82
85
|
}>, {
|
|
83
86
|
viewIdentity: string;
|
|
84
87
|
dragCached: boolean;
|
|
@@ -156,6 +159,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
156
159
|
virtualized: boolean;
|
|
157
160
|
virtualTableData: () => never[];
|
|
158
161
|
virtualProps: () => {};
|
|
162
|
+
dragIndicatorPaddingLeft: number;
|
|
163
|
+
dragIndicatorPaddingRight: number;
|
|
164
|
+
fixedRightDragEnabled: boolean;
|
|
159
165
|
}>, {
|
|
160
166
|
clearFilter: () => void;
|
|
161
167
|
sort: (prop: any, order: any) => void;
|
|
@@ -262,6 +268,13 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
262
268
|
data: Record<string, any>;
|
|
263
269
|
callback: Function;
|
|
264
270
|
}) => void;
|
|
271
|
+
fixedColumnDragEnd: (event: {
|
|
272
|
+
width: number;
|
|
273
|
+
oldWidth: number;
|
|
274
|
+
prop?: string | undefined;
|
|
275
|
+
column?: any;
|
|
276
|
+
nativeEvent?: Event | undefined;
|
|
277
|
+
}) => void;
|
|
265
278
|
}, string, Readonly<import("vue-demi").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
266
279
|
viewIdentity?: string | undefined;
|
|
267
280
|
data?: Record<string, any>[] | undefined;
|
|
@@ -341,6 +354,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
341
354
|
virtualized?: boolean | undefined;
|
|
342
355
|
virtualTableData?: Record<string, any>[] | undefined;
|
|
343
356
|
virtualProps?: Record<string, any> | undefined;
|
|
357
|
+
dragIndicatorPaddingLeft?: number | undefined;
|
|
358
|
+
dragIndicatorPaddingRight?: number | undefined;
|
|
359
|
+
fixedRightDragEnabled?: boolean | undefined;
|
|
344
360
|
}>, {
|
|
345
361
|
viewIdentity: string;
|
|
346
362
|
dragCached: boolean;
|
|
@@ -418,6 +434,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
418
434
|
virtualized: boolean;
|
|
419
435
|
virtualTableData: () => never[];
|
|
420
436
|
virtualProps: () => {};
|
|
437
|
+
dragIndicatorPaddingLeft: number;
|
|
438
|
+
dragIndicatorPaddingRight: number;
|
|
439
|
+
fixedRightDragEnabled: boolean;
|
|
421
440
|
}>>>, {
|
|
422
441
|
background: string;
|
|
423
442
|
columns: NfTableColumnAttributes[] | any;
|
|
@@ -495,6 +514,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
|
|
|
495
514
|
virtualized: boolean;
|
|
496
515
|
virtualTableData: Record<string, any>[];
|
|
497
516
|
virtualProps: Record<string, any>;
|
|
517
|
+
dragIndicatorPaddingLeft: number;
|
|
518
|
+
dragIndicatorPaddingRight: number;
|
|
519
|
+
fixedRightDragEnabled: boolean;
|
|
498
520
|
}>, Partial<Record<any, (_: {
|
|
499
521
|
slot: any;
|
|
500
522
|
}) => any>> & Partial<Record<any, (_: {
|
|
@@ -260,7 +260,7 @@ const setFields = async(tableColumns) => {
|
|
|
260
260
|
/**
|
|
261
261
|
* 更新已选列表
|
|
262
262
|
*/
|
|
263
|
-
const checkedCount = ref<string[]>([]) // 勾选的
|
|
263
|
+
const checkedCount = ref<string[]>([]) // 勾选的prop
|
|
264
264
|
|
|
265
265
|
const showCheckCount = computed(() => {
|
|
266
266
|
return checkedCount.value.filter(item => !(item === 'selection' || item === props.operationPropKey)).length
|