es-grid-template 0.1.1 → 0.1.2-1
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/grid-component/ColumnsChoose.js +25 -8
- package/es/grid-component/Command.js +6 -5
- package/es/grid-component/ContextMenu.d.ts +2 -2
- package/es/grid-component/ContextMenu.js +1 -0
- package/es/grid-component/EditableCell.js +265 -248
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.js +24 -16
- package/es/grid-component/TableGrid.js +2 -1
- package/es/grid-component/async-select/index.d.ts +9 -0
- package/es/grid-component/async-select/index.js +35 -0
- package/es/grid-component/hooks/constant.d.ts +10 -0
- package/es/grid-component/hooks/constant.js +11 -1
- package/es/grid-component/hooks/useColumns/index.js +7 -4
- package/es/grid-component/hooks/utils.d.ts +2 -0
- package/es/grid-component/hooks/utils.js +11 -0
- package/es/grid-component/index.d.ts +3 -2
- package/es/grid-component/styles.scss +89 -30
- package/es/grid-component/table/Grid.js +7 -6
- package/es/grid-component/table/GridEdit.d.ts +1 -1
- package/es/grid-component/table/GridEdit.js +19 -15
- package/es/grid-component/type.d.ts +6 -3
- package/es/grid-component/useContext.d.ts +2 -1
- package/es/index.d.ts +1 -1
- package/lib/grid-component/ColumnsChoose.js +25 -8
- package/lib/grid-component/Command.js +7 -5
- package/lib/grid-component/ContextMenu.d.ts +2 -2
- package/lib/grid-component/ContextMenu.js +2 -0
- package/lib/grid-component/EditableCell.js +262 -245
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.js +24 -16
- package/lib/grid-component/TableGrid.js +2 -1
- package/lib/grid-component/async-select/index.d.ts +9 -0
- package/lib/grid-component/async-select/index.js +44 -0
- package/lib/grid-component/hooks/constant.d.ts +10 -0
- package/lib/grid-component/hooks/constant.js +12 -2
- package/lib/grid-component/hooks/useColumns/index.js +7 -4
- package/lib/grid-component/hooks/utils.d.ts +2 -0
- package/lib/grid-component/hooks/utils.js +16 -3
- package/lib/grid-component/index.d.ts +3 -2
- package/lib/grid-component/styles.scss +89 -30
- package/lib/grid-component/table/Grid.js +7 -6
- package/lib/grid-component/table/GridEdit.d.ts +1 -1
- package/lib/grid-component/table/GridEdit.js +19 -15
- package/lib/grid-component/type.d.ts +6 -3
- package/lib/grid-component/useContext.d.ts +2 -1
- package/lib/index.d.ts +1 -1
- package/package.json +102 -113
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import React, { useContext } from "react";
|
|
3
|
-
import { Button, DatePicker, Divider, Input, TimePicker } from "antd";
|
|
3
|
+
import { Button, ColorPicker, DatePicker, Divider, Input, TimePicker, Row, Col } from "antd";
|
|
4
4
|
import { checkDecimalSeparator, checkThousandSeparator, checkFieldKey, convertArrayWithIndent, convertDateToDayjs,
|
|
5
5
|
// convertDayjsToDate,
|
|
6
6
|
convertLabelToTitle,
|
|
7
7
|
// customWeekStartEndFormat,
|
|
8
|
-
getDatepickerFormat, getTemplate, isDisable, isEmpty, isNullOrUndefined, customWeekStartEndFormat, convertDayjsToDate
|
|
8
|
+
getDatepickerFormat, getTemplate, isDisable, isEmpty, isNullOrUndefined, customWeekStartEndFormat, convertDayjsToDate, parseBooleanToValue, isColor, genPresets
|
|
9
9
|
// convertDayjsToDate
|
|
10
10
|
} from "./hooks";
|
|
11
11
|
// import moment from "moment";
|
|
12
12
|
// import dayjs from "dayjs";
|
|
13
13
|
import { TreeSelect } from "antd";
|
|
14
|
-
import { AsyncTableSelect } from "./async-table-select";
|
|
15
14
|
import classNames from "classnames";
|
|
16
15
|
import { NumericFormat } from "react-numeric-component";
|
|
17
16
|
import { TableContext } from "./useContext";
|
|
18
17
|
import dayjs from "dayjs";
|
|
19
18
|
import moment from "moment";
|
|
20
19
|
import { Controller } from "react-hook-form";
|
|
21
|
-
import { Select } from "rc-master-ui";
|
|
20
|
+
import { Checkbox, Select } from "rc-master-ui";
|
|
21
|
+
import { AsyncSelect } from "./async-select";
|
|
22
|
+
import { AsyncTableSelect } from "./async-table-select";
|
|
23
|
+
import { cyan, green, red, blue } from '@ant-design/colors';
|
|
22
24
|
|
|
23
25
|
// import moment from "moment";
|
|
24
26
|
|
|
@@ -59,16 +61,30 @@ const EditableCell = props => {
|
|
|
59
61
|
const dateTimePickerRef = React.useRef(null);
|
|
60
62
|
// const timePickerRef = React.useRef(null);
|
|
61
63
|
|
|
62
|
-
const isInvalid = false;
|
|
63
|
-
const keySelect = checkFieldKey(column?.editSelectSettings?.fieldKey);
|
|
64
|
-
const inputKey = column?.editSelectSettings?.inputKey;
|
|
65
|
-
const options = column?.editSelectSettings?.validateOption ? column?.editSelectSettings?.validateOption(record, column.dataIndex) : column?.editSelectSettings?.options ? column?.editSelectSettings?.options : [];
|
|
66
|
-
const optionsTree = column?.editSelectSettings?.validateOption ? convertArrayWithIndent(column?.editSelectSettings?.validateOption(record, column.dataIndex)) : column?.editSelectSettings?.options ? convertArrayWithIndent(column?.editSelectSettings?.options) : [];
|
|
67
64
|
const inputNode = (value, onChange) => {
|
|
68
65
|
const dateFormat = getDatepickerFormat(editType, column);
|
|
69
66
|
const date = !isEmpty(value) ? convertDateToDayjs(new Date(value), dateFormat) : null;
|
|
70
67
|
const maxDate = convertDateToDayjs(column.maxDate, dateFormat) ?? undefined;
|
|
71
68
|
const minDate = convertDateToDayjs(column.minDate, dateFormat) ?? undefined;
|
|
69
|
+
const {
|
|
70
|
+
fieldValue,
|
|
71
|
+
columns: selectColumns,
|
|
72
|
+
isMulti,
|
|
73
|
+
selectMode,
|
|
74
|
+
menuWidth,
|
|
75
|
+
fieldNames,
|
|
76
|
+
toolbarItems,
|
|
77
|
+
filterOption,
|
|
78
|
+
inputKey,
|
|
79
|
+
toolbarClick,
|
|
80
|
+
loadOptions,
|
|
81
|
+
validateOption,
|
|
82
|
+
options: selectOptions
|
|
83
|
+
} = column.editSelectSettings || {};
|
|
84
|
+
const isInvalid = false;
|
|
85
|
+
const keySelect = checkFieldKey(column?.editSelectSettings?.fieldKey);
|
|
86
|
+
const options = validateOption ? validateOption(record, column.dataIndex) : selectOptions ?? [];
|
|
87
|
+
const optionsTree = validateOption ? convertArrayWithIndent(validateOption(record, column.dataIndex)) : selectOptions ? convertArrayWithIndent(selectOptions) : [];
|
|
72
88
|
switch (editType) {
|
|
73
89
|
case 'date':
|
|
74
90
|
return /*#__PURE__*/React.createElement(DatePicker, {
|
|
@@ -94,6 +110,7 @@ const EditableCell = props => {
|
|
|
94
110
|
if (newState !== prevState) {
|
|
95
111
|
handleCellChange?.({
|
|
96
112
|
key: key,
|
|
113
|
+
field: column.field ?? column.dataIndex,
|
|
97
114
|
record: formState,
|
|
98
115
|
prevState,
|
|
99
116
|
newState,
|
|
@@ -126,12 +143,6 @@ const EditableCell = props => {
|
|
|
126
143
|
popupClassName: 'be-popup-container'
|
|
127
144
|
});
|
|
128
145
|
case 'datetime':
|
|
129
|
-
// const dateTimeFormat = getDatepickerFormat(editType, column)
|
|
130
|
-
// // @ts-ignore
|
|
131
|
-
// // const dateTimeValue = !isEmpty(record[column.dataIndex]) ? convertDateToDayjs(new Date(record[column.dataIndex]), dateTimeFormat) : null
|
|
132
|
-
// const maxDateTime = convertDateToDayjs(column.maxDate, dateTimeFormat) ?? undefined
|
|
133
|
-
// const minDateTime = convertDateToDayjs(column.minDate, dateTimeFormat) ?? undefined
|
|
134
|
-
|
|
135
146
|
return /*#__PURE__*/React.createElement(DatePicker
|
|
136
147
|
// id={`col${indexCol}-record${indexRow}`}
|
|
137
148
|
, {
|
|
@@ -171,6 +182,7 @@ const EditableCell = props => {
|
|
|
171
182
|
if (prevState !== newState) {
|
|
172
183
|
handleCellChange?.({
|
|
173
184
|
key: key,
|
|
185
|
+
field: column.field ?? column.dataIndex,
|
|
174
186
|
record: formState,
|
|
175
187
|
prevState,
|
|
176
188
|
newState,
|
|
@@ -245,7 +257,7 @@ const EditableCell = props => {
|
|
|
245
257
|
popupClassName: 'be-popup-container'
|
|
246
258
|
});
|
|
247
259
|
case 'selectTable':
|
|
248
|
-
const rr =
|
|
260
|
+
const rr = selectColumns ?? [];
|
|
249
261
|
const columnsTable = rr.map(colSelect => {
|
|
250
262
|
return {
|
|
251
263
|
title: colSelect.headerTemplate ? colSelect.headerTemplate : t ? t(colSelect.headerText) : colSelect.headerText,
|
|
@@ -264,53 +276,24 @@ const EditableCell = props => {
|
|
|
264
276
|
align: colSelect.textAlign
|
|
265
277
|
};
|
|
266
278
|
});
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
//
|
|
270
|
-
// if (column?.editSelectSettings?.isMulti || column?.editSelectSettings?.selectMode === 'checkbox') {
|
|
271
|
-
// 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
|
|
272
|
-
// } else {
|
|
273
|
-
// valueSelectTable = record[column?.editSelectSettings?.fieldValue ?? column.dataIndex] ?? ''
|
|
274
|
-
// }
|
|
275
|
-
//
|
|
276
|
-
// if (!valueSelectTable && column?.editSelectSettings?.defaultValue?.(record[column.dataIndex], record)) {
|
|
277
|
-
// valueSelectTable = column?.editSelectSettings?.defaultValue(record[column.dataIndex], record)
|
|
278
|
-
// }
|
|
279
|
-
//
|
|
280
|
-
//
|
|
281
|
-
|
|
282
|
-
let valueSelectTable;
|
|
283
|
-
if (column?.editSelectSettings?.isMulti || column?.editSelectSettings?.selectMode === 'checkbox') {
|
|
279
|
+
let valueSelectTable = value;
|
|
280
|
+
if (fieldValue) {
|
|
284
281
|
// @ts-ignore
|
|
285
|
-
valueSelectTable =
|
|
286
|
-
} else {
|
|
287
|
-
// const find = (!isNullOrUndefined(record[column.dataIndex]) && record[column.dataIndex] !== '') ? options?.find((val: any) => val[keySelect] === record[column?.editSelectSettings?.fieldValue ?? column.dataIndex]) : ''
|
|
288
|
-
// @ts-ignore
|
|
289
|
-
const find = !isNullOrUndefined(record[column.dataIndex]) && record[column.dataIndex] !== '' ? options?.find(val => val[keySelect] === record[column.dataIndex]) : '';
|
|
290
|
-
valueSelectTable = find ? {
|
|
291
|
-
label: find[column?.editSelectSettings?.inputKey ?? column.dataIndex],
|
|
292
|
-
// @ts-ignore
|
|
293
|
-
[column.dataIndex]: find[column?.editSelectSettings?.fieldValue ?? keySelect],
|
|
294
|
-
key: find[column?.editSelectSettings?.fieldValue ?? keySelect],
|
|
295
|
-
[keySelect]: find[column?.editSelectSettings?.fieldValue ?? keySelect]
|
|
296
|
-
} : '';
|
|
282
|
+
valueSelectTable = record[fieldValue] ?? value;
|
|
297
283
|
}
|
|
298
|
-
|
|
299
|
-
if (!valueSelectTable && column?.editSelectSettings?.defaultValue?.(record[column.dataIndex], record)) {
|
|
284
|
+
if (isMulti || selectMode === 'checkbox') {
|
|
300
285
|
// @ts-ignore
|
|
301
|
-
valueSelectTable = column
|
|
286
|
+
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;
|
|
302
287
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
288
|
+
return /*#__PURE__*/React.createElement(AsyncTableSelect
|
|
289
|
+
// id={`col${indexCol}-record${indexRow}`}
|
|
290
|
+
, {
|
|
306
291
|
columns: columnsTable,
|
|
307
292
|
options: options,
|
|
308
|
-
defaultOptions: options
|
|
309
|
-
|
|
310
|
-
,
|
|
311
|
-
value: value,
|
|
293
|
+
defaultOptions: options,
|
|
294
|
+
value: valueSelectTable,
|
|
312
295
|
onChange: (val, option) => {
|
|
313
|
-
onChange(val);
|
|
296
|
+
onChange(val ?? '');
|
|
314
297
|
const formState = getValues();
|
|
315
298
|
// const itemState = getValues(dataIndex)
|
|
316
299
|
// @ts-ignore
|
|
@@ -318,6 +301,7 @@ const EditableCell = props => {
|
|
|
318
301
|
const newState = val;
|
|
319
302
|
handleCellChange?.({
|
|
320
303
|
key: getRowKey?.(record, index),
|
|
304
|
+
field: column.field ?? column.dataIndex,
|
|
321
305
|
record: formState,
|
|
322
306
|
prevState,
|
|
323
307
|
newState,
|
|
@@ -326,9 +310,9 @@ const EditableCell = props => {
|
|
|
326
310
|
});
|
|
327
311
|
},
|
|
328
312
|
showSearch: true,
|
|
329
|
-
mode:
|
|
330
|
-
|
|
331
|
-
selectMode:
|
|
313
|
+
mode: isMulti || selectMode === 'checkbox' ? 'multiple' : undefined,
|
|
314
|
+
valueSelectAble: true,
|
|
315
|
+
selectMode: selectMode,
|
|
332
316
|
style: {
|
|
333
317
|
width: '100%',
|
|
334
318
|
height: '100%'
|
|
@@ -337,24 +321,24 @@ const EditableCell = props => {
|
|
|
337
321
|
allowClear: column.isClearable ?? false,
|
|
338
322
|
maxTagCount: 'responsive',
|
|
339
323
|
rowKey: keySelect,
|
|
340
|
-
popupMatchSelectWidth:
|
|
324
|
+
popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
|
|
341
325
|
optionFilterProp: "label",
|
|
342
326
|
popupClassName: 'be-popup-container',
|
|
343
|
-
loadOptions:
|
|
327
|
+
loadOptions: loadOptions,
|
|
344
328
|
status: isInvalid ? 'error' : undefined,
|
|
345
329
|
dropdownRender: menu => {
|
|
346
|
-
if (
|
|
330
|
+
if (toolbarItems && toolbarItems.length > 0) {
|
|
347
331
|
return /*#__PURE__*/React.createElement(React.Fragment, null, menu, /*#__PURE__*/React.createElement(Divider, {
|
|
348
332
|
style: {
|
|
349
333
|
margin: '8px 0'
|
|
350
334
|
}
|
|
351
335
|
}), /*#__PURE__*/React.createElement("div", {
|
|
352
336
|
className: 'toolbar-control d-flex justify-content-end'
|
|
353
|
-
},
|
|
337
|
+
}, toolbarItems.map(it => {
|
|
354
338
|
return /*#__PURE__*/React.createElement("div", {
|
|
355
339
|
key: it.key,
|
|
356
340
|
className: 'toolbar-item',
|
|
357
|
-
onClick: () =>
|
|
341
|
+
onClick: () => toolbarClick?.({
|
|
358
342
|
item: it,
|
|
359
343
|
column
|
|
360
344
|
})
|
|
@@ -366,88 +350,151 @@ const EditableCell = props => {
|
|
|
366
350
|
return /*#__PURE__*/React.createElement(React.Fragment, null, " ", menu);
|
|
367
351
|
}
|
|
368
352
|
},
|
|
369
|
-
filterOption:
|
|
370
|
-
fieldNames:
|
|
353
|
+
filterOption: filterOption,
|
|
354
|
+
fieldNames: fieldNames ? fieldNames : {
|
|
371
355
|
value: keySelect,
|
|
372
|
-
label:
|
|
356
|
+
label: inputKey ?? 'label'
|
|
373
357
|
}
|
|
374
358
|
});
|
|
375
359
|
case 'select':
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
// if (!valueCustomSelect && column?.editSelectSettings?.defaultValue) {
|
|
386
|
-
//
|
|
387
|
-
// if (column?.editSelectSettings.fieldLabel && record[column?.editSelectSettings.fieldLabel]) {
|
|
388
|
-
//
|
|
389
|
-
// // valueCustomSelect = {...column?.editSelectSettings?.defaultValue(record), label: record[column?.editSelectSettings.fieldLabel]}
|
|
390
|
-
// valueCustomSelect = {...column?.editSelectSettings?.defaultValue(record[column.dataIndex], record), label: record[column?.editSelectSettings.fieldLabel]}
|
|
391
|
-
//
|
|
392
|
-
// } else {
|
|
393
|
-
// valueCustomSelect = column?.editSelectSettings?.defaultValue(record[column.dataIndex], record)
|
|
394
|
-
//
|
|
395
|
-
// }
|
|
396
|
-
//
|
|
397
|
-
// }
|
|
398
|
-
|
|
360
|
+
let valueSelect = value;
|
|
361
|
+
if (fieldValue) {
|
|
362
|
+
// @ts-ignore
|
|
363
|
+
valueSelect = record[fieldValue] ?? value;
|
|
364
|
+
}
|
|
365
|
+
if (isMulti || selectMode === 'checkbox') {
|
|
366
|
+
// @ts-ignore
|
|
367
|
+
valueSelect = !isNullOrUndefined(record[column.dataIndex]) && Array.isArray(record[column.dataIndex]) && record[column.dataIndex]?.length > 0 ? options.filter(val => record[column.dataIndex]?.includes(val[keySelect])) : undefined;
|
|
368
|
+
}
|
|
399
369
|
return /*#__PURE__*/React.createElement(Select, {
|
|
400
|
-
|
|
370
|
+
options: options,
|
|
371
|
+
value: valueSelect,
|
|
372
|
+
onChange: (val, option) => {
|
|
373
|
+
onChange(val ?? '');
|
|
374
|
+
const formState = getValues();
|
|
375
|
+
// const itemState = getValues(dataIndex)
|
|
376
|
+
// @ts-ignore
|
|
377
|
+
const prevState = record[dataIndex];
|
|
378
|
+
const newState = val;
|
|
379
|
+
handleCellChange?.({
|
|
380
|
+
key: getRowKey?.(record, index),
|
|
381
|
+
field: column.field ?? column.dataIndex,
|
|
382
|
+
record: formState,
|
|
383
|
+
prevState,
|
|
384
|
+
newState,
|
|
385
|
+
option: option,
|
|
386
|
+
type: 'blur'
|
|
387
|
+
});
|
|
388
|
+
},
|
|
401
389
|
showSearch: true,
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
// isMulti={column?.editSelectSettings?.isMulti}
|
|
405
|
-
,
|
|
390
|
+
mode: isMulti || selectMode === 'checkbox' ? 'multiple' : undefined,
|
|
391
|
+
valueSelectAble: true,
|
|
406
392
|
style: {
|
|
407
|
-
width: '100%'
|
|
393
|
+
width: '100%',
|
|
394
|
+
height: '100%'
|
|
408
395
|
},
|
|
409
|
-
value: value
|
|
410
|
-
// options={options}
|
|
411
|
-
,
|
|
412
|
-
options: [{
|
|
413
|
-
value: 'jack',
|
|
414
|
-
label: 'Jack'
|
|
415
|
-
}, {
|
|
416
|
-
value: 'lucy',
|
|
417
|
-
label: 'Lucy'
|
|
418
|
-
}, {
|
|
419
|
-
value: 'Yiminghe',
|
|
420
|
-
label: 'yiminghe'
|
|
421
|
-
}, {
|
|
422
|
-
value: 'disabled',
|
|
423
|
-
label: 'Disabled',
|
|
424
|
-
disabled: true
|
|
425
|
-
}],
|
|
426
396
|
placeholder: t ? t('Select') : 'Select',
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
397
|
+
allowClear: column.isClearable ?? false,
|
|
398
|
+
maxTagCount: 'responsive',
|
|
399
|
+
popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
|
|
400
|
+
optionFilterProp: "label",
|
|
401
|
+
popupClassName: 'be-popup-container',
|
|
402
|
+
status: isInvalid ? 'error' : undefined,
|
|
403
|
+
filterOption: filterOption,
|
|
404
|
+
fieldNames: fieldNames ? fieldNames : {
|
|
405
|
+
value: keySelect,
|
|
406
|
+
label: inputKey ?? 'label'
|
|
430
407
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
408
|
+
});
|
|
409
|
+
case 'asyncSelect':
|
|
410
|
+
let valueAsyncSelect = value;
|
|
411
|
+
if (fieldValue) {
|
|
412
|
+
// @ts-ignore
|
|
413
|
+
valueAsyncSelect = record[fieldValue] ?? value;
|
|
414
|
+
}
|
|
415
|
+
if (isMulti || selectMode === 'checkbox') {
|
|
416
|
+
// @ts-ignore
|
|
417
|
+
valueAsyncSelect = !isNullOrUndefined(record[column.dataIndex]) && Array.isArray(record[column.dataIndex]) && record[column.dataIndex]?.length > 0 ? options.filter(val => record[column.dataIndex]?.includes(val[keySelect])) : undefined;
|
|
418
|
+
}
|
|
419
|
+
return /*#__PURE__*/React.createElement(AsyncSelect, {
|
|
420
|
+
options: options,
|
|
421
|
+
defaultOptions: options,
|
|
422
|
+
value: valueAsyncSelect,
|
|
423
|
+
onChange: (val, option) => {
|
|
424
|
+
onChange(val ?? '');
|
|
425
|
+
const formState = getValues();
|
|
426
|
+
// const itemState = getValues(dataIndex)
|
|
427
|
+
// @ts-ignore
|
|
428
|
+
const prevState = record[dataIndex];
|
|
429
|
+
const newState = val;
|
|
430
|
+
handleCellChange?.({
|
|
431
|
+
key: getRowKey?.(record, index),
|
|
432
|
+
field: column.field ?? column.dataIndex,
|
|
433
|
+
record: formState,
|
|
434
|
+
prevState,
|
|
435
|
+
newState,
|
|
436
|
+
option: option,
|
|
437
|
+
type: 'blur'
|
|
438
|
+
});
|
|
439
|
+
},
|
|
440
|
+
showSearch: true,
|
|
441
|
+
mode: isMulti || selectMode === 'checkbox' ? 'multiple' : undefined,
|
|
442
|
+
valueSelectAble: true,
|
|
443
|
+
style: {
|
|
444
|
+
width: '100%',
|
|
445
|
+
height: '100%'
|
|
446
|
+
},
|
|
447
|
+
placeholder: t ? t('Select') : 'Select',
|
|
448
|
+
allowClear: column.isClearable ?? false,
|
|
449
|
+
maxTagCount: 'responsive',
|
|
450
|
+
popupMatchSelectWidth: menuWidth ? menuWidth + 10 : undefined,
|
|
451
|
+
optionFilterProp: "label",
|
|
452
|
+
popupClassName: 'be-popup-container',
|
|
453
|
+
loadOptions: loadOptions,
|
|
454
|
+
status: isInvalid ? 'error' : undefined
|
|
455
|
+
// dropdownRender={(menu) => {
|
|
456
|
+
// if (toolbarItems && toolbarItems.length > 0) {
|
|
457
|
+
// return (
|
|
458
|
+
// <>
|
|
459
|
+
// {menu}
|
|
460
|
+
// <Divider style={{margin: '8px 0'}}/>
|
|
461
|
+
//
|
|
462
|
+
// <div
|
|
463
|
+
// className={'toolbar-control d-flex justify-content-end'}
|
|
464
|
+
// >
|
|
465
|
+
// {toolbarItems.map((it) => {
|
|
466
|
+
// return (
|
|
467
|
+
// <div
|
|
468
|
+
// key={it.key}
|
|
469
|
+
// className={'toolbar-item'}
|
|
470
|
+
// onClick={() => toolbarClick?.({item: it, column})}
|
|
471
|
+
// >
|
|
472
|
+
// {it.template ? getTemplate(it.template) : (
|
|
473
|
+
// <Button className='toolbar-item-btn'>
|
|
435
474
|
//
|
|
436
|
-
//
|
|
437
|
-
//
|
|
438
|
-
//
|
|
475
|
+
// {it.icon && getTemplate(it.icon)}
|
|
476
|
+
// {it.title}
|
|
477
|
+
// </Button>
|
|
478
|
+
// )}
|
|
439
479
|
//
|
|
440
|
-
//
|
|
441
|
-
//
|
|
442
|
-
//
|
|
480
|
+
// </div>
|
|
481
|
+
// )
|
|
482
|
+
// })}
|
|
443
483
|
//
|
|
444
|
-
//
|
|
445
|
-
//
|
|
446
|
-
//
|
|
484
|
+
// </div>
|
|
485
|
+
// </>
|
|
486
|
+
// )
|
|
487
|
+
// } else {
|
|
488
|
+
// return <> {menu}</>
|
|
447
489
|
// }
|
|
490
|
+
//
|
|
448
491
|
// }}
|
|
449
492
|
,
|
|
450
|
-
|
|
493
|
+
filterOption: filterOption,
|
|
494
|
+
fieldNames: fieldNames ? fieldNames : {
|
|
495
|
+
value: keySelect,
|
|
496
|
+
label: inputKey ?? 'label'
|
|
497
|
+
}
|
|
451
498
|
});
|
|
452
499
|
case 'treeSelect':
|
|
453
500
|
// let valueTreeSelect
|
|
@@ -497,22 +544,35 @@ const EditableCell = props => {
|
|
|
497
544
|
status: isInvalid ? 'error' : undefined
|
|
498
545
|
});
|
|
499
546
|
case 'checkbox':
|
|
500
|
-
return /*#__PURE__*/React.createElement(
|
|
501
|
-
// @ts-ignore
|
|
502
|
-
, {
|
|
503
|
-
checked: record[column.dataIndex],
|
|
504
|
-
id: `col${indexCol}-record${indexRow}`,
|
|
505
|
-
type: "checkbox",
|
|
547
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
506
548
|
style: {
|
|
507
|
-
|
|
549
|
+
display: 'flex',
|
|
550
|
+
alignItems: 'center',
|
|
551
|
+
justifyContent: column.align ?? 'left',
|
|
552
|
+
paddingInline: 5,
|
|
553
|
+
height: '100%'
|
|
508
554
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
//
|
|
512
|
-
// }}
|
|
555
|
+
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
556
|
+
checked: Boolean(value)
|
|
557
|
+
// style={{ textAlign: column.align ?? 'left' }}
|
|
513
558
|
,
|
|
559
|
+
onChange: val => {
|
|
560
|
+
const newVal = parseBooleanToValue(val.target.checked, typeof value);
|
|
561
|
+
onChange(newVal);
|
|
562
|
+
const key = getRowKey?.(record, index);
|
|
563
|
+
const formState = getValues();
|
|
564
|
+
handleCellChange?.({
|
|
565
|
+
key: key,
|
|
566
|
+
record: formState,
|
|
567
|
+
option: value,
|
|
568
|
+
prevState: value,
|
|
569
|
+
newState: newVal,
|
|
570
|
+
field: column.field ?? column.dataIndex,
|
|
571
|
+
type: 'blur'
|
|
572
|
+
});
|
|
573
|
+
},
|
|
514
574
|
disabled: isDisable(column, record) ?? false
|
|
515
|
-
});
|
|
575
|
+
}));
|
|
516
576
|
|
|
517
577
|
// case 'form':
|
|
518
578
|
//
|
|
@@ -572,28 +632,50 @@ const EditableCell = props => {
|
|
|
572
632
|
// )
|
|
573
633
|
|
|
574
634
|
case 'color':
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
,
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
635
|
+
const color = isColor(value) ? value : '#ffffff';
|
|
636
|
+
const presets = genPresets({
|
|
637
|
+
blue,
|
|
638
|
+
red,
|
|
639
|
+
green,
|
|
640
|
+
cyan
|
|
641
|
+
});
|
|
642
|
+
return /*#__PURE__*/React.createElement(ColorPicker, {
|
|
643
|
+
value: color,
|
|
644
|
+
allowClear: column.isClearable ?? true,
|
|
645
|
+
onChangeComplete: valueColor => {
|
|
646
|
+
onChange(`#${valueColor.toHex()}`);
|
|
647
|
+
const key = getRowKey?.(record, index);
|
|
648
|
+
const formState = getValues();
|
|
649
|
+
handleCellChange?.({
|
|
650
|
+
key: key,
|
|
651
|
+
field: column.field ?? column.dataIndex,
|
|
652
|
+
option: `#${valueColor.toHex()}`,
|
|
653
|
+
record: formState,
|
|
654
|
+
prevState: value,
|
|
655
|
+
newState: `#${valueColor.toHex()}`,
|
|
656
|
+
type: 'blur'
|
|
657
|
+
});
|
|
658
|
+
},
|
|
659
|
+
presets: presets,
|
|
660
|
+
panelRender: (_, {
|
|
661
|
+
components: {
|
|
662
|
+
Picker,
|
|
663
|
+
Presets
|
|
664
|
+
}
|
|
665
|
+
}) => /*#__PURE__*/React.createElement(Row, {
|
|
666
|
+
justify: "space-between",
|
|
667
|
+
wrap: false,
|
|
668
|
+
className: "custom-panel be-popup-container"
|
|
669
|
+
}, /*#__PURE__*/React.createElement(Col, {
|
|
670
|
+
span: 12
|
|
671
|
+
}, /*#__PURE__*/React.createElement(Presets, null)), /*#__PURE__*/React.createElement(Divider, {
|
|
672
|
+
type: "vertical",
|
|
673
|
+
style: {
|
|
674
|
+
height: 'auto'
|
|
675
|
+
}
|
|
676
|
+
}), /*#__PURE__*/React.createElement(Col, {
|
|
677
|
+
flex: "auto"
|
|
678
|
+
}, /*#__PURE__*/React.createElement(Picker, null)))
|
|
597
679
|
});
|
|
598
680
|
|
|
599
681
|
// case 'image':
|
|
@@ -648,13 +730,7 @@ const EditableCell = props => {
|
|
|
648
730
|
'be-cell-edit-align-center': column.align === 'center',
|
|
649
731
|
'be-cell-edit-align-left': column.align === 'left',
|
|
650
732
|
'be-cell-edit-align-right': !column.align || column.align === 'right'
|
|
651
|
-
})
|
|
652
|
-
|
|
653
|
-
// onFocus={(e) => {
|
|
654
|
-
// e.target.setSelectionRange(0, e.target.innerText.length - 1)
|
|
655
|
-
// }}
|
|
656
|
-
,
|
|
657
|
-
|
|
733
|
+
}),
|
|
658
734
|
onValueChange: values => {
|
|
659
735
|
onChange(values?.floatValue);
|
|
660
736
|
},
|
|
@@ -665,12 +741,13 @@ const EditableCell = props => {
|
|
|
665
741
|
// @ts-ignore
|
|
666
742
|
const prevState = record[dataIndex];
|
|
667
743
|
const newState = value;
|
|
668
|
-
|
|
744
|
+
const key = getRowKey?.(record, index);
|
|
669
745
|
// @ts-ignore
|
|
670
746
|
if (itemState !== record[dataIndex]) {
|
|
671
|
-
// @ts-ignore
|
|
672
747
|
handleCellChange?.({
|
|
673
|
-
key:
|
|
748
|
+
key: key,
|
|
749
|
+
field: column.field ?? column.dataIndex,
|
|
750
|
+
option: newState,
|
|
674
751
|
record: formState,
|
|
675
752
|
prevState,
|
|
676
753
|
newState,
|
|
@@ -678,26 +755,6 @@ const EditableCell = props => {
|
|
|
678
755
|
});
|
|
679
756
|
}
|
|
680
757
|
}
|
|
681
|
-
|
|
682
|
-
// onBlur={() => {
|
|
683
|
-
// const tempValue = tempResource[indexRow][column.dataIndex]
|
|
684
|
-
//
|
|
685
|
-
// if (indexFocus !== -1 && tempValue !== valueNumeric) {
|
|
686
|
-
// if (column.min || column.min === 0 || column.max || column.max === 0) {
|
|
687
|
-
// handleCellChange(valueNumeric, valueNumeric, record, col, indexRow, indexCol)
|
|
688
|
-
// } else {
|
|
689
|
-
// handleCellChange(valueNumeric, valueNumeric, record, col, indexRow, indexCol)
|
|
690
|
-
// }
|
|
691
|
-
// }
|
|
692
|
-
//
|
|
693
|
-
// }}
|
|
694
|
-
|
|
695
|
-
// onPaste={(e: any) => handleOnCellPaste(e, indexRow, indexCol)}
|
|
696
|
-
|
|
697
|
-
// onKeyDown={(e: any) => {
|
|
698
|
-
// onInputKeydown(e, floatValue, floatValue, record, col, indexRow, indexCol)
|
|
699
|
-
//
|
|
700
|
-
// }}
|
|
701
758
|
}));
|
|
702
759
|
default:
|
|
703
760
|
return /*#__PURE__*/React.createElement(Input, {
|
|
@@ -713,30 +770,27 @@ const EditableCell = props => {
|
|
|
713
770
|
value: !isNullOrUndefined(value) ? value : '',
|
|
714
771
|
onBlur: () => {
|
|
715
772
|
const formState = getValues();
|
|
716
|
-
const itemState = getValues(dataIndex)
|
|
717
|
-
//
|
|
718
|
-
|
|
719
|
-
|
|
773
|
+
// const itemState = getValues(dataIndex)
|
|
774
|
+
// @ts-ignore
|
|
775
|
+
const prevState = record[dataIndex];
|
|
776
|
+
const newState = value;
|
|
720
777
|
//
|
|
721
778
|
// console.log('newState', newState)
|
|
722
779
|
// console.log('prevState', prevState)
|
|
723
|
-
|
|
780
|
+
const key = getRowKey?.(record, index);
|
|
724
781
|
// @ts-ignore
|
|
725
|
-
if (
|
|
726
|
-
// @ts-ignore
|
|
782
|
+
if (newState !== prevState) {
|
|
727
783
|
handleCellChange?.({
|
|
728
|
-
key:
|
|
784
|
+
key: key,
|
|
729
785
|
record: formState,
|
|
786
|
+
option: value,
|
|
787
|
+
prevState,
|
|
788
|
+
newState,
|
|
789
|
+
field: column.field ?? column.dataIndex,
|
|
730
790
|
type: 'blur'
|
|
731
791
|
});
|
|
732
792
|
}
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
// onKeyDown={(e: any) => {
|
|
736
|
-
// console.log('onKeyDown edit', e.key)
|
|
737
|
-
// }}
|
|
738
|
-
,
|
|
739
|
-
|
|
793
|
+
},
|
|
740
794
|
onPressEnter: () => {
|
|
741
795
|
const formState = getValues();
|
|
742
796
|
const newState = getValues(dataIndex);
|
|
@@ -755,49 +809,12 @@ const EditableCell = props => {
|
|
|
755
809
|
// }
|
|
756
810
|
},
|
|
757
811
|
onChange: onChange
|
|
758
|
-
// onFocus={(e) => {
|
|
759
|
-
// e.target.setSelectionRange(0, e.target.innerText.length - 1)
|
|
760
|
-
// }}
|
|
761
|
-
// invalid={isInvalid}
|
|
762
812
|
|
|
763
|
-
//
|
|
764
|
-
//
|
|
765
|
-
// handleCellUpdate('text', val.target?.value, record, col, indexRow, indexCol)
|
|
766
|
-
//
|
|
767
|
-
// }}
|
|
768
|
-
// onPaste={(e: any) => handleOnCellPaste(e, indexRow, indexCol)}
|
|
769
|
-
// onBlur={(val: any) => {
|
|
770
|
-
// const tempValue = tempResource[indexRow][column.dataIndex]
|
|
771
|
-
//
|
|
772
|
-
// if (indexFocus !== -1 && tempValue !== record[column.dataIndex]) {
|
|
773
|
-
//
|
|
774
|
-
// handleCellChange(val.target?.value, val.target?.value, record, col, indexRow, indexCol)
|
|
775
|
-
//
|
|
776
|
-
// }
|
|
777
|
-
// }}
|
|
778
|
-
// onKeyDown={(e: any) => {
|
|
779
|
-
// onInputKeydown(e, e.target?.value, e.target?.value, record, col, indexRow, indexCol)
|
|
780
|
-
// }}
|
|
813
|
+
// invalid={isInvalid}
|
|
781
814
|
});
|
|
782
815
|
}
|
|
783
816
|
};
|
|
784
|
-
return /*#__PURE__*/React.createElement("div", restProps, editing ?
|
|
785
|
-
/*#__PURE__*/
|
|
786
|
-
// <Form.Item
|
|
787
|
-
// name={dataIndex}
|
|
788
|
-
//
|
|
789
|
-
// style={{ margin: 0 }}
|
|
790
|
-
// // rules={[
|
|
791
|
-
// // {
|
|
792
|
-
// // required: true,
|
|
793
|
-
// // message: ``,
|
|
794
|
-
// //
|
|
795
|
-
// // },
|
|
796
|
-
// // ]}
|
|
797
|
-
// >
|
|
798
|
-
// {inputNode()}
|
|
799
|
-
// </Form.Item>
|
|
800
|
-
React.createElement(Controller, {
|
|
817
|
+
return /*#__PURE__*/React.createElement("div", restProps, editing ? /*#__PURE__*/React.createElement(Controller, {
|
|
801
818
|
name: dataIndex,
|
|
802
819
|
control: control,
|
|
803
820
|
render: ({
|