@kdcloudjs/kdesign 1.7.17 → 1.7.18
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/dist/kdesign-complete.less +23 -16
- package/dist/kdesign.css +19 -15
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +125 -85
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +3 -3
- package/dist/kdesign.min.js +3 -3
- package/dist/kdesign.min.js.map +1 -1
- package/es/cascader/cascader.js +59 -60
- package/es/cascader/style/index.css +16 -6
- package/es/cascader/style/index.less +20 -6
- package/es/dropdown/dropdown.js +15 -5
- package/es/input/ClearableLabeledInput.js +9 -1
- package/es/select/option.js +6 -2
- package/es/select/select.js +32 -14
- package/es/select/style/index.css +2 -8
- package/es/select/style/index.less +3 -10
- package/lib/cascader/cascader.js +58 -59
- package/lib/cascader/style/index.css +16 -6
- package/lib/cascader/style/index.less +20 -6
- package/lib/dropdown/dropdown.js +15 -5
- package/lib/input/ClearableLabeledInput.js +8 -0
- package/lib/select/option.js +6 -2
- package/lib/select/select.js +32 -14
- package/lib/select/style/index.css +2 -8
- package/lib/select/style/index.less +3 -10
- package/package.json +1 -1
package/es/cascader/cascader.js
CHANGED
|
@@ -16,7 +16,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
16
16
|
}
|
|
17
17
|
return t;
|
|
18
18
|
};
|
|
19
|
-
import React, { useMemo, useCallback } from 'react';
|
|
19
|
+
import React, { useMemo, useCallback, useState, useRef } from 'react';
|
|
20
20
|
import classNames from 'classnames';
|
|
21
21
|
import { tuple } from '../_utils/type';
|
|
22
22
|
import { getCompProps } from '../_utils';
|
|
@@ -59,38 +59,41 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
59
59
|
onPopupVisibleChange = allProps.onPopupVisibleChange,
|
|
60
60
|
onPopperVisibleChange = allProps.onPopperVisibleChange,
|
|
61
61
|
customPrefixcls = allProps.prefixCls,
|
|
62
|
+
customAllowClear = allProps.allowClear,
|
|
63
|
+
popupPlacement = allProps.popupPlacement,
|
|
64
|
+
maxTagCount = allProps.maxTagCount,
|
|
62
65
|
otherProps = __rest(allProps
|
|
63
66
|
// className前缀
|
|
64
|
-
, ["mode", "style", "options", "bordered", "disabled", "children", "loadData", "clearIcon", "className", "fieldNames", "placeholder", "defaultValue", "maxTagPlaceholder", "displayRender", "expandTrigger", "changeOnSelect", "dropdownRender", "notFoundContent", "getPopupContainer", "defaultPopupVisible", "onPopupVisibleChange", "onPopperVisibleChange", "prefixCls"]);
|
|
67
|
+
, ["mode", "style", "options", "bordered", "disabled", "children", "loadData", "clearIcon", "className", "fieldNames", "placeholder", "defaultValue", "maxTagPlaceholder", "displayRender", "expandTrigger", "changeOnSelect", "dropdownRender", "notFoundContent", "getPopupContainer", "defaultPopupVisible", "onPopupVisibleChange", "onPopperVisibleChange", "prefixCls", "allowClear", "popupPlacement", "maxTagCount"]);
|
|
65
68
|
// className前缀
|
|
66
69
|
var prefixCls = getPrefixCls(pkgPrefixCls, 'cascader', customPrefixcls);
|
|
67
|
-
var pickerRef =
|
|
68
|
-
var triggerRef =
|
|
69
|
-
var wrapperRef =
|
|
70
|
+
var pickerRef = useRef();
|
|
71
|
+
var triggerRef = useRef();
|
|
72
|
+
var wrapperRef = useRef();
|
|
70
73
|
var mergeRef = ref || pickerRef;
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
visible =
|
|
74
|
-
setVisible =
|
|
74
|
+
var _useState = useState(!!props.popperVisible || !!props.popupVisible || defaultPopupVisible),
|
|
75
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
76
|
+
visible = _useState2[0],
|
|
77
|
+
setVisible = _useState2[1];
|
|
75
78
|
React.useEffect(function () {
|
|
76
79
|
setVisible(!!props.popperVisible || !!props.popupVisible);
|
|
77
80
|
}, [props.popperVisible, props.popupVisible]);
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
menus =
|
|
81
|
-
setMenus =
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
currentOptions =
|
|
85
|
-
setCurrentOptions =
|
|
86
|
-
var
|
|
87
|
-
|
|
88
|
-
selectedOptions =
|
|
89
|
-
setSelectedOptions =
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
value =
|
|
93
|
-
setValue =
|
|
81
|
+
var _useState3 = useState([options]),
|
|
82
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
83
|
+
menus = _useState4[0],
|
|
84
|
+
setMenus = _useState4[1];
|
|
85
|
+
var _useState5 = useState([]),
|
|
86
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
87
|
+
currentOptions = _useState6[0],
|
|
88
|
+
setCurrentOptions = _useState6[1];
|
|
89
|
+
var _useState7 = useState([]),
|
|
90
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
91
|
+
selectedOptions = _useState8[0],
|
|
92
|
+
setSelectedOptions = _useState8[1];
|
|
93
|
+
var _useState9 = useState(props.value || defaultValue || []),
|
|
94
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
95
|
+
value = _useState10[0],
|
|
96
|
+
setValue = _useState10[1];
|
|
94
97
|
React.useEffect(function () {
|
|
95
98
|
props.value && setValue(props.value);
|
|
96
99
|
}, [props.value]);
|
|
@@ -192,37 +195,10 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
192
195
|
});
|
|
193
196
|
});
|
|
194
197
|
}, [currentOptions, isMultiple]);
|
|
195
|
-
var allowClear =
|
|
196
|
-
var locatorProps = {
|
|
197
|
-
style: style,
|
|
198
|
-
tabIndex: 0,
|
|
199
|
-
className: classNames("".concat(prefixCls, "-picker"), className, {
|
|
200
|
-
expand: visible,
|
|
201
|
-
allowClear: allowClear,
|
|
202
|
-
disabled: disabled
|
|
203
|
-
})
|
|
204
|
-
};
|
|
198
|
+
var allowClear = customAllowClear && value.length > 0;
|
|
205
199
|
var handleClear = function handleClear() {
|
|
206
200
|
onChange([]);
|
|
207
201
|
};
|
|
208
|
-
var inputProps = {
|
|
209
|
-
value: value,
|
|
210
|
-
placeholder: placeholder,
|
|
211
|
-
readOnly: true,
|
|
212
|
-
disabled: disabled,
|
|
213
|
-
className: classNames("".concat(prefixCls, "-picker-input"), {
|
|
214
|
-
expand: visible
|
|
215
|
-
}),
|
|
216
|
-
suffix: props.suffixIcon || /*#__PURE__*/React.createElement(Icon, {
|
|
217
|
-
type: "arrow-down",
|
|
218
|
-
className: classNames({
|
|
219
|
-
expand: visible
|
|
220
|
-
})
|
|
221
|
-
})
|
|
222
|
-
};
|
|
223
|
-
if (bordered) {
|
|
224
|
-
inputProps.borderType = 'bordered';
|
|
225
|
-
}
|
|
226
202
|
var renderSuffix = function renderSuffix() {
|
|
227
203
|
var _classNames;
|
|
228
204
|
var suffixIcon = allProps.suffixIcon;
|
|
@@ -260,8 +236,6 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
260
236
|
};
|
|
261
237
|
var renderMultiple = function renderMultiple() {
|
|
262
238
|
var _classNames3, _classNames4;
|
|
263
|
-
var maxTagCount = allProps.maxTagCount,
|
|
264
|
-
maxTagPlaceholder = allProps.maxTagPlaceholder;
|
|
265
239
|
var multipleCls = classNames((_classNames3 = {
|
|
266
240
|
disabled: disabled
|
|
267
241
|
}, _defineProperty(_classNames3, "".concat(prefixCls, "-multiple"), true), _defineProperty(_classNames3, "".concat(prefixCls, "-bordered"), bordered), _classNames3));
|
|
@@ -300,19 +274,44 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
300
274
|
}, renderSuffix())));
|
|
301
275
|
};
|
|
302
276
|
var renderSingle = function renderSingle() {
|
|
303
|
-
|
|
277
|
+
var inputProps = {
|
|
278
|
+
value: value,
|
|
279
|
+
placeholder: placeholder,
|
|
280
|
+
readOnly: true,
|
|
281
|
+
borderType: bordered ? 'bordered' : 'underline',
|
|
282
|
+
disabled: disabled,
|
|
283
|
+
className: classNames("".concat(prefixCls, "-picker-input"), {
|
|
284
|
+
expand: visible
|
|
285
|
+
}),
|
|
286
|
+
suffix: props.suffixIcon || /*#__PURE__*/React.createElement(Icon, {
|
|
287
|
+
type: "arrow-down",
|
|
288
|
+
className: classNames({
|
|
289
|
+
expand: visible
|
|
290
|
+
})
|
|
291
|
+
})
|
|
292
|
+
};
|
|
293
|
+
var singleProps = {
|
|
294
|
+
style: style,
|
|
295
|
+
tabIndex: 0,
|
|
296
|
+
className: classNames("".concat(prefixCls, "-picker"), className, _defineProperty({
|
|
297
|
+
expand: visible,
|
|
298
|
+
allowClear: allowClear,
|
|
299
|
+
disabled: disabled
|
|
300
|
+
}, "".concat(prefixCls, "-bordered"), bordered))
|
|
301
|
+
};
|
|
302
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, singleProps, {
|
|
304
303
|
ref: mergeRef
|
|
305
304
|
}, otherProps), React.Children.count(children) === 1 && children.type ? /*#__PURE__*/React.cloneElement(children, {
|
|
306
305
|
ref: triggerRef
|
|
307
|
-
}) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("
|
|
306
|
+
}) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
308
307
|
ref: triggerRef
|
|
309
308
|
}, /*#__PURE__*/React.createElement(Input, _extends({}, inputProps)), /*#__PURE__*/React.createElement("span", {
|
|
310
309
|
className: "".concat(prefixCls, "-picker-label")
|
|
311
|
-
}, (labels === null || labels === void 0 ? void 0 : labels.length) ? displayRender(labels, currentOptions) : '')
|
|
310
|
+
}, (labels === null || labels === void 0 ? void 0 : labels.length) ? displayRender(labels, currentOptions) : ''), allowClear && /*#__PURE__*/React.createElement(Icon, {
|
|
312
311
|
type: "close-solid",
|
|
313
312
|
className: "".concat(prefixCls, "-picker-close"),
|
|
314
313
|
onClick: handleClear
|
|
315
|
-
})));
|
|
314
|
+
}))));
|
|
316
315
|
};
|
|
317
316
|
var cascaderLocator = isMultiple ? renderMultiple() : renderSingle();
|
|
318
317
|
var onExpend = function onExpend(index, opt, opts) {
|
|
@@ -424,7 +423,7 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
424
423
|
trigger: 'click',
|
|
425
424
|
getPopupContainer: getPopupContainer,
|
|
426
425
|
prefixCls: "".concat(prefixCls, "-menus"),
|
|
427
|
-
placement: allProps.popperPlacement ||
|
|
426
|
+
placement: allProps.popperPlacement || popupPlacement,
|
|
428
427
|
popperClassName: allProps.popperClassName || allProps.popupClassName,
|
|
429
428
|
getTriggerElement: function getTriggerElement() {
|
|
430
429
|
return triggerRef.current;
|
|
@@ -108,9 +108,9 @@
|
|
|
108
108
|
/** 浮层箭头样式 **/
|
|
109
109
|
.kd-cascader-picker {
|
|
110
110
|
position: relative;
|
|
111
|
-
display: inline-block;
|
|
112
111
|
outline: none;
|
|
113
112
|
cursor: pointer;
|
|
113
|
+
background: var(--kd-c-cascader-color-background, var(--kd-g-color-white, #fff));
|
|
114
114
|
}
|
|
115
115
|
.kd-cascader-picker:focus > .kd-cascader-picker-input {
|
|
116
116
|
border-color: var(--kd-c-cascader-color-active, #999);
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
left: 0;
|
|
140
140
|
width: 100%;
|
|
141
141
|
height: 20px;
|
|
142
|
-
padding: 0 24px 0
|
|
142
|
+
padding: 0 24px 0 0;
|
|
143
143
|
line-height: 20px;
|
|
144
144
|
-webkit-transform: translateY(-50%);
|
|
145
145
|
transform: translateY(-50%);
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
-webkit-transition: all 0.2s;
|
|
170
170
|
transition: all 0.2s;
|
|
171
171
|
}
|
|
172
|
-
.kd-cascader-picker.allowClear:hover
|
|
172
|
+
.kd-cascader-picker.allowClear:hover .kd-cascader-picker-close {
|
|
173
173
|
opacity: 1;
|
|
174
174
|
visibility: visible;
|
|
175
175
|
-webkit-transition: all 0.2s;
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
.kd-cascader-picker-close {
|
|
187
187
|
position: absolute;
|
|
188
188
|
top: 50%;
|
|
189
|
-
right:
|
|
189
|
+
right: 0;
|
|
190
190
|
opacity: 0;
|
|
191
191
|
cursor: pointer;
|
|
192
192
|
visibility: hidden;
|
|
@@ -278,11 +278,20 @@
|
|
|
278
278
|
.kd-cascader-menus .kd-empty {
|
|
279
279
|
padding: 10px 0 20px;
|
|
280
280
|
}
|
|
281
|
-
.kd-cascader-bordered {
|
|
281
|
+
.kd-cascader-bordered:not(.kd-cascader-multiple) .kd-cascader-picker-label {
|
|
282
|
+
padding-left: 9px;
|
|
283
|
+
}
|
|
284
|
+
.kd-cascader-bordered:not(.kd-cascader-multiple) .kd-cascader-picker-close {
|
|
285
|
+
right: 10px;
|
|
286
|
+
}
|
|
287
|
+
.kd-cascader-bordered.kd-cascader-multiple {
|
|
282
288
|
border: 1px solid #d9d9d9;
|
|
283
|
-
padding-left: 8px
|
|
289
|
+
padding-left: 8px;
|
|
284
290
|
border-radius: 2px;
|
|
285
291
|
}
|
|
292
|
+
.kd-cascader-bordered.kd-cascader-multiple .kd-cascader-suffix {
|
|
293
|
+
right: 9px;
|
|
294
|
+
}
|
|
286
295
|
.kd-cascader-multiple {
|
|
287
296
|
padding: 1px 28px 1px 0;
|
|
288
297
|
-webkit-transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
@@ -301,6 +310,7 @@
|
|
|
301
310
|
overflow-x: hidden;
|
|
302
311
|
position: relative;
|
|
303
312
|
border-bottom: 1px solid #d9d9d9;
|
|
313
|
+
background: var(--kd-c-cascader-color-background, var(--kd-g-color-white, #fff));
|
|
304
314
|
}
|
|
305
315
|
.kd-cascader-multiple-wrapper {
|
|
306
316
|
display: -webkit-box;
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
.@{cascader-picker-prefix-cls} {
|
|
10
10
|
position: relative;
|
|
11
|
-
display: inline-block;
|
|
12
11
|
outline: none;
|
|
13
12
|
cursor: pointer;
|
|
13
|
+
background: @cascader-bg-color;
|
|
14
14
|
|
|
15
15
|
&:focus > &-input {
|
|
16
16
|
border-color: @cascader-active-color;
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
left: 0;
|
|
48
48
|
width: 100%;
|
|
49
49
|
height: 20px;
|
|
50
|
-
padding: 0 24px 0
|
|
50
|
+
padding: 0 24px 0 0;
|
|
51
51
|
line-height: 20px;
|
|
52
52
|
transform: translateY(-50%);
|
|
53
53
|
.ellipsis;
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
&.allowClear:hover {
|
|
81
|
-
|
|
81
|
+
.@{cascader-picker-prefix-cls}-close {
|
|
82
82
|
opacity: 1;
|
|
83
83
|
visibility: visible;
|
|
84
84
|
transition: all 0.2s;
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
&-close {
|
|
96
96
|
position: absolute;
|
|
97
97
|
top: 50%;
|
|
98
|
-
right:
|
|
98
|
+
right: 0;
|
|
99
99
|
opacity: 0;
|
|
100
100
|
cursor: pointer;
|
|
101
101
|
visibility: hidden;
|
|
@@ -183,10 +183,23 @@
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
.@{kd-prefix}-cascader {
|
|
186
|
-
&-bordered {
|
|
186
|
+
&-bordered:not(.@{kd-prefix}-cascader-multiple) {
|
|
187
|
+
.@{cascader-picker-prefix-cls}-label {
|
|
188
|
+
padding-left: 9px;
|
|
189
|
+
}
|
|
190
|
+
.@{cascader-picker-prefix-cls}-close {
|
|
191
|
+
right: 10px;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
&-bordered&-multiple {
|
|
187
196
|
border: 1px solid #d9d9d9;
|
|
188
|
-
padding-left: 8px
|
|
197
|
+
padding-left: 8px;
|
|
189
198
|
border-radius: 2px;
|
|
199
|
+
|
|
200
|
+
.@{kd-prefix}-cascader-suffix {
|
|
201
|
+
right: 9px;
|
|
202
|
+
}
|
|
190
203
|
}
|
|
191
204
|
|
|
192
205
|
&-multiple {
|
|
@@ -203,6 +216,7 @@
|
|
|
203
216
|
overflow-x: hidden;
|
|
204
217
|
position: relative;
|
|
205
218
|
border-bottom: 1px solid #d9d9d9;
|
|
219
|
+
background: @cascader-bg-color;
|
|
206
220
|
}
|
|
207
221
|
|
|
208
222
|
&-multiple-wrapper {
|
package/es/dropdown/dropdown.js
CHANGED
|
@@ -30,6 +30,7 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
30
30
|
onItemClick = allProps.onItemClick,
|
|
31
31
|
defaultVisible = allProps.defaultVisible,
|
|
32
32
|
onVisibleChange = allProps.onVisibleChange,
|
|
33
|
+
trigger = allProps.trigger,
|
|
33
34
|
customPrefixcls = allProps.prefixCls;
|
|
34
35
|
// className前缀
|
|
35
36
|
var prefixCls = getPrefixCls(pkgPrefixCls, 'dropdown', customPrefixcls);
|
|
@@ -40,10 +41,23 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
40
41
|
React.useEffect(function () {
|
|
41
42
|
setVisible(!!props.visible);
|
|
42
43
|
}, [props.visible]);
|
|
44
|
+
var handleVisibleChange = function handleVisibleChange(visible) {
|
|
45
|
+
props.visible === undefined && setVisible(visible);
|
|
46
|
+
onVisibleChange && onVisibleChange(visible);
|
|
47
|
+
};
|
|
43
48
|
var child = children && ((_a = children === null || children === void 0 ? void 0 : children.type) === null || _a === void 0 ? void 0 : _a.displayName) === 'Input' ? /*#__PURE__*/React.createElement("span", {
|
|
44
49
|
className: classNames("".concat(prefixCls, "-trigger"), "".concat(prefixCls, "-trigger-container")),
|
|
45
50
|
ref: ref
|
|
46
|
-
},
|
|
51
|
+
}, trigger === 'focus' ? /*#__PURE__*/React.cloneElement(React.Children.only(children), {
|
|
52
|
+
onFocus: function onFocus(e) {
|
|
53
|
+
children.props.onFocus && children.props.onFocus(e);
|
|
54
|
+
handleVisibleChange(true);
|
|
55
|
+
},
|
|
56
|
+
onBlur: function onBlur(e) {
|
|
57
|
+
children.props.onBlur && children.props.onBlur(e);
|
|
58
|
+
handleVisibleChange(false);
|
|
59
|
+
}
|
|
60
|
+
}) : children) : /*#__PURE__*/React.cloneElement(React.Children.only(children), {
|
|
47
61
|
ref: children.ref || ref,
|
|
48
62
|
className: classNames("".concat(prefixCls, "-trigger"), children.props.className, {
|
|
49
63
|
disabled: disabled
|
|
@@ -110,10 +124,6 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
110
124
|
role: "menuitem"
|
|
111
125
|
}, href === undefined || disabled ? /*#__PURE__*/React.createElement("span", null, label) : /*#__PURE__*/React.createElement("a", _extends({}, alinkProps), /*#__PURE__*/React.createElement("span", null, label)));
|
|
112
126
|
}));
|
|
113
|
-
var handleVisibleChange = function handleVisibleChange(visible) {
|
|
114
|
-
props.visible === undefined && setVisible(visible);
|
|
115
|
-
onVisibleChange && onVisibleChange(visible);
|
|
116
|
-
};
|
|
117
127
|
var popperProps = _extends(_extends({}, allProps), {
|
|
118
128
|
visible: visible,
|
|
119
129
|
prefixCls: prefixCls,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
3
3
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
4
|
-
import React, { useState } from 'react';
|
|
4
|
+
import React, { useRef, useState } from 'react';
|
|
5
5
|
import { Icon } from '../index';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import { tuple } from '../_utils/type';
|
|
@@ -30,6 +30,7 @@ var ClearableInput = function ClearableInput(props) {
|
|
|
30
30
|
inputCount = props.inputCount,
|
|
31
31
|
count = props.count,
|
|
32
32
|
status = props.status;
|
|
33
|
+
var fixRef = useRef(null);
|
|
33
34
|
var _useState = useState(false),
|
|
34
35
|
_useState2 = _slicedToArray(_useState, 2),
|
|
35
36
|
isMouseEnter = _useState2[0],
|
|
@@ -44,6 +45,11 @@ var ClearableInput = function ClearableInput(props) {
|
|
|
44
45
|
e.stopPropagation();
|
|
45
46
|
e.preventDefault();
|
|
46
47
|
};
|
|
48
|
+
var clickHandle = function clickHandle(e) {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
e.stopPropagation();
|
|
51
|
+
(_b = (_a = fixRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('input')) === null || _b === void 0 ? void 0 : _b.focus();
|
|
52
|
+
};
|
|
47
53
|
var renderClearIcon = function renderClearIcon() {
|
|
48
54
|
var _classNames;
|
|
49
55
|
if (!allowClear) {
|
|
@@ -85,7 +91,9 @@ var ClearableInput = function ClearableInput(props) {
|
|
|
85
91
|
var inputWrapperClasses = classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefixCls, "-wrapper"), true), _defineProperty(_classNames2, "".concat(prefixCls, "-wrapper-focused"), focused && !disabled), _defineProperty(_classNames2, _concatInstanceProperty(_context = "".concat(prefixCls, "-wrapper-size-")).call(_context, size), size), _defineProperty(_classNames2, "".concat(prefixCls, "-wrapper-borderless"), borderType === 'none'), _defineProperty(_classNames2, "".concat(prefixCls, "-wrapper-underline"), borderType === 'underline'), _defineProperty(_classNames2, "".concat(prefixCls, "-error"), status === 'error'), _defineProperty(_classNames2, "".concat(prefixCls, "-wrapper-disabled"), disabled), _classNames2), _defineProperty({}, className, className && !addonBefore && !addonAfter));
|
|
86
92
|
return /*#__PURE__*/React.createElement("span", {
|
|
87
93
|
className: inputWrapperClasses,
|
|
94
|
+
ref: fixRef,
|
|
88
95
|
style: style,
|
|
96
|
+
onClick: clickHandle,
|
|
89
97
|
onMouseEnter: mouseEnterHandle,
|
|
90
98
|
onMouseLeave: mouseLeaveHandle
|
|
91
99
|
}, prefixNode, /*#__PURE__*/React.cloneElement(originElement, {
|
package/es/select/option.js
CHANGED
|
@@ -48,9 +48,12 @@ var InternalOption = function InternalOption(props, ref) {
|
|
|
48
48
|
}
|
|
49
49
|
onChangeSelect && onChangeSelect(value, children, isSelected);
|
|
50
50
|
};
|
|
51
|
-
var
|
|
51
|
+
var handleOnMouseEnter = function handleOnMouseEnter() {
|
|
52
52
|
onChangeActiveIndex && onChangeActiveIndex(index);
|
|
53
53
|
};
|
|
54
|
+
var handleOnMouseLeave = function handleOnMouseLeave() {
|
|
55
|
+
onChangeActiveIndex && onChangeActiveIndex(-1);
|
|
56
|
+
};
|
|
54
57
|
var titleText = title || (_typeof(children) !== 'object' ? children : null);
|
|
55
58
|
var checkStyle = {
|
|
56
59
|
minHeight: '22px',
|
|
@@ -61,7 +64,8 @@ var InternalOption = function InternalOption(props, ref) {
|
|
|
61
64
|
className: optionCls,
|
|
62
65
|
title: titleText,
|
|
63
66
|
onClick: handleClick,
|
|
64
|
-
|
|
67
|
+
onMouseEnter: handleOnMouseEnter,
|
|
68
|
+
onMouseLeave: handleOnMouseLeave
|
|
65
69
|
}, /*#__PURE__*/React.createElement("div", {
|
|
66
70
|
className: contentCls
|
|
67
71
|
}, isMultiple ? /*#__PURE__*/React.createElement(Checkbox, {
|
package/es/select/select.js
CHANGED
|
@@ -53,7 +53,8 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
53
53
|
children = selectProps.children,
|
|
54
54
|
options = selectProps.options,
|
|
55
55
|
placeholder = selectProps.placeholder,
|
|
56
|
-
|
|
56
|
+
_selectProps$dropdown = selectProps.dropdownStyle,
|
|
57
|
+
dropdownStyle = _selectProps$dropdown === void 0 ? {} : _selectProps$dropdown,
|
|
57
58
|
style = selectProps.style,
|
|
58
59
|
clearIcon = selectProps.clearIcon,
|
|
59
60
|
filterOption = selectProps.filterOption,
|
|
@@ -82,6 +83,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
82
83
|
selectMulOpts: []
|
|
83
84
|
}); // 多选ref已选中项
|
|
84
85
|
var measureRef = useRef(null);
|
|
86
|
+
var clearRef = useRef(null);
|
|
85
87
|
var _useState = useState([]),
|
|
86
88
|
_useState2 = _slicedToArray(_useState, 2),
|
|
87
89
|
mulOptions = _useState2[0],
|
|
@@ -122,7 +124,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
122
124
|
// 多选底部样式
|
|
123
125
|
var multipleFooterCls = classNames(_defineProperty({}, "".concat(selectPrefixCls, "-multiple-footer"), true));
|
|
124
126
|
// 多选,单选公共样式
|
|
125
|
-
var commCls = classNames((_classNames6 = {}, _defineProperty(_classNames6, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), _defineProperty(_classNames6, _concatInstanceProperty(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-wrapper"), true), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-show-search"), isShowSearch), _classNames6));
|
|
127
|
+
var commCls = classNames((_classNames6 = {}, _defineProperty(_classNames6, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), _defineProperty(_classNames6, _concatInstanceProperty(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-wrapper"), true), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-show-search"), isShowSearch && focusd), _classNames6));
|
|
126
128
|
useEffect(function () {
|
|
127
129
|
if (typeof props.visible !== 'undefined') {
|
|
128
130
|
setOptionShow(props.visible);
|
|
@@ -268,7 +270,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
268
270
|
}, [optionLabelProp, selectProps]);
|
|
269
271
|
// 点击下拉列表中某项回调
|
|
270
272
|
var handleOption = function handleOption(key, label, isSelected) {
|
|
271
|
-
var _a;
|
|
273
|
+
var _a, _b;
|
|
272
274
|
var onSelect = selectProps.onSelect,
|
|
273
275
|
onDeselect = selectProps.onDeselect,
|
|
274
276
|
labelInValue = selectProps.labelInValue,
|
|
@@ -283,6 +285,8 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
283
285
|
})) || {};
|
|
284
286
|
if (isMultiple) {
|
|
285
287
|
(_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
288
|
+
} else {
|
|
289
|
+
(_b = searchRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
|
286
290
|
}
|
|
287
291
|
var optionsObj = obj.props ? obj.props : obj || {};
|
|
288
292
|
if (value !== undefined) {
|
|
@@ -439,17 +443,17 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
439
443
|
var renderSuffix = function renderSuffix() {
|
|
440
444
|
var _classNames7;
|
|
441
445
|
var suffixIcon = selectProps.suffixIcon;
|
|
442
|
-
var selectedVal = multipleRef.current.selectedVal;
|
|
443
446
|
// 选择器下拉icon样式
|
|
444
447
|
var arrowIconCls = classNames((_classNames7 = {}, _defineProperty(_classNames7, "".concat(selectPrefixCls, "-icon-arrow"), true), _defineProperty(_classNames7, "".concat(selectPrefixCls, "-icon-arrow-up"), optionShow), _defineProperty(_classNames7, "".concat(selectPrefixCls, "-icon-arrow-down"), !optionShow), _defineProperty(_classNames7, "".concat(selectPrefixCls, "-icon-arrow-focus"), optionShow), _classNames7));
|
|
445
|
-
var iconShow = allowClear && !disabled && ((isMultiple ? mulOptions.length > 0 : (
|
|
448
|
+
var iconShow = allowClear && !disabled && ((isMultiple ? mulOptions.length > 0 : (singleVal !== null && singleVal !== void 0 ? singleVal : '') !== '') || searchValue);
|
|
446
449
|
var clearIconCls = classNames(_defineProperty({}, "".concat(selectPrefixCls, "-icon-clear"), true));
|
|
447
450
|
return /*#__PURE__*/React.createElement(React.Fragment, null, iconShow && /*#__PURE__*/React.createElement("span", {
|
|
448
451
|
onClick: handleReset,
|
|
449
452
|
onMouseDown: function onMouseDown(e) {
|
|
450
453
|
return e.preventDefault();
|
|
451
454
|
},
|
|
452
|
-
className: clearIconCls
|
|
455
|
+
className: clearIconCls,
|
|
456
|
+
ref: clearRef
|
|
453
457
|
}, clearIcon || /*#__PURE__*/React.createElement(Icon, {
|
|
454
458
|
type: "close-solid"
|
|
455
459
|
})), showArrow && /*#__PURE__*/React.createElement("span", {
|
|
@@ -545,9 +549,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
545
549
|
maxHeight: listHeight || '300px'
|
|
546
550
|
};
|
|
547
551
|
// 下拉框style属性
|
|
548
|
-
var dropDownStyle = _extends({
|
|
549
|
-
width: style === null || style === void 0 ? void 0 : style.width
|
|
550
|
-
}, dropdownStyle);
|
|
551
552
|
var checkboxStyle = {
|
|
552
553
|
height: '30px',
|
|
553
554
|
background: 'none'
|
|
@@ -556,7 +557,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
556
557
|
var checked = mulOptions.length === filledOptions.length;
|
|
557
558
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
558
559
|
className: dropDownCls,
|
|
559
|
-
style:
|
|
560
|
+
style: dropdownStyle,
|
|
560
561
|
ref: dropDownRef
|
|
561
562
|
}, !dropdownRender && childrenToRender.length > 0 && dropRender(eleOptionList, heightStyle), renderNotContent(), /*#__PURE__*/React.createElement("div", null, dropdownRender && dropdownRender(dropRender(childrenToRender, heightStyle))), isMultiple && realChildren.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
562
563
|
className: multipleFooterCls
|
|
@@ -720,7 +721,18 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
720
721
|
onDropdownVisibleChange && onDropdownVisibleChange(true);
|
|
721
722
|
}
|
|
722
723
|
}, [optionShow]);
|
|
723
|
-
|
|
724
|
+
useEffect(function () {
|
|
725
|
+
var _a;
|
|
726
|
+
var fn = function fn(e) {
|
|
727
|
+
e.stopPropagation();
|
|
728
|
+
};
|
|
729
|
+
(_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseup', fn);
|
|
730
|
+
return function () {
|
|
731
|
+
var _a;
|
|
732
|
+
(_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseup', fn);
|
|
733
|
+
};
|
|
734
|
+
}, [singleVal, mulOptions]);
|
|
735
|
+
var _useState13 = useState(isShowSearch ? getActiveIndex(0) : -1),
|
|
724
736
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
725
737
|
activeIndex = _useState14[0],
|
|
726
738
|
setActiveIndex = _useState14[1];
|
|
@@ -814,13 +826,19 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
814
826
|
if (selectRef === null || selectRef === void 0 ? void 0 : selectRef.current) {
|
|
815
827
|
var _ref2 = (_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(),
|
|
816
828
|
width = _ref2.width;
|
|
817
|
-
return _extends({
|
|
818
|
-
|
|
829
|
+
return _extends(_extends(_extends({
|
|
830
|
+
minWidth: width,
|
|
831
|
+
maxWidth: 600
|
|
832
|
+
}, dropdownStyle), {
|
|
833
|
+
width: (dropdownStyle === null || dropdownStyle === void 0 ? void 0 : dropdownStyle.width) || 'auto',
|
|
819
834
|
zIndex: 1050
|
|
820
|
-
}, popperStyle);
|
|
835
|
+
}), popperStyle);
|
|
821
836
|
}
|
|
822
837
|
};
|
|
823
838
|
var handleVisibleChange = function handleVisibleChange(visible) {
|
|
839
|
+
if (!visible) {
|
|
840
|
+
setActiveIndex(isShowSearch ? getActiveIndex(0) : -1);
|
|
841
|
+
}
|
|
824
842
|
if (visible !== optionShow) {
|
|
825
843
|
props.visible === undefined && setOptionShow(visible);
|
|
826
844
|
onVisibleChange && onVisibleChange(visible);
|
|
@@ -249,7 +249,7 @@
|
|
|
249
249
|
.kd-select-visible .kd-select-icon-active {
|
|
250
250
|
color: #3761ca;
|
|
251
251
|
}
|
|
252
|
-
.kd-select-visible .kd-select-selection-item {
|
|
252
|
+
.kd-select-visible div.kd-select-show-search .kd-select-selection-item {
|
|
253
253
|
color: var(--kd-c-select-placeholder-color-text, #b2b2b2);
|
|
254
254
|
}
|
|
255
255
|
.kd-select-icon-arrow {
|
|
@@ -277,9 +277,6 @@
|
|
|
277
277
|
transition: transform calc(0.3s - 0.1s) cubic-bezier(0.4, 0, 0.6, 1);
|
|
278
278
|
transition: transform calc(0.3s - 0.1s) cubic-bezier(0.4, 0, 0.6, 1), -webkit-transform calc(0.3s - 0.1s) cubic-bezier(0.4, 0, 0.6, 1);
|
|
279
279
|
}
|
|
280
|
-
.kd-select-icon-arrow-focus {
|
|
281
|
-
color: var(--kd-c-select-color-border-foucs, var(--kd-g-color-theme, #5582f3));
|
|
282
|
-
}
|
|
283
280
|
.kd-select-icon-clear {
|
|
284
281
|
opacity: 0;
|
|
285
282
|
z-index: 1;
|
|
@@ -362,7 +359,7 @@
|
|
|
362
359
|
z-index: var(--kd-c-select-z-index, var(--kd-g-z-index-popper, 1050));
|
|
363
360
|
-webkit-box-sizing: border-box;
|
|
364
361
|
box-sizing: border-box;
|
|
365
|
-
padding:
|
|
362
|
+
padding: 8px 0;
|
|
366
363
|
margin: 0;
|
|
367
364
|
overflow: auto;
|
|
368
365
|
font-size: var(--kd-c-select-dropdown-font-size, 12px);
|
|
@@ -415,9 +412,6 @@
|
|
|
415
412
|
.kd-select-item-option-content .kd-checkbox .kd-checkbox-children {
|
|
416
413
|
display: inline-block;
|
|
417
414
|
}
|
|
418
|
-
.kd-select-item-option:hover:not(.kd-select-item-option-selected):not(.kd-select-item-option-disabled) {
|
|
419
|
-
background-color: var(--kd-c-select-color-background, #f5f5f5);
|
|
420
|
-
}
|
|
421
415
|
.kd-select-item-option-active:not(.kd-select-item-option-disabled) {
|
|
422
416
|
background-color: var(--kd-c-select-color-background, #f5f5f5);
|
|
423
417
|
}
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
.@{select-prefix-cls}-icon-active {
|
|
22
22
|
color: #3761ca;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
& div.@{select-prefix-cls}-show-search .@{select-prefix-cls}-selection-item {
|
|
25
26
|
color: @select-placeholder-color;
|
|
26
27
|
}
|
|
27
28
|
}
|
|
@@ -40,10 +41,6 @@
|
|
|
40
41
|
transform: rotate(0deg);
|
|
41
42
|
transition: transform calc(@transition-duration - 0.1s) @ease;
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
&-focus {
|
|
45
|
-
color: @select-g-color-border-foucs;
|
|
46
|
-
}
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
&-clear {
|
|
@@ -135,7 +132,7 @@
|
|
|
135
132
|
left: 0;
|
|
136
133
|
z-index: @select-z-index;
|
|
137
134
|
box-sizing: border-box;
|
|
138
|
-
padding:
|
|
135
|
+
padding: 8px 0; // update
|
|
139
136
|
margin: 0;
|
|
140
137
|
overflow: auto;
|
|
141
138
|
font-size: @select-list-font-size; // update
|
|
@@ -184,10 +181,6 @@
|
|
|
184
181
|
}
|
|
185
182
|
}
|
|
186
183
|
|
|
187
|
-
&:hover:not(&-selected):not(&-disabled) {
|
|
188
|
-
background-color: @select-item-active-bg;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
184
|
&-active:not(&-disabled) {
|
|
192
185
|
background-color: @select-item-active-bg;
|
|
193
186
|
}
|