labsense-ui-kit 1.1.40 → 1.1.41

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.
@@ -5,7 +5,8 @@ export interface SidebarItems {
5
5
  label: string;
6
6
  icon: IconNames;
7
7
  iconWeight?: string;
8
- url: string;
8
+ url?: string;
9
+ children?: SidebarItems[];
9
10
  }
10
11
  export interface logoDetails {
11
12
  icon: IconNames;
package/dist/index.js CHANGED
@@ -6093,33 +6093,32 @@ var ProgressBar = function ProgressBar(_ref) {
6093
6093
  })));
6094
6094
  };
6095
6095
 
6096
- var _templateObject$l, _templateObject2$h, _templateObject3$b, _templateObject4$8, _templateObject5$7, _templateObject6$6;
6097
- var SidebarContainer = styled__default.div(_templateObject$l || (_templateObject$l = _taggedTemplateLiteralLoose(["\n width: ", ";\n height: 100vh;\n background: ", "; \n transition: width 0.3s ease-in-out;\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: 10;\n justify-content: space-between;\n"])), function (_ref) {
6096
+ var _templateObject$l, _templateObject2$h, _templateObject3$b, _templateObject4$8, _templateObject5$7;
6097
+ var SidebarContainer = styled__default.div(_templateObject$l || (_templateObject$l = _taggedTemplateLiteralLoose(["\n width: ", ";\n height: 100vh;\n background: ", ";\n transition: width 0.3s ease-in-out;\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: 10;\n justify-content: space-between;\n"])), function (_ref) {
6098
6098
  var $isExpanded = _ref.$isExpanded;
6099
6099
  return $isExpanded ? '225px' : '68px';
6100
6100
  }, function (_ref2) {
6101
6101
  var $background = _ref2.$background;
6102
- return $background ? $background : colorVariables.accent.softBlue;
6102
+ return $background || colorVariables.accent.softBlue;
6103
6103
  });
6104
- var SidebarItem = styled__default(reactRouterDom.NavLink)(_templateObject2$h || (_templateObject2$h = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n height: 28px;\n width: 100%;\n gap: 10px;\n cursor: pointer;\n border-radius: 4px;\n color: ", ";\n transition: background 0.3s;\n\n &:hover {\n background: ", ";\n }\n"])), colorVariables.text.medium, colorVariables["default"].primary);
6105
- var ContentWrapper = styled__default.div(_templateObject3$b || (_templateObject3$b = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n gap: 16px;\n width: 100%;\n"])));
6106
- var IconWrapper$2 = styled__default.div(_templateObject4$8 || (_templateObject4$8 = _taggedTemplateLiteralLoose(["\n background: ", "; \n font-weight: bold;\n padding: 4px;\n border-radius: 4px;\n width: 28px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n > div:first-child {\n cursor: pointer;\n }\n"])), function (_ref3) {
6104
+ var SidebarLink = styled__default(reactRouterDom.NavLink)(_templateObject2$h || (_templateObject2$h = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n height: 28px;\n width: 100%;\n gap: 10px;\n cursor: pointer;\n border-radius: 4px;\n color: ", ";\n text-decoration: none;\n transition: background 0.3s;\n\n &:hover {\n background: ", ";\n }\n"])), colorVariables.text.medium, colorVariables["default"].primary);
6105
+ var IconWrapper$2 = styled__default.div(_templateObject3$b || (_templateObject3$b = _taggedTemplateLiteralLoose(["\n background: ", ";\n padding: 4px;\n border-radius: 4px;\n width: 28px;\n display: flex;\n align-items: center;\n justify-content: center;\n"])), function (_ref3) {
6107
6106
  var $selected = _ref3.$selected;
6108
6107
  return $selected ? colorVariables["default"].primary : colorVariables["default"].tertiary;
6109
6108
  });
6110
- var Logo = styled__default.div(_templateObject5$7 || (_templateObject5$7 = _taggedTemplateLiteralLoose(["\n display: flex;\n width: 100%;\n min-width: max-content;\n height: 32px;\n align-items: center;\n justify-content: start;\n gap: 10px;\n"])));
6111
- var TextContainer = styled__default.span(_templateObject6$6 || (_templateObject6$6 = _taggedTemplateLiteralLoose(["\n width: 100%;\n white-space: nowrap;\n padding: ", ";\n font-size: ", ";\n font-weight: ", ";\n color: ", ";\n opacity: ", ";\n visibility: ", ";\n transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;\n"])), function (_ref4) {
6109
+ var Logo = styled__default.div(_templateObject4$8 || (_templateObject4$8 = _taggedTemplateLiteralLoose(["\n display: flex;\n width: 100%;\n min-width: max-content;\n height: 32px;\n align-items: center;\n justify-content: start;\n gap: 10px;\n"])));
6110
+ var TextContainer = styled__default.span(_templateObject5$7 || (_templateObject5$7 = _taggedTemplateLiteralLoose(["\n white-space: nowrap;\n padding: ", ";\n font-size: ", ";\n font-weight: ", ";\n color: ", ";\n opacity: ", ";\n visibility: ", ";\n transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;\n"])), function (_ref4) {
6112
6111
  var $padding = _ref4.$padding;
6113
6112
  return $padding;
6114
6113
  }, function (_ref5) {
6115
6114
  var $fontSize = _ref5.$fontSize;
6116
- return $fontSize ? $fontSize : '20px';
6115
+ return $fontSize || '20px';
6117
6116
  }, function (_ref6) {
6118
6117
  var $fontWeight = _ref6.$fontWeight;
6119
- return $fontWeight ? $fontWeight : '500';
6118
+ return $fontWeight || '500';
6120
6119
  }, function (_ref7) {
6121
6120
  var $color = _ref7.$color;
6122
- return $color ? $color : colorVariables["default"].primary;
6121
+ return $color || colorVariables["default"].primary;
6123
6122
  }, function (_ref8) {
6124
6123
  var $isExpanded = _ref8.$isExpanded;
6125
6124
  return $isExpanded ? 1 : 0;
@@ -6136,15 +6135,49 @@ var Sidebar = function Sidebar(_ref10) {
6136
6135
  isExpanded = _ref10$isExpanded === void 0 ? false : _ref10$isExpanded,
6137
6136
  setIsExpanded = _ref10.setIsExpanded;
6138
6137
  var location = reactRouterDom.useLocation();
6139
- var getTopLevelPathWithSlash = function getTopLevelPathWithSlash(pathname) {
6140
- var parts = pathname.split('/').filter(String);
6141
- return parts.length > 0 ? '/' + parts[0] : '/';
6138
+ var _useState = React.useState({}),
6139
+ openMenus = _useState[0],
6140
+ setOpenMenus = _useState[1];
6141
+ React.useEffect(function () {
6142
+ if (!isExpanded) setOpenMenus({});
6143
+ }, [isExpanded]);
6144
+ var toggleMenu = function toggleMenu(id) {
6145
+ setOpenMenus(function (prev) {
6146
+ var _extends2;
6147
+ return _extends({}, prev, (_extends2 = {}, _extends2[id] = !prev[id], _extends2));
6148
+ });
6142
6149
  };
6143
- var getTopLevelPath = function getTopLevelPath(pathname) {
6144
- var parts = pathname.split('/').filter(String);
6145
- return parts.length > 0 ? "/" + parts[0] + "/" : '/';
6150
+ var isRouteActive = function isRouteActive(item) {
6151
+ var _item$children;
6152
+ return (item.url ? location.pathname.startsWith(item.url) : false) || ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.some(function (child) {
6153
+ return child.url && location.pathname.startsWith(child.url);
6154
+ }));
6155
+ };
6156
+ var renderChildLinks = function renderChildLinks(children) {
6157
+ return React__default.createElement(Container, {
6158
+ "$padding": '0px 0px 0px 16px',
6159
+ "$flexDirection": 'column',
6160
+ "$gap": '10px'
6161
+ }, children.map(function (child) {
6162
+ var active = location.pathname.startsWith(child.url || '');
6163
+ return React__default.createElement(SidebarLink, {
6164
+ to: child.url || '#',
6165
+ key: child.id
6166
+ }, React__default.createElement(IconWrapper$2, {
6167
+ "$selected": active
6168
+ }, React__default.createElement(Icon, {
6169
+ icon: child.icon,
6170
+ size: 18,
6171
+ weight: child.iconWeight,
6172
+ color: active ? colorVariables.text.white : colorVariables.text.medium
6173
+ })), React__default.createElement(TextContainer, {
6174
+ "$isExpanded": isExpanded,
6175
+ "$fontSize": '12px',
6176
+ "$padding": '0px 10px 0px 0px',
6177
+ "$color": colorVariables.text.medium
6178
+ }, child.label));
6179
+ }));
6146
6180
  };
6147
- var topLevelPath = getTopLevelPathWithSlash(location.pathname) || getTopLevelPath(location.pathname);
6148
6181
  return React__default.createElement(SidebarContainer, {
6149
6182
  "$background": background,
6150
6183
  "$isExpanded": isExpanded,
@@ -6154,30 +6187,62 @@ var Sidebar = function Sidebar(_ref10) {
6154
6187
  onMouseLeave: function onMouseLeave() {
6155
6188
  return setIsExpanded(false);
6156
6189
  }
6190
+ }, React__default.createElement(Container, {
6191
+ "$flexDirection": 'column',
6192
+ "$gap": '28px',
6193
+ "$width": '100%'
6157
6194
  }, logo && React__default.createElement(Logo, null, React__default.createElement(Icon, {
6158
6195
  icon: logo.icon
6159
6196
  }), React__default.createElement(TextContainer, {
6160
6197
  "$isExpanded": isExpanded,
6161
- "$fontWeight": "700"
6162
- }, logo.name)), React__default.createElement(ContentWrapper, null, content.map(function (item) {
6163
- var isActive = item.url.includes(topLevelPath);
6164
- return React__default.createElement(SidebarItem, {
6165
- to: item.url,
6166
- key: item.id
6198
+ "$fontWeight": '700'
6199
+ }, logo.name)), React__default.createElement(Container, {
6200
+ "$flexDirection": 'column',
6201
+ "$gap": '16px',
6202
+ "$width": '100%'
6203
+ }, content.map(function (item) {
6204
+ var _item$children2;
6205
+ var active = isRouteActive(item);
6206
+ var hasChildren = !!((_item$children2 = item.children) !== null && _item$children2 !== void 0 && _item$children2.length);
6207
+ var isOpen = openMenus[item.id];
6208
+ var ContentLayout = React__default.createElement(Container, {
6209
+ "$alignItems": 'center',
6210
+ "$gap": '8px',
6211
+ "$width": '100%',
6212
+ "$cursor": 'pointer',
6213
+ "$borderRadius": '4px',
6214
+ "$hoverBackground": colorVariables["default"].primary,
6215
+ onClick: function onClick() {
6216
+ return hasChildren && toggleMenu(item.id);
6217
+ }
6167
6218
  }, React__default.createElement(IconWrapper$2, {
6168
- "$selected": isActive
6219
+ "$selected": !!active
6169
6220
  }, React__default.createElement(Icon, {
6170
6221
  icon: item.icon,
6171
6222
  size: 20,
6172
6223
  weight: item.iconWeight,
6173
- color: isActive ? colorVariables.text.white : colorVariables.text.medium
6224
+ color: active ? colorVariables.text.white : colorVariables.text.medium
6174
6225
  })), React__default.createElement(TextContainer, {
6175
6226
  "$isExpanded": isExpanded,
6176
- "$fontSize": "14px",
6227
+ "$fontSize": '14px',
6177
6228
  "$padding": '0px 10px 0px 0px',
6178
6229
  "$color": colorVariables.text.medium
6179
- }, item.label));
6180
- })), ProfileContent);
6230
+ }, item.label), hasChildren && React__default.createElement(Icon, {
6231
+ icon: isOpen ? 'UpArrow' : 'DownArrow',
6232
+ size: 10,
6233
+ color: colorVariables.border.extraBold,
6234
+ onClick: function onClick() {}
6235
+ }));
6236
+ return item.url ? React__default.createElement(SidebarLink, {
6237
+ key: item.id,
6238
+ to: item.url
6239
+ }, ContentLayout) : React__default.createElement(Container, {
6240
+ key: item.id,
6241
+ "$flexDirection": 'column',
6242
+ "$alignItems": 'start',
6243
+ "$gap": '8px'
6244
+ }, ContentLayout, hasChildren && isExpanded && isOpen && renderChildLinks(item.children));
6245
+ }))), ProfileContent);
6181
6246
  };
6182
6247
 
6183
6248
  var _templateObject$m, _templateObject2$i, _templateObject3$c, _templateObject4$9;