@vowt-tech/ui 0.177.1 → 0.178.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/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ Copyright (c) 2026 VOWT. Todos os direitos reservados à VOWT.
2
+
3
+ Este repositório e o pacote @vowt-tech/ui, com o código, o tema, as logos, as imagens e a
4
+ documentação, são propriedade da VOWT. O código fica visível no GitHub e no npm, mas nenhum
5
+ direito de uso, cópia, modificação ou distribuição é concedido a quem não tiver autorização
6
+ por escrito da VOWT.
7
+
8
+ All rights reserved. No license is granted to use, copy, modify or distribute this software
9
+ or its assets without written permission from VOWT.
@@ -1,6 +1,6 @@
1
1
  # Design system VOWT, guia para este app
2
2
 
3
- > Pasta gerada pelo pacote @vowt-tech/ui 0.177.1. Não edite: ela é refeita a cada atualização
3
+ > Pasta gerada pelo pacote @vowt-tech/ui 0.178.0. Não edite: ela é refeita a cada atualização
4
4
  > do pacote pelo comando `vowt-ux-ui-design sync`. Regra própria deste app fica fora daqui.
5
5
 
6
6
  Este app usa o design system da VOWT. Do pacote @vowt-tech/ui, o app importa os fundamentos,
package/guia/VERSAO CHANGED
@@ -1 +1 @@
1
- 0.177.1
1
+ 0.178.0
@@ -1,6 +1,6 @@
1
1
  # Componentes
2
2
 
3
- > Gerado do pacote @vowt-tech/ui 0.177.1. Cada linha traz o nome da peça, o import do pacote e
3
+ > Gerado do pacote @vowt-tech/ui 0.178.0. Cada linha traz o nome da peça, o import do pacote e
4
4
  > a página com o exemplo.
5
5
 
6
6
  Antes de montar uma tela, procure aqui. Cada peça é importada do pacote, como
@@ -25,6 +25,7 @@ app não copia nem altera a peça: o pedido de mudança vai ao repositório vowt
25
25
  - `button`: `import { Button, StatefulButton, buttonVariants, CopyButton } from '@vowt-tech/ui/button'`. Página: https://developers.vowt.com.br/button
26
26
  - `calendar`: `import { Calendar, CalendarDayButton } from '@vowt-tech/ui/calendar'`. Página: https://developers.vowt.com.br/calendar
27
27
  - `card`: `import { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent, Panel, panelVariants } from '@vowt-tech/ui/card'`. Página: https://developers.vowt.com.br/card
28
+ - `change-card`: `import { ChangeCard } from '@vowt-tech/ui/change-card'`. Página: https://developers.vowt.com.br/change-card
28
29
  - `chart`: `import { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, CHART_COLORS, seriesConfig, formatNumber, AXIS, CHART_ANIMATION } from '@vowt-tech/ui/chart'`. Página: https://developers.vowt.com.br/chart
29
30
  - `checkbox`: `import { Checkbox } from '@vowt-tech/ui/checkbox'`. Página: https://developers.vowt.com.br/checkbox
30
31
  - `code-block`: `import { CodeBlock } from '@vowt-tech/ui/code-block'`. Página: https://developers.vowt.com.br/code-block
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vowt-tech/ui",
3
- "version": "0.177.1",
3
+ "version": "0.178.0",
4
4
  "description": "Design system da VOWT: base visual e componentes compartilhados por todos os produtos.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -0,0 +1,290 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { CheckCircle2Icon, MinusIcon, PencilIcon, PlusIcon, TriangleAlertIcon } from 'lucide-react';
5
+ import { cn } from '../lib/utils';
6
+ import { Alert, AlertDescription, AlertTitle } from './alert';
7
+ import { Badge } from './badge';
8
+ import { Button } from './button';
9
+ import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from './card';
10
+ import { CollapsibleSection } from './collapsible';
11
+ import { Spinner } from './spinner';
12
+
13
+ // Cartão de mudanças, D-865: a lista de mudanças propostas, como as que um agente de IA sugere,
14
+ // para a pessoa revisar antes de aplicar. Cada item diz o tipo, criar, alterar ou remover, o
15
+ // objeto, o campo e o valor de antes, riscado, e o de depois, em destaque de sucesso. A cor nunca
16
+ // fala sozinha: cada valor leva o rótulo "Antes" ou "Depois", visível e lido pelo leitor de tela.
17
+ // Os itens ficam agrupados por objeto; com mais de `collapseAfter` itens, cada grupo recolhe.
18
+ // O pacote não sabe quem pode aplicar: o app passa as ações que a pessoa pode usar, com o texto
19
+ // dele, e o estado. Aplicando, os botões travam contra o clique duplo.
20
+
21
+ export type ChangeKind = 'create' | 'update' | 'remove';
22
+ export type ChangeStatus = 'pending' | 'applying' | 'applied' | 'failed';
23
+
24
+ export type ChangeItem = {
25
+ id: string;
26
+ kind: ChangeKind;
27
+ /** O objeto que muda, como o nome de um registro. Os itens são agrupados por ele. */
28
+ object: string;
29
+ /** O campo, como "Telefone". Sem campo, o item fala do objeto inteiro. */
30
+ field?: string;
31
+ /** Valor de antes. Criar não tem. */
32
+ before?: React.ReactNode;
33
+ /** Valor de depois. Remover não tem. */
34
+ after?: React.ReactNode;
35
+ };
36
+
37
+ export type ChangeAction = { label: string; onClick: () => void; icon?: React.ReactNode };
38
+
39
+ const LABELS = {
40
+ create: 'Criar',
41
+ update: 'Alterar',
42
+ remove: 'Remover',
43
+ before: 'Antes',
44
+ after: 'Depois',
45
+ applying: 'Aplicando as mudanças',
46
+ applied: 'Mudanças aplicadas',
47
+ failed: 'Não foi possível aplicar',
48
+ nothingApplied: 'Nada foi aplicado.',
49
+ changes: (n: number) => (n === 1 ? '1 mudança' : `${n} mudanças`),
50
+ };
51
+
52
+ export type ChangeCardLabels = Partial<typeof LABELS>;
53
+
54
+ const KIND = {
55
+ create: { variant: 'success', icon: PlusIcon },
56
+ update: { variant: 'info', icon: PencilIcon },
57
+ remove: { variant: 'destructive', icon: MinusIcon },
58
+ } as const;
59
+
60
+ function ChangeValue({
61
+ tone,
62
+ label,
63
+ children,
64
+ }: {
65
+ tone: 'before' | 'after';
66
+ label: string;
67
+ children: React.ReactNode;
68
+ }) {
69
+ return (
70
+ <span data-slot="change-value" data-tone={tone} className="flex min-w-0 items-baseline gap-1.5">
71
+ <span className="shrink-0 text-body-12 text-muted-foreground">{label}</span>
72
+ <span
73
+ className={cn(
74
+ 'min-w-0 break-words',
75
+ tone === 'before'
76
+ ? 'text-muted-foreground line-through decoration-text-error'
77
+ : 'text-body-13-medium text-text-success',
78
+ )}
79
+ >
80
+ {children}
81
+ </span>
82
+ </span>
83
+ );
84
+ }
85
+
86
+ function ChangeRow({ item, labels }: { item: ChangeItem; labels: typeof LABELS }) {
87
+ const kind = KIND[item.kind];
88
+ const Icon = kind.icon;
89
+ return (
90
+ <li
91
+ data-slot="change-item"
92
+ data-kind={item.kind}
93
+ className="grid gap-1.5 py-2.5 first:pt-0 last:pb-0"
94
+ >
95
+ <div className="flex min-w-0 flex-wrap items-center gap-2">
96
+ <Badge variant={kind.variant}>
97
+ <Icon data-icon="inline-start" aria-hidden />
98
+ {labels[item.kind]}
99
+ </Badge>
100
+ {item.field && <span className="min-w-0 text-body-13-medium">{item.field}</span>}
101
+ </div>
102
+ {(item.kind !== 'create' && item.before !== undefined) ||
103
+ (item.kind !== 'remove' && item.after !== undefined) ? (
104
+ <div className="grid gap-1">
105
+ {item.kind !== 'create' && item.before !== undefined && (
106
+ <ChangeValue tone="before" label={labels.before}>
107
+ {item.before}
108
+ </ChangeValue>
109
+ )}
110
+ {item.kind !== 'remove' && item.after !== undefined && (
111
+ <ChangeValue tone="after" label={labels.after}>
112
+ {item.after}
113
+ </ChangeValue>
114
+ )}
115
+ </div>
116
+ ) : null}
117
+ </li>
118
+ );
119
+ }
120
+
121
+ function ChangeCard({
122
+ title,
123
+ description,
124
+ changes,
125
+ status = 'pending',
126
+ error,
127
+ primaryAction,
128
+ secondaryAction,
129
+ tertiaryAction,
130
+ undoAction,
131
+ collapseAfter = 5,
132
+ size = 'default',
133
+ labels: customLabels,
134
+ className,
135
+ }: {
136
+ title: React.ReactNode;
137
+ description?: React.ReactNode;
138
+ changes: ChangeItem[];
139
+ /** pending: esperando a decisão; applying: aplicando; applied: aplicado; failed: falhou. */
140
+ status?: ChangeStatus;
141
+ /** Mensagem do app quando falha. O cartão acrescenta que nada foi aplicado. */
142
+ error?: React.ReactNode;
143
+ /** A ação principal, como Aplicar. */
144
+ primaryAction?: ChangeAction;
145
+ /** A ação secundária, como Descartar. */
146
+ secondaryAction?: ChangeAction;
147
+ /** Uma terceira ação, opcional, como Solicitar ao Administrador. */
148
+ tertiaryAction?: ChangeAction;
149
+ /** Depois de aplicado, a ação de desfazer, se o app oferecer. */
150
+ undoAction?: ChangeAction;
151
+ /** Com mais itens que isso, cada grupo recolhe e expande. */
152
+ collapseAfter?: number;
153
+ size?: 'sm' | 'default' | 'lg';
154
+ /** Textos do cartão, para outro idioma. */
155
+ labels?: ChangeCardLabels;
156
+ className?: string;
157
+ }) {
158
+ const labels = { ...LABELS, ...customLabels };
159
+ const groups = React.useMemo(() => {
160
+ const map = new Map<string, ChangeItem[]>();
161
+ for (const c of changes) map.set(c.object, [...(map.get(c.object) ?? []), c]);
162
+ return [...map];
163
+ }, [changes]);
164
+ const collapsible = changes.length > collapseAfter;
165
+ const busy = status === 'applying';
166
+ const buttonSize = size === 'sm' ? 'sm' : size === 'lg' ? 'lg' : 'default';
167
+ const showActions = status === 'pending' || status === 'applying' || status === 'failed';
168
+
169
+ const list = (items: ChangeItem[]) => (
170
+ <ul className="grid divide-y">
171
+ {items.map((item) => (
172
+ <ChangeRow key={item.id} item={item} labels={labels} />
173
+ ))}
174
+ </ul>
175
+ );
176
+
177
+ return (
178
+ <Card
179
+ data-slot="change-card"
180
+ data-status={status}
181
+ size={size}
182
+ aria-busy={busy || undefined}
183
+ className={cn(
184
+ size === 'sm' && '[&_[data-slot=change-item]]:text-body-12',
185
+ size === 'lg' && 'text-body-14',
186
+ className,
187
+ )}
188
+ >
189
+ <CardHeader>
190
+ <CardTitle className={cn(size === 'lg' && 'text-heading-18')}>{title}</CardTitle>
191
+ <CardDescription>{description ?? labels.changes(changes.length)}</CardDescription>
192
+ </CardHeader>
193
+ <CardContent className="grid gap-3">
194
+ {collapsible ? (
195
+ <div className="-mx-2.5">
196
+ {groups.map(([object, items], i) => (
197
+ <CollapsibleSection
198
+ key={object}
199
+ title={object}
200
+ count={items.length}
201
+ defaultOpen={i === 0}
202
+ >
203
+ {list(items)}
204
+ </CollapsibleSection>
205
+ ))}
206
+ </div>
207
+ ) : (
208
+ groups.map(([object, items]) => (
209
+ <section key={object} aria-label={object} className="grid gap-2">
210
+ {groups.length > 1 && (
211
+ <h4 className="text-body-12-medium text-muted-foreground">{object}</h4>
212
+ )}
213
+ {list(items)}
214
+ </section>
215
+ ))
216
+ )}
217
+ {/* O estado é anunciado para o leitor de tela quando muda. */}
218
+ <div role="status" aria-live="polite" className="contents">
219
+ {status === 'applying' && (
220
+ <p className="flex items-center gap-2 text-body-13 text-muted-foreground">
221
+ <Spinner label="" />
222
+ {labels.applying}
223
+ </p>
224
+ )}
225
+ {status === 'applied' && (
226
+ <Alert variant="success">
227
+ <CheckCircle2Icon aria-hidden />
228
+ <AlertTitle>{labels.applied}</AlertTitle>
229
+ </Alert>
230
+ )}
231
+ {status === 'failed' && (
232
+ <Alert variant="destructive-subtle">
233
+ <TriangleAlertIcon aria-hidden />
234
+ <AlertTitle>{labels.failed}</AlertTitle>
235
+ <AlertDescription>
236
+ {error ? <>{error} </> : null}
237
+ {labels.nothingApplied}
238
+ </AlertDescription>
239
+ </Alert>
240
+ )}
241
+ </div>
242
+ </CardContent>
243
+ {((showActions && (primaryAction || secondaryAction || tertiaryAction)) ||
244
+ (status === 'applied' && undoAction)) && (
245
+ <CardFooter className="flex flex-wrap justify-end gap-2">
246
+ {status === 'applied' && undoAction ? (
247
+ <Button variant="outline" size={buttonSize} onClick={undoAction.onClick}>
248
+ {undoAction.icon}
249
+ {undoAction.label}
250
+ </Button>
251
+ ) : (
252
+ <>
253
+ {tertiaryAction && (
254
+ <Button
255
+ variant="ghost"
256
+ size={buttonSize}
257
+ className="mr-auto"
258
+ disabled={busy}
259
+ onClick={tertiaryAction.onClick}
260
+ >
261
+ {tertiaryAction.icon}
262
+ {tertiaryAction.label}
263
+ </Button>
264
+ )}
265
+ {secondaryAction && (
266
+ <Button
267
+ variant="outline"
268
+ size={buttonSize}
269
+ disabled={busy}
270
+ onClick={secondaryAction.onClick}
271
+ >
272
+ {secondaryAction.icon}
273
+ {secondaryAction.label}
274
+ </Button>
275
+ )}
276
+ {primaryAction && (
277
+ <Button size={buttonSize} disabled={busy} onClick={primaryAction.onClick}>
278
+ {busy ? <Spinner data-icon="inline-start" label="" /> : primaryAction.icon}
279
+ {primaryAction.label}
280
+ </Button>
281
+ )}
282
+ </>
283
+ )}
284
+ </CardFooter>
285
+ )}
286
+ </Card>
287
+ );
288
+ }
289
+
290
+ export { ChangeCard };
@@ -404,16 +404,20 @@ export function DateRangePicker({
404
404
  <DropdownMenu>
405
405
  <DropdownMenuTrigger
406
406
  render={
407
- <Button
408
- variant="outline"
409
- disabled={disabled}
410
- size={size}
411
- aria-label="Período de comparação"
412
- />
407
+ // O nome do botão é o texto visível, "Comparado a" e as datas, para quem vê e para o
408
+ // leitor de tela, sem um nome escondido diferente do que aparece.
409
+ <Button variant="outline" disabled={disabled} size={size} />
413
410
  }
414
411
  >
415
412
  <CalendarIcon data-icon="inline-start" className="text-muted-foreground" />
416
- {versus ? rangeText(versus) : 'Sem comparação'}
413
+ {versus ? (
414
+ <>
415
+ {/* O espaço separa as palavras no nome lido pelo leitor de tela. */}
416
+ <span className="text-muted-foreground">Comparado a</span> {rangeText(versus)}
417
+ </>
418
+ ) : (
419
+ 'Sem comparação'
420
+ )}
417
421
  <ChevronDownIcon data-icon="inline-end" className="text-muted-foreground" />
418
422
  </DropdownMenuTrigger>
419
423
  <DropdownMenuContent align="start" className="min-w-52">
@@ -52,6 +52,8 @@ function Heatmap({
52
52
  <TooltipTrigger
53
53
  render={
54
54
  <span
55
+ // D-860: com o papel de imagem, o nome da célula vale para o leitor de tela.
56
+ role="img"
55
57
  aria-label={`${r}, ${c}: ${format(v)}`}
56
58
  // Sem altura mínima: no celular, ela passava da coluna e colava nas vizinhas.
57
59
  className={cn(
@@ -5,6 +5,8 @@ import { cn } from '../lib/utils';
5
5
 
6
6
  // Escolha de um valor ou de uma faixa arrastando, como a faixa de preço de um filtro ou o desconto
7
7
  // de um cupom. Com dois valores, vira faixa. O valor aparece ao lado, escrito pelo app (D-309).
8
+ // D-860: o aria-label vai para o controle que a pessoa arrasta, onde o leitor de tela lê; na faixa,
9
+ // cada ponta ganha o nome com "mínimo" e "máximo".
8
10
 
9
11
  function Slider({
10
12
  className,
@@ -12,6 +14,7 @@ function Slider({
12
14
  value,
13
15
  min = 0,
14
16
  max = 100,
17
+ 'aria-label': ariaLabel,
15
18
  ...props
16
19
  }: SliderPrimitive.Root.Props) {
17
20
  const values = Array.isArray(value)
@@ -36,6 +39,12 @@ function Slider({
36
39
  {values.map((_, i) => (
37
40
  <SliderPrimitive.Thumb
38
41
  key={i}
42
+ index={i}
43
+ aria-label={
44
+ ariaLabel && values.length > 1
45
+ ? `${ariaLabel}, ${i === 0 ? 'mínimo' : 'máximo'}`
46
+ : ariaLabel
47
+ }
39
48
  className="block size-4 rounded-full border-2 border-selected-strong bg-card shadow-raised transition-[box-shadow] outline-none hover:ring-4 hover:ring-ring/30 focus-visible:focus-ring data-dragging:ring-4 data-dragging:ring-ring/50"
40
49
  />
41
50
  ))}
@@ -22,10 +22,26 @@ function Table({
22
22
  borderless?: boolean;
23
23
  compact?: boolean;
24
24
  }) {
25
+ // D-860: quando a tabela é mais larga que o espaço e rola de lado, o contêiner entra na ordem
26
+ // do Tab, para quem usa só o teclado rolar com as setas. Sem rolagem, fica fora do Tab.
27
+ const ref = React.useRef<HTMLDivElement>(null);
28
+ const [scrolls, setScrolls] = React.useState(false);
29
+ React.useEffect(() => {
30
+ const el = ref.current;
31
+ if (!el || typeof ResizeObserver === 'undefined') return;
32
+ const check = () => setScrolls(el.scrollWidth > el.clientWidth + 1);
33
+ check();
34
+ const observer = new ResizeObserver(check);
35
+ observer.observe(el);
36
+ if (el.firstElementChild) observer.observe(el.firstElementChild);
37
+ return () => observer.disconnect();
38
+ }, []);
25
39
  return (
26
40
  <div
41
+ ref={ref}
27
42
  data-slot="table-container"
28
- className="relative w-full overflow-x-auto scroll-fade-x [--scroll-fade-size:--spacing(6)] not-supports-[animation-timeline:scroll()]:[--scroll-fade-size:0px]"
43
+ tabIndex={scrolls ? 0 : undefined}
44
+ className="relative w-full overflow-x-auto outline-none focus-visible:focus-ring scroll-fade-x [--scroll-fade-size:--spacing(6)] not-supports-[animation-timeline:scroll()]:[--scroll-fade-size:0px]"
29
45
  >
30
46
  <table
31
47
  data-slot="table"
@@ -972,7 +972,7 @@
972
972
  --doc-blue-1: oklch(0.95 0.035 255);
973
973
  --doc-blue-2: oklch(0.86 0.08 255);
974
974
  --doc-blue-3: oklch(0.73 0.13 255);
975
- --doc-blue-4: oklch(0.56 0.15 255);
975
+ --doc-blue-4: oklch(0.54 0.15 255);
976
976
  --doc-blue-5: oklch(0.4 0.11 255);
977
977
  --doc-purple-1: oklch(0.95 0.035 300);
978
978
  --doc-purple-2: oklch(0.86 0.08 300);