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.
@@ -1759,6 +1759,9 @@ p {
1759
1759
  color: var(--primary-color);
1760
1760
  cursor: pointer;
1761
1761
  }
1762
+ .lm_custom_option_columns .custom_hiddle {
1763
+ display: none;
1764
+ }
1762
1765
  .lm_custom_option_columns .fixed_title {
1763
1766
  color: var(--color-45);
1764
1767
  font-size: 12px;
@@ -536,6 +536,9 @@ p {
536
536
  color: var(--primary-color);
537
537
  cursor: pointer;
538
538
  }
539
+ .lm_custom_option_columns .custom_hiddle {
540
+ display: none;
541
+ }
539
542
  .lm_custom_option_columns .fixed_title {
540
543
  color: var(--color-45);
541
544
  font-size: 12px;
@@ -24,6 +24,9 @@
24
24
  color: var(--primary-color);
25
25
  cursor: pointer;
26
26
  }
27
+ .lm_custom_option_columns .custom_hiddle {
28
+ display: none;
29
+ }
27
30
  .lm_custom_option_columns .fixed_title {
28
31
  color: var(--color-45);
29
32
  font-size: 12px;
@@ -78,6 +78,9 @@ var EditableRow = function EditableRow(_a) {
78
78
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
79
79
  form = _Form$useForm2[0];
80
80
 
81
+ var dataKey = props.dataKey,
82
+ pushAllForm = props.pushAllForm;
83
+ pushAllForm === null || pushAllForm === void 0 ? void 0 : pushAllForm(form, dataKey, index);
81
84
  return /*#__PURE__*/React.createElement(Form, {
82
85
  form: form,
83
86
  disabled: props.disabled || false,
@@ -95,6 +98,9 @@ var EditableSortRow = function EditableSortRow(_a) {
95
98
  _Form$useForm4 = _slicedToArray(_Form$useForm3, 1),
96
99
  form = _Form$useForm4[0];
97
100
 
101
+ var dataKey = props.dataKey,
102
+ pushAllForm = props.pushAllForm;
103
+ pushAllForm === null || pushAllForm === void 0 ? void 0 : pushAllForm(form, dataKey, index);
98
104
  return /*#__PURE__*/React.createElement(Form, {
99
105
  form: form,
100
106
  disabled: props.disabled || false,
@@ -728,6 +734,12 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
728
734
  disabledDataSourceRowKeys.current = checkTableRowIsDisable(deepDataSourceRef.current, localDisabledRows.disabledRows, _rowKey);
729
735
  var tableWarpRef = useRef(null);
730
736
  var autoSizerRef = useRef(null);
737
+ var allFormListRef = useRef({});
738
+ var scrollToIndexRef = useRef(null);
739
+
740
+ var _Form$useForm5 = Form.useForm(),
741
+ _Form$useForm6 = _slicedToArray(_Form$useForm5, 1),
742
+ checkForm = _Form$useForm6[0];
731
743
 
732
744
  var onColSortEnd = function onColSortEnd(active, over) {
733
745
  var _a;
@@ -1272,12 +1284,249 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
1272
1284
  },
1273
1285
  columns: columns.map(function (item) {
1274
1286
  return omit(item, ['render', 'sorter', 'onFilter', 'filters', 'componentProps', 'formProps', 'editable']);
1275
- })
1287
+ }),
1288
+ // verify: async () => {
1289
+ // let allRule = {}
1290
+ // let time
1291
+ // let fullNum = 0
1292
+ // columns.forEach((col: any) => {
1293
+ // if (col?.formProps?.rules) {
1294
+ // allRule[col.dataIndex] = col?.formProps?.rules || []
1295
+ // }
1296
+ // })
1297
+ // const validator = new AsyncValidator(allRule);
1298
+ // let flag = true
1299
+ // let messageIndex = null
1300
+ // let errorRowKey = null
1301
+ // let errorInfo = null
1302
+ // const deepValidator = async (data, index) => {
1303
+ // for (let i = 0; i < data.length; i++) {
1304
+ // if (flag) {
1305
+ // try {
1306
+ // await validator.validate(data[i], (errors, fields) => {
1307
+ // if (errors) {
1308
+ // errorInfo = { errors, fields, value: data[i] };
1309
+ // flag = false
1310
+ // messageIndex = index === null ? i : index
1311
+ // errorRowKey = data?.[i]?.[rowKey]
1312
+ // } else if (data[i].children) {
1313
+ // deepValidator(data[i].children, i)
1314
+ // }
1315
+ // })
1316
+ // } catch (error) {
1317
+ // break;
1318
+ // }
1319
+ // }
1320
+ // }
1321
+ // }
1322
+ // await deepValidator(dataSource, null)
1323
+ // console.log(flag, 'fff')
1324
+ // if (flag) {
1325
+ // return Promise.resolve(dataSource)
1326
+ // } else {
1327
+ // setTimeout(() => {
1328
+ // if (messageIndex !== null) {
1329
+ // scrollToIndexRef.current?.(messageIndex, { align: 'center' })
1330
+ // time = setInterval(async () => {
1331
+ // fullNum++
1332
+ // if (fullNum > 5) {
1333
+ // clearInterval(time)
1334
+ // } else {
1335
+ // const form = (Object.values(allFormListRef.current || []).find((item: any) => item.key === errorRowKey) as any)?.form
1336
+ // if (form) {
1337
+ // try {
1338
+ // await form.validateFields()
1339
+ // console.log('验证成功')
1340
+ // } catch (error) {
1341
+ // console.log('验证失败', error)
1342
+ // return error
1343
+ // } finally {
1344
+ // clearInterval(time)
1345
+ // }
1346
+ // }
1347
+ // }
1348
+ // }, 500)
1349
+ // }
1350
+ // }, 100)
1351
+ // return Promise.reject(errorInfo)
1352
+ // }
1353
+ // },
1354
+ verify: function verify() {
1355
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
1356
+ var time, fullNum, flag, messageIndex, errorRowKey, errorInfo, deepValidator;
1357
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1358
+ while (1) {
1359
+ switch (_context4.prev = _context4.next) {
1360
+ case 0:
1361
+ fullNum = 0;
1362
+ flag = true;
1363
+ messageIndex = null;
1364
+ errorRowKey = null;
1365
+ errorInfo = null;
1366
+
1367
+ deepValidator = function deepValidator(data, index) {
1368
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1369
+ var _c, i;
1370
+
1371
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1372
+ while (1) {
1373
+ switch (_context2.prev = _context2.next) {
1374
+ case 0:
1375
+ i = 0;
1376
+
1377
+ case 1:
1378
+ if (!(i < data.length)) {
1379
+ _context2.next = 21;
1380
+ break;
1381
+ }
1382
+
1383
+ if (!flag) {
1384
+ _context2.next = 18;
1385
+ break;
1386
+ }
1387
+
1388
+ _context2.prev = 3;
1389
+ checkForm.resetFields();
1390
+ checkForm.setFieldsValue(data[i]);
1391
+ _context2.next = 8;
1392
+ return checkForm.validateFields();
1393
+
1394
+ case 8:
1395
+ if (data[i].children) {
1396
+ deepValidator(data[i].children, i);
1397
+ }
1398
+
1399
+ _context2.next = 18;
1400
+ break;
1401
+
1402
+ case 11:
1403
+ _context2.prev = 11;
1404
+ _context2.t0 = _context2["catch"](3);
1405
+ errorInfo = {
1406
+ error: _context2.t0,
1407
+ value: data[i]
1408
+ };
1409
+ flag = false;
1410
+ messageIndex = index === null ? i : index;
1411
+ errorRowKey = (_c = data === null || data === void 0 ? void 0 : data[i]) === null || _c === void 0 ? void 0 : _c[_rowKey];
1412
+ return _context2.abrupt("break", 21);
1413
+
1414
+ case 18:
1415
+ i++;
1416
+ _context2.next = 1;
1417
+ break;
1418
+
1419
+ case 21:
1420
+ case "end":
1421
+ return _context2.stop();
1422
+ }
1423
+ }
1424
+ }, _callee2, null, [[3, 11]]);
1425
+ }));
1426
+ };
1427
+
1428
+ _context4.next = 8;
1429
+ return deepValidator(dataSource, null);
1430
+
1431
+ case 8:
1432
+ if (!flag) {
1433
+ _context4.next = 12;
1434
+ break;
1435
+ }
1436
+
1437
+ return _context4.abrupt("return", Promise.resolve(dataSource));
1438
+
1439
+ case 12:
1440
+ setTimeout(function () {
1441
+ var _a;
1442
+
1443
+ if (messageIndex !== null) {
1444
+ (_a = scrollToIndexRef.current) === null || _a === void 0 ? void 0 : _a.call(scrollToIndexRef, messageIndex, {
1445
+ align: 'center'
1446
+ });
1447
+ time = setInterval(function () {
1448
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
1449
+ var _b, form;
1450
+
1451
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1452
+ while (1) {
1453
+ switch (_context3.prev = _context3.next) {
1454
+ case 0:
1455
+ fullNum++;
1456
+
1457
+ if (!(fullNum > 5)) {
1458
+ _context3.next = 5;
1459
+ break;
1460
+ }
1461
+
1462
+ clearInterval(time);
1463
+ _context3.next = 20;
1464
+ break;
1465
+
1466
+ case 5:
1467
+ form = (_b = Object.values(allFormListRef.current || []).find(function (item) {
1468
+ return item.key === errorRowKey;
1469
+ })) === null || _b === void 0 ? void 0 : _b.form;
1470
+
1471
+ if (!form) {
1472
+ _context3.next = 20;
1473
+ break;
1474
+ }
1475
+
1476
+ _context3.prev = 7;
1477
+ _context3.next = 10;
1478
+ return form.validateFields();
1479
+
1480
+ case 10:
1481
+ console.log('验证成功');
1482
+ _context3.next = 17;
1483
+ break;
1484
+
1485
+ case 13:
1486
+ _context3.prev = 13;
1487
+ _context3.t0 = _context3["catch"](7);
1488
+ console.log('验证失败', _context3.t0);
1489
+ return _context3.abrupt("return", _context3.t0);
1490
+
1491
+ case 17:
1492
+ _context3.prev = 17;
1493
+ clearInterval(time);
1494
+ return _context3.finish(17);
1495
+
1496
+ case 20:
1497
+ case "end":
1498
+ return _context3.stop();
1499
+ }
1500
+ }
1501
+ }, _callee3, null, [[7, 13, 17, 20]]);
1502
+ }));
1503
+ }, 500);
1504
+ }
1505
+ }, 100);
1506
+ return _context4.abrupt("return", Promise.reject(errorInfo));
1507
+
1508
+ case 14:
1509
+ case "end":
1510
+ return _context4.stop();
1511
+ }
1512
+ }
1513
+ }, _callee4);
1514
+ }));
1515
+ }
1276
1516
  };
1277
1517
  });
1278
1518
  var isShowAddAction = useMemo(function () {
1279
1519
  return isEdit && isAdd || isHoverEdit && isAdd;
1280
1520
  }, [isEdit, isAdd, isHoverEdit]);
1521
+
1522
+ var pushAllForm = function pushAllForm(form, key, index) {
1523
+ allFormListRef.current[key] = {
1524
+ form: form,
1525
+ key: key,
1526
+ index: index
1527
+ };
1528
+ };
1529
+
1281
1530
  var config = useRef(Object.assign({
1282
1531
  pagination: false,
1283
1532
  tableLayout: 'fixed',
@@ -1288,7 +1537,11 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
1288
1537
  return record[_rowKey] || record.index || Math.random();
1289
1538
  },
1290
1539
  components: {
1291
- table: virtual ? VirtualTable : null,
1540
+ table: virtual ? function (props) {
1541
+ return /*#__PURE__*/React.createElement(VirtualTable, Object.assign({}, props, {
1542
+ fn: scrollToIndexRef
1543
+ }));
1544
+ } : null,
1292
1545
  body: Object.assign({
1293
1546
  row: function row(rowProps) {
1294
1547
  return sortOpen ? EditableSortRow(Object.assign(Object.assign({}, rowProps), {
@@ -1297,7 +1550,7 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
1297
1550
  virtual: virtual
1298
1551
  }));
1299
1552
  },
1300
- cell: MemoEditableCell
1553
+ cell: props.shouldUpdate ? EditableCell : MemoEditableCell
1301
1554
  }, sortOpen ? {
1302
1555
  wrapper: function wrapper(wrapperProps) {
1303
1556
  var _a, _b, _c;
@@ -1324,7 +1577,10 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
1324
1577
  var _a;
1325
1578
 
1326
1579
  return {
1327
- disabled: disabled || !!((_a = disabledDataSourceRowKeys.current) === null || _a === void 0 ? void 0 : _a.includes(record[_rowKey]))
1580
+ disabled: disabled || !!((_a = disabledDataSourceRowKeys.current) === null || _a === void 0 ? void 0 : _a.includes(record[_rowKey])),
1581
+ dataKey: record[_rowKey],
1582
+ index: index,
1583
+ pushAllForm: pushAllForm
1328
1584
  };
1329
1585
  }
1330
1586
  }, resetProps));
@@ -1396,7 +1652,15 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
1396
1652
  isShowAddAction: isShowAddAction,
1397
1653
  recordCreatorProps: recordCreatorProps,
1398
1654
  handleAdd: handleAdd
1399
- }));
1655
+ }), /*#__PURE__*/React.createElement(Form, {
1656
+ form: checkForm,
1657
+ component: false
1658
+ }, columns.map(function (item) {
1659
+ return /*#__PURE__*/React.createElement(Form.Item, Object.assign({
1660
+ noStyle: true,
1661
+ name: item.dataIndex
1662
+ }, (item === null || item === void 0 ? void 0 : item['formProps']) || {}));
1663
+ })));
1400
1664
  } // @ts-ignore
1401
1665
 
1402
1666
 
@@ -1449,6 +1713,14 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
1449
1713
  isShowAddAction: isShowAddAction,
1450
1714
  recordCreatorProps: recordCreatorProps,
1451
1715
  handleAdd: handleAdd
1452
- }));
1716
+ }), /*#__PURE__*/React.createElement(Form, {
1717
+ form: checkForm,
1718
+ component: false
1719
+ }, columns.map(function (item) {
1720
+ return /*#__PURE__*/React.createElement(Form.Item, Object.assign({
1721
+ noStyle: true,
1722
+ name: item.dataIndex
1723
+ }, (item === null || item === void 0 ? void 0 : item['formProps']) || {}));
1724
+ })));
1453
1725
  });
1454
1726
  export default /*#__PURE__*/memo(EditTable);
@@ -67,8 +67,7 @@ var DndContainer = function DndContainer(_ref) {
67
67
  move: move,
68
68
  items: items,
69
69
  tableWidth: tableWidth
70
- }; // console.log('instance', instance)
71
-
70
+ };
72
71
  return /*#__PURE__*/React.createElement(DndContext, {
73
72
  sensors: sensors,
74
73
  onDragStart: handleDragStart,
@@ -62,7 +62,7 @@ export function getExpandStatus(children) {
62
62
  return isExpandRow(children) ? (_e = (_d = (_c = (_b = (_a = children === null || children === void 0 ? void 0 : children[0]) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.children) === null || _c === void 0 ? void 0 : _c[1]) === null || _d === void 0 ? void 0 : _d.props) === null || _e === void 0 ? void 0 : _e['aria-label'] : '';
63
63
  }
64
64
  export function checkMemoShouldUploadSpecialFun(prev, next) {
65
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
65
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
66
66
 
67
67
  var checkExpandStatus = getExpandStatus(prev.children) === getExpandStatus(next.children);
68
68
 
@@ -116,13 +116,17 @@ export function checkMemoShouldUploadSpecialFun(prev, next) {
116
116
  return isEqual(prev.style, next.style);
117
117
  }
118
118
 
119
+ if (((_l = next.className) === null || _l === void 0 ? void 0 : _l.indexOf('ant-table-row-expand-icon-cell')) > -1) {
120
+ return false;
121
+ }
122
+
119
123
  if (next.className.indexOf('ant-table-selection-column') > -1) {
120
- return isEqual((_m = (_l = prev.children) === null || _l === void 0 ? void 0 : _l[1]) === null || _m === void 0 ? void 0 : _m.props, (_p = (_o = next.children) === null || _o === void 0 ? void 0 : _o[1]) === null || _p === void 0 ? void 0 : _p.props);
124
+ return 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);
121
125
  }
122
126
  /** 如果启用了快速复制功能,需要实时判断rowIndex与getLength */
123
127
 
124
128
 
125
- if (((_q = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _q === void 0 ? void 0 : _q.quickcopy) || ((_r = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _r === void 0 ? void 0 : _r.quickcopy)) {
129
+ 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)) {
126
130
  var pickProps = ['record', 'colIndex', 'rowIndex', 'getLength'];
127
131
  var p = pick(prev, pickProps);
128
132
  var n = pick(next, pickProps);
@@ -20,6 +20,8 @@ var useOptions = function useOptions(_ref) {
20
20
  ref = _ref.ref,
21
21
  trRef = _ref.trRef;
22
22
 
23
+ var _a;
24
+
23
25
  var _useStore = useStore(),
24
26
  state = _useStore.state,
25
27
  dispatch = _useStore.dispatch,
@@ -29,7 +31,9 @@ var useOptions = function useOptions(_ref) {
29
31
  var rowHeight = state.rowHeight,
30
32
  totalLen = state.totalLen;
31
33
  var sliceColumns = useMemo(function () {
32
- return children === null || children === void 0 ? void 0 : children.reduce(function (pre, cur) {
34
+ var _a;
35
+
36
+ return (_a = children === null || children === void 0 ? void 0 : children.reduce) === null || _a === void 0 ? void 0 : _a.call(children, function (pre, cur) {
33
37
  var _a, _b;
34
38
 
35
39
  if (typeof ((_a = cur.props) === null || _a === void 0 ? void 0 : _a.fixLeft) === 'number') {
@@ -58,9 +62,9 @@ var useOptions = function useOptions(_ref) {
58
62
  }, [sliceColumns]); // 非固定列长度
59
63
 
60
64
  var centerColumnsLen = useMemo(function () {
61
- var _a;
65
+ var _a, _b;
62
66
 
63
- return (_a = sliceColumns.centerColumns.length) !== null && _a !== void 0 ? _a : 0;
67
+ 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;
64
68
  }, [sliceColumns]);
65
69
  useEffect(function () {
66
70
  if (state.columnsLen !== centerColumnsLen) {
@@ -94,8 +98,10 @@ var useOptions = function useOptions(_ref) {
94
98
  }, [virtualItems]); // 右侧隐藏数量
95
99
 
96
100
  var rightColSpan = useMemo(function () {
97
- return sliceColumns.centerColumns.length - virtualItems.length - leftColSpan || 0;
98
- }, [sliceColumns.centerColumns.length, virtualItems.length, leftColSpan]);
101
+ var _a;
102
+
103
+ 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;
104
+ }, [(_a = sliceColumns === null || sliceColumns === void 0 ? void 0 : sliceColumns.centerColumns) === null || _a === void 0 ? void 0 : _a.length, virtualItems.length, leftColSpan]);
99
105
  return Object.assign(Object.assign({
100
106
  virtualItems: virtualItems
101
107
  }, sliceColumns), {
@@ -5,6 +5,7 @@ import { TableContext, useRealive } from './context';
5
5
  var VirtualTable = /*#__PURE__*/React.memo(function (tableProps) {
6
6
  var _a, _b, _c, _d;
7
7
 
8
+ var fn = tableProps.fn;
8
9
  var bodyRef = useRef(null);
9
10
 
10
11
  var _useRealive = useRealive(),
@@ -23,7 +24,8 @@ var VirtualTable = /*#__PURE__*/React.memo(function (tableProps) {
23
24
  return state.rowHeight;
24
25
  }, [state.rowHeight]),
25
26
  overscan: 5
26
- }); // 列动态宽度
27
+ });
28
+ fn.current = rowVirtual.scrollToIndex; // 列动态宽度
27
29
 
28
30
  var columnEstimateSize = useCallback(function (i) {
29
31
  var _a, _b;
@@ -1759,6 +1759,9 @@ p {
1759
1759
  color: var(--primary-color);
1760
1760
  cursor: pointer;
1761
1761
  }
1762
+ .lm_custom_option_columns .custom_hiddle {
1763
+ display: none;
1764
+ }
1762
1765
  .lm_custom_option_columns .fixed_title {
1763
1766
  color: var(--color-45);
1764
1767
  font-size: 12px;
@@ -536,6 +536,9 @@ p {
536
536
  color: var(--primary-color);
537
537
  cursor: pointer;
538
538
  }
539
+ .lm_custom_option_columns .custom_hiddle {
540
+ display: none;
541
+ }
539
542
  .lm_custom_option_columns .fixed_title {
540
543
  color: var(--color-45);
541
544
  font-size: 12px;
@@ -24,6 +24,9 @@
24
24
  color: var(--primary-color);
25
25
  cursor: pointer;
26
26
  }
27
+ .lm_custom_option_columns .custom_hiddle {
28
+ display: none;
29
+ }
27
30
  .lm_custom_option_columns .fixed_title {
28
31
  color: var(--color-45);
29
32
  font-size: 12px;