@mailstep/design-system 0.8.49 → 0.8.50

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.8.49",
3
+ "version": "0.8.50",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -4,6 +4,7 @@ type ItemType = {
4
4
  title: string | React.ReactElement;
5
5
  onClick: () => void;
6
6
  link?: string;
7
+ disabled?: boolean;
7
8
  };
8
9
  export type Props = {
9
10
  items: ItemType[];
@@ -16,6 +16,11 @@ const StyledLink = styled$1(Link)`
16
16
  background-color: bgLightGray1;
17
17
  border-radius: 6px;
18
18
  }
19
+ ${({ $disabled }) => $disabled && css`
20
+ opacity: 0.5;
21
+ pointer-events: none;
22
+ cursor: not-allowed;
23
+ `}
19
24
  ${({ $isActive }) => $isActive && css`
20
25
  background-color: red1;
21
26
  color: white;
@@ -32,23 +37,31 @@ const StyledLink = styled$1(Link)`
32
37
  `}
33
38
  `;
34
39
  const MenuItem = ({ item, ItemComponent, onClose }) => {
35
- const { onClick, link, hasSeparator, name, autoClose } = item;
40
+ const { onClick, link, hasSeparator, name, autoClose, disabled } = item;
41
+ const isActive = link === useLocation().pathname;
42
+ const onClickCallback = useCallback((e) => {
43
+ if (disabled) {
44
+ e.preventDefault();
45
+ return;
46
+ }
47
+ if (onClick) {
48
+ e.preventDefault();
49
+ onClick();
50
+ }
51
+ if (autoClose && onClose) setTimeout(() => {
52
+ onClose();
53
+ }, 200);
54
+ }, [
55
+ autoClose,
56
+ disabled,
57
+ onClick,
58
+ onClose
59
+ ]);
36
60
  return /* @__PURE__ */ jsx(StyledLink, {
37
- to: link,
38
- $isActive: link === useLocation().pathname,
39
- onClick: useCallback((e) => {
40
- if (onClick) {
41
- e.preventDefault();
42
- onClick();
43
- }
44
- if (autoClose && onClose) setTimeout(() => {
45
- onClose();
46
- }, 200);
47
- }, [
48
- autoClose,
49
- onClick,
50
- onClose
51
- ]),
61
+ to: disabled ? void 0 : link,
62
+ $isActive: isActive,
63
+ $disabled: !!disabled,
64
+ onClick: onClickCallback,
52
65
  $hasSeparator: !!hasSeparator,
53
66
  "data-cy": name,
54
67
  size: "inherit",
@@ -11,6 +11,7 @@ export type DefaultItem = {
11
11
  hidden?: boolean;
12
12
  count?: number;
13
13
  autoClose?: boolean;
14
+ disabled?: boolean;
14
15
  };
15
16
  export type Item = {
16
17
  link?: string | Pathname;
@@ -19,6 +20,7 @@ export type Item = {
19
20
  name?: string;
20
21
  autoClose?: boolean;
21
22
  hidden?: boolean;
23
+ disabled?: boolean;
22
24
  };
23
25
  export type MenuItemProps<ItemType extends Item> = {
24
26
  item: ItemType;