labsense-ui-kit 1.4.49 → 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 +99 -8
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +99 -8
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -7450,8 +7450,17 @@ var Icon = function Icon(_ref2) {
|
|
|
7450
7450
|
console.warn("Icon '" + icon + "' not found");
|
|
7451
7451
|
return null;
|
|
7452
7452
|
}
|
|
7453
|
+
var handleKeyDown = onClick ? function (e) {
|
|
7454
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
7455
|
+
e.preventDefault();
|
|
7456
|
+
onClick(e);
|
|
7457
|
+
}
|
|
7458
|
+
} : undefined;
|
|
7453
7459
|
return React.createElement(IconWrapper, {
|
|
7454
7460
|
onClick: onClick,
|
|
7461
|
+
onKeyDown: handleKeyDown,
|
|
7462
|
+
role: onClick ? 'button' : undefined,
|
|
7463
|
+
tabIndex: onClick ? 0 : undefined,
|
|
7455
7464
|
"$clickable": !!onClick,
|
|
7456
7465
|
"$cursor": cursor
|
|
7457
7466
|
}, React.createElement(IconSVG, {
|
|
@@ -7702,13 +7711,68 @@ var ModalContainer = styled.div(_templateObject2$2 || (_templateObject2$2 = _tag
|
|
|
7702
7711
|
var $overflowY = _ref3.$overflowY;
|
|
7703
7712
|
return $overflowY ? $overflowY : 'auto';
|
|
7704
7713
|
});
|
|
7714
|
+
var FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
7715
|
+
var openModalContainers = [];
|
|
7716
|
+
var setInert = function setInert(el, inert) {
|
|
7717
|
+
if (inert) el.setAttribute('inert', '');else el.removeAttribute('inert');
|
|
7718
|
+
};
|
|
7705
7719
|
var Modal = function Modal(_ref4) {
|
|
7706
7720
|
var isOpen = _ref4.isOpen,
|
|
7707
7721
|
maxWidth = _ref4.maxWidth,
|
|
7708
7722
|
overflow = _ref4.overflow,
|
|
7709
7723
|
children = _ref4.children;
|
|
7724
|
+
var containerRef = useRef(null);
|
|
7725
|
+
var previouslyFocusedElement = useRef(null);
|
|
7726
|
+
useEffect(function () {
|
|
7727
|
+
if (!isOpen) return;
|
|
7728
|
+
var container = containerRef.current;
|
|
7729
|
+
if (!container) return;
|
|
7730
|
+
previouslyFocusedElement.current = document.activeElement;
|
|
7731
|
+
openModalContainers.forEach(function (el) {
|
|
7732
|
+
return setInert(el, true);
|
|
7733
|
+
});
|
|
7734
|
+
openModalContainers.push(container);
|
|
7735
|
+
var focusableElements = function focusableElements() {
|
|
7736
|
+
return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR));
|
|
7737
|
+
};
|
|
7738
|
+
var firstFocusable = focusableElements()[0];
|
|
7739
|
+
(firstFocusable != null ? firstFocusable : container).focus();
|
|
7740
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
7741
|
+
if (e.key !== 'Tab') return;
|
|
7742
|
+
var focusable = focusableElements();
|
|
7743
|
+
if (focusable.length === 0) {
|
|
7744
|
+
e.preventDefault();
|
|
7745
|
+
return;
|
|
7746
|
+
}
|
|
7747
|
+
var first = focusable[0];
|
|
7748
|
+
var last = focusable[focusable.length - 1];
|
|
7749
|
+
var active = document.activeElement;
|
|
7750
|
+
if (e.shiftKey) {
|
|
7751
|
+
if (active === first || !container.contains(active)) {
|
|
7752
|
+
e.preventDefault();
|
|
7753
|
+
last.focus();
|
|
7754
|
+
}
|
|
7755
|
+
} else if (active === last || !container.contains(active)) {
|
|
7756
|
+
e.preventDefault();
|
|
7757
|
+
first.focus();
|
|
7758
|
+
}
|
|
7759
|
+
};
|
|
7760
|
+
container.addEventListener('keydown', handleKeyDown);
|
|
7761
|
+
return function () {
|
|
7762
|
+
container.removeEventListener('keydown', handleKeyDown);
|
|
7763
|
+
var idx = openModalContainers.indexOf(container);
|
|
7764
|
+
if (idx !== -1) openModalContainers.splice(idx, 1);
|
|
7765
|
+
var newTop = openModalContainers[openModalContainers.length - 1];
|
|
7766
|
+
if (newTop) setInert(newTop, false);
|
|
7767
|
+
if (previouslyFocusedElement.current && document.contains(previouslyFocusedElement.current)) {
|
|
7768
|
+
previouslyFocusedElement.current.focus();
|
|
7769
|
+
}
|
|
7770
|
+
};
|
|
7771
|
+
}, [isOpen]);
|
|
7710
7772
|
if (!isOpen) return null;
|
|
7711
7773
|
return createPortal(React.createElement(ModalOverlay, null, React.createElement(ModalContainer, {
|
|
7774
|
+
ref: containerRef,
|
|
7775
|
+
tabIndex: -1,
|
|
7712
7776
|
"$maxWidth": maxWidth,
|
|
7713
7777
|
"$overflowY": overflow,
|
|
7714
7778
|
onClick: function onClick(e) {
|
|
@@ -10481,6 +10545,14 @@ var SelectOption = function SelectOption(_ref38) {
|
|
|
10481
10545
|
};
|
|
10482
10546
|
var dropdownRef = useRef(null);
|
|
10483
10547
|
var searchInputRef = useRef(null);
|
|
10548
|
+
var dropdownButtonRef = useRef(null);
|
|
10549
|
+
var closeAndRestoreFocus = function closeAndRestoreFocus() {
|
|
10550
|
+
var _dropdownButtonRef$cu;
|
|
10551
|
+
setIsOpen(false);
|
|
10552
|
+
setSearchTerm('');
|
|
10553
|
+
setHighlightedIndex(-1);
|
|
10554
|
+
(_dropdownButtonRef$cu = dropdownButtonRef.current) === null || _dropdownButtonRef$cu === void 0 ? void 0 : _dropdownButtonRef$cu.focus();
|
|
10555
|
+
};
|
|
10484
10556
|
var handleOptionClick = function handleOptionClick(selectedValue) {
|
|
10485
10557
|
if (value === selectedValue && allowDeselect) {
|
|
10486
10558
|
var Event = {
|
|
@@ -10499,9 +10571,7 @@ var SelectOption = function SelectOption(_ref38) {
|
|
|
10499
10571
|
};
|
|
10500
10572
|
onChange(_Event);
|
|
10501
10573
|
}
|
|
10502
|
-
|
|
10503
|
-
setSearchTerm('');
|
|
10504
|
-
setHighlightedIndex(-1);
|
|
10574
|
+
closeAndRestoreFocus();
|
|
10505
10575
|
};
|
|
10506
10576
|
var filteredOptions = searchTerm ? options.filter(function (option) {
|
|
10507
10577
|
return option.label.toLowerCase().includes(searchTerm.toLowerCase());
|
|
@@ -10518,8 +10588,7 @@ var SelectOption = function SelectOption(_ref38) {
|
|
|
10518
10588
|
}
|
|
10519
10589
|
};
|
|
10520
10590
|
onChange(Event);
|
|
10521
|
-
|
|
10522
|
-
setSearchTerm('');
|
|
10591
|
+
closeAndRestoreFocus();
|
|
10523
10592
|
};
|
|
10524
10593
|
useEffect(function () {
|
|
10525
10594
|
var handleClickOutside = function handleClickOutside(event) {
|
|
@@ -10586,9 +10655,7 @@ var SelectOption = function SelectOption(_ref38) {
|
|
|
10586
10655
|
}
|
|
10587
10656
|
break;
|
|
10588
10657
|
case 'Escape':
|
|
10589
|
-
|
|
10590
|
-
setSearchTerm('');
|
|
10591
|
-
setHighlightedIndex(-1);
|
|
10658
|
+
closeAndRestoreFocus();
|
|
10592
10659
|
break;
|
|
10593
10660
|
}
|
|
10594
10661
|
};
|
|
@@ -10610,9 +10677,22 @@ var SelectOption = function SelectOption(_ref38) {
|
|
|
10610
10677
|
ref: dropdownRef,
|
|
10611
10678
|
"$width": width
|
|
10612
10679
|
}, React.createElement(DropdownButton$1, {
|
|
10680
|
+
ref: dropdownButtonRef,
|
|
10613
10681
|
onClick: function onClick() {
|
|
10614
10682
|
if (!disabled && !loading) toggleDropdown();
|
|
10615
10683
|
},
|
|
10684
|
+
onKeyDown: function onKeyDown(e) {
|
|
10685
|
+
if (disabled || loading) return;
|
|
10686
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
10687
|
+
e.preventDefault();
|
|
10688
|
+
toggleDropdown();
|
|
10689
|
+
}
|
|
10690
|
+
},
|
|
10691
|
+
role: 'button',
|
|
10692
|
+
tabIndex: disabled || loading ? -1 : 0,
|
|
10693
|
+
"aria-haspopup": 'listbox',
|
|
10694
|
+
"aria-expanded": isOpen,
|
|
10695
|
+
"aria-disabled": disabled || loading,
|
|
10616
10696
|
"$width": width,
|
|
10617
10697
|
"$border": border,
|
|
10618
10698
|
"$background": background,
|
|
@@ -13362,6 +13442,17 @@ var Tabs = function Tabs(_ref15) {
|
|
|
13362
13442
|
onClick: function onClick() {
|
|
13363
13443
|
if (!disabled && tab.onClick) tab.onClick();
|
|
13364
13444
|
},
|
|
13445
|
+
onKeyDown: function onKeyDown(e) {
|
|
13446
|
+
if (disabled || !tab.onClick) return;
|
|
13447
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
13448
|
+
e.preventDefault();
|
|
13449
|
+
tab.onClick();
|
|
13450
|
+
}
|
|
13451
|
+
},
|
|
13452
|
+
role: 'tab',
|
|
13453
|
+
tabIndex: disabled ? -1 : 0,
|
|
13454
|
+
"aria-selected": activeTab === tab.title,
|
|
13455
|
+
"aria-disabled": disabled,
|
|
13365
13456
|
"$disabled": disabled,
|
|
13366
13457
|
"$headerHeight": headerHeight
|
|
13367
13458
|
}, React.createElement(TabItemContainer, {
|