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
|
@@ -120,7 +120,7 @@ const GridEdit = props => {
|
|
|
120
120
|
const handleAddSingle = item => {
|
|
121
121
|
const defaultRowValue = getDefaultValue(defaultValue);
|
|
122
122
|
const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid();
|
|
123
|
-
if (item.onClick) {
|
|
123
|
+
if (item && item.onClick) {
|
|
124
124
|
item.onClick({
|
|
125
125
|
toolbar: item
|
|
126
126
|
});
|
|
@@ -183,7 +183,7 @@ const GridEdit = props => {
|
|
|
183
183
|
toolbar: item
|
|
184
184
|
});
|
|
185
185
|
} else {
|
|
186
|
-
if (!record
|
|
186
|
+
if (!record?.parentId) {
|
|
187
187
|
// Cập nhật data mới
|
|
188
188
|
const newData = [...dataSource];
|
|
189
189
|
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
@@ -228,7 +228,7 @@ const GridEdit = props => {
|
|
|
228
228
|
toolbar: item
|
|
229
229
|
});
|
|
230
230
|
} else {
|
|
231
|
-
if (!record
|
|
231
|
+
if (!record?.parentId) {
|
|
232
232
|
// Cập nhật data mới
|
|
233
233
|
const newData = [...dataSource];
|
|
234
234
|
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
@@ -328,7 +328,7 @@ const GridEdit = props => {
|
|
|
328
328
|
color: '#28c76f'
|
|
329
329
|
},
|
|
330
330
|
onClick: () => handleAddSingle(item)
|
|
331
|
-
}, item.
|
|
331
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
|
|
332
332
|
}
|
|
333
333
|
};
|
|
334
334
|
}
|
|
@@ -346,7 +346,7 @@ const GridEdit = props => {
|
|
|
346
346
|
variant: 'outlined',
|
|
347
347
|
onClick: handleDeleteAll,
|
|
348
348
|
className: "d-flex toolbar-button"
|
|
349
|
-
}, item.
|
|
349
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
|
|
350
350
|
}
|
|
351
351
|
};
|
|
352
352
|
}
|
|
@@ -377,7 +377,7 @@ const GridEdit = props => {
|
|
|
377
377
|
color: '#28c76f'
|
|
378
378
|
},
|
|
379
379
|
onClick: () => handleAddSingle(item)
|
|
380
|
-
}, item.
|
|
380
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item'))));
|
|
381
381
|
}
|
|
382
382
|
};
|
|
383
383
|
}
|
|
@@ -395,7 +395,7 @@ const GridEdit = props => {
|
|
|
395
395
|
variant: 'outlined',
|
|
396
396
|
onClick: handleDuplicate,
|
|
397
397
|
className: "d-flex toolbar-button"
|
|
398
|
-
}, item.
|
|
398
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Duplicate') : 'Duplicate')));
|
|
399
399
|
}
|
|
400
400
|
};
|
|
401
401
|
}
|
|
@@ -413,7 +413,7 @@ const GridEdit = props => {
|
|
|
413
413
|
variant: 'outlined',
|
|
414
414
|
onClick: () => handleInsertBefore(item),
|
|
415
415
|
className: "d-flex toolbar-button"
|
|
416
|
-
}, item.
|
|
416
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before')));
|
|
417
417
|
}
|
|
418
418
|
};
|
|
419
419
|
}
|
|
@@ -431,7 +431,7 @@ const GridEdit = props => {
|
|
|
431
431
|
variant: 'outlined',
|
|
432
432
|
onClick: () => handleInsertAfter(item),
|
|
433
433
|
className: "d-flex toolbar-button"
|
|
434
|
-
}, item.
|
|
434
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')));
|
|
435
435
|
}
|
|
436
436
|
};
|
|
437
437
|
}
|
|
@@ -449,7 +449,7 @@ const GridEdit = props => {
|
|
|
449
449
|
variant: 'outlined',
|
|
450
450
|
onClick: () => handleInsertChild(item),
|
|
451
451
|
className: "d-flex toolbar-button"
|
|
452
|
-
}, item.
|
|
452
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')));
|
|
453
453
|
}
|
|
454
454
|
};
|
|
455
455
|
}
|
|
@@ -467,7 +467,7 @@ const GridEdit = props => {
|
|
|
467
467
|
variant: 'outlined',
|
|
468
468
|
onClick: handleDeleteAll,
|
|
469
469
|
className: "d-flex toolbar-button"
|
|
470
|
-
}, item.
|
|
470
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item'));
|
|
471
471
|
}
|
|
472
472
|
};
|
|
473
473
|
}
|
|
@@ -620,7 +620,7 @@ const GridEdit = props => {
|
|
|
620
620
|
});
|
|
621
621
|
const newRange = addRows8(table, getRowsPasteIndex(pastesArray).length);
|
|
622
622
|
const record = flattenData(childrenColumnName, dataSource)[getFirstSelectCell(pastesArray).row];
|
|
623
|
-
if (!record
|
|
623
|
+
if (!record?.parentId) {
|
|
624
624
|
// Cập nhật data mới
|
|
625
625
|
const newData = [...dataSource];
|
|
626
626
|
|
|
@@ -898,7 +898,7 @@ const GridEdit = props => {
|
|
|
898
898
|
|
|
899
899
|
// Chuyển đổi dữ liệu từ clipboard thành mảng
|
|
900
900
|
const rows = pasteData.split("\n").map(row => row.replace(/\r/g, "").split("\t"));
|
|
901
|
-
if (!record
|
|
901
|
+
if (!record?.parentId) {
|
|
902
902
|
// Cập nhật data mới
|
|
903
903
|
const newData = [...dataSource];
|
|
904
904
|
|
|
@@ -1294,7 +1294,10 @@ const GridEdit = props => {
|
|
|
1294
1294
|
onKeyDown: event => {
|
|
1295
1295
|
const key = getRowKey(record, dataSource.indexOf(record));
|
|
1296
1296
|
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
|
|
1297
|
-
if (
|
|
1297
|
+
if (record[rowKey] !== editingKey) {
|
|
1298
|
+
// ~~ khi editingKey = ''
|
|
1299
|
+
event.preventDefault();
|
|
1300
|
+
event.stopPropagation();
|
|
1298
1301
|
handleEdit(record, column, column.editType, event);
|
|
1299
1302
|
handleCellClick(rowNumber, record, column);
|
|
1300
1303
|
const hasKey = mergedExpandedKeys.has(key);
|
|
@@ -1304,9 +1307,24 @@ const GridEdit = props => {
|
|
|
1304
1307
|
} else {
|
|
1305
1308
|
onTriggerExpand(record);
|
|
1306
1309
|
}
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
+
} else {
|
|
1311
|
+
if (event.key === 'Enter') {
|
|
1312
|
+
event.preventDefault();
|
|
1313
|
+
event.stopPropagation();
|
|
1314
|
+
if (editingKey && editingKey !== '' && (rowNumber ?? 0) + 1 < flattenArray(dataSource).length && event.key === 'Enter') {
|
|
1315
|
+
handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
1316
|
+
} else {
|
|
1317
|
+
// focus cell hiện tại và tắt edit
|
|
1318
|
+
handleFocusCell(rowNumber ?? 0, colIndex, column, 'vertical', event);
|
|
1319
|
+
setEditingKey('');
|
|
1320
|
+
|
|
1321
|
+
// thêm dòng mới
|
|
1322
|
+
|
|
1323
|
+
// handleAddSingle()
|
|
1324
|
+
//
|
|
1325
|
+
// handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event)
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1310
1328
|
}
|
|
1311
1329
|
}
|
|
1312
1330
|
if (event.key === 'Tab') {
|
|
@@ -1359,7 +1377,7 @@ const GridEdit = props => {
|
|
|
1359
1377
|
},
|
|
1360
1378
|
onClick: () => {
|
|
1361
1379
|
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
1362
|
-
setEditingKey('')
|
|
1380
|
+
// setEditingKey('')
|
|
1363
1381
|
}
|
|
1364
1382
|
},
|
|
1365
1383
|
// 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 {};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
columns:
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import type { IFormat } from "./type";
|
|
3
|
+
type Props = {
|
|
4
|
+
columns: any[];
|
|
5
|
+
dataSourceFilter?: any[];
|
|
6
|
+
onFilter?: (query: any, col?: any[]) => void;
|
|
7
|
+
mode?: 'sidebar' | 'dropdown';
|
|
8
|
+
defaultFilter?: any[];
|
|
9
|
+
leftFilterWidth?: number;
|
|
10
|
+
format?: IFormat;
|
|
7
11
|
t?: any;
|
|
8
|
-
triggerChangeKeys?: any;
|
|
9
12
|
};
|
|
10
|
-
|
|
13
|
+
declare const AdvanceFilter: (props: Props) => React.JSX.Element;
|
|
14
|
+
export default AdvanceFilter;
|