@agility/plenum-ui 2.0.0-rc9 → 2.0.0
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/README.md +104 -31
- package/build.js +30 -25
- package/dist/index.d.ts +101 -61
- package/dist/index.js +1 -6295
- package/dist/index.js.map +4 -4
- package/dist/{lib/tailwind.css → tailwind.css} +3729 -8120
- package/dist/types/stories/atoms/buttons/Button/Alternative/Alternative.stories.d.ts +1 -0
- package/dist/types/stories/atoms/buttons/Button/Button.d.ts +3 -7
- package/dist/types/stories/atoms/buttons/Button/Danger/Danger.stories.d.ts +1 -0
- package/dist/types/stories/atoms/buttons/Button/Primary/Primary.stories.d.ts +1 -0
- package/dist/types/stories/atoms/buttons/Button/Secondary/Secondary.stories.d.ts +1 -0
- package/dist/types/stories/atoms/buttons/Capsule/Capsule.d.ts +1 -1
- package/dist/types/stories/atoms/icons/DynamicIcon.d.ts +2 -2
- package/dist/types/stories/atoms/icons/TablerIcon.d.ts +1 -1
- package/dist/types/stories/index.d.ts +4 -4
- package/dist/types/stories/molecules/inputs/InputField/InputField.d.ts +7 -7
- package/dist/types/stories/molecules/inputs/TextInput/TextInput.d.ts +1 -1
- package/dist/types/stories/molecules/inputs/select/Select.d.ts +4 -2
- package/dist/types/stories/molecules/inputs/textArea/TextArea.d.ts +5 -1
- package/dist/types/stories/molecules/inputs/toggleSwitch/ToggleSwitch.d.ts +10 -7
- package/dist/types/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.d.ts +5 -5
- package/dist/types/stories/organisms/AnimatedLabelInput/index.d.ts +1 -1
- package/dist/types/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.d.ts +12 -0
- package/dist/types/stories/organisms/AnimatedLabelTextArea/index.d.ts +3 -0
- package/dist/types/stories/organisms/ButtonDropdown/ButtonDropdown.d.ts +1 -0
- package/dist/types/stories/organisms/DropdownComponent/DropdownComponent.d.ts +24 -13
- package/dist/types/stories/organisms/DropdownComponent/index.d.ts +2 -2
- package/dist/types/stories/organisms/EmptySectionPlaceholder/index.d.ts +1 -1
- package/dist/types/stories/organisms/index.d.ts +4 -3
- package/local.sh +100 -0
- package/package.json +36 -19
- package/rollup.config.mjs +42 -0
- package/stories/atoms/badges/Badge.tsx +1 -1
- package/stories/atoms/buttons/Button/Alternative/Alternative.stories.ts +10 -0
- package/stories/atoms/buttons/Button/Button.tsx +111 -25
- package/stories/atoms/buttons/Button/Danger/Danger.stories.ts +14 -2
- package/stories/atoms/buttons/Button/Primary/Primary.stories.ts +14 -2
- package/stories/atoms/buttons/Button/Secondary/Secondary.stories.ts +13 -1
- package/stories/atoms/buttons/Button/defaultArgs.ts +1 -1
- package/stories/atoms/buttons/Capsule/Capsule.tsx +2 -1
- package/stories/atoms/icons/DynamicIcon.stories.ts +1 -1
- package/stories/atoms/icons/DynamicIcon.tsx +7 -7
- package/stories/atoms/icons/IconWithShadow.stories.ts +3 -3
- package/stories/atoms/icons/TablerIcon.tsx +1 -1
- package/stories/atoms/loaders/Loader.tsx +12 -6
- package/stories/atoms/loaders/NProgress/RadialProgress.tsx +0 -2
- package/stories/index.ts +8 -4
- package/stories/molecules/inputs/InputCounter/InputCounter.tsx +2 -2
- package/stories/molecules/inputs/InputField/InputField.tsx +31 -29
- package/stories/molecules/inputs/InputLabel/InputLabel.tsx +1 -1
- package/stories/molecules/inputs/TextInput/TextInput.tsx +12 -6
- package/stories/molecules/inputs/checkbox/Checkbox.stories.ts +1 -1
- package/stories/molecules/inputs/checkbox/Checkbox.tsx +1 -2
- package/stories/molecules/inputs/combobox/ComboBox.tsx +126 -135
- package/stories/molecules/inputs/radio/Radio.stories.ts +2 -2
- package/stories/molecules/inputs/select/Select.tsx +10 -2
- package/stories/molecules/inputs/textArea/TextArea.stories.ts +1 -1
- package/stories/molecules/inputs/textArea/TextArea.tsx +57 -27
- package/stories/molecules/inputs/toggleSwitch/ToggleSwitch.stories.tsx +15 -16
- package/stories/molecules/inputs/toggleSwitch/ToggleSwitch.tsx +63 -57
- package/stories/molecules/tabs/index.tsx +2 -3
- package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.stories.tsx +10 -1
- package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.tsx +53 -37
- package/stories/organisms/AnimatedLabelInput/index.tsx +1 -1
- package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.stories.tsx +26 -0
- package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.tsx +61 -0
- package/stories/organisms/AnimatedLabelTextArea/index.tsx +3 -0
- package/stories/organisms/ButtonDropdown/ButtonDropdown.stories.tsx +59 -59
- package/stories/organisms/ButtonDropdown/ButtonDropdown.tsx +42 -30
- package/stories/organisms/DropdownComponent/Dropdown.stories.tsx +26 -2
- package/stories/organisms/DropdownComponent/DropdownComponent.tsx +232 -180
- package/stories/organisms/DropdownComponent/dropdownItems.ts +30 -9
- package/stories/organisms/DropdownComponent/index.ts +2 -2
- package/stories/organisms/EmptySectionPlaceholder/EmptySectionPlaceholder.stories.tsx +3 -3
- package/stories/organisms/EmptySectionPlaceholder/index.tsx +2 -1
- package/stories/organisms/FormInputWithAddons/FormInputWithAddons.stories.tsx +1 -1
- package/stories/organisms/FormInputWithAddons/FormInputWithAddons.tsx +7 -2
- package/stories/organisms/index.ts +12 -3
- package/tailwind.config.js +81 -37
- package/tsconfig.lib.json +13 -6
- package/watch.js +49 -0
- package/.yarnrc.yml +0 -1
- package/dist/types/stories/layouts/index.d.ts +0 -0
- package/stories/layouts/CardLayout/CardLayout.stories.tsx +0 -18
- package/stories/layouts/CardLayout/CardLayout.tsx +0 -22
- package/stories/layouts/CardLayout/index.tsx +0 -3
- package/stories/layouts/ModalLayout/ModalLayout.stories.tsx +0 -18
- package/stories/layouts/ModalLayout/ModalLayout.tsx +0 -22
- package/stories/layouts/ModalLayout/index.tsx +0 -3
- package/stories/layouts/index.ts +0 -0
- package/stories/organisms/DropdownComponent/Dropdown.test.tsx +0 -0
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export { default } from
|
|
3
|
-
export * from './Tabs';
|
|
1
|
+
export * from "./Tabs"
|
|
2
|
+
export { default } from "./Tabs"
|
|
@@ -11,11 +11,20 @@ const meta: Meta<typeof AnimatedLabelInput> = {
|
|
|
11
11
|
export default meta
|
|
12
12
|
type Story = StoryObj<typeof AnimatedLabelInput>
|
|
13
13
|
export const DefaultAnimatedLabelInputsStory: Story = {
|
|
14
|
+
args: {
|
|
15
|
+
id: "test",
|
|
16
|
+
label: {
|
|
17
|
+
display: "Label"
|
|
18
|
+
}
|
|
19
|
+
} as IAnimatedLabelInputProps
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const DefaultAnimatedLabelInputsStoryWithPlaceHolder: Story = {
|
|
14
23
|
args: {
|
|
15
24
|
id: "test",
|
|
16
25
|
label: {
|
|
17
26
|
display: "Label"
|
|
18
27
|
},
|
|
19
|
-
|
|
28
|
+
placeholder: "Placeholder"
|
|
20
29
|
} as IAnimatedLabelInputProps
|
|
21
30
|
}
|
|
@@ -1,59 +1,75 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { default as cn } from "classnames"
|
|
3
3
|
import InputField, { IInputFieldProps } from "@/stories/molecules/inputs/InputField"
|
|
4
|
-
import
|
|
4
|
+
import InputCounter from "@/stories/molecules/inputs/InputCounter"
|
|
5
5
|
|
|
6
|
-
interface ILabelProps extends React.
|
|
6
|
+
interface ILabelProps extends React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement> {
|
|
7
7
|
display: string
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export interface IAnimatedLabelInputProps {
|
|
10
|
+
export interface IAnimatedLabelInputProps extends Omit<IInputFieldProps, "handleChange"> {
|
|
11
11
|
id: string
|
|
12
12
|
containerStyles?: string
|
|
13
13
|
message?: string
|
|
14
|
-
input?: IInputFieldProps
|
|
15
|
-
textarea?: ITextareaProps
|
|
16
14
|
required?: boolean
|
|
17
15
|
isError?: boolean
|
|
16
|
+
isShowCounter?: boolean
|
|
17
|
+
maxLength?: number
|
|
18
18
|
label: ILabelProps
|
|
19
|
+
handleChange: (value: string) => void
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
const AnimatedLabelInput: React.FC<IAnimatedLabelInputProps> = ({
|
|
22
|
-
id,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
required,
|
|
28
|
-
isError,
|
|
29
|
-
containerStyles
|
|
30
|
-
}) => {
|
|
22
|
+
const AnimatedLabelInput: React.FC<IAnimatedLabelInputProps> = (props: IAnimatedLabelInputProps) => {
|
|
23
|
+
const { id, containerStyles, message, required, isError, label, value, isShowCounter, maxLength, handleChange, ...input } = props
|
|
24
|
+
|
|
25
|
+
const [hasValue, setHasValue] = React.useState<boolean>(!!value)
|
|
26
|
+
const [valueLength, setValueLength] = React.useState<number>(0)
|
|
27
|
+
|
|
31
28
|
return (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
29
|
+
<>
|
|
30
|
+
<div className={cn("group relative", containerStyles ? containerStyles : "")}>
|
|
31
|
+
<InputField
|
|
32
|
+
id={id}
|
|
33
|
+
isError={isError}
|
|
34
|
+
value={value}
|
|
35
|
+
handleChange={(v) => {
|
|
36
|
+
setHasValue(!!v)
|
|
37
|
+
setValueLength(v.length)
|
|
38
|
+
if (handleChange) handleChange(v)
|
|
39
|
+
}}
|
|
40
|
+
{...input}
|
|
41
|
+
/>
|
|
42
|
+
<label
|
|
43
|
+
className={cn(
|
|
44
|
+
"absolute z-10 ml-[3px] inline-block bg-white text-sm transition-all text-gray-500 left-1 px-1",
|
|
45
|
+
hasValue ? "!-top-[8px] !ml-[.172rem] !text-xs text-gray-600" : "top-[9px]",
|
|
46
|
+
"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",
|
|
48
|
+
|
|
49
|
+
isError && "!text-red-600"
|
|
50
|
+
)}
|
|
51
|
+
htmlFor={id}
|
|
52
|
+
>
|
|
53
|
+
{label.display}
|
|
54
|
+
{required && <span className="text-red-600 ml-1">*</span>}
|
|
55
|
+
</label>
|
|
56
|
+
|
|
57
|
+
<div className="flex flex-row space-x-3">
|
|
58
|
+
<div className="grow">
|
|
59
|
+
{message && (
|
|
60
|
+
<span className={cn("mt-1 block text-sm", isError ? "text-red-500" : "text-gray-500")}>
|
|
61
|
+
{message}
|
|
62
|
+
</span>
|
|
63
|
+
)}
|
|
64
|
+
</div>
|
|
65
|
+
{isShowCounter && (
|
|
66
|
+
<div className="shrink-0">
|
|
67
|
+
<InputCounter current={Number(valueLength)} limit={maxLength ?? 150} />
|
|
68
|
+
</div>
|
|
53
69
|
)}
|
|
54
70
|
</div>
|
|
55
71
|
</div>
|
|
56
|
-
|
|
72
|
+
</>
|
|
57
73
|
)
|
|
58
74
|
}
|
|
59
75
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import AnimatedLabelTextArea, { IAnimatedLabelTextAreaProps } from "./AnimatedLabelTextArea"
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof AnimatedLabelTextArea> = {
|
|
5
|
+
title: "Design System/organisms/Animated Label Text Area",
|
|
6
|
+
component: AnimatedLabelTextArea,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
argTypes: {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default meta
|
|
12
|
+
type Story = StoryObj<typeof AnimatedLabelTextArea>
|
|
13
|
+
export const DefaultAnimatedLabelTextAreasStory: Story = {
|
|
14
|
+
args: {
|
|
15
|
+
id: "test",
|
|
16
|
+
label: "Label"
|
|
17
|
+
} as IAnimatedLabelTextAreaProps
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const DefaultAnimatedLabelTextAreasStoryWithPlaceholder: Story = {
|
|
21
|
+
args: {
|
|
22
|
+
id: "test",
|
|
23
|
+
label: "Label",
|
|
24
|
+
placeholder: "Placeholder"
|
|
25
|
+
} as IAnimatedLabelTextAreaProps
|
|
26
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { default as cn } from "classnames"
|
|
3
|
+
|
|
4
|
+
import TextArea, { ITextareaProps } from "@/stories/molecules/inputs/textArea"
|
|
5
|
+
|
|
6
|
+
export interface IAnimatedLabelTextAreaProps extends ITextareaProps {
|
|
7
|
+
id: string
|
|
8
|
+
containerStyles?: string
|
|
9
|
+
message?: string
|
|
10
|
+
required?: boolean
|
|
11
|
+
isError?: boolean
|
|
12
|
+
handleChange: (value: string) => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const AnimatedLabelTextArea: React.FC<IAnimatedLabelTextAreaProps> = (props: IAnimatedLabelTextAreaProps) => {
|
|
16
|
+
const { id, containerStyles, message, required, isError, label, value, handleChange, onChange, ...input } = props
|
|
17
|
+
|
|
18
|
+
const [hasValue, setHasValue] = React.useState<boolean>(!!value)
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div className={cn("group relative", containerStyles ? containerStyles : "")}>
|
|
22
|
+
<TextArea
|
|
23
|
+
id={id}
|
|
24
|
+
isError={isError}
|
|
25
|
+
value={value}
|
|
26
|
+
{...input}
|
|
27
|
+
onChange={(v) => {
|
|
28
|
+
setHasValue(!!v)
|
|
29
|
+
if (handleChange) handleChange(v)
|
|
30
|
+
}}
|
|
31
|
+
label={undefined}
|
|
32
|
+
/>
|
|
33
|
+
<label
|
|
34
|
+
className={cn(
|
|
35
|
+
"absolute z-10 ml-[3px] inline-block bg-white text-sm transition-all text-gray-500 left-1 px-1",
|
|
36
|
+
hasValue ? "!-top-[8px] !ml-[.172rem] !text-xs text-gray-600" : "top-[9px]",
|
|
37
|
+
"peer-placeholder-shown:!-top-[8px] peer-placeholder-shown:!ml-[.172rem] peer-placeholder-shown:!text-xs peer-placeholder-shown:text-gray-600",
|
|
38
|
+
"group-focus-within:!-top-[8px] group-focus-within:!ml-[.172rem] group-focus-within:!text-xs group-focus-within:text-gray-600",
|
|
39
|
+
|
|
40
|
+
isError && "!text-red-600"
|
|
41
|
+
)}
|
|
42
|
+
htmlFor={label?.htmlFor || id}
|
|
43
|
+
>
|
|
44
|
+
{label?.display}
|
|
45
|
+
{required && <span className="text-red-600 ml-1">*</span>}
|
|
46
|
+
</label>
|
|
47
|
+
|
|
48
|
+
<div className="flex flex-row space-x-3">
|
|
49
|
+
<div className="grow transition-all">
|
|
50
|
+
{message && (
|
|
51
|
+
<span className={cn("mt-1 block text-sm", isError ? "text-red-500" : "text-gray-500")}>
|
|
52
|
+
{message}
|
|
53
|
+
</span>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default AnimatedLabelTextArea
|
|
@@ -2,74 +2,74 @@ import type { Meta, StoryObj } from "@storybook/react"
|
|
|
2
2
|
import ButtonDropdown from "."
|
|
3
3
|
import { IItemProp } from "../DropdownComponent"
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
const meta: Meta<typeof ButtonDropdown> = {
|
|
7
6
|
title: "Design System/Organisms/Button Dropdown",
|
|
8
7
|
component: ButtonDropdown,
|
|
9
8
|
tags: ["autodocs"],
|
|
10
9
|
argTypes: {}
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
key: "Copy",
|
|
22
|
-
label: "Copy",
|
|
23
|
-
onClick: () => {
|
|
24
|
-
console.log("Copy action")
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
[
|
|
29
|
-
{
|
|
30
|
-
icon: {
|
|
31
|
-
name: "IconFolderPlus",
|
|
32
|
-
pos: "leading",
|
|
33
|
-
className: "h-5 w-5",
|
|
34
|
-
outline: false
|
|
35
|
-
},
|
|
36
|
-
key: "Add to Batch",
|
|
37
|
-
label: "Add to Batch",
|
|
38
|
-
onClick: () => {
|
|
39
|
-
console.log("Add to Batch action")
|
|
40
|
-
}
|
|
11
|
+
const dropdownDataWithIcons: IItemProp[][] = [
|
|
12
|
+
[
|
|
13
|
+
{
|
|
14
|
+
icon: {
|
|
15
|
+
icon: "IconCopy"
|
|
16
|
+
|
|
17
|
+
// className: "h-5 w-5",
|
|
18
|
+
// outline: false
|
|
41
19
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
20
|
+
iconPosition: "leading",
|
|
21
|
+
key: "Copy",
|
|
22
|
+
label: "Copy The Thing",
|
|
23
|
+
onClick: () => {}
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
[
|
|
27
|
+
{
|
|
28
|
+
icon: {
|
|
29
|
+
icon: "IconFolderPlus"
|
|
30
|
+
// name: "IconFolderPlus",
|
|
31
|
+
// className: "h-5 w-5",
|
|
32
|
+
// outline: false
|
|
33
|
+
},
|
|
34
|
+
key: "Add to Batch",
|
|
35
|
+
label: "Add to Batch",
|
|
36
|
+
onClick: () => {
|
|
37
|
+
console.log("Add to Batch action")
|
|
54
38
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
{
|
|
58
|
-
icon:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
isEmphasized: true
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
icon: {
|
|
42
|
+
icon: "IconEye",
|
|
43
|
+
//pos: "leading",
|
|
44
|
+
className: "h-5 w-5",
|
|
45
|
+
outline: false
|
|
46
|
+
},
|
|
47
|
+
iconPosition: "leading",
|
|
48
|
+
key: "View Batch",
|
|
49
|
+
label: "View Batch",
|
|
50
|
+
onClick: () => {
|
|
51
|
+
console.log("View Batch action")
|
|
70
52
|
}
|
|
71
|
-
|
|
72
|
-
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
{
|
|
57
|
+
icon: {
|
|
58
|
+
icon: "IconTrash"
|
|
59
|
+
|
|
60
|
+
// pos: "leading",
|
|
61
|
+
// className: "h-5 w-5",
|
|
62
|
+
// outline: false
|
|
63
|
+
},
|
|
64
|
+
key: "Delete",
|
|
65
|
+
label: "Delete",
|
|
66
|
+
onClick: () => {
|
|
67
|
+
console.log("Delete action")
|
|
68
|
+
},
|
|
69
|
+
isEmphasized: true
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
]
|
|
73
73
|
|
|
74
74
|
export default meta
|
|
75
75
|
type Story = StoryObj<typeof ButtonDropdown>
|
|
@@ -8,6 +8,7 @@ import Dropdown, { IDropdownProps, defaultClassNames } from "../DropdownComponen
|
|
|
8
8
|
export interface IButtonDropdownProps {
|
|
9
9
|
button: IButtonProps
|
|
10
10
|
dropDown: IDropdownProps
|
|
11
|
+
hideDivider?: boolean
|
|
11
12
|
placement?: IDropdownProps["placement"]
|
|
12
13
|
offsetOptions?: IDropdownProps["offsetOptions"]
|
|
13
14
|
}
|
|
@@ -15,22 +16,7 @@ export interface IButtonDropdownProps {
|
|
|
15
16
|
/**
|
|
16
17
|
* Primary UI component for user interaction
|
|
17
18
|
*/
|
|
18
|
-
const ButtonDropdown: FC<IButtonDropdownProps> = ({ button, dropDown, placement, offsetOptions }) => {
|
|
19
|
-
const dropDownClasses: IDropdownProps["classNames"] = {
|
|
20
|
-
...defaultClassNames,
|
|
21
|
-
groupClassname: cn(
|
|
22
|
-
"flex items-center justify-center rounded-l-none border !border-l-0 rounded-r px-2 transition-all hover:!border-l-0",
|
|
23
|
-
button.actionType === "primary"
|
|
24
|
-
? "border-purple-600 bg-purple-600 !text-white hover:border-purple-700 hover:bg-purple-700 active:!border-purple-800 active:!bg-purple-800 fill-white"
|
|
25
|
-
: "",
|
|
26
|
-
button.actionType === "secondary"
|
|
27
|
-
? "border-purple-50 bg-purple-50 !text-purple-700 hover:border-purple-100 hover:bg-purple-100 active:!border-purple-300 active:!bg-purple-300 fill-purple-700"
|
|
28
|
-
: "",
|
|
29
|
-
button.actionType === "alternative"
|
|
30
|
-
? "border-gray-300 bg-white !text-gray-700 fill-gray-700 hover:border-gray-300 hover:bg-gray-50 active:bg-gray-100"
|
|
31
|
-
: ""
|
|
32
|
-
)
|
|
33
|
-
}
|
|
19
|
+
const ButtonDropdown: FC<IButtonDropdownProps> = ({ button, dropDown, hideDivider = false, placement = "bottom-end", offsetOptions }) => {
|
|
34
20
|
return (
|
|
35
21
|
<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]">
|
|
36
22
|
<Button
|
|
@@ -38,40 +24,66 @@ const ButtonDropdown: FC<IButtonDropdownProps> = ({ button, dropDown, placement,
|
|
|
38
24
|
...button,
|
|
39
25
|
className: cn(
|
|
40
26
|
button.className,
|
|
41
|
-
"!rounded-r-none !border-r-0 hover:!border-r-0 !focus:ring-transparent !focus-visible:ring-transparent !focus-within:ring-transparent !focus:ring-0 !focus-within:ring-0 !focus-visible:ring-0 !focus:ring-offset-0 !focus-visible:ring-offset-0 !focus-within:ring-offset-0 !ring-0 outline-none focus:outline-none focus-visible:outline-none focus-within:outline-none !ring-offset-0"
|
|
27
|
+
"!rounded-r-none !border-r-0 hover:!border-r-0 !focus:ring-transparent !focus-visible:ring-transparent !focus-within:ring-transparent !focus:ring-0 !focus-within:ring-0 !focus-visible:ring-0 !focus:ring-offset-0 !focus-visible:ring-offset-0 !focus-within:ring-offset-0 !ring-0 outline-none focus:outline-none focus-visible:outline-none focus-within:outline-none !ring-offset-0",
|
|
28
|
+
"border-r-transparent"
|
|
42
29
|
)
|
|
43
30
|
}}
|
|
44
31
|
/>
|
|
45
|
-
<div
|
|
32
|
+
{!hideDivider && <div
|
|
46
33
|
className={cn(
|
|
47
34
|
"w-[1px] rt",
|
|
48
|
-
button.actionType === "primary"
|
|
49
|
-
|
|
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 " : "",
|
|
50
39
|
button.actionType === "alternative" ? "bg-gray-300" : ""
|
|
51
40
|
)}
|
|
52
|
-
></div>
|
|
41
|
+
></div>}
|
|
53
42
|
<Dropdown
|
|
54
43
|
{...{
|
|
55
|
-
...(dropDown as IDropdownProps),
|
|
56
44
|
CustomDropdownTrigger: (
|
|
57
45
|
<DynamicIcon
|
|
58
46
|
{...{
|
|
59
|
-
icon: "
|
|
47
|
+
icon: "IconChevronDown",
|
|
60
48
|
className: cn("h-5 w-5", {
|
|
61
|
-
"text-
|
|
62
|
-
"text-purple-700": button.actionType === "secondary",
|
|
49
|
+
"text-violet-100": button.actionType === "primary",
|
|
50
|
+
"text-purple-700 ": button.actionType === "secondary",
|
|
63
51
|
"text-gray-700": button.actionType === "alternative"
|
|
64
|
-
}
|
|
52
|
+
},
|
|
53
|
+
dropDown.iconClassname
|
|
54
|
+
),
|
|
65
55
|
}}
|
|
66
56
|
/>
|
|
67
57
|
),
|
|
68
|
-
|
|
58
|
+
buttonClassname: cn(
|
|
59
|
+
"flex items-center justify-center rounded-l-none border !border-l-0 rounded-r px-2 transition-all hover:!border-l-0",
|
|
60
|
+
button.actionType === "primary"
|
|
61
|
+
? cn(
|
|
62
|
+
"border-violet-700 bg-violet-800 !text-white hover:border-violet-700 hover:bg-violet-700 active:!border-violet-800 active:bg-violet-800 fill-white",
|
|
63
|
+
"disabled:bg-violet-400 disabled:text-white disabled:hover:none disabled:active:bg-violet-400 disabled:border-violet-400"
|
|
64
|
+
)
|
|
65
|
+
: "",
|
|
66
|
+
button.actionType === "secondary"
|
|
67
|
+
? cn(
|
|
68
|
+
"border-purple-400 bg-purple-50 text-purple-700 hover:bg-purple-100 active:bg-purple-300 fill-purple-700",
|
|
69
|
+
"disabled:bg-purple-50 disabled:text-grey-50 disabled:hover:none disabled:active:bg-purple-50 "
|
|
70
|
+
)
|
|
71
|
+
: "",
|
|
72
|
+
button.actionType === "alternative"
|
|
73
|
+
? cn(
|
|
74
|
+
"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"
|
|
76
|
+
)
|
|
77
|
+
: "",
|
|
78
|
+
dropDown.buttonClassname
|
|
79
|
+
),
|
|
69
80
|
offsetOptions: offsetOptions ?? {
|
|
70
81
|
crossAxis: 0,
|
|
71
|
-
mainAxis:
|
|
72
|
-
alignmentAxis:
|
|
82
|
+
mainAxis: -4, //up/down
|
|
83
|
+
alignmentAxis: 0 //left/right
|
|
73
84
|
},
|
|
74
|
-
placement
|
|
85
|
+
placement,
|
|
86
|
+
...(dropDown as IDropdownProps),
|
|
75
87
|
}}
|
|
76
88
|
/>
|
|
77
89
|
<div className="hidden !bg-purple-100 !text-purple-600 transition-all hover:bg-purple-200 focus:bg-purple-300" />
|
|
@@ -13,12 +13,12 @@ const meta: Meta<typeof Dropdown> = {
|
|
|
13
13
|
type Story = StoryObj<typeof Dropdown>
|
|
14
14
|
|
|
15
15
|
const IconElement = () => (
|
|
16
|
-
<DynamicIcon className="h-5 w-5 text-gray-400 hover:text-gray-600" icon={"
|
|
16
|
+
<DynamicIcon className="h-5 w-5 text-gray-400 hover:text-gray-600" icon={"IconDotsVertical"} />
|
|
17
17
|
)
|
|
18
18
|
const defaultArgs: Story["args"] = {
|
|
19
19
|
items: [...dropdownDataBase],
|
|
20
20
|
label: "Dropdown",
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
placement: "bottom-end"
|
|
23
23
|
}
|
|
24
24
|
export const WithLabel: Story = {
|
|
@@ -39,6 +39,30 @@ export const WithLabelAndIcons: Story = {
|
|
|
39
39
|
items: [...dropdownDataWithIcons]
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
export const WithCustomItemLabelsAndIcons: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
...defaultArgs,
|
|
45
|
+
items: [
|
|
46
|
+
...dropdownDataWithIcons,
|
|
47
|
+
[
|
|
48
|
+
{
|
|
49
|
+
icon: { icon: "Icon123" },
|
|
50
|
+
label: (
|
|
51
|
+
<div className="flex items-baseline gap-x-2">
|
|
52
|
+
sdfsdf{" "}
|
|
53
|
+
<div className="flex space-x-1">
|
|
54
|
+
<div className="h-1 w-1 animate-[bounce_1s_infinite] rounded-full bg-gray-500"></div>
|
|
55
|
+
<div className="h-1 w-1 animate-[bounce_1s_infinite_0.2s] rounded-full bg-gray-500"></div>
|
|
56
|
+
<div className="h-1 w-1 animate-[bounce_1s_infinite_0.4s] rounded-full bg-gray-500"></div>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
),
|
|
60
|
+
key: "sdfsdf"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
42
66
|
export const WithIcons: Story = {
|
|
43
67
|
args: {
|
|
44
68
|
...defaultArgs,
|