labsense-ui-kit 1.4.48 → 1.4.50
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.js +100 -9
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +100 -9
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7455,8 +7455,17 @@ var Icon = function Icon(_ref2) {
|
|
|
7455
7455
|
console.warn("Icon '" + icon + "' not found");
|
|
7456
7456
|
return null;
|
|
7457
7457
|
}
|
|
7458
|
+
var handleKeyDown = onClick ? function (e) {
|
|
7459
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
7460
|
+
e.preventDefault();
|
|
7461
|
+
onClick(e);
|
|
7462
|
+
}
|
|
7463
|
+
} : undefined;
|
|
7458
7464
|
return React__default.createElement(IconWrapper, {
|
|
7459
7465
|
onClick: onClick,
|
|
7466
|
+
onKeyDown: handleKeyDown,
|
|
7467
|
+
role: onClick ? 'button' : undefined,
|
|
7468
|
+
tabIndex: onClick ? 0 : undefined,
|
|
7460
7469
|
"$clickable": !!onClick,
|
|
7461
7470
|
"$cursor": cursor
|
|
7462
7471
|
}, React__default.createElement(IconSVG, {
|
|
@@ -7707,13 +7716,68 @@ var ModalContainer = styled__default.div(_templateObject2$2 || (_templateObject2
|
|
|
7707
7716
|
var $overflowY = _ref3.$overflowY;
|
|
7708
7717
|
return $overflowY ? $overflowY : 'auto';
|
|
7709
7718
|
});
|
|
7719
|
+
var FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
7720
|
+
var openModalContainers = [];
|
|
7721
|
+
var setInert = function setInert(el, inert) {
|
|
7722
|
+
if (inert) el.setAttribute('inert', '');else el.removeAttribute('inert');
|
|
7723
|
+
};
|
|
7710
7724
|
var Modal = function Modal(_ref4) {
|
|
7711
7725
|
var isOpen = _ref4.isOpen,
|
|
7712
7726
|
maxWidth = _ref4.maxWidth,
|
|
7713
7727
|
overflow = _ref4.overflow,
|
|
7714
7728
|
children = _ref4.children;
|
|
7729
|
+
var containerRef = React.useRef(null);
|
|
7730
|
+
var previouslyFocusedElement = React.useRef(null);
|
|
7731
|
+
React.useEffect(function () {
|
|
7732
|
+
if (!isOpen) return;
|
|
7733
|
+
var container = containerRef.current;
|
|
7734
|
+
if (!container) return;
|
|
7735
|
+
previouslyFocusedElement.current = document.activeElement;
|
|
7736
|
+
openModalContainers.forEach(function (el) {
|
|
7737
|
+
return setInert(el, true);
|
|
7738
|
+
});
|
|
7739
|
+
openModalContainers.push(container);
|
|
7740
|
+
var focusableElements = function focusableElements() {
|
|
7741
|
+
return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR));
|
|
7742
|
+
};
|
|
7743
|
+
var firstFocusable = focusableElements()[0];
|
|
7744
|
+
(firstFocusable != null ? firstFocusable : container).focus();
|
|
7745
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
7746
|
+
if (e.key !== 'Tab') return;
|
|
7747
|
+
var focusable = focusableElements();
|
|
7748
|
+
if (focusable.length === 0) {
|
|
7749
|
+
e.preventDefault();
|
|
7750
|
+
return;
|
|
7751
|
+
}
|
|
7752
|
+
var first = focusable[0];
|
|
7753
|
+
var last = focusable[focusable.length - 1];
|
|
7754
|
+
var active = document.activeElement;
|
|
7755
|
+
if (e.shiftKey) {
|
|
7756
|
+
if (active === first || !container.contains(active)) {
|
|
7757
|
+
e.preventDefault();
|
|
7758
|
+
last.focus();
|
|
7759
|
+
}
|
|
7760
|
+
} else if (active === last || !container.contains(active)) {
|
|
7761
|
+
e.preventDefault();
|
|
7762
|
+
first.focus();
|
|
7763
|
+
}
|
|
7764
|
+
};
|
|
7765
|
+
container.addEventListener('keydown', handleKeyDown);
|
|
7766
|
+
return function () {
|
|
7767
|
+
container.removeEventListener('keydown', handleKeyDown);
|
|
7768
|
+
var idx = openModalContainers.indexOf(container);
|
|
7769
|
+
if (idx !== -1) openModalContainers.splice(idx, 1);
|
|
7770
|
+
var newTop = openModalContainers[openModalContainers.length - 1];
|
|
7771
|
+
if (newTop) setInert(newTop, false);
|
|
7772
|
+
if (previouslyFocusedElement.current && document.contains(previouslyFocusedElement.current)) {
|
|
7773
|
+
previouslyFocusedElement.current.focus();
|
|
7774
|
+
}
|
|
7775
|
+
};
|
|
7776
|
+
}, [isOpen]);
|
|
7715
7777
|
if (!isOpen) return null;
|
|
7716
7778
|
return ReactDOM.createPortal(React__default.createElement(ModalOverlay, null, React__default.createElement(ModalContainer, {
|
|
7779
|
+
ref: containerRef,
|
|
7780
|
+
tabIndex: -1,
|
|
7717
7781
|
"$maxWidth": maxWidth,
|
|
7718
7782
|
"$overflowY": overflow,
|
|
7719
7783
|
onClick: function onClick(e) {
|
|
@@ -10486,6 +10550,14 @@ var SelectOption = function SelectOption(_ref38) {
|
|
|
10486
10550
|
};
|
|
10487
10551
|
var dropdownRef = React.useRef(null);
|
|
10488
10552
|
var searchInputRef = React.useRef(null);
|
|
10553
|
+
var dropdownButtonRef = React.useRef(null);
|
|
10554
|
+
var closeAndRestoreFocus = function closeAndRestoreFocus() {
|
|
10555
|
+
var _dropdownButtonRef$cu;
|
|
10556
|
+
setIsOpen(false);
|
|
10557
|
+
setSearchTerm('');
|
|
10558
|
+
setHighlightedIndex(-1);
|
|
10559
|
+
(_dropdownButtonRef$cu = dropdownButtonRef.current) === null || _dropdownButtonRef$cu === void 0 ? void 0 : _dropdownButtonRef$cu.focus();
|
|
10560
|
+
};
|
|
10489
10561
|
var handleOptionClick = function handleOptionClick(selectedValue) {
|
|
10490
10562
|
if (value === selectedValue && allowDeselect) {
|
|
10491
10563
|
var Event = {
|
|
@@ -10504,9 +10576,7 @@ var SelectOption = function SelectOption(_ref38) {
|
|
|
10504
10576
|
};
|
|
10505
10577
|
onChange(_Event);
|
|
10506
10578
|
}
|
|
10507
|
-
|
|
10508
|
-
setSearchTerm('');
|
|
10509
|
-
setHighlightedIndex(-1);
|
|
10579
|
+
closeAndRestoreFocus();
|
|
10510
10580
|
};
|
|
10511
10581
|
var filteredOptions = searchTerm ? options.filter(function (option) {
|
|
10512
10582
|
return option.label.toLowerCase().includes(searchTerm.toLowerCase());
|
|
@@ -10523,8 +10593,7 @@ var SelectOption = function SelectOption(_ref38) {
|
|
|
10523
10593
|
}
|
|
10524
10594
|
};
|
|
10525
10595
|
onChange(Event);
|
|
10526
|
-
|
|
10527
|
-
setSearchTerm('');
|
|
10596
|
+
closeAndRestoreFocus();
|
|
10528
10597
|
};
|
|
10529
10598
|
React.useEffect(function () {
|
|
10530
10599
|
var handleClickOutside = function handleClickOutside(event) {
|
|
@@ -10591,9 +10660,7 @@ var SelectOption = function SelectOption(_ref38) {
|
|
|
10591
10660
|
}
|
|
10592
10661
|
break;
|
|
10593
10662
|
case 'Escape':
|
|
10594
|
-
|
|
10595
|
-
setSearchTerm('');
|
|
10596
|
-
setHighlightedIndex(-1);
|
|
10663
|
+
closeAndRestoreFocus();
|
|
10597
10664
|
break;
|
|
10598
10665
|
}
|
|
10599
10666
|
};
|
|
@@ -10615,9 +10682,22 @@ var SelectOption = function SelectOption(_ref38) {
|
|
|
10615
10682
|
ref: dropdownRef,
|
|
10616
10683
|
"$width": width
|
|
10617
10684
|
}, React__default.createElement(DropdownButton$1, {
|
|
10685
|
+
ref: dropdownButtonRef,
|
|
10618
10686
|
onClick: function onClick() {
|
|
10619
10687
|
if (!disabled && !loading) toggleDropdown();
|
|
10620
10688
|
},
|
|
10689
|
+
onKeyDown: function onKeyDown(e) {
|
|
10690
|
+
if (disabled || loading) return;
|
|
10691
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
10692
|
+
e.preventDefault();
|
|
10693
|
+
toggleDropdown();
|
|
10694
|
+
}
|
|
10695
|
+
},
|
|
10696
|
+
role: 'button',
|
|
10697
|
+
tabIndex: disabled || loading ? -1 : 0,
|
|
10698
|
+
"aria-haspopup": 'listbox',
|
|
10699
|
+
"aria-expanded": isOpen,
|
|
10700
|
+
"aria-disabled": disabled || loading,
|
|
10621
10701
|
"$width": width,
|
|
10622
10702
|
"$border": border,
|
|
10623
10703
|
"$background": background,
|
|
@@ -12447,7 +12527,7 @@ var Overlay = styled__default.div(_templateObject$n || (_templateObject$n = _tag
|
|
|
12447
12527
|
return $isOpen ? 'visible' : 'hidden';
|
|
12448
12528
|
});
|
|
12449
12529
|
var HamburgerButton = styled__default.button(_templateObject2$j || (_templateObject2$j = _taggedTemplateLiteralLoose(["\n display: none;\n \n @media (max-width: ", ") {\n display: flex;\n width: max-content;\n border: none;\n padding: 8px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n // box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n transition: transform 0.2s ease;\n\n &:active {\n transform: scale(0.95);\n }\n }\n"])), MOBILE_BREAKPOINT);
|
|
12450
|
-
var SidebarContainer = styled__default.div(_templateObject3$c || (_templateObject3$c = _taggedTemplateLiteralLoose(["\n width: 68px;\n max-width: 68px;\n height: 100vh;\n background: ", ";\n transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n display: flex;\n flex-direction: column;\n align-items: start;\n padding: 20px;\n position: fixed;\n left: 0;\n top: 0;\n overflow: hidden;\n z-index: 998;\n justify-content: space-between;\n gap: 24px;\n\n /* Expand on hover */\n &:hover {\n width:
|
|
12530
|
+
var SidebarContainer = styled__default.div(_templateObject3$c || (_templateObject3$c = _taggedTemplateLiteralLoose(["\n width: 68px;\n max-width: 68px;\n height: 100vh;\n background: ", ";\n transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n display: flex;\n flex-direction: column;\n align-items: start;\n padding: 20px;\n position: fixed;\n left: 0;\n top: 0;\n overflow: hidden;\n z-index: 998;\n justify-content: space-between;\n gap: 24px;\n\n /* Expand on hover to a fixed width - not max-content, which would resize\n the sidebar itself depending on which submenu happens to be open (a\n longer/deeper-indented child label, e.g. \"API Key Management\" under\n Administration, made the box wider than with it collapsed or another\n menu open). Sized to comfortably fit the longest current label already\n used with room to spare; matches the fixed width already used for the\n mobile-open state below. */\n &:hover {\n width: 230px;\n max-width: 230px;\n\n /* You can also add a class for children */\n span, .expandable {\n opacity: 1;\n visibility: visible;\n transform: translateX(0);\n }\n }\n\n /* Mobile styles */\n @media (max-width: ", ") {\n transform: translateX(", ");\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n width: 280px;\n max-width: 280px;\n box-shadow: ", ";\n\n /* Always show text on mobile when open */\n span, .expandable {\n opacity: ", ";\n visibility: ", ";\n transform: translateX(0);\n }\n\n /* Disable hover expansion on mobile */\n &:hover {\n width: 280px;\n max-width: 280px;\n }\n }\n"])), function (_ref3) {
|
|
12451
12531
|
var $background = _ref3.$background,
|
|
12452
12532
|
theme = _ref3.theme;
|
|
12453
12533
|
return $background || theme.vms.accent.softBlue;
|
|
@@ -13367,6 +13447,17 @@ var Tabs = function Tabs(_ref15) {
|
|
|
13367
13447
|
onClick: function onClick() {
|
|
13368
13448
|
if (!disabled && tab.onClick) tab.onClick();
|
|
13369
13449
|
},
|
|
13450
|
+
onKeyDown: function onKeyDown(e) {
|
|
13451
|
+
if (disabled || !tab.onClick) return;
|
|
13452
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
13453
|
+
e.preventDefault();
|
|
13454
|
+
tab.onClick();
|
|
13455
|
+
}
|
|
13456
|
+
},
|
|
13457
|
+
role: 'tab',
|
|
13458
|
+
tabIndex: disabled ? -1 : 0,
|
|
13459
|
+
"aria-selected": activeTab === tab.title,
|
|
13460
|
+
"aria-disabled": disabled,
|
|
13370
13461
|
"$disabled": disabled,
|
|
13371
13462
|
"$headerHeight": headerHeight
|
|
13372
13463
|
}, React__default.createElement(TabItemContainer, {
|