es-grid-template 0.0.7 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -19
- package/es/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +1 -1
- package/es/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +7 -11
- package/es/grid-component/ColumnsChoose.d.ts +9 -0
- package/es/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +66 -70
- package/es/grid-component/EditableCell.d.ts +19 -0
- package/es/grid-component/EditableCell.js +842 -0
- package/es/{FilterSearch.js → grid-component/FilterSearch.js} +2 -2
- package/es/grid-component/GridStyle.d.ts +4 -0
- package/es/grid-component/GridStyle.js +5 -0
- package/es/grid-component/InternalTable.d.ts +6 -0
- package/es/grid-component/InternalTable.js +283 -0
- package/es/grid-component/LoadingSpinner.d.ts +3 -0
- package/es/grid-component/LoadingSpinner.js +20 -0
- package/es/grid-component/Message/Message.d.ts +2 -0
- package/es/grid-component/Message/Message.js +16 -0
- package/es/grid-component/Message/index.d.ts +1 -0
- package/es/grid-component/Message/index.js +1 -0
- package/es/grid-component/TableGrid.d.ts +10 -0
- package/es/grid-component/TableGrid.js +375 -0
- package/es/grid-component/async-table-select/index.d.ts +9 -0
- package/es/grid-component/async-table-select/index.js +37 -0
- package/es/{hooks → grid-component/hooks}/constant.d.ts +14 -0
- package/es/{hooks → grid-component/hooks}/constant.js +17 -2
- package/es/grid-component/hooks/useColumns/index.d.ts +6 -0
- package/es/grid-component/hooks/useColumns/index.js +422 -0
- package/es/grid-component/hooks/utils.d.ts +35 -0
- package/es/{hooks → grid-component/hooks}/utils.js +147 -19
- package/es/grid-component/index.d.ts +2 -0
- package/es/grid-component/index.js +2 -0
- package/es/grid-component/rc-table/Grid.d.ts +8 -0
- package/es/grid-component/rc-table/Grid.js +99 -0
- package/es/grid-component/rc-table/GridEdit.d.ts +9 -0
- package/es/grid-component/rc-table/GridEdit.js +706 -0
- package/es/grid-component/type.d.ts +225 -0
- package/es/grid-component/useContext.d.ts +27 -0
- package/es/grid-component/useContext.js +4 -0
- package/es/index.d.ts +1 -2
- package/es/index.js +2 -2
- package/es/table-grid/styles.scss +551 -0
- package/lib/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +1 -1
- package/lib/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +11 -14
- package/lib/grid-component/ColumnsChoose.d.ts +9 -0
- package/lib/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +66 -70
- package/lib/grid-component/EditableCell.d.ts +19 -0
- package/lib/grid-component/EditableCell.js +844 -0
- package/lib/{FilterSearch.js → grid-component/FilterSearch.js} +3 -3
- package/lib/grid-component/GridStyle.d.ts +4 -0
- package/lib/grid-component/GridStyle.js +12 -0
- package/lib/grid-component/InternalTable.d.ts +6 -0
- package/lib/grid-component/InternalTable.js +292 -0
- package/lib/grid-component/LoadingSpinner.d.ts +3 -0
- package/lib/grid-component/LoadingSpinner.js +29 -0
- package/lib/grid-component/Message/Message.d.ts +2 -0
- package/lib/grid-component/Message/Message.js +25 -0
- package/lib/grid-component/Message/index.d.ts +1 -0
- package/lib/grid-component/Message/index.js +16 -0
- package/lib/grid-component/TableGrid.d.ts +10 -0
- package/lib/grid-component/TableGrid.js +382 -0
- package/lib/grid-component/async-table-select/index.d.ts +9 -0
- package/lib/grid-component/async-table-select/index.js +46 -0
- package/lib/{hooks → grid-component/hooks}/constant.d.ts +14 -0
- package/lib/{hooks → grid-component/hooks}/constant.js +18 -3
- package/lib/grid-component/hooks/useColumns/index.d.ts +6 -0
- package/lib/grid-component/hooks/useColumns/index.js +435 -0
- package/lib/grid-component/hooks/utils.d.ts +35 -0
- package/lib/{hooks → grid-component/hooks}/utils.js +164 -22
- package/lib/grid-component/index.d.ts +2 -0
- package/lib/grid-component/index.js +9 -0
- package/lib/grid-component/rc-table/Grid.d.ts +8 -0
- package/lib/grid-component/rc-table/Grid.js +108 -0
- package/lib/grid-component/rc-table/GridEdit.d.ts +9 -0
- package/lib/grid-component/rc-table/GridEdit.js +715 -0
- package/lib/grid-component/type.d.ts +225 -0
- package/lib/grid-component/useContext.d.ts +27 -0
- package/lib/grid-component/useContext.js +10 -0
- package/lib/index.d.ts +1 -2
- package/lib/index.js +7 -3
- package/lib/table-grid/styles.scss +551 -0
- package/package.json +17 -6
- package/es/ColumnsChoose.d.ts +0 -10
- package/es/GridTable.d.ts +0 -7
- package/es/GridTable.js +0 -927
- package/es/hooks/useColumns/index.d.ts +0 -2
- package/es/hooks/useColumns/index.js +0 -25
- package/es/hooks/utils.d.ts +0 -18
- package/es/styles.scss +0 -30
- package/es/type.d.ts +0 -88
- package/lib/ColumnsChoose.d.ts +0 -10
- package/lib/GridTable.d.ts +0 -7
- package/lib/GridTable.js +0 -936
- package/lib/hooks/useColumns/index.d.ts +0 -2
- package/lib/hooks/useColumns/index.js +0 -31
- package/lib/hooks/utils.d.ts +0 -18
- package/lib/styles.scss +0 -30
- package/lib/type.d.ts +0 -88
- /package/es/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
- /package/es/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
- /package/es/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
- /package/es/{hooks → grid-component/hooks}/index.d.ts +0 -0
- /package/es/{hooks → grid-component/hooks}/index.js +0 -0
- /package/es/{hooks → grid-component/hooks}/useIsOverflow.d.ts +0 -0
- /package/es/{hooks → grid-component/hooks}/useIsOverflow.js +0 -0
- /package/es/{hooks → grid-component/hooks}/useOnClickOutside.d.ts +0 -0
- /package/es/{hooks → grid-component/hooks}/useOnClickOutside.js +0 -0
- /package/es/{type.js → grid-component/type.js} +0 -0
- /package/lib/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
- /package/lib/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
- /package/lib/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
- /package/lib/{hooks → grid-component/hooks}/index.d.ts +0 -0
- /package/lib/{hooks → grid-component/hooks}/index.js +0 -0
- /package/lib/{hooks → grid-component/hooks}/useIsOverflow.d.ts +0 -0
- /package/lib/{hooks → grid-component/hooks}/useIsOverflow.js +0 -0
- /package/lib/{hooks → grid-component/hooks}/useOnClickOutside.d.ts +0 -0
- /package/lib/{hooks → grid-component/hooks}/useOnClickOutside.js +0 -0
- /package/lib/{type.js → grid-component/type.js} +0 -0
|
@@ -0,0 +1,842 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
|
+
import { Button, DatePicker, Divider, Input, TimePicker } from "antd";
|
|
4
|
+
import { checkDecimalSeparator, checkThousandSeparator, checkFieldKey, convertArrayWithIndent, convertDateToDayjs,
|
|
5
|
+
// convertDayjsToDate,
|
|
6
|
+
convertLabelToTitle,
|
|
7
|
+
// customWeekStartEndFormat,
|
|
8
|
+
getDatepickerFormat, getTemplate, isDisable, isEmpty, isNullOrUndefined, customWeekStartEndFormat, convertDayjsToDate
|
|
9
|
+
// convertDayjsToDate
|
|
10
|
+
} from "./hooks";
|
|
11
|
+
// import moment from "moment";
|
|
12
|
+
// import dayjs from "dayjs";
|
|
13
|
+
import { TreeSelect } from "antd";
|
|
14
|
+
import { AsyncTableSelect } from "./async-table-select";
|
|
15
|
+
import classNames from "classnames";
|
|
16
|
+
import { NumericFormat } from "react-numeric-component";
|
|
17
|
+
import { TableContext } from "./useContext";
|
|
18
|
+
import dayjs from "dayjs";
|
|
19
|
+
import moment from "moment";
|
|
20
|
+
import { Controller } from "react-hook-form";
|
|
21
|
+
import { Select } from "rc-master-ui";
|
|
22
|
+
|
|
23
|
+
// import moment from "moment";
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
SHOW_PARENT
|
|
27
|
+
} = TreeSelect;
|
|
28
|
+
const filterTreeNode = (input, treeNode) => {
|
|
29
|
+
const {
|
|
30
|
+
title,
|
|
31
|
+
value
|
|
32
|
+
} = treeNode;
|
|
33
|
+
return title.toLowerCase().includes(input.toLowerCase()) || value.toLowerCase().includes(input.toLowerCase());
|
|
34
|
+
};
|
|
35
|
+
const EditableCell = props => {
|
|
36
|
+
const {
|
|
37
|
+
t,
|
|
38
|
+
editing,
|
|
39
|
+
dataIndex,
|
|
40
|
+
title,
|
|
41
|
+
editType,
|
|
42
|
+
record,
|
|
43
|
+
index,
|
|
44
|
+
children,
|
|
45
|
+
column,
|
|
46
|
+
indexRow,
|
|
47
|
+
indexCol,
|
|
48
|
+
...restProps
|
|
49
|
+
} = props;
|
|
50
|
+
const {
|
|
51
|
+
rowKey,
|
|
52
|
+
format,
|
|
53
|
+
control,
|
|
54
|
+
getValues,
|
|
55
|
+
handleCellChange
|
|
56
|
+
} = useContext(TableContext);
|
|
57
|
+
const datePickerRef = React.useRef(null);
|
|
58
|
+
const dateTimePickerRef = React.useRef(null);
|
|
59
|
+
// const timePickerRef = React.useRef(null);
|
|
60
|
+
|
|
61
|
+
const isInvalid = false;
|
|
62
|
+
const keySelect = checkFieldKey(column?.editSelectSettings?.fieldKey);
|
|
63
|
+
const inputKey = column?.editSelectSettings?.inputKey;
|
|
64
|
+
const options = column?.editSelectSettings?.validateOption ? column?.editSelectSettings?.validateOption(record, column.dataIndex) : column?.editSelectSettings?.options ? column?.editSelectSettings?.options : [];
|
|
65
|
+
const optionsTree = column?.editSelectSettings?.validateOption ? convertArrayWithIndent(column?.editSelectSettings?.validateOption(record, column.dataIndex)) : column?.editSelectSettings?.options ? convertArrayWithIndent(column?.editSelectSettings?.options) : [];
|
|
66
|
+
const inputNode = (value, onChange) => {
|
|
67
|
+
const dateFormat = getDatepickerFormat(editType, column);
|
|
68
|
+
const date = !isEmpty(value) ? convertDateToDayjs(new Date(value), dateFormat) : null;
|
|
69
|
+
const maxDate = convertDateToDayjs(column.maxDate, dateFormat) ?? undefined;
|
|
70
|
+
const minDate = convertDateToDayjs(column.minDate, dateFormat) ?? undefined;
|
|
71
|
+
switch (editType) {
|
|
72
|
+
case 'date':
|
|
73
|
+
return /*#__PURE__*/React.createElement(DatePicker
|
|
74
|
+
// id={`col${indexCol}-record${indexRow}`}
|
|
75
|
+
, {
|
|
76
|
+
ref: datePickerRef,
|
|
77
|
+
format: {
|
|
78
|
+
format: dateFormat,
|
|
79
|
+
type: 'mask'
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// locale={buddhistLocale}
|
|
83
|
+
,
|
|
84
|
+
style: {
|
|
85
|
+
width: '100%',
|
|
86
|
+
height: '100%'
|
|
87
|
+
},
|
|
88
|
+
value: date
|
|
89
|
+
// defaultValue={date}
|
|
90
|
+
,
|
|
91
|
+
|
|
92
|
+
onBlur: () => {
|
|
93
|
+
const formState = getValues();
|
|
94
|
+
const itemState = getValues(dataIndex);
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
const prevState = record[dataIndex];
|
|
97
|
+
const newState = itemState;
|
|
98
|
+
if (newState !== prevState) {
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
handleCellChange?.({
|
|
101
|
+
key: record[rowKey],
|
|
102
|
+
record: formState,
|
|
103
|
+
prevState,
|
|
104
|
+
newState,
|
|
105
|
+
type: 'blur'
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
placeholder: column.placeholder,
|
|
110
|
+
disabled: isDisable(column, record) ?? false,
|
|
111
|
+
maxDate: maxDate,
|
|
112
|
+
minDate: minDate
|
|
113
|
+
|
|
114
|
+
// onOpenChange={(open) => {
|
|
115
|
+
// console.log(open)
|
|
116
|
+
// if (open) {
|
|
117
|
+
// handleSubmit(onSubmit)
|
|
118
|
+
// }
|
|
119
|
+
// }}
|
|
120
|
+
,
|
|
121
|
+
|
|
122
|
+
onChange: (newDate, dateString) => {
|
|
123
|
+
const newDateValue = dateString ? moment(convertDayjsToDate(dateString, dateFormat)).format() : null;
|
|
124
|
+
onChange(newDateValue);
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
datePickerRef.current?.focus();
|
|
128
|
+
}, 0);
|
|
129
|
+
},
|
|
130
|
+
popupClassName: 'be-popup-container'
|
|
131
|
+
});
|
|
132
|
+
case 'datetime':
|
|
133
|
+
// const dateTimeFormat = getDatepickerFormat(editType, column)
|
|
134
|
+
// // @ts-ignore
|
|
135
|
+
// // const dateTimeValue = !isEmpty(record[column.dataIndex]) ? convertDateToDayjs(new Date(record[column.dataIndex]), dateTimeFormat) : null
|
|
136
|
+
// const maxDateTime = convertDateToDayjs(column.maxDate, dateTimeFormat) ?? undefined
|
|
137
|
+
// const minDateTime = convertDateToDayjs(column.minDate, dateTimeFormat) ?? undefined
|
|
138
|
+
|
|
139
|
+
return /*#__PURE__*/React.createElement(DatePicker
|
|
140
|
+
// id={`col${indexCol}-record${indexRow}`}
|
|
141
|
+
, {
|
|
142
|
+
ref: dateTimePickerRef,
|
|
143
|
+
format: {
|
|
144
|
+
format: dateFormat,
|
|
145
|
+
type: 'mask'
|
|
146
|
+
}
|
|
147
|
+
// locale={buddhistLocale}
|
|
148
|
+
,
|
|
149
|
+
style: {
|
|
150
|
+
width: '100%',
|
|
151
|
+
height: '100%'
|
|
152
|
+
},
|
|
153
|
+
showTime: true,
|
|
154
|
+
value: date,
|
|
155
|
+
placeholder: column.placeholder,
|
|
156
|
+
disabled: isDisable(column, record) ?? false,
|
|
157
|
+
maxDate: maxDate,
|
|
158
|
+
minDate: minDate,
|
|
159
|
+
onChange: (newDate, dateString) => {
|
|
160
|
+
const newDateValue = dateString ? moment(convertDayjsToDate(dateString, dateFormat)).format() : null;
|
|
161
|
+
onChange(newDateValue);
|
|
162
|
+
setTimeout(() => {
|
|
163
|
+
// @ts-ignore
|
|
164
|
+
dateTimePickerRef.current?.focus();
|
|
165
|
+
}, 0);
|
|
166
|
+
},
|
|
167
|
+
onBlur: () => {
|
|
168
|
+
const formState = getValues();
|
|
169
|
+
const itemState = getValues(dataIndex);
|
|
170
|
+
// @ts-ignore
|
|
171
|
+
const prevState = record[dataIndex];
|
|
172
|
+
const newState = itemState;
|
|
173
|
+
if (prevState !== newState) {
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
handleCellChange?.({
|
|
176
|
+
key: record[rowKey],
|
|
177
|
+
record: formState,
|
|
178
|
+
prevState,
|
|
179
|
+
newState,
|
|
180
|
+
type: 'blur'
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
popupClassName: 'be-popup-container'
|
|
185
|
+
});
|
|
186
|
+
case 'month':
|
|
187
|
+
case 'quarter':
|
|
188
|
+
case 'year':
|
|
189
|
+
const pickerFormat = getDatepickerFormat(editType, column);
|
|
190
|
+
// @ts-ignore
|
|
191
|
+
// const dateValue = !isEmpty(record[column.dataIndex]) ? dayjs(record[column.key], pickerFormat) : null
|
|
192
|
+
const maxDateValue1 = !isEmpty(column.maxDate) ? dayjs(column.maxDate, pickerFormat) : undefined;
|
|
193
|
+
const minDateValue1 = !isEmpty(column.minDate) ? dayjs(column.minDate, pickerFormat) : undefined;
|
|
194
|
+
return /*#__PURE__*/React.createElement(DatePicker, {
|
|
195
|
+
id: `col${indexCol}-record${indexRow}`,
|
|
196
|
+
format: {
|
|
197
|
+
format: pickerFormat,
|
|
198
|
+
type: 'mask'
|
|
199
|
+
},
|
|
200
|
+
style: {
|
|
201
|
+
width: '100%',
|
|
202
|
+
height: '100%'
|
|
203
|
+
}
|
|
204
|
+
// defaultValue={dateValue}
|
|
205
|
+
,
|
|
206
|
+
picker: editType,
|
|
207
|
+
placeholder: column.placeholder,
|
|
208
|
+
disabled: isDisable(column, record) ?? false,
|
|
209
|
+
maxDate: maxDateValue1,
|
|
210
|
+
minDate: minDateValue1
|
|
211
|
+
// onChange={(dValue, dateString) => {
|
|
212
|
+
// const newDateValue = dateString ? dateString : null
|
|
213
|
+
//
|
|
214
|
+
// // record[column.dataIndex] = newDateValue
|
|
215
|
+
// // handleCellChange(newDateValue, newDateValue, record, col, indexRow, indexCol)
|
|
216
|
+
// }}
|
|
217
|
+
,
|
|
218
|
+
popupClassName: 'be-popup-container'
|
|
219
|
+
});
|
|
220
|
+
case 'week':
|
|
221
|
+
const weekFormat = getDatepickerFormat(editType, column);
|
|
222
|
+
|
|
223
|
+
// @ts-ignore
|
|
224
|
+
// const weekValue = !isEmpty(record[column.dataIndex]) ? dayjs(record[column.dataIndex], weekFormat) : null
|
|
225
|
+
const maxWeekValue = !isEmpty(column.maxDate) ? dayjs(column.maxDate, weekFormat) : undefined;
|
|
226
|
+
const minWeekValue = !isEmpty(column.minDate) ? dayjs(column.minDate, weekFormat) : undefined;
|
|
227
|
+
return /*#__PURE__*/React.createElement(DatePicker, {
|
|
228
|
+
format: val => customWeekStartEndFormat(val, weekFormat),
|
|
229
|
+
style: {
|
|
230
|
+
width: '100%',
|
|
231
|
+
height: '100%'
|
|
232
|
+
}
|
|
233
|
+
// defaultValue={weekValue}
|
|
234
|
+
,
|
|
235
|
+
picker: editType,
|
|
236
|
+
placeholder: column.placeholder,
|
|
237
|
+
disabled: isDisable(column, record) ?? false,
|
|
238
|
+
maxDate: maxWeekValue,
|
|
239
|
+
minDate: minWeekValue
|
|
240
|
+
// onChange={(dateValue, dateString) => {
|
|
241
|
+
// const newDateValue = dateString ? dateString : null
|
|
242
|
+
//
|
|
243
|
+
// record[column.dataIndex] = newDateValue
|
|
244
|
+
// handleCellChange(newDateValue, newDateValue, record, col, indexRow, indexCol)
|
|
245
|
+
// }}
|
|
246
|
+
,
|
|
247
|
+
popupClassName: 'be-popup-container'
|
|
248
|
+
});
|
|
249
|
+
case 'time':
|
|
250
|
+
const timeFormat = getDatepickerFormat(editType, column);
|
|
251
|
+
const maxTimeValue = !isEmpty(column.maxTime) ? dayjs(column.maxTime).format(timeFormat) : null;
|
|
252
|
+
const minTimeValue = !isEmpty(column.minTime) ? dayjs(column.minTime).format(timeFormat) : null;
|
|
253
|
+
|
|
254
|
+
// @ts-ignore
|
|
255
|
+
// const timeValue = !isEmpty(record[column.dataIndex]) ? dayjs(record[column.dataIndex], timeFormat) : null
|
|
256
|
+
const maxTime = maxTimeValue ? dayjs(maxTimeValue, timeFormat) : undefined;
|
|
257
|
+
const minTime = minTimeValue ? dayjs(minTimeValue, timeFormat) : undefined;
|
|
258
|
+
return /*#__PURE__*/React.createElement(TimePicker, {
|
|
259
|
+
format: {
|
|
260
|
+
format: timeFormat,
|
|
261
|
+
type: 'mask'
|
|
262
|
+
}
|
|
263
|
+
// defaultValue={timeValue}
|
|
264
|
+
,
|
|
265
|
+
maxDate: maxTime,
|
|
266
|
+
minDate: minTime,
|
|
267
|
+
disabled: isDisable(column, record) ?? false
|
|
268
|
+
// onChange={(values: any, timeString) => {
|
|
269
|
+
// const newTimeValue = timeString ? timeString : null
|
|
270
|
+
// const newrecordData = {
|
|
271
|
+
// ...record,
|
|
272
|
+
// // [column.dataIndex]: newTimeValue
|
|
273
|
+
// }
|
|
274
|
+
//
|
|
275
|
+
// // handleCellChange(newTimeValue, newTimeValue, newrecordData, col, indexRow, indexCol)
|
|
276
|
+
// }}
|
|
277
|
+
,
|
|
278
|
+
style: {
|
|
279
|
+
width: '100%',
|
|
280
|
+
height: '100%'
|
|
281
|
+
},
|
|
282
|
+
popupClassName: 'be-popup-container'
|
|
283
|
+
});
|
|
284
|
+
case 'selectTable':
|
|
285
|
+
const rr = column?.editSelectSettings && column?.editSelectSettings.columns ? column?.editSelectSettings.columns : [];
|
|
286
|
+
const columnsTable = rr.map(colSelect => {
|
|
287
|
+
return {
|
|
288
|
+
title: colSelect.headerTemplate ? colSelect.headerTemplate : t ? t(colSelect.headerText) : colSelect.headerText,
|
|
289
|
+
dataIndex: colSelect.dataIndex,
|
|
290
|
+
key: colSelect.dataIndex,
|
|
291
|
+
render: colSelect.template ? (text, recd, ind) => /*#__PURE__*/React.createElement(React.Fragment, null, colSelect.template?.({
|
|
292
|
+
value: text,
|
|
293
|
+
rowData: recd,
|
|
294
|
+
column: colSelect,
|
|
295
|
+
field: colSelect.dataIndex,
|
|
296
|
+
index: ind,
|
|
297
|
+
[colSelect.dataIndex]: text
|
|
298
|
+
})) : undefined,
|
|
299
|
+
width: colSelect.width,
|
|
300
|
+
ellipsis: true,
|
|
301
|
+
align: colSelect.textAlign
|
|
302
|
+
};
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
// let valueSelectTable
|
|
306
|
+
//
|
|
307
|
+
// if (column?.editSelectSettings?.isMulti || column?.editSelectSettings?.selectMode === 'checkbox') {
|
|
308
|
+
// valueSelectTable = (!isNullOrUndefined(record[column.dataIndex]) && Array.isArray(record[column.dataIndex]) && record[column.dataIndex]?.length > 0) ? options.filter((val: any) => record[column.dataIndex]?.includes(val[keySelect])) : undefined
|
|
309
|
+
// } else {
|
|
310
|
+
// valueSelectTable = record[column?.editSelectSettings?.fieldValue ?? column.dataIndex] ?? ''
|
|
311
|
+
// }
|
|
312
|
+
//
|
|
313
|
+
// if (!valueSelectTable && column?.editSelectSettings?.defaultValue?.(record[column.dataIndex], record)) {
|
|
314
|
+
// valueSelectTable = column?.editSelectSettings?.defaultValue(record[column.dataIndex], record)
|
|
315
|
+
// }
|
|
316
|
+
//
|
|
317
|
+
//
|
|
318
|
+
|
|
319
|
+
let valueSelectTable;
|
|
320
|
+
if (column?.editSelectSettings?.isMulti || column?.editSelectSettings?.selectMode === 'checkbox') {
|
|
321
|
+
// @ts-ignore
|
|
322
|
+
valueSelectTable = !isNullOrUndefined(record[column.dataIndex]) && Array.isArray(record[column.dataIndex]) && record[column.dataIndex]?.length > 0 ? options.filter(val => record[column.dataIndex]?.includes(val[keySelect])) : undefined;
|
|
323
|
+
} else {
|
|
324
|
+
// const find = (!isNullOrUndefined(record[column.dataIndex]) && record[column.dataIndex] !== '') ? options?.find((val: any) => val[keySelect] === record[column?.editSelectSettings?.fieldValue ?? column.dataIndex]) : ''
|
|
325
|
+
// @ts-ignore
|
|
326
|
+
const find = !isNullOrUndefined(record[column.dataIndex]) && record[column.dataIndex] !== '' ? options?.find(val => val[keySelect] === record[column.dataIndex]) : '';
|
|
327
|
+
valueSelectTable = find ? {
|
|
328
|
+
label: find[column?.editSelectSettings?.inputKey ?? column.dataIndex],
|
|
329
|
+
// @ts-ignore
|
|
330
|
+
[column.dataIndex]: find[column?.editSelectSettings?.fieldValue ?? keySelect],
|
|
331
|
+
key: find[column?.editSelectSettings?.fieldValue ?? keySelect],
|
|
332
|
+
[keySelect]: find[column?.editSelectSettings?.fieldValue ?? keySelect]
|
|
333
|
+
} : '';
|
|
334
|
+
}
|
|
335
|
+
// @ts-ignore
|
|
336
|
+
if (!valueSelectTable && column?.editSelectSettings?.defaultValue?.(record[column.dataIndex], record)) {
|
|
337
|
+
// @ts-ignore
|
|
338
|
+
valueSelectTable = column?.editSelectSettings?.defaultValue(record[column.dataIndex], record);
|
|
339
|
+
}
|
|
340
|
+
return /*#__PURE__*/React.createElement(AsyncTableSelect, {
|
|
341
|
+
id: `col${indexCol}-record${indexRow}`,
|
|
342
|
+
columns: columnsTable,
|
|
343
|
+
options: options,
|
|
344
|
+
defaultOptions: options
|
|
345
|
+
// onChange={(val: any, option) => {
|
|
346
|
+
// // const newValue = val && (column?.editSelectSettings?.isMulti || column?.editSelectSettings?.selectMode === 'checkbox') ? (val?.map((item: any) => item[keySelect]) ?? []) : (val ? val[keySelect] : null)
|
|
347
|
+
// const newrecordData = {
|
|
348
|
+
// ...record,
|
|
349
|
+
// [column.dataIndex]: val
|
|
350
|
+
// }
|
|
351
|
+
//
|
|
352
|
+
// // handleCellChange(option, val, newrecordData, col, indexRow, indexCol)
|
|
353
|
+
// }}
|
|
354
|
+
,
|
|
355
|
+
showSearch: true,
|
|
356
|
+
mode: column?.editSelectSettings?.isMulti || column?.editSelectSettings?.selectMode === 'checkbox' ? 'multiple' : undefined,
|
|
357
|
+
focusToSelectAll: true,
|
|
358
|
+
selectMode: column?.editSelectSettings?.selectMode,
|
|
359
|
+
style: {
|
|
360
|
+
width: '100%',
|
|
361
|
+
height: '100%'
|
|
362
|
+
},
|
|
363
|
+
value: valueSelectTable,
|
|
364
|
+
placeholder: t ? t('Select') : 'Select',
|
|
365
|
+
allowClear: column.isClearable ?? false,
|
|
366
|
+
maxTagCount: 'responsive',
|
|
367
|
+
rowKey: keySelect,
|
|
368
|
+
popupMatchSelectWidth: column?.editSelectSettings?.menuWidth ? column?.editSelectSettings?.menuWidth + 10 : undefined,
|
|
369
|
+
optionFilterProp: "label",
|
|
370
|
+
popupClassName: 'be-popup-container'
|
|
371
|
+
// onPaste={(e: any) => handleOnCellPaste(e, indexRow, indexCol)}
|
|
372
|
+
,
|
|
373
|
+
loadOptions: column?.editSelectSettings?.loadOptions,
|
|
374
|
+
status: isInvalid ? 'error' : undefined,
|
|
375
|
+
dropdownRender: menu => {
|
|
376
|
+
if (column?.editSelectSettings?.toolbarItems && column?.editSelectSettings?.toolbarItems.length > 0) {
|
|
377
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, menu, /*#__PURE__*/React.createElement(Divider, {
|
|
378
|
+
style: {
|
|
379
|
+
margin: '8px 0'
|
|
380
|
+
}
|
|
381
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
382
|
+
className: 'toolbar-control d-flex justify-content-end'
|
|
383
|
+
}, column?.editSelectSettings?.toolbarItems.map(it => {
|
|
384
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
385
|
+
key: it.key,
|
|
386
|
+
className: 'toolbar-item',
|
|
387
|
+
onClick: () => column?.editSelectSettings?.toolbarClick?.({
|
|
388
|
+
item: it,
|
|
389
|
+
column
|
|
390
|
+
})
|
|
391
|
+
}, it.template ? getTemplate(it.template) : /*#__PURE__*/React.createElement(Button, {
|
|
392
|
+
className: "toolbar-item-btn"
|
|
393
|
+
}, it.icon && getTemplate(it.icon), it.title));
|
|
394
|
+
})));
|
|
395
|
+
} else {
|
|
396
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, " ", menu);
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
filterOption: column?.editSelectSettings?.filterOption,
|
|
400
|
+
fieldNames: column?.editSelectSettings?.fieldNames ? column?.editSelectSettings?.fieldNames : {
|
|
401
|
+
value: keySelect,
|
|
402
|
+
label: column?.editSelectSettings?.inputKey ?? 'label'
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
case 'select':
|
|
406
|
+
// let valueCustomSelect
|
|
407
|
+
// if (column?.editSelectSettings?.isMulti) {
|
|
408
|
+
// valueCustomSelect = (!isNullOrUndefined(record[column.dataIndex]) && record[column.dataIndex]?.length > 0) ? options.filter((val: any) => record[column.dataIndex]?.includes(val[keySelect])) : []
|
|
409
|
+
// } else {
|
|
410
|
+
//
|
|
411
|
+
// valueCustomSelect = (!isNullOrUndefined(record[column.dataIndex]) && record[column.dataIndex] !== '') ? options?.find((val: any) => val[keySelect] === record[column.dataIndex]) : ''
|
|
412
|
+
//
|
|
413
|
+
// }
|
|
414
|
+
//
|
|
415
|
+
// if (!valueCustomSelect && column?.editSelectSettings?.defaultValue) {
|
|
416
|
+
//
|
|
417
|
+
// if (column?.editSelectSettings.fieldLabel && record[column?.editSelectSettings.fieldLabel]) {
|
|
418
|
+
//
|
|
419
|
+
// // valueCustomSelect = {...column?.editSelectSettings?.defaultValue(record), label: record[column?.editSelectSettings.fieldLabel]}
|
|
420
|
+
// valueCustomSelect = {...column?.editSelectSettings?.defaultValue(record[column.dataIndex], record), label: record[column?.editSelectSettings.fieldLabel]}
|
|
421
|
+
//
|
|
422
|
+
// } else {
|
|
423
|
+
// valueCustomSelect = column?.editSelectSettings?.defaultValue(record[column.dataIndex], record)
|
|
424
|
+
//
|
|
425
|
+
// }
|
|
426
|
+
//
|
|
427
|
+
// }
|
|
428
|
+
|
|
429
|
+
return /*#__PURE__*/React.createElement(Select, {
|
|
430
|
+
id: `col${indexCol}-record${indexRow}`,
|
|
431
|
+
showSearch: true,
|
|
432
|
+
valueSelectAble: true
|
|
433
|
+
|
|
434
|
+
// isMulti={column?.editSelectSettings?.isMulti}
|
|
435
|
+
,
|
|
436
|
+
style: {
|
|
437
|
+
width: '100%'
|
|
438
|
+
},
|
|
439
|
+
value: value
|
|
440
|
+
// options={options}
|
|
441
|
+
,
|
|
442
|
+
options: [{
|
|
443
|
+
value: 'jack',
|
|
444
|
+
label: 'Jack'
|
|
445
|
+
}, {
|
|
446
|
+
value: 'lucy',
|
|
447
|
+
label: 'Lucy'
|
|
448
|
+
}, {
|
|
449
|
+
value: 'Yiminghe',
|
|
450
|
+
label: 'yiminghe'
|
|
451
|
+
}, {
|
|
452
|
+
value: 'disabled',
|
|
453
|
+
label: 'Disabled',
|
|
454
|
+
disabled: true
|
|
455
|
+
}],
|
|
456
|
+
placeholder: t ? t('Select') : 'Select',
|
|
457
|
+
onChange: (val, item) => {
|
|
458
|
+
console.log('item', item);
|
|
459
|
+
onChange(val);
|
|
460
|
+
},
|
|
461
|
+
onBlur: () => {
|
|
462
|
+
const formState = getValues();
|
|
463
|
+
// const itemState = getValues(dataIndex)
|
|
464
|
+
|
|
465
|
+
// @ts-ignore
|
|
466
|
+
const prevState = record[dataIndex];
|
|
467
|
+
// const newState = value
|
|
468
|
+
|
|
469
|
+
// console.log('prevState', prevState)
|
|
470
|
+
// console.log('newState', newState)
|
|
471
|
+
// console.log('itemState', itemState)
|
|
472
|
+
if (value !== prevState) {
|
|
473
|
+
// @ts-ignore
|
|
474
|
+
handleCellChange?.({
|
|
475
|
+
key: record[rowKey],
|
|
476
|
+
record: formState,
|
|
477
|
+
type: 'blur'
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
popupClassName: 'be-popup-container'
|
|
482
|
+
});
|
|
483
|
+
case 'treeSelect':
|
|
484
|
+
// let valueTreeSelect
|
|
485
|
+
|
|
486
|
+
const newTreeData = convertLabelToTitle(optionsTree);
|
|
487
|
+
// @ts-ignore
|
|
488
|
+
const valueTreeSelect = column?.editSelectSettings?.isMulti ? Array.isArray(record[column.dataIndex]) ? record[column.dataIndex] : [] : record[column.dataIndex];
|
|
489
|
+
return /*#__PURE__*/React.createElement(TreeSelect, {
|
|
490
|
+
id: `col${indexCol}-record${indexRow}`,
|
|
491
|
+
className: 'be-tree-select',
|
|
492
|
+
style: {
|
|
493
|
+
width: '100%'
|
|
494
|
+
},
|
|
495
|
+
value: valueTreeSelect,
|
|
496
|
+
dropdownStyle: {
|
|
497
|
+
maxHeight: 400,
|
|
498
|
+
overflow: 'auto'
|
|
499
|
+
},
|
|
500
|
+
treeData: newTreeData,
|
|
501
|
+
placeholder: t ? t('Select') : 'Select',
|
|
502
|
+
treeDefaultExpandAll: true,
|
|
503
|
+
virtual: true,
|
|
504
|
+
allowClear: true
|
|
505
|
+
// maxTagTextLength={column?.editSelectSettings?.showItems}
|
|
506
|
+
,
|
|
507
|
+
maxTagCount: column?.editSelectSettings?.showItems,
|
|
508
|
+
maxTagPlaceholder: 2,
|
|
509
|
+
treeTitleRender: column?.editSelectSettings?.formatOptionLabel,
|
|
510
|
+
showCheckedStrategy: SHOW_PARENT,
|
|
511
|
+
multiple: column?.editSelectSettings?.selectMode === 'checkbox' || column?.editSelectSettings?.isMulti,
|
|
512
|
+
fieldNames: {
|
|
513
|
+
label: inputKey ? inputKey : 'title',
|
|
514
|
+
value: keySelect,
|
|
515
|
+
children: 'children'
|
|
516
|
+
},
|
|
517
|
+
treeCheckable: column?.editSelectSettings?.selectMode === 'checkbox'
|
|
518
|
+
// getPopupContainer={() => tableWrapperRef.current}
|
|
519
|
+
,
|
|
520
|
+
filterTreeNode: filterTreeNode
|
|
521
|
+
// onChange={(val: any) => {
|
|
522
|
+
// record[column.dataIndex] = val
|
|
523
|
+
// handleCellChange(val, val, record, col, indexRow, indexCol)
|
|
524
|
+
//
|
|
525
|
+
// }}
|
|
526
|
+
,
|
|
527
|
+
|
|
528
|
+
status: isInvalid ? 'error' : undefined
|
|
529
|
+
});
|
|
530
|
+
case 'checkbox':
|
|
531
|
+
return /*#__PURE__*/React.createElement(Input
|
|
532
|
+
// @ts-ignore
|
|
533
|
+
, {
|
|
534
|
+
checked: record[column.dataIndex],
|
|
535
|
+
id: `col${indexCol}-record${indexRow}`,
|
|
536
|
+
type: "checkbox",
|
|
537
|
+
style: {
|
|
538
|
+
textAlign: column.align ?? 'left'
|
|
539
|
+
}
|
|
540
|
+
// onChange={(val) => {
|
|
541
|
+
// record[column.dataIndex] = val.currentTarget.checked
|
|
542
|
+
// handleCellChange(val.currentTarget.checked, val.currentTarget.checked, record, col, indexRow, indexCol)
|
|
543
|
+
// }}
|
|
544
|
+
,
|
|
545
|
+
disabled: isDisable(column, record) ?? false
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
// case 'form':
|
|
549
|
+
//
|
|
550
|
+
// const valueForm = record[column.dataIndex]
|
|
551
|
+
//
|
|
552
|
+
// return (
|
|
553
|
+
// <EditForm
|
|
554
|
+
// column={col}
|
|
555
|
+
// t={t}
|
|
556
|
+
// id={`col${indexCol}-record${indexRow}`}
|
|
557
|
+
// value={valueForm}
|
|
558
|
+
// fieldKey={'name'}
|
|
559
|
+
// recordData={record}
|
|
560
|
+
// indexRow={indexRow}
|
|
561
|
+
// cellFocus={cellFocus}
|
|
562
|
+
// onChange={(val: any) => {
|
|
563
|
+
// // record[column.dataIndex] = val
|
|
564
|
+
// const newrecordData = {
|
|
565
|
+
// ...record,
|
|
566
|
+
// [column.dataIndex]: val
|
|
567
|
+
// }
|
|
568
|
+
// handleCellChange(val, val, newrecordData, col, indexRow, indexCol)
|
|
569
|
+
// }}
|
|
570
|
+
// menuPortalTarget={tableContainerRef}
|
|
571
|
+
// classNamePrefix={column.classElement ?? 'select'}
|
|
572
|
+
// placeholder={t ? t(column.placeholder ? column.placeholder : '') : (column.placeholder ? column.placeholder : '')}
|
|
573
|
+
// menuWidth={column.editFromSettings?.menuWidth}
|
|
574
|
+
// menuHeight={column.editFromSettings?.menuHeight}
|
|
575
|
+
// />
|
|
576
|
+
// )
|
|
577
|
+
|
|
578
|
+
// case 'file':
|
|
579
|
+
// const valueFile = record[column.dataIndex]
|
|
580
|
+
// return (
|
|
581
|
+
//
|
|
582
|
+
//
|
|
583
|
+
// <InputFile
|
|
584
|
+
// value={valueFile}
|
|
585
|
+
// uploading={column.uploading}
|
|
586
|
+
// allowedExtensions={column.allowedExtensions}
|
|
587
|
+
// asyncUploadSettings={column.asyncUploadSettings}
|
|
588
|
+
// disable={isDisable(col, record)}
|
|
589
|
+
// onChange={(val: string) => {
|
|
590
|
+
//
|
|
591
|
+
// const newValue = Array.isArray(val) ? val.map((it: any) => it) : val
|
|
592
|
+
// const newrecordData = {
|
|
593
|
+
// ...record,
|
|
594
|
+
// [column.dataIndex]: newValue
|
|
595
|
+
// }
|
|
596
|
+
// handleCellChange(val, newValue, newrecordData, col, indexRow, indexCol)
|
|
597
|
+
// }}
|
|
598
|
+
//
|
|
599
|
+
//
|
|
600
|
+
// />
|
|
601
|
+
//
|
|
602
|
+
//
|
|
603
|
+
// )
|
|
604
|
+
|
|
605
|
+
case 'color':
|
|
606
|
+
// const color = record[column.dataIndex]
|
|
607
|
+
|
|
608
|
+
return /*#__PURE__*/React.createElement(Input, {
|
|
609
|
+
type: 'color',
|
|
610
|
+
id: `col${indexCol}-record${indexRow}`,
|
|
611
|
+
style: {
|
|
612
|
+
textAlign: column.align
|
|
613
|
+
}
|
|
614
|
+
// @ts-ignore
|
|
615
|
+
,
|
|
616
|
+
value: !isNullOrUndefined(record[column.dataIndex]) ? record[column.dataIndex] : '',
|
|
617
|
+
disabled: isDisable(column, record) ?? false,
|
|
618
|
+
className: classNames('be-cell-editing rounded-0 input-element')
|
|
619
|
+
|
|
620
|
+
// onChange={(val: any) => {
|
|
621
|
+
// if (record[column.dataIndex] !== val.target?.value) {
|
|
622
|
+
// record[column.dataIndex] = val.target?.value
|
|
623
|
+
// }
|
|
624
|
+
// }}
|
|
625
|
+
// onBlur={(val: any) => {
|
|
626
|
+
// handleCellChange(val, val.target?.value, record, col, indexRow, indexCol)
|
|
627
|
+
// }}
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
// case 'image':
|
|
631
|
+
// let image = record[column.dataIndex]
|
|
632
|
+
// return (
|
|
633
|
+
// <ImageUpload
|
|
634
|
+
// id={`col${indexCol}-record${indexRow}`}
|
|
635
|
+
// defaultImage={image}
|
|
636
|
+
// width={column.width}
|
|
637
|
+
// height={38}
|
|
638
|
+
// onKeyDown={(val: any, path: string) => {
|
|
639
|
+
// const checkKey = checkKeyDown(val, col, indexRow + 1, indexCol + 1)
|
|
640
|
+
// if (checkKey === 'ArrecordDown' || checkKey === 'ArrecordUp' || checkKey === 'Enter') {
|
|
641
|
+
// let newVal = ''
|
|
642
|
+
// if (newVal != record[column.dataIndex]) {
|
|
643
|
+
// record[column.dataIndex] = path
|
|
644
|
+
// // handleDataChange(path, record, col, indexRow, indexCol)
|
|
645
|
+
// handleCellChange(path, record, col, indexRow, indexCol)
|
|
646
|
+
// }
|
|
647
|
+
// }
|
|
648
|
+
// }}
|
|
649
|
+
// />
|
|
650
|
+
// )
|
|
651
|
+
|
|
652
|
+
case 'numeric':
|
|
653
|
+
const thousandSeparator = column.format?.thousandSeparator ? column.format?.thousandSeparator : format?.thousandSeparator;
|
|
654
|
+
const decimalSeparator = column.format?.decimalSeparator ? column.format?.decimalSeparator : format?.decimalSeparator;
|
|
655
|
+
|
|
656
|
+
// let floatValue = value
|
|
657
|
+
|
|
658
|
+
const numericFormatProps = {
|
|
659
|
+
value,
|
|
660
|
+
thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
|
|
661
|
+
decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
|
|
662
|
+
decimalScale: !isEmpty(column.format?.decimalScale) ? column.format?.decimalScale : undefined,
|
|
663
|
+
fixedDecimalScale: !isEmpty(column.format?.fixedDecimalScale) ? column.format?.fixedDecimalScale : false,
|
|
664
|
+
allowNegative: column.format?.allowNegative ?? true,
|
|
665
|
+
prefix: column.format?.prefix ?? undefined,
|
|
666
|
+
suffix: column.format?.suffix ?? undefined
|
|
667
|
+
};
|
|
668
|
+
return /*#__PURE__*/React.createElement(NumericFormat, _extends({
|
|
669
|
+
id: `col${indexCol}-record${indexRow}`
|
|
670
|
+
}, numericFormatProps, {
|
|
671
|
+
min: column.min,
|
|
672
|
+
max: column.max,
|
|
673
|
+
customInput: Input
|
|
674
|
+
// valueIsNumericString={true}
|
|
675
|
+
,
|
|
676
|
+
autoComplete: 'off',
|
|
677
|
+
className: classNames('be-cell-editing rounded-0 input-element', {
|
|
678
|
+
'is-invalid': isInvalid,
|
|
679
|
+
'be-cell-edit-align-center': column.align === 'center',
|
|
680
|
+
'be-cell-edit-align-left': column.align === 'left',
|
|
681
|
+
'be-cell-edit-align-right': !column.align || column.align === 'right'
|
|
682
|
+
})
|
|
683
|
+
|
|
684
|
+
// onFocus={(e) => {
|
|
685
|
+
// e.target.setSelectionRange(0, e.target.innerText.length - 1)
|
|
686
|
+
// }}
|
|
687
|
+
,
|
|
688
|
+
|
|
689
|
+
onValueChange: values => {
|
|
690
|
+
onChange(values?.floatValue);
|
|
691
|
+
},
|
|
692
|
+
onBlur: () => {
|
|
693
|
+
const formState = getValues();
|
|
694
|
+
const itemState = getValues(dataIndex);
|
|
695
|
+
|
|
696
|
+
// @ts-ignore
|
|
697
|
+
const prevState = record[dataIndex];
|
|
698
|
+
const newState = value;
|
|
699
|
+
|
|
700
|
+
// @ts-ignore
|
|
701
|
+
if (itemState !== record[dataIndex]) {
|
|
702
|
+
// @ts-ignore
|
|
703
|
+
handleCellChange?.({
|
|
704
|
+
key: record[rowKey],
|
|
705
|
+
record: formState,
|
|
706
|
+
prevState,
|
|
707
|
+
newState,
|
|
708
|
+
type: 'blur'
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// onBlur={() => {
|
|
714
|
+
// const tempValue = tempResource[indexRow][column.dataIndex]
|
|
715
|
+
//
|
|
716
|
+
// if (indexFocus !== -1 && tempValue !== valueNumeric) {
|
|
717
|
+
// if (column.min || column.min === 0 || column.max || column.max === 0) {
|
|
718
|
+
// handleCellChange(valueNumeric, valueNumeric, record, col, indexRow, indexCol)
|
|
719
|
+
// } else {
|
|
720
|
+
// handleCellChange(valueNumeric, valueNumeric, record, col, indexRow, indexCol)
|
|
721
|
+
// }
|
|
722
|
+
// }
|
|
723
|
+
//
|
|
724
|
+
// }}
|
|
725
|
+
|
|
726
|
+
// onPaste={(e: any) => handleOnCellPaste(e, indexRow, indexCol)}
|
|
727
|
+
|
|
728
|
+
// onKeyDown={(e: any) => {
|
|
729
|
+
// onInputKeydown(e, floatValue, floatValue, record, col, indexRow, indexCol)
|
|
730
|
+
//
|
|
731
|
+
// }}
|
|
732
|
+
}));
|
|
733
|
+
default:
|
|
734
|
+
return /*#__PURE__*/React.createElement(Input, {
|
|
735
|
+
id: `col${indexCol}-record${indexRow}`,
|
|
736
|
+
style: {
|
|
737
|
+
textAlign: column.align
|
|
738
|
+
}
|
|
739
|
+
// @ts-ignore
|
|
740
|
+
// value={!isNullOrUndefined(record[column.dataIndex]) ? record[column.dataIndex] : ''}
|
|
741
|
+
,
|
|
742
|
+
disabled: isDisable(column, record) ?? false,
|
|
743
|
+
className: classNames('be-cell-editing rounded-0 input-element'),
|
|
744
|
+
value: !isNullOrUndefined(value) ? value : '',
|
|
745
|
+
onBlur: () => {
|
|
746
|
+
const formState = getValues();
|
|
747
|
+
const itemState = getValues(dataIndex);
|
|
748
|
+
// // @ts-ignore
|
|
749
|
+
// const prevState = record[dataIndex]
|
|
750
|
+
// const newState = value
|
|
751
|
+
//
|
|
752
|
+
// console.log('newState', newState)
|
|
753
|
+
// console.log('prevState', prevState)
|
|
754
|
+
|
|
755
|
+
// @ts-ignore
|
|
756
|
+
if (itemState !== record[dataIndex]) {
|
|
757
|
+
// @ts-ignore
|
|
758
|
+
handleCellChange?.({
|
|
759
|
+
key: record[rowKey],
|
|
760
|
+
record: formState,
|
|
761
|
+
type: 'blur'
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// onKeyDown={(e: any) => {
|
|
767
|
+
// console.log('onKeyDown edit', e.key)
|
|
768
|
+
// }}
|
|
769
|
+
,
|
|
770
|
+
|
|
771
|
+
onPressEnter: () => {
|
|
772
|
+
const formState = getValues();
|
|
773
|
+
const newState = getValues(dataIndex);
|
|
774
|
+
// @ts-ignore
|
|
775
|
+
const prevState = record[dataIndex];
|
|
776
|
+
// @ts-ignore
|
|
777
|
+
// if (itemState !== record[dataIndex]) {
|
|
778
|
+
// @ts-ignore
|
|
779
|
+
handleCellChange?.({
|
|
780
|
+
key: record[rowKey],
|
|
781
|
+
newState,
|
|
782
|
+
prevState,
|
|
783
|
+
record: formState,
|
|
784
|
+
type: 'enter'
|
|
785
|
+
});
|
|
786
|
+
// }
|
|
787
|
+
},
|
|
788
|
+
onChange: onChange
|
|
789
|
+
// onFocus={(e) => {
|
|
790
|
+
// e.target.setSelectionRange(0, e.target.innerText.length - 1)
|
|
791
|
+
// }}
|
|
792
|
+
// invalid={isInvalid}
|
|
793
|
+
|
|
794
|
+
// onChange={(val: any) => {
|
|
795
|
+
//
|
|
796
|
+
// handleCellUpdate('text', val.target?.value, record, col, indexRow, indexCol)
|
|
797
|
+
//
|
|
798
|
+
// }}
|
|
799
|
+
// onPaste={(e: any) => handleOnCellPaste(e, indexRow, indexCol)}
|
|
800
|
+
// onBlur={(val: any) => {
|
|
801
|
+
// const tempValue = tempResource[indexRow][column.dataIndex]
|
|
802
|
+
//
|
|
803
|
+
// if (indexFocus !== -1 && tempValue !== record[column.dataIndex]) {
|
|
804
|
+
//
|
|
805
|
+
// handleCellChange(val.target?.value, val.target?.value, record, col, indexRow, indexCol)
|
|
806
|
+
//
|
|
807
|
+
// }
|
|
808
|
+
// }}
|
|
809
|
+
// onKeyDown={(e: any) => {
|
|
810
|
+
// onInputKeydown(e, e.target?.value, e.target?.value, record, col, indexRow, indexCol)
|
|
811
|
+
// }}
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
return /*#__PURE__*/React.createElement("div", restProps, editing ?
|
|
816
|
+
/*#__PURE__*/
|
|
817
|
+
// <Form.Item
|
|
818
|
+
// name={dataIndex}
|
|
819
|
+
//
|
|
820
|
+
// style={{ margin: 0 }}
|
|
821
|
+
// // rules={[
|
|
822
|
+
// // {
|
|
823
|
+
// // required: true,
|
|
824
|
+
// // message: ``,
|
|
825
|
+
// //
|
|
826
|
+
// // },
|
|
827
|
+
// // ]}
|
|
828
|
+
// >
|
|
829
|
+
// {inputNode()}
|
|
830
|
+
// </Form.Item>
|
|
831
|
+
React.createElement(Controller, {
|
|
832
|
+
name: dataIndex,
|
|
833
|
+
control: control,
|
|
834
|
+
render: ({
|
|
835
|
+
field: {
|
|
836
|
+
value,
|
|
837
|
+
onChange
|
|
838
|
+
}
|
|
839
|
+
}) => inputNode(value, onChange)
|
|
840
|
+
}) : children);
|
|
841
|
+
};
|
|
842
|
+
export default EditableCell;
|