es-grid-template 1.7.27 → 1.7.29
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/es/grid-component/InternalTable.js +31 -36
- package/es/grid-component/TempTable.d.ts +4 -0
- package/es/grid-component/TempTable.js +21 -0
- package/es/grid-component/hooks/columns/index.js +3 -1
- package/es/grid-component/index.d.ts +2 -2
- package/es/grid-component/index.js +6 -4
- package/es/grid-component/styles.scss +0 -1
- package/es/grid-component/table/GridEdit.js +112 -96
- package/es/grid-component/type.d.ts +7 -1
- package/es/table-component/InternalTable.js +100 -127
- package/es/table-component/TableContainer.d.ts +6 -1
- package/es/table-component/TableContainer.js +82 -74
- package/es/table-component/TableContainerEdit.d.ts +4 -0
- package/es/table-component/TableContainerEdit.js +370 -85
- package/es/table-component/body/TableBody.d.ts +2 -8
- package/es/table-component/body/TableBody.js +1 -0
- package/es/table-component/body/TableBodyCell.d.ts +1 -1
- package/es/table-component/body/TableBodyCell.js +25 -12
- package/es/table-component/body/TableBodyCellEdit.d.ts +1 -1
- package/es/table-component/body/TableBodyCellEdit.js +44 -19
- package/es/table-component/body/TableBodyRow.d.ts +3 -3
- package/es/table-component/body/TableBodyRow.js +4 -6
- package/es/table-component/footer/TableFooter.d.ts +2 -8
- package/es/table-component/footer/TableFooter.js +14 -13
- package/es/table-component/footer/TableFooterCell.d.ts +3 -6
- package/es/table-component/footer/TableFooterCell.js +12 -10
- package/es/table-component/footer/TableFooterRow.d.ts +2 -8
- package/es/table-component/footer/TableFooterRow.js +23 -48
- package/es/table-component/header/TableHead.d.ts +4 -3
- package/es/table-component/header/TableHead.js +3 -61
- package/es/table-component/header/TableHeadCell.d.ts +0 -3
- package/es/table-component/header/TableHeadCell.js +11 -9
- package/es/table-component/header/TableHeadRow.d.ts +6 -6
- package/es/table-component/header/TableHeadRow.js +10 -32
- package/es/table-component/hook/utils.js +1 -1
- package/es/table-component/style.scss +26 -2
- package/es/table-component/table/Grid.d.ts +1 -0
- package/es/table-component/table/Grid.js +12 -6
- package/es/table-component/table/TableWrapper.d.ts +33 -0
- package/es/table-component/table/TableWrapper.js +245 -0
- package/es/table-component/type.d.ts +5 -4
- package/es/table-component/useContext.d.ts +4 -0
- package/es/table-component/useContext.js +4 -0
- package/lib/grid-component/InternalTable.js +30 -35
- package/lib/grid-component/TempTable.d.ts +4 -0
- package/lib/grid-component/TempTable.js +30 -0
- package/lib/grid-component/hooks/columns/index.js +3 -1
- package/lib/grid-component/index.d.ts +2 -2
- package/lib/grid-component/index.js +5 -3
- package/lib/grid-component/styles.scss +0 -1
- package/lib/grid-component/table/GridEdit.js +112 -96
- package/lib/grid-component/type.d.ts +7 -1
- package/lib/table-component/InternalTable.js +101 -127
- package/lib/table-component/TableContainer.d.ts +6 -1
- package/lib/table-component/TableContainer.js +84 -74
- package/lib/table-component/TableContainerEdit.d.ts +4 -0
- package/lib/table-component/TableContainerEdit.js +366 -83
- package/lib/table-component/body/TableBody.d.ts +2 -8
- package/lib/table-component/body/TableBody.js +2 -0
- package/lib/table-component/body/TableBodyCell.d.ts +1 -1
- package/lib/table-component/body/TableBodyCell.js +25 -12
- package/lib/table-component/body/TableBodyCellEdit.d.ts +1 -1
- package/lib/table-component/body/TableBodyCellEdit.js +43 -19
- package/lib/table-component/body/TableBodyRow.d.ts +3 -3
- package/lib/table-component/body/TableBodyRow.js +4 -6
- package/lib/table-component/footer/TableFooter.d.ts +2 -8
- package/lib/table-component/footer/TableFooter.js +15 -13
- package/lib/table-component/footer/TableFooterCell.d.ts +3 -6
- package/lib/table-component/footer/TableFooterCell.js +13 -10
- package/lib/table-component/footer/TableFooterRow.d.ts +2 -8
- package/lib/table-component/footer/TableFooterRow.js +23 -48
- package/lib/table-component/header/TableHead.d.ts +4 -3
- package/lib/table-component/header/TableHead.js +3 -61
- package/lib/table-component/header/TableHeadCell.d.ts +0 -3
- package/lib/table-component/header/TableHeadCell.js +11 -8
- package/lib/table-component/header/TableHeadRow.d.ts +6 -6
- package/lib/table-component/header/TableHeadRow.js +10 -32
- package/lib/table-component/hook/utils.js +1 -1
- package/lib/table-component/style.scss +26 -2
- package/lib/table-component/table/Grid.d.ts +1 -0
- package/lib/table-component/table/Grid.js +12 -6
- package/lib/table-component/table/TableWrapper.d.ts +33 -0
- package/lib/table-component/table/TableWrapper.js +254 -0
- package/lib/table-component/type.d.ts +5 -4
- package/lib/table-component/useContext.d.ts +4 -0
- package/lib/table-component/useContext.js +4 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import React, { createContext, Fragment, useCallback, useContext, useState } from 'react';
|
|
3
3
|
import 'react-resizable/css/styles.css';
|
|
4
4
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
|
-
import { addRowIdArray, booleanOperator, convertFilters, convertFlatColumn, filterDataByColumns4, findItemByKey, findItemPath, flattenArray, getAllRowKey, getFormat, getTypeFilter, groupArrayByColumns, numberOperator, removeColumns, removeInvisibleColumns, stringOperator, translateOption, unFlattenData, updateArrayByKey, updateColumnsByGroup,
|
|
5
|
+
import { addRowIdArray, booleanOperator, convertFilters, convertFlatColumn, filterDataByColumns4, findItemByKey, findItemPath, flattenArray, getAllRowKey, getFormat, getTypeFilter, groupArrayByColumns, isNullOrUndefined, numberOperator, removeColumns, removeInvisibleColumns, stringOperator, translateOption, unFlattenData, updateArrayByKey, updateColumnsByGroup,
|
|
6
6
|
// updateData,
|
|
7
7
|
updateOrInsert } from "./hooks";
|
|
8
8
|
import dayjs from "dayjs";
|
|
@@ -185,6 +185,7 @@ const InternalTable = props => {
|
|
|
185
185
|
wrapSettings,
|
|
186
186
|
onFilter,
|
|
187
187
|
onSorter,
|
|
188
|
+
defaultSorter,
|
|
188
189
|
...rest
|
|
189
190
|
} = props;
|
|
190
191
|
const id = React.useMemo(() => {
|
|
@@ -298,6 +299,7 @@ const InternalTable = props => {
|
|
|
298
299
|
setColumns(propsColumns);
|
|
299
300
|
}, [propsColumns]);
|
|
300
301
|
const handleOnFilter = queries => {
|
|
302
|
+
console.log('queries', queries);
|
|
301
303
|
if (onFilter) {
|
|
302
304
|
onFilter?.(convertFilters(queries));
|
|
303
305
|
} else {
|
|
@@ -330,30 +332,6 @@ const InternalTable = props => {
|
|
|
330
332
|
// @ts-ignore
|
|
331
333
|
return record => record?.[rowKey];
|
|
332
334
|
}, [rowKey]);
|
|
333
|
-
|
|
334
|
-
// const [transformSelectionColumns] = useColumns<RecordType>(
|
|
335
|
-
// {
|
|
336
|
-
// locale,
|
|
337
|
-
// t,
|
|
338
|
-
// rowKey,
|
|
339
|
-
// // dataSource: mergerdData,
|
|
340
|
-
// dataSource,
|
|
341
|
-
// buddhistLocale,
|
|
342
|
-
// dataSourceFilter: propDataSourceFilter,
|
|
343
|
-
// format,
|
|
344
|
-
// sortMultiple,
|
|
345
|
-
// groupAble,
|
|
346
|
-
// groupSetting,
|
|
347
|
-
// groupColumns,
|
|
348
|
-
// handleResize,
|
|
349
|
-
// // onMouseHover
|
|
350
|
-
// },
|
|
351
|
-
// );
|
|
352
|
-
|
|
353
|
-
// const mergedColumns: any = React.useMemo(() => {
|
|
354
|
-
// return transformSelectionColumns(columns)
|
|
355
|
-
// }, [columns, transformSelectionColumns])
|
|
356
|
-
|
|
357
335
|
const firstNonGroupColumn = flatColumns2(columns).find(col => col.field && col.field !== '#' && !groupColumns?.includes(col.field) && col.hidden !== true);
|
|
358
336
|
const nonGroupColumns = flatColumns2(columns).filter(col => col.field && col.field !== '#' && !groupColumns?.includes(col.field) && col.hidden !== true);
|
|
359
337
|
const getColumnSearchProps = useCallback(column => ({
|
|
@@ -367,6 +345,8 @@ const InternalTable = props => {
|
|
|
367
345
|
searchValue,
|
|
368
346
|
setSearchValue
|
|
369
347
|
}) => {
|
|
348
|
+
// console.log('selectedKeys', selectedKeys)
|
|
349
|
+
|
|
370
350
|
const type = getTypeFilter(column);
|
|
371
351
|
// const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? booleanOperator : (!type || type === 'Text' ? stringOperator : numberOperator)
|
|
372
352
|
|
|
@@ -402,6 +382,10 @@ const InternalTable = props => {
|
|
|
402
382
|
type: "primary",
|
|
403
383
|
onClick: () => {
|
|
404
384
|
// confirm({closeDropdown: false})
|
|
385
|
+
const typeFilter = getTypeFilter(column);
|
|
386
|
+
if ((!typeFilter || typeFilter === 'Text') && isNullOrUndefined(selectedKeys[0])) {
|
|
387
|
+
setSelectedKeys(['']);
|
|
388
|
+
}
|
|
405
389
|
confirm();
|
|
406
390
|
// handleSearch(selectedKeys as string[], confirm)
|
|
407
391
|
},
|
|
@@ -460,7 +444,9 @@ const InternalTable = props => {
|
|
|
460
444
|
id: id,
|
|
461
445
|
wrapSettings: wrapSettings
|
|
462
446
|
})),
|
|
463
|
-
ellipsis: column.ellipsis !== false,
|
|
447
|
+
ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
448
|
+
// ellipsis: column.ellipsis !== false,
|
|
449
|
+
|
|
464
450
|
align: column.textAlign ?? column.align,
|
|
465
451
|
fixed: column.fixedType ?? column.fixed,
|
|
466
452
|
isSummary: column.isSummary ?? column.haveSum,
|
|
@@ -519,15 +505,19 @@ const InternalTable = props => {
|
|
|
519
505
|
...(transformedColumn.allowFiltering === false ? {} : {
|
|
520
506
|
...getColumnSearchProps(column)
|
|
521
507
|
}),
|
|
522
|
-
sorter: column.sorter === false ? undefined : {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
508
|
+
// sorter: (column.sorter === false ? undefined : {
|
|
509
|
+
// // @ts-ignore
|
|
510
|
+
// compare: (a: any, b: any) => onSorter ? a : a[column.field] - b[column.field],
|
|
511
|
+
// multiple: sortMultiple ? colIndex : undefined
|
|
512
|
+
|
|
513
|
+
// }),
|
|
514
|
+
// @ts-ignore
|
|
515
|
+
sorter: (a, b) => a[column.field] - b[column.field],
|
|
527
516
|
sortIcon: args => {
|
|
528
517
|
const {
|
|
529
518
|
sortOrder
|
|
530
519
|
} = args;
|
|
520
|
+
console.log('sortOrder', sortOrder);
|
|
531
521
|
return /*#__PURE__*/React.createElement(Fragment, null, !sortOrder && /*#__PURE__*/React.createElement(SortCancel, {
|
|
532
522
|
fontSize: 15,
|
|
533
523
|
style: {
|
|
@@ -566,7 +556,8 @@ const InternalTable = props => {
|
|
|
566
556
|
id: `${column.field}`,
|
|
567
557
|
width: column.width,
|
|
568
558
|
onResize: handleResize?.(column),
|
|
569
|
-
className: column.headerTextAlign === 'center' ? 'head-align-center' : column.headerTextAlign === 'right' ? 'head-align-right' : ''
|
|
559
|
+
className: `${column.headerTextAlign === 'center' ? 'head-align-center' : column.headerTextAlign === 'right' ? 'head-align-right' : ''}
|
|
560
|
+
${wrapSettings && wrapSettings.wrapMode === 'Content' ? 'ui-rc-table-cell-ellipsis' : ''}`
|
|
570
561
|
}),
|
|
571
562
|
onCell: (data, index) => {
|
|
572
563
|
return {
|
|
@@ -603,10 +594,11 @@ const InternalTable = props => {
|
|
|
603
594
|
}
|
|
604
595
|
return renderContent(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
605
596
|
},
|
|
597
|
+
defaultSortOrder: 'ascend',
|
|
606
598
|
hidden: groupSetting && groupSetting.hiddenColumnGroup === false ? transformedColumn.hidden : groupAble && groupColumns && groupColumns.includes(column.field) ? true : transformedColumn.hidden
|
|
607
599
|
};
|
|
608
600
|
});
|
|
609
|
-
}, [columns, t, id, wrapSettings,
|
|
601
|
+
}, [columns, t, id, wrapSettings, editAble, getColumnSearchProps, groupSetting, groupAble, groupColumns, mergedData, filterStates, mergedFilterKeys, pagination, handleResize, firstNonGroupColumn?.field, nonGroupColumns, format]);
|
|
610
602
|
const transformColumns = React.useCallback(cols => {
|
|
611
603
|
return cols.map(column => {
|
|
612
604
|
const find = convertColumns.find(it => it.field === column.field);
|
|
@@ -627,11 +619,13 @@ const InternalTable = props => {
|
|
|
627
619
|
id: id,
|
|
628
620
|
wrapSettings: wrapSettings
|
|
629
621
|
})),
|
|
630
|
-
ellipsis: column.ellipsis !== false,
|
|
622
|
+
// ellipsis: column.ellipsis !== false,
|
|
623
|
+
ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
631
624
|
align: column.textAlign ?? column.align,
|
|
632
625
|
fixed: column.fixedType ?? column.fixed,
|
|
633
626
|
isSummary: column.isSummary ?? column.haveSum,
|
|
634
|
-
hidden: column.hidden ?? column.visible === false
|
|
627
|
+
hidden: column.hidden ?? column.visible === false,
|
|
628
|
+
defaultSortOrder: 'ascend'
|
|
635
629
|
};
|
|
636
630
|
|
|
637
631
|
// Xử lý đệ quy cho children
|
|
@@ -654,7 +648,7 @@ const InternalTable = props => {
|
|
|
654
648
|
};
|
|
655
649
|
}
|
|
656
650
|
});
|
|
657
|
-
}, [convertColumns, id, t, wrapSettings]);
|
|
651
|
+
}, [convertColumns, editAble, id, t, wrapSettings]);
|
|
658
652
|
const mergedColumns = React.useMemo(() => {
|
|
659
653
|
return transformColumns(columns);
|
|
660
654
|
}, [columns, transformColumns]);
|
|
@@ -906,6 +900,7 @@ const InternalTable = props => {
|
|
|
906
900
|
}
|
|
907
901
|
};
|
|
908
902
|
const handleChange = (paging, filters, sorter) => {
|
|
903
|
+
console.log('sorter', sorter);
|
|
909
904
|
onSorter?.(sorter);
|
|
910
905
|
};
|
|
911
906
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React, { Fragment } from 'react';
|
|
3
|
+
import Table from "../table-component";
|
|
4
|
+
import InternalTable from "./InternalTable";
|
|
5
|
+
const TempTable = props => {
|
|
6
|
+
const {
|
|
7
|
+
infiniteScroll,
|
|
8
|
+
groupAble,
|
|
9
|
+
editAble,
|
|
10
|
+
...rest
|
|
11
|
+
} = props;
|
|
12
|
+
const TabComponent = groupAble ? InternalTable : Table;
|
|
13
|
+
// const TabComponent = editAble ? Table : InternalTable
|
|
14
|
+
|
|
15
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(TabComponent, _extends({}, rest, {
|
|
16
|
+
infiniteScroll: infiniteScroll,
|
|
17
|
+
groupAble: groupAble,
|
|
18
|
+
editAble: editAble
|
|
19
|
+
})));
|
|
20
|
+
};
|
|
21
|
+
export default TempTable;
|
|
@@ -499,7 +499,9 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
499
499
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
500
500
|
placeholder: t ? t('Search') : `Search`,
|
|
501
501
|
value: selectedKeys[0],
|
|
502
|
-
onChange: e =>
|
|
502
|
+
onChange: e => {
|
|
503
|
+
setSelectedKeys(e.target.value ? [e.target.value] : ['']);
|
|
504
|
+
}
|
|
503
505
|
// onPressEnter={() => handleSearch(selectedKeys as string[], confirm)}
|
|
504
506
|
,
|
|
505
507
|
onPressEnter: () => confirm(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TempTable from './TempTable';
|
|
2
2
|
import type { ColumnsTable, TableProps, ColumnTable, CommandItem, ContextMenuItem } from './type';
|
|
3
3
|
import type { ToolbarItem } from "rc-master-ui/es/toolbar";
|
|
4
4
|
export type { ColumnsTable, TableProps, ColumnTable, ToolbarItem, CommandItem, ContextMenuItem };
|
|
5
|
-
export default
|
|
5
|
+
export default TempTable;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import InternalTable
|
|
3
|
-
|
|
4
|
-
//
|
|
1
|
+
import TempTable from "./TempTable";
|
|
2
|
+
// import InternalTable from './InternalTable'
|
|
3
|
+
|
|
4
|
+
//
|
|
5
|
+
// export default InternalTable
|
|
6
|
+
export default TempTable;
|
|
@@ -470,14 +470,28 @@ const GridEdit = props => {
|
|
|
470
470
|
|
|
471
471
|
// return [...new Set(Array.from(rangeCells).map((item: any) => parseInt(item.split('-')[0])))] ?? []
|
|
472
472
|
return arr.filter(it => it < leng);
|
|
473
|
-
}, [dataSource
|
|
473
|
+
}, [dataSource, rangeCells]);
|
|
474
474
|
const contextMenuItems = React.useMemo(() => {
|
|
475
475
|
const a = showDefaultContext !== false ? [...defaultContext] : [];
|
|
476
476
|
const b = propsContext && propsContext.length > 0 ? [...propsContext, {
|
|
477
477
|
type: 'divider'
|
|
478
478
|
}] : [];
|
|
479
479
|
return [...b, ...a];
|
|
480
|
-
}, [propsContext, showDefaultContext]);
|
|
480
|
+
}, [defaultContext, propsContext, showDefaultContext]);
|
|
481
|
+
const {
|
|
482
|
+
control,
|
|
483
|
+
handleSubmit,
|
|
484
|
+
setValue,
|
|
485
|
+
trigger,
|
|
486
|
+
getValues,
|
|
487
|
+
reset,
|
|
488
|
+
formState: {
|
|
489
|
+
errors
|
|
490
|
+
}
|
|
491
|
+
} = useForm({
|
|
492
|
+
mode: 'onChange',
|
|
493
|
+
resolver: validate ? yupResolver(validate) : undefined
|
|
494
|
+
});
|
|
481
495
|
const onTriggerExpand = React.useCallback(record => {
|
|
482
496
|
const key = getRowKey(record, dataSource.indexOf(record));
|
|
483
497
|
let newExpandedKeys;
|
|
@@ -765,6 +779,84 @@ const GridEdit = props => {
|
|
|
765
779
|
const handleDeleteAll = React.useCallback(() => {
|
|
766
780
|
triggerChangeData?.([], 'INSERT_BEFORE');
|
|
767
781
|
}, [triggerChangeData]);
|
|
782
|
+
const onSubmit = formData => {
|
|
783
|
+
try {
|
|
784
|
+
// const record = (await form.validateFields()) as RecordType;
|
|
785
|
+
const row = {
|
|
786
|
+
...formData
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
// const newData = [...dataSource]
|
|
790
|
+
const newData = [...originData];
|
|
791
|
+
|
|
792
|
+
// @ts-ignore
|
|
793
|
+
const index = flattenData(childrenColumnName, newData).findIndex(item => formData[rowKey] === item[rowKey]);
|
|
794
|
+
const rs = updateArrayByKey(newData, row, rowKey);
|
|
795
|
+
if (index > -1) {
|
|
796
|
+
triggerChangeData?.(rs, 'onChange');
|
|
797
|
+
}
|
|
798
|
+
} catch (errInfo) {
|
|
799
|
+
console.log('Validate Failed:', errInfo);
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
const handleCellChange = args => {
|
|
803
|
+
const {
|
|
804
|
+
record,
|
|
805
|
+
type: changeType,
|
|
806
|
+
newState,
|
|
807
|
+
prevState,
|
|
808
|
+
option,
|
|
809
|
+
field,
|
|
810
|
+
indexCol,
|
|
811
|
+
indexRow,
|
|
812
|
+
key
|
|
813
|
+
} = args;
|
|
814
|
+
console.log('changeType', changeType);
|
|
815
|
+
if (changeType === 'blur') {
|
|
816
|
+
const handleChangeCallback = callbackData => {
|
|
817
|
+
const callbackRecord = callbackData;
|
|
818
|
+
Object.entries(callbackRecord).forEach(([name, value]) => {
|
|
819
|
+
setValue(name, value);
|
|
820
|
+
});
|
|
821
|
+
onSubmit(callbackRecord);
|
|
822
|
+
};
|
|
823
|
+
if (onCellChange) {
|
|
824
|
+
if (onCellChange.length > 1) {
|
|
825
|
+
onCellChange({
|
|
826
|
+
field,
|
|
827
|
+
indexCol,
|
|
828
|
+
type: 'onChange',
|
|
829
|
+
value: newState,
|
|
830
|
+
option,
|
|
831
|
+
indexRow,
|
|
832
|
+
rowData: record,
|
|
833
|
+
rowId: key,
|
|
834
|
+
// rowsData: [...dataSource],
|
|
835
|
+
rowsData: [...originData],
|
|
836
|
+
sumValue: []
|
|
837
|
+
}, handleChangeCallback);
|
|
838
|
+
} else {
|
|
839
|
+
onCellChange({
|
|
840
|
+
field,
|
|
841
|
+
indexCol,
|
|
842
|
+
type: 'onChange',
|
|
843
|
+
option,
|
|
844
|
+
value: newState,
|
|
845
|
+
indexRow,
|
|
846
|
+
rowData: record,
|
|
847
|
+
rowId: key,
|
|
848
|
+
// rowsData: [...dataSource],
|
|
849
|
+
rowsData: [...originData],
|
|
850
|
+
sumValue: []
|
|
851
|
+
}, handleChangeCallback);
|
|
852
|
+
onSubmit(record);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
if (prevState && newState && prevState !== newState && changeType === 'enter') {
|
|
857
|
+
onSubmit(record);
|
|
858
|
+
}
|
|
859
|
+
};
|
|
768
860
|
const handleDeleteContent = React.useCallback(() => {
|
|
769
861
|
if (selectedCells.current.size > 0) {
|
|
770
862
|
const newData = [...dataSource];
|
|
@@ -781,16 +873,31 @@ const GridEdit = props => {
|
|
|
781
873
|
const column = flatColumns2(visibleCols)[colIndex];
|
|
782
874
|
const rowData = flattenData(childrenColumnName, dataSource)[rowIndex];
|
|
783
875
|
if (newData[rowIndex] && field && field in newData[rowIndex] && isEditable(column, rowData)) {
|
|
876
|
+
const rowDta = {
|
|
877
|
+
...newData[rowIndex]
|
|
878
|
+
};
|
|
879
|
+
|
|
784
880
|
// @ts-ignore
|
|
785
881
|
newData[rowIndex][field] = '';
|
|
882
|
+
handleCellChange({
|
|
883
|
+
key: getRowKey?.(newData[rowIndex], rowIndex),
|
|
884
|
+
field: column.field ?? column.dataIndex,
|
|
885
|
+
record: newData[rowIndex],
|
|
886
|
+
prevState: rowDta[field],
|
|
887
|
+
newState: '',
|
|
888
|
+
option: '',
|
|
889
|
+
indexCol: colIndex,
|
|
890
|
+
indexRow: rowIndex,
|
|
891
|
+
type: 'blur'
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
// if (onCellChange)
|
|
786
895
|
}
|
|
787
896
|
}
|
|
788
897
|
const rsFilterData = updateOrInsert(flattenArray([...originData]), newData);
|
|
789
|
-
|
|
790
|
-
// triggerChangeData?.([...newData], 'DELETE_CONTENT')
|
|
791
898
|
triggerChangeData?.([...rsFilterData], 'DELETE_CONTENT');
|
|
792
899
|
}
|
|
793
|
-
}, [dataSource, originData, triggerChangeData, visibleCols]);
|
|
900
|
+
}, [dataSource, getRowKey, handleCellChange, originData, triggerChangeData, visibleCols]);
|
|
794
901
|
const toolbarItemsBottom = useMemo(() => {
|
|
795
902
|
if (!rowsFocus || rowsFocus.length === 0) {
|
|
796
903
|
return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
|
|
@@ -1000,20 +1107,6 @@ const GridEdit = props => {
|
|
|
1000
1107
|
};
|
|
1001
1108
|
});
|
|
1002
1109
|
}, [handleAddMulti, handleDeleteAll, handleDeleteRows, handleDuplicate, handleInsertAfter, handleInsertBefore, handleInsertChild, itemsAdd, rowsFocus, t, toolbarItems]);
|
|
1003
|
-
const {
|
|
1004
|
-
control,
|
|
1005
|
-
handleSubmit,
|
|
1006
|
-
setValue,
|
|
1007
|
-
trigger,
|
|
1008
|
-
getValues,
|
|
1009
|
-
reset,
|
|
1010
|
-
formState: {
|
|
1011
|
-
errors
|
|
1012
|
-
}
|
|
1013
|
-
} = useForm({
|
|
1014
|
-
mode: 'onChange',
|
|
1015
|
-
resolver: validate ? yupResolver(validate) : undefined
|
|
1016
|
-
});
|
|
1017
1110
|
|
|
1018
1111
|
// const isEditing = React.useCallback((record: RecordType) => {
|
|
1019
1112
|
// return record[rowKey as any] === editingKey.current
|
|
@@ -1815,83 +1908,6 @@ const GridEdit = props => {
|
|
|
1815
1908
|
e.clipboardData.setData("text/plain", copyText);
|
|
1816
1909
|
Message(t ? t('CopySuccessful') : 'Copy Successful');
|
|
1817
1910
|
};
|
|
1818
|
-
const onSubmit = formData => {
|
|
1819
|
-
try {
|
|
1820
|
-
// const record = (await form.validateFields()) as RecordType;
|
|
1821
|
-
const row = {
|
|
1822
|
-
...formData
|
|
1823
|
-
};
|
|
1824
|
-
|
|
1825
|
-
// const newData = [...dataSource]
|
|
1826
|
-
const newData = [...originData];
|
|
1827
|
-
|
|
1828
|
-
// @ts-ignore
|
|
1829
|
-
const index = flattenData(childrenColumnName, newData).findIndex(item => formData[rowKey] === item[rowKey]);
|
|
1830
|
-
const rs = updateArrayByKey(newData, row, rowKey);
|
|
1831
|
-
if (index > -1) {
|
|
1832
|
-
triggerChangeData?.(rs, 'onChange');
|
|
1833
|
-
}
|
|
1834
|
-
} catch (errInfo) {
|
|
1835
|
-
console.log('Validate Failed:', errInfo);
|
|
1836
|
-
}
|
|
1837
|
-
};
|
|
1838
|
-
const handleCellChange = args => {
|
|
1839
|
-
const {
|
|
1840
|
-
record,
|
|
1841
|
-
type: changeType,
|
|
1842
|
-
newState,
|
|
1843
|
-
prevState,
|
|
1844
|
-
option,
|
|
1845
|
-
field,
|
|
1846
|
-
indexCol,
|
|
1847
|
-
indexRow,
|
|
1848
|
-
key
|
|
1849
|
-
} = args;
|
|
1850
|
-
if (changeType === 'blur') {
|
|
1851
|
-
const handleChangeCallback = callbackData => {
|
|
1852
|
-
const callbackRecord = callbackData;
|
|
1853
|
-
Object.entries(callbackRecord).forEach(([name, value]) => {
|
|
1854
|
-
setValue(name, value);
|
|
1855
|
-
});
|
|
1856
|
-
onSubmit(callbackRecord);
|
|
1857
|
-
};
|
|
1858
|
-
if (onCellChange) {
|
|
1859
|
-
if (onCellChange.length > 1) {
|
|
1860
|
-
onCellChange({
|
|
1861
|
-
field,
|
|
1862
|
-
indexCol,
|
|
1863
|
-
type: 'onChange',
|
|
1864
|
-
value: newState,
|
|
1865
|
-
option,
|
|
1866
|
-
indexRow,
|
|
1867
|
-
rowData: record,
|
|
1868
|
-
rowId: key,
|
|
1869
|
-
// rowsData: [...dataSource],
|
|
1870
|
-
rowsData: [...originData],
|
|
1871
|
-
sumValue: []
|
|
1872
|
-
}, handleChangeCallback);
|
|
1873
|
-
} else {
|
|
1874
|
-
onCellChange({
|
|
1875
|
-
field,
|
|
1876
|
-
indexCol,
|
|
1877
|
-
type: 'onChange',
|
|
1878
|
-
option,
|
|
1879
|
-
value: newState,
|
|
1880
|
-
indexRow,
|
|
1881
|
-
rowData: record,
|
|
1882
|
-
rowId: key,
|
|
1883
|
-
// rowsData: [...dataSource],
|
|
1884
|
-
rowsData: [...originData],
|
|
1885
|
-
sumValue: []
|
|
1886
|
-
}, handleChangeCallback);
|
|
1887
|
-
onSubmit(record);
|
|
1888
|
-
}
|
|
1889
|
-
}
|
|
1890
|
-
}
|
|
1891
|
-
if (prevState && newState && prevState !== newState && changeType === 'enter') {
|
|
1892
|
-
onSubmit(record);
|
|
1893
|
-
}
|
|
1894
|
-
};
|
|
1895
1911
|
const handleEdit = (record, col, editType, rowIndex, e) => {
|
|
1896
1912
|
onRemoveBorderSelectedCell(selectedCells.current, id);
|
|
1897
1913
|
setTooltipContent('');
|
|
@@ -185,6 +185,11 @@ export type Locale = TableLocale & {
|
|
|
185
185
|
delete_rows: string;
|
|
186
186
|
custom: string;
|
|
187
187
|
};
|
|
188
|
+
export type Sort = {
|
|
189
|
+
columnKey: string;
|
|
190
|
+
field: string;
|
|
191
|
+
order: 'ascend' | 'descend' | null;
|
|
192
|
+
};
|
|
188
193
|
export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary' | 'pagination' | 'locale'> {
|
|
189
194
|
editAble?: boolean;
|
|
190
195
|
infiniteScroll?: boolean;
|
|
@@ -223,8 +228,9 @@ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<Re
|
|
|
223
228
|
column: ColumnTable<RecordType>;
|
|
224
229
|
columnKey: string;
|
|
225
230
|
field: string;
|
|
226
|
-
|
|
231
|
+
order: 'ascend' | 'descend' | null;
|
|
227
232
|
}) => void;
|
|
233
|
+
defaultSorter?: Sort[];
|
|
228
234
|
selectionSettings?: SelectionSettings;
|
|
229
235
|
rowKey?: string | keyof RecordType | GetRowKey<RecordType>;
|
|
230
236
|
rowSelection?: RowSelection<RecordType>;
|