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