uiw 5.0.0-bate.2.0 → 5.0.0-bate.2.1

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/dist/uiw.js CHANGED
@@ -17427,6 +17427,7 @@ function esm_Table(props) {
17427
17427
  var [expandIndex, setExpandIndex] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]);
17428
17428
  var [locationWidth, setLocationWidth] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({});
17429
17429
  var finalLocationWidth = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)({});
17430
+ var tableRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
17430
17431
  var updateLocation = function updateLocation(params, index, key, colSpan) {
17431
17432
  if (colSpan === void 0) {
17432
17433
  colSpan = 0;
@@ -17445,7 +17446,6 @@ function esm_Table(props) {
17445
17446
  var initialValue = 0,
17446
17447
  headerIndex = 0,
17447
17448
  deepParams = [];
17448
- console.log('initialValue0000', initialValue);
17449
17449
  params.forEach((_, index) => {
17450
17450
  var i = "" + fistIndex + headerIndex;
17451
17451
  if (typeof params[index] === 'number') {
@@ -17477,7 +17477,6 @@ function esm_Table(props) {
17477
17477
  }
17478
17478
  headerIndex -= 1;
17479
17479
  }
17480
- console.log('initialValue', initialValue);
17481
17480
  if (deepParams.filter(it => typeof it !== 'number').length) deepClumnsLocation(deepParams, fistIndex + 1);
17482
17481
  };
17483
17482
  var computed = () => {
@@ -17613,8 +17612,35 @@ function esm_Table(props) {
17613
17612
  render,
17614
17613
  ellipsis
17615
17614
  } = getLevelItems(self.selfColumns);
17615
+
17616
+ /**
17617
+ * 处理 column width
17618
+ */
17619
+ var headData = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(() => {
17620
+ var newData = header;
17621
+ if (tableRef.current && header[0].length > 0) {
17622
+ var arr = header[0].map(item => item.width || false);
17623
+ if (!arr.includes(false)) {
17624
+ // 如果每列都设置了宽度,则判断设置的宽度小于容器宽度,则删除列的宽度,让table自动计算
17625
+ var w = tableRef.current.scrollWidth;
17626
+ var allNum = header[0].reduce((pre, cur) => {
17627
+ return pre + (cur.width || 0);
17628
+ }, 0);
17629
+ if (allNum < w - 1) {
17630
+ newData[0] = header[0].map(item => {
17631
+ if (!item.fixed) {
17632
+ delete item.width;
17633
+ }
17634
+ return item;
17635
+ });
17636
+ }
17637
+ }
17638
+ }
17639
+ return newData;
17640
+ }, [header, tableRef]);
17616
17641
  return /*#__PURE__*/(0,jsx_runtime.jsxs)((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, {
17617
17642
  children: [/*#__PURE__*/(0,jsx_runtime.jsx)(TableStyleWrap, extends_extends({
17643
+ ref: tableRef,
17618
17644
  className: cls
17619
17645
  }, other, {
17620
17646
  style: extends_extends({}, other.style, style.div),
@@ -17630,7 +17656,7 @@ function esm_Table(props) {
17630
17656
  }), columns && columns.length > 0 && /*#__PURE__*/(0,jsx_runtime.jsx)(TheadComponent, {
17631
17657
  onCellHead: onCellHead,
17632
17658
  bordered: bordered,
17633
- data: header,
17659
+ data: headData,
17634
17660
  locationWidth: locationWidth,
17635
17661
  updateLocation: updateLocation
17636
17662
  }), data && data.length > 0 && /*#__PURE__*/(0,jsx_runtime.jsx)("tbody", {