ds-web-all 1.0.1-beta.89 → 1.0.1-beta.90

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.
@@ -455,25 +455,6 @@ function CFTable(_ref2) {
455
455
  _useState10 = _slicedToArray(_useState9, 2),
456
456
  resizeScrollX = _useState10[0],
457
457
  setResizeScrollX = _useState10[1];
458
- var _setColumnWidthMap = function _setColumnWidthMap(val, isResize) {
459
- var newVal = typeof val === 'function' ? val(columnWidthMapRef.current) : val;
460
- setColumnWidthMap(newVal);
461
- columnWidthMapRef.current = newVal;
462
- if (isResize) {
463
- var sum = rowSelectWidth;
464
- var _loopForEach = function loopForEach(arr) {
465
- arr.forEach(function (col) {
466
- if (col.children && col.children.length > 0) {
467
- _loopForEach(col.children);
468
- } else {
469
- sum += newVal[col.name] || 0;
470
- }
471
- });
472
- };
473
- _loopForEach(columns);
474
- setResizeScrollX(sum);
475
- }
476
- };
477
458
  var rowSelectWidth = (0, _react.useMemo)(function () {
478
459
  return newRowSelection ? typeof rowSelection.columnWidth === 'string' ? rowSelection.columnWidth.replace('px', '') : rowSelection.columnWidth || 32 : 0;
479
460
  }, [newRowSelection]);
@@ -489,6 +470,24 @@ function CFTable(_ref2) {
489
470
  };
490
471
  return _loopMap(columns);
491
472
  }, [columns]);
473
+ var simpleColumnsStr = (0, _react.useMemo)(function () {
474
+ return JSON.stringify(simpleColumns);
475
+ }, [simpleColumns]);
476
+ (0, _react.useEffect)(function () {
477
+ columnWidthMapRef.current = columnWidthMap;
478
+ var sum = rowSelectWidth;
479
+ var _loopForEach = function loopForEach(arr) {
480
+ arr.forEach(function (col) {
481
+ if (col.children && col.children.length > 0) {
482
+ _loopForEach(col.children);
483
+ } else {
484
+ sum += columnWidthMap[col.name] || 0;
485
+ }
486
+ });
487
+ };
488
+ _loopForEach(columns);
489
+ setResizeScrollX(sum);
490
+ }, [columnWidthMap, rowSelectWidth]);
492
491
  (0, _react.useEffect)(function () {
493
492
  columnConfigWidthMapOld.current = _objectSpread({}, columnConfigWidthMap.current);
494
493
  var newData = _objectSpread(_objectSpread({}, columnConfigWidthMap.current), columnWidthMapRef.current);
@@ -524,22 +523,36 @@ function CFTable(_ref2) {
524
523
  if (tableWidth < mergeScroll.x) {
525
524
  tableWidth = mergeScroll.x;
526
525
  }
527
- if (widthTotal < tableWidth - rowSelectWidth && nullNum > 0) {
528
- var nullCellNum = (tableWidth - rowSelectWidth - widthTotalNull) / nullNum;
529
- var _loopForEach3 = function loopForEach1(arr) {
530
- arr.forEach(function (col) {
531
- if (col.children && col.children.length > 0) {
532
- _loopForEach3(col.children);
533
- } else if (!columnConfigWidthMap.current[col.name]) {
534
- newData[col.name] = nullCellNum;
535
- }
536
- });
537
- };
538
- _loopForEach3(simpleColumns);
526
+ if (widthTotal < tableWidth - rowSelectWidth) {
527
+ if (nullNum > 0) {
528
+ var nullCellNum = (tableWidth - rowSelectWidth - widthTotalNull) / nullNum;
529
+ var _loopForEach3 = function loopForEach1(arr) {
530
+ arr.forEach(function (col) {
531
+ if (col.children && col.children.length > 0) {
532
+ _loopForEach3(col.children);
533
+ } else if (!columnConfigWidthMap.current[col.name]) {
534
+ newData[col.name] = nullCellNum;
535
+ }
536
+ });
537
+ };
538
+ _loopForEach3(simpleColumns);
539
+ } else {
540
+ var ratio = widthTotal > 0 ? (tableWidth - rowSelectWidth) / widthTotal : 1;
541
+ var _loopForEach4 = function loopForEach1(arr) {
542
+ arr.forEach(function (col) {
543
+ if (col.children && col.children.length > 0) {
544
+ _loopForEach4(col.children);
545
+ } else {
546
+ newData[col.name] = (newData[col.name] || 80) * ratio;
547
+ }
548
+ });
549
+ };
550
+ _loopForEach4(simpleColumns);
551
+ }
539
552
  }
540
553
  }
541
- _setColumnWidthMap(newData);
542
- }, [JSON.stringify(simpleColumns)]);
554
+ setColumnWidthMap(newData);
555
+ }, [simpleColumnsStr]);
543
556
  var showColumns = (0, _react.useMemo)(function () {
544
557
  var _loopMap2 = function loopMap(arr) {
545
558
  return arr.map(function (el) {
@@ -603,9 +616,9 @@ function CFTable(_ref2) {
603
616
  var _onColResizeUp = function onColResizeUp(e) {
604
617
  document.body.style.userSelect = '';
605
618
  setColResizeStyle(null);
606
- _setColumnWidthMap(function (old) {
619
+ setColumnWidthMap(function (old) {
607
620
  return _objectSpread(_objectSpread({}, old), {}, _defineProperty({}, nameKey, minMaxNum(e.clientX - ((parentBcr === null || parentBcr === void 0 ? void 0 : parentBcr.left) || 0), minResize, maxResize)));
608
- }, true);
621
+ });
609
622
  window.removeEventListener('mousemove', onColResizeMove);
610
623
  window.removeEventListener('mouseup', _onColResizeUp);
611
624
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "ds-web-all",
4
- "version": "1.0.1-beta.89",
4
+ "version": "1.0.1-beta.90",
5
5
  "scripts": {
6
6
  "start": "cross-env BUILD_ENV=dev && dumi dev",
7
7
  "docs:build": "cross-env BUILD_ENV=production && dumi build",