labsense-ui-kit 1.2.96 → 1.2.98

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 CHANGED
@@ -7,6 +7,7 @@ var styled__default = _interopDefault(styled);
7
7
  var reactHotToast = require('react-hot-toast');
8
8
  var reactRouterDom = require('react-router-dom');
9
9
  var reactI18next = require('react-i18next');
10
+ var reactDom = require('react-dom');
10
11
 
11
12
  function _extends() {
12
13
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
@@ -9327,7 +9328,7 @@ var TextContainer = styled__default.span(_templateObject6$7 || (_templateObject6
9327
9328
  var $fontWeight = _ref15.$fontWeight;
9328
9329
  return $fontWeight || '500';
9329
9330
  }, SidebarContainer);
9330
- var NotificationBadge = styled__default.div(_templateObject7$5 || (_templateObject7$5 = _taggedTemplateLiteralLoose(["\n position: ", ";\n top: -4px;\n right: -4px;\n background: red;\n color: white;\n font-size: 10px;\n font-weight: bold;\n border-radius: 50%;\n padding: 2px 5px;\n min-width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n"])), function (_ref16) {
9331
+ var NotificationBadge = styled__default.div(_templateObject7$5 || (_templateObject7$5 = _taggedTemplateLiteralLoose(["\n position: ", ";\n // top: -4px;\n // right: 4px;\n background: red;\n color: white;\n font-size: 10px;\n font-weight: bold;\n border-radius: 50%;\n padding: 2px 5px;\n min-width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 100;\n width: max-content;\n"])), function (_ref16) {
9331
9332
  var $position = _ref16.$position;
9332
9333
  return $position || 'absolute';
9333
9334
  });
@@ -9343,7 +9344,17 @@ var Sidebar = function Sidebar(_ref17) {
9343
9344
  var _useState = React.useState({}),
9344
9345
  openMenus = _useState[0],
9345
9346
  setOpenMenus = _useState[1];
9346
- var isExpandedRef = React__default.useRef(isExpanded);
9347
+ var isExpandedRef = React.useRef(isExpanded);
9348
+ var _useState2 = React.useState(function () {
9349
+ var container = document.getElementById('badge-portal-container');
9350
+ if (!container) {
9351
+ container = document.createElement('div');
9352
+ container.id = 'badge-portal-container';
9353
+ document.body.appendChild(container);
9354
+ }
9355
+ return container;
9356
+ }),
9357
+ badgePortalContainer = _useState2[0];
9347
9358
  React.useEffect(function () {
9348
9359
  isExpandedRef.current = isExpanded;
9349
9360
  if (!isExpanded) setOpenMenus({});
@@ -9455,7 +9466,18 @@ var Sidebar = function Sidebar(_ref17) {
9455
9466
  "$cursor": 'pointer',
9456
9467
  "$borderRadius": '4px'
9457
9468
  }, React__default.createElement(Container, {
9458
- "$position": 'relative'
9469
+ "$position": 'relative',
9470
+ id: "icon-container-" + item.id,
9471
+ ref: function ref(el) {
9472
+ if (el && _getTotalNotifications(item) > 0) {
9473
+ var rect = el.getBoundingClientRect();
9474
+ var badge = document.getElementById("badge-" + item.id);
9475
+ if (badge) {
9476
+ badge.style.top = rect.top - 4 + "px";
9477
+ badge.style.left = rect.right - 14 + "px";
9478
+ }
9479
+ }
9480
+ }
9459
9481
  }, React__default.createElement(IconWrapper$2, {
9460
9482
  "$selected": !!isActive
9461
9483
  }, React__default.createElement(Icon, {
@@ -9464,7 +9486,12 @@ var Sidebar = function Sidebar(_ref17) {
9464
9486
  size: 20,
9465
9487
  weight: item.iconWeight,
9466
9488
  color: isActive ? themeColors.vms.text.white : themeColors.vms.text.medium
9467
- })), _getTotalNotifications(item) > 0 && React__default.createElement(NotificationBadge, null, _getTotalNotifications(item) > 99 ? '99+' : _getTotalNotifications(item))), React__default.createElement(TextContainer, {
9489
+ })), _getTotalNotifications(item) > 0 && reactDom.createPortal(React__default.createElement(NotificationBadge, {
9490
+ id: "badge-" + item.id,
9491
+ style: {
9492
+ position: 'fixed'
9493
+ }
9494
+ }, _getTotalNotifications(item) > 99 ? '99+' : _getTotalNotifications(item)), badgePortalContainer)), React__default.createElement(TextContainer, {
9468
9495
  "$fontSize": '14px'
9469
9496
  }, item.label)), hasChildren && React__default.createElement(Container, {
9470
9497
  "$padding": '9px',
@@ -9506,6 +9533,26 @@ var Sidebar = function Sidebar(_ref17) {
9506
9533
  setIsExpanded(expanded);
9507
9534
  }
9508
9535
  }, [setIsExpanded]);
9536
+ React.useEffect(function () {
9537
+ var updateBadgePositions = function updateBadgePositions() {
9538
+ content.forEach(function (item) {
9539
+ if (_getTotalNotifications(item) > 0) {
9540
+ var iconContainer = document.getElementById("icon-container-" + item.id);
9541
+ var badge = document.getElementById("badge-" + item.id);
9542
+ if (iconContainer && badge) {
9543
+ var rect = iconContainer.getBoundingClientRect();
9544
+ badge.style.top = rect.top - 4 + "px";
9545
+ badge.style.left = rect.right - 14 + "px";
9546
+ }
9547
+ }
9548
+ });
9549
+ };
9550
+ updateBadgePositions();
9551
+ window.addEventListener('resize', updateBadgePositions);
9552
+ return function () {
9553
+ window.removeEventListener('resize', updateBadgePositions);
9554
+ };
9555
+ }, [content, isExpanded, _getTotalNotifications]);
9509
9556
  return React__default.createElement(SidebarContainer, {
9510
9557
  "$background": background,
9511
9558
  onMouseEnter: function onMouseEnter() {
@@ -9687,7 +9734,7 @@ var TableRow = function TableRow(_ref) {
9687
9734
  };
9688
9735
 
9689
9736
  var _templateObject$q, _templateObject2$l, _templateObject3$e, _templateObject4$b, _templateObject5$9;
9690
- var TableContainer = styled__default.div(_templateObject$q || (_templateObject$q = _taggedTemplateLiteralLoose(["\n background: ", ";\n display: flex;\n flex-direction: column;\n border-radius: 8px;\n scrollbar-width: thin;\n flex: 1;\n height: 100%;\n overflow: hidden;\n box-sizing: border-box;\n"])), function (_ref) {
9737
+ var TableContainer = styled__default.div(_templateObject$q || (_templateObject$q = _taggedTemplateLiteralLoose(["\n background: ", ";\n display: flex;\n flex-direction: column;\n border-radius: 8px;\n scrollbar-width: thin;\n flex: 1;\n height: 100%;\n"])), function (_ref) {
9691
9738
  var theme = _ref.theme;
9692
9739
  return theme.vms.brand.light;
9693
9740
  });