@catalystsoftware/ui 1.0.2 → 1.0.5

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 (157) hide show
  1. package/data/tailwind.config.js +261 -3821
  2. package/dist/components/catalyst-ui/buttons/burger.tsx +207 -0
  3. package/dist/components/catalyst-ui/core/data-display/timeline.tsx +210 -0
  4. package/dist/components/catalyst-ui/core/feedback/alert.tsx +491 -0
  5. package/dist/components/catalyst-ui/core/feedback/spinner-1.tsx +65 -0
  6. package/dist/components/catalyst-ui/core/feedback/toast.tsx +1857 -0
  7. package/dist/components/catalyst-ui/core/navigation/menu.tsx +164 -0
  8. package/dist/components/catalyst-ui/forms/toggle-class.tsx +176 -0
  9. package/dist/components/catalyst-ui/hooks/use-copy-to-clipboard.tsx +419 -0
  10. package/dist/components/catalyst-ui/hooks/use-counter.tsx +13 -0
  11. package/dist/components/catalyst-ui/hooks/use-event-listener.tsx +23 -0
  12. package/dist/components/catalyst-ui/hooks/use-export-markdown.tsx +47 -0
  13. package/dist/components/catalyst-ui/hooks/use-focus.tsx +17 -0
  14. package/dist/components/catalyst-ui/hooks/use-interval.tsx +23 -0
  15. package/dist/components/catalyst-ui/hooks/use-is-client.tsx +16 -0
  16. package/dist/components/catalyst-ui/hooks/use-media-query.tsx +19 -0
  17. package/dist/components/catalyst-ui/hooks/use-mobile.tsx +19 -0
  18. package/dist/components/catalyst-ui/hooks/use-resize-observer.tsx +81 -0
  19. package/dist/components/catalyst-ui/hooks/use-timeout.tsx +21 -0
  20. package/dist/components/catalyst-ui/hooks/use-timer.tsx +209 -0
  21. package/dist/components/catalyst-ui/hooks/use-toggle.tsx +12 -0
  22. package/dist/components/catalyst-ui/media/image.tsx +13 -0
  23. package/dist/components/catalyst-ui/overlays/dual-sidebar.tsx +4142 -0
  24. package/dist/components/catalyst-ui/overlays/sidebar-original.tsx +726 -0
  25. package/dist/components/catalyst-ui/primitives/accordion.tsx +250 -0
  26. package/dist/components/catalyst-ui/primitives/alert-dialog.tsx +126 -0
  27. package/dist/components/catalyst-ui/primitives/aspect-ratio.tsx +9 -0
  28. package/dist/components/catalyst-ui/primitives/avatar.tsx +296 -0
  29. package/dist/components/catalyst-ui/primitives/badge.tsx +57 -0
  30. package/dist/components/catalyst-ui/primitives/breadcrumb.tsx +101 -0
  31. package/dist/components/catalyst-ui/primitives/button.tsx +265 -0
  32. package/dist/components/catalyst-ui/primitives/calendar-v4.tsx +208 -0
  33. package/dist/components/catalyst-ui/primitives/calendar.tsx +295 -0
  34. package/dist/components/catalyst-ui/primitives/card.tsx +618 -0
  35. package/dist/components/catalyst-ui/primitives/carousel.tsx +238 -0
  36. package/dist/components/catalyst-ui/primitives/chart.tsx +347 -0
  37. package/dist/components/catalyst-ui/primitives/checkbox.tsx +225 -0
  38. package/dist/components/catalyst-ui/primitives/collapsible.tsx +212 -0
  39. package/dist/components/catalyst-ui/primitives/command.tsx +393 -0
  40. package/dist/components/catalyst-ui/primitives/context-menu.tsx +236 -0
  41. package/dist/components/catalyst-ui/primitives/dialog.tsx +471 -0
  42. package/dist/components/catalyst-ui/primitives/drawer.tsx +761 -0
  43. package/dist/components/catalyst-ui/primitives/dropdown-menu.tsx +290 -0
  44. package/dist/components/catalyst-ui/primitives/empty.tsx +104 -0
  45. package/dist/components/catalyst-ui/primitives/field.tsx +244 -0
  46. package/dist/components/catalyst-ui/primitives/hover-card.tsx +124 -0
  47. package/dist/components/catalyst-ui/primitives/input-otp.tsx +76 -0
  48. package/dist/components/catalyst-ui/primitives/input.tsx +64 -0
  49. package/dist/components/catalyst-ui/primitives/item.tsx +196 -0
  50. package/dist/components/catalyst-ui/primitives/kbd.tsx +75 -0
  51. package/dist/components/catalyst-ui/primitives/label.tsx +24 -0
  52. package/dist/components/catalyst-ui/primitives/navigation-menu.tsx +150 -0
  53. package/dist/components/catalyst-ui/primitives/pagination.tsx +198 -0
  54. package/dist/components/catalyst-ui/primitives/popover.tsx +232 -0
  55. package/dist/components/catalyst-ui/primitives/progress.tsx +34 -0
  56. package/dist/components/catalyst-ui/primitives/radio-group.tsx +43 -0
  57. package/dist/components/catalyst-ui/primitives/resizable.tsx +56 -0
  58. package/dist/components/catalyst-ui/primitives/select.tsx +155 -0
  59. package/dist/components/catalyst-ui/primitives/separator.tsx +74 -0
  60. package/dist/components/catalyst-ui/primitives/sheet.tsx +126 -0
  61. package/dist/components/catalyst-ui/primitives/skeleton.tsx +15 -0
  62. package/dist/components/catalyst-ui/primitives/slider.tsx +27 -0
  63. package/dist/components/catalyst-ui/primitives/switch.tsx +187 -0
  64. package/dist/components/catalyst-ui/primitives/tabs.tsx +335 -0
  65. package/dist/components/catalyst-ui/primitives/textarea.tsx +24 -0
  66. package/dist/components/catalyst-ui/primitives/toggle-group.tsx +55 -0
  67. package/dist/components/catalyst-ui/primitives/toggle.tsx +42 -0
  68. package/dist/components/catalyst-ui/primitives/tooltip.tsx +116 -0
  69. package/dist/components/catalyst-ui/utils/basic-auth.tsx +40 -0
  70. package/dist/components/catalyst-ui/utils/context-storage.tsx +19 -0
  71. package/dist/components/catalyst-ui/utils/cors-middleware.tsx +71 -0
  72. package/dist/components/catalyst-ui/utils/deferred-content.tsx +595 -0
  73. package/dist/components/catalyst-ui/utils/honeypot-middleware.tsx +38 -0
  74. package/dist/components/catalyst-ui/utils/incId.tsx +75 -0
  75. package/dist/components/catalyst-ui/utils/jwk-auth.tsx +36 -0
  76. package/dist/components/catalyst-ui/utils/request-id.tsx +14 -0
  77. package/dist/components/catalyst-ui/utils/secure-headers.tsx +37 -0
  78. package/dist/components/catalyst-ui/utils/server-timing.tsx +23 -0
  79. package/dist/components/catalyst-ui/utils/utils.ts +43 -0
  80. package/dist/components/catalyst-ui/utils/with-cookie.tsx +43 -0
  81. package/dist/components/catalyst-ui/x/accordian-x.tsx +428 -0
  82. package/dist/components/catalyst-ui/x/alert-x.tsx +413 -0
  83. package/dist/components/catalyst-ui/x/animated-text-x.tsx +2242 -0
  84. package/dist/components/catalyst-ui/x/avatar-x.tsx +515 -0
  85. package/dist/components/catalyst-ui/x/badge-x.tsx +670 -0
  86. package/dist/components/catalyst-ui/x/button-X.tsx +2857 -0
  87. package/dist/components/catalyst-ui/x/button-group-x.tsx +847 -0
  88. package/dist/components/catalyst-ui/x/calendar-x.tsx +1910 -0
  89. package/dist/components/catalyst-ui/x/card-x.tsx +2597 -0
  90. package/dist/components/catalyst-ui/x/checkbox-x.tsx +656 -0
  91. package/dist/components/catalyst-ui/x/collapsible-x.tsx +1360 -0
  92. package/dist/components/catalyst-ui/x/combobox-x.tsx +911 -0
  93. package/dist/components/catalyst-ui/x/data-table-x.tsx +1753 -0
  94. package/dist/components/catalyst-ui/x/date-picker-x.tsx +648 -0
  95. package/dist/components/catalyst-ui/x/dialog-x.tsx +659 -0
  96. package/dist/components/catalyst-ui/x/dropdown-menu-x.tsx +612 -0
  97. package/dist/components/catalyst-ui/x/hover-card-x.tsx +375 -0
  98. package/dist/components/catalyst-ui/x/icon-x.tsx +840 -0
  99. package/dist/components/catalyst-ui/x/input-mask-x.tsx +981 -0
  100. package/dist/components/catalyst-ui/x/input-otp-x.tsx +659 -0
  101. package/dist/components/catalyst-ui/x/loader-x.tsx +1757 -0
  102. package/dist/components/catalyst-ui/x/pagination-x.tsx +622 -0
  103. package/dist/components/catalyst-ui/x/popover-x.tsx +744 -0
  104. package/dist/components/catalyst-ui/x/radio-group-x.tsx +499 -0
  105. package/dist/components/catalyst-ui/x/select-x.tsx +1127 -0
  106. package/dist/components/catalyst-ui/x/sheet-x.tsx +668 -0
  107. package/dist/components/catalyst-ui/x/switch-x.tsx +681 -0
  108. package/dist/components/catalyst-ui/x/table-x.tsx +574 -0
  109. package/dist/components/catalyst-ui/x/tabs-x.tsx +839 -0
  110. package/dist/components/catalyst-ui/x/textarea-x.tsx +1263 -0
  111. package/dist/components/catalyst-ui/x/tooltip-x.tsx +396 -0
  112. package/dist/components/catalyst-ui/x/tracker-x.tsx +560 -0
  113. package/dist/data/bg-data.tsx +901 -0
  114. package/dist/data/buttons-data.tsx +2327 -0
  115. package/dist/data/charts-data.tsx +102 -0
  116. package/dist/data/chat-data.tsx +83 -0
  117. package/dist/data/code-data.tsx +1040 -0
  118. package/dist/data/comboboxes-data.tsx +1843 -0
  119. package/dist/data/command-data.tsx +1381 -0
  120. package/dist/data/core-data.tsx +15953 -0
  121. package/dist/data/crm-data.tsx +47 -0
  122. package/dist/data/data.tsx +159 -0
  123. package/dist/data/date-and-time-data.tsx +554 -0
  124. package/dist/data/dependencies.tsx +7 -0
  125. package/dist/data/ecommerce-data.tsx +1387 -0
  126. package/dist/data/forms-data.tsx +7890 -0
  127. package/dist/data/hooks-data.tsx +5487 -0
  128. package/dist/data/index.ts +34 -0
  129. package/dist/data/inputs-data.tsx +557 -0
  130. package/dist/data/interactive-data.tsx +5394 -0
  131. package/dist/data/lofi-data.tsx +18295 -0
  132. package/dist/data/marketing-data.tsx +2546 -0
  133. package/dist/data/media-data.tsx +1510 -0
  134. package/dist/data/motion-data.tsx +5801 -0
  135. package/dist/data/overlay-data.tsx +4136 -0
  136. package/dist/data/pdf-data.tsx +124 -0
  137. package/dist/data/pos-data.tsx +213 -0
  138. package/dist/data/postcss.config.js +6 -0
  139. package/dist/data/primitive-data.tsx +5170 -0
  140. package/dist/data/prompt-data.tsx +1226 -0
  141. package/dist/data/requiredLibs.ts +4 -0
  142. package/dist/data/sandbox-data.tsx +1 -0
  143. package/dist/data/sidebars-data.tsx +5421 -0
  144. package/dist/data/stacks-data.tsx +32 -0
  145. package/dist/data/table-data.tsx +706 -0
  146. package/dist/data/tailwind.config.js +270 -0
  147. package/dist/data/tailwind.config.ngin.js +3830 -0
  148. package/dist/data/tailwind.css +431 -0
  149. package/dist/data/tools-data.tsx +6910 -0
  150. package/dist/data/typography-data.tsx +2050 -0
  151. package/dist/data/utils-data.tsx +6500 -0
  152. package/dist/data/x-data.tsx +1171 -0
  153. package/dist/data.tsx +159 -0
  154. package/package.json +1 -1
  155. package/dist/index.d.ts +0 -3
  156. package/dist/index.d.ts.map +0 -1
  157. package/dist/index.js.map +0 -362
@@ -0,0 +1,911 @@
1
+ /**
2
+
3
+
4
+
5
+
6
+
7
+
8
+ export function ComboboxX({ combobox = 'default', children, ...props }: any) {
9
+ switch (combobox) {
10
+ case 'Closable':
11
+ break
12
+ default:
13
+ break;
14
+ }
15
+ }
16
+
17
+ const ComboboxDemo = () => {
18
+ const [open, setOpen] = useState(false)
19
+ const [value, setValue] = useState('')
20
+
21
+ return (
22
+ <Popover open={open} onOpenChange={setOpen}>
23
+ <PopoverTrigger asChild>
24
+ <Button
25
+ variant='outline'
26
+ role='combobox'
27
+ aria-expanded={open}
28
+ className='w-full max-w-xs justify-between'
29
+ aria-label='Framework combobox'
30
+ >
31
+ {value ? frameworks.find(framework => framework.value === value)?.label : 'Select framework...'}
32
+ <ChevronsUpDownIcon className='opacity-50' />
33
+ </Button>
34
+ </PopoverTrigger>
35
+ <PopoverContent className='p-0'>
36
+ <Command>
37
+ <CommandInput placeholder='Search framework...' className='h-9' />
38
+ <CommandList>
39
+ <CommandEmpty>No framework found.</CommandEmpty>
40
+ <CommandGroup>
41
+ {frameworks.map(framework => (
42
+ <CommandItem
43
+ key={framework.value}
44
+ value={framework.value}
45
+ onSelect={currentValue => {
46
+ setValue(currentValue === value ? '' : currentValue)
47
+ setOpen(false)
48
+ }}
49
+ >
50
+ {framework.label}
51
+ <CheckIcon className={cn('ml-auto', value === framework.value ? 'opacity-100' : 'opacity-0')} />
52
+ </CommandItem>
53
+ ))}
54
+ </CommandGroup>
55
+ </CommandList>
56
+ </Command>
57
+ </PopoverContent>
58
+ </Popover>
59
+ )
60
+ }
61
+
62
+ const ComboboxOptionGroupDemo = () => {
63
+ const id = useId()
64
+ const [open, setOpen] = useState<boolean>(false)
65
+ const [value, setValue] = useState<string>('')
66
+
67
+ return (
68
+ <div className='w-full max-w-xs space-y-2'>
69
+ <Label htmlFor={id}>Combobox option group</Label>
70
+ <Popover open={open} onOpenChange={setOpen}>
71
+ <PopoverTrigger asChild>
72
+ <Button
73
+ id={id}
74
+ variant='outline'
75
+ role='combobox'
76
+ aria-expanded={open}
77
+ className='bg-background hover:bg-background border-input w-full justify-between px-3 font-normal outline-offset-0 outline-none focus-visible:outline-[3px]'
78
+ >
79
+ {value ? (
80
+ <span className='flex min-w-0 items-center gap-2'>
81
+ <span className='truncate'>{value}</span>
82
+ </span>
83
+ ) : (
84
+ <span className='text-muted-foreground'>Select item</span>
85
+ )}
86
+ <ChevronsUpDownIcon className='text-muted-foreground/80 shrink-0' aria-hidden='true' />
87
+ </Button>
88
+ </PopoverTrigger>
89
+ <PopoverContent className='border-input w-full min-w-[var(--radix-popper-anchor-width)] p-0' align='start'>
90
+ <Command>
91
+ <CommandInput placeholder='Search item...' />
92
+ <CommandList>
93
+ <CommandEmpty>No item found.</CommandEmpty>
94
+ {items.map(group => (
95
+ <Fragment key={group.continent}>
96
+ <CommandGroup heading={group.continent}>
97
+ {group.items.map(item => (
98
+ <CommandItem
99
+ key={item.value}
100
+ value={item.value}
101
+ onSelect={currentValue => {
102
+ setValue(currentValue)
103
+ setOpen(false)
104
+ }}
105
+ >
106
+ {item.value}
107
+ {value === item.value && <CheckIcon size={16} className='ml-auto' />}
108
+ </CommandItem>
109
+ ))}
110
+ </CommandGroup>
111
+ </Fragment>
112
+ ))}
113
+ </CommandList>
114
+ </Command>
115
+ </PopoverContent>
116
+ </Popover>
117
+ </div>
118
+ )
119
+ }
120
+
121
+ const ComboboxOptionDisabledDemo = () => {
122
+ const id = useId()
123
+ const [open, setOpen] = useState<boolean>(false)
124
+ const [value, setValue] = useState<string>('')
125
+
126
+ return (
127
+ <div className='w-full max-w-xs space-y-2'>
128
+ <Label htmlFor={id}>Combobox disabled option </Label>
129
+ <Popover open={open} onOpenChange={setOpen}>
130
+ <PopoverTrigger asChild>
131
+ <Button
132
+ id={id}
133
+ variant='outline'
134
+ role='combobox'
135
+ aria-expanded={open}
136
+ className='bg-background hover:bg-background border-input w-full justify-between px-3 font-normal outline-offset-0 outline-none focus-visible:outline-[3px]'
137
+ >
138
+ {value ? (
139
+ <span className='flex min-w-0 items-center gap-2'>
140
+ <span className='truncate'>{value}</span>
141
+ </span>
142
+ ) : (
143
+ <span className='text-muted-foreground'>Select item</span>
144
+ )}
145
+ <ChevronsUpDownIcon className='text-muted-foreground/80 shrink-0' aria-hidden='true' />
146
+ </Button>
147
+ </PopoverTrigger>
148
+ <PopoverContent className='border-input w-full min-w-[var(--radix-popper-anchor-width)] p-0' align='start'>
149
+ <Command>
150
+ <CommandInput placeholder='Search item...' />
151
+ <CommandList>
152
+ <CommandEmpty>No item found.</CommandEmpty>
153
+ {items.map(group => (
154
+ <Fragment key={group.category}>
155
+ <CommandGroup heading={group.category}>
156
+ {group.items.map(item => (
157
+ <CommandItem
158
+ key={item.value}
159
+ value={item.value}
160
+ onSelect={currentValue => {
161
+ setValue(currentValue)
162
+ setOpen(false)
163
+ }}
164
+ className={cn(item.disabled && 'cursor-not-allowed opacity-50')}
165
+ disabled={item.disabled}
166
+ >
167
+ {item.value}
168
+ {value === item.value && <CheckIcon size={16} className='ml-auto' />}
169
+ </CommandItem>
170
+ ))}
171
+ </CommandGroup>
172
+ </Fragment>
173
+ ))}
174
+ </CommandList>
175
+ </Command>
176
+ </PopoverContent>
177
+ </Popover>
178
+ </div>
179
+ )
180
+ }
181
+
182
+ const ComboboxOptionWithIIconDemo = () => {
183
+ const id = useId()
184
+ const [open, setOpen] = useState<boolean>(false)
185
+ const [value, setValue] = useState<string>('')
186
+
187
+ return (
188
+ <div className='w-full max-w-xs space-y-2'>
189
+ <Label htmlFor={id}>Combobox option with icon</Label>
190
+ <Popover open={open} onOpenChange={setOpen}>
191
+ <PopoverTrigger asChild>
192
+ <Button
193
+ id={id}
194
+ variant='outline'
195
+ role='combobox'
196
+ aria-expanded={open}
197
+ className='bg-background hover:bg-background border-input w-full justify-between px-3 font-normal outline-offset-0 outline-none focus-visible:outline-[3px]'
198
+ >
199
+ {value ? (
200
+ <span className='flex min-w-0 items-center gap-2'>
201
+ {(() => {
202
+ const selectedItem = industries.find(industry => industry.value === value)
203
+
204
+ if (selectedItem) {
205
+ const Icon = selectedItem.icon
206
+
207
+ return <Icon className='text-muted-foreground' />
208
+ }
209
+
210
+ return null
211
+ })()}
212
+ <span className='truncate'>{industries.find(industry => industry.value === value)?.label}</span>
213
+ </span>
214
+ ) : (
215
+ <span className='text-muted-foreground'>Select industry category</span>
216
+ )}
217
+ <ChevronsUpDownIcon className='text-muted-foreground/80 shrink-0' aria-hidden='true' />
218
+ </Button>
219
+ </PopoverTrigger>
220
+ <PopoverContent className='border-input w-full min-w-[var(--radix-popper-anchor-width)] p-0' align='start'>
221
+ <Command>
222
+ <CommandInput placeholder='Search industries...' />
223
+ <CommandList>
224
+ <CommandEmpty>No industry found.</CommandEmpty>
225
+ <CommandGroup>
226
+ {industries.map(industry => (
227
+ <CommandItem
228
+ key={industry.value}
229
+ value={industry.value}
230
+ onSelect={currentValue => {
231
+ setValue(currentValue === value ? '' : currentValue)
232
+ setOpen(false)
233
+ }}
234
+ className='flex items-center justify-between'
235
+ >
236
+ <div className='flex items-center gap-2'>
237
+ <industry.icon className='text-muted-foreground size-4' />
238
+ {industry.label}
239
+ </div>
240
+ </CommandItem>
241
+ ))}
242
+ </CommandGroup>
243
+ </CommandList>
244
+ </Command>
245
+ </PopoverContent>
246
+ </Popover>
247
+ </div>
248
+ )
249
+ }
250
+
251
+ const ComboboxCustomCheckIconDemo = () => {
252
+ const id = useId()
253
+ const [open, setOpen] = useState(false)
254
+ const [value, setValue] = useState('')
255
+
256
+ return (
257
+ <div className='w-full max-w-xs space-y-2'>
258
+ <Label htmlFor={id}>Combobox with custom check icon</Label>
259
+ <Popover open={open} onOpenChange={setOpen}>
260
+ <PopoverTrigger asChild>
261
+ <Button
262
+ id={id}
263
+ variant='outline'
264
+ role='combobox'
265
+ aria-expanded={open}
266
+ className='w-full max-w-xs justify-between'
267
+ >
268
+ {value ? (
269
+ frameworks.find(framework => framework.value === value)?.label
270
+ ) : (
271
+ <span className='text-muted-foreground'>Select industry category</span>
272
+ )}
273
+ <ChevronsUpDownIcon className='opacity-50' />
274
+ </Button>
275
+ </PopoverTrigger>
276
+ <PopoverContent className='p-0'>
277
+ <Command>
278
+ <CommandInput placeholder='Search framework...' className='h-9' />
279
+ <CommandList>
280
+ <CommandEmpty>No framework found.</CommandEmpty>
281
+ <CommandGroup>
282
+ {frameworks.map(framework => (
283
+ <CommandItem
284
+ key={framework.value}
285
+ value={framework.value}
286
+ onSelect={currentValue => {
287
+ setValue(currentValue === value ? '' : currentValue)
288
+ setOpen(false)
289
+ }}
290
+ >
291
+ {framework.label}
292
+ <CircleCheckIcon
293
+ className={cn(
294
+ 'ml-auto fill-blue-500 stroke-white',
295
+ value === framework.value ? 'opacity-100' : 'opacity-0'
296
+ )}
297
+ />
298
+ </CommandItem>
299
+ ))}
300
+ </CommandGroup>
301
+ </CommandList>
302
+ </Command>
303
+ </PopoverContent>
304
+ </Popover>
305
+ </div>
306
+ )
307
+ }
308
+
309
+ const ComboboxWithSearchAndButtonDemo = () => {
310
+ const id = useId()
311
+ const [open, setOpen] = useState<boolean>(false)
312
+ const [value, setValue] = useState<string>('harvard')
313
+
314
+ return (
315
+ <div className='w-full max-w-xs space-y-2'>
316
+ <Label htmlFor={id}>Combobox with search and add button</Label>
317
+ <Popover open={open} onOpenChange={setOpen}>
318
+ <PopoverTrigger asChild>
319
+ <Button
320
+ id={id}
321
+ variant='outline'
322
+ role='combobox'
323
+ aria-expanded={open}
324
+ className='bg-background hover:bg-background border-input w-full justify-between px-3 font-normal outline-offset-0 outline-none focus-visible:outline-[3px]'
325
+ >
326
+ <span className={cn('truncate', !value && 'text-muted-foreground')}>
327
+ {value ? (
328
+ universities.find(university => university.value === value)?.label
329
+ ) : (
330
+ <span className='text-muted-foreground'>Select university</span>
331
+ )}
332
+ </span>
333
+ <ChevronsUpDownIcon className='text-muted-foreground/80 shrink-0' aria-hidden='true' />
334
+ </Button>
335
+ </PopoverTrigger>
336
+ <PopoverContent className='border-input w-full min-w-[var(--radix-popper-anchor-width)] p-0' align='start'>
337
+ <Command>
338
+ <CommandInput placeholder='Find university' />
339
+ <CommandList>
340
+ <CommandEmpty>No university found.</CommandEmpty>
341
+ <CommandGroup>
342
+ {universities.map(university => (
343
+ <CommandItem
344
+ key={university.value}
345
+ value={university.value}
346
+ onSelect={currentValue => {
347
+ setValue(currentValue === value ? '' : currentValue)
348
+ setOpen(false)
349
+ }}
350
+ >
351
+ {university.label}
352
+ {value === university.value && <CheckIcon size={16} className='ml-auto' />}
353
+ </CommandItem>
354
+ ))}
355
+ </CommandGroup>
356
+ <CommandSeparator />
357
+ <CommandGroup>
358
+ <Button variant='ghost' className='w-full justify-start font-normal'>
359
+ <PlusIcon className='-ms-2 opacity-60' aria-hidden='true' />
360
+ New university
361
+ </Button>
362
+ </CommandGroup>
363
+ </CommandList>
364
+ </Command>
365
+ </PopoverContent>
366
+ </Popover>
367
+ </div>
368
+ )
369
+ }
370
+
371
+ const ComboboxTimezoneDemo = () => {
372
+ const id = useId()
373
+ const [open, setOpen] = useState(false)
374
+ const [value, setValue] = useState<string>('Indian/Cocos')
375
+
376
+ // Fetch supported timezones
377
+ const timezones = Intl.supportedValuesOf('timeZone')
378
+
379
+ const formattedTimezones = useMemo(() => {
380
+ return timezones
381
+ .map(timezone => {
382
+ const formatter = new Intl.DateTimeFormat('en', {
383
+ timeZone: timezone,
384
+ timeZoneName: 'shortOffset'
385
+ })
386
+
387
+ const parts = formatter.formatToParts(new Date())
388
+ const offset = parts.find(part => part.type === 'timeZoneName')?.value || ''
389
+ const formattedOffset = offset === 'GMT' ? 'GMT+0' : offset
390
+
391
+ return {
392
+ value: timezone,
393
+ label: `(${formattedOffset}) ${timezone.replace(/_/g, ' ')}`,
394
+ numericOffset: parseInt(formattedOffset.replace('GMT', '').replace('+', '') || '0')
395
+ }
396
+ })
397
+ .sort((a, b) => a.numericOffset - b.numericOffset) // Sort by numeric offset
398
+ }, [timezones])
399
+
400
+ return (
401
+ <div className='w-full max-w-xs space-y-2'>
402
+ <Label htmlFor={id}>Timezone combobox</Label>
403
+ <Popover open={open} onOpenChange={setOpen}>
404
+ <PopoverTrigger asChild>
405
+ <Button id={id} variant='outline' role='combobox' aria-expanded={open} className='w-full justify-between'>
406
+ <span className={cn('truncate')}>
407
+ {value ? (
408
+ formattedTimezones.find(timezone => timezone.value === value)?.label
409
+ ) : (
410
+ <span className='text-muted-foreground'>Select timezone</span>
411
+ )}
412
+ </span>
413
+ <ChevronsUpDownIcon className='text-muted-foreground/80 shrink-0' aria-hidden='true' />
414
+ </Button>
415
+ </PopoverTrigger>
416
+ <PopoverContent className='w-(--radix-popper-anchor-width) p-0'>
417
+ <Command>
418
+ <CommandInput placeholder='Search timezone' />
419
+ <CommandList>
420
+ <CommandEmpty>No timezone found.</CommandEmpty>
421
+ <CommandGroup>
422
+ {formattedTimezones.map(({ value: itemValue, label }) => (
423
+ <CommandItem
424
+ key={itemValue}
425
+ value={itemValue}
426
+ onSelect={currentValue => {
427
+ setValue(currentValue === value ? '' : currentValue)
428
+ setOpen(false)
429
+ }}
430
+ >
431
+ <span className='truncate'>{label}</span>
432
+ {value === itemValue && <CheckIcon size={16} className='ml-auto' />}
433
+ </CommandItem>
434
+ ))}
435
+ </CommandGroup>
436
+ </CommandList>
437
+ </Command>
438
+ </PopoverContent>
439
+ </Popover>
440
+ </div>
441
+ )
442
+ }
443
+
444
+ const ComboboxUserDemo = () => {
445
+ const id = useId()
446
+ const [open, setOpen] = useState(false)
447
+ const [value, setValue] = useState('')
448
+
449
+ const selectedUser = users.find(user => user.name === value)
450
+
451
+ return (
452
+ <div className='w-full max-w-xs space-y-2'>
453
+ <Label htmlFor={id}>User combobox</Label>
454
+ <Popover open={open} onOpenChange={setOpen}>
455
+ <PopoverTrigger asChild>
456
+ <Button id={id} variant='outline' role='combobox' aria-expanded={open} className='w-full justify-between'>
457
+ {selectedUser ? (
458
+ <span className='flex gap-2'>
459
+ <Avatar className='size-6'>
460
+ <AvatarImage src={selectedUser.avatar} alt={selectedUser.name} />
461
+ <AvatarFallback>{selectedUser.name[0]}</AvatarFallback>
462
+ </Avatar>
463
+ <span className='font-medium'>{selectedUser.name}</span>
464
+ </span>
465
+ ) : (
466
+ <span className='text-muted-foreground'>Select user</span>
467
+ )}
468
+ <ChevronsUpDownIcon className='text-muted-foreground/80 shrink-0' aria-hidden='true' />
469
+ </Button>
470
+ </PopoverTrigger>
471
+ <PopoverContent className='w-[300px] p-0'>
472
+ <Command>
473
+ <CommandInput placeholder='Search user...' />
474
+ <CommandList>
475
+ <CommandEmpty>No users found.</CommandEmpty>
476
+ <CommandGroup>
477
+ {users.map(user => (
478
+ <CommandItem
479
+ key={user.name}
480
+ value={user.name}
481
+ onSelect={currentValue => {
482
+ setValue(currentValue === value ? '' : currentValue)
483
+ setOpen(false)
484
+ }}
485
+ >
486
+ <span className='flex items-center gap-2'>
487
+ <Avatar className='size-7'>
488
+ <AvatarImage src={user.avatar} alt={user.name} />
489
+ <AvatarFallback>{user.name[0]}</AvatarFallback>
490
+ </Avatar>
491
+ <span className='flex flex-col'>
492
+ <span className='font-medium'>{user.name}</span>
493
+ <span className='text-muted-foreground text-sm'>{user.email}</span>
494
+ </span>
495
+ </span>
496
+ {value === user.name && <CheckIcon size={16} className='ml-auto' />}
497
+ </CommandItem>
498
+ ))}
499
+ </CommandGroup>
500
+ </CommandList>
501
+ </Command>
502
+ </PopoverContent>
503
+ </Popover>
504
+ </div>
505
+ )
506
+ }
507
+
508
+ const ComboboxCountryFlagDemo = () => {
509
+ const id = useId()
510
+ const [open, setOpen] = useState<boolean>(false)
511
+ const [value, setValue] = useState<string>('')
512
+
513
+ return (
514
+ <div className='w-full max-w-xs space-y-2'>
515
+ <Label htmlFor={id}>Options with flag and search</Label>
516
+ <Popover open={open} onOpenChange={setOpen}>
517
+ <PopoverTrigger asChild>
518
+ <Button
519
+ id={id}
520
+ variant='outline'
521
+ role='combobox'
522
+ aria-expanded={open}
523
+ className='bg-background hover:bg-background border-input w-full justify-between px-3 font-normal outline-offset-0 outline-none focus-visible:outline-[3px]'
524
+ >
525
+ {value ? (
526
+ <span className='flex min-w-0 items-center gap-2'>
527
+ <img src={countries.find(item => item.label === value)?.flag} alt={value} className='h-4 w-5' />
528
+ <span className='truncate'>{value}</span>
529
+ </span>
530
+ ) : (
531
+ <span className='text-muted-foreground'>Select country</span>
532
+ )}
533
+ <ChevronDownIcon className='text-muted-foreground/80 shrink-0' aria-hidden='true' />
534
+ </Button>
535
+ </PopoverTrigger>
536
+ <PopoverContent className='border-input w-full min-w-[var(--radix-popper-anchor-width)] p-0' align='start'>
537
+ <Command>
538
+ <CommandInput placeholder='Search country...' />
539
+ <CommandList>
540
+ <CommandEmpty>No country found.</CommandEmpty>
541
+ {countries.map(country => (
542
+ <CommandItem
543
+ key={country.value}
544
+ value={country.label}
545
+ onSelect={currentValue => {
546
+ setValue(currentValue)
547
+ setOpen(false)
548
+ }}
549
+ >
550
+ <img src={country.flag} alt={`${country.label} flag`} className='h-4 w-5' />
551
+ {country.label}
552
+ {value === country.value && <CheckIcon size={16} className='ml-auto' />}
553
+ </CommandItem>
554
+ ))}
555
+ </CommandList>
556
+ </Command>
557
+ </PopoverContent>
558
+ </Popover>
559
+ </div>
560
+ )
561
+ }
562
+
563
+ const ComboboxMultipleDemo = () => {
564
+ const id = useId()
565
+ const [open, setOpen] = useState(false)
566
+ const [selectedValues, setSelectedValues] = useState<string[]>(['london', 'react'])
567
+
568
+ const toggleSelection = (value: string) => {
569
+ setSelectedValues(prev => (prev.includes(value) ? prev.filter(v => v !== value) : [...prev, value]))
570
+ }
571
+
572
+ const removeSelection = (value: string) => {
573
+ setSelectedValues(prev => prev.filter(v => v !== value))
574
+ }
575
+
576
+ return (
577
+ <div className='w-full max-w-xs space-y-2'>
578
+ <Label htmlFor={id}>Multiple combobox</Label>
579
+ <Popover open={open} onOpenChange={setOpen}>
580
+ <PopoverTrigger asChild>
581
+ <Button
582
+ id={id}
583
+ variant='outline'
584
+ role='combobox'
585
+ aria-expanded={open}
586
+ className='h-auto min-h-8 w-full justify-between hover:bg-transparent'
587
+ >
588
+ <div className='flex flex-wrap items-center gap-1 pr-2.5'>
589
+ {selectedValues.length > 0 ? (
590
+ selectedValues.map(val => {
591
+ const framework = frameworks.find(c => c.value === val)
592
+
593
+ return framework ? (
594
+ <Badge key={val} variant='outline' className='rounded-sm'>
595
+ {framework.label}
596
+ <Button
597
+ variant='ghost'
598
+ size='icon'
599
+ className='size-4'
600
+ onClick={e => {
601
+ e.stopPropagation()
602
+ removeSelection(val)
603
+ }}
604
+ asChild
605
+ >
606
+ <span>
607
+ <XIcon className='size-3' />
608
+ </span>
609
+ </Button>
610
+ </Badge>
611
+ ) : null
612
+ })
613
+ ) : (
614
+ <span className='text-muted-foreground'>Select framework</span>
615
+ )}
616
+ </div>
617
+ <ChevronsUpDownIcon className='text-muted-foreground/80 shrink-0' aria-hidden='true' />
618
+ </Button>
619
+ </PopoverTrigger>
620
+ <PopoverContent className='w-(--radix-popper-anchor-width) p-0'>
621
+ <Command>
622
+ <CommandInput placeholder='Search framework...' />
623
+ <CommandList>
624
+ <CommandEmpty>No framework found.</CommandEmpty>
625
+ <CommandGroup>
626
+ {frameworks.map(framework => (
627
+ <CommandItem
628
+ key={framework.value}
629
+ value={framework.value}
630
+ onSelect={() => toggleSelection(framework.value)}
631
+ >
632
+ <span className='truncate'>{framework.label}</span>
633
+ {selectedValues.includes(framework.value) && <CheckIcon size={16} className='ml-auto' />}
634
+ </CommandItem>
635
+ ))}
636
+ </CommandGroup>
637
+ </CommandList>
638
+ </Command>
639
+ </PopoverContent>
640
+ </Popover>
641
+ </div>
642
+ )
643
+ }
644
+
645
+ const ComboboxMultipleExpandableDemo = () => {
646
+ const id = useId()
647
+ const [open, setOpen] = useState(false)
648
+ const [expanded, setExpanded] = useState(false)
649
+
650
+ const [selectedValues, setSelectedValues] = useState<string[]>(['react', 'qwik', 'solidjs', 'angular', 'astro'])
651
+
652
+ const toggleSelection = (value: string) => {
653
+ setSelectedValues(prev => (prev.includes(value) ? prev.filter(v => v !== value) : [...prev, value]))
654
+ }
655
+
656
+ const removeSelection = (value: string) => {
657
+ setSelectedValues(prev => prev.filter(v => v !== value))
658
+ }
659
+
660
+ // Define maxShownItems before using visibleItems
661
+ const maxShownItems = 2
662
+ const visibleItems = expanded ? selectedValues : selectedValues.slice(0, maxShownItems)
663
+ const hiddenCount = selectedValues.length - visibleItems.length
664
+
665
+ return (
666
+ <div className='w-full max-w-xs space-y-2'>
667
+ <Label htmlFor={id}>Multiple combobox expandable</Label>
668
+ <Popover open={open} onOpenChange={setOpen}>
669
+ <PopoverTrigger asChild>
670
+ <Button
671
+ id={id}
672
+ variant='outline'
673
+ role='combobox'
674
+ aria-expanded={open}
675
+ className='h-auto min-h-8 w-full justify-between hover:bg-transparent'
676
+ >
677
+ <div className='flex flex-wrap items-center gap-1 pr-2.5'>
678
+ {selectedValues.length > 0 ? (
679
+ <>
680
+ {visibleItems.map(val => {
681
+ const framework = frameworks.find(c => c.value === val)
682
+
683
+ return framework ? (
684
+ <Badge key={val} variant='outline' className='rounded-sm'>
685
+ {framework.label}
686
+ <Button
687
+ variant='ghost'
688
+ size='icon'
689
+ className='size-4'
690
+ onClick={e => {
691
+ e.stopPropagation()
692
+ removeSelection(val)
693
+ }}
694
+ asChild
695
+ >
696
+ <span>
697
+ <XIcon className='size-3' />
698
+ </span>
699
+ </Button>
700
+ </Badge>
701
+ ) : null
702
+ })}
703
+ {hiddenCount > 0 || expanded ? (
704
+ <Badge
705
+ variant='outline'
706
+ onClick={e => {
707
+ e.stopPropagation()
708
+ setExpanded(prev => !prev)
709
+ }}
710
+ className='rounded-sm'
711
+ >
712
+ {expanded ? 'Show Less' : `+${hiddenCount} more`}
713
+ </Badge>
714
+ ) : null}
715
+ </>
716
+ ) : (
717
+ <span className='text-muted-foreground'>Select framework</span>
718
+ )}
719
+ </div>
720
+ <ChevronsUpDownIcon className='text-muted-foreground/80 shrink-0' aria-hidden='true' />
721
+ </Button>
722
+ </PopoverTrigger>
723
+ <PopoverContent className='w-(--radix-popper-anchor-width) p-0'>
724
+ <Command>
725
+ <CommandInput placeholder='Search framework...' />
726
+ <CommandList>
727
+ <CommandEmpty>No framework found.</CommandEmpty>
728
+ <CommandGroup>
729
+ {frameworks.map(framework => (
730
+ <CommandItem
731
+ key={framework.value}
732
+ value={framework.value}
733
+ onSelect={() => toggleSelection(framework.value)}
734
+ >
735
+ <span className='truncate'>{framework.label}</span>
736
+ {selectedValues.includes(framework.value) && <CheckIcon size={16} className='ml-auto' />}
737
+ </CommandItem>
738
+ ))}
739
+ </CommandGroup>
740
+ </CommandList>
741
+ </Command>
742
+ </PopoverContent>
743
+ </Popover>
744
+ </div>
745
+ )
746
+ }
747
+
748
+ const ComboboxMultipleCountBadgeDemo = () => {
749
+ const id = useId()
750
+ const [open, setOpen] = useState(false)
751
+
752
+ const [selectedValues, setSelectedValues] = useState<string[]>([
753
+ 'react',
754
+ 'nextjs',
755
+ 'angular',
756
+ 'vue',
757
+ 'django',
758
+ 'astro'
759
+ ])
760
+
761
+ const toggleSelection = (value: string) => {
762
+ setSelectedValues(prev => (prev.includes(value) ? prev.filter(v => v !== value) : [...prev, value]))
763
+ }
764
+
765
+ return (
766
+ <div className='w-full max-w-xs space-y-2'>
767
+ <Label htmlFor={id}>Multiple Count badge</Label>
768
+ <Popover open={open} onOpenChange={setOpen}>
769
+ <PopoverTrigger asChild>
770
+ <Button
771
+ id={id}
772
+ variant='outline'
773
+ role='combobox'
774
+ aria-expanded={open}
775
+ className='h-auto min-h-8 w-full justify-between hover:bg-transparent'
776
+ >
777
+ {selectedValues.length > 0 ? (
778
+ <span>
779
+ <Badge variant='outline' className='rounded-sm'>
780
+ {selectedValues.length}
781
+ </Badge>{' '}
782
+ frameworks selected
783
+ </span>
784
+ ) : (
785
+ <span className='text-muted-foreground'>Select framework</span>
786
+ )}
787
+ <ChevronsUpDownIcon className='text-muted-foreground/80 shrink-0' aria-hidden='true' />
788
+ </Button>
789
+ </PopoverTrigger>
790
+ <PopoverContent className='w-(--radix-popper-anchor-width) p-0'>
791
+ <Command>
792
+ <CommandInput placeholder='Search framework...' />
793
+ <CommandList>
794
+ <CommandEmpty>No framework found.</CommandEmpty>
795
+ <CommandGroup>
796
+ {frameworks.map(framework => (
797
+ <CommandItem
798
+ key={framework.value}
799
+ value={framework.value}
800
+ onSelect={() => toggleSelection(framework.value)}
801
+ >
802
+ <span className='truncate'>{framework.label}</span>
803
+ {selectedValues.includes(framework.value) && <CheckIcon size={16} className='ml-auto' />}
804
+ </CommandItem>
805
+ ))}
806
+ </CommandGroup>
807
+ </CommandList>
808
+ </Command>
809
+ </PopoverContent>
810
+ </Popover>
811
+ </div>
812
+ )
813
+ }
814
+
815
+ const ComboboxSlideInDemo = () => {
816
+ const id = useId()
817
+ const [open, setOpen] = useState(false)
818
+ const [value, setValue] = useState('')
819
+
820
+ return (
821
+ <div className='w-full max-w-xs space-y-2'>
822
+ <Label htmlFor={id}>Combobox menu slide-in from bottom</Label>
823
+ <Popover open={open} onOpenChange={setOpen}>
824
+ <PopoverTrigger asChild>
825
+ <Button
826
+ id={id}
827
+ variant='outline'
828
+ role='combobox'
829
+ aria-expanded={open}
830
+ className='w-full max-w-xs justify-between'
831
+ >
832
+ {value ? frameworks.find(framework => framework.value === value)?.label : 'Select framework...'}
833
+ <ChevronsUpDownIcon className='opacity-50' />
834
+ </Button>
835
+ </PopoverTrigger>
836
+ <PopoverContent className='data-[state=open]:zoom-in-100 data-[state=open]:slide-in-from-bottom-10 p-0 duration-400'>
837
+ <Command>
838
+ <CommandInput placeholder='Search framework...' className='h-9' />
839
+ <CommandList>
840
+ <CommandEmpty>No framework found.</CommandEmpty>
841
+ <CommandGroup>
842
+ {frameworks.map(framework => (
843
+ <CommandItem
844
+ key={framework.value}
845
+ value={framework.value}
846
+ onSelect={currentValue => {
847
+ setValue(currentValue === value ? '' : currentValue)
848
+ setOpen(false)
849
+ }}
850
+ >
851
+ {framework.label}
852
+ <CheckIcon className={cn('ml-auto', value === framework.value ? 'opacity-100' : 'opacity-0')} />
853
+ </CommandItem>
854
+ ))}
855
+ </CommandGroup>
856
+ </CommandList>
857
+ </Command>
858
+ </PopoverContent>
859
+ </Popover>
860
+ </div>
861
+ )
862
+ }
863
+
864
+ const ComboboxSlideInDemo = () => {
865
+ const id = useId()
866
+ const [open, setOpen] = useState(false)
867
+ const [value, setValue] = useState('')
868
+
869
+ return (
870
+ <div className='w-full max-w-xs space-y-2'>
871
+ <Label htmlFor={id}>Combobox menu zoom-in</Label>
872
+ <Popover open={open} onOpenChange={setOpen}>
873
+ <PopoverTrigger asChild>
874
+ <Button
875
+ id={id}
876
+ variant='outline'
877
+ role='combobox'
878
+ aria-expanded={open}
879
+ className='w-full max-w-xs justify-between'
880
+ >
881
+ {value ? frameworks.find(framework => framework.value === value)?.label : 'Select framework...'}
882
+ <ChevronsUpDownIcon className='opacity-50' />
883
+ </Button>
884
+ </PopoverTrigger>
885
+ <PopoverContent className='data-[state=open]:!zoom-in-0 origin-center p-0 duration-500'>
886
+ <Command>
887
+ <CommandInput placeholder='Search framework...' className='h-9' />
888
+ <CommandList>
889
+ <CommandEmpty>No framework found.</CommandEmpty>
890
+ <CommandGroup>
891
+ {frameworks.map(framework => (
892
+ <CommandItem
893
+ key={framework.value}
894
+ value={framework.value}
895
+ onSelect={currentValue => {
896
+ setValue(currentValue === value ? '' : currentValue)
897
+ setOpen(false)
898
+ }}
899
+ >
900
+ {framework.label}
901
+ <CheckIcon className={cn('ml-auto', value === framework.value ? 'opacity-100' : 'opacity-0')} />
902
+ </CommandItem>
903
+ ))}
904
+ </CommandGroup>
905
+ </CommandList>
906
+ </Command>
907
+ </PopoverContent>
908
+ </Popover>
909
+ </div>
910
+ )
911
+ } */