es-grid-template 1.7.32 → 1.7.34
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/ColumnsChoose.js +0 -3
- package/es/grid-component/InternalTable.js +0 -4
- package/es/grid-component/TableGrid.js +0 -4
- package/es/grid-component/TempTable.js +2 -0
- package/es/grid-component/hooks/columns/index.js +0 -8
- package/es/grid-component/hooks/utils.js +0 -14
- package/es/grid-component/table/GridEdit.js +3 -5
- package/es/table-component/InternalTable.js +9 -3
- package/es/table-component/TableContainer.d.ts +1 -0
- package/es/table-component/TableContainer.js +11 -2
- package/es/table-component/TableContainerEdit.d.ts +1 -1
- package/es/table-component/TableContainerEdit.js +34 -13
- package/es/table-component/body/EditableCell.js +3 -2
- package/es/table-component/body/TableBodyCell.js +165 -9
- package/es/table-component/body/TableBodyCellEdit.js +22 -23
- package/es/table-component/body/TableBodyRow.js +0 -3
- package/es/table-component/header/TableHeadCell.d.ts +2 -0
- package/es/table-component/header/TableHeadCell.js +10 -6
- package/es/table-component/header/TableHeadRow.d.ts +1 -1
- package/es/table-component/header/TableHeadRow.js +4 -5
- package/es/table-component/hook/utils.d.ts +1 -0
- package/es/table-component/hook/utils.js +23 -5
- package/es/table-component/style.scss +42 -14
- package/es/table-component/table/Grid.d.ts +1 -0
- package/es/table-component/table/Grid.js +3 -1
- package/es/table-component/table/TableWrapper.js +5 -5
- package/es/table-component/type.d.ts +14 -1
- package/es/table-component/useContext.d.ts +5 -2
- package/es/table-component/useContext.js +1 -0
- package/lib/grid-component/ColumnsChoose.js +0 -3
- package/lib/grid-component/InternalTable.js +0 -4
- package/lib/grid-component/TableGrid.js +0 -4
- package/lib/grid-component/TempTable.js +2 -0
- package/lib/grid-component/hooks/columns/index.js +0 -8
- package/lib/grid-component/hooks/utils.js +0 -14
- package/lib/grid-component/table/GridEdit.js +3 -5
- package/lib/table-component/InternalTable.js +8 -2
- package/lib/table-component/TableContainer.d.ts +1 -0
- package/lib/table-component/TableContainer.js +11 -2
- package/lib/table-component/TableContainerEdit.d.ts +1 -1
- package/lib/table-component/TableContainerEdit.js +34 -13
- package/lib/table-component/body/EditableCell.js +3 -2
- package/lib/table-component/body/TableBodyCell.js +165 -9
- package/lib/table-component/body/TableBodyCellEdit.js +22 -22
- package/lib/table-component/body/TableBodyRow.js +0 -3
- package/lib/table-component/header/TableHeadCell.d.ts +2 -0
- package/lib/table-component/header/TableHeadCell.js +9 -6
- package/lib/table-component/header/TableHeadRow.d.ts +1 -1
- package/lib/table-component/header/TableHeadRow.js +4 -5
- package/lib/table-component/hook/utils.d.ts +1 -0
- package/lib/table-component/hook/utils.js +24 -5
- package/lib/table-component/style.scss +42 -14
- package/lib/table-component/table/Grid.d.ts +1 -0
- package/lib/table-component/table/Grid.js +3 -1
- package/lib/table-component/table/TableWrapper.js +5 -5
- package/lib/table-component/type.d.ts +14 -1
- package/lib/table-component/useContext.d.ts +5 -2
- package/lib/table-component/useContext.js +1 -0
- package/package.json +1 -1
|
@@ -22,6 +22,7 @@ type Props<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
22
22
|
onContextMenu?: (data: T) => (event: any) => void;
|
|
23
23
|
triggerChangeColumns?: (args: any, keys: any) => void;
|
|
24
24
|
windowSize: any;
|
|
25
|
+
isDataTree: boolean;
|
|
25
26
|
};
|
|
26
27
|
declare const Grid: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
27
28
|
export default Grid;
|
|
@@ -218,6 +218,7 @@ const Grid = props => {
|
|
|
218
218
|
sensors: sensors
|
|
219
219
|
}, /*#__PURE__*/React.createElement(ContainerComponent, _extends({}, rest, {
|
|
220
220
|
id: id,
|
|
221
|
+
t: t,
|
|
221
222
|
table: table,
|
|
222
223
|
editAble: editAble,
|
|
223
224
|
dataSource: dataSource,
|
|
@@ -236,7 +237,8 @@ const Grid = props => {
|
|
|
236
237
|
columnHidden: columnHidden,
|
|
237
238
|
setExpanded: setExpanded,
|
|
238
239
|
expanded: expanded,
|
|
239
|
-
infiniteScroll: infiniteScroll
|
|
240
|
+
infiniteScroll: infiniteScroll,
|
|
241
|
+
setMergedFilterKeys: setMergedFilterKeys
|
|
240
242
|
}))));
|
|
241
243
|
};
|
|
242
244
|
export default Grid;
|
|
@@ -167,12 +167,12 @@ const TableWrapper = props => {
|
|
|
167
167
|
return /*#__PURE__*/React.createElement("div", {
|
|
168
168
|
style: {
|
|
169
169
|
position: 'relative'
|
|
170
|
-
}
|
|
171
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
170
|
+
},
|
|
172
171
|
className: classNames(`${prefix}-grid-container`, {
|
|
173
172
|
'ui-rc-table-ping-right': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) >= 0 && (tableContainerRef.current?.scrollLeft ?? 0) + (tableContainerRef.current?.clientWidth ?? 0) < (tableContainerRef.current?.scrollWidth ?? 0),
|
|
174
173
|
'ui-rc-table-ping-left': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) > 0
|
|
175
|
-
})
|
|
174
|
+
})
|
|
175
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
176
176
|
id: id,
|
|
177
177
|
ref: tableContainerRef,
|
|
178
178
|
style: {
|
|
@@ -191,8 +191,8 @@ const TableWrapper = props => {
|
|
|
191
191
|
onScroll: handleScroll
|
|
192
192
|
}, /*#__PURE__*/React.createElement("table", {
|
|
193
193
|
style: {
|
|
194
|
-
display: 'grid'
|
|
195
|
-
|
|
194
|
+
display: 'grid',
|
|
195
|
+
minWidth: table.getTotalSize()
|
|
196
196
|
}
|
|
197
197
|
}, /*#__PURE__*/React.createElement(TableHead, {
|
|
198
198
|
tableContainerRef: tableContainerRef,
|
|
@@ -85,7 +85,6 @@ export type ColumnTable<RecordType = AnyObject> = {
|
|
|
85
85
|
width?: number;
|
|
86
86
|
maxWidth?: number;
|
|
87
87
|
minWidth?: number;
|
|
88
|
-
align?: ITextAlign;
|
|
89
88
|
type?: IColumnType;
|
|
90
89
|
haveSum?: boolean;
|
|
91
90
|
isSummary?: boolean;
|
|
@@ -106,9 +105,19 @@ export type ColumnTable<RecordType = AnyObject> = {
|
|
|
106
105
|
source?: any[];
|
|
107
106
|
showFilterSearch?: boolean;
|
|
108
107
|
headerText?: string;
|
|
108
|
+
/**
|
|
109
|
+
* @deprecated Please use `visible` instead.
|
|
110
|
+
* @since 1.7.33
|
|
111
|
+
*/
|
|
112
|
+
hidden?: boolean;
|
|
109
113
|
visible?: boolean;
|
|
110
114
|
headerTooltip?: boolean | string | (() => ReactNode | ReactElement);
|
|
111
115
|
columnGroupText?: string;
|
|
116
|
+
/**
|
|
117
|
+
* @deprecated Please use `textAlign` instead.
|
|
118
|
+
* @since 1.7.34
|
|
119
|
+
*/
|
|
120
|
+
align?: ITextAlign;
|
|
112
121
|
textAlign?: ITextAlign;
|
|
113
122
|
headerTextAlign?: ITextAlign;
|
|
114
123
|
template?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
|
|
@@ -135,6 +144,10 @@ export type ColumnTable<RecordType = AnyObject> = {
|
|
|
135
144
|
*/
|
|
136
145
|
fixedType?: FixedType;
|
|
137
146
|
fixed?: FixedType;
|
|
147
|
+
/**
|
|
148
|
+
* @deprecated Please use `wrapSettings` instead.
|
|
149
|
+
* @since 1.7.34
|
|
150
|
+
*/
|
|
138
151
|
headerTextWrap?: boolean;
|
|
139
152
|
ellipsis?: boolean;
|
|
140
153
|
allowResizing?: boolean;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import type { ExpandableConfig, IFormat, IWrapSettings, Locale, RangeState, RecordDoubleClickEventArgs, SelectionSettings } from "./type";
|
|
3
3
|
import type { SubmitHandler } from "react-hook-form";
|
|
4
|
+
import type { ExpandedState } from '@tanstack/react-table';
|
|
4
5
|
export type IPositionCell = {
|
|
5
6
|
rowId: string;
|
|
6
7
|
colId: string;
|
|
7
8
|
} | undefined;
|
|
8
9
|
export interface IContext<T> {
|
|
10
|
+
t?: any;
|
|
9
11
|
prefix: string;
|
|
10
12
|
id: string;
|
|
11
13
|
rowKey: string;
|
|
@@ -14,8 +16,8 @@ export interface IContext<T> {
|
|
|
14
16
|
format?: IFormat;
|
|
15
17
|
expandable?: ExpandableConfig<T>;
|
|
16
18
|
wrapSettings?: IWrapSettings;
|
|
17
|
-
setExpanded:
|
|
18
|
-
expanded:
|
|
19
|
+
setExpanded: Dispatch<SetStateAction<ExpandedState>>;
|
|
20
|
+
expanded: ExpandedState;
|
|
19
21
|
recordDoubleClick?: (args: RecordDoubleClickEventArgs<T>) => void;
|
|
20
22
|
selectionSettings?: SelectionSettings;
|
|
21
23
|
setIsSelectionChange: Dispatch<SetStateAction<{
|
|
@@ -63,6 +65,7 @@ export interface IContext<T> {
|
|
|
63
65
|
handleDeleteContent?: () => void;
|
|
64
66
|
handleAddMulti?: (item: any, n: number, id?: string) => void;
|
|
65
67
|
dataErrors?: any[];
|
|
68
|
+
isDataTree: boolean;
|
|
66
69
|
}
|
|
67
70
|
export declare const TableContext: import("react").Context<IContext<any>>;
|
|
68
71
|
export type ContextCellChange = {
|
|
@@ -227,7 +227,6 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
227
227
|
//
|
|
228
228
|
// const onCheck = (keys: string[]) => {
|
|
229
229
|
//
|
|
230
|
-
// console.log('keys', keys)
|
|
231
230
|
// // setSelectedKeys(keys)
|
|
232
231
|
// setMergedSelectedKeys(keys)
|
|
233
232
|
// // setIsManualUpdate(true)
|
|
@@ -236,12 +235,10 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
236
235
|
//
|
|
237
236
|
// const handleAccept = () => {
|
|
238
237
|
//
|
|
239
|
-
// console.log('mergedSelectedKeys', mergedSelectedKeys)
|
|
240
238
|
//
|
|
241
239
|
// // const rs1 = updateColumns(propsColumns, selectedKeys)
|
|
242
240
|
// const rs1 = updateColumns(propsColumns, mergedSelectedKeys)
|
|
243
241
|
//
|
|
244
|
-
// console.log('rs1', rs1)
|
|
245
242
|
//
|
|
246
243
|
// triggerChangeColumns?.(rs1, 'columnChoose')
|
|
247
244
|
//
|
|
@@ -307,7 +307,6 @@ const InternalTable = props => {
|
|
|
307
307
|
setColumns(propsColumns);
|
|
308
308
|
}, [propsColumns]);
|
|
309
309
|
const handleOnFilter = queries => {
|
|
310
|
-
console.log('queries', queries);
|
|
311
310
|
if (onFilter) {
|
|
312
311
|
onFilter?.((0, _hooks.convertFilters)(queries));
|
|
313
312
|
} else {
|
|
@@ -353,8 +352,6 @@ const InternalTable = props => {
|
|
|
353
352
|
searchValue,
|
|
354
353
|
setSearchValue
|
|
355
354
|
}) => {
|
|
356
|
-
// console.log('selectedKeys', selectedKeys)
|
|
357
|
-
|
|
358
355
|
const type = (0, _hooks.getTypeFilter)(column);
|
|
359
356
|
// const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? booleanOperator : (!type || type === 'Text' ? stringOperator : numberOperator)
|
|
360
357
|
|
|
@@ -907,7 +904,6 @@ const InternalTable = props => {
|
|
|
907
904
|
}
|
|
908
905
|
};
|
|
909
906
|
const handleChange = (paging, filters, sorter) => {
|
|
910
|
-
console.log('sorter', sorter);
|
|
911
907
|
onSorter?.(sorter);
|
|
912
908
|
};
|
|
913
909
|
|
|
@@ -351,10 +351,6 @@ const TableGrid = props => {
|
|
|
351
351
|
hideSelectAll: !type || type === 'single' || mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
// onScroll={(event) => {
|
|
355
|
-
// console.log('event', event)
|
|
356
|
-
// }}
|
|
357
|
-
|
|
358
354
|
// onFilter={(val: any) => {
|
|
359
355
|
// handleOnFilter(val)
|
|
360
356
|
// // triggerFilter?.(convertFilters(val))
|
|
@@ -21,6 +21,8 @@ const TempTable = props => {
|
|
|
21
21
|
|
|
22
22
|
// const TabComponent = groupAble ? InternalTable : Table
|
|
23
23
|
const TabComponent = editAble ? _tableComponent.default : _InternalTable.default;
|
|
24
|
+
// const TabComponent = InternalTable
|
|
25
|
+
|
|
24
26
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(TabComponent, (0, _extends2.default)({}, rest, {
|
|
25
27
|
infiniteScroll: infiniteScroll,
|
|
26
28
|
groupAble: groupAble,
|
|
@@ -79,9 +79,6 @@ const getValueCell = (column, value, record, rowIndex, colIndex, format) => {
|
|
|
79
79
|
// const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString()) : '0'
|
|
80
80
|
|
|
81
81
|
const tmpval = typeof value === 'string' ? Number(value) : value;
|
|
82
|
-
|
|
83
|
-
// console.log('aaaaa', Number(value))
|
|
84
|
-
|
|
85
82
|
const numericFormatProps = {
|
|
86
83
|
thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
87
84
|
decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
@@ -95,7 +92,6 @@ const getValueCell = (column, value, record, rowIndex, colIndex, format) => {
|
|
|
95
92
|
// if ( typeof value === "string") {
|
|
96
93
|
// const ttt = removeNumericFormat(value, undefined, numericFormatProps )
|
|
97
94
|
//
|
|
98
|
-
// console.log('ttt', ttt)
|
|
99
95
|
// }
|
|
100
96
|
|
|
101
97
|
const contentNumber = !(0, _utils.isEmpty)(value) ? dec || dec === 0 ? parseFloat(tmpval.toFixed(dec)).toString() : tmpval.toString() : '0';
|
|
@@ -140,9 +136,6 @@ const renderValueCell = (column, value, record, rowIndex, colIndex, format, edit
|
|
|
140
136
|
// const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString()) : '0'
|
|
141
137
|
|
|
142
138
|
const tmpval = typeof value === 'string' ? Number(value) : value;
|
|
143
|
-
|
|
144
|
-
// console.log('aaaaa', Number(value))
|
|
145
|
-
|
|
146
139
|
const numericFormatProps = {
|
|
147
140
|
thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
148
141
|
decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
@@ -156,7 +149,6 @@ const renderValueCell = (column, value, record, rowIndex, colIndex, format, edit
|
|
|
156
149
|
// if ( typeof value === "string") {
|
|
157
150
|
// const ttt = removeNumericFormat(value, undefined, numericFormatProps )
|
|
158
151
|
//
|
|
159
|
-
// console.log('ttt', ttt)
|
|
160
152
|
// }
|
|
161
153
|
|
|
162
154
|
const contentNumber = !(0, _utils.isEmpty)(value) ? dec || dec === 0 ? parseFloat(tmpval.toFixed(dec)).toString() : tmpval.toString() : '0';
|
|
@@ -691,7 +691,6 @@ function addRowsDownWithCtrl(arr, n) {
|
|
|
691
691
|
|
|
692
692
|
// Hàm kiểm tra kiểu date hợp lệ
|
|
693
693
|
const isValidDate = item => {
|
|
694
|
-
// console.log('!isNaN(Date.parse(d))', !isNaN(Date.parse(d)))
|
|
695
694
|
// return !isNaN(Date.parse(d))
|
|
696
695
|
|
|
697
696
|
if (typeof item === 'number') {
|
|
@@ -831,7 +830,6 @@ function addRowsDown(arr, n) {
|
|
|
831
830
|
// const isValidDate = (item: any) => {
|
|
832
831
|
//
|
|
833
832
|
//
|
|
834
|
-
// // console.log('!isNaN(Date.parse(d))', !isNaN(Date.parse(d)))
|
|
835
833
|
// // return !isNaN(Date.parse(d))
|
|
836
834
|
//
|
|
837
835
|
// if (typeof item === 'number') {
|
|
@@ -978,7 +976,6 @@ function addRowsUpWithCtrl(array, n) {
|
|
|
978
976
|
|
|
979
977
|
// Hàm kiểm tra kiểu date hợp lệ
|
|
980
978
|
const isValidDate = item => {
|
|
981
|
-
// console.log('!isNaN(Date.parse(d))', !isNaN(Date.parse(d)))
|
|
982
979
|
// return !isNaN(Date.parse(d))
|
|
983
980
|
|
|
984
981
|
if (typeof item === 'number') {
|
|
@@ -1122,7 +1119,6 @@ function addRowsUp(array, n) {
|
|
|
1122
1119
|
// const isValidDate = (item: any) => {
|
|
1123
1120
|
//
|
|
1124
1121
|
//
|
|
1125
|
-
// // console.log('!isNaN(Date.parse(d))', !isNaN(Date.parse(d)))
|
|
1126
1122
|
// // return !isNaN(Date.parse(d))
|
|
1127
1123
|
//
|
|
1128
1124
|
// if (typeof item === 'number') {
|
|
@@ -2706,17 +2702,12 @@ function mergeWithFilter(dataArray, dataFilter) {
|
|
|
2706
2702
|
const result = [...dataArray];
|
|
2707
2703
|
dataFilter.forEach((filterItem, i) => {
|
|
2708
2704
|
const existsInArray = result.find(item => item.rowId === filterItem.rowId);
|
|
2709
|
-
|
|
2710
|
-
// console.log('existsInArray', existsInArray)
|
|
2711
|
-
|
|
2712
2705
|
if (!existsInArray) {
|
|
2713
2706
|
// tìm index của phần tử trước đó trong dataFilter
|
|
2714
2707
|
for (let j = i - 1; j >= 0; j--) {
|
|
2715
2708
|
const prevFilterItem = dataFilter[j];
|
|
2716
2709
|
const indexInResult = result.findIndex(item => item.rowId === prevFilterItem.rowId);
|
|
2717
2710
|
if (indexInResult !== -1) {
|
|
2718
|
-
// console.log('filterItem', filterItem)
|
|
2719
|
-
|
|
2720
2711
|
result.splice(indexInResult + 1, 0, filterItem);
|
|
2721
2712
|
return;
|
|
2722
2713
|
}
|
|
@@ -2736,17 +2727,12 @@ function mergeWithFilter2(dataArray, dataFilter) {
|
|
|
2736
2727
|
const result = [...dataArray];
|
|
2737
2728
|
dataFilter.forEach((filterItem, i) => {
|
|
2738
2729
|
const existsInArray = result.find(item => item.rowId === filterItem.rowId);
|
|
2739
|
-
|
|
2740
|
-
// console.log('existsInArray', existsInArray)
|
|
2741
|
-
|
|
2742
2730
|
if (!existsInArray) {
|
|
2743
2731
|
// tìm index của phần tử trước đó trong dataFilter
|
|
2744
2732
|
for (let j = i - 1; j >= 0; j--) {
|
|
2745
2733
|
const prevFilterItem = dataFilter[j];
|
|
2746
2734
|
const indexInResult = result.findIndex(item => item.rowId === prevFilterItem.rowId);
|
|
2747
2735
|
if (indexInResult !== -1) {
|
|
2748
|
-
// console.log('filterItem', filterItem)
|
|
2749
|
-
|
|
2750
2736
|
result.splice(indexInResult + 1, 0, filterItem);
|
|
2751
2737
|
return;
|
|
2752
2738
|
}
|
|
@@ -742,7 +742,7 @@ const GridEdit = props => {
|
|
|
742
742
|
const newExpandedKeys = [...mergedExpandedKeys, key];
|
|
743
743
|
setInnerExpandedKeys(newExpandedKeys);
|
|
744
744
|
}
|
|
745
|
-
}, [dataSource, defaultValue, getRowKey, mergedExpandedKeys, rowKey, rowsFocus, triggerChangeData]);
|
|
745
|
+
}, [dataSource, defaultValue, getRowKey, mergedExpandedKeys, mergedFilterKeys, originData, rowKey, rowsFocus, setMergedFilterKeys, triggerChangeData]);
|
|
746
746
|
const handleDeleteRows = _react.default.useCallback(item => {
|
|
747
747
|
// setTimeout(() => {
|
|
748
748
|
// onAddBgSelectedCell(selectedCells.current, id)
|
|
@@ -808,7 +808,6 @@ const GridEdit = props => {
|
|
|
808
808
|
indexRow,
|
|
809
809
|
key
|
|
810
810
|
} = args;
|
|
811
|
-
console.log('changeType', changeType);
|
|
812
811
|
if (changeType === 'blur') {
|
|
813
812
|
const handleChangeCallback = callbackData => {
|
|
814
813
|
const callbackRecord = callbackData;
|
|
@@ -854,7 +853,7 @@ const GridEdit = props => {
|
|
|
854
853
|
onSubmit(record);
|
|
855
854
|
}
|
|
856
855
|
};
|
|
857
|
-
const handleDeleteContent =
|
|
856
|
+
const handleDeleteContent = () => {
|
|
858
857
|
if (selectedCells.current.size > 0) {
|
|
859
858
|
const newData = [...dataSource];
|
|
860
859
|
|
|
@@ -894,7 +893,7 @@ const GridEdit = props => {
|
|
|
894
893
|
const rsFilterData = (0, _hooks.updateOrInsert)((0, _hooks.flattenArray)([...originData]), newData);
|
|
895
894
|
triggerChangeData?.([...rsFilterData], 'DELETE_CONTENT');
|
|
896
895
|
}
|
|
897
|
-
}
|
|
896
|
+
};
|
|
898
897
|
const toolbarItemsBottom = (0, _react.useMemo)(() => {
|
|
899
898
|
if (!rowsFocus || rowsFocus.length === 0) {
|
|
900
899
|
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 => {
|
|
@@ -1467,7 +1466,6 @@ const GridEdit = props => {
|
|
|
1467
1466
|
row.replace(/\r/g, "").split("\t")
|
|
1468
1467
|
|
|
1469
1468
|
// {
|
|
1470
|
-
// console.log('row', row)
|
|
1471
1469
|
// return row.replace(/\r/g, "").split("\t")
|
|
1472
1470
|
// }
|
|
1473
1471
|
);
|
|
@@ -152,6 +152,9 @@ const InternalTable = props => {
|
|
|
152
152
|
|
|
153
153
|
// return convertToTanStackColumns<RecordType>(columns, expanded, setExpanded, expandable)
|
|
154
154
|
}, [t, columns, format, editAble]);
|
|
155
|
+
const isDataTree = _react.default.useMemo(() => {
|
|
156
|
+
return (0, _utils.isTree)(dataSource);
|
|
157
|
+
}, [dataSource]);
|
|
155
158
|
const columnPinning = _react.default.useMemo(() => {
|
|
156
159
|
return {
|
|
157
160
|
left: (0, _utils.getFixedFields)(columns, 'left'),
|
|
@@ -283,7 +286,9 @@ const InternalTable = props => {
|
|
|
283
286
|
setExpanded: setExpanded,
|
|
284
287
|
isFullScreen: isFullScreen,
|
|
285
288
|
setIsFullScreen: setIsFullScreen,
|
|
286
|
-
windowSize: windowSize
|
|
289
|
+
windowSize: windowSize,
|
|
290
|
+
height: height,
|
|
291
|
+
isDataTree: isDataTree
|
|
287
292
|
})), /*#__PURE__*/_react.default.createElement(_antd.Modal, {
|
|
288
293
|
open: isFullScreen,
|
|
289
294
|
footer: null,
|
|
@@ -346,7 +351,8 @@ const InternalTable = props => {
|
|
|
346
351
|
isFullScreen: isFullScreen,
|
|
347
352
|
setIsFullScreen: setIsFullScreen,
|
|
348
353
|
height: windowSize.innerHeight - 70,
|
|
349
|
-
windowSize: windowSize
|
|
354
|
+
windowSize: windowSize,
|
|
355
|
+
isDataTree: isDataTree
|
|
350
356
|
})))));
|
|
351
357
|
};
|
|
352
358
|
var _default = exports.default = InternalTable;
|
|
@@ -31,6 +31,7 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
31
31
|
columnHidden: any;
|
|
32
32
|
isFullScreen: boolean;
|
|
33
33
|
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
34
|
+
isDataTree: boolean;
|
|
34
35
|
};
|
|
35
36
|
declare const TableContainer: <RecordType extends object>(props: TableContainerProps<RecordType>) => React.JSX.Element;
|
|
36
37
|
export default TableContainer;
|
|
@@ -79,7 +79,8 @@ const TableContainer = props => {
|
|
|
79
79
|
contextMenuClick,
|
|
80
80
|
contextMenuHidden,
|
|
81
81
|
isFullScreen,
|
|
82
|
-
setIsFullScreen
|
|
82
|
+
setIsFullScreen,
|
|
83
|
+
isDataTree
|
|
83
84
|
} = props;
|
|
84
85
|
const tableContainerRef = _react.default.useRef(null);
|
|
85
86
|
const containerRef = _react.default.useRef(null);
|
|
@@ -132,6 +133,12 @@ const TableContainer = props => {
|
|
|
132
133
|
virtualPaddingRight = fixedRightColumns && fixedRightColumns.length > 0 ? pdRight - rightWidth > 0 ? pdRight - rightWidth : 0 : pdRight;
|
|
133
134
|
// virtualPaddingRight = columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0)
|
|
134
135
|
}
|
|
136
|
+
const columnSizingState = table.getState().columnSizing;
|
|
137
|
+
_react.default.useEffect(() => {
|
|
138
|
+
requestAnimationFrame(() => {
|
|
139
|
+
columnVirtualizer.measure();
|
|
140
|
+
});
|
|
141
|
+
}, [columnSizingState, columnVirtualizer]);
|
|
135
142
|
const triggerCommandClick = () => {};
|
|
136
143
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
137
144
|
ref: containerRef,
|
|
@@ -192,6 +199,7 @@ const TableContainer = props => {
|
|
|
192
199
|
triggerChangeColumns: triggerChangeColumns
|
|
193
200
|
})))), /*#__PURE__*/_react.default.createElement(_useContext.TableContext.Provider, {
|
|
194
201
|
value: {
|
|
202
|
+
t,
|
|
195
203
|
locale,
|
|
196
204
|
prefix,
|
|
197
205
|
id,
|
|
@@ -210,7 +218,8 @@ const TableContainer = props => {
|
|
|
210
218
|
onContextMenu,
|
|
211
219
|
setSorterChange,
|
|
212
220
|
setFilterChange,
|
|
213
|
-
windowSize
|
|
221
|
+
windowSize,
|
|
222
|
+
isDataTree
|
|
214
223
|
}
|
|
215
224
|
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, {
|
|
216
225
|
contextMenuItems: contextMenuItems,
|
|
@@ -18,11 +18,11 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
18
18
|
setFilterChange: Dispatch<SetStateAction<boolean>>;
|
|
19
19
|
onContextMenu?: (data: T) => (event: any) => void;
|
|
20
20
|
tableHeight?: number;
|
|
21
|
+
isDataTree: boolean;
|
|
21
22
|
windowSize: {
|
|
22
23
|
innerHeight: number;
|
|
23
24
|
innerWidth: number;
|
|
24
25
|
};
|
|
25
|
-
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[], copyRows: T[]) => void;
|
|
26
26
|
mergedFilterKeys?: any;
|
|
27
27
|
setMergedFilterKeys?: any;
|
|
28
28
|
setExpanded?: any;
|
|
@@ -122,7 +122,8 @@ const TableContainerEdit = props => {
|
|
|
122
122
|
contextMenuClick,
|
|
123
123
|
contextMenuHidden,
|
|
124
124
|
showDefaultContext,
|
|
125
|
-
commandSettings
|
|
125
|
+
commandSettings,
|
|
126
|
+
isDataTree
|
|
126
127
|
} = props;
|
|
127
128
|
const containerRef = _react.default.useRef(null);
|
|
128
129
|
const bottomToolbarRef = _react.default.useRef(null);
|
|
@@ -284,6 +285,8 @@ const TableContainerEdit = props => {
|
|
|
284
285
|
}
|
|
285
286
|
}, [validate, dataSource]);
|
|
286
287
|
const visibleColumns = table.getVisibleLeafColumns();
|
|
288
|
+
// const visibleColumns = table.getVisibleFlatColumns();
|
|
289
|
+
|
|
287
290
|
const fixedLeftColumns = table.getState().columnPinning.left ? visibleColumns.filter(vc => table.getState().columnPinning.left?.includes(vc.id)) : [];
|
|
288
291
|
const fixedRightColumns = table.getState().columnPinning.right ? visibleColumns.filter(vc => table.getState().columnPinning.right?.includes(vc.id)) : [];
|
|
289
292
|
|
|
@@ -300,7 +303,7 @@ const TableContainerEdit = props => {
|
|
|
300
303
|
// },
|
|
301
304
|
|
|
302
305
|
measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
|
|
303
|
-
overscan:
|
|
306
|
+
overscan: 0 //how many columns to render on each side off screen each way (adjust this for performance)
|
|
304
307
|
});
|
|
305
308
|
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
306
309
|
const cacheColumns = columnVirtualizer.measurementsCache;
|
|
@@ -387,7 +390,7 @@ const TableContainerEdit = props => {
|
|
|
387
390
|
}, [onDataChange]);
|
|
388
391
|
const triggerPaste = _react.default.useCallback((pastedRows, pastedColumnsArray, newData, copyRows) => {
|
|
389
392
|
const handlePasteCallback = callbackData => {
|
|
390
|
-
const rsFilterData = (0, _utils.updateOrInsert)((0, _utils.flattenArray)([...
|
|
393
|
+
const rsFilterData = (0, _utils.updateOrInsert)((0, _utils.flattenArray)([...originData]), callbackData);
|
|
391
394
|
const rs = (0, _utils.unFlattenData)(rsFilterData);
|
|
392
395
|
triggerChangeData(rs);
|
|
393
396
|
};
|
|
@@ -398,7 +401,7 @@ const TableContainerEdit = props => {
|
|
|
398
401
|
pasteData: pastedRows,
|
|
399
402
|
copyRows,
|
|
400
403
|
type: 'onPaste',
|
|
401
|
-
data:
|
|
404
|
+
data: originData,
|
|
402
405
|
pastedColumns: pastedColumnsArray
|
|
403
406
|
}, handlePasteCallback);
|
|
404
407
|
} else {
|
|
@@ -407,7 +410,7 @@ const TableContainerEdit = props => {
|
|
|
407
410
|
pasteData: pastedRows,
|
|
408
411
|
type: 'onPaste',
|
|
409
412
|
copyRows,
|
|
410
|
-
data:
|
|
413
|
+
data: originData,
|
|
411
414
|
pastedColumns: pastedColumnsArray
|
|
412
415
|
}, handlePasteCallback);
|
|
413
416
|
triggerChangeData(newData);
|
|
@@ -415,7 +418,7 @@ const TableContainerEdit = props => {
|
|
|
415
418
|
} else {
|
|
416
419
|
triggerChangeData(newData);
|
|
417
420
|
}
|
|
418
|
-
}, [
|
|
421
|
+
}, [onCellPaste, originData, triggerChangeData]);
|
|
419
422
|
const handlePasted = _react.default.useCallback(pasteData => {
|
|
420
423
|
if (!startCell) {
|
|
421
424
|
return;
|
|
@@ -613,7 +616,7 @@ const TableContainerEdit = props => {
|
|
|
613
616
|
}, [startCell, endCell, table, copySelectionToClipboard]);
|
|
614
617
|
_react.default.useEffect(() => {
|
|
615
618
|
const handlePaste = e => {
|
|
616
|
-
if (startCell) {
|
|
619
|
+
if (startCell && !editingKey) {
|
|
617
620
|
e.preventDefault(); // Chặn hành vi mặc định
|
|
618
621
|
const clipboardText = e.clipboardData?.getData('text/plain') ?? '';
|
|
619
622
|
handlePasteToTable(clipboardText);
|
|
@@ -621,7 +624,7 @@ const TableContainerEdit = props => {
|
|
|
621
624
|
};
|
|
622
625
|
window.addEventListener('paste', handlePaste);
|
|
623
626
|
return () => window.removeEventListener('paste', handlePaste);
|
|
624
|
-
}, [startCell, endCell, table, handlePasteToTable]);
|
|
627
|
+
}, [startCell, endCell, table, handlePasteToTable, editingKey]);
|
|
625
628
|
_react.default.useEffect(() => {
|
|
626
629
|
const handleClickOutside = event => {
|
|
627
630
|
const element = event.target;
|
|
@@ -634,7 +637,7 @@ const TableContainerEdit = props => {
|
|
|
634
637
|
const isInsideContainerContext = containerContextMenu && element.closest(".popup-context-menu");
|
|
635
638
|
const isInsideToolbar = element.closest(`.ui-rc-toolbar-selection-overflow-item`) && itemContainer;
|
|
636
639
|
const isInsideHeader = itemHeader && itemHeader.contains(event.target);
|
|
637
|
-
if (isInsideContainer || isInsideToolbar || isInsideHeader || isInsideContainerContext) {
|
|
640
|
+
if (isInsideContainer || isInsideToolbar || isInsideHeader || isInsideContainerContext || element.id === id) {
|
|
638
641
|
return;
|
|
639
642
|
}
|
|
640
643
|
if (containerRef.current && tableBody && !tableBody.contains(event.target)) {
|
|
@@ -661,14 +664,30 @@ const TableContainerEdit = props => {
|
|
|
661
664
|
// document.removeEventListener('touchstart', handleClickOutside)
|
|
662
665
|
};
|
|
663
666
|
}, [dataSource, editingKey, id, onBlur]);
|
|
667
|
+
const columnSizingState = table.getState().columnSizing;
|
|
668
|
+
_react.default.useEffect(() => {
|
|
669
|
+
requestAnimationFrame(() => {
|
|
670
|
+
columnVirtualizer.measure();
|
|
671
|
+
});
|
|
672
|
+
}, [columnSizingState, columnVirtualizer]);
|
|
664
673
|
|
|
665
674
|
// React.useEffect(() => {
|
|
666
|
-
//
|
|
675
|
+
// if (!containerRef.current) return;
|
|
676
|
+
|
|
677
|
+
// const containerWidth = containerRef.current.offsetWidth - 2;
|
|
678
|
+
// const totalWidth = table.getTotalSize();
|
|
679
|
+
|
|
680
|
+
// if (totalWidth && totalWidth < containerWidth) {
|
|
681
|
+
// const factor = containerWidth / totalWidth;
|
|
667
682
|
|
|
668
|
-
//
|
|
669
|
-
//
|
|
683
|
+
// table.setColumnSizing(
|
|
684
|
+
// table.getAllLeafColumns().reduce((acc, col) => {
|
|
685
|
+
// acc[col.id] = ((col.getSize() || col.columnDef.size || 150) * factor);
|
|
686
|
+
// return acc;
|
|
687
|
+
// }, {} as Record<string, number>)
|
|
688
|
+
// );
|
|
670
689
|
// }
|
|
671
|
-
// }, [
|
|
690
|
+
// }, [table.getTotalSize(), windowSize.innerWidth])
|
|
672
691
|
|
|
673
692
|
_react.default.useEffect(() => {
|
|
674
693
|
const totalHeight = minHeight ?? height;
|
|
@@ -1491,6 +1510,8 @@ const TableContainerEdit = props => {
|
|
|
1491
1510
|
onSubmit: handleSubmit(onSubmit)
|
|
1492
1511
|
}, /*#__PURE__*/_react.default.createElement(_useContext.TableContext.Provider, {
|
|
1493
1512
|
value: {
|
|
1513
|
+
t,
|
|
1514
|
+
isDataTree,
|
|
1494
1515
|
locale,
|
|
1495
1516
|
prefix,
|
|
1496
1517
|
id,
|
|
@@ -50,7 +50,7 @@ const filterTreeNode = (input, treeNode) => {
|
|
|
50
50
|
};
|
|
51
51
|
const EditableCell = props => {
|
|
52
52
|
const {
|
|
53
|
-
t,
|
|
53
|
+
// t,
|
|
54
54
|
// editing,
|
|
55
55
|
dataIndex,
|
|
56
56
|
editType,
|
|
@@ -71,7 +71,8 @@ const EditableCell = props => {
|
|
|
71
71
|
errors,
|
|
72
72
|
id,
|
|
73
73
|
startCell,
|
|
74
|
-
rowKey
|
|
74
|
+
rowKey,
|
|
75
|
+
t
|
|
75
76
|
} = (0, _react.useContext)(_useContext.TableContext);
|
|
76
77
|
const datePickerRef = _react.default.useRef(null);
|
|
77
78
|
const dateTimePickerRef = _react.default.useRef(null);
|