@lemon-fe/kits 1.0.2-0 → 1.0.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/components/DataGrid/cell-editors/Date.d.ts +10 -3
- package/es/components/DataGrid/cell-editors/Date.js +15 -3
- package/es/components/DataGrid/cell-editors/Select.d.ts +2 -2
- package/es/components/DataGrid/components/CustomColumnPanel/DragContext.d.ts +4 -0
- package/es/components/DataGrid/components/CustomColumnPanel/DragContext.js +3 -0
- package/es/components/DataGrid/components/CustomColumnPanel/FieldModal.d.ts +10 -0
- package/es/components/DataGrid/components/CustomColumnPanel/FieldModal.js +256 -0
- package/es/components/DataGrid/components/CustomColumnPanel/Item.d.ts +14 -0
- package/es/components/DataGrid/components/CustomColumnPanel/Item.js +200 -0
- package/es/components/DataGrid/components/CustomColumnPanel/index.d.ts +5 -0
- package/es/components/DataGrid/components/CustomColumnPanel/index.js +366 -0
- package/es/components/DataGrid/components/CustomColumnPanel/typings.d.ts +25 -0
- package/es/components/DataGrid/components/Search.js +2 -2
- package/es/components/DataGrid/components/Selected.js +3 -3
- package/es/components/DataGrid/index.d.ts +16 -7
- package/es/components/DataGrid/index.js +838 -364
- package/es/components/DataGrid/index.less +261 -8
- package/es/components/DataGrid/renderer/CellDeleteRenderer.d.ts +1 -1
- package/es/components/DataGrid/renderer/CellDeleteRenderer.js +49 -12
- package/es/components/DataGrid/renderer/CellIndexRenderer.js +6 -1
- package/es/components/DataGrid/renderer/DetailCellRenderer.d.ts +1 -0
- package/es/components/DataGrid/renderer/DetailCellRenderer.js +6 -3
- package/es/components/DataGrid/typings.d.ts +24 -5
- package/es/components/DataGrid/utils.d.ts +3 -1
- package/es/components/DataGrid/utils.js +13 -3
- package/es/components/Dropdown/index.d.ts +7 -8
- package/es/components/Dropdown/index.js +40 -47
- package/es/components/Dropdown/index.less +2 -10
- package/es/components/DurationPicker/index.d.ts +3 -1
- package/es/components/DurationPicker/index.js +13 -4
- package/es/components/Filter/index.d.ts +1 -1
- package/es/components/Filter/index.js +22 -8
- package/es/components/Filter/typings.d.ts +6 -1
- package/es/components/FormLayout/index.less +6 -2
- package/es/components/GreyPanel/index.less +5 -0
- package/es/components/Icons/Clear.d.ts +1 -1
- package/es/components/Icons/Clear.js +1 -2
- package/es/components/Icons/Drag/drag.svg +7 -0
- package/es/components/Icons/Drag/index.d.ts +3 -0
- package/es/components/Icons/Drag/index.js +34 -0
- package/es/components/Icons/NewTag.d.ts +3 -0
- package/es/components/Icons/NewTag.js +22 -0
- package/es/components/Icons/Plus/index.d.ts +3 -0
- package/es/components/Icons/Plus/index.js +30 -0
- package/es/components/Icons/Plus/plus.svg +6 -0
- package/es/components/Icons/Reload.d.ts +3 -0
- package/es/components/Icons/Reload.js +21 -0
- package/es/components/Icons/Tip.d.ts +1 -1
- package/es/components/Icons/Tip.js +1 -0
- package/es/components/Icons/index.d.ts +8 -0
- package/es/components/Icons/index.js +9 -1
- package/es/components/InputCompact/index.d.ts +1 -0
- package/es/components/InputCompact/index.js +19 -8
- package/es/components/InputCompact/index.less +15 -0
- package/es/components/InputNumber/index.d.ts +1 -1
- package/es/components/InputNumber/index.js +3 -1
- package/es/components/Layout/index.less +2 -1
- package/es/components/Popup/index.d.ts +1 -1
- package/es/components/Popup/index.js +68 -41
- package/es/components/Popup/index.less +3 -0
- package/es/components/SelectPanel/index.d.ts +17 -0
- package/es/components/SelectPanel/index.js +70 -0
- package/es/components/SelectPanel/index.less +112 -0
- package/es/components/SelectView/index.d.ts +6 -2
- package/es/components/SelectView/index.js +75 -40
- package/es/components/SelectView/index.less +19 -6
- package/es/components/SiderTree/index.js +2 -9
- package/es/components/SiderTree/index.less +6 -26
- package/es/components/State/index.d.ts +1 -1
- package/es/components/State/index.js +13 -3
- package/es/components/State/index.less +6 -1
- package/es/hooks/useBatchOperator/index.d.ts +40 -4
- package/es/hooks/useBatchOperator/index.js +591 -356
- package/es/hooks/useHistoryBlock/index.d.ts +8 -0
- package/es/hooks/useHistoryBlock/index.js +30 -0
- package/es/index.d.ts +4 -1
- package/es/index.js +4 -1
- package/es/index.less +1 -0
- package/es/init.js +26 -1
- package/es/layouts/MicroLayout/index.js +69 -5
- package/es/layouts/MicroLayout/typings.d.ts +4 -2
- package/es/layouts/TabInstance.d.ts +31 -0
- package/es/layouts/TabInstance.js +115 -0
- package/es/layouts/components/RouteTab.d.ts +7 -3
- package/es/layouts/components/RouteTab.js +6 -2
- package/es/layouts/utils.d.ts +1 -1
- package/es/layouts/utils.js +2 -2
- package/es/styles/overrides.less +34 -4
- package/es/styles/theme.less +20 -0
- package/es/styles/utils.less +17 -17
- package/package.json +5 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
|
|
3
|
+
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."); }
|
|
4
|
+
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
|
|
11
|
+
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."); }
|
|
12
|
+
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
18
|
+
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
+
|
|
21
|
+
import { DndContext, DragOverlay, closestCenter } from '@dnd-kit/core';
|
|
22
|
+
import { useDebounce, useRequest } from '@lemon-fe/hooks';
|
|
23
|
+
import { Button, Tooltip, message } from 'antd';
|
|
24
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
25
|
+
import { useGridStore } from "../../hooks";
|
|
26
|
+
import { prefix } from "../../utils";
|
|
27
|
+
import DragContext from "./DragContext";
|
|
28
|
+
import FieldModal from "./FieldModal";
|
|
29
|
+
import ItemWrapper from "./Item";
|
|
30
|
+
import Icons from "../../../Icons";
|
|
31
|
+
export default function CustomColumnPanel(params) {
|
|
32
|
+
var columnApi = params.columnApi,
|
|
33
|
+
api = params.api,
|
|
34
|
+
enableSave = params.enableSave;
|
|
35
|
+
|
|
36
|
+
var _useState = useState(false),
|
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
+
searching = _useState2[0],
|
|
39
|
+
setSearching = _useState2[1];
|
|
40
|
+
|
|
41
|
+
var _useState3 = useState(columnApi.getColumnState()),
|
|
42
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
43
|
+
state = _useState4[0],
|
|
44
|
+
setState = _useState4[1];
|
|
45
|
+
|
|
46
|
+
var _useState5 = useState(''),
|
|
47
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
48
|
+
overlay = _useState6[0],
|
|
49
|
+
setOverlay = _useState6[1];
|
|
50
|
+
|
|
51
|
+
var _useState7 = useState(),
|
|
52
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
53
|
+
dragActive = _useState8[0],
|
|
54
|
+
setDragActive = _useState8[1];
|
|
55
|
+
|
|
56
|
+
var _useState9 = useState(false),
|
|
57
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
58
|
+
field = _useState10[0],
|
|
59
|
+
setField = _useState10[1];
|
|
60
|
+
|
|
61
|
+
var _useState11 = useState(''),
|
|
62
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
63
|
+
keywords = _useState12[0],
|
|
64
|
+
setKeywords = _useState12[1];
|
|
65
|
+
|
|
66
|
+
var handleColumnState = useDebounce(function () {
|
|
67
|
+
setState(columnApi.getColumnState());
|
|
68
|
+
}, 16);
|
|
69
|
+
var handleChangeKeywords = useDebounce(setKeywords, 200);
|
|
70
|
+
useEffect(function () {
|
|
71
|
+
var handler = function handler(e) {
|
|
72
|
+
if (e.type === 'columnMoved' && !e.finished) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
handleColumnState();
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
api.addEventListener('columnMoved', handler);
|
|
80
|
+
api.addEventListener('columnPinned', handler);
|
|
81
|
+
api.addEventListener('columnResized', handler);
|
|
82
|
+
api.addEventListener('columnValueChanged', handler);
|
|
83
|
+
api.addEventListener('newColumnsLoaded', handler);
|
|
84
|
+
return function () {
|
|
85
|
+
api.removeEventListener('columnMoved', handler);
|
|
86
|
+
api.removeEventListener('columnPinned', handler);
|
|
87
|
+
api.removeEventListener('columnResized', handler);
|
|
88
|
+
api.removeEventListener('columnValueChanged', handler);
|
|
89
|
+
api.removeEventListener('newColumnsLoaded', handler);
|
|
90
|
+
};
|
|
91
|
+
}, []);
|
|
92
|
+
var list = useMemo(function () {
|
|
93
|
+
var items = [];
|
|
94
|
+
var prevPath = [];
|
|
95
|
+
|
|
96
|
+
var isUserColGroup = function isUserColGroup(colGroupDef) {
|
|
97
|
+
if (colGroupDef !== null && Object.keys(colGroupDef).length > 0) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return false;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
state.forEach(function (item, idx) {
|
|
105
|
+
var column = columnApi.getColumn(item.colId);
|
|
106
|
+
|
|
107
|
+
if (column === null) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
var def = column.getColDef();
|
|
112
|
+
|
|
113
|
+
if (def.suppressColumnsToolPanel) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
var title = def.headerName || def.field || '';
|
|
118
|
+
|
|
119
|
+
if (keywords && !title.includes(keywords)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
var originNode = {
|
|
124
|
+
index: idx,
|
|
125
|
+
key: item.colId,
|
|
126
|
+
id: item.colId,
|
|
127
|
+
column: column,
|
|
128
|
+
title: title,
|
|
129
|
+
children: [],
|
|
130
|
+
leaf: []
|
|
131
|
+
};
|
|
132
|
+
var node = originNode;
|
|
133
|
+
var path = [node];
|
|
134
|
+
var parent = column.getOriginalParent();
|
|
135
|
+
|
|
136
|
+
while (parent) {
|
|
137
|
+
var groupDef = parent.getColGroupDef();
|
|
138
|
+
|
|
139
|
+
if (!isUserColGroup(groupDef)) {
|
|
140
|
+
parent = parent.getOriginalParent();
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
var id = "$$group-".concat(parent.getGroupId());
|
|
145
|
+
var parentNode = {
|
|
146
|
+
index: idx,
|
|
147
|
+
key: "".concat(id, "-").concat(item.colId),
|
|
148
|
+
id: id,
|
|
149
|
+
children: [node],
|
|
150
|
+
title: groupDef.headerName,
|
|
151
|
+
leaf: [originNode]
|
|
152
|
+
};
|
|
153
|
+
node = parentNode;
|
|
154
|
+
path.unshift(node);
|
|
155
|
+
parent = parent.getOriginalParent();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
for (var i = 0; i < path.length; i++) {
|
|
159
|
+
var node1 = prevPath[i];
|
|
160
|
+
var node2 = path[i];
|
|
161
|
+
|
|
162
|
+
if (node1 !== undefined && node2 !== undefined && node1.id === node2.id) {
|
|
163
|
+
node1.children = [].concat(_toConsumableArray(node1.children), _toConsumableArray(node2.children));
|
|
164
|
+
node1.leaf = [].concat(_toConsumableArray(node1.leaf), _toConsumableArray(node2.leaf));
|
|
165
|
+
path[i] = node1;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (i === 0) {
|
|
170
|
+
items.push(path[0]);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
prevPath = path;
|
|
176
|
+
});
|
|
177
|
+
return items;
|
|
178
|
+
}, [state, keywords]);
|
|
179
|
+
var grid = useGridStore(function (val) {
|
|
180
|
+
return val.grid;
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
var _useRequest = useRequest(function () {
|
|
184
|
+
return grid.saveFields();
|
|
185
|
+
}, {
|
|
186
|
+
loadingState: true,
|
|
187
|
+
onSuccess: function onSuccess() {
|
|
188
|
+
message.success('操作成功');
|
|
189
|
+
}
|
|
190
|
+
}),
|
|
191
|
+
save = _useRequest.run,
|
|
192
|
+
loading = _useRequest.loading;
|
|
193
|
+
|
|
194
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
195
|
+
className: prefix('column-panel')
|
|
196
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
197
|
+
className: prefix('column-panel-header')
|
|
198
|
+
}, !searching ? /*#__PURE__*/React.createElement("div", {
|
|
199
|
+
className: prefix('column-panel-tools')
|
|
200
|
+
}, /*#__PURE__*/React.createElement("div", null, "\u663E\u793A"), /*#__PURE__*/React.createElement("div", {
|
|
201
|
+
className: prefix('column-panel-icon'),
|
|
202
|
+
style: {
|
|
203
|
+
marginLeft: 'auto'
|
|
204
|
+
},
|
|
205
|
+
onClick: function onClick() {
|
|
206
|
+
setSearching(true);
|
|
207
|
+
}
|
|
208
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
209
|
+
title: "\u641C\u7D22",
|
|
210
|
+
placement: "bottom"
|
|
211
|
+
}, /*#__PURE__*/React.createElement(Icons.Search, null))), /*#__PURE__*/React.createElement("div", {
|
|
212
|
+
className: prefix('column-panel-icon'),
|
|
213
|
+
onClick: function onClick() {
|
|
214
|
+
setField(true);
|
|
215
|
+
}
|
|
216
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
217
|
+
title: "\u6DFB\u52A0\u81EA\u5B9A\u4E49\u5217",
|
|
218
|
+
placement: "bottom"
|
|
219
|
+
}, /*#__PURE__*/React.createElement(Icons.Plus, null))), /*#__PURE__*/React.createElement("div", {
|
|
220
|
+
className: prefix('column-panel-icon'),
|
|
221
|
+
onClick: function onClick() {
|
|
222
|
+
grid.resetFields();
|
|
223
|
+
}
|
|
224
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
225
|
+
title: "\u91CD\u7F6E",
|
|
226
|
+
placement: "bottom"
|
|
227
|
+
}, /*#__PURE__*/React.createElement(Icons.Reload, null)))) : /*#__PURE__*/React.createElement("div", {
|
|
228
|
+
className: prefix('column-panel-search')
|
|
229
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
230
|
+
autoFocus: true,
|
|
231
|
+
placeholder: "\u641C\u7D22",
|
|
232
|
+
onChange: function onChange(e) {
|
|
233
|
+
handleChangeKeywords(e.target.value);
|
|
234
|
+
}
|
|
235
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
236
|
+
className: prefix('column-panel-icon'),
|
|
237
|
+
onClick: function onClick() {
|
|
238
|
+
setSearching(false);
|
|
239
|
+
handleChangeKeywords('');
|
|
240
|
+
}
|
|
241
|
+
}, /*#__PURE__*/React.createElement(Icons.Clear, null)))), /*#__PURE__*/React.createElement(DndContext, {
|
|
242
|
+
onDragStart: function onDragStart(e) {
|
|
243
|
+
var _e$active$data$curren;
|
|
244
|
+
|
|
245
|
+
setOverlay((_e$active$data$curren = e.active.data.current) === null || _e$active$data$curren === void 0 ? void 0 : _e$active$data$curren.title);
|
|
246
|
+
},
|
|
247
|
+
collisionDetection: closestCenter,
|
|
248
|
+
onDragMove: function onDragMove(e) {
|
|
249
|
+
var active = e.active,
|
|
250
|
+
over = e.over;
|
|
251
|
+
var drop;
|
|
252
|
+
|
|
253
|
+
if (active.rect.current.translated && over && !over.disabled) {
|
|
254
|
+
var overlayRect = active.rect.current.translated;
|
|
255
|
+
var targetRect = over.rect;
|
|
256
|
+
var overlayCenter = {
|
|
257
|
+
x: overlayRect.left + overlayRect.width / 2,
|
|
258
|
+
y: overlayRect.top + overlayRect.height / 2
|
|
259
|
+
};
|
|
260
|
+
var node = over.data.current;
|
|
261
|
+
var dragIndex = active.data.current.index;
|
|
262
|
+
var targetIndex = node.index;
|
|
263
|
+
|
|
264
|
+
if (dragIndex !== targetIndex) {
|
|
265
|
+
var targetCenter = {
|
|
266
|
+
x: targetRect.left + targetRect.width / 2,
|
|
267
|
+
y: targetRect.top + targetRect.height / 2
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
if (overlayCenter.y >= targetCenter.y) {
|
|
271
|
+
if (dragIndex >= targetIndex) {
|
|
272
|
+
drop = {
|
|
273
|
+
indicator: 'bottom',
|
|
274
|
+
index: targetIndex + 1,
|
|
275
|
+
node: node
|
|
276
|
+
};
|
|
277
|
+
} else {
|
|
278
|
+
drop = {
|
|
279
|
+
indicator: 'bottom',
|
|
280
|
+
index: targetIndex,
|
|
281
|
+
node: node
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
if (dragIndex >= targetIndex) {
|
|
286
|
+
drop = {
|
|
287
|
+
indicator: 'top',
|
|
288
|
+
index: targetIndex,
|
|
289
|
+
node: node
|
|
290
|
+
};
|
|
291
|
+
} else {
|
|
292
|
+
drop = {
|
|
293
|
+
indicator: 'top',
|
|
294
|
+
index: targetIndex - 1,
|
|
295
|
+
node: node
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
setDragActive(drop);
|
|
303
|
+
},
|
|
304
|
+
onDragEnd: function onDragEnd(e) {
|
|
305
|
+
if (dragActive) {
|
|
306
|
+
var node = e.active.data.current;
|
|
307
|
+
|
|
308
|
+
if (node.column) {
|
|
309
|
+
columnApi.moveColumn(node.column, dragActive.index);
|
|
310
|
+
} else {
|
|
311
|
+
columnApi.moveColumns(node.leaf.map(function (item) {
|
|
312
|
+
return item.column;
|
|
313
|
+
}), dragActive.index);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
setOverlay('');
|
|
318
|
+
setDragActive(undefined);
|
|
319
|
+
},
|
|
320
|
+
onDragCancel: function onDragCancel() {
|
|
321
|
+
setOverlay('');
|
|
322
|
+
setDragActive(undefined);
|
|
323
|
+
}
|
|
324
|
+
}, /*#__PURE__*/React.createElement(DragContext.Provider, {
|
|
325
|
+
value: dragActive
|
|
326
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
327
|
+
className: prefix('column-panel-body')
|
|
328
|
+
}, list.map(function (node) {
|
|
329
|
+
return /*#__PURE__*/React.createElement(ItemWrapper, {
|
|
330
|
+
onEdit: function onEdit(v) {
|
|
331
|
+
var data = grid.getField(v.id);
|
|
332
|
+
|
|
333
|
+
if (data !== undefined) {
|
|
334
|
+
setField(data);
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
onDelete: function onDelete(v) {
|
|
338
|
+
grid.deleteField(v.id);
|
|
339
|
+
},
|
|
340
|
+
node: node,
|
|
341
|
+
columnApi: columnApi,
|
|
342
|
+
api: api,
|
|
343
|
+
level: 0,
|
|
344
|
+
key: node.key
|
|
345
|
+
});
|
|
346
|
+
}))), /*#__PURE__*/React.createElement(DragOverlay, {
|
|
347
|
+
dropAnimation: null
|
|
348
|
+
}, overlay ? /*#__PURE__*/React.createElement("div", {
|
|
349
|
+
className: prefix('column-panel-drag-overlay')
|
|
350
|
+
}, overlay) : null)), enableSave ? /*#__PURE__*/React.createElement("div", {
|
|
351
|
+
className: prefix('column-panel-footer')
|
|
352
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
353
|
+
loading: loading,
|
|
354
|
+
type: "link",
|
|
355
|
+
onClick: save
|
|
356
|
+
}, "\u4FDD\u5B58")) : null, /*#__PURE__*/React.createElement(FieldModal, {
|
|
357
|
+
open: field,
|
|
358
|
+
nodes: list,
|
|
359
|
+
onCancel: function onCancel() {
|
|
360
|
+
setField(false);
|
|
361
|
+
},
|
|
362
|
+
onOk: function onOk(value) {
|
|
363
|
+
grid.setField(value);
|
|
364
|
+
}
|
|
365
|
+
}));
|
|
366
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Column } from '@ag-grid-community/core';
|
|
2
|
+
|
|
3
|
+
export type Node = {
|
|
4
|
+
index: number;
|
|
5
|
+
key: string;
|
|
6
|
+
id: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
column?: Column;
|
|
9
|
+
children: Node[];
|
|
10
|
+
leaf: Node[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type DragActive = {
|
|
14
|
+
node: Node;
|
|
15
|
+
indicator: 'top' | 'bottom';
|
|
16
|
+
index: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type FieldCol = {
|
|
20
|
+
summary: boolean;
|
|
21
|
+
summaryType: number;
|
|
22
|
+
expression: string;
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
@@ -78,7 +78,7 @@ export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props,
|
|
|
78
78
|
var col = cols[i];
|
|
79
79
|
var value = grid.api.getValue(col, node);
|
|
80
80
|
|
|
81
|
-
if (value !== undefined && value !== null && typeof value === 'string' && value.includes(keywords)) {
|
|
81
|
+
if (value !== undefined && value !== null && typeof value === 'string' && value.toUpperCase().includes(keywords.toUpperCase())) {
|
|
82
82
|
nodes.push({
|
|
83
83
|
index: idx,
|
|
84
84
|
id: node.id
|
|
@@ -119,7 +119,7 @@ export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props,
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
} else {
|
|
122
|
-
node.setSelected(true);
|
|
122
|
+
node.setSelected(true, true);
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
|
|
@@ -24,9 +24,9 @@ export default /*#__PURE__*/memo(function Selected(props) {
|
|
|
24
24
|
useEffect(function () {
|
|
25
25
|
return selection.listen(setKeys);
|
|
26
26
|
}, []);
|
|
27
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
27
|
+
return keys.length > 0 ? /*#__PURE__*/React.createElement("span", {
|
|
28
28
|
className: prefix('selected')
|
|
29
|
-
}, "\u5DF2\u9009", keys.length, "\u6761
|
|
29
|
+
}, "\u5DF2\u9009", keys.length, "\u6761", /*#__PURE__*/React.createElement("a", {
|
|
30
30
|
onClick: onClear
|
|
31
|
-
}, "\u6E05\u7A7A\u5DF2\u9009"));
|
|
31
|
+
}, "\u6E05\u7A7A\u5DF2\u9009")) : null;
|
|
32
32
|
});
|
|
@@ -2,6 +2,7 @@ import type { ColDef, IRowNode } from '@ag-grid-community/core';
|
|
|
2
2
|
import { GridApi, ColumnApi } from '@ag-grid-community/core';
|
|
3
3
|
import React, { Component } from 'react';
|
|
4
4
|
import EditorWrapper from './cell-editors/Wrapper';
|
|
5
|
+
import type { FieldCol } from './components/CustomColumnPanel/typings';
|
|
5
6
|
import type { ColType, DataGridProps, DataGridState } from './typings';
|
|
6
7
|
export default class DataGrid<TData extends Record<string, any>> extends Component<DataGridProps<TData>, DataGridState<TData>> {
|
|
7
8
|
api: GridApi<TData>;
|
|
@@ -17,6 +18,7 @@ export default class DataGrid<TData extends Record<string, any>> extends Compone
|
|
|
17
18
|
private sideBarDef;
|
|
18
19
|
private searchRef;
|
|
19
20
|
private prevFocusedCell;
|
|
21
|
+
private fields;
|
|
20
22
|
static defaultProps: {
|
|
21
23
|
stopEditingWhenCellsLoseFocus: boolean;
|
|
22
24
|
autoLoad: boolean;
|
|
@@ -48,7 +50,7 @@ export default class DataGrid<TData extends Record<string, any>> extends Compone
|
|
|
48
50
|
static EmptyCol: ColType<any>;
|
|
49
51
|
static Editors: {
|
|
50
52
|
Text: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").TextEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
51
|
-
Date: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").DateEditorParams & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
53
|
+
Date: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").DateEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
52
54
|
Number: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").NumberEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
53
55
|
Select: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "allowClear" | "mode" | "options" | "virtual" | "showSearch" | "listHeight"> & {
|
|
54
56
|
fieldNames?: {
|
|
@@ -60,28 +62,35 @@ export default class DataGrid<TData extends Record<string, any>> extends Compone
|
|
|
60
62
|
} & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
61
63
|
Wrapper: typeof EditorWrapper;
|
|
62
64
|
};
|
|
65
|
+
static isSummaryRow({ node }: {
|
|
66
|
+
node?: IRowNode<any>;
|
|
67
|
+
}): boolean;
|
|
63
68
|
constructor(props: DataGridProps<TData>);
|
|
69
|
+
setField(field: FieldCol): void;
|
|
70
|
+
getField(id: string): FieldCol | undefined;
|
|
71
|
+
deleteField(id: string): void;
|
|
72
|
+
saveFields(): Promise<void>;
|
|
73
|
+
resetFields(): void;
|
|
64
74
|
private getPagination;
|
|
65
75
|
componentDidUpdate(prevProps: DataGridProps<TData>): void;
|
|
66
76
|
componentWillUnmount(): void;
|
|
67
|
-
componentDidMount(): void
|
|
77
|
+
componentDidMount(): Promise<void>;
|
|
68
78
|
private syncColRender;
|
|
69
79
|
private syncSelection;
|
|
70
80
|
private syncRowData;
|
|
81
|
+
private getFieldsSummary;
|
|
82
|
+
private updateColumnDefs;
|
|
83
|
+
private getFullColumnDef;
|
|
71
84
|
private getColumnDefs;
|
|
72
|
-
|
|
85
|
+
isClientMode(): boolean;
|
|
73
86
|
private clearReadyQueue;
|
|
74
87
|
afterReady(cb: () => void): void;
|
|
75
88
|
private isPreserveSelected;
|
|
76
89
|
private updateRowData;
|
|
77
|
-
isSummaryRow({ node }: {
|
|
78
|
-
node?: IRowNode<any>;
|
|
79
|
-
}): boolean;
|
|
80
90
|
private getSummaryRowData;
|
|
81
91
|
private getDataFromServer;
|
|
82
92
|
private pagination;
|
|
83
93
|
private init;
|
|
84
|
-
private LoadingOverlay;
|
|
85
94
|
private NoRowsOverlay;
|
|
86
95
|
private getMainMenuItems;
|
|
87
96
|
private getRowId;
|