uiw 5.0.0-bate-7 → 5.0.0-bate-9

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
@@ -16869,6 +16869,83 @@ function locationFixed(fixed, location, index) {
16869
16869
  };
16870
16870
  }
16871
16871
 
16872
+ // 通过树获取子节点个数
16873
+ // 记录顶层父级
16874
+ // 通过顶层父级进行获取展开的 key
16875
+ // 通过 key 进行获取个数
16876
+ class NodeTreeData {
16877
+ constructor(dataList, rowKey, childName) {
16878
+ this.parentToChild = new Map([]);
16879
+ this.childToParent = new Map([]);
16880
+ this.childTreeCount = new Map([]);
16881
+ this.rowKey = 'id';
16882
+ this.childName = 'children';
16883
+ this.rowKey = rowKey || this.rowKey;
16884
+ this.childName = childName || this.childName;
16885
+ this.init(dataList);
16886
+ }
16887
+ /**把根据父级 key 存储对应下所有子集的个数*/
16888
+ init(dataList, parentList) {
16889
+ if (parentList === void 0) {
16890
+ parentList = [];
16891
+ }
16892
+ dataList.forEach(item => {
16893
+ if (Array.isArray(item[this.childName])) {
16894
+ var newParent = parentList.concat([item[this.rowKey]]);
16895
+ var parentKey = newParent[0];
16896
+ this.childToParent.set(item[this.rowKey], parentKey);
16897
+ this.parentToChild.set(parentKey, newParent);
16898
+ this.childTreeCount.set(item[this.rowKey], item[this.childName].length);
16899
+ this.init(item[this.childName], newParent);
16900
+ }
16901
+ });
16902
+ }
16903
+ /**获取合并行数*/
16904
+ getSum(key, expandedKeys) {
16905
+ var _this = this;
16906
+ var parentKey = this.childToParent.get(key) || '';
16907
+ var childList = this.parentToChild.get(parentKey) || [];
16908
+ var summary = {};
16909
+ var summaryCount = {};
16910
+ var lg = childList.length;
16911
+ for (var index = 0; index < lg; index++) {
16912
+ var childKey = childList[index];
16913
+ if (expandedKeys.includes(childKey)) {
16914
+ (function () {
16915
+ summary[childKey] = {
16916
+ count: 1,
16917
+ level: index
16918
+ };
16919
+ var count = _this.childTreeCount.get(childKey || '') || 0;
16920
+ Object.entries(summary).forEach(_ref => {
16921
+ var [k, value] = _ref;
16922
+ /**计算合并行个数*/
16923
+ summary[k] = {
16924
+ count: value.count + count,
16925
+ level: value.level
16926
+ };
16927
+ summaryCount[value.level] = value.count + count;
16928
+ });
16929
+ })();
16930
+ } else {
16931
+ break;
16932
+ }
16933
+ }
16934
+ return {
16935
+ summary,
16936
+ summaryCount
16937
+ };
16938
+ }
16939
+ }
16940
+ var getRowSpan = (rowSpan, leve, index) => {
16941
+ var show = leve < index + 1;
16942
+ var newRowSpan = leve === index ? rowSpan : undefined;
16943
+ return {
16944
+ show,
16945
+ rowSpan: newRowSpan
16946
+ };
16947
+ };
16948
+
16872
16949
  ;// CONCATENATED MODULE: ../react-table/esm/ThComponent.js
16873
16950
 
16874
16951
 
@@ -17041,11 +17118,15 @@ function TableTr(props) {
17041
17118
  childrenColumnName,
17042
17119
  locationWidth,
17043
17120
  header,
17044
- isAutoExpanded = true
17121
+ isAutoExpanded = true,
17122
+ treeData,
17123
+ isAutoMergeRowSpan,
17124
+ expandIndex,
17125
+ setExpandIndex
17045
17126
  } = props;
17046
17127
  var [isOpacity, setIsOpacity] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false);
17047
17128
  var [childrenIndex, setChildrenIndex] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(0);
17048
- var [expandIndex, setExpandIndex] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]);
17129
+ // const [expandIndex, setExpandIndex] = useState<Array<T[keyof T] | number>>([]);
17049
17130
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(() => {
17050
17131
  setIsOpacity(!!(data != null && data.find(it => it[childrenColumnName])));
17051
17132
  setChildrenIndex((keys == null ? void 0 : keys.findIndex(it => it.key === 'uiw-expanded')) === -1 ? 0 : 1);
@@ -17083,14 +17164,27 @@ function TableTr(props) {
17083
17164
  return /*#__PURE__*/(0,jsx_runtime.jsx)((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, {
17084
17165
  children: data.map((trData, rowNum) => {
17085
17166
  var key = rowKey ? trData[rowKey] : rowNum;
17167
+ var summary = treeData == null ? void 0 : treeData.getSum(key, expandIndex || []);
17086
17168
  return /*#__PURE__*/(0,jsx_runtime.jsxs)((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, {
17087
17169
  children: [/*#__PURE__*/(0,jsx_runtime.jsx)("tr", {
17088
17170
  children: keys.map((keyName, colNum) => {
17171
+ var isHasChildren = Array.isArray(trData[childrenColumnName]);
17172
+ var itemShow = {};
17173
+ console.log(isAutoMergeRowSpan, summary);
17174
+ if (isAutoMergeRowSpan && summary) {
17175
+ var newLaval = Reflect.get(keyName, 'level');
17176
+ var summaryCount = summary.summaryCount[newLaval];
17177
+ if (hierarchy === newLaval && isHasChildren) {
17178
+ itemShow.rowSpan = summaryCount;
17179
+ } else if (hierarchy && Reflect.has(keyName, 'level') && hierarchy > newLaval) {
17180
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {}, colNum);
17181
+ }
17182
+ }
17089
17183
  var objs = {
17090
17184
  children: trData[keyName.key]
17091
17185
  };
17092
17186
  if (render[keyName.key]) {
17093
- var child = render[keyName.key](trData[keyName.key], keyName.key, trData, rowNum, colNum);
17187
+ var child = render[keyName.key](trData[keyName.key], keyName.key, trData, rowNum, colNum, itemShow.rowSpan);
17094
17188
  if ( /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().isValidElement(child)) {
17095
17189
  objs.children = child;
17096
17190
  } else {
@@ -17104,8 +17198,9 @@ function TableTr(props) {
17104
17198
  objs.children = child.children;
17105
17199
  }
17106
17200
  }
17201
+ } else if (itemShow.rowSpan && isAutoMergeRowSpan) {
17202
+ objs.rowSpan = itemShow.rowSpan;
17107
17203
  }
17108
- var isHasChildren = Array.isArray(trData[childrenColumnName]);
17109
17204
  var isExpanded = false;
17110
17205
  if ((isOpacity || hierarchy || isHasChildren) && colNum === childrenIndex && isAutoExpanded) {
17111
17206
  isExpanded = true;
@@ -17162,7 +17257,7 @@ function TableTr(props) {
17162
17257
  ;// CONCATENATED MODULE: ../react-table/esm/index.js
17163
17258
 
17164
17259
 
17165
- var react_table_esm_excluded = ["prefixCls", "className", "columns", "data", "title", "footer", "bordered", "onCell", "onCellHead", "empty", "children", "expandable", "rowKey", "scroll"];
17260
+ var react_table_esm_excluded = ["prefixCls", "className", "columns", "data", "title", "footer", "bordered", "onCell", "onCellHead", "empty", "children", "expandable", "rowKey", "scroll", "isAutoMergeRowSpan"];
17166
17261
 
17167
17262
 
17168
17263
 
@@ -17195,7 +17290,8 @@ function esm_Table(props) {
17195
17290
  empty,
17196
17291
  expandable,
17197
17292
  rowKey,
17198
- scroll
17293
+ scroll,
17294
+ isAutoMergeRowSpan = false
17199
17295
  } = props,
17200
17296
  other = _objectWithoutPropertiesLoose(props, react_table_esm_excluded);
17201
17297
  var [expandIndex, setExpandIndex] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]);
@@ -17385,6 +17481,7 @@ function esm_Table(props) {
17385
17481
  render,
17386
17482
  ellipsis
17387
17483
  } = getLevelItems(self.selfColumns);
17484
+ var treeData = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(() => isAutoMergeRowSpan && new NodeTreeData(data, rowKey, (expandable == null ? void 0 : expandable.childrenColumnName) || 'children') || undefined, [data, rowKey, expandable == null ? void 0 : expandable.childrenColumnName, isAutoMergeRowSpan]);
17388
17485
  return /*#__PURE__*/(0,jsx_runtime.jsxs)((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, {
17389
17486
  children: [/*#__PURE__*/(0,jsx_runtime.jsx)(TableStyleWrap, extends_extends({
17390
17487
  className: cls
@@ -17419,7 +17516,11 @@ function esm_Table(props) {
17419
17516
  isExpandedDom: isExpandedDom,
17420
17517
  indentSize: typeof (expandable == null ? void 0 : expandable.indentSize) === 'number' ? expandable == null ? void 0 : expandable.indentSize : 16,
17421
17518
  childrenColumnName: (expandable == null ? void 0 : expandable.childrenColumnName) || 'children',
17422
- isAutoExpanded: expandable == null ? void 0 : expandable.isAutoExpanded
17519
+ isAutoExpanded: expandable == null ? void 0 : expandable.isAutoExpanded,
17520
+ treeData: treeData,
17521
+ isAutoMergeRowSpan: isAutoMergeRowSpan,
17522
+ expandIndex: expandIndex,
17523
+ setExpandIndex: setExpandIndex
17423
17524
  })
17424
17525
  }), data && data.length === 0 && empty && /*#__PURE__*/(0,jsx_runtime.jsx)("tbody", {
17425
17526
  children: /*#__PURE__*/(0,jsx_runtime.jsx)("tr", {