@vowt-tech/ui 0.0.0-stage → 0.177.1

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.
Files changed (116) hide show
  1. package/README.md +13 -2
  2. package/bin/vowt-ux-ui-design.mjs +483 -0
  3. package/guia/LEIA-PRIMEIRO.md +106 -0
  4. package/guia/VERSAO +1 -0
  5. package/guia/componentes.md +104 -0
  6. package/guia/regras/atualizar.md +136 -0
  7. package/guia/regras/componentes.md +374 -0
  8. package/guia/regras/fundamentos.md +257 -0
  9. package/guia/regras/marca.md +200 -0
  10. package/guia/regras/medidas.md +114 -0
  11. package/guia/regras/regras-de-base.md +85 -0
  12. package/guia/regras/telas/acoes.md +56 -0
  13. package/guia/regras/telas/direcao-ux.md +327 -0
  14. package/guia/regras/telas/padroes.md +58 -0
  15. package/guia/regras/telas/regras.md +171 -0
  16. package/guia/regras/telas/voz.md +134 -0
  17. package/package.json +72 -4
  18. package/src/brand/icons.ts +215 -0
  19. package/src/brand/logo.tsx +288 -0
  20. package/src/components/accordion.tsx +58 -0
  21. package/src/components/ai-orb.tsx +67 -0
  22. package/src/components/alert-dialog.tsx +227 -0
  23. package/src/components/alert.tsx +128 -0
  24. package/src/components/area-chart.tsx +180 -0
  25. package/src/components/attachment.tsx +339 -0
  26. package/src/components/avatar.tsx +197 -0
  27. package/src/components/badge.tsx +242 -0
  28. package/src/components/bar-chart.tsx +138 -0
  29. package/src/components/bar-list.tsx +85 -0
  30. package/src/components/brand-icon.tsx +52 -0
  31. package/src/components/breadcrumb.tsx +96 -0
  32. package/src/components/button-group.tsx +29 -0
  33. package/src/components/button.tsx +208 -0
  34. package/src/components/calendar.tsx +238 -0
  35. package/src/components/card.tsx +136 -0
  36. package/src/components/chart.tsx +289 -0
  37. package/src/components/checkbox.tsx +42 -0
  38. package/src/components/code-block.tsx +31 -0
  39. package/src/components/collapsible.tsx +114 -0
  40. package/src/components/color-picker.tsx +93 -0
  41. package/src/components/combo-chart.tsx +139 -0
  42. package/src/components/combobox.tsx +200 -0
  43. package/src/components/command.tsx +191 -0
  44. package/src/components/date-picker.tsx +435 -0
  45. package/src/components/description-list.tsx +280 -0
  46. package/src/components/dialog.tsx +192 -0
  47. package/src/components/diff-view.tsx +109 -0
  48. package/src/components/dropdown-menu.tsx +248 -0
  49. package/src/components/emoji-picker.tsx +299 -0
  50. package/src/components/empty.tsx +197 -0
  51. package/src/components/field.tsx +226 -0
  52. package/src/components/file-upload.tsx +186 -0
  53. package/src/components/funnel-chart.tsx +224 -0
  54. package/src/components/gauge-chart.tsx +109 -0
  55. package/src/components/heatmap.tsx +105 -0
  56. package/src/components/hover-card.tsx +47 -0
  57. package/src/components/image-viewer.tsx +174 -0
  58. package/src/components/input-otp.tsx +86 -0
  59. package/src/components/input.tsx +470 -0
  60. package/src/components/item.tsx +94 -0
  61. package/src/components/kbd.tsx +28 -0
  62. package/src/components/label.tsx +21 -0
  63. package/src/components/line-chart.tsx +92 -0
  64. package/src/components/link.tsx +34 -0
  65. package/src/components/message.tsx +903 -0
  66. package/src/components/number-field.tsx +79 -0
  67. package/src/components/pagination.tsx +208 -0
  68. package/src/components/phone-input.tsx +147 -0
  69. package/src/components/pie-chart.tsx +117 -0
  70. package/src/components/popover.tsx +102 -0
  71. package/src/components/powered-by.tsx +39 -0
  72. package/src/components/progress.tsx +278 -0
  73. package/src/components/prose.tsx +42 -0
  74. package/src/components/radar-chart.tsx +66 -0
  75. package/src/components/radial-chart.tsx +73 -0
  76. package/src/components/radio-group.tsx +135 -0
  77. package/src/components/rating.tsx +192 -0
  78. package/src/components/rich-text.tsx +1651 -0
  79. package/src/components/scatter-chart.tsx +115 -0
  80. package/src/components/scroll-area.tsx +50 -0
  81. package/src/components/select.tsx +193 -0
  82. package/src/components/separator.tsx +20 -0
  83. package/src/components/sheet.tsx +142 -0
  84. package/src/components/sidebar.tsx +570 -0
  85. package/src/components/skeleton.tsx +18 -0
  86. package/src/components/slider.tsx +47 -0
  87. package/src/components/sonner.tsx +178 -0
  88. package/src/components/sparkline.tsx +68 -0
  89. package/src/components/spinner.tsx +35 -0
  90. package/src/components/status-dot.tsx +45 -0
  91. package/src/components/stepper.tsx +228 -0
  92. package/src/components/switch.tsx +35 -0
  93. package/src/components/table.tsx +267 -0
  94. package/src/components/tabs.tsx +184 -0
  95. package/src/components/tag-input.tsx +238 -0
  96. package/src/components/textarea.tsx +47 -0
  97. package/src/components/time-picker.tsx +183 -0
  98. package/src/components/timeline.tsx +75 -0
  99. package/src/components/toggle-group.tsx +93 -0
  100. package/src/components/toggle.tsx +51 -0
  101. package/src/components/tooltip.tsx +160 -0
  102. package/src/components/tree.tsx +136 -0
  103. package/src/components/voice-message.tsx +193 -0
  104. package/src/css.d.ts +2 -0
  105. package/src/hooks/use-appearance.ts +57 -0
  106. package/src/hooks/use-mobile.ts +20 -0
  107. package/src/lib/appearance.ts +16 -0
  108. package/src/lib/button-render.ts +32 -0
  109. package/src/lib/char-count.tsx +67 -0
  110. package/src/lib/date.ts +45 -0
  111. package/src/lib/file-accept.ts +59 -0
  112. package/src/lib/markdown.ts +187 -0
  113. package/src/lib/utils.ts +29 -0
  114. package/src/lib/voice.ts +68 -0
  115. package/src/styles/shadcn.css +642 -0
  116. package/src/styles/theme.css +1825 -0
@@ -0,0 +1,227 @@
1
+ 'use client';
2
+
3
+ // Confirmação: pergunta antes de uma ação difícil de desfazer. Acabamento igual ao da
4
+ // janela (cantos de 16px e sombra de janela).
5
+
6
+ import * as React from 'react';
7
+ import { AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';
8
+ import { ArchiveIcon, PowerIcon, TrashIcon } from 'lucide-react';
9
+ import { cn } from '../lib/utils';
10
+
11
+ import { Button } from './button';
12
+ import { useQuietInitialFocus } from './dialog';
13
+
14
+ function AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) {
15
+ return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />;
16
+ }
17
+
18
+ function AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props) {
19
+ return <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />;
20
+ }
21
+
22
+ function AlertDialogPortal({ ...props }: AlertDialogPrimitive.Portal.Props) {
23
+ return <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />;
24
+ }
25
+
26
+ function AlertDialogOverlay({ className, ...props }: AlertDialogPrimitive.Backdrop.Props) {
27
+ return (
28
+ <AlertDialogPrimitive.Backdrop
29
+ data-slot="alert-dialog-overlay"
30
+ className={cn(
31
+ 'fixed inset-0 isolate z-50 bg-surface-overlay duration-(--duration-fast) supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',
32
+ className,
33
+ )}
34
+ {...props}
35
+ />
36
+ );
37
+ }
38
+
39
+ function AlertDialogContent({
40
+ className,
41
+ size = 'default',
42
+ ref,
43
+ initialFocus,
44
+ ...props
45
+ }: AlertDialogPrimitive.Popup.Props & {
46
+ /** D-858: sm 400, padrão 560 e lg 880, as larguras do Dialog. */
47
+ size?: 'sm' | 'default' | 'lg';
48
+ }) {
49
+ const focus = useQuietInitialFocus(ref);
50
+ return (
51
+ <AlertDialogPortal>
52
+ <AlertDialogOverlay />
53
+ <AlertDialogPrimitive.Popup
54
+ data-slot="alert-dialog-content"
55
+ data-size={size}
56
+ className={cn(
57
+ 'group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 max-w-[calc(100%-2rem)] gap-4 rounded-card bg-popover p-5 shadow-dialog text-popover-foreground ring-1 ring-border duration-(--duration-fast) outline-none data-[size=sm]:sm:max-w-dialog-sm data-[size=default]:sm:max-w-dialog data-[size=lg]:sm:max-w-dialog-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
58
+ className,
59
+ )}
60
+ ref={focus.ref}
61
+ initialFocus={initialFocus ?? focus.initialFocus}
62
+ {...props}
63
+ />
64
+ </AlertDialogPortal>
65
+ );
66
+ }
67
+
68
+ function AlertDialogHeader({ className, ...props }: React.ComponentProps<'div'>) {
69
+ return (
70
+ <div
71
+ data-slot="alert-dialog-header"
72
+ className={cn(
73
+ 'grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-not-data-[size=sm]/alert-dialog-content:place-items-start sm:group-not-data-[size=sm]/alert-dialog-content:text-left sm:group-not-data-[size=sm]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]',
74
+ className,
75
+ )}
76
+ {...props}
77
+ />
78
+ );
79
+ }
80
+
81
+ function AlertDialogFooter({ className, ...props }: React.ComponentProps<'div'>) {
82
+ return (
83
+ <div
84
+ data-slot="alert-dialog-footer"
85
+ className={cn(
86
+ 'flex flex-col-reverse gap-2 pt-1 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end',
87
+ className,
88
+ )}
89
+ {...props}
90
+ />
91
+ );
92
+ }
93
+
94
+ function AlertDialogTitle({
95
+ className,
96
+ ...props
97
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
98
+ return (
99
+ <AlertDialogPrimitive.Title
100
+ data-slot="alert-dialog-title"
101
+ className={cn(
102
+ 'text-title-dialog sm:group-not-data-[size=sm]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2',
103
+ className,
104
+ )}
105
+ {...props}
106
+ />
107
+ );
108
+ }
109
+
110
+ function AlertDialogDescription({
111
+ className,
112
+ ...props
113
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
114
+ return (
115
+ <AlertDialogPrimitive.Description
116
+ data-slot="alert-dialog-description"
117
+ className={cn(
118
+ 'text-body-13 text-balance text-muted-foreground md:text-pretty *:[a]:font-semibold *:[a]:text-link *:[a]:hover:text-link-hover',
119
+ className,
120
+ )}
121
+ {...props}
122
+ />
123
+ );
124
+ }
125
+
126
+ function AlertDialogAction({ className, ...props }: React.ComponentProps<typeof Button>) {
127
+ return <Button data-slot="alert-dialog-action" className={cn(className)} {...props} />;
128
+ }
129
+
130
+ function AlertDialogCancel({
131
+ className,
132
+ variant = 'outline',
133
+ size = 'default',
134
+ ...props
135
+ }: AlertDialogPrimitive.Close.Props &
136
+ Pick<React.ComponentProps<typeof Button>, 'variant' | 'size'>) {
137
+ return (
138
+ <AlertDialogPrimitive.Close
139
+ data-slot="alert-dialog-cancel"
140
+ className={cn(className)}
141
+ render={<Button variant={variant} size={size} />}
142
+ {...props}
143
+ />
144
+ );
145
+ }
146
+
147
+ // Confirmação pronta, D-706, pelo mapa de ações: o nome do item no título, Cancelar à esquerda e
148
+ // a ação à direita, no botão e com o ícone do tipo. Apagar e Desconectar em vermelho; Arquivar em
149
+ // contorno, porque não é perda.
150
+ const CONFIRM = {
151
+ delete: {
152
+ label: 'Excluir',
153
+ variant: 'destructive',
154
+ icon: <TrashIcon data-icon="inline-start" data-danger />,
155
+ },
156
+ disconnect: {
157
+ label: 'Desconectar',
158
+ variant: 'destructive',
159
+ icon: <PowerIcon data-icon="inline-start" data-danger />,
160
+ },
161
+ archive: {
162
+ label: 'Arquivar',
163
+ variant: 'outline',
164
+ icon: <ArchiveIcon data-icon="inline-start" />,
165
+ },
166
+ } as const;
167
+
168
+ function ConfirmDialog({
169
+ open,
170
+ onOpenChange,
171
+ kind = 'delete',
172
+ title,
173
+ description,
174
+ action,
175
+ onConfirm,
176
+ }: {
177
+ open: boolean;
178
+ onOpenChange: (open: boolean) => void;
179
+ /** O tipo da ação, que dá o botão e o ícone. */
180
+ kind?: keyof typeof CONFIRM;
181
+ /** Com o nome do item, como "Excluir a empresa Terra Couro?". */
182
+ title: React.ReactNode;
183
+ description: React.ReactNode;
184
+ /** Texto do botão, quando não é o do tipo, como "Remover" ou "Apagar histórico". */
185
+ action?: string;
186
+ onConfirm: () => void;
187
+ }) {
188
+ const c = CONFIRM[kind];
189
+ return (
190
+ <AlertDialog open={open} onOpenChange={onOpenChange}>
191
+ <AlertDialogContent>
192
+ <AlertDialogHeader>
193
+ <AlertDialogTitle>{title}</AlertDialogTitle>
194
+ <AlertDialogDescription>{description}</AlertDialogDescription>
195
+ </AlertDialogHeader>
196
+ <AlertDialogFooter>
197
+ <AlertDialogCancel>Cancelar</AlertDialogCancel>
198
+ <Button
199
+ variant={c.variant}
200
+ onClick={() => {
201
+ onConfirm();
202
+ onOpenChange(false);
203
+ }}
204
+ >
205
+ {c.icon}
206
+ {action ?? c.label}
207
+ </Button>
208
+ </AlertDialogFooter>
209
+ </AlertDialogContent>
210
+ </AlertDialog>
211
+ );
212
+ }
213
+
214
+ export {
215
+ ConfirmDialog,
216
+ AlertDialog,
217
+ AlertDialogAction,
218
+ AlertDialogCancel,
219
+ AlertDialogContent,
220
+ AlertDialogDescription,
221
+ AlertDialogFooter,
222
+ AlertDialogHeader,
223
+ AlertDialogOverlay,
224
+ AlertDialogPortal,
225
+ AlertDialogTitle,
226
+ AlertDialogTrigger,
227
+ };
@@ -0,0 +1,128 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { XIcon } from 'lucide-react';
5
+ import { cva, type VariantProps } from 'class-variance-authority';
6
+ import { cn } from '../lib/utils';
7
+ import { Button } from './button';
8
+
9
+ // Fechar, D-772: sem o X por padrão, porque o aviso fixo fica até o problema ser resolvido. Com
10
+ // `dismissible`, o X aparece no canto de cima, à direita, e `onDismiss` avisa o app.
11
+ //
12
+ // A ação, como Aprovar e Recusar, ocupa uma coluna própria à direita, no meio da altura, e nunca
13
+ // passa por cima do texto. No celular, ela desce para baixo do texto (revisão do Lucas, 04/11/2026).
14
+
15
+ const alertVariants = cva(
16
+ "group/alert relative grid w-full gap-1 rounded-card border px-4 py-3 text-left text-body-13 has-[>svg]:grid-cols-[auto_1fr] sm:has-data-[slot=alert-action]:grid-cols-[1fr_auto] sm:has-[>svg]:has-data-[slot=alert-action]:grid-cols-[auto_1fr_auto] has-data-[slot=alert-action]:gap-x-4 has-[>svg]:has-data-[slot=alert-action]:gap-x-2.5 has-[>svg]:gap-x-2.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-3",
17
+ {
18
+ variants: {
19
+ variant: {
20
+ default: 'bg-card text-card-foreground',
21
+ destructive:
22
+ 'bg-card text-text-error *:data-[slot=alert-description]:text-text-error *:[svg]:text-current',
23
+ // Status suaves.
24
+ success:
25
+ 'border-transparent bg-success-subtle text-success-subtle-foreground *:data-[slot=alert-description]:text-success-subtle-foreground/85',
26
+ warning:
27
+ 'border-transparent bg-warning-subtle text-warning-subtle-foreground *:data-[slot=alert-description]:text-warning-subtle-foreground/85',
28
+ info: 'border-transparent bg-info-subtle text-info-subtle-foreground *:data-[slot=alert-description]:text-info-subtle-foreground/85',
29
+ // D-806: algo automático em ação, como o robô ou o agente de IA conversando, no violeta forte
30
+ // da IA, o mesmo da mensagem da IA, para não sumir no cinza da conversa.
31
+ ai: 'border-transparent bg-chat-ai text-foreground *:data-[slot=alert-description]:text-foreground *:[svg]:text-ai',
32
+ 'destructive-subtle':
33
+ 'border-transparent bg-destructive-subtle text-destructive-subtle-foreground *:data-[slot=alert-description]:text-destructive-subtle-foreground/85',
34
+ },
35
+ },
36
+ defaultVariants: {
37
+ variant: 'default',
38
+ },
39
+ },
40
+ );
41
+
42
+ function Alert({
43
+ className,
44
+ variant,
45
+ dismissible = false,
46
+ onDismiss,
47
+ closeLabel = 'Fechar aviso',
48
+ children,
49
+ ...props
50
+ }: React.ComponentProps<'div'> &
51
+ VariantProps<typeof alertVariants> & {
52
+ /** Mostra o X no canto. Desligado por padrão: o aviso fixo fica até o problema ser resolvido. */
53
+ dismissible?: boolean;
54
+ /** Chamado ao fechar, para o app lembrar que a pessoa fechou. */
55
+ onDismiss?: () => void;
56
+ /** Nome do X para leitor de tela. */
57
+ closeLabel?: string;
58
+ }) {
59
+ const [open, setOpen] = React.useState(true);
60
+ if (!open) return null;
61
+ return (
62
+ <div
63
+ data-slot="alert"
64
+ role="alert"
65
+ data-dismissible={dismissible || undefined}
66
+ className={cn(alertVariants({ variant }), dismissible && 'pr-12', className)}
67
+ {...props}
68
+ >
69
+ {children}
70
+ {dismissible && (
71
+ <Button
72
+ data-slot="alert-close"
73
+ variant="ghost"
74
+ size="icon-sm"
75
+ aria-label={closeLabel}
76
+ className="absolute top-1.5 right-1.5 text-current"
77
+ onClick={() => {
78
+ setOpen(false);
79
+ onDismiss?.();
80
+ }}
81
+ >
82
+ <XIcon />
83
+ </Button>
84
+ )}
85
+ </div>
86
+ );
87
+ }
88
+
89
+ function AlertTitle({ className, ...props }: React.ComponentProps<'div'>) {
90
+ return (
91
+ <div
92
+ data-slot="alert-title"
93
+ className={cn(
94
+ 'text-body-13-medium group-has-[>svg]/alert:col-start-2 [&_a]:font-semibold [&_a]:text-link [&_a]:hover:text-link-hover',
95
+ className,
96
+ )}
97
+ {...props}
98
+ />
99
+ );
100
+ }
101
+
102
+ function AlertDescription({ className, ...props }: React.ComponentProps<'div'>) {
103
+ return (
104
+ <div
105
+ data-slot="alert-description"
106
+ className={cn(
107
+ 'text-body-13 text-balance text-muted-foreground md:text-pretty [&_a]:font-semibold [&_a]:text-foreground [&_a]:underline-offset-2 [&_a]:hover:text-foreground/70 [&_p:not(:last-child)]:mb-4',
108
+ className,
109
+ )}
110
+ {...props}
111
+ />
112
+ );
113
+ }
114
+
115
+ function AlertAction({ className, ...props }: React.ComponentProps<'div'>) {
116
+ return (
117
+ <div
118
+ data-slot="alert-action"
119
+ className={cn(
120
+ 'mt-1.5 flex flex-wrap items-center gap-2 group-has-[>svg]/alert:col-start-2 sm:col-[-2/-1] sm:row-span-2 sm:row-start-1 sm:mt-0 sm:self-center sm:pl-2 group-has-[>svg]/alert:sm:col-[-2/-1]',
121
+ className,
122
+ )}
123
+ {...props}
124
+ />
125
+ );
126
+ }
127
+
128
+ export { Alert, AlertTitle, AlertDescription, AlertAction };
@@ -0,0 +1,180 @@
1
+ 'use client';
2
+
3
+ import { useId } from 'react';
4
+ import {
5
+ Area,
6
+ AreaChart as AreaPrimitive,
7
+ CartesianGrid,
8
+ ReferenceDot,
9
+ XAxis,
10
+ YAxis,
11
+ } from 'recharts';
12
+ import {
13
+ AXIS,
14
+ type ChartDatum,
15
+ type ChartSeries,
16
+ ChartContainer,
17
+ ChartLegend,
18
+ ChartTooltip,
19
+ formatNumber,
20
+ seriesConfig,
21
+ CHART_ANIMATION,
22
+ } from './chart';
23
+ import { cn } from '../lib/utils';
24
+
25
+ // Gráfico de área pronto (D-156): vendas, visitas ou conversas ao longo do tempo. Curva suave,
26
+ // reta ou em degraus; empilhado ou em 100%; com o pico marcado e os últimos pontos tracejados
27
+ // quando o período ainda não fechou, como o dia de hoje.
28
+
29
+ function AreaChart({
30
+ data,
31
+ index,
32
+ series,
33
+ curve = 'smooth',
34
+ stack,
35
+ peak = false,
36
+ partial = 0,
37
+ yAxis = true,
38
+ format = formatNumber,
39
+ className,
40
+ }: {
41
+ data: ChartDatum[];
42
+ /** Campo do eixo de baixo, como "dia". */
43
+ index: string;
44
+ series: ChartSeries[];
45
+ curve?: 'smooth' | 'linear' | 'step';
46
+ /** "normal" empilha; "expand" empilha em 100%. */
47
+ stack?: 'normal' | 'expand';
48
+ /** Marca o maior valor da primeira série, com o rótulo em cima. */
49
+ peak?: boolean;
50
+ /** Quantos pontos do fim são de um período que ainda não fechou: a linha fica tracejada. */
51
+ partial?: number;
52
+ yAxis?: boolean;
53
+ format?: (value: unknown) => string;
54
+ className?: string;
55
+ }) {
56
+ const id = useId().replace(/:/g, '');
57
+ const config = seriesConfig(series);
58
+ const type = curve === 'smooth' ? 'monotone' : curve === 'step' ? 'step' : 'linear';
59
+ const first = series[0]?.key ?? '';
60
+ const top = peak
61
+ ? data.reduce<ChartDatum | null>(
62
+ (best, d) => (best === null || Number(d[first]) > Number(best[first]) ? d : best),
63
+ null,
64
+ )
65
+ : null;
66
+ // Tracejado no fim: a série é desenhada duas vezes, cheia até o corte e tracejada depois.
67
+ const cut = partial > 0 ? data.length - 1 - partial : -1;
68
+ const rows =
69
+ cut >= 0
70
+ ? data.map((d, i) => ({
71
+ ...d,
72
+ ...Object.fromEntries(
73
+ series.flatMap((s) => [
74
+ [`${s.key}__done`, i <= cut ? d[s.key] : null],
75
+ [`${s.key}__open`, i >= cut ? d[s.key] : null],
76
+ ]),
77
+ ),
78
+ }))
79
+ : data;
80
+
81
+ return (
82
+ <ChartContainer config={config} className={cn('aspect-auto h-64', className)}>
83
+ {(hidden) => (
84
+ <AreaPrimitive
85
+ data={rows}
86
+ stackOffset={stack === 'expand' ? 'expand' : undefined}
87
+ margin={{ top: peak ? 28 : 8, right: 8, left: 0, bottom: 0 }}
88
+ >
89
+ <defs>
90
+ {series.map((s) => (
91
+ <linearGradient key={s.key} id={`${id}-${s.key}`} x1="0" y1="0" x2="0" y2="1">
92
+ <stop offset="0%" stopColor={`var(--color-${s.key})`} stopOpacity={0.22} />
93
+ <stop offset="100%" stopColor={`var(--color-${s.key})`} stopOpacity={0.02} />
94
+ </linearGradient>
95
+ ))}
96
+ </defs>
97
+ <CartesianGrid vertical={false} />
98
+ <XAxis dataKey={index} {...AXIS} minTickGap={24} />
99
+ {yAxis && (
100
+ <YAxis
101
+ {...AXIS}
102
+ width="auto"
103
+ tickFormatter={(v) => (stack === 'expand' ? `${Math.round(v * 100)}%` : format(v))}
104
+ />
105
+ )}
106
+ <ChartTooltip formatValue={format} />
107
+ {series.length > 1 && <ChartLegend />}
108
+ {series.map((s) =>
109
+ cut >= 0 ? (
110
+ [
111
+ <Area
112
+ key={`${s.key}-done`}
113
+ {...CHART_ANIMATION}
114
+ dataKey={`${s.key}__done`}
115
+ name={s.key}
116
+ hide={hidden.has(s.key)}
117
+ type={type}
118
+ stackId={stack ? 'a' : undefined}
119
+ stroke={`var(--color-${s.key})`}
120
+ strokeWidth={2}
121
+ fill={`url(#${id}-${s.key})`}
122
+ activeDot={{ r: 4, strokeWidth: 2, stroke: 'var(--card)' }}
123
+ />,
124
+ <Area
125
+ key={`${s.key}-open`}
126
+ {...CHART_ANIMATION}
127
+ dataKey={`${s.key}__open`}
128
+ name={s.key}
129
+ hide={hidden.has(s.key)}
130
+ type={type}
131
+ stackId={stack ? 'b' : undefined}
132
+ stroke={`var(--color-${s.key})`}
133
+ strokeWidth={2}
134
+ strokeDasharray="4 4"
135
+ fill="transparent"
136
+ legendType="none"
137
+ tooltipType="none"
138
+ activeDot={false}
139
+ />,
140
+ ]
141
+ ) : (
142
+ <Area
143
+ key={s.key}
144
+ {...CHART_ANIMATION}
145
+ dataKey={s.key}
146
+ hide={hidden.has(s.key)}
147
+ type={type}
148
+ stackId={stack && !s.dashed ? 'a' : undefined}
149
+ stroke={`var(--color-${s.key})`}
150
+ strokeWidth={s.dashed ? 1.5 : 2}
151
+ // Série tracejada, como a meta, é só a linha, sem preenchimento.
152
+ strokeDasharray={s.dashed ? '4 4' : undefined}
153
+ fill={s.dashed ? 'none' : `url(#${id}-${s.key})`}
154
+ activeDot={{ r: 4, strokeWidth: 2, stroke: 'var(--card)' }}
155
+ />
156
+ ),
157
+ )}
158
+ {top && !hidden.has(first) && (
159
+ <ReferenceDot
160
+ x={top[index] as string}
161
+ y={Number(top[first])}
162
+ r={5}
163
+ fill="var(--card)"
164
+ stroke={`var(--color-${first})`}
165
+ strokeWidth={2}
166
+ label={{
167
+ value: format(top[first]),
168
+ position: 'top',
169
+ offset: 10,
170
+ className: 'fill-foreground text-body-12-semibold',
171
+ }}
172
+ />
173
+ )}
174
+ </AreaPrimitive>
175
+ )}
176
+ </ChartContainer>
177
+ );
178
+ }
179
+
180
+ export { AreaChart };