@agility/plenum-ui 2.0.0-rc2 → 2.0.0-rc4

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.
Files changed (25) hide show
  1. package/dist/index.d.ts +15 -11
  2. package/dist/index.js +111 -66
  3. package/dist/index.js.map +2 -2
  4. package/dist/types/stories/atoms/buttons/Button/Alternative/Alternative.stories.d.ts +1 -0
  5. package/dist/types/stories/atoms/buttons/Button/Button.d.ts +6 -4
  6. package/dist/types/stories/atoms/buttons/Button/Danger/Danger.stories.d.ts +1 -0
  7. package/dist/types/stories/atoms/buttons/Button/Primary/Primary.stories.d.ts +1 -0
  8. package/dist/types/stories/atoms/buttons/Button/Secondary/Secondary.stories.d.ts +1 -0
  9. package/dist/types/stories/molecules/inputs/InputField/InputField.d.ts +2 -0
  10. package/dist/types/stories/organisms/DropdownComponent/DropdownComponent.d.ts +3 -7
  11. package/package.json +2 -2
  12. package/stories/atoms/buttons/Button/Alternative/Alternative.stories.ts +7 -0
  13. package/stories/atoms/buttons/Button/Button.tsx +25 -2
  14. package/stories/atoms/buttons/Button/Danger/Danger.stories.ts +7 -0
  15. package/stories/atoms/buttons/Button/Primary/Primary.stories.ts +7 -0
  16. package/stories/atoms/buttons/Button/Secondary/Secondary.stories.ts +7 -0
  17. package/stories/molecules/inputs/InputCounter/InputCounter.stories.tsx +18 -0
  18. package/stories/molecules/inputs/InputCounter/InputCounter.tsx +24 -0
  19. package/stories/molecules/inputs/InputCounter/index.tsx +3 -0
  20. package/stories/molecules/inputs/InputField/InputField.tsx +6 -1
  21. package/stories/molecules/inputs/TextInput/TextInput.stories.tsx +32 -0
  22. package/stories/molecules/inputs/TextInput/TextInput.tsx +162 -0
  23. package/stories/molecules/inputs/TextInput/index.tsx +3 -0
  24. package/stories/organisms/DropdownComponent/DropdownComponent.tsx +111 -80
  25. package/stories/organisms/DropdownComponent/dropdownItems.ts +8 -8
@@ -18,15 +18,11 @@ import {
18
18
  } from "@floating-ui/react"
19
19
 
20
20
  import { ClassNameWithAutocomplete } from "utils/types"
21
- import { DynamicIcon, IDynamicIconProps } from "@/stories/atoms/icons"
21
+ import { DynamicIcon, IDynamicIconProps, UnifiedIconName } from "@/stories/atoms/icons"
22
22
 
23
23
  export interface IItemProp extends HTMLAttributes<HTMLButtonElement> {
24
- icon?: {
25
- name: IDynamicIconProps["icon"]
26
- className?: ClassNameWithAutocomplete
27
- pos?: "trailing" | "leading"
28
- outline?: boolean
29
- }
24
+ icon?: IDynamicIconProps | UnifiedIconName
25
+ iconPosition?: "trailing" | "leading"
30
26
  label: string
31
27
  onClick?(): void
32
28
  isEmphasized?: boolean
@@ -180,80 +176,115 @@ const Dropdown: React.FC<IDropdownProps> = ({
180
176
  {items.map((itemStack, idx) => {
181
177
  return (
182
178
  <React.Fragment key={`${idx}-list-${id}`}>
183
- {itemStack.map(({ onClick, label, key, isEmphasized, icon, ...rest }) => {
184
- const active = activeItem && activeItem === key
185
- const itemClass = cn(
186
- itemClassname,
187
- "group flex cursor-pointer items-center px-4 py-2 text-sm transition-all",
188
- {
189
- "text-red-500": isEmphasized
190
- },
191
- {
192
- "text-gray-900": !isEmphasized
193
- },
194
- {
195
- "bg-gray-100 text-gray-900": active
196
- },
197
- active ? activeItemClassname : "",
198
- {
199
- "bg-gray-100 text-red-500 hover:text-red-500":
200
- active && isEmphasized
201
- },
202
- itemClassname
203
- )
179
+ {itemStack.map(
180
+ ({
181
+ onClick,
182
+ label,
183
+ key,
184
+ isEmphasized,
185
+ icon,
186
+ iconPosition,
187
+ ...rest
188
+ }) => {
189
+ const active = activeItem && activeItem === key
190
+ const itemClass = cn(
191
+ itemClassname,
192
+ "group flex cursor-pointer items-center px-4 py-2 text-sm transition-all",
193
+ {
194
+ "text-red-500": isEmphasized
195
+ },
196
+ {
197
+ "text-gray-900": !isEmphasized
198
+ },
199
+ {
200
+ "bg-gray-100 text-gray-900": active
201
+ },
202
+ active ? activeItemClassname : "",
203
+ {
204
+ "bg-gray-100 text-red-500 hover:text-red-500":
205
+ active && isEmphasized
206
+ },
207
+ itemClassname
208
+ )
204
209
 
205
- return (
206
- <li key={key}>
207
- <button
208
- {...{
209
- onClick: () => {
210
- setActiveItem(key)
211
- onClick && onClick()
212
- },
213
- key,
214
- className: cn(itemClass, "w-full"),
215
- ...rest
216
- }}
217
- >
218
- <div className="flex items-center gap-x-4">
219
- {icon &&
220
- (icon.pos === "leading" ||
221
- icon?.pos === undefined) && (
222
- <DynamicIcon
223
- {...{
224
- icon: icon.name,
225
- className: cn(
226
- icon.className,
227
- {
228
- "text-red-500": isEmphasized
229
- },
230
- "opacity-60 group-hover:opacity-100"
231
- ),
232
- outline: icon.outline
233
- }}
234
- />
235
- )}
236
- <div className="whitespace-nowrap">{label}</div>
237
- {icon && icon.pos === "trailing" && (
238
- <DynamicIcon
239
- {...{
240
- icon: icon.name,
241
- className: cn(
242
- icon.className,
243
- {
244
- "text-red-500": isEmphasized
245
- },
246
- "opacity-60 group-"
247
- ),
248
- outline: icon.outline
249
- }}
250
- />
251
- )}
252
- </div>
253
- </button>
254
- </li>
255
- )
256
- })}
210
+ return (
211
+ <li key={key}>
212
+ <button
213
+ {...{
214
+ onClick: () => {
215
+ setActiveItem(key)
216
+ onClick && onClick()
217
+ },
218
+ key,
219
+ className: cn(itemClass, "w-full"),
220
+ ...rest
221
+ }}
222
+ >
223
+ <div className="flex items-center gap-x-4">
224
+ {icon &&
225
+ (iconPosition === "leading" ||
226
+ iconPosition === undefined) &&
227
+ (typeof icon === "string" ? (
228
+ <DynamicIcon
229
+ {...{
230
+ icon: icon,
231
+ className: cn(
232
+ {
233
+ "text-red-500": isEmphasized
234
+ },
235
+ "opacity-60 group"
236
+ )
237
+ }}
238
+ />
239
+ ) : (
240
+ <DynamicIcon
241
+ {...{
242
+ ...icon,
243
+ className: cn(
244
+ icon.className,
245
+ {
246
+ "text-red-500": isEmphasized
247
+ },
248
+ "opacity-60 group"
249
+ )
250
+ }}
251
+ />
252
+ ))}
253
+ <div className="whitespace-nowrap">{label}</div>
254
+ {icon &&
255
+ iconPosition === "trailing" &&
256
+ (typeof icon === "string" ? (
257
+ <DynamicIcon
258
+ {...{
259
+ icon: icon,
260
+ className: cn(
261
+ {
262
+ "text-red-500": isEmphasized
263
+ },
264
+ "opacity-60 group"
265
+ )
266
+ }}
267
+ />
268
+ ) : (
269
+ <DynamicIcon
270
+ {...{
271
+ ...icon,
272
+ className: cn(
273
+ icon.className,
274
+ {
275
+ "text-red-500": isEmphasized
276
+ },
277
+ "opacity-60 group"
278
+ )
279
+ }}
280
+ />
281
+ ))}
282
+ </div>
283
+ </button>
284
+ </li>
285
+ )
286
+ }
287
+ )}
257
288
  </React.Fragment>
258
289
  )
259
290
  })}
@@ -42,11 +42,11 @@ export const dropdownDataWithIcons: IItemProp[][] = [
42
42
  [
43
43
  {
44
44
  icon: {
45
- name: "IconClipboardCopy",
46
- pos: "leading",
45
+ icon: "IconClipboardCopy",
47
46
  className: "h-5 w-5",
48
47
  outline: false
49
48
  },
49
+ iconPosition: "leading",
50
50
  key: "Copy",
51
51
  label: "Copy",
52
52
  onClick: () => {
@@ -57,11 +57,11 @@ export const dropdownDataWithIcons: IItemProp[][] = [
57
57
  [
58
58
  {
59
59
  icon: {
60
- name: "IconFolderPlus",
61
- pos: "leading",
60
+ icon: "IconFolderPlus",
62
61
  className: "h-5 w-5",
63
62
  outline: false
64
63
  },
64
+ iconPosition: "leading",
65
65
  key: "Add to Batch",
66
66
  label: "Add to Batch",
67
67
  onClick: () => {
@@ -70,11 +70,11 @@ export const dropdownDataWithIcons: IItemProp[][] = [
70
70
  },
71
71
  {
72
72
  icon: {
73
- name: "IconEye",
74
- pos: "leading",
73
+ icon: "IconEye",
75
74
  className: "h-5 w-5",
76
75
  outline: false
77
76
  },
77
+ iconPosition: "leading",
78
78
  key: "View Batch",
79
79
  label: "View Batch",
80
80
  onClick: () => {
@@ -85,11 +85,11 @@ export const dropdownDataWithIcons: IItemProp[][] = [
85
85
  [
86
86
  {
87
87
  icon: {
88
- name: "IconTrash",
89
- pos: "leading",
88
+ icon: "IconTrash",
90
89
  className: "h-5 w-5",
91
90
  outline: false
92
91
  },
92
+ iconPosition: "leading",
93
93
  key: "Delete",
94
94
  label: "Delete",
95
95
  onClick: () => {