es-grid-template 1.2.6 → 1.2.8
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/AdvanceFilter.d.ts +11 -7
- package/es/grid-component/AdvanceFilter.js +419 -509
- package/es/grid-component/ColumnsChoose.js +2 -1
- package/es/grid-component/ContextMenu.js +2 -1
- package/es/grid-component/EditableCell.d.ts +2 -2
- package/es/grid-component/EditableCell.js +16 -11
- package/es/grid-component/InternalTable.js +128 -2
- package/es/grid-component/TableGrid.js +11 -2
- package/es/grid-component/checkbox-control/index.d.ts +13 -0
- package/es/grid-component/checkbox-control/index.js +40 -0
- package/es/grid-component/hooks/columns/index.d.ts +2 -2
- package/es/grid-component/hooks/columns/index.js +8 -2
- package/es/grid-component/hooks/useColumns.js +5 -2
- package/es/grid-component/hooks/utils.d.ts +6 -5
- package/es/grid-component/hooks/utils.js +8 -2
- package/es/grid-component/styles.scss +13 -3
- package/es/grid-component/table/GridEdit.js +36 -18
- package/es/grid-component/type.d.ts +26 -13
- package/lib/grid-component/AdvanceFilter.d.ts +11 -7
- package/lib/grid-component/AdvanceFilter.js +415 -506
- package/lib/grid-component/ColumnsChoose.js +2 -1
- package/lib/grid-component/ContextMenu.js +2 -1
- package/lib/grid-component/EditableCell.d.ts +2 -2
- package/lib/grid-component/EditableCell.js +16 -11
- package/lib/grid-component/InternalTable.js +127 -1
- package/lib/grid-component/TableGrid.js +11 -2
- package/lib/grid-component/checkbox-control/index.d.ts +13 -0
- package/lib/grid-component/checkbox-control/index.js +48 -0
- package/lib/grid-component/hooks/columns/index.d.ts +2 -2
- package/lib/grid-component/hooks/columns/index.js +8 -2
- package/lib/grid-component/hooks/useColumns.js +5 -2
- package/lib/grid-component/hooks/utils.d.ts +6 -5
- package/lib/grid-component/hooks/utils.js +11 -4
- package/lib/grid-component/styles.scss +13 -3
- package/lib/grid-component/table/GridEdit.js +36 -18
- package/lib/grid-component/type.d.ts +26 -13
- package/package.json +4 -2
|
@@ -127,7 +127,7 @@ const GridEdit = props => {
|
|
|
127
127
|
const handleAddSingle = item => {
|
|
128
128
|
const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
|
|
129
129
|
const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : (0, _hooks.newGuid)();
|
|
130
|
-
if (item.onClick) {
|
|
130
|
+
if (item && item.onClick) {
|
|
131
131
|
item.onClick({
|
|
132
132
|
toolbar: item
|
|
133
133
|
});
|
|
@@ -190,7 +190,7 @@ const GridEdit = props => {
|
|
|
190
190
|
toolbar: item
|
|
191
191
|
});
|
|
192
192
|
} else {
|
|
193
|
-
if (!record
|
|
193
|
+
if (!record?.parentId) {
|
|
194
194
|
// Cập nhật data mới
|
|
195
195
|
const newData = [...dataSource];
|
|
196
196
|
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
@@ -235,7 +235,7 @@ const GridEdit = props => {
|
|
|
235
235
|
toolbar: item
|
|
236
236
|
});
|
|
237
237
|
} else {
|
|
238
|
-
if (!record
|
|
238
|
+
if (!record?.parentId) {
|
|
239
239
|
// Cập nhật data mới
|
|
240
240
|
const newData = [...dataSource];
|
|
241
241
|
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
@@ -335,7 +335,7 @@ const GridEdit = props => {
|
|
|
335
335
|
color: '#28c76f'
|
|
336
336
|
},
|
|
337
337
|
onClick: () => handleAddSingle(item)
|
|
338
|
-
}, item.
|
|
338
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
|
|
339
339
|
}
|
|
340
340
|
};
|
|
341
341
|
}
|
|
@@ -353,7 +353,7 @@ const GridEdit = props => {
|
|
|
353
353
|
variant: 'outlined',
|
|
354
354
|
onClick: handleDeleteAll,
|
|
355
355
|
className: "d-flex toolbar-button"
|
|
356
|
-
}, item.
|
|
356
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
|
|
357
357
|
}
|
|
358
358
|
};
|
|
359
359
|
}
|
|
@@ -384,7 +384,7 @@ const GridEdit = props => {
|
|
|
384
384
|
color: '#28c76f'
|
|
385
385
|
},
|
|
386
386
|
onClick: () => handleAddSingle(item)
|
|
387
|
-
}, item.
|
|
387
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
|
|
388
388
|
}
|
|
389
389
|
};
|
|
390
390
|
}
|
|
@@ -402,7 +402,7 @@ const GridEdit = props => {
|
|
|
402
402
|
variant: 'outlined',
|
|
403
403
|
onClick: handleDuplicate,
|
|
404
404
|
className: "d-flex toolbar-button"
|
|
405
|
-
}, item.
|
|
405
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Duplicate') : 'Duplicate')));
|
|
406
406
|
}
|
|
407
407
|
};
|
|
408
408
|
}
|
|
@@ -420,7 +420,7 @@ const GridEdit = props => {
|
|
|
420
420
|
variant: 'outlined',
|
|
421
421
|
onClick: () => handleInsertBefore(item),
|
|
422
422
|
className: "d-flex toolbar-button"
|
|
423
|
-
}, item.
|
|
423
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before')));
|
|
424
424
|
}
|
|
425
425
|
};
|
|
426
426
|
}
|
|
@@ -438,7 +438,7 @@ const GridEdit = props => {
|
|
|
438
438
|
variant: 'outlined',
|
|
439
439
|
onClick: () => handleInsertAfter(item),
|
|
440
440
|
className: "d-flex toolbar-button"
|
|
441
|
-
}, item.
|
|
441
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')));
|
|
442
442
|
}
|
|
443
443
|
};
|
|
444
444
|
}
|
|
@@ -456,7 +456,7 @@ const GridEdit = props => {
|
|
|
456
456
|
variant: 'outlined',
|
|
457
457
|
onClick: () => handleInsertChild(item),
|
|
458
458
|
className: "d-flex toolbar-button"
|
|
459
|
-
}, item.
|
|
459
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')));
|
|
460
460
|
}
|
|
461
461
|
};
|
|
462
462
|
}
|
|
@@ -474,7 +474,7 @@ const GridEdit = props => {
|
|
|
474
474
|
variant: 'outlined',
|
|
475
475
|
onClick: handleDeleteAll,
|
|
476
476
|
className: "d-flex toolbar-button"
|
|
477
|
-
}, item.
|
|
477
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
|
|
478
478
|
}
|
|
479
479
|
};
|
|
480
480
|
}
|
|
@@ -627,7 +627,7 @@ const GridEdit = props => {
|
|
|
627
627
|
});
|
|
628
628
|
const newRange = (0, _hooks.addRows8)(table, (0, _hooks.getRowsPasteIndex)(pastesArray).length);
|
|
629
629
|
const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[(0, _hooks.getFirstSelectCell)(pastesArray).row];
|
|
630
|
-
if (!record
|
|
630
|
+
if (!record?.parentId) {
|
|
631
631
|
// Cập nhật data mới
|
|
632
632
|
const newData = [...dataSource];
|
|
633
633
|
|
|
@@ -905,7 +905,7 @@ const GridEdit = props => {
|
|
|
905
905
|
|
|
906
906
|
// Chuyển đổi dữ liệu từ clipboard thành mảng
|
|
907
907
|
const rows = pasteData.split("\n").map(row => row.replace(/\r/g, "").split("\t"));
|
|
908
|
-
if (!record
|
|
908
|
+
if (!record?.parentId) {
|
|
909
909
|
// Cập nhật data mới
|
|
910
910
|
const newData = [...dataSource];
|
|
911
911
|
|
|
@@ -1301,7 +1301,10 @@ const GridEdit = props => {
|
|
|
1301
1301
|
onKeyDown: event => {
|
|
1302
1302
|
const key = getRowKey(record, dataSource.indexOf(record));
|
|
1303
1303
|
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
|
|
1304
|
-
if (
|
|
1304
|
+
if (record[rowKey] !== editingKey) {
|
|
1305
|
+
// ~~ khi editingKey = ''
|
|
1306
|
+
event.preventDefault();
|
|
1307
|
+
event.stopPropagation();
|
|
1305
1308
|
handleEdit(record, column, column.editType, event);
|
|
1306
1309
|
handleCellClick(rowNumber, record, column);
|
|
1307
1310
|
const hasKey = mergedExpandedKeys.has(key);
|
|
@@ -1311,9 +1314,24 @@ const GridEdit = props => {
|
|
|
1311
1314
|
} else {
|
|
1312
1315
|
onTriggerExpand(record);
|
|
1313
1316
|
}
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
+
} else {
|
|
1318
|
+
if (event.key === 'Enter') {
|
|
1319
|
+
event.preventDefault();
|
|
1320
|
+
event.stopPropagation();
|
|
1321
|
+
if (editingKey && editingKey !== '' && (rowNumber ?? 0) + 1 < (0, _hooks.flattenArray)(dataSource).length && event.key === 'Enter') {
|
|
1322
|
+
handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
1323
|
+
} else {
|
|
1324
|
+
// focus cell hiện tại và tắt edit
|
|
1325
|
+
handleFocusCell(rowNumber ?? 0, colIndex, column, 'vertical', event);
|
|
1326
|
+
setEditingKey('');
|
|
1327
|
+
|
|
1328
|
+
// thêm dòng mới
|
|
1329
|
+
|
|
1330
|
+
// handleAddSingle()
|
|
1331
|
+
//
|
|
1332
|
+
// handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event)
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1317
1335
|
}
|
|
1318
1336
|
}
|
|
1319
1337
|
if (event.key === 'Tab') {
|
|
@@ -1366,7 +1384,7 @@ const GridEdit = props => {
|
|
|
1366
1384
|
},
|
|
1367
1385
|
onClick: () => {
|
|
1368
1386
|
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
1369
|
-
setEditingKey('')
|
|
1387
|
+
// setEditingKey('')
|
|
1370
1388
|
}
|
|
1371
1389
|
},
|
|
1372
1390
|
// className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable',
|
|
@@ -7,15 +7,17 @@ import type { ToolbarItem as RcToolbarItem } from "rc-master-ui/es/toolbar";
|
|
|
7
7
|
import type { ItemType } from "rc-master-ui/es/menu/interface";
|
|
8
8
|
import type { FieldNames, FilterFunc } from "rc-select/es/Select";
|
|
9
9
|
import type { ColorPickerProps } from "antd";
|
|
10
|
+
import type { FixedType } from "rc-base-table/lib/interface";
|
|
10
11
|
export type IColumnType = "number" | "time" | "date" | "week" | "month" | "file" | "quarter" | "year" | "datetime" | "string" | "boolean" | "checkbox" | "color" | null | undefined;
|
|
11
12
|
export type AnyObject = Record<PropertyKey, any>;
|
|
12
|
-
export type ToolbarItem = Omit<RcToolbarItem, 'position'> & {
|
|
13
|
-
position?: 'Top' | 'Bottom';
|
|
14
|
-
onClick?: (args: any) => void;
|
|
15
|
-
};
|
|
16
13
|
export type SelectMode = 'checkbox' | 'radio' | undefined;
|
|
17
14
|
export type ITextAlign = 'center' | 'left' | 'right';
|
|
18
15
|
export type Frozen = 'left' | 'right' | 'Left' | 'Right';
|
|
16
|
+
export type ToolbarItem = Omit<RcToolbarItem, 'position' | 'align'> & {
|
|
17
|
+
position?: 'Top' | 'Bottom';
|
|
18
|
+
align?: ITextAlign;
|
|
19
|
+
onClick?: (args: any) => void;
|
|
20
|
+
};
|
|
19
21
|
export type ContextMenuItem = ItemType & {};
|
|
20
22
|
export type ITemplateColumn = {
|
|
21
23
|
value: any;
|
|
@@ -26,7 +28,7 @@ export type ITemplateColumn = {
|
|
|
26
28
|
};
|
|
27
29
|
export type ColumnSelectTable = {
|
|
28
30
|
field: string;
|
|
29
|
-
dataIndex
|
|
31
|
+
dataIndex?: string;
|
|
30
32
|
type?: IColumnType;
|
|
31
33
|
headerText?: string;
|
|
32
34
|
fixedType?: 'left' | 'right' | undefined;
|
|
@@ -86,6 +88,8 @@ export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTempl
|
|
|
86
88
|
field?: string;
|
|
87
89
|
key?: any;
|
|
88
90
|
type?: IColumnType;
|
|
91
|
+
/** @deprecated This function is deprecated and should use `onChange` instead */
|
|
92
|
+
haveSum?: boolean;
|
|
89
93
|
isSummary?: boolean;
|
|
90
94
|
summaryTemplate?: (data: number, key: string) => ReactElement | ReactNode;
|
|
91
95
|
maxWidth?: string | number;
|
|
@@ -100,18 +104,16 @@ export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTempl
|
|
|
100
104
|
source?: any[];
|
|
101
105
|
showFilterSearch?: boolean;
|
|
102
106
|
headerText?: string;
|
|
107
|
+
visible?: boolean;
|
|
103
108
|
headerTooltip?: boolean | string | (() => ReactNode | ReactElement);
|
|
104
109
|
columnGroupText?: string;
|
|
105
110
|
textAlign?: ITextAlign;
|
|
106
|
-
|
|
107
|
-
template?: ReactNode | ReactElement | ((value: any, record: RecordType, index: number) => ReactNode | ReactElement);
|
|
111
|
+
template?: ReactNode | ReactElement | ((args: ColumnTemplate<RecordType>) => ReactNode | ReactElement);
|
|
108
112
|
showTooltip?: boolean;
|
|
109
113
|
tooltipDescription?: ReactNode | ReactElement | ((value: any, record: RecordType, index: number) => ReactNode | ReactElement);
|
|
110
114
|
headerTemplate?: React.ReactNode | React.ReactElement | ((column: ColumnType<RecordType>) => React.ReactNode | React.ReactElement);
|
|
111
115
|
commandItems?: CommandItem[];
|
|
112
116
|
children?: ColumnType<RecordType>[];
|
|
113
|
-
};
|
|
114
|
-
export type ColumnEditType<RecordType = AnyObject> = Omit<ColumnType<RecordType>, 'children'> & {
|
|
115
117
|
editType?: EditType | ((rowData?: RecordType) => EditType);
|
|
116
118
|
disable?: boolean | ((rowData: any) => boolean);
|
|
117
119
|
editEnable?: boolean | ((rowData: any) => boolean);
|
|
@@ -123,12 +125,17 @@ export type ColumnEditType<RecordType = AnyObject> = Omit<ColumnType<RecordType>
|
|
|
123
125
|
max?: number;
|
|
124
126
|
min?: number;
|
|
125
127
|
editSelectSettings?: IEditSelectSettings;
|
|
126
|
-
|
|
128
|
+
fixedType?: FixedType;
|
|
129
|
+
};
|
|
130
|
+
export type ColumnTemplate<RecordType> = {
|
|
131
|
+
value: any;
|
|
132
|
+
rowData: RecordType;
|
|
133
|
+
index: number;
|
|
134
|
+
field: string;
|
|
127
135
|
};
|
|
128
136
|
export type ColumnsType<RecordType = AnyObject> = ColumnType<RecordType>[];
|
|
129
|
-
export type
|
|
130
|
-
export type
|
|
131
|
-
export type ColumnsTable<RecordType = AnyObject> = (ColumnType<RecordType> | ColumnEditType<RecordType>)[];
|
|
137
|
+
export type ColumnTable<RecordType = AnyObject> = ColumnType<RecordType>;
|
|
138
|
+
export type ColumnsTable<RecordType = AnyObject> = ColumnTable<RecordType>[];
|
|
132
139
|
export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary'> {
|
|
133
140
|
editAble?: boolean;
|
|
134
141
|
groupAble?: boolean;
|
|
@@ -150,6 +157,7 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
|
|
|
150
157
|
recordDoubleClick?: (args: RecordDoubleClickEventArgs<RecordType>) => void;
|
|
151
158
|
toolbarItems?: ToolbarItem[];
|
|
152
159
|
showColumnChoose?: boolean;
|
|
160
|
+
showAdvanceFilter?: boolean;
|
|
153
161
|
onFilter?: (query: {
|
|
154
162
|
field: string;
|
|
155
163
|
key: string;
|
|
@@ -180,6 +188,7 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
|
|
|
180
188
|
defaultValue?: AnyObject | (() => AnyObject);
|
|
181
189
|
summary?: boolean | ((data: readonly RecordType[]) => React.ReactNode);
|
|
182
190
|
showEmptyText?: boolean;
|
|
191
|
+
commandSettings?: CommandSettings;
|
|
183
192
|
}
|
|
184
193
|
export interface TableEditProps<RecordType = AnyObject> extends Omit<TableProps<RecordType>, 'columns'> {
|
|
185
194
|
columns: ColumnsTable<RecordType>;
|
|
@@ -289,4 +298,8 @@ export type IFormat = {
|
|
|
289
298
|
};
|
|
290
299
|
export type GetRowKey<RecordType> = (record: RecordType, index?: number) => Key;
|
|
291
300
|
export type Presets = Required<ColorPickerProps>['presets'][number];
|
|
301
|
+
export type CommandSettings = {
|
|
302
|
+
client?: boolean;
|
|
303
|
+
confirmDialog?: boolean;
|
|
304
|
+
};
|
|
292
305
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-grid-template",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "es-grid-template",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"rc-checkbox": "^3.5.0",
|
|
61
61
|
"rc-dropdown": "^4.2.1",
|
|
62
62
|
"rc-field-form": "^2.6.0",
|
|
63
|
-
"rc-master-ui": "^1.1.
|
|
63
|
+
"rc-master-ui": "^1.1.22",
|
|
64
64
|
"rc-select": "^14.16.3",
|
|
65
65
|
"rc-tooltip": "^6.3.0",
|
|
66
66
|
"rc-tree": "^5.10.1",
|
|
@@ -71,6 +71,8 @@
|
|
|
71
71
|
"react-resizable": "^3.0.5",
|
|
72
72
|
"sass": "^1.81.0",
|
|
73
73
|
"styled-components": "^6.1.15",
|
|
74
|
+
"sweetalert2": "^11.4.14",
|
|
75
|
+
"sweetalert2-react-content": "^5.0.0",
|
|
74
76
|
"throttle-debounce": "^5.0.2",
|
|
75
77
|
"vitest": "^2.0.5"
|
|
76
78
|
},
|