@94ai/nf-table 8.3.4 → 8.3.7

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 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, (_: {
@@ -38,7 +38,7 @@ declare const _default: import("vue-demi").DefineComponent<__VLS_WithDefaults<__
38
38
  isIndeterminate: import("vue-demi").Ref<boolean>;
39
39
  columnName: import("vue-demi").Ref<string>;
40
40
  searchValue: Record<string, any>[];
41
- checkedCount: import("vue-demi").Ref<number>;
41
+ checkedCount: import("vue-demi").Ref<string[]>;
42
42
  fields: import("vue-demi").Ref<{
43
43
  name: string;
44
44
  list: Record<string, any>[];
@@ -5360,7 +5360,7 @@ __sfc_main$1.setup = (__props, __ctx) => {
5360
5360
  updateColumn();
5361
5361
  if (currentTable.value.every((i) => !i.initHidden)) {
5362
5362
  showColumn.value = currentTable.value.map((i) => i.prop);
5363
- checkedCount.value = list.length;
5363
+ checkedCount.value = list.map((item) => item.prop || item.type);
5364
5364
  checkAll2.value = true;
5365
5365
  isIndeterminate.value = false;
5366
5366
  }
@@ -5387,7 +5387,10 @@ __sfc_main$1.setup = (__props, __ctx) => {
5387
5387
  }
5388
5388
  fields.value = items;
5389
5389
  };
5390
- const checkedCount = vueDemi.ref(0);
5390
+ const checkedCount = vueDemi.ref([]);
5391
+ const showCheckCount = vueDemi.computed(() => {
5392
+ return checkedCount.value.filter((item) => !(item === "selection" || item === props.operationPropKey)).length;
5393
+ });
5391
5394
  const updateColumn = () => {
5392
5395
  fixedColumn.value = [];
5393
5396
  unFixedColumn.value = [];
@@ -5427,14 +5430,14 @@ __sfc_main$1.setup = (__props, __ctx) => {
5427
5430
  const updateCheckStatus = () => {
5428
5431
  showColumn.value = currentTable.value.filter((i) => !i.initHidden).map((item) => item.prop);
5429
5432
  if (columnName.value && fields.value.length) {
5430
- checkedCount.value = searchValue.filter((i) => !i.initHidden).length;
5431
- checkAll2.value = checkedCount.value === searchValue.length;
5432
- isIndeterminate.value = checkedCount.value > 0 && checkedCount.value < searchValue.length;
5433
+ checkedCount.value = searchValue.filter((i) => !i.initHidden).map((item) => item.prop || item.type);
5434
+ checkAll2.value = checkedCount.value.length === searchValue.length;
5435
+ isIndeterminate.value = checkedCount.value.length > 0 && checkedCount.value.length < searchValue.length;
5433
5436
  return;
5434
5437
  }
5435
- checkedCount.value = showColumn.value.length;
5436
- checkAll2.value = checkedCount.value === currentTable.value.length;
5437
- isIndeterminate.value = checkedCount.value > 0 && checkedCount.value < currentTable.value.length;
5438
+ checkedCount.value = showColumn.value;
5439
+ checkAll2.value = checkedCount.value.length === currentTable.value.length;
5440
+ isIndeterminate.value = checkedCount.value.length > 0 && checkedCount.value.length < currentTable.value.length;
5438
5441
  };
5439
5442
  const columnName = vueDemi.ref("");
5440
5443
  let searchValue = [];
@@ -5619,7 +5622,7 @@ __sfc_main$1.setup = (__props, __ctx) => {
5619
5622
  fixedColumn,
5620
5623
  unFixedColumn,
5621
5624
  fields,
5622
- checkedCount,
5625
+ showCheckCount,
5623
5626
  columnName,
5624
5627
  handleSearch,
5625
5628
  checkAll: checkAll2,
@@ -5696,7 +5699,7 @@ var _sfc_render$2 = function render2() {
5696
5699
  },
5697
5700
  expression: "checkAll"
5698
5701
  }
5699
- }, [_vm._v(_vm._s(_vm.getAllCheckDesc(_vm.checkedCount)))]) : _vm._e()], 1), _c("div", {
5702
+ }, [_vm._v(_vm._s(_vm.getAllCheckDesc(_vm.showCheckCount)))]) : _vm._e()], 1), _c("div", {
5700
5703
  staticClass: "nf-select-column"
5701
5704
  }, _vm._l(_vm.fields, function(item, index2) {
5702
5705
  return _c("div", {
@@ -9405,6 +9408,24 @@ __sfc_main.props = {
9405
9408
  required: false,
9406
9409
  type: Object,
9407
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
9408
9429
  }
9409
9430
  };
9410
9431
  __sfc_main.setup = (__props, __ctx) => {
@@ -9973,6 +9994,199 @@ __sfc_main.setup = (__props, __ctx) => {
9973
9994
  resizeTable();
9974
9995
  await ((_b = (_a2 = props.tableEvents)["header-dragend"]) == null ? void 0 : _b.call(_a2, newWidth, oldWidth, column, event));
9975
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
+ });
9976
10190
  async function clearDragCached() {
9977
10191
  await commonUtils.CachedManager.asyncCachedSet(`${cStorageKey.value}$drag-column-width`, null);
9978
10192
  }
@@ -10101,6 +10315,7 @@ __sfc_main.setup = (__props, __ctx) => {
10101
10315
  });
10102
10316
  if (cInitSearchApi.value)
10103
10317
  onNfSearchFormSearch();
10318
+ initOpFixedRightResizer();
10104
10319
  });
10105
10320
  const nfTableBorder = window.nfTableBorder;
10106
10321
  const nfSearchFormModel = vueDemi.computed({