@agility/plenum-ui 2.0.0 → 2.0.2
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.d.ts +3 -18
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/tailwind.css +45 -11
- package/dist/types/stories/molecules/inputs/checkbox/Checkbox.d.ts +2 -0
- package/dist/types/stories/organisms/DropdownComponent/dropdownItems.d.ts +1 -0
- package/package.json +2 -2
- package/stories/molecules/inputs/InputLabel/InputLabel.tsx +5 -5
- package/stories/molecules/inputs/TextInput/TextInput.stories.tsx +31 -1
- package/stories/molecules/inputs/TextInput/TextInput.tsx +5 -3
- package/stories/molecules/inputs/checkbox/Checkbox.tsx +6 -2
- package/stories/molecules/inputs/select/Select.stories.tsx +53 -0
- package/stories/molecules/inputs/select/Select.tsx +1 -1
- package/stories/molecules/inputs/textArea/{TextArea.stories.ts → TextArea.stories.tsx} +24 -1
- package/stories/molecules/inputs/textArea/TextArea.tsx +1 -1
- package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.stories.tsx +22 -1
- package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.tsx +21 -8
- package/stories/organisms/DropdownComponent/Dropdown.stories.tsx +7 -2
- package/stories/organisms/DropdownComponent/DropdownComponent.tsx +14 -3
- package/stories/organisms/DropdownComponent/dropdownItems.ts +38 -32
- package/tailwind.config.js +57 -0
- package/dist/types/stories/molecules/inputs/select/Select.stories.d.ts +0 -6
- package/dist/types/stories/molecules/inputs/textArea/TextArea.stories.d.ts +0 -6
- package/stories/molecules/inputs/select/Select.stories.ts +0 -23
package/dist/tailwind.css
CHANGED
|
@@ -3093,17 +3093,6 @@ select {
|
|
|
3093
3093
|
margin-left: calc(0.75rem * calc(1 - var(--tw-space-x-reverse)));
|
|
3094
3094
|
}
|
|
3095
3095
|
|
|
3096
|
-
.divide-y > :not([hidden]) ~ :not([hidden]) {
|
|
3097
|
-
--tw-divide-y-reverse: 0;
|
|
3098
|
-
border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
|
|
3099
|
-
border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
|
|
3100
|
-
}
|
|
3101
|
-
|
|
3102
|
-
.divide-gray-100 > :not([hidden]) ~ :not([hidden]) {
|
|
3103
|
-
--tw-divide-opacity: 1;
|
|
3104
|
-
border-color: rgb(243 244 246 / var(--tw-divide-opacity));
|
|
3105
|
-
}
|
|
3106
|
-
|
|
3107
3096
|
.overflow-auto {
|
|
3108
3097
|
overflow: auto;
|
|
3109
3098
|
}
|
|
@@ -3182,6 +3171,22 @@ select {
|
|
|
3182
3171
|
border-bottom-right-radius: 0.25rem;
|
|
3183
3172
|
}
|
|
3184
3173
|
|
|
3174
|
+
.rounded-bl {
|
|
3175
|
+
border-bottom-left-radius: 0.25rem;
|
|
3176
|
+
}
|
|
3177
|
+
|
|
3178
|
+
.rounded-br {
|
|
3179
|
+
border-bottom-right-radius: 0.25rem;
|
|
3180
|
+
}
|
|
3181
|
+
|
|
3182
|
+
.rounded-tl {
|
|
3183
|
+
border-top-left-radius: 0.25rem;
|
|
3184
|
+
}
|
|
3185
|
+
|
|
3186
|
+
.rounded-tr {
|
|
3187
|
+
border-top-right-radius: 0.25rem;
|
|
3188
|
+
}
|
|
3189
|
+
|
|
3185
3190
|
.border {
|
|
3186
3191
|
border-width: 1px;
|
|
3187
3192
|
}
|
|
@@ -3202,6 +3207,10 @@ select {
|
|
|
3202
3207
|
border-right-width: 0px !important;
|
|
3203
3208
|
}
|
|
3204
3209
|
|
|
3210
|
+
.border-b {
|
|
3211
|
+
border-bottom-width: 1px;
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3205
3214
|
.border-dashed {
|
|
3206
3215
|
border-style: dashed;
|
|
3207
3216
|
}
|
|
@@ -48800,6 +48809,10 @@ select {
|
|
|
48800
48809
|
background-color: rgb(19 78 74 / 0.95);
|
|
48801
48810
|
}
|
|
48802
48811
|
|
|
48812
|
+
.bg-transparent-black-03 {
|
|
48813
|
+
background-color: rgba(0, 0, 0, 0.03);
|
|
48814
|
+
}
|
|
48815
|
+
|
|
48803
48816
|
.bg-violet-100 {
|
|
48804
48817
|
--tw-bg-opacity: 1;
|
|
48805
48818
|
background-color: rgb(237 233 254 / var(--tw-bg-opacity));
|
|
@@ -50105,6 +50118,10 @@ select {
|
|
|
50105
50118
|
background-color: rgb(128 102 20 / 0.95);
|
|
50106
50119
|
}
|
|
50107
50120
|
|
|
50121
|
+
.bg-label-gradient-idle {
|
|
50122
|
+
background-image: linear-gradient(to top, #FFF 8px, transparent 8px);
|
|
50123
|
+
}
|
|
50124
|
+
|
|
50108
50125
|
.from-0\% {
|
|
50109
50126
|
--tw-gradient-from-position: 0%;
|
|
50110
50127
|
}
|
|
@@ -50205,6 +50222,10 @@ select {
|
|
|
50205
50222
|
padding: 14rem;
|
|
50206
50223
|
}
|
|
50207
50224
|
|
|
50225
|
+
.p-6 {
|
|
50226
|
+
padding: 1.5rem;
|
|
50227
|
+
}
|
|
50228
|
+
|
|
50208
50229
|
.p-60 {
|
|
50209
50230
|
padding: 15rem;
|
|
50210
50231
|
}
|
|
@@ -58588,6 +58609,11 @@ select {
|
|
|
58588
58609
|
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
|
58589
58610
|
}
|
|
58590
58611
|
|
|
58612
|
+
.\!ring-gray-300 {
|
|
58613
|
+
--tw-ring-opacity: 1 !important;
|
|
58614
|
+
--tw-ring-color: rgb(209 213 219 / var(--tw-ring-opacity)) !important;
|
|
58615
|
+
}
|
|
58616
|
+
|
|
58591
58617
|
.\!ring-purple-500 {
|
|
58592
58618
|
--tw-ring-opacity: 1 !important;
|
|
58593
58619
|
--tw-ring-color: rgb(121 51 221 / var(--tw-ring-opacity)) !important;
|
|
@@ -59071,6 +59097,14 @@ select {
|
|
|
59071
59097
|
margin-left: .172rem !important;
|
|
59072
59098
|
}
|
|
59073
59099
|
|
|
59100
|
+
.group:focus-within .group-focus-within\:\!bg-label-gradient-focus {
|
|
59101
|
+
background-image: linear-gradient(to top, #FFF 9px, transparent 9px) !important;
|
|
59102
|
+
}
|
|
59103
|
+
|
|
59104
|
+
.group:focus-within .group-focus-within\:bg-label-gradient-focus {
|
|
59105
|
+
background-image: linear-gradient(to top, #FFF 9px, transparent 9px);
|
|
59106
|
+
}
|
|
59107
|
+
|
|
59074
59108
|
.group:focus-within .group-focus-within\:\!text-xs {
|
|
59075
59109
|
font-size: 0.75rem !important;
|
|
59076
59110
|
line-height: 1rem !important;
|
|
@@ -22,6 +22,8 @@ export interface ICheckboxProps {
|
|
|
22
22
|
hasBorder?: boolean;
|
|
23
23
|
/** any arbitrary classNames to add to the wrapper */
|
|
24
24
|
className?: string;
|
|
25
|
+
/** Label ClassName */
|
|
26
|
+
labelClassName?: string;
|
|
25
27
|
}
|
|
26
28
|
/** Comment */
|
|
27
29
|
declare const Checkbox: FC<ICheckboxProps>;
|
package/package.json
CHANGED
|
@@ -24,13 +24,13 @@ const InputLabel: FC<IInputLabelProps> = ({
|
|
|
24
24
|
label
|
|
25
25
|
}: IInputLabelProps) => {
|
|
26
26
|
const labelStyles = cn(
|
|
27
|
-
"z-[2]",
|
|
28
|
-
{ "inline-block font-medium transition-all text-sm text-gray-700
|
|
27
|
+
"z-[2] bg-label-gradient-idle group-focus-within:bg-label-gradient-focus",
|
|
28
|
+
{ "inline-block font-medium transition-all text-sm text-gray-700 ": !isPlaceholder },
|
|
29
29
|
{ "inline-block font-medium ml-2 relative transition-all": isPlaceholder },
|
|
30
30
|
{ "text-sm text-gray-400 px-2 top-8": isPlaceholder && !isActive },
|
|
31
|
-
{ "text-xs text-gray-700 px-1 top-[10px]
|
|
32
|
-
{ "text-xs text-red-500 px-1 top-[10px]
|
|
33
|
-
{ "text-red-500
|
|
31
|
+
{ "text-xs text-gray-700 px-1 top-[10px] ": isPlaceholder && isActive },
|
|
32
|
+
{ "text-xs text-red-500 px-1 top-[10px] ": isPlaceholder && isError },
|
|
33
|
+
{ "text-red-500 ": !isPlaceholder && isError },
|
|
34
34
|
{ "text-gray-500/[.5]": isDisabled }
|
|
35
35
|
)
|
|
36
36
|
if (!label) return null
|
|
@@ -6,7 +6,19 @@ const meta: Meta<typeof TextInput> = {
|
|
|
6
6
|
title: "Design System/molecules/inputs/TextInput",
|
|
7
7
|
component: TextInput,
|
|
8
8
|
tags: ["autodocs"],
|
|
9
|
-
argTypes: {}
|
|
9
|
+
argTypes: {},
|
|
10
|
+
decorators: [
|
|
11
|
+
(Story, context) => {
|
|
12
|
+
if (context.name === "Default Text Input Story Dark BG") {
|
|
13
|
+
return (
|
|
14
|
+
<div className="bg-transparent-black-03 rounded p-6">
|
|
15
|
+
<Story />
|
|
16
|
+
</div>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
return <Story />
|
|
20
|
+
}
|
|
21
|
+
]
|
|
10
22
|
}
|
|
11
23
|
|
|
12
24
|
export default meta
|
|
@@ -30,3 +42,21 @@ export const DefaultTextInputStory: Story = {
|
|
|
30
42
|
placeholder: "placeholder"
|
|
31
43
|
}
|
|
32
44
|
}
|
|
45
|
+
export const DefaultTextInputStoryDarkBG: Story = {
|
|
46
|
+
args: {
|
|
47
|
+
type: "text",
|
|
48
|
+
label: "Label",
|
|
49
|
+
isFocused: true,
|
|
50
|
+
isError: false,
|
|
51
|
+
id: "id",
|
|
52
|
+
name: "name",
|
|
53
|
+
isRequired: true,
|
|
54
|
+
|
|
55
|
+
isDisabled: false,
|
|
56
|
+
isReadonly: false,
|
|
57
|
+
message: "message",
|
|
58
|
+
isShowCounter: true,
|
|
59
|
+
maxLength: 100,
|
|
60
|
+
placeholder: "placeholder"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -86,6 +86,7 @@ const TextInput = (
|
|
|
86
86
|
} else {
|
|
87
87
|
input.blur()
|
|
88
88
|
}
|
|
89
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
89
90
|
}, [isFocus])
|
|
90
91
|
|
|
91
92
|
// set label as active if default value is set
|
|
@@ -103,7 +104,7 @@ const TextInput = (
|
|
|
103
104
|
if (!name) name = id
|
|
104
105
|
|
|
105
106
|
return (
|
|
106
|
-
<div className="relative">
|
|
107
|
+
<div className="relative group">
|
|
107
108
|
<InputLabel
|
|
108
109
|
isPlaceholder={true}
|
|
109
110
|
label={label}
|
|
@@ -128,13 +129,14 @@ const TextInput = (
|
|
|
128
129
|
"w-full rounded border py-2 px-3 text-sm font-normal leading-5",
|
|
129
130
|
{ "border-gray-300": !isFocus && !isError && !isDisabled },
|
|
130
131
|
{
|
|
131
|
-
"!border-purple-500 shadow-none outline-purple-500 focus:!ring-purple-500":
|
|
132
|
+
"!border-purple-500 shadow-none outline-purple-500 focus:!ring-purple-500":
|
|
133
|
+
isFocus && !isError && !isDisabled
|
|
132
134
|
},
|
|
133
135
|
{
|
|
134
136
|
"!border-red-500 shadow-none focus:ring-red-500": isError
|
|
135
137
|
},
|
|
136
138
|
{
|
|
137
|
-
"placeholder:text-gray-300 !border-gray-300 !outline-gray-300 focus:!ring-gray-300"
|
|
139
|
+
"placeholder:text-gray-300 !border-gray-300 !outline-gray-300 focus:!ring-gray-300": isDisabled
|
|
138
140
|
},
|
|
139
141
|
className
|
|
140
142
|
)}
|
|
@@ -26,6 +26,8 @@ export interface ICheckboxProps {
|
|
|
26
26
|
hasBorder?: boolean
|
|
27
27
|
/** any arbitrary classNames to add to the wrapper */
|
|
28
28
|
className?: string
|
|
29
|
+
/** Label ClassName */
|
|
30
|
+
labelClassName?: string
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
/** Comment */
|
|
@@ -41,6 +43,7 @@ const Checkbox: FC<ICheckboxProps> = ({
|
|
|
41
43
|
onChange,
|
|
42
44
|
hasBorder,
|
|
43
45
|
className,
|
|
46
|
+
labelClassName,
|
|
44
47
|
...props
|
|
45
48
|
}: ICheckboxProps) => {
|
|
46
49
|
const uniqueID = useId()
|
|
@@ -83,9 +86,10 @@ const Checkbox: FC<ICheckboxProps> = ({
|
|
|
83
86
|
/>
|
|
84
87
|
</div>
|
|
85
88
|
<div className="ml-3 text-sm ">
|
|
86
|
-
|
|
89
|
+
<>
|
|
87
90
|
<InputLabel label={label} isRequired={isRequired} id={id} />
|
|
88
|
-
|
|
91
|
+
</>
|
|
92
|
+
|
|
89
93
|
{message && (
|
|
90
94
|
<p id={`${id}-description`} className="text-gray-500">
|
|
91
95
|
{message}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import Select from "./Select"
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Select> = {
|
|
5
|
+
title: "Design System/Molecules/Inputs/Select",
|
|
6
|
+
component: Select,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
argTypes: {},
|
|
9
|
+
decorators: [
|
|
10
|
+
(Story, context) => {
|
|
11
|
+
if (context.name === "Default Select Dark BG") {
|
|
12
|
+
return (
|
|
13
|
+
<div className="bg-transparent-black-03 rounded p-6">
|
|
14
|
+
<Story />
|
|
15
|
+
</div>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
return <Story />
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default meta
|
|
24
|
+
type TStory = StoryObj<typeof Select>
|
|
25
|
+
|
|
26
|
+
export const DefaultSelect: TStory = {
|
|
27
|
+
args: {
|
|
28
|
+
label: "Label",
|
|
29
|
+
id: "select",
|
|
30
|
+
name: "select",
|
|
31
|
+
options: [
|
|
32
|
+
{ label: "Canada", value: "value1" },
|
|
33
|
+
{ label: "USA", value: "value2" }
|
|
34
|
+
],
|
|
35
|
+
isDisabled: false,
|
|
36
|
+
isError: false,
|
|
37
|
+
isRequired: false
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export const DefaultSelectDarkBG: TStory = {
|
|
41
|
+
args: {
|
|
42
|
+
label: "Label",
|
|
43
|
+
id: "select",
|
|
44
|
+
name: "select",
|
|
45
|
+
options: [
|
|
46
|
+
{ label: "Canada", value: "value1" },
|
|
47
|
+
{ label: "USA", value: "value2" }
|
|
48
|
+
],
|
|
49
|
+
isDisabled: false,
|
|
50
|
+
isError: false,
|
|
51
|
+
isRequired: false
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -63,7 +63,7 @@ const Select: React.FC<ISelectProps> = ({
|
|
|
63
63
|
typeof onChange == "function" && onChange(targetValue)
|
|
64
64
|
setSelectedOption(targetValue)
|
|
65
65
|
}
|
|
66
|
-
const wrapperStyle = cn({ "opacity-50": isDisabled })
|
|
66
|
+
const wrapperStyle = cn("group", { "opacity-50": isDisabled })
|
|
67
67
|
return (
|
|
68
68
|
<div className={wrapperStyle}>
|
|
69
69
|
{label && (
|
|
@@ -3,7 +3,20 @@ import Textarea from "./TextArea"
|
|
|
3
3
|
const meta: Meta<typeof Textarea> = {
|
|
4
4
|
title: "Design System/Molecules/Inputs/TextArea",
|
|
5
5
|
component: Textarea,
|
|
6
|
-
tags: ["autodocs"]
|
|
6
|
+
tags: ["autodocs"],
|
|
7
|
+
argTypes: {},
|
|
8
|
+
decorators: [
|
|
9
|
+
(Story, context) => {
|
|
10
|
+
if (context.name === "Default Textarea Dark BG") {
|
|
11
|
+
return (
|
|
12
|
+
<div className="bg-transparent-black-03 rounded p-6">
|
|
13
|
+
<Story />
|
|
14
|
+
</div>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
return <Story />
|
|
18
|
+
}
|
|
19
|
+
]
|
|
7
20
|
}
|
|
8
21
|
const dummyText: string = `Checkmate... Life finds a way. Is this my espresso machine? Wh-what is-h-how did you get my espresso machine? You're a very talented young man, with your own clever thoughts and ideas. Do you need a manager? Is this my espresso machine? Wh-what is-h-how did you get my espresso machine?
|
|
9
22
|
|
|
@@ -19,4 +32,14 @@ export const DefaultTextarea: Story = {
|
|
|
19
32
|
placeholder: dummyText
|
|
20
33
|
}
|
|
21
34
|
}
|
|
35
|
+
export const DefaultTextareaDarkBG: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
id: "appDescription",
|
|
38
|
+
name: "description",
|
|
39
|
+
rows: 12,
|
|
40
|
+
cols: 18,
|
|
41
|
+
label: { display: "Description" },
|
|
42
|
+
placeholder: dummyText
|
|
43
|
+
}
|
|
44
|
+
}
|
|
22
45
|
export default meta
|
|
@@ -5,7 +5,19 @@ const meta: Meta<typeof AnimatedLabelInput> = {
|
|
|
5
5
|
title: "Design System/organisms/Animated Label Input",
|
|
6
6
|
component: AnimatedLabelInput,
|
|
7
7
|
tags: ["autodocs"],
|
|
8
|
-
argTypes: {}
|
|
8
|
+
argTypes: {},
|
|
9
|
+
decorators: [
|
|
10
|
+
(Story, context) => {
|
|
11
|
+
if (context.name === "Default Animated Label Inputs Dark BG Story") {
|
|
12
|
+
return (
|
|
13
|
+
<div className="bg-transparent-black-03 p-6">
|
|
14
|
+
<Story />
|
|
15
|
+
</div>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
return <Story />
|
|
19
|
+
}
|
|
20
|
+
]
|
|
9
21
|
}
|
|
10
22
|
|
|
11
23
|
export default meta
|
|
@@ -18,6 +30,15 @@ export const DefaultAnimatedLabelInputsStory: Story = {
|
|
|
18
30
|
}
|
|
19
31
|
} as IAnimatedLabelInputProps
|
|
20
32
|
}
|
|
33
|
+
export const DefaultAnimatedLabelInputsDarkBGStory: Story = {
|
|
34
|
+
args: {
|
|
35
|
+
id: "test",
|
|
36
|
+
label: {
|
|
37
|
+
display: "Label with Dark BG"
|
|
38
|
+
},
|
|
39
|
+
value: "Value"
|
|
40
|
+
} as IAnimatedLabelInputProps
|
|
41
|
+
}
|
|
21
42
|
|
|
22
43
|
export const DefaultAnimatedLabelInputsStoryWithPlaceHolder: Story = {
|
|
23
44
|
args: {
|
|
@@ -20,7 +20,19 @@ export interface IAnimatedLabelInputProps extends Omit<IInputFieldProps, "handle
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const AnimatedLabelInput: React.FC<IAnimatedLabelInputProps> = (props: IAnimatedLabelInputProps) => {
|
|
23
|
-
const {
|
|
23
|
+
const {
|
|
24
|
+
id,
|
|
25
|
+
containerStyles,
|
|
26
|
+
message,
|
|
27
|
+
required,
|
|
28
|
+
isError,
|
|
29
|
+
label,
|
|
30
|
+
value,
|
|
31
|
+
isShowCounter,
|
|
32
|
+
maxLength,
|
|
33
|
+
handleChange,
|
|
34
|
+
...input
|
|
35
|
+
} = props
|
|
24
36
|
|
|
25
37
|
const [hasValue, setHasValue] = React.useState<boolean>(!!value)
|
|
26
38
|
const [valueLength, setValueLength] = React.useState<number>(0)
|
|
@@ -39,20 +51,21 @@ const AnimatedLabelInput: React.FC<IAnimatedLabelInputProps> = (props: IAnimated
|
|
|
39
51
|
}}
|
|
40
52
|
{...input}
|
|
41
53
|
/>
|
|
42
|
-
<
|
|
54
|
+
<div
|
|
43
55
|
className={cn(
|
|
44
|
-
"absolute z-10 ml-[3px] inline-block bg-
|
|
56
|
+
"absolute z-10 ml-[3px] inline-block bg-label-gradient-idle text-sm transition-all text-gray-500 left-1 px-1",
|
|
45
57
|
hasValue ? "!-top-[8px] !ml-[.172rem] !text-xs text-gray-600" : "top-[9px]",
|
|
46
58
|
"peer-placeholder-shown:!-top-[8px] peer-placeholder-shown:!ml-[.172rem] peer-placeholder-shown:!text-xs peer-placeholder-shown:text-gray-600",
|
|
47
|
-
"group-focus-within:!-top-[8px] group-focus-within:!ml-[.172rem] group-focus-within:!text-xs group-focus-within:text-gray-600",
|
|
59
|
+
"group-focus-within:!-top-[8px] group-focus-within:!bg-label-gradient-focus group-focus-within:!ml-[.172rem] group-focus-within:!text-xs group-focus-within:text-gray-600",
|
|
48
60
|
|
|
49
61
|
isError && "!text-red-600"
|
|
50
62
|
)}
|
|
51
|
-
htmlFor={id}
|
|
52
63
|
>
|
|
53
|
-
{
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
<label htmlFor={id}>
|
|
65
|
+
{label.display}
|
|
66
|
+
{required && <span className="text-red-600 ml-1">*</span>}
|
|
67
|
+
</label>
|
|
68
|
+
</div>
|
|
56
69
|
|
|
57
70
|
<div className="flex flex-row space-x-3">
|
|
58
71
|
<div className="grow">
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
2
|
|
|
3
3
|
import { DynamicIcon } from "@/stories/atoms/icons"
|
|
4
|
-
import { dropdownDataBase, dropdownDataWithIcons } from "./dropdownItems"
|
|
4
|
+
import { dropdownDataBase, dropdownDataWithIcons, multipleGroups } from "./dropdownItems"
|
|
5
5
|
import Dropdown, { defaultClassNames } from "./DropdownComponent"
|
|
6
6
|
|
|
7
7
|
const meta: Meta<typeof Dropdown> = {
|
|
@@ -18,7 +18,6 @@ const IconElement = () => (
|
|
|
18
18
|
const defaultArgs: Story["args"] = {
|
|
19
19
|
items: [...dropdownDataBase],
|
|
20
20
|
label: "Dropdown",
|
|
21
|
-
|
|
22
21
|
placement: "bottom-end"
|
|
23
22
|
}
|
|
24
23
|
export const WithLabel: Story = {
|
|
@@ -26,6 +25,12 @@ export const WithLabel: Story = {
|
|
|
26
25
|
...defaultArgs
|
|
27
26
|
}
|
|
28
27
|
}
|
|
28
|
+
export const MultipleGroups: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
...defaultArgs,
|
|
31
|
+
items: multipleGroups
|
|
32
|
+
}
|
|
33
|
+
}
|
|
29
34
|
|
|
30
35
|
export const CustomTrigger: Story = {
|
|
31
36
|
args: {
|
|
@@ -57,8 +57,7 @@ export interface IDropdownProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
57
57
|
}
|
|
58
58
|
export const defaultClassNames = {
|
|
59
59
|
groupClassname: "flex inline-block text-left",
|
|
60
|
-
itemsClassname:
|
|
61
|
-
"mt-2 origin-bottom-right rounded bg-white shadow-lg z-[99999] divide-y divide-gray-100 border border-gray-300 ",
|
|
60
|
+
itemsClassname: "mt-2 origin-bottom-right rounded bg-white shadow-lg z-[99999] border border-gray-300 ",
|
|
62
61
|
itemClassname:
|
|
63
62
|
"group flex font-muli cursor-pointer items-center px-4 py-2 text-sm transition-all hover:bg-gray-100 hover:text-gray-900 justify-between gap-4 ",
|
|
64
63
|
activeItemClassname: "block px-4 py-2 text-sm text-gray-700 bg-gray-100 hover:bg-gray-200 hover:text-gray-900",
|
|
@@ -176,7 +175,19 @@ const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
176
175
|
{...{
|
|
177
176
|
key: key,
|
|
178
177
|
id: key.toString(),
|
|
179
|
-
className: cn(
|
|
178
|
+
className: cn(
|
|
179
|
+
itemClass,
|
|
180
|
+
//Round the corners of the first item in the first stack and the last item in the last stack
|
|
181
|
+
itemIndex === 0 && stackIndex === 0 && "rounded-tl rounded-tr",
|
|
182
|
+
itemIndex === itemStack.length - 1 &&
|
|
183
|
+
stackIndex === items.length - 1 &&
|
|
184
|
+
"rounded-bl rounded-br",
|
|
185
|
+
//Add dividing line between stacks
|
|
186
|
+
stackIndex !== items.length - 1 &&
|
|
187
|
+
itemIndex === itemStack.length - 1 &&
|
|
188
|
+
"border-b border-b-gray-100",
|
|
189
|
+
"w-full"
|
|
190
|
+
),
|
|
180
191
|
...rest,
|
|
181
192
|
...getItemProps(),
|
|
182
193
|
onClick: () => {
|
|
@@ -3,26 +3,26 @@ import { IItemProp } from "./DropdownComponent"
|
|
|
3
3
|
export const dropdownDataBase: IItemProp[][] = [
|
|
4
4
|
[
|
|
5
5
|
{
|
|
6
|
-
icon: {
|
|
7
|
-
icon: "IconCopy"
|
|
8
|
-
// pos: "leading",
|
|
9
|
-
// className: "h-5 w-5",
|
|
10
|
-
// outline: false
|
|
11
|
-
},
|
|
6
|
+
icon: { icon: "IconCopy" },
|
|
12
7
|
key: "Copy",
|
|
13
8
|
label: "Copy to Clipboard",
|
|
14
9
|
onClick: () => {
|
|
15
10
|
console.log("Copy action")
|
|
16
11
|
}
|
|
17
12
|
},
|
|
18
|
-
|
|
19
13
|
{
|
|
20
|
-
icon: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// outline: false
|
|
14
|
+
icon: { icon: "IconTrash" },
|
|
15
|
+
label: "Delete",
|
|
16
|
+
onClick: () => {
|
|
17
|
+
console.log("Delete action")
|
|
25
18
|
},
|
|
19
|
+
isEmphasized: true,
|
|
20
|
+
key: "Delete"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
{
|
|
25
|
+
icon: { icon: "IconPlus" },
|
|
26
26
|
key: "Add to Batch",
|
|
27
27
|
label: "Add to Batch",
|
|
28
28
|
onClick: () => {
|
|
@@ -30,35 +30,41 @@ export const dropdownDataBase: IItemProp[][] = [
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
|
-
icon: {
|
|
34
|
-
icon: "IconEye"
|
|
35
|
-
// pos: "leading",
|
|
36
|
-
// className: "h-5 w-5",
|
|
37
|
-
// outline: false
|
|
38
|
-
},
|
|
33
|
+
icon: { icon: "IconEye" },
|
|
39
34
|
key: "View Batch",
|
|
40
35
|
label: "View Batch",
|
|
41
36
|
onClick: () => {
|
|
42
37
|
console.log("View Batch action")
|
|
43
38
|
}
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
icon: {
|
|
47
|
-
icon: "IconTrash"
|
|
48
|
-
// pos: "leading",
|
|
49
|
-
// className: "h-5 w-5",
|
|
50
|
-
// outline: false
|
|
51
|
-
},
|
|
52
|
-
label: "Delete",
|
|
53
|
-
onClick: () => {
|
|
54
|
-
console.log("Delete action")
|
|
55
|
-
},
|
|
56
|
-
isEmphasized: true,
|
|
57
|
-
key: "Delete"
|
|
58
39
|
}
|
|
59
40
|
]
|
|
60
41
|
]
|
|
61
42
|
|
|
43
|
+
export const multipleGroups: IItemProp[][] = [
|
|
44
|
+
[
|
|
45
|
+
{
|
|
46
|
+
icon: { icon: "IconArrowUp" },
|
|
47
|
+
key: "moveUp",
|
|
48
|
+
label: "Move up",
|
|
49
|
+
onClick: () => {
|
|
50
|
+
window.alert("moved up")
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{ icon: { icon: "IconArrowDown" }, key: "moveDown", label: "Moved down", onClick: () => {} }
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
{ icon: { icon: "IconCheck" }, key: "publish", label: "Publish", onClick: () => {} },
|
|
57
|
+
{ icon: { icon: "IconEyeOff" }, key: "unpublish", label: "Unpublish", onClick: () => {} }
|
|
58
|
+
],
|
|
59
|
+
[
|
|
60
|
+
{ icon: { icon: "IconEyeCheck" }, key: "reqApproval", label: "Request Approval", onClick: () => {} },
|
|
61
|
+
{ icon: { icon: "IconThumbUp" }, key: "approve", label: "Approve", onClick: () => {} },
|
|
62
|
+
{ icon: { icon: "IconBan" }, key: "decline", label: "Decline", onClick: () => {} }
|
|
63
|
+
],
|
|
64
|
+
[{ icon: { icon: "IconCopy" }, key: "Copy", label: "Copy", onClick: () => {} }],
|
|
65
|
+
[{ icon: { icon: "IconTrash" }, key: "delete", label: "Delete", onClick: () => {} }]
|
|
66
|
+
]
|
|
67
|
+
|
|
62
68
|
export const dropdownDataWithIcons: IItemProp[][] = [
|
|
63
69
|
[
|
|
64
70
|
{
|