@robomous/ui-core 0.1.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/LICENSE +202 -0
- package/README.md +38 -0
- package/components.json +13 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +47 -0
- package/dist/lib/button.d.ts +1 -0
- package/dist/lib/button.js +4 -0
- package/dist/lib/cn.d.ts +18 -0
- package/dist/lib/cn.js +21 -0
- package/dist/lib/menu.d.ts +1 -0
- package/dist/lib/menu.js +16 -0
- package/dist/lib/progress.d.ts +3 -0
- package/dist/lib/progress.js +6 -0
- package/dist/lib/select.d.ts +1 -0
- package/dist/lib/select.js +3 -0
- package/dist/primitives/alert.d.ts +10 -0
- package/dist/primitives/alert.js +27 -0
- package/dist/primitives/badge.d.ts +9 -0
- package/dist/primitives/badge.js +28 -0
- package/dist/primitives/button.d.ts +10 -0
- package/dist/primitives/button.js +35 -0
- package/dist/primitives/card.d.ts +11 -0
- package/dist/primitives/card.js +24 -0
- package/dist/primitives/combobox.d.ts +24 -0
- package/dist/primitives/combobox.js +58 -0
- package/dist/primitives/dialog.d.ts +17 -0
- package/dist/primitives/dialog.js +36 -0
- package/dist/primitives/dropdown-menu.d.ts +29 -0
- package/dist/primitives/dropdown-menu.js +50 -0
- package/dist/primitives/field.d.ts +24 -0
- package/dist/primitives/field.js +67 -0
- package/dist/primitives/input-group.d.ts +16 -0
- package/dist/primitives/input-group.js +56 -0
- package/dist/primitives/input.d.ts +3 -0
- package/dist/primitives/input.js +6 -0
- package/dist/primitives/label.d.ts +4 -0
- package/dist/primitives/label.js +7 -0
- package/dist/primitives/progress.d.ts +4 -0
- package/dist/primitives/progress.js +7 -0
- package/dist/primitives/select.d.ts +15 -0
- package/dist/primitives/select.js +35 -0
- package/dist/primitives/separator.d.ts +4 -0
- package/dist/primitives/separator.js +8 -0
- package/dist/primitives/sheet.d.ts +14 -0
- package/dist/primitives/sheet.js +36 -0
- package/dist/primitives/skeleton.d.ts +2 -0
- package/dist/primitives/skeleton.js +6 -0
- package/dist/primitives/sonner.d.ts +4 -0
- package/dist/primitives/sonner.js +40 -0
- package/dist/primitives/table.d.ts +10 -0
- package/dist/primitives/table.js +27 -0
- package/dist/primitives/tabs.d.ts +11 -0
- package/dist/primitives/tabs.js +28 -0
- package/dist/primitives/textarea.d.ts +3 -0
- package/dist/primitives/textarea.js +6 -0
- package/dist/primitives/tooltip.d.ts +7 -0
- package/dist/primitives/tooltip.js +17 -0
- package/dist/statusTone.d.ts +37 -0
- package/dist/statusTone.js +38 -0
- package/dist/tokens.d.ts +26 -0
- package/dist/tokens.js +96 -0
- package/gates/canonical.test.mjs +71 -0
- package/gates/extensions.test.mjs +373 -0
- package/gates/index.d.mts +51 -0
- package/gates/index.mjs +514 -0
- package/gates/tokens.test.mjs +276 -0
- package/package.json +60 -0
- package/shadcn/README.md +13 -0
- package/shadcn/alert.tsx +76 -0
- package/shadcn/badge.tsx +49 -0
- package/shadcn/button.tsx +67 -0
- package/shadcn/card.tsx +103 -0
- package/shadcn/combobox.tsx +299 -0
- package/shadcn/dialog.tsx +166 -0
- package/shadcn/dropdown-menu.tsx +267 -0
- package/shadcn/field.tsx +236 -0
- package/shadcn/input-group.tsx +154 -0
- package/shadcn/input.tsx +19 -0
- package/shadcn/label.tsx +22 -0
- package/shadcn/progress.tsx +29 -0
- package/shadcn/select.tsx +190 -0
- package/shadcn/separator.tsx +28 -0
- package/shadcn/sheet.tsx +145 -0
- package/shadcn/skeleton.tsx +13 -0
- package/shadcn/sonner.tsx +49 -0
- package/shadcn/table.tsx +114 -0
- package/shadcn/tabs.tsx +88 -0
- package/shadcn/textarea.tsx +18 -0
- package/shadcn/tooltip.tsx +57 -0
- package/src/harness.test.tsx +37 -0
- package/src/index.ts +119 -0
- package/src/lib/button.ts +4 -0
- package/src/lib/cn.test.ts +33 -0
- package/src/lib/cn.ts +23 -0
- package/src/lib/menu.ts +16 -0
- package/src/lib/progress.ts +6 -0
- package/src/lib/select.ts +4 -0
- package/src/primitives/alert.tsx +76 -0
- package/src/primitives/badge.tsx +57 -0
- package/src/primitives/button.tsx +67 -0
- package/src/primitives/card.tsx +103 -0
- package/src/primitives/combobox.test.tsx +38 -0
- package/src/primitives/combobox.tsx +299 -0
- package/src/primitives/dialog.tsx +166 -0
- package/src/primitives/dropdown-menu.tsx +267 -0
- package/src/primitives/field.tsx +236 -0
- package/src/primitives/input-group.tsx +154 -0
- package/src/primitives/input.tsx +19 -0
- package/src/primitives/label.tsx +22 -0
- package/src/primitives/primitives.test.tsx +440 -0
- package/src/primitives/progress.tsx +29 -0
- package/src/primitives/select.tsx +190 -0
- package/src/primitives/separator.tsx +28 -0
- package/src/primitives/sheet.tsx +145 -0
- package/src/primitives/skeleton.tsx +13 -0
- package/src/primitives/sonner.test.tsx +41 -0
- package/src/primitives/sonner.tsx +65 -0
- package/src/primitives/table.tsx +114 -0
- package/src/primitives/tabs.tsx +88 -0
- package/src/primitives/textarea.tsx +18 -0
- package/src/primitives/tooltip.tsx +57 -0
- package/src/statusTone.test.ts +20 -0
- package/src/statusTone.ts +52 -0
- package/src/styles.css +204 -0
- package/src/tokens.test.ts +285 -0
- package/src/tokens.ts +102 -0
|
@@ -0,0 +1,299 @@
|
|
|
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/cn.js"
|
|
7
|
+
import { Button } from "./button.js"
|
|
8
|
+
import {
|
|
9
|
+
InputGroup,
|
|
10
|
+
InputGroupAddon,
|
|
11
|
+
InputGroupButton,
|
|
12
|
+
InputGroupInput,
|
|
13
|
+
} from "./input-group.js"
|
|
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-4", className)}
|
|
31
|
+
{...props}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
<ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />
|
|
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
|
+
asChild
|
|
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
|
+
<ComboboxTrigger />
|
|
80
|
+
</InputGroupButton>
|
|
81
|
+
)}
|
|
82
|
+
{showClear && <ComboboxClear disabled={disabled} />}
|
|
83
|
+
</InputGroupAddon>
|
|
84
|
+
{children}
|
|
85
|
+
</InputGroup>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function ComboboxContent({
|
|
90
|
+
className,
|
|
91
|
+
side = "bottom",
|
|
92
|
+
sideOffset = 6,
|
|
93
|
+
align = "start",
|
|
94
|
+
alignOffset = 0,
|
|
95
|
+
anchor,
|
|
96
|
+
...props
|
|
97
|
+
}: ComboboxPrimitive.Popup.Props &
|
|
98
|
+
Pick<
|
|
99
|
+
ComboboxPrimitive.Positioner.Props,
|
|
100
|
+
"side" | "align" | "sideOffset" | "alignOffset" | "anchor"
|
|
101
|
+
>) {
|
|
102
|
+
return (
|
|
103
|
+
<ComboboxPrimitive.Portal>
|
|
104
|
+
<ComboboxPrimitive.Positioner
|
|
105
|
+
side={side}
|
|
106
|
+
sideOffset={sideOffset}
|
|
107
|
+
align={align}
|
|
108
|
+
alignOffset={alignOffset}
|
|
109
|
+
anchor={anchor}
|
|
110
|
+
className="isolate z-50"
|
|
111
|
+
>
|
|
112
|
+
<ComboboxPrimitive.Popup
|
|
113
|
+
data-slot="combobox-content"
|
|
114
|
+
data-chips={!!anchor}
|
|
115
|
+
className={cn("dark 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) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
|
116
|
+
{...props}
|
|
117
|
+
/>
|
|
118
|
+
</ComboboxPrimitive.Positioner>
|
|
119
|
+
</ComboboxPrimitive.Portal>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {
|
|
124
|
+
return (
|
|
125
|
+
<ComboboxPrimitive.List
|
|
126
|
+
data-slot="combobox-list"
|
|
127
|
+
className={cn(
|
|
128
|
+
"no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0",
|
|
129
|
+
className
|
|
130
|
+
)}
|
|
131
|
+
{...props}
|
|
132
|
+
/>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function ComboboxItem({
|
|
137
|
+
className,
|
|
138
|
+
children,
|
|
139
|
+
...props
|
|
140
|
+
}: ComboboxPrimitive.Item.Props) {
|
|
141
|
+
return (
|
|
142
|
+
<ComboboxPrimitive.Item
|
|
143
|
+
data-slot="combobox-item"
|
|
144
|
+
className={cn(
|
|
145
|
+
"relative flex w-full cursor-default items-center gap-2 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
146
|
+
className
|
|
147
|
+
)}
|
|
148
|
+
{...props}
|
|
149
|
+
>
|
|
150
|
+
{children}
|
|
151
|
+
<ComboboxPrimitive.ItemIndicator
|
|
152
|
+
render={
|
|
153
|
+
<span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center" />
|
|
154
|
+
}
|
|
155
|
+
>
|
|
156
|
+
<CheckIcon className="pointer-events-none" />
|
|
157
|
+
</ComboboxPrimitive.ItemIndicator>
|
|
158
|
+
</ComboboxPrimitive.Item>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {
|
|
163
|
+
return (
|
|
164
|
+
<ComboboxPrimitive.Group
|
|
165
|
+
data-slot="combobox-group"
|
|
166
|
+
className={cn(className)}
|
|
167
|
+
{...props}
|
|
168
|
+
/>
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function ComboboxLabel({
|
|
173
|
+
className,
|
|
174
|
+
...props
|
|
175
|
+
}: ComboboxPrimitive.GroupLabel.Props) {
|
|
176
|
+
return (
|
|
177
|
+
<ComboboxPrimitive.GroupLabel
|
|
178
|
+
data-slot="combobox-label"
|
|
179
|
+
className={cn("px-2 py-1.5 text-xs text-muted-foreground", className)}
|
|
180
|
+
{...props}
|
|
181
|
+
/>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {
|
|
186
|
+
return (
|
|
187
|
+
<ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
|
|
192
|
+
return (
|
|
193
|
+
<ComboboxPrimitive.Empty
|
|
194
|
+
data-slot="combobox-empty"
|
|
195
|
+
className={cn(
|
|
196
|
+
"hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex",
|
|
197
|
+
className
|
|
198
|
+
)}
|
|
199
|
+
{...props}
|
|
200
|
+
/>
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function ComboboxSeparator({
|
|
205
|
+
className,
|
|
206
|
+
...props
|
|
207
|
+
}: ComboboxPrimitive.Separator.Props) {
|
|
208
|
+
return (
|
|
209
|
+
<ComboboxPrimitive.Separator
|
|
210
|
+
data-slot="combobox-separator"
|
|
211
|
+
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
|
212
|
+
{...props}
|
|
213
|
+
/>
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function ComboboxChips({
|
|
218
|
+
className,
|
|
219
|
+
...props
|
|
220
|
+
}: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> &
|
|
221
|
+
ComboboxPrimitive.Chips.Props) {
|
|
222
|
+
return (
|
|
223
|
+
<ComboboxPrimitive.Chips
|
|
224
|
+
data-slot="combobox-chips"
|
|
225
|
+
className={cn(
|
|
226
|
+
"flex min-h-8 flex-wrap items-center gap-1 rounded-lg border border-input bg-transparent bg-clip-padding px-2.5 py-1 text-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40",
|
|
227
|
+
className
|
|
228
|
+
)}
|
|
229
|
+
{...props}
|
|
230
|
+
/>
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function ComboboxChip({
|
|
235
|
+
className,
|
|
236
|
+
children,
|
|
237
|
+
showRemove = true,
|
|
238
|
+
...props
|
|
239
|
+
}: ComboboxPrimitive.Chip.Props & {
|
|
240
|
+
showRemove?: boolean
|
|
241
|
+
}) {
|
|
242
|
+
return (
|
|
243
|
+
<ComboboxPrimitive.Chip
|
|
244
|
+
data-slot="combobox-chip"
|
|
245
|
+
className={cn(
|
|
246
|
+
"flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0",
|
|
247
|
+
className
|
|
248
|
+
)}
|
|
249
|
+
{...props}
|
|
250
|
+
>
|
|
251
|
+
{children}
|
|
252
|
+
{showRemove && (
|
|
253
|
+
<ComboboxPrimitive.ChipRemove
|
|
254
|
+
render={<Button variant="ghost" size="icon-xs" />}
|
|
255
|
+
className="-ml-1 opacity-50 hover:opacity-100"
|
|
256
|
+
data-slot="combobox-chip-remove"
|
|
257
|
+
>
|
|
258
|
+
<XIcon className="pointer-events-none" />
|
|
259
|
+
</ComboboxPrimitive.ChipRemove>
|
|
260
|
+
)}
|
|
261
|
+
</ComboboxPrimitive.Chip>
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function ComboboxChipsInput({
|
|
266
|
+
className,
|
|
267
|
+
...props
|
|
268
|
+
}: ComboboxPrimitive.Input.Props) {
|
|
269
|
+
return (
|
|
270
|
+
<ComboboxPrimitive.Input
|
|
271
|
+
data-slot="combobox-chip-input"
|
|
272
|
+
className={cn("min-w-16 flex-1 outline-none", className)}
|
|
273
|
+
{...props}
|
|
274
|
+
/>
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function useComboboxAnchor() {
|
|
279
|
+
return React.useRef<HTMLDivElement | null>(null)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export {
|
|
283
|
+
Combobox,
|
|
284
|
+
ComboboxInput,
|
|
285
|
+
ComboboxContent,
|
|
286
|
+
ComboboxList,
|
|
287
|
+
ComboboxItem,
|
|
288
|
+
ComboboxGroup,
|
|
289
|
+
ComboboxLabel,
|
|
290
|
+
ComboboxCollection,
|
|
291
|
+
ComboboxEmpty,
|
|
292
|
+
ComboboxSeparator,
|
|
293
|
+
ComboboxChips,
|
|
294
|
+
ComboboxChip,
|
|
295
|
+
ComboboxChipsInput,
|
|
296
|
+
ComboboxTrigger,
|
|
297
|
+
ComboboxValue,
|
|
298
|
+
useComboboxAnchor,
|
|
299
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Dialog as DialogPrimitive } from "radix-ui"
|
|
3
|
+
|
|
4
|
+
import { cn } from "../lib/cn.js"
|
|
5
|
+
import { Button } from "./button.js"
|
|
6
|
+
import { XIcon } from "lucide-react"
|
|
7
|
+
|
|
8
|
+
function Dialog({
|
|
9
|
+
...props
|
|
10
|
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
11
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function DialogTrigger({
|
|
15
|
+
...props
|
|
16
|
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
17
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function DialogPortal({
|
|
21
|
+
...props
|
|
22
|
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
23
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function DialogClose({
|
|
27
|
+
...props
|
|
28
|
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
29
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function DialogOverlay({
|
|
33
|
+
className,
|
|
34
|
+
...props
|
|
35
|
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
36
|
+
return (
|
|
37
|
+
<DialogPrimitive.Overlay
|
|
38
|
+
data-slot="dialog-overlay"
|
|
39
|
+
className={cn(
|
|
40
|
+
"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function DialogContent({
|
|
49
|
+
className,
|
|
50
|
+
children,
|
|
51
|
+
showCloseButton = true,
|
|
52
|
+
...props
|
|
53
|
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
54
|
+
showCloseButton?: boolean
|
|
55
|
+
}) {
|
|
56
|
+
return (
|
|
57
|
+
<DialogPortal>
|
|
58
|
+
<DialogOverlay />
|
|
59
|
+
<DialogPrimitive.Content
|
|
60
|
+
data-slot="dialog-content"
|
|
61
|
+
className={cn(
|
|
62
|
+
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
63
|
+
className
|
|
64
|
+
)}
|
|
65
|
+
{...props}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
{showCloseButton && (
|
|
69
|
+
<DialogPrimitive.Close data-slot="dialog-close" asChild>
|
|
70
|
+
<Button
|
|
71
|
+
variant="ghost"
|
|
72
|
+
className="absolute top-2 right-2"
|
|
73
|
+
size="icon-sm"
|
|
74
|
+
>
|
|
75
|
+
<XIcon
|
|
76
|
+
/>
|
|
77
|
+
<span className="sr-only">Close</span>
|
|
78
|
+
</Button>
|
|
79
|
+
</DialogPrimitive.Close>
|
|
80
|
+
)}
|
|
81
|
+
</DialogPrimitive.Content>
|
|
82
|
+
</DialogPortal>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
87
|
+
return (
|
|
88
|
+
<div
|
|
89
|
+
data-slot="dialog-header"
|
|
90
|
+
className={cn("flex flex-col gap-2", className)}
|
|
91
|
+
{...props}
|
|
92
|
+
/>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function DialogFooter({
|
|
97
|
+
className,
|
|
98
|
+
showCloseButton = false,
|
|
99
|
+
children,
|
|
100
|
+
...props
|
|
101
|
+
}: React.ComponentProps<"div"> & {
|
|
102
|
+
showCloseButton?: boolean
|
|
103
|
+
}) {
|
|
104
|
+
return (
|
|
105
|
+
<div
|
|
106
|
+
data-slot="dialog-footer"
|
|
107
|
+
className={cn(
|
|
108
|
+
"-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",
|
|
109
|
+
className
|
|
110
|
+
)}
|
|
111
|
+
{...props}
|
|
112
|
+
>
|
|
113
|
+
{children}
|
|
114
|
+
{showCloseButton && (
|
|
115
|
+
<DialogPrimitive.Close asChild>
|
|
116
|
+
<Button variant="outline">Close</Button>
|
|
117
|
+
</DialogPrimitive.Close>
|
|
118
|
+
)}
|
|
119
|
+
</div>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function DialogTitle({
|
|
124
|
+
className,
|
|
125
|
+
...props
|
|
126
|
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
127
|
+
return (
|
|
128
|
+
<DialogPrimitive.Title
|
|
129
|
+
data-slot="dialog-title"
|
|
130
|
+
className={cn(
|
|
131
|
+
"font-heading text-base leading-none font-medium",
|
|
132
|
+
className
|
|
133
|
+
)}
|
|
134
|
+
{...props}
|
|
135
|
+
/>
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function DialogDescription({
|
|
140
|
+
className,
|
|
141
|
+
...props
|
|
142
|
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
143
|
+
return (
|
|
144
|
+
<DialogPrimitive.Description
|
|
145
|
+
data-slot="dialog-description"
|
|
146
|
+
className={cn(
|
|
147
|
+
"text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
148
|
+
className
|
|
149
|
+
)}
|
|
150
|
+
{...props}
|
|
151
|
+
/>
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export {
|
|
156
|
+
Dialog,
|
|
157
|
+
DialogClose,
|
|
158
|
+
DialogContent,
|
|
159
|
+
DialogDescription,
|
|
160
|
+
DialogFooter,
|
|
161
|
+
DialogHeader,
|
|
162
|
+
DialogOverlay,
|
|
163
|
+
DialogPortal,
|
|
164
|
+
DialogTitle,
|
|
165
|
+
DialogTrigger,
|
|
166
|
+
}
|