import React, { useState } from 'react';
import {
Button,
Input,
Label,
Card,
CardHeader,
CardTitle,
CardDescription,
CardContent,
CardFooter,
Tabs,
TabsContent,
TabsList,
TabsTrigger,
Badge,
Alert,
AlertDescription,
AlertTitle,
Checkbox,
RadioGroup,
RadioGroupItem,
Switch,
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
Textarea,
Progress,
Separator,
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
Slider,
Dialog,
DialogTrigger,
DialogContent,
DialogHeader,
DialogTitle,
DialogDescription,
DialogFooter,
AlertDialog,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogAction,
AlertDialogCancel,
Pagination,
PaginationContent,
PaginationItem,
PaginationLink,
PaginationNext,
PaginationPrevious,
PaginationEllipsis,
Stepper,
Step,
TreeView,
RichTextEditor,
usePagination,
useStepper,
} from 'xertica-ui/ui';
import { Header, Sidebar } from 'xertica-ui/layout';
import { useLayout, useTheme } from 'xertica-ui/hooks';
import { toast } from 'sonner';
import { Link } from 'react-router-dom';
import { Trans, useTranslation } from 'react-i18next';
import {
Settings,
User,
Mail,
Phone,
Calendar,
Search,
PanelLeft,
Home,
Users,
Plus,
Trash2,
Archive,
ArrowRightLeft,
FileEdit,
Clock,
Map,
} from 'lucide-react';
export function TemplateContent() {
const { t } = useTranslation();
// ── TreeView demo data (built inside the component so labels react to language switches) ──
const treeData = [
{
id: 'components',
label: t('templates.enhanced.treeView.nodes.components'),
children: [
{
id: 'ui',
label: t('templates.enhanced.treeView.nodes.ui'),
children: [
{ id: 'button', label: t('templates.enhanced.treeView.nodes.button') },
{ id: 'input', label: t('templates.enhanced.treeView.nodes.input') },
{ id: 'pagination', label: t('templates.enhanced.treeView.nodes.pagination') },
],
},
{
id: 'layout',
label: t('templates.enhanced.treeView.nodes.layout'),
children: [
{ id: 'sidebar', label: t('templates.enhanced.treeView.nodes.sidebar') },
{ id: 'header', label: t('templates.enhanced.treeView.nodes.header') },
],
},
],
},
{
id: 'hooks',
label: t('templates.enhanced.treeView.nodes.hooks'),
// Hook identifiers stay as code — not translated.
children: [
{ id: 'use-pagination', label: 'usePagination' },
{ id: 'use-stepper', label: 'useStepper' },
{ id: 'use-tree-view', label: 'useTreeView' },
],
},
];
const { sidebarExpanded, sidebarWidth } = useLayout();
const { disableDarkMode } = useTheme();
const [progress, setProgress] = useState(45);
const [sliderValue, setSliderValue] = useState([50]);
const [switchEnabled, setSwitchEnabled] = useState(false);
const [richText, setRichText] = useState('');
// Dialog demo inputs (controlled so they re-localise on language switch).
// Seeded lazily from `t(...)` so the initial value reflects the current
// language at first render; subsequent language switches don't overwrite
// user edits.
const [dialogName, setDialogName] = useState(() => t('templates.dialogs.nameDefaultValue'));
const [dialogUsername, setDialogUsername] = useState(() =>
t('templates.dialogs.usernameDefaultValue')
);
// ── Pagination demo ─────────────────────────────────────────────────────────
const { currentPage, totalPages, items, next, prev, goTo, canGoPrev, canGoNext } = usePagination({
totalItems: 120,
pageSize: 10,
});
// ── Stepper demo ────────────────────────────────────────────────────────────
const {
currentStep,
next: stepNext,
prev: stepPrev,
isFirstStep,
isLastStep,
} = useStepper({ totalSteps: 3 });
const handleFormSubmit = (e: React.FormEvent) => {
e.preventDefault();
toast.success(t('templates.formSubmitSuccess'));
};
return (
}
/>
{t('templates.title')}
{t('templates.subtitle')}
{/* Alert Examples */}
{t('templates.sections.alerts')}
{t('templates.alerts.infoTitle')}
{t('templates.alerts.infoDescription')}
{t('templates.alerts.errorTitle')}
{t('templates.alerts.errorDescription')}
{t('templates.alerts.successTitle')}
{t('templates.alerts.successDescription')}
{t('templates.alerts.warningTitle')}
{t('templates.alerts.warningDescription')}
{/* Cards & Tabs */}
{t('templates.sections.cardsAndTabs')}
{t('templates.tabs.overview')}
{t('templates.tabs.forms')}
{t('templates.tabs.data')}
{t('templates.tabs.settings')}
{/* Overview Tab */}
{t('stats.totalUsers')}
{t('stats.last30Days')}
{t('templates.overview.totalUsersDemoValue')}
+12%
{t('stats.totalRevenue')}
{t('stats.currentMonth')}
{t('templates.overview.revenueDemoValue')}
+8%
{t('stats.conversionRate')}
{t('stats.currentWeek')}
{t('templates.overview.conversionRateDemoValue')}
-2%
{t('templates.overview.progressTitle')}
{t('templates.overview.progressDescription')}
{t('templates.overview.projectProgress')}
{progress}%
setProgress(Math.max(0, progress - 10))}
>
-10%
setProgress(Math.min(100, progress + 10))}
>
+10%
{t('templates.overview.volume')}
{sliderValue[0]}%
{/* Forms Tab */}
{t('templates.forms.registrationTitle')}
{t('templates.forms.registrationDescription')}
{t('templates.forms.cancel')}
{t('templates.forms.createAccount')}
{/* Data Tab */}
{t('templates.data.title')}
{t('templates.data.description')}
{t('templates.data.headers.name')}
{t('templates.data.headers.email')}
{t('templates.data.headers.role')}
{t('templates.data.headers.status')}
{t('templates.data.headers.actions')}
Ana Silva
{`ana.silva@${t('templates.data.demoEmailDomain')}`}
{t('templates.data.roles.developerFemale')}
{t('templates.data.status.active')}
{t('templates.data.edit')}
Bruno Costa
{`bruno.costa@${t('templates.data.demoEmailDomain')}`}
{t('templates.data.roles.designer')}
{t('templates.data.status.active')}
{t('templates.data.edit')}
Carla Oliveira
{`carla.oliveira@${t('templates.data.demoEmailDomain')}`}
{t('templates.data.roles.manager')}
{t('templates.data.status.away')}
{t('templates.data.edit')}
Diego Santos
{`diego.santos@${t('templates.data.demoEmailDomain')}`}
{t('templates.data.roles.analyst')}
{t('templates.data.status.inactive')}
{t('templates.data.edit')}
{t('templates.data.showing', { count: 4, total: 127 })}
{t('templates.data.previous')}
{t('templates.data.next')}
{/* Settings Tab */}
{t('templates.settings.title')}
{t('templates.settings.description')}
{!disableDarkMode && (
<>
{t('templates.settings.darkMode')}
{t('templates.settings.darkModeDescription')}
>
)}
{t('templates.settings.emailNotifications')}
{t('templates.settings.emailNotificationsDescription')}
{t('templates.settings.pushNotifications')}
{t('templates.settings.pushNotificationsDescription')}
{t('templates.settings.language')}
{t('templates.settings.languages.ptBR')}
{t('templates.settings.languages.en')}
{t('templates.settings.languages.es')}
{t('templates.settings.timezone')}
{t('templates.settings.timezones.saoPaulo')}
{t('templates.settings.timezones.newYork')}
{t('templates.settings.timezones.london')}
{t('templates.settings.restoreDefaults')}
{t('templates.settings.saveChanges')}
{/* Button Variants */}
{t('templates.sections.buttons')}
{t('templates.buttons.title')}
{t('templates.buttons.description')}
{t('templates.buttons.variants')}
{t('templates.buttons.variantLabels.default')}
{t('templates.buttons.variantLabels.secondary')}
{t('templates.buttons.variantLabels.outline')}
{t('templates.buttons.variantLabels.ghost')}
{t('templates.buttons.variantLabels.link')}
{t('templates.buttons.variantLabels.destructive')}
{t('templates.buttons.sizes')}
{t('templates.buttons.sizeLabels.small')}
{t('templates.buttons.sizeLabels.default')}
{t('templates.buttons.sizeLabels.large')}
{t('templates.buttons.withIcons')}
{t('templates.buttons.profile')}
{t('templates.buttons.messages')}
{t('templates.buttons.schedule')}
{t('templates.buttons.states')}
{t('templates.buttons.disabled')}
{t('templates.buttons.outlineDisabled')}
{/* Badges */}
{t('templates.sections.badges')}
{t('templates.badges.title')}
{t('templates.badges.description')}
{t('templates.badges.labels.default')}
{t('templates.badges.labels.secondary')}
{t('templates.badges.labels.outline')}
{t('templates.badges.labels.destructive')}
{t('templates.badges.labels.success')}
{t('templates.badges.labels.warning')}
{t('templates.badges.labels.info')}
{/* Dialogs */}
{t('templates.sections.dialogs')}
{t('templates.dialogs.dialogTitle')}
{t('templates.dialogs.dialogDescription')}
{t('templates.dialogs.editProfile')}
{t('templates.dialogs.editProfile')}
{t('templates.dialogs.editProfileDescription')}
{t('templates.dialogs.update')}
{t('templates.dialogs.alertDialogTitle')}
{t('templates.dialogs.alertDialogDescription')}
{t('templates.dialogs.deleteAccount')}
{t('templates.dialogs.areYouSure')}
{t('templates.dialogs.deleteWarning')}
{t('templates.dialogs.cancel')}
{t('templates.dialogs.continue')}
{/* Sidebar Variations */}
{t('templates.sections.sidebarVariations')}
{t('templates.sidebar.title')}
{t('templates.sidebar.description')}
{t('templates.sidebar.assistantMode')}
{t('templates.sidebar.defaultMode')}
{}}
user={{ email: 'admin@xertica.com' }}
onLogout={() => toast(t('templates.sidebar.logoutToast'))}
location={{ pathname: '/assistant/current' }}
navigate={() => {}}
variant="assistant"
search={{
show: true,
placeholder: t('templates.sidebar.searchTopicsPlaceholder'),
}}
fixedArea={{
show: true,
content: (
{t('templates.sidebar.newConversation')}
),
}}
navigationGroups={[
{
id: 'recent',
label: t('templates.sidebar.recent'),
icon: Clock,
items: [
{
path: '/assistant/refatoracao',
label: t('templates.sidebar.items.sidebarRefactor'),
icon: PanelLeft,
description: t(
'templates.sidebar.items.sidebarRefactorDescription'
),
actions: [
{
label: t('templates.sidebar.actions.rename'),
icon: FileEdit,
onClick: () =>
toast(t('templates.sidebar.actions.renameToast')),
},
{
label: t('templates.sidebar.actions.move'),
icon: ArrowRightLeft,
children: [
{
label: t('templates.sidebar.actions.moveActive'),
onClick: () =>
toast(t('templates.sidebar.actions.moveActiveToast')),
},
{
label: t('templates.sidebar.actions.moveMonitoring'),
onClick: () =>
toast(
t('templates.sidebar.actions.moveMonitoringToast')
),
},
{
label: t('templates.sidebar.actions.moveArchive'),
onClick: () =>
toast(
t('templates.sidebar.actions.moveArchiveToast')
),
},
],
},
{
label: t('templates.sidebar.actions.clear'),
icon: Trash2,
onClick: () =>
toast(t('templates.sidebar.actions.clearToast')),
variant: 'destructive',
},
],
},
],
},
{
id: 'projects',
label: t('templates.sidebar.constructionMonitoring'),
icon: Map,
actions: [
{
label: t('templates.sidebar.actions.newCategory'),
icon: Plus,
onClick: () =>
toast(t('templates.sidebar.actions.newCategoryToast')),
},
{
label: t('templates.sidebar.actions.archiveGroup'),
icon: Archive,
onClick: () =>
toast(t('templates.sidebar.actions.archiveGroupToast')),
},
],
items: [
{
path: '/assistant/br163',
label: t('templates.sidebar.items.br163Restoration'),
icon: () => (
),
description: (
{t('templates.sidebar.items.br163Location')}
67%
),
},
],
},
]}
/>
{t('templates.sidebar.assistantContent')}
{}}
user={{
name: 'Ariel Santos',
email: 'admin@xertica.com',
avatar: 'https://github.com/shadcn.png',
}}
onLogout={() => toast(t('templates.sidebar.logoutToast'))}
onSettingsClick={() =>
toast(t('templates.sidebar.settingsClickedToast'))
}
location={{ pathname: '/home' }}
navigate={() => {}}
variant="default"
routes={[
{
path: '/home',
label: t('templates.sidebar.routes.home'),
icon: Home,
},
{
path: '/dashboard',
label: t('templates.sidebar.routes.dashboard'),
icon: Users,
},
{
path: '/settings',
label: t('templates.sidebar.routes.settings'),
icon: Settings,
},
]}
/>
{t('templates.sidebar.defaultContent')}
{/* ── v2.2.1 Components ──────────────────────────────────── */}
{t('templates.sections.enhancedComponents')}
{/* Pagination com disabled */}
{t('templates.enhanced.pagination.title')}
}}
/>
{t('templates.enhanced.pagination.pageOfTotal', {
current: currentPage,
total: totalPages,
})}
{
e.preventDefault();
prev();
}}
disabled={!canGoPrev}
/>
{items.map(item =>
item.type === 'ellipsis' ? (
) : (
{
e.preventDefault();
goTo(item.page);
}}
>
{item.page}
)
)}
{
e.preventDefault();
next();
}}
disabled={!canGoNext}
/>
{/* Stepper com ARIA */}
{t('templates.enhanced.stepper.title')}
}}
/>
{t('templates.enhanced.stepper.previous')}
{isLastStep
? t('templates.enhanced.stepper.finish')
: t('templates.enhanced.stepper.next')}
{/* TreeView com ariaLabel */}
{t('templates.enhanced.treeView.title')}
}}
/>
console.log(
t('templates.enhanced.treeView.selectedConsoleLog'),
node.label
)
}
className="max-w-xs border border-border rounded-[var(--radius-lg)] p-2"
/>
{/* RichTextEditor sem Auto-save */}
{t('templates.enhanced.richText.title')}
}}
/>
{/* Footer Note */}
{t('templates.footer.title')}
{t('templates.footer.subtitle')}
{t('templates.footer.descriptionPart1')}
xertica-ui
{t('templates.footer.descriptionPart2')}
{t('templates.footer.tipTitle')}
{t('templates.footer.tipDescriptionPart1')}
styles/xertica/tokens.css
{t('templates.footer.tipDescriptionPart2')}
);
}