@kdcloudjs/kdesign 1.6.5 → 1.6.7
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/CHANGELOG.md +36 -0
- package/dist/kdesign-complete.less +113 -106
- package/dist/kdesign.css +108 -84
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +758 -513
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +3 -3
- package/dist/kdesign.min.js +8 -8
- package/dist/kdesign.min.js.map +1 -1
- package/es/_utils/hooks.js +1 -9
- package/es/carousel/style/index.css +3 -0
- package/es/carousel/style/index.less +4 -0
- package/es/cascader/style/index.css +7 -7
- package/es/cascader/style/token.less +2 -2
- package/es/config-provider/compDefaultProps.d.ts +5 -0
- package/es/config-provider/compDefaultProps.js +6 -1
- package/es/date-picker/date-picker.js +11 -14
- package/es/date-picker/panel/month/month.d.ts +0 -1
- package/es/date-picker/panel/month/month.js +6 -4
- package/es/date-picker/range/input-range.js +41 -11
- package/es/date-picker/range-picker.js +8 -11
- package/es/date-picker/single/input-date.js +40 -10
- package/es/date-picker/style/index.css +27 -23
- package/es/date-picker/style/index.less +16 -33
- package/es/date-picker/style/mixin.less +7 -0
- package/es/date-picker/style/token.less +2 -1
- package/es/form/Field.d.ts +1 -0
- package/es/form/Field.js +9 -5
- package/es/form/FieldLabel.d.ts +1 -0
- package/es/form/FieldLabel.js +4 -2
- package/es/input/ClearableLabeledInput.js +23 -5
- package/es/input/TextArea.d.ts +1 -0
- package/es/input/TextArea.js +8 -6
- package/es/input/style/index.css +12 -8
- package/es/input/style/index.less +9 -5
- package/es/input/style/mixin.less +3 -3
- package/es/input/style/token.less +2 -0
- package/es/search/style/index.css +3 -1
- package/es/search/style/index.less +3 -1
- package/es/search/style/token.less +2 -1
- package/es/select/interface.d.ts +2 -0
- package/es/select/option.js +1 -1
- package/es/select/select.js +180 -128
- package/es/select/style/index.css +54 -24
- package/es/select/style/index.less +60 -43
- package/es/select/style/mixin.less +0 -2
- package/es/select/style/token.less +2 -0
- package/es/split-panel/style/index.css +0 -6
- package/es/split-panel/style/index.less +0 -3
- package/es/steps/style/index.css +0 -13
- package/es/steps/style/index.less +0 -11
- package/es/table/feature/mergeCellHover.d.ts +3 -0
- package/es/table/feature/mergeCellHover.js +7 -0
- package/es/table/interface.d.ts +8 -0
- package/es/table/table.d.ts +2 -2
- package/es/table/table.js +20 -6
- package/es/tooltip/style/index.css +1 -1
- package/es/tooltip/style/token.less +1 -1
- package/lib/_utils/hooks.js +1 -9
- package/lib/carousel/style/index.css +3 -0
- package/lib/carousel/style/index.less +4 -0
- package/lib/cascader/style/index.css +7 -7
- package/lib/cascader/style/token.less +2 -2
- package/lib/config-provider/compDefaultProps.d.ts +5 -0
- package/lib/config-provider/compDefaultProps.js +6 -1
- package/lib/date-picker/date-picker.js +10 -16
- package/lib/date-picker/panel/month/month.d.ts +0 -1
- package/lib/date-picker/panel/month/month.js +10 -8
- package/lib/date-picker/range/input-range.js +40 -11
- package/lib/date-picker/range-picker.js +7 -13
- package/lib/date-picker/single/input-date.js +37 -9
- package/lib/date-picker/style/index.css +27 -23
- package/lib/date-picker/style/index.less +16 -33
- package/lib/date-picker/style/mixin.less +7 -0
- package/lib/date-picker/style/token.less +2 -1
- package/lib/form/Field.d.ts +1 -0
- package/lib/form/Field.js +10 -6
- package/lib/form/FieldLabel.d.ts +1 -0
- package/lib/form/FieldLabel.js +4 -2
- package/lib/input/ClearableLabeledInput.js +34 -5
- package/lib/input/TextArea.d.ts +1 -0
- package/lib/input/TextArea.js +9 -7
- package/lib/input/style/index.css +12 -8
- package/lib/input/style/index.less +9 -5
- package/lib/input/style/mixin.less +3 -3
- package/lib/input/style/token.less +2 -0
- package/lib/search/style/index.css +3 -1
- package/lib/search/style/index.less +3 -1
- package/lib/search/style/token.less +2 -1
- package/lib/select/interface.d.ts +2 -0
- package/lib/select/option.js +1 -1
- package/lib/select/select.js +179 -126
- package/lib/select/style/index.css +54 -24
- package/lib/select/style/index.less +60 -43
- package/lib/select/style/mixin.less +0 -2
- package/lib/select/style/token.less +2 -0
- package/lib/split-panel/style/index.css +0 -6
- package/lib/split-panel/style/index.less +0 -3
- package/lib/steps/style/index.css +0 -13
- package/lib/steps/style/index.less +0 -11
- package/lib/table/feature/mergeCellHover.d.ts +3 -0
- package/lib/table/feature/mergeCellHover.js +15 -0
- package/lib/table/interface.d.ts +8 -0
- package/lib/table/table.d.ts +2 -2
- package/lib/table/table.js +20 -4
- package/lib/tooltip/style/index.css +1 -1
- package/lib/tooltip/style/token.less +1 -1
- package/package.json +1 -1
package/lib/select/select.js
CHANGED
|
@@ -35,6 +35,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
35
35
|
|
|
36
36
|
var _hooks = require("../_utils/hooks");
|
|
37
37
|
|
|
38
|
+
var _isBoolean = _interopRequireDefault(require("lodash/isBoolean"));
|
|
39
|
+
|
|
38
40
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
39
41
|
|
|
40
42
|
var _ConfigContext = _interopRequireDefault(require("../config-provider/ConfigContext"));
|
|
@@ -53,10 +55,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "functi
|
|
|
53
55
|
|
|
54
56
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
55
57
|
|
|
56
|
-
var
|
|
57
|
-
var _context, _classNames7, _classNames13, _classNames14;
|
|
58
|
+
var INPUT_MIN_WIDTH = 4; // 输入框最小宽度
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
var InternalSelect = function InternalSelect(props, ref) {
|
|
61
|
+
var _context, _classNames6, _classNames12;
|
|
60
62
|
|
|
61
63
|
var _useContext = (0, _react.useContext)(_ConfigContext.default),
|
|
62
64
|
getPrefixCls = _useContext.getPrefixCls,
|
|
@@ -92,6 +94,9 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
92
94
|
dropdownStyle = selectProps.dropdownStyle,
|
|
93
95
|
style = selectProps.style,
|
|
94
96
|
clearIcon = selectProps.clearIcon,
|
|
97
|
+
filterOption = selectProps.filterOption,
|
|
98
|
+
optionFilterProp = selectProps.optionFilterProp,
|
|
99
|
+
optionLabelProp = selectProps.optionLabelProp,
|
|
95
100
|
_selectProps$popperSt = selectProps.popperStyle,
|
|
96
101
|
popperStyle = _selectProps$popperSt === void 0 ? {} : _selectProps$popperSt;
|
|
97
102
|
var isMultiple = mode === 'multiple'; // 是否多选
|
|
@@ -118,6 +123,8 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
118
123
|
selectMulOpts: []
|
|
119
124
|
}); // 多选ref已选中项
|
|
120
125
|
|
|
126
|
+
var measureRef = _react.default.useRef(null);
|
|
127
|
+
|
|
121
128
|
var _useState = (0, _react.useState)([]),
|
|
122
129
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
123
130
|
mulOptions = _useState2[0],
|
|
@@ -132,18 +139,19 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
132
139
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
133
140
|
optionShow = _useState6[0],
|
|
134
141
|
setOptionShow = _useState6[1]; // 下拉列表是否展示
|
|
142
|
+
// const [searchInput, setSearchInput] = useState<string>('') // 搜索框值
|
|
135
143
|
|
|
136
144
|
|
|
137
145
|
var _useState7 = (0, _react.useState)(''),
|
|
138
146
|
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
searchValue = _useState8[0],
|
|
148
|
+
setSearchValue = _useState8[1]; // 搜索框定时器
|
|
141
149
|
|
|
142
150
|
|
|
143
|
-
var _useState9 = (0, _react.useState)(
|
|
151
|
+
var _useState9 = (0, _react.useState)(INPUT_MIN_WIDTH),
|
|
144
152
|
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
145
|
-
|
|
146
|
-
|
|
153
|
+
inputWidth = _useState10[0],
|
|
154
|
+
setInputWidth = _useState10[1]; // 输入框宽度
|
|
147
155
|
|
|
148
156
|
|
|
149
157
|
var selectPrefixCls = getPrefixCls(prefixCls, 'select', customPrefixcls); // 选择器样式
|
|
@@ -151,15 +159,13 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
151
159
|
var selectCls = (0, _classnames.default)(selectPrefixCls, className, (0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-visible"), optionShow));
|
|
152
160
|
var selectionCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-selector"), true)); // 下拉列表框样式
|
|
153
161
|
|
|
154
|
-
var dropDownCls = (0, _classnames.default)(dropdownClassName, (0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-dropdown"), true)); //
|
|
155
|
-
|
|
156
|
-
var searchCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-dropdown-search"), true)); // 下拉子项列表样式
|
|
162
|
+
var dropDownCls = (0, _classnames.default)(dropdownClassName, (0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-dropdown"), true)); // 下拉子项列表样式
|
|
157
163
|
|
|
158
164
|
var dropContentCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-dropdown-scroll"), (isMultiple ? (realChildren === null || realChildren === void 0 ? void 0 : realChildren.length) > 8 : (realChildren === null || realChildren === void 0 ? void 0 : realChildren.length) > 10) || selectProps.dropdownRender)); // 多选底部样式
|
|
159
165
|
|
|
160
166
|
var multipleFooterCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-multiple-footer"), true)); // 多选,单选公共样式
|
|
161
167
|
|
|
162
|
-
var commCls = (0, _classnames.default)((
|
|
168
|
+
var commCls = (0, _classnames.default)((_classNames6 = {}, (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), (0, _defineProperty2.default)(_classNames6, (0, _concat.default)(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-wrapper"), true), _classNames6));
|
|
163
169
|
|
|
164
170
|
_react.default.useEffect(function () {
|
|
165
171
|
setOptionShow(!!props.visible);
|
|
@@ -209,8 +215,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
209
215
|
}
|
|
210
216
|
}, [isMultiple, initValue, children, options]);
|
|
211
217
|
(0, _react.useEffect)(function () {
|
|
212
|
-
var _a;
|
|
213
|
-
|
|
214
218
|
if (!isMultiple) {
|
|
215
219
|
multipleRef.current.selectedVal = initValue; // 默认选中值
|
|
216
220
|
|
|
@@ -226,28 +230,27 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
226
230
|
})) || {};
|
|
227
231
|
|
|
228
232
|
if (options && options.length) {
|
|
229
|
-
setSingleVal((obj
|
|
233
|
+
setSingleVal(getOptionLabel(obj) || (obj === null || obj === void 0 ? void 0 : obj.value));
|
|
230
234
|
} else {
|
|
231
|
-
setSingleVal(
|
|
235
|
+
// setSingleVal(obj.props?.children)
|
|
236
|
+
setSingleVal(getOptionLabel(obj));
|
|
232
237
|
}
|
|
233
238
|
} else {
|
|
234
239
|
setSingleVal(undefined);
|
|
235
240
|
}
|
|
236
241
|
}
|
|
237
|
-
}, [initValue, realChildren]);
|
|
238
|
-
|
|
242
|
+
}, [initValue, realChildren]);
|
|
239
243
|
(0, _react.useEffect)(function () {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}, [
|
|
244
|
-
(0, _react.useEffect)(function () {
|
|
245
|
-
handleClear();
|
|
246
|
-
}, [optionShow === false]);
|
|
244
|
+
if (optionShow === false) {
|
|
245
|
+
handleClear();
|
|
246
|
+
}
|
|
247
|
+
}, [optionShow]);
|
|
247
248
|
var handleFocus = (0, _react.useCallback)(function (e) {
|
|
249
|
+
e.stopPropagation();
|
|
248
250
|
onFocus && onFocus(e);
|
|
249
251
|
}, [onFocus]);
|
|
250
252
|
var handleBlur = (0, _react.useCallback)(function (e) {
|
|
253
|
+
e.stopPropagation();
|
|
251
254
|
onBlur && onBlur(e);
|
|
252
255
|
}, [onBlur]); // 点击组件
|
|
253
256
|
|
|
@@ -257,8 +260,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
257
260
|
if (!optionShow) {
|
|
258
261
|
var onDropdownVisibleChange = selectProps.onDropdownVisibleChange;
|
|
259
262
|
onDropdownVisibleChange && onDropdownVisibleChange(!optionShow);
|
|
260
|
-
}
|
|
261
|
-
|
|
263
|
+
}
|
|
262
264
|
};
|
|
263
265
|
|
|
264
266
|
(0, _react.useEffect)(function () {
|
|
@@ -271,11 +273,62 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
271
273
|
e.stopPropagation();
|
|
272
274
|
}
|
|
273
275
|
});
|
|
274
|
-
}, []);
|
|
276
|
+
}, []);
|
|
277
|
+
(0, _react.useLayoutEffect)(function () {
|
|
278
|
+
measureRef.current && setInputWidth(measureRef.current.scrollWidth);
|
|
279
|
+
}, [searchValue]);
|
|
280
|
+
var filledOptions = (0, _react.useMemo)(function () {
|
|
281
|
+
if (filterOption === false || !searchValue) {
|
|
282
|
+
return realChildren;
|
|
283
|
+
}
|
|
275
284
|
|
|
276
|
-
|
|
277
|
-
|
|
285
|
+
var childrenList = [];
|
|
286
|
+
|
|
287
|
+
var handleFilledOption = function handleFilledOption(option) {
|
|
288
|
+
if (filterOption === true) {
|
|
289
|
+
return String(option[optionFilterProp]).toLowerCase().indexOf(searchValue.toLowerCase()) !== -1;
|
|
290
|
+
} else if (typeof filterOption === 'function') {
|
|
291
|
+
return filterOption(searchValue, option);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return true;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
(0, _map.default)(realChildren).call(realChildren, function (item) {
|
|
298
|
+
if (item === null || item === undefined) return;
|
|
299
|
+
var isValidOption = true;
|
|
300
|
+
|
|
301
|
+
if ((item === null || item === void 0 ? void 0 : item.props) && (item.type.displayName === 'Option' || item.type.name === 'Option')) {
|
|
302
|
+
isValidOption = handleFilledOption(item.props);
|
|
303
|
+
} else {
|
|
304
|
+
isValidOption = handleFilledOption(item);
|
|
305
|
+
}
|
|
278
306
|
|
|
307
|
+
if (isValidOption) {
|
|
308
|
+
childrenList.push(item);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
return childrenList;
|
|
312
|
+
}, [searchValue, realChildren, filterOption, optionFilterProp]);
|
|
313
|
+
var getOptionLabel = (0, _react.useCallback)(function (obj) {
|
|
314
|
+
var _a;
|
|
315
|
+
|
|
316
|
+
if (obj.props) {
|
|
317
|
+
if (optionLabelProp) {
|
|
318
|
+
return obj === null || obj === void 0 ? void 0 : obj.props[optionLabelProp];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return (_a = obj.props) === null || _a === void 0 ? void 0 : _a.children;
|
|
322
|
+
} else {
|
|
323
|
+
if (optionLabelProp) {
|
|
324
|
+
return obj[optionLabelProp];
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return obj === null || obj === void 0 ? void 0 : obj.label;
|
|
329
|
+
}, [optionLabelProp]); // 点击下拉列表中某项回调
|
|
330
|
+
|
|
331
|
+
var handleOption = function handleOption(key, label, isSelected) {
|
|
279
332
|
var onSelect = selectProps.onSelect,
|
|
280
333
|
onDeselect = selectProps.onDeselect,
|
|
281
334
|
labelInValue = selectProps.labelInValue,
|
|
@@ -292,7 +345,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
292
345
|
var optionsObj = obj.props ? obj.props : obj || {};
|
|
293
346
|
|
|
294
347
|
if (value !== undefined) {
|
|
295
|
-
// onChange && onChange(labelInValue ? { value: key, label } : key)
|
|
296
348
|
if (isMultiple) {
|
|
297
349
|
var _multipleRef$current = multipleRef.current,
|
|
298
350
|
selectedVal = _multipleRef$current.selectedVal,
|
|
@@ -308,7 +360,8 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
308
360
|
valArr.push(key);
|
|
309
361
|
optsArr.push((0, _extends2.default)((0, _extends2.default)({}, optionsObj), {
|
|
310
362
|
value: key,
|
|
311
|
-
label: obj.props ?
|
|
363
|
+
// label: obj.props ? obj.props?.children : obj.label || key,
|
|
364
|
+
label: getOptionLabel(obj) || key
|
|
312
365
|
}));
|
|
313
366
|
}
|
|
314
367
|
|
|
@@ -333,11 +386,10 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
333
386
|
}
|
|
334
387
|
|
|
335
388
|
if (!isMultiple) {
|
|
336
|
-
setSingleVal(
|
|
389
|
+
setSingleVal(getOptionLabel(obj) || key);
|
|
337
390
|
multipleRef.current.selectedVal = key;
|
|
338
391
|
setInitValue(key);
|
|
339
|
-
props.visible === undefined && setOptionShow(false);
|
|
340
|
-
|
|
392
|
+
props.visible === undefined && setOptionShow(false);
|
|
341
393
|
onChange && onChange(labelInValue ? {
|
|
342
394
|
value: key,
|
|
343
395
|
label: label
|
|
@@ -360,10 +412,9 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
360
412
|
|
|
361
413
|
_selectMulOpts.push((0, _extends2.default)((0, _extends2.default)({}, optionsObj), {
|
|
362
414
|
value: key,
|
|
363
|
-
label:
|
|
415
|
+
label: getOptionLabel(obj) || key
|
|
364
416
|
}));
|
|
365
|
-
}
|
|
366
|
-
|
|
417
|
+
}
|
|
367
418
|
|
|
368
419
|
setMulOptions((0, _toConsumableArray2.default)(_selectMulOpts));
|
|
369
420
|
onChange && onChange(labelInValue ? _selectMulOpts : _selectedVal, _selectMulOpts);
|
|
@@ -371,11 +422,9 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
371
422
|
if (!isSelected) {
|
|
372
423
|
onDeselect && onDeselect(key); // 下拉项取消选中时调用,参数为选中项的value,多选模式下生效
|
|
373
424
|
}
|
|
374
|
-
}
|
|
375
|
-
// onSelect && onSelect(key) // 下拉项被选中时调用,参数为选中项value或key
|
|
376
|
-
// }
|
|
377
|
-
|
|
425
|
+
}
|
|
378
426
|
|
|
427
|
+
setSearchValue('');
|
|
379
428
|
onSelect && onSelect(key); // 下拉项被选中时调用,参数为选中项value或key
|
|
380
429
|
}; // 多选模式下选中所有 与清除所有 (可以优化)
|
|
381
430
|
|
|
@@ -388,14 +437,13 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
388
437
|
if ((realChildren === null || realChildren === void 0 ? void 0 : realChildren.length) !== selectedVal.length) {
|
|
389
438
|
(0, _map.default)(realChildren).call(realChildren, function (child) {
|
|
390
439
|
var _ref = child.props || child,
|
|
391
|
-
value = _ref.value
|
|
392
|
-
children = _ref.children;
|
|
440
|
+
value = _ref.value;
|
|
393
441
|
|
|
394
442
|
if (!(0, _includes.default)(selectedVal).call(selectedVal, value)) {
|
|
395
443
|
selectedVal.push(value);
|
|
396
444
|
selectMulOpts.push({
|
|
397
445
|
value: value,
|
|
398
|
-
label:
|
|
446
|
+
label: getOptionLabel(child)
|
|
399
447
|
});
|
|
400
448
|
}
|
|
401
449
|
});
|
|
@@ -407,45 +455,31 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
407
455
|
}
|
|
408
456
|
|
|
409
457
|
onChange && onChange(labelInValue ? selectMulOpts : selectedVal, selectMulOpts);
|
|
410
|
-
}; //
|
|
458
|
+
}; // 输入框变化搜索内容
|
|
411
459
|
|
|
412
460
|
|
|
413
|
-
var handleSearch = (0, _react.useCallback)(function (event) {
|
|
414
|
-
var _a;
|
|
415
|
-
|
|
416
|
-
if (event.currentTarget.matches('i')) {
|
|
417
|
-
onSearch && onSearch((_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.value);
|
|
418
|
-
}
|
|
419
|
-
}, [onSearch]); // 输入框变化搜索内容
|
|
420
|
-
|
|
421
461
|
var handleSearchChange = (0, _react.useCallback)(function (event) {
|
|
422
462
|
var val = event.currentTarget.value;
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}, 500));
|
|
427
|
-
}, [onSearch, timer]); // 清除搜索内容
|
|
463
|
+
setSearchValue(val);
|
|
464
|
+
onSearch === null || onSearch === void 0 ? void 0 : onSearch(val);
|
|
465
|
+
}, [onSearch]); // 清除搜索内容
|
|
428
466
|
|
|
429
467
|
var handleClear = (0, _react.useCallback)(function () {
|
|
430
468
|
if (searchRef.current) {
|
|
431
469
|
searchRef.current.value = '';
|
|
432
|
-
|
|
433
|
-
setSearchInput('');
|
|
470
|
+
setSearchValue('');
|
|
434
471
|
}
|
|
435
|
-
}, [
|
|
472
|
+
}, [searchRef]); // 清空选择器内容
|
|
436
473
|
|
|
437
474
|
var handleReset = function handleReset(e) {
|
|
438
|
-
e.stopPropagation();
|
|
439
|
-
// e.nativeEvent.stopImmediatePropagation()
|
|
475
|
+
e.stopPropagation();
|
|
440
476
|
|
|
441
477
|
if (isMultiple) {
|
|
442
478
|
multipleRef.current.selectedVal = [];
|
|
443
479
|
multipleRef.current.selectMulOpts = [];
|
|
444
480
|
setMulOptions([]);
|
|
445
481
|
} else {
|
|
446
|
-
|
|
447
|
-
setInitValue(''); // selectionRef.current.value = ''
|
|
448
|
-
// multipleRef.current.selectedVal = ''
|
|
482
|
+
setInitValue('');
|
|
449
483
|
}
|
|
450
484
|
|
|
451
485
|
onClear && onClear('');
|
|
@@ -455,8 +489,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
455
489
|
|
|
456
490
|
var handleRemove = function handleRemove(e) {
|
|
457
491
|
if (disabled) return;
|
|
458
|
-
var tag = e.currentTarget.parentNode.getAttribute('data-tag');
|
|
459
|
-
|
|
492
|
+
var tag = e.currentTarget.parentNode.getAttribute('data-tag');
|
|
460
493
|
var _multipleRef$current4 = multipleRef.current,
|
|
461
494
|
selectedVal = _multipleRef$current4.selectedVal,
|
|
462
495
|
selectMulOpts = _multipleRef$current4.selectMulOpts;
|
|
@@ -470,19 +503,19 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
470
503
|
|
|
471
504
|
|
|
472
505
|
var renderSuffix = function renderSuffix() {
|
|
473
|
-
var
|
|
506
|
+
var _classNames7;
|
|
474
507
|
|
|
475
508
|
var suffixIcon = selectProps.suffixIcon;
|
|
476
509
|
var selectedVal = multipleRef.current.selectedVal; // 选择器下拉icon样式
|
|
477
510
|
|
|
478
|
-
var arrowIconCls = (0, _classnames.default)((
|
|
511
|
+
var arrowIconCls = (0, _classnames.default)((_classNames7 = {}, (0, _defineProperty2.default)(_classNames7, "".concat(selectPrefixCls, "-icon-arrow"), true), (0, _defineProperty2.default)(_classNames7, "".concat(selectPrefixCls, "-icon-arrow-up"), optionShow), (0, _defineProperty2.default)(_classNames7, "".concat(selectPrefixCls, "-icon-arrow-down"), !optionShow), (0, _defineProperty2.default)(_classNames7, "".concat(selectPrefixCls, "-icon-arrow-focus"), optionShow), _classNames7));
|
|
479
512
|
var iconShow = allowClear && !disabled && (isMultiple ? mulOptions.length > 0 : (selectedVal !== null && selectedVal !== void 0 ? selectedVal : '') !== '');
|
|
480
513
|
var clearIconCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-icon-clear"), true));
|
|
481
514
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, iconShow && /*#__PURE__*/_react.default.createElement("span", {
|
|
482
515
|
onClick: handleReset,
|
|
483
516
|
className: clearIconCls
|
|
484
517
|
}, /*#__PURE__*/_react.default.createElement(_index.Icon, {
|
|
485
|
-
type: "close"
|
|
518
|
+
type: "close-solid"
|
|
486
519
|
}) || clearIcon), showArrow && /*#__PURE__*/_react.default.createElement("span", {
|
|
487
520
|
className: arrowIconCls
|
|
488
521
|
}, suffixIcon || /*#__PURE__*/_react.default.createElement(_index.Icon, {
|
|
@@ -525,30 +558,26 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
525
558
|
var emptyListCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-dropdown-empty"), true));
|
|
526
559
|
var notFoundContent = selectProps.notFoundContent;
|
|
527
560
|
var emptyContent = notFoundContent || '暂无数据';
|
|
528
|
-
return (
|
|
561
|
+
return (filledOptions === null || filledOptions === void 0 ? void 0 : filledOptions.length) === 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
529
562
|
className: emptyListCls
|
|
530
563
|
}, emptyContent);
|
|
531
|
-
};
|
|
564
|
+
}; // const isShowSearch = useCallback(() => {
|
|
565
|
+
// return !showSearch ? false : !!searchValue
|
|
566
|
+
// }, [showSearch, searchValue])
|
|
532
567
|
|
|
533
|
-
var isShowSearch = (0, _react.useCallback)(function () {
|
|
534
|
-
if (isMultiple) {
|
|
535
|
-
return showSearch !== null && showSearch !== void 0 ? showSearch : true;
|
|
536
|
-
}
|
|
537
568
|
|
|
538
|
-
|
|
539
|
-
|
|
569
|
+
var isShowSearch = (0, _react.useMemo)(function () {
|
|
570
|
+
return (0, _isBoolean.default)(showSearch) ? showSearch : isMultiple;
|
|
571
|
+
}, [isMultiple, showSearch]); // 渲染下拉列表框
|
|
540
572
|
|
|
541
573
|
var renderContent = function renderContent() {
|
|
542
|
-
var
|
|
543
|
-
|
|
544
|
-
var searchIcon = selectProps.searchIcon,
|
|
545
|
-
dropdownRender = selectProps.dropdownRender,
|
|
574
|
+
var dropdownRender = selectProps.dropdownRender,
|
|
546
575
|
listHeight = selectProps.listHeight;
|
|
547
576
|
var selectedVal = multipleRef.current.selectedVal;
|
|
548
|
-
var childrenToRender =
|
|
577
|
+
var childrenToRender = filledOptions;
|
|
549
578
|
|
|
550
|
-
if (Array.isArray(
|
|
551
|
-
childrenToRender = (0, _map.default)(
|
|
579
|
+
if (Array.isArray(childrenToRender) && childrenToRender.length > 0) {
|
|
580
|
+
childrenToRender = (0, _map.default)(childrenToRender).call(childrenToRender, function (item, index) {
|
|
552
581
|
if (item === null || item === undefined) return;
|
|
553
582
|
var temp = renderOption(item, index);
|
|
554
583
|
return temp;
|
|
@@ -572,26 +601,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
572
601
|
className: dropDownCls,
|
|
573
602
|
style: dropDownStyle,
|
|
574
603
|
ref: dropDownRef
|
|
575
|
-
},
|
|
576
|
-
className: searchCls
|
|
577
|
-
}, /*#__PURE__*/_react.default.createElement(_index.Input, {
|
|
578
|
-
ref: searchRef,
|
|
579
|
-
value: ((_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.value) || '',
|
|
580
|
-
borderType: "bordered",
|
|
581
|
-
placeholder: "\u8BF7\u8F93\u5165\u9700\u8981\u641C\u7D22\u7684\u5185\u5BB9",
|
|
582
|
-
// 搜索图标
|
|
583
|
-
prefix: /*#__PURE__*/_react.default.createElement("span", {
|
|
584
|
-
onClick: handleSearch
|
|
585
|
-
}, /*#__PURE__*/_react.default.createElement(_index.Icon, {
|
|
586
|
-
type: "search"
|
|
587
|
-
}) || searchIcon),
|
|
588
|
-
suffix: searchInput && /*#__PURE__*/_react.default.createElement("span", {
|
|
589
|
-
onClick: handleClear
|
|
590
|
-
}, /*#__PURE__*/_react.default.createElement(_index.Icon, {
|
|
591
|
-
type: "close"
|
|
592
|
-
})),
|
|
593
|
-
onChange: handleSearchChange
|
|
594
|
-
})), !dropdownRender && realChildren.length > 0 && dropRender(childrenToRender, heightStyle), renderNotContent(), /*#__PURE__*/_react.default.createElement("div", null, dropdownRender && dropdownRender(dropRender(childrenToRender, heightStyle))), isMultiple && /*#__PURE__*/_react.default.createElement("div", {
|
|
604
|
+
}, !dropdownRender && childrenToRender.length > 0 && dropRender(childrenToRender, heightStyle), renderNotContent(), /*#__PURE__*/_react.default.createElement("div", null, dropdownRender && dropdownRender(dropRender(childrenToRender, heightStyle))), isMultiple && /*#__PURE__*/_react.default.createElement("div", {
|
|
595
605
|
className: multipleFooterCls
|
|
596
606
|
}, /*#__PURE__*/_react.default.createElement(_index.Checkbox, {
|
|
597
607
|
style: checkboxStyle,
|
|
@@ -625,15 +635,43 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
625
635
|
disabled: disabled
|
|
626
636
|
}, maxTagPlaceholder);
|
|
627
637
|
}
|
|
628
|
-
}, [mulOptions]);
|
|
638
|
+
}, [mulOptions]);
|
|
639
|
+
|
|
640
|
+
var renderSingle = function renderSingle() {
|
|
641
|
+
var hiddenStyle = isShowSearch && !!searchValue || singleVal ? {
|
|
642
|
+
visibility: 'hidden'
|
|
643
|
+
} : undefined;
|
|
644
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
645
|
+
className: singleCls,
|
|
646
|
+
ref: selectionRef
|
|
647
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
648
|
+
className: "".concat(selectPrefixCls, "-selection-search")
|
|
649
|
+
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
650
|
+
ref: searchRef,
|
|
651
|
+
value: searchValue,
|
|
652
|
+
className: "".concat(selectPrefixCls, "-selection-search-input"),
|
|
653
|
+
onChange: handleSearchChange,
|
|
654
|
+
onFocus: handleFocus,
|
|
655
|
+
onBlur: handleBlur,
|
|
656
|
+
readOnly: !isShowSearch || !!disabled
|
|
657
|
+
})), singleVal && !searchValue && /*#__PURE__*/_react.default.createElement("span", {
|
|
658
|
+
className: "".concat(selectPrefixCls, "-selection-item")
|
|
659
|
+
}, singleVal), /*#__PURE__*/_react.default.createElement("span", {
|
|
660
|
+
className: "".concat(selectPrefixCls, "-placeholder"),
|
|
661
|
+
style: hiddenStyle
|
|
662
|
+
}, placeholder), /*#__PURE__*/_react.default.createElement("span", {
|
|
663
|
+
className: "".concat(selectPrefixCls, "-suffix")
|
|
664
|
+
}, renderSuffix())));
|
|
665
|
+
}; // 渲染多选选择器 (待优化:多选框下拉按钮样式调整,限制tag数代码优化)
|
|
666
|
+
|
|
629
667
|
|
|
630
668
|
var renderMultiple = function renderMultiple() {
|
|
631
|
-
var _context3,
|
|
669
|
+
var _context3, _classNames10, _context4, _classNames11;
|
|
632
670
|
|
|
633
671
|
var maxTagCount = selectProps.maxTagCount,
|
|
634
672
|
maxTagPlaceholder = selectProps.maxTagPlaceholder;
|
|
635
|
-
var multipleCls = (0, _classnames.default)(commCls, (
|
|
636
|
-
var itemCls = (0, _classnames.default)((
|
|
673
|
+
var multipleCls = (0, _classnames.default)(commCls, (_classNames10 = {}, (0, _defineProperty2.default)(_classNames10, "".concat(selectPrefixCls, "-multiple-disabled"), disabled), (0, _defineProperty2.default)(_classNames10, (0, _concat.default)(_context3 = "".concat(selectPrefixCls, "-")).call(_context3, mode), mode), (0, _defineProperty2.default)(_classNames10, "".concat(selectPrefixCls, "-focused"), autoFocus || optionShow), (0, _defineProperty2.default)(_classNames10, "".concat(selectPrefixCls, "-placeholder"), placeholder && !mulOptions.length), _classNames10));
|
|
674
|
+
var itemCls = (0, _classnames.default)((_classNames11 = {}, (0, _defineProperty2.default)(_classNames11, "".concat(selectPrefixCls, "-selection-item"), true), (0, _defineProperty2.default)(_classNames11, (0, _concat.default)(_context4 = "".concat(selectPrefixCls, "-selection-item-")).call(_context4, size), size), _classNames11));
|
|
637
675
|
var TagStyle = {
|
|
638
676
|
margin: '2px 8px 2px 0'
|
|
639
677
|
};
|
|
@@ -659,14 +697,29 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
659
697
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
660
698
|
className: "".concat(selectPrefixCls, "-selection-item-content")
|
|
661
699
|
}, "\u5171", mulOptions.length, "\u9879")) : null), /*#__PURE__*/_react.default.createElement("span", {
|
|
700
|
+
className: "".concat(selectPrefixCls, "-selection-search"),
|
|
701
|
+
style: {
|
|
702
|
+
width: inputWidth
|
|
703
|
+
}
|
|
704
|
+
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
705
|
+
ref: searchRef,
|
|
706
|
+
value: searchValue,
|
|
707
|
+
className: "".concat(selectPrefixCls, "-selection-search-input"),
|
|
708
|
+
onChange: handleSearchChange,
|
|
709
|
+
onFocus: handleFocus,
|
|
710
|
+
onBlur: handleBlur,
|
|
711
|
+
readOnly: !isShowSearch || !!disabled
|
|
712
|
+
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
713
|
+
ref: measureRef,
|
|
714
|
+
className: "".concat(selectPrefixCls, "-selection-search-mirror")
|
|
715
|
+
}, searchValue, "\xA0")), /*#__PURE__*/_react.default.createElement("span", {
|
|
662
716
|
className: "".concat(selectPrefixCls, "-placeholder")
|
|
663
|
-
}, !mulOptions.length && placeholder), /*#__PURE__*/_react.default.createElement("span", {
|
|
717
|
+
}, !mulOptions.length && !searchValue && placeholder), /*#__PURE__*/_react.default.createElement("span", {
|
|
664
718
|
className: "".concat(selectPrefixCls, "-suffix")
|
|
665
719
|
}, renderSuffix()));
|
|
666
720
|
};
|
|
667
721
|
|
|
668
|
-
var singleCls = (0, _classnames.default)(commCls, (
|
|
669
|
-
var singleTextCls = (0, _classnames.default)((_classNames14 = {}, (0, _defineProperty2.default)(_classNames14, "".concat(selectPrefixCls, "-single-text"), true), (0, _defineProperty2.default)(_classNames14, "".concat(selectPrefixCls, "-single-disabled-text"), disabled), _classNames14));
|
|
722
|
+
var singleCls = (0, _classnames.default)(commCls, (_classNames12 = {}, (0, _defineProperty2.default)(_classNames12, "".concat(selectPrefixCls, "-single"), true), (0, _defineProperty2.default)(_classNames12, "".concat(selectPrefixCls, "-single-disabled"), disabled), (0, _defineProperty2.default)(_classNames12, "".concat(selectPrefixCls, "-single-focused"), autoFocus && !disabled || optionShow), _classNames12));
|
|
670
723
|
|
|
671
724
|
var renderSelect = function renderSelect() {
|
|
672
725
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -676,18 +729,18 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
676
729
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
677
730
|
className: selectionCls,
|
|
678
731
|
onClick: handleClick,
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
},
|
|
732
|
+
tabIndex: disabled ? -1 : 0,
|
|
733
|
+
onFocus: function onFocus() {
|
|
734
|
+
var _a;
|
|
735
|
+
|
|
736
|
+
return (_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
737
|
+
},
|
|
738
|
+
onBlur: function onBlur() {
|
|
739
|
+
var _a;
|
|
740
|
+
|
|
741
|
+
return (_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
742
|
+
}
|
|
743
|
+
}, !isMultiple ? renderSingle() : renderMultiple()));
|
|
691
744
|
};
|
|
692
745
|
|
|
693
746
|
var catchStyle = function catchStyle() {
|