labsense-ui-kit 1.3.57 → 1.3.58
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/MultiSelectDropdown.d.ts +2 -0
- package/dist/index.js +45 -9
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +45 -9
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -7941,11 +7941,16 @@ var OptionComponent = function OptionComponent(_ref9) {
|
|
|
7941
7941
|
}) : [].concat(selectedOptions, [currentOption]);
|
|
7942
7942
|
onChange === null || onChange === void 0 ? void 0 : onChange(newOption);
|
|
7943
7943
|
};
|
|
7944
|
-
var
|
|
7945
|
-
return a.labelText.localeCompare(b.labelText);
|
|
7946
|
-
}).filter(function (option) {
|
|
7944
|
+
var filteredOptions = options.filter(function (option) {
|
|
7947
7945
|
return option.labelText.toLowerCase().includes(searchQuery.toLowerCase());
|
|
7948
7946
|
});
|
|
7947
|
+
var firstOption = filteredOptions[0],
|
|
7948
|
+
restOptions = filteredOptions.slice(1);
|
|
7949
|
+
var finalOptions = (firstOption === null || firstOption === void 0 ? void 0 : firstOption.value) === '__SELECT_ALL__' ? [firstOption].concat(restOptions.sort(function (a, b) {
|
|
7950
|
+
return a.labelText.localeCompare(b.labelText);
|
|
7951
|
+
})) : filteredOptions.sort(function (a, b) {
|
|
7952
|
+
return a.labelText.localeCompare(b.labelText);
|
|
7953
|
+
});
|
|
7949
7954
|
return React.createElement(Container, {
|
|
7950
7955
|
"$flexDirection": 'column',
|
|
7951
7956
|
"$gap": '8px',
|
|
@@ -7966,18 +7971,22 @@ var OptionComponent = function OptionComponent(_ref9) {
|
|
|
7966
7971
|
onChange: handleSearchChange,
|
|
7967
7972
|
"$inputColor": searchbarTextColor,
|
|
7968
7973
|
"$placeholderColor": placeholderColor
|
|
7969
|
-
})), React.createElement(OptionContainer, null,
|
|
7974
|
+
})), React.createElement(OptionContainer, null, finalOptions.length > 0 ? finalOptions.map(function (option, id) {
|
|
7970
7975
|
return React.createElement(OptionItem, {
|
|
7971
7976
|
key: option.value,
|
|
7972
7977
|
"$optionBorder": optionBorder,
|
|
7973
|
-
"$isborder": id !==
|
|
7978
|
+
"$isborder": id !== finalOptions.length - 1
|
|
7974
7979
|
}, React.createElement(OptionLabel, {
|
|
7975
7980
|
htmlFor: option.value,
|
|
7976
7981
|
"$optionColor": optionColor
|
|
7977
7982
|
}, React.createElement("input", {
|
|
7978
7983
|
id: option.value,
|
|
7979
7984
|
type: 'checkbox',
|
|
7980
|
-
checked:
|
|
7985
|
+
checked: option.value === '__SELECT_ALL__' ? options.filter(function (o) {
|
|
7986
|
+
return o.value !== '__SELECT_ALL__';
|
|
7987
|
+
}).every(function (o) {
|
|
7988
|
+
return selectedOptions.includes(o.value);
|
|
7989
|
+
}) : selectedOptions.includes(option.value),
|
|
7981
7990
|
onChange: function onChange() {
|
|
7982
7991
|
return handleOptionToggle(option.value);
|
|
7983
7992
|
}
|
|
@@ -8248,7 +8257,11 @@ var MultiSelectDropdown = function MultiSelectDropdown(_ref31) {
|
|
|
8248
8257
|
_ref31$searchBox = _ref31.searchBox,
|
|
8249
8258
|
searchBox = _ref31$searchBox === void 0 ? true : _ref31$searchBox,
|
|
8250
8259
|
_ref31$NoOptionsText = _ref31.NoOptionsText,
|
|
8251
|
-
NoOptionsText = _ref31$NoOptionsText === void 0 ? 'No Options Available' : _ref31$NoOptionsText
|
|
8260
|
+
NoOptionsText = _ref31$NoOptionsText === void 0 ? 'No Options Available' : _ref31$NoOptionsText,
|
|
8261
|
+
_ref31$selectAllOptio = _ref31.selectAllOption,
|
|
8262
|
+
selectAllOption = _ref31$selectAllOptio === void 0 ? false : _ref31$selectAllOptio,
|
|
8263
|
+
_ref31$selectAllLabel = _ref31.selectAllLabel,
|
|
8264
|
+
selectAllLabel = _ref31$selectAllLabel === void 0 ? 'Select All' : _ref31$selectAllLabel;
|
|
8252
8265
|
var themeColors = useTheme();
|
|
8253
8266
|
var _useState = useState(false),
|
|
8254
8267
|
dropUp = _useState[0],
|
|
@@ -8299,6 +8312,29 @@ var MultiSelectDropdown = function MultiSelectDropdown(_ref31) {
|
|
|
8299
8312
|
}));
|
|
8300
8313
|
}
|
|
8301
8314
|
};
|
|
8315
|
+
var SELECT_ALL_VALUE = '__SELECT_ALL__';
|
|
8316
|
+
var computedOptions = React.useMemo(function () {
|
|
8317
|
+
if (!selectAllOption) return options;
|
|
8318
|
+
return [{
|
|
8319
|
+
value: SELECT_ALL_VALUE,
|
|
8320
|
+
labelText: selectAllLabel
|
|
8321
|
+
}].concat(options);
|
|
8322
|
+
}, [options, selectAllOption, selectAllLabel]);
|
|
8323
|
+
var allOptionValues = options.map(function (opt) {
|
|
8324
|
+
return opt.value;
|
|
8325
|
+
});
|
|
8326
|
+
var handleOptionChange = function handleOptionChange(values) {
|
|
8327
|
+
if (values.includes(SELECT_ALL_VALUE)) {
|
|
8328
|
+
var isAllSelected = allOptionValues.every(function (v) {
|
|
8329
|
+
return selectedOptions.includes(v);
|
|
8330
|
+
});
|
|
8331
|
+
handleSelectChange(isAllSelected ? [] : allOptionValues);
|
|
8332
|
+
return;
|
|
8333
|
+
}
|
|
8334
|
+
handleSelectChange(values.filter(function (v) {
|
|
8335
|
+
return v !== SELECT_ALL_VALUE;
|
|
8336
|
+
}));
|
|
8337
|
+
};
|
|
8302
8338
|
return React.createElement(Container$2, null, title && React.createElement(TitleText, {
|
|
8303
8339
|
"$titleColor": titleColor || themeColors.vms.text.dark,
|
|
8304
8340
|
"$titleSize": titleSize,
|
|
@@ -8364,9 +8400,9 @@ var MultiSelectDropdown = function MultiSelectDropdown(_ref31) {
|
|
|
8364
8400
|
bottom: dropUp ? 'calc(100% + 8px)' : 'auto'
|
|
8365
8401
|
}
|
|
8366
8402
|
}, React.createElement(OptionComponent, {
|
|
8367
|
-
options:
|
|
8403
|
+
options: computedOptions,
|
|
8368
8404
|
selectedOptions: selectedOptions,
|
|
8369
|
-
onChange:
|
|
8405
|
+
onChange: handleOptionChange,
|
|
8370
8406
|
placeholder: placeholder,
|
|
8371
8407
|
placeholderColor: placeholderColor,
|
|
8372
8408
|
optionBorder: optionBorder,
|