linkmore-design 1.1.27-alpha.2 → 1.1.27-alpha.4
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/index.umd.js +305 -14
- package/dist/index.umd.min.js +21 -21
- package/dist/variables.css +3 -0
- package/es/CustomTableOption/style/index.css +3 -0
- package/es/CustomTableOption/style/variables.css +3 -0
- package/es/LmEditTable/EditTable.js +278 -6
- package/es/LmEditTable/rowSort/DndContainerRow.js +1 -2
- package/es/LmEditTable/util.js +7 -3
- package/es/LmEditTable/virtual/VirtualRow.js +11 -5
- package/es/LmEditTable/virtual/VirtualTable.js +3 -1
- package/es/styles/variables.css +3 -0
- package/lib/CustomTableOption/style/index.css +3 -0
- package/lib/CustomTableOption/style/variables.css +3 -0
- package/lib/LmEditTable/EditTable.js +278 -6
- package/lib/LmEditTable/rowSort/DndContainerRow.js +1 -2
- package/lib/LmEditTable/util.js +7 -3
- package/lib/LmEditTable/virtual/VirtualRow.js +11 -5
- package/lib/LmEditTable/virtual/VirtualTable.js +3 -1
- package/lib/styles/variables.css +3 -0
- package/package.json +1 -1
|
@@ -112,6 +112,9 @@ var EditableRow = function EditableRow(_a) {
|
|
|
112
112
|
_Form$useForm2 = (0, _slicedToArray2.default)(_Form$useForm, 1),
|
|
113
113
|
form = _Form$useForm2[0];
|
|
114
114
|
|
|
115
|
+
var dataKey = props.dataKey,
|
|
116
|
+
pushAllForm = props.pushAllForm;
|
|
117
|
+
pushAllForm === null || pushAllForm === void 0 ? void 0 : pushAllForm(form, dataKey, index);
|
|
115
118
|
return /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Form, {
|
|
116
119
|
form: form,
|
|
117
120
|
disabled: props.disabled || false,
|
|
@@ -129,6 +132,9 @@ var EditableSortRow = function EditableSortRow(_a) {
|
|
|
129
132
|
_Form$useForm4 = (0, _slicedToArray2.default)(_Form$useForm3, 1),
|
|
130
133
|
form = _Form$useForm4[0];
|
|
131
134
|
|
|
135
|
+
var dataKey = props.dataKey,
|
|
136
|
+
pushAllForm = props.pushAllForm;
|
|
137
|
+
pushAllForm === null || pushAllForm === void 0 ? void 0 : pushAllForm(form, dataKey, index);
|
|
132
138
|
return /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Form, {
|
|
133
139
|
form: form,
|
|
134
140
|
disabled: props.disabled || false,
|
|
@@ -762,6 +768,12 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
762
768
|
disabledDataSourceRowKeys.current = (0, _util.checkTableRowIsDisable)(deepDataSourceRef.current, localDisabledRows.disabledRows, _rowKey);
|
|
763
769
|
var tableWarpRef = (0, _react.useRef)(null);
|
|
764
770
|
var autoSizerRef = (0, _react.useRef)(null);
|
|
771
|
+
var allFormListRef = (0, _react.useRef)({});
|
|
772
|
+
var scrollToIndexRef = (0, _react.useRef)(null);
|
|
773
|
+
|
|
774
|
+
var _Form$useForm5 = _linkmoreDesign.Form.useForm(),
|
|
775
|
+
_Form$useForm6 = (0, _slicedToArray2.default)(_Form$useForm5, 1),
|
|
776
|
+
checkForm = _Form$useForm6[0];
|
|
765
777
|
|
|
766
778
|
var onColSortEnd = function onColSortEnd(active, over) {
|
|
767
779
|
var _a;
|
|
@@ -1305,12 +1317,249 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1305
1317
|
},
|
|
1306
1318
|
columns: columns.map(function (item) {
|
|
1307
1319
|
return (0, _lodash.omit)(item, ['render', 'sorter', 'onFilter', 'filters', 'componentProps', 'formProps', 'editable']);
|
|
1308
|
-
})
|
|
1320
|
+
}),
|
|
1321
|
+
// verify: async () => {
|
|
1322
|
+
// let allRule = {}
|
|
1323
|
+
// let time
|
|
1324
|
+
// let fullNum = 0
|
|
1325
|
+
// columns.forEach((col: any) => {
|
|
1326
|
+
// if (col?.formProps?.rules) {
|
|
1327
|
+
// allRule[col.dataIndex] = col?.formProps?.rules || []
|
|
1328
|
+
// }
|
|
1329
|
+
// })
|
|
1330
|
+
// const validator = new AsyncValidator(allRule);
|
|
1331
|
+
// let flag = true
|
|
1332
|
+
// let messageIndex = null
|
|
1333
|
+
// let errorRowKey = null
|
|
1334
|
+
// let errorInfo = null
|
|
1335
|
+
// const deepValidator = async (data, index) => {
|
|
1336
|
+
// for (let i = 0; i < data.length; i++) {
|
|
1337
|
+
// if (flag) {
|
|
1338
|
+
// try {
|
|
1339
|
+
// await validator.validate(data[i], (errors, fields) => {
|
|
1340
|
+
// if (errors) {
|
|
1341
|
+
// errorInfo = { errors, fields, value: data[i] };
|
|
1342
|
+
// flag = false
|
|
1343
|
+
// messageIndex = index === null ? i : index
|
|
1344
|
+
// errorRowKey = data?.[i]?.[rowKey]
|
|
1345
|
+
// } else if (data[i].children) {
|
|
1346
|
+
// deepValidator(data[i].children, i)
|
|
1347
|
+
// }
|
|
1348
|
+
// })
|
|
1349
|
+
// } catch (error) {
|
|
1350
|
+
// break;
|
|
1351
|
+
// }
|
|
1352
|
+
// }
|
|
1353
|
+
// }
|
|
1354
|
+
// }
|
|
1355
|
+
// await deepValidator(dataSource, null)
|
|
1356
|
+
// console.log(flag, 'fff')
|
|
1357
|
+
// if (flag) {
|
|
1358
|
+
// return Promise.resolve(dataSource)
|
|
1359
|
+
// } else {
|
|
1360
|
+
// setTimeout(() => {
|
|
1361
|
+
// if (messageIndex !== null) {
|
|
1362
|
+
// scrollToIndexRef.current?.(messageIndex, { align: 'center' })
|
|
1363
|
+
// time = setInterval(async () => {
|
|
1364
|
+
// fullNum++
|
|
1365
|
+
// if (fullNum > 5) {
|
|
1366
|
+
// clearInterval(time)
|
|
1367
|
+
// } else {
|
|
1368
|
+
// const form = (Object.values(allFormListRef.current || []).find((item: any) => item.key === errorRowKey) as any)?.form
|
|
1369
|
+
// if (form) {
|
|
1370
|
+
// try {
|
|
1371
|
+
// await form.validateFields()
|
|
1372
|
+
// console.log('验证成功')
|
|
1373
|
+
// } catch (error) {
|
|
1374
|
+
// console.log('验证失败', error)
|
|
1375
|
+
// return error
|
|
1376
|
+
// } finally {
|
|
1377
|
+
// clearInterval(time)
|
|
1378
|
+
// }
|
|
1379
|
+
// }
|
|
1380
|
+
// }
|
|
1381
|
+
// }, 500)
|
|
1382
|
+
// }
|
|
1383
|
+
// }, 100)
|
|
1384
|
+
// return Promise.reject(errorInfo)
|
|
1385
|
+
// }
|
|
1386
|
+
// },
|
|
1387
|
+
verify: function verify() {
|
|
1388
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee4() {
|
|
1389
|
+
var time, fullNum, flag, messageIndex, errorRowKey, errorInfo, deepValidator;
|
|
1390
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee4$(_context4) {
|
|
1391
|
+
while (1) {
|
|
1392
|
+
switch (_context4.prev = _context4.next) {
|
|
1393
|
+
case 0:
|
|
1394
|
+
fullNum = 0;
|
|
1395
|
+
flag = true;
|
|
1396
|
+
messageIndex = null;
|
|
1397
|
+
errorRowKey = null;
|
|
1398
|
+
errorInfo = null;
|
|
1399
|
+
|
|
1400
|
+
deepValidator = function deepValidator(data, index) {
|
|
1401
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2() {
|
|
1402
|
+
var _c, i;
|
|
1403
|
+
|
|
1404
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
|
1405
|
+
while (1) {
|
|
1406
|
+
switch (_context2.prev = _context2.next) {
|
|
1407
|
+
case 0:
|
|
1408
|
+
i = 0;
|
|
1409
|
+
|
|
1410
|
+
case 1:
|
|
1411
|
+
if (!(i < data.length)) {
|
|
1412
|
+
_context2.next = 21;
|
|
1413
|
+
break;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
if (!flag) {
|
|
1417
|
+
_context2.next = 18;
|
|
1418
|
+
break;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
_context2.prev = 3;
|
|
1422
|
+
checkForm.resetFields();
|
|
1423
|
+
checkForm.setFieldsValue(data[i]);
|
|
1424
|
+
_context2.next = 8;
|
|
1425
|
+
return checkForm.validateFields();
|
|
1426
|
+
|
|
1427
|
+
case 8:
|
|
1428
|
+
if (data[i].children) {
|
|
1429
|
+
deepValidator(data[i].children, i);
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
_context2.next = 18;
|
|
1433
|
+
break;
|
|
1434
|
+
|
|
1435
|
+
case 11:
|
|
1436
|
+
_context2.prev = 11;
|
|
1437
|
+
_context2.t0 = _context2["catch"](3);
|
|
1438
|
+
errorInfo = {
|
|
1439
|
+
error: _context2.t0,
|
|
1440
|
+
value: data[i]
|
|
1441
|
+
};
|
|
1442
|
+
flag = false;
|
|
1443
|
+
messageIndex = index === null ? i : index;
|
|
1444
|
+
errorRowKey = (_c = data === null || data === void 0 ? void 0 : data[i]) === null || _c === void 0 ? void 0 : _c[_rowKey];
|
|
1445
|
+
return _context2.abrupt("break", 21);
|
|
1446
|
+
|
|
1447
|
+
case 18:
|
|
1448
|
+
i++;
|
|
1449
|
+
_context2.next = 1;
|
|
1450
|
+
break;
|
|
1451
|
+
|
|
1452
|
+
case 21:
|
|
1453
|
+
case "end":
|
|
1454
|
+
return _context2.stop();
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
}, _callee2, null, [[3, 11]]);
|
|
1458
|
+
}));
|
|
1459
|
+
};
|
|
1460
|
+
|
|
1461
|
+
_context4.next = 8;
|
|
1462
|
+
return deepValidator(dataSource, null);
|
|
1463
|
+
|
|
1464
|
+
case 8:
|
|
1465
|
+
if (!flag) {
|
|
1466
|
+
_context4.next = 12;
|
|
1467
|
+
break;
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
return _context4.abrupt("return", Promise.resolve(dataSource));
|
|
1471
|
+
|
|
1472
|
+
case 12:
|
|
1473
|
+
setTimeout(function () {
|
|
1474
|
+
var _a;
|
|
1475
|
+
|
|
1476
|
+
if (messageIndex !== null) {
|
|
1477
|
+
(_a = scrollToIndexRef.current) === null || _a === void 0 ? void 0 : _a.call(scrollToIndexRef, messageIndex, {
|
|
1478
|
+
align: 'center'
|
|
1479
|
+
});
|
|
1480
|
+
time = setInterval(function () {
|
|
1481
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3() {
|
|
1482
|
+
var _b, form;
|
|
1483
|
+
|
|
1484
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee3$(_context3) {
|
|
1485
|
+
while (1) {
|
|
1486
|
+
switch (_context3.prev = _context3.next) {
|
|
1487
|
+
case 0:
|
|
1488
|
+
fullNum++;
|
|
1489
|
+
|
|
1490
|
+
if (!(fullNum > 5)) {
|
|
1491
|
+
_context3.next = 5;
|
|
1492
|
+
break;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
clearInterval(time);
|
|
1496
|
+
_context3.next = 20;
|
|
1497
|
+
break;
|
|
1498
|
+
|
|
1499
|
+
case 5:
|
|
1500
|
+
form = (_b = Object.values(allFormListRef.current || []).find(function (item) {
|
|
1501
|
+
return item.key === errorRowKey;
|
|
1502
|
+
})) === null || _b === void 0 ? void 0 : _b.form;
|
|
1503
|
+
|
|
1504
|
+
if (!form) {
|
|
1505
|
+
_context3.next = 20;
|
|
1506
|
+
break;
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
_context3.prev = 7;
|
|
1510
|
+
_context3.next = 10;
|
|
1511
|
+
return form.validateFields();
|
|
1512
|
+
|
|
1513
|
+
case 10:
|
|
1514
|
+
console.log('验证成功');
|
|
1515
|
+
_context3.next = 17;
|
|
1516
|
+
break;
|
|
1517
|
+
|
|
1518
|
+
case 13:
|
|
1519
|
+
_context3.prev = 13;
|
|
1520
|
+
_context3.t0 = _context3["catch"](7);
|
|
1521
|
+
console.log('验证失败', _context3.t0);
|
|
1522
|
+
return _context3.abrupt("return", _context3.t0);
|
|
1523
|
+
|
|
1524
|
+
case 17:
|
|
1525
|
+
_context3.prev = 17;
|
|
1526
|
+
clearInterval(time);
|
|
1527
|
+
return _context3.finish(17);
|
|
1528
|
+
|
|
1529
|
+
case 20:
|
|
1530
|
+
case "end":
|
|
1531
|
+
return _context3.stop();
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
}, _callee3, null, [[7, 13, 17, 20]]);
|
|
1535
|
+
}));
|
|
1536
|
+
}, 500);
|
|
1537
|
+
}
|
|
1538
|
+
}, 100);
|
|
1539
|
+
return _context4.abrupt("return", Promise.reject(errorInfo));
|
|
1540
|
+
|
|
1541
|
+
case 14:
|
|
1542
|
+
case "end":
|
|
1543
|
+
return _context4.stop();
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}, _callee4);
|
|
1547
|
+
}));
|
|
1548
|
+
}
|
|
1309
1549
|
};
|
|
1310
1550
|
});
|
|
1311
1551
|
var isShowAddAction = (0, _react.useMemo)(function () {
|
|
1312
1552
|
return isEdit && isAdd || isHoverEdit && isAdd;
|
|
1313
1553
|
}, [isEdit, isAdd, isHoverEdit]);
|
|
1554
|
+
|
|
1555
|
+
var pushAllForm = function pushAllForm(form, key, index) {
|
|
1556
|
+
allFormListRef.current[key] = {
|
|
1557
|
+
form: form,
|
|
1558
|
+
key: key,
|
|
1559
|
+
index: index
|
|
1560
|
+
};
|
|
1561
|
+
};
|
|
1562
|
+
|
|
1314
1563
|
var config = (0, _react.useRef)(Object.assign({
|
|
1315
1564
|
pagination: false,
|
|
1316
1565
|
tableLayout: 'fixed',
|
|
@@ -1321,7 +1570,11 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1321
1570
|
return record[_rowKey] || record.index || Math.random();
|
|
1322
1571
|
},
|
|
1323
1572
|
components: {
|
|
1324
|
-
table: virtual ?
|
|
1573
|
+
table: virtual ? function (props) {
|
|
1574
|
+
return /*#__PURE__*/_react.default.createElement(_virtual.VirtualTable, Object.assign({}, props, {
|
|
1575
|
+
fn: scrollToIndexRef
|
|
1576
|
+
}));
|
|
1577
|
+
} : null,
|
|
1325
1578
|
body: Object.assign({
|
|
1326
1579
|
row: function row(rowProps) {
|
|
1327
1580
|
return sortOpen ? EditableSortRow(Object.assign(Object.assign({}, rowProps), {
|
|
@@ -1330,7 +1583,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1330
1583
|
virtual: virtual
|
|
1331
1584
|
}));
|
|
1332
1585
|
},
|
|
1333
|
-
cell: MemoEditableCell
|
|
1586
|
+
cell: props.shouldUpdate ? EditableCell : MemoEditableCell
|
|
1334
1587
|
}, sortOpen ? {
|
|
1335
1588
|
wrapper: function wrapper(wrapperProps) {
|
|
1336
1589
|
var _a, _b, _c;
|
|
@@ -1357,7 +1610,10 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1357
1610
|
var _a;
|
|
1358
1611
|
|
|
1359
1612
|
return {
|
|
1360
|
-
disabled: disabled || !!((_a = disabledDataSourceRowKeys.current) === null || _a === void 0 ? void 0 : _a.includes(record[_rowKey]))
|
|
1613
|
+
disabled: disabled || !!((_a = disabledDataSourceRowKeys.current) === null || _a === void 0 ? void 0 : _a.includes(record[_rowKey])),
|
|
1614
|
+
dataKey: record[_rowKey],
|
|
1615
|
+
index: index,
|
|
1616
|
+
pushAllForm: pushAllForm
|
|
1361
1617
|
};
|
|
1362
1618
|
}
|
|
1363
1619
|
}, resetProps));
|
|
@@ -1429,7 +1685,15 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1429
1685
|
isShowAddAction: isShowAddAction,
|
|
1430
1686
|
recordCreatorProps: recordCreatorProps,
|
|
1431
1687
|
handleAdd: handleAdd
|
|
1432
|
-
})
|
|
1688
|
+
}), /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Form, {
|
|
1689
|
+
form: checkForm,
|
|
1690
|
+
component: false
|
|
1691
|
+
}, columns.map(function (item) {
|
|
1692
|
+
return /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Form.Item, Object.assign({
|
|
1693
|
+
noStyle: true,
|
|
1694
|
+
name: item.dataIndex
|
|
1695
|
+
}, (item === null || item === void 0 ? void 0 : item['formProps']) || {}));
|
|
1696
|
+
})));
|
|
1433
1697
|
} // @ts-ignore
|
|
1434
1698
|
|
|
1435
1699
|
|
|
@@ -1482,7 +1746,15 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1482
1746
|
isShowAddAction: isShowAddAction,
|
|
1483
1747
|
recordCreatorProps: recordCreatorProps,
|
|
1484
1748
|
handleAdd: handleAdd
|
|
1485
|
-
})
|
|
1749
|
+
}), /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Form, {
|
|
1750
|
+
form: checkForm,
|
|
1751
|
+
component: false
|
|
1752
|
+
}, columns.map(function (item) {
|
|
1753
|
+
return /*#__PURE__*/_react.default.createElement(_linkmoreDesign.Form.Item, Object.assign({
|
|
1754
|
+
noStyle: true,
|
|
1755
|
+
name: item.dataIndex
|
|
1756
|
+
}, (item === null || item === void 0 ? void 0 : item['formProps']) || {}));
|
|
1757
|
+
})));
|
|
1486
1758
|
});
|
|
1487
1759
|
|
|
1488
1760
|
var _default = /*#__PURE__*/(0, _react.memo)(EditTable);
|
|
@@ -82,8 +82,7 @@ var DndContainer = function DndContainer(_ref) {
|
|
|
82
82
|
move: move,
|
|
83
83
|
items: items,
|
|
84
84
|
tableWidth: tableWidth
|
|
85
|
-
};
|
|
86
|
-
|
|
85
|
+
};
|
|
87
86
|
return /*#__PURE__*/_react.default.createElement(_core.DndContext, {
|
|
88
87
|
sensors: sensors,
|
|
89
88
|
onDragStart: handleDragStart,
|
package/lib/LmEditTable/util.js
CHANGED
|
@@ -88,7 +88,7 @@ function getExpandStatus(children) {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
function checkMemoShouldUploadSpecialFun(prev, next) {
|
|
91
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
91
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
92
92
|
|
|
93
93
|
var checkExpandStatus = getExpandStatus(prev.children) === getExpandStatus(next.children);
|
|
94
94
|
|
|
@@ -142,13 +142,17 @@ function checkMemoShouldUploadSpecialFun(prev, next) {
|
|
|
142
142
|
return (0, _lodash.isEqual)(prev.style, next.style);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
if (((_l = next.className) === null || _l === void 0 ? void 0 : _l.indexOf('ant-table-row-expand-icon-cell')) > -1) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
|
|
145
149
|
if (next.className.indexOf('ant-table-selection-column') > -1) {
|
|
146
|
-
return (0, _lodash.isEqual)((
|
|
150
|
+
return (0, _lodash.isEqual)((_o = (_m = prev.children) === null || _m === void 0 ? void 0 : _m[1]) === null || _o === void 0 ? void 0 : _o.props, (_q = (_p = next.children) === null || _p === void 0 ? void 0 : _p[1]) === null || _q === void 0 ? void 0 : _q.props);
|
|
147
151
|
}
|
|
148
152
|
/** 如果启用了快速复制功能,需要实时判断rowIndex与getLength */
|
|
149
153
|
|
|
150
154
|
|
|
151
|
-
if (((
|
|
155
|
+
if (((_r = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _r === void 0 ? void 0 : _r.quickcopy) || ((_s = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _s === void 0 ? void 0 : _s.quickcopy)) {
|
|
152
156
|
var pickProps = ['record', 'colIndex', 'rowIndex', 'getLength'];
|
|
153
157
|
var p = (0, _lodash.pick)(prev, pickProps);
|
|
154
158
|
var n = (0, _lodash.pick)(next, pickProps);
|
|
@@ -33,6 +33,8 @@ var useOptions = function useOptions(_ref) {
|
|
|
33
33
|
ref = _ref.ref,
|
|
34
34
|
trRef = _ref.trRef;
|
|
35
35
|
|
|
36
|
+
var _a;
|
|
37
|
+
|
|
36
38
|
var _useStore = (0, _context.useStore)(),
|
|
37
39
|
state = _useStore.state,
|
|
38
40
|
dispatch = _useStore.dispatch,
|
|
@@ -42,7 +44,9 @@ var useOptions = function useOptions(_ref) {
|
|
|
42
44
|
var rowHeight = state.rowHeight,
|
|
43
45
|
totalLen = state.totalLen;
|
|
44
46
|
var sliceColumns = (0, _react.useMemo)(function () {
|
|
45
|
-
|
|
47
|
+
var _a;
|
|
48
|
+
|
|
49
|
+
return (_a = children === null || children === void 0 ? void 0 : children.reduce) === null || _a === void 0 ? void 0 : _a.call(children, function (pre, cur) {
|
|
46
50
|
var _a, _b;
|
|
47
51
|
|
|
48
52
|
if (typeof ((_a = cur.props) === null || _a === void 0 ? void 0 : _a.fixLeft) === 'number') {
|
|
@@ -71,9 +75,9 @@ var useOptions = function useOptions(_ref) {
|
|
|
71
75
|
}, [sliceColumns]); // 非固定列长度
|
|
72
76
|
|
|
73
77
|
var centerColumnsLen = (0, _react.useMemo)(function () {
|
|
74
|
-
var _a;
|
|
78
|
+
var _a, _b;
|
|
75
79
|
|
|
76
|
-
return (_a = sliceColumns.centerColumns.length) !== null &&
|
|
80
|
+
return (_b = (_a = sliceColumns === null || sliceColumns === void 0 ? void 0 : sliceColumns.centerColumns) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
77
81
|
}, [sliceColumns]);
|
|
78
82
|
(0, _react.useEffect)(function () {
|
|
79
83
|
if (state.columnsLen !== centerColumnsLen) {
|
|
@@ -107,8 +111,10 @@ var useOptions = function useOptions(_ref) {
|
|
|
107
111
|
}, [virtualItems]); // 右侧隐藏数量
|
|
108
112
|
|
|
109
113
|
var rightColSpan = (0, _react.useMemo)(function () {
|
|
110
|
-
|
|
111
|
-
|
|
114
|
+
var _a;
|
|
115
|
+
|
|
116
|
+
return ((_a = sliceColumns === null || sliceColumns === void 0 ? void 0 : sliceColumns.centerColumns) === null || _a === void 0 ? void 0 : _a.length) - (virtualItems === null || virtualItems === void 0 ? void 0 : virtualItems.length) - leftColSpan || 0;
|
|
117
|
+
}, [(_a = sliceColumns === null || sliceColumns === void 0 ? void 0 : sliceColumns.centerColumns) === null || _a === void 0 ? void 0 : _a.length, virtualItems.length, leftColSpan]);
|
|
112
118
|
return Object.assign(Object.assign({
|
|
113
119
|
virtualItems: virtualItems
|
|
114
120
|
}, sliceColumns), {
|
|
@@ -20,6 +20,7 @@ var _context = require("./context");
|
|
|
20
20
|
var VirtualTable = /*#__PURE__*/_react.default.memo(function (tableProps) {
|
|
21
21
|
var _a, _b, _c, _d;
|
|
22
22
|
|
|
23
|
+
var fn = tableProps.fn;
|
|
23
24
|
var bodyRef = (0, _react.useRef)(null);
|
|
24
25
|
|
|
25
26
|
var _useRealive = (0, _context.useRealive)(),
|
|
@@ -38,7 +39,8 @@ var VirtualTable = /*#__PURE__*/_react.default.memo(function (tableProps) {
|
|
|
38
39
|
return state.rowHeight;
|
|
39
40
|
}, [state.rowHeight]),
|
|
40
41
|
overscan: 5
|
|
41
|
-
});
|
|
42
|
+
});
|
|
43
|
+
fn.current = rowVirtual.scrollToIndex; // 列动态宽度
|
|
42
44
|
|
|
43
45
|
var columnEstimateSize = (0, _react.useCallback)(function (i) {
|
|
44
46
|
var _a, _b;
|
package/lib/styles/variables.css
CHANGED