@mailstep/design-system 0.13.9-beta.1 → 0.13.10

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": "@mailstep/design-system",
3
- "version": "0.13.9-beta.1",
3
+ "version": "0.13.10",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -1,6 +1,6 @@
1
1
  import Icon from "../../Elements/Icon/Icon.js";
2
2
  import { Paragraph3, Paragraph5 } from "../../Elements/Typography/Typography.js";
3
- import { ItemDropdownArrow, ItemIcon, ItemLabel, ItemLinkWrap, ItemsSeparator, MenuItemContainer, OverflowWithEllipsis, SubItemsWrap } from "./styles.js";
3
+ import { ItemCount, ItemDropdownArrow, ItemIcon, ItemLabel, ItemLinkWrap, ItemsSeparator, MenuItemContainer, OverflowWithEllipsis, SubItemsWrap } from "./styles.js";
4
4
  import SubitemTooltip from "./components/SubitemTooltip.js";
5
5
  import { useLeftMenuContext } from "./context/useLeftMenuContext.js";
6
6
  import useOutSideHover from "./hooks/useOutsideHover.js";
@@ -9,7 +9,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { matchPath } from "react-router";
10
10
  //#region packages/ui/Blocks/SideMenu/MenuItem.tsx
11
11
  const removeOptionalEnd = /\?$/;
12
- const MenuItem = ({ icon, title, link = "", items, id, isSubitem, isCompact, lightMode = false, separator = false, isLeftMenuOpen, onCloseLeftMenu, onClick }) => {
12
+ const MenuItem = ({ icon, title, link = "", items, id, count, isSubitem, isCompact, lightMode = false, separator = false, isLeftMenuOpen, onCloseLeftMenu, onClick }) => {
13
13
  const hasChildren = items && items?.length > 0;
14
14
  const { expandedItem, expandItem } = useLeftMenuContext();
15
15
  const isExpanded = expandedItem === id;
@@ -61,6 +61,8 @@ const MenuItem = ({ icon, title, link = "", items, id, isSubitem, isCompact, lig
61
61
  $isCompact: isCompact,
62
62
  className: itemLinkWrapClassName,
63
63
  $lightMode: lightMode,
64
+ $isHovering: isHovering,
65
+ "data-testid": id ? `menu-item-${id}` : void 0,
64
66
  as: link ? void 0 : "a",
65
67
  ...link ? {
66
68
  exact: true,
@@ -70,20 +72,27 @@ const MenuItem = ({ icon, title, link = "", items, id, isSubitem, isCompact, lig
70
72
  children: [/* @__PURE__ */ jsxs(ItemLabel, {
71
73
  $isCompact: isCompact,
72
74
  isSubitem,
73
- children: [!isSubitem && icon && /* @__PURE__ */ jsx(ItemIcon, {
74
- className: "mainIcon",
75
- $isCompact: isCompact,
76
- children: typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, {
77
- icon,
78
- fill: "none"
79
- }) : icon
80
- }), /* @__PURE__ */ jsx(Title, {
81
- variant: "semiBold",
82
- mt: 0,
83
- mb: 0,
84
- textAlign: isCompact ? "center" : "left",
85
- children: /* @__PURE__ */ jsx(OverflowWithEllipsis, { children: title })
86
- })]
75
+ children: [
76
+ !isSubitem && icon && /* @__PURE__ */ jsx(ItemIcon, {
77
+ className: "mainIcon",
78
+ $isCompact: isCompact,
79
+ children: typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, {
80
+ icon,
81
+ fill: "none"
82
+ }) : icon
83
+ }),
84
+ /* @__PURE__ */ jsx(Title, {
85
+ variant: "semiBold",
86
+ mt: 0,
87
+ mb: 0,
88
+ textAlign: isCompact ? "center" : "left",
89
+ children: /* @__PURE__ */ jsx(OverflowWithEllipsis, { children: title })
90
+ }),
91
+ !!count && /* @__PURE__ */ jsx(ItemCount, {
92
+ $isCompact: isCompact,
93
+ children: count
94
+ })
95
+ ]
87
96
  }), !isCompact && hasChildren && /* @__PURE__ */ jsx(ItemDropdownArrow, {
88
97
  icon: "goDown",
89
98
  $lightMode: lightMode
@@ -1,4 +1,5 @@
1
1
  import { useClickOutside } from "../Modal/hooks/useClickOutside.js";
2
+ import { HamburgerMenuButton } from "./components/HamburgerMenu.js";
2
3
  import MenuFooter from "./components/Footer.js";
3
4
  import { LeftMenuProvider } from "./context/LeftMenuContext.js";
4
5
  import { BodyWrap, Container, Overlay, ScrollWrap, TopLevelWrap } from "./styles.js";
@@ -6,7 +7,7 @@ import MenuItem_default from "./MenuItem.js";
6
7
  import "react";
7
8
  import { jsx, jsxs } from "react/jsx-runtime";
8
9
  //#region packages/ui/Blocks/SideMenu/SideMenu.tsx
9
- const SideMenu = ({ menuItems, isCompact, setIsCompact, isLeftMenuOpen, isAlwaysVisible, onCloseLeftMenu, variant = "dark", children }) => {
10
+ const SideMenu = ({ menuItems, isCompact, setIsCompact, isLeftMenuOpen, isAlwaysVisible, onCloseLeftMenu, showHamburgerMenu = false, variant = "dark", children }) => {
10
11
  const lightMode = variant === "light";
11
12
  return /* @__PURE__ */ jsx(LeftMenuProvider, { children: /* @__PURE__ */ jsxs(Container, {
12
13
  isLeftMenuOpen,
@@ -16,21 +17,28 @@ const SideMenu = ({ menuItems, isCompact, setIsCompact, isLeftMenuOpen, isAlways
16
17
  isLeftMenuOpen,
17
18
  ref: useClickOutside({ onClose: onCloseLeftMenu }),
18
19
  lightMode,
19
- children: [/* @__PURE__ */ jsx(ScrollWrap, { children: /* @__PURE__ */ jsxs(BodyWrap, {
20
- isCompact,
21
- children: [menuItems.map((item, index) => /* @__PURE__ */ jsx(MenuItem_default, {
22
- isCompact,
20
+ children: [
21
+ showHamburgerMenu && /* @__PURE__ */ jsx(HamburgerMenuButton, {
23
22
  isLeftMenuOpen,
24
- onCloseLeftMenu,
25
- lightMode,
26
- separator: !!item.separator,
27
- ...item
28
- }, `${item.id ?? item.title}-${index}`)), children]
29
- }) }), /* @__PURE__ */ jsx(MenuFooter, {
30
- isCompact,
31
- setIsCompact,
32
- lightMode
33
- })]
23
+ onClick: onCloseLeftMenu
24
+ }),
25
+ /* @__PURE__ */ jsx(ScrollWrap, { children: /* @__PURE__ */ jsxs(BodyWrap, {
26
+ isCompact,
27
+ children: [menuItems.map((item, index) => /* @__PURE__ */ jsx(MenuItem_default, {
28
+ isCompact,
29
+ isLeftMenuOpen,
30
+ onCloseLeftMenu,
31
+ lightMode,
32
+ separator: !!item.separator,
33
+ ...item
34
+ }, `${item.id ?? item.title}-${index}`)), children]
35
+ }) }),
36
+ /* @__PURE__ */ jsx(MenuFooter, {
37
+ isCompact,
38
+ setIsCompact,
39
+ lightMode
40
+ })
41
+ ]
34
42
  }), /* @__PURE__ */ jsx(Overlay, {})]
35
43
  }) });
36
44
  };
@@ -1,6 +1,8 @@
1
+ import React from 'react';
1
2
  type Props = {
2
3
  isLeftMenuOpen?: boolean;
3
4
  onClick?: () => void;
5
+ mr?: string;
4
6
  };
5
- export declare const HamburgerMenuButton: ({ isLeftMenuOpen, onClick }: Props) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const HamburgerMenuButton: ({ isLeftMenuOpen, onClick, mr }: Props) => React.ReactElement;
6
8
  export {};
@@ -35,11 +35,11 @@ const HamburgerMenuWrapper = styled$2(x.div)`
35
35
  display: none;
36
36
  }
37
37
  `;
38
- const HamburgerMenuButton = ({ isLeftMenuOpen, onClick }) => {
38
+ const HamburgerMenuButton = ({ isLeftMenuOpen, onClick, mr = "8px" }) => {
39
39
  const theme = useTheme();
40
- const neutralColor = th$1.color("neutral20")({ theme });
40
+ const neutralColor = th$1.color("bgLightGray2")({ theme });
41
41
  return /* @__PURE__ */ jsx(HamburgerMenuWrapper, {
42
- mr: "8px",
42
+ mr,
43
43
  onClick,
44
44
  isLeftMenuOpen: !!isLeftMenuOpen,
45
45
  children: isLeftMenuOpen ? /* @__PURE__ */ jsx(MobileCancel, { fill: neutralColor }) : /* @__PURE__ */ jsx(HamburgerMenu, {
@@ -1,12 +1,12 @@
1
1
  import { H6 } from "../../../Elements/Typography/Typography.js";
2
2
  import { Portal } from "../../../Elements/Portal/index.js";
3
- import { ItemLinkWrap, TooltipItemLabel, TooltipWrap } from "../styles.js";
3
+ import { ItemCount, ItemLinkWrap, TooltipItemLabel, TooltipWrap } from "../styles.js";
4
4
  import { useMemo } from "react";
5
- import { jsx } from "react/jsx-runtime";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
6
  import styled from "styled-components";
7
7
  import { Popper } from "react-popper";
8
8
  //#region packages/ui/Blocks/SideMenu/components/SubitemTooltip.tsx
9
- const TooltipItem = ({ title, link = "", lightMode }) => {
9
+ const TooltipItem = ({ title, link = "", lightMode, count }) => {
10
10
  return /* @__PURE__ */ jsx(ItemLinkWrap, {
11
11
  ...useMemo(() => {
12
12
  return link.startsWith("https://") ? {
@@ -16,14 +16,14 @@ const TooltipItem = ({ title, link = "", lightMode }) => {
16
16
  }, [link]),
17
17
  exact: true,
18
18
  $lightMode: lightMode,
19
- children: /* @__PURE__ */ jsx(TooltipItemLabel, { children: /* @__PURE__ */ jsx(H6, {
19
+ children: /* @__PURE__ */ jsxs(TooltipItemLabel, { children: [/* @__PURE__ */ jsx(H6, {
20
20
  variant: "medium",
21
21
  children: title
22
- }) })
22
+ }), !!count && /* @__PURE__ */ jsx(ItemCount, { children: count })] })
23
23
  });
24
24
  };
25
25
  const PopoverWrapper = styled.div`
26
- z-index: 5;
26
+ z-index: 31;
27
27
  display: ${({ isLeftMenuOpen }) => isLeftMenuOpen ? "block" : "none"};
28
28
  @media (min-width: 1024px) {
29
29
  display: block;
@@ -4,6 +4,7 @@ export declare const menuItems: ({
4
4
  link: string;
5
5
  id: string;
6
6
  items?: undefined;
7
+ count?: undefined;
7
8
  } | {
8
9
  title: string;
9
10
  icon: import("react/jsx-runtime").JSX.Element;
@@ -14,4 +15,22 @@ export declare const menuItems: ({
14
15
  link: string;
15
16
  id: string;
16
17
  }[];
18
+ count?: undefined;
19
+ } | {
20
+ title: string;
21
+ icon: import("react/jsx-runtime").JSX.Element;
22
+ link: string;
23
+ id: string;
24
+ count: number;
25
+ items: ({
26
+ title: string;
27
+ link: string;
28
+ id: string;
29
+ count?: undefined;
30
+ } | {
31
+ title: string;
32
+ link: string;
33
+ id: string;
34
+ count: number;
35
+ })[];
17
36
  })[];
@@ -53,6 +53,7 @@ const menuItems = [
53
53
  icon: /* @__PURE__ */ jsx(Expeditions, {}),
54
54
  link: "/expeditions",
55
55
  id: "expeditions",
56
+ count: 3,
56
57
  items: [
57
58
  {
58
59
  title: "Expeditions",
@@ -62,7 +63,8 @@ const menuItems = [
62
63
  {
63
64
  title: "Outbound receipts",
64
65
  link: "/expeditions/outbound-receipts",
65
- id: "outboundReceipts"
66
+ id: "outboundReceipts",
67
+ count: 3
66
68
  },
67
69
  {
68
70
  title: "Missing goods",
@@ -16,6 +16,7 @@ export declare const TooltipItemLabel: import("styled-components").StyledCompone
16
16
  export declare const ItemLinkWrap: import("styled-components").StyledComponent<typeof NavLink, import("@xstyled/styled-components").Theme, {
17
17
  $isCompact?: boolean;
18
18
  $lightMode?: boolean;
19
+ $isHovering?: boolean;
19
20
  appearance?: "gray" | "default";
20
21
  }, never>;
21
22
  export declare const MenuItemContainer: import("styled-components").StyledComponent<"div", import("@xstyled/styled-components").Theme, {
@@ -41,3 +42,6 @@ export declare const BodyWrap: import("styled-components").StyledComponent<"div"
41
42
  isCompact: boolean;
42
43
  }, never>;
43
44
  export declare const Overlay: import("styled-components").StyledComponent<"div", import("@xstyled/styled-components").Theme, {}, never>;
45
+ export declare const ItemCount: import("styled-components").StyledComponent<"span", import("@xstyled/styled-components").Theme, {
46
+ $isCompact?: boolean;
47
+ }, never>;
@@ -67,6 +67,8 @@ const ItemDropdownArrow = styled$1(Icon)`
67
67
  const TooltipItemLabel = styled$1.div`
68
68
  line-height: 1.5;
69
69
  letter-spacing: 0.4px;
70
+ display: flex;
71
+ align-items: center;
70
72
  `;
71
73
  const ItemLinkWrap = styled$1(NavLink)`
72
74
  display: flex;
@@ -78,14 +80,17 @@ const ItemLinkWrap = styled$1(NavLink)`
78
80
  font-weight: 600;
79
81
  letter-spacing: 0.4px;
80
82
  position: relative;
81
- color: ${({ $lightMode }) => $lightMode ? th$1.color("typoPrimary") : th$1.color("lightGray5")};
83
+ color: ${({ $lightMode, $isHovering }) => {
84
+ if ($lightMode) return th$1.color("typoPrimary");
85
+ if ($isHovering) return "white";
86
+ return th$1.color("lightGray5");
87
+ }};
82
88
  transition: moving 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
83
89
  transition-property: transform;
84
90
 
85
91
  &.toplevel {
86
92
  margin: ${({ $isCompact }) => $isCompact ? "0 0 12px 0" : "16px 0"};
87
93
  padding: ${({ $isCompact }) => $isCompact ? "10px 14px 6px 13px" : "9px 10px"};
88
- gap: ${({ $isCompact }) => $isCompact ? "none" : "30px"};
89
94
  justify-content: ${({ $isCompact }) => $isCompact ? "center" : "space-between"};
90
95
  &.active {
91
96
  color: ${({ $lightMode }) => $lightMode ? th$1("colors.red1") : "white"};
@@ -130,7 +135,7 @@ const MenuItemContainer = styled$1.div`
130
135
  z-index: 1;
131
136
  stroke: ${({ $lightMode }) => $lightMode ? th$1.color("blue2") : void 0};
132
137
  .selected > ${ItemLabel}, .active > ${ItemLabel} {
133
- color: ${({ $lightMode }) => $lightMode ? th$1.color("red1") : th$1.color("white")};
138
+ color: ${({ $lightMode }) => $lightMode ? th$1.color("red1") : th$1.color("sideMenuSelectedText")};
134
139
  stroke: ${({ $lightMode }) => $lightMode ? th$1.color("red1") : th$1.color("blue2")};
135
140
  }
136
141
 
@@ -230,7 +235,7 @@ const TooltipWrap = styled$1.div`
230
235
  top: -50px;
231
236
  }
232
237
 
233
- & :not(:last-child) {
238
+ & > :not(:last-child) {
234
239
  border-radius: 0;
235
240
  border-bottom: 0.5px solid ${({ $lightMode }) => $lightMode ? th$1.color("neutral20") : th$1("colors.textTertiary")};
236
241
  }
@@ -259,9 +264,10 @@ const OverflowWithEllipsis = styled$1.span`
259
264
  max-width: 140px;
260
265
  overflow: hidden;
261
266
  text-overflow: ellipsis;
267
+ white-space: nowrap;
262
268
  `;
263
269
  const TopLevelWrap = styled$1.div`
264
- background-color: ${({ lightMode }) => lightMode ? "white" : th$1("colors.blue3")};
270
+ background-color: ${({ lightMode }) => lightMode ? "white" : th$1("colors.sideMenuBackground")};
265
271
  border-right: 1px solid ${th$1("colors.lightGray6")};
266
272
  height: -webkit-fill-available;
267
273
  transition: width 0.5s ease;
@@ -306,5 +312,28 @@ const Overlay = styled$1.div`
306
312
  display: none;
307
313
  }
308
314
  `;
315
+ const ItemCount = styled$1.span`
316
+ display: flex;
317
+ align-items: center;
318
+ justify-content: center;
319
+ flex-shrink: 0;
320
+ min-width: 20px;
321
+ height: 18px;
322
+ padding: 0 5px;
323
+ border-radius: 9px;
324
+ background-color: #ffffff;
325
+ color: ${th$1.color("red1")};
326
+ font-size: 12px;
327
+ line-height: 18px;
328
+ font-weight: 600;
329
+ margin-left: 8px;
330
+
331
+ ${({ $isCompact }) => $isCompact && css`
332
+ position: absolute;
333
+ top: 0;
334
+ right: 2px;
335
+ margin-left: 0;
336
+ `}
337
+ `;
309
338
  //#endregion
310
- export { BodyWrap, Container, ItemDropdownArrow, ItemIcon, ItemLabel, ItemLinkWrap, ItemsSeparator, MenuItemContainer, OverflowWithEllipsis, Overlay, ScrollWrap, SubItemsWrap, TooltipItemLabel, TooltipWrap, TopLevelWrap };
339
+ export { BodyWrap, Container, ItemCount, ItemDropdownArrow, ItemIcon, ItemLabel, ItemLinkWrap, ItemsSeparator, MenuItemContainer, OverflowWithEllipsis, Overlay, ScrollWrap, SubItemsWrap, TooltipItemLabel, TooltipWrap, TopLevelWrap };
@@ -10,6 +10,7 @@ export type MenuItemType = {
10
10
  lightMode?: boolean;
11
11
  separator?: boolean;
12
12
  appearance?: 'gray' | 'default';
13
+ count?: number;
13
14
  };
14
15
  export type SideMenuProps = {
15
16
  menuItems: MenuItemType[];
@@ -18,6 +19,7 @@ export type SideMenuProps = {
18
19
  isLeftMenuOpen?: boolean;
19
20
  isAlwaysVisible?: boolean;
20
21
  onCloseLeftMenu?: () => void;
22
+ showHamburgerMenu?: boolean;
21
23
  variant?: 'dark' | 'light';
22
24
  children?: ReactNode;
23
25
  };