@robosystems/core 0.9.2 → 0.9.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robosystems/core",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "Shared RoboSystems frontend core library (auth, contexts, task monitoring, UI components) for the RoboSystems Next.js apps",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -23,13 +23,25 @@ function MobileSidebar({ navigationItems, features, bottomMenuActions, additiona
23
23
  return null;
24
24
  return (_jsxs(_Fragment, { children: [_jsx(Sidebar, { "aria-label": "Sidebar with multi-level dropdown example", theme: customTheme.sidebar, className: twMerge(`fixed inset-y-0 left-0 z-20 hidden h-full shrink-0 flex-col border-r border-gray-200 pt-16 ${borderColorClass} lg:flex`, isOpen && 'flex'), id: "sidebar", children: _jsxs("div", { className: "flex h-full flex-col justify-between", children: [_jsxs("div", { className: "py-2", children: [additionalMobileComponents && (_jsx("div", { className: "hidden pb-2 max-md:block", children: additionalMobileComponents })), _jsxs(SidebarItems, { children: [_jsx(OrgSection, { isCollapsed: false, showOrgSection: features.showOrgSection }), _jsx(SidebarItemGroup, { className: "mt-0 border-t-0 pt-2 pb-1", children: navigationItems.map((item) => (_jsx(CustomSidebarItem, Object.assign({}, item, { pathname: pathname }), item.label))) })] })] }), _jsx(BottomMenu, { isCollapsed: false, features: features, bottomMenuActions: bottomMenuActions })] }) }), _jsx("div", { onClick: close, "aria-hidden": "true", className: "fixed inset-0 z-10 h-full w-full bg-zinc-900/50 pt-16 dark:bg-zinc-900/90" })] }));
25
25
  }
26
+ // SidebarItem renders an <a> for an href and forwards these, but its props are typed
27
+ // as a div's, so they are spread rather than written as attributes. A link that opens a
28
+ // new tab gets noopener and noreferrer, so the page it opens can't reach back into the
29
+ // app's window through window.opener.
30
+ function newTabProps(target) {
31
+ return target
32
+ ? {
33
+ target,
34
+ rel: target === '_blank' ? 'noopener noreferrer' : undefined,
35
+ }
36
+ : {};
37
+ }
26
38
  function CustomSidebarItem({ href, target, icon: Icon, label, items, badge, pathname, }) {
27
39
  if (!(items === null || items === void 0 ? void 0 : items.length)) {
28
40
  const isExternal = target === '_blank' || (href === null || href === void 0 ? void 0 : href.startsWith('http'));
29
41
  if (isExternal) {
30
- return (_jsx(SidebarItem, { href: href || '#', icon: Icon, active: pathname === href, theme: customTheme.sidebar.item, className: pathname === href
42
+ return (_jsx(SidebarItem, Object.assign({ href: href || '#' }, newTabProps(target), { icon: Icon, active: pathname === href, theme: customTheme.sidebar.item, className: pathname === href
31
43
  ? 'bg-primary-50 text-primary-700 dark:bg-primary-200 dark:text-primary-800'
32
- : '', children: label }));
44
+ : '', children: label })));
33
45
  }
34
46
  return (_jsx(SidebarItem, { as: Link, href: href || '#', icon: Icon, active: pathname === href, theme: customTheme.sidebar.item, className: pathname === href
35
47
  ? 'bg-zinc-100 text-gray-900 dark:bg-zinc-800 dark:text-gray-200'
@@ -39,9 +51,9 @@ function CustomSidebarItem({ href, target, icon: Icon, label, items, badge, path
39
51
  var _a;
40
52
  const isExternal = item.target === '_blank' || ((_a = item.href) === null || _a === void 0 ? void 0 : _a.startsWith('http'));
41
53
  if (isExternal) {
42
- return (_jsx(SidebarItem, { href: item.href || '#', active: pathname === item.href, theme: customTheme.sidebar.item, className: pathname === item.href
54
+ return (_jsx(SidebarItem, Object.assign({ href: item.href || '#' }, newTabProps(item.target), { active: pathname === item.href, theme: customTheme.sidebar.item, className: pathname === item.href
43
55
  ? 'bg-primary-50 text-primary-700 dark:bg-primary-200 dark:text-primary-800'
44
- : '', children: item.label }, item.label));
56
+ : '', children: item.label }), item.label));
45
57
  }
46
58
  return (_jsx(SidebarItem, { as: Link, href: item.href || '#', active: pathname === item.href, theme: customTheme.sidebar.item, className: pathname === item.href
47
59
  ? 'bg-primary-50 text-primary-700 dark:bg-primary-200 dark:text-primary-800'