labsense-ui-kit 1.3.35 → 1.3.37
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/Dropdown/SelectOption.d.ts +2 -0
- package/dist/index.js +24 -10
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +24 -10
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8191,7 +8191,6 @@ var SearchBar$1 = styled__default.input(_templateObject10$3 || (_templateObject1
|
|
|
8191
8191
|
return $placeholderColor || theme.vms.text.light;
|
|
8192
8192
|
});
|
|
8193
8193
|
var SelectOption = function SelectOption(_ref37) {
|
|
8194
|
-
var _options$find;
|
|
8195
8194
|
var title = _ref37.title,
|
|
8196
8195
|
titlecolor = _ref37.titlecolor,
|
|
8197
8196
|
titleWeight = _ref37.titleWeight,
|
|
@@ -8241,7 +8240,11 @@ var SelectOption = function SelectOption(_ref37) {
|
|
|
8241
8240
|
_ref37$dropDownPositi = _ref37.dropDownPosition,
|
|
8242
8241
|
dropDownPosition = _ref37$dropDownPositi === void 0 ? 'left' : _ref37$dropDownPositi,
|
|
8243
8242
|
_ref37$allowCustomVal = _ref37.allowCustomValue,
|
|
8244
|
-
allowCustomValue = _ref37$allowCustomVal === void 0 ? false : _ref37$allowCustomVal
|
|
8243
|
+
allowCustomValue = _ref37$allowCustomVal === void 0 ? false : _ref37$allowCustomVal,
|
|
8244
|
+
_ref37$loading = _ref37.loading,
|
|
8245
|
+
loading = _ref37$loading === void 0 ? false : _ref37$loading,
|
|
8246
|
+
_ref37$loadingText = _ref37.loadingText,
|
|
8247
|
+
loadingText = _ref37$loadingText === void 0 ? 'Loading...' : _ref37$loadingText;
|
|
8245
8248
|
var themeColors = useTheme();
|
|
8246
8249
|
var _useState = React.useState(false),
|
|
8247
8250
|
dropUp = _useState[0],
|
|
@@ -8252,6 +8255,12 @@ var SelectOption = function SelectOption(_ref37) {
|
|
|
8252
8255
|
var _useState3 = React.useState(''),
|
|
8253
8256
|
searchTerm = _useState3[0],
|
|
8254
8257
|
setSearchTerm = _useState3[1];
|
|
8258
|
+
React.useEffect(function () {
|
|
8259
|
+
if (loading) {
|
|
8260
|
+
setIsOpen(false);
|
|
8261
|
+
setSearchTerm('');
|
|
8262
|
+
}
|
|
8263
|
+
}, [loading]);
|
|
8255
8264
|
var showSearchBox = searchBox && (options.length > 5 || allowCustomValue);
|
|
8256
8265
|
var toggleDropdown = function toggleDropdown() {
|
|
8257
8266
|
var refToUse = (positionRef === null || positionRef === void 0 ? void 0 : positionRef.current) || dropdownRef.current;
|
|
@@ -8327,9 +8336,10 @@ var SelectOption = function SelectOption(_ref37) {
|
|
|
8327
8336
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
8328
8337
|
};
|
|
8329
8338
|
}, []);
|
|
8330
|
-
var
|
|
8339
|
+
var selectedOption = options === null || options === void 0 ? void 0 : options.find(function (option) {
|
|
8331
8340
|
return option.value === value;
|
|
8332
|
-
})
|
|
8341
|
+
});
|
|
8342
|
+
var displayLabel = (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || (allowCustomValue && value ? value : '');
|
|
8333
8343
|
var handleSearchChange = function handleSearchChange(e) {
|
|
8334
8344
|
setSearchTerm(e.target.value);
|
|
8335
8345
|
};
|
|
@@ -8352,7 +8362,7 @@ var SelectOption = function SelectOption(_ref37) {
|
|
|
8352
8362
|
"$width": width
|
|
8353
8363
|
}, React__default.createElement(DropdownButton$1, {
|
|
8354
8364
|
onClick: function onClick() {
|
|
8355
|
-
if (!disabled) toggleDropdown();
|
|
8365
|
+
if (!disabled && !loading) toggleDropdown();
|
|
8356
8366
|
},
|
|
8357
8367
|
"$width": width,
|
|
8358
8368
|
"$border": border,
|
|
@@ -8360,19 +8370,23 @@ var SelectOption = function SelectOption(_ref37) {
|
|
|
8360
8370
|
"$borderRadius": borderRadius,
|
|
8361
8371
|
"$size": size,
|
|
8362
8372
|
"$isOpen": isOpen,
|
|
8363
|
-
"$disabled": disabled
|
|
8373
|
+
"$disabled": disabled || loading
|
|
8364
8374
|
}, icon && React__default.createElement(Icon, {
|
|
8365
8375
|
icon: icon.name,
|
|
8366
8376
|
size: icon.size || 14,
|
|
8367
8377
|
weight: icon.weight || '1px',
|
|
8368
8378
|
color: icon.color || themeColors.vms.text.medium,
|
|
8369
8379
|
cursor: 'pointer'
|
|
8370
|
-
}),
|
|
8380
|
+
}), loading ? React__default.createElement(LabelText$1, {
|
|
8381
|
+
"$fontStyle": 'italic',
|
|
8382
|
+
"$disabled": true,
|
|
8383
|
+
"$size": size
|
|
8384
|
+
}, loadingText) : displayLabel ? React__default.createElement(LabelText$1, {
|
|
8371
8385
|
"$color": color,
|
|
8372
8386
|
"$disabled": disabled,
|
|
8373
8387
|
"$size": size
|
|
8374
|
-
},
|
|
8375
|
-
"$fontStyle": fontStyle
|
|
8388
|
+
}, displayLabel) : React__default.createElement(LabelText$1, {
|
|
8389
|
+
"$fontStyle": fontStyle || 'italic',
|
|
8376
8390
|
"$color": color || themeColors.vms.text.medium,
|
|
8377
8391
|
"$size": size
|
|
8378
8392
|
}, labelText), React__default.createElement(Icon, {
|
|
@@ -8417,7 +8431,7 @@ var SelectOption = function SelectOption(_ref37) {
|
|
|
8417
8431
|
onClick: function onClick() {
|
|
8418
8432
|
return handleOptionClick(option.value);
|
|
8419
8433
|
},
|
|
8420
|
-
"$optionSelected": option.value === value
|
|
8434
|
+
"$optionSelected": option.value === value || allowCustomValue && option.value === displayLabel
|
|
8421
8435
|
}, option.label);
|
|
8422
8436
|
}) : !isCustomValue && React__default.createElement(NoOptions, null, NoOptionsText)))));
|
|
8423
8437
|
};
|