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.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,
|
|
@@ -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, {
|