@agility/plenum-ui 2.1.21 → 2.1.23-rc1
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/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/tailwind.css +3 -8
- package/package.json +1 -1
- package/stories/molecules/inputs/radio/Radio.tsx +35 -35
- package/stories/organisms/ButtonDropdown/ButtonDropdown.stories.tsx +64 -13
- package/stories/organisms/ButtonDropdown/ButtonDropdown.tsx +53 -34
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
|
|
79284
|
-
--tw-bg-opacity: 1;
|
|
79285
|
-
background-color: rgb(
|
|
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));
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import InputLabel from "@/stories/molecules/inputs/InputLabel"
|
|
2
|
-
import { useId } from "@/utils/useId"
|
|
3
|
-
import React from "react"
|
|
4
|
-
import { default as cn } from "classnames"
|
|
1
|
+
import InputLabel from "@/stories/molecules/inputs/InputLabel";
|
|
2
|
+
import { useId } from "@/utils/useId";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { default as cn } from "classnames";
|
|
5
5
|
export interface IRadioProps {
|
|
6
6
|
/** group name */
|
|
7
|
-
name?: string
|
|
7
|
+
name?: string;
|
|
8
8
|
/** Radio label */
|
|
9
|
-
label: string
|
|
9
|
+
label: string;
|
|
10
10
|
/** Radio ID */
|
|
11
|
-
id?: string
|
|
11
|
+
id?: string;
|
|
12
12
|
/** Disabled state */
|
|
13
|
-
isDisabled?: boolean
|
|
13
|
+
isDisabled?: boolean;
|
|
14
14
|
/** Check state */
|
|
15
|
-
isChecked?: boolean
|
|
15
|
+
isChecked?: boolean;
|
|
16
16
|
/** If field is required */
|
|
17
|
-
isRequired?: boolean
|
|
17
|
+
isRequired?: boolean;
|
|
18
18
|
/** Error state */
|
|
19
|
-
isError?: boolean
|
|
19
|
+
isError?: boolean;
|
|
20
20
|
/** Message or description */
|
|
21
|
-
message?: string
|
|
21
|
+
message?: string;
|
|
22
22
|
/** value */
|
|
23
|
-
value?: string
|
|
23
|
+
value?: string;
|
|
24
24
|
/** Callback on input change */
|
|
25
|
-
onChange?(value: string, isChecked: boolean): void
|
|
25
|
+
onChange?(value: string, isChecked: boolean): void;
|
|
26
26
|
/** Callback on click */
|
|
27
|
-
onClick?(value: string, isChecked: boolean): void
|
|
27
|
+
onClick?(value: string, isChecked: boolean): void;
|
|
28
28
|
}
|
|
29
29
|
const Radio: React.FC<IRadioProps> = ({
|
|
30
30
|
label,
|
|
@@ -39,24 +39,24 @@ const Radio: React.FC<IRadioProps> = ({
|
|
|
39
39
|
onClick,
|
|
40
40
|
value
|
|
41
41
|
}) => {
|
|
42
|
-
const uniqueID = useId()
|
|
43
|
-
if (!id) id = `input-${uniqueID}
|
|
44
|
-
if (!name) name = id
|
|
42
|
+
const uniqueID = useId();
|
|
43
|
+
if (!id) id = `input-${uniqueID}`;
|
|
44
|
+
if (!name) name = id;
|
|
45
45
|
|
|
46
|
-
const checboxStyles = cn("focus:ring-purple-500 h-4 w-4 text-
|
|
46
|
+
const checboxStyles = cn("focus:ring-purple-500 h-4 w-4 text-blue-600 border-gray-300", {
|
|
47
47
|
"border-red-500 shadow-none": isError
|
|
48
|
-
})
|
|
49
|
-
const wrapperStyles = cn("relative flex items-start", { "opacity-50": isDisabled })
|
|
48
|
+
});
|
|
49
|
+
const wrapperStyles = cn("relative flex items-start", { "opacity-50": isDisabled });
|
|
50
50
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
51
|
-
const targetValue = e.currentTarget.value
|
|
52
|
-
const targetChecked = e.currentTarget.checked
|
|
53
|
-
typeof onChange === "function" && onChange(targetValue, targetChecked)
|
|
54
|
-
}
|
|
51
|
+
const targetValue = e.currentTarget.value;
|
|
52
|
+
const targetChecked = e.currentTarget.checked;
|
|
53
|
+
typeof onChange === "function" && onChange(targetValue, targetChecked);
|
|
54
|
+
};
|
|
55
55
|
const handleClick = (e: React.MouseEvent<HTMLInputElement>) => {
|
|
56
|
-
const targetValue = e.currentTarget.value
|
|
57
|
-
const targetChecked = e.currentTarget.checked
|
|
58
|
-
typeof onClick === "function" && onClick(targetValue, targetChecked)
|
|
59
|
-
}
|
|
56
|
+
const targetValue = e.currentTarget.value;
|
|
57
|
+
const targetChecked = e.currentTarget.checked;
|
|
58
|
+
typeof onClick === "function" && onClick(targetValue, targetChecked);
|
|
59
|
+
};
|
|
60
60
|
return (
|
|
61
61
|
<div className={wrapperStyles}>
|
|
62
62
|
<div className="flex items-center h-5">
|
|
@@ -68,12 +68,12 @@ const Radio: React.FC<IRadioProps> = ({
|
|
|
68
68
|
value={value}
|
|
69
69
|
className={checboxStyles}
|
|
70
70
|
disabled={isDisabled}
|
|
71
|
-
|
|
71
|
+
checked={isChecked}
|
|
72
72
|
onChange={(e) => {
|
|
73
|
-
handleChange(e)
|
|
73
|
+
handleChange(e);
|
|
74
74
|
}}
|
|
75
75
|
onClick={(e) => {
|
|
76
|
-
handleClick(e)
|
|
76
|
+
handleClick(e);
|
|
77
77
|
}}
|
|
78
78
|
/>
|
|
79
79
|
</div>
|
|
@@ -86,7 +86,7 @@ const Radio: React.FC<IRadioProps> = ({
|
|
|
86
86
|
)}
|
|
87
87
|
</div>
|
|
88
88
|
</div>
|
|
89
|
-
)
|
|
90
|
-
}
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
91
|
|
|
92
|
-
export default Radio
|
|
92
|
+
export default Radio;
|
|
@@ -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
|
|
2
|
-
import { default as cn } from "classnames"
|
|
3
|
-
import Button, { IButtonProps } from "@/stories/atoms/buttons/Button"
|
|
4
|
-
|
|
5
|
-
import {
|
|
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> = ({
|
|
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 &&
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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(
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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-
|
|
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;
|