@trackany-device/components 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/package.json +185 -0
- package/src/assets/logo.png +0 -0
- package/src/assets/map/arrows/map-arrow-blue.png +0 -0
- package/src/assets/map/arrows/map-arrow-green.png +0 -0
- package/src/assets/map/arrows/map-arrow-purple.png +0 -0
- package/src/assets/map/arrows/map-arrow-red.png +0 -0
- package/src/assets/map/flags/flag-blue.png +0 -0
- package/src/assets/map/flags/flag-green.png +0 -0
- package/src/assets/map/flags/flag-red.png +0 -0
- package/src/assets/map/flags/flag-yellow.png +0 -0
- package/src/assets/map/pins/map-pin-blue.png +0 -0
- package/src/assets/map/pins/map-pin-green.png +0 -0
- package/src/assets/map/pins/map-pin-purple.png +0 -0
- package/src/assets/map/pins/map-pin-red.png +0 -0
- package/src/components/Card.tsx +9 -0
- package/src/components/alert-error.tsx +24 -0
- package/src/components/app-content.tsx +22 -0
- package/src/components/app-header.tsx +153 -0
- package/src/components/app-logo-icon.tsx +13 -0
- package/src/components/app-logo.tsx +21 -0
- package/src/components/app-shell.tsx +19 -0
- package/src/components/app-sidebar-header.tsx +68 -0
- package/src/components/app-sidebar.tsx +106 -0
- package/src/components/appearance-tabs.tsx +46 -0
- package/src/components/breadcrumbs.tsx +50 -0
- package/src/components/cms/blurred-image.tsx +111 -0
- package/src/components/cms/section-bg.tsx +473 -0
- package/src/components/cms/section-button.tsx +127 -0
- package/src/components/cms/sections/banner-5050-section.tsx +135 -0
- package/src/components/cms/sections/blogs-listing-section.tsx +270 -0
- package/src/components/cms/sections/cards-grid-section.tsx +185 -0
- package/src/components/cms/sections/contact-form-section.tsx +157 -0
- package/src/components/cms/sections/cta-section.tsx +101 -0
- package/src/components/cms/sections/featured-blog-slider-section.tsx +256 -0
- package/src/components/cms/sections/featured-products-grid-section.tsx +173 -0
- package/src/components/cms/sections/featured-solutions-grid-section.tsx +183 -0
- package/src/components/cms/sections/hero-section.tsx +180 -0
- package/src/components/cms/sections/solutions-with-filter-section.tsx +234 -0
- package/src/components/cms/sections/text-section.tsx +77 -0
- package/src/components/cutout-image.tsx +228 -0
- package/src/components/devices/devices-mini-map.tsx +275 -0
- package/src/components/docs/docs-shell.tsx +280 -0
- package/src/components/fleet-hero-animated.tsx +383 -0
- package/src/components/input-error.tsx +17 -0
- package/src/components/keenicons/assets/duotone/Read Me.txt +7 -0
- package/src/components/keenicons/assets/duotone/demo-files/demo.css +160 -0
- package/src/components/keenicons/assets/duotone/demo-files/demo.js +32 -0
- package/src/components/keenicons/assets/duotone/demo.html +12424 -0
- package/src/components/keenicons/assets/duotone/fonts/keenicons-duotone.svg +1109 -0
- package/src/components/keenicons/assets/duotone/fonts/keenicons-duotone.ttf +0 -0
- package/src/components/keenicons/assets/duotone/fonts/keenicons-duotone.woff +0 -0
- package/src/components/keenicons/assets/duotone/selection.json +17313 -0
- package/src/components/keenicons/assets/duotone/style.css +4931 -0
- package/src/components/keenicons/assets/filled/Read Me.txt +7 -0
- package/src/components/keenicons/assets/filled/demo-files/demo.css +160 -0
- package/src/components/keenicons/assets/filled/demo-files/demo.js +32 -0
- package/src/components/keenicons/assets/filled/demo.html +12370 -0
- package/src/components/keenicons/assets/filled/fonts/keenicons-filled.svg +1082 -0
- package/src/components/keenicons/assets/filled/fonts/keenicons-filled.ttf +0 -0
- package/src/components/keenicons/assets/filled/fonts/keenicons-filled.woff +0 -0
- package/src/components/keenicons/assets/filled/selection.json +17096 -0
- package/src/components/keenicons/assets/filled/style.css +4769 -0
- package/src/components/keenicons/assets/outline/Read Me.txt +7 -0
- package/src/components/keenicons/assets/outline/demo-files/demo.css +160 -0
- package/src/components/keenicons/assets/outline/demo-files/demo.js +32 -0
- package/src/components/keenicons/assets/outline/demo.html +11356 -0
- package/src/components/keenicons/assets/outline/fonts/keenicons-outline.svg +575 -0
- package/src/components/keenicons/assets/outline/fonts/keenicons-outline.ttf +0 -0
- package/src/components/keenicons/assets/outline/fonts/keenicons-outline.woff +0 -0
- package/src/components/keenicons/assets/outline/selection.json +13054 -0
- package/src/components/keenicons/assets/outline/style.css +1721 -0
- package/src/components/keenicons/assets/solid/Read Me.txt +7 -0
- package/src/components/keenicons/assets/solid/demo-files/demo.css +160 -0
- package/src/components/keenicons/assets/solid/demo-files/demo.js +32 -0
- package/src/components/keenicons/assets/solid/demo.html +11356 -0
- package/src/components/keenicons/assets/solid/fonts/keenicons-solid.svg +575 -0
- package/src/components/keenicons/assets/solid/fonts/keenicons-solid.ttf +0 -0
- package/src/components/keenicons/assets/solid/fonts/keenicons-solid.woff +0 -0
- package/src/components/keenicons/assets/solid/selection.json +13048 -0
- package/src/components/keenicons/assets/solid/style.css +1721 -0
- package/src/components/keenicons/assets/styles.css +4 -0
- package/src/components/keenicons/index.ts +2 -0
- package/src/components/keenicons/keenicons.tsx +16 -0
- package/src/components/keenicons/types.ts +7 -0
- package/src/components/nav-footer.tsx +49 -0
- package/src/components/nav-main.tsx +53 -0
- package/src/components/nav-user.tsx +59 -0
- package/src/components/notification-bell.tsx +190 -0
- package/src/components/products/product-card.tsx +159 -0
- package/src/components/text-link.tsx +23 -0
- package/src/components/ui/accordion-menu.tsx +322 -0
- package/src/components/ui/accordion.tsx +133 -0
- package/src/components/ui/alert-dialog.tsx +82 -0
- package/src/components/ui/alert.tsx +63 -0
- package/src/components/ui/avatar-group.tsx +129 -0
- package/src/components/ui/avatar.tsx +67 -0
- package/src/components/ui/badge.tsx +230 -0
- package/src/components/ui/breadcrumb.tsx +88 -0
- package/src/components/ui/button.tsx +412 -0
- package/src/components/ui/calendar.tsx +56 -0
- package/src/components/ui/card.tsx +147 -0
- package/src/components/ui/chart.tsx +290 -0
- package/src/components/ui/checkbox.tsx +47 -0
- package/src/components/ui/code.tsx +45 -0
- package/src/components/ui/collapsible.tsx +31 -0
- package/src/components/ui/command-palette.tsx +189 -0
- package/src/components/ui/command.tsx +138 -0
- package/src/components/ui/cookie-banner.tsx +220 -0
- package/src/components/ui/copy-button.tsx +60 -0
- package/src/components/ui/data-grid-column-filter.tsx +124 -0
- package/src/components/ui/data-grid-column-header.tsx +284 -0
- package/src/components/ui/data-grid-column-visibility.tsx +38 -0
- package/src/components/ui/data-grid-pagination.tsx +206 -0
- package/src/components/ui/data-grid-table-dnd-rows.tsx +147 -0
- package/src/components/ui/data-grid-table-dnd.tsx +175 -0
- package/src/components/ui/data-grid-table.tsx +500 -0
- package/src/components/ui/data-grid.tsx +193 -0
- package/src/components/ui/data-list.tsx +76 -0
- package/src/components/ui/datefield.tsx +91 -0
- package/src/components/ui/dialog.tsx +139 -0
- package/src/components/ui/divider.tsx +41 -0
- package/src/components/ui/drawer.tsx +59 -0
- package/src/components/ui/dropdown-menu.tsx +224 -0
- package/src/components/ui/empty-state.tsx +54 -0
- package/src/components/ui/file-upload.tsx +152 -0
- package/src/components/ui/form.tsx +88 -0
- package/src/components/ui/icon.tsx +14 -0
- package/src/components/ui/input-otp.tsx +71 -0
- package/src/components/ui/input.tsx +155 -0
- package/src/components/ui/kbd.tsx +26 -0
- package/src/components/ui/label.tsx +31 -0
- package/src/components/ui/navigation-menu.tsx +168 -0
- package/src/components/ui/pagination.tsx +37 -0
- package/src/components/ui/placeholder-pattern.tsx +21 -0
- package/src/components/ui/popover.tsx +50 -0
- package/src/components/ui/progress.tsx +65 -0
- package/src/components/ui/radio-group.tsx +73 -0
- package/src/components/ui/resizable.tsx +39 -0
- package/src/components/ui/scroll-area.tsx +50 -0
- package/src/components/ui/select.tsx +234 -0
- package/src/components/ui/separator.tsx +24 -0
- package/src/components/ui/sheet.tsx +147 -0
- package/src/components/ui/sidebar.tsx +721 -0
- package/src/components/ui/skeleton.tsx +15 -0
- package/src/components/ui/slider.tsx +35 -0
- package/src/components/ui/sonner.tsx +28 -0
- package/src/components/ui/sortable.tsx +724 -0
- package/src/components/ui/spinner.tsx +17 -0
- package/src/components/ui/stat-card.tsx +82 -0
- package/src/components/ui/stepper.tsx +410 -0
- package/src/components/ui/switch.tsx +68 -0
- package/src/components/ui/table.tsx +42 -0
- package/src/components/ui/tabs.tsx +196 -0
- package/src/components/ui/timeline.tsx +90 -0
- package/src/components/ui/toggle-group.tsx +73 -0
- package/src/components/ui/toggle.tsx +45 -0
- package/src/components/ui/tooltip.tsx +55 -0
- package/src/components/user-info.tsx +33 -0
- package/src/components/user-menu-content.tsx +53 -0
- package/src/components/web/SiteFooter.tsx +154 -0
- package/src/components/web/SiteHeader.tsx +159 -0
- package/src/components/workflows/workflow-canvas.tsx +321 -0
- package/src/controls/Blockquote.tsx +25 -0
- package/src/controls/Button.tsx +101 -0
- package/src/controls/Checkbox.tsx +29 -0
- package/src/controls/DateField.tsx +37 -0
- package/src/controls/FormField.tsx +20 -0
- package/src/controls/Heading.tsx +28 -0
- package/src/controls/Input.tsx +21 -0
- package/src/controls/Label.tsx +18 -0
- package/src/controls/Paragraph.tsx +39 -0
- package/src/controls/PasswordInput.tsx +40 -0
- package/src/controls/RadioGroup.tsx +70 -0
- package/src/controls/Select.tsx +24 -0
- package/src/controls/Slider.tsx +33 -0
- package/src/controls/Switch.tsx +31 -0
- package/src/controls/Textarea.tsx +22 -0
- package/src/elements/ConfirmPasswordForm.tsx +43 -0
- package/src/elements/DeviceStatusBadge.tsx +38 -0
- package/src/elements/DriverCard.tsx +67 -0
- package/src/elements/ForgotPasswordForm.tsx +64 -0
- package/src/elements/IncidentCard.tsx +67 -0
- package/src/elements/LoginForm.tsx +100 -0
- package/src/elements/OtpForm.tsx +71 -0
- package/src/elements/RegisterForm.tsx +150 -0
- package/src/elements/ResetPasswordForm.tsx +72 -0
- package/src/elements/SmsChallengeForm.tsx +104 -0
- package/src/elements/VehicleCard.tsx +73 -0
- package/src/elements/VerifyEmailForm.tsx +39 -0
- package/src/hooks/use-appearance.tsx +117 -0
- package/src/hooks/use-applied-theme.ts +98 -0
- package/src/hooks/use-clipboard.ts +34 -0
- package/src/hooks/use-current-url.ts +83 -0
- package/src/hooks/use-dark-mode.ts +48 -0
- package/src/hooks/use-flash-toast.ts +29 -0
- package/src/hooks/use-initials.tsx +24 -0
- package/src/hooks/use-mobile-navigation.ts +12 -0
- package/src/hooks/use-mobile.tsx +38 -0
- package/src/index.ts +408 -0
- package/src/layouts/AppLayout.tsx +60 -0
- package/src/layouts/AuthLayout.tsx +32 -0
- package/src/layouts/SettingsLayout.tsx +21 -0
- package/src/layouts/app/AIChatLayout.tsx +73 -0
- package/src/layouts/app/AsideSidebarLayout.tsx +3 -0
- package/src/layouts/app/CalendarSidebarLayout.tsx +69 -0
- package/src/layouts/app/CommunitiesNavbarLayout.tsx +3 -0
- package/src/layouts/app/DualNavbarSidebarLayout.tsx +3 -0
- package/src/layouts/app/FocusSidebarLayout.tsx +75 -0
- package/src/layouts/app/MailLayout.tsx +69 -0
- package/src/layouts/app/MegaMenuHeaderLayout.tsx +3 -0
- package/src/layouts/app/MegaMenuLayout.tsx +81 -0
- package/src/layouts/app/MegaMenuNavbarLayout.tsx +88 -0
- package/src/layouts/app/MegaMenuSearchNavbarLayout.tsx +3 -0
- package/src/layouts/app/NavbarCollapsibleLayout.tsx +88 -0
- package/src/layouts/app/NavbarCollapsibleLinksLayout.tsx +3 -0
- package/src/layouts/app/NavbarMinimalLayout.tsx +3 -0
- package/src/layouts/app/NavbarMinimalSidebarLayout.tsx +3 -0
- package/src/layouts/app/NavbarSidebarDashboardLayout.tsx +3 -0
- package/src/layouts/app/NavbarSidebarLayout.tsx +92 -0
- package/src/layouts/app/NavbarSimpleSidebarLayout.tsx +3 -0
- package/src/layouts/app/NavbarTitledSidebarLayout.tsx +3 -0
- package/src/layouts/app/PanelSidebarLayout.tsx +3 -0
- package/src/layouts/app/SearchNavbarSidebarLayout.tsx +3 -0
- package/src/layouts/app/SidebarBreadcrumbLayout.tsx +3 -0
- package/src/layouts/app/SidebarCleanLayout.tsx +3 -0
- package/src/layouts/app/SidebarCommunitiesLayout.tsx +3 -0
- package/src/layouts/app/SidebarContentLayout.tsx +3 -0
- package/src/layouts/app/SidebarDualMenuLayout.tsx +104 -0
- package/src/layouts/app/SidebarFixedLayout.tsx +166 -0
- package/src/layouts/app/SidebarFooterNavbarLayout.tsx +3 -0
- package/src/layouts/app/SidebarHeaderMenuLayout.tsx +3 -0
- package/src/layouts/app/SidebarMegaMenuLayout.tsx +4 -0
- package/src/layouts/app/SidebarMinimalLayout.tsx +70 -0
- package/src/layouts/app/SidebarMobileSearchLayout.tsx +3 -0
- package/src/layouts/app/SidebarMultiPanelLayout.tsx +3 -0
- package/src/layouts/app/SidebarPrimarySecondaryLayout.tsx +3 -0
- package/src/layouts/app/SidebarSearchHeaderLayout.tsx +103 -0
- package/src/layouts/app/SidebarSearchToolbarLayout.tsx +3 -0
- package/src/layouts/app/SidebarTabsDualLayout.tsx +3 -0
- package/src/layouts/app/SidebarTabsLayout.tsx +98 -0
- package/src/layouts/app/SidebarTreeLayout.tsx +3 -0
- package/src/layouts/app/SplitNavbarLayout.tsx +3 -0
- package/src/layouts/app/SplitSidebarDashboardLayout.tsx +3 -0
- package/src/layouts/app/SplitSidebarLayout.tsx +99 -0
- package/src/layouts/app/TopNavLayout.tsx +105 -0
- package/src/layouts/app/TopNavLinksLayout.tsx +3 -0
- package/src/layouts/app/WorkspaceBreadcrumbLayout.tsx +3 -0
- package/src/layouts/app/WorkspaceCommunitiesLayout.tsx +3 -0
- package/src/layouts/app/WorkspaceNavbarLayout.tsx +3 -0
- package/src/layouts/app/WorkspaceSidebarLayout.tsx +98 -0
- package/src/layouts/app/WorkspaceSidebarTitleLayout.tsx +3 -0
- package/src/layouts/app/app-header-layout.tsx +45 -0
- package/src/layouts/app/app-sidebar-layout.tsx +56 -0
- package/src/layouts/app/layout-context.tsx +44 -0
- package/src/layouts/app/layout-types.ts +47 -0
- package/src/layouts/app/partials/Footer.tsx +35 -0
- package/src/layouts/app/partials/HeaderTopbar.tsx +96 -0
- package/src/layouts/app/partials/Navbar.tsx +85 -0
- package/src/layouts/app/partials/Toolbar.tsx +47 -0
- package/src/layouts/app-layout.tsx +29 -0
- package/src/layouts/auth/AuthBrandedLayout.tsx +58 -0
- package/src/layouts/auth/AuthCardLayout.tsx +31 -0
- package/src/layouts/auth/AuthCenteredLayout.tsx +41 -0
- package/src/layouts/auth/AuthClassicLayout.tsx +41 -0
- package/src/layouts/auth/AuthSimpleLayout.tsx +33 -0
- package/src/layouts/auth/AuthSplitLayout.tsx +89 -0
- package/src/layouts/web-app-layout.tsx +162 -0
- package/src/layouts/web-layout.tsx +23 -0
- package/src/lib/datetime.ts +188 -0
- package/src/lib/google-maps-loader.ts +99 -0
- package/src/lib/location.ts +127 -0
- package/src/lib/lucide-icon-map.ts +132 -0
- package/src/lib/map-markers.ts +124 -0
- package/src/lib/map-styles.ts +351 -0
- package/src/lib/utils.ts +11 -0
- package/src/platform/adapters/default.tsx +156 -0
- package/src/platform/adapters/inertia.tsx +88 -0
- package/src/platform/adapters/nextjs.ts +86 -0
- package/src/platform/context.tsx +106 -0
- package/src/platform/index.ts +27 -0
- package/src/platform/types.ts +105 -0
- package/src/styles/layouts/sidebar-fixed.css +161 -0
- package/src/styles/themes.css +583 -0
- package/src/types/assets.d.ts +5 -0
- package/src/types/auth.ts +25 -0
- package/src/types/global.d.ts +13 -0
- package/src/types/index.ts +9 -0
- package/src/types/navigation.ts +15 -0
- package/src/types/ui.ts +32 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Loader2Icon } from 'lucide-react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
|
|
6
|
+
function Spinner({ className, ...props }: React.ComponentProps<'svg'>) {
|
|
7
|
+
return (
|
|
8
|
+
<Loader2Icon
|
|
9
|
+
role="status"
|
|
10
|
+
aria-label="Loading"
|
|
11
|
+
className={cn('size-4 animate-spin', className)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { Spinner };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { LucideIcon } from 'lucide-react';
|
|
2
|
+
import { ArrowDownRight, ArrowRight, ArrowUpRight } from 'lucide-react';
|
|
3
|
+
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
label: string;
|
|
8
|
+
value: number | string;
|
|
9
|
+
delta?: string;
|
|
10
|
+
deltaType?: 'up' | 'down' | 'neutral';
|
|
11
|
+
icon?: LucideIcon;
|
|
12
|
+
description?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const DELTA_STYLES: Record<NonNullable<Props['deltaType']>, string> = {
|
|
17
|
+
up: 'text-success',
|
|
18
|
+
down: 'text-destructive',
|
|
19
|
+
neutral: 'text-muted-foreground',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const DELTA_ICONS: Record<NonNullable<Props['deltaType']>, LucideIcon> = {
|
|
23
|
+
up: ArrowUpRight,
|
|
24
|
+
down: ArrowDownRight,
|
|
25
|
+
neutral: ArrowRight,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function StatCard({
|
|
29
|
+
label,
|
|
30
|
+
value,
|
|
31
|
+
delta,
|
|
32
|
+
deltaType = 'neutral',
|
|
33
|
+
icon: Icon,
|
|
34
|
+
description,
|
|
35
|
+
className,
|
|
36
|
+
}: Props) {
|
|
37
|
+
const DeltaIcon = DELTA_ICONS[deltaType];
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
className={cn(
|
|
42
|
+
'rounded-xl border bg-card p-5 shadow-sm transition-colors',
|
|
43
|
+
className,
|
|
44
|
+
)}
|
|
45
|
+
>
|
|
46
|
+
<div className="flex items-start justify-between gap-3">
|
|
47
|
+
<p className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
|
|
48
|
+
{label}
|
|
49
|
+
</p>
|
|
50
|
+
{Icon && (
|
|
51
|
+
<span
|
|
52
|
+
className="bg-primary-subtle text-primary flex h-9 w-9 items-center justify-center rounded-lg"
|
|
53
|
+
aria-hidden="true"
|
|
54
|
+
>
|
|
55
|
+
<Icon className="size-4" />
|
|
56
|
+
</span>
|
|
57
|
+
)}
|
|
58
|
+
</div>
|
|
59
|
+
<p className="font-display mt-3 text-3xl font-semibold leading-none text-foreground">
|
|
60
|
+
{typeof value === 'number' ? value.toLocaleString() : value}
|
|
61
|
+
</p>
|
|
62
|
+
{(delta || description) && (
|
|
63
|
+
<div className="mt-3 flex items-center gap-2 text-xs">
|
|
64
|
+
{delta && (
|
|
65
|
+
<span
|
|
66
|
+
className={cn(
|
|
67
|
+
'inline-flex items-center gap-1 font-medium',
|
|
68
|
+
DELTA_STYLES[deltaType],
|
|
69
|
+
)}
|
|
70
|
+
>
|
|
71
|
+
<DeltaIcon aria-hidden="true" className="size-3.5" />
|
|
72
|
+
{delta}
|
|
73
|
+
</span>
|
|
74
|
+
)}
|
|
75
|
+
{description && (
|
|
76
|
+
<span className="text-muted-foreground">{description}</span>
|
|
77
|
+
)}
|
|
78
|
+
</div>
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { createContext, useContext } from 'react';
|
|
7
|
+
import { cn } from '../../lib/utils';
|
|
8
|
+
|
|
9
|
+
// Types
|
|
10
|
+
type StepperOrientation = 'horizontal' | 'vertical';
|
|
11
|
+
type StepState = 'active' | 'completed' | 'inactive' | 'loading';
|
|
12
|
+
type StepIndicators = {
|
|
13
|
+
active?: React.ReactNode;
|
|
14
|
+
completed?: React.ReactNode;
|
|
15
|
+
inactive?: React.ReactNode;
|
|
16
|
+
loading?: React.ReactNode;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
interface StepperContextValue {
|
|
20
|
+
activeStep: number;
|
|
21
|
+
setActiveStep: (step: number) => void;
|
|
22
|
+
stepsCount: number;
|
|
23
|
+
orientation: StepperOrientation;
|
|
24
|
+
registerTrigger: (node: HTMLButtonElement | null) => void;
|
|
25
|
+
triggerNodes: HTMLButtonElement[];
|
|
26
|
+
focusNext: (currentIdx: number) => void;
|
|
27
|
+
focusPrev: (currentIdx: number) => void;
|
|
28
|
+
focusFirst: () => void;
|
|
29
|
+
focusLast: () => void;
|
|
30
|
+
indicators: StepIndicators;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface StepItemContextValue {
|
|
34
|
+
step: number;
|
|
35
|
+
state: StepState;
|
|
36
|
+
isDisabled: boolean;
|
|
37
|
+
isLoading: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const StepperContext = createContext<StepperContextValue | undefined>(undefined);
|
|
41
|
+
const StepItemContext = createContext<StepItemContextValue | undefined>(undefined);
|
|
42
|
+
|
|
43
|
+
function useStepper() {
|
|
44
|
+
const ctx = useContext(StepperContext);
|
|
45
|
+
if (!ctx) throw new Error('useStepper must be used within a Stepper');
|
|
46
|
+
return ctx;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function useStepItem() {
|
|
50
|
+
const ctx = useContext(StepItemContext);
|
|
51
|
+
if (!ctx) throw new Error('useStepItem must be used within a StepperItem');
|
|
52
|
+
return ctx;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface StepperProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
56
|
+
defaultValue?: number;
|
|
57
|
+
value?: number;
|
|
58
|
+
onValueChange?: (value: number) => void;
|
|
59
|
+
orientation?: StepperOrientation;
|
|
60
|
+
indicators?: StepIndicators;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function Stepper({
|
|
64
|
+
defaultValue = 1,
|
|
65
|
+
value,
|
|
66
|
+
onValueChange,
|
|
67
|
+
orientation = 'horizontal',
|
|
68
|
+
className,
|
|
69
|
+
children,
|
|
70
|
+
indicators = {},
|
|
71
|
+
...props
|
|
72
|
+
}: StepperProps) {
|
|
73
|
+
const [activeStep, setActiveStep] = React.useState(defaultValue);
|
|
74
|
+
const [triggerNodes, setTriggerNodes] = React.useState<HTMLButtonElement[]>([]);
|
|
75
|
+
|
|
76
|
+
// Register/unregister triggers
|
|
77
|
+
const registerTrigger = React.useCallback((node: HTMLButtonElement | null) => {
|
|
78
|
+
setTriggerNodes((prev) => {
|
|
79
|
+
if (node && !prev.includes(node)) {
|
|
80
|
+
return [...prev, node];
|
|
81
|
+
} else if (!node && prev.includes(node!)) {
|
|
82
|
+
return prev.filter((n) => n !== node);
|
|
83
|
+
} else {
|
|
84
|
+
return prev;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}, []);
|
|
88
|
+
|
|
89
|
+
const handleSetActiveStep = React.useCallback(
|
|
90
|
+
(step: number) => {
|
|
91
|
+
if (value === undefined) {
|
|
92
|
+
setActiveStep(step);
|
|
93
|
+
}
|
|
94
|
+
onValueChange?.(step);
|
|
95
|
+
},
|
|
96
|
+
[value, onValueChange],
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const currentStep = value ?? activeStep;
|
|
100
|
+
|
|
101
|
+
// Keyboard navigation logic
|
|
102
|
+
const focusTrigger = (idx: number) => {
|
|
103
|
+
if (triggerNodes[idx]) triggerNodes[idx].focus();
|
|
104
|
+
};
|
|
105
|
+
const focusNext = (currentIdx: number) => focusTrigger((currentIdx + 1) % triggerNodes.length);
|
|
106
|
+
const focusPrev = (currentIdx: number) => focusTrigger((currentIdx - 1 + triggerNodes.length) % triggerNodes.length);
|
|
107
|
+
const focusFirst = () => focusTrigger(0);
|
|
108
|
+
const focusLast = () => focusTrigger(triggerNodes.length - 1);
|
|
109
|
+
|
|
110
|
+
// Context value
|
|
111
|
+
const contextValue = React.useMemo<StepperContextValue>(
|
|
112
|
+
() => ({
|
|
113
|
+
activeStep: currentStep,
|
|
114
|
+
setActiveStep: handleSetActiveStep,
|
|
115
|
+
stepsCount: React.Children.toArray(children).filter(
|
|
116
|
+
(child): child is React.ReactElement =>
|
|
117
|
+
React.isValidElement(child) && (child.type as { displayName?: string }).displayName === 'StepperItem',
|
|
118
|
+
).length,
|
|
119
|
+
orientation,
|
|
120
|
+
registerTrigger,
|
|
121
|
+
focusNext,
|
|
122
|
+
focusPrev,
|
|
123
|
+
focusFirst,
|
|
124
|
+
focusLast,
|
|
125
|
+
triggerNodes,
|
|
126
|
+
indicators,
|
|
127
|
+
}),
|
|
128
|
+
[currentStep, handleSetActiveStep, children, orientation, registerTrigger, triggerNodes],
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<StepperContext.Provider value={contextValue}>
|
|
133
|
+
<div
|
|
134
|
+
role="tablist"
|
|
135
|
+
aria-orientation={orientation}
|
|
136
|
+
data-slot="stepper"
|
|
137
|
+
className={cn('w-full', className)}
|
|
138
|
+
data-orientation={orientation}
|
|
139
|
+
{...props}
|
|
140
|
+
>
|
|
141
|
+
{children}
|
|
142
|
+
</div>
|
|
143
|
+
</StepperContext.Provider>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
interface StepperItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
148
|
+
step: number;
|
|
149
|
+
completed?: boolean;
|
|
150
|
+
disabled?: boolean;
|
|
151
|
+
loading?: boolean;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function StepperItem({
|
|
155
|
+
step,
|
|
156
|
+
completed = false,
|
|
157
|
+
disabled = false,
|
|
158
|
+
loading = false,
|
|
159
|
+
className,
|
|
160
|
+
children,
|
|
161
|
+
...props
|
|
162
|
+
}: StepperItemProps) {
|
|
163
|
+
const { activeStep } = useStepper();
|
|
164
|
+
|
|
165
|
+
const state: StepState = completed || step < activeStep ? 'completed' : activeStep === step ? 'active' : 'inactive';
|
|
166
|
+
|
|
167
|
+
const isLoading = loading && step === activeStep;
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<StepItemContext.Provider value={{ step, state, isDisabled: disabled, isLoading }}>
|
|
171
|
+
<div
|
|
172
|
+
data-slot="stepper-item"
|
|
173
|
+
className={cn(
|
|
174
|
+
'group/step flex items-center justify-center group-data-[orientation=horizontal]/stepper-nav:flex-row group-data-[orientation=vertical]/stepper-nav:flex-col not-last:flex-1',
|
|
175
|
+
className,
|
|
176
|
+
)}
|
|
177
|
+
data-state={state}
|
|
178
|
+
{...(isLoading ? { 'data-loading': true } : {})}
|
|
179
|
+
{...props}
|
|
180
|
+
>
|
|
181
|
+
{children}
|
|
182
|
+
</div>
|
|
183
|
+
</StepItemContext.Provider>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
interface StepperTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
188
|
+
asChild?: boolean;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function StepperTrigger({ asChild = false, className, children, tabIndex, ...props }: StepperTriggerProps) {
|
|
192
|
+
const { state, isLoading } = useStepItem();
|
|
193
|
+
const stepperCtx = useStepper();
|
|
194
|
+
const { setActiveStep, activeStep, registerTrigger, triggerNodes, focusNext, focusPrev, focusFirst, focusLast } =
|
|
195
|
+
stepperCtx;
|
|
196
|
+
const { step, isDisabled } = useStepItem();
|
|
197
|
+
const isSelected = activeStep === step;
|
|
198
|
+
const id = `stepper-tab-${step}`;
|
|
199
|
+
const panelId = `stepper-panel-${step}`;
|
|
200
|
+
|
|
201
|
+
// Register this trigger for keyboard navigation
|
|
202
|
+
const btnRef = React.useRef<HTMLButtonElement>(null);
|
|
203
|
+
React.useEffect(() => {
|
|
204
|
+
if (btnRef.current) {
|
|
205
|
+
registerTrigger(btnRef.current);
|
|
206
|
+
}
|
|
207
|
+
}, [btnRef.current]);
|
|
208
|
+
|
|
209
|
+
// Find our index among triggers for navigation
|
|
210
|
+
const myIdx = React.useMemo(
|
|
211
|
+
() => triggerNodes.findIndex((n: HTMLButtonElement) => n === btnRef.current),
|
|
212
|
+
[triggerNodes, btnRef.current],
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
const handleKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>) => {
|
|
216
|
+
switch (e.key) {
|
|
217
|
+
case 'ArrowRight':
|
|
218
|
+
case 'ArrowDown':
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
if (myIdx !== -1 && focusNext) focusNext(myIdx);
|
|
221
|
+
break;
|
|
222
|
+
case 'ArrowLeft':
|
|
223
|
+
case 'ArrowUp':
|
|
224
|
+
e.preventDefault();
|
|
225
|
+
if (myIdx !== -1 && focusPrev) focusPrev(myIdx);
|
|
226
|
+
break;
|
|
227
|
+
case 'Home':
|
|
228
|
+
e.preventDefault();
|
|
229
|
+
if (focusFirst) focusFirst();
|
|
230
|
+
break;
|
|
231
|
+
case 'End':
|
|
232
|
+
e.preventDefault();
|
|
233
|
+
if (focusLast) focusLast();
|
|
234
|
+
break;
|
|
235
|
+
case 'Enter':
|
|
236
|
+
case ' ':
|
|
237
|
+
e.preventDefault();
|
|
238
|
+
setActiveStep(step);
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
if (asChild) {
|
|
244
|
+
return (
|
|
245
|
+
<span data-slot="stepper-trigger" data-state={state} className={className}>
|
|
246
|
+
{children}
|
|
247
|
+
</span>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return (
|
|
252
|
+
<button
|
|
253
|
+
ref={btnRef}
|
|
254
|
+
role="tab"
|
|
255
|
+
id={id}
|
|
256
|
+
aria-selected={isSelected}
|
|
257
|
+
aria-controls={panelId}
|
|
258
|
+
tabIndex={typeof tabIndex === 'number' ? tabIndex : isSelected ? 0 : -1}
|
|
259
|
+
data-slot="stepper-trigger"
|
|
260
|
+
data-state={state}
|
|
261
|
+
data-loading={isLoading}
|
|
262
|
+
className={cn(
|
|
263
|
+
'cursor-pointer focus-visible:border-ring focus-visible:ring-ring/50 inline-flex items-center gap-3 rounded-full outline-none focus-visible:z-10 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-60',
|
|
264
|
+
className,
|
|
265
|
+
)}
|
|
266
|
+
onClick={() => setActiveStep(step)}
|
|
267
|
+
onKeyDown={handleKeyDown}
|
|
268
|
+
disabled={isDisabled}
|
|
269
|
+
{...props}
|
|
270
|
+
>
|
|
271
|
+
{children}
|
|
272
|
+
</button>
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function StepperIndicator({ children, className }: React.ComponentProps<'div'>) {
|
|
277
|
+
const { state, isLoading } = useStepItem();
|
|
278
|
+
const { indicators } = useStepper();
|
|
279
|
+
|
|
280
|
+
return (
|
|
281
|
+
<div
|
|
282
|
+
data-slot="stepper-indicator"
|
|
283
|
+
data-state={state}
|
|
284
|
+
className={cn(
|
|
285
|
+
'relative flex items-center overflow-hidden justify-center size-6 shrink-0 border-background bg-accent text-accent-foreground rounded-full text-xs data-[state=completed]:bg-primary data-[state=completed]:text-primary-foreground data-[state=active]:bg-primary data-[state=active]:text-primary-foreground',
|
|
286
|
+
className,
|
|
287
|
+
)}
|
|
288
|
+
>
|
|
289
|
+
<div className="absolute">
|
|
290
|
+
{indicators &&
|
|
291
|
+
((isLoading && indicators.loading) ||
|
|
292
|
+
(state === 'completed' && indicators.completed) ||
|
|
293
|
+
(state === 'active' && indicators.active) ||
|
|
294
|
+
(state === 'inactive' && indicators.inactive))
|
|
295
|
+
? (isLoading && indicators.loading) ||
|
|
296
|
+
(state === 'completed' && indicators.completed) ||
|
|
297
|
+
(state === 'active' && indicators.active) ||
|
|
298
|
+
(state === 'inactive' && indicators.inactive)
|
|
299
|
+
: children}
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function StepperSeparator({ className }: React.ComponentProps<'div'>) {
|
|
306
|
+
const { state } = useStepItem();
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
<div
|
|
310
|
+
data-slot="stepper-separator"
|
|
311
|
+
data-state={state}
|
|
312
|
+
className={cn(
|
|
313
|
+
'm-0.5 rounded-full bg-muted group-data-[orientation=vertical]/stepper-nav:h-12 group-data-[orientation=vertical]/stepper-nav:w-0.5 group-data-[orientation=horizontal]/stepper-nav:h-0.5 group-data-[orientation=horizontal]/stepper-nav:flex-1',
|
|
314
|
+
className,
|
|
315
|
+
)}
|
|
316
|
+
/>
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function StepperTitle({ children, className }: React.ComponentProps<'h3'>) {
|
|
321
|
+
const { state } = useStepItem();
|
|
322
|
+
|
|
323
|
+
return (
|
|
324
|
+
<h3 data-slot="stepper-title" data-state={state} className={cn('text-sm font-medium leading-none', className)}>
|
|
325
|
+
{children}
|
|
326
|
+
</h3>
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function StepperDescription({ children, className }: React.ComponentProps<'div'>) {
|
|
331
|
+
const { state } = useStepItem();
|
|
332
|
+
|
|
333
|
+
return (
|
|
334
|
+
<div data-slot="stepper-description" data-state={state} className={cn('text-sm text-muted-foreground', className)}>
|
|
335
|
+
{children}
|
|
336
|
+
</div>
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function StepperNav({ children, className }: React.ComponentProps<'nav'>) {
|
|
341
|
+
const { activeStep, orientation } = useStepper();
|
|
342
|
+
|
|
343
|
+
return (
|
|
344
|
+
<nav
|
|
345
|
+
data-slot="stepper-nav"
|
|
346
|
+
data-state={activeStep}
|
|
347
|
+
data-orientation={orientation}
|
|
348
|
+
className={cn(
|
|
349
|
+
'group/stepper-nav inline-flex data-[orientation=horizontal]:w-full data-[orientation=horizontal]:flex-row data-[orientation=vertical]:flex-col',
|
|
350
|
+
className,
|
|
351
|
+
)}
|
|
352
|
+
>
|
|
353
|
+
{children}
|
|
354
|
+
</nav>
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function StepperPanel({ children, className }: React.ComponentProps<'div'>) {
|
|
359
|
+
const { activeStep } = useStepper();
|
|
360
|
+
|
|
361
|
+
return (
|
|
362
|
+
<div data-slot="stepper-panel" data-state={activeStep} className={cn('w-full', className)}>
|
|
363
|
+
{children}
|
|
364
|
+
</div>
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
interface StepperContentProps extends React.ComponentProps<'div'> {
|
|
369
|
+
value: number;
|
|
370
|
+
forceMount?: boolean;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function StepperContent({ value, forceMount, children, className }: StepperContentProps) {
|
|
374
|
+
const { activeStep } = useStepper();
|
|
375
|
+
const isActive = value === activeStep;
|
|
376
|
+
|
|
377
|
+
if (!forceMount && !isActive) {
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return (
|
|
382
|
+
<div
|
|
383
|
+
data-slot="stepper-content"
|
|
384
|
+
data-state={activeStep}
|
|
385
|
+
className={cn('w-full', className, !isActive && forceMount && 'hidden')}
|
|
386
|
+
hidden={!isActive && forceMount}
|
|
387
|
+
>
|
|
388
|
+
{children}
|
|
389
|
+
</div>
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export {
|
|
394
|
+
useStepper,
|
|
395
|
+
useStepItem,
|
|
396
|
+
Stepper,
|
|
397
|
+
StepperItem,
|
|
398
|
+
StepperTrigger,
|
|
399
|
+
StepperIndicator,
|
|
400
|
+
StepperSeparator,
|
|
401
|
+
StepperTitle,
|
|
402
|
+
StepperDescription,
|
|
403
|
+
StepperPanel,
|
|
404
|
+
StepperContent,
|
|
405
|
+
StepperNav,
|
|
406
|
+
type StepperProps,
|
|
407
|
+
type StepperItemProps,
|
|
408
|
+
type StepperTriggerProps,
|
|
409
|
+
type StepperContentProps,
|
|
410
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
5
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
|
|
8
|
+
const SwitchContext = React.createContext<{ permanent: boolean }>({ permanent: false });
|
|
9
|
+
|
|
10
|
+
const switchVariants = cva(
|
|
11
|
+
'relative peer inline-flex shrink-0 cursor-pointer items-center rounded-full transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=unchecked]:bg-input',
|
|
12
|
+
{
|
|
13
|
+
variants: {
|
|
14
|
+
shape: { pill: 'rounded-full', square: 'rounded-md' },
|
|
15
|
+
size: { sm: 'h-5 w-8', md: 'h-6 w-10', lg: 'h-8 w-14', xl: 'h-9 w-16' },
|
|
16
|
+
permanent: { true: 'bg-input', false: 'data-[state=checked]:bg-primary' },
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: { shape: 'pill', permanent: false, size: 'md' },
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const switchThumbVariants = cva(
|
|
23
|
+
'pointer-events-none block bg-white w-1/2 h-[calc(100%-4px)] shadow-lg ring-0 transition-transform start-0 data-[state=unchecked]:translate-x-[2px] data-[state=checked]:translate-x-[calc(100%-2px)] rtl:data-[state=unchecked]:-translate-x-[2px] rtl:data-[state=checked]:-translate-x-[calc(100%-2px)]',
|
|
24
|
+
{
|
|
25
|
+
variants: {
|
|
26
|
+
shape: { pill: 'rounded-full', square: 'rounded-md' },
|
|
27
|
+
size: { sm: '', md: '', lg: '', xl: '' },
|
|
28
|
+
},
|
|
29
|
+
defaultVariants: { shape: 'pill', size: 'md' },
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
function SwitchWrapper({
|
|
34
|
+
className,
|
|
35
|
+
children,
|
|
36
|
+
permanent = false,
|
|
37
|
+
...props
|
|
38
|
+
}: React.HTMLAttributes<HTMLDivElement> & { permanent?: boolean }) {
|
|
39
|
+
return (
|
|
40
|
+
<SwitchContext.Provider value={{ permanent }}>
|
|
41
|
+
<div data-slot="switch-wrapper" className={cn('relative inline-flex items-center', className)} {...props}>
|
|
42
|
+
{children}
|
|
43
|
+
</div>
|
|
44
|
+
</SwitchContext.Provider>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function Switch({
|
|
49
|
+
className,
|
|
50
|
+
thumbClassName = '',
|
|
51
|
+
shape,
|
|
52
|
+
size,
|
|
53
|
+
...props
|
|
54
|
+
}: React.ComponentProps<typeof SwitchPrimitive.Root> &
|
|
55
|
+
VariantProps<typeof switchVariants> & { thumbClassName?: string }) {
|
|
56
|
+
const { permanent } = React.useContext(SwitchContext);
|
|
57
|
+
return (
|
|
58
|
+
<SwitchPrimitive.Root
|
|
59
|
+
data-slot="switch"
|
|
60
|
+
className={cn(switchVariants({ shape, size, permanent }), className)}
|
|
61
|
+
{...props}
|
|
62
|
+
>
|
|
63
|
+
<SwitchPrimitive.Thumb className={cn(switchThumbVariants({ shape, size }), thumbClassName)} />
|
|
64
|
+
</SwitchPrimitive.Root>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { Switch, SwitchWrapper };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
|
|
6
|
+
function Table({ className, ...props }: React.HTMLAttributes<HTMLTableElement>) {
|
|
7
|
+
return (
|
|
8
|
+
<div data-slot="table-wrapper" className="relative w-full overflow-auto">
|
|
9
|
+
<table data-slot="table" className={cn('w-full caption-bottom text-foreground text-sm', className)} {...props} />
|
|
10
|
+
</div>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function TableHeader({ className, ...props }: React.HTMLAttributes<HTMLTableSectionElement>) {
|
|
15
|
+
return <thead data-slot="table-header" className={cn('[&_tr]:border-b', className)} {...props} />;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function TableBody({ className, ...props }: React.HTMLAttributes<HTMLTableSectionElement>) {
|
|
19
|
+
return <tbody data-slot="table-body" className={cn('[&_tr:last-child]:border-0', className)} {...props} />;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function TableFooter({ className, ...props }: React.HTMLAttributes<HTMLTableSectionElement>) {
|
|
23
|
+
return <tfoot data-slot="table-footer" className={cn('border-t bg-muted/50 font-medium last:[&>tr]:border-b-0', className)} {...props} />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function TableRow({ className, ...props }: React.HTMLAttributes<HTMLTableRowElement>) {
|
|
27
|
+
return <tr data-slot="table-row" className={cn('border-b transition-colors [&:has(td):hover]:bg-muted/50 data-[state=selected]:bg-muted', className)} {...props} />;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function TableHead({ className, ...props }: React.ThHTMLAttributes<HTMLTableCellElement>) {
|
|
31
|
+
return <th data-slot="table-head" className={cn('h-12 px-4 text-left rtl:text-right align-middle font-normal text-muted-foreground [&:has([role=checkbox])]:pe-0', className)} {...props} />;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function TableCell({ className, ...props }: React.TdHTMLAttributes<HTMLTableCellElement>) {
|
|
35
|
+
return <td data-slot="table-cell" className={cn('p-4 align-middle [&:has([role=checkbox])]:pe-0', className)} {...props} />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function TableCaption({ className, ...props }: React.HTMLAttributes<HTMLTableCaptionElement>) {
|
|
39
|
+
return <caption data-slot="table-caption" className={cn('mt-4 text-sm text-muted-foreground', className)} {...props} />;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow };
|