@lemon-fe/kits 1.0.0-13 → 1.0.0-15
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/components/Actions/index.js +4 -3
- package/es/components/DataGrid/cell-editors/Custom.js +8 -2
- package/es/components/DataGrid/cell-editors/Number.d.ts +14 -0
- package/es/components/DataGrid/cell-editors/Number.js +20 -9
- package/es/components/DataGrid/cell-editors/Select.js +5 -6
- package/es/components/DataGrid/index.d.ts +1 -0
- package/es/components/DataGrid/index.js +114 -67
- package/es/components/DataGrid/index.less +4 -1
- package/es/components/DataGrid/typings.d.ts +3 -3
- package/es/components/SelectView/index.d.ts +1 -0
- package/es/components/SelectView/index.js +3 -2
- package/es/styles/utils.less +2 -2
- package/package.json +1 -1
|
@@ -89,7 +89,7 @@ function Actions(props) {
|
|
|
89
89
|
}));
|
|
90
90
|
|
|
91
91
|
if (handleClick !== undefined) {
|
|
92
|
-
return /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
92
|
+
return /*#__PURE__*/React.createElement(Dropdown.Button, _extends({
|
|
93
93
|
key: text,
|
|
94
94
|
disabled: disabled,
|
|
95
95
|
overlay: overlay,
|
|
@@ -100,10 +100,11 @@ function Actions(props) {
|
|
|
100
100
|
_ = _ref2[1];
|
|
101
101
|
|
|
102
102
|
return [leftBtn, /*#__PURE__*/React.createElement(Button, {
|
|
103
|
-
icon: /*#__PURE__*/React.createElement(Icons.More, null)
|
|
103
|
+
icon: /*#__PURE__*/React.createElement(Icons.More, null),
|
|
104
|
+
type: rest.type
|
|
104
105
|
})];
|
|
105
106
|
}
|
|
106
|
-
}, text);
|
|
107
|
+
}, rest), text);
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
1
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
8
|
|
|
3
9
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -97,9 +103,9 @@ export default /*#__PURE__*/forwardRef(function CustomEditor(props, ref) {
|
|
|
97
103
|
}
|
|
98
104
|
};
|
|
99
105
|
|
|
100
|
-
return /*#__PURE__*/React.createElement(EditorWrapper, null, editableRender(field ? get(value, field) : null, data, rowIndex, {
|
|
106
|
+
return /*#__PURE__*/React.createElement(EditorWrapper, null, editableRender(field ? get(value, field) : null, data, rowIndex, _objectSpread(_objectSpread({}, props), {}, {
|
|
101
107
|
context: context,
|
|
102
108
|
ref: elm,
|
|
103
109
|
onChange: handleChange
|
|
104
|
-
}));
|
|
110
|
+
})));
|
|
105
111
|
});
|
|
@@ -2,8 +2,22 @@ import React from 'react';
|
|
|
2
2
|
import type { ICellEditorReactComp } from '@ag-grid-community/react';
|
|
3
3
|
import type { ICellEditorParams } from '@ag-grid-community/core';
|
|
4
4
|
export interface NumberEditorParams {
|
|
5
|
+
/**
|
|
6
|
+
* @description 最小值
|
|
7
|
+
*/
|
|
5
8
|
min?: number;
|
|
9
|
+
/**
|
|
10
|
+
* @description 最大值
|
|
11
|
+
*/
|
|
6
12
|
max?: number;
|
|
13
|
+
/**
|
|
14
|
+
* @description 空值
|
|
15
|
+
*/
|
|
16
|
+
emptyValue?: number;
|
|
17
|
+
/**
|
|
18
|
+
* @description 当值不合理时,不修改单元格
|
|
19
|
+
*/
|
|
20
|
+
undoWhenError?: boolean;
|
|
7
21
|
}
|
|
8
22
|
declare const _default: React.ForwardRefExoticComponent<ICellEditorParams<any, any> & NumberEditorParams & React.RefAttributes<ICellEditorReactComp>>;
|
|
9
23
|
export default _default;
|
|
@@ -18,8 +18,12 @@ export default /*#__PURE__*/forwardRef(function NumberEditor(props, ref) {
|
|
|
18
18
|
var _props$value;
|
|
19
19
|
|
|
20
20
|
var cellStartedEdit = props.cellStartedEdit,
|
|
21
|
-
min = props.min,
|
|
22
|
-
|
|
21
|
+
_props$min = props.min,
|
|
22
|
+
min = _props$min === void 0 ? -99999999 : _props$min,
|
|
23
|
+
_props$max = props.max,
|
|
24
|
+
max = _props$max === void 0 ? 99999999 : _props$max,
|
|
25
|
+
emptyValue = props.emptyValue,
|
|
26
|
+
undoWhenError = props.undoWhenError;
|
|
23
27
|
|
|
24
28
|
var _useState = useState((_props$value = props.value) !== null && _props$value !== void 0 ? _props$value : null),
|
|
25
29
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -36,24 +40,31 @@ export default /*#__PURE__*/forwardRef(function NumberEditor(props, ref) {
|
|
|
36
40
|
}, [cellStartedEdit]);
|
|
37
41
|
|
|
38
42
|
var getValue = function getValue() {
|
|
39
|
-
if (value === '' || value === null) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
43
|
var val;
|
|
44
|
+
var error = false;
|
|
44
45
|
|
|
45
|
-
if (
|
|
46
|
+
if (value === '' || value === null) {
|
|
47
|
+
val = emptyValue !== null && emptyValue !== void 0 ? emptyValue : null;
|
|
48
|
+
} else if (typeof value === 'string') {
|
|
46
49
|
val = parseFloat(value);
|
|
47
50
|
} else {
|
|
48
51
|
val = value;
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
if (
|
|
54
|
+
if (val === null) {
|
|
55
|
+
error = true;
|
|
56
|
+
} else if (val < min) {
|
|
57
|
+
error = true;
|
|
52
58
|
val = min;
|
|
53
|
-
} else if (
|
|
59
|
+
} else if (val > max) {
|
|
60
|
+
error = true;
|
|
54
61
|
val = max;
|
|
55
62
|
}
|
|
56
63
|
|
|
64
|
+
if (error && undoWhenError) {
|
|
65
|
+
return props.value;
|
|
66
|
+
}
|
|
67
|
+
|
|
57
68
|
return val;
|
|
58
69
|
};
|
|
59
70
|
|
|
@@ -18,9 +18,10 @@ import { Select } from 'antd';
|
|
|
18
18
|
import EditorWrapper from "./Wrapper";
|
|
19
19
|
import { editorPrefixClass } from "./utils";
|
|
20
20
|
export default /*#__PURE__*/forwardRef(function SelectEditor(props, ref) {
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
var cellStartedEdit = props.cellStartedEdit,
|
|
22
|
+
cellEditorParams = props.colDef.cellEditorParams,
|
|
23
|
+
column = props.column,
|
|
24
|
+
node = props.node;
|
|
24
25
|
|
|
25
26
|
var _useState = useState(props.value),
|
|
26
27
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -62,9 +63,7 @@ export default /*#__PURE__*/forwardRef(function SelectEditor(props, ref) {
|
|
|
62
63
|
value: value,
|
|
63
64
|
onChange: function onChange(val) {
|
|
64
65
|
setValue(val);
|
|
65
|
-
|
|
66
|
-
stopEditing();
|
|
67
|
-
});
|
|
66
|
+
node.setDataValue(column, val);
|
|
68
67
|
}
|
|
69
68
|
})));
|
|
70
69
|
});
|
|
@@ -79,6 +79,7 @@ export default class DataGrid<TData> extends Component<DataGridProps<TData>, {
|
|
|
79
79
|
private validateRecord;
|
|
80
80
|
validate(): Promise<boolean>;
|
|
81
81
|
private cellValueChanged;
|
|
82
|
+
private rowDataUpdated;
|
|
82
83
|
private cellEditingStop;
|
|
83
84
|
fetch(page?: number): void;
|
|
84
85
|
refresh(): void;
|
|
@@ -11,6 +11,16 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
11
11
|
|
|
12
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
13
|
|
|
14
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
15
|
+
|
|
16
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
|
+
|
|
18
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
19
|
+
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
+
|
|
14
24
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
15
25
|
|
|
16
26
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -23,16 +33,6 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
23
33
|
|
|
24
34
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
25
35
|
|
|
26
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
27
|
-
|
|
28
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
29
|
-
|
|
30
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
31
|
-
|
|
32
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
-
|
|
34
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
35
|
-
|
|
36
36
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
37
37
|
|
|
38
38
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -203,10 +203,47 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
_defineProperty(_assertThisInitialized(_this), "cellValueChanged", function (evt) {
|
|
206
|
-
var
|
|
206
|
+
var _this$props2 = _this.props,
|
|
207
|
+
onDataSouceChange = _this$props2.onDataSouceChange,
|
|
208
|
+
onCellValueChanged = _this$props2.onCellValueChanged;
|
|
209
|
+
|
|
210
|
+
if (onCellValueChanged) {
|
|
211
|
+
onCellValueChanged(evt);
|
|
212
|
+
}
|
|
207
213
|
|
|
208
214
|
if (onDataSouceChange !== undefined) {
|
|
209
|
-
|
|
215
|
+
/**
|
|
216
|
+
* 这么做是为了解决可编辑表格直接修改了原始数据的问题
|
|
217
|
+
*/
|
|
218
|
+
_this.dataSource = _toConsumableArray(_this.dataSource);
|
|
219
|
+
onDataSouceChange(_this.dataSource);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
_defineProperty(_assertThisInitialized(_this), "rowDataUpdated", function () {
|
|
224
|
+
if (!_this.isReady) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
var onDataSouceChange = _this.props.onDataSouceChange;
|
|
229
|
+
var data = [];
|
|
230
|
+
|
|
231
|
+
_this.api.forEachNode(function (rowNode) {
|
|
232
|
+
if (rowNode.data !== undefined) {
|
|
233
|
+
data.push(rowNode.data);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
/**
|
|
237
|
+
* 浅比较是为了防止通过设置props.dataSource触发onDataSourceChange
|
|
238
|
+
*/
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
if (!shallowEqual(data, _this.dataSource)) {
|
|
242
|
+
_this.dataSource = data;
|
|
243
|
+
|
|
244
|
+
if (onDataSouceChange !== undefined) {
|
|
245
|
+
onDataSouceChange(data);
|
|
246
|
+
}
|
|
210
247
|
}
|
|
211
248
|
});
|
|
212
249
|
|
|
@@ -240,9 +277,9 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
240
277
|
_createClass(DataGrid, [{
|
|
241
278
|
key: "getPagination",
|
|
242
279
|
value: function getPagination() {
|
|
243
|
-
var _this$
|
|
244
|
-
pagination = _this$
|
|
245
|
-
fetch = _this$
|
|
280
|
+
var _this$props3 = this.props,
|
|
281
|
+
pagination = _this$props3.pagination,
|
|
282
|
+
fetch = _this$props3.fetch;
|
|
246
283
|
var page = 1;
|
|
247
284
|
var pageSize = 50;
|
|
248
285
|
var total = 0;
|
|
@@ -275,12 +312,12 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
275
312
|
value: function componentDidUpdate(prevProps) {
|
|
276
313
|
var _prevProps$rowSelecti;
|
|
277
314
|
|
|
278
|
-
var _this$
|
|
279
|
-
columns = _this$
|
|
280
|
-
rowSelection = _this$
|
|
281
|
-
dataSource = _this$
|
|
282
|
-
context = _this$
|
|
283
|
-
loading = _this$
|
|
315
|
+
var _this$props4 = this.props,
|
|
316
|
+
columns = _this$props4.columns,
|
|
317
|
+
rowSelection = _this$props4.rowSelection,
|
|
318
|
+
dataSource = _this$props4.dataSource,
|
|
319
|
+
context = _this$props4.context,
|
|
320
|
+
loading = _this$props4.loading;
|
|
284
321
|
|
|
285
322
|
if (columns !== prevProps.columns) {
|
|
286
323
|
this.syncColRender();
|
|
@@ -311,11 +348,11 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
311
348
|
value: function syncColRender() {
|
|
312
349
|
var _this2 = this;
|
|
313
350
|
|
|
314
|
-
var _this$
|
|
315
|
-
_this$
|
|
316
|
-
columns = _this$
|
|
317
|
-
_this$
|
|
318
|
-
columnRenderMethods = _this$
|
|
351
|
+
var _this$props5 = this.props,
|
|
352
|
+
_this$props5$columns = _this$props5.columns,
|
|
353
|
+
columns = _this$props5$columns === void 0 ? [] : _this$props5$columns,
|
|
354
|
+
_this$props5$columnRe = _this$props5.columnRenderMethods,
|
|
355
|
+
columnRenderMethods = _this$props5$columnRe === void 0 ? ['title', 'render', 'editable.render'] : _this$props5$columnRe;
|
|
319
356
|
this.colRenderer.reset();
|
|
320
357
|
var descriptor = Object.create(null);
|
|
321
358
|
|
|
@@ -408,10 +445,10 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
408
445
|
value: function getColumDefs() {
|
|
409
446
|
var _this4 = this;
|
|
410
447
|
|
|
411
|
-
var _this$
|
|
412
|
-
_this$
|
|
413
|
-
columns = _this$
|
|
414
|
-
rowActions = _this$
|
|
448
|
+
var _this$props6 = this.props,
|
|
449
|
+
_this$props6$columns = _this$props6.columns,
|
|
450
|
+
columns = _this$props6$columns === void 0 ? [] : _this$props6$columns,
|
|
451
|
+
rowActions = _this$props6.rowActions;
|
|
415
452
|
|
|
416
453
|
var map = function map(cols) {
|
|
417
454
|
return cols.map(function (item) {
|
|
@@ -884,31 +921,39 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
884
921
|
var _validate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
885
922
|
var _this9 = this;
|
|
886
923
|
|
|
887
|
-
var result, flag, errors, failed;
|
|
924
|
+
var promises, result, flag, errors, failed;
|
|
888
925
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
889
926
|
while (1) {
|
|
890
927
|
switch (_context.prev = _context.next) {
|
|
891
928
|
case 0:
|
|
892
|
-
|
|
893
|
-
|
|
929
|
+
promises = [];
|
|
930
|
+
this.api.forEachNode(function (rowNode) {
|
|
931
|
+
var record = rowNode.data;
|
|
932
|
+
|
|
933
|
+
if (record === undefined) {
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
|
|
894
937
|
var rowId = _this9.getRowId({
|
|
895
938
|
data: record
|
|
896
939
|
});
|
|
897
940
|
|
|
898
941
|
if (_this9.validator === null) {
|
|
899
|
-
|
|
942
|
+
promises.push(Promise.resolve(true));
|
|
943
|
+
} else {
|
|
944
|
+
promises.push(_this9.validator.validate(record).catch(function (_ref5) {
|
|
945
|
+
var fields = _ref5.fields;
|
|
946
|
+
return Promise.reject({
|
|
947
|
+
id: rowId,
|
|
948
|
+
fields: fields
|
|
949
|
+
});
|
|
950
|
+
}));
|
|
900
951
|
}
|
|
952
|
+
});
|
|
953
|
+
_context.next = 4;
|
|
954
|
+
return Promise.allSettled(promises);
|
|
901
955
|
|
|
902
|
-
|
|
903
|
-
var fields = _ref5.fields;
|
|
904
|
-
return Promise.reject({
|
|
905
|
-
id: rowId,
|
|
906
|
-
fields: fields
|
|
907
|
-
});
|
|
908
|
-
});
|
|
909
|
-
}));
|
|
910
|
-
|
|
911
|
-
case 2:
|
|
956
|
+
case 4:
|
|
912
957
|
result = _context.sent;
|
|
913
958
|
flag = false;
|
|
914
959
|
errors = new Map();
|
|
@@ -931,7 +976,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
931
976
|
});
|
|
932
977
|
|
|
933
978
|
if (!flag) {
|
|
934
|
-
_context.next =
|
|
979
|
+
_context.next = 12;
|
|
935
980
|
break;
|
|
936
981
|
}
|
|
937
982
|
|
|
@@ -940,10 +985,10 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
940
985
|
});
|
|
941
986
|
return _context.abrupt("return", Promise.reject(failed));
|
|
942
987
|
|
|
943
|
-
case
|
|
988
|
+
case 12:
|
|
944
989
|
return _context.abrupt("return", true);
|
|
945
990
|
|
|
946
|
-
case
|
|
991
|
+
case 13:
|
|
947
992
|
case "end":
|
|
948
993
|
return _context.stop();
|
|
949
994
|
}
|
|
@@ -991,24 +1036,24 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
991
1036
|
value: function render() {
|
|
992
1037
|
var _this11 = this;
|
|
993
1038
|
|
|
994
|
-
var _this$
|
|
995
|
-
rowSelection = _this$
|
|
996
|
-
rowKey = _this$
|
|
997
|
-
fetch = _this$
|
|
998
|
-
dataSource = _this$
|
|
999
|
-
summary = _this$
|
|
1000
|
-
rowActions = _this$
|
|
1001
|
-
context = _this$
|
|
1002
|
-
onGridReady = _this$
|
|
1003
|
-
pagination = _this$
|
|
1004
|
-
columnTypesProp = _this$
|
|
1005
|
-
defaultColDefProp = _this$
|
|
1006
|
-
componentsProp = _this$
|
|
1007
|
-
columns = _this$
|
|
1008
|
-
loadingProp = _this$
|
|
1009
|
-
autoLoad = _this$
|
|
1010
|
-
sideBarProp = _this$
|
|
1011
|
-
restProps = _objectWithoutProperties(_this$
|
|
1039
|
+
var _this$props7 = this.props,
|
|
1040
|
+
rowSelection = _this$props7.rowSelection,
|
|
1041
|
+
rowKey = _this$props7.rowKey,
|
|
1042
|
+
fetch = _this$props7.fetch,
|
|
1043
|
+
dataSource = _this$props7.dataSource,
|
|
1044
|
+
summary = _this$props7.summary,
|
|
1045
|
+
rowActions = _this$props7.rowActions,
|
|
1046
|
+
context = _this$props7.context,
|
|
1047
|
+
onGridReady = _this$props7.onGridReady,
|
|
1048
|
+
pagination = _this$props7.pagination,
|
|
1049
|
+
columnTypesProp = _this$props7.columnTypes,
|
|
1050
|
+
defaultColDefProp = _this$props7.defaultColDef,
|
|
1051
|
+
componentsProp = _this$props7.components,
|
|
1052
|
+
columns = _this$props7.columns,
|
|
1053
|
+
loadingProp = _this$props7.loading,
|
|
1054
|
+
autoLoad = _this$props7.autoLoad,
|
|
1055
|
+
sideBarProp = _this$props7.sideBar,
|
|
1056
|
+
restProps = _objectWithoutProperties(_this$props7, _excluded4);
|
|
1012
1057
|
|
|
1013
1058
|
var _this$state2 = this.state,
|
|
1014
1059
|
colDefs = _this$state2.colDefs,
|
|
@@ -1030,8 +1075,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1030
1075
|
suppressPaginationPanel: true,
|
|
1031
1076
|
suppressCopyRowsToClipboard: true,
|
|
1032
1077
|
suppressColumnVirtualisation: true,
|
|
1033
|
-
|
|
1034
|
-
onCellEditingStopped: this.cellEditingStop,
|
|
1078
|
+
stopEditingWhenCellsLoseFocus: true,
|
|
1035
1079
|
loadingOverlayComponent: this.LoadingOverlay,
|
|
1036
1080
|
noRowsOverlayComponent: this.NoRowsOverlay,
|
|
1037
1081
|
getMainMenuItems: this.getMainMenuItems,
|
|
@@ -1040,6 +1084,9 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1040
1084
|
sideBar: sideBarProp === true ? this.sideBarDef : sideBarProp,
|
|
1041
1085
|
pinnedBottomRowData: Array.isArray(summary) ? summary : summary ? [summary] : undefined
|
|
1042
1086
|
}, restProps, {
|
|
1087
|
+
onRowDataUpdated: this.rowDataUpdated,
|
|
1088
|
+
onCellValueChanged: this.cellValueChanged,
|
|
1089
|
+
onCellEditingStopped: this.cellEditingStop,
|
|
1043
1090
|
pagination: enablePagination,
|
|
1044
1091
|
paginationPageSize: pageSize,
|
|
1045
1092
|
columnDefs: colDefs,
|
|
@@ -261,10 +261,13 @@
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
.ag-cell-inline-editing {
|
|
264
|
+
background-color: transparent;
|
|
264
265
|
height: calc(var(--ag-row-height) - 1px);
|
|
265
266
|
}
|
|
266
267
|
|
|
267
|
-
.ag-ltr
|
|
268
|
+
.ag-ltr
|
|
269
|
+
.ag-context-menu-open
|
|
270
|
+
.ag-cell-focus:not(.ag-cell-range-selected):not(.ag-cell-inline-editing),
|
|
268
271
|
.ag-ltr .ag-cell-focus:not(.ag-cell-range-selected):not(.ag-cell-inline-editing):focus-within,
|
|
269
272
|
.ag-rll .ag-cell-focus:not(.ag-cell-range-selected):not(.ag-cell-inline-editing):focus-within {
|
|
270
273
|
border-color: transparent;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AgGridReactProps } from '@ag-grid-community/react';
|
|
2
|
-
import type { ColDef, ColGroupDef, ICellRendererParams, IHeaderParams } from '@ag-grid-community/core';
|
|
2
|
+
import type { ColDef, ColGroupDef, ICellEditorParams, ICellRendererParams, IHeaderParams } from '@ag-grid-community/core';
|
|
3
3
|
import type { RuleItem } from 'async-validator/dist-types/interface';
|
|
4
4
|
import type { ReactElement, ReactNode, RefObject } from 'react';
|
|
5
|
-
export type { ColDef, ColGroupDef, ColumnState } from '@ag-grid-community/core';
|
|
5
|
+
export type { ColDef, ColGroupDef, ColumnState, GridApi, ICellEditorParams, ICellRendererParams, } from '@ag-grid-community/core';
|
|
6
6
|
export declare type GetRowKey<T> = string | ((data: T) => string);
|
|
7
7
|
export declare type PathType = string | (string | number)[];
|
|
8
8
|
export declare type ValidateRule<T> = Pick<RuleItem, 'required' | 'message' | 'pattern' | 'min' | 'max' | 'len' | 'type'> & {
|
|
@@ -16,7 +16,7 @@ export declare type EditableRender<T> = (val: any, record: T, index: number, par
|
|
|
16
16
|
blur?: () => void;
|
|
17
17
|
}>;
|
|
18
18
|
onChange: (val: Partial<T>, action?: 'stop' | 'next') => void;
|
|
19
|
-
}) => ReactNode;
|
|
19
|
+
} & ICellEditorParams) => ReactNode;
|
|
20
20
|
export interface ColumnType<TData> extends Omit<ColDef<TData>, 'editable'> {
|
|
21
21
|
title?: ReactNode | ((params: IHeaderParams) => ReactNode);
|
|
22
22
|
dataIndex?: PathType;
|
|
@@ -46,6 +46,7 @@ interface Props<RecordType, ParamsType extends Record<string, any>> {
|
|
|
46
46
|
style?: CSSProperties;
|
|
47
47
|
}) => ReactElement;
|
|
48
48
|
} & FilterProps<ParamsType>;
|
|
49
|
+
loading?: boolean;
|
|
49
50
|
}
|
|
50
51
|
export default function SelectView<RecordType extends Record<string | number, any>, ParamsType extends Record<string, any>>(props: Props<RecordType, ParamsType>): JSX.Element;
|
|
51
52
|
export {};
|
|
@@ -33,7 +33,6 @@ import Filter from "../Filter";
|
|
|
33
33
|
import DataGrid from "../DataGrid";
|
|
34
34
|
import { PREFIX_CLS } from "../../constants";
|
|
35
35
|
import { DeleteTwoTone } from '@ant-design/icons';
|
|
36
|
-
var defaultRows = [];
|
|
37
36
|
export default function SelectView(props) {
|
|
38
37
|
var emptyValue = useMemo(function () {
|
|
39
38
|
return [];
|
|
@@ -49,7 +48,8 @@ export default function SelectView(props) {
|
|
|
49
48
|
rowKey = props.rowKey,
|
|
50
49
|
filter = props.filter,
|
|
51
50
|
dataSource = props.dataSource,
|
|
52
|
-
rowFilter = props.rowFilter
|
|
51
|
+
rowFilter = props.rowFilter,
|
|
52
|
+
loading = props.loading;
|
|
53
53
|
var prefixCls = "".concat(PREFIX_CLS, "-select-view");
|
|
54
54
|
|
|
55
55
|
var _useState = useState(value || emptyValue),
|
|
@@ -196,6 +196,7 @@ export default function SelectView(props) {
|
|
|
196
196
|
},
|
|
197
197
|
dataSource: rows,
|
|
198
198
|
columns: columns,
|
|
199
|
+
loading: loading,
|
|
199
200
|
fetch: request,
|
|
200
201
|
pagination: true
|
|
201
202
|
}))));
|
package/es/styles/utils.less
CHANGED
|
@@ -100,11 +100,11 @@
|
|
|
100
100
|
|
|
101
101
|
&::-webkit-scrollbar-track {
|
|
102
102
|
background-color: #fff;
|
|
103
|
-
border-radius:
|
|
103
|
+
border-radius: 4px;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
&::-webkit-scrollbar-thumb {
|
|
107
107
|
background-color: #ddd;
|
|
108
|
-
border-radius:
|
|
108
|
+
border-radius: 4px;
|
|
109
109
|
}
|
|
110
110
|
}
|