labsense-ui-kit 1.4.49 → 1.4.51
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/Table/index.d.ts +3 -0
- package/dist/index.js +116 -10
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +116 -10
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/Table/index.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ interface HeaderCellConfig {
|
|
|
10
10
|
alignment?: string;
|
|
11
11
|
CustomFunction?: React.ReactElement;
|
|
12
12
|
groupTitle?: string;
|
|
13
|
+
sortable?: boolean;
|
|
14
|
+
sortDirection?: 'asc' | 'desc';
|
|
15
|
+
onSortClick?: () => void;
|
|
13
16
|
}
|
|
14
17
|
interface HeaderConfig {
|
|
15
18
|
headercolor?: string;
|
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,
|
|
@@ -13181,7 +13261,7 @@ var Table = function Table(_ref9) {
|
|
|
13181
13261
|
onChange: toggleSelectAll,
|
|
13182
13262
|
"$borderSize": 2
|
|
13183
13263
|
})), tableheaderconfig.headerdata.map(function (columndata, index, allCols) {
|
|
13184
|
-
var _allCols, _columndata$maintext;
|
|
13264
|
+
var _allCols, _columndata$maintext, _columndata$maintext2;
|
|
13185
13265
|
var currentGroupTitle = columndata.groupTitle || '';
|
|
13186
13266
|
var prevGroupTitle = index > 0 ? allCols[index - 1].groupTitle || '' : '';
|
|
13187
13267
|
var isFirstOfGroup = currentGroupTitle && currentGroupTitle !== prevGroupTitle;
|
|
@@ -13209,8 +13289,23 @@ var Table = function Table(_ref9) {
|
|
|
13209
13289
|
"$lineHeight": 'normal'
|
|
13210
13290
|
}, currentGroupTitle), React__default.createElement(LegendDivider, null)) : React__default.createElement(LegendDivider, {
|
|
13211
13291
|
"$marginRight": currentGroupTitle !== (((_allCols = allCols[index + 1]) === null || _allCols === void 0 ? void 0 : _allCols.groupTitle) || '') ? '8px' : '0px'
|
|
13212
|
-
})) : null), React__default.createElement(
|
|
13292
|
+
})) : null), columndata.sortable ? React__default.createElement(Container, {
|
|
13293
|
+
"$width": '100%',
|
|
13294
|
+
"$alignItems": 'center',
|
|
13295
|
+
"$gap": '6px',
|
|
13296
|
+
"$cursor": 'pointer',
|
|
13297
|
+
"$justifyContent": columndata.alignment === 'end' ? 'flex-end' : columndata.alignment === 'center' ? 'center' : 'flex-start',
|
|
13298
|
+
onClick: columndata.onSortClick
|
|
13299
|
+
}, React__default.createElement(TableCell, {
|
|
13213
13300
|
maintext: (_columndata$maintext = columndata.maintext) != null ? _columndata$maintext : '',
|
|
13301
|
+
alignment: columndata.alignment
|
|
13302
|
+
}), React__default.createElement(Icon, {
|
|
13303
|
+
icon: columndata.sortDirection === 'desc' ? 'ArrowDown' : 'ArrowUp',
|
|
13304
|
+
size: 10,
|
|
13305
|
+
color: 'currentColor',
|
|
13306
|
+
cursor: 'pointer'
|
|
13307
|
+
})) : React__default.createElement(TableCell, {
|
|
13308
|
+
maintext: (_columndata$maintext2 = columndata.maintext) != null ? _columndata$maintext2 : '',
|
|
13214
13309
|
width: columndata.width,
|
|
13215
13310
|
minWidth: columndata.minWidth,
|
|
13216
13311
|
maxWidth: columndata.maxWidth,
|
|
@@ -13367,6 +13462,17 @@ var Tabs = function Tabs(_ref15) {
|
|
|
13367
13462
|
onClick: function onClick() {
|
|
13368
13463
|
if (!disabled && tab.onClick) tab.onClick();
|
|
13369
13464
|
},
|
|
13465
|
+
onKeyDown: function onKeyDown(e) {
|
|
13466
|
+
if (disabled || !tab.onClick) return;
|
|
13467
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
13468
|
+
e.preventDefault();
|
|
13469
|
+
tab.onClick();
|
|
13470
|
+
}
|
|
13471
|
+
},
|
|
13472
|
+
role: 'tab',
|
|
13473
|
+
tabIndex: disabled ? -1 : 0,
|
|
13474
|
+
"aria-selected": activeTab === tab.title,
|
|
13475
|
+
"aria-disabled": disabled,
|
|
13370
13476
|
"$disabled": disabled,
|
|
13371
13477
|
"$headerHeight": headerHeight
|
|
13372
13478
|
}, React__default.createElement(TabItemContainer, {
|