@vowt-tech/ui 0.0.0-stage → 0.177.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +13 -2
  2. package/bin/vowt-ux-ui-design.mjs +483 -0
  3. package/guia/LEIA-PRIMEIRO.md +106 -0
  4. package/guia/VERSAO +1 -0
  5. package/guia/componentes.md +104 -0
  6. package/guia/regras/atualizar.md +136 -0
  7. package/guia/regras/componentes.md +374 -0
  8. package/guia/regras/fundamentos.md +257 -0
  9. package/guia/regras/marca.md +200 -0
  10. package/guia/regras/medidas.md +114 -0
  11. package/guia/regras/regras-de-base.md +85 -0
  12. package/guia/regras/telas/acoes.md +56 -0
  13. package/guia/regras/telas/direcao-ux.md +327 -0
  14. package/guia/regras/telas/padroes.md +58 -0
  15. package/guia/regras/telas/regras.md +171 -0
  16. package/guia/regras/telas/voz.md +134 -0
  17. package/package.json +72 -4
  18. package/src/brand/icons.ts +215 -0
  19. package/src/brand/logo.tsx +288 -0
  20. package/src/components/accordion.tsx +58 -0
  21. package/src/components/ai-orb.tsx +67 -0
  22. package/src/components/alert-dialog.tsx +227 -0
  23. package/src/components/alert.tsx +128 -0
  24. package/src/components/area-chart.tsx +180 -0
  25. package/src/components/attachment.tsx +339 -0
  26. package/src/components/avatar.tsx +197 -0
  27. package/src/components/badge.tsx +242 -0
  28. package/src/components/bar-chart.tsx +138 -0
  29. package/src/components/bar-list.tsx +85 -0
  30. package/src/components/brand-icon.tsx +52 -0
  31. package/src/components/breadcrumb.tsx +96 -0
  32. package/src/components/button-group.tsx +29 -0
  33. package/src/components/button.tsx +208 -0
  34. package/src/components/calendar.tsx +238 -0
  35. package/src/components/card.tsx +136 -0
  36. package/src/components/chart.tsx +289 -0
  37. package/src/components/checkbox.tsx +42 -0
  38. package/src/components/code-block.tsx +31 -0
  39. package/src/components/collapsible.tsx +114 -0
  40. package/src/components/color-picker.tsx +93 -0
  41. package/src/components/combo-chart.tsx +139 -0
  42. package/src/components/combobox.tsx +200 -0
  43. package/src/components/command.tsx +191 -0
  44. package/src/components/date-picker.tsx +435 -0
  45. package/src/components/description-list.tsx +280 -0
  46. package/src/components/dialog.tsx +192 -0
  47. package/src/components/diff-view.tsx +109 -0
  48. package/src/components/dropdown-menu.tsx +248 -0
  49. package/src/components/emoji-picker.tsx +299 -0
  50. package/src/components/empty.tsx +197 -0
  51. package/src/components/field.tsx +226 -0
  52. package/src/components/file-upload.tsx +186 -0
  53. package/src/components/funnel-chart.tsx +224 -0
  54. package/src/components/gauge-chart.tsx +109 -0
  55. package/src/components/heatmap.tsx +105 -0
  56. package/src/components/hover-card.tsx +47 -0
  57. package/src/components/image-viewer.tsx +174 -0
  58. package/src/components/input-otp.tsx +86 -0
  59. package/src/components/input.tsx +470 -0
  60. package/src/components/item.tsx +94 -0
  61. package/src/components/kbd.tsx +28 -0
  62. package/src/components/label.tsx +21 -0
  63. package/src/components/line-chart.tsx +92 -0
  64. package/src/components/link.tsx +34 -0
  65. package/src/components/message.tsx +903 -0
  66. package/src/components/number-field.tsx +79 -0
  67. package/src/components/pagination.tsx +208 -0
  68. package/src/components/phone-input.tsx +147 -0
  69. package/src/components/pie-chart.tsx +117 -0
  70. package/src/components/popover.tsx +102 -0
  71. package/src/components/powered-by.tsx +39 -0
  72. package/src/components/progress.tsx +278 -0
  73. package/src/components/prose.tsx +42 -0
  74. package/src/components/radar-chart.tsx +66 -0
  75. package/src/components/radial-chart.tsx +73 -0
  76. package/src/components/radio-group.tsx +135 -0
  77. package/src/components/rating.tsx +192 -0
  78. package/src/components/rich-text.tsx +1651 -0
  79. package/src/components/scatter-chart.tsx +115 -0
  80. package/src/components/scroll-area.tsx +50 -0
  81. package/src/components/select.tsx +193 -0
  82. package/src/components/separator.tsx +20 -0
  83. package/src/components/sheet.tsx +142 -0
  84. package/src/components/sidebar.tsx +570 -0
  85. package/src/components/skeleton.tsx +18 -0
  86. package/src/components/slider.tsx +47 -0
  87. package/src/components/sonner.tsx +178 -0
  88. package/src/components/sparkline.tsx +68 -0
  89. package/src/components/spinner.tsx +35 -0
  90. package/src/components/status-dot.tsx +45 -0
  91. package/src/components/stepper.tsx +228 -0
  92. package/src/components/switch.tsx +35 -0
  93. package/src/components/table.tsx +267 -0
  94. package/src/components/tabs.tsx +184 -0
  95. package/src/components/tag-input.tsx +238 -0
  96. package/src/components/textarea.tsx +47 -0
  97. package/src/components/time-picker.tsx +183 -0
  98. package/src/components/timeline.tsx +75 -0
  99. package/src/components/toggle-group.tsx +93 -0
  100. package/src/components/toggle.tsx +51 -0
  101. package/src/components/tooltip.tsx +160 -0
  102. package/src/components/tree.tsx +136 -0
  103. package/src/components/voice-message.tsx +193 -0
  104. package/src/css.d.ts +2 -0
  105. package/src/hooks/use-appearance.ts +57 -0
  106. package/src/hooks/use-mobile.ts +20 -0
  107. package/src/lib/appearance.ts +16 -0
  108. package/src/lib/button-render.ts +32 -0
  109. package/src/lib/char-count.tsx +67 -0
  110. package/src/lib/date.ts +45 -0
  111. package/src/lib/file-accept.ts +59 -0
  112. package/src/lib/markdown.ts +187 -0
  113. package/src/lib/utils.ts +29 -0
  114. package/src/lib/voice.ts +68 -0
  115. package/src/styles/shadcn.css +642 -0
  116. package/src/styles/theme.css +1825 -0
@@ -0,0 +1,208 @@
1
+ import { Button as ButtonPrimitive } from '@base-ui/react/button';
2
+ import * as React from 'react';
3
+ import { cva, type VariantProps } from 'class-variance-authority';
4
+ import { CheckIcon, CopyIcon } from 'lucide-react';
5
+ import { toast } from 'sonner';
6
+ import { buttonSemantics } from '../lib/button-render';
7
+ import { cn } from '../lib/utils';
8
+
9
+ const buttonVariants = cva(
10
+ "group/button inline-flex shrink-0 items-center justify-center rounded-control border border-transparent bg-clip-padding text-body-13-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring-strong focus-visible:focus-ring active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-ring-invalid dark:aria-invalid:border-border-error [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-icon",
11
+ {
12
+ variants: {
13
+ variant: {
14
+ // Desligado no escuro fica cinza: o azul a 50% virava um azul-marinho que parecia ligado.
15
+ default:
16
+ 'bg-primary text-primary-foreground hover:bg-primary-hover disabled:bg-surface-action-disabled disabled:text-text-on-action-disabled',
17
+ outline:
18
+ 'border-input bg-surface-control hover:bg-hover hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-hover',
19
+ secondary:
20
+ 'bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground dark:disabled:bg-surface-strong',
21
+ // D-791: o hover do botão discreto em gray 100 mesmo dentro de cartão branco, onde o
22
+ // hover das linhas fica em gray 50, D-728; no gray 50 o botão quase não mudava.
23
+ ghost:
24
+ 'hover:bg-surface-hover hover:text-foreground aria-expanded:bg-surface-hover aria-expanded:text-foreground',
25
+ destructive:
26
+ 'bg-destructive-subtle text-foreground [&_svg]:text-icon-error hover:bg-destructive-subtle-hover focus-visible:border-destructive/40 focus-visible:ring-ring-invalid dark:bg-destructive/20 dark:hover:bg-destructive/30',
27
+ link: 'text-foreground hover:text-foreground/70',
28
+ // D-655: ação de IA preenchida com o degradê, como Sugerir no Composer.
29
+ ai: 'bg-ai-gradient text-text-on-ai hover:opacity-90 aria-expanded:opacity-90',
30
+ },
31
+ // Alturas pela escala, D-680 e D-682: mínimo 24, pequeno 28, padrão 32, grande 36, iguais às do
32
+ // campo, para botão e busca alinharem lado a lado. O texto cresce junto (D-360): 12 no mínimo
33
+ // e no pequeno, 13 no padrão, 14 no grande e 16 no extra grande.
34
+ // D-789: com um Badge de número no fim, o respiro da direita diminui para ele acompanhar o
35
+ // canto do botão.
36
+ size: {
37
+ default:
38
+ 'h-control gap-2 px-4 has-data-[icon=inline-end]:pr-3.5 has-data-[icon=inline-start]:pl-3.5 has-[>[data-slot=badge]:last-child]:pr-1.5',
39
+ xs: "h-control-xs gap-1 px-2 text-body-12-medium [--spinner-size:0.75rem] in-data-[slot=button-group]:rounded-control has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 has-[>[data-slot=badge]:last-child]:pr-0.5 [&_svg:not([class*='size-'])]:size-icon-xs",
40
+ sm: "h-control-sm gap-1.5 px-3 text-body-13-medium [--spinner-size:0.875rem] in-data-[slot=button-group]:rounded-control has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5 has-[>[data-slot=badge]:last-child]:pr-1 [&_svg:not([class*='size-'])]:size-icon",
41
+ lg: "h-control-lg gap-2 px-4 text-body-14-medium has-data-[icon=inline-end]:pr-3.5 has-data-[icon=inline-start]:pl-3.5 [&_svg:not([class*='size-'])]:size-icon-lg",
42
+ // D-858: a escala pública é sm, padrão e lg. O xs e o xl continuam só para não quebrar quem
43
+ // já usa: o xs nas peças compactas do pacote, como o aviso, e o xl antigo vale como lg.
44
+ // Extra grande (D-165): chamada principal de página, como a entrada de um site.
45
+ xl: "h-control-xl gap-2 px-6 text-heading-16-medium has-data-[icon=inline-end]:pr-5 has-data-[icon=inline-start]:pl-5 [&_svg:not([class*='size-'])]:size-icon-xl",
46
+ // Ícone sozinho (D-175): o icon-sm, de 32, é o mais usado, em linha de tabela e cabeçalho
47
+ // de card. O ícone de dentro tem 16, pelo size-icon-solo; 12 no icon-xs e 20 no icon-xl.
48
+ icon: "size-control [&_svg:not([class*='size-'])]:size-icon-solo",
49
+ 'icon-xs':
50
+ "size-control-xs in-data-[slot=button-group]:rounded-control [--spinner-size:0.75rem] [&_svg:not([class*='size-'])]:size-icon-xs",
51
+ 'icon-sm':
52
+ "size-control-sm in-data-[slot=button-group]:rounded-control [--spinner-size:0.875rem] [&_svg:not([class*='size-'])]:size-icon-solo",
53
+ 'icon-lg': "size-control-lg [&_svg:not([class*='size-'])]:size-icon-solo",
54
+ 'icon-xl': "size-control-xl [&_svg:not([class*='size-'])]:size-icon-xl",
55
+ },
56
+ // Forma (D-164): pílula para chamadas de página, como a entrada de um site ou de uma campanha.
57
+ // Nos painéis, o canto padrão continua.
58
+ shape: {
59
+ default: '',
60
+ pill: 'rounded-full in-data-[slot=button-group]:rounded-full',
61
+ },
62
+ },
63
+ defaultVariants: {
64
+ variant: 'default',
65
+ size: 'default',
66
+ shape: 'default',
67
+ },
68
+ },
69
+ );
70
+
71
+ // Botão que é um link, com render={<Link />} ou <a>: sai com o papel de link para o leitor de
72
+ // tela, e não de botão, mantendo a aparência, o foco e o Enter que navega. Detectado sozinho.
73
+ function Button({
74
+ className,
75
+ variant = 'default',
76
+ size = 'default',
77
+ shape = 'default',
78
+ nativeButton,
79
+ ...props
80
+ }: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
81
+ return (
82
+ <ButtonPrimitive
83
+ data-slot="button"
84
+ className={cn(buttonVariants({ variant, size, shape, className }))}
85
+ {...buttonSemantics(props.render, nativeButton)}
86
+ {...props}
87
+ />
88
+ );
89
+ }
90
+
91
+ // Botão com estado (D-309): liga e desliga uma coisa, como "Seguir" que vira "Seguindo". O texto e o
92
+ // ícone mudam com o estado; com `onLabel`, ligado e com o mouse em cima mostra a ação de desfazer,
93
+ // como "Deixar de seguir". Com `dual`, ligado vira o botão principal, em Midnight.
94
+ function StatefulButton({
95
+ pressed,
96
+ onPressedChange,
97
+ off,
98
+ on,
99
+ hover,
100
+ dual = false,
101
+ size = 'default',
102
+ className,
103
+ ...props
104
+ }: Omit<ButtonPrimitive.Props, 'children' | 'onClick'> &
105
+ Pick<VariantProps<typeof buttonVariants>, 'size'> & {
106
+ pressed: boolean;
107
+ onPressedChange: (pressed: boolean) => void;
108
+ /** Conteúdo desligado, como ícone de + e "Seguir". */
109
+ off: React.ReactNode;
110
+ /** Conteúdo ligado, como ícone de ✓ e "Seguindo". */
111
+ on: React.ReactNode;
112
+ /** Conteúdo ligado com o mouse em cima, como "Deixar de seguir". */
113
+ hover?: React.ReactNode;
114
+ dual?: boolean;
115
+ }) {
116
+ return (
117
+ <Button
118
+ data-slot="stateful-button"
119
+ aria-pressed={pressed}
120
+ variant={dual && pressed ? 'default' : 'outline'}
121
+ size={size}
122
+ onClick={() => onPressedChange(!pressed)}
123
+ className={cn('group/stateful', className)}
124
+ {...props}
125
+ >
126
+ {!pressed ? (
127
+ off
128
+ ) : hover ? (
129
+ <>
130
+ <span className="contents group-hover/stateful:hidden">{on}</span>
131
+ <span className="hidden group-hover/stateful:contents">{hover}</span>
132
+ </>
133
+ ) : (
134
+ on
135
+ )}
136
+ </Button>
137
+ );
138
+ }
139
+
140
+ // Botão de copiar ao lado de um dado (e-mail, telefone, CNPJ). Mostra o ✓ por um instante. Com
141
+ // variant="inline", vem com o valor junto, em fonte de código, para códigos como o de um erro ou
142
+ // de uma chave: o texto e o botão numa peça só.
143
+ export function CopyButton({
144
+ value,
145
+ label,
146
+ variant = 'icon',
147
+ children,
148
+ className,
149
+ }: {
150
+ value: string;
151
+ /** O que é copiado, para o leitor de tela e o aviso ("e-mail", "telefone"). */
152
+ label: string;
153
+ /** "icon": só o botão; "inline": o valor e o botão juntos. */
154
+ variant?: 'icon' | 'inline';
155
+ /** No inline, troca o texto mostrado, como um código encurtado. Copia sempre o `value`. */
156
+ children?: React.ReactNode;
157
+ className?: string;
158
+ }) {
159
+ // Arquivo sem use client, porque o buttonVariants serve também a telas do servidor: os
160
+ // ganchos vêm por React.*. Em tela do servidor, o CopyButton entra dentro de uma peça cliente.
161
+ const [done, setDone] = React.useState(false);
162
+ // O "copiado" some sozinho; ao sair da tela antes disso, o tempo é cancelado.
163
+ const timer = React.useRef<ReturnType<typeof setTimeout>>(undefined);
164
+ React.useEffect(() => () => clearTimeout(timer.current), []);
165
+ async function copy() {
166
+ try {
167
+ await navigator.clipboard.writeText(value);
168
+ setDone(true);
169
+ toast.success(`${label[0]?.toUpperCase()}${label.slice(1)} copiado.`);
170
+ clearTimeout(timer.current);
171
+ timer.current = setTimeout(() => setDone(false), 1500);
172
+ } catch {
173
+ toast.error('Não foi possível copiar.');
174
+ }
175
+ }
176
+ const button = (
177
+ <Button
178
+ type="button"
179
+ variant="ghost"
180
+ size="icon-xs"
181
+ aria-label={`Copiar ${label}`}
182
+ className={cn('text-muted-foreground relative z-10', variant === 'icon' && className)}
183
+ onClick={(e) => {
184
+ e.preventDefault();
185
+ e.stopPropagation();
186
+ void copy();
187
+ }}
188
+ >
189
+ {done ? <CheckIcon /> : <CopyIcon />}
190
+ </Button>
191
+ );
192
+ if (variant === 'icon') return button;
193
+ return (
194
+ <span
195
+ data-slot="copy-button"
196
+ data-variant="inline"
197
+ className={cn(
198
+ 'inline-flex max-w-full items-center gap-0.5 rounded-inner bg-muted py-0.5 pr-0.5 pl-2',
199
+ className,
200
+ )}
201
+ >
202
+ <code className="truncate text-mono-12 text-foreground">{children ?? value}</code>
203
+ {button}
204
+ </span>
205
+ );
206
+ }
207
+
208
+ export { Button, StatefulButton, buttonVariants };
@@ -0,0 +1,238 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { cn } from '../lib/utils';
5
+ import {
6
+ DayPicker,
7
+ getDefaultClassNames,
8
+ type DayButton,
9
+ type DropdownProps,
10
+ type Locale,
11
+ } from 'react-day-picker';
12
+ import { ptBR } from 'react-day-picker/locale';
13
+
14
+ import { Button, buttonVariants } from './button';
15
+ import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from 'lucide-react';
16
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './select';
17
+
18
+ // Base do shadcn: calendário em português, com casas de 36px. O Date picker (Padrões)
19
+ // é montado sobre ele. Mês e ano no topo usam o Select do pacote, e não a lista do navegador,
20
+ // para ficarem iguais em todo navegador.
21
+
22
+ function Calendar({
23
+ className,
24
+ classNames,
25
+ showOutsideDays = true,
26
+ captionLayout = 'label',
27
+ buttonVariant = 'ghost',
28
+ locale = ptBR,
29
+ formatters,
30
+ components,
31
+ ...props
32
+ }: React.ComponentProps<typeof DayPicker> & {
33
+ buttonVariant?: React.ComponentProps<typeof Button>['variant'];
34
+ }) {
35
+ const defaultClassNames = getDefaultClassNames();
36
+
37
+ return (
38
+ <DayPicker
39
+ showOutsideDays={showOutsideDays}
40
+ className={cn(
41
+ 'group/calendar bg-card p-3 [--cell-radius:var(--radius-control)] [--cell-size:--spacing(9)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent',
42
+ String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
43
+ String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
44
+ className,
45
+ )}
46
+ captionLayout={captionLayout}
47
+ locale={locale}
48
+ formatters={{
49
+ formatMonthDropdown: (date) => date.toLocaleString(locale?.code, { month: 'short' }),
50
+ // O curto do date-fns escreve "sab", sem acento; o do navegador dá "sáb.", sem o ponto.
51
+ formatWeekdayName: (date) =>
52
+ date.toLocaleDateString(locale?.code, { weekday: 'short' }).replace('.', ''),
53
+ ...formatters,
54
+ }}
55
+ classNames={{
56
+ root: cn('w-fit', defaultClassNames.root),
57
+ months: cn('relative flex flex-col gap-4 md:flex-row', defaultClassNames.months),
58
+ month: cn('flex w-full flex-col gap-4', defaultClassNames.month),
59
+ nav: cn(
60
+ 'absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1',
61
+ defaultClassNames.nav,
62
+ ),
63
+ button_previous: cn(
64
+ buttonVariants({ variant: buttonVariant }),
65
+ 'size-(--cell-size) p-0 select-none aria-disabled:opacity-50',
66
+ defaultClassNames.button_previous,
67
+ ),
68
+ button_next: cn(
69
+ buttonVariants({ variant: buttonVariant }),
70
+ 'size-(--cell-size) p-0 select-none aria-disabled:opacity-50',
71
+ defaultClassNames.button_next,
72
+ ),
73
+ month_caption: cn(
74
+ 'flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)',
75
+ defaultClassNames.month_caption,
76
+ ),
77
+ dropdowns: cn(
78
+ 'flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-body-13-medium',
79
+ defaultClassNames.dropdowns,
80
+ ),
81
+ dropdown_root: cn('relative rounded-(--cell-radius)', defaultClassNames.dropdown_root),
82
+ dropdown: cn('absolute inset-0 bg-popover opacity-0', defaultClassNames.dropdown),
83
+ caption_label: cn(
84
+ 'font-medium select-none',
85
+ captionLayout === 'label'
86
+ ? 'text-body-13-medium'
87
+ : 'flex items-center gap-1 rounded-(--cell-radius) text-body-13-medium [&>svg]:size-icon-sm [&>svg]:text-muted-foreground',
88
+ defaultClassNames.caption_label,
89
+ ),
90
+ month_grid: cn('w-full border-collapse', defaultClassNames.month_grid),
91
+ weekdays: cn('flex', defaultClassNames.weekdays),
92
+ weekday: cn(
93
+ 'flex-1 rounded-(--cell-radius) text-body-12 text-muted-foreground select-none',
94
+ defaultClassNames.weekday,
95
+ ),
96
+ week: cn('mt-2 flex w-full', defaultClassNames.week),
97
+ week_number_header: cn('w-(--cell-size) select-none', defaultClassNames.week_number_header),
98
+ week_number: cn(
99
+ 'text-body-12 text-muted-foreground select-none',
100
+ defaultClassNames.week_number,
101
+ ),
102
+ day: cn(
103
+ 'group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)',
104
+ props.showWeekNumber
105
+ ? '[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)'
106
+ : '[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)',
107
+ defaultClassNames.day,
108
+ ),
109
+ range_start: cn(
110
+ 'relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted',
111
+ defaultClassNames.range_start,
112
+ ),
113
+ range_middle: cn('rounded-none', defaultClassNames.range_middle),
114
+ range_end: cn(
115
+ 'relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted',
116
+ defaultClassNames.range_end,
117
+ ),
118
+ today: cn(
119
+ 'rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none',
120
+ defaultClassNames.today,
121
+ ),
122
+ outside: cn(
123
+ 'text-muted-foreground aria-selected:text-muted-foreground',
124
+ defaultClassNames.outside,
125
+ ),
126
+ disabled: cn('text-muted-foreground opacity-50', defaultClassNames.disabled),
127
+ hidden: cn('invisible', defaultClassNames.hidden),
128
+ ...classNames,
129
+ }}
130
+ components={{
131
+ Root: ({ className, rootRef, ...props }) => {
132
+ return <div data-slot="calendar" ref={rootRef} className={cn(className)} {...props} />;
133
+ },
134
+ Chevron: ({ className, orientation, ...props }) => {
135
+ if (orientation === 'left') {
136
+ return <ChevronLeftIcon className={cn('size-icon-lg', className)} {...props} />;
137
+ }
138
+
139
+ if (orientation === 'right') {
140
+ return <ChevronRightIcon className={cn('size-icon-lg', className)} {...props} />;
141
+ }
142
+
143
+ return <ChevronDownIcon className={cn('size-icon-xs', className)} {...props} />;
144
+ },
145
+ Dropdown: CalendarDropdown,
146
+ DayButton: ({ ...props }) => <CalendarDayButton locale={locale} {...props} />,
147
+ WeekNumber: ({ children, ...props }) => {
148
+ return (
149
+ <td {...props}>
150
+ <div className="flex size-(--cell-size) items-center justify-center text-center">
151
+ {children}
152
+ </div>
153
+ </td>
154
+ );
155
+ },
156
+ ...components,
157
+ }}
158
+ {...props}
159
+ />
160
+ );
161
+ }
162
+
163
+ /** Mês ou ano no topo: o Select do pacote no lugar do campo de lista do navegador. */
164
+ function CalendarDropdown({
165
+ options = [],
166
+ value,
167
+ onChange,
168
+ disabled,
169
+ 'aria-label': ariaLabel,
170
+ }: DropdownProps) {
171
+ const current = Number(value);
172
+ return (
173
+ <Select
174
+ value={current}
175
+ disabled={disabled}
176
+ onValueChange={(v) => {
177
+ if (v === null) return;
178
+ // O calendário lê o valor como se viesse do campo de lista; o evento leva só o valor.
179
+ onChange?.({ target: { value: String(v) } } as React.ChangeEvent<HTMLSelectElement>);
180
+ }}
181
+ >
182
+ <SelectTrigger
183
+ size="sm"
184
+ aria-label={ariaLabel}
185
+ className="relative border-transparent px-2 text-body-13-medium hover:bg-hover dark:bg-transparent dark:hover:bg-hover"
186
+ >
187
+ <SelectValue>{(v: number) => options.find((o) => o.value === v)?.label}</SelectValue>
188
+ </SelectTrigger>
189
+ <SelectContent alignItemWithTrigger={false} className="scroll-hairline max-h-64">
190
+ {options.map((o) => (
191
+ <SelectItem key={o.value} value={o.value} disabled={o.disabled}>
192
+ {o.label}
193
+ </SelectItem>
194
+ ))}
195
+ </SelectContent>
196
+ </Select>
197
+ );
198
+ }
199
+
200
+ function CalendarDayButton({
201
+ className,
202
+ day,
203
+ modifiers,
204
+ locale,
205
+ ...props
206
+ }: React.ComponentProps<typeof DayButton> & { locale?: Partial<Locale> }) {
207
+ const defaultClassNames = getDefaultClassNames();
208
+
209
+ const ref = React.useRef<HTMLButtonElement>(null);
210
+ React.useEffect(() => {
211
+ if (modifiers.focused) ref.current?.focus();
212
+ }, [modifiers.focused]);
213
+
214
+ return (
215
+ <Button
216
+ variant="ghost"
217
+ size="icon"
218
+ data-day={day.date.toLocaleDateString(locale?.code)}
219
+ data-selected-single={
220
+ modifiers.selected &&
221
+ !modifiers.range_start &&
222
+ !modifiers.range_end &&
223
+ !modifiers.range_middle
224
+ }
225
+ data-range-start={modifiers.range_start}
226
+ data-range-end={modifiers.range_end}
227
+ data-range-middle={modifiers.range_middle}
228
+ className={cn(
229
+ 'relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:focus-ring data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-selected-strong data-[range-end=true]:text-selected-strong-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-selected-strong data-[range-start=true]:text-selected-strong-foreground data-[selected-single=true]:bg-selected-strong data-[selected-single=true]:text-selected-strong-foreground dark:hover:text-foreground [&>span]:text-body-12 [&>span]:opacity-70',
230
+ defaultClassNames.day,
231
+ className,
232
+ )}
233
+ {...props}
234
+ />
235
+ );
236
+ }
237
+
238
+ export { Calendar, CalendarDayButton };
@@ -0,0 +1,136 @@
1
+ import * as React from 'react';
2
+ import { mergeProps } from '@base-ui/react/merge-props';
3
+ import { useRender } from '@base-ui/react/use-render';
4
+ import { cva, type VariantProps } from 'class-variance-authority';
5
+ import { cn } from '../lib/utils';
6
+
7
+ // tokens-ok-ligacao: só estrutura e tokens: moldura com cabeçalho, conteúdo e rodapé.
8
+
9
+ function Card({
10
+ className,
11
+ size = 'default',
12
+ ...props
13
+ }: React.ComponentProps<'div'> & {
14
+ /** Respiro interno, igual ao do Panel pelo tema, D-812: sm 12px, default 16px, lg 24px. */
15
+ size?: 'sm' | 'default' | 'lg';
16
+ }) {
17
+ return (
18
+ <div
19
+ data-slot="card"
20
+ data-size={size}
21
+ className={cn(
22
+ 'group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-card bg-card py-(--card-spacing) text-body-13 text-card-foreground shadow-card border border-input [--card-spacing:var(--scale-card)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:var(--scale-card-sm)] data-[size=lg]:[--card-spacing:var(--scale-card-lg)] *:[img:first-child]:rounded-t-card *:[img:last-child]:rounded-b-card',
23
+ className,
24
+ )}
25
+ {...props}
26
+ />
27
+ );
28
+ }
29
+
30
+ function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
31
+ return (
32
+ <div
33
+ data-slot="card-header"
34
+ className={cn(
35
+ 'group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-card px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)',
36
+ className,
37
+ )}
38
+ {...props}
39
+ />
40
+ );
41
+ }
42
+
43
+ function CardTitle({ className, ...props }: React.ComponentProps<'div'>) {
44
+ return (
45
+ <div
46
+ data-slot="card-title"
47
+ className={cn('text-title-card group-data-[size=sm]/card:text-body-13-semibold', className)}
48
+ {...props}
49
+ />
50
+ );
51
+ }
52
+
53
+ function CardDescription({ className, ...props }: React.ComponentProps<'div'>) {
54
+ return (
55
+ <div
56
+ data-slot="card-description"
57
+ className={cn('text-body-13 text-muted-foreground', className)}
58
+ {...props}
59
+ />
60
+ );
61
+ }
62
+
63
+ function CardAction({ className, ...props }: React.ComponentProps<'div'>) {
64
+ return (
65
+ <div
66
+ data-slot="card-action"
67
+ className={cn('col-start-2 row-span-2 row-start-1 self-start justify-self-end', className)}
68
+ {...props}
69
+ />
70
+ );
71
+ }
72
+
73
+ function CardContent({ className, ...props }: React.ComponentProps<'div'>) {
74
+ return (
75
+ <div data-slot="card-content" className={cn('px-(--card-spacing)', className)} {...props} />
76
+ );
77
+ }
78
+
79
+ function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
80
+ return (
81
+ <div
82
+ data-slot="card-footer"
83
+ className={cn('flex items-center px-(--card-spacing) pb-(--card-spacing)', className)}
84
+ {...props}
85
+ />
86
+ );
87
+ }
88
+
89
+ // Caixa com borda e fundo de cartão, canto do cartão, respiro igual ao do Card, D-812, para agrupar o que está dentro: uma linha de
90
+ // configuração, um resumo, um item de lista. Diferente do Card, não traz cabeçalho nem rodapé; o
91
+ // conteúdo decide o próprio arranjo. Com `render`, vira a tag certa, como <li> ou um link.
92
+ const panelVariants = cva('rounded-card border border-input bg-card text-card-foreground', {
93
+ variants: {
94
+ padding: {
95
+ none: '',
96
+ sm: 'p-card-sm',
97
+ md: 'p-card',
98
+ lg: 'p-card-lg',
99
+ },
100
+ interactive: {
101
+ true: 'outline-none transition-colors hover:bg-hover focus-visible:focus-ring',
102
+ false: '',
103
+ },
104
+ },
105
+ defaultVariants: { padding: 'md', interactive: false },
106
+ });
107
+
108
+ function Panel({
109
+ className,
110
+ padding,
111
+ interactive,
112
+ render,
113
+ ...props
114
+ }: useRender.ComponentProps<'div'> & VariantProps<typeof panelVariants>) {
115
+ return useRender({
116
+ defaultTagName: 'div',
117
+ props: mergeProps<'div'>(
118
+ { className: cn(panelVariants({ padding, interactive }), className) },
119
+ props,
120
+ ),
121
+ render,
122
+ state: { slot: 'panel' },
123
+ });
124
+ }
125
+
126
+ export {
127
+ Card,
128
+ CardHeader,
129
+ CardFooter,
130
+ CardTitle,
131
+ CardAction,
132
+ CardDescription,
133
+ CardContent,
134
+ Panel,
135
+ panelVariants,
136
+ };