es-grid-template 1.8.28 → 1.8.30
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/CHANGELOG.md +6 -0
- package/LICENSE +21 -21
- package/README.md +1 -1
- package/assets/index.scss +1170 -1170
- package/es/grid-component/hooks/constant.js +6 -6
- package/es/grid-component/hooks/useColumns.d.ts +1 -3
- package/es/grid-component/styles.scss +1437 -1437
- package/es/table-component/TableContainer.d.ts +7 -0
- package/es/table-component/TableContainer.js +7 -2
- package/es/table-component/TableContainerEdit.d.ts +7 -0
- package/es/table-component/TableContainerEdit.js +24 -9
- package/es/table-component/body/TableBodyCell.js +79 -37
- package/es/table-component/body/TableBodyCellEdit.js +57 -73
- package/es/table-component/body/TableBodyRow.js +4 -2
- package/es/table-component/components/number/index.d.ts +2 -1
- package/es/table-component/components/number/index.js +13 -5
- package/es/table-component/components/number-range/index.d.ts +2 -1
- package/es/table-component/components/number-range/index.js +22 -6
- package/es/table-component/header/TableHeadCell.js +2 -1
- package/es/table-component/header/TableHeadCell2.js +41 -16
- package/es/table-component/header/TableHeadGroupCell.js +2 -1
- package/es/table-component/header/renderFilter.d.ts +1 -1
- package/es/table-component/header/renderFilter.js +13 -5
- package/es/table-component/hook/constant.js +6 -6
- package/es/table-component/hook/useColumns.d.ts +21 -2
- package/es/table-component/hook/useColumns.js +115 -4
- package/es/table-component/hook/utils.d.ts +12 -1
- package/es/table-component/hook/utils.js +173 -0
- package/es/table-component/style.scss +1220 -1220
- package/es/table-component/table/Grid.js +29 -24
- package/es/table-component/table/TableWrapper.js +2 -1
- package/es/table-component/type.d.ts +10 -5
- package/es/table-component/useContext.d.ts +11 -2
- package/lib/grid-component/hooks/constant.js +6 -6
- package/lib/grid-component/hooks/useColumns.d.ts +1 -3
- package/lib/grid-component/styles.scss +1437 -1437
- package/lib/table-component/TableContainer.d.ts +7 -0
- package/lib/table-component/TableContainer.js +7 -2
- package/lib/table-component/TableContainerEdit.d.ts +7 -0
- package/lib/table-component/TableContainerEdit.js +23 -8
- package/lib/table-component/body/TableBodyCell.js +79 -37
- package/lib/table-component/body/TableBodyCellEdit.js +57 -73
- package/lib/table-component/body/TableBodyRow.js +4 -2
- package/lib/table-component/components/number/index.d.ts +2 -1
- package/lib/table-component/components/number/index.js +13 -5
- package/lib/table-component/components/number-range/index.d.ts +2 -1
- package/lib/table-component/components/number-range/index.js +22 -6
- package/lib/table-component/header/TableHeadCell.js +2 -1
- package/lib/table-component/header/TableHeadCell2.js +40 -15
- package/lib/table-component/header/TableHeadGroupCell.js +2 -1
- package/lib/table-component/header/renderFilter.d.ts +1 -1
- package/lib/table-component/header/renderFilter.js +13 -5
- package/lib/table-component/hook/constant.js +6 -6
- package/lib/table-component/hook/useColumns.d.ts +21 -2
- package/lib/table-component/hook/useColumns.js +116 -4
- package/lib/table-component/hook/utils.d.ts +12 -1
- package/lib/table-component/hook/utils.js +193 -4
- package/lib/table-component/style.scss +1220 -1220
- package/lib/table-component/table/Grid.js +28 -23
- package/lib/table-component/table/TableWrapper.js +2 -1
- package/lib/table-component/type.d.ts +10 -5
- package/lib/table-component/useContext.d.ts +11 -2
- package/package.json +117 -116
|
@@ -17,7 +17,7 @@ import { arrayMove } from '@dnd-kit/sortable';
|
|
|
17
17
|
import React from 'react';
|
|
18
18
|
import TableContainer from "../TableContainer";
|
|
19
19
|
import { OperatorFeature } from "../features/operator";
|
|
20
|
-
import { convertFilters, convertToObjTrue, filterDataByColumns, getAllRowKey, isObjEqual } from "../hook/utils";
|
|
20
|
+
import { convertFilters, convertToObjTrue, filterByIds, filterDataByColumns, getAllRowKey, isObjEqual } from "../hook/utils";
|
|
21
21
|
import TableContainerEdit from "../TableContainerEdit";
|
|
22
22
|
const Grid = props => {
|
|
23
23
|
const {
|
|
@@ -42,8 +42,8 @@ const Grid = props => {
|
|
|
42
42
|
setMergedFilterKeys,
|
|
43
43
|
onSorter,
|
|
44
44
|
onFilter,
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
allowFiltering,
|
|
46
|
+
allowSortering,
|
|
47
47
|
groupColumns,
|
|
48
48
|
// height= 700,
|
|
49
49
|
height,
|
|
@@ -52,6 +52,7 @@ const Grid = props => {
|
|
|
52
52
|
triggerChangeColumns,
|
|
53
53
|
infiniteScroll,
|
|
54
54
|
mergedSelectedKeys,
|
|
55
|
+
allowResizing,
|
|
55
56
|
...rest
|
|
56
57
|
} = props;
|
|
57
58
|
const [columnResizeMode] = React.useState('onChange');
|
|
@@ -65,6 +66,8 @@ const Grid = props => {
|
|
|
65
66
|
|
|
66
67
|
// const [rowSelection, setRowSelection] = React.useState<RowSelectionState>(convertToObjTrue(selectionSettings?.selectedRowKeys ?? []))
|
|
67
68
|
const [rowSelection, setRowSelection] = React.useState(convertToObjTrue(mergedSelectedKeys));
|
|
69
|
+
// const [rowsSelected, setRowsSelected] = React.useState<RecordType[]>([])
|
|
70
|
+
|
|
68
71
|
const [grouping, setGrouping] = React.useState([]);
|
|
69
72
|
const [columnSizing, setColumnSizing] = React.useState({});
|
|
70
73
|
const [columnSizingInfo, setColumnSizingInfo] = React.useState({});
|
|
@@ -78,7 +81,8 @@ const Grid = props => {
|
|
|
78
81
|
const [isSelectionChange, setIsSelectionChange] = React.useState({
|
|
79
82
|
isChange: false,
|
|
80
83
|
type: '',
|
|
81
|
-
rowData: {}
|
|
84
|
+
rowData: {},
|
|
85
|
+
rowsData: []
|
|
82
86
|
});
|
|
83
87
|
const [sorterChange, setSorterChange] = React.useState(false);
|
|
84
88
|
const [filterChange, setFilterChange] = React.useState(false);
|
|
@@ -111,15 +115,15 @@ const Grid = props => {
|
|
|
111
115
|
// enableRowSelection: true,
|
|
112
116
|
enableRowSelection: row => {
|
|
113
117
|
if (selectionSettings?.getCheckboxProps) {
|
|
114
|
-
return !selectionSettings?.getCheckboxProps(row.original)
|
|
118
|
+
return !selectionSettings?.getCheckboxProps(row.original)?.disabled;
|
|
115
119
|
}
|
|
116
120
|
return true;
|
|
117
121
|
},
|
|
118
122
|
onRowSelectionChange: setRowSelection,
|
|
119
|
-
// get
|
|
120
123
|
// RowSelection
|
|
121
124
|
|
|
122
125
|
// ColumnSizing
|
|
126
|
+
enableColumnResizing: allowResizing !== false,
|
|
123
127
|
columnResizeMode,
|
|
124
128
|
columnResizeDirection,
|
|
125
129
|
onColumnSizingChange: setColumnSizing,
|
|
@@ -128,13 +132,13 @@ const Grid = props => {
|
|
|
128
132
|
|
|
129
133
|
// ColumnSorting
|
|
130
134
|
// getSortedRowModel: getSortedRowModel(),
|
|
131
|
-
enableSorting: allowSorter !== false,
|
|
132
135
|
onSortingChange: setSorting,
|
|
133
136
|
enableMultiSort: sortMultiple,
|
|
134
137
|
isMultiSortEvent: () => sortMultiple ? true : false,
|
|
138
|
+
enableSorting: allowSortering !== false,
|
|
135
139
|
// ColumnSorting
|
|
136
140
|
|
|
137
|
-
enableFilters:
|
|
141
|
+
enableFilters: allowFiltering !== false,
|
|
138
142
|
onColumnFiltersChange: setColumnFilters,
|
|
139
143
|
onColumnOperatorChange: setOperator,
|
|
140
144
|
// getFilteredRowModel: getFilteredRowModel(),
|
|
@@ -175,41 +179,41 @@ const Grid = props => {
|
|
|
175
179
|
// }, [columnSizingInfo])
|
|
176
180
|
|
|
177
181
|
React.useEffect(() => {
|
|
178
|
-
// if (!manualUpdate) {
|
|
179
|
-
|
|
180
|
-
const isEqual = isObjEqual(convertToObjTrue(mergedSelectedKeys), rowSelection);
|
|
181
|
-
|
|
182
|
-
// console.log('isEqual', isEqual)
|
|
183
182
|
// if (Object.keys(rowSelection) !== Object.keys(mergedSelectedKeys) && !isSelectionChange.isChange) {
|
|
184
|
-
// // if (Object.keys(rowSelection) !== Object.keys(mergedSelectedKeys) && !isEqual) {
|
|
185
183
|
// setRowSelection(convertToObjTrue(mergedSelectedKeys))
|
|
186
184
|
|
|
187
185
|
// }
|
|
188
186
|
|
|
187
|
+
const isEqual = isObjEqual(convertToObjTrue(mergedSelectedKeys), rowSelection);
|
|
189
188
|
if (!isEqual) {
|
|
190
|
-
//
|
|
191
|
-
|
|
189
|
+
// setIsSelectionChange((prev) => ({
|
|
190
|
+
// ...prev,
|
|
191
|
+
// isChange: false
|
|
192
|
+
// }))
|
|
193
|
+
// setRowSelection(convertToObjTrue(mergedSelectedKeys))
|
|
192
194
|
}
|
|
193
195
|
}, [mergedSelectedKeys]);
|
|
194
196
|
React.useEffect(() => {
|
|
195
197
|
if (isSelectionChange.isChange) {
|
|
196
198
|
// setManualUpdate(true)
|
|
197
199
|
const aa = table.getState().rowSelection;
|
|
198
|
-
|
|
200
|
+
|
|
201
|
+
// const dataTable = table.getRowModel().flatRows
|
|
202
|
+
|
|
199
203
|
const ids = Object.keys(aa);
|
|
200
|
-
|
|
204
|
+
|
|
205
|
+
// const ssss = dataTable.filter(it => ids.includes(it.id)) // lấy rowsData của trang hiện tại
|
|
206
|
+
const ssss = filterByIds(ids, isSelectionChange.rowsData ?? []); // lấy rowsData của trang hiện tại
|
|
207
|
+
// const ssss = (isSelectionChange.rowsData ?? []) as any[] // lấy rowsData của trang hiện tại
|
|
208
|
+
|
|
201
209
|
const rs = ssss.map(it => it.original);
|
|
210
|
+
// const rs = allRows.map(it => it.original)
|
|
211
|
+
|
|
202
212
|
rowSelected?.({
|
|
203
213
|
type: isSelectionChange.type,
|
|
204
214
|
rowData: isSelectionChange.rowData,
|
|
205
215
|
selected: rs
|
|
206
216
|
});
|
|
207
|
-
|
|
208
|
-
// setIsSelectionChange((prev) => ({
|
|
209
|
-
// ...prev,
|
|
210
|
-
// isChange: false
|
|
211
|
-
|
|
212
|
-
// }))
|
|
213
217
|
}
|
|
214
218
|
}, [isSelectionChange, rowSelection, table.getState().rowSelection]);
|
|
215
219
|
React.useEffect(() => {
|
|
@@ -291,6 +295,7 @@ const Grid = props => {
|
|
|
291
295
|
originData: originData,
|
|
292
296
|
prefix: prefix,
|
|
293
297
|
selectionSettings: selectionSettings,
|
|
298
|
+
isSelectionChange: isSelectionChange,
|
|
294
299
|
setIsSelectionChange: setIsSelectionChange,
|
|
295
300
|
setSorterChange: setSorterChange,
|
|
296
301
|
setFilterChange: setFilterChange,
|
|
@@ -92,11 +92,11 @@ export type ColumnTable<RecordType = AnyObject> = {
|
|
|
92
92
|
format?: IFormat | ((rowData: any) => IFormat);
|
|
93
93
|
allowFiltering?: boolean;
|
|
94
94
|
/**
|
|
95
|
-
* @deprecated Please use `
|
|
95
|
+
* @deprecated Please use `allowSortering` instead.
|
|
96
96
|
* @since 1.7.25
|
|
97
97
|
*/
|
|
98
98
|
sorter?: boolean;
|
|
99
|
-
|
|
99
|
+
allowSortering?: boolean;
|
|
100
100
|
operator?: FilterOperator;
|
|
101
101
|
hideOperator?: boolean;
|
|
102
102
|
placeholder?: string;
|
|
@@ -122,7 +122,10 @@ export type ColumnTable<RecordType = AnyObject> = {
|
|
|
122
122
|
headerTextAlign?: ITextAlign;
|
|
123
123
|
template?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
|
|
124
124
|
showTooltip?: boolean;
|
|
125
|
-
tooltipDescription?:
|
|
125
|
+
tooltipDescription?: string | ((args: {
|
|
126
|
+
value: any;
|
|
127
|
+
record: RecordType;
|
|
128
|
+
}) => ReactNode | ReactElement);
|
|
126
129
|
headerTemplate?: React.ReactNode | React.ReactElement | ((column: ColumnTable<RecordType>) => React.ReactNode | React.ReactElement);
|
|
127
130
|
commandItems?: CommandItem[];
|
|
128
131
|
children?: ColumnTable<RecordType>[];
|
|
@@ -212,7 +215,7 @@ export type TableProps<RecordType = AnyObject> = {
|
|
|
212
215
|
toolbarItems?: ToolbarItem[];
|
|
213
216
|
showColumnChoose?: boolean;
|
|
214
217
|
showAdvanceFilter?: boolean;
|
|
215
|
-
|
|
218
|
+
allowFiltering?: boolean;
|
|
216
219
|
onFilter?: (query: {
|
|
217
220
|
field: string;
|
|
218
221
|
key: string;
|
|
@@ -220,7 +223,7 @@ export type TableProps<RecordType = AnyObject> = {
|
|
|
220
223
|
predicate: 'and' | 'or';
|
|
221
224
|
value: any;
|
|
222
225
|
}[]) => void;
|
|
223
|
-
|
|
226
|
+
allowSortering?: boolean;
|
|
224
227
|
onSorter?: (args: Sorter[]) => void;
|
|
225
228
|
selectionSettings?: SelectionSettings;
|
|
226
229
|
rowSelection?: RowSelection<RecordType>;
|
|
@@ -239,6 +242,7 @@ export type TableProps<RecordType = AnyObject> = {
|
|
|
239
242
|
summary?: boolean;
|
|
240
243
|
showEmptyText?: boolean;
|
|
241
244
|
commandSettings?: CommandSettings;
|
|
245
|
+
rowClassName?: string | RowClassName<RecordType>;
|
|
242
246
|
onCellPaste?: ICellPasteModel<RecordType>;
|
|
243
247
|
onCellChange?: (args: CellChangeArgs<RecordType>, handleCallback: (rowData: any, index: any, value?: any) => void) => void;
|
|
244
248
|
onCellClick?: (args: ICellClick, callback?: any) => void;
|
|
@@ -472,6 +476,7 @@ export type SelectionSettings<T = AnyObject> = {
|
|
|
472
476
|
mode?: 'checkbox' | 'radio';
|
|
473
477
|
type?: 'single' | 'multiple';
|
|
474
478
|
checkboxOnly?: boolean;
|
|
479
|
+
checkStrictly?: boolean;
|
|
475
480
|
columnWidth?: number;
|
|
476
481
|
hideSelectAll?: boolean;
|
|
477
482
|
selectedRowKeys?: Key[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import type { ColumnTable, ExpandableConfig, IFormat, IWrapSettings, Locale, PaginationConfig, RangeState, RecordDoubleClickEventArgs, SelectionSettings } from "./type";
|
|
2
|
+
import type { ColumnTable, ExpandableConfig, IFormat, IWrapSettings, Locale, PaginationConfig, RangeState, RecordDoubleClickEventArgs, RowClassName, SelectionSettings } from "./type";
|
|
3
3
|
import type { SubmitHandler } from "react-hook-form";
|
|
4
|
-
import type { ExpandedState } from '@tanstack/react-table';
|
|
4
|
+
import type { ExpandedState, Table } from '@tanstack/react-table';
|
|
5
5
|
export type IPositionCell = {
|
|
6
6
|
rowId: string;
|
|
7
7
|
colId: string;
|
|
@@ -20,10 +20,17 @@ export interface IContext<T> {
|
|
|
20
20
|
expanded: ExpandedState;
|
|
21
21
|
recordDoubleClick?: (args: RecordDoubleClickEventArgs<T>) => void;
|
|
22
22
|
selectionSettings?: SelectionSettings;
|
|
23
|
+
isSelectionChange?: {
|
|
24
|
+
isChange: boolean;
|
|
25
|
+
type: string;
|
|
26
|
+
rowData: T;
|
|
27
|
+
rowsData: T[];
|
|
28
|
+
};
|
|
23
29
|
setIsSelectionChange: Dispatch<SetStateAction<{
|
|
24
30
|
isChange: boolean;
|
|
25
31
|
type: string;
|
|
26
32
|
rowData: T;
|
|
33
|
+
rowsData: T[];
|
|
27
34
|
}>>;
|
|
28
35
|
setSorterChange: Dispatch<SetStateAction<boolean>>;
|
|
29
36
|
setFilterChange: Dispatch<SetStateAction<boolean>>;
|
|
@@ -68,6 +75,8 @@ export interface IContext<T> {
|
|
|
68
75
|
isDataTree: boolean;
|
|
69
76
|
handleCellClick?: (rowNumber: number, record: T, column: ColumnTable, rowId: string, cellValue: any) => void;
|
|
70
77
|
pagination?: false | PaginationConfig;
|
|
78
|
+
rowClassName?: string | RowClassName<T>;
|
|
79
|
+
table?: Table<T>;
|
|
71
80
|
}
|
|
72
81
|
export declare const TableContext: import("react").Context<IContext<any>>;
|
|
73
82
|
export type ContextCellChange = {
|
|
@@ -220,16 +220,16 @@ const optionFontSize = exports.optionFontSize = [{
|
|
|
220
220
|
label: '48'
|
|
221
221
|
}];
|
|
222
222
|
|
|
223
|
-
/**
|
|
224
|
-
* Sort order for BaseTable
|
|
223
|
+
/**
|
|
224
|
+
* Sort order for BaseTable
|
|
225
225
|
*/
|
|
226
226
|
const SortOrder = {
|
|
227
|
-
/**
|
|
228
|
-
* Sort data in ascending order
|
|
227
|
+
/**
|
|
228
|
+
* Sort data in ascending order
|
|
229
229
|
*/
|
|
230
230
|
ascend: 'Ascending',
|
|
231
|
-
/**
|
|
232
|
-
* Sort data in descending order
|
|
231
|
+
/**
|
|
232
|
+
* Sort data in descending order
|
|
233
233
|
*/
|
|
234
234
|
descend: 'Descending'
|
|
235
235
|
};
|
|
@@ -15,7 +15,5 @@ interface UseColumnsConfig<RecordType> {
|
|
|
15
15
|
rowKey?: any;
|
|
16
16
|
onMouseHover?: any;
|
|
17
17
|
}
|
|
18
|
-
declare const useColumns: <RecordType extends AnyObject = AnyObject>(config: UseColumnsConfig<RecordType>) => readonly [
|
|
19
|
-
any
|
|
20
|
-
];
|
|
18
|
+
declare const useColumns: <RecordType extends AnyObject = AnyObject>(config: UseColumnsConfig<RecordType>) => readonly [any];
|
|
21
19
|
export default useColumns;
|