labsense-ui-kit 1.4.2 → 1.4.3
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 +1 -0
- package/dist/index.js +116 -74
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +116 -74
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
|
@@ -58,6 +58,7 @@ interface MultiSelectDropdownProps {
|
|
|
58
58
|
NoOptionsText?: string;
|
|
59
59
|
selectAllOption?: boolean;
|
|
60
60
|
selectAllLabel?: string;
|
|
61
|
+
dropdownPosition?: 'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight';
|
|
61
62
|
}
|
|
62
63
|
declare const MultiSelectDropdown: React.FC<MultiSelectDropdownProps>;
|
|
63
64
|
export default MultiSelectDropdown;
|
package/dist/index.js
CHANGED
|
@@ -8562,7 +8562,7 @@ var LabelText = styled__default.div(_templateObject5$4 || (_templateObject5$4 =
|
|
|
8562
8562
|
theme = _ref21.theme;
|
|
8563
8563
|
return $labelColor || theme.vms.text.medium;
|
|
8564
8564
|
});
|
|
8565
|
-
var DropdownMenu = styled__default.div(_templateObject6$4 || (_templateObject6$4 = _taggedTemplateLiteralLoose(["\n max-height: 156px;\n padding: 4px;\n box-sizing: border-box;\n border: ", ";\n border-radius: ", ";\n width: ", ";\n background: ", ";\n display: flex;\n flex-direction: column;\n gap: 4px;\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n margin-top: 8px;\n overflow-y: auto;\n position: absolute;\n z-index: 2;\n scrollbar-width: thin;\n"])), function (_ref22) {
|
|
8565
|
+
var DropdownMenu = styled__default.div(_templateObject6$4 || (_templateObject6$4 = _taggedTemplateLiteralLoose(["\n max-height: 156px;\n padding: 4px;\n box-sizing: border-box;\n border: ", ";\n border-radius: ", ";\n width: ", ";\n background: ", ";\n display: flex;\n flex-direction: column;\n gap: 4px;\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n margin-top: 8px;\n overflow-y: auto;\n position: absolute;\n z-index: 2;\n scrollbar-width: thin;\n \n ", "\n"])), function (_ref22) {
|
|
8566
8566
|
var theme = _ref22.theme;
|
|
8567
8567
|
return "1px solid " + theme.vms.border.light;
|
|
8568
8568
|
}, function (_ref23) {
|
|
@@ -8575,12 +8575,30 @@ var DropdownMenu = styled__default.div(_templateObject6$4 || (_templateObject6$4
|
|
|
8575
8575
|
var $menuBackground = _ref25.$menuBackground,
|
|
8576
8576
|
theme = _ref25.theme;
|
|
8577
8577
|
return $menuBackground || theme.vms.accent.light_2;
|
|
8578
|
+
}, function (_ref26) {
|
|
8579
|
+
var $position = _ref26.$position;
|
|
8580
|
+
switch ($position) {
|
|
8581
|
+
case 'topLeft':
|
|
8582
|
+
return "\n bottom: calc(100% + 8px);\n left: 0;\n top: auto;\n ";
|
|
8583
|
+
case 'topCenter':
|
|
8584
|
+
return "\n bottom: calc(100% + 8px);\n left: 50%;\n transform: translateX(-50%);\n top: auto;\n ";
|
|
8585
|
+
case 'topRight':
|
|
8586
|
+
return "\n bottom: calc(100% + 8px);\n right: 0;\n top: auto;\n ";
|
|
8587
|
+
case 'bottomLeft':
|
|
8588
|
+
return "\n top: calc(100% + 8px);\n left: 0;\n bottom: auto;\n ";
|
|
8589
|
+
case 'bottomCenter':
|
|
8590
|
+
return "\n top: calc(100% + 8px);\n left: 50%;\n transform: translateX(-50%);\n bottom: auto;\n ";
|
|
8591
|
+
case 'bottomRight':
|
|
8592
|
+
return "\n top: calc(100% + 8px);\n right: 0;\n bottom: auto;\n ";
|
|
8593
|
+
default:
|
|
8594
|
+
return '';
|
|
8595
|
+
}
|
|
8578
8596
|
});
|
|
8579
8597
|
var SelectedOptionsWrapper = styled__default.div(_templateObject7$2 || (_templateObject7$2 = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n height: 100%;\n"])));
|
|
8580
|
-
var SelectedOptionDiv = styled__default.div(_templateObject8$2 || (_templateObject8$2 = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n background: ", ";\n border-radius: 4px;\n padding: 6px 8px;\n box-sizing: border-box;\n gap: 6px;\n font-style: normal;\n font-weight: 400;\n font-size: 12px;\n line-height: 12px;\n color: ", ";\n"])), function (
|
|
8581
|
-
var $selectedOptionBackground =
|
|
8582
|
-
$disabled =
|
|
8583
|
-
theme =
|
|
8598
|
+
var SelectedOptionDiv = styled__default.div(_templateObject8$2 || (_templateObject8$2 = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n background: ", ";\n border-radius: 4px;\n padding: 6px 8px;\n box-sizing: border-box;\n gap: 6px;\n font-style: normal;\n font-weight: 400;\n font-size: 12px;\n line-height: 12px;\n color: ", ";\n"])), function (_ref27) {
|
|
8599
|
+
var $selectedOptionBackground = _ref27.$selectedOptionBackground,
|
|
8600
|
+
$disabled = _ref27.$disabled,
|
|
8601
|
+
theme = _ref27.theme;
|
|
8584
8602
|
switch ($selectedOptionBackground) {
|
|
8585
8603
|
case 'dark':
|
|
8586
8604
|
return theme.vms.text.dark;
|
|
@@ -8601,9 +8619,9 @@ var SelectedOptionDiv = styled__default.div(_templateObject8$2 || (_templateObje
|
|
|
8601
8619
|
default:
|
|
8602
8620
|
return $selectedOptionBackground || theme.vms.accent.light_2;
|
|
8603
8621
|
}
|
|
8604
|
-
}, function (
|
|
8605
|
-
var $selectedOptionColor =
|
|
8606
|
-
theme =
|
|
8622
|
+
}, function (_ref28) {
|
|
8623
|
+
var $selectedOptionColor = _ref28.$selectedOptionColor,
|
|
8624
|
+
theme = _ref28.theme;
|
|
8607
8625
|
switch ($selectedOptionColor) {
|
|
8608
8626
|
case 'dark':
|
|
8609
8627
|
return theme.vms.text.dark;
|
|
@@ -8625,88 +8643,94 @@ var SelectedOptionDiv = styled__default.div(_templateObject8$2 || (_templateObje
|
|
|
8625
8643
|
return $selectedOptionColor;
|
|
8626
8644
|
}
|
|
8627
8645
|
});
|
|
8628
|
-
var RemoveIcon = styled__default.div(_templateObject9$2 || (_templateObject9$2 = _taggedTemplateLiteralLoose(["\n width: 14px;\n height: 14px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: ", ";\n border-radius: 50%;\n box-sizing: border-box;\n background: ", ";\n > div {\n cursor: ", ";\n }\n"])), function (
|
|
8629
|
-
var $disabled =
|
|
8646
|
+
var RemoveIcon = styled__default.div(_templateObject9$2 || (_templateObject9$2 = _taggedTemplateLiteralLoose(["\n width: 14px;\n height: 14px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: ", ";\n border-radius: 50%;\n box-sizing: border-box;\n background: ", ";\n > div {\n cursor: ", ";\n }\n"])), function (_ref29) {
|
|
8647
|
+
var $disabled = _ref29.$disabled;
|
|
8630
8648
|
return $disabled ? 'not-allowed' : 'pointer';
|
|
8631
|
-
}, function (_ref29) {
|
|
8632
|
-
var removeIconBackground = _ref29.removeIconBackground,
|
|
8633
|
-
$type = _ref29.$type,
|
|
8634
|
-
theme = _ref29.theme;
|
|
8635
|
-
return removeIconBackground ? removeIconBackground : $type === 'remove' ? '#5E5E5E24' : theme.vms.disabled.primary;
|
|
8636
8649
|
}, function (_ref30) {
|
|
8637
|
-
var
|
|
8650
|
+
var removeIconBackground = _ref30.removeIconBackground,
|
|
8651
|
+
$type = _ref30.$type,
|
|
8652
|
+
theme = _ref30.theme;
|
|
8653
|
+
return removeIconBackground ? removeIconBackground : $type === 'remove' ? '#5E5E5E24' : theme.vms.disabled.primary;
|
|
8654
|
+
}, function (_ref31) {
|
|
8655
|
+
var $disabled = _ref31.$disabled;
|
|
8638
8656
|
return $disabled ? 'not-allowed' : 'pointer';
|
|
8639
8657
|
});
|
|
8640
8658
|
var TextWrapper = styled__default.div(_templateObject10$2 || (_templateObject10$2 = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n gap: 4px;\n"])));
|
|
8641
|
-
var Asterisk = styled__default.span(_templateObject11$2 || (_templateObject11$2 = _taggedTemplateLiteralLoose(["\n color: ", ";\n font-size: 10px;\n height: fit-content;\n position: absolute;\n top: -2px;\n right: -8px;\n"])), function (
|
|
8642
|
-
var theme =
|
|
8659
|
+
var Asterisk = styled__default.span(_templateObject11$2 || (_templateObject11$2 = _taggedTemplateLiteralLoose(["\n color: ", ";\n font-size: 10px;\n height: fit-content;\n position: absolute;\n top: -2px;\n right: -8px;\n"])), function (_ref32) {
|
|
8660
|
+
var theme = _ref32.theme;
|
|
8643
8661
|
return theme.vms["default"].error;
|
|
8644
8662
|
});
|
|
8645
|
-
var MultiSelectDropdown = function MultiSelectDropdown(
|
|
8646
|
-
var title =
|
|
8647
|
-
titleWeight =
|
|
8648
|
-
titleSize =
|
|
8649
|
-
titleColor =
|
|
8650
|
-
|
|
8651
|
-
labelText =
|
|
8652
|
-
labelStyle =
|
|
8653
|
-
labelColor =
|
|
8654
|
-
|
|
8655
|
-
replaceLabel =
|
|
8656
|
-
options =
|
|
8657
|
-
width =
|
|
8658
|
-
optionWidth =
|
|
8659
|
-
height =
|
|
8660
|
-
placeholder =
|
|
8661
|
-
border =
|
|
8662
|
-
background =
|
|
8663
|
-
selectedOptionBackground =
|
|
8664
|
-
selectedOptionColor =
|
|
8665
|
-
menuBackground =
|
|
8666
|
-
optionsBorderRadius =
|
|
8667
|
-
borderRadius =
|
|
8668
|
-
removeIconBackground =
|
|
8669
|
-
handleSelectChange =
|
|
8670
|
-
selectedOptions =
|
|
8671
|
-
placeholderColor =
|
|
8672
|
-
optionBorder =
|
|
8673
|
-
optionColor =
|
|
8674
|
-
searchIcon =
|
|
8675
|
-
searchbarTextColor =
|
|
8676
|
-
searchBoxBackground =
|
|
8677
|
-
searchBoxBorder =
|
|
8678
|
-
searchBoxBorderRadius =
|
|
8679
|
-
size =
|
|
8680
|
-
removeIcon =
|
|
8681
|
-
type =
|
|
8682
|
-
icon =
|
|
8683
|
-
|
|
8684
|
-
disabled =
|
|
8685
|
-
|
|
8686
|
-
required =
|
|
8687
|
-
|
|
8688
|
-
searchBox =
|
|
8689
|
-
|
|
8690
|
-
NoOptionsText =
|
|
8691
|
-
|
|
8692
|
-
selectAllOption =
|
|
8693
|
-
|
|
8694
|
-
selectAllLabel =
|
|
8663
|
+
var MultiSelectDropdown = function MultiSelectDropdown(_ref33) {
|
|
8664
|
+
var title = _ref33.title,
|
|
8665
|
+
titleWeight = _ref33.titleWeight,
|
|
8666
|
+
titleSize = _ref33.titleSize,
|
|
8667
|
+
titleColor = _ref33.titleColor,
|
|
8668
|
+
_ref33$labelText = _ref33.labelText,
|
|
8669
|
+
labelText = _ref33$labelText === void 0 ? 'Select Cameras' : _ref33$labelText,
|
|
8670
|
+
labelStyle = _ref33.labelStyle,
|
|
8671
|
+
labelColor = _ref33.labelColor,
|
|
8672
|
+
_ref33$replaceLabel = _ref33.replaceLabel,
|
|
8673
|
+
replaceLabel = _ref33$replaceLabel === void 0 ? true : _ref33$replaceLabel,
|
|
8674
|
+
options = _ref33.options,
|
|
8675
|
+
width = _ref33.width,
|
|
8676
|
+
optionWidth = _ref33.optionWidth,
|
|
8677
|
+
height = _ref33.height,
|
|
8678
|
+
placeholder = _ref33.placeholder,
|
|
8679
|
+
border = _ref33.border,
|
|
8680
|
+
background = _ref33.background,
|
|
8681
|
+
selectedOptionBackground = _ref33.selectedOptionBackground,
|
|
8682
|
+
selectedOptionColor = _ref33.selectedOptionColor,
|
|
8683
|
+
menuBackground = _ref33.menuBackground,
|
|
8684
|
+
optionsBorderRadius = _ref33.optionsBorderRadius,
|
|
8685
|
+
borderRadius = _ref33.borderRadius,
|
|
8686
|
+
removeIconBackground = _ref33.removeIconBackground,
|
|
8687
|
+
handleSelectChange = _ref33.handleSelectChange,
|
|
8688
|
+
selectedOptions = _ref33.selectedOptions,
|
|
8689
|
+
placeholderColor = _ref33.placeholderColor,
|
|
8690
|
+
optionBorder = _ref33.optionBorder,
|
|
8691
|
+
optionColor = _ref33.optionColor,
|
|
8692
|
+
searchIcon = _ref33.searchIcon,
|
|
8693
|
+
searchbarTextColor = _ref33.searchbarTextColor,
|
|
8694
|
+
searchBoxBackground = _ref33.searchBoxBackground,
|
|
8695
|
+
searchBoxBorder = _ref33.searchBoxBorder,
|
|
8696
|
+
searchBoxBorderRadius = _ref33.searchBoxBorderRadius,
|
|
8697
|
+
size = _ref33.size,
|
|
8698
|
+
removeIcon = _ref33.removeIcon,
|
|
8699
|
+
type = _ref33.type,
|
|
8700
|
+
icon = _ref33.icon,
|
|
8701
|
+
_ref33$disabled = _ref33.disabled,
|
|
8702
|
+
disabled = _ref33$disabled === void 0 ? false : _ref33$disabled,
|
|
8703
|
+
_ref33$required = _ref33.required,
|
|
8704
|
+
required = _ref33$required === void 0 ? false : _ref33$required,
|
|
8705
|
+
_ref33$searchBox = _ref33.searchBox,
|
|
8706
|
+
searchBox = _ref33$searchBox === void 0 ? true : _ref33$searchBox,
|
|
8707
|
+
_ref33$NoOptionsText = _ref33.NoOptionsText,
|
|
8708
|
+
NoOptionsText = _ref33$NoOptionsText === void 0 ? 'No Options Available' : _ref33$NoOptionsText,
|
|
8709
|
+
_ref33$selectAllOptio = _ref33.selectAllOption,
|
|
8710
|
+
selectAllOption = _ref33$selectAllOptio === void 0 ? false : _ref33$selectAllOptio,
|
|
8711
|
+
_ref33$selectAllLabel = _ref33.selectAllLabel,
|
|
8712
|
+
selectAllLabel = _ref33$selectAllLabel === void 0 ? 'Select All' : _ref33$selectAllLabel,
|
|
8713
|
+
dropdownPosition = _ref33.dropdownPosition;
|
|
8695
8714
|
var themeColors = useTheme();
|
|
8696
8715
|
var _useState = React.useState(false),
|
|
8697
8716
|
dropUp = _useState[0],
|
|
8698
8717
|
setDropUp = _useState[1];
|
|
8699
|
-
var _useState2 = React.useState(
|
|
8700
|
-
|
|
8701
|
-
|
|
8718
|
+
var _useState2 = React.useState('left'),
|
|
8719
|
+
horizontalAlign = _useState2[0],
|
|
8720
|
+
setHorizontalAlign = _useState2[1];
|
|
8721
|
+
var _useState3 = React.useState(false),
|
|
8722
|
+
isOpen = _useState3[0],
|
|
8723
|
+
setIsOpen = _useState3[1];
|
|
8702
8724
|
var dropdownRef = React.useRef(null);
|
|
8703
8725
|
var dropdownButtonRef = React.useRef(null);
|
|
8726
|
+
var dropdownMenuRef = React.useRef(null);
|
|
8704
8727
|
var toggleDropdown = function toggleDropdown() {
|
|
8705
8728
|
if (disabled) return;
|
|
8706
8729
|
var refToUse = dropdownRef.current;
|
|
8707
|
-
if (refToUse) {
|
|
8730
|
+
if (refToUse && !dropdownPosition) {
|
|
8708
8731
|
var rect = refToUse.getBoundingClientRect();
|
|
8709
8732
|
var windowHeight = window.innerHeight;
|
|
8733
|
+
var windowWidth = window.innerWidth;
|
|
8710
8734
|
var spaceBelow = windowHeight - rect.bottom;
|
|
8711
8735
|
var spaceAbove = rect.top;
|
|
8712
8736
|
var dropdownHeight = 156;
|
|
@@ -8715,6 +8739,19 @@ var MultiSelectDropdown = function MultiSelectDropdown(_ref32) {
|
|
|
8715
8739
|
} else {
|
|
8716
8740
|
setDropUp(false);
|
|
8717
8741
|
}
|
|
8742
|
+
var estimatedDropdownWidth = optionWidth ? parseInt(optionWidth) : 200;
|
|
8743
|
+
var spaceRight = windowWidth - rect.left;
|
|
8744
|
+
var spaceLeft = rect.right;
|
|
8745
|
+
var buttonWidth = rect.width;
|
|
8746
|
+
if (spaceRight >= estimatedDropdownWidth) {
|
|
8747
|
+
setHorizontalAlign('left');
|
|
8748
|
+
} else if (spaceLeft >= estimatedDropdownWidth) {
|
|
8749
|
+
setHorizontalAlign('right');
|
|
8750
|
+
} else if (rect.left + buttonWidth / 2 >= estimatedDropdownWidth / 2 && windowWidth - (rect.left + buttonWidth / 2) >= estimatedDropdownWidth / 2) {
|
|
8751
|
+
setHorizontalAlign('center');
|
|
8752
|
+
} else {
|
|
8753
|
+
setHorizontalAlign('left');
|
|
8754
|
+
}
|
|
8718
8755
|
}
|
|
8719
8756
|
setIsOpen(function (prev) {
|
|
8720
8757
|
return !prev;
|
|
@@ -8854,12 +8891,17 @@ var MultiSelectDropdown = function MultiSelectDropdown(_ref32) {
|
|
|
8854
8891
|
weight: '2px',
|
|
8855
8892
|
color: themeColors.vms.text.medium
|
|
8856
8893
|
})), isOpen && React__default.createElement(DropdownMenu, {
|
|
8894
|
+
ref: dropdownMenuRef,
|
|
8857
8895
|
"$width": optionWidth,
|
|
8858
8896
|
"$menuBackground": menuBackground || themeColors.vms.text.white,
|
|
8859
8897
|
"$optionsBorderRadius": optionsBorderRadius,
|
|
8860
|
-
|
|
8898
|
+
"$position": dropdownPosition,
|
|
8899
|
+
style: dropdownPosition ? undefined : {
|
|
8861
8900
|
top: dropUp ? 'auto' : 'calc(100% + 8px)',
|
|
8862
|
-
bottom: dropUp ? 'calc(100% + 8px)' : 'auto'
|
|
8901
|
+
bottom: dropUp ? 'calc(100% + 8px)' : 'auto',
|
|
8902
|
+
left: horizontalAlign === 'left' ? '0' : horizontalAlign === 'center' ? '50%' : 'auto',
|
|
8903
|
+
right: horizontalAlign === 'right' ? '0' : 'auto',
|
|
8904
|
+
transform: horizontalAlign === 'center' ? 'translateX(-50%)' : 'none'
|
|
8863
8905
|
}
|
|
8864
8906
|
}, React__default.createElement(OptionComponent, {
|
|
8865
8907
|
options: computedOptions,
|