uiw 5.0.0-bate-6 → 5.0.0-bate-8

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,72 @@ 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 lg = childList.length;
16910
+ for (var index = 0; index < lg; index++) {
16911
+ var childKey = childList[index];
16912
+ if (expandedKeys.includes(childKey)) {
16913
+ (function () {
16914
+ summary[childKey] = 1;
16915
+ var count = _this.childTreeCount.get(childKey || '') || 0;
16916
+ Object.entries(summary).forEach(_ref => {
16917
+ var [k, value] = _ref;
16918
+ /**计算合并行个数*/
16919
+ summary[k] = value + count;
16920
+ });
16921
+ })();
16922
+ } else {
16923
+ break;
16924
+ }
16925
+ }
16926
+ return summary;
16927
+ }
16928
+ }
16929
+ var getRowSpan = (rowSpan, leve, index) => {
16930
+ var show = leve < index + 1;
16931
+ var newRowSpan = leve === index ? rowSpan : undefined;
16932
+ return {
16933
+ show,
16934
+ rowSpan: newRowSpan
16935
+ };
16936
+ };
16937
+
16872
16938
  ;// CONCATENATED MODULE: ../react-table/esm/ThComponent.js
16873
16939
 
16874
16940
 
@@ -17040,7 +17106,10 @@ function TableTr(props) {
17040
17106
  indentSize,
17041
17107
  childrenColumnName,
17042
17108
  locationWidth,
17043
- header
17109
+ header,
17110
+ isAutoExpanded = true,
17111
+ treeData,
17112
+ isAutoMergeRowSpan
17044
17113
  } = props;
17045
17114
  var [isOpacity, setIsOpacity] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false);
17046
17115
  var [childrenIndex, setChildrenIndex] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(0);
@@ -17082,14 +17151,22 @@ function TableTr(props) {
17082
17151
  return /*#__PURE__*/(0,jsx_runtime.jsx)((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, {
17083
17152
  children: data.map((trData, rowNum) => {
17084
17153
  var key = rowKey ? trData[rowKey] : rowNum;
17154
+ var summary = treeData == null ? void 0 : treeData.getSum(key, expandIndex);
17085
17155
  return /*#__PURE__*/(0,jsx_runtime.jsxs)((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, {
17086
17156
  children: [/*#__PURE__*/(0,jsx_runtime.jsx)("tr", {
17087
17157
  children: keys.map((keyName, colNum) => {
17158
+ var itemShow = {};
17159
+ if (isAutoMergeRowSpan && summary) {
17160
+ itemShow = getRowSpan(summary[key], hierarchy, colNum);
17161
+ if (!itemShow.show) {
17162
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(external_root_React_commonjs2_react_commonjs_react_amd_react_.Fragment, {});
17163
+ }
17164
+ }
17088
17165
  var objs = {
17089
17166
  children: trData[keyName.key]
17090
17167
  };
17091
17168
  if (render[keyName.key]) {
17092
- var child = render[keyName.key](trData[keyName.key], keyName.key, trData, rowNum, colNum);
17169
+ var child = render[keyName.key](trData[keyName.key], keyName.key, trData, rowNum, colNum, itemShow.rowSpan);
17093
17170
  if ( /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().isValidElement(child)) {
17094
17171
  objs.children = child;
17095
17172
  } else {
@@ -17103,9 +17180,17 @@ function TableTr(props) {
17103
17180
  objs.children = child.children;
17104
17181
  }
17105
17182
  }
17183
+ } else if (itemShow.rowSpan && isAutoMergeRowSpan) {
17184
+ objs.rowSpan = itemShow.rowSpan;
17106
17185
  }
17107
17186
  var isHasChildren = Array.isArray(trData[childrenColumnName]);
17108
- if (colNum === childrenIndex && (isOpacity || hierarchy || isHasChildren)) {
17187
+ var isExpanded = false;
17188
+ if ((isOpacity || hierarchy || isHasChildren) && colNum === childrenIndex && isAutoExpanded) {
17189
+ isExpanded = true;
17190
+ } else if ((isOpacity || hierarchy || isHasChildren) && !isAutoExpanded && keyName.isExpanded) {
17191
+ isExpanded = true;
17192
+ }
17193
+ if (isExpanded) {
17109
17194
  objs.children = /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
17110
17195
  children: [IconDom(key, isHasChildren), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
17111
17196
  style: {
@@ -17155,7 +17240,7 @@ function TableTr(props) {
17155
17240
  ;// CONCATENATED MODULE: ../react-table/esm/index.js
17156
17241
 
17157
17242
 
17158
- var react_table_esm_excluded = ["prefixCls", "className", "columns", "data", "title", "footer", "bordered", "onCell", "onCellHead", "empty", "children", "expandable", "rowKey", "scroll"];
17243
+ var react_table_esm_excluded = ["prefixCls", "className", "columns", "data", "title", "footer", "bordered", "onCell", "onCellHead", "empty", "children", "expandable", "rowKey", "scroll", "isAutoMergeRowSpan"];
17159
17244
 
17160
17245
 
17161
17246
 
@@ -17188,7 +17273,8 @@ function esm_Table(props) {
17188
17273
  empty,
17189
17274
  expandable,
17190
17275
  rowKey,
17191
- scroll
17276
+ scroll,
17277
+ isAutoMergeRowSpan = false
17192
17278
  } = props,
17193
17279
  other = _objectWithoutPropertiesLoose(props, react_table_esm_excluded);
17194
17280
  var [expandIndex, setExpandIndex] = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]);
@@ -17378,6 +17464,7 @@ function esm_Table(props) {
17378
17464
  render,
17379
17465
  ellipsis
17380
17466
  } = getLevelItems(self.selfColumns);
17467
+ 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]);
17381
17468
  return /*#__PURE__*/(0,jsx_runtime.jsxs)((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, {
17382
17469
  children: [/*#__PURE__*/(0,jsx_runtime.jsx)(TableStyleWrap, extends_extends({
17383
17470
  className: cls
@@ -17411,7 +17498,10 @@ function esm_Table(props) {
17411
17498
  hierarchy: 0,
17412
17499
  isExpandedDom: isExpandedDom,
17413
17500
  indentSize: typeof (expandable == null ? void 0 : expandable.indentSize) === 'number' ? expandable == null ? void 0 : expandable.indentSize : 16,
17414
- childrenColumnName: (expandable == null ? void 0 : expandable.childrenColumnName) || 'children'
17501
+ childrenColumnName: (expandable == null ? void 0 : expandable.childrenColumnName) || 'children',
17502
+ isAutoExpanded: expandable == null ? void 0 : expandable.isAutoExpanded,
17503
+ treeData: treeData,
17504
+ isAutoMergeRowSpan: isAutoMergeRowSpan
17415
17505
  })
17416
17506
  }), data && data.length === 0 && empty && /*#__PURE__*/(0,jsx_runtime.jsx)("tbody", {
17417
17507
  children: /*#__PURE__*/(0,jsx_runtime.jsx)("tr", {