es-grid-template 1.9.99 → 1.9.101
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/base-table/cell/EditCell.js +2 -58
- package/es/ali-table/base-table/cell/HeaderEditCell.js +2 -58
- package/es/grid-component/type.d.ts +1 -1
- package/es/group-component/body/EditableCell.js +2 -58
- package/es/group-component/body/TableBody.js +4 -0
- package/es/group-component/body/TableBodyCellEdit.js +5 -4
- package/es/group-component/body/TableBodyRow.js +7 -3
- package/es/group-component/components/async-table-select/index.d.ts +2 -11
- package/es/group-component/components/async-table-select/index.js +1 -40
- package/es/table-component/body/EditableCell.js +2 -58
- package/es/table-component/body/TableBodyCellEdit.js +5 -4
- package/es/table-component/body/TableBodyRow.js +1 -2
- package/es/table-component/components/async-table-select/index.d.ts +2 -1
- package/es/table-component/components/async-table-select/index.js +39 -3
- package/lib/ali-table/base-table/cell/EditCell.js +2 -58
- package/lib/ali-table/base-table/cell/HeaderEditCell.js +2 -58
- package/lib/grid-component/type.d.ts +1 -1
- package/lib/group-component/body/EditableCell.js +2 -58
- package/lib/group-component/body/TableBody.js +4 -0
- package/lib/group-component/body/TableBodyCellEdit.js +5 -4
- package/lib/group-component/body/TableBodyRow.js +7 -3
- package/lib/group-component/components/async-table-select/index.d.ts +2 -11
- package/lib/group-component/components/async-table-select/index.js +7 -44
- package/lib/table-component/body/EditableCell.js +2 -58
- package/lib/table-component/body/TableBodyCellEdit.js +5 -4
- package/lib/table-component/body/TableBodyRow.js +1 -2
- package/lib/table-component/components/async-table-select/index.d.ts +2 -1
- package/lib/table-component/components/async-table-select/index.js +38 -2
- package/package.json +1 -1
|
@@ -558,64 +558,8 @@ const EditCell = props => {
|
|
|
558
558
|
fieldNames: fieldNames ? fieldNames : {
|
|
559
559
|
value: keySelect,
|
|
560
560
|
label: inputKey ?? 'label'
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
// onBlur={(event: any) => {
|
|
564
|
-
|
|
565
|
-
// if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
566
|
-
// const val = event.inputValue
|
|
567
|
-
// onChange(val ?? undefined)
|
|
568
|
-
|
|
569
|
-
// const formState = getValues()
|
|
570
|
-
// // const itemState = getValues(dataIndex)
|
|
571
|
-
// // @ts-ignore
|
|
572
|
-
// const prevState = record[dataIndex]
|
|
573
|
-
// const newState = val
|
|
574
|
-
|
|
575
|
-
// handleCellChange?.({
|
|
576
|
-
// key,
|
|
577
|
-
// field: column.field ?? column.field as any,
|
|
578
|
-
// record: formState,
|
|
579
|
-
// prevState,
|
|
580
|
-
// newState,
|
|
581
|
-
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
582
|
-
// indexCol,
|
|
583
|
-
// indexRow,
|
|
584
|
-
// type: 'blur'
|
|
585
|
-
// })
|
|
586
|
-
// }
|
|
587
|
-
// }}
|
|
588
|
-
|
|
589
|
-
// onKeyDown={(event: any) => {
|
|
590
|
-
|
|
591
|
-
// if (event.key === 'Enter' && event.target?.value && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
592
|
-
|
|
593
|
-
// const val = event.target.value
|
|
594
|
-
// onChange(val)
|
|
595
|
-
|
|
596
|
-
// const formState = getValues()
|
|
597
|
-
// // const itemState = getValues(dataIndex)
|
|
598
|
-
// // @ts-ignore
|
|
599
|
-
// const prevState = record[dataIndex]
|
|
600
|
-
// const newState = val
|
|
601
|
-
|
|
602
|
-
// handleCellChange?.({
|
|
603
|
-
// key,
|
|
604
|
-
// field: column.field ?? column.field as any,
|
|
605
|
-
// record: formState,
|
|
606
|
-
// prevState,
|
|
607
|
-
// newState,
|
|
608
|
-
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
609
|
-
// indexCol,
|
|
610
|
-
// indexRow,
|
|
611
|
-
// type: 'blur'
|
|
612
|
-
// })
|
|
613
|
-
|
|
614
|
-
// }
|
|
615
|
-
|
|
616
|
-
// }}
|
|
617
|
-
,
|
|
618
|
-
|
|
561
|
+
},
|
|
562
|
+
searchTextAsValue: column.editSelectSettings?.searchTextAsValue,
|
|
619
563
|
"data-tooltip-content": message,
|
|
620
564
|
"data-tooltip-id": `${tableId}-tooltip-error`
|
|
621
565
|
});
|
|
@@ -556,64 +556,8 @@ const HeaderEditCell = props => {
|
|
|
556
556
|
fieldNames: fieldNames ? fieldNames : {
|
|
557
557
|
value: keySelect,
|
|
558
558
|
label: inputKey ?? 'label'
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
// onBlur={(event: any) => {
|
|
562
|
-
|
|
563
|
-
// if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
564
|
-
// const val = event.inputValue
|
|
565
|
-
// onChange(val ?? undefined)
|
|
566
|
-
|
|
567
|
-
// const formState = getValues()
|
|
568
|
-
// // const itemState = getValues(dataIndex)
|
|
569
|
-
// // @ts-ignore
|
|
570
|
-
// const prevState = record[dataIndex]
|
|
571
|
-
// const newState = val
|
|
572
|
-
|
|
573
|
-
// handleCellChange?.({
|
|
574
|
-
// key,
|
|
575
|
-
// field: column.field ?? column.field as any,
|
|
576
|
-
// record: formState,
|
|
577
|
-
// prevState,
|
|
578
|
-
// newState,
|
|
579
|
-
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
580
|
-
// indexCol,
|
|
581
|
-
// indexRow,
|
|
582
|
-
// type: 'blur'
|
|
583
|
-
// })
|
|
584
|
-
// }
|
|
585
|
-
// }}
|
|
586
|
-
|
|
587
|
-
// onKeyDown={(event: any) => {
|
|
588
|
-
|
|
589
|
-
// if (event.key === 'Enter' && event.target?.value && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
590
|
-
|
|
591
|
-
// const val = event.target.value
|
|
592
|
-
// onChange(val)
|
|
593
|
-
|
|
594
|
-
// const formState = getValues()
|
|
595
|
-
// // const itemState = getValues(dataIndex)
|
|
596
|
-
// // @ts-ignore
|
|
597
|
-
// const prevState = record[dataIndex]
|
|
598
|
-
// const newState = val
|
|
599
|
-
|
|
600
|
-
// handleCellChange?.({
|
|
601
|
-
// key,
|
|
602
|
-
// field: column.field ?? column.field as any,
|
|
603
|
-
// record: formState,
|
|
604
|
-
// prevState,
|
|
605
|
-
// newState,
|
|
606
|
-
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
607
|
-
// indexCol,
|
|
608
|
-
// indexRow,
|
|
609
|
-
// type: 'blur'
|
|
610
|
-
// })
|
|
611
|
-
|
|
612
|
-
// }
|
|
613
|
-
|
|
614
|
-
// }}
|
|
615
|
-
,
|
|
616
|
-
|
|
559
|
+
},
|
|
560
|
+
searchTextAsValue: column.editSelectSettings?.searchTextAsValue,
|
|
617
561
|
"data-tooltip-content": message,
|
|
618
562
|
"data-tooltip-id": `${tableId}-tooltip-error`
|
|
619
563
|
});
|
|
@@ -614,7 +614,7 @@ export type IEditSelectSettings = {
|
|
|
614
614
|
fieldValue?: string;
|
|
615
615
|
/** get label form other field **/
|
|
616
616
|
fieldLabel?: string;
|
|
617
|
-
/**
|
|
617
|
+
/** Lưu nội dung tìm kiếm làm giá trị khi rời ô chọn đơn. `select` và `selectTable` cũng hỗ trợ Enter. */
|
|
618
618
|
searchTextAsValue?: boolean;
|
|
619
619
|
filterKey?: string[];
|
|
620
620
|
selectMode?: SelectMode;
|
|
@@ -556,64 +556,8 @@ const EditableCell = props => {
|
|
|
556
556
|
fieldNames: fieldNames ? fieldNames : {
|
|
557
557
|
value: keySelect,
|
|
558
558
|
label: inputKey ?? 'label'
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
// onBlur={(event: any) => {
|
|
562
|
-
|
|
563
|
-
// if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
564
|
-
// const val = event.inputValue
|
|
565
|
-
// onChange(val ?? undefined)
|
|
566
|
-
|
|
567
|
-
// const formState = getValues()
|
|
568
|
-
// // const itemState = getValues(dataIndex)
|
|
569
|
-
// // @ts-ignore
|
|
570
|
-
// const prevState = record[dataIndex]
|
|
571
|
-
// const newState = val
|
|
572
|
-
|
|
573
|
-
// handleCellChange?.({
|
|
574
|
-
// key,
|
|
575
|
-
// field: column.field ?? column.field as any,
|
|
576
|
-
// record: formState,
|
|
577
|
-
// prevState,
|
|
578
|
-
// newState,
|
|
579
|
-
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
580
|
-
// indexCol,
|
|
581
|
-
// indexRow,
|
|
582
|
-
// type: 'blur'
|
|
583
|
-
// })
|
|
584
|
-
// }
|
|
585
|
-
// }}
|
|
586
|
-
|
|
587
|
-
// onKeyDown={(event: any) => {
|
|
588
|
-
|
|
589
|
-
// if (event.key === 'Enter' && event.target?.value && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
590
|
-
|
|
591
|
-
// const val = event.target.value
|
|
592
|
-
// onChange(val)
|
|
593
|
-
|
|
594
|
-
// const formState = getValues()
|
|
595
|
-
// // const itemState = getValues(dataIndex)
|
|
596
|
-
// // @ts-ignore
|
|
597
|
-
// const prevState = record[dataIndex]
|
|
598
|
-
// const newState = val
|
|
599
|
-
|
|
600
|
-
// handleCellChange?.({
|
|
601
|
-
// key,
|
|
602
|
-
// field: column.field ?? column.field as any,
|
|
603
|
-
// record: formState,
|
|
604
|
-
// prevState,
|
|
605
|
-
// newState,
|
|
606
|
-
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
607
|
-
// indexCol,
|
|
608
|
-
// indexRow,
|
|
609
|
-
// type: 'blur'
|
|
610
|
-
// })
|
|
611
|
-
|
|
612
|
-
// }
|
|
613
|
-
|
|
614
|
-
// }}
|
|
615
|
-
,
|
|
616
|
-
|
|
559
|
+
},
|
|
560
|
+
searchTextAsValue: column.editSelectSettings?.searchTextAsValue,
|
|
617
561
|
"data-tooltip-content": message,
|
|
618
562
|
"data-tooltip-id": `${id}-tooltip-error`
|
|
619
563
|
});
|
|
@@ -27,9 +27,13 @@ const TableBody = ({
|
|
|
27
27
|
locale
|
|
28
28
|
} = React.useContext(TableContext);
|
|
29
29
|
|
|
30
|
+
// Keep measured heights attached to records when expanding, sorting or filtering.
|
|
31
|
+
const getItemKey = React.useCallback(index => rows[index].id, [rows]);
|
|
32
|
+
|
|
30
33
|
//dynamic row height virtualization - alternatively you could use a simpler fixed row height strategy without the need for `measureElement`
|
|
31
34
|
const rowVirtualizer = useVirtualizer({
|
|
32
35
|
count: rows.length,
|
|
36
|
+
getItemKey,
|
|
33
37
|
estimateSize: () => 36,
|
|
34
38
|
//estimate row height for accurate scrollbar dragging
|
|
35
39
|
getScrollElement: () => tableContainerRef.current,
|
|
@@ -930,7 +930,7 @@ const TableBodyCellEdit = props => {
|
|
|
930
930
|
}),
|
|
931
931
|
style: {
|
|
932
932
|
display: 'flex',
|
|
933
|
-
|
|
933
|
+
minHeight: 36,
|
|
934
934
|
userSelect: 'none',
|
|
935
935
|
width: cell.column.getSize(),
|
|
936
936
|
// flexBasis: cell.column.getSize(),
|
|
@@ -1019,7 +1019,7 @@ const TableBodyCellEdit = props => {
|
|
|
1019
1019
|
}),
|
|
1020
1020
|
style: {
|
|
1021
1021
|
display: 'flex',
|
|
1022
|
-
|
|
1022
|
+
minHeight: 36,
|
|
1023
1023
|
width: cell.column.getSize(),
|
|
1024
1024
|
minWidth: cell.column.getSize(),
|
|
1025
1025
|
// flex: 1,
|
|
@@ -1045,7 +1045,7 @@ const TableBodyCellEdit = props => {
|
|
|
1045
1045
|
}),
|
|
1046
1046
|
style: {
|
|
1047
1047
|
display: 'flex',
|
|
1048
|
-
|
|
1048
|
+
minHeight: 36,
|
|
1049
1049
|
width: cell.column.getSize(),
|
|
1050
1050
|
minWidth: cell.column.getSize(),
|
|
1051
1051
|
// flex: 1,
|
|
@@ -1186,7 +1186,8 @@ const TableBodyCellEdit = props => {
|
|
|
1186
1186
|
minWidth: cell.column.getSize(),
|
|
1187
1187
|
// flex: 1,
|
|
1188
1188
|
// maxWidth: cell.column.getSize(),
|
|
1189
|
-
height:
|
|
1189
|
+
height: isEditing && canEdit ? 36 : undefined,
|
|
1190
|
+
minHeight: 36,
|
|
1190
1191
|
...getCommonPinningStyles(cell.column),
|
|
1191
1192
|
cursor: isPasting ? 'crosshair' : undefined
|
|
1192
1193
|
},
|
|
@@ -55,10 +55,15 @@ const TableBodyRow = ({
|
|
|
55
55
|
const rowClass = typeof rowClassName === 'function' ? rowClassName(row.original, row.index, row.depth) : rowClassName;
|
|
56
56
|
const rowStyles = typeof onRowStyles === 'function' ? onRowStyles(row.original, row) : onRowStyles;
|
|
57
57
|
const isRowEditable = rowEditable ? rowEditable(row.original) : true;
|
|
58
|
+
|
|
59
|
+
// A reused DOM row needs measuring again when its virtual index changes.
|
|
60
|
+
const measureRow = React.useCallback(element => {
|
|
61
|
+
rowVirtualizer.measureElement(element);
|
|
62
|
+
}, [rowVirtualizer, virtualRow.index]);
|
|
58
63
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
59
64
|
"data-index": virtualRow.index //needed for dynamic row height measurement
|
|
60
65
|
,
|
|
61
|
-
ref:
|
|
66
|
+
ref: measureRow //measure dynamic row height
|
|
62
67
|
,
|
|
63
68
|
key: row.id,
|
|
64
69
|
"data-row-key": row.id,
|
|
@@ -78,8 +83,7 @@ const TableBodyRow = ({
|
|
|
78
83
|
//this should always be a `style` as it changes on scroll
|
|
79
84
|
// height: isEditing ? '36px' : undefined,
|
|
80
85
|
gridTemplateColumns: `${templateColumns.map(n => `${n}fr`).join(" ")}`,
|
|
81
|
-
|
|
82
|
-
minHeight: isEditing ? undefined : virtualRow.size,
|
|
86
|
+
minHeight: isEditing ? virtualRow.size : 36,
|
|
83
87
|
...rowStyles
|
|
84
88
|
}
|
|
85
89
|
}, getRowFocusHandlers(row.original, rowFocus), {
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { TableSelectProps } from "rc-master-ui";
|
|
4
|
-
import type { LoadOptionsArgs } from '../../../grid-component/type';
|
|
5
|
-
export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends TableSelectProps {
|
|
6
|
-
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
|
|
7
|
-
debounceTimeout?: number;
|
|
8
|
-
defaultOptions?: OptionType[];
|
|
9
|
-
rowData?: any;
|
|
10
|
-
}
|
|
11
|
-
export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, rowData, ...props }: DebounceSelectProps<OptionType>): JSX.Element;
|
|
1
|
+
export { AsyncTableSelect } from '../../../table-component/components/async-table-select';
|
|
2
|
+
export type { DebounceSelectProps } from '../../../table-component/components/async-table-select';
|
|
@@ -1,40 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
3
|
-
import debounce from 'lodash/debounce';
|
|
4
|
-
import { TableSelect } from "rc-master-ui";
|
|
5
|
-
export function AsyncTableSelect({
|
|
6
|
-
loadOptions,
|
|
7
|
-
debounceTimeout = 500,
|
|
8
|
-
defaultOptions,
|
|
9
|
-
columns,
|
|
10
|
-
rowData,
|
|
11
|
-
...props
|
|
12
|
-
}) {
|
|
13
|
-
const [options, setOptions] = useState(defaultOptions ?? []);
|
|
14
|
-
const debounceFetcher = useMemo(() => {
|
|
15
|
-
const fetchOptions = value => {
|
|
16
|
-
if (value.trim().length === 0) {
|
|
17
|
-
setOptions(defaultOptions ?? []);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (loadOptions) {
|
|
21
|
-
loadOptions(value, newOptions => {
|
|
22
|
-
setOptions(newOptions);
|
|
23
|
-
}, {
|
|
24
|
-
rowData
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
return debounce(fetchOptions, debounceTimeout);
|
|
29
|
-
}, [debounceTimeout, loadOptions, defaultOptions, rowData]);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
setOptions(defaultOptions ?? []);
|
|
32
|
-
}, [defaultOptions]);
|
|
33
|
-
return /*#__PURE__*/React.createElement(TableSelect, _extends({}, props, {
|
|
34
|
-
filterOption: loadOptions ? false : props?.filterOption,
|
|
35
|
-
onSearch: debounceFetcher,
|
|
36
|
-
onSelect: () => setOptions(defaultOptions ?? []),
|
|
37
|
-
options: options,
|
|
38
|
-
columns: columns
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
1
|
+
export { AsyncTableSelect } from "../../../table-component/components/async-table-select";
|
|
@@ -558,64 +558,8 @@ const EditableCell = props => {
|
|
|
558
558
|
fieldNames: fieldNames ? fieldNames : {
|
|
559
559
|
value: keySelect,
|
|
560
560
|
label: inputKey ?? 'label'
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
// onBlur={(event: any) => {
|
|
564
|
-
|
|
565
|
-
// if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
566
|
-
// const val = event.inputValue
|
|
567
|
-
// onChange(val ?? undefined)
|
|
568
|
-
|
|
569
|
-
// const formState = getValues()
|
|
570
|
-
// // const itemState = getValues(dataIndex)
|
|
571
|
-
// // @ts-ignore
|
|
572
|
-
// const prevState = record[dataIndex]
|
|
573
|
-
// const newState = val
|
|
574
|
-
|
|
575
|
-
// handleCellChange?.({
|
|
576
|
-
// key,
|
|
577
|
-
// field: column.field ?? column.field as any,
|
|
578
|
-
// record: formState,
|
|
579
|
-
// prevState,
|
|
580
|
-
// newState,
|
|
581
|
-
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
582
|
-
// indexCol,
|
|
583
|
-
// indexRow,
|
|
584
|
-
// type: 'blur'
|
|
585
|
-
// })
|
|
586
|
-
// }
|
|
587
|
-
// }}
|
|
588
|
-
|
|
589
|
-
// onKeyDown={(event: any) => {
|
|
590
|
-
|
|
591
|
-
// if (event.key === 'Enter' && event.target?.value && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
592
|
-
|
|
593
|
-
// const val = event.target.value
|
|
594
|
-
// onChange(val)
|
|
595
|
-
|
|
596
|
-
// const formState = getValues()
|
|
597
|
-
// // const itemState = getValues(dataIndex)
|
|
598
|
-
// // @ts-ignore
|
|
599
|
-
// const prevState = record[dataIndex]
|
|
600
|
-
// const newState = val
|
|
601
|
-
|
|
602
|
-
// handleCellChange?.({
|
|
603
|
-
// key,
|
|
604
|
-
// field: column.field ?? column.field as any,
|
|
605
|
-
// record: formState,
|
|
606
|
-
// prevState,
|
|
607
|
-
// newState,
|
|
608
|
-
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
609
|
-
// indexCol,
|
|
610
|
-
// indexRow,
|
|
611
|
-
// type: 'blur'
|
|
612
|
-
// })
|
|
613
|
-
|
|
614
|
-
// }
|
|
615
|
-
|
|
616
|
-
// }}
|
|
617
|
-
,
|
|
618
|
-
|
|
561
|
+
},
|
|
562
|
+
searchTextAsValue: column.editSelectSettings?.searchTextAsValue,
|
|
619
563
|
"data-tooltip-content": message,
|
|
620
564
|
"data-tooltip-id": `${id}-tooltip-error`
|
|
621
565
|
});
|
|
@@ -958,7 +958,7 @@ const TableBodyCellEdit = props => {
|
|
|
958
958
|
}),
|
|
959
959
|
style: {
|
|
960
960
|
display: 'flex',
|
|
961
|
-
|
|
961
|
+
minHeight: 32,
|
|
962
962
|
userSelect: 'none',
|
|
963
963
|
width: cell.column.getSize(),
|
|
964
964
|
// flexBasis: cell.column.getSize(),
|
|
@@ -1047,7 +1047,7 @@ const TableBodyCellEdit = props => {
|
|
|
1047
1047
|
}),
|
|
1048
1048
|
style: {
|
|
1049
1049
|
display: 'flex',
|
|
1050
|
-
|
|
1050
|
+
minHeight: 32,
|
|
1051
1051
|
width: cell.column.getSize(),
|
|
1052
1052
|
minWidth: cell.column.getSize(),
|
|
1053
1053
|
// flex: 1,
|
|
@@ -1073,7 +1073,7 @@ const TableBodyCellEdit = props => {
|
|
|
1073
1073
|
}),
|
|
1074
1074
|
style: {
|
|
1075
1075
|
display: 'flex',
|
|
1076
|
-
|
|
1076
|
+
minHeight: 32,
|
|
1077
1077
|
width: cell.column.getSize(),
|
|
1078
1078
|
minWidth: cell.column.getSize(),
|
|
1079
1079
|
// flex: 1,
|
|
@@ -1283,7 +1283,8 @@ const TableBodyCellEdit = props => {
|
|
|
1283
1283
|
minWidth: cell.column.getSize(),
|
|
1284
1284
|
// flex: 1,
|
|
1285
1285
|
// maxWidth: cell.column.getSize(),
|
|
1286
|
-
height:
|
|
1286
|
+
height: isEditing && canEdit ? 32 : undefined,
|
|
1287
|
+
minHeight: 32,
|
|
1287
1288
|
...getCommonPinningStyles(cell.column),
|
|
1288
1289
|
cursor: isPasting ? 'crosshair' : undefined
|
|
1289
1290
|
},
|
|
@@ -84,8 +84,7 @@ const TableBodyRow = ({
|
|
|
84
84
|
transform: `translateY(${virtualRow.start}px)`,
|
|
85
85
|
//this should always be a `style` as it changes on scroll
|
|
86
86
|
gridTemplateColumns: `${templateColumns.map(n => `${n}fr`).join(" ")}`,
|
|
87
|
-
|
|
88
|
-
minHeight: isEditing ? undefined : virtualRow.size,
|
|
87
|
+
minHeight: isEditing ? virtualRow.size : 32,
|
|
89
88
|
...rowStyles
|
|
90
89
|
}
|
|
91
90
|
}, getRowFocusHandlers(row.original, rowFocus), {
|
|
@@ -7,5 +7,6 @@ export interface DebounceSelectProps<OptionType extends BaseOptionType = Default
|
|
|
7
7
|
debounceTimeout?: number;
|
|
8
8
|
defaultOptions?: OptionType[];
|
|
9
9
|
rowData?: any;
|
|
10
|
+
searchTextAsValue?: boolean;
|
|
10
11
|
}
|
|
11
|
-
export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, rowData, ...props }: DebounceSelectProps<OptionType>): JSX.Element;
|
|
12
|
+
export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, rowData, searchTextAsValue, ...props }: DebounceSelectProps<OptionType>): JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import debounce from 'lodash/debounce';
|
|
4
4
|
import { TableSelect } from "rc-master-ui";
|
|
5
5
|
export function AsyncTableSelect({
|
|
@@ -8,9 +8,12 @@ export function AsyncTableSelect({
|
|
|
8
8
|
defaultOptions,
|
|
9
9
|
columns,
|
|
10
10
|
rowData,
|
|
11
|
+
searchTextAsValue,
|
|
11
12
|
...props
|
|
12
13
|
}) {
|
|
13
14
|
const [options, setOptions] = useState(defaultOptions ?? []);
|
|
15
|
+
const searchText = useRef('');
|
|
16
|
+
const allowSearchText = searchTextAsValue && !props.mode && props.selectMode !== 'checkbox';
|
|
14
17
|
const debounceFetcher = useMemo(() => {
|
|
15
18
|
const fetchOptions = value => {
|
|
16
19
|
if (value.trim().length === 0) {
|
|
@@ -32,8 +35,41 @@ export function AsyncTableSelect({
|
|
|
32
35
|
}, [defaultOptions]);
|
|
33
36
|
return /*#__PURE__*/React.createElement(TableSelect, _extends({}, props, {
|
|
34
37
|
filterOption: loadOptions ? false : props?.filterOption,
|
|
35
|
-
onSearch:
|
|
36
|
-
|
|
38
|
+
onSearch: value => {
|
|
39
|
+
searchText.current = value;
|
|
40
|
+
debounceFetcher(value);
|
|
41
|
+
},
|
|
42
|
+
onChange: (value, option) => {
|
|
43
|
+
searchText.current = '';
|
|
44
|
+
props.onChange?.(value, option);
|
|
45
|
+
},
|
|
46
|
+
onSelect: () => {
|
|
47
|
+
searchText.current = '';
|
|
48
|
+
setOptions(defaultOptions ?? []);
|
|
49
|
+
},
|
|
50
|
+
onBlur: event => {
|
|
51
|
+
const value = searchText.current;
|
|
52
|
+
searchText.current = '';
|
|
53
|
+
if (allowSearchText && value) {
|
|
54
|
+
props.onChange?.(value, {
|
|
55
|
+
value,
|
|
56
|
+
label: value,
|
|
57
|
+
searchTextAsValue: true
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
props.onBlur?.(event);
|
|
61
|
+
},
|
|
62
|
+
onInputKeyDown: event => {
|
|
63
|
+
props.onInputKeyDown?.(event);
|
|
64
|
+
if (!allowSearchText || event.key !== 'Enter' || !searchText.current) return;
|
|
65
|
+
|
|
66
|
+
// Stop Enter before the dropdown selects the active row or the grid saves again.
|
|
67
|
+
event.stopPropagation();
|
|
68
|
+
if (!event.nativeEvent.isComposing && event.keyCode !== 229) {
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
event.currentTarget.blur();
|
|
71
|
+
}
|
|
72
|
+
},
|
|
37
73
|
options: options,
|
|
38
74
|
columns: columns
|
|
39
75
|
}));
|
|
@@ -565,64 +565,8 @@ const EditCell = props => {
|
|
|
565
565
|
fieldNames: fieldNames ? fieldNames : {
|
|
566
566
|
value: keySelect,
|
|
567
567
|
label: inputKey ?? 'label'
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
// onBlur={(event: any) => {
|
|
571
|
-
|
|
572
|
-
// if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
573
|
-
// const val = event.inputValue
|
|
574
|
-
// onChange(val ?? undefined)
|
|
575
|
-
|
|
576
|
-
// const formState = getValues()
|
|
577
|
-
// // const itemState = getValues(dataIndex)
|
|
578
|
-
// // @ts-ignore
|
|
579
|
-
// const prevState = record[dataIndex]
|
|
580
|
-
// const newState = val
|
|
581
|
-
|
|
582
|
-
// handleCellChange?.({
|
|
583
|
-
// key,
|
|
584
|
-
// field: column.field ?? column.field as any,
|
|
585
|
-
// record: formState,
|
|
586
|
-
// prevState,
|
|
587
|
-
// newState,
|
|
588
|
-
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
589
|
-
// indexCol,
|
|
590
|
-
// indexRow,
|
|
591
|
-
// type: 'blur'
|
|
592
|
-
// })
|
|
593
|
-
// }
|
|
594
|
-
// }}
|
|
595
|
-
|
|
596
|
-
// onKeyDown={(event: any) => {
|
|
597
|
-
|
|
598
|
-
// if (event.key === 'Enter' && event.target?.value && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
599
|
-
|
|
600
|
-
// const val = event.target.value
|
|
601
|
-
// onChange(val)
|
|
602
|
-
|
|
603
|
-
// const formState = getValues()
|
|
604
|
-
// // const itemState = getValues(dataIndex)
|
|
605
|
-
// // @ts-ignore
|
|
606
|
-
// const prevState = record[dataIndex]
|
|
607
|
-
// const newState = val
|
|
608
|
-
|
|
609
|
-
// handleCellChange?.({
|
|
610
|
-
// key,
|
|
611
|
-
// field: column.field ?? column.field as any,
|
|
612
|
-
// record: formState,
|
|
613
|
-
// prevState,
|
|
614
|
-
// newState,
|
|
615
|
-
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
616
|
-
// indexCol,
|
|
617
|
-
// indexRow,
|
|
618
|
-
// type: 'blur'
|
|
619
|
-
// })
|
|
620
|
-
|
|
621
|
-
// }
|
|
622
|
-
|
|
623
|
-
// }}
|
|
624
|
-
,
|
|
625
|
-
|
|
568
|
+
},
|
|
569
|
+
searchTextAsValue: column.editSelectSettings?.searchTextAsValue,
|
|
626
570
|
"data-tooltip-content": message,
|
|
627
571
|
"data-tooltip-id": `${tableId}-tooltip-error`
|
|
628
572
|
});
|
|
@@ -563,64 +563,8 @@ const HeaderEditCell = props => {
|
|
|
563
563
|
fieldNames: fieldNames ? fieldNames : {
|
|
564
564
|
value: keySelect,
|
|
565
565
|
label: inputKey ?? 'label'
|
|
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
|
-
|
|
566
|
+
},
|
|
567
|
+
searchTextAsValue: column.editSelectSettings?.searchTextAsValue,
|
|
624
568
|
"data-tooltip-content": message,
|
|
625
569
|
"data-tooltip-id": `${tableId}-tooltip-error`
|
|
626
570
|
});
|
|
@@ -614,7 +614,7 @@ export type IEditSelectSettings = {
|
|
|
614
614
|
fieldValue?: string;
|
|
615
615
|
/** get label form other field **/
|
|
616
616
|
fieldLabel?: string;
|
|
617
|
-
/**
|
|
617
|
+
/** Lưu nội dung tìm kiếm làm giá trị khi rời ô chọn đơn. `select` và `selectTable` cũng hỗ trợ Enter. */
|
|
618
618
|
searchTextAsValue?: boolean;
|
|
619
619
|
filterKey?: string[];
|
|
620
620
|
selectMode?: SelectMode;
|
|
@@ -563,64 +563,8 @@ const EditableCell = props => {
|
|
|
563
563
|
fieldNames: fieldNames ? fieldNames : {
|
|
564
564
|
value: keySelect,
|
|
565
565
|
label: inputKey ?? 'label'
|
|
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
|
-
|
|
566
|
+
},
|
|
567
|
+
searchTextAsValue: column.editSelectSettings?.searchTextAsValue,
|
|
624
568
|
"data-tooltip-content": message,
|
|
625
569
|
"data-tooltip-id": `${id}-tooltip-error`
|
|
626
570
|
});
|
|
@@ -36,9 +36,13 @@ const TableBody = ({
|
|
|
36
36
|
locale
|
|
37
37
|
} = _react.default.useContext(_useContext.TableContext);
|
|
38
38
|
|
|
39
|
+
// Keep measured heights attached to records when expanding, sorting or filtering.
|
|
40
|
+
const getItemKey = _react.default.useCallback(index => rows[index].id, [rows]);
|
|
41
|
+
|
|
39
42
|
//dynamic row height virtualization - alternatively you could use a simpler fixed row height strategy without the need for `measureElement`
|
|
40
43
|
const rowVirtualizer = (0, _reactVirtual.useVirtualizer)({
|
|
41
44
|
count: rows.length,
|
|
45
|
+
getItemKey,
|
|
42
46
|
estimateSize: () => 36,
|
|
43
47
|
//estimate row height for accurate scrollbar dragging
|
|
44
48
|
getScrollElement: () => tableContainerRef.current,
|
|
@@ -937,7 +937,7 @@ const TableBodyCellEdit = props => {
|
|
|
937
937
|
}),
|
|
938
938
|
style: {
|
|
939
939
|
display: 'flex',
|
|
940
|
-
|
|
940
|
+
minHeight: 36,
|
|
941
941
|
userSelect: 'none',
|
|
942
942
|
width: cell.column.getSize(),
|
|
943
943
|
// flexBasis: cell.column.getSize(),
|
|
@@ -1026,7 +1026,7 @@ const TableBodyCellEdit = props => {
|
|
|
1026
1026
|
}),
|
|
1027
1027
|
style: {
|
|
1028
1028
|
display: 'flex',
|
|
1029
|
-
|
|
1029
|
+
minHeight: 36,
|
|
1030
1030
|
width: cell.column.getSize(),
|
|
1031
1031
|
minWidth: cell.column.getSize(),
|
|
1032
1032
|
// flex: 1,
|
|
@@ -1052,7 +1052,7 @@ const TableBodyCellEdit = props => {
|
|
|
1052
1052
|
}),
|
|
1053
1053
|
style: {
|
|
1054
1054
|
display: 'flex',
|
|
1055
|
-
|
|
1055
|
+
minHeight: 36,
|
|
1056
1056
|
width: cell.column.getSize(),
|
|
1057
1057
|
minWidth: cell.column.getSize(),
|
|
1058
1058
|
// flex: 1,
|
|
@@ -1193,7 +1193,8 @@ const TableBodyCellEdit = props => {
|
|
|
1193
1193
|
minWidth: cell.column.getSize(),
|
|
1194
1194
|
// flex: 1,
|
|
1195
1195
|
// maxWidth: cell.column.getSize(),
|
|
1196
|
-
height:
|
|
1196
|
+
height: isEditing && canEdit ? 36 : undefined,
|
|
1197
|
+
minHeight: 36,
|
|
1197
1198
|
...(0, _utils.getCommonPinningStyles)(cell.column),
|
|
1198
1199
|
cursor: isPasting ? 'crosshair' : undefined
|
|
1199
1200
|
},
|
|
@@ -62,10 +62,15 @@ const TableBodyRow = ({
|
|
|
62
62
|
const rowClass = typeof rowClassName === 'function' ? rowClassName(row.original, row.index, row.depth) : rowClassName;
|
|
63
63
|
const rowStyles = typeof onRowStyles === 'function' ? onRowStyles(row.original, row) : onRowStyles;
|
|
64
64
|
const isRowEditable = rowEditable ? rowEditable(row.original) : true;
|
|
65
|
+
|
|
66
|
+
// A reused DOM row needs measuring again when its virtual index changes.
|
|
67
|
+
const measureRow = _react.default.useCallback(element => {
|
|
68
|
+
rowVirtualizer.measureElement(element);
|
|
69
|
+
}, [rowVirtualizer, virtualRow.index]);
|
|
65
70
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
66
71
|
"data-index": virtualRow.index //needed for dynamic row height measurement
|
|
67
72
|
,
|
|
68
|
-
ref:
|
|
73
|
+
ref: measureRow //measure dynamic row height
|
|
69
74
|
,
|
|
70
75
|
key: row.id,
|
|
71
76
|
"data-row-key": row.id,
|
|
@@ -85,8 +90,7 @@ const TableBodyRow = ({
|
|
|
85
90
|
//this should always be a `style` as it changes on scroll
|
|
86
91
|
// height: isEditing ? '36px' : undefined,
|
|
87
92
|
gridTemplateColumns: `${templateColumns.map(n => `${n}fr`).join(" ")}`,
|
|
88
|
-
|
|
89
|
-
minHeight: isEditing ? undefined : virtualRow.size,
|
|
93
|
+
minHeight: isEditing ? virtualRow.size : 36,
|
|
90
94
|
...rowStyles
|
|
91
95
|
}
|
|
92
96
|
}, (0, _rowFocus.getRowFocusHandlers)(row.original, rowFocus), {
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { TableSelectProps } from "rc-master-ui";
|
|
4
|
-
import type { LoadOptionsArgs } from '../../../grid-component/type';
|
|
5
|
-
export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends TableSelectProps {
|
|
6
|
-
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
|
|
7
|
-
debounceTimeout?: number;
|
|
8
|
-
defaultOptions?: OptionType[];
|
|
9
|
-
rowData?: any;
|
|
10
|
-
}
|
|
11
|
-
export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, rowData, ...props }: DebounceSelectProps<OptionType>): JSX.Element;
|
|
1
|
+
export { AsyncTableSelect } from '../../../table-component/components/async-table-select';
|
|
2
|
+
export type { DebounceSelectProps } from '../../../table-component/components/async-table-select';
|
|
@@ -1,49 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function AsyncTableSelect({
|
|
15
|
-
loadOptions,
|
|
16
|
-
debounceTimeout = 500,
|
|
17
|
-
defaultOptions,
|
|
18
|
-
columns,
|
|
19
|
-
rowData,
|
|
20
|
-
...props
|
|
21
|
-
}) {
|
|
22
|
-
const [options, setOptions] = (0, _react.useState)(defaultOptions ?? []);
|
|
23
|
-
const debounceFetcher = (0, _react.useMemo)(() => {
|
|
24
|
-
const fetchOptions = value => {
|
|
25
|
-
if (value.trim().length === 0) {
|
|
26
|
-
setOptions(defaultOptions ?? []);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (loadOptions) {
|
|
30
|
-
loadOptions(value, newOptions => {
|
|
31
|
-
setOptions(newOptions);
|
|
32
|
-
}, {
|
|
33
|
-
rowData
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
return (0, _debounce.default)(fetchOptions, debounceTimeout);
|
|
38
|
-
}, [debounceTimeout, loadOptions, defaultOptions, rowData]);
|
|
39
|
-
(0, _react.useEffect)(() => {
|
|
40
|
-
setOptions(defaultOptions ?? []);
|
|
41
|
-
}, [defaultOptions]);
|
|
42
|
-
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.TableSelect, (0, _extends2.default)({}, props, {
|
|
43
|
-
filterOption: loadOptions ? false : props?.filterOption,
|
|
44
|
-
onSearch: debounceFetcher,
|
|
45
|
-
onSelect: () => setOptions(defaultOptions ?? []),
|
|
46
|
-
options: options,
|
|
47
|
-
columns: columns
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
6
|
+
Object.defineProperty(exports, "AsyncTableSelect", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _asyncTableSelect.AsyncTableSelect;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _asyncTableSelect = require("../../../table-component/components/async-table-select");
|
|
@@ -565,64 +565,8 @@ const EditableCell = props => {
|
|
|
565
565
|
fieldNames: fieldNames ? fieldNames : {
|
|
566
566
|
value: keySelect,
|
|
567
567
|
label: inputKey ?? 'label'
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
// onBlur={(event: any) => {
|
|
571
|
-
|
|
572
|
-
// if (event.inputValue && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
573
|
-
// const val = event.inputValue
|
|
574
|
-
// onChange(val ?? undefined)
|
|
575
|
-
|
|
576
|
-
// const formState = getValues()
|
|
577
|
-
// // const itemState = getValues(dataIndex)
|
|
578
|
-
// // @ts-ignore
|
|
579
|
-
// const prevState = record[dataIndex]
|
|
580
|
-
// const newState = val
|
|
581
|
-
|
|
582
|
-
// handleCellChange?.({
|
|
583
|
-
// key,
|
|
584
|
-
// field: column.field ?? column.field as any,
|
|
585
|
-
// record: formState,
|
|
586
|
-
// prevState,
|
|
587
|
-
// newState,
|
|
588
|
-
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
589
|
-
// indexCol,
|
|
590
|
-
// indexRow,
|
|
591
|
-
// type: 'blur'
|
|
592
|
-
// })
|
|
593
|
-
// }
|
|
594
|
-
// }}
|
|
595
|
-
|
|
596
|
-
// onKeyDown={(event: any) => {
|
|
597
|
-
|
|
598
|
-
// if (event.key === 'Enter' && event.target?.value && column?.editSelectSettings?.searchTextAsValue && isMulti !== true) {
|
|
599
|
-
|
|
600
|
-
// const val = event.target.value
|
|
601
|
-
// onChange(val)
|
|
602
|
-
|
|
603
|
-
// const formState = getValues()
|
|
604
|
-
// // const itemState = getValues(dataIndex)
|
|
605
|
-
// // @ts-ignore
|
|
606
|
-
// const prevState = record[dataIndex]
|
|
607
|
-
// const newState = val
|
|
608
|
-
|
|
609
|
-
// handleCellChange?.({
|
|
610
|
-
// key,
|
|
611
|
-
// field: column.field ?? column.field as any,
|
|
612
|
-
// record: formState,
|
|
613
|
-
// prevState,
|
|
614
|
-
// newState,
|
|
615
|
-
// option: { value: val, label: val, searchTextAsValue: true } as any,
|
|
616
|
-
// indexCol,
|
|
617
|
-
// indexRow,
|
|
618
|
-
// type: 'blur'
|
|
619
|
-
// })
|
|
620
|
-
|
|
621
|
-
// }
|
|
622
|
-
|
|
623
|
-
// }}
|
|
624
|
-
,
|
|
625
|
-
|
|
568
|
+
},
|
|
569
|
+
searchTextAsValue: column.editSelectSettings?.searchTextAsValue,
|
|
626
570
|
"data-tooltip-content": message,
|
|
627
571
|
"data-tooltip-id": `${id}-tooltip-error`
|
|
628
572
|
});
|
|
@@ -963,7 +963,7 @@ const TableBodyCellEdit = props => {
|
|
|
963
963
|
}),
|
|
964
964
|
style: {
|
|
965
965
|
display: 'flex',
|
|
966
|
-
|
|
966
|
+
minHeight: 32,
|
|
967
967
|
userSelect: 'none',
|
|
968
968
|
width: cell.column.getSize(),
|
|
969
969
|
// flexBasis: cell.column.getSize(),
|
|
@@ -1052,7 +1052,7 @@ const TableBodyCellEdit = props => {
|
|
|
1052
1052
|
}),
|
|
1053
1053
|
style: {
|
|
1054
1054
|
display: 'flex',
|
|
1055
|
-
|
|
1055
|
+
minHeight: 32,
|
|
1056
1056
|
width: cell.column.getSize(),
|
|
1057
1057
|
minWidth: cell.column.getSize(),
|
|
1058
1058
|
// flex: 1,
|
|
@@ -1078,7 +1078,7 @@ const TableBodyCellEdit = props => {
|
|
|
1078
1078
|
}),
|
|
1079
1079
|
style: {
|
|
1080
1080
|
display: 'flex',
|
|
1081
|
-
|
|
1081
|
+
minHeight: 32,
|
|
1082
1082
|
width: cell.column.getSize(),
|
|
1083
1083
|
minWidth: cell.column.getSize(),
|
|
1084
1084
|
// flex: 1,
|
|
@@ -1288,7 +1288,8 @@ const TableBodyCellEdit = props => {
|
|
|
1288
1288
|
minWidth: cell.column.getSize(),
|
|
1289
1289
|
// flex: 1,
|
|
1290
1290
|
// maxWidth: cell.column.getSize(),
|
|
1291
|
-
height:
|
|
1291
|
+
height: isEditing && canEdit ? 32 : undefined,
|
|
1292
|
+
minHeight: 32,
|
|
1292
1293
|
...(0, _utils.getCommonPinningStyles)(cell.column),
|
|
1293
1294
|
cursor: isPasting ? 'crosshair' : undefined
|
|
1294
1295
|
},
|
|
@@ -91,8 +91,7 @@ const TableBodyRow = ({
|
|
|
91
91
|
transform: `translateY(${virtualRow.start}px)`,
|
|
92
92
|
//this should always be a `style` as it changes on scroll
|
|
93
93
|
gridTemplateColumns: `${templateColumns.map(n => `${n}fr`).join(" ")}`,
|
|
94
|
-
|
|
95
|
-
minHeight: isEditing ? undefined : virtualRow.size,
|
|
94
|
+
minHeight: isEditing ? virtualRow.size : 32,
|
|
96
95
|
...rowStyles
|
|
97
96
|
}
|
|
98
97
|
}, (0, _rowFocus.getRowFocusHandlers)(row.original, rowFocus), {
|
|
@@ -7,5 +7,6 @@ export interface DebounceSelectProps<OptionType extends BaseOptionType = Default
|
|
|
7
7
|
debounceTimeout?: number;
|
|
8
8
|
defaultOptions?: OptionType[];
|
|
9
9
|
rowData?: any;
|
|
10
|
+
searchTextAsValue?: boolean;
|
|
10
11
|
}
|
|
11
|
-
export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, rowData, ...props }: DebounceSelectProps<OptionType>): JSX.Element;
|
|
12
|
+
export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, rowData, searchTextAsValue, ...props }: DebounceSelectProps<OptionType>): JSX.Element;
|
|
@@ -17,9 +17,12 @@ function AsyncTableSelect({
|
|
|
17
17
|
defaultOptions,
|
|
18
18
|
columns,
|
|
19
19
|
rowData,
|
|
20
|
+
searchTextAsValue,
|
|
20
21
|
...props
|
|
21
22
|
}) {
|
|
22
23
|
const [options, setOptions] = (0, _react.useState)(defaultOptions ?? []);
|
|
24
|
+
const searchText = (0, _react.useRef)('');
|
|
25
|
+
const allowSearchText = searchTextAsValue && !props.mode && props.selectMode !== 'checkbox';
|
|
23
26
|
const debounceFetcher = (0, _react.useMemo)(() => {
|
|
24
27
|
const fetchOptions = value => {
|
|
25
28
|
if (value.trim().length === 0) {
|
|
@@ -41,8 +44,41 @@ function AsyncTableSelect({
|
|
|
41
44
|
}, [defaultOptions]);
|
|
42
45
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.TableSelect, (0, _extends2.default)({}, props, {
|
|
43
46
|
filterOption: loadOptions ? false : props?.filterOption,
|
|
44
|
-
onSearch:
|
|
45
|
-
|
|
47
|
+
onSearch: value => {
|
|
48
|
+
searchText.current = value;
|
|
49
|
+
debounceFetcher(value);
|
|
50
|
+
},
|
|
51
|
+
onChange: (value, option) => {
|
|
52
|
+
searchText.current = '';
|
|
53
|
+
props.onChange?.(value, option);
|
|
54
|
+
},
|
|
55
|
+
onSelect: () => {
|
|
56
|
+
searchText.current = '';
|
|
57
|
+
setOptions(defaultOptions ?? []);
|
|
58
|
+
},
|
|
59
|
+
onBlur: event => {
|
|
60
|
+
const value = searchText.current;
|
|
61
|
+
searchText.current = '';
|
|
62
|
+
if (allowSearchText && value) {
|
|
63
|
+
props.onChange?.(value, {
|
|
64
|
+
value,
|
|
65
|
+
label: value,
|
|
66
|
+
searchTextAsValue: true
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
props.onBlur?.(event);
|
|
70
|
+
},
|
|
71
|
+
onInputKeyDown: event => {
|
|
72
|
+
props.onInputKeyDown?.(event);
|
|
73
|
+
if (!allowSearchText || event.key !== 'Enter' || !searchText.current) return;
|
|
74
|
+
|
|
75
|
+
// Stop Enter before the dropdown selects the active row or the grid saves again.
|
|
76
|
+
event.stopPropagation();
|
|
77
|
+
if (!event.nativeEvent.isComposing && event.keyCode !== 229) {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
event.currentTarget.blur();
|
|
80
|
+
}
|
|
81
|
+
},
|
|
46
82
|
options: options,
|
|
47
83
|
columns: columns
|
|
48
84
|
}));
|