@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,79 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { NumberField } from '@base-ui/react/number-field';
5
+ import { MinusIcon, PlusIcon } from 'lucide-react';
6
+ import { cn } from '../lib/utils';
7
+
8
+ // Campo de número com os botões de menos e mais, como quantidade em estoque. Aceita digitar,
9
+ // as setas do teclado e o Shift para pular de 10 em 10. Uma caixa só, sem divisória, com largura
10
+ // de conteúdo de 128px, que não estica nem dentro de um Field; o className muda a largura da caixa.
11
+ // O id vai no Root: o Base UI o passa ao campo e aos botões, pelo aria-controls.
12
+
13
+ function NumberInput({
14
+ value,
15
+ onValueChange,
16
+ min,
17
+ max,
18
+ step = 1,
19
+ disabled,
20
+ id,
21
+ className,
22
+ size = 'default',
23
+ 'aria-label': ariaLabel,
24
+ 'aria-invalid': ariaInvalid,
25
+ }: {
26
+ value: number | null;
27
+ onValueChange: (value: number | null) => void;
28
+ min?: number;
29
+ max?: number;
30
+ step?: number;
31
+ disabled?: boolean;
32
+ id?: string;
33
+ className?: string;
34
+ /** Altura 32, 40 ou 48, como o Input. */
35
+ size?: 'sm' | 'default' | 'lg';
36
+ 'aria-label'?: string;
37
+ 'aria-invalid'?: boolean;
38
+ }) {
39
+ const button =
40
+ 'flex w-9 group-data-[size=sm]/number:w-8 group-data-[size=lg]/number:w-10 shrink-0 items-center justify-center text-muted-foreground transition-colors outline-none hover:bg-hover hover:text-foreground focus-visible:bg-hover disabled:pointer-events-none disabled:opacity-40 [&_svg]:size-icon-lg';
41
+ return (
42
+ <NumberField.Root
43
+ id={id}
44
+ value={value}
45
+ onValueChange={(v) => onValueChange(v)}
46
+ min={min}
47
+ max={max}
48
+ step={step}
49
+ largeStep={step * 10}
50
+ disabled={disabled}
51
+ locale="pt-BR"
52
+ className="flex"
53
+ >
54
+ <NumberField.Group
55
+ data-slot="number-input"
56
+ data-size={size}
57
+ data-invalid={ariaInvalid || undefined}
58
+ className={cn(
59
+ 'group/number flex h-control w-32 data-[size=sm]:h-control-sm data-[size=lg]:h-control-lg items-stretch overflow-hidden rounded-control border border-input data-invalid:border-destructive data-invalid:ring-3 data-invalid:ring-ring-invalid transition-colors focus-within:border-ring-strong focus-within:focus-ring-field data-disabled:opacity-50 bg-surface-control',
60
+ className,
61
+ )}
62
+ >
63
+ <NumberField.Decrement aria-label="Diminuir" className={button}>
64
+ <MinusIcon />
65
+ </NumberField.Decrement>
66
+ <NumberField.Input
67
+ aria-label={ariaLabel}
68
+ aria-invalid={ariaInvalid}
69
+ className="w-full min-w-0 bg-transparent text-center text-body-13 tabular-nums outline-none"
70
+ />
71
+ <NumberField.Increment aria-label="Aumentar" className={button}>
72
+ <PlusIcon />
73
+ </NumberField.Increment>
74
+ </NumberField.Group>
75
+ </NumberField.Root>
76
+ );
77
+ }
78
+
79
+ export { NumberInput };
@@ -0,0 +1,208 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { cn } from '../lib/utils';
5
+ import { ChevronLeftIcon, ChevronRightIcon, EllipsisIcon } from 'lucide-react';
6
+ import { Button } from './button';
7
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './select';
8
+
9
+ // Base do shadcn, adaptada: as listas trocam de página sem mudar de endereço, então cada
10
+ // página é um botão (e não um link), e os textos ficam em português.
11
+
12
+ function Pagination({ className, ...props }: React.ComponentProps<'nav'>) {
13
+ return (
14
+ <nav
15
+ aria-label="Páginas"
16
+ data-slot="pagination"
17
+ className={cn('mx-auto flex w-full justify-center', className)}
18
+ {...props}
19
+ />
20
+ );
21
+ }
22
+
23
+ function PaginationContent({ className, ...props }: React.ComponentProps<'ul'>) {
24
+ return (
25
+ <ul
26
+ data-slot="pagination-content"
27
+ className={cn('flex items-center gap-1', className)}
28
+ {...props}
29
+ />
30
+ );
31
+ }
32
+
33
+ function PaginationItem({ ...props }: React.ComponentProps<'li'>) {
34
+ return <li data-slot="pagination-item" {...props} />;
35
+ }
36
+
37
+ type PaginationLinkProps = { isActive?: boolean } & React.ComponentProps<typeof Button>;
38
+
39
+ function PaginationLink({ className, isActive, size = 'icon-sm', ...props }: PaginationLinkProps) {
40
+ return (
41
+ <Button
42
+ variant={isActive ? 'outline' : 'ghost'}
43
+ size={size}
44
+ aria-current={isActive ? 'page' : undefined}
45
+ data-slot="pagination-link"
46
+ data-active={isActive}
47
+ className={cn('tabular-nums', className)}
48
+ {...props}
49
+ />
50
+ );
51
+ }
52
+
53
+ /** Sem `text`, mostra só a seta (com o nome para leitor de tela). */
54
+ function PaginationPrevious({
55
+ text,
56
+ ...props
57
+ }: React.ComponentProps<typeof PaginationLink> & { text?: string }) {
58
+ return (
59
+ <PaginationLink aria-label="Página anterior" size={text ? 'sm' : 'icon-sm'} {...props}>
60
+ <ChevronLeftIcon aria-hidden data-icon={text ? 'inline-start' : undefined} />
61
+ {text && <span className="hidden sm:block">{text}</span>}
62
+ </PaginationLink>
63
+ );
64
+ }
65
+
66
+ function PaginationNext({
67
+ text,
68
+ ...props
69
+ }: React.ComponentProps<typeof PaginationLink> & { text?: string }) {
70
+ return (
71
+ <PaginationLink aria-label="Próxima página" size={text ? 'sm' : 'icon-sm'} {...props}>
72
+ {text && <span className="hidden sm:block">{text}</span>}
73
+ <ChevronRightIcon aria-hidden data-icon={text ? 'inline-end' : undefined} />
74
+ </PaginationLink>
75
+ );
76
+ }
77
+
78
+ function PaginationEllipsis({ className, ...props }: React.ComponentProps<'span'>) {
79
+ return (
80
+ <span
81
+ aria-hidden
82
+ data-slot="pagination-ellipsis"
83
+ className={cn(
84
+ "text-muted-foreground flex size-control-sm items-center justify-center [&_svg:not([class*='size-'])]:size-3",
85
+ className,
86
+ )}
87
+ {...props}
88
+ >
89
+ <EllipsisIcon aria-hidden />
90
+ </span>
91
+ );
92
+ }
93
+
94
+ // Paginação de lista, montada com as peças acima: sempre visível, com "1–25 de 312", números
95
+ // das páginas e quantos por página, 25, 50 ou 100 (D-309).
96
+
97
+ const PAGE_SIZES = [25, 50, 100] as const;
98
+
99
+ /** Páginas a mostrar: a primeira, a última e as vizinhas da atual; o resto vira "…". */
100
+ function pageWindow(page: number, pages: number): (number | 'gap')[] {
101
+ const keep = new Set([1, pages, page - 1, page, page + 1].filter((p) => p >= 1 && p <= pages));
102
+ const out: (number | 'gap')[] = [];
103
+ let last = 0;
104
+ for (const p of [...keep].sort((a, b) => a - b)) {
105
+ if (p - last > 1) out.push('gap');
106
+ out.push(p);
107
+ last = p;
108
+ }
109
+ return out;
110
+ }
111
+
112
+ function Pager({
113
+ page,
114
+ size,
115
+ total,
116
+ onPage,
117
+ onSize,
118
+ noun = ['registro', 'registros'],
119
+ className,
120
+ }: {
121
+ page: number;
122
+ size: number;
123
+ total: number;
124
+ onPage: (page: number) => void;
125
+ onSize?: (size: number) => void;
126
+ noun?: [string, string];
127
+ className?: string;
128
+ }) {
129
+ const pages = Math.max(1, Math.ceil(total / size));
130
+ const first = total === 0 ? 0 : (page - 1) * size + 1;
131
+ const last = Math.min(total, page * size);
132
+ return (
133
+ <div
134
+ data-slot="pager"
135
+ className={cn(
136
+ 'text-muted-foreground flex flex-wrap items-center justify-between gap-3 text-body-13',
137
+ className,
138
+ )}
139
+ >
140
+ <span className="tabular-nums">
141
+ {total === 0
142
+ ? `0 ${noun[1]}`
143
+ : `${first}–${last} de ${total} ${total === 1 ? noun[0] : noun[1]}`}
144
+ </span>
145
+ <div className="flex flex-wrap items-center gap-x-4 gap-y-2">
146
+ {onSize && (
147
+ <div className="flex items-center gap-2">
148
+ Por página
149
+ <Select value={String(size)} onValueChange={(v) => onSize(Number(v))}>
150
+ <SelectTrigger size="sm" className="w-18" aria-label="Itens por página">
151
+ <SelectValue />
152
+ </SelectTrigger>
153
+ <SelectContent>
154
+ {PAGE_SIZES.map((n) => (
155
+ <SelectItem key={n} value={String(n)}>
156
+ {n}
157
+ </SelectItem>
158
+ ))}
159
+ </SelectContent>
160
+ </Select>
161
+ </div>
162
+ )}
163
+ <Pagination className="mx-0 w-auto">
164
+ <PaginationContent>
165
+ <PaginationItem>
166
+ <PaginationPrevious disabled={page <= 1} onClick={() => onPage(page - 1)} />
167
+ </PaginationItem>
168
+ {/* No celular, os números saem e fica "4 de 13" entre as setas, para caber no cartão. */}
169
+ <PaginationItem className="px-2 text-body-13 tabular-nums sm:hidden">
170
+ {page} de {pages}
171
+ </PaginationItem>
172
+ {pageWindow(page, pages).map((p, i) => (
173
+ <PaginationItem key={p === 'gap' ? `gap-${i}` : p} className="max-sm:hidden">
174
+ {p === 'gap' ? (
175
+ <PaginationEllipsis />
176
+ ) : (
177
+ <PaginationLink
178
+ isActive={p === page}
179
+ aria-label={`Página ${p}`}
180
+ onClick={() => onPage(p)}
181
+ >
182
+ {p}
183
+ </PaginationLink>
184
+ )}
185
+ </PaginationItem>
186
+ ))}
187
+ <PaginationItem>
188
+ <PaginationNext disabled={page >= pages} onClick={() => onPage(page + 1)} />
189
+ </PaginationItem>
190
+ </PaginationContent>
191
+ </Pagination>
192
+ </div>
193
+ </div>
194
+ );
195
+ }
196
+
197
+ export {
198
+ Pager,
199
+ PAGE_SIZES,
200
+ pageWindow,
201
+ Pagination,
202
+ PaginationContent,
203
+ PaginationEllipsis,
204
+ PaginationItem,
205
+ PaginationLink,
206
+ PaginationNext,
207
+ PaginationPrevious,
208
+ };
@@ -0,0 +1,147 @@
1
+ 'use client';
2
+
3
+ import { AR, BR, PT, PY, US, UY } from 'country-flag-icons/react/3x2';
4
+ import { useState } from 'react';
5
+ import { InputGroup, InputGroupAddon, InputGroupInput } from './input';
6
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './select';
7
+ import { cn } from '../lib/utils';
8
+
9
+ // Telefone com o país, base de tudo que envolve WhatsApp (D-309). O país aparece pela bandeira em SVG,
10
+ // do pacote country-flag-icons, porque o Windows não desenha bandeira em emoji; o nome do país fica
11
+ // para o leitor de tela. Mostra a máscara do Brasil, (11) 99999-9999, e entrega ao app só os dígitos
12
+ // com o país: "+5511999999999".
13
+
14
+ export type PhoneCountry = { code: string; dial: string; name: string };
15
+
16
+ const COUNTRIES: PhoneCountry[] = [
17
+ { code: 'BR', dial: '55', name: 'Brasil' },
18
+ { code: 'PT', dial: '351', name: 'Portugal' },
19
+ { code: 'US', dial: '1', name: 'Estados Unidos' },
20
+ { code: 'AR', dial: '54', name: 'Argentina' },
21
+ { code: 'PY', dial: '595', name: 'Paraguai' },
22
+ { code: 'UY', dial: '598', name: 'Uruguai' },
23
+ ];
24
+
25
+ // Só os seis países da lista, para não carregar as bandeiras do mundo todo.
26
+ const FLAGS: Record<string, typeof BR> = { BR, PT, US, AR, PY, UY };
27
+
28
+ /** Bandeira de 20×14 com contorno fino, para a bandeira branca não sumir no fundo claro. */
29
+ function Flag({ code }: { code: string }) {
30
+ const Svg = FLAGS[code];
31
+ if (!Svg) return null;
32
+ return (
33
+ <Svg
34
+ aria-hidden
35
+ preserveAspectRatio="xMidYMid slice"
36
+ className="ring-border h-3.5 w-5 shrink-0 rounded-small ring-1"
37
+ />
38
+ );
39
+ }
40
+
41
+ /** Máscara do Brasil: (11) 9999-9999 ou (11) 99999-9999. Outros países ficam só com os dígitos. */
42
+ function formatLocal(digits: string, country: string): string {
43
+ if (country !== 'BR') return digits;
44
+ const d = digits.slice(0, 11);
45
+ if (d.length <= 2) return d.length ? `(${d}` : '';
46
+ const ddd = d.slice(0, 2);
47
+ const rest = d.slice(2);
48
+ const cut = rest.length > 8 ? 5 : 4;
49
+ return rest.length > cut
50
+ ? `(${ddd}) ${rest.slice(0, cut)}-${rest.slice(cut)}`
51
+ : `(${ddd}) ${rest}`;
52
+ }
53
+
54
+ function splitValue(value: string): { country: string; digits: string } {
55
+ const all = value.replace(/\D/g, '');
56
+ const match = [...COUNTRIES]
57
+ .sort((a, b) => b.dial.length - a.dial.length)
58
+ .find((c) => all.startsWith(c.dial));
59
+ return match
60
+ ? { country: match.code, digits: all.slice(match.dial.length) }
61
+ : { country: 'BR', digits: all };
62
+ }
63
+
64
+ function PhoneInput({
65
+ value,
66
+ onValueChange,
67
+ id,
68
+ disabled,
69
+ className,
70
+ size = 'default',
71
+ 'aria-invalid': ariaInvalid,
72
+ }: {
73
+ /** Número com o país, como "+5511999999999"; vazio quando não há número. */
74
+ value: string;
75
+ onValueChange: (value: string) => void;
76
+ id?: string;
77
+ disabled?: boolean;
78
+ className?: string;
79
+ /** Altura 32, 40 ou 48, como o Input. */
80
+ size?: 'sm' | 'default' | 'lg';
81
+ 'aria-invalid'?: boolean;
82
+ }) {
83
+ const parsed = splitValue(value);
84
+ const [country, setCountry] = useState(parsed.country);
85
+ const dial = COUNTRIES.find((c) => c.code === country)?.dial ?? '55';
86
+ const emit = (digits: string, code = country) => {
87
+ const d = COUNTRIES.find((c) => c.code === code)?.dial ?? '55';
88
+ onValueChange(digits ? `+${d}${digits}` : '');
89
+ };
90
+ return (
91
+ <InputGroup data-slot="phone-input" size={size} className={cn(className)}>
92
+ <InputGroupAddon className="pl-1">
93
+ <Select
94
+ value={country}
95
+ disabled={disabled}
96
+ onValueChange={(c) => {
97
+ setCountry(c as string);
98
+ emit(parsed.digits, c as string);
99
+ }}
100
+ >
101
+ <SelectTrigger
102
+ size="sm"
103
+ aria-label="País"
104
+ className={cn(
105
+ 'h-control-sm gap-1 border-0 bg-transparent px-2 shadow-none dark:bg-transparent',
106
+ size === 'sm' && 'h-control-xs px-1.5',
107
+ )}
108
+ >
109
+ <SelectValue>
110
+ {(c: string) => {
111
+ const item = COUNTRIES.find((x) => x.code === c);
112
+ return (
113
+ <span className="text-foreground flex items-center gap-1.5 tabular-nums">
114
+ <Flag code={c} />
115
+ <span className="sr-only">{item?.name}</span>+{item?.dial}
116
+ </span>
117
+ );
118
+ }}
119
+ </SelectValue>
120
+ </SelectTrigger>
121
+ <SelectContent>
122
+ {COUNTRIES.map((c) => (
123
+ <SelectItem key={c.code} value={c.code}>
124
+ <Flag code={c.code} />
125
+ {c.name} <span className="text-muted-foreground tabular-nums">+{c.dial}</span>
126
+ </SelectItem>
127
+ ))}
128
+ </SelectContent>
129
+ </Select>
130
+ </InputGroupAddon>
131
+ <InputGroupInput
132
+ id={id}
133
+ type="tel"
134
+ inputMode="tel"
135
+ autoComplete="tel-national"
136
+ disabled={disabled}
137
+ aria-invalid={ariaInvalid}
138
+ placeholder={dial === '55' ? '(11) 99999-9999' : 'Número'}
139
+ value={formatLocal(parsed.digits, country)}
140
+ onChange={(e) => emit(e.target.value.replace(/\D/g, '').slice(0, 15))}
141
+ className="tabular-nums"
142
+ />
143
+ </InputGroup>
144
+ );
145
+ }
146
+
147
+ export { PhoneInput, COUNTRIES as PHONE_COUNTRIES };
@@ -0,0 +1,117 @@
1
+ 'use client';
2
+
3
+ import { Cell, Label, Pie, PieChart as PiePrimitive } from 'recharts';
4
+ import {
5
+ type ChartConfig,
6
+ CHART_COLORS,
7
+ ChartContainer,
8
+ ChartLegend,
9
+ ChartTooltip,
10
+ formatNumber,
11
+ CHART_ANIMATION,
12
+ } from './chart';
13
+ import { cn } from '../lib/utils';
14
+
15
+ // Pizza e rosca prontas (D-156): a parte de cada canal nas vendas, de cada motivo nos chamados.
16
+ // Rosca com o total no meio é a forma padrão; pizza só com até 4 fatias. Mais de 5 fatias juntam
17
+ // em "Outros". As fatias têm 2px de espaço entre elas.
18
+
19
+ export type PieSlice = { key: string; label: string; value: number; color?: string };
20
+
21
+ function PieChart({
22
+ data,
23
+ donut = true,
24
+ centerValue,
25
+ centerLabel,
26
+ format = formatNumber,
27
+ className,
28
+ }: {
29
+ data: PieSlice[];
30
+ donut?: boolean;
31
+ /** No meio da rosca, como o total: "R$ 48,00 mil". Sem ele, mostra a soma. */
32
+ centerValue?: string;
33
+ centerLabel?: string;
34
+ format?: (value: unknown) => string;
35
+ className?: string;
36
+ }) {
37
+ const config: ChartConfig = Object.fromEntries(
38
+ data.map((d, i) => [
39
+ d.key,
40
+ { label: d.label, color: d.color ?? CHART_COLORS[i % CHART_COLORS.length]! },
41
+ ]),
42
+ );
43
+ return (
44
+ <ChartContainer config={config} className={cn('aspect-auto h-64', className)}>
45
+ {(hidden) => {
46
+ // Fatia desligada na legenda sai da rosca, e o total do meio passa a somar só as que ficam.
47
+ const shown = data.filter((d) => !hidden.has(d.key));
48
+ const total = shown.reduce((n, d) => n + d.value, 0);
49
+ return (
50
+ <PiePrimitive>
51
+ <ChartTooltip formatValue={format} />
52
+ <Pie
53
+ data={shown}
54
+ dataKey="value"
55
+ nameKey="key"
56
+ innerRadius={donut ? '62%' : 0}
57
+ outerRadius="88%"
58
+ paddingAngle={donut ? 1.5 : 0}
59
+ stroke="var(--card)"
60
+ strokeWidth={2}
61
+ cornerRadius={donut ? 4 : 0}
62
+ {...CHART_ANIMATION}
63
+ >
64
+ {shown.map((d) => (
65
+ <Cell key={d.key} fill={`var(--color-${d.key})`} />
66
+ ))}
67
+ {donut && (
68
+ <Label
69
+ content={({ viewBox }) => {
70
+ const { cx, cy, innerRadius } = (viewBox ?? {}) as {
71
+ cx?: number;
72
+ cy?: number;
73
+ innerRadius?: number;
74
+ };
75
+ if (cx === undefined || cy === undefined) return null;
76
+ // O valor do meio cabe no furo da rosca: desce um ou dois degraus quando o
77
+ // texto, pela largura média de cada letra, passaria do anel.
78
+ const value = centerValue ?? format(total);
79
+ const room = (innerRadius ?? 80) * 1.7;
80
+ // Furo pequeno, numa rosca espremida pelo cartão ou pela legenda: só o
81
+ // número, sem a linha de baixo, que passaria por cima das fatias.
82
+ const label = (innerRadius ?? 80) >= 48 ? centerLabel : undefined;
83
+ const valueSize =
84
+ value.length * 11 <= room
85
+ ? 'text-stat-chart'
86
+ : value.length * 9 <= room
87
+ ? 'text-heading-16'
88
+ : 'text-heading-14';
89
+ return (
90
+ <text x={cx} y={cy} textAnchor="middle" dominantBaseline="middle">
91
+ <tspan
92
+ x={cx}
93
+ y={label ? cy - 8 : cy}
94
+ className={cn('fill-foreground', valueSize)}
95
+ >
96
+ {value}
97
+ </tspan>
98
+ {label && (
99
+ <tspan x={cx} y={cy + 16} className="fill-muted-foreground text-body-12">
100
+ {label}
101
+ </tspan>
102
+ )}
103
+ </text>
104
+ );
105
+ }}
106
+ />
107
+ )}
108
+ </Pie>
109
+ <ChartLegend />
110
+ </PiePrimitive>
111
+ );
112
+ }}
113
+ </ChartContainer>
114
+ );
115
+ }
116
+
117
+ export { PieChart };
@@ -0,0 +1,102 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { Popover as PopoverPrimitive } from '@base-ui/react/popover';
5
+ import { cn } from '../lib/utils';
6
+
7
+ function Popover({ ...props }: PopoverPrimitive.Root.Props) {
8
+ return <PopoverPrimitive.Root data-slot="popover" {...props} />;
9
+ }
10
+
11
+ function PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {
12
+ return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />;
13
+ }
14
+
15
+ /** Ponto da tela, em pixels a partir do canto de cima à esquerda, como o do clique ou do cursor. */
16
+ export type PopoverPoint = { x: number; y: number; height?: number };
17
+
18
+ /**
19
+ * Por padrão, o balão abre junto do botão que o abriu. Com `anchor`, abre junto de outro elemento;
20
+ * com `anchorPoint`, junto de um ponto da tela, como onde a pessoa clicou ou onde está o cursor do
21
+ * texto. O ponto pode ser uma função, chamada a cada reposicionamento, para acompanhar a rolagem.
22
+ */
23
+ function PopoverContent({
24
+ className,
25
+ align = 'center',
26
+ alignOffset = 0,
27
+ side = 'bottom',
28
+ sideOffset = 4,
29
+ anchor,
30
+ anchorPoint,
31
+ ...props
32
+ }: PopoverPrimitive.Popup.Props &
33
+ Pick<
34
+ PopoverPrimitive.Positioner.Props,
35
+ 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'anchor'
36
+ > & {
37
+ /** Ponto em que o balão abre. Com `height`, a linha inteira, como a do texto. */
38
+ anchorPoint?: PopoverPoint | (() => PopoverPoint | null) | null;
39
+ }) {
40
+ const pointAnchor = React.useMemo(() => {
41
+ if (!anchorPoint) return undefined;
42
+ return {
43
+ getBoundingClientRect: () => {
44
+ const p = typeof anchorPoint === 'function' ? anchorPoint() : anchorPoint;
45
+ return new DOMRect(p?.x ?? 0, p?.y ?? 0, 0, p?.height ?? 0);
46
+ },
47
+ };
48
+ }, [anchorPoint]);
49
+ return (
50
+ <PopoverPrimitive.Portal>
51
+ <PopoverPrimitive.Positioner
52
+ anchor={pointAnchor ?? anchor}
53
+ align={align}
54
+ alignOffset={alignOffset}
55
+ side={side}
56
+ sideOffset={sideOffset}
57
+ className="isolate z-50"
58
+ >
59
+ <PopoverPrimitive.Popup
60
+ data-slot="popover-content"
61
+ className={cn(
62
+ 'z-50 flex w-72 max-w-(--available-width) origin-(--transform-origin) flex-col gap-3 rounded-menu bg-popover p-3 text-body-13 text-popover-foreground shadow-menu ring-1 ring-border outline-hidden duration-(--duration-fast) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 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',
63
+ className,
64
+ )}
65
+ {...props}
66
+ />
67
+ </PopoverPrimitive.Positioner>
68
+ </PopoverPrimitive.Portal>
69
+ );
70
+ }
71
+
72
+ function PopoverHeader({ className, ...props }: React.ComponentProps<'div'>) {
73
+ return (
74
+ <div
75
+ data-slot="popover-header"
76
+ className={cn('flex flex-col gap-0.5 text-body-13', className)}
77
+ {...props}
78
+ />
79
+ );
80
+ }
81
+
82
+ function PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props) {
83
+ return (
84
+ <PopoverPrimitive.Title
85
+ data-slot="popover-title"
86
+ className={cn('text-body-13-medium', className)}
87
+ {...props}
88
+ />
89
+ );
90
+ }
91
+
92
+ function PopoverDescription({ className, ...props }: PopoverPrimitive.Description.Props) {
93
+ return (
94
+ <PopoverPrimitive.Description
95
+ data-slot="popover-description"
96
+ className={cn('text-muted-foreground', className)}
97
+ {...props}
98
+ />
99
+ );
100
+ }
101
+
102
+ export { Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger };
@@ -0,0 +1,39 @@
1
+ import { LogoMark } from '../brand/logo';
2
+ import { cn } from '../lib/utils';
3
+
4
+ // Selo "Runs on VOWT", D-710 e D-714: no pé das páginas que o cliente da loja vê, como a proposta,
5
+ // a sala de reunião e o formulário. É o selo oficial da marca, o mesmo do rodapé das lojas: o ícone
6
+ // e a frase, sempre em inglês e sem variação. A loja aparece em cima, com a logo dela; a VOWT só
7
+ // assina embaixo, pequena e em cinza. Com `href`, vira link para o site da VOWT.
8
+
9
+ function PoweredBy({
10
+ href,
11
+ className,
12
+ }: {
13
+ /** Endereço do site da VOWT; sem ele, o selo não é link. */
14
+ href?: string;
15
+ className?: string;
16
+ }) {
17
+ const content = (
18
+ <>
19
+ <LogoMark aria-hidden className="size-3.5" />
20
+ Runs on VOWT
21
+ </>
22
+ );
23
+ const base = cn(
24
+ 'inline-flex items-center gap-1.5 text-body-12-medium text-muted-foreground',
25
+ href && 'rounded-item outline-none hover:text-foreground focus-visible:focus-ring',
26
+ className,
27
+ );
28
+ return href ? (
29
+ <a data-slot="powered-by" href={href} target="_blank" rel="noreferrer" className={base}>
30
+ {content}
31
+ </a>
32
+ ) : (
33
+ <span data-slot="powered-by" className={base}>
34
+ {content}
35
+ </span>
36
+ );
37
+ }
38
+
39
+ export { PoweredBy };