@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,186 +1,186 @@
|
|
|
1
|
-
import React, { FC, useEffect, useId, useRef, useState } from "react"
|
|
2
|
-
import { default as cn } from "classnames"
|
|
3
|
-
|
|
4
|
-
import { InputSelect } from "./InputSelect"
|
|
5
|
-
import { AcceptedInputTypes, InputField } from "@/stories/molecules"
|
|
6
|
-
import InputCounter from "@/stories/molecules/inputs/InputCounter"
|
|
7
|
-
|
|
8
|
-
export type SelectOptions = {
|
|
9
|
-
label: string
|
|
10
|
-
value: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface ITextInputSelectProps {
|
|
14
|
-
/** Input type*/
|
|
15
|
-
type: AcceptedInputTypes
|
|
16
|
-
/** Input ID */
|
|
17
|
-
id?: string
|
|
18
|
-
/** Input Name */
|
|
19
|
-
name?: string
|
|
20
|
-
/** Label for the input */
|
|
21
|
-
label?: string
|
|
22
|
-
/** placeholder for the input */
|
|
23
|
-
placeholder?: string
|
|
24
|
-
/** Force the focus state on the input */
|
|
25
|
-
isFocused?: boolean
|
|
26
|
-
/** Error state */
|
|
27
|
-
isError?: boolean
|
|
28
|
-
/** If field is required */
|
|
29
|
-
isRequired?: boolean
|
|
30
|
-
/** Disabled state */
|
|
31
|
-
isDisabled?: boolean
|
|
32
|
-
/** Set default value */
|
|
33
|
-
defaultValue?: string
|
|
34
|
-
/** Set value */
|
|
35
|
-
value: string
|
|
36
|
-
/** Message shown under the text field */
|
|
37
|
-
message?: string
|
|
38
|
-
/** Input character counter */
|
|
39
|
-
isShowCounter?: boolean
|
|
40
|
-
/** Max length of input character */
|
|
41
|
-
maxLength?: number
|
|
42
|
-
/** Select input location */
|
|
43
|
-
selectLocation?: "left" | "right"
|
|
44
|
-
/** Prefix */
|
|
45
|
-
prefix?: string
|
|
46
|
-
/** List of options to show on the select field */
|
|
47
|
-
inputOptions?: SelectOptions[]
|
|
48
|
-
/** Callback on base input */
|
|
49
|
-
onChange?(value: string): void
|
|
50
|
-
/** Callback on input select field */
|
|
51
|
-
onSelectOption?(value: string): void
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const TextInputSelect: FC<ITextInputSelectProps> = ({
|
|
55
|
-
label,
|
|
56
|
-
isFocused,
|
|
57
|
-
isError,
|
|
58
|
-
id,
|
|
59
|
-
name,
|
|
60
|
-
isRequired,
|
|
61
|
-
type,
|
|
62
|
-
defaultValue,
|
|
63
|
-
isDisabled,
|
|
64
|
-
message,
|
|
65
|
-
isShowCounter,
|
|
66
|
-
maxLength,
|
|
67
|
-
placeholder,
|
|
68
|
-
inputOptions,
|
|
69
|
-
selectLocation = "right",
|
|
70
|
-
prefix,
|
|
71
|
-
onChange,
|
|
72
|
-
onSelectOption,
|
|
73
|
-
value: externalValue
|
|
74
|
-
}: ITextInputSelectProps) => {
|
|
75
|
-
const [isFocus, setIsFocus] = useState<boolean>(Boolean(isFocused))
|
|
76
|
-
const [value, setValue] = useState<string>(defaultValue || "")
|
|
77
|
-
const inputRef = useRef<HTMLInputElement>(null)
|
|
78
|
-
|
|
79
|
-
const uniqueID = useId()
|
|
80
|
-
if (!id) id = `select-${uniqueID}`
|
|
81
|
-
if (!name) name = id
|
|
82
|
-
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
setValue(externalValue)
|
|
85
|
-
}, [externalValue])
|
|
86
|
-
|
|
87
|
-
// set force focus
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
const input = inputRef.current
|
|
90
|
-
if (!input || isFocus === undefined || isFocused === undefined || isDisabled) return
|
|
91
|
-
if (isFocus || isFocused) {
|
|
92
|
-
input.focus()
|
|
93
|
-
} else {
|
|
94
|
-
input.blur()
|
|
95
|
-
}
|
|
96
|
-
}, [isFocus, isFocused])
|
|
97
|
-
|
|
98
|
-
// set label as active if default value is set
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
const input = inputRef.current
|
|
101
|
-
if (!input || defaultValue === undefined || defaultValue === "") return
|
|
102
|
-
}, [defaultValue])
|
|
103
|
-
|
|
104
|
-
const handleInputFocus = (): void => {
|
|
105
|
-
setIsFocus(true)
|
|
106
|
-
// add other focus effects here
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const handleInputBlur = (): void => {
|
|
110
|
-
setIsFocus(false)
|
|
111
|
-
// add other focus effects here
|
|
112
|
-
}
|
|
113
|
-
const labelStyles = cn("block inline-block font-medium transition-all text-sm text-gray-700 mb-1", {
|
|
114
|
-
"text-red-500 bg-white": isError
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
const discriptionStyles = cn("text-sm mt-1 block", { "text-gray-500": !isError }, { "text-red-500": isError })
|
|
118
|
-
|
|
119
|
-
return (
|
|
120
|
-
<div>
|
|
121
|
-
{label && (
|
|
122
|
-
<label htmlFor={id} className={labelStyles}>
|
|
123
|
-
{label}
|
|
124
|
-
{isRequired && <span className="text-red-500"> *</span>}
|
|
125
|
-
</label>
|
|
126
|
-
)}
|
|
127
|
-
<div className="flex">
|
|
128
|
-
{inputOptions?.length && selectLocation === "left" && (
|
|
129
|
-
<InputSelect
|
|
130
|
-
inputOptions={inputOptions}
|
|
131
|
-
align="left"
|
|
132
|
-
onSelectOption={onSelectOption}
|
|
133
|
-
className={cn(isError ? "border-red-500" : "")}
|
|
134
|
-
isDisabled={isDisabled}
|
|
135
|
-
/>
|
|
136
|
-
)}
|
|
137
|
-
<div className="relative flex-grow focus-within:z-20">
|
|
138
|
-
{prefix && (
|
|
139
|
-
<div className="pointer-events-none pr-10 absolute inset-y-0 left-0 flex items-center pl-3">
|
|
140
|
-
<span className="text-gray-500 sm:text-sm">{prefix}</span>
|
|
141
|
-
</div>
|
|
142
|
-
)}
|
|
143
|
-
<InputField
|
|
144
|
-
onFocus={handleInputFocus}
|
|
145
|
-
onBlur={handleInputBlur}
|
|
146
|
-
handleChange={(v) => onChange && onChange(v)}
|
|
147
|
-
ref={inputRef}
|
|
148
|
-
type={type}
|
|
149
|
-
name={name}
|
|
150
|
-
id={id}
|
|
151
|
-
className={cn(
|
|
152
|
-
"w-full border border-gray-300 py-2 px-3 text-sm font-normal leading-5",
|
|
153
|
-
"focus:border-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500 sm:text-sm",
|
|
154
|
-
selectLocation === "right" ? `rounded-l` : `rounded-r`,
|
|
155
|
-
isError ? "border-red-500" : "",
|
|
156
|
-
prefix ? `pl-7` : ""
|
|
157
|
-
)}
|
|
158
|
-
isDisabled={isDisabled}
|
|
159
|
-
defaultValue={defaultValue}
|
|
160
|
-
value={value}
|
|
161
|
-
maxLength={maxLength}
|
|
162
|
-
placeholder={placeholder}
|
|
163
|
-
/>
|
|
164
|
-
</div>
|
|
165
|
-
{inputOptions?.length && selectLocation === "right" && (
|
|
166
|
-
<InputSelect
|
|
167
|
-
inputOptions={inputOptions}
|
|
168
|
-
align={"right"}
|
|
169
|
-
onSelectOption={onSelectOption}
|
|
170
|
-
isDisabled={isDisabled}
|
|
171
|
-
className={cn(isError ? "border-red-500" : "")}
|
|
172
|
-
/>
|
|
173
|
-
)}
|
|
174
|
-
</div>
|
|
175
|
-
<div className="flex flex-row space-x-3">
|
|
176
|
-
<div className="grow">{message && <span className={discriptionStyles}>{message}</span>}</div>
|
|
177
|
-
{isShowCounter && (
|
|
178
|
-
<div className="shrink-0">
|
|
179
|
-
<InputCounter current={Number(value?.length)} limit={maxLength} />
|
|
180
|
-
</div>
|
|
181
|
-
)}
|
|
182
|
-
</div>
|
|
183
|
-
</div>
|
|
184
|
-
)
|
|
185
|
-
}
|
|
186
|
-
export default TextInputSelect
|
|
1
|
+
import React, { FC, useEffect, useId, useRef, useState } from "react"
|
|
2
|
+
import { default as cn } from "classnames"
|
|
3
|
+
|
|
4
|
+
import { InputSelect } from "./InputSelect"
|
|
5
|
+
import { AcceptedInputTypes, InputField } from "@/stories/molecules"
|
|
6
|
+
import InputCounter from "@/stories/molecules/inputs/InputCounter"
|
|
7
|
+
|
|
8
|
+
export type SelectOptions = {
|
|
9
|
+
label: string
|
|
10
|
+
value: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ITextInputSelectProps {
|
|
14
|
+
/** Input type*/
|
|
15
|
+
type: AcceptedInputTypes
|
|
16
|
+
/** Input ID */
|
|
17
|
+
id?: string
|
|
18
|
+
/** Input Name */
|
|
19
|
+
name?: string
|
|
20
|
+
/** Label for the input */
|
|
21
|
+
label?: string
|
|
22
|
+
/** placeholder for the input */
|
|
23
|
+
placeholder?: string
|
|
24
|
+
/** Force the focus state on the input */
|
|
25
|
+
isFocused?: boolean
|
|
26
|
+
/** Error state */
|
|
27
|
+
isError?: boolean
|
|
28
|
+
/** If field is required */
|
|
29
|
+
isRequired?: boolean
|
|
30
|
+
/** Disabled state */
|
|
31
|
+
isDisabled?: boolean
|
|
32
|
+
/** Set default value */
|
|
33
|
+
defaultValue?: string
|
|
34
|
+
/** Set value */
|
|
35
|
+
value: string
|
|
36
|
+
/** Message shown under the text field */
|
|
37
|
+
message?: string
|
|
38
|
+
/** Input character counter */
|
|
39
|
+
isShowCounter?: boolean
|
|
40
|
+
/** Max length of input character */
|
|
41
|
+
maxLength?: number
|
|
42
|
+
/** Select input location */
|
|
43
|
+
selectLocation?: "left" | "right"
|
|
44
|
+
/** Prefix */
|
|
45
|
+
prefix?: string
|
|
46
|
+
/** List of options to show on the select field */
|
|
47
|
+
inputOptions?: SelectOptions[]
|
|
48
|
+
/** Callback on base input */
|
|
49
|
+
onChange?(value: string): void
|
|
50
|
+
/** Callback on input select field */
|
|
51
|
+
onSelectOption?(value: string): void
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const TextInputSelect: FC<ITextInputSelectProps> = ({
|
|
55
|
+
label,
|
|
56
|
+
isFocused,
|
|
57
|
+
isError,
|
|
58
|
+
id,
|
|
59
|
+
name,
|
|
60
|
+
isRequired,
|
|
61
|
+
type,
|
|
62
|
+
defaultValue,
|
|
63
|
+
isDisabled,
|
|
64
|
+
message,
|
|
65
|
+
isShowCounter,
|
|
66
|
+
maxLength,
|
|
67
|
+
placeholder,
|
|
68
|
+
inputOptions,
|
|
69
|
+
selectLocation = "right",
|
|
70
|
+
prefix,
|
|
71
|
+
onChange,
|
|
72
|
+
onSelectOption,
|
|
73
|
+
value: externalValue
|
|
74
|
+
}: ITextInputSelectProps) => {
|
|
75
|
+
const [isFocus, setIsFocus] = useState<boolean>(Boolean(isFocused))
|
|
76
|
+
const [value, setValue] = useState<string>(defaultValue || "")
|
|
77
|
+
const inputRef = useRef<HTMLInputElement>(null)
|
|
78
|
+
|
|
79
|
+
const uniqueID = useId()
|
|
80
|
+
if (!id) id = `select-${uniqueID}`
|
|
81
|
+
if (!name) name = id
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
setValue(externalValue)
|
|
85
|
+
}, [externalValue])
|
|
86
|
+
|
|
87
|
+
// set force focus
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
const input = inputRef.current
|
|
90
|
+
if (!input || isFocus === undefined || isFocused === undefined || isDisabled) return
|
|
91
|
+
if (isFocus || isFocused) {
|
|
92
|
+
input.focus()
|
|
93
|
+
} else {
|
|
94
|
+
input.blur()
|
|
95
|
+
}
|
|
96
|
+
}, [isFocus, isFocused])
|
|
97
|
+
|
|
98
|
+
// set label as active if default value is set
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
const input = inputRef.current
|
|
101
|
+
if (!input || defaultValue === undefined || defaultValue === "") return
|
|
102
|
+
}, [defaultValue])
|
|
103
|
+
|
|
104
|
+
const handleInputFocus = (): void => {
|
|
105
|
+
setIsFocus(true)
|
|
106
|
+
// add other focus effects here
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const handleInputBlur = (): void => {
|
|
110
|
+
setIsFocus(false)
|
|
111
|
+
// add other focus effects here
|
|
112
|
+
}
|
|
113
|
+
const labelStyles = cn("block inline-block font-medium transition-all text-sm text-gray-700 mb-1", {
|
|
114
|
+
"text-red-500 bg-white": isError
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
const discriptionStyles = cn("text-sm mt-1 block", { "text-gray-500": !isError }, { "text-red-500": isError })
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<div>
|
|
121
|
+
{label && (
|
|
122
|
+
<label htmlFor={id} className={labelStyles}>
|
|
123
|
+
{label}
|
|
124
|
+
{isRequired && <span className="text-red-500"> *</span>}
|
|
125
|
+
</label>
|
|
126
|
+
)}
|
|
127
|
+
<div className="flex">
|
|
128
|
+
{inputOptions?.length && selectLocation === "left" && (
|
|
129
|
+
<InputSelect
|
|
130
|
+
inputOptions={inputOptions}
|
|
131
|
+
align="left"
|
|
132
|
+
onSelectOption={onSelectOption}
|
|
133
|
+
className={cn(isError ? "border-red-500" : "")}
|
|
134
|
+
isDisabled={isDisabled}
|
|
135
|
+
/>
|
|
136
|
+
)}
|
|
137
|
+
<div className="relative flex-grow focus-within:z-20">
|
|
138
|
+
{prefix && (
|
|
139
|
+
<div className="pointer-events-none pr-10 absolute inset-y-0 left-0 flex items-center pl-3">
|
|
140
|
+
<span className="text-gray-500 sm:text-sm">{prefix}</span>
|
|
141
|
+
</div>
|
|
142
|
+
)}
|
|
143
|
+
<InputField
|
|
144
|
+
onFocus={handleInputFocus}
|
|
145
|
+
onBlur={handleInputBlur}
|
|
146
|
+
handleChange={(v) => onChange && onChange(v)}
|
|
147
|
+
ref={inputRef}
|
|
148
|
+
type={type}
|
|
149
|
+
name={name}
|
|
150
|
+
id={id}
|
|
151
|
+
className={cn(
|
|
152
|
+
"w-full border border-gray-300 py-2 px-3 text-sm font-normal leading-5",
|
|
153
|
+
"focus:border-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500 sm:text-sm",
|
|
154
|
+
selectLocation === "right" ? `rounded-l` : `rounded-r`,
|
|
155
|
+
isError ? "border-red-500" : "",
|
|
156
|
+
prefix ? `pl-7` : ""
|
|
157
|
+
)}
|
|
158
|
+
isDisabled={isDisabled}
|
|
159
|
+
defaultValue={defaultValue}
|
|
160
|
+
value={value}
|
|
161
|
+
maxLength={maxLength}
|
|
162
|
+
placeholder={placeholder}
|
|
163
|
+
/>
|
|
164
|
+
</div>
|
|
165
|
+
{inputOptions?.length && selectLocation === "right" && (
|
|
166
|
+
<InputSelect
|
|
167
|
+
inputOptions={inputOptions}
|
|
168
|
+
align={"right"}
|
|
169
|
+
onSelectOption={onSelectOption}
|
|
170
|
+
isDisabled={isDisabled}
|
|
171
|
+
className={cn(isError ? "border-red-500" : "")}
|
|
172
|
+
/>
|
|
173
|
+
)}
|
|
174
|
+
</div>
|
|
175
|
+
<div className="flex flex-row space-x-3">
|
|
176
|
+
<div className="grow">{message && <span className={discriptionStyles}>{message}</span>}</div>
|
|
177
|
+
{isShowCounter && (
|
|
178
|
+
<div className="shrink-0">
|
|
179
|
+
<InputCounter current={Number(value?.length)} limit={maxLength} />
|
|
180
|
+
</div>
|
|
181
|
+
)}
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
export default TextInputSelect
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import TextInputSelect, { ITextInputSelectProps } from "./TextInputSelect"
|
|
2
|
-
export type { ITextInputSelectProps }
|
|
3
|
-
export default TextInputSelect
|
|
1
|
+
import TextInputSelect, { ITextInputSelectProps } from "./TextInputSelect"
|
|
2
|
+
export type { ITextInputSelectProps }
|
|
3
|
+
export default TextInputSelect
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import AnimatedLabelInput, { IAnimatedLabelInputProps } from "./AnimatedLabelInput"
|
|
2
|
-
import AnimatedLabelTextArea, { IAnimatedLabelTextAreaProps } from "./AnimatedLabelTextArea"
|
|
3
|
-
import ButtonDropdown, { IButtonDropdownProps } from "./ButtonDropdown"
|
|
4
|
-
import Dropdown, { IDropdownProps, IItemProp } from "./DropdownComponent"
|
|
5
|
-
import EmptySectionPlaceholder, { IEmptySectionPlaceholderProps } from "./EmptySectionPlaceholder"
|
|
6
|
-
import FormInputWithAddons, { IFormInputWithAddonsProps } from "./FormInputWithAddons"
|
|
7
|
-
import TextInputSelect, { ITextInputSelectProps } from "./TextInputSelect"
|
|
8
|
-
|
|
9
|
-
export type {
|
|
10
|
-
IAnimatedLabelInputProps,
|
|
11
|
-
IAnimatedLabelTextAreaProps,
|
|
12
|
-
IButtonDropdownProps,
|
|
13
|
-
IDropdownProps,
|
|
14
|
-
IEmptySectionPlaceholderProps,
|
|
15
|
-
IItemProp,
|
|
16
|
-
IFormInputWithAddonsProps,
|
|
17
|
-
ITextInputSelectProps
|
|
18
|
-
}
|
|
19
|
-
export {
|
|
20
|
-
AnimatedLabelInput,
|
|
21
|
-
AnimatedLabelTextArea,
|
|
22
|
-
ButtonDropdown,
|
|
23
|
-
Dropdown,
|
|
24
|
-
EmptySectionPlaceholder,
|
|
25
|
-
FormInputWithAddons,
|
|
26
|
-
TextInputSelect
|
|
27
|
-
}
|
|
1
|
+
import AnimatedLabelInput, { IAnimatedLabelInputProps } from "./AnimatedLabelInput"
|
|
2
|
+
import AnimatedLabelTextArea, { IAnimatedLabelTextAreaProps } from "./AnimatedLabelTextArea"
|
|
3
|
+
import ButtonDropdown, { IButtonDropdownProps } from "./ButtonDropdown"
|
|
4
|
+
import Dropdown, { IDropdownProps, IItemProp } from "./DropdownComponent"
|
|
5
|
+
import EmptySectionPlaceholder, { IEmptySectionPlaceholderProps } from "./EmptySectionPlaceholder"
|
|
6
|
+
import FormInputWithAddons, { IFormInputWithAddonsProps } from "./FormInputWithAddons"
|
|
7
|
+
import TextInputSelect, { ITextInputSelectProps } from "./TextInputSelect"
|
|
8
|
+
|
|
9
|
+
export type {
|
|
10
|
+
IAnimatedLabelInputProps,
|
|
11
|
+
IAnimatedLabelTextAreaProps,
|
|
12
|
+
IButtonDropdownProps,
|
|
13
|
+
IDropdownProps,
|
|
14
|
+
IEmptySectionPlaceholderProps,
|
|
15
|
+
IItemProp,
|
|
16
|
+
IFormInputWithAddonsProps,
|
|
17
|
+
ITextInputSelectProps
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
AnimatedLabelInput,
|
|
21
|
+
AnimatedLabelTextArea,
|
|
22
|
+
ButtonDropdown,
|
|
23
|
+
Dropdown,
|
|
24
|
+
EmptySectionPlaceholder,
|
|
25
|
+
FormInputWithAddons,
|
|
26
|
+
TextInputSelect
|
|
27
|
+
}
|