@mailstep/design-system 0.8.49 → 0.8.51

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.51",
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[];
@@ -1,5 +1,5 @@
1
- import { DragEndEvent } from '@dnd-kit/core';
2
- import { CommonGridProps, GridActionsType, GridSelectorsType, ColumnDefinition } from '../types';
1
+ import { type CommonGridProps, type GridActionsType, type GridSelectorsType, type ColumnDefinition } from '../types';
2
+ import { type DragEndEvent } from '@dnd-kit/core';
3
3
  type Props = {
4
4
  columns: CommonGridProps['columnsDefinitions'];
5
5
  gridActions: GridActionsType;
@@ -2,7 +2,7 @@ import { checksColumnsOrder, isColumnOn } from "../utils/index.js";
2
2
  import { useCallback, useEffect, useMemo, useState } from "react";
3
3
  //#region packages/ui/Blocks/CommonGrid/hooks/useManageColumn.ts
4
4
  const useManageColumn = ({ columns, gridSelectors, gridActions, onClose }) => {
5
- const { resetGrid, setColumnConfig, setColumnsOrder } = gridActions;
5
+ const { setColumnConfig, setColumnsOrder } = gridActions;
6
6
  const { columnConfig, columnsOrder } = gridSelectors;
7
7
  const initialColumnsOrder = useMemo(() => columns?.map((col) => col.name), [columns]);
8
8
  const columnsOrderValue = columnsOrder?.length ? columnsOrder : initialColumnsOrder;
@@ -29,14 +29,15 @@ const useManageColumn = ({ columns, gridSelectors, gridActions, onClose }) => {
29
29
  ]);
30
30
  const resetColumnConfig = useCallback(() => {
31
31
  setUpdatedColumnsOrder(initialColumnsOrder);
32
- resetGrid?.();
32
+ setColumnConfig?.({});
33
+ setColumnsOrder?.([]);
33
34
  onClose?.();
34
35
  setColumnsConfigOptions({});
35
36
  }, [
36
37
  onClose,
37
- resetGrid,
38
- initialColumnsOrder,
39
- columnConfig
38
+ setColumnConfig,
39
+ setColumnsOrder,
40
+ initialColumnsOrder
40
41
  ]);
41
42
  const onCloseForm = useCallback(() => {
42
43
  setUpdatedColumnsOrder(columnsOrderValue);
@@ -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;