@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,47 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { CharCount, useCharCount } from '../lib/char-count';
5
+ import { cn } from '../lib/utils';
6
+
7
+ // Com `showCount` e `maxLength`, mostra "45/120" no canto de baixo quando o texto passa de 80% do
8
+ // limite; aí o `className` vai para a caixa de fora.
9
+ function Textarea({
10
+ className,
11
+ showCount = false,
12
+ onChange,
13
+ ...props
14
+ }: React.ComponentProps<'textarea'> & {
15
+ /** Contador de letras, "45/120", a partir de 80% do `maxLength`. Precisa do `maxLength`. */
16
+ showCount?: boolean;
17
+ }) {
18
+ const count = useCharCount({
19
+ enabled: showCount,
20
+ maxLength: props.maxLength,
21
+ value: props.value,
22
+ defaultValue: props.defaultValue,
23
+ onChange,
24
+ });
25
+ const textarea = (
26
+ <textarea
27
+ data-slot="textarea"
28
+ className={cn(
29
+ 'flex field-sizing-content min-h-20 w-full rounded-control border border-input bg-surface-control px-2.5 py-2.5 text-body-13 transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring-strong focus-visible:focus-ring-field disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-ring-invalid dark:disabled:bg-input/80 dark:aria-invalid:border-border-error',
30
+ count.on ? 'pb-7' : className,
31
+ )}
32
+ onChange={count.onChange}
33
+ {...props}
34
+ />
35
+ );
36
+ if (!count.on) return textarea;
37
+ return (
38
+ <div data-slot="textarea-count" className={cn('relative w-full min-w-0', className)}>
39
+ {textarea}
40
+ {count.visible && (
41
+ <CharCount length={count.length} max={props.maxLength as number} className="bottom-2" />
42
+ )}
43
+ </div>
44
+ );
45
+ }
46
+
47
+ export { Textarea };
@@ -0,0 +1,183 @@
1
+ 'use client';
2
+
3
+ import { ClockIcon } from 'lucide-react';
4
+ import { useEffect, useRef, useState } from 'react';
5
+ import { Button } from './button';
6
+ import { Popover, PopoverContent, PopoverTrigger } from './popover';
7
+ import { cn } from '../lib/utils';
8
+
9
+ // Campo de hora próprio, no lugar do campo do navegador, que muda de cara em cada um (D-309).
10
+ // Abre duas colunas, horas e minutos, que rolam até o valor escolhido. Aceita intervalo de
11
+ // minutos, como de 15 em 15, limite de horário, como o expediente, e horários ocupados.
12
+
13
+ const pad = (n: number) => String(n).padStart(2, '0');
14
+ const toMinutes = (v: string) => {
15
+ const m = /^(\d{1,2}):(\d{2})$/.exec(v);
16
+ return m ? Number(m[1]) * 60 + Number(m[2]) : null;
17
+ };
18
+
19
+ function Column({
20
+ label,
21
+ items,
22
+ selected,
23
+ state,
24
+ onPick,
25
+ }: {
26
+ label: string;
27
+ items: number[];
28
+ selected: number | null;
29
+ /** "busy" fica riscado; "off" fica apagado, sem riscar. */
30
+ state: (n: number) => 'ok' | 'busy' | 'off';
31
+ onPick: (n: number) => void;
32
+ }) {
33
+ const list = useRef<HTMLDivElement>(null);
34
+ useEffect(() => {
35
+ // Abre no valor escolhido ou, sem valor, no primeiro horário possível.
36
+ const box = list.current;
37
+ const el =
38
+ box?.querySelector<HTMLElement>('[data-selected]') ??
39
+ box?.querySelector<HTMLElement>('button:enabled');
40
+ if (box && el) box.scrollTop = el.offsetTop - box.clientHeight / 2 + el.clientHeight / 2;
41
+ }, []);
42
+ return (
43
+ <div
44
+ ref={list}
45
+ role="listbox"
46
+ aria-label={label}
47
+ className="scroll-hairline relative flex h-64 w-14 flex-col gap-0.5 overflow-y-auto p-1"
48
+ >
49
+ {items.map((n) => {
50
+ const on = n === selected;
51
+ const st = state(n);
52
+ return (
53
+ <button
54
+ key={n}
55
+ type="button"
56
+ role="option"
57
+ aria-selected={on}
58
+ data-selected={on || undefined}
59
+ disabled={st !== 'ok'}
60
+ data-busy={st === 'busy' || undefined}
61
+ onClick={() => onPick(n)}
62
+ className={cn(
63
+ 'h-control-sm shrink-0 rounded-control text-body-13-semibold tabular-nums outline-none hover:bg-hover focus-visible:focus-ring disabled:pointer-events-none disabled:text-muted-foreground/50 data-busy:line-through',
64
+ on && 'bg-selected-strong text-selected-strong-foreground hover:bg-selected-strong',
65
+ )}
66
+ >
67
+ {pad(n)}
68
+ </button>
69
+ );
70
+ })}
71
+ </div>
72
+ );
73
+ }
74
+
75
+ function TimePicker({
76
+ id,
77
+ value,
78
+ onChange,
79
+ step = 5,
80
+ min,
81
+ max,
82
+ busy = [],
83
+ disabled,
84
+ placeholder = '--:--',
85
+ size = 'default',
86
+ className,
87
+ 'aria-label': ariaLabel,
88
+ }: {
89
+ id?: string;
90
+ /** "14:30" ou vazio. */
91
+ value: string;
92
+ onChange: (value: string) => void;
93
+ /** De quantos em quantos minutos, como 5, 15 ou 30. */
94
+ step?: number;
95
+ /** Primeiro horário possível, como "08:00". */
96
+ min?: string;
97
+ /** Último horário possível, como "18:00". */
98
+ max?: string;
99
+ /** Horários já ocupados, como ["10:00", "10:30"]; aparecem riscados. */
100
+ busy?: string[];
101
+ disabled?: boolean;
102
+ placeholder?: string;
103
+ /** Altura 32, 40 ou 48, como o Input. */
104
+ size?: 'sm' | 'default' | 'lg';
105
+ className?: string;
106
+ 'aria-label'?: string;
107
+ }) {
108
+ const [open, setOpen] = useState(false);
109
+ const current = toMinutes(value);
110
+ const hour = current === null ? null : Math.floor(current / 60);
111
+ const minute = current === null ? null : current % 60;
112
+ const lo = (min ? toMinutes(min) : null) ?? 0;
113
+ const hi = (max ? toMinutes(max) : null) ?? 23 * 60 + 59;
114
+ const taken = new Set(busy.map(toMinutes));
115
+ const minutes = Array.from({ length: Math.ceil(60 / step) }, (_, i) => i * step);
116
+ const inRange = (t: number) => t >= lo && t <= hi;
117
+ const allowed = (t: number) => inRange(t) && !taken.has(t);
118
+ // Fora do expediente nem aparece; hora toda ocupada aparece riscada.
119
+ const hours = Array.from({ length: 24 }, (_, i) => i).filter((h) =>
120
+ minutes.some((m) => inRange(h * 60 + m)),
121
+ );
122
+
123
+ const pick = (h: number, m: number) => onChange(`${pad(h)}:${pad(m)}`);
124
+
125
+ return (
126
+ <Popover open={open} onOpenChange={setOpen}>
127
+ <PopoverTrigger
128
+ render={
129
+ <Button
130
+ id={id}
131
+ variant="outline"
132
+ size={size}
133
+ disabled={disabled}
134
+ aria-label={ariaLabel && (value ? `${ariaLabel}: ${value}` : ariaLabel)}
135
+ className={cn(
136
+ 'w-28 justify-start border-input px-2.5 text-body-13 tabular-nums has-data-[icon=inline-start]:pl-3 aria-expanded:border-ring-strong',
137
+ !value && 'text-muted-foreground',
138
+ className,
139
+ )}
140
+ />
141
+ }
142
+ >
143
+ <ClockIcon data-icon="inline-start" className="text-muted-foreground" />
144
+ {value || placeholder}
145
+ </PopoverTrigger>
146
+ <PopoverContent align="start" className="w-auto gap-0 p-0">
147
+ <div className="flex divide-x">
148
+ <Column
149
+ label="Horas"
150
+ items={hours}
151
+ selected={hour}
152
+ state={(h) => (minutes.some((m) => allowed(h * 60 + m)) ? 'ok' : 'busy')}
153
+ onPick={(h) => {
154
+ const m =
155
+ minute !== null && allowed(h * 60 + minute)
156
+ ? minute
157
+ : minutes.find((x) => allowed(h * 60 + x));
158
+ if (m !== undefined) pick(h, m);
159
+ }}
160
+ />
161
+ <Column
162
+ label="Minutos"
163
+ items={minutes}
164
+ selected={minute}
165
+ state={(m) => {
166
+ const h = hour ?? hours.find((x) => allowed(x * 60 + m));
167
+ if (h === undefined || !inRange(h * 60 + m)) return 'off';
168
+ return taken.has(h * 60 + m) ? 'busy' : 'ok';
169
+ }}
170
+ onPick={(m) => {
171
+ const h = hour ?? hours.find((x) => allowed(x * 60 + m));
172
+ if (h === undefined) return;
173
+ pick(h, m);
174
+ setOpen(false);
175
+ }}
176
+ />
177
+ </div>
178
+ </PopoverContent>
179
+ </Popover>
180
+ );
181
+ }
182
+
183
+ export { TimePicker };
@@ -0,0 +1,75 @@
1
+ import type { ReactNode } from 'react';
2
+ import { cn } from '../lib/utils';
3
+
4
+ // tokens-ok-ligacao: só estrutura e tokens: a linha do tempo com os ícones que o app passa.
5
+
6
+ // Linha do tempo de um registro (D-341), como o histórico do contato: o que aconteceu, agrupado
7
+ // por dia, do mais novo para o mais antigo. Cada item tem ícone, o que foi, o detalhe, quem fez e
8
+ // a hora. Volta a Timeline que saiu na D-309; o Stepper continua para processos com etapas.
9
+
10
+ export type TimelineItem = {
11
+ id: string;
12
+ icon?: ReactNode;
13
+ /** O que aconteceu, como "Negócio criado". */
14
+ title: ReactNode;
15
+ /** O detalhe, como o nome do negócio ou o texto da nota. */
16
+ description?: ReactNode;
17
+ /** Quem fez, como "Carla" ou "Lia, agente de IA". */
18
+ by?: ReactNode;
19
+ /** A hora, como "14:32". */
20
+ time?: string;
21
+ };
22
+
23
+ export type TimelineDay = { label: string; items: TimelineItem[] };
24
+
25
+ function Timeline({
26
+ days,
27
+ empty = 'Nenhuma atividade registrada.',
28
+ className,
29
+ }: {
30
+ days: TimelineDay[];
31
+ empty?: ReactNode;
32
+ className?: string;
33
+ }) {
34
+ if (days.every((d) => d.items.length === 0))
35
+ return <p className="text-body-13 text-muted-foreground">{empty}</p>;
36
+ return (
37
+ <div data-slot="timeline" className={cn('grid gap-6', className)}>
38
+ {days.map((d) => (
39
+ <section key={d.label} className="grid gap-3">
40
+ <h3 className="text-body-12-medium text-muted-foreground">{d.label}</h3>
41
+ <ol className="grid">
42
+ {d.items.map((i, n) => (
43
+ <li key={i.id} className="group/tl relative flex gap-3 pb-5 last:pb-0">
44
+ {n < d.items.length - 1 && (
45
+ <span aria-hidden className="absolute top-8 bottom-0 left-3.5 w-px bg-border" />
46
+ )}
47
+ <span className="flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground [&_svg]:size-icon-sm">
48
+ {i.icon}
49
+ </span>
50
+ <div className="grid min-w-0 flex-1 gap-0.5 pt-0.5">
51
+ <div className="flex flex-wrap items-baseline justify-between gap-x-3">
52
+ <span className="text-body-13-medium">{i.title}</span>
53
+ {i.time && (
54
+ <span className="text-body-12 text-muted-foreground tabular-nums">
55
+ {i.time}
56
+ </span>
57
+ )}
58
+ </div>
59
+ {i.description && (
60
+ <div className="text-body-13 break-words text-muted-foreground">
61
+ {i.description}
62
+ </div>
63
+ )}
64
+ {i.by && <span className="text-body-12 text-muted-foreground">por {i.by}</span>}
65
+ </div>
66
+ </li>
67
+ ))}
68
+ </ol>
69
+ </section>
70
+ ))}
71
+ </div>
72
+ );
73
+ }
74
+
75
+ export { Timeline };
@@ -0,0 +1,93 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { Toggle as TogglePrimitive } from '@base-ui/react/toggle';
5
+ import { ToggleGroup as ToggleGroupPrimitive } from '@base-ui/react/toggle-group';
6
+ import { type VariantProps } from 'class-variance-authority';
7
+ import { cn } from '../lib/utils';
8
+
9
+ import { toggleVariants } from './toggle';
10
+
11
+ const ToggleGroupContext = React.createContext<
12
+ VariantProps<typeof toggleVariants> & {
13
+ spacing?: number;
14
+ orientation?: 'horizontal' | 'vertical';
15
+ }
16
+ >({
17
+ size: 'default',
18
+ variant: 'default',
19
+ spacing: 2,
20
+ orientation: 'horizontal',
21
+ });
22
+
23
+ function ToggleGroup({
24
+ className,
25
+ variant,
26
+ size,
27
+ spacing = 2,
28
+ orientation = 'horizontal',
29
+ children,
30
+ ...props
31
+ }: ToggleGroupPrimitive.Props &
32
+ VariantProps<typeof toggleVariants> & {
33
+ spacing?: number;
34
+ orientation?: 'horizontal' | 'vertical';
35
+ }) {
36
+ return (
37
+ <ToggleGroupPrimitive
38
+ data-slot="toggle-group"
39
+ data-variant={variant}
40
+ data-size={size}
41
+ data-spacing={spacing}
42
+ data-orientation={orientation}
43
+ orientation={orientation}
44
+ style={{ '--gap': spacing } as React.CSSProperties}
45
+ className={cn(
46
+ 'group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-control data-vertical:flex-col data-vertical:items-stretch',
47
+ // Colados (spacing 0): trilho cinza com a opção ligada em branco, igual ao Segmented control (D-145).
48
+ 'data-[spacing=0]:gap-1 data-[spacing=0]:bg-muted data-[spacing=0]:p-1',
49
+ className,
50
+ )}
51
+ {...props}
52
+ >
53
+ <ToggleGroupContext.Provider value={{ variant, size, spacing, orientation }}>
54
+ {children}
55
+ </ToggleGroupContext.Provider>
56
+ </ToggleGroupPrimitive>
57
+ );
58
+ }
59
+
60
+ function ToggleGroupItem({
61
+ className,
62
+ children,
63
+ variant = 'default',
64
+ size = 'default',
65
+ ...props
66
+ }: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
67
+ const context = React.useContext(ToggleGroupContext);
68
+
69
+ return (
70
+ <TogglePrimitive
71
+ data-slot="toggle-group-item"
72
+ data-variant={context.variant || variant}
73
+ data-size={context.size || size}
74
+ data-spacing={context.spacing}
75
+ className={cn(
76
+ 'shrink-0 focus:z-10 focus-visible:z-10',
77
+ 'group-data-[spacing=0]/toggle-group:rounded-item group-data-[spacing=0]/toggle-group:border-0 group-data-[spacing=0]/toggle-group:bg-transparent group-data-[spacing=0]/toggle-group:text-muted-foreground group-data-[spacing=0]/toggle-group:hover:bg-transparent group-data-[spacing=0]/toggle-group:hover:text-foreground group-data-[spacing=0]/toggle-group:data-pressed:bg-card! group-data-[spacing=0]/toggle-group:data-pressed:text-foreground group-data-[spacing=0]/toggle-group:data-pressed:shadow-raised dark:group-data-[spacing=0]/toggle-group:data-pressed:bg-surface-strong!',
78
+ // Colado: itens 8 abaixo do controle, para o trilho de 4 de respiro fechar na altura dos controles.
79
+ 'group-data-[spacing=0]/toggle-group:h-[calc(var(--scale-control)-0.5rem)] group-data-[spacing=0]/toggle-group:min-w-[calc(var(--scale-control)-0.5rem)] group-data-[spacing=0]/toggle-group:data-[size=sm]:h-[calc(var(--scale-control-sm)-0.5rem)] group-data-[spacing=0]/toggle-group:data-[size=sm]:min-w-[calc(var(--scale-control-sm)-0.5rem)]',
80
+ toggleVariants({
81
+ variant: context.variant || variant,
82
+ size: context.size || size,
83
+ }),
84
+ className,
85
+ )}
86
+ {...props}
87
+ >
88
+ {children}
89
+ </TogglePrimitive>
90
+ );
91
+ }
92
+
93
+ export { ToggleGroup, ToggleGroupItem };
@@ -0,0 +1,51 @@
1
+ 'use client';
2
+
3
+ import { Toggle as TogglePrimitive } from '@base-ui/react/toggle';
4
+ import { cva, type VariantProps } from 'class-variance-authority';
5
+ import { cn } from '../lib/utils';
6
+
7
+ // Base do shadcn: botão que fica ligado ou desligado. Ligado usa `selected`, um tom acima
8
+ // do passar o mouse, para os dois não se confundirem.
9
+ const toggleVariants = cva(
10
+ "group/toggle inline-flex items-center justify-center gap-1 rounded-control text-body-13-medium whitespace-nowrap transition-all outline-none hover:bg-hover hover:text-foreground focus-visible:border-ring-strong focus-visible:focus-ring disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-ring-invalid aria-pressed:bg-selected data-pressed:bg-selected [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-icon",
11
+ {
12
+ variants: {
13
+ variant: {
14
+ default: 'bg-transparent',
15
+ outline: 'border border-input bg-transparent hover:bg-hover',
16
+ // Filtro rápido em pílula, como Atrasados ou Sem dono: borda, texto apagado e, ligado, o
17
+ // fundo selecionado com a borda forte.
18
+ chip: 'rounded-full border bg-transparent text-muted-foreground aria-pressed:border-selected-strong aria-pressed:text-selected-foreground data-pressed:border-selected-strong data-pressed:text-selected-foreground',
19
+ },
20
+ size: {
21
+ default:
22
+ 'h-control min-w-control px-2.5 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5',
23
+ sm: "h-control-sm min-w-control-sm px-2 text-body-13-medium has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-icon-sm",
24
+ lg: 'h-control-lg min-w-control-lg px-4 has-data-[icon=inline-end]:pr-4 has-data-[icon=inline-start]:pl-4',
25
+ // D-858: fora da escala pública, mantido só para não quebrar quem já usa.
26
+ xs: 'h-control-xs gap-1.5 px-2.5 text-body-12-medium',
27
+ },
28
+ },
29
+ defaultVariants: {
30
+ variant: 'default',
31
+ size: 'default',
32
+ },
33
+ },
34
+ );
35
+
36
+ function Toggle({
37
+ className,
38
+ variant = 'default',
39
+ size = 'default',
40
+ ...props
41
+ }: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
42
+ return (
43
+ <TogglePrimitive
44
+ data-slot="toggle"
45
+ className={cn(toggleVariants({ variant, size, className }))}
46
+ {...props}
47
+ />
48
+ );
49
+ }
50
+
51
+ export { Toggle, toggleVariants };
@@ -0,0 +1,160 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
5
+ import { InfoIcon } from 'lucide-react';
6
+ import { cn } from '../lib/utils';
7
+
8
+ // A dica abre na hora, sem espera. Com o TooltipProvider por fora, ele dá a espera, 0 por padrão,
9
+ // e junta as dicas vizinhas: passar de um botão ao outro troca a dica sem piscar. Sem o Provider,
10
+ // cada Tooltip cria o seu com espera 0, porque a peça de base esperaria 600ms.
11
+ const HasProvider = React.createContext(false);
12
+
13
+ function TooltipProvider({ delay = 0, ...props }: TooltipPrimitive.Provider.Props) {
14
+ return (
15
+ <HasProvider.Provider value>
16
+ <TooltipPrimitive.Provider data-slot="tooltip-provider" delay={delay} {...props} />
17
+ </HasProvider.Provider>
18
+ );
19
+ }
20
+
21
+ function Tooltip({ ...props }: TooltipPrimitive.Root.Props) {
22
+ const hasProvider = React.useContext(HasProvider);
23
+ const root = <TooltipPrimitive.Root data-slot="tooltip" {...props} />;
24
+ return hasProvider ? (
25
+ root
26
+ ) : (
27
+ <TooltipPrimitive.Provider delay={0}>{root}</TooltipPrimitive.Provider>
28
+ );
29
+ }
30
+
31
+ // Aparência da caixa e da seta, a mesma na dica que abre e na desenhada parada.
32
+ const BOX =
33
+ 'inline-flex w-fit max-w-xs items-center gap-1.5 rounded-menu bg-foreground px-2.5 py-1.5 text-body-12-medium text-background shadow-menu has-data-[slot=kbd]:pr-1.5';
34
+ // tokens-ok: ponta do balão, um quadrado de 10px girado
35
+ const ARROW = 'size-2.5 rotate-45 rounded-[2px] bg-foreground';
36
+
37
+ function TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props) {
38
+ return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
39
+ }
40
+
41
+ function TooltipContent({
42
+ className,
43
+ side = 'top',
44
+ sideOffset = 4,
45
+ align = 'center',
46
+ alignOffset = 0,
47
+ children,
48
+ ...props
49
+ }: TooltipPrimitive.Popup.Props &
50
+ Pick<TooltipPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {
51
+ return (
52
+ <TooltipPrimitive.Portal>
53
+ <TooltipPrimitive.Positioner
54
+ align={align}
55
+ alignOffset={alignOffset}
56
+ side={side}
57
+ sideOffset={sideOffset}
58
+ className="isolate z-50"
59
+ >
60
+ <TooltipPrimitive.Popup
61
+ data-slot="tooltip-content"
62
+ className={cn(
63
+ BOX,
64
+ 'z-50 origin-(--transform-origin) 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-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-small data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 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',
65
+ className,
66
+ )}
67
+ {...props}
68
+ >
69
+ {children}
70
+ <TooltipPrimitive.Arrow
71
+ className={cn(
72
+ ARROW,
73
+ 'z-50 translate-y-[calc(-50%-2px)] fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5',
74
+ )}
75
+ />
76
+ </TooltipPrimitive.Popup>
77
+ </TooltipPrimitive.Positioner>
78
+ </TooltipPrimitive.Portal>
79
+ );
80
+ }
81
+
82
+ type Side = 'top' | 'bottom' | 'left' | 'right';
83
+
84
+ const ARROW_SIDE: Record<Side, string> = {
85
+ top: '-bottom-1 left-1/2 -translate-x-1/2',
86
+ bottom: '-top-1 left-1/2 -translate-x-1/2',
87
+ left: '-right-1 top-1/2 -translate-y-1/2',
88
+ right: '-left-1 top-1/2 -translate-y-1/2',
89
+ };
90
+
91
+ /**
92
+ * Só a aparência da dica, parada e no lugar, sem abrir por cima da página. Serve para mostrar a
93
+ * dica num catálogo, num tutorial ou numa imagem de ajuda. `side` diz para que lado a dica está
94
+ * do botão; a seta aponta para o lado contrário.
95
+ */
96
+ function TooltipBubble({
97
+ side = 'top',
98
+ className,
99
+ children,
100
+ ...props
101
+ }: React.ComponentProps<'span'> & { side?: Side }) {
102
+ return (
103
+ <span
104
+ data-slot="tooltip-content"
105
+ data-side={side}
106
+ className={cn(BOX, 'relative whitespace-nowrap', className)}
107
+ {...props}
108
+ >
109
+ {children}
110
+ <span aria-hidden className={cn(ARROW, 'absolute', ARROW_SIDE[side])} />
111
+ </span>
112
+ );
113
+ }
114
+
115
+ /**
116
+ * Ícone de dica pronto: um "i" pequeno que abre a explicação ao passar o mouse ou chegar com Tab.
117
+ * Fica ao lado de um título ou rótulo, como "Ticket médio", para explicar a conta.
118
+ */
119
+ function InfoHint({
120
+ children,
121
+ label = 'Mais informações',
122
+ side = 'top',
123
+ size = 'default',
124
+ className,
125
+ }: {
126
+ /** `sm`: menor, ao lado do rótulo de um campo; `lg`: ao lado de um título. */
127
+ size?: 'sm' | 'default' | 'lg';
128
+ /** O texto da dica. */
129
+ children: React.ReactNode;
130
+ /** Nome do botão para o leitor de tela. */
131
+ label?: string;
132
+ side?: Side;
133
+ className?: string;
134
+ }) {
135
+ return (
136
+ <Tooltip>
137
+ <TooltipTrigger
138
+ aria-label={label}
139
+ className={cn(
140
+ 'relative inline-flex shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none after:absolute hover:text-foreground focus-visible:focus-ring',
141
+ size === 'sm'
142
+ ? 'size-4 after:-inset-2'
143
+ : size === 'lg'
144
+ ? 'size-6 after:-inset-1'
145
+ : 'size-5 after:-inset-1.5',
146
+ className,
147
+ )}
148
+ >
149
+ <InfoIcon
150
+ className={size === 'sm' ? 'size-icon-xs' : size === 'lg' ? 'size-icon' : 'size-icon-sm'}
151
+ />
152
+ </TooltipTrigger>
153
+ <TooltipContent side={side} className="whitespace-normal">
154
+ {children}
155
+ </TooltipContent>
156
+ </Tooltip>
157
+ );
158
+ }
159
+
160
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider, TooltipBubble, InfoHint };