@vowt-tech/ui 0.0.0-stage → 0.177.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.
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,278 @@
1
+ 'use client';
2
+
3
+ import { Progress as ProgressPrimitive } from '@base-ui/react/progress';
4
+ import { cn } from '../lib/utils';
5
+
6
+ // Base do shadcn: barra de andamento de uma tarefa, como uma importação, ou do uso do plano,
7
+ // com o número e o limite ao lado (D-309).
8
+
9
+ type ProgressTone = 'usage' | 'goal';
10
+
11
+ /**
12
+ * Cor da barra pelo tom. Uso: encher é ruim, âmbar a partir de `warnAt`, 80% por padrão, e
13
+ * vermelho no limite. Meta: encher é bom, azul no caminho e verde ao chegar. Sem tom, sempre a cor de selecionado.
14
+ */
15
+ function toneFill(ratio: number, tone: ProgressTone | undefined, warnAt = 0.8): string {
16
+ // Meta em andamento em azul, mais leve que o preto (D-379); ao chegar, verde.
17
+ if (tone === 'goal') return ratio >= 1 ? 'bg-success' : 'bg-chart-1';
18
+ if (tone === 'usage')
19
+ return ratio >= 1 ? 'bg-destructive' : ratio >= warnAt ? 'bg-warning' : 'bg-selected-strong';
20
+ return 'bg-selected-strong';
21
+ }
22
+
23
+ function Progress({
24
+ className,
25
+ children,
26
+ value,
27
+ max = 100,
28
+ tone,
29
+ warnAt = 0.8,
30
+ ...props
31
+ }: ProgressPrimitive.Root.Props & {
32
+ /** "usage": encher é ruim, âmbar no aviso e vermelho no limite; "goal": verde ao chegar. */
33
+ tone?: ProgressTone;
34
+ /** No tom "usage", a fração em que fica âmbar, de 0 a 1. */
35
+ warnAt?: number;
36
+ }) {
37
+ const ratio = value != null && max > 0 ? Math.min(1, value / max) : 0;
38
+ return (
39
+ <ProgressPrimitive.Root
40
+ value={value}
41
+ max={max}
42
+ data-slot="progress"
43
+ className={cn('flex flex-wrap gap-2', className)}
44
+ {...props}
45
+ >
46
+ {children}
47
+ <ProgressTrack>
48
+ <ProgressIndicator className={tone ? toneFill(ratio, tone, warnAt) : undefined} />
49
+ </ProgressTrack>
50
+ </ProgressPrimitive.Root>
51
+ );
52
+ }
53
+
54
+ function ProgressTrack({ className, ...props }: ProgressPrimitive.Track.Props) {
55
+ return (
56
+ <ProgressPrimitive.Track
57
+ className={cn(
58
+ // Trilha um tom acima do cinza suave, que sumia no cartão, sobretudo no escuro.
59
+ 'bg-surface-track relative flex h-1.5 w-full items-center overflow-x-hidden rounded-full',
60
+ className,
61
+ )}
62
+ data-slot="progress-track"
63
+ {...props}
64
+ />
65
+ );
66
+ }
67
+
68
+ function ProgressIndicator({ className, ...props }: ProgressPrimitive.Indicator.Props) {
69
+ return (
70
+ <ProgressPrimitive.Indicator
71
+ data-slot="progress-indicator"
72
+ className={cn('bg-selected-strong h-full rounded-full transition-all', className)}
73
+ {...props}
74
+ />
75
+ );
76
+ }
77
+
78
+ function ProgressLabel({ className, ...props }: ProgressPrimitive.Label.Props) {
79
+ return (
80
+ <ProgressPrimitive.Label
81
+ className={cn('text-body-13-medium', className)}
82
+ data-slot="progress-label"
83
+ {...props}
84
+ />
85
+ );
86
+ }
87
+
88
+ function ProgressValue({ className, ...props }: ProgressPrimitive.Value.Props) {
89
+ return (
90
+ <ProgressPrimitive.Value
91
+ className={cn('text-muted-foreground ml-auto text-body-13-medium tabular-nums', className)}
92
+ data-slot="progress-value"
93
+ {...props}
94
+ />
95
+ );
96
+ }
97
+
98
+ // Progresso em tracinhos (D-311), para o uso do plano: cada tracinho é uma fatia do limite. Fica
99
+ // âmbar a partir de `warnAt`, 80% por padrão, e vermelho no limite, como aviso antes de o plano
100
+ // acabar.
101
+ function ProgressSegments({
102
+ value,
103
+ max = 100,
104
+ segments = 48,
105
+ tone = 'usage',
106
+ warnAt = 0.8,
107
+ className,
108
+ 'aria-label': ariaLabel,
109
+ }: {
110
+ value: number;
111
+ max?: number;
112
+ segments?: number;
113
+ /** "usage": uso do plano, encher é ruim; "goal": força da senha ou meta, encher é bom. */
114
+ tone?: ProgressTone;
115
+ /** No tom "usage", a fração em que fica âmbar, de 0 a 1, como 0.9 para avisar só aos 90%. */
116
+ warnAt?: number;
117
+ className?: string;
118
+ 'aria-label': string;
119
+ }) {
120
+ const ratio = max > 0 ? Math.min(1, value / max) : 0;
121
+ const filled = Math.round(ratio * segments);
122
+ const fill = toneFill(ratio, tone, warnAt);
123
+ return (
124
+ <div
125
+ role="progressbar"
126
+ aria-label={ariaLabel}
127
+ aria-valuemin={0}
128
+ aria-valuemax={max}
129
+ aria-valuenow={value}
130
+ data-slot="progress-segments"
131
+ className={cn('flex h-6 w-full gap-[3px]', className)}
132
+ >
133
+ {Array.from({ length: segments }, (_, i) => (
134
+ <span
135
+ key={i}
136
+ // tokens-ok: gomo da barra em partes, de 4px de altura
137
+ className={cn('flex-1 rounded-[2px]', i < filled ? fill : 'bg-surface-strong')}
138
+ />
139
+ ))}
140
+ </div>
141
+ );
142
+ }
143
+
144
+ // Barra única dividida em partes (D-312): o pipeline por etapa, a origem das vendas por canal. Cada
145
+ // parte tem a cor da série, na ordem fixa do tema, e 2px de espaço; a legenda embaixo tem o nome e
146
+ // o número, para não depender só da cor.
147
+ const PART_COLORS = [
148
+ 'var(--chart-1)',
149
+ 'var(--chart-2)',
150
+ 'var(--chart-3)',
151
+ 'var(--chart-4)',
152
+ 'var(--chart-5)',
153
+ ];
154
+
155
+ function ProgressStacked({
156
+ parts,
157
+ format = (v) => v.toLocaleString('pt-BR'),
158
+ legend = true,
159
+ className,
160
+ 'aria-label': ariaLabel,
161
+ }: {
162
+ parts: { label: string; value: number; color?: string }[];
163
+ format?: (value: number) => string;
164
+ legend?: boolean;
165
+ className?: string;
166
+ 'aria-label': string;
167
+ }) {
168
+ const total = parts.reduce((n, p) => n + p.value, 0) || 1;
169
+ const color = (i: number, c?: string) => c ?? PART_COLORS[i % PART_COLORS.length];
170
+ return (
171
+ <div data-slot="progress-stacked" className={cn('grid gap-3', className)}>
172
+ <div
173
+ role="img"
174
+ aria-label={ariaLabel}
175
+ className="flex h-2.5 w-full gap-[2px] overflow-hidden rounded-full"
176
+ >
177
+ {parts.map((p, i) => (
178
+ <span
179
+ key={p.label}
180
+ className="h-full first:rounded-l-full last:rounded-r-full"
181
+ style={{ width: `${(p.value / total) * 100}%`, background: color(i, p.color) }}
182
+ />
183
+ ))}
184
+ </div>
185
+ {legend && (
186
+ <ul className="flex flex-wrap gap-x-4 gap-y-1.5">
187
+ {parts.map((p, i) => (
188
+ <li key={p.label} className="flex items-center gap-1.5 text-body-12">
189
+ <span className="size-2 rounded-full" style={{ background: color(i, p.color) }} />
190
+ <span className="text-muted-foreground">{p.label}</span>
191
+ <span className="font-semibold tabular-nums">{format(p.value)}</span>
192
+ </li>
193
+ ))}
194
+ </ul>
195
+ )}
196
+ </div>
197
+ );
198
+ }
199
+
200
+ // tokens-ok-ligacao: barra própria, com as cores do tema; não usa o Recharts.
201
+
202
+ // Barra segmentada, D-731: a parte de cada categoria num todo, numa linha só, como os motivos de
203
+ // perda ou positivo, neutro e negativo. Mais leve que a rosca quando são poucas categorias. Embaixo,
204
+ // a lista com a cor, o nome, a quantidade e a parte.
205
+
206
+ export type CategoryBarItem = { key: string; label: string; value: number; color?: string };
207
+
208
+ const COLORS = [
209
+ 'var(--chart-1)',
210
+ 'var(--chart-2)',
211
+ 'var(--chart-3)',
212
+ 'var(--chart-4)',
213
+ 'var(--chart-5)',
214
+ ];
215
+
216
+ function CategoryBar({
217
+ items,
218
+ format = (v: number) => v.toLocaleString('pt-BR'),
219
+ list = true,
220
+ share = true,
221
+ className,
222
+ }: {
223
+ items: CategoryBarItem[];
224
+ format?: (value: number) => string;
225
+ /** A lista embaixo da barra. */
226
+ list?: boolean;
227
+ /** A parte em % na lista; tire quando o valor já é longo, como dinheiro. */
228
+ share?: boolean;
229
+ className?: string;
230
+ }) {
231
+ const total = items.reduce((n, i) => n + i.value, 0) || 1;
232
+ const pct = (v: number) =>
233
+ `${((v / total) * 100).toLocaleString('pt-BR', { maximumFractionDigits: 1 })}%`;
234
+ return (
235
+ <div data-slot="category-bar" className={cn('grid gap-4', className)}>
236
+ <div className="flex h-3 w-full gap-1 overflow-hidden" aria-hidden>
237
+ {items.map((i, n) => (
238
+ <span
239
+ key={i.key}
240
+ className="h-full rounded-full first:rounded-l-full last:rounded-r-full"
241
+ style={{ width: `${(i.value / total) * 100}%`, background: i.color ?? COLORS[n % 5] }}
242
+ />
243
+ ))}
244
+ </div>
245
+ {list && (
246
+ <ul className="grid gap-2.5">
247
+ {items.map((i, n) => (
248
+ <li key={i.key} className="flex items-center gap-2 text-body-13">
249
+ <span
250
+ aria-hidden
251
+ className="size-2 shrink-0 rounded-full"
252
+ style={{ background: i.color ?? COLORS[n % 5] }}
253
+ />
254
+ <span className="min-w-0 flex-1 truncate">{i.label}</span>
255
+ <span className="text-body-13-medium tabular-nums">{format(i.value)}</span>
256
+ {share && (
257
+ <span className="w-12 text-right text-muted-foreground tabular-nums">
258
+ {pct(i.value)}
259
+ </span>
260
+ )}
261
+ </li>
262
+ ))}
263
+ </ul>
264
+ )}
265
+ </div>
266
+ );
267
+ }
268
+
269
+ export {
270
+ ProgressStacked,
271
+ Progress,
272
+ ProgressTrack,
273
+ ProgressIndicator,
274
+ ProgressLabel,
275
+ ProgressValue,
276
+ ProgressSegments,
277
+ CategoryBar,
278
+ };
@@ -0,0 +1,42 @@
1
+ import type * as React from 'react';
2
+ import { cn } from '../lib/utils';
3
+
4
+ // Texto corrido formatado, como um artigo da central de ajuda, um termo ou uma nota de versão. Dá
5
+ // tamanho, espaço e peso aos títulos, parágrafos, listas, links, citações e trechos de código que
6
+ // vêm de fora, como um texto escrito no painel, sem precisar de classe em cada um.
7
+
8
+ function Prose({
9
+ size = 'default',
10
+ className,
11
+ ...props
12
+ }: React.ComponentProps<'div'> & {
13
+ /** "sm" para painéis estreitos, como o widget de suporte; "lg" para leitura longa, como um artigo. */
14
+ size?: 'sm' | 'default' | 'lg';
15
+ }) {
16
+ return (
17
+ <div
18
+ data-slot="prose"
19
+ data-size={size}
20
+ className={cn(
21
+ 'grid min-w-0 text-foreground',
22
+ size === 'sm'
23
+ ? 'gap-3 text-body-13 [&_h2]:text-heading-14 [&_h3]:text-body-13-semibold'
24
+ : size === 'lg'
25
+ ? 'gap-5 text-heading-16-regular [&_h2]:text-heading-20 [&_h3]:text-heading-16'
26
+ : 'gap-4 text-body-14 [&_h2]:text-heading-18 [&_h3]:text-heading-14',
27
+ '[&_h2]:mt-3 [&_h3]:mt-2 [&>:first-child]:mt-0',
28
+ '[&_a]:font-semibold [&_a]:underline [&_a]:underline-offset-2 [&_a:hover]:text-muted-foreground',
29
+ '[&_strong]:font-semibold',
30
+ '[&_ol]:grid [&_ol]:list-decimal [&_ol]:gap-1 [&_ol]:pl-5 [&_ul]:grid [&_ul]:list-disc [&_ul]:gap-1 [&_ul]:pl-5 [&_li]:pl-1 [&_li::marker]:text-muted-foreground',
31
+ '[&_blockquote]:border-l-2 [&_blockquote]:pl-4 [&_blockquote]:text-muted-foreground',
32
+ '[&_code]:rounded-small [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:text-mono-12',
33
+ '[&_pre]:overflow-x-auto [&_pre]:rounded-inner [&_pre]:bg-muted [&_pre]:p-3 [&_pre_code]:bg-transparent [&_pre_code]:p-0',
34
+ '[&_img]:rounded-inner [&_img]:border [&_hr]:border-border',
35
+ className,
36
+ )}
37
+ {...props}
38
+ />
39
+ );
40
+ }
41
+
42
+ export { Prose };
@@ -0,0 +1,66 @@
1
+ 'use client';
2
+
3
+ import { PolarAngleAxis, PolarGrid, Radar, RadarChart as RadarPrimitive } from 'recharts';
4
+ import {
5
+ type ChartDatum,
6
+ type ChartSeries,
7
+ ChartContainer,
8
+ ChartLegend,
9
+ ChartTooltip,
10
+ formatNumber,
11
+ seriesConfig,
12
+ CHART_ANIMATION,
13
+ } from './chart';
14
+ import { cn } from '../lib/utils';
15
+
16
+ // Radar pronto (D-156): comparar o mesmo conjunto de notas, como a avaliação do atendimento por
17
+ // quesito, entre duas equipes ou dois meses. De 5 a 8 eixos; até 3 séries.
18
+
19
+ function RadarChart({
20
+ data,
21
+ index,
22
+ series,
23
+ dots = false,
24
+ format = formatNumber,
25
+ className,
26
+ }: {
27
+ data: ChartDatum[];
28
+ /** Campo dos eixos, como "quesito". */
29
+ index: string;
30
+ series: ChartSeries[];
31
+ dots?: boolean;
32
+ format?: (value: unknown) => string;
33
+ className?: string;
34
+ }) {
35
+ return (
36
+ <ChartContainer config={seriesConfig(series)} className={cn('aspect-square h-72', className)}>
37
+ {(hidden) => (
38
+ <RadarPrimitive data={data} outerRadius="72%">
39
+ <PolarGrid stroke="var(--border)" />
40
+ <PolarAngleAxis
41
+ dataKey={index}
42
+ tick={{ fill: 'var(--muted-foreground)', className: 'text-body-12' }}
43
+ />
44
+ <ChartTooltip formatValue={format} />
45
+ {series.length > 1 && <ChartLegend />}
46
+ {series.map((s, i) => (
47
+ <Radar
48
+ key={s.key}
49
+ {...CHART_ANIMATION}
50
+ dataKey={s.key}
51
+ hide={hidden.has(s.key)}
52
+ stroke={`var(--color-${s.key})`}
53
+ strokeWidth={2}
54
+ fill={`var(--color-${s.key})`}
55
+ fillOpacity={i === 0 ? 0.18 : 0.08}
56
+ strokeDasharray={s.dashed ? '4 4' : undefined}
57
+ dot={dots ? { r: 3, fillOpacity: 1 } : false}
58
+ />
59
+ ))}
60
+ </RadarPrimitive>
61
+ )}
62
+ </ChartContainer>
63
+ );
64
+ }
65
+
66
+ export { RadarChart };
@@ -0,0 +1,73 @@
1
+ 'use client';
2
+
3
+ import { PolarAngleAxis, RadialBar, RadialBarChart } from 'recharts';
4
+ import { CHART_COLORS, type ChartConfig, ChartContainer, CHART_ANIMATION } from './chart';
5
+ import { cn } from '../lib/utils';
6
+
7
+ // Anel de meta (D-156): quanto da meta do mês já foi feito, com o número no meio. Até 3 anéis,
8
+ // do de fora para o de dentro, para comparar metas, como vendas, pedidos e clientes novos.
9
+
10
+ export type RadialItem = { key: string; label: string; value: number; max: number; color?: string };
11
+
12
+ function RadialChart({
13
+ data,
14
+ centerValue,
15
+ centerLabel,
16
+ className,
17
+ }: {
18
+ data: RadialItem[];
19
+ /** No meio, como "72%". Sem ele, mostra a porcentagem do primeiro anel. */
20
+ centerValue?: string;
21
+ centerLabel?: string;
22
+ className?: string;
23
+ }) {
24
+ const config: ChartConfig = Object.fromEntries(
25
+ data.map((d, i) => [
26
+ d.key,
27
+ { label: d.label, color: d.color ?? CHART_COLORS[i % CHART_COLORS.length]! },
28
+ ]),
29
+ );
30
+ const rows = data.map((d) => ({
31
+ key: d.key,
32
+ pct: Math.min(100, (d.value / d.max) * 100),
33
+ fill: `var(--color-${d.key})`,
34
+ }));
35
+ const first = rows[0];
36
+ const inner = 78 - data.length * 12;
37
+ return (
38
+ <ChartContainer config={config} className={cn('aspect-square h-56', className)}>
39
+ <RadialBarChart
40
+ data={rows}
41
+ startAngle={90}
42
+ endAngle={-270}
43
+ innerRadius={`${inner}%`}
44
+ outerRadius="92%"
45
+ barSize={data.length > 1 ? 10 : 14}
46
+ >
47
+ <PolarAngleAxis type="number" domain={[0, 100]} tick={false} axisLine={false} />
48
+ <RadialBar
49
+ dataKey="pct"
50
+ background={{ fill: 'var(--muted)' }}
51
+ cornerRadius={8}
52
+ {...CHART_ANIMATION}
53
+ />
54
+ <text x="50%" y="50%" textAnchor="middle" dominantBaseline="middle">
55
+ <tspan
56
+ x="50%"
57
+ dy={centerLabel ? '-0.4em' : 0}
58
+ className="fill-foreground text-stat-chart"
59
+ >
60
+ {centerValue ?? `${Math.round(first?.pct ?? 0)}%`}
61
+ </tspan>
62
+ {centerLabel && (
63
+ <tspan x="50%" dy="1.6em" className="fill-muted-foreground text-body-12">
64
+ {centerLabel}
65
+ </tspan>
66
+ )}
67
+ </text>
68
+ </RadialBarChart>
69
+ </ChartContainer>
70
+ );
71
+ }
72
+
73
+ export { RadialChart };
@@ -0,0 +1,135 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { Radio as RadioPrimitive } from '@base-ui/react/radio';
5
+ import { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group';
6
+ import { cn } from '../lib/utils';
7
+ import { panelVariants } from './card';
8
+ import { Checkbox } from './checkbox';
9
+
10
+ // Erro no grupo inteiro: `aria-invalid` no RadioGroup avisa o leitor de tela uma vez e pinta todas
11
+ // as opções de vermelho. Ainda dá para marcar o erro numa opção só, no RadioGroupItem.
12
+ function RadioGroup({
13
+ className,
14
+ 'aria-invalid': ariaInvalid,
15
+ ...props
16
+ }: RadioGroupPrimitive.Props & { 'aria-invalid'?: boolean }) {
17
+ return (
18
+ <RadioGroupPrimitive
19
+ data-slot="radio-group"
20
+ aria-invalid={ariaInvalid || undefined}
21
+ data-group-invalid={ariaInvalid ? '' : undefined}
22
+ className={cn('group/radio-group grid w-full gap-2', className)}
23
+ {...props}
24
+ />
25
+ );
26
+ }
27
+
28
+ // Acessibilidade: nos controles do Base UI o `id` vai para um campo invisível; o elemento
29
+ // que a pessoa usa recebe o nome pelo rótulo `${id}-label` (que o Label cria sozinho com o htmlFor).
30
+ // Desmarcada, a borda sai do texto a 35%, e não da borda de campo: a 10% o círculo de 20px sumia,
31
+ // sobretudo no escuro. O elemento é um span, então o desabilitado vem pelo data-disabled.
32
+ function RadioGroupItem({ className, ...props }: RadioPrimitive.Root.Props) {
33
+ return (
34
+ <RadioPrimitive.Root
35
+ data-slot="radio-group-item"
36
+ aria-labelledby={props.id && !props['aria-label'] ? `${props.id}-label` : undefined}
37
+ className={cn(
38
+ 'group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-border-control-empty outline-none group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-border-control-empty after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring-strong focus-visible:focus-ring data-disabled:cursor-not-allowed data-disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-ring-invalid aria-invalid:aria-checked:border-selected-strong group-data-group-invalid/radio-group:border-destructive group-data-group-invalid/radio-group:ring-3 group-data-group-invalid/radio-group:ring-ring-invalid group-data-group-invalid/radio-group:data-checked:border-selected-strong dark:group-data-group-invalid/radio-group:border-border-error dark:bg-input/30 dark:aria-invalid:border-border-error data-checked:border-selected-strong data-checked:bg-selected-strong data-checked:text-selected-strong-foreground group-has-[:focus-visible]/field-label:data-checked:border-selected-strong dark:data-checked:bg-selected-strong',
39
+ className,
40
+ )}
41
+ {...props}
42
+ >
43
+ <RadioPrimitive.Indicator
44
+ data-slot="radio-group-indicator"
45
+ className="flex size-4 items-center justify-center"
46
+ >
47
+ <span className="absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-selected-strong-foreground" />
48
+ </RadioPrimitive.Indicator>
49
+ </RadioPrimitive.Root>
50
+ );
51
+ }
52
+
53
+ // Opção em formato de cartão, com título e explicação curta, para escolhas que pedem contexto:
54
+ // tipo de frete, plano, forma de pagamento. Radio card escolhe uma dentro de um RadioGroup;
55
+ // Checkbox card marca quantas quiser.
56
+
57
+ const cardClass = cn(
58
+ panelVariants(),
59
+ 'flex cursor-pointer items-start gap-3 transition-colors hover:bg-hover has-data-checked:border-selected-strong has-data-checked:ring-1 has-data-checked:ring-selected-strong has-focus-visible:focus-ring has-data-disabled:cursor-not-allowed has-data-disabled:opacity-50',
60
+ );
61
+
62
+ function CardText({
63
+ title,
64
+ description,
65
+ icon,
66
+ }: {
67
+ title: React.ReactNode;
68
+ description?: React.ReactNode;
69
+ icon?: React.ReactNode;
70
+ }) {
71
+ return (
72
+ <>
73
+ <span className="grid min-w-0 flex-1 gap-0.5">
74
+ <span className="text-body-13-medium">{title}</span>
75
+ {description && <span className="text-body-13 text-muted-foreground">{description}</span>}
76
+ </span>
77
+ {icon && <span className="text-muted-foreground [&_svg]:size-icon-xl">{icon}</span>}
78
+ </>
79
+ );
80
+ }
81
+
82
+ function RadioCard({
83
+ value,
84
+ title,
85
+ description,
86
+ icon,
87
+ disabled,
88
+ className,
89
+ }: {
90
+ value: string;
91
+ title: React.ReactNode;
92
+ description?: React.ReactNode;
93
+ icon?: React.ReactNode;
94
+ disabled?: boolean;
95
+ className?: string;
96
+ }) {
97
+ return (
98
+ <label data-slot="radio-card" className={cn(cardClass, className)}>
99
+ <RadioGroupItem value={value} disabled={disabled} className="mt-0.5" />
100
+ <CardText title={title} description={description} icon={icon} />
101
+ </label>
102
+ );
103
+ }
104
+
105
+ function CheckboxCard({
106
+ checked,
107
+ onCheckedChange,
108
+ title,
109
+ description,
110
+ icon,
111
+ disabled,
112
+ className,
113
+ }: {
114
+ checked: boolean;
115
+ onCheckedChange: (checked: boolean) => void;
116
+ title: React.ReactNode;
117
+ description?: React.ReactNode;
118
+ icon?: React.ReactNode;
119
+ disabled?: boolean;
120
+ className?: string;
121
+ }) {
122
+ return (
123
+ <label data-slot="checkbox-card" className={cn(cardClass, className)}>
124
+ <Checkbox
125
+ checked={checked}
126
+ onCheckedChange={(c) => onCheckedChange(c === true)}
127
+ disabled={disabled}
128
+ className="mt-0.5"
129
+ />
130
+ <CardText title={title} description={description} icon={icon} />
131
+ </label>
132
+ );
133
+ }
134
+
135
+ export { RadioGroup, RadioGroupItem, RadioCard, CheckboxCard };