@agility/plenum-ui 2.0.0-rc4 → 2.0.0-rc40
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 +278 -89
- package/dist/index.js +1 -5980
- package/dist/index.js.map +4 -4
- package/dist/tailwind.css +63599 -0
- 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 +3 -3
- package/dist/types/stories/molecules/inputs/InputCounter/InputCounter.d.ts +10 -0
- package/dist/types/stories/molecules/inputs/InputCounter/index.d.ts +2 -0
- package/dist/types/stories/molecules/inputs/InputField/InputField.d.ts +6 -4
- package/dist/types/stories/molecules/inputs/TextInput/TextInput.d.ts +39 -0
- package/dist/types/stories/molecules/inputs/TextInput/index.d.ts +4 -0
- package/dist/types/stories/molecules/inputs/index.d.ts +5 -4
- package/dist/types/stories/molecules/inputs/select/Select.d.ts +2 -2
- package/dist/types/stories/molecules/inputs/textArea/TextArea.d.ts +34 -21
- package/dist/types/stories/molecules/inputs/textArea/TextArea.stories.d.ts +4 -4
- package/dist/types/stories/molecules/inputs/textArea/index.d.ts +3 -3
- package/dist/types/stories/molecules/inputs/toggleSwitch/ToggleSwitch.d.ts +10 -7
- package/dist/types/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.d.ts +3 -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/DropdownComponent/DropdownComponent.d.ts +21 -12
- 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/TextInputSelect/InputSelect.d.ts +16 -0
- package/dist/types/stories/organisms/TextInputSelect/TextInputSelect.d.ts +48 -0
- package/dist/types/stories/organisms/TextInputSelect/index.d.ts +3 -0
- package/dist/types/stories/organisms/index.d.ts +5 -3
- package/local.sh +100 -0
- package/package.json +36 -19
- package/rollup.config.mjs +42 -0
- package/stories/Introduction.mdx +1 -1
- 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 +108 -24
- 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/index.ts +22 -10
- package/stories/molecules/index.ts +22 -6
- package/stories/molecules/inputs/InputField/InputField.tsx +10 -9
- package/stories/molecules/inputs/TextInput/TextInput.tsx +6 -3
- package/stories/molecules/inputs/TextInput/index.tsx +4 -2
- package/stories/molecules/inputs/checkbox/Checkbox.tsx +1 -2
- package/stories/molecules/inputs/combobox/ComboBox.tsx +126 -135
- package/stories/molecules/inputs/index.ts +18 -4
- package/stories/molecules/inputs/select/Select.tsx +1 -1
- package/stories/molecules/inputs/textArea/TextArea.stories.ts +7 -5
- package/stories/molecules/inputs/textArea/TextArea.tsx +139 -48
- package/stories/molecules/inputs/textArea/index.ts +3 -3
- 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 +43 -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 +65 -58
- package/stories/organisms/ButtonDropdown/ButtonDropdown.tsx +26 -21
- package/stories/organisms/DropdownComponent/Dropdown.stories.tsx +2 -2
- package/stories/organisms/DropdownComponent/DropdownComponent.tsx +213 -178
- 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/TextInputSelect/InputSelect.tsx +59 -0
- package/stories/organisms/TextInputSelect/TextInputSelect.stories.tsx +33 -0
- package/stories/organisms/TextInputSelect/TextInputSelect.tsx +186 -0
- package/stories/organisms/TextInputSelect/index.tsx +3 -0
- package/stories/organisms/index.ts +15 -4
- 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,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
|
package/stories/index.ts
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
INestedInputButtonProps,
|
|
35
35
|
IRadioProps,
|
|
36
36
|
ISelectProps,
|
|
37
|
-
|
|
37
|
+
ITextareaProps,
|
|
38
38
|
IToggleSwitchProps,
|
|
39
39
|
AcceptedInputTypes,
|
|
40
40
|
Checkbox,
|
|
@@ -44,14 +44,18 @@ import {
|
|
|
44
44
|
NestedInputButton,
|
|
45
45
|
Radio,
|
|
46
46
|
Select,
|
|
47
|
-
|
|
48
|
-
ToggleSwitch
|
|
47
|
+
Textarea,
|
|
48
|
+
ToggleSwitch,
|
|
49
|
+
TextInput,
|
|
50
|
+
ITextInputProps,
|
|
51
|
+
ISimpleSelectOptions
|
|
49
52
|
} from "./molecules"
|
|
50
53
|
// Organism Components, props, and type gaurds.
|
|
51
54
|
import {
|
|
52
55
|
IAnimatedLabelInputProps,
|
|
56
|
+
AnimatedLabelTextArea,
|
|
57
|
+
IAnimatedLabelTextAreaProps,
|
|
53
58
|
IButtonDropdownProps,
|
|
54
|
-
IDropdownClassnames,
|
|
55
59
|
IDropdownProps,
|
|
56
60
|
IEmptySectionPlaceholderProps,
|
|
57
61
|
IItemProp,
|
|
@@ -60,7 +64,9 @@ import {
|
|
|
60
64
|
ButtonDropdown,
|
|
61
65
|
Dropdown,
|
|
62
66
|
EmptySectionPlaceholder,
|
|
63
|
-
FormInputWithAddons
|
|
67
|
+
FormInputWithAddons,
|
|
68
|
+
TextInputSelect,
|
|
69
|
+
ITextInputSelectProps
|
|
64
70
|
} from "./organisms"
|
|
65
71
|
|
|
66
72
|
export type {
|
|
@@ -68,6 +74,7 @@ export type {
|
|
|
68
74
|
IBadgeProps,
|
|
69
75
|
IButtonProps,
|
|
70
76
|
ICapsuleProps,
|
|
77
|
+
ITextInputSelectProps,
|
|
71
78
|
IDynamicIconProps,
|
|
72
79
|
IIconWithShadowProps,
|
|
73
80
|
ILoaderProps,
|
|
@@ -79,12 +86,12 @@ export type {
|
|
|
79
86
|
INestedInputButtonProps,
|
|
80
87
|
IRadioProps,
|
|
81
88
|
ISelectProps,
|
|
82
|
-
|
|
89
|
+
ITextareaProps,
|
|
83
90
|
IToggleSwitchProps,
|
|
84
91
|
AcceptedInputTypes,
|
|
85
92
|
IAnimatedLabelInputProps,
|
|
93
|
+
IAnimatedLabelTextAreaProps,
|
|
86
94
|
IButtonDropdownProps,
|
|
87
|
-
IDropdownClassnames,
|
|
88
95
|
IDropdownProps,
|
|
89
96
|
IEmptySectionPlaceholderProps,
|
|
90
97
|
IItemProp,
|
|
@@ -92,7 +99,9 @@ export type {
|
|
|
92
99
|
UnifiedIconName,
|
|
93
100
|
IconName,
|
|
94
101
|
FAIconName,
|
|
95
|
-
BTNActionType
|
|
102
|
+
BTNActionType,
|
|
103
|
+
ITextInputProps,
|
|
104
|
+
ISimpleSelectOptions
|
|
96
105
|
}
|
|
97
106
|
export {
|
|
98
107
|
Avatar,
|
|
@@ -103,9 +112,10 @@ export {
|
|
|
103
112
|
NestedInputButton,
|
|
104
113
|
Radio,
|
|
105
114
|
Select,
|
|
106
|
-
|
|
115
|
+
Textarea,
|
|
107
116
|
ToggleSwitch,
|
|
108
117
|
AnimatedLabelInput,
|
|
118
|
+
AnimatedLabelTextArea,
|
|
109
119
|
ButtonDropdown,
|
|
110
120
|
Dropdown,
|
|
111
121
|
EmptySectionPlaceholder,
|
|
@@ -120,5 +130,7 @@ export {
|
|
|
120
130
|
isFAIcon,
|
|
121
131
|
isHeroIcon,
|
|
122
132
|
isTablerIcon,
|
|
123
|
-
isUnifiedIconName
|
|
133
|
+
isUnifiedIconName,
|
|
134
|
+
TextInput,
|
|
135
|
+
TextInputSelect
|
|
124
136
|
}
|
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
INestedInputButtonProps,
|
|
7
7
|
IRadioProps,
|
|
8
8
|
ISelectProps,
|
|
9
|
-
|
|
9
|
+
ISimpleSelectOptions,
|
|
10
|
+
ITextareaProps,
|
|
10
11
|
IToggleSwitchProps,
|
|
11
12
|
AcceptedInputTypes,
|
|
12
13
|
Checkbox,
|
|
@@ -16,8 +17,10 @@ import {
|
|
|
16
17
|
NestedInputButton,
|
|
17
18
|
Radio,
|
|
18
19
|
Select,
|
|
19
|
-
|
|
20
|
-
ToggleSwitch
|
|
20
|
+
Textarea,
|
|
21
|
+
ToggleSwitch,
|
|
22
|
+
ITextInputProps,
|
|
23
|
+
TextInput
|
|
21
24
|
} from "./inputs"
|
|
22
25
|
|
|
23
26
|
export type {
|
|
@@ -28,8 +31,21 @@ export type {
|
|
|
28
31
|
INestedInputButtonProps,
|
|
29
32
|
IRadioProps,
|
|
30
33
|
ISelectProps,
|
|
31
|
-
|
|
34
|
+
ISimpleSelectOptions,
|
|
35
|
+
ITextareaProps,
|
|
32
36
|
IToggleSwitchProps,
|
|
33
|
-
AcceptedInputTypes
|
|
37
|
+
AcceptedInputTypes,
|
|
38
|
+
ITextInputProps
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
Checkbox,
|
|
42
|
+
Combobox,
|
|
43
|
+
InputField,
|
|
44
|
+
InputLabel,
|
|
45
|
+
NestedInputButton,
|
|
46
|
+
Radio,
|
|
47
|
+
Select,
|
|
48
|
+
Textarea,
|
|
49
|
+
ToggleSwitch,
|
|
50
|
+
TextInput
|
|
34
51
|
}
|
|
35
|
-
export { Checkbox, Combobox, InputField, InputLabel, NestedInputButton, Radio, Select, TextAreaField, ToggleSwitch }
|
|
@@ -13,14 +13,15 @@ export type AcceptedInputTypes =
|
|
|
13
13
|
| "tel"
|
|
14
14
|
| "text"
|
|
15
15
|
| "url"
|
|
16
|
+
| "currency"
|
|
16
17
|
|
|
17
|
-
export interface IInputFieldProps extends React.
|
|
18
|
+
export interface IInputFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> {
|
|
18
19
|
/** Callback on change */
|
|
19
20
|
handleChange: (value: string) => void
|
|
20
21
|
/** Input ID*/
|
|
21
|
-
id
|
|
22
|
+
id?: string
|
|
22
23
|
/** Input Name */
|
|
23
|
-
name
|
|
24
|
+
name?: string
|
|
24
25
|
/** Force the focus state on the input */
|
|
25
26
|
isFocused?: boolean
|
|
26
27
|
/** Error condition */
|
|
@@ -37,6 +38,8 @@ export interface IInputFieldProps extends React.ComponentPropsWithoutRef<"input"
|
|
|
37
38
|
required?: boolean
|
|
38
39
|
/** use input psuedo classes for :valid and :invalid styles. on by default */
|
|
39
40
|
clientSideCheck?: boolean
|
|
41
|
+
/** Placeholder text */
|
|
42
|
+
placeholder?: string
|
|
40
43
|
/**ref for input */
|
|
41
44
|
ref?: React.Ref<HTMLInputElement>
|
|
42
45
|
}
|
|
@@ -53,28 +56,26 @@ const InputField: React.FC<IInputFieldProps> = ({
|
|
|
53
56
|
handleChange,
|
|
54
57
|
required,
|
|
55
58
|
clientSideCheck = true,
|
|
56
|
-
placeholder,
|
|
57
59
|
className,
|
|
60
|
+
placeholder,
|
|
58
61
|
ref,
|
|
59
62
|
...rest
|
|
60
63
|
}) => {
|
|
61
|
-
|
|
62
64
|
return (
|
|
63
65
|
<input
|
|
64
66
|
{...{
|
|
67
|
+
ref,
|
|
65
68
|
type,
|
|
66
69
|
id,
|
|
67
|
-
ref,
|
|
68
70
|
name,
|
|
69
71
|
value,
|
|
70
72
|
onChange: (e) => {
|
|
71
|
-
|
|
72
|
-
handleChange(e.target.value)
|
|
73
|
+
if (handleChange) handleChange(e.target.value)
|
|
73
74
|
},
|
|
74
75
|
autoFocus: isFocused,
|
|
75
76
|
readOnly: isReadonly,
|
|
76
77
|
disabled: isDisabled,
|
|
77
|
-
placeholder: placeholder ||
|
|
78
|
+
placeholder: placeholder || undefined,
|
|
78
79
|
required,
|
|
79
80
|
"aria-invalid": isError,
|
|
80
81
|
"aria-disabled": isDisabled,
|
|
@@ -32,7 +32,7 @@ export interface ITextInputProps {
|
|
|
32
32
|
/** Max length of input character */
|
|
33
33
|
maxLength?: number
|
|
34
34
|
/** Callback on change */
|
|
35
|
-
|
|
35
|
+
handleChange(value: string): void
|
|
36
36
|
/** input value */
|
|
37
37
|
value: string
|
|
38
38
|
/**Placeholder input text*/
|
|
@@ -56,7 +56,7 @@ const TextInput = (
|
|
|
56
56
|
message,
|
|
57
57
|
isShowCounter,
|
|
58
58
|
maxLength,
|
|
59
|
-
|
|
59
|
+
handleChange,
|
|
60
60
|
placeholder,
|
|
61
61
|
value: externalValue,
|
|
62
62
|
className,
|
|
@@ -116,7 +116,10 @@ const TextInput = (
|
|
|
116
116
|
<InputField
|
|
117
117
|
onFocus={handleInputFocus}
|
|
118
118
|
onBlur={handleInputBlur}
|
|
119
|
-
handleChange={(v) =>
|
|
119
|
+
handleChange={(v: string) => {
|
|
120
|
+
setValue(v)
|
|
121
|
+
handleChange(v)
|
|
122
|
+
}}
|
|
120
123
|
ref={ref}
|
|
121
124
|
type={type}
|
|
122
125
|
name={name}
|
|
@@ -53,13 +53,12 @@ const Checkbox: FC<ICheckboxProps> = ({
|
|
|
53
53
|
const wrapperStyles = cn(
|
|
54
54
|
"relative flex items-center min-h-[38px]",
|
|
55
55
|
{ "opacity-50": isDisabled },
|
|
56
|
-
{ "rounded-sm
|
|
56
|
+
{ "rounded-sm border border-1 px-3 border-gray-200": hasBorder },
|
|
57
57
|
{ "py-3": hasBorder && message },
|
|
58
58
|
className
|
|
59
59
|
)
|
|
60
60
|
|
|
61
61
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
62
|
-
console.log(e)
|
|
63
62
|
const targetValue = e.target.value
|
|
64
63
|
const targetChecked = e.target.checked
|
|
65
64
|
typeof onChange === "function" && onChange(targetValue, targetChecked)
|
|
@@ -44,151 +44,142 @@ function classNames(...classes: string[]) {
|
|
|
44
44
|
return classes.filter(Boolean).join(" ")
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
47
|
+
const Combobox = <T extends Record<string, unknown>>({
|
|
48
|
+
label,
|
|
49
|
+
items,
|
|
50
|
+
displayProperty,
|
|
51
|
+
displayValue,
|
|
52
|
+
keyProperty,
|
|
53
|
+
onChange,
|
|
54
|
+
placeholder,
|
|
55
|
+
message,
|
|
56
|
+
isDisabled,
|
|
57
|
+
isError,
|
|
58
|
+
isRequired,
|
|
59
|
+
id,
|
|
60
|
+
nullable
|
|
61
|
+
}: IComboboxProps<T>) => {
|
|
62
|
+
const [query, setQuery] = useState<string>("")
|
|
63
|
+
const [selectedItem, setSelectedItem] = useState<T | undefined>()
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
65
|
+
const onChangeValue = (value: T | undefined) => {
|
|
66
|
+
if (value && selectedItem && value[keyProperty] === selectedItem[keyProperty]) {
|
|
67
|
+
setSelectedItem(undefined)
|
|
68
|
+
} else {
|
|
69
|
+
setSelectedItem(value)
|
|
71
70
|
}
|
|
71
|
+
}
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (displayValue) {
|
|
75
|
+
const dv = items.find((i) => i[displayProperty] === displayValue)
|
|
76
|
+
setSelectedItem(dv)
|
|
77
|
+
}
|
|
78
|
+
}, [displayValue])
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
typeof onChange === "function" && onChange(selectedItem)
|
|
82
|
+
}, [selectedItem])
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
84
|
+
const filteredItems =
|
|
85
|
+
query === ""
|
|
86
|
+
? items
|
|
87
|
+
: items.filter((item) => {
|
|
88
|
+
return `${item[displayProperty]}`.toLowerCase().includes(query.toLowerCase())
|
|
89
|
+
})
|
|
90
|
+
const labelStyles = cn("block text-sm font-medium text-gray-700")
|
|
91
|
+
const buttonStyles = cn("absolute inset-y-0 right-0 flex items-center rounded-r px-2 focus:outline-none")
|
|
92
|
+
const optionStyles = cn(
|
|
93
|
+
"absolute z-30 mt-1 max-h-60 w-full overflow-auto rounded bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"
|
|
94
|
+
)
|
|
95
|
+
return (
|
|
96
|
+
<HeadlessUICombobox
|
|
97
|
+
as="div"
|
|
98
|
+
value={selectedItem}
|
|
99
|
+
onChange={(e: T | undefined) => onChangeValue(e)}
|
|
100
|
+
disabled={isDisabled}
|
|
101
|
+
nullable={nullable ? undefined : false}
|
|
102
|
+
>
|
|
103
|
+
{label && (
|
|
104
|
+
<HeadlessUICombobox.Label className={labelStyles}>
|
|
105
|
+
<InputLabel
|
|
106
|
+
isPlaceholder
|
|
107
|
+
isActive
|
|
108
|
+
label={label}
|
|
109
|
+
isRequired={isRequired}
|
|
110
|
+
id={id}
|
|
111
|
+
isError={isError}
|
|
112
|
+
isDisabled={isDisabled}
|
|
113
|
+
/>
|
|
114
|
+
</HeadlessUICombobox.Label>
|
|
115
|
+
)}
|
|
116
|
+
<div className="relative">
|
|
116
117
|
<div className="relative">
|
|
117
|
-
<
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
118
|
+
<HeadlessUICombobox.Input
|
|
119
|
+
className={`w-full rounded border border-gray-300 focus:border-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500 sm:text-sm ${
|
|
120
|
+
isError ? "border-red-500" : ""
|
|
121
|
+
}`}
|
|
122
|
+
onChange={(event) => setQuery(event.target.value)}
|
|
123
|
+
displayValue={(item: Record<string, unknown>) => `${item ? item[displayProperty] : ""}`}
|
|
124
|
+
placeholder={placeholder}
|
|
125
|
+
/>
|
|
126
|
+
{selectedItem && nullable && (
|
|
127
|
+
<button
|
|
128
|
+
className="absolute right-8 top-[1px] h-9 w-5 text-gray-400 hover:text-gray-500"
|
|
129
|
+
onClick={() => setSelectedItem(undefined)}
|
|
130
|
+
>
|
|
131
|
+
<DynamicIcon icon="IconX" className="h-4 w-4 " aria-hidden="true" />
|
|
132
|
+
</button>
|
|
133
|
+
)}
|
|
134
|
+
</div>
|
|
135
|
+
<HeadlessUICombobox.Button className={buttonStyles}>
|
|
136
|
+
<DynamicIcon icon="IconSelector" className="h-5 w-5 text-gray-400" aria-hidden="true" />
|
|
137
|
+
</HeadlessUICombobox.Button>
|
|
138
|
+
|
|
139
|
+
{filteredItems.length > 0 && (
|
|
140
|
+
<HeadlessUICombobox.Options className={optionStyles}>
|
|
141
|
+
{filteredItems.map((item, index) => (
|
|
142
|
+
<HeadlessUICombobox.Option
|
|
143
|
+
key={`${item[keyProperty]}-${index}`}
|
|
144
|
+
value={item}
|
|
145
|
+
className={({ active }) =>
|
|
146
|
+
classNames(
|
|
147
|
+
"relative cursor-default select-none py-2 pl-3 pr-9",
|
|
148
|
+
active ? "bg-purple-600 text-white" : "text-gray-900"
|
|
149
|
+
)
|
|
150
|
+
}
|
|
130
151
|
>
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
<DynamicIcon icon="SelectorIcon" className="h-5 w-5 text-gray-400" aria-hidden="true" />
|
|
137
|
-
</HeadlessUICombobox.Button>
|
|
152
|
+
{({ active, selected }) => (
|
|
153
|
+
<>
|
|
154
|
+
<span className={classNames("block truncate", selected ? "font-semibold" : "")}>
|
|
155
|
+
{`${item[displayProperty]}`}
|
|
156
|
+
</span>
|
|
138
157
|
|
|
139
|
-
|
|
140
|
-
<HeadlessUICombobox.Options className={optionStyles}>
|
|
141
|
-
{filteredItems.map((item, index) => (
|
|
142
|
-
<HeadlessUICombobox.Option
|
|
143
|
-
key={`${item[keyProperty]}-${index}`}
|
|
144
|
-
value={item}
|
|
145
|
-
className={({ active }) =>
|
|
146
|
-
classNames(
|
|
147
|
-
"relative cursor-default select-none py-2 pl-3 pr-9",
|
|
148
|
-
active ? "bg-purple-600 text-white" : "text-gray-900"
|
|
149
|
-
)
|
|
150
|
-
}
|
|
151
|
-
>
|
|
152
|
-
{({ active, selected }) => (
|
|
153
|
-
<>
|
|
158
|
+
{selected && (
|
|
154
159
|
<span
|
|
155
160
|
className={classNames(
|
|
156
|
-
"
|
|
157
|
-
|
|
161
|
+
"absolute inset-y-0 right-0 flex items-center pr-4",
|
|
162
|
+
active ? "text-white" : "text-purple-600"
|
|
158
163
|
)}
|
|
159
164
|
>
|
|
160
|
-
|
|
165
|
+
<DynamicIcon icon="IconCheck" className="h-5 w-5" aria-hidden="true" />
|
|
161
166
|
</span>
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
</HeadlessUICombobox.Options>
|
|
182
|
-
)}
|
|
183
|
-
</div>
|
|
184
|
-
<div className="grow">
|
|
185
|
-
{message && (
|
|
186
|
-
<span className={`mt-1 block text-sm ${isError ? `text-red-500` : `text-gray-500`}`}>
|
|
187
|
-
{message}
|
|
188
|
-
</span>
|
|
189
|
-
)}
|
|
190
|
-
</div>
|
|
191
|
-
</HeadlessUICombobox>
|
|
192
|
-
)
|
|
193
|
-
}
|
|
194
|
-
export default Combobox
|
|
167
|
+
)}
|
|
168
|
+
</>
|
|
169
|
+
)}
|
|
170
|
+
</HeadlessUICombobox.Option>
|
|
171
|
+
))}
|
|
172
|
+
</HeadlessUICombobox.Options>
|
|
173
|
+
)}
|
|
174
|
+
</div>
|
|
175
|
+
<div className="grow">
|
|
176
|
+
{message && (
|
|
177
|
+
<span className={`mt-1 block text-sm ${isError ? `text-red-500` : `text-gray-500`}`}>
|
|
178
|
+
{message}
|
|
179
|
+
</span>
|
|
180
|
+
)}
|
|
181
|
+
</div>
|
|
182
|
+
</HeadlessUICombobox>
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
export default Combobox
|
|
@@ -4,8 +4,9 @@ import InputField, { AcceptedInputTypes, IInputFieldProps } from "./InputField"
|
|
|
4
4
|
import InputLabel, { IInputLabelProps } from "./InputLabel"
|
|
5
5
|
import NestedInputButton, { INestedInputButtonProps } from "./NestedInputButton"
|
|
6
6
|
import Radio, { IRadioProps } from "./radio"
|
|
7
|
-
import Select, { ISelectProps } from "./select"
|
|
8
|
-
import
|
|
7
|
+
import Select, { ISelectProps, ISimpleSelectOptions } from "./select"
|
|
8
|
+
import Textarea, { ITextareaProps } from "./textArea"
|
|
9
|
+
import TextInput, { ITextInputProps } from "./TextInput"
|
|
9
10
|
import ToggleSwitch, { IToggleSwitchProps } from "./toggleSwitch"
|
|
10
11
|
|
|
11
12
|
export type {
|
|
@@ -16,9 +17,22 @@ export type {
|
|
|
16
17
|
INestedInputButtonProps,
|
|
17
18
|
IRadioProps,
|
|
18
19
|
ISelectProps,
|
|
19
|
-
|
|
20
|
+
ISimpleSelectOptions,
|
|
21
|
+
ITextareaProps,
|
|
22
|
+
ITextInputProps,
|
|
20
23
|
IToggleSwitchProps,
|
|
21
24
|
AcceptedInputTypes
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
export {
|
|
27
|
+
export {
|
|
28
|
+
Checkbox,
|
|
29
|
+
Combobox,
|
|
30
|
+
InputField,
|
|
31
|
+
InputLabel,
|
|
32
|
+
NestedInputButton,
|
|
33
|
+
Radio,
|
|
34
|
+
Select,
|
|
35
|
+
Textarea,
|
|
36
|
+
ToggleSwitch,
|
|
37
|
+
TextInput
|
|
38
|
+
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
-
import
|
|
3
|
-
const meta: Meta<typeof
|
|
2
|
+
import Textarea from "./TextArea"
|
|
3
|
+
const meta: Meta<typeof Textarea> = {
|
|
4
4
|
title: "Design System/Molecules/Inputs/TextArea",
|
|
5
|
-
component:
|
|
5
|
+
component: Textarea,
|
|
6
6
|
tags: ["autodocs"]
|
|
7
7
|
}
|
|
8
8
|
const dummyText: string = `Checkmate... Life finds a way. Is this my espresso machine? Wh-what is-h-how did you get my espresso machine? You're a very talented young man, with your own clever thoughts and ideas. Do you need a manager? Is this my espresso machine? Wh-what is-h-how did you get my espresso machine?
|
|
9
9
|
|
|
10
10
|
I was part of something special. Just my luck, no ice. You really think you can fly that thing? Must go faster... go, go, go, go, go! God creates dinosaurs. God destroys dinosaurs. God creates Man. Man destroys God. Man creates Dinosaurs. Yeah, but your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should.`
|
|
11
|
-
type Story = StoryObj<typeof
|
|
12
|
-
export const
|
|
11
|
+
type Story = StoryObj<typeof Textarea>
|
|
12
|
+
export const DefaultTextarea: Story = {
|
|
13
13
|
args: {
|
|
14
14
|
id: "appDescription",
|
|
15
15
|
name: "description",
|
|
16
16
|
rows: 12,
|
|
17
|
+
cols: 18,
|
|
18
|
+
label: { display: "Description" },
|
|
17
19
|
placeholder: dummyText
|
|
18
20
|
}
|
|
19
21
|
}
|