@94ai/nf-table 9.0.0 → 10.0.0

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.
@@ -1024,7 +1024,7 @@
1024
1024
  return {
1025
1025
  ...(item.events || {}),
1026
1026
  click: (...args) => {
1027
- item.events?.click(args);
1027
+ item.events?.click?.(args);
1028
1028
  item.onClick?.(scope.row, scope)
1029
1029
  }
1030
1030
  }
@@ -1075,10 +1075,6 @@
1075
1075
  return key
1076
1076
  })
1077
1077
 
1078
- const cStorageKeyViewIdentity = computed(() => {
1079
- return 'nf-table-view-identity'
1080
- })
1081
-
1082
1078
  const checkViewIdentityChange = async () => {
1083
1079
  // const userId = (window as any).userId
1084
1080
  // const viewField = (window as any).viewField
@@ -1437,7 +1433,7 @@
1437
1433
  columns.every(i => {
1438
1434
  if (i.prop === key) {
1439
1435
  i.initHidden = state.initHidden
1440
- i.attr ? i.attr['fixed'] = state.fixed : i.attr = { fixed: state.fixed }
1436
+ i.attr['fixed'] = state.fixed
1441
1437
  i._index = state.index
1442
1438
  if (maxIndex < state.index) {
1443
1439
  maxIndex = state.index
@@ -1464,7 +1460,7 @@
1464
1460
  console.log(e)
1465
1461
  }
1466
1462
  }
1467
- tableColumns.value = columns.sort((a, b) => a._index! - b._index! < 0 ? -1 : a._index! - b._index! > 0 ? 1 : 0)
1463
+ tableColumns.value = columns.sort((a, b) => a._index! - b._index!)
1468
1464
  nextTick(() => {
1469
1465
  props.columns._skip = false
1470
1466
  })
@@ -1555,7 +1551,7 @@
1555
1551
  }
1556
1552
 
1557
1553
  const showPage = computed(() => {
1558
- return showData.value.length > props.pageAttrs['page-size']!
1554
+ return props.data.length > props.pageAttrs['page-size']!
1559
1555
  })
1560
1556
 
1561
1557
  const renderPage = computed(() => {
@@ -1763,6 +1759,10 @@
1763
1759
 
1764
1760
  // 为固定在右侧的"操作"列添加拖拽句柄(脱离文档流也可拖拽)
1765
1761
  let opFixedRightCleanup: Function | null = null
1762
+ onBeforeUnmount(() => {
1763
+ opFixedRightCleanup?.()
1764
+ opFixedRightCleanup = null
1765
+ })
1766
1766
  const initOpFixedRightResizer = async () => {
1767
1767
  await nextTick()
1768
1768
  opFixedRightCleanup?.(); opFixedRightCleanup = null
@@ -1776,19 +1776,17 @@
1776
1776
  const opCol = visibleColumns.find(col => (col.prop || col.attr?.prop) === props.operationPropKey)
1777
1777
  if (!opCol || opCol?.attr?.fixed !== 'right') return
1778
1778
 
1779
- // 固定右侧表头 th 列集合(仅包含 fixed right 的列)
1779
+ // Element UI 的固定表头保留全部列的 th,非固定列由样式隐藏。
1780
1780
  const fixedRightHeader = tableEl.querySelector('.el-table__fixed-right .el-table__fixed-header-wrapper thead tr') as HTMLElement
1781
1781
 
1782
1782
  if (!fixedRightHeader) return
1783
- // 仅包含 fixed='right' 的列,用于定位对应 th
1783
+ // 使用可见列中的顺序定位固定表头中的 th。
1784
1784
  const fixedIndex = visibleColumns.findIndex(col => col?.attr?.fixed === 'right')
1785
- if (fixedIndex < 0) return
1786
1785
  const th = fixedRightHeader.querySelectorAll('th')[fixedIndex] as HTMLElement
1787
1786
  if (!th) return
1788
1787
 
1789
1788
  // 在 .el-table__fixed-right 下创建覆盖层(宽高自适应、相对定位),句柄相对该层绝对定位到左侧
1790
1789
  const fixedRightRoot = tableEl.querySelector('.el-table__fixed-right') as HTMLElement
1791
- if (!fixedRightRoot) return
1792
1790
  // 清理历史覆盖层
1793
1791
  const oldOverlay = fixedRightRoot.querySelector('[data-nf-fixed-right-overlay="true"]') as HTMLElement
1794
1792
  if (oldOverlay) oldOverlay.remove()
@@ -1804,8 +1802,7 @@
1804
1802
  // 隐藏固定列相邻列与固定列本身的原生拖拽 after,避免干扰
1805
1803
  const mainHeader = tableEl.querySelector('.el-table__header-wrapper thead tr') as HTMLElement
1806
1804
  const cleanupHideAfter: HTMLElement[] = []
1807
- const hideNativeAfter = (el?: HTMLElement) => {
1808
- if (!el) return
1805
+ const hideNativeAfter = (el: HTMLElement) => {
1809
1806
  el.classList.add('nf-table-hide-after')
1810
1807
  cleanupHideAfter.push(el)
1811
1808
  }
@@ -1864,6 +1861,7 @@
1864
1861
  // 拖动时显示指示线
1865
1862
  // 拖动时显示指示线(使用 rAF + transform 提升性能)
1866
1863
  let pending = false
1864
+ let indicatorFrame = 0
1867
1865
  let cachedRect: DOMRect | null = null
1868
1866
  const onPointerMove = (e: PointerEvent) => {
1869
1867
  e.preventDefault()
@@ -1880,7 +1878,8 @@
1880
1878
  if (indicatorLine) {
1881
1879
  if (!pending) {
1882
1880
  pending = true
1883
- requestAnimationFrame(() => {
1881
+ indicatorFrame = requestAnimationFrame(() => {
1882
+ indicatorFrame = 0
1884
1883
  indicatorLine!.style.display = 'block'
1885
1884
  indicatorLine!.style.transform = `translateX(${dragX}px)`
1886
1885
  pending = false
@@ -1889,7 +1888,10 @@
1889
1888
  }
1890
1889
  }
1891
1890
 
1892
- const onPointerUp = async (e: PointerEvent) => {
1891
+ const stopPointerDrag = () => {
1892
+ if (indicatorFrame) cancelAnimationFrame(indicatorFrame)
1893
+ indicatorFrame = 0
1894
+ pending = false
1893
1895
  document.removeEventListener('pointermove', onPointerMove)
1894
1896
  document.removeEventListener('pointerup', onPointerUp)
1895
1897
  const dragMask = document.getElementById('nf-fixed-right-drag-mask')
@@ -1900,6 +1902,10 @@
1900
1902
  indicatorLine.remove()
1901
1903
  indicatorLine = null
1902
1904
  }
1905
+ }
1906
+
1907
+ const onPointerUp = async (e: PointerEvent) => {
1908
+ stopPointerDrag()
1903
1909
 
1904
1910
  try { handle.releasePointerCapture && handle.releasePointerCapture(e.pointerId) } catch {}
1905
1911
 
@@ -1950,6 +1956,7 @@
1950
1956
  handle.addEventListener('pointerdown', onPointerDown)
1951
1957
  opFixedRightCleanup = () => {
1952
1958
  try {
1959
+ stopPointerDrag()
1953
1960
  handle.removeEventListener('pointerdown', onPointerDown)
1954
1961
  handle.remove()
1955
1962
  // 恢复原生 after
@@ -2131,10 +2138,7 @@
2131
2138
  const nfTableBorder = (window as any).nfTableBorder
2132
2139
 
2133
2140
  /** nfSearchForm表单数据(如果存在<nf-search-form>) */
2134
- const nfSearchFormModel = computed({
2135
- get: () => nfSearchFormRef.value?.nfSearchFormModel || {},
2136
- set: formData => nfSearchFormRef.value?.setNfSearchFormModel?.(formData)
2137
- })
2141
+ const nfSearchFormModel = computed(() => nfSearchFormRef.value?.nfSearchFormModel || {})
2138
2142
 
2139
2143
  defineExpose({
2140
2144
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-table",
3
- "version": "9.0.0",
3
+ "version": "10.0.0",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -14,17 +14,18 @@
14
14
  "url": "http://gitlab.94ai.pro/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/common-utils": "^9.0.0",
18
- "@94ai/nf-button": "^9.0.0",
19
- "@94ai/nf-drawer": "^9.0.0",
20
- "@94ai/nf-message": "^9.0.0",
21
- "@94ai/nf-search-form": "^9.0.0",
22
- "@94ai/nf-tag": "^9.0.0",
23
- "@94ai/nf-theme-chalk": "^9.0.0",
17
+ "@94ai/common-utils": "^10.0.0",
18
+ "@94ai/nf-button": "^10.0.0",
19
+ "@94ai/nf-drawer": "^10.0.0",
20
+ "@94ai/nf-message": "^10.0.0",
21
+ "@94ai/nf-search-form": "^10.0.0",
22
+ "@94ai/nf-tag": "^10.0.0",
23
+ "@94ai/nf-theme-chalk": "^10.0.0",
24
24
  "idb-keyval": "^6.2.1",
25
25
  "vue-demi": "^0.14.5",
26
26
  "vue-router": "3.6.4",
27
- "vuedraggable": "^2.24.3"
27
+ "vuedraggable": "^2.24.3",
28
+ "@94ai/vue2-runtime-helpers": "1.0.1"
28
29
  },
29
30
  "peerDependenciesMeta": {
30
31
  "@vue/composition-api": {
@@ -33,11 +34,10 @@
33
34
  },
34
35
  "peerDependencies": {
35
36
  "@vue/composition-api": "^1.0.0-rc.1",
36
- "element-ui": ">=2.13.2",
37
- "vue": "^2.0.0 || >=3.0.0"
37
+ "vue": "^2.0.0 || >=3.0.0",
38
+ "element-ui": ">=2.13.2"
38
39
  },
39
40
  "types": "lib/index.d.ts",
40
41
  "main": "lib/nf-table.cjs.js",
41
- "module": "lib/nf-table.esm-bundler.js",
42
- "gitHead": "afe3016f0e42dfb7fedf6cbbe400ec08bf4b8662"
42
+ "module": "lib/nf-table.esm-bundler.js"
43
43
  }