@catalystsoftware/ui 1.0.5 → 1.0.6
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/dist/data/data.tsx +29 -29
- package/dist/data/tailwind.config.js +3821 -261
- package/dist/data.tsx +29 -29
- package/package.json +4 -3
- package/components/catalyst-ui/buttons/burger.tsx +0 -207
- package/components/catalyst-ui/core/data-display/timeline.tsx +0 -210
- package/components/catalyst-ui/core/feedback/alert.tsx +0 -491
- package/components/catalyst-ui/core/feedback/spinner-1.tsx +0 -65
- package/components/catalyst-ui/core/feedback/toast.tsx +0 -1857
- package/components/catalyst-ui/core/navigation/menu.tsx +0 -164
- package/components/catalyst-ui/forms/toggle-class.tsx +0 -176
- package/components/catalyst-ui/hooks/use-copy-to-clipboard.tsx +0 -419
- package/components/catalyst-ui/hooks/use-counter.tsx +0 -13
- package/components/catalyst-ui/hooks/use-event-listener.tsx +0 -23
- package/components/catalyst-ui/hooks/use-export-markdown.tsx +0 -47
- package/components/catalyst-ui/hooks/use-focus.tsx +0 -17
- package/components/catalyst-ui/hooks/use-interval.tsx +0 -23
- package/components/catalyst-ui/hooks/use-is-client.tsx +0 -16
- package/components/catalyst-ui/hooks/use-media-query.tsx +0 -19
- package/components/catalyst-ui/hooks/use-mobile.tsx +0 -19
- package/components/catalyst-ui/hooks/use-resize-observer.tsx +0 -81
- package/components/catalyst-ui/hooks/use-timeout.tsx +0 -21
- package/components/catalyst-ui/hooks/use-timer.tsx +0 -209
- package/components/catalyst-ui/hooks/use-toggle.tsx +0 -12
- package/components/catalyst-ui/media/image.tsx +0 -13
- package/components/catalyst-ui/overlays/dual-sidebar.tsx +0 -4142
- package/components/catalyst-ui/overlays/sidebar-original.tsx +0 -726
- package/components/catalyst-ui/primitives/accordion.tsx +0 -250
- package/components/catalyst-ui/primitives/alert-dialog.tsx +0 -126
- package/components/catalyst-ui/primitives/aspect-ratio.tsx +0 -9
- package/components/catalyst-ui/primitives/avatar.tsx +0 -296
- package/components/catalyst-ui/primitives/badge.tsx +0 -57
- package/components/catalyst-ui/primitives/breadcrumb.tsx +0 -101
- package/components/catalyst-ui/primitives/button.tsx +0 -265
- package/components/catalyst-ui/primitives/calendar-v4.tsx +0 -208
- package/components/catalyst-ui/primitives/calendar.tsx +0 -295
- package/components/catalyst-ui/primitives/card.tsx +0 -618
- package/components/catalyst-ui/primitives/carousel.tsx +0 -238
- package/components/catalyst-ui/primitives/chart.tsx +0 -347
- package/components/catalyst-ui/primitives/checkbox.tsx +0 -225
- package/components/catalyst-ui/primitives/collapsible.tsx +0 -212
- package/components/catalyst-ui/primitives/command.tsx +0 -393
- package/components/catalyst-ui/primitives/context-menu.tsx +0 -236
- package/components/catalyst-ui/primitives/dialog.tsx +0 -471
- package/components/catalyst-ui/primitives/drawer.tsx +0 -761
- package/components/catalyst-ui/primitives/dropdown-menu.tsx +0 -290
- package/components/catalyst-ui/primitives/empty.tsx +0 -104
- package/components/catalyst-ui/primitives/field.tsx +0 -244
- package/components/catalyst-ui/primitives/hover-card.tsx +0 -124
- package/components/catalyst-ui/primitives/input-otp.tsx +0 -76
- package/components/catalyst-ui/primitives/input.tsx +0 -64
- package/components/catalyst-ui/primitives/item.tsx +0 -196
- package/components/catalyst-ui/primitives/kbd.tsx +0 -75
- package/components/catalyst-ui/primitives/label.tsx +0 -24
- package/components/catalyst-ui/primitives/navigation-menu.tsx +0 -150
- package/components/catalyst-ui/primitives/pagination.tsx +0 -198
- package/components/catalyst-ui/primitives/popover.tsx +0 -232
- package/components/catalyst-ui/primitives/progress.tsx +0 -34
- package/components/catalyst-ui/primitives/radio-group.tsx +0 -43
- package/components/catalyst-ui/primitives/resizable.tsx +0 -56
- package/components/catalyst-ui/primitives/select.tsx +0 -155
- package/components/catalyst-ui/primitives/separator.tsx +0 -74
- package/components/catalyst-ui/primitives/sheet.tsx +0 -126
- package/components/catalyst-ui/primitives/skeleton.tsx +0 -15
- package/components/catalyst-ui/primitives/slider.tsx +0 -27
- package/components/catalyst-ui/primitives/switch.tsx +0 -187
- package/components/catalyst-ui/primitives/tabs.tsx +0 -335
- package/components/catalyst-ui/primitives/textarea.tsx +0 -24
- package/components/catalyst-ui/primitives/toggle-group.tsx +0 -55
- package/components/catalyst-ui/primitives/toggle.tsx +0 -42
- package/components/catalyst-ui/primitives/tooltip.tsx +0 -116
- package/components/catalyst-ui/utils/basic-auth.tsx +0 -40
- package/components/catalyst-ui/utils/context-storage.tsx +0 -19
- package/components/catalyst-ui/utils/cors-middleware.tsx +0 -71
- package/components/catalyst-ui/utils/deferred-content.tsx +0 -595
- package/components/catalyst-ui/utils/honeypot-middleware.tsx +0 -38
- package/components/catalyst-ui/utils/incId.tsx +0 -75
- package/components/catalyst-ui/utils/jwk-auth.tsx +0 -36
- package/components/catalyst-ui/utils/request-id.tsx +0 -14
- package/components/catalyst-ui/utils/secure-headers.tsx +0 -37
- package/components/catalyst-ui/utils/server-timing.tsx +0 -23
- package/components/catalyst-ui/utils/utils.ts +0 -43
- package/components/catalyst-ui/utils/with-cookie.tsx +0 -43
- package/components/catalyst-ui/x/accordian-x.tsx +0 -428
- package/components/catalyst-ui/x/alert-x.tsx +0 -413
- package/components/catalyst-ui/x/animated-text-x.tsx +0 -2242
- package/components/catalyst-ui/x/avatar-x.tsx +0 -515
- package/components/catalyst-ui/x/badge-x.tsx +0 -670
- package/components/catalyst-ui/x/button-X.tsx +0 -2857
- package/components/catalyst-ui/x/button-group-x.tsx +0 -847
- package/components/catalyst-ui/x/calendar-x.tsx +0 -1910
- package/components/catalyst-ui/x/card-x.tsx +0 -2597
- package/components/catalyst-ui/x/checkbox-x.tsx +0 -656
- package/components/catalyst-ui/x/collapsible-x.tsx +0 -1360
- package/components/catalyst-ui/x/combobox-x.tsx +0 -911
- package/components/catalyst-ui/x/data-table-x.tsx +0 -1753
- package/components/catalyst-ui/x/date-picker-x.tsx +0 -648
- package/components/catalyst-ui/x/dialog-x.tsx +0 -659
- package/components/catalyst-ui/x/dropdown-menu-x.tsx +0 -612
- package/components/catalyst-ui/x/hover-card-x.tsx +0 -375
- package/components/catalyst-ui/x/icon-x.tsx +0 -840
- package/components/catalyst-ui/x/input-mask-x.tsx +0 -981
- package/components/catalyst-ui/x/input-otp-x.tsx +0 -659
- package/components/catalyst-ui/x/loader-x.tsx +0 -1757
- package/components/catalyst-ui/x/pagination-x.tsx +0 -622
- package/components/catalyst-ui/x/popover-x.tsx +0 -744
- package/components/catalyst-ui/x/radio-group-x.tsx +0 -499
- package/components/catalyst-ui/x/select-x.tsx +0 -1127
- package/components/catalyst-ui/x/sheet-x.tsx +0 -668
- package/components/catalyst-ui/x/switch-x.tsx +0 -681
- package/components/catalyst-ui/x/table-x.tsx +0 -574
- package/components/catalyst-ui/x/tabs-x.tsx +0 -839
- package/components/catalyst-ui/x/textarea-x.tsx +0 -1263
- package/components/catalyst-ui/x/tooltip-x.tsx +0 -396
- package/components/catalyst-ui/x/tracker-x.tsx +0 -560
- package/data/bg-data.tsx +0 -901
- package/data/buttons-data.tsx +0 -2327
- package/data/charts-data.tsx +0 -102
- package/data/chat-data.tsx +0 -83
- package/data/code-data.tsx +0 -1040
- package/data/comboboxes-data.tsx +0 -1843
- package/data/command-data.tsx +0 -1381
- package/data/core-data.tsx +0 -15953
- package/data/crm-data.tsx +0 -47
- package/data/data.tsx +0 -159
- package/data/date-and-time-data.tsx +0 -554
- package/data/dependencies.tsx +0 -7
- package/data/ecommerce-data.tsx +0 -1387
- package/data/forms-data.tsx +0 -7890
- package/data/hooks-data.tsx +0 -5487
- package/data/index.ts +0 -34
- package/data/inputs-data.tsx +0 -557
- package/data/interactive-data.tsx +0 -5394
- package/data/lofi-data.tsx +0 -18295
- package/data/marketing-data.tsx +0 -2546
- package/data/media-data.tsx +0 -1510
- package/data/motion-data.tsx +0 -5801
- package/data/overlay-data.tsx +0 -4136
- package/data/pdf-data.tsx +0 -124
- package/data/pos-data.tsx +0 -213
- package/data/postcss.config.js +0 -6
- package/data/primitive-data.tsx +0 -5170
- package/data/prompt-data.tsx +0 -1226
- package/data/requiredLibs.ts +0 -4
- package/data/sandbox-data.tsx +0 -1
- package/data/sidebars-data.tsx +0 -5421
- package/data/stacks-data.tsx +0 -32
- package/data/table-data.tsx +0 -706
- package/data/tailwind.config.js +0 -270
- package/data/tailwind.config.ngin.js +0 -3830
- package/data/tailwind.css +0 -431
- package/data/tools-data.tsx +0 -6910
- package/data/typography-data.tsx +0 -2050
- package/data/utils-data.tsx +0 -6500
- package/data/x-data.tsx +0 -1171
|
@@ -1,911 +0,0 @@
|
|
|
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
|
-
} */
|