@catalystsoftware/ui 1.0.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 +7 -0
- package/components/catalyst-ui/buttons/burger.tsx +207 -0
- package/components/catalyst-ui/core/data-display/timeline.tsx +210 -0
- package/components/catalyst-ui/core/feedback/alert.tsx +491 -0
- package/components/catalyst-ui/core/feedback/spinner-1.tsx +65 -0
- package/components/catalyst-ui/core/feedback/toast.tsx +1857 -0
- package/components/catalyst-ui/core/navigation/menu.tsx +164 -0
- package/components/catalyst-ui/forms/toggle-class.tsx +176 -0
- package/components/catalyst-ui/hooks/use-copy-to-clipboard.tsx +419 -0
- package/components/catalyst-ui/hooks/use-counter.tsx +13 -0
- package/components/catalyst-ui/hooks/use-event-listener.tsx +23 -0
- package/components/catalyst-ui/hooks/use-export-markdown.tsx +47 -0
- package/components/catalyst-ui/hooks/use-focus.tsx +17 -0
- package/components/catalyst-ui/hooks/use-interval.tsx +23 -0
- package/components/catalyst-ui/hooks/use-is-client.tsx +16 -0
- package/components/catalyst-ui/hooks/use-media-query.tsx +19 -0
- package/components/catalyst-ui/hooks/use-mobile.tsx +19 -0
- package/components/catalyst-ui/hooks/use-resize-observer.tsx +81 -0
- package/components/catalyst-ui/hooks/use-timeout.tsx +21 -0
- package/components/catalyst-ui/hooks/use-timer.tsx +209 -0
- package/components/catalyst-ui/hooks/use-toggle.tsx +12 -0
- package/components/catalyst-ui/media/image.tsx +13 -0
- package/components/catalyst-ui/overlays/dual-sidebar.tsx +4142 -0
- package/components/catalyst-ui/overlays/sidebar-original.tsx +726 -0
- package/components/catalyst-ui/primitives/accordion.tsx +250 -0
- package/components/catalyst-ui/primitives/alert-dialog.tsx +126 -0
- package/components/catalyst-ui/primitives/aspect-ratio.tsx +9 -0
- package/components/catalyst-ui/primitives/avatar.tsx +296 -0
- package/components/catalyst-ui/primitives/badge.tsx +57 -0
- package/components/catalyst-ui/primitives/breadcrumb.tsx +101 -0
- package/components/catalyst-ui/primitives/button.tsx +265 -0
- package/components/catalyst-ui/primitives/calendar-v4.tsx +208 -0
- package/components/catalyst-ui/primitives/calendar.tsx +295 -0
- package/components/catalyst-ui/primitives/card.tsx +618 -0
- package/components/catalyst-ui/primitives/carousel.tsx +238 -0
- package/components/catalyst-ui/primitives/chart.tsx +347 -0
- package/components/catalyst-ui/primitives/checkbox.tsx +225 -0
- package/components/catalyst-ui/primitives/collapsible.tsx +212 -0
- package/components/catalyst-ui/primitives/command.tsx +393 -0
- package/components/catalyst-ui/primitives/context-menu.tsx +236 -0
- package/components/catalyst-ui/primitives/dialog.tsx +471 -0
- package/components/catalyst-ui/primitives/drawer.tsx +761 -0
- package/components/catalyst-ui/primitives/dropdown-menu.tsx +290 -0
- package/components/catalyst-ui/primitives/empty.tsx +104 -0
- package/components/catalyst-ui/primitives/field.tsx +244 -0
- package/components/catalyst-ui/primitives/hover-card.tsx +124 -0
- package/components/catalyst-ui/primitives/input-otp.tsx +76 -0
- package/components/catalyst-ui/primitives/input.tsx +64 -0
- package/components/catalyst-ui/primitives/item.tsx +196 -0
- package/components/catalyst-ui/primitives/kbd.tsx +75 -0
- package/components/catalyst-ui/primitives/label.tsx +24 -0
- package/components/catalyst-ui/primitives/navigation-menu.tsx +150 -0
- package/components/catalyst-ui/primitives/pagination.tsx +198 -0
- package/components/catalyst-ui/primitives/popover.tsx +232 -0
- package/components/catalyst-ui/primitives/progress.tsx +34 -0
- package/components/catalyst-ui/primitives/radio-group.tsx +43 -0
- package/components/catalyst-ui/primitives/resizable.tsx +56 -0
- package/components/catalyst-ui/primitives/select.tsx +155 -0
- package/components/catalyst-ui/primitives/separator.tsx +74 -0
- package/components/catalyst-ui/primitives/sheet.tsx +126 -0
- package/components/catalyst-ui/primitives/skeleton.tsx +15 -0
- package/components/catalyst-ui/primitives/slider.tsx +27 -0
- package/components/catalyst-ui/primitives/switch.tsx +187 -0
- package/components/catalyst-ui/primitives/tabs.tsx +335 -0
- package/components/catalyst-ui/primitives/textarea.tsx +24 -0
- package/components/catalyst-ui/primitives/toggle-group.tsx +55 -0
- package/components/catalyst-ui/primitives/toggle.tsx +42 -0
- package/components/catalyst-ui/primitives/tooltip.tsx +116 -0
- package/components/catalyst-ui/utils/basic-auth.tsx +40 -0
- package/components/catalyst-ui/utils/context-storage.tsx +19 -0
- package/components/catalyst-ui/utils/cors-middleware.tsx +71 -0
- package/components/catalyst-ui/utils/deferred-content.tsx +595 -0
- package/components/catalyst-ui/utils/honeypot-middleware.tsx +38 -0
- package/components/catalyst-ui/utils/incId.tsx +75 -0
- package/components/catalyst-ui/utils/jwk-auth.tsx +36 -0
- package/components/catalyst-ui/utils/request-id.tsx +14 -0
- package/components/catalyst-ui/utils/secure-headers.tsx +37 -0
- package/components/catalyst-ui/utils/server-timing.tsx +23 -0
- package/components/catalyst-ui/utils/utils.ts +43 -0
- package/components/catalyst-ui/utils/with-cookie.tsx +43 -0
- package/components/catalyst-ui/x/accordian-x.tsx +428 -0
- package/components/catalyst-ui/x/alert-x.tsx +413 -0
- package/components/catalyst-ui/x/animated-text-x.tsx +2242 -0
- package/components/catalyst-ui/x/avatar-x.tsx +515 -0
- package/components/catalyst-ui/x/badge-x.tsx +670 -0
- package/components/catalyst-ui/x/button-X.tsx +2857 -0
- package/components/catalyst-ui/x/button-group-x.tsx +847 -0
- package/components/catalyst-ui/x/calendar-x.tsx +1910 -0
- package/components/catalyst-ui/x/card-x.tsx +2597 -0
- package/components/catalyst-ui/x/checkbox-x.tsx +656 -0
- package/components/catalyst-ui/x/collapsible-x.tsx +1360 -0
- package/components/catalyst-ui/x/combobox-x.tsx +911 -0
- package/components/catalyst-ui/x/data-table-x.tsx +1753 -0
- package/components/catalyst-ui/x/date-picker-x.tsx +648 -0
- package/components/catalyst-ui/x/dialog-x.tsx +659 -0
- package/components/catalyst-ui/x/dropdown-menu-x.tsx +612 -0
- package/components/catalyst-ui/x/hover-card-x.tsx +375 -0
- package/components/catalyst-ui/x/icon-x.tsx +840 -0
- package/components/catalyst-ui/x/input-mask-x.tsx +981 -0
- package/components/catalyst-ui/x/input-otp-x.tsx +659 -0
- package/components/catalyst-ui/x/loader-x.tsx +1757 -0
- package/components/catalyst-ui/x/pagination-x.tsx +622 -0
- package/components/catalyst-ui/x/popover-x.tsx +744 -0
- package/components/catalyst-ui/x/radio-group-x.tsx +499 -0
- package/components/catalyst-ui/x/select-x.tsx +1127 -0
- package/components/catalyst-ui/x/sheet-x.tsx +668 -0
- package/components/catalyst-ui/x/switch-x.tsx +681 -0
- package/components/catalyst-ui/x/table-x.tsx +574 -0
- package/components/catalyst-ui/x/tabs-x.tsx +839 -0
- package/components/catalyst-ui/x/textarea-x.tsx +1263 -0
- package/components/catalyst-ui/x/tooltip-x.tsx +396 -0
- package/components/catalyst-ui/x/tracker-x.tsx +560 -0
- package/data/bg-data.tsx +901 -0
- package/data/buttons-data.tsx +2327 -0
- package/data/charts-data.tsx +102 -0
- package/data/chat-data.tsx +83 -0
- package/data/code-data.tsx +1040 -0
- package/data/comboboxes-data.tsx +1843 -0
- package/data/command-data.tsx +1381 -0
- package/data/core-data.tsx +15953 -0
- package/data/crm-data.tsx +47 -0
- package/data/data.tsx +159 -0
- package/data/date-and-time-data.tsx +554 -0
- package/data/dependencies.tsx +7 -0
- package/data/ecommerce-data.tsx +1387 -0
- package/data/forms-data.tsx +7890 -0
- package/data/hooks-data.tsx +5487 -0
- package/data/index.ts +34 -0
- package/data/inputs-data.tsx +557 -0
- package/data/interactive-data.tsx +5394 -0
- package/data/lofi-data.tsx +18295 -0
- package/data/marketing-data.tsx +2546 -0
- package/data/media-data.tsx +1510 -0
- package/data/motion-data.tsx +5801 -0
- package/data/overlay-data.tsx +4136 -0
- package/data/pdf-data.tsx +124 -0
- package/data/pos-data.tsx +213 -0
- package/data/postcss.config.js +6 -0
- package/data/primitive-data.tsx +5170 -0
- package/data/prompt-data.tsx +1226 -0
- package/data/requiredLibs.ts +4 -0
- package/data/sandbox-data.tsx +1 -0
- package/data/sidebars-data.tsx +5421 -0
- package/data/stacks-data.tsx +32 -0
- package/data/table-data.tsx +706 -0
- package/data/tailwind.config.js +3830 -0
- package/data/tailwind.config.ngin.js +3830 -0
- package/data/tailwind.css +431 -0
- package/data/tools-data.tsx +6910 -0
- package/data/typography-data.tsx +2050 -0
- package/data/utils-data.tsx +6500 -0
- package/data/x-data.tsx +1171 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30245 -0
- package/dist/index.js.map +362 -0
- package/package.json +50 -0
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import React, { useId } from 'react'
|
|
2
|
+
import { cn } from "~/components/catalyst-ui"
|
|
3
|
+
import { Alert, AlertTitle, AlertDescription, useAlertContext, alertVariants } from "~/components/catalyst-ui"
|
|
4
|
+
import { Avatar, AvatarImage, AvatarFallback } from "~/components/catalyst-ui"
|
|
5
|
+
import { Button } from "~/components/catalyst-ui"
|
|
6
|
+
import { Progress,TsxSection, } from "~/components/catalyst-ui"
|
|
7
|
+
import { X } from "lucide-react"
|
|
8
|
+
import type { LucideIcon } from "lucide-react"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* ★ ━━━━ ☆ ━━━━ AlertX ━━━━ ☆ ━━━━ ★
|
|
12
|
+
* type AlertType = 'default' | 'withAvatar' | 'closable' | 'withLink' | 'attachedIcon' | 'focusedIcon' | 'fileUpload' | 'multipleAction' | 'task' | 'withAction'
|
|
13
|
+
*
|
|
14
|
+
* ★ ━━━━ ☆ ━━━━ USAGE ━━━━ ☆ ━━━━ ★
|
|
15
|
+
* ★ ━━━━━━━━━ withAvatar ━━━━━━━━━ ★
|
|
16
|
+
* ```jsx
|
|
17
|
+
* <AlertX alert="withAvatar">
|
|
18
|
+
* <AlertXTitle avatar='https://cdn.shadcnstudio.com/ss-assets/avatar/avatar-5.png' name='Hallie Richards'>
|
|
19
|
+
* Sara has replied on the uploaded image.
|
|
20
|
+
* </AlertXTitle>
|
|
21
|
+
* <AlertXDescription>12 unread messages. Tap to see.</AlertXDescription>
|
|
22
|
+
* </AlertX>
|
|
23
|
+
* ```
|
|
24
|
+
* ★ ━━━━━━━━━ closable ━━━━━━━━━ ★
|
|
25
|
+
* ```jsx
|
|
26
|
+
* {isClosableActive && (
|
|
27
|
+
* <AlertX alert="closable">
|
|
28
|
+
* <AlertXTitle onClose={() => setIsClosableActive(false)}>New message!</AlertXTitle>
|
|
29
|
+
* <AlertXDescription>12 unread messages. Tap to see.</AlertXDescription>
|
|
30
|
+
* </AlertX>
|
|
31
|
+
* )}
|
|
32
|
+
* ```
|
|
33
|
+
* ★ ━━━━━━━━━ withAction ━━━━━━━━━ ★
|
|
34
|
+
* ```jsx
|
|
35
|
+
* <AlertX alert="withAction">
|
|
36
|
+
* <AlertXTitle actionLabel="Open" onAction={() => console.log('opened')}>
|
|
37
|
+
* New message!
|
|
38
|
+
* </AlertXTitle>
|
|
39
|
+
* </AlertX>
|
|
40
|
+
* ```
|
|
41
|
+
* ★ ━━━━━━━━━ attachedIcon ━━━━━━━━━ ★
|
|
42
|
+
* ```jsx
|
|
43
|
+
* <AlertX alert="attachedIcon" variant="destructive">
|
|
44
|
+
* <AlertXTitle>This file contains virus!</AlertXTitle>
|
|
45
|
+
* </AlertX>
|
|
46
|
+
* ```
|
|
47
|
+
* ★ ━━━━━━━━━ focusedIcon ━━━━━━━━━ ★
|
|
48
|
+
* ```jsx
|
|
49
|
+
* <AlertX alert="focusedIcon">
|
|
50
|
+
* <AlertXTitle>This file contains virus!</AlertXTitle>
|
|
51
|
+
* </AlertX>
|
|
52
|
+
* ```
|
|
53
|
+
* ★ ━━━━━━━━━ multipleAction ━━━━━━━━━ ★
|
|
54
|
+
* ```jsx
|
|
55
|
+
* {isMultipleActionActive && (
|
|
56
|
+
* <AlertX alert="multipleAction" variant="primary">
|
|
57
|
+
* <AlertXTitle onClose={() => setIsMultipleActionActive(false)}>
|
|
58
|
+
* A new update is available
|
|
59
|
+
* </AlertXTitle>
|
|
60
|
+
* <AlertXDescription
|
|
61
|
+
* skipLabel="Skip this update"
|
|
62
|
+
* installLabel="Install now"
|
|
63
|
+
* onSkip={() => console.log('skipped')}
|
|
64
|
+
* onInstall={() => console.log('installed')}
|
|
65
|
+
* >
|
|
66
|
+
* Includes the at new dashboard View. Pages end exports will now load faster
|
|
67
|
+
* </AlertXDescription>
|
|
68
|
+
* </AlertX>
|
|
69
|
+
* )}
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
type AlertType = 'default' | 'withAvatar' | 'closable' | 'withLink' | 'attachedIcon' | 'focusedIcon' | 'fileUpload' | 'multipleAction' | 'task' | 'withAction'
|
|
75
|
+
|
|
76
|
+
const AlertXContext = React.createContext<AlertType>('default')
|
|
77
|
+
|
|
78
|
+
interface AlertContextValue {
|
|
79
|
+
variant?: string
|
|
80
|
+
alert?: string
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function AlertX({ alert = 'default', variant, children, ...props }: any) {
|
|
84
|
+
const contextValue: AlertContextValue = { variant, alert }
|
|
85
|
+
|
|
86
|
+
switch (alert) {
|
|
87
|
+
case 'attachedIcon':
|
|
88
|
+
return (
|
|
89
|
+
<AlertXContext.Provider value={contextValue}>
|
|
90
|
+
<Alert className={cn(alertVariants({ variant }), 'flex items-stretch p-0', props.className)} {...props}>
|
|
91
|
+
<div className='bg-destructive/10 text-destructive flex items-center rounded-l-lg border-r p-2'>
|
|
92
|
+
<svg className="size-4" />
|
|
93
|
+
</div>
|
|
94
|
+
{children}
|
|
95
|
+
</Alert>
|
|
96
|
+
</AlertXContext.Provider>
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
case 'spotlight':
|
|
100
|
+
return (
|
|
101
|
+
<AlertXContext.Provider value={contextValue}>
|
|
102
|
+
<Alert className={cn(alertVariants({ variant }), 'before:bg-primary/70 relative before:absolute before:size-full before:rounded-lg', props.className)} {...props}>
|
|
103
|
+
{children}
|
|
104
|
+
</Alert>
|
|
105
|
+
</AlertXContext.Provider>
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
default:
|
|
109
|
+
return (
|
|
110
|
+
<AlertXContext.Provider value={contextValue}>
|
|
111
|
+
<Alert className={cn(alertVariants({ variant }), props.className)} {...props}>
|
|
112
|
+
{children}
|
|
113
|
+
</Alert>
|
|
114
|
+
</AlertXContext.Provider>
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function AlertXTitle({ children, ...props }: any) {
|
|
120
|
+
const alertType = React.useContext(AlertXContext)
|
|
121
|
+
|
|
122
|
+
switch (alertType) {
|
|
123
|
+
case 'withAvatar':
|
|
124
|
+
return (
|
|
125
|
+
<div className={cn('col-start-2 flex items-center justify-between gap-3', props.className)}>
|
|
126
|
+
<Avatar className='rounded-sm'>
|
|
127
|
+
<AvatarImage src={props.avatar} alt={props.name} className='rounded-sm' />
|
|
128
|
+
<AvatarFallback className='text-xs'>{props.name?.[0]}</AvatarFallback>
|
|
129
|
+
</Avatar>
|
|
130
|
+
<div className='flex-1'>
|
|
131
|
+
<div className='min-h-4 font-medium tracking-tight'>{children}</div>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
case 'closable':
|
|
137
|
+
return (
|
|
138
|
+
<div className={cn('flex items-start justify-between gap-3', props.className)}>
|
|
139
|
+
<svg className="size-4 shrink-0 mt-0.5" />
|
|
140
|
+
<div className='flex-1 min-h-4 font-medium tracking-tight'>{children}</div>
|
|
141
|
+
<button className='shrink-0 cursor-pointer opacity-70 hover:opacity-100 transition-opacity' onClick={props.onClose}>
|
|
142
|
+
<X className='size-5' />
|
|
143
|
+
<span className='sr-only'>Close</span>
|
|
144
|
+
</button>
|
|
145
|
+
</div>
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
case 'withAction':
|
|
149
|
+
return (
|
|
150
|
+
<div className={cn('flex items-center justify-between gap-3 [&>svg]:translate-y-0', props.className)}>
|
|
151
|
+
<svg className="size-4 shrink-0" />
|
|
152
|
+
<div className='flex-1 font-medium tracking-tight'>{children}</div>
|
|
153
|
+
<Button variant='outline' className='h-7 cursor-pointer rounded-md px-2' onClick={props.onAction}>
|
|
154
|
+
{props.actionLabel || 'Open'}
|
|
155
|
+
</Button>
|
|
156
|
+
</div>
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
case 'attachedIcon':
|
|
160
|
+
return (
|
|
161
|
+
<div className={cn('p-3 min-h-4 font-medium tracking-tight', props.className)}>
|
|
162
|
+
{children}
|
|
163
|
+
</div>
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
case 'focusedIcon':
|
|
167
|
+
return (
|
|
168
|
+
<div className={cn('flex items-center gap-3', props.className)}>
|
|
169
|
+
<Avatar className='rounded-md'>
|
|
170
|
+
<AvatarFallback className='bg-destructive dark:bg-destructive/60 rounded-md text-white'>
|
|
171
|
+
<svg className="size-4" />
|
|
172
|
+
</AvatarFallback>
|
|
173
|
+
</Avatar>
|
|
174
|
+
<div className='min-h-4 font-medium tracking-tight'>{children}</div>
|
|
175
|
+
</div>
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
case 'task':
|
|
179
|
+
return (
|
|
180
|
+
<div className={cn('flex gap-3', props.className)}>
|
|
181
|
+
<Avatar className='rounded-sm'>
|
|
182
|
+
<AvatarImage src={props.avatar} alt={props.name} className='rounded-sm' />
|
|
183
|
+
<AvatarFallback className='text-xs'>{props.name?.[0]}</AvatarFallback>
|
|
184
|
+
</Avatar>
|
|
185
|
+
<div className='flex-1'>
|
|
186
|
+
<div className='min-h-4 font-medium tracking-tight'>{children}</div>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
case 'multipleAction':
|
|
192
|
+
return (
|
|
193
|
+
<div className={cn('flex justify-between gap-3', props.className)}>
|
|
194
|
+
<svg className="size-4 shrink-0 mt-0.5" />
|
|
195
|
+
<div className='flex-1 min-h-4 font-medium tracking-tight'>{children}</div>
|
|
196
|
+
<button className='shrink-0 cursor-pointer' onClick={props.onClose}>
|
|
197
|
+
<X className='size-5' />
|
|
198
|
+
<span className='sr-only'>Close</span>
|
|
199
|
+
</button>
|
|
200
|
+
</div>
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
default:
|
|
204
|
+
return (
|
|
205
|
+
<AlertTitle className={cn(props.className)} {...props}>
|
|
206
|
+
{children}
|
|
207
|
+
</AlertTitle>
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function AlertXDescription({ children, ...props }: any) {
|
|
213
|
+
const alertType = React.useContext(AlertXContext)
|
|
214
|
+
|
|
215
|
+
switch (alertType) {
|
|
216
|
+
case 'withAvatar':
|
|
217
|
+
return (
|
|
218
|
+
<div className={cn('text-muted-foreground text-sm [&_p]:leading-relaxed col-start-2', props.className)}>
|
|
219
|
+
{children}
|
|
220
|
+
</div>
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
case 'closable':
|
|
224
|
+
return (
|
|
225
|
+
<div className={cn('text-muted-foreground text-sm [&_p]:leading-relaxed ml-7', props.className)}>
|
|
226
|
+
{children}
|
|
227
|
+
</div>
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
case 'task':
|
|
231
|
+
return (
|
|
232
|
+
<div className={cn('flex flex-col gap-2', props.className)}>
|
|
233
|
+
<div className='text-muted-foreground text-sm [&_p]:leading-relaxed'>{children}</div>
|
|
234
|
+
<Progress
|
|
235
|
+
value={props.progress || 0}
|
|
236
|
+
className='bg-amber-600/20 *:bg-amber-600 dark:bg-amber-400/20 dark:*:bg-amber-400'
|
|
237
|
+
aria-label='Task progress'
|
|
238
|
+
/>
|
|
239
|
+
</div>
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
case 'multipleAction':
|
|
243
|
+
return (
|
|
244
|
+
<div className={cn('flex flex-col gap-4 ml-7', props.className)}>
|
|
245
|
+
<div className='text-primary-foreground/80 text-sm [&_p]:leading-relaxed'>{children}</div>
|
|
246
|
+
<div className='flex items-center gap-4'>
|
|
247
|
+
<Button className='bg-secondary/10 focus-visible:bg-secondary/20 hover:bg-secondary/20 h-7 cursor-pointer rounded-md px-2' onClick={props.onSkip}>
|
|
248
|
+
{props.skipLabel || 'Skip this update'}
|
|
249
|
+
</Button>
|
|
250
|
+
<Button variant='secondary' className='h-7 cursor-pointer rounded-md px-2' onClick={props.onInstall}>
|
|
251
|
+
{props.installLabel || 'Install now'}
|
|
252
|
+
</Button>
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
default:
|
|
258
|
+
return (
|
|
259
|
+
<AlertDescription className={cn(props.className)} {...props}>
|
|
260
|
+
{children}
|
|
261
|
+
</AlertDescription>
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function AlertXDemo() {
|
|
267
|
+
const [isClosableActive, setIsClosableActive] = React.useState(true)
|
|
268
|
+
const [isMultipleActionActive, setIsMultipleActionActive] = React.useState(true)
|
|
269
|
+
const [progress, setProgress] = React.useState(0)
|
|
270
|
+
|
|
271
|
+
React.useEffect(() => {
|
|
272
|
+
const timer = setTimeout(() => setProgress(50), 100)
|
|
273
|
+
return () => clearTimeout(timer)
|
|
274
|
+
}, [])
|
|
275
|
+
|
|
276
|
+
return (
|
|
277
|
+
<div className="space-y-8 p-6 max-w-3xl mx-auto">
|
|
278
|
+
<div>
|
|
279
|
+
<h3 className="text-lg font-semibold mb-4">With Avatar</h3>
|
|
280
|
+
<AlertX alert="withAvatar">
|
|
281
|
+
<AlertXTitle avatar='https://cdn.shadcnstudio.com/ss-assets/avatar/avatar-5.png' name='Hallie Richards'>
|
|
282
|
+
Sara has replied on the uploaded image.
|
|
283
|
+
</AlertXTitle>
|
|
284
|
+
<AlertXDescription>12 unread messages. Tap to see.</AlertXDescription>
|
|
285
|
+
</AlertX>
|
|
286
|
+
<TsxSection
|
|
287
|
+
title="AlertX"
|
|
288
|
+
code={`<AlertX alert="withAvatar">
|
|
289
|
+
<AlertXTitle avatar='https://cdn.shadcnstudio.com/ss-assets/avatar/avatar-5.png' name='Hallie Richards'>
|
|
290
|
+
Sara has replied on the uploaded image.
|
|
291
|
+
</AlertXTitle>
|
|
292
|
+
<AlertXDescription>12 unread messages. Tap to see.</AlertXDescription>
|
|
293
|
+
</AlertX>`}
|
|
294
|
+
/>
|
|
295
|
+
</div>
|
|
296
|
+
|
|
297
|
+
<div>
|
|
298
|
+
<h3 className="text-lg font-semibold mb-4">Closable</h3>
|
|
299
|
+
{isClosableActive && (
|
|
300
|
+
<AlertX alert="closable">
|
|
301
|
+
<AlertXTitle onClose={() => setIsClosableActive(false)}>New message!</AlertXTitle>
|
|
302
|
+
<AlertXDescription>12 unread messages. Tap to see.</AlertXDescription>
|
|
303
|
+
</AlertX>
|
|
304
|
+
)}
|
|
305
|
+
<TsxSection
|
|
306
|
+
title="AlertX"
|
|
307
|
+
code={` {isClosableActive && (
|
|
308
|
+
<AlertX alert="closable">
|
|
309
|
+
<AlertXTitle onClose={() => setIsClosableActive(false)}>New message!</AlertXTitle>
|
|
310
|
+
<AlertXDescription>12 unread messages. Tap to see.</AlertXDescription>
|
|
311
|
+
</AlertX>
|
|
312
|
+
)}`}
|
|
313
|
+
/>
|
|
314
|
+
</div>
|
|
315
|
+
|
|
316
|
+
<div>
|
|
317
|
+
<h3 className="text-lg font-semibold mb-4">With Action</h3>
|
|
318
|
+
<AlertX alert="withAction">
|
|
319
|
+
<AlertXTitle actionLabel="Open" onAction={() => console.log('opened')}>
|
|
320
|
+
New message!
|
|
321
|
+
</AlertXTitle>
|
|
322
|
+
</AlertX>
|
|
323
|
+
<TsxSection
|
|
324
|
+
title="AlertX"
|
|
325
|
+
code={`<AlertX alert="withAction">
|
|
326
|
+
<AlertXTitle actionLabel="Open" onAction={() => console.log('opened')}>
|
|
327
|
+
New message!
|
|
328
|
+
</AlertXTitle>
|
|
329
|
+
</AlertX>`}
|
|
330
|
+
/>
|
|
331
|
+
</div>
|
|
332
|
+
|
|
333
|
+
<div>
|
|
334
|
+
<h3 className="text-lg font-semibold mb-4">Attached Icon</h3>
|
|
335
|
+
<AlertX alert="attachedIcon" variant="destructive">
|
|
336
|
+
<AlertXTitle>This file contains virus!</AlertXTitle>
|
|
337
|
+
</AlertX>
|
|
338
|
+
<TsxSection
|
|
339
|
+
title="AlertX"
|
|
340
|
+
code={`<AlertX alert="attachedIcon" variant="destructive">
|
|
341
|
+
<AlertXTitle>This file contains virus!</AlertXTitle>
|
|
342
|
+
</AlertX>`}
|
|
343
|
+
/>
|
|
344
|
+
</div>
|
|
345
|
+
|
|
346
|
+
<div>
|
|
347
|
+
<h3 className="text-lg font-semibold mb-4">Focused Icon</h3>
|
|
348
|
+
<AlertX alert="focusedIcon">
|
|
349
|
+
<AlertXTitle>This file contains virus!</AlertXTitle>
|
|
350
|
+
</AlertX>
|
|
351
|
+
<TsxSection
|
|
352
|
+
title="AlertX"
|
|
353
|
+
code={`<AlertX alert="focusedIcon">
|
|
354
|
+
<AlertXTitle>This file contains virus!</AlertXTitle>
|
|
355
|
+
</AlertX>`}
|
|
356
|
+
/>
|
|
357
|
+
</div>
|
|
358
|
+
|
|
359
|
+
<div>
|
|
360
|
+
<h3 className="text-lg font-semibold mb-4">Task</h3>
|
|
361
|
+
<AlertX alert="task">
|
|
362
|
+
<AlertXTitle avatar='https://cdn.shadcnstudio.com/ss-assets/avatar/avatar-5.png' name='Rocky'>
|
|
363
|
+
@Rocky
|
|
364
|
+
</AlertXTitle>
|
|
365
|
+
<AlertXDescription progress={progress}>
|
|
366
|
+
this projects task is remaining, deadline is near.
|
|
367
|
+
</AlertXDescription>
|
|
368
|
+
</AlertX>
|
|
369
|
+
<TsxSection
|
|
370
|
+
title="AlertX"
|
|
371
|
+
code={``}
|
|
372
|
+
/>
|
|
373
|
+
</div>
|
|
374
|
+
|
|
375
|
+
<div>
|
|
376
|
+
<h3 className="text-lg font-semibold mb-4">Multiple Actions</h3>
|
|
377
|
+
{isMultipleActionActive && (
|
|
378
|
+
<AlertX alert="multipleAction" variant="primary">
|
|
379
|
+
<AlertXTitle onClose={() => setIsMultipleActionActive(false)}>
|
|
380
|
+
A new update is available
|
|
381
|
+
</AlertXTitle>
|
|
382
|
+
<AlertXDescription
|
|
383
|
+
skipLabel="Skip this update"
|
|
384
|
+
installLabel="Install now"
|
|
385
|
+
onSkip={() => console.log('skipped')}
|
|
386
|
+
onInstall={() => console.log('installed')}
|
|
387
|
+
>
|
|
388
|
+
Includes the at new dashboard View. Pages end exports will now load faster
|
|
389
|
+
</AlertXDescription>
|
|
390
|
+
</AlertX>
|
|
391
|
+
)}
|
|
392
|
+
<TsxSection
|
|
393
|
+
title="AlertX"
|
|
394
|
+
code={`{isMultipleActionActive && (
|
|
395
|
+
<AlertX alert="multipleAction" variant="primary">
|
|
396
|
+
<AlertXTitle onClose={() => setIsMultipleActionActive(false)}>
|
|
397
|
+
A new update is available
|
|
398
|
+
</AlertXTitle>
|
|
399
|
+
<AlertXDescription
|
|
400
|
+
skipLabel="Skip this update"
|
|
401
|
+
installLabel="Install now"
|
|
402
|
+
onSkip={() => console.log('skipped')}
|
|
403
|
+
onInstall={() => console.log('installed')}
|
|
404
|
+
>
|
|
405
|
+
Includes the at new dashboard View. Pages end exports will now load faster
|
|
406
|
+
</AlertXDescription>
|
|
407
|
+
</AlertX>
|
|
408
|
+
)}`}
|
|
409
|
+
/>
|
|
410
|
+
</div>
|
|
411
|
+
</div>
|
|
412
|
+
)
|
|
413
|
+
}
|