@sheinx/hooks 3.3.3-beta.1 → 3.3.3-beta.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA8CX,MAAM,UAAU,MAAM;;;;;;;;CAkO5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA8CX,MAAM,UAAU,MAAM;;;;;;;;CAmO5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -337,12 +337,13 @@ var useTableLayout = function useTableLayout(props) {
337
337
  getColgroup(adjust === 'drag');
338
338
  setAdjust(false);
339
339
  } else {
340
- checkFloat();
340
+ // checkFloat();
341
341
  // checkScroll();
342
342
  // 拖拽列会导致 scrollWidth 变化
343
343
  syncScrollWidth();
344
344
  }
345
345
  checkScroll();
346
+ checkFloat();
346
347
  }, [colgroup]);
347
348
  return {
348
349
  isScrollX: !!isScrollX,
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { TableFormatColumn } from './use-table.type';
2
3
  interface UseTableVirtualProps {
3
4
  data: any[];
4
5
  rowsInView: number;
@@ -8,6 +9,7 @@ interface UseTableVirtualProps {
8
9
  scrollLeft?: number;
9
10
  disabled?: boolean;
10
11
  isRtl?: boolean;
12
+ columns: TableFormatColumn<any>[];
11
13
  }
12
14
  declare const useTableVirtual: (props: UseTableVirtualProps) => {
13
15
  scrollHeight: number;
@@ -1 +1 @@
1
- {"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAGA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;oBA+GpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAtEuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BAkInB,MAAM;CAmElD,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;oBAiLpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAnFuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BA+InB,MAAM;CAmElD,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -39,6 +39,58 @@ var useTableVirtual = function useTableVirtual(props) {
39
39
  setOffsetY = _useState10[1];
40
40
  var rowsInView = props.rowsInView === 0 ? props.data.length : props.rowsInView;
41
41
  var sleft = props.scrollLeft !== undefined ? props.scrollLeft : innerLeft;
42
+ var rowSpanInfos = (0, _react.useMemo)(function () {
43
+ var rowSpanColumns = props.columns.filter(function (col) {
44
+ return typeof col.rowSpan === 'function';
45
+ });
46
+ if (rowSpanColumns.length === 0) return;
47
+ var _rowSpanInfos = [];
48
+ var totalLength = props.data.length;
49
+ var _loop = function _loop(i) {
50
+ var startIndex = i;
51
+ var rowSpanInfo = rowSpanColumns.map(function (col) {
52
+ var rowSpan = col.rowSpan;
53
+ function getRowSpanCount(index, _count) {
54
+ var count = _count;
55
+ if (index === totalLength - 1) return count;
56
+ var prevRowData = props.data[index];
57
+ var nextRowData = props.data[index + 1];
58
+ if (rowSpan(prevRowData, nextRowData)) {
59
+ count = count + 1;
60
+ getRowSpanCount(index + 1, count);
61
+ }
62
+ return count;
63
+ }
64
+ var count = getRowSpanCount(i, 1);
65
+ return [startIndex, startIndex + count - 1];
66
+ });
67
+ _rowSpanInfos.push(rowSpanInfo);
68
+ };
69
+ for (var i = 0; i < totalLength; i++) {
70
+ _loop(i);
71
+ }
72
+ for (var _i = 0; _i < _rowSpanInfos.length; _i++) {
73
+ if (_i === _rowSpanInfos.length - 1) break;
74
+ var spans1 = _rowSpanInfos[_i];
75
+ var spans2 = _rowSpanInfos[_i + 1];
76
+ for (var j = 0; j < spans1.length; j++) {
77
+ var _spans1$j = _slicedToArray(spans1[j], 2),
78
+ startIndex1 = _spans1$j[0],
79
+ endIndex1 = _spans1$j[1];
80
+ var _spans2$j = _slicedToArray(spans2[j], 1),
81
+ startIndex2 = _spans2$j[0];
82
+ if (endIndex1 === startIndex2) {
83
+ spans2[j][0] = startIndex1;
84
+ }
85
+ }
86
+ }
87
+ return _rowSpanInfos.map(function (_rowSpanInfo) {
88
+ var startIndexs = _rowSpanInfo.map(function (arr) {
89
+ return arr[0];
90
+ });
91
+ return Math.min.apply(Math, _toConsumableArray(startIndexs));
92
+ });
93
+ }, [props.data, props.columns]);
42
94
  var _useRef = (0, _react.useRef)({
43
95
  cachedHeight: [],
44
96
  shouldUpdateHeight: true,
@@ -98,7 +150,20 @@ var useTableVirtual = function useTableVirtual(props) {
98
150
  var maxIndex = Math.max(props.data.length - rowsInView, 0);
99
151
  for (var i = 0; i <= maxIndex; i++) {
100
152
  sum += context.cachedHeight[i] || props.rowHeight;
101
- if (scrollTop < sum || i === maxIndex) {
153
+ var rowSpanHeight = 0;
154
+ if (rowSpanInfos) {
155
+ var siblingsIndexs = [];
156
+ for (var k = 0; k < rowSpanInfos.length; k++) {
157
+ if (rowSpanInfos[k] <= i && k !== i) {
158
+ siblingsIndexs.push(k);
159
+ }
160
+ }
161
+ for (var j = 0; j < siblingsIndexs.length; j++) {
162
+ var index = siblingsIndexs[j];
163
+ rowSpanHeight += context.cachedHeight[index] || props.rowHeight;
164
+ }
165
+ }
166
+ if (scrollTop < sum + rowSpanHeight || i === maxIndex) {
102
167
  currentIndex = i;
103
168
  var beforeHeight = i === 0 ? 0 : sum - (context.cachedHeight[i] || props.rowHeight);
104
169
  top = scrollTop - beforeHeight;
@@ -1 +1 @@
1
- {"version":3,"file":"is.d.ts","sourceRoot":"","sources":["is.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wBAAgB,SAAS,YAExB;AASD,eAAO,MAAM,OAAO,4BAAgB,CAAC;AACrC,eAAO,MAAM,QAAQ,QAAS,OAAO,sBACc,CAAC;AACpD,eAAO,MAAM,MAAM,QAAS,OAAO,gBAAqC,CAAC;AACzE,eAAO,MAAM,SAAS,QAAS,OAAO,mBAA2C,CAAC;AAClF,eAAO,MAAM,OAAO,QAAS,OAAO,KAAG,OAA+B,CAAC;AACvE,eAAO,MAAM,QAAQ,MAAO,OAAO,gBAAuC,CAAC;AAC3E,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,OAAgC,CAAC;AACzE,eAAO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AS,OAAO,mBAA2C,CAAC;AAClF,eAAO,MAAM,OAAO,QAAS,OAAO,KAAG,OAA+B,CAAC;AACvE,eAAO,MAAM,QAAQ,MAAO,OAAO,gBAAuC,CAAC;AAC3E,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,OAAgC,CAAC;AACzE,eAAO,MAAM,QAAQ,MAAO,OAAO,gBAAuC,CAAC;AAC3E,eAAO,MAAM,WAAW,QAAS,GAAG,qBAAwC,CAAC;AAC7E,eAAO,MAAM,KAAK,QAjBsB,OAAO,mBAiBb,CAAC;AACnC,eAAO,MAAM,KAAK,QAlBsB,OAAO,mBAkBb,CAAC;AACnC,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,OAUvC,CAAC;AACF,eAAO,MAAM,eAAe,QAAS,OAAO,yBAE3C,CAAC;AACF,eAAO,MAAM,WAAW,QAAS,OAAO,KAAG,OAS1C,CAAC;AAEF,eAAO,MAAM,MAAM,MAAO,OAAO,kBAA2C,CAAC;AAE7E,eAAO,MAAM,SAAS,MAAO,OAAO,YACiC,CAAC;AAGtE,eAAO,MAAM,KAAK,MAAO,OAAO,KAAG,OAAkB,CAAC;AAEtD,eAAO,MAAM,OAAO,QAAS,OAAO,KAAG,OActC,CAAC;AAEF,eAAO,MAAM,MAAM,OAAQ,OAAO,6EASjC,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,OACqC,CAAC;AAEjE,eAAO,MAAM,SAAS,QAAO,OAG5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAAa,MAAM,KAAG,OASnD,CAAC;AAEF,wBAAgB,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,WAAW,CAQjE"}
package/cjs/utils/is.js CHANGED
@@ -56,7 +56,7 @@ var isBuffer = exports.isBuffer = function isBuffer(val) {
56
56
  return false;
57
57
  };
58
58
  var isUnMatchedData = exports.isUnMatchedData = function isUnMatchedData(val) {
59
- return isObject(val) && val.IS_NOT_MATCHED_VALUE;
59
+ return isObject(val) && val.IS_NOT_MATCHED_VALUE === true;
60
60
  };
61
61
  var isMergeable = exports.isMergeable = function isMergeable(val) {
62
62
  if (!isObject(val)) return false;
@@ -1 +1 @@
1
- {"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA8CX,MAAM,UAAU,MAAM;;;;;;;;CAkO5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA8CX,MAAM,UAAU,MAAM;;;;;;;;CAmO5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -328,12 +328,13 @@ var useTableLayout = function useTableLayout(props) {
328
328
  getColgroup(adjust === 'drag');
329
329
  setAdjust(false);
330
330
  } else {
331
- checkFloat();
331
+ // checkFloat();
332
332
  // checkScroll();
333
333
  // 拖拽列会导致 scrollWidth 变化
334
334
  syncScrollWidth();
335
335
  }
336
336
  checkScroll();
337
+ checkFloat();
337
338
  }, [colgroup]);
338
339
  return {
339
340
  isScrollX: !!isScrollX,
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { TableFormatColumn } from './use-table.type';
2
3
  interface UseTableVirtualProps {
3
4
  data: any[];
4
5
  rowsInView: number;
@@ -8,6 +9,7 @@ interface UseTableVirtualProps {
8
9
  scrollLeft?: number;
9
10
  disabled?: boolean;
10
11
  isRtl?: boolean;
12
+ columns: TableFormatColumn<any>[];
11
13
  }
12
14
  declare const useTableVirtual: (props: UseTableVirtualProps) => {
13
15
  scrollHeight: number;
@@ -1 +1 @@
1
- {"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAGA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;oBA+GpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAtEuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BAkInB,MAAM;CAmElD,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;oBAiLpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAnFuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BA+InB,MAAM;CAmElD,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -9,7 +9,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
9
9
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
11
  import { usePersistFn } from "../../common/use-persist-fn";
12
- import { useState, useRef, useEffect } from 'react';
12
+ import { useState, useRef, useEffect, useMemo } from 'react';
13
13
  var useTableVirtual = function useTableVirtual(props) {
14
14
  var _useState = useState(0),
15
15
  _useState2 = _slicedToArray(_useState, 2),
@@ -33,6 +33,58 @@ var useTableVirtual = function useTableVirtual(props) {
33
33
  setOffsetY = _useState10[1];
34
34
  var rowsInView = props.rowsInView === 0 ? props.data.length : props.rowsInView;
35
35
  var sleft = props.scrollLeft !== undefined ? props.scrollLeft : innerLeft;
36
+ var rowSpanInfos = useMemo(function () {
37
+ var rowSpanColumns = props.columns.filter(function (col) {
38
+ return typeof col.rowSpan === 'function';
39
+ });
40
+ if (rowSpanColumns.length === 0) return;
41
+ var _rowSpanInfos = [];
42
+ var totalLength = props.data.length;
43
+ var _loop = function _loop(i) {
44
+ var startIndex = i;
45
+ var rowSpanInfo = rowSpanColumns.map(function (col) {
46
+ var rowSpan = col.rowSpan;
47
+ function getRowSpanCount(index, _count) {
48
+ var count = _count;
49
+ if (index === totalLength - 1) return count;
50
+ var prevRowData = props.data[index];
51
+ var nextRowData = props.data[index + 1];
52
+ if (rowSpan(prevRowData, nextRowData)) {
53
+ count = count + 1;
54
+ getRowSpanCount(index + 1, count);
55
+ }
56
+ return count;
57
+ }
58
+ var count = getRowSpanCount(i, 1);
59
+ return [startIndex, startIndex + count - 1];
60
+ });
61
+ _rowSpanInfos.push(rowSpanInfo);
62
+ };
63
+ for (var i = 0; i < totalLength; i++) {
64
+ _loop(i);
65
+ }
66
+ for (var _i = 0; _i < _rowSpanInfos.length; _i++) {
67
+ if (_i === _rowSpanInfos.length - 1) break;
68
+ var spans1 = _rowSpanInfos[_i];
69
+ var spans2 = _rowSpanInfos[_i + 1];
70
+ for (var j = 0; j < spans1.length; j++) {
71
+ var _spans1$j = _slicedToArray(spans1[j], 2),
72
+ startIndex1 = _spans1$j[0],
73
+ endIndex1 = _spans1$j[1];
74
+ var _spans2$j = _slicedToArray(spans2[j], 1),
75
+ startIndex2 = _spans2$j[0];
76
+ if (endIndex1 === startIndex2) {
77
+ spans2[j][0] = startIndex1;
78
+ }
79
+ }
80
+ }
81
+ return _rowSpanInfos.map(function (_rowSpanInfo) {
82
+ var startIndexs = _rowSpanInfo.map(function (arr) {
83
+ return arr[0];
84
+ });
85
+ return Math.min.apply(Math, _toConsumableArray(startIndexs));
86
+ });
87
+ }, [props.data, props.columns]);
36
88
  var _useRef = useRef({
37
89
  cachedHeight: [],
38
90
  shouldUpdateHeight: true,
@@ -92,7 +144,20 @@ var useTableVirtual = function useTableVirtual(props) {
92
144
  var maxIndex = Math.max(props.data.length - rowsInView, 0);
93
145
  for (var i = 0; i <= maxIndex; i++) {
94
146
  sum += context.cachedHeight[i] || props.rowHeight;
95
- if (scrollTop < sum || i === maxIndex) {
147
+ var rowSpanHeight = 0;
148
+ if (rowSpanInfos) {
149
+ var siblingsIndexs = [];
150
+ for (var k = 0; k < rowSpanInfos.length; k++) {
151
+ if (rowSpanInfos[k] <= i && k !== i) {
152
+ siblingsIndexs.push(k);
153
+ }
154
+ }
155
+ for (var j = 0; j < siblingsIndexs.length; j++) {
156
+ var index = siblingsIndexs[j];
157
+ rowSpanHeight += context.cachedHeight[index] || props.rowHeight;
158
+ }
159
+ }
160
+ if (scrollTop < sum + rowSpanHeight || i === maxIndex) {
96
161
  currentIndex = i;
97
162
  var beforeHeight = i === 0 ? 0 : sum - (context.cachedHeight[i] || props.rowHeight);
98
163
  top = scrollTop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eAAO,MAAM,SAAS,MAAO,OAAO,YACiC,CAAC;AAGtE,eAAO,MAAM,KAAK,MAAO,OAAO,KAAG,OAAkB,CAAC;AAEtD,eAAO,MAAM,OAAO,QAAS,OAAO,KAAG,OActC,CAAC;AAEF,eAAO,MAAM,MAAM,OAAQ,OAAO,6EASjC,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,OACqC,CAAC;AAEjE,eAAO,MAAM,SAAS,QAAO,OAG5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAAa,MAAM,KAAG,OASnD,CAAC;AAEF,wBAAgB,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,WAAW,CAQjE"}
package/esm/utils/is.js CHANGED
@@ -45,7 +45,7 @@ export var isBuffer = function isBuffer(val) {
45
45
  return false;
46
46
  };
47
47
  export var isUnMatchedData = function isUnMatchedData(val) {
48
- return isObject(val) && val.IS_NOT_MATCHED_VALUE;
48
+ return isObject(val) && val.IS_NOT_MATCHED_VALUE === true;
49
49
  };
50
50
  export var isMergeable = function isMergeable(val) {
51
51
  if (!isObject(val)) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.3.3-beta.1",
3
+ "version": "3.3.3-beta.3",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",