es-grid-template 0.0.7 → 0.0.13
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/LICENSE +21 -19
- package/es/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +1 -1
- package/es/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +7 -11
- package/es/grid-component/ColumnsChoose.d.ts +9 -0
- package/es/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +66 -70
- package/es/grid-component/EditableCell.d.ts +19 -0
- package/es/grid-component/EditableCell.js +842 -0
- package/es/{FilterSearch.js → grid-component/FilterSearch.js} +2 -2
- package/es/grid-component/GridStyle.d.ts +4 -0
- package/es/grid-component/GridStyle.js +5 -0
- package/es/grid-component/InternalTable.d.ts +6 -0
- package/es/grid-component/InternalTable.js +283 -0
- package/es/grid-component/LoadingSpinner.d.ts +3 -0
- package/es/grid-component/LoadingSpinner.js +20 -0
- package/es/grid-component/Message/Message.d.ts +2 -0
- package/es/grid-component/Message/Message.js +16 -0
- package/es/grid-component/Message/index.d.ts +1 -0
- package/es/grid-component/Message/index.js +1 -0
- package/es/grid-component/TableGrid.d.ts +10 -0
- package/es/grid-component/TableGrid.js +375 -0
- package/es/grid-component/async-table-select/index.d.ts +9 -0
- package/es/grid-component/async-table-select/index.js +37 -0
- package/es/{hooks → grid-component/hooks}/constant.d.ts +14 -0
- package/es/{hooks → grid-component/hooks}/constant.js +17 -2
- package/es/grid-component/hooks/useColumns/index.d.ts +6 -0
- package/es/grid-component/hooks/useColumns/index.js +422 -0
- package/es/grid-component/hooks/utils.d.ts +35 -0
- package/es/{hooks → grid-component/hooks}/utils.js +147 -19
- package/es/grid-component/index.d.ts +2 -0
- package/es/grid-component/index.js +2 -0
- package/es/grid-component/rc-table/Grid.d.ts +8 -0
- package/es/grid-component/rc-table/Grid.js +99 -0
- package/es/grid-component/rc-table/GridEdit.d.ts +9 -0
- package/es/grid-component/rc-table/GridEdit.js +706 -0
- package/es/grid-component/type.d.ts +225 -0
- package/es/grid-component/useContext.d.ts +27 -0
- package/es/grid-component/useContext.js +4 -0
- package/es/index.d.ts +1 -2
- package/es/index.js +2 -2
- package/es/table-grid/styles.scss +551 -0
- package/lib/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +1 -1
- package/lib/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +11 -14
- package/lib/grid-component/ColumnsChoose.d.ts +9 -0
- package/lib/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +66 -70
- package/lib/grid-component/EditableCell.d.ts +19 -0
- package/lib/grid-component/EditableCell.js +844 -0
- package/lib/{FilterSearch.js → grid-component/FilterSearch.js} +3 -3
- package/lib/grid-component/GridStyle.d.ts +4 -0
- package/lib/grid-component/GridStyle.js +12 -0
- package/lib/grid-component/InternalTable.d.ts +6 -0
- package/lib/grid-component/InternalTable.js +292 -0
- package/lib/grid-component/LoadingSpinner.d.ts +3 -0
- package/lib/grid-component/LoadingSpinner.js +29 -0
- package/lib/grid-component/Message/Message.d.ts +2 -0
- package/lib/grid-component/Message/Message.js +25 -0
- package/lib/grid-component/Message/index.d.ts +1 -0
- package/lib/grid-component/Message/index.js +16 -0
- package/lib/grid-component/TableGrid.d.ts +10 -0
- package/lib/grid-component/TableGrid.js +382 -0
- package/lib/grid-component/async-table-select/index.d.ts +9 -0
- package/lib/grid-component/async-table-select/index.js +46 -0
- package/lib/{hooks → grid-component/hooks}/constant.d.ts +14 -0
- package/lib/{hooks → grid-component/hooks}/constant.js +18 -3
- package/lib/grid-component/hooks/useColumns/index.d.ts +6 -0
- package/lib/grid-component/hooks/useColumns/index.js +435 -0
- package/lib/grid-component/hooks/utils.d.ts +35 -0
- package/lib/{hooks → grid-component/hooks}/utils.js +164 -22
- package/lib/grid-component/index.d.ts +2 -0
- package/lib/grid-component/index.js +9 -0
- package/lib/grid-component/rc-table/Grid.d.ts +8 -0
- package/lib/grid-component/rc-table/Grid.js +108 -0
- package/lib/grid-component/rc-table/GridEdit.d.ts +9 -0
- package/lib/grid-component/rc-table/GridEdit.js +715 -0
- package/lib/grid-component/type.d.ts +225 -0
- package/lib/grid-component/useContext.d.ts +27 -0
- package/lib/grid-component/useContext.js +10 -0
- package/lib/index.d.ts +1 -2
- package/lib/index.js +7 -3
- package/lib/table-grid/styles.scss +551 -0
- package/package.json +17 -6
- package/es/ColumnsChoose.d.ts +0 -10
- package/es/GridTable.d.ts +0 -7
- package/es/GridTable.js +0 -927
- package/es/hooks/useColumns/index.d.ts +0 -2
- package/es/hooks/useColumns/index.js +0 -25
- package/es/hooks/utils.d.ts +0 -18
- package/es/styles.scss +0 -30
- package/es/type.d.ts +0 -88
- package/lib/ColumnsChoose.d.ts +0 -10
- package/lib/GridTable.d.ts +0 -7
- package/lib/GridTable.js +0 -936
- package/lib/hooks/useColumns/index.d.ts +0 -2
- package/lib/hooks/useColumns/index.js +0 -31
- package/lib/hooks/utils.d.ts +0 -18
- package/lib/styles.scss +0 -30
- package/lib/type.d.ts +0 -88
- /package/es/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
- /package/es/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
- /package/es/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
- /package/es/{hooks → grid-component/hooks}/index.d.ts +0 -0
- /package/es/{hooks → grid-component/hooks}/index.js +0 -0
- /package/es/{hooks → grid-component/hooks}/useIsOverflow.d.ts +0 -0
- /package/es/{hooks → grid-component/hooks}/useIsOverflow.js +0 -0
- /package/es/{hooks → grid-component/hooks}/useOnClickOutside.d.ts +0 -0
- /package/es/{hooks → grid-component/hooks}/useOnClickOutside.js +0 -0
- /package/es/{type.js → grid-component/type.js} +0 -0
- /package/lib/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
- /package/lib/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
- /package/lib/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
- /package/lib/{hooks → grid-component/hooks}/index.d.ts +0 -0
- /package/lib/{hooks → grid-component/hooks}/index.js +0 -0
- /package/lib/{hooks → grid-component/hooks}/useIsOverflow.d.ts +0 -0
- /package/lib/{hooks → grid-component/hooks}/useIsOverflow.js +0 -0
- /package/lib/{hooks → grid-component/hooks}/useOnClickOutside.d.ts +0 -0
- /package/lib/{hooks → grid-component/hooks}/useOnClickOutside.js +0 -0
- /package/lib/{type.js → grid-component/type.js} +0 -0
|
@@ -4,10 +4,20 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getDatepickerFormat = exports.getAllVisibleKeys = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.checkThousandSeparator = exports.checkDecimalSeparator = void 0;
|
|
7
|
+
exports.getEditType = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = exports.getAllVisibleKeys = exports.customWeekStartEndFormat = exports.convertLabelToTitle = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.convertArrayWithIndent = exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = void 0;
|
|
8
8
|
exports.getHiddenParentKeys = getHiddenParentKeys;
|
|
9
|
-
exports.updateColumns = exports.sumDataByField = exports.isNullOrUndefined = exports.isNameColor = exports.isEmpty = exports.isColor = exports.getVisibleColumnKeys = exports.getTypeFilter = void 0;
|
|
9
|
+
exports.updateData = exports.updateColumns = exports.updateArrayByKey = exports.totalFixedWidth = exports.sumDataByField = exports.newGuid = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.isEmpty = exports.isDisable = exports.isColor = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = void 0;
|
|
10
10
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
11
|
+
var _moment = _interopRequireDefault(require("moment/moment"));
|
|
12
|
+
var _uuid = require("uuid");
|
|
13
|
+
const newGuid = () => {
|
|
14
|
+
for (let i = 0; i < 20; i++) {
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
// const id = crypto.randomUUID()
|
|
17
|
+
return (0, _uuid.v4)();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.newGuid = newGuid;
|
|
11
21
|
const sumDataByField = (data, field) => {
|
|
12
22
|
if (data && data.length > 0) {
|
|
13
23
|
return data.reduce((accumulator, currentValue) => {
|
|
@@ -55,17 +65,11 @@ const checkDecimalSeparator = (thousandSeparator, decimalSeparator) => {
|
|
|
55
65
|
};
|
|
56
66
|
exports.checkDecimalSeparator = checkDecimalSeparator;
|
|
57
67
|
const isEmpty = d => {
|
|
58
|
-
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
return false;
|
|
68
|
+
return d === null || d === undefined || d === '';
|
|
62
69
|
};
|
|
63
70
|
exports.isEmpty = isEmpty;
|
|
64
71
|
const isNullOrUndefined = d => {
|
|
65
|
-
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
return false;
|
|
72
|
+
return d === null || d === undefined;
|
|
69
73
|
};
|
|
70
74
|
exports.isNullOrUndefined = isNullOrUndefined;
|
|
71
75
|
const convertDayjsToDate = (dateString, format) => {
|
|
@@ -120,8 +124,7 @@ exports.getAllVisibleKeys = getAllVisibleKeys;
|
|
|
120
124
|
const getVisibleColumnKeys = columns => {
|
|
121
125
|
const allKeys = getAllVisibleKeys(columns);
|
|
122
126
|
const allParentKeys = getHiddenParentKeys(columns);
|
|
123
|
-
|
|
124
|
-
return rs;
|
|
127
|
+
return allKeys.filter(item => !allParentKeys.includes(item));
|
|
125
128
|
};
|
|
126
129
|
exports.getVisibleColumnKeys = getVisibleColumnKeys;
|
|
127
130
|
function getHiddenParentKeys(columns, parentKeys = []) {
|
|
@@ -146,15 +149,14 @@ const updateColumns = (columns, includes) => {
|
|
|
146
149
|
...column
|
|
147
150
|
};
|
|
148
151
|
let hasVisibleChild = false;
|
|
152
|
+
if (!column.key && !column.dataIndex) {
|
|
153
|
+
return column;
|
|
154
|
+
}
|
|
149
155
|
if (newColumn.children) {
|
|
150
156
|
newColumn.children = updateColumns(newColumn.children, includes);
|
|
151
157
|
hasVisibleChild = newColumn.children.some(child => !child.hidden);
|
|
152
158
|
}
|
|
153
|
-
|
|
154
|
-
newColumn.hidden = true;
|
|
155
|
-
} else {
|
|
156
|
-
newColumn.hidden = false;
|
|
157
|
-
}
|
|
159
|
+
newColumn.hidden = newColumn.key && !includes.includes(newColumn.key);
|
|
158
160
|
if (newColumn.children && newColumn.children.length > 0) {
|
|
159
161
|
newColumn.hidden = !hasVisibleChild;
|
|
160
162
|
}
|
|
@@ -181,15 +183,19 @@ const getDatepickerFormat = (type, col) => {
|
|
|
181
183
|
case "time":
|
|
182
184
|
return col.format?.timeFormat ? col.format?.timeFormat : 'HH:mm';
|
|
183
185
|
default:
|
|
184
|
-
return
|
|
186
|
+
return 'DD/MM/YYYY';
|
|
185
187
|
}
|
|
186
188
|
};
|
|
187
189
|
exports.getDatepickerFormat = getDatepickerFormat;
|
|
190
|
+
const customWeekStartEndFormat = (value, weekFormat) => {
|
|
191
|
+
return `${(0, _dayjs.default)(value).startOf('week').format(weekFormat)} ~ ${(0, _dayjs.default)(value).endOf('week').format(weekFormat)}`;
|
|
192
|
+
};
|
|
193
|
+
exports.customWeekStartEndFormat = customWeekStartEndFormat;
|
|
188
194
|
const getTypeFilter = col => {
|
|
189
|
-
if (col
|
|
195
|
+
if (col?.typeFilter) {
|
|
190
196
|
return col.typeFilter;
|
|
191
197
|
}
|
|
192
|
-
const type = col
|
|
198
|
+
const type = col?.type ?? 'Text';
|
|
193
199
|
switch (type) {
|
|
194
200
|
case "number":
|
|
195
201
|
return 'Number';
|
|
@@ -203,7 +209,7 @@ const getTypeFilter = col => {
|
|
|
203
209
|
return 'Checkbox';
|
|
204
210
|
|
|
205
211
|
// case "week": return ''
|
|
206
|
-
// case "month": return
|
|
212
|
+
// case "month": return 'Month'
|
|
207
213
|
// case "quarter": return col.format?.dateFormat ? col.format?.dateFormat : 'DD/MM/YYYY'
|
|
208
214
|
// case "year": return col.format?.yearFormat ? col.format?.yearFormat : 'YYYY'
|
|
209
215
|
// case "time": return col.format?.timeFormat ? col.format?.timeFormat : 'HH:mm'
|
|
@@ -212,4 +218,140 @@ const getTypeFilter = col => {
|
|
|
212
218
|
return 'Text';
|
|
213
219
|
}
|
|
214
220
|
};
|
|
215
|
-
exports.getTypeFilter = getTypeFilter;
|
|
221
|
+
exports.getTypeFilter = getTypeFilter;
|
|
222
|
+
const updateArrayByKey = (arr, element, key) => {
|
|
223
|
+
if (arr) {
|
|
224
|
+
return arr.map(item => {
|
|
225
|
+
if (item[key] === element[key]) {
|
|
226
|
+
return {
|
|
227
|
+
...item,
|
|
228
|
+
...element
|
|
229
|
+
};
|
|
230
|
+
} else if (item.children && item.children.length > 0) {
|
|
231
|
+
item.children = updateArrayByKey(item.children, element, key);
|
|
232
|
+
}
|
|
233
|
+
return item;
|
|
234
|
+
});
|
|
235
|
+
} else {
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
exports.updateArrayByKey = updateArrayByKey;
|
|
240
|
+
const getDateString = (column, value) => {
|
|
241
|
+
if (value instanceof Date) {
|
|
242
|
+
return (0, _moment.default)(value).format();
|
|
243
|
+
}
|
|
244
|
+
return value;
|
|
245
|
+
};
|
|
246
|
+
exports.getDateString = getDateString;
|
|
247
|
+
const getEditType = (column, rowData) => {
|
|
248
|
+
if (column && typeof column.editType === 'function') {
|
|
249
|
+
return column.editType(rowData);
|
|
250
|
+
}
|
|
251
|
+
return column.editType;
|
|
252
|
+
};
|
|
253
|
+
exports.getEditType = getEditType;
|
|
254
|
+
const isDisable = (column, rowData) => {
|
|
255
|
+
if (column && typeof column?.disable === 'function') {
|
|
256
|
+
return column.disable(rowData);
|
|
257
|
+
}
|
|
258
|
+
return !!column?.disable;
|
|
259
|
+
};
|
|
260
|
+
exports.isDisable = isDisable;
|
|
261
|
+
const checkFieldKey = key => {
|
|
262
|
+
if (key) {
|
|
263
|
+
return key;
|
|
264
|
+
} else {
|
|
265
|
+
return 'value';
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
exports.checkFieldKey = checkFieldKey;
|
|
269
|
+
const convertLabelToTitle = data => {
|
|
270
|
+
return data.map(item => {
|
|
271
|
+
const {
|
|
272
|
+
label,
|
|
273
|
+
title,
|
|
274
|
+
value,
|
|
275
|
+
...rest
|
|
276
|
+
} = item;
|
|
277
|
+
const newItem = {
|
|
278
|
+
...rest,
|
|
279
|
+
value,
|
|
280
|
+
key: value,
|
|
281
|
+
title: title ? title : label
|
|
282
|
+
};
|
|
283
|
+
if (item.children) {
|
|
284
|
+
newItem.children = convertLabelToTitle(item.children);
|
|
285
|
+
}
|
|
286
|
+
return newItem;
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
exports.convertLabelToTitle = convertLabelToTitle;
|
|
290
|
+
const convertArrayWithIndent = (inputArray, parentIndent = 0) => {
|
|
291
|
+
if (inputArray) {
|
|
292
|
+
return inputArray.map(item => {
|
|
293
|
+
const indent = parentIndent;
|
|
294
|
+
if (item.children && item.children.length > 0) {
|
|
295
|
+
item.children = convertArrayWithIndent(item.children, indent + 1);
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
...item,
|
|
299
|
+
indent,
|
|
300
|
+
rowId: item.rowId ? item.rowId : item.id ? item.id : newGuid()
|
|
301
|
+
};
|
|
302
|
+
});
|
|
303
|
+
} else {
|
|
304
|
+
return [];
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
exports.convertArrayWithIndent = convertArrayWithIndent;
|
|
308
|
+
const getTemplate = template => {
|
|
309
|
+
if (template && typeof template === 'function') {
|
|
310
|
+
return template();
|
|
311
|
+
}
|
|
312
|
+
return template;
|
|
313
|
+
};
|
|
314
|
+
exports.getTemplate = getTemplate;
|
|
315
|
+
const totalFixedWidth = (columns, type, selectionSettings) => {
|
|
316
|
+
const totalFixedLeftWidth = columns.filter(column => column.fixed === type) // Lọc các cột có fixed
|
|
317
|
+
.reduce((sum, column) => {
|
|
318
|
+
const width = typeof column.width === 'number' ? column.width : parseInt(column.width, 10) || 0; // Chuyển từ chuỗi sang số, nếu không hợp lệ thì lấy 0
|
|
319
|
+
return sum + width;
|
|
320
|
+
}, 0);
|
|
321
|
+
const selectColumnWidth = !selectionSettings?.mode ? 0.0000001 : typeof selectionSettings?.columnWidth === 'number' ? selectionSettings?.columnWidth : parseInt(selectionSettings?.columnWidth, 10) || 50;
|
|
322
|
+
return totalFixedLeftWidth + selectColumnWidth;
|
|
323
|
+
};
|
|
324
|
+
exports.totalFixedWidth = totalFixedWidth;
|
|
325
|
+
const isObjEmpty = obj => {
|
|
326
|
+
if (isNullOrUndefined(obj)) {
|
|
327
|
+
return true;
|
|
328
|
+
} else {
|
|
329
|
+
return Object.keys(obj).length === 0;
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
exports.isObjEmpty = isObjEmpty;
|
|
333
|
+
const getColumnsVisible = (columns, index) => {
|
|
334
|
+
const itemsBeforeIndex = columns.slice(0, index);
|
|
335
|
+
const itemsAfterIndex = columns.slice(index);
|
|
336
|
+
itemsAfterIndex.map(it => {
|
|
337
|
+
if (it.hidden !== false) {
|
|
338
|
+
itemsBeforeIndex.push(it);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
return itemsBeforeIndex;
|
|
342
|
+
};
|
|
343
|
+
exports.getColumnsVisible = getColumnsVisible;
|
|
344
|
+
const updateData = (initData, rows, key) => {
|
|
345
|
+
const updatedData = initData.map(item => {
|
|
346
|
+
const newData = rows.find(row => row[key] === item[key]);
|
|
347
|
+
return newData ? {
|
|
348
|
+
...item,
|
|
349
|
+
...newData
|
|
350
|
+
} : item;
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// Thêm các phần tử mới chưa có trong initialData
|
|
354
|
+
const newRows = rows.filter(row => !initData.some(item => item[key] === row[key]));
|
|
355
|
+
return [...updatedData, ...newRows];
|
|
356
|
+
};
|
|
357
|
+
exports.updateData = updateData;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _InternalTable = _interopRequireDefault(require("./InternalTable"));
|
|
9
|
+
var _default = exports.default = _InternalTable.default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { GridTableProps } from "../type";
|
|
3
|
+
type Props<T> = GridTableProps<T> & {
|
|
4
|
+
setColumns?: any;
|
|
5
|
+
tableRef: any;
|
|
6
|
+
};
|
|
7
|
+
declare const Grid: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
8
|
+
export default Grid;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _GridStyle = require("../GridStyle");
|
|
11
|
+
var _TableGrid = _interopRequireDefault(require("../TableGrid"));
|
|
12
|
+
var _EditableCell = _interopRequireDefault(require("../EditableCell"));
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
const Grid = props => {
|
|
16
|
+
const {
|
|
17
|
+
columns,
|
|
18
|
+
height,
|
|
19
|
+
tableRef,
|
|
20
|
+
className,
|
|
21
|
+
components,
|
|
22
|
+
...rest
|
|
23
|
+
} = props;
|
|
24
|
+
|
|
25
|
+
// const transformColumns = React.useCallback((cols: ColumnsTable<RecordType>): ColumnsTable<RecordType> => {
|
|
26
|
+
// return cols.map((column) => {
|
|
27
|
+
//
|
|
28
|
+
// if (column?.children && column?.children.length > 0) {
|
|
29
|
+
// return {
|
|
30
|
+
// ...column,
|
|
31
|
+
// children: transformColumns(column?.children) // Xử lý đệ quy cho cấp con
|
|
32
|
+
// }
|
|
33
|
+
// }
|
|
34
|
+
//
|
|
35
|
+
// if (column.dataIndex === 'index' || column.field === 'index' || column.dataIndex === '#' || column.dataIndex === '#') {
|
|
36
|
+
// return {
|
|
37
|
+
// ...column,
|
|
38
|
+
// render: (value: any, record: any, rowIndex: number) => {
|
|
39
|
+
// return rowIndex + 1
|
|
40
|
+
// }
|
|
41
|
+
// }
|
|
42
|
+
// }
|
|
43
|
+
//
|
|
44
|
+
// return {
|
|
45
|
+
// ...column,
|
|
46
|
+
// }
|
|
47
|
+
// })
|
|
48
|
+
// }, [])
|
|
49
|
+
//
|
|
50
|
+
//
|
|
51
|
+
// const mergedColumns = useMemo(() => {
|
|
52
|
+
//
|
|
53
|
+
// // @ts-ignore
|
|
54
|
+
// return transformColumns(columns ?? [])
|
|
55
|
+
//
|
|
56
|
+
// }, [transformColumns, columns])
|
|
57
|
+
|
|
58
|
+
const addFilter = _react.default.useCallback(cols => {
|
|
59
|
+
return cols.map(column => {
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
if (!column?.dataIndex && !column?.key) {
|
|
62
|
+
return column;
|
|
63
|
+
}
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
if (column?.children && column?.children.length > 0) {
|
|
66
|
+
return {
|
|
67
|
+
...column,
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
children: addFilter(column?.children) // Xử lý đệ quy cho cấp con
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
if (column.dataIndex === 'index' || column.field === 'index' || column.dataIndex === '#' || column.dataIndex === '#') {
|
|
74
|
+
return {
|
|
75
|
+
...column,
|
|
76
|
+
render: (value, record, rowIndex) => {
|
|
77
|
+
return rowIndex + 1;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
...column
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}, []);
|
|
86
|
+
const tmpColumns = (0, _react.useMemo)(() => {
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
return addFilter(columns ?? []);
|
|
89
|
+
}, [addFilter, columns]);
|
|
90
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_GridStyle.GridStyle, {
|
|
91
|
+
heightTable: height,
|
|
92
|
+
style: {
|
|
93
|
+
position: 'relative'
|
|
94
|
+
}
|
|
95
|
+
}, /*#__PURE__*/_react.default.createElement(_TableGrid.default, (0, _extends2.default)({}, rest, {
|
|
96
|
+
tableRef: tableRef,
|
|
97
|
+
components: {
|
|
98
|
+
...components,
|
|
99
|
+
body: {
|
|
100
|
+
cell: _EditableCell.default
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// columns={mergedColumns}
|
|
104
|
+
,
|
|
105
|
+
columns: tmpColumns
|
|
106
|
+
}))));
|
|
107
|
+
};
|
|
108
|
+
var _default = exports.default = Grid;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import 'dayjs/locale/es';
|
|
3
|
+
import 'dayjs/locale/vi';
|
|
4
|
+
import type { TableEditProps } from "../type";
|
|
5
|
+
type Props<RecordType> = TableEditProps<RecordType> & {
|
|
6
|
+
tableRef: any;
|
|
7
|
+
};
|
|
8
|
+
declare const GridEdit: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
9
|
+
export default GridEdit;
|