@tc96/cli 0.27.0 → 0.28.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 +4 -4
- package/cli.js +82 -27
- package/package.json +1 -1
- package/registry/agenda-1.json +1297 -0
- package/registry/aggregate.json +1 -1
- package/registry/ai-chat-1.json +91 -0
- package/registry/checklist.json +21 -7
- package/registry/collection.json +624 -351
- package/registry/crm-1.json +1317 -0
- package/registry/crm-2.json +1400 -0
- package/registry/dashboard-5.json +167 -0
- package/registry/dashboard-6.json +143 -0
- package/registry/dashboard-7.json +188 -0
- package/registry/documents-1.json +1322 -0
- package/registry/finance-1.json +845 -0
- package/registry/finance-2.json +973 -0
- package/registry/finance-3.json +1436 -0
- package/registry/{workflow-editor.json → flow-1.json} +37 -37
- package/registry/{agent-builder.json → flow-2.json} +55 -55
- package/registry/{run-monitor.json → flow-3.json} +16 -16
- package/registry/{impact-map.json → flow-4.json} +16 -16
- package/registry/inbox-1.json +1184 -0
- package/registry/inventory-1.json +828 -0
- package/registry/inventory-2.json +956 -0
- package/registry/legal-1.json +1345 -0
- package/registry/legal-2.json +1279 -0
- package/registry/legal-3.json +1273 -0
- package/registry/legal-4.json +1273 -0
- package/registry/legal-5.json +1393 -0
- package/registry/legal-6.json +1309 -0
- package/registry/legal-7.json +1315 -0
- package/registry/legal-8.json +1358 -0
- package/registry/legal-9.json +1381 -0
- package/registry/marketing-1.json +833 -0
- package/registry/marketing-2.json +961 -0
- package/registry/navbar-1.json +6 -6
- package/registry/navbar-10.json +50 -0
- package/registry/navbar-11.json +48 -0
- package/registry/navbar-12.json +48 -0
- package/registry/navbar-6.json +48 -0
- package/registry/navbar-7.json +72 -0
- package/registry/navbar-8.json +50 -0
- package/registry/navbar-9.json +54 -0
- package/registry/projects-1.json +865 -0
- package/registry/projects-2.json +993 -0
- package/registry/projects-3.json +1346 -0
- package/registry/properties.json +65 -58
- package/registry/record-group.json +5 -1
- package/registry/revenue-1.json +834 -0
- package/registry/revenue-2.json +968 -0
- package/registry/revenue-3.json +821 -0
- package/registry/revenue-4.json +949 -0
- package/registry/rich-text-editor-1.json +172 -0
- package/registry/rich-text-editor-2.json +158 -0
- package/registry/rich-text-editor-3.json +198 -0
- package/registry/rich-text-editor-4.json +200 -0
- package/registry/rich-text-editor-5.json +237 -0
- package/registry/rich-text-editor.json +27 -7
- package/registry/{settings-1.json → settings-account-1.json} +17 -17
- package/registry/{settings-23.json → settings-account-2.json} +17 -17
- package/registry/{settings-7.json → settings-catalog-1.json} +17 -17
- package/registry/{settings-16.json → settings-catalog-10.json} +17 -17
- package/registry/{settings-8.json → settings-catalog-2.json} +17 -17
- package/registry/{settings-9.json → settings-catalog-3.json} +17 -17
- package/registry/{settings-10.json → settings-catalog-4.json} +29 -20
- package/registry/{settings-11.json → settings-catalog-5.json} +17 -17
- package/registry/{settings-12.json → settings-catalog-6.json} +17 -17
- package/registry/{settings-13.json → settings-catalog-7.json} +17 -17
- package/registry/{settings-14.json → settings-catalog-8.json} +29 -19
- package/registry/{settings-15.json → settings-catalog-9.json} +28 -18
- package/registry/{settings-19.json → settings-integration-1.json} +17 -17
- package/registry/settings-integration-2.json +122 -0
- package/registry/{settings-22.json → settings-integration-3.json} +17 -17
- package/registry/settings-integration-4.json +129 -0
- package/registry/settings-integration-5.json +122 -0
- package/registry/settings-integration-6.json +92 -0
- package/registry/{settings-21.json → settings-integration-7.json} +23 -17
- package/registry/settings-integration-8.json +593 -0
- package/registry/{settings-20.json → settings-notification-channel-1.json} +17 -17
- package/registry/{settings-2.json → settings-preference-1.json} +17 -17
- package/registry/{settings-3.json → settings-preference-2.json} +17 -17
- package/registry/{settings-4.json → settings-preference-3.json} +17 -17
- package/registry/{settings-18.json → settings-role-permission-1.json} +17 -17
- package/registry/{settings-17.json → settings-security-1.json} +17 -17
- package/registry/{settings-5.json → settings-workspace-1.json} +28 -28
- package/registry/{settings-6.json → settings-workspace-2.json} +31 -31
- package/registry/support-1.json +853 -0
- package/registry/support-2.json +981 -0
- package/registry/support-3.json +762 -0
- package/registry/support-4.json +538 -0
- package/registry/team-1.json +829 -0
- package/registry/team-2.json +957 -0
- package/registry/ui/gauge.json +1 -1
- package/registry/ui/menu.json +1 -1
- package/registry/ui/property-meta.json +16 -0
- package/registry/ui/property-tone.json +12 -0
- package/registry/ui/scroll-area.json +1 -1
- package/registry/ui/select.json +1 -1
- package/registry/view.json +624 -351
- package/registry/app-shell-5.json +0 -106
- package/registry/bulk-import-1.json +0 -151
- package/registry/collection-layouts.json +0 -836
- package/registry/collection-views.json +0 -836
- package/registry/detail-sheet.json +0 -54
- package/registry/icon-row.json +0 -52
- package/registry/lookup-create-1.json +0 -157
- package/registry/next-steps-1.json +0 -147
- package/registry/settings-shell.json +0 -60
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dashboard-5",
|
|
3
|
+
"type": "registry:block",
|
|
4
|
+
"files": [
|
|
5
|
+
{
|
|
6
|
+
"path": "blocks/application/dashboard/dashboard-5/dashboard-5-skeleton.tsx",
|
|
7
|
+
"type": "registry:file",
|
|
8
|
+
"content": "import { cn } from '@tc96/utils'\nimport {\n KpiSkeleton,\n PanelSkeleton,\n TableSkeleton,\n} from '../shared/dashboard-skeleton-parts'\n\nexport function Dashboard5Skeleton({\n className,\n label,\n title,\n}: Readonly<{ className?: string; label: string; title: string }>) {\n return (\n <section\n aria-busy=\"true\"\n aria-label={label}\n className={cn('grid gap-4', className)}\n >\n <h2 className=\"font-semibold text-lg\">{title}</h2>\n <div className=\"grid gap-4 sm:grid-cols-2 xl:grid-cols-4\">\n <KpiSkeleton />\n <KpiSkeleton />\n <KpiSkeleton />\n <KpiSkeleton />\n </div>\n <div className=\"grid gap-4 lg:grid-cols-2\">\n <TableSkeleton rows={3} />\n <TableSkeleton rows={3} />\n <PanelSkeleton height={180} />\n <PanelSkeleton height={180} />\n </div>\n </section>\n )\n}\n",
|
|
9
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/dashboard-5/dashboard-5-skeleton.tsx"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "blocks/application/dashboard/dashboard-5/dashboard-5.tsx",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"content": "import { Badge } from '@tc96/ui/badge'\nimport { StateSurface } from '@tc96/ui/patterns/surfaces/state/composition/state-surface/state-surface'\nimport { renderAnchor } from '@tc96/ui/render-anchor'\nimport { cn } from '@tc96/utils'\nimport { CategoryBarChart } from '../shared/category-bar-chart'\nimport { DashboardError } from '../shared/dashboard-error'\nimport { DashboardHeader } from '../shared/dashboard-header'\nimport { DashboardLink } from '../shared/dashboard-link'\nimport { DashboardLinkList } from '../shared/dashboard-link-list'\nimport {\n DashboardMetricCard,\n type DashboardMetricCardProps,\n} from '../shared/dashboard-metric-card'\nimport { DashboardPanel } from '../shared/dashboard-panel'\nimport { DashboardPanelLink } from '../shared/dashboard-panel-link'\nimport { createDateFormatter } from '../shared/format-date'\nimport { createMoneyFormatter } from '../shared/format-money'\nimport { PeriodColumnChart } from '../shared/period-column-chart'\nimport { Dashboard5Skeleton } from './dashboard-5-skeleton'\nimport { defaultDashboard5Labels } from './labels'\nimport type { Dashboard5Props, Dashboard5Urgency } from './types'\n\nconst urgencyVariants: Record<\n Dashboard5Urgency,\n 'error' | 'secondary' | 'warning'\n> = {\n later: 'secondary',\n overdue: 'error',\n soon: 'warning',\n today: 'error',\n}\n\nconst captureTones = {\n running: 'positive',\n simulated: 'neutral',\n stopped: 'negative',\n} as const\n\nconst dueDaySeries = [{ color: 'var(--chart-1)', id: 'due' }]\n\nexport function Dashboard5({\n appointments,\n breadcrumbs,\n className,\n currency,\n deadlines,\n dueDays = [],\n error = false,\n labels: labelsProp,\n links = {},\n locale,\n metrics = {},\n onRetry,\n pending = false,\n publications,\n queues,\n renderLink = renderAnchor,\n timeZone,\n}: Readonly<Dashboard5Props>) {\n const labels = { ...defaultDashboard5Labels, ...labelsProp }\n const numbers = createMoneyFormatter({ currency, locale })\n const dates = createDateFormatter({ locale, timeZone })\n const formatCount = numbers.count\n const dueDayData = dueDays.map((day) => ({\n period: dates.dayMonth(day.date),\n series: 'due',\n value: day.count,\n }))\n\n if (pending) {\n return (\n <Dashboard5Skeleton\n className={className}\n label={labels.loading}\n title={labels.title}\n />\n )\n }\n\n const metricCards: DashboardMetricCardProps[] = []\n if (metrics.dueSoon) {\n metricCards.push({\n detail: metrics.dueSoon.detail,\n href: metrics.dueSoon.href,\n id: 'due-soon',\n label: labels.dueSoonLabel,\n tone: metrics.dueSoon.count > 0 ? 'warning' : 'neutral',\n value: formatCount(metrics.dueSoon.count),\n })\n }\n if (metrics.overdue) {\n metricCards.push({\n detail: metrics.overdue.detail,\n href: metrics.overdue.href,\n id: 'overdue',\n label: labels.overdueLabel,\n tone: metrics.overdue.count > 0 ? 'negative' : 'neutral',\n value: formatCount(metrics.overdue.count),\n })\n }\n if (metrics.publications) {\n metricCards.push({\n detail: metrics.publications.detail,\n href: metrics.publications.href,\n id: 'publications',\n label: labels.publicationsLabel,\n value: formatCount(metrics.publications.count),\n })\n }\n if (metrics.capture) {\n metricCards.push({\n detail: metrics.capture.detail,\n href: metrics.capture.href,\n id: 'capture',\n label: labels.captureLabel,\n tone: captureTones[metrics.capture.state],\n value: labels.captureStates[metrics.capture.state],\n })\n }\n\n const isEmpty =\n metricCards.length === 0 &&\n deadlines.length === 0 &&\n (publications ?? []).length === 0 &&\n appointments.length === 0 &&\n queues.length === 0 &&\n dueDays.length === 0\n\n return (\n <section\n aria-label={labels.title}\n className={cn('grid gap-4', className)}\n data-block=\"dashboard-5\"\n >\n <DashboardHeader\n breadcrumbs={breadcrumbs}\n labels={labels}\n renderLink={renderLink}\n />\n {error ? (\n <DashboardError\n description={labels.errorDescription}\n onRetry={onRetry}\n retry={labels.retry}\n title={labels.errorTitle}\n />\n ) : isEmpty ? (\n <StateSurface\n description={labels.emptyDescription}\n kind=\"empty\"\n title={labels.emptyTitle}\n />\n ) : (\n <>\n {metricCards.length > 0 ? (\n <ul\n aria-label={labels.indicators}\n className=\"m-0 grid list-none gap-4 p-0 sm:grid-cols-2 xl:grid-cols-4\"\n >\n {metricCards.map((card) => (\n <li className=\"min-w-0\" key={card.id}>\n <DashboardMetricCard {...card} renderLink={renderLink} />\n </li>\n ))}\n </ul>\n ) : null}\n <div className=\"grid items-start gap-4 lg:grid-cols-2\">\n <DashboardPanel\n action={\n links.deadlines ? (\n <DashboardPanelLink\n href={links.deadlines}\n label={labels.deadlinesLink}\n renderLink={renderLink}\n />\n ) : undefined\n }\n title={labels.deadlinesTitle}\n >\n <DashboardLinkList\n empty={labels.deadlinesEmpty}\n items={deadlines.map((deadline) => ({\n description: labels.fatalOn(\n deadline.lawsuitTitle,\n dates.dayMonth(deadline.fatalDate),\n ),\n href: deadline.href,\n id: deadline.id,\n title: deadline.title,\n trailing: (\n <Badge\n data-urgency={deadline.urgency}\n variant={urgencyVariants[deadline.urgency]}\n >\n {deadline.daysLeft}\n </Badge>\n ),\n }))}\n label={labels.deadlinesTitle}\n renderLink={renderLink}\n />\n </DashboardPanel>\n {publications ? (\n <DashboardPanel\n action={\n links.publications ? (\n <DashboardPanelLink\n href={links.publications}\n label={labels.publicationsLink}\n renderLink={renderLink}\n />\n ) : undefined\n }\n title={labels.publicationsTitle}\n >\n <DashboardLinkList\n empty={labels.publicationsEmpty}\n items={publications.map((publication) => ({\n description: publication.description,\n href: publication.href,\n id: publication.id,\n title: publication.title,\n trailing: <Badge variant=\"outline\">{labels.decide}</Badge>,\n }))}\n label={labels.publicationsTitle}\n renderLink={renderLink}\n />\n </DashboardPanel>\n ) : null}\n {dueDays.length > 0 ? (\n <DashboardPanel title={labels.dueDaysTitle}>\n <PeriodColumnChart\n columnTooltip={(datum) =>\n labels.dueDaysTooltip(\n datum.period,\n formatCount(datum.value),\n )\n }\n data={dueDayData}\n formatAxis={formatCount}\n height={200}\n label={labels.dueDaysLabel}\n periods={dueDayData.map((datum) => datum.period)}\n series={dueDaySeries}\n summary={labels.dueDaysSummary(\n dueDayData.map((datum) => ({\n count: formatCount(datum.value),\n label: datum.period,\n })),\n )}\n />\n </DashboardPanel>\n ) : null}\n <DashboardPanel title={labels.queuesTitle}>\n {queues.length === 0 ? (\n <p className=\"text-muted-foreground text-sm\">\n {labels.queuesEmpty}\n </p>\n ) : (\n <>\n <CategoryBarChart\n data={queues.map((queue) => ({\n id: queue.id,\n label: queue.label,\n value: queue.count,\n }))}\n formatValue={formatCount}\n label={labels.queuesLabel}\n summary={labels.queuesSummary(\n queues.map((queue) => ({\n count: formatCount(queue.count),\n label: queue.label,\n })),\n )}\n tooltipText={(datum) =>\n labels.queuesTooltip(\n datum.label,\n formatCount(datum.value),\n )\n }\n />\n <ul\n aria-label={labels.queuesTitle}\n className=\"m-0 grid list-none gap-1 p-0\"\n >\n {queues.map((queue) => (\n <li\n className=\"flex items-center justify-between gap-3 text-sm\"\n data-queue={queue.id}\n key={queue.id}\n >\n {queue.href ? (\n <DashboardLink\n className=\"hover:underline\"\n href={queue.href}\n renderLink={renderLink}\n >\n {queue.label}\n </DashboardLink>\n ) : (\n <span>{queue.label}</span>\n )}\n <span className=\"font-medium tabular-nums\">\n {formatCount(queue.count)}\n </span>\n </li>\n ))}\n </ul>\n </>\n )}\n </DashboardPanel>\n <DashboardPanel\n action={\n links.agenda ? (\n <DashboardPanelLink\n href={links.agenda}\n label={labels.agendaLink}\n renderLink={renderLink}\n />\n ) : undefined\n }\n title={labels.appointmentsTitle}\n >\n <DashboardLinkList\n empty={labels.appointmentsEmpty}\n items={appointments.map((appointment) => ({\n description: appointment.recordTitle,\n href: appointment.href,\n id: appointment.id,\n title: appointment.title,\n trailing: (\n <Badge variant=\"secondary\">\n {labels.appointmentWhen(\n dates.dayMonth(appointment.startsAt),\n dates.time(appointment.startsAt),\n )}\n </Badge>\n ),\n }))}\n label={labels.appointmentsTitle}\n renderLink={renderLink}\n />\n </DashboardPanel>\n </div>\n </>\n )}\n </section>\n )\n}\n",
|
|
15
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/dashboard-5/dashboard-5.tsx"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "blocks/application/dashboard/dashboard-5/index.ts",
|
|
19
|
+
"type": "registry:file",
|
|
20
|
+
"content": "export { Dashboard5 } from './dashboard-5'\nexport type {\n Dashboard5Appointment,\n Dashboard5CaptureMetric,\n Dashboard5CaptureState,\n Dashboard5CountMetric,\n Dashboard5CountSummaryItem,\n Dashboard5Deadline,\n Dashboard5DueDay,\n Dashboard5Labels,\n Dashboard5Links,\n Dashboard5Metrics,\n Dashboard5Props,\n Dashboard5Publication,\n Dashboard5Queue,\n Dashboard5Urgency,\n} from './types'\n",
|
|
21
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/dashboard-5/index.ts"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "blocks/application/dashboard/dashboard-5/labels.ts",
|
|
25
|
+
"type": "registry:file",
|
|
26
|
+
"content": "import type { Dashboard5Labels } from './types'\n\nconst joinCounts = (items: { count: string; label: string }[]) =>\n items.map((item) => `${item.label}: ${item.count}`).join('; ')\n\nexport const defaultDashboard5Labels: Dashboard5Labels = {\n agendaLink: 'Abrir Agenda',\n appointmentWhen: (day, time) => `${day} · ${time}`,\n appointmentsEmpty: 'Nenhum compromisso marcado nos seus processos.',\n appointmentsTitle: 'Compromissos dos meus processos',\n breadcrumb: 'Navegação estrutural',\n captureLabel: 'Captura do DJEN',\n captureStates: {\n running: 'Em dia',\n simulated: 'Simulado',\n stopped: 'Parada',\n },\n decide: 'Decidir',\n deadlinesEmpty: 'Nenhum prazo seu em andamento.',\n deadlinesLink: 'Abrir Prazos',\n deadlinesTitle: 'Meus prazos',\n description:\n 'Prazos que vencem, publicações para decidir e a situação da captura.',\n dueDaysLabel: 'Prazos que vencem em cada um dos próximos dias úteis',\n dueDaysSummary: joinCounts,\n dueDaysTitle: 'Prazos por dia',\n dueDaysTooltip: (day, count) => `${day}: ${count}`,\n dueSoonLabel: 'Vencem em até 5 dias úteis',\n emptyDescription:\n 'Os prazos, as publicações e os compromissos aparecem aqui assim que chegarem.',\n emptyTitle: 'Nenhuma pendência',\n errorDescription: 'Tente de novo em instantes.',\n errorTitle: 'Não foi possível carregar.',\n export: 'Exportar',\n fatalOn: (lawsuitTitle, date) => `${lawsuitTitle} · fatal ${date}`,\n indicators: 'Indicadores',\n loading: 'Carregando pendências',\n overdueLabel: 'Prazos atrasados',\n period: 'Período',\n publicationsEmpty:\n 'Nenhuma publicação para decidir. As novas chegam com a próxima captura.',\n publicationsLabel: 'Publicações para decidir',\n publicationsLink: 'Abrir fila',\n publicationsTitle: 'Publicações para decidir',\n queuesEmpty: 'Nenhuma fila de prazo.',\n queuesLabel: 'Prazos em cada fila',\n queuesSummary: joinCounts,\n queuesTitle: 'Filas de prazo',\n queuesTooltip: (label, count) => `${label}: ${count}`,\n retry: 'Tentar de novo',\n title: 'Pendências',\n}\n",
|
|
27
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/dashboard-5/labels.ts"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "blocks/application/dashboard/dashboard-5/types.ts",
|
|
31
|
+
"type": "registry:file",
|
|
32
|
+
"content": "import type { RenderLink } from '@tc96/ui/render-anchor'\nimport type {\n DashboardBreadcrumbItem,\n DashboardFormatProps,\n} from '../shared/types'\n\nexport interface Dashboard5CountMetric {\n count: number\n detail?: string\n href?: string\n}\n\nexport type Dashboard5CaptureState = 'running' | 'simulated' | 'stopped'\n\nexport interface Dashboard5CaptureMetric {\n detail?: string\n href?: string\n state: Dashboard5CaptureState\n}\n\nexport interface Dashboard5Metrics {\n capture?: Dashboard5CaptureMetric\n dueSoon?: Dashboard5CountMetric\n overdue?: Dashboard5CountMetric\n publications?: Dashboard5CountMetric\n}\n\nexport type Dashboard5Urgency = 'later' | 'overdue' | 'soon' | 'today'\n\nexport interface Dashboard5Deadline {\n daysLeft: string\n fatalDate: string\n href?: string\n id: string\n lawsuitTitle: string\n title: string\n urgency: Dashboard5Urgency\n}\n\nexport interface Dashboard5Publication {\n availableOn: string\n description: string\n href?: string\n id: string\n title: string\n}\n\nexport interface Dashboard5Appointment {\n href?: string\n id: string\n recordTitle: string\n startsAt: string\n title: string\n}\n\nexport interface Dashboard5Queue {\n count: number\n href?: string\n id: string\n label: string\n}\n\nexport interface Dashboard5DueDay {\n count: number\n date: string\n}\n\nexport interface Dashboard5Links {\n agenda?: string\n deadlines?: string\n publications?: string\n}\n\nexport interface Dashboard5CountSummaryItem {\n count: string\n label: string\n}\n\nexport interface Dashboard5Labels {\n agendaLink: string\n appointmentWhen: (day: string, time: string) => string\n appointmentsEmpty: string\n appointmentsTitle: string\n breadcrumb: string\n captureLabel: string\n captureStates: Record<Dashboard5CaptureState, string>\n decide: string\n deadlinesEmpty: string\n deadlinesLink: string\n deadlinesTitle: string\n description: string\n dueDaysLabel: string\n dueDaysSummary: (items: Dashboard5CountSummaryItem[]) => string\n dueDaysTitle: string\n dueDaysTooltip: (day: string, count: string) => string\n dueSoonLabel: string\n emptyDescription: string\n emptyTitle: string\n errorDescription: string\n errorTitle: string\n export: string\n fatalOn: (lawsuitTitle: string, date: string) => string\n indicators: string\n loading: string\n overdueLabel: string\n period: string\n publicationsEmpty: string\n publicationsLabel: string\n publicationsLink: string\n publicationsTitle: string\n queuesEmpty: string\n queuesLabel: string\n queuesSummary: (items: Dashboard5CountSummaryItem[]) => string\n queuesTitle: string\n queuesTooltip: (label: string, count: string) => string\n retry: string\n title: string\n}\n\nexport interface Dashboard5Props extends DashboardFormatProps {\n appointments: Dashboard5Appointment[]\n breadcrumbs?: DashboardBreadcrumbItem[]\n className?: string\n deadlines: Dashboard5Deadline[]\n dueDays?: Dashboard5DueDay[]\n error?: boolean\n labels?: Partial<Dashboard5Labels>\n links?: Dashboard5Links\n metrics?: Dashboard5Metrics\n onRetry?: () => void\n pending?: boolean\n publications?: Dashboard5Publication[]\n queues: Dashboard5Queue[]\n renderLink?: RenderLink\n timeZone?: string\n}\n",
|
|
33
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/dashboard-5/types.ts"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "blocks/application/dashboard/shared/category-bar-chart.tsx",
|
|
37
|
+
"type": "registry:file",
|
|
38
|
+
"content": "import { barX, defineChart, text } from '@tanstack/charts'\nimport { scaleBand } from '@tanstack/charts/scales/band'\nimport { scaleLinear } from '@tanstack/charts/scales/linear'\nimport { tooltip } from '@tanstack/charts/tooltip'\nimport { useMemo } from 'react'\nimport { TanstackChartFrame, tanstackChartTheme } from './tanstack-chart-frame'\n\nexport interface CategoryBarDatum {\n id: string\n label: string\n value: number\n}\n\nexport interface CategoryBarChartProps {\n color?: string\n data: readonly CategoryBarDatum[]\n formatValue: (value: number) => string\n label: string\n summary: string\n tooltipText: (datum: CategoryBarDatum) => string\n}\n\nconst rowHeight = 36\n\nexport function CategoryBarChart({\n color = 'var(--chart-1)',\n data,\n formatValue,\n label,\n summary,\n tooltipText,\n}: Readonly<CategoryBarChartProps>) {\n const definition = useMemo(\n () =>\n defineChart({\n focus: 'group-y',\n marks: [\n barX(data, {\n fill: color,\n key: (datum) => datum.id,\n radius: { end: 4 },\n x: (datum) => datum.value,\n y: (datum) => datum.label,\n }),\n text(data, {\n anchor: 'start',\n dx: 6,\n fill: 'var(--foreground)',\n fontWeight: 500,\n key: (datum) => `${datum.id}-value`,\n text: (datum) => formatValue(datum.value),\n x: (datum) => datum.value,\n y: (datum) => datum.label,\n }),\n ],\n margin: { right: 72 },\n scales: {\n x: { axis: false, nice: true, scale: scaleLinear },\n y: { scale: () => scaleBand<string>().padding(0.28) },\n },\n theme: tanstackChartTheme,\n tooltip: {\n format: ({ datum }: { datum: CategoryBarDatum }) =>\n tooltipText(datum),\n use: tooltip,\n },\n }),\n [color, data, formatValue, tooltipText],\n )\n\n return (\n <TanstackChartFrame\n definition={definition}\n height={Math.max(data.length, 1) * rowHeight + 16}\n label={label}\n summary={summary}\n />\n )\n}\n",
|
|
39
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/category-bar-chart.tsx"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "blocks/application/dashboard/shared/dashboard-error.tsx",
|
|
43
|
+
"type": "registry:file",
|
|
44
|
+
"content": "import { Button } from '@tc96/ui/button'\nimport { StateSurface } from '@tc96/ui/patterns/surfaces/state/composition/state-surface/state-surface'\n\nexport interface DashboardErrorProps {\n description: string\n onRetry?: () => void\n retry: string\n title: string\n}\n\nexport function DashboardError({\n description,\n onRetry,\n retry,\n title,\n}: Readonly<DashboardErrorProps>) {\n return (\n <StateSurface\n actions={\n onRetry ? (\n <Button onClick={onRetry} size=\"sm\" variant=\"outline\">\n {retry}\n </Button>\n ) : undefined\n }\n description={description}\n kind=\"error\"\n title={title}\n />\n )\n}\n",
|
|
45
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-error.tsx"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "blocks/application/dashboard/shared/dashboard-header.tsx",
|
|
49
|
+
"type": "registry:file",
|
|
50
|
+
"content": "import { DownloadSimpleIcon } from '@phosphor-icons/react'\nimport {\n Breadcrumb,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbList,\n BreadcrumbPage,\n BreadcrumbSeparator,\n} from '@tc96/ui/breadcrumb'\nimport { Button } from '@tc96/ui/button'\nimport {\n Select,\n SelectItem,\n SelectPopup,\n SelectTrigger,\n SelectValue,\n} from '@tc96/ui/select'\nimport { Fragment } from 'react'\nimport type { DashboardHeaderLabels, DashboardHeaderProps } from './types'\n\nexport interface DashboardHeaderComponentProps extends DashboardHeaderProps {\n labels: DashboardHeaderLabels\n showExport?: boolean\n}\n\nexport function DashboardHeader({\n breadcrumbs,\n labels,\n onExport,\n onPeriodChange,\n period,\n periodOptions,\n renderLink,\n showExport = true,\n}: Readonly<DashboardHeaderComponentProps>) {\n const hasPeriod =\n onPeriodChange !== undefined &&\n period !== undefined &&\n periodOptions !== undefined &&\n periodOptions.length > 0\n\n return (\n <header\n className=\"flex flex-wrap items-end justify-between gap-4\"\n data-slot=\"dashboard-header\"\n >\n <div className=\"grid min-w-0 gap-1.5\">\n {breadcrumbs?.length ? (\n <Breadcrumb aria-label={labels.breadcrumb}>\n <BreadcrumbList>\n {breadcrumbs.map((item, index) => {\n const current = index === breadcrumbs.length - 1\n return (\n <Fragment key={`${index}-${item.label}`}>\n <BreadcrumbItem>\n {current ? (\n <BreadcrumbPage>{item.label}</BreadcrumbPage>\n ) : item.href && renderLink ? (\n <BreadcrumbLink render={renderLink(item.href)}>\n {item.label}\n </BreadcrumbLink>\n ) : (\n item.label\n )}\n </BreadcrumbItem>\n {current ? null : <BreadcrumbSeparator />}\n </Fragment>\n )\n })}\n </BreadcrumbList>\n </Breadcrumb>\n ) : null}\n <h2 className=\"font-semibold text-lg\">{labels.title}</h2>\n {labels.description ? (\n <p className=\"text-muted-foreground text-sm\">{labels.description}</p>\n ) : null}\n </div>\n {hasPeriod || (onExport && showExport) ? (\n <div className=\"flex flex-wrap items-center gap-2\">\n {hasPeriod ? (\n <Select\n items={periodOptions}\n onValueChange={(next) => {\n if (next) onPeriodChange(next)\n }}\n value={period}\n >\n <SelectTrigger aria-label={labels.period} className=\"w-44\">\n <SelectValue />\n </SelectTrigger>\n <SelectPopup>\n {periodOptions.map((option) => (\n <SelectItem key={option.value} value={option.value}>\n {option.label}\n </SelectItem>\n ))}\n </SelectPopup>\n </Select>\n ) : null}\n {onExport && showExport ? (\n <Button onClick={onExport} size=\"sm\" variant=\"outline\">\n <DownloadSimpleIcon aria-hidden=\"true\" />\n {labels.export}\n </Button>\n ) : null}\n </div>\n ) : null}\n </header>\n )\n}\n",
|
|
51
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-header.tsx"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "blocks/application/dashboard/shared/dashboard-link-list.tsx",
|
|
55
|
+
"type": "registry:file",
|
|
56
|
+
"content": "import type { RenderLink } from '@tc96/ui/render-anchor'\nimport type { ReactNode } from 'react'\nimport { DashboardLink } from './dashboard-link'\n\nexport interface DashboardLinkListItem {\n description?: string\n href?: string\n id: string\n title: string\n trailing?: ReactNode\n}\n\nexport interface DashboardLinkListProps {\n empty: string\n items: readonly DashboardLinkListItem[]\n label: string\n renderLink?: RenderLink\n}\n\nexport function DashboardLinkList({\n empty,\n items,\n label,\n renderLink,\n}: Readonly<DashboardLinkListProps>) {\n if (items.length === 0) {\n return <p className=\"text-muted-foreground text-sm\">{empty}</p>\n }\n\n return (\n <ul aria-label={label} className=\"m-0 grid list-none gap-3 p-0\">\n {items.map((item) => (\n <li\n className=\"flex items-start justify-between gap-3\"\n data-item={item.id}\n key={item.id}\n >\n <div className=\"grid min-w-0 gap-0.5\">\n {item.href && renderLink ? (\n <DashboardLink\n className=\"truncate font-medium text-sm hover:underline\"\n href={item.href}\n renderLink={renderLink}\n >\n {item.title}\n </DashboardLink>\n ) : (\n <span className=\"truncate font-medium text-sm\">{item.title}</span>\n )}\n {item.description ? (\n <span className=\"truncate text-muted-foreground text-xs\">\n {item.description}\n </span>\n ) : null}\n </div>\n {item.trailing ? (\n <div className=\"flex shrink-0 items-center gap-2\">\n {item.trailing}\n </div>\n ) : null}\n </li>\n ))}\n </ul>\n )\n}\n",
|
|
57
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-link-list.tsx"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"path": "blocks/application/dashboard/shared/dashboard-link.tsx",
|
|
61
|
+
"type": "registry:file",
|
|
62
|
+
"content": "import type { RenderLink } from '@tc96/ui/render-anchor'\nimport { cn } from '@tc96/utils'\nimport { cloneElement, type ReactElement, type ReactNode } from 'react'\n\nexport interface DashboardLinkProps {\n 'aria-label'?: string\n children: ReactNode\n className?: string\n href: string\n renderLink: RenderLink\n}\n\nexport function DashboardLink({\n 'aria-label': ariaLabel,\n children,\n className,\n href,\n renderLink,\n}: Readonly<DashboardLinkProps>) {\n const element = renderLink(href) as ReactElement<{\n 'aria-label'?: string\n className?: string\n }>\n\n return cloneElement(\n element,\n {\n 'aria-label': ariaLabel,\n className: cn(\n 'rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background',\n element.props.className,\n className,\n ),\n },\n children,\n )\n}\n",
|
|
63
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-link.tsx"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"path": "blocks/application/dashboard/shared/dashboard-metric-card.tsx",
|
|
67
|
+
"type": "registry:file",
|
|
68
|
+
"content": "import { CaretRightIcon } from '@phosphor-icons/react'\nimport { CardPanel } from '@tc96/ui/card'\nimport { WidgetShell } from '@tc96/ui/patterns/widgets/shared/widget-shell'\nimport type { RenderLink } from '@tc96/ui/render-anchor'\nimport { cn } from '@tc96/utils'\nimport { DashboardLink } from './dashboard-link'\n\nexport type DashboardMetricTone =\n | 'negative'\n | 'neutral'\n | 'positive'\n | 'warning'\n\nconst toneClassNames: Record<DashboardMetricTone, string> = {\n negative: 'text-destructive-foreground',\n neutral: 'text-foreground',\n positive: 'text-success-foreground',\n warning: 'text-warning-foreground',\n}\n\nexport interface DashboardMetricCardProps {\n description?: string\n detail?: string\n href?: string\n id: string\n label: string\n renderLink?: RenderLink\n tone?: DashboardMetricTone\n value: string\n}\n\nexport function DashboardMetricCard({\n description,\n detail,\n href,\n id,\n label,\n renderLink,\n tone = 'neutral',\n value,\n}: Readonly<DashboardMetricCardProps>) {\n return (\n <WidgetShell className=\"h-full\" data-metric={id}>\n <CardPanel className=\"grid content-start gap-2 p-5\">\n {href && renderLink ? (\n <DashboardLink\n className=\"flex items-center justify-between gap-2 text-muted-foreground text-sm hover:text-foreground\"\n href={href}\n renderLink={renderLink}\n >\n {label}\n <CaretRightIcon aria-hidden=\"true\" className=\"size-3.5 shrink-0\" />\n </DashboardLink>\n ) : (\n <p className=\"text-muted-foreground text-sm\">{label}</p>\n )}\n <p\n className={cn(\n 'font-semibold text-2xl tabular-nums',\n toneClassNames[tone],\n )}\n data-slot=\"dashboard-metric-value\"\n >\n {value}\n </p>\n {detail ? (\n <p className=\"text-muted-foreground text-xs tabular-nums\">{detail}</p>\n ) : null}\n {description ? (\n <p\n className=\"text-muted-foreground text-xs\"\n data-slot=\"dashboard-metric-description\"\n >\n {description}\n </p>\n ) : null}\n </CardPanel>\n </WidgetShell>\n )\n}\n",
|
|
69
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-metric-card.tsx"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"path": "blocks/application/dashboard/shared/dashboard-panel-link.tsx",
|
|
73
|
+
"type": "registry:file",
|
|
74
|
+
"content": "import { ArrowRightIcon } from '@phosphor-icons/react'\nimport { Button } from '@tc96/ui/button'\nimport type { RenderLink } from '@tc96/ui/render-anchor'\n\nexport function DashboardPanelLink({\n href,\n label,\n renderLink,\n}: Readonly<{ href?: string; label: string; renderLink: RenderLink }>) {\n if (!href) return null\n\n return (\n <Button render={renderLink(href)} size=\"sm\" variant=\"ghost\">\n {label}\n <ArrowRightIcon aria-hidden=\"true\" />\n </Button>\n )\n}\n",
|
|
75
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-panel-link.tsx"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"path": "blocks/application/dashboard/shared/dashboard-panel.tsx",
|
|
79
|
+
"type": "registry:file",
|
|
80
|
+
"content": "import { CardAction, CardHeader, CardPanel, CardTitle } from '@tc96/ui/card'\nimport { WidgetShell } from '@tc96/ui/patterns/widgets/shared/widget-shell'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport { useId } from 'react'\n\nexport interface DashboardPanelProps {\n action?: ReactNode\n children: ReactNode\n className?: string\n title: string\n}\n\nexport function DashboardPanel({\n action,\n children,\n className,\n title,\n}: Readonly<DashboardPanelProps>) {\n const titleId = useId()\n\n return (\n <WidgetShell aria-labelledby={titleId} className={className}>\n <CardHeader className=\"grid-rows-1 items-center p-5\">\n <CardTitle className=\"font-semibold text-base\" id={titleId}>\n {title}\n </CardTitle>\n {action ? (\n <CardAction className=\"row-span-1 self-center\">{action}</CardAction>\n ) : null}\n </CardHeader>\n <CardPanel className={cn('grid gap-4 px-5 pb-5')}>{children}</CardPanel>\n </WidgetShell>\n )\n}\n",
|
|
81
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-panel.tsx"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"path": "blocks/application/dashboard/shared/dashboard-skeleton-parts.tsx",
|
|
85
|
+
"type": "registry:file",
|
|
86
|
+
"content": "import { CardPanel } from '@tc96/ui/card'\nimport { WidgetShell } from '@tc96/ui/patterns/widgets/shared/widget-shell'\nimport { Skeleton } from '@tc96/ui/skeleton'\n\nconst rowKeys = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight']\n\nexport function KpiSkeleton() {\n return (\n <WidgetShell>\n <CardPanel className=\"grid gap-3 p-5\">\n <Skeleton className=\"h-4 w-24\" />\n <Skeleton className=\"h-7 w-32\" />\n <Skeleton className=\"h-3 w-16\" />\n </CardPanel>\n </WidgetShell>\n )\n}\n\nexport function PanelSkeleton({\n className,\n height = 220,\n}: Readonly<{ className?: string; height?: number }>) {\n return (\n <WidgetShell className={className}>\n <CardPanel className=\"grid gap-4 p-5\">\n <Skeleton className=\"h-5 w-40\" />\n <Skeleton style={{ height }} />\n </CardPanel>\n </WidgetShell>\n )\n}\n\nexport function TableSkeleton({\n className,\n rows = 5,\n}: Readonly<{ className?: string; rows?: number }>) {\n return (\n <WidgetShell className={className}>\n <CardPanel className=\"grid gap-3 p-5\">\n <Skeleton className=\"h-5 w-40\" />\n {rowKeys.slice(0, rows).map((key) => (\n <Skeleton className=\"h-8\" key={key} />\n ))}\n </CardPanel>\n </WidgetShell>\n )\n}\n",
|
|
87
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-skeleton-parts.tsx"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"path": "blocks/application/dashboard/shared/format-date.ts",
|
|
91
|
+
"type": "registry:file",
|
|
92
|
+
"content": "import { defaultDashboardLocale } from './format'\n\nfunction parseIso(value: string) {\n return new Date(value.length <= 10 ? `${value}T12:00:00Z` : value)\n}\n\nexport function createDateFormatter({\n locale = defaultDashboardLocale,\n timeZone,\n}: {\n locale?: string\n timeZone?: string\n} = {}) {\n const dayMonth = new Intl.DateTimeFormat(locale, {\n day: '2-digit',\n month: '2-digit',\n timeZone,\n })\n const fullDate = new Intl.DateTimeFormat(locale, {\n day: '2-digit',\n month: '2-digit',\n timeZone,\n year: 'numeric',\n })\n const weekday = new Intl.DateTimeFormat(locale, {\n timeZone,\n weekday: 'short',\n })\n const time = new Intl.DateTimeFormat(locale, {\n hour: '2-digit',\n minute: '2-digit',\n timeZone,\n })\n const month = new Intl.DateTimeFormat(locale, {\n month: 'short',\n timeZone: 'UTC',\n year: 'numeric',\n })\n\n return {\n dayMonth: (iso: string) => dayMonth.format(parseIso(iso)),\n fullDate: (iso: string) => fullDate.format(parseIso(iso)),\n month: (isoMonth: string) =>\n month.format(new Date(`${isoMonth.slice(0, 7)}-15T12:00:00Z`)),\n time: (iso: string) => time.format(parseIso(iso)),\n weekday: (iso: string) => weekday.format(parseIso(iso)),\n }\n}\n\nexport type DateFormatter = ReturnType<typeof createDateFormatter>\n",
|
|
93
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/format-date.ts"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"path": "blocks/application/dashboard/shared/format-money.ts",
|
|
97
|
+
"type": "registry:file",
|
|
98
|
+
"content": "import { formatAmount } from '@tc96/ui/helpers/format'\nimport { defaultDashboardCurrency, defaultDashboardLocale } from './format'\nimport type { DashboardFormatProps } from './types'\n\nexport function createMoneyFormatter({\n currency = defaultDashboardCurrency,\n locale = defaultDashboardLocale,\n}: DashboardFormatProps = {}) {\n const cents = (amount: number) =>\n formatAmount(amount / 100, { currency, locale, style: 'currency' })\n\n const compactCents = (amount: number) =>\n formatAmount(amount / 100, {\n currency,\n locale,\n maximumFractionDigits: 1,\n notation: 'compact',\n style: 'currency',\n })\n\n const count = (amount: number) =>\n formatAmount(amount, {\n locale,\n maximumFractionDigits: 0,\n style: 'decimal',\n })\n\n const percent = (ratio: number) =>\n formatAmount(ratio, {\n locale,\n maximumFractionDigits: 1,\n minimumFractionDigits: 0,\n style: 'percent',\n })\n\n return { cents, compactCents, count, percent }\n}\n\nexport type MoneyFormatter = ReturnType<typeof createMoneyFormatter>\n",
|
|
99
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/format-money.ts"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"path": "blocks/application/dashboard/shared/format.ts",
|
|
103
|
+
"type": "registry:file",
|
|
104
|
+
"content": "import { formatAmount } from '@tc96/ui/helpers/format'\nimport type { DashboardFormatProps, DashboardValueFormat } from './types'\n\nexport const defaultDashboardLocale = 'pt-BR'\nexport const defaultDashboardCurrency = 'BRL'\n\nexport function createDashboardFormatter({\n currency = defaultDashboardCurrency,\n locale = defaultDashboardLocale,\n}: DashboardFormatProps = {}) {\n const value = (amount: number, format: DashboardValueFormat = 'number') => {\n if (format === 'currency') {\n return formatAmount(amount, {\n currency,\n locale,\n maximumFractionDigits: 0,\n style: 'currency',\n })\n }\n if (format === 'percent') {\n return formatAmount(amount, {\n locale,\n maximumFractionDigits: 1,\n minimumFractionDigits: 0,\n style: 'percent',\n })\n }\n return formatAmount(amount, {\n locale,\n maximumFractionDigits: 1,\n style: 'decimal',\n })\n }\n\n const exactCurrency = (amount: number) =>\n formatAmount(amount, { currency, locale, style: 'currency' })\n\n const delta = (amount: number) =>\n formatAmount(amount, {\n locale,\n maximumFractionDigits: 1,\n minimumFractionDigits: 0,\n signDisplay: 'exceptZero',\n style: 'percent',\n })\n\n return { currency: exactCurrency, delta, value }\n}\n\nexport type DashboardFormatter = ReturnType<typeof createDashboardFormatter>\n",
|
|
105
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/format.ts"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"path": "blocks/application/dashboard/shared/period-column-chart.tsx",
|
|
109
|
+
"type": "registry:file",
|
|
110
|
+
"content": "import { barY, defineChart, group, lineY } from '@tanstack/charts'\nimport { scaleBand } from '@tanstack/charts/scales/band'\nimport { scaleLinear } from '@tanstack/charts/scales/linear'\nimport { tooltip } from '@tanstack/charts/tooltip'\nimport { useMemo } from 'react'\nimport { TanstackChartFrame, tanstackChartTheme } from './tanstack-chart-frame'\n\nexport interface PeriodColumnSeries {\n color: string\n id: string\n}\n\nexport interface PeriodColumnDatum {\n forecast?: boolean\n period: string\n series: string\n value: number\n}\n\nexport interface PeriodLineDatum {\n period: string\n value: number\n}\n\nexport interface PeriodColumnChartProps {\n columnTooltip: (datum: PeriodColumnDatum) => string\n data: readonly PeriodColumnDatum[]\n formatAxis: (value: number) => string\n height?: number\n label: string\n line?: {\n color: string\n data: readonly PeriodLineDatum[]\n tooltip: (datum: PeriodLineDatum) => string\n }\n periods: readonly string[]\n series: readonly PeriodColumnSeries[]\n summary: string\n}\n\nconst forecastDash = '4 3'\n\nexport function PeriodColumnChart({\n columnTooltip,\n data,\n formatAxis,\n height = 260,\n label,\n line,\n periods,\n series,\n summary,\n}: Readonly<PeriodColumnChartProps>) {\n const definition = useMemo(() => {\n const seriesIds = series.map((item) => item.id)\n const colorOf = (id: string) =>\n series.find((item) => item.id === id)?.color ?? 'var(--chart-1)'\n const actual = data.filter((datum) => !datum.forecast)\n const forecast = data.filter((datum) => datum.forecast)\n const layout =\n seriesIds.length > 1\n ? group({ padding: 0.12, scale: scaleBand<string>().domain(seriesIds) })\n : undefined\n const columnOptions = {\n key: (datum: PeriodColumnDatum) => `${datum.period}-${datum.series}`,\n layout,\n maxThickness: 28,\n radius: { end: 3 },\n x: (datum: PeriodColumnDatum) => datum.period,\n y: (datum: PeriodColumnDatum) => datum.value,\n z: (datum: PeriodColumnDatum) => datum.series,\n }\n\n return defineChart({\n focus: 'group-x',\n marks: [\n barY(actual, {\n ...columnOptions,\n fill: (datum) => colorOf(datum.series),\n id: 'actual',\n }),\n barY(forecast, {\n ...columnOptions,\n fill: (datum) => colorOf(datum.series),\n fillOpacity: 0.3,\n id: 'forecast',\n stroke: (datum) => colorOf(datum.series),\n strokeDasharray: forecastDash,\n strokeWidth: 1.5,\n }),\n ...(line\n ? [\n lineY(line.data, {\n id: 'line',\n key: (datum) => `${datum.period}-line`,\n points: true,\n stroke: line.color,\n x: (datum) => datum.period,\n y: (datum) => datum.value,\n }),\n ]\n : []),\n ],\n scales: {\n x: {\n scale: () => scaleBand<string>().domain(periods).padding(0.24),\n },\n y: {\n axis: { ticks: { count: 4, format: formatAxis } },\n grid: true,\n nice: true,\n scale: scaleLinear,\n },\n },\n theme: tanstackChartTheme,\n tooltip: {\n format: ({ datum }: { datum: PeriodColumnDatum | PeriodLineDatum }) =>\n 'series' in datum\n ? columnTooltip(datum)\n : (line?.tooltip(datum) ?? ''),\n use: tooltip,\n },\n })\n }, [columnTooltip, data, formatAxis, line, periods, series])\n\n return (\n <TanstackChartFrame\n definition={definition}\n height={height}\n label={label}\n summary={summary}\n />\n )\n}\n",
|
|
111
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/period-column-chart.tsx"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"path": "blocks/application/dashboard/shared/tanstack-chart-frame.tsx",
|
|
115
|
+
"type": "registry:file",
|
|
116
|
+
"content": "import type {\n ChartTheme,\n ChartValue,\n DomChartDefinition,\n} from '@tanstack/charts'\nimport { Chart } from '@tanstack/charts/react'\n\nexport const tanstackChartTheme: Partial<ChartTheme> = {\n foreground: 'var(--foreground)',\n grid: 'var(--border)',\n muted: 'var(--muted-foreground)',\n palette: [\n 'var(--chart-1)',\n 'var(--chart-2)',\n 'var(--chart-3)',\n 'var(--chart-4)',\n 'var(--chart-5)',\n ],\n}\n\nexport interface TanstackChartFrameProps<\n TDatum,\n TXValue extends ChartValue,\n TYValue extends ChartValue,\n> {\n definition: DomChartDefinition<TDatum, TXValue, TYValue>\n height?: number\n label: string\n summary: string\n}\n\nexport function TanstackChartFrame<\n TDatum,\n TXValue extends ChartValue,\n TYValue extends ChartValue,\n>({\n definition,\n height = 240,\n label,\n summary,\n}: Readonly<TanstackChartFrameProps<TDatum, TXValue, TYValue>>) {\n return (\n <div\n className=\"min-w-0 text-muted-foreground text-xs [--ts-chart-tooltip-background:var(--popover)] [--ts-chart-tooltip-border:1px_solid_var(--border)] [--ts-chart-tooltip-color:var(--popover-foreground)]\"\n data-slot=\"dashboard-chart\"\n >\n <Chart<TDatum, TXValue, TYValue>\n ariaDescription={summary}\n ariaLabel={label}\n definition={definition}\n height={height}\n />\n </div>\n )\n}\n",
|
|
117
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/tanstack-chart-frame.tsx"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"path": "blocks/application/dashboard/shared/types.ts",
|
|
121
|
+
"type": "registry:file",
|
|
122
|
+
"content": "import type { RenderLink } from '@tc96/ui/render-anchor'\n\nexport type DashboardTone =\n | 'error'\n | 'info'\n | 'outline'\n | 'secondary'\n | 'success'\n | 'warning'\n\nexport interface DashboardBadgeData {\n label: string\n tone?: DashboardTone\n}\n\nexport type DashboardValueFormat = 'currency' | 'number' | 'percent'\n\nexport type DashboardTrend = 'negative' | 'neutral' | 'positive'\n\nexport interface DashboardKpi {\n delta?: number\n format?: DashboardValueFormat\n id: string\n label: string\n sparkline?: number[]\n trend?: DashboardTrend\n value: number\n}\n\nexport interface DashboardFormatProps {\n currency?: string\n locale?: string\n}\n\nexport interface DashboardBreadcrumbItem {\n href?: string\n label: string\n}\n\nexport interface DashboardOption {\n label: string\n value: string\n}\n\nexport interface DashboardFilterOption extends DashboardOption {\n count?: number\n}\n\nexport interface DashboardRowAction {\n destructive?: boolean\n id: string\n label: string\n}\n\nexport interface DashboardPagination {\n page: number\n pageCount: number\n}\n\nexport interface DashboardHeaderProps {\n breadcrumbs?: DashboardBreadcrumbItem[]\n onExport?: () => void\n onPeriodChange?: (period: string) => void\n period?: string\n periodOptions?: DashboardOption[]\n renderLink?: RenderLink\n}\n\nexport interface DashboardHeaderLabels {\n breadcrumb: string\n description: string\n export: string\n period: string\n title: string\n}\n\nexport interface DashboardTableLabels {\n nextPage: string\n pageOf: (page: number, pageCount: number) => string\n pagination: string\n previousPage: string\n search: string\n}\n",
|
|
123
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/types.ts"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"path": "helpers/format.ts",
|
|
127
|
+
"type": "registry:file",
|
|
128
|
+
"content": "/**\n * Options accepted by the amount formatters. They mirror the subset of\n * `Intl.NumberFormat` options the widgets need; `locale`, `currency` and\n * `style` have defaults, everything else is passed through untouched.\n */\nexport interface AmountFormatOptions {\n currency?: string\n locale?: string\n maximumFractionDigits?: number\n minimumFractionDigits?: number\n minimumIntegerDigits?: number\n notation?: 'compact' | 'standard'\n signDisplay?: 'always' | 'auto' | 'exceptZero' | 'never'\n style?: 'currency' | 'decimal' | 'percent'\n}\n\n/** An amount split at its decimal separator; see {@link splitAmountAtDecimal}. */\nexport interface AmountParts {\n fraction: string\n integer: string\n}\n\n/** Locale used when `AmountFormatOptions.locale` is omitted. */\nexport const defaultAmountLocale = 'en-US'\n/** Currency used when `AmountFormatOptions.currency` is omitted. */\nexport const defaultAmountCurrency = 'USD'\n\nconst percentFractionDigits = {\n maximumFractionDigits: 2,\n minimumFractionDigits: 2,\n}\n\n/**\n * Creates the `Intl.NumberFormat` behind {@link formatAmount}. Percentages\n * get two fraction digits unless `maximumFractionDigits` is set, and the\n * currency is only forwarded for the `currency` style.\n *\n * @param options - Formatting options; defaults to US dollars in `en-US`.\n * @returns A reusable formatter for the resolved options.\n */\nexport function createAmountFormatter({\n currency = defaultAmountCurrency,\n locale = defaultAmountLocale,\n style = 'currency',\n ...options\n}: AmountFormatOptions = {}): Intl.NumberFormat {\n const usesPercentDefaults =\n style === 'percent' && options.maximumFractionDigits === undefined\n\n return new Intl.NumberFormat(locale, {\n ...options,\n ...(style === 'currency' ? { currency } : {}),\n ...(usesPercentDefaults ? percentFractionDigits : {}),\n style,\n })\n}\n\n/**\n * Formats a number as currency, decimal or percent. Percentages follow the\n * `Intl` convention: `0.0934` becomes `9.34%`.\n *\n * @param value - The amount to format. Percentages are ratios, not points.\n * @param options - Formatting options; defaults to US dollars in `en-US`.\n * @returns The formatted amount for the locale.\n */\nexport function formatAmount(\n value: number,\n options?: AmountFormatOptions,\n): string {\n return createAmountFormatter(options).format(value)\n}\n\n/** Concatenates the values of `Intl.NumberFormat` parts back into text. */\nfunction joinParts(parts: readonly Intl.NumberFormatPart[]): string {\n return parts.map((part) => part.value).join('')\n}\n\n/**\n * Formats an amount and splits it at the decimal separator, so the fraction\n * (separator, digits and any trailing suffix such as `%`) can be rendered\n * with a lighter style than the integer part.\n *\n * @param value - The amount to format.\n * @param options - Formatting options; defaults to US dollars in `en-US`.\n * @returns The integer part and the fraction; the fraction is empty when the\n * formatted amount has no decimal separator.\n */\nexport function splitAmountAtDecimal(\n value: number,\n options?: AmountFormatOptions,\n): AmountParts {\n const parts = createAmountFormatter(options).formatToParts(value)\n const decimalIndex = parts.findIndex((part) => part.type === 'decimal')\n\n if (decimalIndex === -1) return { fraction: '', integer: joinParts(parts) }\n\n return {\n fraction: joinParts(parts.slice(decimalIndex)),\n integer: joinParts(parts.slice(0, decimalIndex)),\n }\n}\n",
|
|
129
|
+
"target": "~/packages/ui/src/helpers/format.ts"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"path": "patterns/surfaces/state/composition/state-surface/state-surface.tsx",
|
|
133
|
+
"type": "registry:file",
|
|
134
|
+
"content": "import {\n FileMagnifyingGlassIcon,\n LockIcon,\n MagnifyingGlassIcon,\n TrayIcon,\n WarningIcon,\n} from '@phosphor-icons/react'\nimport {\n Empty,\n EmptyContent,\n EmptyDescription,\n EmptyHeader,\n EmptyMedia,\n EmptyTitle,\n} from '@tc96/ui/empty'\nimport { IconFrame } from '@tc96/ui/icon-frame'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport {\n STATE_SURFACE_ICON_COLORS,\n STATE_SURFACE_ROLES,\n type StateSurfaceKind,\n type StateSurfaceProps,\n} from '../../core'\n\nconst KIND_ICONS = {\n empty: TrayIcon,\n error: WarningIcon,\n 'no-result': MagnifyingGlassIcon,\n 'not-found': FileMagnifyingGlassIcon,\n permission: LockIcon,\n} as const satisfies Record<StateSurfaceKind, typeof TrayIcon>\n\nexport function StateSurface({\n actions,\n className,\n description,\n icon,\n kind,\n title,\n}: StateSurfaceProps): ReactNode {\n const Icon = KIND_ICONS[kind]\n const iconColor = STATE_SURFACE_ICON_COLORS[kind]\n\n return (\n <Empty\n className={className}\n data-kind={kind}\n role={STATE_SURFACE_ROLES[kind]}\n >\n <EmptyHeader>\n {icon === null ? null : (\n <EmptyMedia>\n <IconFrame\n className={cn(!iconColor && 'bg-muted/60')}\n color={iconColor}\n shape=\"rounded\"\n size=\"xl\"\n >\n {icon === undefined ? <Icon aria-hidden=\"true\" /> : icon}\n </IconFrame>\n </EmptyMedia>\n )}\n <EmptyTitle>{title}</EmptyTitle>\n <EmptyDescription>{description}</EmptyDescription>\n </EmptyHeader>\n {actions ? (\n <EmptyContent className=\"flex-row flex-wrap justify-center gap-2\">\n {actions}\n </EmptyContent>\n ) : null}\n </Empty>\n )\n}\n",
|
|
135
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/composition/state-surface/state-surface.tsx"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"path": "patterns/surfaces/state/core.ts",
|
|
139
|
+
"type": "registry:file",
|
|
140
|
+
"content": "import type { ReactNode } from 'react'\n\nexport const STATE_SURFACE_KINDS = [\n 'empty',\n 'no-result',\n 'error',\n 'permission',\n 'not-found',\n] as const\n\nexport type StateSurfaceKind = (typeof STATE_SURFACE_KINDS)[number]\n\nexport type StateGuardState = 'data' | 'loading' | StateSurfaceKind\n\nexport type StateSurfaceRole = 'alert' | 'status'\n\nexport const STATE_SURFACE_ROLES = {\n empty: 'status',\n error: 'alert',\n 'no-result': 'status',\n 'not-found': 'status',\n permission: 'alert',\n} as const satisfies Record<StateSurfaceKind, StateSurfaceRole>\n\nexport const STATE_SURFACE_ICON_COLORS: Partial<\n Record<StateSurfaceKind, string>\n> = {\n error: 'var(--destructive)',\n permission: 'var(--destructive)',\n}\n\nexport interface StateSurfaceProps {\n actions?: ReactNode\n className?: string\n description: ReactNode\n icon?: ReactNode\n kind: StateSurfaceKind\n title: ReactNode\n}\n\nexport type StateGuardProps = {\n children: ReactNode\n} & (\n | { state: 'data'; surface?: Omit<StateSurfaceProps, 'kind'> }\n | {\n state: 'loading'\n surface: Pick<StateSurfaceProps, 'className' | 'title'> & {\n description?: ReactNode\n }\n }\n | { state: StateSurfaceKind; surface: Omit<StateSurfaceProps, 'kind'> }\n)\n",
|
|
141
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/core.ts"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"path": "patterns/widgets/shared/widget-shell.tsx",
|
|
145
|
+
"type": "registry:file",
|
|
146
|
+
"content": "import { Card } from '@tc96/ui/card'\nimport { cn } from '@tc96/utils'\nimport type { ComponentProps, ReactElement } from 'react'\n\nexport interface WidgetShellProps extends ComponentProps<typeof Card> {}\n\nexport function WidgetShell({\n className,\n render = <section />,\n ...props\n}: Readonly<WidgetShellProps>): ReactElement {\n return (\n <Card\n className={cn('min-w-0 border-transparent', className)}\n render={render}\n {...props}\n />\n )\n}\n",
|
|
147
|
+
"target": "~/packages/ui/src/patterns/widgets/shared/widget-shell.tsx"
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"dependencies": [
|
|
151
|
+
"@phosphor-icons/react@2.1.10",
|
|
152
|
+
"@tanstack/charts@1.5.0",
|
|
153
|
+
"react@19.1.1"
|
|
154
|
+
],
|
|
155
|
+
"registryDependencies": [
|
|
156
|
+
"@ui/badge",
|
|
157
|
+
"@ui/breadcrumb",
|
|
158
|
+
"@ui/button",
|
|
159
|
+
"@ui/card",
|
|
160
|
+
"@ui/empty",
|
|
161
|
+
"@ui/icon-frame",
|
|
162
|
+
"@ui/render-anchor",
|
|
163
|
+
"@ui/select",
|
|
164
|
+
"@ui/skeleton"
|
|
165
|
+
],
|
|
166
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
167
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dashboard-6",
|
|
3
|
+
"type": "registry:block",
|
|
4
|
+
"files": [
|
|
5
|
+
{
|
|
6
|
+
"path": "blocks/application/dashboard/dashboard-6/dashboard-6-skeleton.tsx",
|
|
7
|
+
"type": "registry:file",
|
|
8
|
+
"content": "import { cn } from '@tc96/utils'\nimport {\n KpiSkeleton,\n PanelSkeleton,\n TableSkeleton,\n} from '../shared/dashboard-skeleton-parts'\n\nexport function Dashboard6Skeleton({\n className,\n label,\n title,\n}: Readonly<{ className?: string; label: string; title: string }>) {\n return (\n <section\n aria-busy=\"true\"\n aria-label={label}\n className={cn('grid gap-4', className)}\n >\n <h2 className=\"font-semibold text-lg\">{title}</h2>\n <div className=\"grid gap-4 sm:grid-cols-2 xl:grid-cols-4\">\n <KpiSkeleton />\n <KpiSkeleton />\n <KpiSkeleton />\n <KpiSkeleton />\n </div>\n <div className=\"grid gap-4 xl:grid-cols-[3fr_2fr]\">\n <TableSkeleton rows={4} />\n <PanelSkeleton height={160} />\n </div>\n </section>\n )\n}\n",
|
|
9
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/dashboard-6/dashboard-6-skeleton.tsx"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "blocks/application/dashboard/dashboard-6/dashboard-6.tsx",
|
|
13
|
+
"type": "registry:file",
|
|
14
|
+
"content": "import { StateSurface } from '@tc96/ui/patterns/surfaces/state/composition/state-surface/state-surface'\nimport { renderAnchor } from '@tc96/ui/render-anchor'\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from '@tc96/ui/table'\nimport { cn } from '@tc96/utils'\nimport { CategoryBarChart } from '../shared/category-bar-chart'\nimport { DashboardError } from '../shared/dashboard-error'\nimport { DashboardHeader } from '../shared/dashboard-header'\nimport { DashboardLink } from '../shared/dashboard-link'\nimport { DashboardMetricCard } from '../shared/dashboard-metric-card'\nimport { DashboardPanel } from '../shared/dashboard-panel'\nimport { createMoneyFormatter } from '../shared/format-money'\nimport { Dashboard6Skeleton } from './dashboard-6-skeleton'\nimport { defaultDashboard6Labels } from './labels'\nimport type { Dashboard6Props } from './types'\n\nexport function Dashboard6({\n breadcrumbs,\n className,\n currency,\n error = false,\n labels: labelsProp,\n locale,\n lossReasons,\n onPeriodChange,\n onRetry,\n pending = false,\n period,\n periodOptions,\n renderLink = renderAnchor,\n stages,\n summary,\n}: Readonly<Dashboard6Props>) {\n const labels = { ...defaultDashboard6Labels, ...labelsProp }\n\n if (pending) {\n return (\n <Dashboard6Skeleton\n className={className}\n label={labels.loading}\n title={labels.title}\n />\n )\n }\n\n const numbers = createMoneyFormatter({ currency, locale })\n const leads = (count: number) => labels.leadCount(count, numbers.count(count))\n const isEmpty =\n summary === undefined && stages.length === 0 && lossReasons.length === 0\n\n return (\n <section\n aria-label={labels.title}\n className={cn('grid gap-4', className)}\n data-block=\"dashboard-6\"\n >\n <DashboardHeader\n breadcrumbs={breadcrumbs}\n labels={labels}\n onPeriodChange={onPeriodChange}\n period={period}\n periodOptions={periodOptions}\n renderLink={renderLink}\n />\n {error ? (\n <DashboardError\n description={labels.errorDescription}\n onRetry={onRetry}\n retry={labels.retry}\n title={labels.errorTitle}\n />\n ) : isEmpty ? (\n <StateSurface\n description={labels.emptyDescription}\n kind=\"empty\"\n title={labels.emptyTitle}\n />\n ) : (\n <>\n {summary ? (\n <ul\n aria-label={labels.indicators}\n className=\"m-0 grid list-none gap-4 p-0 sm:grid-cols-2 xl:grid-cols-4\"\n >\n <li className=\"min-w-0\">\n <DashboardMetricCard\n detail={numbers.cents(summary.open.valueCents)}\n id=\"open\"\n label={labels.openLabel}\n value={leads(summary.open.count)}\n />\n </li>\n <li className=\"min-w-0\">\n <DashboardMetricCard\n detail={numbers.cents(summary.won.valueCents)}\n id=\"won\"\n label={labels.wonLabel}\n tone={summary.won.count > 0 ? 'positive' : 'neutral'}\n value={leads(summary.won.count)}\n />\n </li>\n <li className=\"min-w-0\">\n <DashboardMetricCard\n detail={numbers.cents(summary.lost.valueCents)}\n id=\"lost\"\n label={labels.lostLabel}\n value={leads(summary.lost.count)}\n />\n </li>\n <li className=\"min-w-0\">\n <DashboardMetricCard\n detail={labels.conversionDetail}\n id=\"conversion\"\n label={labels.conversionLabel}\n value={\n summary.conversion === null\n ? labels.noConversion\n : numbers.percent(summary.conversion)\n }\n />\n </li>\n </ul>\n ) : null}\n <div className=\"grid items-start gap-4 xl:grid-cols-[3fr_2fr]\">\n <DashboardPanel title={labels.funnelTitle}>\n {summary ? (\n <div className=\"grid gap-0.5\">\n <span className=\"text-muted-foreground text-xs\">\n {labels.funnelTotal}\n </span>\n <span\n className=\"font-semibold text-xl tabular-nums\"\n data-slot=\"dashboard-funnel-total\"\n >\n {numbers.cents(summary.open.valueCents)}\n </span>\n </div>\n ) : null}\n {stages.length > 0 ? (\n <>\n <CategoryBarChart\n data={stages.map((stage) => ({\n id: stage.id,\n label: stage.name,\n value: stage.count,\n }))}\n formatValue={leads}\n label={labels.funnelLabel}\n summary={labels.funnelSummary(\n stages.map((stage) => ({\n count: leads(stage.count),\n label: stage.name,\n })),\n )}\n tooltipText={(datum) =>\n labels.tooltip(datum.label, leads(datum.value))\n }\n />\n <Table aria-label={labels.funnelLabel}>\n <TableHeader>\n <TableRow>\n <TableHead>{labels.columnStage}</TableHead>\n <TableHead className=\"text-right\">\n {labels.columnLeads}\n </TableHead>\n <TableHead className=\"text-right\">\n {labels.columnValue}\n </TableHead>\n </TableRow>\n </TableHeader>\n <TableBody>\n {stages.map((stage) => (\n <TableRow data-stage={stage.id} key={stage.id}>\n <TableCell>\n {stage.href ? (\n <DashboardLink\n className=\"font-medium hover:underline\"\n href={stage.href}\n renderLink={renderLink}\n >\n {stage.name}\n </DashboardLink>\n ) : (\n <span className=\"font-medium\">{stage.name}</span>\n )}\n </TableCell>\n <TableCell className=\"text-right tabular-nums\">\n {numbers.count(stage.count)}\n </TableCell>\n <TableCell className=\"text-right tabular-nums\">\n {numbers.cents(stage.valueCents)}\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </>\n ) : null}\n </DashboardPanel>\n <DashboardPanel title={labels.lossesTitle}>\n {lossReasons.length === 0 ? (\n <p className=\"text-muted-foreground text-sm\">\n {labels.lossesEmpty}\n </p>\n ) : (\n <CategoryBarChart\n color=\"var(--chart-2)\"\n data={lossReasons.map((reason) => ({\n id: reason.id,\n label: reason.name,\n value: reason.count,\n }))}\n formatValue={leads}\n label={labels.lossesLabel}\n summary={labels.lossesSummary(\n lossReasons.map((reason) => ({\n count: leads(reason.count),\n label: reason.name,\n })),\n )}\n tooltipText={(datum) =>\n labels.tooltip(datum.label, leads(datum.value))\n }\n />\n )}\n </DashboardPanel>\n </div>\n </>\n )}\n </section>\n )\n}\n",
|
|
15
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/dashboard-6/dashboard-6.tsx"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "blocks/application/dashboard/dashboard-6/index.ts",
|
|
19
|
+
"type": "registry:file",
|
|
20
|
+
"content": "export { Dashboard6 } from './dashboard-6'\nexport type {\n Dashboard6CountSummaryItem,\n Dashboard6Labels,\n Dashboard6LossReason,\n Dashboard6Props,\n Dashboard6Stage,\n Dashboard6Summary,\n Dashboard6Total,\n} from './types'\n",
|
|
21
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/dashboard-6/index.ts"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "blocks/application/dashboard/dashboard-6/labels.ts",
|
|
25
|
+
"type": "registry:file",
|
|
26
|
+
"content": "import type { Dashboard6Labels } from './types'\n\nconst joinCounts = (items: { count: string; label: string }[]) =>\n items.map((item) => `${item.label}: ${item.count}`).join('; ')\n\nexport const defaultDashboard6Labels: Dashboard6Labels = {\n breadcrumb: 'Navegação estrutural',\n columnLeads: 'Leads',\n columnStage: 'Etapa',\n columnValue: 'Valor',\n conversionDetail: 'ganhos entre os encerrados',\n conversionLabel: 'Conversão',\n description: 'Leads em aberto, ganhos, perdas e motivos do período.',\n emptyDescription: 'O resumo aparece aqui assim que houver leads no funil.',\n emptyTitle: 'Nenhum lead no funil',\n errorDescription: 'Tente de novo em instantes.',\n errorTitle: 'Não foi possível carregar o resumo do funil',\n export: 'Exportar',\n funnelLabel: 'Leads em aberto por etapa',\n funnelSummary: joinCounts,\n funnelTitle: 'Funil',\n funnelTotal: 'Em aberto no funil',\n indicators: 'Indicadores',\n leadCount: (count, formatted) =>\n count === 1 ? `${formatted} lead` : `${formatted} leads`,\n loading: 'Carregando o resumo do funil',\n lossesEmpty: 'Nenhuma perda no período.',\n lossesLabel: 'Leads perdidos por motivo',\n lossesSummary: joinCounts,\n lossesTitle: 'Perdas por motivo',\n lostLabel: 'Perdidos no período',\n noConversion: '—',\n openLabel: 'Em aberto',\n period: 'Período do resumo',\n retry: 'Tentar de novo',\n title: 'Analítico',\n tooltip: (label, count) => `${label}: ${count}`,\n wonLabel: 'Ganhos no período',\n}\n",
|
|
27
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/dashboard-6/labels.ts"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "blocks/application/dashboard/dashboard-6/types.ts",
|
|
31
|
+
"type": "registry:file",
|
|
32
|
+
"content": "import type { RenderLink } from '@tc96/ui/render-anchor'\nimport type {\n DashboardBreadcrumbItem,\n DashboardFormatProps,\n DashboardOption,\n} from '../shared/types'\n\nexport interface Dashboard6Total {\n count: number\n valueCents: number\n}\n\nexport interface Dashboard6Stage {\n count: number\n href?: string\n id: string\n name: string\n valueCents: number\n}\n\nexport interface Dashboard6LossReason {\n count: number\n id: string\n name: string\n}\n\nexport interface Dashboard6Summary {\n conversion: number | null\n lost: Dashboard6Total\n open: Dashboard6Total\n won: Dashboard6Total\n}\n\nexport interface Dashboard6CountSummaryItem {\n count: string\n label: string\n}\n\nexport interface Dashboard6Labels {\n breadcrumb: string\n columnLeads: string\n columnStage: string\n columnValue: string\n conversionDetail: string\n conversionLabel: string\n description: string\n emptyDescription: string\n emptyTitle: string\n errorDescription: string\n errorTitle: string\n export: string\n funnelLabel: string\n funnelSummary: (items: Dashboard6CountSummaryItem[]) => string\n funnelTitle: string\n funnelTotal: string\n indicators: string\n leadCount: (count: number, formatted: string) => string\n loading: string\n lossesEmpty: string\n lossesLabel: string\n lossesSummary: (items: Dashboard6CountSummaryItem[]) => string\n lossesTitle: string\n lostLabel: string\n noConversion: string\n openLabel: string\n period: string\n retry: string\n title: string\n tooltip: (label: string, count: string) => string\n wonLabel: string\n}\n\nexport interface Dashboard6Props extends DashboardFormatProps {\n breadcrumbs?: DashboardBreadcrumbItem[]\n className?: string\n error?: boolean\n labels?: Partial<Dashboard6Labels>\n lossReasons: Dashboard6LossReason[]\n onPeriodChange?: (period: string) => void\n onRetry?: () => void\n pending?: boolean\n period?: string\n periodOptions?: DashboardOption[]\n renderLink?: RenderLink\n stages: Dashboard6Stage[]\n summary?: Dashboard6Summary\n}\n",
|
|
33
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/dashboard-6/types.ts"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "blocks/application/dashboard/shared/category-bar-chart.tsx",
|
|
37
|
+
"type": "registry:file",
|
|
38
|
+
"content": "import { barX, defineChart, text } from '@tanstack/charts'\nimport { scaleBand } from '@tanstack/charts/scales/band'\nimport { scaleLinear } from '@tanstack/charts/scales/linear'\nimport { tooltip } from '@tanstack/charts/tooltip'\nimport { useMemo } from 'react'\nimport { TanstackChartFrame, tanstackChartTheme } from './tanstack-chart-frame'\n\nexport interface CategoryBarDatum {\n id: string\n label: string\n value: number\n}\n\nexport interface CategoryBarChartProps {\n color?: string\n data: readonly CategoryBarDatum[]\n formatValue: (value: number) => string\n label: string\n summary: string\n tooltipText: (datum: CategoryBarDatum) => string\n}\n\nconst rowHeight = 36\n\nexport function CategoryBarChart({\n color = 'var(--chart-1)',\n data,\n formatValue,\n label,\n summary,\n tooltipText,\n}: Readonly<CategoryBarChartProps>) {\n const definition = useMemo(\n () =>\n defineChart({\n focus: 'group-y',\n marks: [\n barX(data, {\n fill: color,\n key: (datum) => datum.id,\n radius: { end: 4 },\n x: (datum) => datum.value,\n y: (datum) => datum.label,\n }),\n text(data, {\n anchor: 'start',\n dx: 6,\n fill: 'var(--foreground)',\n fontWeight: 500,\n key: (datum) => `${datum.id}-value`,\n text: (datum) => formatValue(datum.value),\n x: (datum) => datum.value,\n y: (datum) => datum.label,\n }),\n ],\n margin: { right: 72 },\n scales: {\n x: { axis: false, nice: true, scale: scaleLinear },\n y: { scale: () => scaleBand<string>().padding(0.28) },\n },\n theme: tanstackChartTheme,\n tooltip: {\n format: ({ datum }: { datum: CategoryBarDatum }) =>\n tooltipText(datum),\n use: tooltip,\n },\n }),\n [color, data, formatValue, tooltipText],\n )\n\n return (\n <TanstackChartFrame\n definition={definition}\n height={Math.max(data.length, 1) * rowHeight + 16}\n label={label}\n summary={summary}\n />\n )\n}\n",
|
|
39
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/category-bar-chart.tsx"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "blocks/application/dashboard/shared/dashboard-error.tsx",
|
|
43
|
+
"type": "registry:file",
|
|
44
|
+
"content": "import { Button } from '@tc96/ui/button'\nimport { StateSurface } from '@tc96/ui/patterns/surfaces/state/composition/state-surface/state-surface'\n\nexport interface DashboardErrorProps {\n description: string\n onRetry?: () => void\n retry: string\n title: string\n}\n\nexport function DashboardError({\n description,\n onRetry,\n retry,\n title,\n}: Readonly<DashboardErrorProps>) {\n return (\n <StateSurface\n actions={\n onRetry ? (\n <Button onClick={onRetry} size=\"sm\" variant=\"outline\">\n {retry}\n </Button>\n ) : undefined\n }\n description={description}\n kind=\"error\"\n title={title}\n />\n )\n}\n",
|
|
45
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-error.tsx"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "blocks/application/dashboard/shared/dashboard-header.tsx",
|
|
49
|
+
"type": "registry:file",
|
|
50
|
+
"content": "import { DownloadSimpleIcon } from '@phosphor-icons/react'\nimport {\n Breadcrumb,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbList,\n BreadcrumbPage,\n BreadcrumbSeparator,\n} from '@tc96/ui/breadcrumb'\nimport { Button } from '@tc96/ui/button'\nimport {\n Select,\n SelectItem,\n SelectPopup,\n SelectTrigger,\n SelectValue,\n} from '@tc96/ui/select'\nimport { Fragment } from 'react'\nimport type { DashboardHeaderLabels, DashboardHeaderProps } from './types'\n\nexport interface DashboardHeaderComponentProps extends DashboardHeaderProps {\n labels: DashboardHeaderLabels\n showExport?: boolean\n}\n\nexport function DashboardHeader({\n breadcrumbs,\n labels,\n onExport,\n onPeriodChange,\n period,\n periodOptions,\n renderLink,\n showExport = true,\n}: Readonly<DashboardHeaderComponentProps>) {\n const hasPeriod =\n onPeriodChange !== undefined &&\n period !== undefined &&\n periodOptions !== undefined &&\n periodOptions.length > 0\n\n return (\n <header\n className=\"flex flex-wrap items-end justify-between gap-4\"\n data-slot=\"dashboard-header\"\n >\n <div className=\"grid min-w-0 gap-1.5\">\n {breadcrumbs?.length ? (\n <Breadcrumb aria-label={labels.breadcrumb}>\n <BreadcrumbList>\n {breadcrumbs.map((item, index) => {\n const current = index === breadcrumbs.length - 1\n return (\n <Fragment key={`${index}-${item.label}`}>\n <BreadcrumbItem>\n {current ? (\n <BreadcrumbPage>{item.label}</BreadcrumbPage>\n ) : item.href && renderLink ? (\n <BreadcrumbLink render={renderLink(item.href)}>\n {item.label}\n </BreadcrumbLink>\n ) : (\n item.label\n )}\n </BreadcrumbItem>\n {current ? null : <BreadcrumbSeparator />}\n </Fragment>\n )\n })}\n </BreadcrumbList>\n </Breadcrumb>\n ) : null}\n <h2 className=\"font-semibold text-lg\">{labels.title}</h2>\n {labels.description ? (\n <p className=\"text-muted-foreground text-sm\">{labels.description}</p>\n ) : null}\n </div>\n {hasPeriod || (onExport && showExport) ? (\n <div className=\"flex flex-wrap items-center gap-2\">\n {hasPeriod ? (\n <Select\n items={periodOptions}\n onValueChange={(next) => {\n if (next) onPeriodChange(next)\n }}\n value={period}\n >\n <SelectTrigger aria-label={labels.period} className=\"w-44\">\n <SelectValue />\n </SelectTrigger>\n <SelectPopup>\n {periodOptions.map((option) => (\n <SelectItem key={option.value} value={option.value}>\n {option.label}\n </SelectItem>\n ))}\n </SelectPopup>\n </Select>\n ) : null}\n {onExport && showExport ? (\n <Button onClick={onExport} size=\"sm\" variant=\"outline\">\n <DownloadSimpleIcon aria-hidden=\"true\" />\n {labels.export}\n </Button>\n ) : null}\n </div>\n ) : null}\n </header>\n )\n}\n",
|
|
51
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-header.tsx"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "blocks/application/dashboard/shared/dashboard-link.tsx",
|
|
55
|
+
"type": "registry:file",
|
|
56
|
+
"content": "import type { RenderLink } from '@tc96/ui/render-anchor'\nimport { cn } from '@tc96/utils'\nimport { cloneElement, type ReactElement, type ReactNode } from 'react'\n\nexport interface DashboardLinkProps {\n 'aria-label'?: string\n children: ReactNode\n className?: string\n href: string\n renderLink: RenderLink\n}\n\nexport function DashboardLink({\n 'aria-label': ariaLabel,\n children,\n className,\n href,\n renderLink,\n}: Readonly<DashboardLinkProps>) {\n const element = renderLink(href) as ReactElement<{\n 'aria-label'?: string\n className?: string\n }>\n\n return cloneElement(\n element,\n {\n 'aria-label': ariaLabel,\n className: cn(\n 'rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background',\n element.props.className,\n className,\n ),\n },\n children,\n )\n}\n",
|
|
57
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-link.tsx"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"path": "blocks/application/dashboard/shared/dashboard-metric-card.tsx",
|
|
61
|
+
"type": "registry:file",
|
|
62
|
+
"content": "import { CaretRightIcon } from '@phosphor-icons/react'\nimport { CardPanel } from '@tc96/ui/card'\nimport { WidgetShell } from '@tc96/ui/patterns/widgets/shared/widget-shell'\nimport type { RenderLink } from '@tc96/ui/render-anchor'\nimport { cn } from '@tc96/utils'\nimport { DashboardLink } from './dashboard-link'\n\nexport type DashboardMetricTone =\n | 'negative'\n | 'neutral'\n | 'positive'\n | 'warning'\n\nconst toneClassNames: Record<DashboardMetricTone, string> = {\n negative: 'text-destructive-foreground',\n neutral: 'text-foreground',\n positive: 'text-success-foreground',\n warning: 'text-warning-foreground',\n}\n\nexport interface DashboardMetricCardProps {\n description?: string\n detail?: string\n href?: string\n id: string\n label: string\n renderLink?: RenderLink\n tone?: DashboardMetricTone\n value: string\n}\n\nexport function DashboardMetricCard({\n description,\n detail,\n href,\n id,\n label,\n renderLink,\n tone = 'neutral',\n value,\n}: Readonly<DashboardMetricCardProps>) {\n return (\n <WidgetShell className=\"h-full\" data-metric={id}>\n <CardPanel className=\"grid content-start gap-2 p-5\">\n {href && renderLink ? (\n <DashboardLink\n className=\"flex items-center justify-between gap-2 text-muted-foreground text-sm hover:text-foreground\"\n href={href}\n renderLink={renderLink}\n >\n {label}\n <CaretRightIcon aria-hidden=\"true\" className=\"size-3.5 shrink-0\" />\n </DashboardLink>\n ) : (\n <p className=\"text-muted-foreground text-sm\">{label}</p>\n )}\n <p\n className={cn(\n 'font-semibold text-2xl tabular-nums',\n toneClassNames[tone],\n )}\n data-slot=\"dashboard-metric-value\"\n >\n {value}\n </p>\n {detail ? (\n <p className=\"text-muted-foreground text-xs tabular-nums\">{detail}</p>\n ) : null}\n {description ? (\n <p\n className=\"text-muted-foreground text-xs\"\n data-slot=\"dashboard-metric-description\"\n >\n {description}\n </p>\n ) : null}\n </CardPanel>\n </WidgetShell>\n )\n}\n",
|
|
63
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-metric-card.tsx"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"path": "blocks/application/dashboard/shared/dashboard-panel.tsx",
|
|
67
|
+
"type": "registry:file",
|
|
68
|
+
"content": "import { CardAction, CardHeader, CardPanel, CardTitle } from '@tc96/ui/card'\nimport { WidgetShell } from '@tc96/ui/patterns/widgets/shared/widget-shell'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport { useId } from 'react'\n\nexport interface DashboardPanelProps {\n action?: ReactNode\n children: ReactNode\n className?: string\n title: string\n}\n\nexport function DashboardPanel({\n action,\n children,\n className,\n title,\n}: Readonly<DashboardPanelProps>) {\n const titleId = useId()\n\n return (\n <WidgetShell aria-labelledby={titleId} className={className}>\n <CardHeader className=\"grid-rows-1 items-center p-5\">\n <CardTitle className=\"font-semibold text-base\" id={titleId}>\n {title}\n </CardTitle>\n {action ? (\n <CardAction className=\"row-span-1 self-center\">{action}</CardAction>\n ) : null}\n </CardHeader>\n <CardPanel className={cn('grid gap-4 px-5 pb-5')}>{children}</CardPanel>\n </WidgetShell>\n )\n}\n",
|
|
69
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-panel.tsx"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"path": "blocks/application/dashboard/shared/dashboard-skeleton-parts.tsx",
|
|
73
|
+
"type": "registry:file",
|
|
74
|
+
"content": "import { CardPanel } from '@tc96/ui/card'\nimport { WidgetShell } from '@tc96/ui/patterns/widgets/shared/widget-shell'\nimport { Skeleton } from '@tc96/ui/skeleton'\n\nconst rowKeys = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight']\n\nexport function KpiSkeleton() {\n return (\n <WidgetShell>\n <CardPanel className=\"grid gap-3 p-5\">\n <Skeleton className=\"h-4 w-24\" />\n <Skeleton className=\"h-7 w-32\" />\n <Skeleton className=\"h-3 w-16\" />\n </CardPanel>\n </WidgetShell>\n )\n}\n\nexport function PanelSkeleton({\n className,\n height = 220,\n}: Readonly<{ className?: string; height?: number }>) {\n return (\n <WidgetShell className={className}>\n <CardPanel className=\"grid gap-4 p-5\">\n <Skeleton className=\"h-5 w-40\" />\n <Skeleton style={{ height }} />\n </CardPanel>\n </WidgetShell>\n )\n}\n\nexport function TableSkeleton({\n className,\n rows = 5,\n}: Readonly<{ className?: string; rows?: number }>) {\n return (\n <WidgetShell className={className}>\n <CardPanel className=\"grid gap-3 p-5\">\n <Skeleton className=\"h-5 w-40\" />\n {rowKeys.slice(0, rows).map((key) => (\n <Skeleton className=\"h-8\" key={key} />\n ))}\n </CardPanel>\n </WidgetShell>\n )\n}\n",
|
|
75
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/dashboard-skeleton-parts.tsx"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"path": "blocks/application/dashboard/shared/format-money.ts",
|
|
79
|
+
"type": "registry:file",
|
|
80
|
+
"content": "import { formatAmount } from '@tc96/ui/helpers/format'\nimport { defaultDashboardCurrency, defaultDashboardLocale } from './format'\nimport type { DashboardFormatProps } from './types'\n\nexport function createMoneyFormatter({\n currency = defaultDashboardCurrency,\n locale = defaultDashboardLocale,\n}: DashboardFormatProps = {}) {\n const cents = (amount: number) =>\n formatAmount(amount / 100, { currency, locale, style: 'currency' })\n\n const compactCents = (amount: number) =>\n formatAmount(amount / 100, {\n currency,\n locale,\n maximumFractionDigits: 1,\n notation: 'compact',\n style: 'currency',\n })\n\n const count = (amount: number) =>\n formatAmount(amount, {\n locale,\n maximumFractionDigits: 0,\n style: 'decimal',\n })\n\n const percent = (ratio: number) =>\n formatAmount(ratio, {\n locale,\n maximumFractionDigits: 1,\n minimumFractionDigits: 0,\n style: 'percent',\n })\n\n return { cents, compactCents, count, percent }\n}\n\nexport type MoneyFormatter = ReturnType<typeof createMoneyFormatter>\n",
|
|
81
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/format-money.ts"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"path": "blocks/application/dashboard/shared/format.ts",
|
|
85
|
+
"type": "registry:file",
|
|
86
|
+
"content": "import { formatAmount } from '@tc96/ui/helpers/format'\nimport type { DashboardFormatProps, DashboardValueFormat } from './types'\n\nexport const defaultDashboardLocale = 'pt-BR'\nexport const defaultDashboardCurrency = 'BRL'\n\nexport function createDashboardFormatter({\n currency = defaultDashboardCurrency,\n locale = defaultDashboardLocale,\n}: DashboardFormatProps = {}) {\n const value = (amount: number, format: DashboardValueFormat = 'number') => {\n if (format === 'currency') {\n return formatAmount(amount, {\n currency,\n locale,\n maximumFractionDigits: 0,\n style: 'currency',\n })\n }\n if (format === 'percent') {\n return formatAmount(amount, {\n locale,\n maximumFractionDigits: 1,\n minimumFractionDigits: 0,\n style: 'percent',\n })\n }\n return formatAmount(amount, {\n locale,\n maximumFractionDigits: 1,\n style: 'decimal',\n })\n }\n\n const exactCurrency = (amount: number) =>\n formatAmount(amount, { currency, locale, style: 'currency' })\n\n const delta = (amount: number) =>\n formatAmount(amount, {\n locale,\n maximumFractionDigits: 1,\n minimumFractionDigits: 0,\n signDisplay: 'exceptZero',\n style: 'percent',\n })\n\n return { currency: exactCurrency, delta, value }\n}\n\nexport type DashboardFormatter = ReturnType<typeof createDashboardFormatter>\n",
|
|
87
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/format.ts"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"path": "blocks/application/dashboard/shared/tanstack-chart-frame.tsx",
|
|
91
|
+
"type": "registry:file",
|
|
92
|
+
"content": "import type {\n ChartTheme,\n ChartValue,\n DomChartDefinition,\n} from '@tanstack/charts'\nimport { Chart } from '@tanstack/charts/react'\n\nexport const tanstackChartTheme: Partial<ChartTheme> = {\n foreground: 'var(--foreground)',\n grid: 'var(--border)',\n muted: 'var(--muted-foreground)',\n palette: [\n 'var(--chart-1)',\n 'var(--chart-2)',\n 'var(--chart-3)',\n 'var(--chart-4)',\n 'var(--chart-5)',\n ],\n}\n\nexport interface TanstackChartFrameProps<\n TDatum,\n TXValue extends ChartValue,\n TYValue extends ChartValue,\n> {\n definition: DomChartDefinition<TDatum, TXValue, TYValue>\n height?: number\n label: string\n summary: string\n}\n\nexport function TanstackChartFrame<\n TDatum,\n TXValue extends ChartValue,\n TYValue extends ChartValue,\n>({\n definition,\n height = 240,\n label,\n summary,\n}: Readonly<TanstackChartFrameProps<TDatum, TXValue, TYValue>>) {\n return (\n <div\n className=\"min-w-0 text-muted-foreground text-xs [--ts-chart-tooltip-background:var(--popover)] [--ts-chart-tooltip-border:1px_solid_var(--border)] [--ts-chart-tooltip-color:var(--popover-foreground)]\"\n data-slot=\"dashboard-chart\"\n >\n <Chart<TDatum, TXValue, TYValue>\n ariaDescription={summary}\n ariaLabel={label}\n definition={definition}\n height={height}\n />\n </div>\n )\n}\n",
|
|
93
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/tanstack-chart-frame.tsx"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"path": "blocks/application/dashboard/shared/types.ts",
|
|
97
|
+
"type": "registry:file",
|
|
98
|
+
"content": "import type { RenderLink } from '@tc96/ui/render-anchor'\n\nexport type DashboardTone =\n | 'error'\n | 'info'\n | 'outline'\n | 'secondary'\n | 'success'\n | 'warning'\n\nexport interface DashboardBadgeData {\n label: string\n tone?: DashboardTone\n}\n\nexport type DashboardValueFormat = 'currency' | 'number' | 'percent'\n\nexport type DashboardTrend = 'negative' | 'neutral' | 'positive'\n\nexport interface DashboardKpi {\n delta?: number\n format?: DashboardValueFormat\n id: string\n label: string\n sparkline?: number[]\n trend?: DashboardTrend\n value: number\n}\n\nexport interface DashboardFormatProps {\n currency?: string\n locale?: string\n}\n\nexport interface DashboardBreadcrumbItem {\n href?: string\n label: string\n}\n\nexport interface DashboardOption {\n label: string\n value: string\n}\n\nexport interface DashboardFilterOption extends DashboardOption {\n count?: number\n}\n\nexport interface DashboardRowAction {\n destructive?: boolean\n id: string\n label: string\n}\n\nexport interface DashboardPagination {\n page: number\n pageCount: number\n}\n\nexport interface DashboardHeaderProps {\n breadcrumbs?: DashboardBreadcrumbItem[]\n onExport?: () => void\n onPeriodChange?: (period: string) => void\n period?: string\n periodOptions?: DashboardOption[]\n renderLink?: RenderLink\n}\n\nexport interface DashboardHeaderLabels {\n breadcrumb: string\n description: string\n export: string\n period: string\n title: string\n}\n\nexport interface DashboardTableLabels {\n nextPage: string\n pageOf: (page: number, pageCount: number) => string\n pagination: string\n previousPage: string\n search: string\n}\n",
|
|
99
|
+
"target": "~/packages/ui/src/blocks/application/dashboard/shared/types.ts"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"path": "helpers/format.ts",
|
|
103
|
+
"type": "registry:file",
|
|
104
|
+
"content": "/**\n * Options accepted by the amount formatters. They mirror the subset of\n * `Intl.NumberFormat` options the widgets need; `locale`, `currency` and\n * `style` have defaults, everything else is passed through untouched.\n */\nexport interface AmountFormatOptions {\n currency?: string\n locale?: string\n maximumFractionDigits?: number\n minimumFractionDigits?: number\n minimumIntegerDigits?: number\n notation?: 'compact' | 'standard'\n signDisplay?: 'always' | 'auto' | 'exceptZero' | 'never'\n style?: 'currency' | 'decimal' | 'percent'\n}\n\n/** An amount split at its decimal separator; see {@link splitAmountAtDecimal}. */\nexport interface AmountParts {\n fraction: string\n integer: string\n}\n\n/** Locale used when `AmountFormatOptions.locale` is omitted. */\nexport const defaultAmountLocale = 'en-US'\n/** Currency used when `AmountFormatOptions.currency` is omitted. */\nexport const defaultAmountCurrency = 'USD'\n\nconst percentFractionDigits = {\n maximumFractionDigits: 2,\n minimumFractionDigits: 2,\n}\n\n/**\n * Creates the `Intl.NumberFormat` behind {@link formatAmount}. Percentages\n * get two fraction digits unless `maximumFractionDigits` is set, and the\n * currency is only forwarded for the `currency` style.\n *\n * @param options - Formatting options; defaults to US dollars in `en-US`.\n * @returns A reusable formatter for the resolved options.\n */\nexport function createAmountFormatter({\n currency = defaultAmountCurrency,\n locale = defaultAmountLocale,\n style = 'currency',\n ...options\n}: AmountFormatOptions = {}): Intl.NumberFormat {\n const usesPercentDefaults =\n style === 'percent' && options.maximumFractionDigits === undefined\n\n return new Intl.NumberFormat(locale, {\n ...options,\n ...(style === 'currency' ? { currency } : {}),\n ...(usesPercentDefaults ? percentFractionDigits : {}),\n style,\n })\n}\n\n/**\n * Formats a number as currency, decimal or percent. Percentages follow the\n * `Intl` convention: `0.0934` becomes `9.34%`.\n *\n * @param value - The amount to format. Percentages are ratios, not points.\n * @param options - Formatting options; defaults to US dollars in `en-US`.\n * @returns The formatted amount for the locale.\n */\nexport function formatAmount(\n value: number,\n options?: AmountFormatOptions,\n): string {\n return createAmountFormatter(options).format(value)\n}\n\n/** Concatenates the values of `Intl.NumberFormat` parts back into text. */\nfunction joinParts(parts: readonly Intl.NumberFormatPart[]): string {\n return parts.map((part) => part.value).join('')\n}\n\n/**\n * Formats an amount and splits it at the decimal separator, so the fraction\n * (separator, digits and any trailing suffix such as `%`) can be rendered\n * with a lighter style than the integer part.\n *\n * @param value - The amount to format.\n * @param options - Formatting options; defaults to US dollars in `en-US`.\n * @returns The integer part and the fraction; the fraction is empty when the\n * formatted amount has no decimal separator.\n */\nexport function splitAmountAtDecimal(\n value: number,\n options?: AmountFormatOptions,\n): AmountParts {\n const parts = createAmountFormatter(options).formatToParts(value)\n const decimalIndex = parts.findIndex((part) => part.type === 'decimal')\n\n if (decimalIndex === -1) return { fraction: '', integer: joinParts(parts) }\n\n return {\n fraction: joinParts(parts.slice(decimalIndex)),\n integer: joinParts(parts.slice(0, decimalIndex)),\n }\n}\n",
|
|
105
|
+
"target": "~/packages/ui/src/helpers/format.ts"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"path": "patterns/surfaces/state/composition/state-surface/state-surface.tsx",
|
|
109
|
+
"type": "registry:file",
|
|
110
|
+
"content": "import {\n FileMagnifyingGlassIcon,\n LockIcon,\n MagnifyingGlassIcon,\n TrayIcon,\n WarningIcon,\n} from '@phosphor-icons/react'\nimport {\n Empty,\n EmptyContent,\n EmptyDescription,\n EmptyHeader,\n EmptyMedia,\n EmptyTitle,\n} from '@tc96/ui/empty'\nimport { IconFrame } from '@tc96/ui/icon-frame'\nimport { cn } from '@tc96/utils'\nimport type { ReactNode } from 'react'\nimport {\n STATE_SURFACE_ICON_COLORS,\n STATE_SURFACE_ROLES,\n type StateSurfaceKind,\n type StateSurfaceProps,\n} from '../../core'\n\nconst KIND_ICONS = {\n empty: TrayIcon,\n error: WarningIcon,\n 'no-result': MagnifyingGlassIcon,\n 'not-found': FileMagnifyingGlassIcon,\n permission: LockIcon,\n} as const satisfies Record<StateSurfaceKind, typeof TrayIcon>\n\nexport function StateSurface({\n actions,\n className,\n description,\n icon,\n kind,\n title,\n}: StateSurfaceProps): ReactNode {\n const Icon = KIND_ICONS[kind]\n const iconColor = STATE_SURFACE_ICON_COLORS[kind]\n\n return (\n <Empty\n className={className}\n data-kind={kind}\n role={STATE_SURFACE_ROLES[kind]}\n >\n <EmptyHeader>\n {icon === null ? null : (\n <EmptyMedia>\n <IconFrame\n className={cn(!iconColor && 'bg-muted/60')}\n color={iconColor}\n shape=\"rounded\"\n size=\"xl\"\n >\n {icon === undefined ? <Icon aria-hidden=\"true\" /> : icon}\n </IconFrame>\n </EmptyMedia>\n )}\n <EmptyTitle>{title}</EmptyTitle>\n <EmptyDescription>{description}</EmptyDescription>\n </EmptyHeader>\n {actions ? (\n <EmptyContent className=\"flex-row flex-wrap justify-center gap-2\">\n {actions}\n </EmptyContent>\n ) : null}\n </Empty>\n )\n}\n",
|
|
111
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/composition/state-surface/state-surface.tsx"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"path": "patterns/surfaces/state/core.ts",
|
|
115
|
+
"type": "registry:file",
|
|
116
|
+
"content": "import type { ReactNode } from 'react'\n\nexport const STATE_SURFACE_KINDS = [\n 'empty',\n 'no-result',\n 'error',\n 'permission',\n 'not-found',\n] as const\n\nexport type StateSurfaceKind = (typeof STATE_SURFACE_KINDS)[number]\n\nexport type StateGuardState = 'data' | 'loading' | StateSurfaceKind\n\nexport type StateSurfaceRole = 'alert' | 'status'\n\nexport const STATE_SURFACE_ROLES = {\n empty: 'status',\n error: 'alert',\n 'no-result': 'status',\n 'not-found': 'status',\n permission: 'alert',\n} as const satisfies Record<StateSurfaceKind, StateSurfaceRole>\n\nexport const STATE_SURFACE_ICON_COLORS: Partial<\n Record<StateSurfaceKind, string>\n> = {\n error: 'var(--destructive)',\n permission: 'var(--destructive)',\n}\n\nexport interface StateSurfaceProps {\n actions?: ReactNode\n className?: string\n description: ReactNode\n icon?: ReactNode\n kind: StateSurfaceKind\n title: ReactNode\n}\n\nexport type StateGuardProps = {\n children: ReactNode\n} & (\n | { state: 'data'; surface?: Omit<StateSurfaceProps, 'kind'> }\n | {\n state: 'loading'\n surface: Pick<StateSurfaceProps, 'className' | 'title'> & {\n description?: ReactNode\n }\n }\n | { state: StateSurfaceKind; surface: Omit<StateSurfaceProps, 'kind'> }\n)\n",
|
|
117
|
+
"target": "~/packages/ui/src/patterns/surfaces/state/core.ts"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"path": "patterns/widgets/shared/widget-shell.tsx",
|
|
121
|
+
"type": "registry:file",
|
|
122
|
+
"content": "import { Card } from '@tc96/ui/card'\nimport { cn } from '@tc96/utils'\nimport type { ComponentProps, ReactElement } from 'react'\n\nexport interface WidgetShellProps extends ComponentProps<typeof Card> {}\n\nexport function WidgetShell({\n className,\n render = <section />,\n ...props\n}: Readonly<WidgetShellProps>): ReactElement {\n return (\n <Card\n className={cn('min-w-0 border-transparent', className)}\n render={render}\n {...props}\n />\n )\n}\n",
|
|
123
|
+
"target": "~/packages/ui/src/patterns/widgets/shared/widget-shell.tsx"
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
"dependencies": [
|
|
127
|
+
"@phosphor-icons/react@2.1.10",
|
|
128
|
+
"@tanstack/charts@1.5.0",
|
|
129
|
+
"react@19.1.1"
|
|
130
|
+
],
|
|
131
|
+
"registryDependencies": [
|
|
132
|
+
"@ui/breadcrumb",
|
|
133
|
+
"@ui/button",
|
|
134
|
+
"@ui/card",
|
|
135
|
+
"@ui/empty",
|
|
136
|
+
"@ui/icon-frame",
|
|
137
|
+
"@ui/render-anchor",
|
|
138
|
+
"@ui/select",
|
|
139
|
+
"@ui/skeleton",
|
|
140
|
+
"@ui/table"
|
|
141
|
+
],
|
|
142
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json"
|
|
143
|
+
}
|