@lemon-fe/components 1.2.0-alpha.2 → 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/data-grid/cell-editors/select.d.ts +2 -2
- package/es/data-grid/cell-editors/select.js +3 -0
- package/es/data-grid/components/custom-panel/index.js +50 -6
- package/es/data-grid/components/custom-panel/item.d.ts +1 -0
- package/es/data-grid/components/custom-panel/item.js +3 -2
- package/es/data-grid/index.d.ts +1 -1
- package/es/data-grid/index.less +5 -1
- package/es/data-grid/locale/zh_CN.js +1 -1
- package/es/filter/locale/zh_CN.js +1 -1
- package/package.json +9 -5
|
@@ -2,7 +2,7 @@ import type { BaseOptionType, SelectProps } from 'antd/lib/select';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { ICellEditorParams } from '@ag-grid-community/core';
|
|
4
4
|
import type { ICellEditorReactComp } from '@ag-grid-community/react';
|
|
5
|
-
export declare type SelectEditorParams = Pick<SelectProps<any, BaseOptionType>, 'disabled' | 'options' | 'virtual' | 'showSearch' | 'listHeight' | 'allowClear' | 'mode'> & {
|
|
5
|
+
export declare type SelectEditorParams = Pick<SelectProps<any, BaseOptionType>, 'disabled' | 'options' | 'virtual' | 'showSearch' | 'listHeight' | 'allowClear' | 'mode' | 'optionFilterProp'> & {
|
|
6
6
|
fieldNames?: {
|
|
7
7
|
label: string;
|
|
8
8
|
value: string;
|
|
@@ -16,7 +16,7 @@ export declare type SelectEditorParams = Pick<SelectProps<any, BaseOptionType>,
|
|
|
16
16
|
*/
|
|
17
17
|
action?: 'next' | 'stop' | 'none';
|
|
18
18
|
};
|
|
19
|
-
declare const _default: React.ForwardRefExoticComponent<ICellEditorParams<any, any, any> & Pick<SelectProps<any, BaseOptionType>, "disabled" | "mode" | "virtual" | "allowClear" | "showSearch" | "options" | "listHeight"> & {
|
|
19
|
+
declare const _default: React.ForwardRefExoticComponent<ICellEditorParams<any, any, any> & Pick<SelectProps<any, BaseOptionType>, "disabled" | "mode" | "virtual" | "allowClear" | "showSearch" | "optionFilterProp" | "options" | "listHeight"> & {
|
|
20
20
|
fieldNames?: {
|
|
21
21
|
label: string;
|
|
22
22
|
value: string;
|
|
@@ -23,6 +23,8 @@ export default /*#__PURE__*/forwardRef(function SelectEditor(props, ref) {
|
|
|
23
23
|
valueByOption = props.valueByOption,
|
|
24
24
|
showSearch = props.showSearch,
|
|
25
25
|
listHeight = props.listHeight,
|
|
26
|
+
_props$optionFilterPr = props.optionFilterProp,
|
|
27
|
+
optionFilterProp = _props$optionFilterPr === void 0 ? 'value' : _props$optionFilterPr,
|
|
26
28
|
_props$action = props.action,
|
|
27
29
|
action = _props$action === void 0 ? 'next' : _props$action;
|
|
28
30
|
var _useState = useState(props.value),
|
|
@@ -88,6 +90,7 @@ export default /*#__PURE__*/forwardRef(function SelectEditor(props, ref) {
|
|
|
88
90
|
style: {
|
|
89
91
|
width: '100%'
|
|
90
92
|
},
|
|
93
|
+
optionFilterProp: optionFilterProp,
|
|
91
94
|
onChange: function onChange(changedValue, opt) {
|
|
92
95
|
if (valueByOption) {
|
|
93
96
|
setValue(opt);
|
|
@@ -9,7 +9,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
9
9
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
11
|
import { Button, Space, Tooltip, message } from 'antd';
|
|
12
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
12
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
13
13
|
import { createPortal } from 'react-dom';
|
|
14
14
|
import Icons from "../../../icons";
|
|
15
15
|
import { useLocaleReceiver } from "../../../locale-receiver";
|
|
@@ -52,6 +52,11 @@ export default function CustomColumnPanel(params) {
|
|
|
52
52
|
var _useLocaleReceiver = useLocaleReceiver('DataGrid'),
|
|
53
53
|
_useLocaleReceiver2 = _slicedToArray(_useLocaleReceiver, 1),
|
|
54
54
|
dataGridLocale = _useLocaleReceiver2[0];
|
|
55
|
+
var listContainer = useRef(null);
|
|
56
|
+
var _useState13 = useState(new Set()),
|
|
57
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
58
|
+
highlights = _useState14[0],
|
|
59
|
+
setHighlights = _useState14[1];
|
|
55
60
|
var handleColumnState = useDebounce(function () {
|
|
56
61
|
setState(columnApi.getColumnState());
|
|
57
62
|
}, 16);
|
|
@@ -95,9 +100,6 @@ export default function CustomColumnPanel(params) {
|
|
|
95
100
|
return;
|
|
96
101
|
}
|
|
97
102
|
var title = def.headerName || def.field || '';
|
|
98
|
-
if (keywords && !title.includes(keywords)) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
103
|
var originNode = {
|
|
102
104
|
index: idx,
|
|
103
105
|
key: item.colId,
|
|
@@ -146,7 +148,41 @@ export default function CustomColumnPanel(params) {
|
|
|
146
148
|
prevPath = path;
|
|
147
149
|
});
|
|
148
150
|
return items;
|
|
149
|
-
}, [state,
|
|
151
|
+
}, [state, columnApi]);
|
|
152
|
+
var handleSearch = function handleSearch() {
|
|
153
|
+
var index = -1;
|
|
154
|
+
var highlight = [];
|
|
155
|
+
if (keywords) {
|
|
156
|
+
var idx = 0;
|
|
157
|
+
var traverse = function traverse(items) {
|
|
158
|
+
items.forEach(function (item) {
|
|
159
|
+
var flag = item.title ? item.title.toUpperCase().includes(keywords.toUpperCase()) : false;
|
|
160
|
+
if (flag) {
|
|
161
|
+
highlight.push(item);
|
|
162
|
+
if (index === -1) {
|
|
163
|
+
index = idx;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
idx += 1;
|
|
167
|
+
traverse(item.children);
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
traverse(list);
|
|
171
|
+
}
|
|
172
|
+
if (listContainer.current === null) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
setHighlights(new Set(highlight.map(function (item) {
|
|
176
|
+
return item.key;
|
|
177
|
+
})));
|
|
178
|
+
if (index < 0) {
|
|
179
|
+
listContainer.current.scrollTop = 0;
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
var _listContainer$curren = listContainer.current.getBoundingClientRect(),
|
|
183
|
+
height = _listContainer$curren.height;
|
|
184
|
+
listContainer.current.scrollTop = Math.max(24 * index - height / 2, 0);
|
|
185
|
+
};
|
|
150
186
|
var grid = useGridStore(function (val) {
|
|
151
187
|
return val.grid;
|
|
152
188
|
});
|
|
@@ -193,10 +229,16 @@ export default function CustomColumnPanel(params) {
|
|
|
193
229
|
placeholder: dataGridLocale.searchText,
|
|
194
230
|
onChange: function onChange(e) {
|
|
195
231
|
handleChangeKeywords(e.target.value);
|
|
232
|
+
},
|
|
233
|
+
onKeyUp: function onKeyUp(e) {
|
|
234
|
+
if (e.key === 'Enter') {
|
|
235
|
+
handleSearch();
|
|
236
|
+
}
|
|
196
237
|
}
|
|
197
238
|
}), /*#__PURE__*/React.createElement("div", {
|
|
198
239
|
className: prefix('column-panel-icon'),
|
|
199
240
|
onClick: function onClick() {
|
|
241
|
+
setHighlights(new Set());
|
|
200
242
|
setSearching(false);
|
|
201
243
|
handleChangeKeywords('');
|
|
202
244
|
}
|
|
@@ -279,9 +321,11 @@ export default function CustomColumnPanel(params) {
|
|
|
279
321
|
}, /*#__PURE__*/React.createElement(DragContext.Provider, {
|
|
280
322
|
value: dragActive
|
|
281
323
|
}, /*#__PURE__*/React.createElement("div", {
|
|
282
|
-
className: prefix('column-panel-body')
|
|
324
|
+
className: prefix('column-panel-body'),
|
|
325
|
+
ref: listContainer
|
|
283
326
|
}, list.map(function (node) {
|
|
284
327
|
return /*#__PURE__*/React.createElement(ItemWrapper, {
|
|
328
|
+
highlights: highlights,
|
|
285
329
|
onEdit: function onEdit(v) {
|
|
286
330
|
var data = grid.getField(v.id);
|
|
287
331
|
if (data !== undefined) {
|
|
@@ -21,7 +21,8 @@ var Item = /*#__PURE__*/memo(function (props) {
|
|
|
21
21
|
level = props.level,
|
|
22
22
|
dragActive = props.dragActive,
|
|
23
23
|
onDelete = props.onDelete,
|
|
24
|
-
onEdit = props.onEdit
|
|
24
|
+
onEdit = props.onEdit,
|
|
25
|
+
highlights = props.highlights;
|
|
25
26
|
var column = node.column;
|
|
26
27
|
var colDef = (column === null || column === void 0 ? void 0 : column.getColDef()) || {};
|
|
27
28
|
var _useDraggable = useDraggable({
|
|
@@ -82,7 +83,7 @@ var Item = /*#__PURE__*/memo(function (props) {
|
|
|
82
83
|
style: {
|
|
83
84
|
paddingLeft: level * 20 + 8
|
|
84
85
|
},
|
|
85
|
-
className: classNames(prefix('column-panel-item'), dragActive ? prefix("column-panel-item-active-".concat(dragActive.indicator)) : undefined),
|
|
86
|
+
className: classNames(prefix('column-panel-item'), dragActive ? prefix("column-panel-item-active-".concat(dragActive.indicator)) : undefined, highlights.has(node.key) ? prefix('column-panel-item-highlight') : undefined),
|
|
86
87
|
ref: setDropRef
|
|
87
88
|
}, /*#__PURE__*/React.createElement("div", {
|
|
88
89
|
className: classNames('ag-wrapper ag-input-wrapper ag-checkbox-input-wrapper', {
|
package/es/data-grid/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ declare const Editors: {
|
|
|
16
16
|
Text: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").TextEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
17
17
|
Date: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").DateEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
18
18
|
Number: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").NumberEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
19
|
-
Select: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "mode" | "virtual" | "allowClear" | "showSearch" | "options" | "listHeight"> & {
|
|
19
|
+
Select: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "mode" | "virtual" | "allowClear" | "showSearch" | "optionFilterProp" | "options" | "listHeight"> & {
|
|
20
20
|
fieldNames?: {
|
|
21
21
|
label: string;
|
|
22
22
|
value: string;
|
package/es/data-grid/index.less
CHANGED
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
display: flex;
|
|
131
131
|
align-items: center;
|
|
132
132
|
height: 24px;
|
|
133
|
-
margin-top: 1px;
|
|
133
|
+
// margin-top: 1px;
|
|
134
134
|
padding: 0 8px;
|
|
135
135
|
|
|
136
136
|
&:hover {
|
|
@@ -175,6 +175,10 @@
|
|
|
175
175
|
&:hover &-operator {
|
|
176
176
|
opacity: 1;
|
|
177
177
|
}
|
|
178
|
+
|
|
179
|
+
&-highlight {
|
|
180
|
+
background-color: ~'var(--@{ant-prefix}-primary-2)';
|
|
181
|
+
}
|
|
178
182
|
}
|
|
179
183
|
|
|
180
184
|
&-drag-overlay {
|
package/package.json
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"author": "鲁盛杰 <lusj@cnlemon.net>",
|
|
8
|
+
"sideEffects": [
|
|
9
|
+
"es/index.less",
|
|
10
|
+
"src/index.less"
|
|
11
|
+
],
|
|
8
12
|
"main": "es/index.js",
|
|
9
13
|
"files": [
|
|
10
14
|
"es"
|
|
11
15
|
],
|
|
12
16
|
"scripts": {
|
|
13
17
|
"build": "father build",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
18
|
+
"prepublish": "npm run build",
|
|
19
|
+
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
16
20
|
},
|
|
17
21
|
"dependencies": {
|
|
18
22
|
"@ag-grid-community/client-side-row-model": "29.2.0",
|
|
@@ -22,7 +26,7 @@
|
|
|
22
26
|
"@ag-grid-community/react": "29.2.0",
|
|
23
27
|
"@ag-grid-community/styles": "29.2.0",
|
|
24
28
|
"@dnd-kit/core": "^6.0.8",
|
|
25
|
-
"@lemon-fe/hooks": "^1.2.0
|
|
29
|
+
"@lemon-fe/hooks": "^1.2.0",
|
|
26
30
|
"@lemon-fe/utils": "^1.1.0",
|
|
27
31
|
"async-validator": "^4.2.5",
|
|
28
32
|
"bignumber.js": ">=9.0.0",
|
|
@@ -62,5 +66,5 @@
|
|
|
62
66
|
"publishConfig": {
|
|
63
67
|
"registry": "https://registry.npmjs.org"
|
|
64
68
|
},
|
|
65
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "32c25ae162a45c94c5a4f791a9c6f3456f4ca4f7"
|
|
66
70
|
}
|