@mdguggenbichler/slugbase-core 0.0.4 → 0.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/frontend/index.tsx +3 -3
- package/frontend/public/favicon.svg +1 -0
- package/frontend/public/slugbase_icon_blue.svg +1 -0
- package/frontend/public/slugbase_icon_white.png +0 -0
- package/frontend/public/slugbase_icon_white.svg +1 -0
- package/frontend/src/App.tsx +179 -0
- package/frontend/src/api/client.ts +134 -0
- package/frontend/src/components/AppSidebar.tsx +214 -0
- package/frontend/src/components/EmptyState.tsx +33 -0
- package/frontend/src/components/Favicon.tsx +76 -0
- package/frontend/src/components/FilterChips.tsx +60 -0
- package/frontend/src/components/FolderIcon.tsx +207 -0
- package/frontend/src/components/GlobalSearch.tsx +275 -0
- package/frontend/src/components/Layout.tsx +60 -0
- package/frontend/src/components/PageHeader.tsx +31 -0
- package/frontend/src/components/ScopeSegmentedControl.tsx +42 -0
- package/frontend/src/components/SentryDebug.tsx +32 -0
- package/frontend/src/components/StatCard.tsx +66 -0
- package/frontend/src/components/TopBar.tsx +63 -0
- package/frontend/src/components/UserDropdown.tsx +86 -0
- package/frontend/src/components/admin/AdminAI.tsx +207 -0
- package/frontend/src/components/admin/AdminOIDCProviders.tsx +183 -0
- package/frontend/src/components/admin/AdminSettings.tsx +413 -0
- package/frontend/src/components/admin/AdminTeams.tsx +177 -0
- package/frontend/src/components/admin/AdminUsers.tsx +225 -0
- package/frontend/src/components/bookmarks/BookmarkCard.tsx +312 -0
- package/frontend/src/components/bookmarks/BookmarkListItem.tsx +159 -0
- package/frontend/src/components/bookmarks/BookmarkTableView.tsx +419 -0
- package/frontend/src/components/bookmarks/BulkActionModals.tsx +162 -0
- package/frontend/src/components/bookmarks/FilterChips.tsx +5 -0
- package/frontend/src/components/modals/BookmarkModal.tsx +493 -0
- package/frontend/src/components/modals/FolderModal.tsx +306 -0
- package/frontend/src/components/modals/ImportModal.tsx +232 -0
- package/frontend/src/components/modals/OIDCProviderModal.tsx +284 -0
- package/frontend/src/components/modals/SharingModal.tsx +96 -0
- package/frontend/src/components/modals/TagModal.tsx +101 -0
- package/frontend/src/components/modals/TeamAssignmentModal.tsx +354 -0
- package/frontend/src/components/modals/TeamModal.tsx +117 -0
- package/frontend/src/components/modals/UserModal.tsx +225 -0
- package/frontend/src/components/profile/CreateTokenModal.tsx +172 -0
- package/frontend/src/components/sharing/ShareResourceDialog.tsx +422 -0
- package/frontend/src/components/ui/Autocomplete.tsx +155 -0
- package/frontend/src/components/ui/Button.tsx +68 -0
- package/frontend/src/components/ui/ConfirmDialog.tsx +79 -0
- package/frontend/src/components/ui/FormFieldWrapper.tsx +36 -0
- package/frontend/src/components/ui/ModalFooterActions.tsx +49 -0
- package/frontend/src/components/ui/ModalSection.tsx +34 -0
- package/frontend/src/components/ui/PageLoadingSkeleton.tsx +24 -0
- package/frontend/src/components/ui/Select.tsx +61 -0
- package/frontend/src/components/ui/SharingField.tsx +298 -0
- package/frontend/src/components/ui/Toast.tsx +47 -0
- package/frontend/src/components/ui/Tooltip.tsx +21 -0
- package/frontend/src/components/ui/alert-dialog.tsx +139 -0
- package/frontend/src/components/ui/badge.tsx +36 -0
- package/frontend/src/components/ui/button-base.tsx +57 -0
- package/frontend/src/components/ui/card.tsx +76 -0
- package/frontend/src/components/ui/command.tsx +161 -0
- package/frontend/src/components/ui/dialog.tsx +120 -0
- package/frontend/src/components/ui/dropdown-menu.tsx +199 -0
- package/frontend/src/components/ui/input.tsx +22 -0
- package/frontend/src/components/ui/label.tsx +24 -0
- package/frontend/src/components/ui/popover.tsx +33 -0
- package/frontend/src/components/ui/progress.tsx +26 -0
- package/frontend/src/components/ui/scroll-area.tsx +48 -0
- package/frontend/src/components/ui/select-base.tsx +159 -0
- package/frontend/src/components/ui/separator.tsx +29 -0
- package/frontend/src/components/ui/sheet.tsx +140 -0
- package/frontend/src/components/ui/sidebar.tsx +783 -0
- package/frontend/src/components/ui/skeleton.tsx +15 -0
- package/frontend/src/components/ui/sonner.tsx +46 -0
- package/frontend/src/components/ui/switch.tsx +28 -0
- package/frontend/src/components/ui/table.tsx +120 -0
- package/frontend/src/components/ui/tooltip-base.tsx +30 -0
- package/frontend/src/config/api.ts +16 -0
- package/frontend/src/config/mode.ts +6 -0
- package/frontend/src/contexts/AppConfigContext.tsx +39 -0
- package/frontend/src/contexts/AuthContext.tsx +137 -0
- package/frontend/src/contexts/SearchCommandContext.tsx +28 -0
- package/frontend/src/hooks/use-mobile.tsx +19 -0
- package/frontend/src/hooks/useConfirmDialog.ts +63 -0
- package/frontend/src/hooks/useMarketingTheme.ts +47 -0
- package/frontend/src/i18n.ts +39 -0
- package/frontend/src/index.css +117 -0
- package/frontend/src/instrument.ts +20 -0
- package/frontend/src/lib/utils.ts +6 -0
- package/frontend/src/locales/de.json +899 -0
- package/frontend/src/locales/en.json +937 -0
- package/frontend/src/locales/es.json +884 -0
- package/frontend/src/locales/fr.json +550 -0
- package/frontend/src/locales/it.json +535 -0
- package/frontend/src/locales/ja.json +535 -0
- package/frontend/src/locales/nl.json +550 -0
- package/frontend/src/locales/pl.json +535 -0
- package/frontend/src/locales/pt.json +535 -0
- package/frontend/src/locales/ru.json +535 -0
- package/frontend/src/locales/zh.json +535 -0
- package/frontend/src/main.tsx +44 -0
- package/frontend/src/pages/Bookmarks.tsx +1004 -0
- package/frontend/src/pages/Dashboard.tsx +427 -0
- package/frontend/src/pages/Folders.tsx +578 -0
- package/frontend/src/pages/GoPreferences.tsx +134 -0
- package/frontend/src/pages/Login.tsx +196 -0
- package/frontend/src/pages/PasswordReset.tsx +242 -0
- package/frontend/src/pages/Profile.tsx +593 -0
- package/frontend/src/pages/SearchEngineGuide.tsx +135 -0
- package/frontend/src/pages/Setup.tsx +210 -0
- package/frontend/src/pages/Signup.tsx +199 -0
- package/frontend/src/pages/Tags.tsx +421 -0
- package/frontend/src/pages/VerifyEmail.tsx +254 -0
- package/frontend/src/pages/admin/AdminAIPage.tsx +5 -0
- package/frontend/src/pages/admin/AdminLayout.tsx +40 -0
- package/frontend/src/pages/admin/AdminMembersPage.tsx +5 -0
- package/frontend/src/pages/admin/AdminOIDCPage.tsx +5 -0
- package/frontend/src/pages/admin/AdminSettingsPage.tsx +5 -0
- package/frontend/src/pages/admin/AdminTeamsPage.tsx +5 -0
- package/frontend/src/utils/favicon.ts +36 -0
- package/frontend/src/utils/formatRelativeTime.ts +37 -0
- package/frontend/src/utils/safeHref.ts +31 -0
- package/frontend/src/vite-env.d.ts +10 -0
- package/package.json +9 -1
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { useAuth } from '../../contexts/AuthContext';
|
|
4
|
+
import api from '../../api/client';
|
|
5
|
+
import { Popover, PopoverContent, PopoverTrigger } from './popover';
|
|
6
|
+
import { Switch } from './switch';
|
|
7
|
+
import { Label } from './label';
|
|
8
|
+
import { Badge } from './badge';
|
|
9
|
+
import { Input } from './input';
|
|
10
|
+
import { ScrollArea } from './scroll-area';
|
|
11
|
+
import Button from './Button';
|
|
12
|
+
import { Users, User, Search, X, Check, UserPlus } from 'lucide-react';
|
|
13
|
+
import { cn } from '@/lib/utils';
|
|
14
|
+
|
|
15
|
+
interface Team {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface UserType {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
email: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SharingValue {
|
|
28
|
+
user_ids: string[];
|
|
29
|
+
team_ids: string[];
|
|
30
|
+
share_all_teams: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface SharingFieldProps {
|
|
34
|
+
value: SharingValue;
|
|
35
|
+
onChange: (value: SharingValue) => void;
|
|
36
|
+
teams: Team[];
|
|
37
|
+
allowTeamSharing: boolean;
|
|
38
|
+
label?: string;
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function SharingField({
|
|
43
|
+
value,
|
|
44
|
+
onChange,
|
|
45
|
+
teams,
|
|
46
|
+
allowTeamSharing,
|
|
47
|
+
label,
|
|
48
|
+
disabled = false,
|
|
49
|
+
}: SharingFieldProps) {
|
|
50
|
+
const { t } = useTranslation();
|
|
51
|
+
const { user } = useAuth();
|
|
52
|
+
const [popoverOpen, setPopoverOpen] = useState(false);
|
|
53
|
+
const [allUsers, setAllUsers] = useState<UserType[]>([]);
|
|
54
|
+
const [userSearchQuery, setUserSearchQuery] = useState('');
|
|
55
|
+
const [teamSearchQuery, setTeamSearchQuery] = useState('');
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (popoverOpen || value.user_ids.length > 0) {
|
|
59
|
+
loadUsers();
|
|
60
|
+
}
|
|
61
|
+
}, [popoverOpen, value.user_ids.length]);
|
|
62
|
+
|
|
63
|
+
async function loadUsers() {
|
|
64
|
+
try {
|
|
65
|
+
const response = await api.get('/admin/users');
|
|
66
|
+
const users = Array.isArray(response.data) ? response.data : [];
|
|
67
|
+
setAllUsers(users.filter((u: UserType) => u.id !== user?.id));
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error('Failed to load users:', error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const filteredUsers = allUsers.filter((u) => {
|
|
74
|
+
if (!userSearchQuery.trim()) return true;
|
|
75
|
+
const query = userSearchQuery.toLowerCase();
|
|
76
|
+
return u.name.toLowerCase().includes(query) || u.email.toLowerCase().includes(query);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const filteredTeams = teams.filter((t) => {
|
|
80
|
+
if (!teamSearchQuery.trim()) return true;
|
|
81
|
+
const query = teamSearchQuery.toLowerCase();
|
|
82
|
+
return t.name.toLowerCase().includes(query) || (t.description && t.description.toLowerCase().includes(query));
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const selectedTeams = teams.filter((t) => value.team_ids.includes(t.id));
|
|
86
|
+
const selectedUsers = allUsers.filter((u) => value.user_ids.includes(u.id));
|
|
87
|
+
const hasSelected = value.share_all_teams || selectedTeams.length > 0 || selectedUsers.length > 0;
|
|
88
|
+
|
|
89
|
+
function handleShareAllTeamsChange(checked: boolean) {
|
|
90
|
+
onChange({
|
|
91
|
+
...value,
|
|
92
|
+
share_all_teams: checked,
|
|
93
|
+
team_ids: checked ? [] : value.team_ids,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function toggleTeam(teamId: string) {
|
|
98
|
+
if (value.share_all_teams) return;
|
|
99
|
+
onChange({
|
|
100
|
+
...value,
|
|
101
|
+
team_ids: value.team_ids.includes(teamId)
|
|
102
|
+
? value.team_ids.filter((id) => id !== teamId)
|
|
103
|
+
: [...value.team_ids, teamId],
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function toggleUser(userId: string) {
|
|
108
|
+
onChange({
|
|
109
|
+
...value,
|
|
110
|
+
user_ids: value.user_ids.includes(userId)
|
|
111
|
+
? value.user_ids.filter((id) => id !== userId)
|
|
112
|
+
: [...value.user_ids, userId],
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function removeTeam(teamId: string) {
|
|
117
|
+
onChange({
|
|
118
|
+
...value,
|
|
119
|
+
team_ids: value.team_ids.filter((id) => id !== teamId),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function removeUser(userId: string) {
|
|
124
|
+
onChange({
|
|
125
|
+
...value,
|
|
126
|
+
user_ids: value.user_ids.filter((id) => id !== userId),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<div className="space-y-3">
|
|
132
|
+
{label && (
|
|
133
|
+
<Label className="text-sm font-medium">{label}</Label>
|
|
134
|
+
)}
|
|
135
|
+
|
|
136
|
+
{allowTeamSharing && (
|
|
137
|
+
<div className="flex items-center justify-between rounded-lg border p-3">
|
|
138
|
+
<div>
|
|
139
|
+
<p className="text-sm font-medium">{t('bookmarks.shareAllTeams')}</p>
|
|
140
|
+
<p className="text-xs text-muted-foreground">
|
|
141
|
+
{t('bookmarks.shareAllTeamsDescription')}
|
|
142
|
+
</p>
|
|
143
|
+
</div>
|
|
144
|
+
<Switch
|
|
145
|
+
checked={value.share_all_teams}
|
|
146
|
+
onCheckedChange={handleShareAllTeamsChange}
|
|
147
|
+
disabled={disabled}
|
|
148
|
+
/>
|
|
149
|
+
</div>
|
|
150
|
+
)}
|
|
151
|
+
|
|
152
|
+
<div className="flex flex-wrap gap-2">
|
|
153
|
+
{value.share_all_teams && (
|
|
154
|
+
<Badge variant="secondary">All teams</Badge>
|
|
155
|
+
)}
|
|
156
|
+
{selectedTeams.map((team) => (
|
|
157
|
+
<Badge
|
|
158
|
+
key={team.id}
|
|
159
|
+
variant="secondary"
|
|
160
|
+
className="pr-1 gap-1.5"
|
|
161
|
+
>
|
|
162
|
+
{team.name}
|
|
163
|
+
<button
|
|
164
|
+
type="button"
|
|
165
|
+
onClick={() => removeTeam(team.id)}
|
|
166
|
+
disabled={disabled}
|
|
167
|
+
className="rounded-full hover:bg-secondary/80 p-0.5 transition-colors focus-visible:ring-2 focus-visible:ring-ring"
|
|
168
|
+
aria-label={t('common.remove')}
|
|
169
|
+
>
|
|
170
|
+
<X className="h-3.5 w-3.5" />
|
|
171
|
+
</button>
|
|
172
|
+
</Badge>
|
|
173
|
+
))}
|
|
174
|
+
{selectedUsers.map((u) => (
|
|
175
|
+
<Badge
|
|
176
|
+
key={u.id}
|
|
177
|
+
variant="secondary"
|
|
178
|
+
className="pr-1 gap-1.5"
|
|
179
|
+
>
|
|
180
|
+
{u.name}
|
|
181
|
+
<button
|
|
182
|
+
type="button"
|
|
183
|
+
onClick={() => removeUser(u.id)}
|
|
184
|
+
disabled={disabled}
|
|
185
|
+
className="rounded-full hover:bg-secondary/80 p-0.5 transition-colors focus-visible:ring-2 focus-visible:ring-ring"
|
|
186
|
+
aria-label={t('common.remove')}
|
|
187
|
+
>
|
|
188
|
+
<X className="h-3.5 w-3.5" />
|
|
189
|
+
</button>
|
|
190
|
+
</Badge>
|
|
191
|
+
))}
|
|
192
|
+
</div>
|
|
193
|
+
|
|
194
|
+
<Popover open={popoverOpen} onOpenChange={setPopoverOpen}>
|
|
195
|
+
<PopoverTrigger asChild>
|
|
196
|
+
<Button
|
|
197
|
+
type="button"
|
|
198
|
+
variant="outline"
|
|
199
|
+
size="sm"
|
|
200
|
+
disabled={disabled}
|
|
201
|
+
className="h-8"
|
|
202
|
+
>
|
|
203
|
+
<UserPlus className="h-4 w-4" />
|
|
204
|
+
{hasSelected
|
|
205
|
+
? value.share_all_teams
|
|
206
|
+
? t('bookmarks.shareAllTeams')
|
|
207
|
+
: t('bookmarks.sharingSummary', {
|
|
208
|
+
teamCount: selectedTeams.length,
|
|
209
|
+
teams: selectedTeams.length === 1 ? t('common.team') : t('common.teams'),
|
|
210
|
+
userCount: selectedUsers.length,
|
|
211
|
+
users: selectedUsers.length === 1 ? t('common.user') : t('common.users'),
|
|
212
|
+
})
|
|
213
|
+
: t('bookmarks.shareWithTeams')}
|
|
214
|
+
</Button>
|
|
215
|
+
</PopoverTrigger>
|
|
216
|
+
<PopoverContent className="w-80 max-h-[400px] p-0" align="start">
|
|
217
|
+
<div className="p-2 space-y-3">
|
|
218
|
+
{allowTeamSharing && !value.share_all_teams && (
|
|
219
|
+
<>
|
|
220
|
+
<div>
|
|
221
|
+
<p className="text-xs font-medium text-muted-foreground mb-2 flex items-center gap-1.5">
|
|
222
|
+
<Users className="h-3.5 w-3.5" />
|
|
223
|
+
{t('bookmarks.shareWithTeams')}
|
|
224
|
+
</p>
|
|
225
|
+
<div className="relative mb-2">
|
|
226
|
+
<Search className="absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground" />
|
|
227
|
+
<Input
|
|
228
|
+
placeholder={t('admin.searchTeams')}
|
|
229
|
+
value={teamSearchQuery}
|
|
230
|
+
onChange={(e) => setTeamSearchQuery(e.target.value)}
|
|
231
|
+
className="pl-8 h-8"
|
|
232
|
+
/>
|
|
233
|
+
</div>
|
|
234
|
+
<ScrollArea className="max-h-32">
|
|
235
|
+
<div className="flex flex-wrap gap-1.5">
|
|
236
|
+
{filteredTeams.map((team) => (
|
|
237
|
+
<button
|
|
238
|
+
key={team.id}
|
|
239
|
+
type="button"
|
|
240
|
+
onClick={() => toggleTeam(team.id)}
|
|
241
|
+
className={cn(
|
|
242
|
+
"inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-colors",
|
|
243
|
+
value.team_ids.includes(team.id)
|
|
244
|
+
? "bg-primary text-primary-foreground"
|
|
245
|
+
: "bg-secondary hover:bg-secondary/80"
|
|
246
|
+
)}
|
|
247
|
+
>
|
|
248
|
+
{value.team_ids.includes(team.id) && <Check className="h-3 w-3" />}
|
|
249
|
+
{team.name}
|
|
250
|
+
</button>
|
|
251
|
+
))}
|
|
252
|
+
</div>
|
|
253
|
+
</ScrollArea>
|
|
254
|
+
</div>
|
|
255
|
+
</>
|
|
256
|
+
)}
|
|
257
|
+
|
|
258
|
+
<div>
|
|
259
|
+
<p className="text-xs font-medium text-muted-foreground mb-2 flex items-center gap-1.5">
|
|
260
|
+
<User className="h-3.5 w-3.5" />
|
|
261
|
+
{t('bookmarks.shareWithUsers')}
|
|
262
|
+
</p>
|
|
263
|
+
<div className="relative mb-2">
|
|
264
|
+
<Search className="absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground" />
|
|
265
|
+
<Input
|
|
266
|
+
placeholder={t('admin.searchUsers')}
|
|
267
|
+
value={userSearchQuery}
|
|
268
|
+
onChange={(e) => setUserSearchQuery(e.target.value)}
|
|
269
|
+
className="pl-8 h-8"
|
|
270
|
+
/>
|
|
271
|
+
</div>
|
|
272
|
+
<ScrollArea className="max-h-32">
|
|
273
|
+
<div className="space-y-1">
|
|
274
|
+
{filteredUsers
|
|
275
|
+
.filter((u) => !value.user_ids.includes(u.id))
|
|
276
|
+
.map((u) => (
|
|
277
|
+
<button
|
|
278
|
+
key={u.id}
|
|
279
|
+
type="button"
|
|
280
|
+
onClick={() => toggleUser(u.id)}
|
|
281
|
+
className="w-full flex items-center justify-between px-2 py-1.5 rounded text-sm hover:bg-accent text-left"
|
|
282
|
+
>
|
|
283
|
+
<div>
|
|
284
|
+
<p className="font-medium">{u.name}</p>
|
|
285
|
+
<p className="text-xs text-muted-foreground">{u.email}</p>
|
|
286
|
+
</div>
|
|
287
|
+
<UserPlus className="h-3.5 w-3.5" />
|
|
288
|
+
</button>
|
|
289
|
+
))}
|
|
290
|
+
</div>
|
|
291
|
+
</ScrollArea>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
</PopoverContent>
|
|
295
|
+
</Popover>
|
|
296
|
+
</div>
|
|
297
|
+
);
|
|
298
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { toast as sonnerToast } from 'sonner';
|
|
2
|
+
import { Toaster } from './sonner';
|
|
3
|
+
|
|
4
|
+
export type ToastVariant = 'success' | 'error' | 'info' | 'warning';
|
|
5
|
+
|
|
6
|
+
export interface Toast {
|
|
7
|
+
id: string;
|
|
8
|
+
message: string;
|
|
9
|
+
variant: ToastVariant;
|
|
10
|
+
duration?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function useToast() {
|
|
14
|
+
const showToast = (
|
|
15
|
+
message: string,
|
|
16
|
+
variant: ToastVariant = 'info',
|
|
17
|
+
duration = 3000
|
|
18
|
+
) => {
|
|
19
|
+
const options = duration > 0 ? { duration } : { duration: Infinity };
|
|
20
|
+
switch (variant) {
|
|
21
|
+
case 'success':
|
|
22
|
+
sonnerToast.success(message, options);
|
|
23
|
+
break;
|
|
24
|
+
case 'error':
|
|
25
|
+
sonnerToast.error(message, options);
|
|
26
|
+
break;
|
|
27
|
+
case 'warning':
|
|
28
|
+
sonnerToast.warning(message, options);
|
|
29
|
+
break;
|
|
30
|
+
case 'info':
|
|
31
|
+
default:
|
|
32
|
+
sonnerToast.info(message, options);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return { showToast };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function ToastProvider({ children }: { children: React.ReactNode }) {
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
{children}
|
|
44
|
+
<Toaster />
|
|
45
|
+
</>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Tooltip as ShadcnTooltip,
|
|
4
|
+
TooltipContent,
|
|
5
|
+
TooltipTrigger,
|
|
6
|
+
} from './tooltip-base';
|
|
7
|
+
|
|
8
|
+
interface TooltipProps {
|
|
9
|
+
content: React.ReactNode;
|
|
10
|
+
children: React.ReactElement;
|
|
11
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function Tooltip({ content, children, position = 'top' }: TooltipProps) {
|
|
15
|
+
return (
|
|
16
|
+
<ShadcnTooltip>
|
|
17
|
+
<TooltipTrigger asChild>{children}</TooltipTrigger>
|
|
18
|
+
<TooltipContent side={position}>{content}</TooltipContent>
|
|
19
|
+
</ShadcnTooltip>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/lib/utils"
|
|
5
|
+
import { buttonVariants } from "@/components/ui/button-base"
|
|
6
|
+
|
|
7
|
+
const AlertDialog = AlertDialogPrimitive.Root
|
|
8
|
+
|
|
9
|
+
const AlertDialogTrigger = AlertDialogPrimitive.Trigger
|
|
10
|
+
|
|
11
|
+
const AlertDialogPortal = AlertDialogPrimitive.Portal
|
|
12
|
+
|
|
13
|
+
const AlertDialogOverlay = React.forwardRef<
|
|
14
|
+
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
|
15
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
|
16
|
+
>(({ className, ...props }, ref) => (
|
|
17
|
+
<AlertDialogPrimitive.Overlay
|
|
18
|
+
className={cn(
|
|
19
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
20
|
+
className
|
|
21
|
+
)}
|
|
22
|
+
{...props}
|
|
23
|
+
ref={ref}
|
|
24
|
+
/>
|
|
25
|
+
))
|
|
26
|
+
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
|
|
27
|
+
|
|
28
|
+
const AlertDialogContent = React.forwardRef<
|
|
29
|
+
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
|
30
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
|
31
|
+
>(({ className, ...props }, ref) => (
|
|
32
|
+
<AlertDialogPortal>
|
|
33
|
+
<AlertDialogOverlay />
|
|
34
|
+
<AlertDialogPrimitive.Content
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn(
|
|
37
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
38
|
+
className
|
|
39
|
+
)}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
</AlertDialogPortal>
|
|
43
|
+
))
|
|
44
|
+
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
|
|
45
|
+
|
|
46
|
+
const AlertDialogHeader = ({
|
|
47
|
+
className,
|
|
48
|
+
...props
|
|
49
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
50
|
+
<div
|
|
51
|
+
className={cn(
|
|
52
|
+
"flex flex-col space-y-2 text-center sm:text-left",
|
|
53
|
+
className
|
|
54
|
+
)}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
)
|
|
58
|
+
AlertDialogHeader.displayName = "AlertDialogHeader"
|
|
59
|
+
|
|
60
|
+
const AlertDialogFooter = ({
|
|
61
|
+
className,
|
|
62
|
+
...props
|
|
63
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
64
|
+
<div
|
|
65
|
+
className={cn(
|
|
66
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
67
|
+
className
|
|
68
|
+
)}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
71
|
+
)
|
|
72
|
+
AlertDialogFooter.displayName = "AlertDialogFooter"
|
|
73
|
+
|
|
74
|
+
const AlertDialogTitle = React.forwardRef<
|
|
75
|
+
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
|
76
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
|
77
|
+
>(({ className, ...props }, ref) => (
|
|
78
|
+
<AlertDialogPrimitive.Title
|
|
79
|
+
ref={ref}
|
|
80
|
+
className={cn("text-lg font-semibold", className)}
|
|
81
|
+
{...props}
|
|
82
|
+
/>
|
|
83
|
+
))
|
|
84
|
+
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName
|
|
85
|
+
|
|
86
|
+
const AlertDialogDescription = React.forwardRef<
|
|
87
|
+
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
|
88
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
|
89
|
+
>(({ className, ...props }, ref) => (
|
|
90
|
+
<AlertDialogPrimitive.Description
|
|
91
|
+
ref={ref}
|
|
92
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
93
|
+
{...props}
|
|
94
|
+
/>
|
|
95
|
+
))
|
|
96
|
+
AlertDialogDescription.displayName =
|
|
97
|
+
AlertDialogPrimitive.Description.displayName
|
|
98
|
+
|
|
99
|
+
const AlertDialogAction = React.forwardRef<
|
|
100
|
+
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
|
101
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
|
102
|
+
>(({ className, ...props }, ref) => (
|
|
103
|
+
<AlertDialogPrimitive.Action
|
|
104
|
+
ref={ref}
|
|
105
|
+
className={cn(buttonVariants(), className)}
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
))
|
|
109
|
+
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
|
|
110
|
+
|
|
111
|
+
const AlertDialogCancel = React.forwardRef<
|
|
112
|
+
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
|
113
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
|
114
|
+
>(({ className, ...props }, ref) => (
|
|
115
|
+
<AlertDialogPrimitive.Cancel
|
|
116
|
+
ref={ref}
|
|
117
|
+
className={cn(
|
|
118
|
+
buttonVariants({ variant: "outline" }),
|
|
119
|
+
"mt-2 sm:mt-0",
|
|
120
|
+
className
|
|
121
|
+
)}
|
|
122
|
+
{...props}
|
|
123
|
+
/>
|
|
124
|
+
))
|
|
125
|
+
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName
|
|
126
|
+
|
|
127
|
+
export {
|
|
128
|
+
AlertDialog,
|
|
129
|
+
AlertDialogPortal,
|
|
130
|
+
AlertDialogOverlay,
|
|
131
|
+
AlertDialogTrigger,
|
|
132
|
+
AlertDialogContent,
|
|
133
|
+
AlertDialogHeader,
|
|
134
|
+
AlertDialogFooter,
|
|
135
|
+
AlertDialogTitle,
|
|
136
|
+
AlertDialogDescription,
|
|
137
|
+
AlertDialogAction,
|
|
138
|
+
AlertDialogCancel,
|
|
139
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/lib/utils"
|
|
5
|
+
|
|
6
|
+
const badgeVariants = cva(
|
|
7
|
+
"inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default:
|
|
12
|
+
"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
|
|
13
|
+
secondary:
|
|
14
|
+
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
15
|
+
destructive:
|
|
16
|
+
"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
|
|
17
|
+
outline: "text-foreground",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
variant: "default",
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
export interface BadgeProps
|
|
27
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
28
|
+
VariantProps<typeof badgeVariants> {}
|
|
29
|
+
|
|
30
|
+
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
31
|
+
return (
|
|
32
|
+
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { Badge, badgeVariants }
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot"
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default:
|
|
13
|
+
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
14
|
+
destructive:
|
|
15
|
+
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
16
|
+
outline:
|
|
17
|
+
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
18
|
+
secondary:
|
|
19
|
+
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
20
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
21
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
default: "h-9 px-4 py-2",
|
|
25
|
+
sm: "h-8 rounded-md px-3 text-xs",
|
|
26
|
+
lg: "h-10 rounded-md px-8",
|
|
27
|
+
icon: "h-9 w-9",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
defaultVariants: {
|
|
31
|
+
variant: "default",
|
|
32
|
+
size: "default",
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
export interface ButtonProps
|
|
38
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
39
|
+
VariantProps<typeof buttonVariants> {
|
|
40
|
+
asChild?: boolean
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
44
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
45
|
+
const Comp = asChild ? Slot : "button"
|
|
46
|
+
return (
|
|
47
|
+
<Comp
|
|
48
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
49
|
+
ref={ref}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
Button.displayName = "Button"
|
|
56
|
+
|
|
57
|
+
export { Button, buttonVariants }
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils"
|
|
4
|
+
|
|
5
|
+
const Card = React.forwardRef<
|
|
6
|
+
HTMLDivElement,
|
|
7
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
8
|
+
>(({ className, ...props }, ref) => (
|
|
9
|
+
<div
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn(
|
|
12
|
+
"rounded-xl border bg-card text-card-foreground shadow",
|
|
13
|
+
className
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
))
|
|
18
|
+
Card.displayName = "Card"
|
|
19
|
+
|
|
20
|
+
const CardHeader = React.forwardRef<
|
|
21
|
+
HTMLDivElement,
|
|
22
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
23
|
+
>(({ className, ...props }, ref) => (
|
|
24
|
+
<div
|
|
25
|
+
ref={ref}
|
|
26
|
+
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
))
|
|
30
|
+
CardHeader.displayName = "CardHeader"
|
|
31
|
+
|
|
32
|
+
const CardTitle = React.forwardRef<
|
|
33
|
+
HTMLDivElement,
|
|
34
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
35
|
+
>(({ className, ...props }, ref) => (
|
|
36
|
+
<div
|
|
37
|
+
ref={ref}
|
|
38
|
+
className={cn("font-semibold leading-none tracking-tight", className)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
))
|
|
42
|
+
CardTitle.displayName = "CardTitle"
|
|
43
|
+
|
|
44
|
+
const CardDescription = React.forwardRef<
|
|
45
|
+
HTMLDivElement,
|
|
46
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
47
|
+
>(({ className, ...props }, ref) => (
|
|
48
|
+
<div
|
|
49
|
+
ref={ref}
|
|
50
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
53
|
+
))
|
|
54
|
+
CardDescription.displayName = "CardDescription"
|
|
55
|
+
|
|
56
|
+
const CardContent = React.forwardRef<
|
|
57
|
+
HTMLDivElement,
|
|
58
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
59
|
+
>(({ className, ...props }, ref) => (
|
|
60
|
+
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
|
61
|
+
))
|
|
62
|
+
CardContent.displayName = "CardContent"
|
|
63
|
+
|
|
64
|
+
const CardFooter = React.forwardRef<
|
|
65
|
+
HTMLDivElement,
|
|
66
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
67
|
+
>(({ className, ...props }, ref) => (
|
|
68
|
+
<div
|
|
69
|
+
ref={ref}
|
|
70
|
+
className={cn("flex items-center p-6 pt-0", className)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
))
|
|
74
|
+
CardFooter.displayName = "CardFooter"
|
|
75
|
+
|
|
76
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
|