@lemon-fe/components 1.4.22-alpha.6 → 1.4.22-alpha.9
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.
|
@@ -25,16 +25,18 @@ export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props,
|
|
|
25
25
|
searchFields = props.searchFields,
|
|
26
26
|
focusColumn = props.focusColumn,
|
|
27
27
|
_props$clearSelection = props.clearSelection,
|
|
28
|
-
clearSelection = _props$clearSelection === void 0 ? true : _props$clearSelection
|
|
28
|
+
clearSelection = _props$clearSelection === void 0 ? true : _props$clearSelection,
|
|
29
|
+
defaultValue = props.defaultValue,
|
|
30
|
+
onValueChange = props.onValueChange;
|
|
29
31
|
// 单行搜索大致耗时
|
|
30
32
|
var duration = useRef(0);
|
|
31
33
|
var defaultState = useMemo(function () {
|
|
32
34
|
return {
|
|
33
|
-
keywords: '',
|
|
35
|
+
keywords: defaultValue || '',
|
|
34
36
|
nodes: [],
|
|
35
37
|
index: -1
|
|
36
38
|
};
|
|
37
|
-
}, []);
|
|
39
|
+
}, [defaultValue]);
|
|
38
40
|
var grid = useGridStore(function (state) {
|
|
39
41
|
return state.grid;
|
|
40
42
|
});
|
|
@@ -75,6 +77,7 @@ export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props,
|
|
|
75
77
|
var handleSearch = useDebounce(function (str, prevState) {
|
|
76
78
|
var keywords = str.trim();
|
|
77
79
|
var start = performance.now();
|
|
80
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(keywords);
|
|
78
81
|
var finish = function finish(newState) {
|
|
79
82
|
searching.current = false;
|
|
80
83
|
setState(function (pre) {
|
|
@@ -253,6 +256,7 @@ export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props,
|
|
|
253
256
|
return /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Input, {
|
|
254
257
|
placeholder: placeholder || dataGridLocale.searchPlaceholderText,
|
|
255
258
|
value: state.keywords,
|
|
259
|
+
defaultValue: defaultValue,
|
|
256
260
|
size: "small",
|
|
257
261
|
onChange: function onChange(e) {
|
|
258
262
|
setState(function (prev) {
|
|
@@ -150,6 +150,12 @@ export interface DataGridSearch {
|
|
|
150
150
|
* 搜索后聚焦到哪个单元格,一般情况不要使用
|
|
151
151
|
*/
|
|
152
152
|
focusColumn?: string;
|
|
153
|
+
/**
|
|
154
|
+
* @description
|
|
155
|
+
* 关键字默认值
|
|
156
|
+
*/
|
|
157
|
+
defaultValue?: string;
|
|
158
|
+
onValueChange?: (value: string) => void;
|
|
153
159
|
}
|
|
154
160
|
export interface DataGridSearchRef {
|
|
155
161
|
reset: () => void;
|
package/es/sider-tree/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var _excluded = ["tabs", "children"],
|
|
2
|
-
_excluded2 = ["data", "showSearch", "placeholder", "onSelect", "filterNode", "operation", "header", "footer", "height", "filterKeepParents", "filterKeepDescendants", "highlightKeywords"];
|
|
2
|
+
_excluded2 = ["data", "showSearch", "placeholder", "onSelect", "filterNode", "operation", "header", "footer", "height", "filterKeepParents", "filterKeepDescendants", "highlightKeywords", "onScroll"];
|
|
3
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
4
|
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."); }
|
|
5
5
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -14,7 +14,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
14
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
15
|
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; }
|
|
16
16
|
import { Input, Tabs, Tree } from 'antd';
|
|
17
|
-
import React, { useMemo, useState } from 'react';
|
|
17
|
+
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
18
18
|
import { EmptyImage } from "../empty";
|
|
19
19
|
import Icons from "../icons";
|
|
20
20
|
import { useLocaleReceiver } from "../locale-receiver";
|
|
@@ -76,6 +76,7 @@ export default function SiderTree(props) {
|
|
|
76
76
|
filterKeepParents = props.filterKeepParents,
|
|
77
77
|
filterKeepDescendants = props.filterKeepDescendants,
|
|
78
78
|
highlightKeywords = props.highlightKeywords,
|
|
79
|
+
onScroll = props.onScroll,
|
|
79
80
|
restProps = _objectWithoutProperties(props, _excluded2);
|
|
80
81
|
var _useState = useState(''),
|
|
81
82
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -169,6 +170,15 @@ export default function SiderTree(props) {
|
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
172
|
var prefixCls = prefix();
|
|
173
|
+
|
|
174
|
+
/** 解决Firefox 元素隐藏后,列表的scrollTop会被重置,但是rc-tree没有监听到的问题 */
|
|
175
|
+
var list = useRef(null);
|
|
176
|
+
var shouldRecoverScroll = useRef(false);
|
|
177
|
+
var scrollTop = useRef(0);
|
|
178
|
+
var handleScroll = useCallback(function (e) {
|
|
179
|
+
scrollTop.current = e.currentTarget.scrollTop;
|
|
180
|
+
onScroll === null || onScroll === void 0 || onScroll(e);
|
|
181
|
+
}, [onScroll]);
|
|
172
182
|
var bodyContent = tree.length <= 0 ? /*#__PURE__*/React.createElement("div", {
|
|
173
183
|
className: prefix('empty')
|
|
174
184
|
}, /*#__PURE__*/React.createElement(EmptyImage, null), /*#__PURE__*/React.createElement("div", null, SiderTreeLocale.noDataText)) : /*#__PURE__*/React.createElement(Tree, _extends({
|
|
@@ -177,6 +187,7 @@ export default function SiderTree(props) {
|
|
|
177
187
|
itemHeight: 28,
|
|
178
188
|
showLine: true,
|
|
179
189
|
height: height,
|
|
190
|
+
ref: list,
|
|
180
191
|
titleRender: function titleRender(node) {
|
|
181
192
|
return /*#__PURE__*/React.createElement(TreeNodeTitle, {
|
|
182
193
|
operation: operation,
|
|
@@ -199,7 +210,8 @@ export default function SiderTree(props) {
|
|
|
199
210
|
verticalAlign: '-0.125em'
|
|
200
211
|
}
|
|
201
212
|
});
|
|
202
|
-
}
|
|
213
|
+
},
|
|
214
|
+
onScroll: handleScroll
|
|
203
215
|
}, restProps));
|
|
204
216
|
return /*#__PURE__*/React.createElement("div", {
|
|
205
217
|
className: prefix('wrapper')
|
|
@@ -209,6 +221,15 @@ export default function SiderTree(props) {
|
|
|
209
221
|
onResize: function onResize(e) {
|
|
210
222
|
if (e.height) {
|
|
211
223
|
setHeight(e.height);
|
|
224
|
+
if (shouldRecoverScroll.current) {
|
|
225
|
+
shouldRecoverScroll.current = false;
|
|
226
|
+
if (scrollTop.current) {
|
|
227
|
+
var _list$current;
|
|
228
|
+
(_list$current = list.current) === null || _list$current === void 0 || _list$current.scrollTo(scrollTop.current);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
shouldRecoverScroll.current = true;
|
|
212
233
|
}
|
|
213
234
|
}
|
|
214
235
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -216,7 +237,7 @@ export default function SiderTree(props) {
|
|
|
216
237
|
style: {
|
|
217
238
|
flex: 1
|
|
218
239
|
}
|
|
219
|
-
}, bodyContent)) : /*#__PURE__*/React.createElement("div", {
|
|
240
|
+
}, height ? bodyContent : null)) : /*#__PURE__*/React.createElement("div", {
|
|
220
241
|
className: prefix('body')
|
|
221
242
|
}, bodyContent), !!footer && /*#__PURE__*/React.createElement("div", {
|
|
222
243
|
className: prefix('footer')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/components",
|
|
3
|
-
"version": "1.4.22-alpha.
|
|
3
|
+
"version": "1.4.22-alpha.9",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"registry": "https://registry.npmjs.org"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "bc70577102696abab10fb21da93d27306a2ef222"
|
|
62
62
|
}
|