@agility/plenum-ui 2.0.0-rc47 → 2.0.0-rc49
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/.eslintrc.json +6 -6
- package/.prettierrc +13 -13
- package/.storybook/Layout.jsx +12 -12
- package/.storybook/head.tsx +4 -4
- package/.storybook/main.ts +18 -18
- package/.storybook/manager-head.html +1 -1
- package/.storybook/manager.ts +25 -25
- package/.storybook/plenumTheme.ts +8 -8
- package/.storybook/preview-head.html +3 -3
- package/.storybook/preview.tsx +28 -28
- package/.vscode/settings.json +3 -3
- package/README.md +271 -271
- package/app/globals.css +99 -99
- package/app/head.tsx +59 -59
- package/app/layout.tsx +28 -28
- package/app/page.tsx +7 -7
- package/build.js +45 -45
- package/dist/index.d.ts +232 -230
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/types/stories/molecules/inputs/select/Select.d.ts +2 -0
- package/local.sh +100 -100
- package/next.config.js +8 -8
- package/package.json +82 -82
- package/pages/api/hello.ts +13 -13
- package/postcss.config.js +6 -6
- package/rollup.config.mjs +41 -41
- package/scripts/create-component.js +97 -97
- package/stories/Introduction.mdx +314 -314
- package/stories/assets/stackalt.svg +1 -1
- package/stories/atoms/Avatar/Avatar.stories.tsx +96 -96
- package/stories/atoms/Avatar/Avatar.tsx +123 -123
- package/stories/atoms/Avatar/index.ts +3 -3
- package/stories/atoms/badges/Badge.tsx +127 -127
- package/stories/atoms/badges/Pill/Pill.stories.tsx +75 -75
- package/stories/atoms/badges/Rounded/Rounded.stories.tsx +75 -75
- package/stories/atoms/badges/index.ts +3 -3
- package/stories/atoms/buttons/Button/Alternative/Alternative.stories.ts +86 -86
- package/stories/atoms/buttons/Button/Button.tsx +232 -232
- package/stories/atoms/buttons/Button/Danger/Danger.stories.ts +90 -90
- package/stories/atoms/buttons/Button/Primary/Primary.stories.ts +97 -97
- package/stories/atoms/buttons/Button/Secondary/Secondary.stories.ts +93 -93
- package/stories/atoms/buttons/Button/defaultArgs.ts +9 -9
- package/stories/atoms/buttons/Button/index.ts +3 -3
- package/stories/atoms/buttons/Capsule/Alternative/Alternative.stories.ts +27 -27
- package/stories/atoms/buttons/Capsule/Capsule.tsx +88 -88
- package/stories/atoms/buttons/Capsule/Danger/Danger.stories.ts +27 -27
- package/stories/atoms/buttons/Capsule/Primary/Primary.stories.ts +27 -27
- package/stories/atoms/buttons/Capsule/Secondary/Secondary.stories.ts +27 -27
- package/stories/atoms/buttons/Capsule/index.ts +3 -3
- package/stories/atoms/buttons/FloatingActionButton/FloatingActionButton.stories.tsx +15 -15
- package/stories/atoms/buttons/FloatingActionButton/FloatingActionButton.tsx +22 -22
- package/stories/atoms/buttons/FloatingActionButton/index.tsx +3 -3
- package/stories/atoms/buttons/index.ts +4 -4
- package/stories/atoms/crumb/Crumb.stories.tsx +18 -18
- package/stories/atoms/crumb/Crumb.tsx +22 -22
- package/stories/atoms/crumb/index.tsx +3 -3
- package/stories/atoms/icons/DynamicIcon.stories.ts +43 -43
- package/stories/atoms/icons/DynamicIcon.tsx +90 -90
- package/stories/atoms/icons/IconWithShadow.stories.ts +43 -43
- package/stories/atoms/icons/IconWithShadow.tsx +16 -16
- package/stories/atoms/icons/TablerIcon.tsx +22 -22
- package/stories/atoms/icons/index.tsx +14 -14
- package/stories/atoms/icons/tablerIconNames.ts +4336 -4336
- package/stories/atoms/index.ts +46 -46
- package/stories/atoms/loaders/Loader.stories.ts +15 -15
- package/stories/atoms/loaders/Loader.tsx +21 -21
- package/stories/atoms/loaders/NProgress/RadialProgress.stories.tsx +19 -19
- package/stories/atoms/loaders/NProgress/RadialProgress.tsx +74 -74
- package/stories/atoms/loaders/NProgress/index.ts +3 -3
- package/stories/atoms/loaders/index.ts +4 -4
- package/stories/index.ts +136 -136
- package/stories/molecules/index.ts +51 -51
- package/stories/molecules/inputs/InputCounter/InputCounter.stories.tsx +18 -18
- package/stories/molecules/inputs/InputCounter/InputCounter.tsx +24 -24
- package/stories/molecules/inputs/InputCounter/index.tsx +3 -3
- package/stories/molecules/inputs/InputField/InputField.stories.tsx +29 -29
- package/stories/molecules/inputs/InputField/InputField.tsx +96 -96
- package/stories/molecules/inputs/InputField/index.tsx +3 -3
- package/stories/molecules/inputs/InputLabel/InputLabel.stories.tsx +19 -19
- package/stories/molecules/inputs/InputLabel/InputLabel.tsx +45 -45
- package/stories/molecules/inputs/InputLabel/index.tsx +3 -3
- package/stories/molecules/inputs/NestedInputButton/NestedInputButton.stories.tsx +52 -52
- package/stories/molecules/inputs/NestedInputButton/NestedInputButton.tsx +64 -64
- package/stories/molecules/inputs/NestedInputButton/index.tsx +3 -3
- package/stories/molecules/inputs/TextInput/TextInput.stories.tsx +32 -32
- package/stories/molecules/inputs/TextInput/TextInput.tsx +165 -165
- package/stories/molecules/inputs/TextInput/index.tsx +5 -5
- package/stories/molecules/inputs/checkbox/Checkbox.stories.ts +23 -23
- package/stories/molecules/inputs/checkbox/Checkbox.tsx +98 -98
- package/stories/molecules/inputs/checkbox/index.ts +3 -3
- package/stories/molecules/inputs/combobox/ComboBox.stories.ts +41 -41
- package/stories/molecules/inputs/combobox/ComboBox.tsx +185 -185
- package/stories/molecules/inputs/combobox/index.ts +3 -3
- package/stories/molecules/inputs/index.ts +38 -38
- package/stories/molecules/inputs/radio/Radio.stories.ts +27 -27
- package/stories/molecules/inputs/radio/Radio.tsx +92 -92
- package/stories/molecules/inputs/radio/index.ts +3 -3
- package/stories/molecules/inputs/select/Select.stories.ts +23 -23
- package/stories/molecules/inputs/select/Select.tsx +108 -100
- package/stories/molecules/inputs/select/index.ts +3 -3
- package/stories/molecules/inputs/textArea/TextArea.stories.ts +22 -22
- package/stories/molecules/inputs/textArea/TextArea.tsx +158 -158
- package/stories/molecules/inputs/textArea/index.ts +3 -3
- package/stories/molecules/inputs/toggleSwitch/ToggleSwitch.stories.tsx +118 -118
- package/stories/molecules/inputs/toggleSwitch/ToggleSwitch.tsx +81 -81
- package/stories/molecules/inputs/toggleSwitch/index.ts +3 -3
- package/stories/molecules/tabs/Tabs.stories.tsx +18 -18
- package/stories/molecules/tabs/Tabs.tsx +22 -22
- package/stories/molecules/tabs/index.tsx +2 -2
- package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.stories.tsx +30 -30
- package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.tsx +66 -66
- package/stories/organisms/AnimatedLabelInput/index.tsx +3 -3
- package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.stories.tsx +26 -26
- package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.tsx +61 -61
- package/stories/organisms/AnimatedLabelTextArea/index.tsx +3 -3
- package/stories/organisms/ButtonDropdown/ButtonDropdown.stories.tsx +125 -125
- package/stories/organisms/ButtonDropdown/ButtonDropdown.tsx +86 -86
- package/stories/organisms/ButtonDropdown/index.tsx +3 -3
- package/stories/organisms/DropdownComponent/Dropdown.stories.tsx +73 -73
- package/stories/organisms/DropdownComponent/DropdownComponent.tsx +346 -346
- package/stories/organisms/DropdownComponent/dropdownItems.ts +122 -122
- package/stories/organisms/DropdownComponent/index.ts +4 -4
- package/stories/organisms/EmptySectionPlaceholder/EmptySectionPlaceholder.stories.tsx +76 -76
- package/stories/organisms/EmptySectionPlaceholder/EmptySectionPlaceholder.tsx +52 -52
- package/stories/organisms/EmptySectionPlaceholder/index.tsx +4 -4
- package/stories/organisms/FormInputWithAddons/FormInputWithAddons.stories.tsx +29 -29
- package/stories/organisms/FormInputWithAddons/FormInputWithAddons.tsx +145 -145
- package/stories/organisms/FormInputWithAddons/index.tsx +3 -3
- package/stories/organisms/TextInputSelect/InputSelect.tsx +59 -59
- package/stories/organisms/TextInputSelect/TextInputSelect.stories.tsx +33 -33
- package/stories/organisms/TextInputSelect/TextInputSelect.tsx +186 -186
- package/stories/organisms/TextInputSelect/index.tsx +3 -3
- package/stories/organisms/index.ts +27 -27
- package/tailwind.config.js +192 -192
- package/tsconfig.json +29 -29
- package/tsconfig.lib.json +25 -25
- package/utils/types.d.ts +2 -2
- package/utils/types.ts +3 -3
- package/utils/useId.d.ts +1 -1
- package/utils/useId.tsx +16 -16
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
import { DynamicIcon, IDynamicIconProps } from "@/stories/atoms/icons"
|
|
2
|
-
import React, { useLayoutEffect, useRef, useState } from "react"
|
|
3
|
-
import { default as cn } from "classnames"
|
|
4
|
-
import InputField, { IInputFieldProps, AcceptedInputTypes } from "@/stories/molecules/inputs/InputField"
|
|
5
|
-
|
|
6
|
-
export interface IFormInputWithAddonsProps extends Omit<IInputFieldProps, "type"> {
|
|
7
|
-
leadIcon?: IDynamicIconProps
|
|
8
|
-
leadLabel?: string
|
|
9
|
-
trailIcon?: IDynamicIconProps
|
|
10
|
-
trailLabel?: string
|
|
11
|
-
iconOutlined?: boolean
|
|
12
|
-
/** @param addonOffset An extra buffer zone in pixels between the trailing/leading icon or label and search input -- Default is 24 */
|
|
13
|
-
addonOffset?: number
|
|
14
|
-
topLabel?: string
|
|
15
|
-
labelClass?: string
|
|
16
|
-
containerClassName?: string
|
|
17
|
-
description?: string
|
|
18
|
-
leadIconClassNames?: string
|
|
19
|
-
customIconClass?: string
|
|
20
|
-
type: AcceptedInputTypes
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const FormInputWithAddons: React.FC<IFormInputWithAddonsProps> = ({
|
|
24
|
-
handleChange,
|
|
25
|
-
value,
|
|
26
|
-
name,
|
|
27
|
-
id,
|
|
28
|
-
placeholder,
|
|
29
|
-
className,
|
|
30
|
-
containerClassName,
|
|
31
|
-
leadIcon,
|
|
32
|
-
leadLabel,
|
|
33
|
-
trailIcon,
|
|
34
|
-
trailLabel,
|
|
35
|
-
topLabel,
|
|
36
|
-
labelClass,
|
|
37
|
-
isDisabled,
|
|
38
|
-
isReadonly,
|
|
39
|
-
isError,
|
|
40
|
-
addonOffset = 24,
|
|
41
|
-
iconOutlined = false,
|
|
42
|
-
description,
|
|
43
|
-
leadIconClassNames,
|
|
44
|
-
customIconClass,
|
|
45
|
-
type,
|
|
46
|
-
...rest
|
|
47
|
-
}) => {
|
|
48
|
-
// #region logic to determine the width of the lead and or trailing labels in order to offset the input padding by the appropriate amount.
|
|
49
|
-
const leadLabelRef = useRef<HTMLLabelElement>(null)
|
|
50
|
-
const trailLabelRef = useRef<HTMLLabelElement>(null)
|
|
51
|
-
const [leadLabelWidth, setLeadLabelWidth] = useState<number>(0)
|
|
52
|
-
const [trailLabelWidth, setTrailLabelWidth] = useState<number>(0)
|
|
53
|
-
useLayoutEffect(() => {
|
|
54
|
-
setLeadLabelWidth(leadLabelRef.current?.clientWidth || 0)
|
|
55
|
-
setTrailLabelWidth(trailLabelRef.current?.clientWidth || 0)
|
|
56
|
-
}, [])
|
|
57
|
-
// #endregion
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<div className={cn("group flex flex-col", containerClassName)}>
|
|
61
|
-
{!leadLabel && !trailLabel && topLabel && (
|
|
62
|
-
<label htmlFor={id} className={cn("flex items-center text-sm font-medium text-gray-600", labelClass)}>
|
|
63
|
-
{topLabel}
|
|
64
|
-
</label>
|
|
65
|
-
)}
|
|
66
|
-
{description && <div className="mb-2 text-sm text-gray-500">{description}</div>}
|
|
67
|
-
<div className="relative flex-grow">
|
|
68
|
-
{(leadLabel || leadIcon) && (
|
|
69
|
-
<label
|
|
70
|
-
ref={leadLabelRef}
|
|
71
|
-
htmlFor={id}
|
|
72
|
-
className={cn(
|
|
73
|
-
"absolute top-0 bottom-0 left-3 flex items-center justify-center text-sm text-gray-500",
|
|
74
|
-
labelClass
|
|
75
|
-
)}
|
|
76
|
-
>
|
|
77
|
-
{leadIcon && (
|
|
78
|
-
<span>
|
|
79
|
-
<DynamicIcon
|
|
80
|
-
{...{
|
|
81
|
-
...leadIcon,
|
|
82
|
-
className: cn(
|
|
83
|
-
"h-5 w-5 text-gray-400",
|
|
84
|
-
leadIconClassNames,
|
|
85
|
-
customIconClass,
|
|
86
|
-
leadIcon.className
|
|
87
|
-
),
|
|
88
|
-
outline: iconOutlined
|
|
89
|
-
}}
|
|
90
|
-
/>
|
|
91
|
-
</span>
|
|
92
|
-
)}
|
|
93
|
-
{leadLabel && leadLabel}
|
|
94
|
-
</label>
|
|
95
|
-
)}
|
|
96
|
-
<InputField
|
|
97
|
-
{...{
|
|
98
|
-
...rest,
|
|
99
|
-
handleChange,
|
|
100
|
-
value,
|
|
101
|
-
id,
|
|
102
|
-
name,
|
|
103
|
-
type,
|
|
104
|
-
autoComplete: "off",
|
|
105
|
-
disabled: isDisabled,
|
|
106
|
-
placeholder: placeholder || "",
|
|
107
|
-
isReadonly,
|
|
108
|
-
isError,
|
|
109
|
-
className,
|
|
110
|
-
// add padding to accomodate inner labels and icons
|
|
111
|
-
style: {
|
|
112
|
-
paddingRight: `${trailLabelWidth + addonOffset}px`,
|
|
113
|
-
paddingLeft: `${leadLabelWidth + addonOffset}px`
|
|
114
|
-
}
|
|
115
|
-
}}
|
|
116
|
-
/>
|
|
117
|
-
{(trailLabel || trailIcon) && (
|
|
118
|
-
<label
|
|
119
|
-
ref={trailLabelRef}
|
|
120
|
-
htmlFor={id}
|
|
121
|
-
className={cn(
|
|
122
|
-
"right absolute top-0 bottom-0 right-3 flex items-center justify-center text-sm !text-gray-500 ",
|
|
123
|
-
labelClass
|
|
124
|
-
)}
|
|
125
|
-
>
|
|
126
|
-
{trailIcon && (
|
|
127
|
-
<span>
|
|
128
|
-
<DynamicIcon
|
|
129
|
-
{...{
|
|
130
|
-
...trailIcon,
|
|
131
|
-
className: cn("h-5 w-5 text-gray-400", customIconClass, trailIcon.className),
|
|
132
|
-
outline: iconOutlined
|
|
133
|
-
}}
|
|
134
|
-
/>
|
|
135
|
-
</span>
|
|
136
|
-
)}
|
|
137
|
-
{trailLabel && trailLabel}
|
|
138
|
-
</label>
|
|
139
|
-
)}
|
|
140
|
-
</div>
|
|
141
|
-
</div>
|
|
142
|
-
)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export default FormInputWithAddons
|
|
1
|
+
import { DynamicIcon, IDynamicIconProps } from "@/stories/atoms/icons"
|
|
2
|
+
import React, { useLayoutEffect, useRef, useState } from "react"
|
|
3
|
+
import { default as cn } from "classnames"
|
|
4
|
+
import InputField, { IInputFieldProps, AcceptedInputTypes } from "@/stories/molecules/inputs/InputField"
|
|
5
|
+
|
|
6
|
+
export interface IFormInputWithAddonsProps extends Omit<IInputFieldProps, "type"> {
|
|
7
|
+
leadIcon?: IDynamicIconProps
|
|
8
|
+
leadLabel?: string
|
|
9
|
+
trailIcon?: IDynamicIconProps
|
|
10
|
+
trailLabel?: string
|
|
11
|
+
iconOutlined?: boolean
|
|
12
|
+
/** @param addonOffset An extra buffer zone in pixels between the trailing/leading icon or label and search input -- Default is 24 */
|
|
13
|
+
addonOffset?: number
|
|
14
|
+
topLabel?: string
|
|
15
|
+
labelClass?: string
|
|
16
|
+
containerClassName?: string
|
|
17
|
+
description?: string
|
|
18
|
+
leadIconClassNames?: string
|
|
19
|
+
customIconClass?: string
|
|
20
|
+
type: AcceptedInputTypes
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const FormInputWithAddons: React.FC<IFormInputWithAddonsProps> = ({
|
|
24
|
+
handleChange,
|
|
25
|
+
value,
|
|
26
|
+
name,
|
|
27
|
+
id,
|
|
28
|
+
placeholder,
|
|
29
|
+
className,
|
|
30
|
+
containerClassName,
|
|
31
|
+
leadIcon,
|
|
32
|
+
leadLabel,
|
|
33
|
+
trailIcon,
|
|
34
|
+
trailLabel,
|
|
35
|
+
topLabel,
|
|
36
|
+
labelClass,
|
|
37
|
+
isDisabled,
|
|
38
|
+
isReadonly,
|
|
39
|
+
isError,
|
|
40
|
+
addonOffset = 24,
|
|
41
|
+
iconOutlined = false,
|
|
42
|
+
description,
|
|
43
|
+
leadIconClassNames,
|
|
44
|
+
customIconClass,
|
|
45
|
+
type,
|
|
46
|
+
...rest
|
|
47
|
+
}) => {
|
|
48
|
+
// #region logic to determine the width of the lead and or trailing labels in order to offset the input padding by the appropriate amount.
|
|
49
|
+
const leadLabelRef = useRef<HTMLLabelElement>(null)
|
|
50
|
+
const trailLabelRef = useRef<HTMLLabelElement>(null)
|
|
51
|
+
const [leadLabelWidth, setLeadLabelWidth] = useState<number>(0)
|
|
52
|
+
const [trailLabelWidth, setTrailLabelWidth] = useState<number>(0)
|
|
53
|
+
useLayoutEffect(() => {
|
|
54
|
+
setLeadLabelWidth(leadLabelRef.current?.clientWidth || 0)
|
|
55
|
+
setTrailLabelWidth(trailLabelRef.current?.clientWidth || 0)
|
|
56
|
+
}, [])
|
|
57
|
+
// #endregion
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div className={cn("group flex flex-col", containerClassName)}>
|
|
61
|
+
{!leadLabel && !trailLabel && topLabel && (
|
|
62
|
+
<label htmlFor={id} className={cn("flex items-center text-sm font-medium text-gray-600", labelClass)}>
|
|
63
|
+
{topLabel}
|
|
64
|
+
</label>
|
|
65
|
+
)}
|
|
66
|
+
{description && <div className="mb-2 text-sm text-gray-500">{description}</div>}
|
|
67
|
+
<div className="relative flex-grow">
|
|
68
|
+
{(leadLabel || leadIcon) && (
|
|
69
|
+
<label
|
|
70
|
+
ref={leadLabelRef}
|
|
71
|
+
htmlFor={id}
|
|
72
|
+
className={cn(
|
|
73
|
+
"absolute top-0 bottom-0 left-3 flex items-center justify-center text-sm text-gray-500",
|
|
74
|
+
labelClass
|
|
75
|
+
)}
|
|
76
|
+
>
|
|
77
|
+
{leadIcon && (
|
|
78
|
+
<span>
|
|
79
|
+
<DynamicIcon
|
|
80
|
+
{...{
|
|
81
|
+
...leadIcon,
|
|
82
|
+
className: cn(
|
|
83
|
+
"h-5 w-5 text-gray-400",
|
|
84
|
+
leadIconClassNames,
|
|
85
|
+
customIconClass,
|
|
86
|
+
leadIcon.className
|
|
87
|
+
),
|
|
88
|
+
outline: iconOutlined
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
</span>
|
|
92
|
+
)}
|
|
93
|
+
{leadLabel && leadLabel}
|
|
94
|
+
</label>
|
|
95
|
+
)}
|
|
96
|
+
<InputField
|
|
97
|
+
{...{
|
|
98
|
+
...rest,
|
|
99
|
+
handleChange,
|
|
100
|
+
value,
|
|
101
|
+
id,
|
|
102
|
+
name,
|
|
103
|
+
type,
|
|
104
|
+
autoComplete: "off",
|
|
105
|
+
disabled: isDisabled,
|
|
106
|
+
placeholder: placeholder || "",
|
|
107
|
+
isReadonly,
|
|
108
|
+
isError,
|
|
109
|
+
className,
|
|
110
|
+
// add padding to accomodate inner labels and icons
|
|
111
|
+
style: {
|
|
112
|
+
paddingRight: `${trailLabelWidth + addonOffset}px`,
|
|
113
|
+
paddingLeft: `${leadLabelWidth + addonOffset}px`
|
|
114
|
+
}
|
|
115
|
+
}}
|
|
116
|
+
/>
|
|
117
|
+
{(trailLabel || trailIcon) && (
|
|
118
|
+
<label
|
|
119
|
+
ref={trailLabelRef}
|
|
120
|
+
htmlFor={id}
|
|
121
|
+
className={cn(
|
|
122
|
+
"right absolute top-0 bottom-0 right-3 flex items-center justify-center text-sm !text-gray-500 ",
|
|
123
|
+
labelClass
|
|
124
|
+
)}
|
|
125
|
+
>
|
|
126
|
+
{trailIcon && (
|
|
127
|
+
<span>
|
|
128
|
+
<DynamicIcon
|
|
129
|
+
{...{
|
|
130
|
+
...trailIcon,
|
|
131
|
+
className: cn("h-5 w-5 text-gray-400", customIconClass, trailIcon.className),
|
|
132
|
+
outline: iconOutlined
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
</span>
|
|
136
|
+
)}
|
|
137
|
+
{trailLabel && trailLabel}
|
|
138
|
+
</label>
|
|
139
|
+
)}
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export default FormInputWithAddons
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import FormInputWithAddons, { IFormInputWithAddonsProps } from "./FormInputWithAddons"
|
|
2
|
-
export type { IFormInputWithAddonsProps }
|
|
3
|
-
export default FormInputWithAddons
|
|
1
|
+
import FormInputWithAddons, { IFormInputWithAddonsProps } from "./FormInputWithAddons"
|
|
2
|
+
export type { IFormInputWithAddonsProps }
|
|
3
|
+
export default FormInputWithAddons
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import React, { FC, useState } from "react"
|
|
2
|
-
import { default as cn } from "classnames"
|
|
3
|
-
|
|
4
|
-
export type SelectOptions = {
|
|
5
|
-
label: string
|
|
6
|
-
value: string
|
|
7
|
-
}
|
|
8
|
-
export interface InputSelectProps {
|
|
9
|
-
align: "left" | "right"
|
|
10
|
-
/** Show the CTA without Background color and a border seperator */
|
|
11
|
-
inputOptions: SelectOptions[]
|
|
12
|
-
/** Onclick callback */
|
|
13
|
-
onSelectOption?(value: string): void
|
|
14
|
-
className?: string
|
|
15
|
-
isDisabled?: boolean
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** Comment */
|
|
19
|
-
export const InputSelect: FC<InputSelectProps> = ({
|
|
20
|
-
inputOptions,
|
|
21
|
-
onSelectOption,
|
|
22
|
-
align = "right",
|
|
23
|
-
className,
|
|
24
|
-
isDisabled
|
|
25
|
-
}: InputSelectProps): JSX.Element | null => {
|
|
26
|
-
const [selectedOption, setSelectedOption] = useState<string>(inputOptions[0].value)
|
|
27
|
-
|
|
28
|
-
const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
29
|
-
const targetValue = e.target.value
|
|
30
|
-
onSelectOption && onSelectOption(targetValue)
|
|
31
|
-
setSelectedOption(targetValue)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!inputOptions?.length) return null
|
|
35
|
-
return (
|
|
36
|
-
<select
|
|
37
|
-
className={cn(
|
|
38
|
-
"relative z-10 inline-flex items-center space-x-2 border border-gray-300 bg-white px-4 py-2 pr-7 text-sm font-medium",
|
|
39
|
-
"focus:border-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500",
|
|
40
|
-
align === "right"
|
|
41
|
-
? "-ml-px rounded-r border-l-white text-gray-700"
|
|
42
|
-
: align === "left"
|
|
43
|
-
? "-mr-px rounded-l border-r-white text-gray-500 focus-within:z-10"
|
|
44
|
-
: "",
|
|
45
|
-
!onSelectOption ? "cursor-default" : "",
|
|
46
|
-
className
|
|
47
|
-
)}
|
|
48
|
-
onChange={handleChange}
|
|
49
|
-
value={selectedOption}
|
|
50
|
-
disabled={isDisabled}
|
|
51
|
-
>
|
|
52
|
-
{inputOptions.map((option) => (
|
|
53
|
-
<option key={option.value} value={option.value}>
|
|
54
|
-
{option.label}
|
|
55
|
-
</option>
|
|
56
|
-
))}
|
|
57
|
-
</select>
|
|
58
|
-
)
|
|
59
|
-
}
|
|
1
|
+
import React, { FC, useState } from "react"
|
|
2
|
+
import { default as cn } from "classnames"
|
|
3
|
+
|
|
4
|
+
export type SelectOptions = {
|
|
5
|
+
label: string
|
|
6
|
+
value: string
|
|
7
|
+
}
|
|
8
|
+
export interface InputSelectProps {
|
|
9
|
+
align: "left" | "right"
|
|
10
|
+
/** Show the CTA without Background color and a border seperator */
|
|
11
|
+
inputOptions: SelectOptions[]
|
|
12
|
+
/** Onclick callback */
|
|
13
|
+
onSelectOption?(value: string): void
|
|
14
|
+
className?: string
|
|
15
|
+
isDisabled?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Comment */
|
|
19
|
+
export const InputSelect: FC<InputSelectProps> = ({
|
|
20
|
+
inputOptions,
|
|
21
|
+
onSelectOption,
|
|
22
|
+
align = "right",
|
|
23
|
+
className,
|
|
24
|
+
isDisabled
|
|
25
|
+
}: InputSelectProps): JSX.Element | null => {
|
|
26
|
+
const [selectedOption, setSelectedOption] = useState<string>(inputOptions[0].value)
|
|
27
|
+
|
|
28
|
+
const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
29
|
+
const targetValue = e.target.value
|
|
30
|
+
onSelectOption && onSelectOption(targetValue)
|
|
31
|
+
setSelectedOption(targetValue)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!inputOptions?.length) return null
|
|
35
|
+
return (
|
|
36
|
+
<select
|
|
37
|
+
className={cn(
|
|
38
|
+
"relative z-10 inline-flex items-center space-x-2 border border-gray-300 bg-white px-4 py-2 pr-7 text-sm font-medium",
|
|
39
|
+
"focus:border-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500",
|
|
40
|
+
align === "right"
|
|
41
|
+
? "-ml-px rounded-r border-l-white text-gray-700"
|
|
42
|
+
: align === "left"
|
|
43
|
+
? "-mr-px rounded-l border-r-white text-gray-500 focus-within:z-10"
|
|
44
|
+
: "",
|
|
45
|
+
!onSelectOption ? "cursor-default" : "",
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
48
|
+
onChange={handleChange}
|
|
49
|
+
value={selectedOption}
|
|
50
|
+
disabled={isDisabled}
|
|
51
|
+
>
|
|
52
|
+
{inputOptions.map((option) => (
|
|
53
|
+
<option key={option.value} value={option.value}>
|
|
54
|
+
{option.label}
|
|
55
|
+
</option>
|
|
56
|
+
))}
|
|
57
|
+
</select>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
-
import TextInputSelect from "."
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof TextInputSelect> = {
|
|
5
|
-
title: "Design System/organisms/TextInputSelect",
|
|
6
|
-
component: TextInputSelect,
|
|
7
|
-
tags: ["autodocs"],
|
|
8
|
-
argTypes: {}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default meta
|
|
12
|
-
type Story = StoryObj<typeof TextInputSelect>
|
|
13
|
-
export const DefaultTextInputSelectStory: Story = {
|
|
14
|
-
args: {
|
|
15
|
-
isFocused: false,
|
|
16
|
-
isError: false,
|
|
17
|
-
id: "input",
|
|
18
|
-
name: "input",
|
|
19
|
-
defaultValue: "",
|
|
20
|
-
isRequired: false,
|
|
21
|
-
isDisabled: false,
|
|
22
|
-
isShowCounter: false,
|
|
23
|
-
label: "Currency",
|
|
24
|
-
placeholder: "420.69",
|
|
25
|
-
type: "currency",
|
|
26
|
-
inputOptions: [
|
|
27
|
-
{ label: "USD", value: "USD" },
|
|
28
|
-
{ label: "CAD", value: "CAD" },
|
|
29
|
-
{ label: "EUR", value: "EUR" }
|
|
30
|
-
],
|
|
31
|
-
prefix: "$"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import TextInputSelect from "."
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof TextInputSelect> = {
|
|
5
|
+
title: "Design System/organisms/TextInputSelect",
|
|
6
|
+
component: TextInputSelect,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
argTypes: {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default meta
|
|
12
|
+
type Story = StoryObj<typeof TextInputSelect>
|
|
13
|
+
export const DefaultTextInputSelectStory: Story = {
|
|
14
|
+
args: {
|
|
15
|
+
isFocused: false,
|
|
16
|
+
isError: false,
|
|
17
|
+
id: "input",
|
|
18
|
+
name: "input",
|
|
19
|
+
defaultValue: "",
|
|
20
|
+
isRequired: false,
|
|
21
|
+
isDisabled: false,
|
|
22
|
+
isShowCounter: false,
|
|
23
|
+
label: "Currency",
|
|
24
|
+
placeholder: "420.69",
|
|
25
|
+
type: "currency",
|
|
26
|
+
inputOptions: [
|
|
27
|
+
{ label: "USD", value: "USD" },
|
|
28
|
+
{ label: "CAD", value: "CAD" },
|
|
29
|
+
{ label: "EUR", value: "EUR" }
|
|
30
|
+
],
|
|
31
|
+
prefix: "$"
|
|
32
|
+
}
|
|
33
|
+
}
|