es-grid-template 1.9.60 → 1.9.62
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/ali-table/InternalTable.d.ts +2 -1
- package/es/ali-table/InternalTable.js +23 -43
- package/es/ali-table/base-table/table.d.ts +2 -2
- package/es/ali-table/base-table/utils.d.ts +2 -0
- package/es/ali-table/base-table/utils.js +12 -1
- package/es/ali-table/interfaces.d.ts +4 -0
- package/es/ali-table/internals.d.ts +2 -1
- package/es/ali-table/pipeline/features/columnCustom.d.ts +1 -0
- package/es/ali-table/pipeline/features/columnCustom.js +297 -17
- package/es/grid-component/type.d.ts +2 -1
- package/es/group-component/body/EditableCell.d.ts +3 -0
- package/es/group-component/body/EditableCell.js +402 -196
- package/es/table-component/body/EditableCell.js +1 -1
- package/es/table-component/components/async-select/index.js +1 -1
- package/es/table-component/hook/utils.d.ts +1 -3
- package/lib/ali-table/InternalTable.d.ts +2 -1
- package/lib/ali-table/InternalTable.js +23 -43
- package/lib/ali-table/base-table/table.d.ts +2 -2
- package/lib/ali-table/base-table/utils.d.ts +2 -0
- package/lib/ali-table/base-table/utils.js +13 -0
- package/lib/ali-table/interfaces.d.ts +4 -0
- package/lib/ali-table/internals.d.ts +2 -1
- package/lib/ali-table/pipeline/features/columnCustom.d.ts +1 -0
- package/lib/ali-table/pipeline/features/columnCustom.js +297 -17
- package/lib/grid-component/type.d.ts +2 -1
- package/lib/group-component/body/EditableCell.d.ts +3 -0
- package/lib/group-component/body/EditableCell.js +399 -194
- package/lib/table-component/body/EditableCell.js +1 -1
- package/lib/table-component/components/async-select/index.js +1 -1
- package/lib/table-component/hook/utils.d.ts +1 -3
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _rcMasterUi = require("rc-master-ui");
|
|
11
|
-
var _utils = require("
|
|
11
|
+
var _utils = require("../../table-component/hook/utils");
|
|
12
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
13
|
var _reactNumericComponent = require("react-numeric-component");
|
|
14
14
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
@@ -20,8 +20,11 @@ var _colors = require("@ant-design/colors");
|
|
|
20
20
|
var _EditForm = require("../components/EditForm");
|
|
21
21
|
var _useContext = require("../useContext");
|
|
22
22
|
var _locale = require("rc-master-ui/es/locale");
|
|
23
|
+
var _hooks = require("../../grid-component/hooks");
|
|
23
24
|
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); }
|
|
24
25
|
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; }
|
|
26
|
+
// import type { EditType } from "rc-master-ui"
|
|
27
|
+
|
|
25
28
|
const {
|
|
26
29
|
SHOW_PARENT
|
|
27
30
|
} = _rcMasterUi.TreeSelect;
|
|
@@ -49,7 +52,9 @@ const EditableCell = props => {
|
|
|
49
52
|
// children,
|
|
50
53
|
column,
|
|
51
54
|
indexRow,
|
|
52
|
-
indexCol
|
|
55
|
+
indexCol,
|
|
56
|
+
// visibleColumns,
|
|
57
|
+
handleNextCell
|
|
53
58
|
// cellEditing,
|
|
54
59
|
// ...restProps
|
|
55
60
|
} = props;
|
|
@@ -67,8 +72,7 @@ const EditableCell = props => {
|
|
|
67
72
|
} = (0, _react.useContext)(_useContext.TableContext);
|
|
68
73
|
const datePickerRef = _react.default.useRef(null);
|
|
69
74
|
const dateTimePickerRef = _react.default.useRef(null);
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
const timePickerRef = _react.default.useRef(null);
|
|
72
76
|
const colFormat = typeof column?.format === 'function' ? column?.format(record) : column?.format;
|
|
73
77
|
const cellFormat = (0, _utils.getFormat)(colFormat, format);
|
|
74
78
|
const inputNode = (value, onChange) => {
|
|
@@ -76,6 +80,7 @@ const EditableCell = props => {
|
|
|
76
80
|
const date = !(0, _utils.isEmpty)(value) ? (0, _utils.convertDateToDayjs)(new Date(value), dateFormat) : null;
|
|
77
81
|
const maxDate = (0, _utils.convertDateToDayjs)(column.maxDate, dateFormat) ?? undefined;
|
|
78
82
|
const minDate = (0, _utils.convertDateToDayjs)(column.minDate, dateFormat) ?? undefined;
|
|
83
|
+
const formValues = getValues();
|
|
79
84
|
const {
|
|
80
85
|
fieldValue,
|
|
81
86
|
columns: selectColumns,
|
|
@@ -85,8 +90,9 @@ const EditableCell = props => {
|
|
|
85
90
|
fieldNames,
|
|
86
91
|
toolbarItems,
|
|
87
92
|
filterOption,
|
|
93
|
+
filterKey,
|
|
88
94
|
inputKey,
|
|
89
|
-
|
|
95
|
+
toolbarClick,
|
|
90
96
|
loadOptions,
|
|
91
97
|
validateOption,
|
|
92
98
|
options: propsOptions
|
|
@@ -104,7 +110,24 @@ const EditableCell = props => {
|
|
|
104
110
|
const options = validateOption ? validateOption(record, column.field) : selectOptions ?? [];
|
|
105
111
|
const optionsTree = validateOption ? (0, _utils.convertArrayWithIndent)(validateOption(record, column.field)) : selectOptions ? (0, _utils.convertArrayWithIndent)(selectOptions) : [];
|
|
106
112
|
|
|
107
|
-
// const
|
|
113
|
+
// const focusToken = (token: FormatToken, fmt: string) => {
|
|
114
|
+
// const input: HTMLInputElement | null =
|
|
115
|
+
// timePickerRef.current?.nativeElement?.querySelector('input') ??
|
|
116
|
+
// timePickerRef.current?.input;
|
|
117
|
+
|
|
118
|
+
// if (!input) return;
|
|
119
|
+
|
|
120
|
+
// const start = fmt.indexOf(token);
|
|
121
|
+
// if (start === -1) return;
|
|
122
|
+
|
|
123
|
+
// input.focus();
|
|
124
|
+
|
|
125
|
+
// input.setSelectionRange(start, start + token.length - 1);
|
|
126
|
+
|
|
127
|
+
// requestAnimationFrame(() => {
|
|
128
|
+
// input.setSelectionRange(start, start + token.length);
|
|
129
|
+
// });
|
|
130
|
+
// };
|
|
108
131
|
|
|
109
132
|
switch (editType) {
|
|
110
133
|
case 'date':
|
|
@@ -115,10 +138,7 @@ const EditableCell = props => {
|
|
|
115
138
|
type: 'mask'
|
|
116
139
|
},
|
|
117
140
|
autoFocus: column.field === startCell?.colId,
|
|
118
|
-
defaultOpen: column.field === startCell?.colId
|
|
119
|
-
|
|
120
|
-
// locale={buddhistLocale}
|
|
121
|
-
,
|
|
141
|
+
defaultOpen: column.field === startCell?.colId,
|
|
122
142
|
style: {
|
|
123
143
|
width: '100%',
|
|
124
144
|
height: '100%'
|
|
@@ -172,9 +192,7 @@ const EditableCell = props => {
|
|
|
172
192
|
format: {
|
|
173
193
|
format: dateFormat,
|
|
174
194
|
type: 'mask'
|
|
175
|
-
}
|
|
176
|
-
// locale={buddhistLocale}
|
|
177
|
-
,
|
|
195
|
+
},
|
|
178
196
|
style: {
|
|
179
197
|
width: '100%',
|
|
180
198
|
height: '100%'
|
|
@@ -186,8 +204,20 @@ const EditableCell = props => {
|
|
|
186
204
|
placeholder: t && column.placeholder ? t(column.placeholder) : undefined,
|
|
187
205
|
disabled: (0, _utils.isDisable)(column, record) ?? false,
|
|
188
206
|
maxDate: maxDate,
|
|
189
|
-
minDate: minDate
|
|
190
|
-
|
|
207
|
+
minDate: minDate
|
|
208
|
+
// mode="date"
|
|
209
|
+
,
|
|
210
|
+
|
|
211
|
+
popupClassName: 'be-popup-container',
|
|
212
|
+
status: isInvalid ? 'error' : undefined,
|
|
213
|
+
"data-tooltip-content": message,
|
|
214
|
+
"data-tooltip-id": `${id}-tooltip-error`,
|
|
215
|
+
autoFocus: column.field === startCell?.colId,
|
|
216
|
+
defaultOpen: column.field === startCell?.colId
|
|
217
|
+
// needConfirm={true}
|
|
218
|
+
,
|
|
219
|
+
|
|
220
|
+
onCalendarChange: (newDate, dateString) => {
|
|
191
221
|
const newDateValue = dateString ? (0, _moment.default)((0, _utils.convertDayjsToDate)(dateString, dateFormat)).format() : null;
|
|
192
222
|
onChange(newDateValue);
|
|
193
223
|
setTimeout(() => {
|
|
@@ -195,32 +225,28 @@ const EditableCell = props => {
|
|
|
195
225
|
dateTimePickerRef.current?.focus();
|
|
196
226
|
}, 0);
|
|
197
227
|
},
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
228
|
+
onOpenChange: open => {
|
|
229
|
+
if (!open) {
|
|
230
|
+
const formState = getValues();
|
|
231
|
+
const itemState = getValues(dataIndex);
|
|
232
|
+
// @ts-ignore
|
|
233
|
+
const prevState = record[dataIndex];
|
|
234
|
+
const newState = itemState;
|
|
235
|
+
if (prevState !== newState) {
|
|
236
|
+
handleCellChange?.({
|
|
237
|
+
key: key,
|
|
238
|
+
field: column.field ?? column.field,
|
|
239
|
+
record: formState,
|
|
240
|
+
prevState,
|
|
241
|
+
newState,
|
|
242
|
+
option: newState,
|
|
243
|
+
indexCol,
|
|
244
|
+
indexRow,
|
|
245
|
+
type: 'blur'
|
|
246
|
+
});
|
|
247
|
+
}
|
|
216
248
|
}
|
|
217
|
-
}
|
|
218
|
-
popupClassName: 'be-popup-container',
|
|
219
|
-
status: isInvalid ? 'error' : undefined,
|
|
220
|
-
"data-tooltip-content": message,
|
|
221
|
-
"data-tooltip-id": `${id}-tooltip-error`,
|
|
222
|
-
autoFocus: column.field === startCell?.colId,
|
|
223
|
-
defaultOpen: column.field === startCell?.colId
|
|
249
|
+
}
|
|
224
250
|
});
|
|
225
251
|
case 'month':
|
|
226
252
|
case 'quarter':
|
|
@@ -274,7 +300,17 @@ const EditableCell = props => {
|
|
|
274
300
|
});
|
|
275
301
|
case 'time':
|
|
276
302
|
const timeFormat = (0, _utils.getDatepickerFormat)(editType, cellFormat);
|
|
277
|
-
|
|
303
|
+
|
|
304
|
+
// chỉ nhận giá trị dạng HH:mm | mm:HH => convert
|
|
305
|
+
|
|
306
|
+
let time = value ?? undefined;
|
|
307
|
+
const typeTime = (0, _utils.getDateValueType)(value);
|
|
308
|
+
if (typeTime === 'time') {
|
|
309
|
+
time = value ? (0, _dayjs.default)(value, timeFormat) : undefined;
|
|
310
|
+
} else {
|
|
311
|
+
const abc = value ? (0, _moment.default)(value).format(timeFormat) : undefined;
|
|
312
|
+
time = abc ? (0, _dayjs.default)(abc, timeFormat) : undefined;
|
|
313
|
+
}
|
|
278
314
|
const maxTimeValue = !(0, _utils.isEmpty)(column.maxTime) ? (0, _dayjs.default)(column.maxTime).format(timeFormat) : null;
|
|
279
315
|
const minTimeValue = !(0, _utils.isEmpty)(column.minTime) ? (0, _dayjs.default)(column.minTime).format(timeFormat) : null;
|
|
280
316
|
|
|
@@ -283,6 +319,7 @@ const EditableCell = props => {
|
|
|
283
319
|
const maxTime = maxTimeValue ? (0, _dayjs.default)(maxTimeValue, timeFormat) : undefined;
|
|
284
320
|
const minTime = minTimeValue ? (0, _dayjs.default)(minTimeValue, timeFormat) : undefined;
|
|
285
321
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.TimePicker, {
|
|
322
|
+
ref: timePickerRef,
|
|
286
323
|
format: {
|
|
287
324
|
format: timeFormat,
|
|
288
325
|
type: 'mask'
|
|
@@ -303,33 +340,119 @@ const EditableCell = props => {
|
|
|
303
340
|
"data-tooltip-content": message,
|
|
304
341
|
"data-tooltip-id": `${id}-tooltip-error`,
|
|
305
342
|
autoFocus: column.field === startCell?.colId,
|
|
306
|
-
defaultOpen: column.field === startCell?.colId
|
|
307
|
-
|
|
343
|
+
defaultOpen: column.field === startCell?.colId
|
|
344
|
+
|
|
345
|
+
// onChange={(newDate, dateString) => {
|
|
346
|
+
|
|
347
|
+
// if (typeTime === 'time') {
|
|
348
|
+
|
|
349
|
+
// onChange(dateString)
|
|
350
|
+
|
|
351
|
+
// } else {
|
|
352
|
+
|
|
353
|
+
// // const datetime = dayjs(dateString as string, timeFormat, true);
|
|
354
|
+
|
|
355
|
+
// const newVal = newDate ? moment(newDate.toDate()).format() : undefined
|
|
356
|
+
|
|
357
|
+
// // const newVal = datetime.isValid() ? moment(datetime.toDate()).format() : ''
|
|
358
|
+
// onChange(newVal)
|
|
359
|
+
|
|
360
|
+
// }
|
|
361
|
+
|
|
362
|
+
// setTimeout(() => {
|
|
363
|
+
// // @ts-ignore
|
|
364
|
+
// dateTimePickerRef.current?.focus()
|
|
365
|
+
// }, 0)
|
|
366
|
+
|
|
367
|
+
// }}
|
|
368
|
+
|
|
369
|
+
// onBlur={() => {
|
|
370
|
+
// const formState = getValues()
|
|
371
|
+
// const itemState = getValues(dataIndex)
|
|
372
|
+
// // @ts-ignore
|
|
373
|
+
// const prevState = record[dataIndex]
|
|
374
|
+
// const newState = itemState
|
|
375
|
+
|
|
376
|
+
// let newValue = newState
|
|
377
|
+
|
|
378
|
+
// if (typeTime === 'time') {
|
|
379
|
+
|
|
380
|
+
// newValue = newState
|
|
381
|
+
|
|
382
|
+
// } else {
|
|
383
|
+
|
|
384
|
+
// const datetime = dayjs(newState as string, timeFormat, true);
|
|
385
|
+
|
|
386
|
+
// const newVal = datetime.isValid() ? moment(datetime.toDate()).format() : undefined
|
|
387
|
+
// onChange(newVal)
|
|
388
|
+
|
|
389
|
+
// newValue = newVal
|
|
390
|
+
|
|
391
|
+
// }
|
|
392
|
+
|
|
393
|
+
// if (prevState !== newState) {
|
|
394
|
+
// handleCellChange?.({
|
|
395
|
+
// key: key as any,
|
|
396
|
+
// field: column.field ?? column.field as any,
|
|
397
|
+
// record: formState,
|
|
398
|
+
// prevState,
|
|
399
|
+
// newState: newValue,
|
|
400
|
+
// option: newValue,
|
|
401
|
+
// indexCol,
|
|
402
|
+
// indexRow,
|
|
403
|
+
// type: 'blur'
|
|
404
|
+
// })
|
|
405
|
+
// }
|
|
406
|
+
// }}
|
|
407
|
+
|
|
408
|
+
// needConfirm={false}
|
|
409
|
+
,
|
|
410
|
+
|
|
411
|
+
onCalendarChange: (newDate, dateString) => {
|
|
308
412
|
// const newDateValue = dateString ? moment(convertDayjsToDate(dateString as string, dateFormat)).format() : null
|
|
309
|
-
|
|
413
|
+
|
|
414
|
+
// onChange(newDateValue)
|
|
415
|
+
|
|
416
|
+
if (typeTime === 'time') {
|
|
417
|
+
onChange(dateString);
|
|
418
|
+
} else {
|
|
419
|
+
// const datetime = dayjs(dateString as string, timeFormat, true);
|
|
420
|
+
|
|
421
|
+
const newVal = newDate ? (0, _moment.default)(newDate.toDate()).format() : undefined;
|
|
422
|
+
|
|
423
|
+
// const newVal = datetime.isValid() ? moment(datetime.toDate()).format() : ''
|
|
424
|
+
onChange(newVal);
|
|
425
|
+
}
|
|
310
426
|
setTimeout(() => {
|
|
311
427
|
// @ts-ignore
|
|
312
|
-
|
|
313
|
-
}
|
|
428
|
+
timePickerRef.current?.focus();
|
|
429
|
+
});
|
|
314
430
|
},
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
431
|
+
onOpenChange: open => {
|
|
432
|
+
if (!open) {
|
|
433
|
+
const formState = getValues();
|
|
434
|
+
const itemState = getValues(dataIndex);
|
|
435
|
+
// @ts-ignore
|
|
436
|
+
const prevState = record[dataIndex];
|
|
437
|
+
const newState = itemState;
|
|
438
|
+
if (prevState !== newState) {
|
|
439
|
+
handleCellChange?.({
|
|
440
|
+
key: key,
|
|
441
|
+
field: column.field ?? column.field,
|
|
442
|
+
record: formState,
|
|
443
|
+
prevState,
|
|
444
|
+
newState,
|
|
445
|
+
option: newState,
|
|
446
|
+
indexCol,
|
|
447
|
+
indexRow,
|
|
448
|
+
type: 'blur'
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
onKeyDown: e => {
|
|
454
|
+
if (e?.code === "Tab") {
|
|
455
|
+
handleNextCell?.();
|
|
333
456
|
}
|
|
334
457
|
}
|
|
335
458
|
});
|
|
@@ -353,37 +476,31 @@ const EditableCell = props => {
|
|
|
353
476
|
align: colSelect.textAlign
|
|
354
477
|
};
|
|
355
478
|
});
|
|
356
|
-
let valueSelectTable =
|
|
479
|
+
let valueSelectTable = formValues[dataIndex];
|
|
357
480
|
if (fieldValue) {
|
|
358
481
|
// @ts-ignore
|
|
359
|
-
valueSelectTable = record[fieldValue] ??
|
|
482
|
+
valueSelectTable = record[fieldValue] ?? formValues[dataIndex];
|
|
360
483
|
}
|
|
361
|
-
|
|
362
|
-
// if (isMulti || selectMode === 'checkbox') {
|
|
363
|
-
// // @ts-ignore
|
|
364
|
-
// valueSelectTable = (!isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0) ? options.filter((val: any) => record[dataIndex]?.includes(val[keySelect])) : undefined
|
|
365
|
-
|
|
366
|
-
// }
|
|
367
|
-
|
|
368
484
|
return /*#__PURE__*/_react.default.createElement(_asyncTableSelect.AsyncTableSelect, {
|
|
369
485
|
columns: columnsTable,
|
|
370
486
|
options: options,
|
|
371
487
|
defaultOptions: options,
|
|
372
488
|
value: valueSelectTable ?? undefined,
|
|
373
|
-
rowData: record,
|
|
374
489
|
autoDestroy: true,
|
|
375
490
|
onChange: (val, option) => {
|
|
376
|
-
onChange(val);
|
|
491
|
+
onChange(val ?? '');
|
|
377
492
|
const formState = getValues();
|
|
378
|
-
|
|
493
|
+
const formNewState = {
|
|
494
|
+
...getValues(),
|
|
495
|
+
[dataIndex]: !(0, _utils.isNullOrUndefined)(formState[dataIndex]) ? formState[dataIndex] : undefined
|
|
496
|
+
};
|
|
379
497
|
// @ts-ignore
|
|
380
|
-
const prevState = record[dataIndex];
|
|
381
|
-
const newState = val;
|
|
498
|
+
const prevState = record[dataIndex] ?? undefined;
|
|
499
|
+
const newState = val ?? undefined;
|
|
382
500
|
handleCellChange?.({
|
|
383
|
-
|
|
384
|
-
key: record[rowKey],
|
|
501
|
+
key,
|
|
385
502
|
field: column.field ?? column.field,
|
|
386
|
-
record:
|
|
503
|
+
record: formNewState,
|
|
387
504
|
prevState,
|
|
388
505
|
newState,
|
|
389
506
|
option: option,
|
|
@@ -413,71 +530,123 @@ const EditableCell = props => {
|
|
|
413
530
|
status: isInvalid ? 'error' : undefined,
|
|
414
531
|
dropdownRender: menu => {
|
|
415
532
|
if (toolbarItems && toolbarItems.length > 0) {
|
|
416
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, menu, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Divider, {
|
|
533
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, menu, toolbarItems && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Divider, {
|
|
417
534
|
style: {
|
|
418
535
|
margin: '8px 0'
|
|
419
536
|
}
|
|
420
537
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
421
538
|
className: 'toolbar-control d-flex justify-content-end'
|
|
422
|
-
}
|
|
539
|
+
}, toolbarItems.map(it => {
|
|
540
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
541
|
+
key: it.key,
|
|
542
|
+
className: 'toolbar-item',
|
|
543
|
+
onClick: () => toolbarClick?.({
|
|
544
|
+
item: it,
|
|
545
|
+
column
|
|
546
|
+
})
|
|
547
|
+
}, it.template ? (0, _hooks.getTemplate)(it.template) : /*#__PURE__*/_react.default.createElement(_rcMasterUi.Button, {
|
|
548
|
+
className: "toolbar-item-btn"
|
|
549
|
+
}, it.icon && (0, _hooks.getTemplate)(it.icon), it.title));
|
|
550
|
+
}))));
|
|
423
551
|
} else {
|
|
424
552
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, " ", menu);
|
|
425
553
|
}
|
|
426
554
|
},
|
|
427
|
-
filterOption:
|
|
555
|
+
filterOption: filterKey ? (input, option) => {
|
|
556
|
+
const searchValue = (0, _utils.removeVietnameseTones)(input.toLowerCase() ?? '');
|
|
557
|
+
const filterValues = filterKey.some(k => {
|
|
558
|
+
const val = option?.[k];
|
|
559
|
+
return (0, _utils.removeVietnameseTones)((val ?? '').toString().toLowerCase()).includes(searchValue);
|
|
560
|
+
});
|
|
561
|
+
return filterValues;
|
|
562
|
+
} : filterOption,
|
|
428
563
|
fieldNames: fieldNames ? fieldNames : {
|
|
429
564
|
value: keySelect,
|
|
430
565
|
label: inputKey ?? 'label'
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// onBlur={(event: any) => {
|
|
569
|
+
|
|
570
|
+
// if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
571
|
+
// const val = event.inputValue
|
|
572
|
+
// onChange(val ?? undefined)
|
|
573
|
+
|
|
574
|
+
// const formState = getValues()
|
|
575
|
+
// // const itemState = getValues(dataIndex)
|
|
576
|
+
// // @ts-ignore
|
|
577
|
+
// const prevState = record[dataIndex]
|
|
578
|
+
// const newState = val
|
|
579
|
+
|
|
580
|
+
// handleCellChange?.({
|
|
581
|
+
// key,
|
|
582
|
+
// field: column.field ?? column.field as any,
|
|
583
|
+
// record: formState,
|
|
584
|
+
// prevState,
|
|
585
|
+
// newState,
|
|
586
|
+
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
587
|
+
// indexCol,
|
|
588
|
+
// indexRow,
|
|
589
|
+
// type: 'blur'
|
|
590
|
+
// })
|
|
591
|
+
// }
|
|
592
|
+
// }}
|
|
593
|
+
|
|
594
|
+
// onKeyDown={(event: any) => {
|
|
595
|
+
|
|
596
|
+
// if (event.key === 'Enter' && event.target?.value && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
597
|
+
|
|
598
|
+
// const val = event.target.value
|
|
599
|
+
// onChange(val)
|
|
600
|
+
|
|
601
|
+
// const formState = getValues()
|
|
602
|
+
// // const itemState = getValues(dataIndex)
|
|
603
|
+
// // @ts-ignore
|
|
604
|
+
// const prevState = record[dataIndex]
|
|
605
|
+
// const newState = val
|
|
606
|
+
|
|
607
|
+
// handleCellChange?.({
|
|
608
|
+
// key,
|
|
609
|
+
// field: column.field ?? column.field as any,
|
|
610
|
+
// record: formState,
|
|
611
|
+
// prevState,
|
|
612
|
+
// newState,
|
|
613
|
+
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
614
|
+
// indexCol,
|
|
615
|
+
// indexRow,
|
|
616
|
+
// type: 'blur'
|
|
617
|
+
// })
|
|
618
|
+
|
|
619
|
+
// }
|
|
620
|
+
|
|
621
|
+
// }}
|
|
622
|
+
,
|
|
623
|
+
|
|
458
624
|
"data-tooltip-content": message,
|
|
459
625
|
"data-tooltip-id": `${id}-tooltip-error`
|
|
460
626
|
});
|
|
461
627
|
case 'select':
|
|
462
|
-
let valueSelect =
|
|
628
|
+
let valueSelect = formValues[dataIndex];
|
|
463
629
|
if (fieldValue) {
|
|
464
630
|
// @ts-ignore
|
|
465
|
-
valueSelect = record[fieldValue] ??
|
|
631
|
+
valueSelect = record[fieldValue] ?? formValues[dataIndex];
|
|
466
632
|
}
|
|
467
633
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, {
|
|
468
634
|
options: options,
|
|
469
|
-
value: valueSelect ??
|
|
635
|
+
value: valueSelect ?? '',
|
|
470
636
|
onChange: (val, option) => {
|
|
471
|
-
onChange(val);
|
|
637
|
+
onChange(val ?? '');
|
|
472
638
|
const formState = getValues();
|
|
473
|
-
|
|
639
|
+
const formNewState = {
|
|
640
|
+
...getValues(),
|
|
641
|
+
[dataIndex]: !(0, _utils.isNullOrUndefined)(formState[dataIndex]) ? formState[dataIndex] : undefined
|
|
642
|
+
};
|
|
474
643
|
// @ts-ignore
|
|
475
|
-
const prevState = record[dataIndex];
|
|
476
|
-
const newState = val;
|
|
644
|
+
const prevState = record[dataIndex] ?? undefined;
|
|
645
|
+
const newState = val ?? undefined;
|
|
477
646
|
handleCellChange?.({
|
|
478
647
|
key,
|
|
479
648
|
field: column.field ?? column.field,
|
|
480
|
-
record:
|
|
649
|
+
record: formNewState,
|
|
481
650
|
prevState,
|
|
482
651
|
newState,
|
|
483
652
|
option: option,
|
|
@@ -486,6 +655,8 @@ const EditableCell = props => {
|
|
|
486
655
|
type: 'blur'
|
|
487
656
|
});
|
|
488
657
|
}
|
|
658
|
+
// destroyOnHidden
|
|
659
|
+
// des
|
|
489
660
|
// autoDestroy={true}
|
|
490
661
|
,
|
|
491
662
|
showSearch: true,
|
|
@@ -504,8 +675,16 @@ const EditableCell = props => {
|
|
|
504
675
|
optionFilterProp: "label",
|
|
505
676
|
popupClassName: 'be-popup-container',
|
|
506
677
|
status: isInvalid ? 'error' : undefined,
|
|
507
|
-
filterOption:
|
|
508
|
-
|
|
678
|
+
filterOption: filterKey ? (input, option) => {
|
|
679
|
+
const searchValue = (0, _utils.removeVietnameseTones)(input.toLowerCase() ?? '');
|
|
680
|
+
const filterValues = filterKey.some(k => {
|
|
681
|
+
const val = option?.[k];
|
|
682
|
+
return (0, _utils.removeVietnameseTones)((val ?? '').toString().toLowerCase()).includes(searchValue);
|
|
683
|
+
});
|
|
684
|
+
return filterValues;
|
|
685
|
+
} : filterOption,
|
|
686
|
+
optionRender: column.editSelectSettings?.formatOptionLabel,
|
|
687
|
+
fieldNames: {
|
|
509
688
|
value: keySelect,
|
|
510
689
|
label: inputKey ?? 'label'
|
|
511
690
|
},
|
|
@@ -535,30 +714,83 @@ const EditableCell = props => {
|
|
|
535
714
|
});
|
|
536
715
|
}
|
|
537
716
|
},
|
|
717
|
+
onKeyDown: event => {
|
|
718
|
+
if (event.key === 'Enter' && event.target?.value && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
719
|
+
const val = event.target.value;
|
|
720
|
+
onChange(val);
|
|
721
|
+
const formState = getValues();
|
|
722
|
+
// const itemState = getValues(dataIndex)
|
|
723
|
+
// @ts-ignore
|
|
724
|
+
const prevState = record[dataIndex];
|
|
725
|
+
const newState = val;
|
|
726
|
+
handleCellChange?.({
|
|
727
|
+
key,
|
|
728
|
+
field: column.field ?? column.field,
|
|
729
|
+
record: formState,
|
|
730
|
+
prevState,
|
|
731
|
+
newState,
|
|
732
|
+
option: {
|
|
733
|
+
value: val,
|
|
734
|
+
label: val,
|
|
735
|
+
searchTextAsValue: true
|
|
736
|
+
},
|
|
737
|
+
indexCol,
|
|
738
|
+
indexRow,
|
|
739
|
+
type: 'blur'
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
},
|
|
743
|
+
dropdownRender: menu => {
|
|
744
|
+
if (toolbarItems && toolbarItems.length > 0) {
|
|
745
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, menu, toolbarItems && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Divider, {
|
|
746
|
+
style: {
|
|
747
|
+
margin: '8px 0'
|
|
748
|
+
}
|
|
749
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
750
|
+
className: 'toolbar-control d-flex justify-content-end'
|
|
751
|
+
}, toolbarItems.map(it => {
|
|
752
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
753
|
+
key: it.key,
|
|
754
|
+
className: 'toolbar-item',
|
|
755
|
+
onClick: () => toolbarClick?.({
|
|
756
|
+
item: it,
|
|
757
|
+
column
|
|
758
|
+
})
|
|
759
|
+
}, it.template ? (0, _hooks.getTemplate)(it.template) : /*#__PURE__*/_react.default.createElement(_rcMasterUi.Button, {
|
|
760
|
+
className: "toolbar-item-btn"
|
|
761
|
+
}, it.icon && (0, _hooks.getTemplate)(it.icon), it.title));
|
|
762
|
+
}))));
|
|
763
|
+
} else {
|
|
764
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, " ", menu);
|
|
765
|
+
}
|
|
766
|
+
},
|
|
538
767
|
"data-tooltip-content": message,
|
|
539
768
|
"data-tooltip-id": `${id}-tooltip-error`
|
|
540
769
|
});
|
|
541
770
|
case 'asyncSelect':
|
|
542
|
-
let valueAsyncSelect =
|
|
771
|
+
let valueAsyncSelect = formValues[dataIndex];
|
|
543
772
|
if (fieldValue) {
|
|
544
773
|
// @ts-ignore
|
|
545
|
-
valueAsyncSelect = record[fieldValue] ??
|
|
774
|
+
valueAsyncSelect = record[fieldValue] ?? formValues[dataIndex];
|
|
546
775
|
}
|
|
547
776
|
return /*#__PURE__*/_react.default.createElement(_asyncSelect.AsyncSelect, {
|
|
548
777
|
options: options,
|
|
549
778
|
defaultOptions: options,
|
|
550
779
|
value: valueAsyncSelect ?? undefined,
|
|
551
780
|
onChange: (val, option) => {
|
|
552
|
-
onChange(val);
|
|
781
|
+
onChange(val ?? '');
|
|
553
782
|
const formState = getValues();
|
|
554
|
-
|
|
783
|
+
const formNewState = {
|
|
784
|
+
...getValues(),
|
|
785
|
+
[dataIndex]: !(0, _utils.isNullOrUndefined)(formState[dataIndex]) ? formState[dataIndex] : undefined
|
|
786
|
+
};
|
|
555
787
|
// @ts-ignore
|
|
556
|
-
const prevState = record[dataIndex];
|
|
557
|
-
const newState = val;
|
|
788
|
+
const prevState = record[dataIndex] ?? undefined;
|
|
789
|
+
const newState = val ?? undefined;
|
|
558
790
|
handleCellChange?.({
|
|
559
791
|
key,
|
|
560
792
|
field: column.field ?? column.field,
|
|
561
|
-
record:
|
|
793
|
+
record: formNewState,
|
|
562
794
|
prevState,
|
|
563
795
|
newState,
|
|
564
796
|
option: option,
|
|
@@ -585,46 +817,40 @@ const EditableCell = props => {
|
|
|
585
817
|
optionFilterProp: "label",
|
|
586
818
|
popupClassName: 'be-popup-container',
|
|
587
819
|
loadOptions: loadOptions,
|
|
588
|
-
status: isInvalid ? 'error' : undefined
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
// return <> {menu}</>
|
|
623
|
-
// }
|
|
624
|
-
//
|
|
625
|
-
// }}
|
|
626
|
-
,
|
|
627
|
-
filterOption: filterOption,
|
|
820
|
+
status: isInvalid ? 'error' : undefined,
|
|
821
|
+
dropdownRender: menu => {
|
|
822
|
+
if (toolbarItems && toolbarItems.length > 0) {
|
|
823
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, menu, toolbarItems && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Divider, {
|
|
824
|
+
style: {
|
|
825
|
+
margin: '8px 0'
|
|
826
|
+
}
|
|
827
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
828
|
+
className: 'toolbar-control d-flex justify-content-end'
|
|
829
|
+
}, toolbarItems.map(it => {
|
|
830
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
831
|
+
key: it.key,
|
|
832
|
+
className: 'toolbar-item',
|
|
833
|
+
onClick: () => toolbarClick?.({
|
|
834
|
+
item: it,
|
|
835
|
+
column
|
|
836
|
+
})
|
|
837
|
+
}, it.template ? (0, _hooks.getTemplate)(it.template) : /*#__PURE__*/_react.default.createElement(_rcMasterUi.Button, {
|
|
838
|
+
className: "toolbar-item-btn"
|
|
839
|
+
}, it.icon && (0, _hooks.getTemplate)(it.icon), it.title));
|
|
840
|
+
}))));
|
|
841
|
+
} else {
|
|
842
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, " ", menu);
|
|
843
|
+
}
|
|
844
|
+
},
|
|
845
|
+
optionRender: column.editSelectSettings?.formatOptionLabel,
|
|
846
|
+
filterOption: filterKey ? (input, option) => {
|
|
847
|
+
const searchValue = (0, _utils.removeVietnameseTones)(input.toLowerCase() ?? '');
|
|
848
|
+
const filterValues = filterKey.some(k => {
|
|
849
|
+
const val = option?.[k];
|
|
850
|
+
return (0, _utils.removeVietnameseTones)((val ?? '').toString().toLowerCase()).includes(searchValue);
|
|
851
|
+
});
|
|
852
|
+
return filterValues;
|
|
853
|
+
} : filterOption,
|
|
628
854
|
fieldNames: fieldNames ? fieldNames : {
|
|
629
855
|
value: keySelect,
|
|
630
856
|
label: inputKey ?? 'label'
|
|
@@ -659,24 +885,12 @@ const EditableCell = props => {
|
|
|
659
885
|
"data-tooltip-id": `${id}-tooltip-error`
|
|
660
886
|
});
|
|
661
887
|
case 'treeSelect':
|
|
662
|
-
// let valueTreeSelect
|
|
663
|
-
|
|
664
888
|
const newTreeData = (0, _utils.convertLabelToTitle)(optionsTree);
|
|
665
|
-
// @ts-ignore
|
|
666
|
-
// const valueTreeSelect = column?.editSelectSettings?.isMulti ? (Array.isArray(record[dataIndex]) ? record[dataIndex] : []) : record[dataIndex]
|
|
667
|
-
|
|
668
889
|
let valueTreeSelect = value;
|
|
669
890
|
if (fieldValue) {
|
|
670
891
|
// @ts-ignore
|
|
671
892
|
valueTreeSelect = record[fieldValue] ?? value;
|
|
672
893
|
}
|
|
673
|
-
|
|
674
|
-
// if (isMulti || selectMode === 'checkbox') {
|
|
675
|
-
// // @ts-ignore
|
|
676
|
-
// valueTreeSelect = (!isNullOrUndefined(record[dataIndex]) && Array.isArray(record[dataIndex]) && record[dataIndex]?.length > 0) ? options.filter((val: any) => record[dataIndex]?.includes(val[keySelect])) : undefined
|
|
677
|
-
|
|
678
|
-
// }
|
|
679
|
-
|
|
680
894
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.TreeSelect, {
|
|
681
895
|
id: `col${indexCol}-record${indexRow}`,
|
|
682
896
|
className: 'be-tree-select',
|
|
@@ -689,21 +903,14 @@ const EditableCell = props => {
|
|
|
689
903
|
maxHeight: 400,
|
|
690
904
|
overflow: 'auto'
|
|
691
905
|
},
|
|
692
|
-
treeData: newTreeData
|
|
693
|
-
|
|
694
|
-
,
|
|
695
|
-
placeholder: t && column?.placeholder ? t(column.placeholder) : tableLocal?.selectPlaceholder,
|
|
906
|
+
treeData: newTreeData,
|
|
907
|
+
placeholder: t && column.placeholder ? t(column.placeholder) : tableLocal?.selectPlaceholder,
|
|
696
908
|
treeDefaultExpandAll: true,
|
|
697
909
|
defaultOpen: column.field === startCell?.colId,
|
|
698
|
-
autoFocus: column.field === startCell?.colId
|
|
699
|
-
|
|
700
|
-
// defaultOpen={column.field === cellEditing?.column.field}
|
|
701
|
-
,
|
|
910
|
+
autoFocus: column.field === startCell?.colId,
|
|
702
911
|
virtual: true,
|
|
703
912
|
allowClear: true,
|
|
704
|
-
showSearch: true
|
|
705
|
-
// maxTagTextLength={column?.editSelectSettings?.showItems}
|
|
706
|
-
,
|
|
913
|
+
showSearch: true,
|
|
707
914
|
maxTagCount: column?.editSelectSettings?.showItems,
|
|
708
915
|
maxTagPlaceholder: 2,
|
|
709
916
|
treeTitleRender: column?.editSelectSettings?.formatOptionLabel,
|
|
@@ -919,7 +1126,7 @@ const EditableCell = props => {
|
|
|
919
1126
|
// let floatValue = value
|
|
920
1127
|
|
|
921
1128
|
const numericFormatProps = {
|
|
922
|
-
value,
|
|
1129
|
+
value: value || '',
|
|
923
1130
|
thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
924
1131
|
decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
925
1132
|
decimalScale: cellFormat?.decimalScale ?? undefined,
|
|
@@ -930,8 +1137,6 @@ const EditableCell = props => {
|
|
|
930
1137
|
};
|
|
931
1138
|
return /*#__PURE__*/_react.default.createElement(_reactNumericComponent.NumericFormat, (0, _extends2.default)({
|
|
932
1139
|
id: `col${indexCol}-record${indexRow}`
|
|
933
|
-
// value={value ? numericFormatter(value.toString(), numericFormatProps) : ''}
|
|
934
|
-
// value={value}
|
|
935
1140
|
}, numericFormatProps, {
|
|
936
1141
|
min: column.min,
|
|
937
1142
|
max: column.max,
|