es-grid-template 1.9.43 → 1.9.45
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/group-component/body/EditableCell.js +7 -7
- package/es/group-component/hook/utils.d.ts +3 -3
- package/es/table-component/TableContainerEdit.js +2 -2
- package/es/table-component/body/EditableCell.js +37 -11
- package/es/table-component/hook/useColumns.js +5 -2
- package/es/table-component/hook/utils.d.ts +3 -0
- package/es/table-component/hook/utils.js +61 -0
- package/lib/group-component/body/EditableCell.js +7 -7
- package/lib/table-component/TableContainerEdit.js +2 -2
- package/lib/table-component/body/EditableCell.js +36 -10
- package/lib/table-component/hook/useColumns.js +4 -1
- package/lib/table-component/hook/utils.d.ts +3 -0
- package/lib/table-component/hook/utils.js +67 -4
- package/package.json +1 -1
|
@@ -366,7 +366,7 @@ const EditableCell = props => {
|
|
|
366
366
|
rowData: record,
|
|
367
367
|
autoDestroy: true,
|
|
368
368
|
onChange: (val, option) => {
|
|
369
|
-
onChange(val
|
|
369
|
+
onChange(val);
|
|
370
370
|
const formState = getValues();
|
|
371
371
|
// const itemState = getValues(dataIndex)
|
|
372
372
|
// @ts-ignore
|
|
@@ -425,7 +425,7 @@ const EditableCell = props => {
|
|
|
425
425
|
onBlur: event => {
|
|
426
426
|
if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
427
427
|
const val = event.inputValue;
|
|
428
|
-
onChange(val
|
|
428
|
+
onChange(val);
|
|
429
429
|
const formState = getValues();
|
|
430
430
|
// const itemState = getValues(dataIndex)
|
|
431
431
|
// @ts-ignore
|
|
@@ -461,7 +461,7 @@ const EditableCell = props => {
|
|
|
461
461
|
options: options,
|
|
462
462
|
value: valueSelect ?? undefined,
|
|
463
463
|
onChange: (val, option) => {
|
|
464
|
-
onChange(val
|
|
464
|
+
onChange(val);
|
|
465
465
|
const formState = getValues();
|
|
466
466
|
// const itemState = getValues(dataIndex)
|
|
467
467
|
// @ts-ignore
|
|
@@ -504,7 +504,7 @@ const EditableCell = props => {
|
|
|
504
504
|
onBlur: event => {
|
|
505
505
|
if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
506
506
|
const val = event.inputValue;
|
|
507
|
-
onChange(val
|
|
507
|
+
onChange(val);
|
|
508
508
|
const formState = getValues();
|
|
509
509
|
// const itemState = getValues(dataIndex)
|
|
510
510
|
// @ts-ignore
|
|
@@ -541,7 +541,7 @@ const EditableCell = props => {
|
|
|
541
541
|
defaultOptions: options,
|
|
542
542
|
value: valueAsyncSelect ?? undefined,
|
|
543
543
|
onChange: (val, option) => {
|
|
544
|
-
onChange(val
|
|
544
|
+
onChange(val);
|
|
545
545
|
const formState = getValues();
|
|
546
546
|
// const itemState = getValues(dataIndex)
|
|
547
547
|
// @ts-ignore
|
|
@@ -623,7 +623,7 @@ const EditableCell = props => {
|
|
|
623
623
|
onBlur: event => {
|
|
624
624
|
if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
625
625
|
const val = event.inputValue;
|
|
626
|
-
onChange(val
|
|
626
|
+
onChange(val);
|
|
627
627
|
const formState = getValues();
|
|
628
628
|
// const itemState = getValues(dataIndex)
|
|
629
629
|
// @ts-ignore
|
|
@@ -706,7 +706,7 @@ const EditableCell = props => {
|
|
|
706
706
|
filterTreeNode: filterTreeNode,
|
|
707
707
|
popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
|
|
708
708
|
onSelect: (val, option) => {
|
|
709
|
-
onChange(val
|
|
709
|
+
onChange(val);
|
|
710
710
|
const formState = getValues();
|
|
711
711
|
// const itemState = getValues(dataIndex)
|
|
712
712
|
// @ts-ignore
|
|
@@ -194,10 +194,10 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
|
|
|
194
194
|
value: any;
|
|
195
195
|
rowData: RecordType;
|
|
196
196
|
}) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
|
|
197
|
-
onCellStyles?: Omit<CSSProperties, "
|
|
198
|
-
onCellHeaderStyles?: Omit<CSSProperties, "
|
|
197
|
+
onCellStyles?: Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position">);
|
|
198
|
+
onCellHeaderStyles?: Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position">);
|
|
199
199
|
onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
|
|
200
|
-
onCellFooterStyles?: Omit<CSSProperties, "
|
|
200
|
+
onCellFooterStyles?: Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position">);
|
|
201
201
|
getValue?: (row: any, rowIndex: number) => any;
|
|
202
202
|
getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
|
|
203
203
|
headerCellProps?: import("./../../grid-component/type").CellProps;
|
|
@@ -1575,7 +1575,7 @@ const TableContainerEdit = props => {
|
|
|
1575
1575
|
const toolbarItemsTop = React.useMemo(() => {
|
|
1576
1576
|
// Chưa có dòng| ô được chọn
|
|
1577
1577
|
if (!rowsFocus || rowsFocus.length === 0) {
|
|
1578
|
-
return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !==
|
|
1578
|
+
return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !== true && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
|
|
1579
1579
|
if (item.key === 'ADD') {
|
|
1580
1580
|
return {
|
|
1581
1581
|
...item,
|
|
@@ -1636,7 +1636,7 @@ const TableContainerEdit = props => {
|
|
|
1636
1636
|
};
|
|
1637
1637
|
});
|
|
1638
1638
|
}
|
|
1639
|
-
return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !==
|
|
1639
|
+
return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !== true).map(item => {
|
|
1640
1640
|
if (item.key === 'ADD') {
|
|
1641
1641
|
return {
|
|
1642
1642
|
...item,
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import React, { useContext } from "react";
|
|
3
3
|
import { DatePicker, TimePicker, ColorPicker, Input } from "rc-master-ui";
|
|
4
4
|
import { Divider, Row, Col, Button } from "antd";
|
|
5
|
-
import { checkDecimalSeparator, checkThousandSeparator, checkFieldKey, convertArrayWithIndent, convertDateToDayjs, convertLabelToTitle, getDatepickerFormat, isDisable, isEmpty, isNullOrUndefined, customWeekStartEndFormat, convertDayjsToDate, parseBooleanToValue, isColor, genPresets, getFormat, removeVietnameseTones } from "../hook/utils";
|
|
5
|
+
import { checkDecimalSeparator, checkThousandSeparator, checkFieldKey, convertArrayWithIndent, convertDateToDayjs, convertLabelToTitle, getDatepickerFormat, isDisable, isEmpty, isNullOrUndefined, customWeekStartEndFormat, convertDayjsToDate, parseBooleanToValue, isColor, genPresets, getFormat, removeVietnameseTones, getDateValueType } from "../hook/utils";
|
|
6
6
|
import classNames from "classnames";
|
|
7
7
|
import { NumericFormat } from "react-numeric-component";
|
|
8
8
|
import dayjs from "dayjs";
|
|
@@ -305,7 +305,20 @@ const EditableCell = props => {
|
|
|
305
305
|
});
|
|
306
306
|
case 'time':
|
|
307
307
|
const timeFormat = getDatepickerFormat(editType, cellFormat);
|
|
308
|
-
|
|
308
|
+
|
|
309
|
+
// chỉ nhận giá trị dạng HH:mm | mm:HH => convert
|
|
310
|
+
|
|
311
|
+
let time = value ?? null;
|
|
312
|
+
const typeTime = getDateValueType(value);
|
|
313
|
+
if (typeTime === 'time') {
|
|
314
|
+
time = value ? dayjs(value, timeFormat) : null;
|
|
315
|
+
} else {
|
|
316
|
+
const abc = moment(value).format(timeFormat);
|
|
317
|
+
time = abc ? dayjs(abc, timeFormat) : null;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// time = value ? dayjs(value, timeFormat) : null
|
|
321
|
+
|
|
309
322
|
const maxTimeValue = !isEmpty(column.maxTime) ? dayjs(column.maxTime).format(timeFormat) : null;
|
|
310
323
|
const minTimeValue = !isEmpty(column.minTime) ? dayjs(column.minTime).format(timeFormat) : null;
|
|
311
324
|
|
|
@@ -336,7 +349,20 @@ const EditableCell = props => {
|
|
|
336
349
|
autoFocus: column.field === startCell?.colId,
|
|
337
350
|
defaultOpen: column.field === startCell?.colId,
|
|
338
351
|
onChange: (newDate, dateString) => {
|
|
352
|
+
if (typeTime === 'time') {
|
|
353
|
+
onChange(dateString);
|
|
354
|
+
} else {
|
|
355
|
+
// const datetime = dayjs(dateString as string, timeFormat, true);
|
|
356
|
+
|
|
357
|
+
const newVal = moment(newDate.toDate()).format();
|
|
358
|
+
|
|
359
|
+
// const newVal = datetime.isValid() ? moment(datetime.toDate()).format() : ''
|
|
360
|
+
|
|
361
|
+
onChange(newVal);
|
|
362
|
+
}
|
|
363
|
+
|
|
339
364
|
// const newDateValue = dateString ? moment(convertDayjsToDate(dateString as string, dateFormat)).format() : null
|
|
365
|
+
|
|
340
366
|
onChange(dateString);
|
|
341
367
|
setTimeout(() => {
|
|
342
368
|
// @ts-ignore
|
|
@@ -396,7 +422,7 @@ const EditableCell = props => {
|
|
|
396
422
|
value: valueSelectTable ?? undefined,
|
|
397
423
|
autoDestroy: true,
|
|
398
424
|
onChange: (val, option) => {
|
|
399
|
-
onChange(val
|
|
425
|
+
onChange(val);
|
|
400
426
|
const formState = getValues();
|
|
401
427
|
// const itemState = getValues(dataIndex)
|
|
402
428
|
// @ts-ignore
|
|
@@ -473,7 +499,7 @@ const EditableCell = props => {
|
|
|
473
499
|
onBlur: event => {
|
|
474
500
|
if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
475
501
|
const val = event.inputValue;
|
|
476
|
-
onChange(val ??
|
|
502
|
+
onChange(val ?? undefined);
|
|
477
503
|
const formState = getValues();
|
|
478
504
|
// const itemState = getValues(dataIndex)
|
|
479
505
|
// @ts-ignore
|
|
@@ -499,7 +525,7 @@ const EditableCell = props => {
|
|
|
499
525
|
onKeyDown: event => {
|
|
500
526
|
if (event.key === 'Enter' && event.target?.value && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
501
527
|
const val = event.target.value;
|
|
502
|
-
onChange(val
|
|
528
|
+
onChange(val);
|
|
503
529
|
const formState = getValues();
|
|
504
530
|
// const itemState = getValues(dataIndex)
|
|
505
531
|
// @ts-ignore
|
|
@@ -535,7 +561,7 @@ const EditableCell = props => {
|
|
|
535
561
|
options: options,
|
|
536
562
|
value: valueSelect ?? undefined,
|
|
537
563
|
onChange: (val, option) => {
|
|
538
|
-
onChange(val
|
|
564
|
+
onChange(val);
|
|
539
565
|
const formState = getValues();
|
|
540
566
|
// const itemState = getValues(dataIndex)
|
|
541
567
|
// @ts-ignore
|
|
@@ -586,7 +612,7 @@ const EditableCell = props => {
|
|
|
586
612
|
onBlur: event => {
|
|
587
613
|
if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
588
614
|
const val = event.inputValue;
|
|
589
|
-
onChange(val
|
|
615
|
+
onChange(val);
|
|
590
616
|
const formState = getValues();
|
|
591
617
|
// const itemState = getValues(dataIndex)
|
|
592
618
|
// @ts-ignore
|
|
@@ -612,7 +638,7 @@ const EditableCell = props => {
|
|
|
612
638
|
onKeyDown: event => {
|
|
613
639
|
if (event.key === 'Enter' && event.target?.value && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
614
640
|
const val = event.target.value;
|
|
615
|
-
onChange(val
|
|
641
|
+
onChange(val);
|
|
616
642
|
const formState = getValues();
|
|
617
643
|
// const itemState = getValues(dataIndex)
|
|
618
644
|
// @ts-ignore
|
|
@@ -673,7 +699,7 @@ const EditableCell = props => {
|
|
|
673
699
|
defaultOptions: options,
|
|
674
700
|
value: valueAsyncSelect ?? undefined,
|
|
675
701
|
onChange: (val, option) => {
|
|
676
|
-
onChange(val
|
|
702
|
+
onChange(val);
|
|
677
703
|
const formState = getValues();
|
|
678
704
|
// const itemState = getValues(dataIndex)
|
|
679
705
|
// @ts-ignore
|
|
@@ -749,7 +775,7 @@ const EditableCell = props => {
|
|
|
749
775
|
onBlur: event => {
|
|
750
776
|
if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
751
777
|
const val = event.inputValue;
|
|
752
|
-
onChange(val
|
|
778
|
+
onChange(val);
|
|
753
779
|
const formState = getValues();
|
|
754
780
|
// const itemState = getValues(dataIndex)
|
|
755
781
|
// @ts-ignore
|
|
@@ -813,7 +839,7 @@ const EditableCell = props => {
|
|
|
813
839
|
filterTreeNode: filterTreeNode,
|
|
814
840
|
popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
|
|
815
841
|
onSelect: (val, option) => {
|
|
816
|
-
onChange(val
|
|
842
|
+
onChange(val);
|
|
817
843
|
const formState = getValues();
|
|
818
844
|
// const itemState = getValues(dataIndex)
|
|
819
845
|
// @ts-ignore
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Fragment } from 'react';
|
|
2
2
|
import ControlCheckbox from "../components/ControlCheckbox";
|
|
3
|
-
import { checkDecimalSeparator, checkThousandSeparator, countUnselectedChildren, excludeItems, getAllChildren, getFormat, isColor, isEmpty, sortByType, toggleRowAndChildren } from "./utils";
|
|
3
|
+
import { checkDecimalSeparator, checkThousandSeparator, convertToDate, countUnselectedChildren, excludeItems, getAllChildren, getFormat, isColor, isEmpty, sortByType, toggleRowAndChildren } from "./utils";
|
|
4
4
|
import { numericFormatter } from 'react-numeric-component';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
6
|
import moment from 'moment';
|
|
@@ -38,7 +38,10 @@ export const renderValueCell = (column, value, record, rowIndex, colIndex, forma
|
|
|
38
38
|
case 'date':
|
|
39
39
|
return value ? dayjs(value).format(format?.dateFormat ?? 'DD/MM/YYYY') : '';
|
|
40
40
|
case 'time':
|
|
41
|
-
|
|
41
|
+
const timeFormat = format?.timeFormat ?? 'HH:mm';
|
|
42
|
+
const abc = convertToDate(value, timeFormat);
|
|
43
|
+
const timeValue = value ? dayjs(abc).format(timeFormat) : '';
|
|
44
|
+
return timeValue ?? '';
|
|
42
45
|
case 'year':
|
|
43
46
|
const year = value ? moment(value).format('yyyy') : '';
|
|
44
47
|
return year;
|
|
@@ -37,6 +37,9 @@ export declare const getFormat: (colFormat?: IFormat, format?: IFormat) => {
|
|
|
37
37
|
export declare function convertFormat(formatStr: string): string;
|
|
38
38
|
export declare const getDatepickerFormat: (type: EditType | TypeFilter | IColumnType, format?: IFormat) => string;
|
|
39
39
|
export declare const getDateRangeFormat: (type: EditType | TypeFilter | IColumnType, format?: IFormat) => string;
|
|
40
|
+
export type DateValueType = 'datetime' | 'time' | 'invalid';
|
|
41
|
+
export declare function getDateValueType(value: unknown): DateValueType;
|
|
42
|
+
export declare const convertToDate: (value?: string | Date | null, format?: string) => string;
|
|
40
43
|
export declare const getTypeFilter: (col: any) => TypeFilter;
|
|
41
44
|
export declare const addRowIdArray: (inputArray: any[]) => any[];
|
|
42
45
|
export declare function groupArrayByColumns(arr: any[], columns: string[] | undefined): any;
|
|
@@ -171,6 +171,67 @@ export const getDateRangeFormat = (type, format) => {
|
|
|
171
171
|
return 'dd/MM/yyyy';
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
|
+
export function getDateValueType(value) {
|
|
175
|
+
if (typeof value !== 'string') {
|
|
176
|
+
return 'invalid';
|
|
177
|
+
}
|
|
178
|
+
const datetimeRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
179
|
+
const timeRegex = /^\d{2}:\d{2}(:\d{2})?$/;
|
|
180
|
+
if (datetimeRegex.test(value)) {
|
|
181
|
+
return 'datetime';
|
|
182
|
+
}
|
|
183
|
+
if (timeRegex.test(value)) {
|
|
184
|
+
return 'time';
|
|
185
|
+
}
|
|
186
|
+
return 'invalid';
|
|
187
|
+
}
|
|
188
|
+
export const convertToDate = (value, format) => {
|
|
189
|
+
if (!value) {
|
|
190
|
+
return '';
|
|
191
|
+
}
|
|
192
|
+
const valueType = getDateValueType(value);
|
|
193
|
+
if (valueType === 'time') {
|
|
194
|
+
const date = dayjs(value, format, true);
|
|
195
|
+
return date.isValid() ? moment(date.toDate()).format() : '';
|
|
196
|
+
}
|
|
197
|
+
if (valueType === 'datetime') {
|
|
198
|
+
return moment(value).format() ?? '';
|
|
199
|
+
}
|
|
200
|
+
if (valueType === 'invalid') {
|
|
201
|
+
return '';
|
|
202
|
+
}
|
|
203
|
+
return '';
|
|
204
|
+
|
|
205
|
+
// if (value instanceof Date) {
|
|
206
|
+
// return moment(value).format();
|
|
207
|
+
// }
|
|
208
|
+
|
|
209
|
+
// let date: dayjs.Dayjs;
|
|
210
|
+
|
|
211
|
+
// if (format) {
|
|
212
|
+
// const bbb = moment(value)
|
|
213
|
+
|
|
214
|
+
// if (!bbb.isValid()) {
|
|
215
|
+
|
|
216
|
+
// // value dạng HH:mm
|
|
217
|
+
// date = dayjs(value, format, true);
|
|
218
|
+
|
|
219
|
+
// } else {
|
|
220
|
+
// // value dạng datetime
|
|
221
|
+
|
|
222
|
+
// date = dayjs(bbb.format(format), format, true);
|
|
223
|
+
|
|
224
|
+
// }
|
|
225
|
+
|
|
226
|
+
// } else {
|
|
227
|
+
|
|
228
|
+
// // Tự nhận diện ISO, YYYY-MM-DD,...
|
|
229
|
+
// date = dayjs(value);
|
|
230
|
+
|
|
231
|
+
// }
|
|
232
|
+
|
|
233
|
+
// return date.isValid() ? moment(date.toDate()).format() : null;
|
|
234
|
+
};
|
|
174
235
|
export const getTypeFilter = col => {
|
|
175
236
|
if (col?.typeFilter) {
|
|
176
237
|
return col.typeFilter;
|
|
@@ -374,7 +374,7 @@ const EditableCell = props => {
|
|
|
374
374
|
rowData: record,
|
|
375
375
|
autoDestroy: true,
|
|
376
376
|
onChange: (val, option) => {
|
|
377
|
-
onChange(val
|
|
377
|
+
onChange(val);
|
|
378
378
|
const formState = getValues();
|
|
379
379
|
// const itemState = getValues(dataIndex)
|
|
380
380
|
// @ts-ignore
|
|
@@ -433,7 +433,7 @@ const EditableCell = props => {
|
|
|
433
433
|
onBlur: event => {
|
|
434
434
|
if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
435
435
|
const val = event.inputValue;
|
|
436
|
-
onChange(val
|
|
436
|
+
onChange(val);
|
|
437
437
|
const formState = getValues();
|
|
438
438
|
// const itemState = getValues(dataIndex)
|
|
439
439
|
// @ts-ignore
|
|
@@ -469,7 +469,7 @@ const EditableCell = props => {
|
|
|
469
469
|
options: options,
|
|
470
470
|
value: valueSelect ?? undefined,
|
|
471
471
|
onChange: (val, option) => {
|
|
472
|
-
onChange(val
|
|
472
|
+
onChange(val);
|
|
473
473
|
const formState = getValues();
|
|
474
474
|
// const itemState = getValues(dataIndex)
|
|
475
475
|
// @ts-ignore
|
|
@@ -512,7 +512,7 @@ const EditableCell = props => {
|
|
|
512
512
|
onBlur: event => {
|
|
513
513
|
if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
514
514
|
const val = event.inputValue;
|
|
515
|
-
onChange(val
|
|
515
|
+
onChange(val);
|
|
516
516
|
const formState = getValues();
|
|
517
517
|
// const itemState = getValues(dataIndex)
|
|
518
518
|
// @ts-ignore
|
|
@@ -549,7 +549,7 @@ const EditableCell = props => {
|
|
|
549
549
|
defaultOptions: options,
|
|
550
550
|
value: valueAsyncSelect ?? undefined,
|
|
551
551
|
onChange: (val, option) => {
|
|
552
|
-
onChange(val
|
|
552
|
+
onChange(val);
|
|
553
553
|
const formState = getValues();
|
|
554
554
|
// const itemState = getValues(dataIndex)
|
|
555
555
|
// @ts-ignore
|
|
@@ -631,7 +631,7 @@ const EditableCell = props => {
|
|
|
631
631
|
onBlur: event => {
|
|
632
632
|
if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
633
633
|
const val = event.inputValue;
|
|
634
|
-
onChange(val
|
|
634
|
+
onChange(val);
|
|
635
635
|
const formState = getValues();
|
|
636
636
|
// const itemState = getValues(dataIndex)
|
|
637
637
|
// @ts-ignore
|
|
@@ -714,7 +714,7 @@ const EditableCell = props => {
|
|
|
714
714
|
filterTreeNode: filterTreeNode,
|
|
715
715
|
popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
|
|
716
716
|
onSelect: (val, option) => {
|
|
717
|
-
onChange(val
|
|
717
|
+
onChange(val);
|
|
718
718
|
const formState = getValues();
|
|
719
719
|
// const itemState = getValues(dataIndex)
|
|
720
720
|
// @ts-ignore
|
|
@@ -1576,7 +1576,7 @@ const TableContainerEdit = props => {
|
|
|
1576
1576
|
const toolbarItemsTop = _react.default.useMemo(() => {
|
|
1577
1577
|
// Chưa có dòng| ô được chọn
|
|
1578
1578
|
if (!rowsFocus || rowsFocus.length === 0) {
|
|
1579
|
-
return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !==
|
|
1579
|
+
return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !== true && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
|
|
1580
1580
|
if (item.key === 'ADD') {
|
|
1581
1581
|
return {
|
|
1582
1582
|
...item,
|
|
@@ -1637,7 +1637,7 @@ const TableContainerEdit = props => {
|
|
|
1637
1637
|
};
|
|
1638
1638
|
});
|
|
1639
1639
|
}
|
|
1640
|
-
return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !==
|
|
1640
|
+
return toolbarItems?.filter(it => it.position !== 'Bottom' && it.visible !== false && it.fixedRight !== true).map(item => {
|
|
1641
1641
|
if (item.key === 'ADD') {
|
|
1642
1642
|
return {
|
|
1643
1643
|
...item,
|
|
@@ -313,7 +313,20 @@ const EditableCell = props => {
|
|
|
313
313
|
});
|
|
314
314
|
case 'time':
|
|
315
315
|
const timeFormat = (0, _utils.getDatepickerFormat)(editType, cellFormat);
|
|
316
|
-
|
|
316
|
+
|
|
317
|
+
// chỉ nhận giá trị dạng HH:mm | mm:HH => convert
|
|
318
|
+
|
|
319
|
+
let time = value ?? null;
|
|
320
|
+
const typeTime = (0, _utils.getDateValueType)(value);
|
|
321
|
+
if (typeTime === 'time') {
|
|
322
|
+
time = value ? (0, _dayjs.default)(value, timeFormat) : null;
|
|
323
|
+
} else {
|
|
324
|
+
const abc = (0, _moment.default)(value).format(timeFormat);
|
|
325
|
+
time = abc ? (0, _dayjs.default)(abc, timeFormat) : null;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// time = value ? dayjs(value, timeFormat) : null
|
|
329
|
+
|
|
317
330
|
const maxTimeValue = !(0, _utils.isEmpty)(column.maxTime) ? (0, _dayjs.default)(column.maxTime).format(timeFormat) : null;
|
|
318
331
|
const minTimeValue = !(0, _utils.isEmpty)(column.minTime) ? (0, _dayjs.default)(column.minTime).format(timeFormat) : null;
|
|
319
332
|
|
|
@@ -344,7 +357,20 @@ const EditableCell = props => {
|
|
|
344
357
|
autoFocus: column.field === startCell?.colId,
|
|
345
358
|
defaultOpen: column.field === startCell?.colId,
|
|
346
359
|
onChange: (newDate, dateString) => {
|
|
360
|
+
if (typeTime === 'time') {
|
|
361
|
+
onChange(dateString);
|
|
362
|
+
} else {
|
|
363
|
+
// const datetime = dayjs(dateString as string, timeFormat, true);
|
|
364
|
+
|
|
365
|
+
const newVal = (0, _moment.default)(newDate.toDate()).format();
|
|
366
|
+
|
|
367
|
+
// const newVal = datetime.isValid() ? moment(datetime.toDate()).format() : ''
|
|
368
|
+
|
|
369
|
+
onChange(newVal);
|
|
370
|
+
}
|
|
371
|
+
|
|
347
372
|
// const newDateValue = dateString ? moment(convertDayjsToDate(dateString as string, dateFormat)).format() : null
|
|
373
|
+
|
|
348
374
|
onChange(dateString);
|
|
349
375
|
setTimeout(() => {
|
|
350
376
|
// @ts-ignore
|
|
@@ -404,7 +430,7 @@ const EditableCell = props => {
|
|
|
404
430
|
value: valueSelectTable ?? undefined,
|
|
405
431
|
autoDestroy: true,
|
|
406
432
|
onChange: (val, option) => {
|
|
407
|
-
onChange(val
|
|
433
|
+
onChange(val);
|
|
408
434
|
const formState = getValues();
|
|
409
435
|
// const itemState = getValues(dataIndex)
|
|
410
436
|
// @ts-ignore
|
|
@@ -481,7 +507,7 @@ const EditableCell = props => {
|
|
|
481
507
|
onBlur: event => {
|
|
482
508
|
if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
483
509
|
const val = event.inputValue;
|
|
484
|
-
onChange(val ??
|
|
510
|
+
onChange(val ?? undefined);
|
|
485
511
|
const formState = getValues();
|
|
486
512
|
// const itemState = getValues(dataIndex)
|
|
487
513
|
// @ts-ignore
|
|
@@ -507,7 +533,7 @@ const EditableCell = props => {
|
|
|
507
533
|
onKeyDown: event => {
|
|
508
534
|
if (event.key === 'Enter' && event.target?.value && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
509
535
|
const val = event.target.value;
|
|
510
|
-
onChange(val
|
|
536
|
+
onChange(val);
|
|
511
537
|
const formState = getValues();
|
|
512
538
|
// const itemState = getValues(dataIndex)
|
|
513
539
|
// @ts-ignore
|
|
@@ -543,7 +569,7 @@ const EditableCell = props => {
|
|
|
543
569
|
options: options,
|
|
544
570
|
value: valueSelect ?? undefined,
|
|
545
571
|
onChange: (val, option) => {
|
|
546
|
-
onChange(val
|
|
572
|
+
onChange(val);
|
|
547
573
|
const formState = getValues();
|
|
548
574
|
// const itemState = getValues(dataIndex)
|
|
549
575
|
// @ts-ignore
|
|
@@ -594,7 +620,7 @@ const EditableCell = props => {
|
|
|
594
620
|
onBlur: event => {
|
|
595
621
|
if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
596
622
|
const val = event.inputValue;
|
|
597
|
-
onChange(val
|
|
623
|
+
onChange(val);
|
|
598
624
|
const formState = getValues();
|
|
599
625
|
// const itemState = getValues(dataIndex)
|
|
600
626
|
// @ts-ignore
|
|
@@ -620,7 +646,7 @@ const EditableCell = props => {
|
|
|
620
646
|
onKeyDown: event => {
|
|
621
647
|
if (event.key === 'Enter' && event.target?.value && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
622
648
|
const val = event.target.value;
|
|
623
|
-
onChange(val
|
|
649
|
+
onChange(val);
|
|
624
650
|
const formState = getValues();
|
|
625
651
|
// const itemState = getValues(dataIndex)
|
|
626
652
|
// @ts-ignore
|
|
@@ -681,7 +707,7 @@ const EditableCell = props => {
|
|
|
681
707
|
defaultOptions: options,
|
|
682
708
|
value: valueAsyncSelect ?? undefined,
|
|
683
709
|
onChange: (val, option) => {
|
|
684
|
-
onChange(val
|
|
710
|
+
onChange(val);
|
|
685
711
|
const formState = getValues();
|
|
686
712
|
// const itemState = getValues(dataIndex)
|
|
687
713
|
// @ts-ignore
|
|
@@ -757,7 +783,7 @@ const EditableCell = props => {
|
|
|
757
783
|
onBlur: event => {
|
|
758
784
|
if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
759
785
|
const val = event.inputValue;
|
|
760
|
-
onChange(val
|
|
786
|
+
onChange(val);
|
|
761
787
|
const formState = getValues();
|
|
762
788
|
// const itemState = getValues(dataIndex)
|
|
763
789
|
// @ts-ignore
|
|
@@ -821,7 +847,7 @@ const EditableCell = props => {
|
|
|
821
847
|
filterTreeNode: filterTreeNode,
|
|
822
848
|
popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
|
|
823
849
|
onSelect: (val, option) => {
|
|
824
|
-
onChange(val
|
|
850
|
+
onChange(val);
|
|
825
851
|
const formState = getValues();
|
|
826
852
|
// const itemState = getValues(dataIndex)
|
|
827
853
|
// @ts-ignore
|
|
@@ -48,7 +48,10 @@ const renderValueCell = (column, value, record, rowIndex, colIndex, format, edit
|
|
|
48
48
|
case 'date':
|
|
49
49
|
return value ? (0, _dayjs.default)(value).format(format?.dateFormat ?? 'DD/MM/YYYY') : '';
|
|
50
50
|
case 'time':
|
|
51
|
-
|
|
51
|
+
const timeFormat = format?.timeFormat ?? 'HH:mm';
|
|
52
|
+
const abc = (0, _utils.convertToDate)(value, timeFormat);
|
|
53
|
+
const timeValue = value ? (0, _dayjs.default)(abc).format(timeFormat) : '';
|
|
54
|
+
return timeValue ?? '';
|
|
52
55
|
case 'year':
|
|
53
56
|
const year = value ? (0, _moment.default)(value).format('yyyy') : '';
|
|
54
57
|
return year;
|
|
@@ -37,6 +37,9 @@ export declare const getFormat: (colFormat?: IFormat, format?: IFormat) => {
|
|
|
37
37
|
export declare function convertFormat(formatStr: string): string;
|
|
38
38
|
export declare const getDatepickerFormat: (type: EditType | TypeFilter | IColumnType, format?: IFormat) => string;
|
|
39
39
|
export declare const getDateRangeFormat: (type: EditType | TypeFilter | IColumnType, format?: IFormat) => string;
|
|
40
|
+
export type DateValueType = 'datetime' | 'time' | 'invalid';
|
|
41
|
+
export declare function getDateValueType(value: unknown): DateValueType;
|
|
42
|
+
export declare const convertToDate: (value?: string | Date | null, format?: string) => string;
|
|
40
43
|
export declare const getTypeFilter: (col: any) => TypeFilter;
|
|
41
44
|
export declare const addRowIdArray: (inputArray: any[]) => any[];
|
|
42
45
|
export declare function groupArrayByColumns(arr: any[], columns: string[] | undefined): any;
|
|
@@ -19,7 +19,7 @@ exports.convertArrayWithIndent = void 0;
|
|
|
19
19
|
exports.convertColumnsToTreeData = convertColumnsToTreeData;
|
|
20
20
|
exports.convertFomatedDateToDate = exports.convertFlatColumn1 = exports.convertFilters = exports.convertDayjsToDate = exports.convertDateToDayjs = void 0;
|
|
21
21
|
exports.convertFormat = convertFormat;
|
|
22
|
-
exports.convertToObjTrue = exports.convertToObj = exports.convertLabelToTitle = void 0;
|
|
22
|
+
exports.convertToObjTrue = exports.convertToObj = exports.convertToDate = exports.convertLabelToTitle = void 0;
|
|
23
23
|
exports.countUnselectedChildren = countUnselectedChildren;
|
|
24
24
|
exports.detectSeparators = exports.customWeekStartEndFormat = void 0;
|
|
25
25
|
exports.excludeItems = excludeItems;
|
|
@@ -33,7 +33,9 @@ exports.getAllChildren = getAllChildren;
|
|
|
33
33
|
exports.getAllVisibleKeys1 = exports.getAllVisibleKeys = exports.getAllRowKey = void 0;
|
|
34
34
|
exports.getCellsByPosition = getCellsByPosition;
|
|
35
35
|
exports.getColIdsBetween = getColIdsBetween;
|
|
36
|
-
exports.
|
|
36
|
+
exports.getDateRangeFormat = exports.getCommonPinningStyles2 = exports.getCommonPinningStyles = void 0;
|
|
37
|
+
exports.getDateValueType = getDateValueType;
|
|
38
|
+
exports.getFormat = exports.getFixedFields = exports.getEditType = exports.getDiffent2Array = exports.getDefaultValue = exports.getDefaultOperator = exports.getDatepickerFormat = void 0;
|
|
37
39
|
exports.getHiddenParentKeys = getHiddenParentKeys;
|
|
38
40
|
exports.getHiddenParentKeys1 = getHiddenParentKeys1;
|
|
39
41
|
exports.getInvisibleColumns = getInvisibleColumns;
|
|
@@ -61,8 +63,7 @@ exports.sumFields = sumFields;
|
|
|
61
63
|
exports.sumNumberFields = sumNumberFields;
|
|
62
64
|
exports.sumSize = void 0;
|
|
63
65
|
exports.toggleRowAndChildren = toggleRowAndChildren;
|
|
64
|
-
exports.unFlattenData = void 0;
|
|
65
|
-
exports.updateArrayByKey = void 0;
|
|
66
|
+
exports.updateArrayByKey = exports.unFlattenData = void 0;
|
|
66
67
|
exports.updateColumnWidthsRecursive = updateColumnWidthsRecursive;
|
|
67
68
|
exports.updateColumnsByGroup = exports.updateColumns1 = void 0;
|
|
68
69
|
exports.updateOrInsert = updateOrInsert;
|
|
@@ -253,6 +254,68 @@ const getDateRangeFormat = (type, format) => {
|
|
|
253
254
|
}
|
|
254
255
|
};
|
|
255
256
|
exports.getDateRangeFormat = getDateRangeFormat;
|
|
257
|
+
function getDateValueType(value) {
|
|
258
|
+
if (typeof value !== 'string') {
|
|
259
|
+
return 'invalid';
|
|
260
|
+
}
|
|
261
|
+
const datetimeRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
262
|
+
const timeRegex = /^\d{2}:\d{2}(:\d{2})?$/;
|
|
263
|
+
if (datetimeRegex.test(value)) {
|
|
264
|
+
return 'datetime';
|
|
265
|
+
}
|
|
266
|
+
if (timeRegex.test(value)) {
|
|
267
|
+
return 'time';
|
|
268
|
+
}
|
|
269
|
+
return 'invalid';
|
|
270
|
+
}
|
|
271
|
+
const convertToDate = (value, format) => {
|
|
272
|
+
if (!value) {
|
|
273
|
+
return '';
|
|
274
|
+
}
|
|
275
|
+
const valueType = getDateValueType(value);
|
|
276
|
+
if (valueType === 'time') {
|
|
277
|
+
const date = (0, _dayjs.default)(value, format, true);
|
|
278
|
+
return date.isValid() ? (0, _moment.default)(date.toDate()).format() : '';
|
|
279
|
+
}
|
|
280
|
+
if (valueType === 'datetime') {
|
|
281
|
+
return (0, _moment.default)(value).format() ?? '';
|
|
282
|
+
}
|
|
283
|
+
if (valueType === 'invalid') {
|
|
284
|
+
return '';
|
|
285
|
+
}
|
|
286
|
+
return '';
|
|
287
|
+
|
|
288
|
+
// if (value instanceof Date) {
|
|
289
|
+
// return moment(value).format();
|
|
290
|
+
// }
|
|
291
|
+
|
|
292
|
+
// let date: dayjs.Dayjs;
|
|
293
|
+
|
|
294
|
+
// if (format) {
|
|
295
|
+
// const bbb = moment(value)
|
|
296
|
+
|
|
297
|
+
// if (!bbb.isValid()) {
|
|
298
|
+
|
|
299
|
+
// // value dạng HH:mm
|
|
300
|
+
// date = dayjs(value, format, true);
|
|
301
|
+
|
|
302
|
+
// } else {
|
|
303
|
+
// // value dạng datetime
|
|
304
|
+
|
|
305
|
+
// date = dayjs(bbb.format(format), format, true);
|
|
306
|
+
|
|
307
|
+
// }
|
|
308
|
+
|
|
309
|
+
// } else {
|
|
310
|
+
|
|
311
|
+
// // Tự nhận diện ISO, YYYY-MM-DD,...
|
|
312
|
+
// date = dayjs(value);
|
|
313
|
+
|
|
314
|
+
// }
|
|
315
|
+
|
|
316
|
+
// return date.isValid() ? moment(date.toDate()).format() : null;
|
|
317
|
+
};
|
|
318
|
+
exports.convertToDate = convertToDate;
|
|
256
319
|
const getTypeFilter = col => {
|
|
257
320
|
if (col?.typeFilter) {
|
|
258
321
|
return col.typeFilter;
|