linkmore-design 1.1.25-beta.1 → 1.1.25-beta.2
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/LmTable/hooks/useDndItems.d.ts +2 -2
- package/dist/LmTable/util.d.ts +1 -1
- package/dist/index.umd.js +102 -51
- package/dist/index.umd.min.js +5 -5
- package/es/LmTable/Table.js +34 -21
- package/es/LmTable/components/HeaderCol.js +5 -2
- package/es/LmTable/hooks/useDndItems.d.ts +2 -2
- package/es/LmTable/hooks/useDndItems.js +58 -27
- package/es/LmTable/util.js +6 -1
- package/lib/LmTable/Table.js +34 -21
- package/lib/LmTable/components/HeaderCol.js +5 -2
- package/lib/LmTable/hooks/useDndItems.d.ts +2 -2
- package/lib/LmTable/hooks/useDndItems.js +58 -27
- package/lib/LmTable/util.js +6 -1
- package/package.json +1 -1
|
@@ -6,8 +6,8 @@ interface IdndItems {
|
|
|
6
6
|
declare function useDndItems(props: any): {
|
|
7
7
|
dndColumns: any;
|
|
8
8
|
items: IdndItems;
|
|
9
|
-
groupRowKeys: any
|
|
10
|
-
groupColKeys: any
|
|
9
|
+
groupRowKeys: any;
|
|
10
|
+
groupColKeys: any;
|
|
11
11
|
updateItems: (value: IdndItems, resume: string) => void;
|
|
12
12
|
};
|
|
13
13
|
export default useDndItems;
|
package/dist/LmTable/util.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param groupColKeys 列分组的keys
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export function transformWithColGroup(columns: any, dataSource: any, groupColKeys: any): {
|
|
8
|
+
export function transformWithColGroup(columns: any, dataSource: any, groupColKeys: any, groupRowKeys: any): {
|
|
9
9
|
columns: any;
|
|
10
10
|
dataSource: any;
|
|
11
11
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -223791,13 +223791,18 @@
|
|
|
223791
223791
|
* @param groupColKeys 列分组的keys
|
|
223792
223792
|
* @returns
|
|
223793
223793
|
*/
|
|
223794
|
-
function transformWithColGroup(columns, dataSource, groupColKeys) {
|
|
223794
|
+
function transformWithColGroup(columns, dataSource, groupColKeys, groupRowKeys) {
|
|
223795
223795
|
if (!Array.isArray(groupColKeys) || !groupColKeys.length) {
|
|
223796
223796
|
return {
|
|
223797
223797
|
columns: columns,
|
|
223798
223798
|
dataSource: dataSource
|
|
223799
223799
|
};
|
|
223800
223800
|
}
|
|
223801
|
+
columns.forEach(function (c) {
|
|
223802
|
+
if (groupRowKeys.includes(c.dataIndex)) {
|
|
223803
|
+
c.show = false;
|
|
223804
|
+
}
|
|
223805
|
+
});
|
|
223801
223806
|
var columnsCopy = lodash.cloneDeep(columns);
|
|
223802
223807
|
var dataSourceCopy = lodash.cloneDeep(dataSource);
|
|
223803
223808
|
|
|
@@ -224461,39 +224466,55 @@
|
|
|
224461
224466
|
arr.splice(index, 1);
|
|
224462
224467
|
}
|
|
224463
224468
|
}
|
|
224464
|
-
function getSortInsert(
|
|
224469
|
+
function getSortInsert(tableHeader, value, _ref) {
|
|
224465
224470
|
var columns = _ref.columns;
|
|
224466
|
-
if (!
|
|
224471
|
+
if (!tableHeader) {
|
|
224467
224472
|
return [];
|
|
224468
224473
|
}
|
|
224469
224474
|
var arr = new Array(columns.length);
|
|
224470
|
-
|
|
224471
|
-
|
|
224475
|
+
tableHeader.push(value);
|
|
224476
|
+
tableHeader.forEach(function (val) {
|
|
224472
224477
|
var index = columns.findIndex(function (item) {
|
|
224473
224478
|
return item.title === val;
|
|
224474
224479
|
});
|
|
224480
|
+
columns[index].show = true;
|
|
224475
224481
|
arr.splice(index, 0, val);
|
|
224476
224482
|
});
|
|
224477
224483
|
return arr.filter(Boolean);
|
|
224478
224484
|
}
|
|
224479
|
-
function getSortDndColumns(
|
|
224485
|
+
function getSortDndColumns(value, _ref2) {
|
|
224480
224486
|
var columns = _ref2.columns;
|
|
224481
|
-
|
|
224487
|
+
var tableHeader = value.tableHeader;
|
|
224488
|
+
var hiddenArr = [].concat(_toConsumableArray$1(value.row), _toConsumableArray$1(value.col)) || [];
|
|
224489
|
+
if (!tableHeader || !tableHeader.length) {
|
|
224482
224490
|
return [];
|
|
224483
224491
|
}
|
|
224484
224492
|
var result = [];
|
|
224485
|
-
|
|
224493
|
+
var _loop = function _loop(i) {
|
|
224486
224494
|
var item = columns.find(function (item) {
|
|
224487
|
-
return item.title ===
|
|
224495
|
+
return item.title === tableHeader[i];
|
|
224488
224496
|
});
|
|
224489
224497
|
if (item) {
|
|
224498
|
+
item.order = i;
|
|
224490
224499
|
result.push(item);
|
|
224491
224500
|
}
|
|
224492
|
-
}
|
|
224493
|
-
|
|
224494
|
-
|
|
224495
|
-
|
|
224496
|
-
|
|
224501
|
+
};
|
|
224502
|
+
for (var i = 0; i < tableHeader.length; i++) {
|
|
224503
|
+
_loop(i);
|
|
224504
|
+
}
|
|
224505
|
+
var _loop2 = function _loop2(_i) {
|
|
224506
|
+
var item = columns.find(function (item) {
|
|
224507
|
+
return item.title === hiddenArr[_i];
|
|
224508
|
+
});
|
|
224509
|
+
if (item) {
|
|
224510
|
+
item.show = false;
|
|
224511
|
+
result.push(item);
|
|
224512
|
+
}
|
|
224513
|
+
};
|
|
224514
|
+
for (var _i = 0; _i < hiddenArr.length; _i++) {
|
|
224515
|
+
_loop2(_i);
|
|
224516
|
+
}
|
|
224517
|
+
return result;
|
|
224497
224518
|
}
|
|
224498
224519
|
function getDataIndexForTitle(row, columns) {
|
|
224499
224520
|
if (!row) {
|
|
@@ -224513,40 +224534,53 @@
|
|
|
224513
224534
|
colSortOpen = props.colSortOpen,
|
|
224514
224535
|
filterChange = props.filterChange,
|
|
224515
224536
|
openRowGroup = props.openRowGroup,
|
|
224516
|
-
openColGroup = props.openColGroup
|
|
224537
|
+
openColGroup = props.openColGroup,
|
|
224538
|
+
customizeGroupRowKeys = props.customizeGroupRowKeys,
|
|
224539
|
+
customizeGroupColKeys = props.customizeGroupColKeys;
|
|
224517
224540
|
var _useState = React.useState(columns),
|
|
224518
224541
|
_useState2 = _slicedToArray$1(_useState, 2),
|
|
224519
224542
|
dndColumns = _useState2[0],
|
|
224520
224543
|
setDndColumns = _useState2[1];
|
|
224521
|
-
var _useState3 = React.useState([]),
|
|
224544
|
+
var _useState3 = React.useState(customizeGroupRowKeys || []),
|
|
224522
224545
|
_useState4 = _slicedToArray$1(_useState3, 2),
|
|
224523
224546
|
groupRowKeys = _useState4[0],
|
|
224524
224547
|
setGroupRowKeys = _useState4[1];
|
|
224525
|
-
var _useState5 = React.useState([]),
|
|
224548
|
+
var _useState5 = React.useState(customizeGroupColKeys || []),
|
|
224526
224549
|
_useState6 = _slicedToArray$1(_useState5, 2),
|
|
224527
224550
|
groupColKeys = _useState6[0],
|
|
224528
224551
|
setGroupColKeys = _useState6[1];
|
|
224552
|
+
React.useEffect(function () {
|
|
224553
|
+
setGroupRowKeys(customizeGroupRowKeys);
|
|
224554
|
+
setGroupColKeys(customizeGroupColKeys);
|
|
224555
|
+
}, [customizeGroupRowKeys, customizeGroupColKeys]);
|
|
224529
224556
|
// 初始化
|
|
224530
|
-
var defaultItems = {
|
|
224531
|
-
|
|
224532
|
-
|
|
224533
|
-
|
|
224534
|
-
|
|
224535
|
-
defaultItems.col = [];
|
|
224536
|
-
}
|
|
224557
|
+
var defaultItems = {
|
|
224558
|
+
row: [],
|
|
224559
|
+
col: [],
|
|
224560
|
+
tableHeader: []
|
|
224561
|
+
};
|
|
224537
224562
|
if (openColGroup || openRowGroup || colSortOpen) {
|
|
224538
|
-
var tableHeader = [];
|
|
224539
224563
|
treeFind(columns, function (node) {
|
|
224540
|
-
|
|
224564
|
+
if (groupRowKeys.includes(node.dataIndex)) {
|
|
224565
|
+
defaultItems.row.push(node.title);
|
|
224566
|
+
} else if (groupColKeys.includes(node.dataIndex)) {
|
|
224567
|
+
defaultItems.col.push(node.title);
|
|
224568
|
+
} else {
|
|
224569
|
+
defaultItems.tableHeader.push(node.title);
|
|
224570
|
+
}
|
|
224541
224571
|
return false;
|
|
224542
224572
|
});
|
|
224543
|
-
defaultItems.tableHeader = tableHeader;
|
|
224544
224573
|
}
|
|
224545
224574
|
var _useState7 = React.useState(defaultItems),
|
|
224546
224575
|
_useState8 = _slicedToArray$1(_useState7, 2),
|
|
224547
224576
|
items = _useState8[0],
|
|
224548
224577
|
setItems = _useState8[1];
|
|
224549
224578
|
React.useEffect(function () {
|
|
224579
|
+
columns.forEach(function (c) {
|
|
224580
|
+
if (customizeGroupRowKeys.includes(c.dataIndex) || customizeGroupColKeys.includes(c.dataIndex)) {
|
|
224581
|
+
c.show = false;
|
|
224582
|
+
}
|
|
224583
|
+
});
|
|
224550
224584
|
setDndColumns(columns);
|
|
224551
224585
|
setItems(defaultItems);
|
|
224552
224586
|
}, [columns]);
|
|
@@ -224562,6 +224596,7 @@
|
|
|
224562
224596
|
columns: columns
|
|
224563
224597
|
});
|
|
224564
224598
|
}
|
|
224599
|
+
// 列分组进行覆盖,只允许存在一个
|
|
224565
224600
|
if (value.col.length >= 2) {
|
|
224566
224601
|
value.tableHeader = getSortInsert(value.tableHeader, items.col[0], {
|
|
224567
224602
|
columns: columns
|
|
@@ -224573,7 +224608,7 @@
|
|
|
224573
224608
|
setItems(value);
|
|
224574
224609
|
setGroupRowKeys(getDataIndexForTitle(value.row, columns));
|
|
224575
224610
|
setGroupColKeys(getDataIndexForTitle(value.col, columns));
|
|
224576
|
-
var newColumns = getSortDndColumns(value
|
|
224611
|
+
var newColumns = getSortDndColumns(value, {
|
|
224577
224612
|
columns: columns
|
|
224578
224613
|
});
|
|
224579
224614
|
setDndColumns(newColumns);
|
|
@@ -224590,7 +224625,9 @@
|
|
|
224590
224625
|
|
|
224591
224626
|
function HeaderCellContent(props) {
|
|
224592
224627
|
var column = props.column,
|
|
224593
|
-
children = props.children
|
|
224628
|
+
children = props.children,
|
|
224629
|
+
openRowGroup = props.openRowGroup,
|
|
224630
|
+
openColGroup = props.openColGroup;
|
|
224594
224631
|
var rowGroup = column.rowGroup,
|
|
224595
224632
|
colGroup = column.colGroup,
|
|
224596
224633
|
_column$title = column.title,
|
|
@@ -224611,6 +224648,7 @@
|
|
|
224611
224648
|
touchAction: 'none',
|
|
224612
224649
|
display: 'flex'
|
|
224613
224650
|
};
|
|
224651
|
+
var isShow = openRowGroup && rowGroup || openColGroup && colGroup;
|
|
224614
224652
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
224615
224653
|
style: {
|
|
224616
224654
|
display: 'flex',
|
|
@@ -224620,13 +224658,13 @@
|
|
|
224620
224658
|
style: {
|
|
224621
224659
|
flex: 1
|
|
224622
224660
|
}
|
|
224623
|
-
}, children),
|
|
224661
|
+
}, children), isShow && /*#__PURE__*/React__default['default'].createElement(Handle$1, _extends$2({
|
|
224624
224662
|
style: style,
|
|
224625
224663
|
ref: setNodeRef
|
|
224626
224664
|
}, attributes, listeners)));
|
|
224627
224665
|
}
|
|
224628
224666
|
|
|
224629
|
-
var _excluded$1$ = ["columns", "dataSource", "autoSize", "rowClick", "onDoubleClick", "checkConfig", "summary", "pagination", "hiddenPage", "loading", "virtual", "sortOpen", "colSortOpen", "resizeable", "customCheck", "components", "rowSelection", "columnsState", "onChange", "filterChange", "tableRowType", "size", "openSheet", "editSheet", "dataChange", "openColGroup", "colGroupTitle", "openRowGroup", "rowGroupTitle", "groupWidth", "onGroupChange", "emptyProps"],
|
|
224667
|
+
var _excluded$1$ = ["columns", "dataSource", "autoSize", "rowClick", "onDoubleClick", "checkConfig", "summary", "pagination", "hiddenPage", "loading", "virtual", "sortOpen", "colSortOpen", "resizeable", "customCheck", "components", "rowSelection", "columnsState", "onChange", "filterChange", "tableRowType", "size", "openSheet", "editSheet", "dataChange", "openColGroup", "colGroupTitle", "openRowGroup", "rowGroupTitle", "groupWidth", "groupRowKeys", "groupColKeys", "onGroupChange", "emptyProps"],
|
|
224630
224668
|
_excluded2$r = ["className", "style"],
|
|
224631
224669
|
_excluded3$6 = ["onResize", "width", "dataIndex", "onResizeStop"];
|
|
224632
224670
|
var Summary$1 = ProviderWarp.Summary;
|
|
@@ -224700,10 +224738,15 @@
|
|
|
224700
224738
|
openRowGroup = props.openRowGroup,
|
|
224701
224739
|
rowGroupTitle = props.rowGroupTitle,
|
|
224702
224740
|
groupWidth = props.groupWidth,
|
|
224741
|
+
customizeGroupRowKeys = props.groupRowKeys,
|
|
224742
|
+
customizeGroupColKeys = props.groupColKeys,
|
|
224703
224743
|
_props$onGroupChange = props.onGroupChange,
|
|
224704
224744
|
onGroupChange = _props$onGroupChange === void 0 ? function () {} : _props$onGroupChange,
|
|
224705
224745
|
emptyProps = props.emptyProps,
|
|
224706
224746
|
resetProps = _objectWithoutProperties$1(props, _excluded$1$);
|
|
224747
|
+
if (!Array.isArray(customizeColumns) || !customizeColumns.length) {
|
|
224748
|
+
return null;
|
|
224749
|
+
}
|
|
224707
224750
|
var _resetProps$rowKey = resetProps.rowKey,
|
|
224708
224751
|
rowKey = _resetProps$rowKey === void 0 ? 'id' : _resetProps$rowKey;
|
|
224709
224752
|
var _React$useContext = React__default['default'].useContext(ConfigContext$5),
|
|
@@ -224726,8 +224769,12 @@
|
|
|
224726
224769
|
useActiveKey = _useState2[0],
|
|
224727
224770
|
setActiveKey = _useState2[1]; // 行选中
|
|
224728
224771
|
var tableWarpRef = React.useRef(null);
|
|
224772
|
+
/** 记录最原始数据 */
|
|
224729
224773
|
var dataSourceRef = React.useRef(null);
|
|
224774
|
+
dataSourceRef.current = customizeDataSource;
|
|
224730
224775
|
var columnsRef = React.useRef(null);
|
|
224776
|
+
columnsRef.current = customizeColumns;
|
|
224777
|
+
|
|
224731
224778
|
/** 右键的ref */
|
|
224732
224779
|
var contentMenuRef = React.useRef(null);
|
|
224733
224780
|
/** 当前展开的列 */
|
|
@@ -224745,7 +224792,9 @@
|
|
|
224745
224792
|
openColGroup: openColGroup,
|
|
224746
224793
|
openRowGroup: openRowGroup,
|
|
224747
224794
|
colSortOpen: colSortOpen,
|
|
224748
|
-
filterChange: filterChange
|
|
224795
|
+
filterChange: filterChange,
|
|
224796
|
+
customizeGroupRowKeys: customizeGroupRowKeys,
|
|
224797
|
+
customizeGroupColKeys: customizeGroupColKeys
|
|
224749
224798
|
}),
|
|
224750
224799
|
dndColumns = _useDndItems.dndColumns,
|
|
224751
224800
|
items = _useDndItems.items,
|
|
@@ -224754,14 +224803,6 @@
|
|
|
224754
224803
|
updateItems = _useDndItems.updateItems;
|
|
224755
224804
|
onGroupChange && onGroupChange(groupRowKeys, groupColKeys);
|
|
224756
224805
|
|
|
224757
|
-
/** 记录最原始数据 */
|
|
224758
|
-
React.useEffect(function () {
|
|
224759
|
-
dataSourceRef.current = customizeDataSource;
|
|
224760
|
-
}, [customizeDataSource]);
|
|
224761
|
-
React.useEffect(function () {
|
|
224762
|
-
columnsRef.current = customizeColumns;
|
|
224763
|
-
}, [customizeColumns]);
|
|
224764
|
-
|
|
224765
224806
|
/** 行分组 */
|
|
224766
224807
|
var _useGroupDataSource = useGroupDataSource({
|
|
224767
224808
|
groupRowKeys: groupRowKeys,
|
|
@@ -224778,8 +224819,8 @@
|
|
|
224778
224819
|
columns: dndColumns
|
|
224779
224820
|
};
|
|
224780
224821
|
}
|
|
224781
|
-
return transformWithColGroup(dndColumns, groupDataSource, groupColKeys);
|
|
224782
|
-
}, [dndColumns, groupDataSource, groupColKeys]),
|
|
224822
|
+
return transformWithColGroup(dndColumns, groupDataSource, groupColKeys, groupRowKeys);
|
|
224823
|
+
}, [dndColumns, groupDataSource, groupColKeys, groupRowKeys]),
|
|
224783
224824
|
columns = _useMemo.columns,
|
|
224784
224825
|
dataSource = _useMemo.dataSource;
|
|
224785
224826
|
React.useEffect(function () {
|
|
@@ -225455,21 +225496,23 @@
|
|
|
225455
225496
|
var resetColumns = React.useCallback(function () {
|
|
225456
225497
|
var colIndex = 0;
|
|
225457
225498
|
var traverseColumns = function traverseColumns(columns) {
|
|
225458
|
-
|
|
225499
|
+
var _loop = function _loop(_i) {
|
|
225500
|
+
var col = columns[_i];
|
|
225459
225501
|
if (col.show === false) {
|
|
225460
|
-
|
|
225461
|
-
|
|
225462
|
-
if (col.children && col.children.length) {
|
|
225502
|
+
columns.splice(_i, 1);
|
|
225503
|
+
_i -= 1;
|
|
225504
|
+
} else if (col.children && col.children.length) {
|
|
225463
225505
|
traverseColumns(col.children);
|
|
225464
|
-
return;
|
|
225465
225506
|
} else {
|
|
225466
225507
|
// $_ 开头表示私有属性
|
|
225467
225508
|
col.$_colIndex = colIndex;
|
|
225509
|
+
// eslint-disable-next-line no-loop-func
|
|
225468
225510
|
col.onHeaderCell = function (column) {
|
|
225511
|
+
i = _i;
|
|
225469
225512
|
return resizeable ? {
|
|
225470
225513
|
width: column.width,
|
|
225471
225514
|
dataIndex: column.dataIndex,
|
|
225472
|
-
onResize: handleResize(
|
|
225515
|
+
onResize: handleResize(_i),
|
|
225473
225516
|
onResizeStop: endResize
|
|
225474
225517
|
} : {
|
|
225475
225518
|
width: column.width,
|
|
@@ -225478,6 +225521,7 @@
|
|
|
225478
225521
|
};
|
|
225479
225522
|
if (openSheet) {
|
|
225480
225523
|
col.onCell = function (record, rowIndex) {
|
|
225524
|
+
i = _i;
|
|
225481
225525
|
return {
|
|
225482
225526
|
record: record,
|
|
225483
225527
|
rowKey: rowKey,
|
|
@@ -225496,9 +225540,13 @@
|
|
|
225496
225540
|
};
|
|
225497
225541
|
};
|
|
225498
225542
|
}
|
|
225543
|
+
colIndex += 1;
|
|
225499
225544
|
}
|
|
225500
|
-
|
|
225501
|
-
}
|
|
225545
|
+
i = _i;
|
|
225546
|
+
};
|
|
225547
|
+
for (var i = 0; i < columns.length; i += 1) {
|
|
225548
|
+
_loop(i);
|
|
225549
|
+
}
|
|
225502
225550
|
};
|
|
225503
225551
|
var innerColumns = lodash.cloneDeep(useColumns.filter(function (item) {
|
|
225504
225552
|
return item.show !== false;
|
|
@@ -225773,7 +225821,10 @@
|
|
|
225773
225821
|
}
|
|
225774
225822
|
}, /*#__PURE__*/React__default['default'].createElement("th", restProps, /*#__PURE__*/React__default['default'].createElement(HeaderCellContent, _extends$2({
|
|
225775
225823
|
column: column
|
|
225776
|
-
}, props
|
|
225824
|
+
}, props, {
|
|
225825
|
+
openRowGroup: openRowGroup,
|
|
225826
|
+
openColGroup: openColGroup
|
|
225827
|
+
}))));
|
|
225777
225828
|
};
|
|
225778
225829
|
var colDraggableContainer = React.useCallback(function (_ref4) {
|
|
225779
225830
|
var props = _extends$2({}, (_objectDestructuringEmpty(_ref4), _ref4));
|