@agility/plenum-ui 2.0.0-rc8 → 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 +105 -65
- 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/index.d.ts +2 -2
- 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/index.d.ts +2 -2
- 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/index.ts +2 -0
- 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/index.ts +2 -1
- 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
|
@@ -22,6 +22,16 @@ export const Alternative: Story = {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
export const AlternativeDisabled: Story = {
|
|
26
|
+
args: {
|
|
27
|
+
actionType: "alternative",
|
|
28
|
+
label: "Button",
|
|
29
|
+
disabled: true,
|
|
30
|
+
onClick: () => {
|
|
31
|
+
window.alert("Button clicked!")
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
25
35
|
export const AlternativeTrailingIcon: Story = {
|
|
26
36
|
args: {
|
|
27
37
|
...Alternative.args,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import Loader from "stories/atoms/loaders/Loader"
|
|
2
2
|
import { default as cn } from "classnames"
|
|
3
|
-
import { HTMLAttributeAnchorTarget } from "react"
|
|
3
|
+
import React, { HTMLAttributeAnchorTarget, forwardRef } from "react"
|
|
4
4
|
import { DynamicIcon, UnifiedIconName, IDynamicIconProps } from "../../icons"
|
|
5
5
|
|
|
6
6
|
// import Loader from "../loaders/loader/Loader"
|
|
7
7
|
|
|
8
8
|
export type BTNActionType = "primary" | "secondary" | "alternative" | "danger"
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
export interface IButtonProps
|
|
11
|
+
extends Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> {
|
|
10
12
|
/** Is the button a Primary CTA, alternative or danger button? */
|
|
11
13
|
actionType?: BTNActionType
|
|
12
14
|
/** How lg should the button be? - Defaults to 'base'. */
|
|
@@ -31,30 +33,31 @@ export interface IButtonProps extends React.ComponentPropsWithoutRef<"button"> {
|
|
|
31
33
|
isLoading?: boolean
|
|
32
34
|
className?: string
|
|
33
35
|
iconObj?: React.ReactNode
|
|
34
|
-
ref?: React.LegacyRef<HTMLButtonElement>
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* Primary UI component for user interaction
|
|
38
39
|
*/
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}: IButtonProps
|
|
40
|
+
const _Button = (
|
|
41
|
+
{
|
|
42
|
+
actionType = "primary",
|
|
43
|
+
size = "sm",
|
|
44
|
+
label,
|
|
45
|
+
icon,
|
|
46
|
+
iconObj,
|
|
47
|
+
CustomSVGIcon,
|
|
48
|
+
fullWidth = false,
|
|
49
|
+
iconPosition = "leading",
|
|
50
|
+
asLink,
|
|
51
|
+
isLoading = false,
|
|
52
|
+
className,
|
|
53
|
+
...props
|
|
54
|
+
}: IButtonProps,
|
|
55
|
+
ref: React.LegacyRef<HTMLButtonElement>
|
|
56
|
+
) => {
|
|
54
57
|
const iconStyles = cn(
|
|
55
58
|
{ "text-white h-5 w-5": actionType === "primary" || actionType === "danger" },
|
|
56
59
|
{ "text-purple-700 h-5 w-5 ": actionType === "secondary" },
|
|
57
|
-
{ "text-gray-
|
|
60
|
+
{ "text-gray-400 h-5 w-5": actionType === "alternative" }
|
|
58
61
|
)
|
|
59
62
|
const loaderColors = cn(
|
|
60
63
|
{ "border-r-white": actionType === "primary" },
|
|
@@ -64,11 +67,91 @@ const Button = ({
|
|
|
64
67
|
)
|
|
65
68
|
const loaderSize = cn({ "h-4 w-4": size === "sm" }, { "h-5 w-5": size === "md" }, { "h-6 w-6 ": size === "lg" })
|
|
66
69
|
|
|
67
|
-
return (
|
|
70
|
+
return asLink ? (
|
|
71
|
+
//@ts-ignore
|
|
72
|
+
<a
|
|
73
|
+
{...{
|
|
74
|
+
href: asLink.href,
|
|
75
|
+
target: asLink.target,
|
|
76
|
+
title: asLink.title,
|
|
77
|
+
className: cn(
|
|
78
|
+
"inline-flex items-center justify-center gap-x-2 font-medium rounded-[3px] !ring-offset-white outline-none focus-visible:ring-2 focus-visible:ring-purple-600 focus-visible:ring-offset-2 focus-within:ring-2 focus-within:ring-purple-600 focus-within:ring-offset-2 focus:ring-2 focus:ring-purple-600 focus:ring-offset-2 active:ring-2 active:ring-purple-600 active:ring-offset-2 transition-all",
|
|
79
|
+
{ "w-full": fullWidth },
|
|
80
|
+
{ "px-[11px] py-[7px] text-xs": size === "xs" },
|
|
81
|
+
{ "px-[13px] py-[9px] text-sm": size === "sm" },
|
|
82
|
+
{ "px-[17px] py-[9px] text-sm": size === "md" },
|
|
83
|
+
{ "px-[17px] py-[9px] text-base": size === "lg" },
|
|
84
|
+
{ "px-[25px] py-[13px] text-base": size === "xl" },
|
|
85
|
+
{
|
|
86
|
+
"bg-violet-800 text-white hover:border-violet-700 hover:bg-violet-700 disabled:bg-violet-400 disabled:focus-visible:ring-0":
|
|
87
|
+
actionType === "primary"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
" bg-purple-50 border-purple-400 border hover:border-purple-500 text-purple-700 hover:bg-purple-100 focus-within:bg-purple-100 focus-visible:bg-purple-100 focus:bg-purple-100 active:bg-purple-100 disabled:bg-purple-50 disabled:text-purple-300 disabled:focus-visible:ring-0":
|
|
91
|
+
actionType === "secondary"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"border-gray-300 bg-white border text-gray-700 hover:bg-gray-50 focus-visible:!border-gray-300 focus-within:!border-gray-300 focus:!border-gray-300 active:!border-gray-300 disabled:bg-gray-50 disabled:text-gray-300 disabled:focus-visible:ring-0":
|
|
95
|
+
actionType === "alternative"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
" bg-red-600 text-white hover:bg-red-700 <focus-visible:!></focus-visible:!>ring-red-500 focus:!ring-red-500 active:!ring-red-500 focus-within:!ring-red-500 disabled:bg-red-400 disabled:text-gray-50 disabled:focus-visible:ring-0":
|
|
99
|
+
actionType === "danger"
|
|
100
|
+
},
|
|
101
|
+
className ? className : ""
|
|
102
|
+
),
|
|
103
|
+
onClick: props.onClick
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
{" "}
|
|
107
|
+
{CustomSVGIcon &&
|
|
108
|
+
(isLoading ? (
|
|
109
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
110
|
+
) : (
|
|
111
|
+
<i>{CustomSVGIcon}</i>
|
|
112
|
+
))}
|
|
113
|
+
{iconObj &&
|
|
114
|
+
iconPosition === "leading" &&
|
|
115
|
+
(!isLoading ? (
|
|
116
|
+
<>{iconObj}</>
|
|
117
|
+
) : (
|
|
118
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
119
|
+
))}
|
|
120
|
+
{icon &&
|
|
121
|
+
iconPosition === "leading" &&
|
|
122
|
+
(isLoading ? (
|
|
123
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
124
|
+
) : typeof icon === "string" ? (
|
|
125
|
+
<DynamicIcon {...{ icon: icon, className: iconStyles }} />
|
|
126
|
+
) : (
|
|
127
|
+
<DynamicIcon {...{ ...icon, className: iconStyles }} />
|
|
128
|
+
))}
|
|
129
|
+
{!icon && !CustomSVGIcon && isLoading && (
|
|
130
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
131
|
+
)}
|
|
132
|
+
{label}
|
|
133
|
+
{icon &&
|
|
134
|
+
iconPosition === "trailing" &&
|
|
135
|
+
(isLoading ? (
|
|
136
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
137
|
+
) : typeof icon === "string" ? (
|
|
138
|
+
<DynamicIcon {...{ icon: icon, className: iconStyles }} />
|
|
139
|
+
) : (
|
|
140
|
+
<DynamicIcon {...{ ...icon, className: iconStyles }} />
|
|
141
|
+
))}
|
|
142
|
+
{iconObj &&
|
|
143
|
+
iconPosition === "trailing" &&
|
|
144
|
+
(!isLoading ? (
|
|
145
|
+
<>{iconObj}</>
|
|
146
|
+
) : (
|
|
147
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
148
|
+
))}
|
|
149
|
+
</a>
|
|
150
|
+
) : (
|
|
68
151
|
<button
|
|
69
152
|
type="button"
|
|
70
153
|
className={cn(
|
|
71
|
-
"inline-flex items-center justify-center gap-x-2 font-medium
|
|
154
|
+
"inline-flex items-center justify-center gap-x-2 font-medium rounded-[3px] !ring-offset-white outline-none focus-visible:ring-2 focus-visible:ring-purple-600 focus-visible:ring-offset-2 focus-within:ring-2 focus-within:ring-purple-600 focus-within:ring-offset-2 focus:ring-2 focus:ring-purple-600 focus:ring-offset-2 active:ring-2 active:ring-purple-600 active:ring-offset-2 transition-all",
|
|
72
155
|
{ "w-full": fullWidth },
|
|
73
156
|
{ "px-[11px] py-[7px] text-xs": size === "xs" },
|
|
74
157
|
{ "px-[13px] py-[9px] text-sm": size === "sm" },
|
|
@@ -76,18 +159,19 @@ const Button = ({
|
|
|
76
159
|
{ "px-[17px] py-[9px] text-base": size === "lg" },
|
|
77
160
|
{ "px-[25px] py-[13px] text-base": size === "xl" },
|
|
78
161
|
{
|
|
79
|
-
"bg-
|
|
162
|
+
"bg-violet-800 text-violet-100 hover:border-violet-700 hover:bg-violet-700 disabled:bg-violet-400 disabled:focus-visible:ring-0":
|
|
163
|
+
actionType === "primary"
|
|
80
164
|
},
|
|
81
165
|
{
|
|
82
|
-
" bg-purple-50 text-purple-700 hover:bg-purple-
|
|
166
|
+
" bg-purple-50 border-purple-400 border hover:border-purple-500 text-purple-700 hover:bg-purple-100 focus-within:bg-purple-100 focus-visible:bg-purple-100 focus:bg-purple-100 active:bg-purple-100 disabled:bg-purple-50 disabled:text-purple-300 disabled:focus-visible:ring-0":
|
|
83
167
|
actionType === "secondary"
|
|
84
168
|
},
|
|
85
169
|
{
|
|
86
|
-
"border-gray-300 bg-white border text-gray-700 hover:bg-gray-50 focus-visible:!border-gray-300 focus-within:!border-gray-300 focus:!border-gray-300 active:!border-gray-300":
|
|
170
|
+
"border-gray-300 bg-white border text-gray-700 hover:bg-gray-50 focus-visible:!border-gray-300 focus-within:!border-gray-300 focus:!border-gray-300 active:!border-gray-300 disabled:bg-gray-50 disabled:text-gray-300 disabled:focus-visible:ring-0":
|
|
87
171
|
actionType === "alternative"
|
|
88
172
|
},
|
|
89
173
|
{
|
|
90
|
-
" bg-red-600 text-white hover:bg-red-700 <focus-visible:!></focus-visible:!>ring-red-500 focus:!ring-red-500 active:!ring-red-500 focus-within:!ring-red-500 ":
|
|
174
|
+
" bg-red-600 text-white hover:bg-red-700 <focus-visible:!></focus-visible:!>ring-red-500 focus:!ring-red-500 active:!ring-red-500 focus-within:!ring-red-500 disabled:bg-red-400 disabled:text-gray-50 disabled:focus-visible:ring-0":
|
|
91
175
|
actionType === "danger"
|
|
92
176
|
},
|
|
93
177
|
className ? className : ""
|
|
@@ -143,4 +227,6 @@ const Button = ({
|
|
|
143
227
|
)
|
|
144
228
|
}
|
|
145
229
|
|
|
230
|
+
const Button = forwardRef<HTMLButtonElement, IButtonProps>(_Button)
|
|
231
|
+
|
|
146
232
|
export default Button
|
|
@@ -22,12 +22,24 @@ export const Danger: Story = {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
export const DangerDisabled: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
actionType: "danger",
|
|
29
|
+
label: "Danger Zone!",
|
|
30
|
+
disabled: true,
|
|
31
|
+
onClick: () => {
|
|
32
|
+
window.alert("Button clicked!")
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
25
37
|
export const DangerTrailingIcon: Story = {
|
|
26
38
|
args: {
|
|
27
39
|
...Danger.args,
|
|
28
40
|
icon: {
|
|
29
41
|
...defaultIcon,
|
|
30
|
-
icon: "
|
|
42
|
+
icon: "IconTrash"
|
|
31
43
|
},
|
|
32
44
|
iconPosition: "trailing"
|
|
33
45
|
}
|
|
@@ -41,7 +53,7 @@ export const DangerLeadingIcon: Story = {
|
|
|
41
53
|
export const DangerSimpleIconName: Story = {
|
|
42
54
|
args: {
|
|
43
55
|
...Danger.args,
|
|
44
|
-
icon: "
|
|
56
|
+
icon: "IconTrash",
|
|
45
57
|
iconPosition: "leading"
|
|
46
58
|
}
|
|
47
59
|
}
|
|
@@ -28,12 +28,24 @@ export const Primary: Story = {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
export const PrimaryDisabled: Story = {
|
|
33
|
+
args: {
|
|
34
|
+
actionType: "primary",
|
|
35
|
+
label: "Button",
|
|
36
|
+
disabled: true,
|
|
37
|
+
onClick: () => {
|
|
38
|
+
window.alert("Button clicked!")
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
export const PrimaryLeadingIcon: Story = {
|
|
32
44
|
args: {
|
|
33
45
|
...Primary.args,
|
|
34
46
|
icon: {
|
|
35
47
|
...defaultIcon,
|
|
36
|
-
icon: "
|
|
48
|
+
icon: "IconCheck",
|
|
37
49
|
outline: false
|
|
38
50
|
},
|
|
39
51
|
iconPosition: "leading"
|
|
@@ -42,7 +54,7 @@ export const PrimaryLeadingIcon: Story = {
|
|
|
42
54
|
export const PrimarySimpleIconName: Story = {
|
|
43
55
|
args: {
|
|
44
56
|
...Primary.args,
|
|
45
|
-
icon: "
|
|
57
|
+
icon: "IconCheck",
|
|
46
58
|
iconPosition: "leading"
|
|
47
59
|
}
|
|
48
60
|
}
|
|
@@ -28,6 +28,18 @@ export const Secondary: Story = {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
export const SecondaryDisabled: Story = {
|
|
33
|
+
args: {
|
|
34
|
+
actionType: "secondary",
|
|
35
|
+
label: "Button",
|
|
36
|
+
disabled: true,
|
|
37
|
+
onClick: () => {
|
|
38
|
+
window.alert("Button clicked!")
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
export const SecondaryTrailingIcon: Story = {
|
|
32
44
|
args: {
|
|
33
45
|
...Secondary.args,
|
|
@@ -44,7 +56,7 @@ export const SecondaryLeadingIcon: Story = {
|
|
|
44
56
|
export const SecondarySimpleIconName: Story = {
|
|
45
57
|
args: {
|
|
46
58
|
...Secondary.args,
|
|
47
|
-
icon: "
|
|
59
|
+
icon: "IconBell",
|
|
48
60
|
iconPosition: "leading"
|
|
49
61
|
}
|
|
50
62
|
}
|
|
@@ -6,7 +6,8 @@ import { UnifiedIconName } from "../../icons/DynamicIcon"
|
|
|
6
6
|
/**
|
|
7
7
|
* Capsule Style Button
|
|
8
8
|
*/
|
|
9
|
-
export interface ICapsuleProps
|
|
9
|
+
export interface ICapsuleProps
|
|
10
|
+
extends React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
|
|
10
11
|
/** Is the button a Primary CTA, alternative or danger button? */
|
|
11
12
|
actionType: BTNActionType
|
|
12
13
|
/** How lg should the button be? - Defaults to 'base'. */
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
-
// TODO: Fix heroicons support
|
|
2
|
+
// TODO: Fix heroicons support
|
|
3
3
|
import * as SolidIcons from "@heroicons/react/solid"
|
|
4
4
|
import * as OutlineIcons from "@heroicons/react/outline"
|
|
5
|
-
import * as TablerIconComponents from "@tabler/icons-react"
|
|
6
5
|
import * as FA from "react-icons/fa"
|
|
7
6
|
import { tablerIconNames, TablerIconName } from "./tablerIconNames"
|
|
8
7
|
import { default as cn } from "classnames"
|
|
9
8
|
|
|
10
|
-
import TablerIcon from "./TablerIcon"
|
|
11
9
|
import { ClassNameWithAutocomplete } from "@/utils/types"
|
|
10
|
+
import TablerIcon from "./TablerIcon"
|
|
12
11
|
|
|
13
12
|
export type IconName = keyof typeof SolidIcons | keyof typeof OutlineIcons
|
|
14
|
-
|
|
15
13
|
export type FAIconName = keyof typeof FA
|
|
16
14
|
|
|
17
|
-
export type UnifiedIconName =
|
|
15
|
+
export type UnifiedIconName = TablerIconName | IconName | FAIconName
|
|
18
16
|
|
|
19
17
|
export function isHeroIcon(name: UnifiedIconName): name is keyof typeof SolidIcons | keyof typeof OutlineIcons {
|
|
20
18
|
return name in SolidIcons || name in OutlineIcons
|
|
@@ -27,11 +25,12 @@ export function isTablerIcon(name: UnifiedIconName): name is TablerIconName {
|
|
|
27
25
|
export function isFAIcon(name: UnifiedIconName): name is keyof typeof FA {
|
|
28
26
|
return name in FA
|
|
29
27
|
}
|
|
28
|
+
|
|
30
29
|
export function isUnifiedIconName(name: UnifiedIconName): name is UnifiedIconName {
|
|
31
|
-
return isTablerIcon(name) || isFAIcon(name)
|
|
30
|
+
return isTablerIcon(name) // || isHeroIcon(name) || isFAIcon(name)
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
export interface IDynamicIconProps extends React.
|
|
33
|
+
export interface IDynamicIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
|
|
35
34
|
icon: UnifiedIconName
|
|
36
35
|
className?: ClassNameWithAutocomplete
|
|
37
36
|
outline?: boolean
|
|
@@ -62,6 +61,7 @@ export const DynamicIcon = ({
|
|
|
62
61
|
/>
|
|
63
62
|
)
|
|
64
63
|
}
|
|
64
|
+
|
|
65
65
|
if (isFAIcon(icon)) {
|
|
66
66
|
const Icon = FA[icon]
|
|
67
67
|
return (
|
|
@@ -11,13 +11,13 @@ type Story = StoryObj<typeof IconWithShadow>
|
|
|
11
11
|
|
|
12
12
|
export const HeroIconSolid: Story = {
|
|
13
13
|
args: {
|
|
14
|
-
icon: "
|
|
14
|
+
icon: "IconCube",
|
|
15
15
|
outline: false
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
export const HeroIconOutline: Story = {
|
|
19
19
|
args: {
|
|
20
|
-
icon: "
|
|
20
|
+
icon: "IconCube",
|
|
21
21
|
outline: true
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -35,7 +35,7 @@ export const TablerIconOutline: Story = {
|
|
|
35
35
|
}
|
|
36
36
|
export const FAIcon: Story = {
|
|
37
37
|
args: {
|
|
38
|
-
icon: "
|
|
38
|
+
icon: "IconBrandGithub",
|
|
39
39
|
outline: true
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -3,7 +3,7 @@ import { TablerIconName } from "./tablerIconNames"
|
|
|
3
3
|
import * as TablerIcons from "@tabler/icons-react"
|
|
4
4
|
import { ClassNameWithAutocomplete } from "@/utils/types"
|
|
5
5
|
|
|
6
|
-
export interface ITablerIconProps extends React.
|
|
6
|
+
export interface ITablerIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
|
|
7
7
|
icon: TablerIconName
|
|
8
8
|
className?: ClassNameWithAutocomplete
|
|
9
9
|
}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
-
import
|
|
2
|
+
import { default as cn } from "classnames"
|
|
3
3
|
|
|
4
4
|
export interface ILoaderProps {
|
|
5
5
|
className?: string
|
|
6
6
|
}
|
|
7
7
|
const Loader: React.FC<ILoaderProps> = ({ className }) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<i
|
|
11
|
+
className={cn(
|
|
12
|
+
"rounded-full w-16 h-16 inline-block border-8 animate-spin m-auto",
|
|
13
|
+
className ? className : "border-purple-700 border-r-gray-200"
|
|
14
|
+
)}
|
|
15
|
+
role="status"
|
|
16
|
+
/>
|
|
17
|
+
</>
|
|
18
|
+
)
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
export default Loader
|
|
@@ -31,8 +31,6 @@ const RadialProgress: React.FC<IRadialProgressProps> = ({
|
|
|
31
31
|
}
|
|
32
32
|
const drawPercentage = useMemo(() => {
|
|
33
33
|
const roundCircum = Math.round(2 * r * Math.PI)
|
|
34
|
-
console.log(roundCircum, "circumference")
|
|
35
|
-
console.log(inputValue, "input value")
|
|
36
34
|
return (inputValue * roundCircum) / 50
|
|
37
35
|
}, [inputValue, r])
|
|
38
36
|
|
package/stories/index.ts
CHANGED
|
@@ -47,13 +47,15 @@ import {
|
|
|
47
47
|
Textarea,
|
|
48
48
|
ToggleSwitch,
|
|
49
49
|
TextInput,
|
|
50
|
-
ITextInputProps
|
|
50
|
+
ITextInputProps,
|
|
51
|
+
ISimpleSelectOptions
|
|
51
52
|
} from "./molecules"
|
|
52
53
|
// Organism Components, props, and type gaurds.
|
|
53
54
|
import {
|
|
54
55
|
IAnimatedLabelInputProps,
|
|
56
|
+
AnimatedLabelTextArea,
|
|
57
|
+
IAnimatedLabelTextAreaProps,
|
|
55
58
|
IButtonDropdownProps,
|
|
56
|
-
IDropdownClassnames,
|
|
57
59
|
IDropdownProps,
|
|
58
60
|
IEmptySectionPlaceholderProps,
|
|
59
61
|
IItemProp,
|
|
@@ -88,8 +90,8 @@ export type {
|
|
|
88
90
|
IToggleSwitchProps,
|
|
89
91
|
AcceptedInputTypes,
|
|
90
92
|
IAnimatedLabelInputProps,
|
|
93
|
+
IAnimatedLabelTextAreaProps,
|
|
91
94
|
IButtonDropdownProps,
|
|
92
|
-
IDropdownClassnames,
|
|
93
95
|
IDropdownProps,
|
|
94
96
|
IEmptySectionPlaceholderProps,
|
|
95
97
|
IItemProp,
|
|
@@ -98,7 +100,8 @@ export type {
|
|
|
98
100
|
IconName,
|
|
99
101
|
FAIconName,
|
|
100
102
|
BTNActionType,
|
|
101
|
-
ITextInputProps
|
|
103
|
+
ITextInputProps,
|
|
104
|
+
ISimpleSelectOptions
|
|
102
105
|
}
|
|
103
106
|
export {
|
|
104
107
|
Avatar,
|
|
@@ -112,6 +115,7 @@ export {
|
|
|
112
115
|
Textarea,
|
|
113
116
|
ToggleSwitch,
|
|
114
117
|
AnimatedLabelInput,
|
|
118
|
+
AnimatedLabelTextArea,
|
|
115
119
|
ButtonDropdown,
|
|
116
120
|
Dropdown,
|
|
117
121
|
EmptySectionPlaceholder,
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
INestedInputButtonProps,
|
|
7
7
|
IRadioProps,
|
|
8
8
|
ISelectProps,
|
|
9
|
+
ISimpleSelectOptions,
|
|
9
10
|
ITextareaProps,
|
|
10
11
|
IToggleSwitchProps,
|
|
11
12
|
AcceptedInputTypes,
|
|
@@ -30,6 +31,7 @@ export type {
|
|
|
30
31
|
INestedInputButtonProps,
|
|
31
32
|
IRadioProps,
|
|
32
33
|
ISelectProps,
|
|
34
|
+
ISimpleSelectOptions,
|
|
33
35
|
ITextareaProps,
|
|
34
36
|
IToggleSwitchProps,
|
|
35
37
|
AcceptedInputTypes,
|
|
@@ -10,8 +10,8 @@ export interface IInputCounterProps {
|
|
|
10
10
|
/** Primary UI component for user interaction */
|
|
11
11
|
const InputCounter: FC<IInputCounterProps> = ({ current = 0, limit }) => {
|
|
12
12
|
return (
|
|
13
|
-
<div className="mt-
|
|
14
|
-
<div className="currentCount">{current}</div>
|
|
13
|
+
<div className="mt-3 text-center text-xs leading-4 font-medium text-gray-500 flex gap-1">
|
|
14
|
+
<div className="currentCount">{current ?? 0}</div>
|
|
15
15
|
{(limit || 0) > 0 && (
|
|
16
16
|
<>
|
|
17
17
|
<div>/</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react"
|
|
1
|
+
import React, { forwardRef } from "react"
|
|
2
2
|
import { default as cn } from "classnames"
|
|
3
3
|
|
|
4
4
|
export type AcceptedInputTypes =
|
|
@@ -15,13 +15,13 @@ export type AcceptedInputTypes =
|
|
|
15
15
|
| "url"
|
|
16
16
|
| "currency"
|
|
17
17
|
|
|
18
|
-
export interface IInputFieldProps extends React.
|
|
18
|
+
export interface IInputFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> {
|
|
19
19
|
/** Callback on change */
|
|
20
20
|
handleChange: (value: string) => void
|
|
21
21
|
/** Input ID*/
|
|
22
|
-
id
|
|
22
|
+
id?: string
|
|
23
23
|
/** Input Name */
|
|
24
|
-
name
|
|
24
|
+
name?: string
|
|
25
25
|
/** Force the focus state on the input */
|
|
26
26
|
isFocused?: boolean
|
|
27
27
|
/** Error condition */
|
|
@@ -38,49 +38,50 @@ export interface IInputFieldProps extends React.ComponentPropsWithoutRef<"input"
|
|
|
38
38
|
required?: boolean
|
|
39
39
|
/** use input psuedo classes for :valid and :invalid styles. on by default */
|
|
40
40
|
clientSideCheck?: boolean
|
|
41
|
+
/** Placeholder text */
|
|
42
|
+
placeholder?: string
|
|
41
43
|
/**ref for input */
|
|
42
|
-
ref?: React.Ref<HTMLInputElement>
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
const InputField
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
46
|
+
const InputField = (
|
|
47
|
+
{
|
|
48
|
+
type,
|
|
49
|
+
id,
|
|
50
|
+
name,
|
|
51
|
+
value,
|
|
52
|
+
isFocused,
|
|
53
|
+
isError,
|
|
54
|
+
isReadonly,
|
|
55
|
+
isDisabled,
|
|
56
|
+
handleChange,
|
|
57
|
+
required,
|
|
58
|
+
clientSideCheck = true,
|
|
59
|
+
className,
|
|
60
|
+
placeholder,
|
|
61
|
+
...rest
|
|
62
|
+
}: IInputFieldProps,
|
|
63
|
+
ref: React.Ref<HTMLInputElement>
|
|
64
|
+
) => {
|
|
63
65
|
return (
|
|
64
66
|
<input
|
|
65
67
|
{...{
|
|
68
|
+
ref,
|
|
66
69
|
type,
|
|
67
70
|
id,
|
|
68
|
-
ref,
|
|
69
71
|
name,
|
|
70
72
|
value,
|
|
71
73
|
onChange: (e) => {
|
|
72
|
-
|
|
73
|
-
handleChange(e.target.value)
|
|
74
|
+
if (handleChange) handleChange(e.target.value)
|
|
74
75
|
},
|
|
75
76
|
autoFocus: isFocused,
|
|
76
77
|
readOnly: isReadonly,
|
|
77
78
|
disabled: isDisabled,
|
|
78
|
-
placeholder: placeholder ||
|
|
79
|
+
placeholder: placeholder || undefined,
|
|
79
80
|
required,
|
|
80
81
|
"aria-invalid": isError,
|
|
81
82
|
"aria-disabled": isDisabled,
|
|
82
83
|
className: cn(
|
|
83
|
-
"peer w-full rounded border border-gray-
|
|
84
|
+
"peer w-full rounded border border-gray-300 px-3 text-sm font-normal leading-5 outline-offset-0 ring-offset-0 focus:border-purple-600 focus:ring-purple-600 ",
|
|
84
85
|
isError ? "!border-red-600 !text-red-600 focus:!ring-red-600" : "",
|
|
85
86
|
isReadonly ? "!border-gray-400 !text-gray-500 focus:!ring-gray-400" : "",
|
|
86
87
|
className
|
|
@@ -91,4 +92,5 @@ const InputField: React.FC<IInputFieldProps> = ({
|
|
|
91
92
|
)
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
const _InputField = forwardRef<HTMLInputElement, IInputFieldProps>(InputField)
|
|
96
|
+
export default _InputField
|
|
@@ -31,7 +31,7 @@ const InputLabel: FC<IInputLabelProps> = ({
|
|
|
31
31
|
{ "text-xs text-gray-700 px-1 top-[10px] bg-white": isPlaceholder && isActive },
|
|
32
32
|
{ "text-xs text-red-500 px-1 top-[10px] bg-white": isPlaceholder && isError },
|
|
33
33
|
{ "text-red-500 bg-white": !isPlaceholder && isError },
|
|
34
|
-
{ "text-gray-
|
|
34
|
+
{ "text-gray-500/[.5]": isDisabled }
|
|
35
35
|
)
|
|
36
36
|
if (!label) return null
|
|
37
37
|
return (
|