@kne/super-select 0.1.2 → 0.1.4
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/index.css +0 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +8 -7
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -2335,7 +2335,8 @@ const SelectInput = p => {
|
|
|
2335
2335
|
}, p, {
|
|
2336
2336
|
locale
|
|
2337
2337
|
});
|
|
2338
|
-
const [
|
|
2338
|
+
const [stateValue, setValue] = useControlValue(props);
|
|
2339
|
+
const value = stateValue || [];
|
|
2339
2340
|
const [searchText, setSearchText] = useState('');
|
|
2340
2341
|
const [open, setOpen] = useState(false);
|
|
2341
2342
|
const [hover, setHover] = useState(false);
|
|
@@ -2395,9 +2396,9 @@ const SelectInput = p => {
|
|
|
2395
2396
|
};
|
|
2396
2397
|
const onSelect = (item, currentSetValue) => {
|
|
2397
2398
|
(currentSetValue || setValue)(value => {
|
|
2398
|
-
const newValue = value.slice(0);
|
|
2399
|
-
const index =
|
|
2400
|
-
if (index === -1 && !checkMaxLength(
|
|
2399
|
+
const newValue = (value || []).slice(0);
|
|
2400
|
+
const index = newValue.findIndex(currentItem => currentItem.value === item.value);
|
|
2401
|
+
if (index === -1 && !checkMaxLength(newValue, maxLength)) {
|
|
2401
2402
|
return value;
|
|
2402
2403
|
}
|
|
2403
2404
|
if (index === -1) {
|
|
@@ -2423,7 +2424,7 @@ const SelectInput = p => {
|
|
|
2423
2424
|
}
|
|
2424
2425
|
}), /*#__PURE__*/React.createElement("div", {
|
|
2425
2426
|
className: classnames(style$3['select-input-inner'], 'select-input-inner')
|
|
2426
|
-
},
|
|
2427
|
+
}, value.length > 0 ? single || value[0].value === selectedAllValue.value ? value[0].label : value.map(item => {
|
|
2427
2428
|
return /*#__PURE__*/React.createElement(Tag, {
|
|
2428
2429
|
key: item.value,
|
|
2429
2430
|
closable: true,
|
|
@@ -2437,7 +2438,7 @@ const SelectInput = p => {
|
|
|
2437
2438
|
className: classnames(style$3['placeholder'], 'select-input-placeholder')
|
|
2438
2439
|
}, placeholder)), /*#__PURE__*/React.createElement("div", {
|
|
2439
2440
|
className: classnames(style$3['select-input-icon'], 'select-input-icon')
|
|
2440
|
-
}, !disabled && allowClear && hover &&
|
|
2441
|
+
}, !disabled && allowClear && hover && value.length > 0 ? /*#__PURE__*/React.createElement(CloseCircleFilled, {
|
|
2441
2442
|
onClick: e => {
|
|
2442
2443
|
e.stopPropagation();
|
|
2443
2444
|
setValue([]);
|
|
@@ -2445,7 +2446,7 @@ const SelectInput = p => {
|
|
|
2445
2446
|
}) : /*#__PURE__*/React.createElement(DownOutlined, null)));
|
|
2446
2447
|
const contextProps = {
|
|
2447
2448
|
props,
|
|
2448
|
-
value,
|
|
2449
|
+
value: value,
|
|
2449
2450
|
setValue,
|
|
2450
2451
|
searchText,
|
|
2451
2452
|
setSearchText,
|