ztxkui 10.0.47 → 10.0.49

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.
@@ -68,7 +68,7 @@ import { useContextMenu } from 'react-contexify';
68
68
  // 获取表格数据
69
69
  function useGetTableRecords() {
70
70
  // 表格数据
71
- var _a = useState(Array.from({ length: 10 }).map(function (item, index) {
71
+ var _a = useState(Array.from({ length: 1000 }).map(function (item, index) {
72
72
  var newItem = {
73
73
  id: "" + (index + 1),
74
74
  test1: index + 1 + "-test1",
@@ -708,28 +708,48 @@ function Table(props) {
708
708
  (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange) &&
709
709
  rowSelection.onChange(selectedRowKeys, selectedRows);
710
710
  } })); }, [rowSelection]);
711
- var virtualRef = useRef();
712
- // 自动开启虚拟滚动
713
- var virtual = useMemo(function () {
714
- if (virtualTableKey)
715
- return virtualTableKey;
716
- if (expandableDataSource.length > 400) {
717
- if (virtualRef.current)
718
- return virtualRef.current;
719
- var key = Math.random().toString(36).slice(-12);
720
- virtualRef.current = key;
721
- return key;
711
+ var isVirtialInit = useRef(true);
712
+ var _o = useState(), virtual = _o[0], setVirtual = _o[1];
713
+ var _p = useState(), virtualY = _p[0], setVirtialY = _p[1];
714
+ useEffect(function () {
715
+ if (onEditableSave)
716
+ return;
717
+ if (virtualTableKey) {
718
+ if (isVirtialInit.current) {
719
+ setVirtual(virtualTableKey);
720
+ setHeight();
721
+ isVirtialInit.current = false;
722
+ }
723
+ }
724
+ else if (expandableDataSource && (expandableDataSource === null || expandableDataSource === void 0 ? void 0 : expandableDataSource.length) > 400) {
725
+ var key_1 = Math.random().toString(36).slice(-10);
726
+ setVirtual(function (item) {
727
+ return item || key_1;
728
+ });
729
+ setHeight();
730
+ }
731
+ else {
732
+ setVirtual(undefined);
733
+ }
734
+ function setHeight() {
735
+ var _a;
736
+ if (isFlex) {
737
+ var body = (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.ant-table-body');
738
+ var height = body === null || body === void 0 ? void 0 : body.clientHeight;
739
+ setVirtialY(height);
740
+ }
722
741
  }
723
- virtualRef.current = undefined;
724
- return undefined;
725
- }, [virtualTableKey, expandableDataSource]);
742
+ }, [isFlex, expandableDataSource, virtualTableKey, onEditableSave]);
726
743
  // 虚拟滚动选项
727
744
  var vComponents = useMemo(function () {
728
745
  if (virtual) {
729
746
  // 使用VList 即可有虚拟列表的效果
747
+ var height = myScroll.y ? myScroll.y : 200;
748
+ if (virtualY)
749
+ height = virtualY;
730
750
  return VList({
731
751
  vid: virtual,
732
- height: myScroll.y ? myScroll.y : 200,
752
+ height: height,
733
753
  resetTopWhenDataChange: false,
734
754
  });
735
755
  }
@@ -737,7 +757,7 @@ function Table(props) {
737
757
  return null;
738
758
  }
739
759
  // eslint-disable-next-line react-hooks/exhaustive-deps
740
- }, [virtual]);
760
+ }, [virtual, virtualY]);
741
761
  var tableComponents = useMemo(function () {
742
762
  var _a, _b;
743
763
  var result = onMoveRow || onEditableSave
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "10.0.47",
3
+ "version": "10.0.49",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",