@agility/plenum-ui 2.1.20 → 2.1.22

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/dist/tailwind.css CHANGED
@@ -79280,9 +79280,9 @@ select {
79280
79280
  border-color: rgb(167 139 250 / var(--tw-border-opacity, 1));
79281
79281
  }
79282
79282
 
79283
- .disabled\:bg-gray-100:disabled {
79284
- --tw-bg-opacity: 1;
79285
- background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));
79283
+ .disabled\:\!bg-gray-50:disabled {
79284
+ --tw-bg-opacity: 1 !important;
79285
+ background-color: rgb(249 250 251 / var(--tw-bg-opacity, 1)) !important;
79286
79286
  }
79287
79287
 
79288
79288
  .disabled\:bg-gray-50:disabled {
@@ -79325,11 +79325,6 @@ select {
79325
79325
  color: rgb(249 250 251 / var(--tw-text-opacity, 1));
79326
79326
  }
79327
79327
 
79328
- .disabled\:text-gray-500:disabled {
79329
- --tw-text-opacity: 1;
79330
- color: rgb(107 114 128 / var(--tw-text-opacity, 1));
79331
- }
79332
-
79333
79328
  .disabled\:text-purple-300:disabled {
79334
79329
  --tw-text-opacity: 1;
79335
79330
  color: rgb(188 153 238 / var(--tw-text-opacity, 1));
@@ -20,6 +20,7 @@ export interface IAvatarProps {
20
20
  * avatar img alt
21
21
  */
22
22
  alt?: string;
23
+ draggable?: boolean;
23
24
  }
24
25
  /**
25
26
  * Avatar component that shows profile image or name initials of the user
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agility/plenum-ui",
3
- "version": "2.1.20",
3
+ "version": "2.1.22",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -1,33 +1,41 @@
1
- import React, { FC, useMemo } from "react"
2
- import { default as cn } from "classnames"
1
+ import React, { FC, useMemo } from "react";
2
+ import { default as cn } from "classnames";
3
3
  // import Image from "next/image"
4
4
  export interface IAvatarProps {
5
5
  /**
6
6
  * source url for the avatar
7
7
  */
8
- src?: string
8
+ src?: string;
9
9
  /**
10
10
  * Initials we use as fallback if no src is passed
11
11
  */
12
- initials?: string
12
+ initials?: string;
13
13
  /**
14
14
  * optional status
15
15
  */
16
- status?: "offline" | "online" | "busy"
16
+ status?: "offline" | "online" | "busy";
17
17
  /**
18
18
  * avatar picture size (also affects status indicator)
19
19
  */
20
- size?: "xxs" | "xs" | "sm" | "md" | "lg" | "xl"
20
+ size?: "xxs" | "xs" | "sm" | "md" | "lg" | "xl";
21
21
  /**
22
22
  * avatar img alt
23
23
  */
24
- alt?: string
24
+ alt?: string;
25
+ draggable?: boolean;
25
26
  }
26
27
 
27
28
  /**
28
29
  * Avatar component that shows profile image or name initials of the user
29
30
  */
30
- const Avatar: FC<IAvatarProps> = ({ src, status, size = "md", alt = "Avatar image", initials }: IAvatarProps) => {
31
+ const Avatar: FC<IAvatarProps> = ({
32
+ src,
33
+ status,
34
+ size = "md",
35
+ alt = "Avatar image",
36
+ initials,
37
+ draggable = false
38
+ }: IAvatarProps) => {
31
39
  const imageStyles = cn("rounded-full", {
32
40
  "h-6 w-6": size === "xxs",
33
41
  "h-8 w-8": size === "xs",
@@ -35,7 +43,7 @@ const Avatar: FC<IAvatarProps> = ({ src, status, size = "md", alt = "Avatar imag
35
43
  "h-12 w-12": size === "md",
36
44
  "h-14 w-14": size === "lg",
37
45
  "h-16 w-16": size === "xl"
38
- })
46
+ });
39
47
  const initialsStyles = cn("inline-flex items-center justify-center rounded-full bg-gray-500", {
40
48
  "h-6 w-6": size === "xxs",
41
49
  "h-8 w-8": size === "xs",
@@ -43,14 +51,14 @@ const Avatar: FC<IAvatarProps> = ({ src, status, size = "md", alt = "Avatar imag
43
51
  "h-12 w-12": size === "md",
44
52
  "h-14 w-14": size === "lg",
45
53
  "h-16 w-16": size === "xl"
46
- })
54
+ });
47
55
  const fontStyles = cn(" leading-none text-white uppercase", {
48
56
  "text-xs": size === "xxs" || size === "xs",
49
57
  "text-sm": size === "sm",
50
58
  "text-base": size === "md",
51
59
  "text-lg": size === "lg",
52
60
  "text-xl": size === "xl"
53
- })
61
+ });
54
62
  const defaultAvatarStyles = cn("inline-block rounded-full overflow-hidden bg-gray-100", {
55
63
  "h-6 w-6": size === "xxs",
56
64
  "h-8 w-8": size === "xs",
@@ -58,7 +66,7 @@ const Avatar: FC<IAvatarProps> = ({ src, status, size = "md", alt = "Avatar imag
58
66
  "h-12 w-12": size === "md",
59
67
  "h-14 w-14": size === "lg",
60
68
  "h-16 w-16": size === "xl"
61
- })
69
+ });
62
70
 
63
71
  const statusStyles = cn("absolute top-0 right-0 block rounded-full ring-2 ring-white", {
64
72
  "h-1.5 w-1.5": size === "xxs",
@@ -70,40 +78,48 @@ const Avatar: FC<IAvatarProps> = ({ src, status, size = "md", alt = "Avatar imag
70
78
  "bg-gray-300": status === "offline",
71
79
  "bg-red-400": status === "busy",
72
80
  "bg-green-400": status === "online"
73
- })
81
+ });
74
82
  const imageSize: number = useMemo(() => {
75
- let imageSize: number = 0
83
+ let imageSize: number = 0;
76
84
  switch (size) {
77
85
  case "xxs":
78
- imageSize = 24
79
- break
86
+ imageSize = 24;
87
+ break;
80
88
  case "xs":
81
- imageSize = 32
82
- break
89
+ imageSize = 32;
90
+ break;
83
91
  case "sm":
84
- imageSize = 40
85
- break
92
+ imageSize = 40;
93
+ break;
86
94
  case "md":
87
- imageSize = 48
88
- break
95
+ imageSize = 48;
96
+ break;
89
97
  case "lg":
90
- imageSize = 56
91
- break
98
+ imageSize = 56;
99
+ break;
92
100
  case "xl":
93
- imageSize = 64
94
- break
101
+ imageSize = 64;
102
+ break;
95
103
  default:
96
- imageSize = 48
97
- break
104
+ imageSize = 48;
105
+ break;
98
106
  }
99
- return imageSize
100
- }, [size])
107
+ return imageSize;
108
+ }, [size]);
101
109
 
102
110
  return (
103
111
  <span className="inline-block relative">
104
112
  {src ? (
105
113
  // eslint-disable-next-line @next/next/no-img-element
106
- <img className={imageStyles} width={imageSize} height={imageSize} src={src} alt={alt} loading="eager" />
114
+ <img
115
+ className={imageStyles}
116
+ width={imageSize}
117
+ height={imageSize}
118
+ src={src}
119
+ alt={alt}
120
+ loading="eager"
121
+ draggable={draggable}
122
+ />
107
123
  ) : initials ? (
108
124
  <span className={initialsStyles}>
109
125
  <span className={fontStyles}>{initials}</span>
@@ -117,7 +133,7 @@ const Avatar: FC<IAvatarProps> = ({ src, status, size = "md", alt = "Avatar imag
117
133
  )}
118
134
  {status && <span className={statusStyles}></span>}
119
135
  </span>
120
- )
121
- }
136
+ );
137
+ };
122
138
 
123
- export default Avatar
139
+ export default Avatar;
@@ -1,13 +1,13 @@
1
- import type { Meta, StoryObj } from "@storybook/react"
2
- import ButtonDropdown from "."
3
- import { IItemProp } from "../DropdownComponent"
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import ButtonDropdown from ".";
3
+ import { IItemProp } from "../DropdownComponent";
4
4
 
5
5
  const meta: Meta<typeof ButtonDropdown> = {
6
6
  title: "Design System/Organisms/Button Dropdown",
7
7
  component: ButtonDropdown,
8
8
  tags: ["autodocs"],
9
9
  argTypes: {}
10
- }
10
+ };
11
11
  const dropdownDataWithIcons: IItemProp[][] = [
12
12
  [
13
13
  {
@@ -34,7 +34,7 @@ const dropdownDataWithIcons: IItemProp[][] = [
34
34
  key: "Add to Batch",
35
35
  label: "Add to Batch",
36
36
  onClick: () => {
37
- console.log("Add to Batch action")
37
+ console.log("Add to Batch action");
38
38
  }
39
39
  },
40
40
  {
@@ -48,7 +48,7 @@ const dropdownDataWithIcons: IItemProp[][] = [
48
48
  key: "View Batch",
49
49
  label: "View Batch",
50
50
  onClick: () => {
51
- console.log("View Batch action")
51
+ console.log("View Batch action");
52
52
  }
53
53
  }
54
54
  ],
@@ -64,15 +64,15 @@ const dropdownDataWithIcons: IItemProp[][] = [
64
64
  key: "Delete",
65
65
  label: "Delete",
66
66
  onClick: () => {
67
- console.log("Delete action")
67
+ console.log("Delete action");
68
68
  },
69
69
  isEmphasized: true
70
70
  }
71
71
  ]
72
- ]
72
+ ];
73
73
 
74
- export default meta
75
- type Story = StoryObj<typeof ButtonDropdown>
74
+ export default meta;
75
+ type Story = StoryObj<typeof ButtonDropdown>;
76
76
 
77
77
  export const Primary: Story = {
78
78
  args: {
@@ -87,7 +87,7 @@ export const Primary: Story = {
87
87
  },
88
88
  placement: "bottom-end"
89
89
  }
90
- }
90
+ };
91
91
  export const Secondary: Story = {
92
92
  args: {
93
93
  button: {
@@ -101,7 +101,7 @@ export const Secondary: Story = {
101
101
  },
102
102
  placement: "bottom-end"
103
103
  }
104
- }
104
+ };
105
105
  export const Alternative: Story = {
106
106
  args: {
107
107
  button: {
@@ -115,4 +115,55 @@ export const Alternative: Story = {
115
115
  },
116
116
  placement: "bottom-end"
117
117
  }
118
- }
118
+ };
119
+
120
+ export const DisabledPrimary: Story = {
121
+ args: {
122
+ button: {
123
+ label: "Primary",
124
+ actionType: "primary",
125
+ disabled: true
126
+ },
127
+ dropDown: {
128
+ label: "Dropdown",
129
+ id: "dropdown-disabled-primary",
130
+ items: dropdownDataWithIcons,
131
+ disabled: true
132
+ },
133
+ placement: "bottom-end"
134
+ }
135
+ };
136
+
137
+ export const DisabledSecondary: Story = {
138
+ args: {
139
+ button: {
140
+ label: "Secondary",
141
+ actionType: "secondary",
142
+ disabled: true
143
+ },
144
+ dropDown: {
145
+ label: "Dropdown",
146
+ id: "dropdown-disabled-secondary",
147
+ items: dropdownDataWithIcons,
148
+ disabled: true
149
+ },
150
+ placement: "bottom-end"
151
+ }
152
+ };
153
+
154
+ export const DisabledAlternative: Story = {
155
+ args: {
156
+ button: {
157
+ label: "Alternative",
158
+ actionType: "alternative",
159
+ disabled: true
160
+ },
161
+ dropDown: {
162
+ label: "Dropdown",
163
+ id: "dropdown-disabled-alternative",
164
+ items: dropdownDataWithIcons,
165
+ disabled: true
166
+ },
167
+ placement: "bottom-end"
168
+ }
169
+ };
@@ -1,22 +1,33 @@
1
- import React, { FC } from "react"
2
- import { default as cn } from "classnames"
3
- import Button, { IButtonProps } from "@/stories/atoms/buttons/Button"
4
-
5
- import { DynamicIcon } from "@/stories/atoms/icons"
6
- import Dropdown, { IDropdownProps, defaultClassNames } from "../DropdownComponent"
1
+ import { FC } from "react";
2
+ import { default as cn } from "classnames";
3
+ import Button, { IButtonProps } from "@/stories/atoms/buttons/Button";
4
+ import { DynamicIcon } from "@/stories/atoms/icons";
5
+ import Dropdown, { IDropdownProps, defaultClassNames } from "../DropdownComponent";
7
6
 
8
7
  export interface IButtonDropdownProps {
9
- button: IButtonProps
10
- dropDown: IDropdownProps
11
- hideDivider?: boolean
12
- placement?: IDropdownProps["placement"]
13
- offsetOptions?: IDropdownProps["offsetOptions"]
8
+ button: IButtonProps;
9
+ dropDown: IDropdownProps;
10
+ hideDivider?: boolean;
11
+ placement?: IDropdownProps["placement"];
12
+ offsetOptions?: IDropdownProps["offsetOptions"];
14
13
  }
15
14
 
16
15
  /**
17
16
  * Primary UI component for user interaction
18
17
  */
19
- const ButtonDropdown: FC<IButtonDropdownProps> = ({ button, dropDown, hideDivider = false, placement = "bottom-end", offsetOptions }) => {
18
+ const ButtonDropdown: FC<IButtonDropdownProps> = ({
19
+ button,
20
+ dropDown,
21
+ hideDivider = false,
22
+ placement = "bottom-end",
23
+ offsetOptions
24
+ }) => {
25
+ const iconTextColours = {
26
+ primary: dropDown.disabled ? "text-gray-300" : "text-violet-100",
27
+ secondary: dropDown.disabled ? "text-gray-400" : "text-purple-700",
28
+ alternative: dropDown.disabled ? "text-gray-500" : "text-gray-700"
29
+ };
30
+
20
31
  return (
21
32
  <div className="flex items-stretch focus-within:ring-purple-600 focus-within:ring-2 focus-within:ring-offset-white focus-within:ring-offset-2 rounded-[3px]">
22
33
  <Button
@@ -29,29 +40,37 @@ const ButtonDropdown: FC<IButtonDropdownProps> = ({ button, dropDown, hideDivide
29
40
  )
30
41
  }}
31
42
  />
32
- {!hideDivider && <div
33
- className={cn(
34
- "w-[1px] rt",
35
- button.actionType === "primary"
36
- ? "bg-violet-700 text-violet-100 hover:border-violet-700 hover:bg-violet-700 disabled:bg-violet-400 disabled:focus-visible:ring-0"
37
- : "",
38
- button.actionType === "secondary" ? "bg-purple-200 " : "",
39
- button.actionType === "alternative" ? "bg-gray-300" : ""
40
- )}
41
- ></div>}
43
+ {!hideDivider && (
44
+ <div
45
+ className={cn(
46
+ "w-[1px] rt",
47
+ button.actionType === "primary"
48
+ ? "bg-violet-700 text-violet-100 hover:border-violet-700 hover:bg-violet-700 disabled:bg-violet-400 disabled:focus-visible:ring-0"
49
+ : "",
50
+ button.actionType === "secondary" ? "bg-purple-200 " : "",
51
+ button.actionType === "alternative" ? "bg-gray-300" : ""
52
+ )}
53
+ ></div>
54
+ )}
42
55
  <Dropdown
43
56
  {...{
44
57
  CustomDropdownTrigger: (
45
58
  <DynamicIcon
46
59
  {...{
47
60
  icon: "IconChevronDown",
48
- className: cn("h-5 w-5", {
49
- "text-violet-100": button.actionType === "primary",
50
- "text-purple-700 ": button.actionType === "secondary",
51
- "text-gray-700": button.actionType === "alternative"
52
- },
53
- dropDown.iconClassname
54
- ),
61
+ className: cn(
62
+ "h-5 w-5 disabled:!bg-gray-50 disabled:focus-visible:ring-0",
63
+ {
64
+ "text-white": dropDown.disabled && button.actionType === "primary",
65
+ "text-purple-300": dropDown.disabled && button.actionType === "secondary",
66
+ "text-gray-300": dropDown.disabled && button.actionType === "alternative",
67
+
68
+ "text-violet-100": !dropDown.disabled && button.actionType === "primary",
69
+ "text-purple-700": !dropDown.disabled && button.actionType === "secondary",
70
+ "text-gray-700": !dropDown.disabled && button.actionType === "alternative"
71
+ },
72
+ dropDown.iconClassname
73
+ )
55
74
  }}
56
75
  />
57
76
  ),
@@ -72,7 +91,7 @@ const ButtonDropdown: FC<IButtonDropdownProps> = ({ button, dropDown, hideDivide
72
91
  button.actionType === "alternative"
73
92
  ? cn(
74
93
  "border-gray-300 bg-white text-gray-700 fill-gray-700 hover:border-gray-300 hover:bg-gray-50 active:bg-gray-100",
75
- "disabled:bg-gray-100 disabled:text-gray-500 disabled:hover:none disabled:active:bg-gray-100 disabled:border-gray-300"
94
+ "disabled:bg-gray-50 disabled:text-gray-300 disabled:hover:none disabled:active:bg-gray-100 disabled:border-gray-300"
76
95
  )
77
96
  : "",
78
97
  dropDown.buttonClassname
@@ -83,11 +102,11 @@ const ButtonDropdown: FC<IButtonDropdownProps> = ({ button, dropDown, hideDivide
83
102
  alignmentAxis: 0 //left/right
84
103
  },
85
104
  placement,
86
- ...(dropDown as IDropdownProps),
105
+ ...(dropDown as IDropdownProps)
87
106
  }}
88
107
  />
89
108
  <div className="hidden !bg-purple-100 !text-purple-600 transition-all hover:bg-purple-200 focus:bg-purple-300" />
90
109
  </div>
91
- )
92
- }
93
- export default ButtonDropdown
110
+ );
111
+ };
112
+ export default ButtonDropdown;