@agility/plenum-ui 2.0.0-rc2 → 2.0.0-rc21
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 +41 -11
- package/build.js +30 -25
- package/dist/index.d.ts +279 -93
- package/dist/index.js +1 -5935
- package/dist/index.js.map +4 -4
- package/dist/tailwind.css +63516 -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 +7 -9
- 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 +1 -1
- 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 +8 -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 +9 -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 +18 -15
- 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 +35 -18
- package/rollup.config.mjs +42 -0
- package/stories/Introduction.mdx +1 -1
- package/stories/atoms/buttons/Button/Alternative/Alternative.stories.ts +7 -0
- package/stories/atoms/buttons/Button/Button.tsx +45 -17
- package/stories/atoms/buttons/Button/Danger/Danger.stories.ts +7 -0
- package/stories/atoms/buttons/Button/Primary/Primary.stories.ts +7 -0
- package/stories/atoms/buttons/Button/Secondary/Secondary.stories.ts +7 -0
- package/stories/atoms/buttons/Capsule/Capsule.tsx +2 -1
- package/stories/atoms/icons/DynamicIcon.tsx +3 -2
- 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/InputCounter/InputCounter.stories.tsx +18 -0
- package/stories/molecules/inputs/InputCounter/InputCounter.tsx +24 -0
- package/stories/molecules/inputs/InputCounter/index.tsx +3 -0
- package/stories/molecules/inputs/InputField/InputField.tsx +13 -7
- package/stories/molecules/inputs/TextInput/TextInput.stories.tsx +32 -0
- package/stories/molecules/inputs/TextInput/TextInput.tsx +165 -0
- package/stories/molecules/inputs/TextInput/index.tsx +5 -0
- package/stories/molecules/inputs/checkbox/Checkbox.tsx +1 -1
- 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 +61 -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 +59 -58
- package/stories/organisms/ButtonDropdown/ButtonDropdown.tsx +13 -16
- package/stories/organisms/DropdownComponent/Dropdown.stories.tsx +1 -1
- package/stories/organisms/DropdownComponent/DropdownComponent.tsx +155 -131
- package/stories/organisms/DropdownComponent/dropdownItems.ts +32 -8
- package/stories/organisms/DropdownComponent/index.ts +2 -2
- package/stories/organisms/EmptySectionPlaceholder/index.tsx +2 -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 +50 -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,5 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { Transition } from "@headlessui/react"
|
|
1
|
+
import React, { HTMLAttributes, useState } from "react"
|
|
3
2
|
import { default as cn } from "classnames"
|
|
4
3
|
import {
|
|
5
4
|
useFloating,
|
|
@@ -18,33 +17,28 @@ import {
|
|
|
18
17
|
} from "@floating-ui/react"
|
|
19
18
|
|
|
20
19
|
import { ClassNameWithAutocomplete } from "utils/types"
|
|
21
|
-
import { DynamicIcon, IDynamicIconProps } from "@/stories/atoms/icons"
|
|
20
|
+
import { DynamicIcon, IDynamicIconProps, UnifiedIconName } from "@/stories/atoms/icons"
|
|
22
21
|
|
|
23
22
|
export interface IItemProp extends HTMLAttributes<HTMLButtonElement> {
|
|
24
|
-
icon?:
|
|
25
|
-
|
|
26
|
-
className?: ClassNameWithAutocomplete
|
|
27
|
-
pos?: "trailing" | "leading"
|
|
28
|
-
outline?: boolean
|
|
29
|
-
}
|
|
23
|
+
icon?: IDynamicIconProps
|
|
24
|
+
iconPosition?: "trailing" | "leading"
|
|
30
25
|
label: string
|
|
31
26
|
onClick?(): void
|
|
32
27
|
isEmphasized?: boolean
|
|
33
28
|
key: React.Key
|
|
34
29
|
}
|
|
35
|
-
export interface IDropdownClassnames {
|
|
36
|
-
groupClassname?: ClassNameWithAutocomplete
|
|
37
|
-
itemsClassname?: ClassNameWithAutocomplete
|
|
38
|
-
itemClassname?: ClassNameWithAutocomplete
|
|
39
|
-
activeItemClassname?: ClassNameWithAutocomplete
|
|
40
|
-
buttonClassname?: ClassNameWithAutocomplete
|
|
41
|
-
}
|
|
42
30
|
export interface IDropdownProps extends HTMLAttributes<HTMLDivElement> {
|
|
43
31
|
items: IItemProp[][]
|
|
44
32
|
label: string
|
|
45
33
|
CustomDropdownTrigger?: React.ReactNode
|
|
46
34
|
id: string
|
|
47
|
-
|
|
35
|
+
groupClassname?: ClassNameWithAutocomplete
|
|
36
|
+
itemsClassname?: ClassNameWithAutocomplete
|
|
37
|
+
itemClassname?: ClassNameWithAutocomplete
|
|
38
|
+
activeItemClassname?: ClassNameWithAutocomplete
|
|
39
|
+
buttonClassname?: ClassNameWithAutocomplete
|
|
40
|
+
iconClassname?: ClassNameWithAutocomplete
|
|
41
|
+
iconSpacingClassname?: ClassNameWithAutocomplete
|
|
48
42
|
placement?: Placement
|
|
49
43
|
offsetOptions?: Partial<{
|
|
50
44
|
mainAxis: number
|
|
@@ -52,7 +46,7 @@ export interface IDropdownProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
52
46
|
alignmentAxis: number | null
|
|
53
47
|
}>
|
|
54
48
|
}
|
|
55
|
-
export const defaultClassNames
|
|
49
|
+
export const defaultClassNames = {
|
|
56
50
|
groupClassname: "flex inline-block text-left",
|
|
57
51
|
itemsClassname:
|
|
58
52
|
"mt-2 origin-bottom-right rounded bg-white shadow-lg z-20 divide-y divide-gray-100 border border-gray-300 ",
|
|
@@ -60,7 +54,9 @@ export const defaultClassNames: IDropdownClassnames = {
|
|
|
60
54
|
"group flex font-muli cursor-pointer items-center px-4 py-2 text-sm transition-all hover:bg-gray-100 hover:text-gray-900 justify-between gap-4 ",
|
|
61
55
|
activeItemClassname: "block px-4 py-2 text-sm text-gray-700 bg-gray-100 hover:bg-gray-200 hover:text-gray-900",
|
|
62
56
|
buttonClassname:
|
|
63
|
-
"py-[2px] z-20 flex items-center rounded outline-purple-500 transition-all
|
|
57
|
+
"py-[2px] z-20 flex items-center rounded outline-purple-500 transition-all text-gray-400 hover:text-gray-600 ",
|
|
58
|
+
iconClassname: "ml-1 h-5 w-6",
|
|
59
|
+
iconSpacingClassname: "flex items-center gap-x-4"
|
|
64
60
|
}
|
|
65
61
|
|
|
66
62
|
/** Comment */
|
|
@@ -68,7 +64,13 @@ const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
68
64
|
items,
|
|
69
65
|
id,
|
|
70
66
|
label,
|
|
71
|
-
|
|
67
|
+
groupClassname,
|
|
68
|
+
itemsClassname,
|
|
69
|
+
itemClassname,
|
|
70
|
+
activeItemClassname,
|
|
71
|
+
buttonClassname,
|
|
72
|
+
iconClassname,
|
|
73
|
+
iconSpacingClassname,
|
|
72
74
|
CustomDropdownTrigger,
|
|
73
75
|
placement = "bottom-start",
|
|
74
76
|
offsetOptions,
|
|
@@ -108,12 +110,10 @@ const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
108
110
|
}
|
|
109
111
|
})
|
|
110
112
|
|
|
111
|
-
const { groupClassname, buttonClassname, itemsClassname, itemClassname, activeItemClassname } = classNames
|
|
112
|
-
|
|
113
113
|
return (
|
|
114
114
|
<div
|
|
115
115
|
{...{
|
|
116
|
-
className: groupClassname,
|
|
116
|
+
className: cn(defaultClassNames.groupClassname, groupClassname),
|
|
117
117
|
role: "combobox",
|
|
118
118
|
"aria-owns": `${id}-list`,
|
|
119
119
|
"aria-expanded": isOpen,
|
|
@@ -124,7 +124,7 @@ const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
124
124
|
<button
|
|
125
125
|
{...{
|
|
126
126
|
ref: refs.setReference,
|
|
127
|
-
className: buttonClassname,
|
|
127
|
+
className: cn(defaultClassNames.buttonClassname, buttonClassname),
|
|
128
128
|
onClick: () => {
|
|
129
129
|
setIsOpen(!isOpen)
|
|
130
130
|
},
|
|
@@ -136,7 +136,10 @@ const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
136
136
|
) : (
|
|
137
137
|
<>
|
|
138
138
|
<span className="pl-1">{label}</span>
|
|
139
|
-
<DynamicIcon
|
|
139
|
+
<DynamicIcon
|
|
140
|
+
icon="ChevronDownIcon"
|
|
141
|
+
className={cn(defaultClassNames.iconClassname, iconClassname)}
|
|
142
|
+
/>
|
|
140
143
|
</>
|
|
141
144
|
)}
|
|
142
145
|
</button>
|
|
@@ -144,121 +147,142 @@ const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
144
147
|
{isMounted && items.length > 0 && isOpen && (
|
|
145
148
|
<FloatingPortal>
|
|
146
149
|
<FloatingFocusManager context={context} modal={true}>
|
|
147
|
-
<
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
<div
|
|
151
|
+
{...getFloatingProps()}
|
|
152
|
+
className={cn(defaultClassNames.itemsClassname, itemsClassname)}
|
|
153
|
+
ref={refs.setFloating}
|
|
154
|
+
aria-labelledby={label}
|
|
155
|
+
style={{
|
|
156
|
+
position: context.strategy,
|
|
157
|
+
top: Math.round(context.y ?? 0),
|
|
158
|
+
left: Math.round(context.x ?? 0),
|
|
159
|
+
width: "max-content",
|
|
160
|
+
maxWidth: "min(calc(100vw - 10px), 25rem)",
|
|
161
|
+
...floatingStyles
|
|
162
|
+
}}
|
|
156
163
|
>
|
|
157
|
-
<ul
|
|
158
|
-
{...{
|
|
159
|
-
...getFloatingProps(),
|
|
160
|
-
className: itemsClassname,
|
|
161
|
-
ref: refs.setFloating,
|
|
162
|
-
// style: floatingStyles,
|
|
163
|
-
"aria-labelledby": label,
|
|
164
|
-
id: `${id}-list`,
|
|
165
|
-
role: "listbox",
|
|
166
|
-
style: {
|
|
167
|
-
position: context.strategy,
|
|
168
|
-
top: Math.round(context.y ?? 0),
|
|
169
|
-
left: Math.round(context.x ?? 0),
|
|
170
|
-
width: "max-content",
|
|
171
|
-
maxWidth: "min(calc(100vw - 10px), 25rem)",
|
|
172
|
-
...floatingStyles
|
|
173
|
-
}
|
|
174
|
-
}}
|
|
175
|
-
className={itemsClassname}
|
|
176
|
-
ref={refs.setFloating}
|
|
177
|
-
aria-labelledby={label}
|
|
178
|
-
{...getFloatingProps()}
|
|
179
|
-
>
|
|
164
|
+
<ul id={`${id}-list`} role="listbox" style={{ ...transitionStyles }}>
|
|
180
165
|
{items.map((itemStack, idx) => {
|
|
181
166
|
return (
|
|
182
167
|
<React.Fragment key={`${idx}-list-${id}`}>
|
|
183
|
-
{itemStack.map(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
"text-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
"opacity-60 group-hover:opacity-100"
|
|
231
|
-
),
|
|
232
|
-
outline: icon.outline
|
|
233
|
-
}}
|
|
234
|
-
/>
|
|
168
|
+
{itemStack.map(
|
|
169
|
+
(
|
|
170
|
+
{ onClick, label, key, isEmphasized, icon, iconPosition, ...rest },
|
|
171
|
+
idx
|
|
172
|
+
) => {
|
|
173
|
+
const active = activeItem && activeItem === key
|
|
174
|
+
const itemClass = cn(
|
|
175
|
+
defaultClassNames.itemClassname,
|
|
176
|
+
itemClassname,
|
|
177
|
+
"group flex cursor-pointer items-center px-4 py-2 text-sm transition-all",
|
|
178
|
+
{
|
|
179
|
+
"text-red-500": isEmphasized
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"text-gray-900": !isEmphasized
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"bg-gray-100 text-gray-900": active
|
|
186
|
+
},
|
|
187
|
+
active
|
|
188
|
+
? cn(
|
|
189
|
+
defaultClassNames.activeItemClassname,
|
|
190
|
+
activeItemClassname
|
|
191
|
+
)
|
|
192
|
+
: "",
|
|
193
|
+
{
|
|
194
|
+
"bg-gray-100 text-red-500 hover:text-red-500":
|
|
195
|
+
active && isEmphasized
|
|
196
|
+
}
|
|
197
|
+
)
|
|
198
|
+
return (
|
|
199
|
+
<li key={`${key}-${idx}`}>
|
|
200
|
+
<button
|
|
201
|
+
{...{
|
|
202
|
+
onClick: () => {
|
|
203
|
+
setActiveItem(key)
|
|
204
|
+
onClick && onClick()
|
|
205
|
+
},
|
|
206
|
+
key: key,
|
|
207
|
+
className: cn(itemClass, "w-full"),
|
|
208
|
+
...rest
|
|
209
|
+
}}
|
|
210
|
+
>
|
|
211
|
+
<div
|
|
212
|
+
className={cn(
|
|
213
|
+
defaultClassNames.iconSpacingClassname,
|
|
214
|
+
iconSpacingClassname
|
|
235
215
|
)}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
216
|
+
>
|
|
217
|
+
{icon &&
|
|
218
|
+
(iconPosition === "leading" ||
|
|
219
|
+
iconPosition === undefined) &&
|
|
220
|
+
(typeof icon === "string" ? (
|
|
221
|
+
<DynamicIcon
|
|
222
|
+
{...{
|
|
223
|
+
icon: icon,
|
|
224
|
+
className: cn(
|
|
225
|
+
{
|
|
226
|
+
"text-red-500": isEmphasized
|
|
227
|
+
},
|
|
228
|
+
"opacity-60 group"
|
|
229
|
+
)
|
|
230
|
+
}}
|
|
231
|
+
/>
|
|
232
|
+
) : (
|
|
233
|
+
<DynamicIcon
|
|
234
|
+
{...{
|
|
235
|
+
...icon,
|
|
236
|
+
className: cn(
|
|
237
|
+
icon.className,
|
|
238
|
+
{
|
|
239
|
+
"text-red-500": isEmphasized
|
|
240
|
+
},
|
|
241
|
+
"opacity-60 group"
|
|
242
|
+
)
|
|
243
|
+
}}
|
|
244
|
+
/>
|
|
245
|
+
))}
|
|
246
|
+
<div className="whitespace-nowrap">{label}</div>
|
|
247
|
+
{icon &&
|
|
248
|
+
iconPosition === "trailing" &&
|
|
249
|
+
(typeof icon === "string" ? (
|
|
250
|
+
<DynamicIcon
|
|
251
|
+
{...{
|
|
252
|
+
icon: icon,
|
|
253
|
+
className: cn(
|
|
254
|
+
{
|
|
255
|
+
"text-red-500": isEmphasized
|
|
256
|
+
},
|
|
257
|
+
"opacity-60 group"
|
|
258
|
+
)
|
|
259
|
+
}}
|
|
260
|
+
/>
|
|
261
|
+
) : (
|
|
262
|
+
<DynamicIcon
|
|
263
|
+
{...{
|
|
264
|
+
...icon,
|
|
265
|
+
className: cn(
|
|
266
|
+
icon.className,
|
|
267
|
+
{
|
|
268
|
+
"text-red-500": isEmphasized
|
|
269
|
+
},
|
|
270
|
+
"opacity-60 group"
|
|
271
|
+
)
|
|
272
|
+
}}
|
|
273
|
+
/>
|
|
274
|
+
))}
|
|
275
|
+
</div>
|
|
276
|
+
</button>
|
|
277
|
+
</li>
|
|
278
|
+
)
|
|
279
|
+
}
|
|
280
|
+
)}
|
|
257
281
|
</React.Fragment>
|
|
258
282
|
)
|
|
259
283
|
})}
|
|
260
284
|
</ul>
|
|
261
|
-
</
|
|
285
|
+
</div>
|
|
262
286
|
</FloatingFocusManager>
|
|
263
287
|
</FloatingPortal>
|
|
264
288
|
)}
|
|
@@ -3,6 +3,12 @@ import { IItemProp } from "./DropdownComponent"
|
|
|
3
3
|
export const dropdownDataBase: IItemProp[][] = [
|
|
4
4
|
[
|
|
5
5
|
{
|
|
6
|
+
icon: {
|
|
7
|
+
icon: "IconCopy"
|
|
8
|
+
// pos: "leading",
|
|
9
|
+
// className: "h-5 w-5",
|
|
10
|
+
// outline: false
|
|
11
|
+
},
|
|
6
12
|
key: "Copy",
|
|
7
13
|
label: "Copy",
|
|
8
14
|
onClick: () => {
|
|
@@ -12,6 +18,12 @@ export const dropdownDataBase: IItemProp[][] = [
|
|
|
12
18
|
],
|
|
13
19
|
[
|
|
14
20
|
{
|
|
21
|
+
icon: {
|
|
22
|
+
icon: "IconPlus"
|
|
23
|
+
// pos: "leading",
|
|
24
|
+
// className: "h-5 w-5",
|
|
25
|
+
// outline: false
|
|
26
|
+
},
|
|
15
27
|
key: "Add to Batch",
|
|
16
28
|
label: "Add to Batch",
|
|
17
29
|
onClick: () => {
|
|
@@ -19,6 +31,12 @@ export const dropdownDataBase: IItemProp[][] = [
|
|
|
19
31
|
}
|
|
20
32
|
},
|
|
21
33
|
{
|
|
34
|
+
icon: {
|
|
35
|
+
icon: "IconEye"
|
|
36
|
+
// pos: "leading",
|
|
37
|
+
// className: "h-5 w-5",
|
|
38
|
+
// outline: false
|
|
39
|
+
},
|
|
22
40
|
key: "View Batch",
|
|
23
41
|
label: "View Batch",
|
|
24
42
|
onClick: () => {
|
|
@@ -28,6 +46,12 @@ export const dropdownDataBase: IItemProp[][] = [
|
|
|
28
46
|
],
|
|
29
47
|
[
|
|
30
48
|
{
|
|
49
|
+
icon: {
|
|
50
|
+
icon: "IconTrash"
|
|
51
|
+
// pos: "leading",
|
|
52
|
+
// className: "h-5 w-5",
|
|
53
|
+
// outline: false
|
|
54
|
+
},
|
|
31
55
|
label: "Delete",
|
|
32
56
|
onClick: () => {
|
|
33
57
|
console.log("Delete action")
|
|
@@ -42,11 +66,11 @@ export const dropdownDataWithIcons: IItemProp[][] = [
|
|
|
42
66
|
[
|
|
43
67
|
{
|
|
44
68
|
icon: {
|
|
45
|
-
|
|
46
|
-
pos: "leading",
|
|
69
|
+
icon: "IconClipboardCopy",
|
|
47
70
|
className: "h-5 w-5",
|
|
48
71
|
outline: false
|
|
49
72
|
},
|
|
73
|
+
iconPosition: "leading",
|
|
50
74
|
key: "Copy",
|
|
51
75
|
label: "Copy",
|
|
52
76
|
onClick: () => {
|
|
@@ -57,11 +81,11 @@ export const dropdownDataWithIcons: IItemProp[][] = [
|
|
|
57
81
|
[
|
|
58
82
|
{
|
|
59
83
|
icon: {
|
|
60
|
-
|
|
61
|
-
pos: "leading",
|
|
84
|
+
icon: "IconFolderPlus",
|
|
62
85
|
className: "h-5 w-5",
|
|
63
86
|
outline: false
|
|
64
87
|
},
|
|
88
|
+
iconPosition: "leading",
|
|
65
89
|
key: "Add to Batch",
|
|
66
90
|
label: "Add to Batch",
|
|
67
91
|
onClick: () => {
|
|
@@ -70,11 +94,11 @@ export const dropdownDataWithIcons: IItemProp[][] = [
|
|
|
70
94
|
},
|
|
71
95
|
{
|
|
72
96
|
icon: {
|
|
73
|
-
|
|
74
|
-
pos: "leading",
|
|
97
|
+
icon: "IconEye",
|
|
75
98
|
className: "h-5 w-5",
|
|
76
99
|
outline: false
|
|
77
100
|
},
|
|
101
|
+
iconPosition: "leading",
|
|
78
102
|
key: "View Batch",
|
|
79
103
|
label: "View Batch",
|
|
80
104
|
onClick: () => {
|
|
@@ -85,11 +109,11 @@ export const dropdownDataWithIcons: IItemProp[][] = [
|
|
|
85
109
|
[
|
|
86
110
|
{
|
|
87
111
|
icon: {
|
|
88
|
-
|
|
89
|
-
pos: "leading",
|
|
112
|
+
icon: "IconTrash",
|
|
90
113
|
className: "h-5 w-5",
|
|
91
114
|
outline: false
|
|
92
115
|
},
|
|
116
|
+
iconPosition: "leading",
|
|
93
117
|
key: "Delete",
|
|
94
118
|
label: "Delete",
|
|
95
119
|
onClick: () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Dropdown, { IItemProp,
|
|
2
|
-
export type { IItemProp,
|
|
1
|
+
import Dropdown, { IItemProp, IDropdownProps, defaultClassNames } from "./DropdownComponent"
|
|
2
|
+
export type { IItemProp, IDropdownProps }
|
|
3
3
|
export { defaultClassNames }
|
|
4
4
|
export default Dropdown
|
|
@@ -79,7 +79,12 @@ const FormInputWithAddons: React.FC<IFormInputWithAddonsProps> = ({
|
|
|
79
79
|
<DynamicIcon
|
|
80
80
|
{...{
|
|
81
81
|
...leadIcon,
|
|
82
|
-
className: cn(
|
|
82
|
+
className: cn(
|
|
83
|
+
"h-5 w-5 text-gray-400",
|
|
84
|
+
leadIconClassNames,
|
|
85
|
+
customIconClass,
|
|
86
|
+
leadIcon.className
|
|
87
|
+
),
|
|
83
88
|
outline: iconOutlined
|
|
84
89
|
}}
|
|
85
90
|
/>
|
|
@@ -123,7 +128,7 @@ const FormInputWithAddons: React.FC<IFormInputWithAddonsProps> = ({
|
|
|
123
128
|
<DynamicIcon
|
|
124
129
|
{...{
|
|
125
130
|
...trailIcon,
|
|
126
|
-
className: cn("h-5 w-5 text-gray-400", customIconClass),
|
|
131
|
+
className: cn("h-5 w-5 text-gray-400", customIconClass, trailIcon.className),
|
|
127
132
|
outline: iconOutlined
|
|
128
133
|
}}
|
|
129
134
|
/>
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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
|
+
}
|