@carlonicora/nextjs-jsonapi 1.17.0 → 1.19.0
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 +1 -1
- package/dist/{BlockNoteEditor-4Z6TZBJE.mjs → BlockNoteEditor-BQ5WWVUF.mjs} +2 -2
- package/dist/{BlockNoteEditor-34T5CY27.js → BlockNoteEditor-IZR6TESC.js} +6 -6
- package/dist/{BlockNoteEditor-34T5CY27.js.map → BlockNoteEditor-IZR6TESC.js.map} +1 -1
- package/dist/{chunk-D7H7SRWB.js → chunk-FB535VUS.js} +3977 -2496
- package/dist/chunk-FB535VUS.js.map +1 -0
- package/dist/{chunk-SXPXC2TY.mjs → chunk-MVNVXOC6.mjs} +5809 -4328
- package/dist/chunk-MVNVXOC6.mjs.map +1 -0
- package/dist/client/index.js +2 -2
- package/dist/client/index.mjs +1 -1
- package/dist/components/index.d.mts +298 -385
- package/dist/components/index.d.ts +298 -385
- package/dist/components/index.js +26 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +35 -11
- package/dist/contexts/index.js +2 -2
- package/dist/contexts/index.mjs +1 -1
- package/dist/scripts/generate-web-module/templates/components/editor.template.d.ts.map +1 -1
- package/dist/scripts/generate-web-module/templates/components/editor.template.js +20 -6
- package/dist/scripts/generate-web-module/templates/components/editor.template.js.map +1 -1
- package/dist/scripts/generate-web-module/templates/components/selector.template.d.ts.map +1 -1
- package/dist/scripts/generate-web-module/templates/components/selector.template.js +46 -48
- package/dist/scripts/generate-web-module/templates/components/selector.template.js.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/index.mjs.map +1 -1
- package/package.json +6 -25
- package/scripts/generate-web-module/templates/components/editor.template.ts +20 -6
- package/scripts/generate-web-module/templates/components/selector.template.ts +46 -48
- package/src/components/forms/CommonDeleter.tsx +2 -2
- package/src/components/forms/CommonEditorTrigger.tsx +3 -3
- package/src/components/forms/DatePickerPopover.tsx +3 -1
- package/src/components/forms/DateRangeSelector.tsx +1 -1
- package/src/components/forms/FormCheckbox.tsx +1 -1
- package/src/components/forms/FormDate.tsx +3 -1
- package/src/components/forms/FormDateTime.tsx +5 -3
- package/src/components/forms/FormSelect.tsx +1 -1
- package/src/components/forms/FormSlider.tsx +4 -1
- package/src/components/forms/__tests__/FormCheckbox.test.tsx +5 -1
- package/src/components/forms/__tests__/FormDate.test.tsx +5 -1
- package/src/components/forms/__tests__/FormSelect.test.tsx +5 -1
- package/src/components/navigations/RecentPagesNavigator.tsx +2 -2
- package/src/components/tables/ContentListTable.tsx +3 -3
- package/src/features/billing/stripe-customer/components/details/PaymentMethodCard.tsx +2 -2
- package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +2 -2
- package/src/features/company/components/forms/CompanyDeleter.tsx +1 -1
- package/src/features/content/components/lists/ContentsList.tsx +1 -1
- package/src/features/notification/components/lists/NotificationsList.tsx +1 -1
- package/src/features/notification/components/modals/NotificationModal.tsx +2 -2
- package/src/features/role/components/forms/FormRoles.tsx +1 -1
- package/src/features/role/components/forms/UserRoleAdd.tsx +1 -1
- package/src/features/user/components/forms/UserEditor.tsx +2 -2
- package/src/features/user/components/forms/UserReactivator.tsx +1 -1
- package/src/features/user/components/forms/UserResentInvitationEmail.tsx +2 -2
- package/src/features/user/components/forms/UserSelector.tsx +5 -1
- package/src/features/user/components/lists/UserListInAdd.tsx +1 -1
- package/src/features/user/components/widgets/UserAvatar.tsx +37 -31
- package/src/features/user/components/widgets/UserSearchPopover.tsx +6 -2
- package/src/hooks/use-mobile.ts +1 -0
- package/src/hooks/useDataListRetriever.ts +1 -0
- package/src/lib/utils.ts +2 -0
- package/src/shadcnui/custom/multi-select.tsx +68 -76
- package/src/shadcnui/ui/accordion.tsx +64 -42
- package/src/shadcnui/ui/alert-dialog.tsx +142 -108
- package/src/shadcnui/ui/alert.tsx +64 -35
- package/src/shadcnui/ui/avatar.tsx +106 -50
- package/src/shadcnui/ui/badge.tsx +34 -26
- package/src/shadcnui/ui/breadcrumb.tsx +103 -92
- package/src/shadcnui/ui/button.tsx +30 -30
- package/src/shadcnui/ui/calendar.tsx +192 -50
- package/src/shadcnui/ui/card.tsx +94 -43
- package/src/shadcnui/ui/carousel.tsx +220 -201
- package/src/shadcnui/ui/chart.tsx +244 -190
- package/src/shadcnui/ui/checkbox.tsx +25 -25
- package/src/shadcnui/ui/collapsible.tsx +10 -4
- package/src/shadcnui/ui/combobox.tsx +292 -0
- package/src/shadcnui/ui/command.tsx +158 -126
- package/src/shadcnui/ui/context-menu.tsx +242 -164
- package/src/shadcnui/ui/dialog.tsx +125 -70
- package/src/shadcnui/ui/drawer.tsx +106 -70
- package/src/shadcnui/ui/dropdown-menu.tsx +231 -182
- package/src/shadcnui/ui/field.tsx +227 -0
- package/src/shadcnui/ui/hover-card.tsx +45 -23
- package/src/shadcnui/ui/input-group.tsx +149 -0
- package/src/shadcnui/ui/input-otp.tsx +19 -9
- package/src/shadcnui/ui/input.tsx +4 -5
- package/src/shadcnui/ui/label.tsx +16 -22
- package/src/shadcnui/ui/navigation-menu.tsx +44 -49
- package/src/shadcnui/ui/popover.tsx +81 -24
- package/src/shadcnui/ui/progress.tsx +77 -22
- package/src/shadcnui/ui/radio-group.tsx +30 -28
- package/src/shadcnui/ui/resizable.tsx +23 -17
- package/src/shadcnui/ui/scroll-area.tsx +50 -35
- package/src/shadcnui/ui/select.tsx +163 -135
- package/src/shadcnui/ui/separator.tsx +5 -8
- package/src/shadcnui/ui/sheet.tsx +40 -50
- package/src/shadcnui/ui/sidebar.tsx +317 -271
- package/src/shadcnui/ui/skeleton.tsx +2 -2
- package/src/shadcnui/ui/slider.tsx +60 -21
- package/src/shadcnui/ui/sonner.tsx +25 -1
- package/src/shadcnui/ui/switch.tsx +31 -24
- package/src/shadcnui/ui/table.tsx +84 -103
- package/src/shadcnui/ui/tabs.tsx +82 -55
- package/src/shadcnui/ui/textarea.tsx +15 -21
- package/src/shadcnui/ui/toggle.tsx +26 -21
- package/src/shadcnui/ui/tooltip.tsx +33 -24
- package/src/testing/factories/createMockApiData.ts +2 -2
- package/src/testing/factories/createMockResponse.ts +3 -8
- package/src/testing/factories/createMockService.ts +1 -4
- package/src/testing/index.ts +4 -18
- package/src/testing/matchers/jsonApiMatchers.ts +14 -16
- package/dist/chunk-D7H7SRWB.js.map +0 -1
- package/dist/chunk-SXPXC2TY.mjs.map +0 -1
- /package/dist/{BlockNoteEditor-4Z6TZBJE.mjs.map → BlockNoteEditor-BQ5WWVUF.mjs.map} +0 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Combobox as ComboboxPrimitive } from "@base-ui/react"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
7
|
+
import { Button } from "@/components/ui/button"
|
|
8
|
+
import {
|
|
9
|
+
InputGroup,
|
|
10
|
+
InputGroupAddon,
|
|
11
|
+
InputGroupButton,
|
|
12
|
+
InputGroupInput,
|
|
13
|
+
} from "@/components/ui/input-group"
|
|
14
|
+
import { ChevronDownIcon, XIcon, CheckIcon } from "lucide-react"
|
|
15
|
+
|
|
16
|
+
const Combobox = ComboboxPrimitive.Root
|
|
17
|
+
|
|
18
|
+
function ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {
|
|
19
|
+
return <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function ComboboxTrigger({
|
|
23
|
+
className,
|
|
24
|
+
children,
|
|
25
|
+
...props
|
|
26
|
+
}: ComboboxPrimitive.Trigger.Props) {
|
|
27
|
+
return (
|
|
28
|
+
<ComboboxPrimitive.Trigger
|
|
29
|
+
data-slot="combobox-trigger"
|
|
30
|
+
className={cn("[&_svg:not([class*='size-'])]:size-3.5", className)}
|
|
31
|
+
{...props}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
<ChevronDownIcon className="text-muted-foreground size-3.5 pointer-events-none" />
|
|
35
|
+
</ComboboxPrimitive.Trigger>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props) {
|
|
40
|
+
return (
|
|
41
|
+
<ComboboxPrimitive.Clear
|
|
42
|
+
data-slot="combobox-clear"
|
|
43
|
+
render={<InputGroupButton variant="ghost" size="icon-xs" />}
|
|
44
|
+
className={cn(className)}
|
|
45
|
+
{...props}
|
|
46
|
+
>
|
|
47
|
+
<XIcon className="pointer-events-none" />
|
|
48
|
+
</ComboboxPrimitive.Clear>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function ComboboxInput({
|
|
53
|
+
className,
|
|
54
|
+
children,
|
|
55
|
+
disabled = false,
|
|
56
|
+
showTrigger = true,
|
|
57
|
+
showClear = false,
|
|
58
|
+
...props
|
|
59
|
+
}: ComboboxPrimitive.Input.Props & {
|
|
60
|
+
showTrigger?: boolean
|
|
61
|
+
showClear?: boolean
|
|
62
|
+
}) {
|
|
63
|
+
return (
|
|
64
|
+
<InputGroup className={cn("w-auto", className)}>
|
|
65
|
+
<ComboboxPrimitive.Input
|
|
66
|
+
render={<InputGroupInput disabled={disabled} />}
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
69
|
+
<InputGroupAddon align="inline-end">
|
|
70
|
+
{showTrigger && (
|
|
71
|
+
<InputGroupButton
|
|
72
|
+
size="icon-xs"
|
|
73
|
+
variant="ghost"
|
|
74
|
+
render={<ComboboxTrigger />}
|
|
75
|
+
data-slot="input-group-button"
|
|
76
|
+
className="group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent"
|
|
77
|
+
disabled={disabled}
|
|
78
|
+
/>
|
|
79
|
+
)}
|
|
80
|
+
{showClear && <ComboboxClear disabled={disabled} />}
|
|
81
|
+
</InputGroupAddon>
|
|
82
|
+
{children}
|
|
83
|
+
</InputGroup>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function ComboboxContent({
|
|
88
|
+
className,
|
|
89
|
+
side = "bottom",
|
|
90
|
+
sideOffset = 6,
|
|
91
|
+
align = "start",
|
|
92
|
+
alignOffset = 0,
|
|
93
|
+
anchor,
|
|
94
|
+
...props
|
|
95
|
+
}: ComboboxPrimitive.Popup.Props &
|
|
96
|
+
Pick<
|
|
97
|
+
ComboboxPrimitive.Positioner.Props,
|
|
98
|
+
"side" | "align" | "sideOffset" | "alignOffset" | "anchor"
|
|
99
|
+
>) {
|
|
100
|
+
return (
|
|
101
|
+
<ComboboxPrimitive.Portal>
|
|
102
|
+
<ComboboxPrimitive.Positioner
|
|
103
|
+
side={side}
|
|
104
|
+
sideOffset={sideOffset}
|
|
105
|
+
align={align}
|
|
106
|
+
alignOffset={alignOffset}
|
|
107
|
+
anchor={anchor}
|
|
108
|
+
className="isolate z-50"
|
|
109
|
+
>
|
|
110
|
+
<ComboboxPrimitive.Popup
|
|
111
|
+
data-slot="combobox-content"
|
|
112
|
+
data-chips={!!anchor}
|
|
113
|
+
className={cn("bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 *:data-[slot=input-group]:bg-input/20 dark:bg-popover max-h-72 min-w-32 overflow-hidden rounded-lg shadow-md ring-1 duration-100 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-7 *:data-[slot=input-group]:border-none *:data-[slot=input-group]:shadow-none group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) data-[chips=true]:min-w-(--anchor-width)", className )}
|
|
114
|
+
{...props}
|
|
115
|
+
/>
|
|
116
|
+
</ComboboxPrimitive.Positioner>
|
|
117
|
+
</ComboboxPrimitive.Portal>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {
|
|
122
|
+
return (
|
|
123
|
+
<ComboboxPrimitive.List
|
|
124
|
+
data-slot="combobox-list"
|
|
125
|
+
className={cn(
|
|
126
|
+
"no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto p-1 data-empty:p-0 overflow-y-auto overscroll-contain",
|
|
127
|
+
className
|
|
128
|
+
)}
|
|
129
|
+
{...props}
|
|
130
|
+
/>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function ComboboxItem({
|
|
135
|
+
className,
|
|
136
|
+
children,
|
|
137
|
+
...props
|
|
138
|
+
}: ComboboxPrimitive.Item.Props) {
|
|
139
|
+
return (
|
|
140
|
+
<ComboboxPrimitive.Item
|
|
141
|
+
data-slot="combobox-item"
|
|
142
|
+
className={cn(
|
|
143
|
+
"data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground min-h-7 gap-2 rounded-md px-2 py-1 text-xs/relaxed [&_svg:not([class*='size-'])]:size-3.5 relative flex w-full cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
144
|
+
className
|
|
145
|
+
)}
|
|
146
|
+
{...props}
|
|
147
|
+
>
|
|
148
|
+
{children}
|
|
149
|
+
<ComboboxPrimitive.ItemIndicator
|
|
150
|
+
render={<span className="pointer-events-none absolute right-2 flex items-center justify-center" />}
|
|
151
|
+
>
|
|
152
|
+
<CheckIcon className="pointer-events-none" />
|
|
153
|
+
</ComboboxPrimitive.ItemIndicator>
|
|
154
|
+
</ComboboxPrimitive.Item>
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {
|
|
159
|
+
return (
|
|
160
|
+
<ComboboxPrimitive.Group
|
|
161
|
+
data-slot="combobox-group"
|
|
162
|
+
className={cn(className)}
|
|
163
|
+
{...props}
|
|
164
|
+
/>
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function ComboboxLabel({
|
|
169
|
+
className,
|
|
170
|
+
...props
|
|
171
|
+
}: ComboboxPrimitive.GroupLabel.Props) {
|
|
172
|
+
return (
|
|
173
|
+
<ComboboxPrimitive.GroupLabel
|
|
174
|
+
data-slot="combobox-label"
|
|
175
|
+
className={cn("text-muted-foreground px-2 py-1.5 text-xs", className)}
|
|
176
|
+
{...props}
|
|
177
|
+
/>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {
|
|
182
|
+
return (
|
|
183
|
+
<ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
|
|
188
|
+
return (
|
|
189
|
+
<ComboboxPrimitive.Empty
|
|
190
|
+
data-slot="combobox-empty"
|
|
191
|
+
className={cn("text-muted-foreground hidden w-full justify-center py-2 text-center text-xs/relaxed group-data-empty/combobox-content:flex", className)}
|
|
192
|
+
{...props}
|
|
193
|
+
/>
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function ComboboxSeparator({
|
|
198
|
+
className,
|
|
199
|
+
...props
|
|
200
|
+
}: ComboboxPrimitive.Separator.Props) {
|
|
201
|
+
return (
|
|
202
|
+
<ComboboxPrimitive.Separator
|
|
203
|
+
data-slot="combobox-separator"
|
|
204
|
+
className={cn("bg-border/50 -mx-1 my-1 h-px", className)}
|
|
205
|
+
{...props}
|
|
206
|
+
/>
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function ComboboxChips({
|
|
211
|
+
className,
|
|
212
|
+
...props
|
|
213
|
+
}: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> &
|
|
214
|
+
ComboboxPrimitive.Chips.Props) {
|
|
215
|
+
return (
|
|
216
|
+
<ComboboxPrimitive.Chips
|
|
217
|
+
data-slot="combobox-chips"
|
|
218
|
+
className={cn("bg-input/20 dark:bg-input/30 border-input focus-within:border-ring focus-within:ring-ring/30 has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40 has-aria-invalid:border-destructive dark:has-aria-invalid:border-destructive/50 flex min-h-7 flex-wrap items-center gap-1 rounded-md border bg-clip-padding px-2 py-0.5 text-xs/relaxed transition-colors focus-within:ring-[2px] has-aria-invalid:ring-[2px] has-data-[slot=combobox-chip]:px-1", className)}
|
|
219
|
+
{...props}
|
|
220
|
+
/>
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function ComboboxChip({
|
|
225
|
+
className,
|
|
226
|
+
children,
|
|
227
|
+
showRemove = true,
|
|
228
|
+
...props
|
|
229
|
+
}: ComboboxPrimitive.Chip.Props & {
|
|
230
|
+
showRemove?: boolean
|
|
231
|
+
}) {
|
|
232
|
+
return (
|
|
233
|
+
<ComboboxPrimitive.Chip
|
|
234
|
+
data-slot="combobox-chip"
|
|
235
|
+
className={cn(
|
|
236
|
+
"bg-muted-foreground/10 text-foreground flex h-[calc(--spacing(4.75))] w-fit items-center justify-center gap-1 rounded-[calc(var(--radius-sm)-2px)] px-1.5 text-xs/relaxed font-medium whitespace-nowrap has-data-[slot=combobox-chip-remove]:pr-0 has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50",
|
|
237
|
+
className
|
|
238
|
+
)}
|
|
239
|
+
{...props}
|
|
240
|
+
>
|
|
241
|
+
{children}
|
|
242
|
+
{showRemove && (
|
|
243
|
+
<ComboboxPrimitive.ChipRemove
|
|
244
|
+
render={<Button variant="ghost" size="icon-xs" />}
|
|
245
|
+
className="-ml-1 opacity-50 hover:opacity-100"
|
|
246
|
+
data-slot="combobox-chip-remove"
|
|
247
|
+
>
|
|
248
|
+
<XIcon className="pointer-events-none" />
|
|
249
|
+
</ComboboxPrimitive.ChipRemove>
|
|
250
|
+
)}
|
|
251
|
+
</ComboboxPrimitive.Chip>
|
|
252
|
+
)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function ComboboxChipsInput({
|
|
256
|
+
className,
|
|
257
|
+
...props
|
|
258
|
+
}: ComboboxPrimitive.Input.Props) {
|
|
259
|
+
return (
|
|
260
|
+
<ComboboxPrimitive.Input
|
|
261
|
+
data-slot="combobox-chip-input"
|
|
262
|
+
className={cn(
|
|
263
|
+
"min-w-16 flex-1 outline-none",
|
|
264
|
+
className
|
|
265
|
+
)}
|
|
266
|
+
{...props}
|
|
267
|
+
/>
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function useComboboxAnchor() {
|
|
272
|
+
return React.useRef<HTMLDivElement | null>(null)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export {
|
|
276
|
+
Combobox,
|
|
277
|
+
ComboboxInput,
|
|
278
|
+
ComboboxContent,
|
|
279
|
+
ComboboxList,
|
|
280
|
+
ComboboxItem,
|
|
281
|
+
ComboboxGroup,
|
|
282
|
+
ComboboxLabel,
|
|
283
|
+
ComboboxCollection,
|
|
284
|
+
ComboboxEmpty,
|
|
285
|
+
ComboboxSeparator,
|
|
286
|
+
ComboboxChips,
|
|
287
|
+
ComboboxChip,
|
|
288
|
+
ComboboxChipsInput,
|
|
289
|
+
ComboboxTrigger,
|
|
290
|
+
ComboboxValue,
|
|
291
|
+
useComboboxAnchor,
|
|
292
|
+
}
|
|
@@ -1,155 +1,187 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Command as CommandPrimitive } from "cmdk"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
7
|
+
import {
|
|
8
|
+
Dialog,
|
|
9
|
+
DialogContent,
|
|
10
|
+
DialogDescription,
|
|
11
|
+
DialogHeader,
|
|
12
|
+
DialogTitle,
|
|
13
|
+
} from "@/components/ui/dialog"
|
|
14
|
+
import {
|
|
15
|
+
InputGroup,
|
|
16
|
+
InputGroupAddon,
|
|
17
|
+
} from "@/components/ui/input-group"
|
|
18
|
+
import { SearchIcon, CheckIcon } from "lucide-react"
|
|
19
|
+
|
|
20
|
+
function Command({
|
|
21
|
+
className,
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof CommandPrimitive>) {
|
|
24
|
+
return (
|
|
25
|
+
<CommandPrimitive
|
|
26
|
+
data-slot="command"
|
|
27
|
+
className={cn(
|
|
28
|
+
"bg-popover text-popover-foreground rounded-xl p-1 flex size-full flex-col overflow-hidden",
|
|
29
|
+
className
|
|
30
|
+
)}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
function CommandDialog({
|
|
37
|
+
title = "Command Palette",
|
|
38
|
+
description = "Search for a command to run...",
|
|
39
|
+
children,
|
|
40
|
+
className,
|
|
41
|
+
showCloseButton = false,
|
|
42
|
+
...props
|
|
43
|
+
}: Omit<React.ComponentProps<typeof Dialog>, "children"> & {
|
|
44
|
+
title?: string
|
|
45
|
+
description?: string
|
|
46
|
+
className?: string
|
|
47
|
+
showCloseButton?: boolean
|
|
48
|
+
children: React.ReactNode
|
|
49
|
+
}) {
|
|
29
50
|
return (
|
|
30
51
|
<Dialog {...props}>
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
52
|
+
<DialogHeader className="sr-only">
|
|
53
|
+
<DialogTitle>{title}</DialogTitle>
|
|
54
|
+
<DialogDescription>{description}</DialogDescription>
|
|
55
|
+
</DialogHeader>
|
|
56
|
+
<DialogContent
|
|
57
|
+
className={cn("rounded-xl! p-0 overflow-hidden p-0", className)}
|
|
58
|
+
showCloseButton={showCloseButton}
|
|
59
|
+
>
|
|
60
|
+
{children}
|
|
35
61
|
</DialogContent>
|
|
36
62
|
</Dialog>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
63
|
+
)
|
|
64
|
+
}
|
|
39
65
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
66
|
+
function CommandInput({
|
|
67
|
+
className,
|
|
68
|
+
...props
|
|
69
|
+
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
|
70
|
+
return (
|
|
71
|
+
<div data-slot="command-input-wrapper" className="p-1 pb-0">
|
|
72
|
+
<InputGroup className="bg-input/20 dark:bg-input/30 h-8!">
|
|
73
|
+
<CommandPrimitive.Input
|
|
74
|
+
data-slot="command-input"
|
|
75
|
+
className={cn(
|
|
76
|
+
"w-full text-xs/relaxed outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
|
77
|
+
className
|
|
78
|
+
)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
<InputGroupAddon>
|
|
82
|
+
<SearchIcon className="size-3.5 shrink-0 opacity-50" />
|
|
83
|
+
</InputGroupAddon>
|
|
84
|
+
</InputGroup>
|
|
85
|
+
</div>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function CommandList({
|
|
90
|
+
className,
|
|
91
|
+
...props
|
|
92
|
+
}: React.ComponentProps<typeof CommandPrimitive.List>) {
|
|
93
|
+
return (
|
|
94
|
+
<CommandPrimitive.List
|
|
95
|
+
data-slot="command-list"
|
|
48
96
|
className={cn(
|
|
49
|
-
"
|
|
50
|
-
className
|
|
97
|
+
"no-scrollbar max-h-72 scroll-py-1 outline-none overflow-x-hidden overflow-y-auto",
|
|
98
|
+
className
|
|
51
99
|
)}
|
|
52
100
|
{...props}
|
|
53
101
|
/>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
|
58
|
-
|
|
59
|
-
const CommandList = React.forwardRef<
|
|
60
|
-
React.ElementRef<typeof CommandPrimitive.List>,
|
|
61
|
-
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
|
|
62
|
-
>(({ className, ...props }, ref) => (
|
|
63
|
-
<CommandPrimitive.List
|
|
64
|
-
ref={ref}
|
|
65
|
-
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
|
|
66
|
-
{...props}
|
|
67
|
-
/>
|
|
68
|
-
));
|
|
102
|
+
)
|
|
103
|
+
}
|
|
69
104
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
|
84
|
-
|
|
85
|
-
const CommandGroup = React.forwardRef<
|
|
86
|
-
React.ElementRef<typeof CommandPrimitive.Group>,
|
|
87
|
-
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
|
|
88
|
-
>(({ className, ...props }, ref) => (
|
|
89
|
-
<CommandPrimitive.Group
|
|
90
|
-
ref={ref}
|
|
91
|
-
className={cn(
|
|
92
|
-
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
|
93
|
-
className,
|
|
94
|
-
)}
|
|
95
|
-
{...props}
|
|
96
|
-
/>
|
|
97
|
-
));
|
|
98
|
-
|
|
99
|
-
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
|
100
|
-
|
|
101
|
-
const CommandSeparator = React.forwardRef<
|
|
102
|
-
React.ElementRef<typeof CommandPrimitive.Separator>,
|
|
103
|
-
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
|
|
104
|
-
>(({ className, ...props }, ref) => (
|
|
105
|
-
<CommandPrimitive.Separator
|
|
106
|
-
ref={ref}
|
|
107
|
-
className={cn("-mx-1 h-px bg-border", className)}
|
|
108
|
-
{...props}
|
|
109
|
-
/>
|
|
110
|
-
));
|
|
111
|
-
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
|
105
|
+
function CommandEmpty({
|
|
106
|
+
className,
|
|
107
|
+
...props
|
|
108
|
+
}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
|
109
|
+
return (
|
|
110
|
+
<CommandPrimitive.Empty
|
|
111
|
+
data-slot="command-empty"
|
|
112
|
+
className={cn("py-6 text-center text-xs/relaxed", className)}
|
|
113
|
+
{...props}
|
|
114
|
+
/>
|
|
115
|
+
)
|
|
116
|
+
}
|
|
112
117
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
));
|
|
118
|
+
function CommandGroup({
|
|
119
|
+
className,
|
|
120
|
+
...props
|
|
121
|
+
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
|
122
|
+
return (
|
|
123
|
+
<CommandPrimitive.Group
|
|
124
|
+
data-slot="command-group"
|
|
125
|
+
className={cn("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium", className)}
|
|
126
|
+
{...props}
|
|
127
|
+
/>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
126
130
|
|
|
127
|
-
|
|
131
|
+
function CommandSeparator({
|
|
132
|
+
className,
|
|
133
|
+
...props
|
|
134
|
+
}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
|
135
|
+
return (
|
|
136
|
+
<CommandPrimitive.Separator
|
|
137
|
+
data-slot="command-separator"
|
|
138
|
+
className={cn("bg-border/50 -mx-1 my-1 h-px", className)}
|
|
139
|
+
{...props}
|
|
140
|
+
/>
|
|
141
|
+
)
|
|
142
|
+
}
|
|
128
143
|
|
|
129
|
-
|
|
144
|
+
function CommandItem({
|
|
130
145
|
className,
|
|
146
|
+
children,
|
|
131
147
|
...props
|
|
132
|
-
}: React.
|
|
148
|
+
}: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
|
133
149
|
return (
|
|
134
|
-
<
|
|
150
|
+
<CommandPrimitive.Item
|
|
151
|
+
data-slot="command-item"
|
|
135
152
|
className={cn(
|
|
136
|
-
"
|
|
137
|
-
className
|
|
153
|
+
"data-selected:bg-muted data-selected:text-foreground data-selected:*:[svg]:text-foreground relative flex min-h-7 cursor-default items-center gap-2 rounded-md px-2.5 py-1.5 text-xs/relaxed outline-hidden select-none [&_svg:not([class*='size-'])]:size-3.5 [[data-slot=dialog-content]_&]:rounded-md group/command-item data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
154
|
+
className
|
|
138
155
|
)}
|
|
139
156
|
{...props}
|
|
157
|
+
>
|
|
158
|
+
{children}
|
|
159
|
+
<CheckIcon className="ml-auto opacity-0 group-has-[[data-slot=command-shortcut]]/command-item:hidden group-data-[checked=true]/command-item:opacity-100" />
|
|
160
|
+
</CommandPrimitive.Item>
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function CommandShortcut({
|
|
165
|
+
className,
|
|
166
|
+
...props
|
|
167
|
+
}: React.ComponentProps<"span">) {
|
|
168
|
+
return (
|
|
169
|
+
<span
|
|
170
|
+
data-slot="command-shortcut"
|
|
171
|
+
className={cn("text-muted-foreground group-data-selected/command-item:text-foreground ml-auto text-[0.625rem] tracking-widest", className)}
|
|
172
|
+
{...props}
|
|
140
173
|
/>
|
|
141
|
-
)
|
|
142
|
-
}
|
|
143
|
-
CommandShortcut.displayName = "CommandShortcut";
|
|
174
|
+
)
|
|
175
|
+
}
|
|
144
176
|
|
|
145
177
|
export {
|
|
146
178
|
Command,
|
|
147
179
|
CommandDialog,
|
|
180
|
+
CommandInput,
|
|
181
|
+
CommandList,
|
|
148
182
|
CommandEmpty,
|
|
149
183
|
CommandGroup,
|
|
150
|
-
CommandInput,
|
|
151
184
|
CommandItem,
|
|
152
|
-
CommandList,
|
|
153
|
-
CommandSeparator,
|
|
154
185
|
CommandShortcut,
|
|
155
|
-
|
|
186
|
+
CommandSeparator,
|
|
187
|
+
}
|