shineout 1.12.12 → 1.12.13-beta.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/css/Select/Result.js +46 -94
- package/css/Select/ResultItem.js +71 -0
- package/css/Select/Select.js +6 -4
- package/css/Select/filter.js +56 -47
- package/css/index.d.ts +1 -1
- package/css/index.js +1 -1
- package/dist/shineout.js +3318 -3440
- package/dist/shineout.js.map +1 -1
- package/dist/shineout.min.js +1 -1
- package/es/Select/Result.js +42 -88
- package/es/Select/ResultItem.js +54 -0
- package/es/Select/Select.js +6 -4
- package/es/Select/filter.js +56 -47
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/lib/Select/Result.js +46 -94
- package/lib/Select/ResultItem.js +71 -0
- package/lib/Select/Select.js +6 -4
- package/lib/Select/filter.js +56 -47
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/css/Select/Result.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
5
5
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
6
|
|
|
7
7
|
exports.__esModule = true;
|
|
8
|
-
exports.default =
|
|
8
|
+
exports.default = void 0;
|
|
9
9
|
|
|
10
10
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
11
11
|
|
|
@@ -37,20 +37,18 @@ var _More = _interopRequireWildcard(require("./More"));
|
|
|
37
37
|
|
|
38
38
|
var _InputTitle = _interopRequireDefault(require("../InputTitle"));
|
|
39
39
|
|
|
40
|
-
var _uid = require("../utils/uid");
|
|
41
|
-
|
|
42
40
|
var _classname = require("../utils/classname");
|
|
43
41
|
|
|
44
|
-
var
|
|
42
|
+
var _shallowEqual = _interopRequireDefault(require("../utils/shallowEqual"));
|
|
43
|
+
|
|
44
|
+
var _ResultItem = _interopRequireDefault(require("./ResultItem"));
|
|
45
|
+
|
|
45
46
|
/**
|
|
46
47
|
* get result className from resultClassName attr
|
|
47
48
|
* @param {function | string} f props => resultClassName
|
|
48
49
|
* @param {any} value result value
|
|
49
50
|
* @returns {string | null}
|
|
50
51
|
*/
|
|
51
|
-
|
|
52
|
-
exports.IS_NOT_MATCHED_VALUE = IS_NOT_MATCHED_VALUE;
|
|
53
|
-
|
|
54
52
|
var getResultClassName = function getResultClassName(f, value) {
|
|
55
53
|
if ((0, _is.isFunc)(f)) {
|
|
56
54
|
return f((0, _is.isObject)(value) && value.IS_NOT_MATCHED_VALUE ? value.value : value);
|
|
@@ -70,32 +68,7 @@ var getResultContent = function getResultContent(data, renderResult, renderUnmat
|
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
return renderResult(data);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
function Item(_ref) {
|
|
77
|
-
var content = _ref.content,
|
|
78
|
-
data = _ref.data,
|
|
79
|
-
disabled = _ref.disabled,
|
|
80
|
-
onClick = _ref.onClick,
|
|
81
|
-
resultClassName = _ref.resultClassName,
|
|
82
|
-
_ref$title = _ref.title,
|
|
83
|
-
title = _ref$title === void 0 ? false : _ref$title,
|
|
84
|
-
only = _ref.only;
|
|
85
|
-
var value = data;
|
|
86
|
-
var click = disabled || !onClick ? undefined : function () {
|
|
87
|
-
return onClick(value);
|
|
88
|
-
};
|
|
89
|
-
var synDisabled = disabled || !click;
|
|
90
|
-
return _react.default.createElement("a", {
|
|
91
|
-
title: title && (0, _is.isString)(content) ? content : null,
|
|
92
|
-
tabIndex: -1,
|
|
93
|
-
className: (0, _classnames.default)((0, _styles.selectClass)((0, _classname.getDirectionClass)('item'), disabled && (0, _classname.getDirectionClass)('disabled'), synDisabled && (0, _classname.getDirectionClass)('ban'), only && 'item-only'), getResultClassName(resultClassName, data))
|
|
94
|
-
}, content, !synDisabled && _react.default.createElement("span", {
|
|
95
|
-
className: (0, _styles.selectClass)('indicator', 'close'),
|
|
96
|
-
onClick: click
|
|
97
|
-
}));
|
|
98
|
-
}
|
|
71
|
+
};
|
|
99
72
|
|
|
100
73
|
var Result =
|
|
101
74
|
/*#__PURE__*/
|
|
@@ -157,42 +130,17 @@ function (_PureComponent) {
|
|
|
157
130
|
|
|
158
131
|
_proto.updateMore = function updateMore(preProps) {
|
|
159
132
|
var _this$props = this.props,
|
|
160
|
-
result = _this$props.result,
|
|
161
133
|
compressed = _this$props.compressed,
|
|
162
134
|
onFilter = _this$props.onFilter,
|
|
163
|
-
|
|
164
|
-
data = _this$props.data;
|
|
135
|
+
values = _this$props.values;
|
|
165
136
|
|
|
166
137
|
if (compressed) {
|
|
167
138
|
if (this.isCompressedBound()) return;
|
|
168
|
-
var shouldRest =
|
|
169
|
-
|
|
170
|
-
if (preProps.result.length !== result.length || (data || []).length !== (preProps.data || []).length) {
|
|
171
|
-
shouldRest = true;
|
|
172
|
-
} else if (preProps.result !== result) {
|
|
173
|
-
var getUnMatchKey = function getUnMatchKey(d, k) {
|
|
174
|
-
return d && d.IS_NOT_MATCHED_VALUE ? d.value : (0, _uid.getKey)(d, k);
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
var isSameData = function isSameData(data1, data2, k) {
|
|
178
|
-
return getUnMatchKey(data1, k) === getUnMatchKey(data2, k);
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
var i = preProps.result.length - 1;
|
|
182
|
-
|
|
183
|
-
while (i >= 0) {
|
|
184
|
-
if (!isSameData(result[i], preProps.result[i], keygen)) {
|
|
185
|
-
shouldRest = true;
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
i -= 1;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
139
|
+
var shouldRest = !(0, _shallowEqual.default)(preProps.values, values);
|
|
192
140
|
|
|
193
141
|
if (shouldRest) {
|
|
194
142
|
this.resetMore();
|
|
195
|
-
} else if (
|
|
143
|
+
} else if ((values || []).length && this.shouldResetMore) {
|
|
196
144
|
this.shouldResetMore = false;
|
|
197
145
|
this.state.more = (0, _More.getResetMore)(onFilter, this.resultEl, this.resultEl.querySelectorAll("." + (0, _styles.selectClass)('item')));
|
|
198
146
|
this.forceUpdate();
|
|
@@ -220,20 +168,17 @@ function (_PureComponent) {
|
|
|
220
168
|
|
|
221
169
|
_proto.isEmptyResult = function isEmptyResult() {
|
|
222
170
|
var _this$props2 = this.props,
|
|
223
|
-
|
|
171
|
+
values = _this$props2.values,
|
|
224
172
|
renderResult = _this$props2.renderResult,
|
|
225
|
-
renderUnmatched = _this$props2.renderUnmatched
|
|
226
|
-
|
|
227
|
-
|
|
173
|
+
renderUnmatched = _this$props2.renderUnmatched,
|
|
174
|
+
getResultByValue = _this$props2.getResultByValue;
|
|
175
|
+
if (values.length <= 0) return true;
|
|
176
|
+
var hasValue = values.find(function (item) {
|
|
177
|
+
var cur = getResultByValue(item);
|
|
228
178
|
var r = getResultContent(cur, renderResult, renderUnmatched);
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return acc;
|
|
235
|
-
}, []);
|
|
236
|
-
return res.length <= 0;
|
|
179
|
+
return !(0, _is.isEmpty)(r);
|
|
180
|
+
});
|
|
181
|
+
return !hasValue;
|
|
237
182
|
};
|
|
238
183
|
|
|
239
184
|
_proto.handelMore = function handelMore(more) {
|
|
@@ -242,21 +187,26 @@ function (_PureComponent) {
|
|
|
242
187
|
});
|
|
243
188
|
};
|
|
244
189
|
|
|
245
|
-
_proto.renderItem = function renderItem(
|
|
190
|
+
_proto.renderItem = function renderItem(value, index) {
|
|
246
191
|
var _this$props3 = this.props,
|
|
247
192
|
renderResult = _this$props3.renderResult,
|
|
248
193
|
renderUnmatched = _this$props3.renderUnmatched,
|
|
249
194
|
datum = _this$props3.datum,
|
|
250
|
-
resultClassName = _this$props3.resultClassName
|
|
251
|
-
|
|
252
|
-
if (
|
|
195
|
+
resultClassName = _this$props3.resultClassName,
|
|
196
|
+
getResultByValue = _this$props3.getResultByValue;
|
|
197
|
+
if (value === null) return null;
|
|
253
198
|
var more = this.getCompressedBound();
|
|
254
|
-
return _react.default.createElement(
|
|
199
|
+
return _react.default.createElement(_ResultItem.default, {
|
|
255
200
|
key: index,
|
|
256
201
|
only: more === 1,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
202
|
+
value: value,
|
|
203
|
+
getDataByValue: getResultByValue,
|
|
204
|
+
getContent: function getContent(data) {
|
|
205
|
+
return getResultContent(data, renderResult, renderUnmatched);
|
|
206
|
+
},
|
|
207
|
+
isDisabled: function isDisabled(data) {
|
|
208
|
+
return datum.disabled(data);
|
|
209
|
+
},
|
|
260
210
|
onClick: this.handleRemove,
|
|
261
211
|
resultClassName: resultClassName,
|
|
262
212
|
title: true
|
|
@@ -285,10 +235,10 @@ function (_PureComponent) {
|
|
|
285
235
|
_proto.renderClear = function renderClear() {
|
|
286
236
|
var _this$props5 = this.props,
|
|
287
237
|
onClear = _this$props5.onClear,
|
|
288
|
-
|
|
289
|
-
|
|
238
|
+
disabled = _this$props5.disabled,
|
|
239
|
+
values = _this$props5.values;
|
|
290
240
|
|
|
291
|
-
if (onClear &&
|
|
241
|
+
if (onClear && values.length && disabled !== true) {
|
|
292
242
|
/* eslint-disable */
|
|
293
243
|
return _react.default.createElement("div", {
|
|
294
244
|
key: "clear",
|
|
@@ -368,16 +318,17 @@ function (_PureComponent) {
|
|
|
368
318
|
var _this$props8 = this.props,
|
|
369
319
|
multiple = _this$props8.multiple,
|
|
370
320
|
compressed = _this$props8.compressed,
|
|
371
|
-
result = _this$props8.result,
|
|
372
321
|
renderResult = _this$props8.renderResult,
|
|
373
322
|
renderUnmatched = _this$props8.renderUnmatched,
|
|
374
323
|
onFilter = _this$props8.onFilter,
|
|
375
324
|
focus = _this$props8.focus,
|
|
376
325
|
filterText = _this$props8.filterText,
|
|
377
|
-
resultClassName = _this$props8.resultClassName
|
|
326
|
+
resultClassName = _this$props8.resultClassName,
|
|
327
|
+
getResultByValue = _this$props8.getResultByValue;
|
|
328
|
+
var values = this.props.values || [];
|
|
378
329
|
|
|
379
330
|
if (multiple) {
|
|
380
|
-
var items =
|
|
331
|
+
var items = values.map(function (n, i) {
|
|
381
332
|
return _this2.renderItem(n, i);
|
|
382
333
|
}).filter(function (n) {
|
|
383
334
|
return !(0, _is.isEmpty)(n);
|
|
@@ -388,22 +339,24 @@ function (_PureComponent) {
|
|
|
388
339
|
}
|
|
389
340
|
|
|
390
341
|
if (focus && onFilter) {
|
|
391
|
-
items.push(this.renderInput(filterText,
|
|
342
|
+
items.push(this.renderInput(filterText, values.length));
|
|
392
343
|
}
|
|
393
344
|
|
|
394
345
|
return items;
|
|
395
346
|
}
|
|
396
347
|
|
|
348
|
+
var result0 = getResultByValue(values[0]);
|
|
349
|
+
|
|
397
350
|
if (onFilter) {
|
|
398
|
-
return this.renderInput(getResultContent(
|
|
351
|
+
return this.renderInput(getResultContent(result0, renderResult, renderUnmatched));
|
|
399
352
|
}
|
|
400
353
|
|
|
401
|
-
var v = getResultContent(
|
|
354
|
+
var v = getResultContent(result0, renderResult, renderUnmatched);
|
|
402
355
|
var title = (0, _is.isString)(v) ? v : undefined;
|
|
403
356
|
return _react.default.createElement("span", {
|
|
404
357
|
key: "result",
|
|
405
358
|
title: title,
|
|
406
|
-
className: (0, _classnames.default)((0, _styles.selectClass)('ellipsis'), getResultClassName(resultClassName,
|
|
359
|
+
className: (0, _classnames.default)((0, _styles.selectClass)('ellipsis'), getResultClassName(resultClassName, result0))
|
|
407
360
|
}, v);
|
|
408
361
|
};
|
|
409
362
|
|
|
@@ -461,7 +414,6 @@ Result.propTypes = {
|
|
|
461
414
|
onFilter: _propTypes.default.func,
|
|
462
415
|
onInputBlur: _propTypes.default.func,
|
|
463
416
|
onInputFocus: _propTypes.default.func,
|
|
464
|
-
result: _propTypes.default.array.isRequired,
|
|
465
417
|
renderResult: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]).isRequired,
|
|
466
418
|
placeholder: _propTypes.default.string,
|
|
467
419
|
setInputReset: _propTypes.default.func,
|
|
@@ -477,8 +429,8 @@ Result.propTypes = {
|
|
|
477
429
|
resultClassName: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]),
|
|
478
430
|
maxLength: _propTypes.default.number,
|
|
479
431
|
innerTitle: _propTypes.default.node,
|
|
480
|
-
|
|
481
|
-
|
|
432
|
+
values: _propTypes.default.array.isRequired,
|
|
433
|
+
getResultByValue: _propTypes.default.func,
|
|
482
434
|
convertBr: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func])
|
|
483
435
|
};
|
|
484
436
|
var _default = Result;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
6
|
+
|
|
7
|
+
exports.__esModule = true;
|
|
8
|
+
exports.default = Item;
|
|
9
|
+
exports.IS_NOT_MATCHED_VALUE = void 0;
|
|
10
|
+
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
|
|
13
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
|
+
|
|
15
|
+
var _styles = require("./styles");
|
|
16
|
+
|
|
17
|
+
var _is = require("../utils/is");
|
|
18
|
+
|
|
19
|
+
var _classname = require("../utils/classname");
|
|
20
|
+
|
|
21
|
+
var IS_NOT_MATCHED_VALUE = 'IS_NOT_MATCHED_VALUE';
|
|
22
|
+
/**
|
|
23
|
+
* get result className from resultClassName attr
|
|
24
|
+
* @param {function | string} f props => resultClassName
|
|
25
|
+
* @param {any} value result value
|
|
26
|
+
* @returns {string | null}
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
exports.IS_NOT_MATCHED_VALUE = IS_NOT_MATCHED_VALUE;
|
|
30
|
+
|
|
31
|
+
var getResultClassName = function getResultClassName(f, value) {
|
|
32
|
+
if ((0, _is.isFunc)(f)) {
|
|
33
|
+
return f((0, _is.isObject)(value) && value.IS_NOT_MATCHED_VALUE ? value.value : value);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if ((0, _is.isString)(f)) {
|
|
37
|
+
return f;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return null;
|
|
41
|
+
}; // eslint-disable-next-line
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
function Item(props) {
|
|
45
|
+
// eslint-disable-next-line react/prop-types
|
|
46
|
+
var value = props.value,
|
|
47
|
+
onClick = props.onClick,
|
|
48
|
+
resultClassName = props.resultClassName,
|
|
49
|
+
_props$title = props.title,
|
|
50
|
+
title = _props$title === void 0 ? false : _props$title,
|
|
51
|
+
only = props.only,
|
|
52
|
+
getDataByValue = props.getDataByValue,
|
|
53
|
+
getContent = props.getContent,
|
|
54
|
+
isDisabled = props.isDisabled;
|
|
55
|
+
var data = getDataByValue(value);
|
|
56
|
+
var disabled = isDisabled(data);
|
|
57
|
+
var content = getContent(data);
|
|
58
|
+
if (data === null) return null;
|
|
59
|
+
var click = disabled || !onClick ? undefined : function () {
|
|
60
|
+
return onClick(data);
|
|
61
|
+
};
|
|
62
|
+
var synDisabled = disabled || !click;
|
|
63
|
+
return _react.default.createElement("a", {
|
|
64
|
+
title: title && (0, _is.isString)(content) ? content : null,
|
|
65
|
+
tabIndex: -1,
|
|
66
|
+
className: (0, _classnames.default)((0, _styles.selectClass)((0, _classname.getDirectionClass)('item'), disabled && (0, _classname.getDirectionClass)('disabled'), synDisabled && (0, _classname.getDirectionClass)('ban'), only && 'item-only'), getResultClassName(resultClassName, data))
|
|
67
|
+
}, content, !synDisabled && _react.default.createElement("span", {
|
|
68
|
+
className: (0, _styles.selectClass)('indicator', 'close'),
|
|
69
|
+
onClick: click
|
|
70
|
+
}));
|
|
71
|
+
}
|
package/css/Select/Select.js
CHANGED
|
@@ -643,7 +643,6 @@ function (_PureComponent) {
|
|
|
643
643
|
datum = _this$props12.datum,
|
|
644
644
|
filterText = _this$props12.filterText,
|
|
645
645
|
onCreate = _this$props12.onCreate,
|
|
646
|
-
result = _this$props12.result,
|
|
647
646
|
compressed = _this$props12.compressed,
|
|
648
647
|
compressedBound = _this$props12.compressedBound,
|
|
649
648
|
trim = _this$props12.trim,
|
|
@@ -657,7 +656,8 @@ function (_PureComponent) {
|
|
|
657
656
|
convertBr = _this$props12.convertBr,
|
|
658
657
|
data = _this$props12.data,
|
|
659
658
|
onFilter = _this$props12.onFilter,
|
|
660
|
-
treeData = _this$props12.treeData
|
|
659
|
+
treeData = _this$props12.treeData,
|
|
660
|
+
getResultByValue = _this$props12.getResultByValue;
|
|
661
661
|
var disabled = this.getDisabledStatus();
|
|
662
662
|
var className = (0, _styles.selectClass)('inner', size, this.state.focus && 'focus', this.state.position, multiple && 'multiple', disabled === true && (0, _classname.getDirectionClass)('disabled'), !trim && 'pre');
|
|
663
663
|
return _react.default.createElement("div", {
|
|
@@ -680,8 +680,10 @@ function (_PureComponent) {
|
|
|
680
680
|
onFilter: onFilter && this.handleFilter,
|
|
681
681
|
datum: datum,
|
|
682
682
|
disabled: disabled,
|
|
683
|
-
focus: this.state.focus
|
|
684
|
-
|
|
683
|
+
focus: this.state.focus // result={result}
|
|
684
|
+
,
|
|
685
|
+
values: datum.values,
|
|
686
|
+
getResultByValue: getResultByValue,
|
|
685
687
|
multiple: multiple,
|
|
686
688
|
placeholder: placeholder,
|
|
687
689
|
renderResult: this.renderResult,
|
package/css/Select/filter.js
CHANGED
|
@@ -44,8 +44,9 @@ var _default = function _default(Origin) {
|
|
|
44
44
|
text: ''
|
|
45
45
|
};
|
|
46
46
|
_this.handleCreate = _this.handleCreate.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
|
47
|
-
_this.handleFilter = _this.handleFilter.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
|
48
|
-
|
|
47
|
+
_this.handleFilter = _this.handleFilter.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this))); // this.getResultByValues = this.getResultByValues.bind(this)
|
|
48
|
+
|
|
49
|
+
_this.getCachedResult = _this.getCachedResult.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
|
49
50
|
_this.resultCache = new Map();
|
|
50
51
|
return _this;
|
|
51
52
|
}
|
|
@@ -108,43 +109,50 @@ var _default = function _default(Origin) {
|
|
|
108
109
|
return undefined;
|
|
109
110
|
};
|
|
110
111
|
|
|
111
|
-
_proto.
|
|
112
|
-
var
|
|
112
|
+
_proto.getCachedResult = function getCachedResult(value) {
|
|
113
|
+
var noCache = this.props.noCache;
|
|
114
|
+
var res = noCache ? undefined : this.resultCache.get(value);
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
noCache = _this$props4.noCache;
|
|
117
|
-
var _datum$values = datum.values,
|
|
118
|
-
values = _datum$values === void 0 ? [] : _datum$values;
|
|
119
|
-
var result = [];
|
|
120
|
-
values.forEach(function (v) {
|
|
121
|
-
var res = noCache ? undefined : _this2.resultCache.get(v);
|
|
122
|
-
|
|
123
|
-
if (!res) {
|
|
124
|
-
var _res;
|
|
125
|
-
|
|
126
|
-
res = _this2.getResult(v);
|
|
127
|
-
if (res !== undefined && !noCache) _this2.resultCache.set(v, res);else if (res === undefined) res = (_res = {}, _res[_Result.IS_NOT_MATCHED_VALUE] = true, _res.value = v, _res);
|
|
128
|
-
}
|
|
116
|
+
if (!res) {
|
|
117
|
+
var _res;
|
|
129
118
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return
|
|
135
|
-
}
|
|
119
|
+
res = this.getResult(value);
|
|
120
|
+
if (res !== undefined && !noCache) this.resultCache.set(value, res);else if (res === undefined) res = (_res = {}, _res[_Result.IS_NOT_MATCHED_VALUE] = true, _res.value = value, _res);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return res;
|
|
124
|
+
} // getResultByValues() {
|
|
125
|
+
// const { datum, noCache } = this.props
|
|
126
|
+
// const { values = [] } = datum
|
|
127
|
+
//
|
|
128
|
+
// const result = []
|
|
129
|
+
// values.forEach(v => {
|
|
130
|
+
// let res = noCache ? undefined : this.resultCache.get(v)
|
|
131
|
+
// if (!res) {
|
|
132
|
+
// res = this.getResult(v)
|
|
133
|
+
// if (res !== undefined && !noCache) this.resultCache.set(v, res)
|
|
134
|
+
// else if (res === undefined) res = { [IS_NOT_MATCHED_VALUE]: true, value: v }
|
|
135
|
+
// }
|
|
136
|
+
// if (res !== undefined) {
|
|
137
|
+
// result.push(res)
|
|
138
|
+
// }
|
|
139
|
+
// })
|
|
140
|
+
//
|
|
141
|
+
// return result
|
|
142
|
+
// }
|
|
143
|
+
;
|
|
136
144
|
|
|
137
145
|
_proto.handleFilter = function handleFilter(text, from) {
|
|
138
|
-
var
|
|
146
|
+
var _this2 = this;
|
|
139
147
|
|
|
140
148
|
if (from === void 0) {
|
|
141
149
|
from = 'edit';
|
|
142
150
|
}
|
|
143
151
|
|
|
144
|
-
var _this$
|
|
145
|
-
filterDelay = _this$
|
|
146
|
-
onFilter = _this$
|
|
147
|
-
onCreate = _this$
|
|
152
|
+
var _this$props4 = this.props,
|
|
153
|
+
filterDelay = _this$props4.filterDelay,
|
|
154
|
+
onFilter = _this$props4.onFilter,
|
|
155
|
+
onCreate = _this$props4.onCreate;
|
|
148
156
|
this.setState({
|
|
149
157
|
text: text
|
|
150
158
|
}); // not filter
|
|
@@ -176,7 +184,7 @@ var _default = function _default(Origin) {
|
|
|
176
184
|
var fn = onFilter(text, from);
|
|
177
185
|
|
|
178
186
|
if (typeof fn === 'function') {
|
|
179
|
-
|
|
187
|
+
_this2.setState({
|
|
180
188
|
innerFilter: fn
|
|
181
189
|
});
|
|
182
190
|
}
|
|
@@ -192,12 +200,12 @@ var _default = function _default(Origin) {
|
|
|
192
200
|
};
|
|
193
201
|
|
|
194
202
|
_proto.filterTreeData = function filterTreeData() {
|
|
195
|
-
var _this$
|
|
196
|
-
treeData = _this$
|
|
197
|
-
expanded = _this$
|
|
198
|
-
showHitDescendants = _this$
|
|
199
|
-
onAdvancedFilter = _this$
|
|
200
|
-
other = (0, _objectWithoutPropertiesLoose2.default)(_this$
|
|
203
|
+
var _this$props5 = this.props,
|
|
204
|
+
treeData = _this$props5.treeData,
|
|
205
|
+
expanded = _this$props5.expanded,
|
|
206
|
+
showHitDescendants = _this$props5.showHitDescendants,
|
|
207
|
+
onAdvancedFilter = _this$props5.onAdvancedFilter,
|
|
208
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_this$props5, ["treeData", "expanded", "showHitDescendants", "onAdvancedFilter"]);
|
|
201
209
|
var innerFilter = this.state.innerFilter;
|
|
202
210
|
var filterExpandedKeys = expanded;
|
|
203
211
|
var newData = treeData;
|
|
@@ -219,10 +227,10 @@ var _default = function _default(Origin) {
|
|
|
219
227
|
};
|
|
220
228
|
|
|
221
229
|
_proto.filterData = function filterData() {
|
|
222
|
-
var _this$
|
|
223
|
-
data = _this$
|
|
224
|
-
hideCreateOption = _this$
|
|
225
|
-
other = (0, _objectWithoutPropertiesLoose2.default)(_this$
|
|
230
|
+
var _this$props6 = this.props,
|
|
231
|
+
data = _this$props6.data,
|
|
232
|
+
hideCreateOption = _this$props6.hideCreateOption,
|
|
233
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_this$props6, ["data", "hideCreateOption"]);
|
|
226
234
|
var _this$state = this.state,
|
|
227
235
|
innerFilter = _this$state.innerFilter,
|
|
228
236
|
innerData = _this$state.innerData;
|
|
@@ -247,11 +255,11 @@ var _default = function _default(Origin) {
|
|
|
247
255
|
};
|
|
248
256
|
|
|
249
257
|
_proto.render = function render() {
|
|
250
|
-
var _this$
|
|
251
|
-
treeData = _this$
|
|
252
|
-
onFilter = _this$
|
|
253
|
-
onCreate = _this$
|
|
254
|
-
other = (0, _objectWithoutPropertiesLoose2.default)(_this$
|
|
258
|
+
var _this$props7 = this.props,
|
|
259
|
+
treeData = _this$props7.treeData,
|
|
260
|
+
onFilter = _this$props7.onFilter,
|
|
261
|
+
onCreate = _this$props7.onCreate,
|
|
262
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_this$props7, ["treeData", "onFilter", "onCreate"]);
|
|
255
263
|
var _this$state2 = this.state,
|
|
256
264
|
filterText = _this$state2.filterText,
|
|
257
265
|
innerData = _this$state2.innerData,
|
|
@@ -261,7 +269,8 @@ var _default = function _default(Origin) {
|
|
|
261
269
|
var props = (0, _objectSpread2.default)({}, other, {
|
|
262
270
|
filterText: filterText,
|
|
263
271
|
inputText: text,
|
|
264
|
-
result: this.getResultByValues(),
|
|
272
|
+
// result: this.getResultByValues(),
|
|
273
|
+
getResultByValue: this.getCachedResult,
|
|
265
274
|
inputable: !!onCreate,
|
|
266
275
|
onCreate: onCreate ? this.handleCreate : undefined,
|
|
267
276
|
onFilter: filterFn,
|
package/css/index.d.ts
CHANGED