@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.
- package/README.md +13 -2
- package/bin/vowt-ux-ui-design.mjs +483 -0
- package/guia/LEIA-PRIMEIRO.md +106 -0
- package/guia/VERSAO +1 -0
- package/guia/componentes.md +104 -0
- package/guia/regras/atualizar.md +136 -0
- package/guia/regras/componentes.md +374 -0
- package/guia/regras/fundamentos.md +257 -0
- package/guia/regras/marca.md +200 -0
- package/guia/regras/medidas.md +114 -0
- package/guia/regras/regras-de-base.md +85 -0
- package/guia/regras/telas/acoes.md +56 -0
- package/guia/regras/telas/direcao-ux.md +327 -0
- package/guia/regras/telas/padroes.md +58 -0
- package/guia/regras/telas/regras.md +171 -0
- package/guia/regras/telas/voz.md +134 -0
- package/package.json +72 -4
- package/src/brand/icons.ts +215 -0
- package/src/brand/logo.tsx +288 -0
- package/src/components/accordion.tsx +58 -0
- package/src/components/ai-orb.tsx +67 -0
- package/src/components/alert-dialog.tsx +227 -0
- package/src/components/alert.tsx +128 -0
- package/src/components/area-chart.tsx +180 -0
- package/src/components/attachment.tsx +339 -0
- package/src/components/avatar.tsx +197 -0
- package/src/components/badge.tsx +242 -0
- package/src/components/bar-chart.tsx +138 -0
- package/src/components/bar-list.tsx +85 -0
- package/src/components/brand-icon.tsx +52 -0
- package/src/components/breadcrumb.tsx +96 -0
- package/src/components/button-group.tsx +29 -0
- package/src/components/button.tsx +208 -0
- package/src/components/calendar.tsx +238 -0
- package/src/components/card.tsx +136 -0
- package/src/components/chart.tsx +289 -0
- package/src/components/checkbox.tsx +42 -0
- package/src/components/code-block.tsx +31 -0
- package/src/components/collapsible.tsx +114 -0
- package/src/components/color-picker.tsx +93 -0
- package/src/components/combo-chart.tsx +139 -0
- package/src/components/combobox.tsx +200 -0
- package/src/components/command.tsx +191 -0
- package/src/components/date-picker.tsx +435 -0
- package/src/components/description-list.tsx +280 -0
- package/src/components/dialog.tsx +192 -0
- package/src/components/diff-view.tsx +109 -0
- package/src/components/dropdown-menu.tsx +248 -0
- package/src/components/emoji-picker.tsx +299 -0
- package/src/components/empty.tsx +197 -0
- package/src/components/field.tsx +226 -0
- package/src/components/file-upload.tsx +186 -0
- package/src/components/funnel-chart.tsx +224 -0
- package/src/components/gauge-chart.tsx +109 -0
- package/src/components/heatmap.tsx +105 -0
- package/src/components/hover-card.tsx +47 -0
- package/src/components/image-viewer.tsx +174 -0
- package/src/components/input-otp.tsx +86 -0
- package/src/components/input.tsx +470 -0
- package/src/components/item.tsx +94 -0
- package/src/components/kbd.tsx +28 -0
- package/src/components/label.tsx +21 -0
- package/src/components/line-chart.tsx +92 -0
- package/src/components/link.tsx +34 -0
- package/src/components/message.tsx +903 -0
- package/src/components/number-field.tsx +79 -0
- package/src/components/pagination.tsx +208 -0
- package/src/components/phone-input.tsx +147 -0
- package/src/components/pie-chart.tsx +117 -0
- package/src/components/popover.tsx +102 -0
- package/src/components/powered-by.tsx +39 -0
- package/src/components/progress.tsx +278 -0
- package/src/components/prose.tsx +42 -0
- package/src/components/radar-chart.tsx +66 -0
- package/src/components/radial-chart.tsx +73 -0
- package/src/components/radio-group.tsx +135 -0
- package/src/components/rating.tsx +192 -0
- package/src/components/rich-text.tsx +1651 -0
- package/src/components/scatter-chart.tsx +115 -0
- package/src/components/scroll-area.tsx +50 -0
- package/src/components/select.tsx +193 -0
- package/src/components/separator.tsx +20 -0
- package/src/components/sheet.tsx +142 -0
- package/src/components/sidebar.tsx +570 -0
- package/src/components/skeleton.tsx +18 -0
- package/src/components/slider.tsx +47 -0
- package/src/components/sonner.tsx +178 -0
- package/src/components/sparkline.tsx +68 -0
- package/src/components/spinner.tsx +35 -0
- package/src/components/status-dot.tsx +45 -0
- package/src/components/stepper.tsx +228 -0
- package/src/components/switch.tsx +35 -0
- package/src/components/table.tsx +267 -0
- package/src/components/tabs.tsx +184 -0
- package/src/components/tag-input.tsx +238 -0
- package/src/components/textarea.tsx +47 -0
- package/src/components/time-picker.tsx +183 -0
- package/src/components/timeline.tsx +75 -0
- package/src/components/toggle-group.tsx +93 -0
- package/src/components/toggle.tsx +51 -0
- package/src/components/tooltip.tsx +160 -0
- package/src/components/tree.tsx +136 -0
- package/src/components/voice-message.tsx +193 -0
- package/src/css.d.ts +2 -0
- package/src/hooks/use-appearance.ts +57 -0
- package/src/hooks/use-mobile.ts +20 -0
- package/src/lib/appearance.ts +16 -0
- package/src/lib/button-render.ts +32 -0
- package/src/lib/char-count.tsx +67 -0
- package/src/lib/date.ts +45 -0
- package/src/lib/file-accept.ts +59 -0
- package/src/lib/markdown.ts +187 -0
- package/src/lib/utils.ts +29 -0
- package/src/lib/voice.ts +68 -0
- package/src/styles/shadcn.css +642 -0
- package/src/styles/theme.css +1825 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SparklesIcon, XIcon } from 'lucide-react';
|
|
3
|
+
import { mergeProps } from '@base-ui/react/merge-props';
|
|
4
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
5
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
6
|
+
import { cn } from '../lib/utils';
|
|
7
|
+
import { Button } from './button';
|
|
8
|
+
|
|
9
|
+
const badgeVariants = cva(
|
|
10
|
+
'group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-badge border border-transparent px-1.5 py-0.5 text-body-12-medium whitespace-nowrap transition-all focus-visible:border-ring-strong focus-visible:focus-ring has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-ring-invalid [&>svg]:pointer-events-none [&>svg]:size-icon-sm! [--spinner-size:0.875rem]',
|
|
11
|
+
{
|
|
12
|
+
variants: {
|
|
13
|
+
variant: {
|
|
14
|
+
default: 'bg-foreground text-card [a]:hover:bg-foreground/90',
|
|
15
|
+
// No escuro, os neutros sobem um tom: o fundo do cinza suave some no cartão escuro.
|
|
16
|
+
secondary:
|
|
17
|
+
'bg-secondary text-secondary-foreground dark:bg-surface-strong [a]:hover:bg-secondary/80',
|
|
18
|
+
destructive:
|
|
19
|
+
'bg-destructive-subtle text-destructive-subtle-foreground focus-visible:ring-ring-invalid dark:bg-destructive/20 [a]:hover:bg-destructive/20',
|
|
20
|
+
// Status suaves: fundo claro e texto escuro do mesmo tom.
|
|
21
|
+
success: 'bg-success-subtle text-success-subtle-foreground',
|
|
22
|
+
warning: 'bg-warning-subtle text-warning-subtle-foreground',
|
|
23
|
+
info: 'bg-info-subtle text-info-subtle-foreground dark:bg-surface-strong',
|
|
24
|
+
// D-681: selo de IA no degradê, como o botão e a borda.
|
|
25
|
+
ai: 'bg-ai-gradient text-text-on-ai',
|
|
26
|
+
outline: 'border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground',
|
|
27
|
+
ghost: 'hover:bg-muted hover:text-muted-foreground dark:hover:bg-hover',
|
|
28
|
+
link: 'text-link hover:text-link-hover',
|
|
29
|
+
},
|
|
30
|
+
// Pequeno: contagem de não lidas, número da aba ou da coluna (D-313).
|
|
31
|
+
size: {
|
|
32
|
+
default: '',
|
|
33
|
+
sm: 'h-5 min-w-5 rounded-full px-1.5 text-body-12 tabular-nums',
|
|
34
|
+
// D-858: grande, ao lado de um título ou num botão grande.
|
|
35
|
+
lg: 'h-6 px-2 text-body-13-medium has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&>svg]:size-icon!',
|
|
36
|
+
// Mínimo: a variação ao lado do número de um Stat, que só compara e não pode pesar (D-374).
|
|
37
|
+
xs: 'h-4 min-w-4 gap-0.5 rounded-full px-1 text-body-10-medium tabular-nums [&>svg]:size-2.5!',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
variant: 'default',
|
|
42
|
+
size: 'default',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
// Selo: situação, contagem ou etiqueta. Ícone à esquerda ou à direita entra como filho, com
|
|
48
|
+
// data-icon. Com `onRemove`, ganha o x para tirar, como numa tag escolhida (D-309).
|
|
49
|
+
function Badge({
|
|
50
|
+
className,
|
|
51
|
+
variant = 'default',
|
|
52
|
+
size = 'default',
|
|
53
|
+
render,
|
|
54
|
+
onRemove,
|
|
55
|
+
removeLabel = 'Remover',
|
|
56
|
+
children,
|
|
57
|
+
...props
|
|
58
|
+
}: useRender.ComponentProps<'span'> &
|
|
59
|
+
VariantProps<typeof badgeVariants> & {
|
|
60
|
+
onRemove?: () => void;
|
|
61
|
+
/** Nome do x para o leitor de tela, como "Tirar a tag VIP". */
|
|
62
|
+
removeLabel?: string;
|
|
63
|
+
}) {
|
|
64
|
+
return useRender({
|
|
65
|
+
defaultTagName: 'span',
|
|
66
|
+
props: mergeProps<'span'>(
|
|
67
|
+
{
|
|
68
|
+
className: cn(badgeVariants({ variant, size }), onRemove && 'pr-0.5', className),
|
|
69
|
+
children: onRemove ? (
|
|
70
|
+
<>
|
|
71
|
+
{children}
|
|
72
|
+
<button
|
|
73
|
+
type="button"
|
|
74
|
+
aria-label={removeLabel}
|
|
75
|
+
onClick={onRemove}
|
|
76
|
+
className="relative inline-flex size-5 items-center justify-center rounded-full outline-none after:absolute after:-inset-1 hover:bg-foreground/10 focus-visible:focus-ring"
|
|
77
|
+
>
|
|
78
|
+
<XIcon className="size-icon-xs" />
|
|
79
|
+
</button>
|
|
80
|
+
</>
|
|
81
|
+
) : (
|
|
82
|
+
children
|
|
83
|
+
),
|
|
84
|
+
},
|
|
85
|
+
props,
|
|
86
|
+
),
|
|
87
|
+
render,
|
|
88
|
+
state: {
|
|
89
|
+
slot: 'badge',
|
|
90
|
+
variant,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Selo de contagem por cima de um botão ou ícone, no canto de cima, como o número de avisos no
|
|
97
|
+
* sino ou de itens no carrinho. Com `dot`, só uma bolinha, para "tem novidade" sem número. Acima
|
|
98
|
+
* de `max`, mostra "9+". Zero esconde o selo. O número não é lido duas vezes: diga a contagem no
|
|
99
|
+
* `aria-label` do botão, como "Avisos, 3 não lidos".
|
|
100
|
+
*/
|
|
101
|
+
function CountBadge({
|
|
102
|
+
count,
|
|
103
|
+
max = 9,
|
|
104
|
+
dot = false,
|
|
105
|
+
tone = 'default',
|
|
106
|
+
className,
|
|
107
|
+
children,
|
|
108
|
+
}: {
|
|
109
|
+
count?: number;
|
|
110
|
+
max?: number;
|
|
111
|
+
dot?: boolean;
|
|
112
|
+
/** `danger` deixa o selo vermelho, para o que pede atenção, como avisos não lidos. */
|
|
113
|
+
tone?: 'default' | 'danger';
|
|
114
|
+
className?: string;
|
|
115
|
+
/** O botão ou ícone que leva o selo. */
|
|
116
|
+
children: React.ReactNode;
|
|
117
|
+
}) {
|
|
118
|
+
const show = dot || (count ?? 0) > 0;
|
|
119
|
+
return (
|
|
120
|
+
<span data-slot="count-badge" className={cn('relative inline-flex w-fit', className)}>
|
|
121
|
+
{children}
|
|
122
|
+
{show && (
|
|
123
|
+
<span
|
|
124
|
+
aria-hidden
|
|
125
|
+
className={cn(
|
|
126
|
+
'pointer-events-none absolute z-10 ring-2 ring-background',
|
|
127
|
+
dot
|
|
128
|
+
? 'top-0.5 right-0.5 size-2 rounded-full'
|
|
129
|
+
: 'top-0 right-0 flex h-4 min-w-4 translate-x-1/3 -translate-y-1/3 items-center justify-center rounded-full px-1 text-body-10-semibold tabular-nums',
|
|
130
|
+
tone === 'danger'
|
|
131
|
+
? 'bg-destructive text-text-on-action'
|
|
132
|
+
: 'bg-selected-strong text-selected-strong-foreground',
|
|
133
|
+
)}
|
|
134
|
+
>
|
|
135
|
+
{dot ? null : (count ?? 0) > max ? `${max}+` : count}
|
|
136
|
+
</span>
|
|
137
|
+
)}
|
|
138
|
+
</span>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Aviso de que um conteúdo foi feito pela IA, como uma descrição de produto ou um resumo.
|
|
143
|
+
// Transparência: quem lê precisa saber que veio do VOWT AI Agent. Duas versões (D-153): Lima, a
|
|
144
|
+
// padrão, e o degradê da IA, do azul ao rosa, para destaque.
|
|
145
|
+
|
|
146
|
+
/** Id do degradê da IA usado como preenchimento de ícones: fill: url(#vowt-ai-gradient). */
|
|
147
|
+
export const AI_GRADIENT_ID = 'vowt-ai-gradient';
|
|
148
|
+
|
|
149
|
+
/** Desenha, escondido, o degradê da IA que os ícones usam como preenchimento. */
|
|
150
|
+
function AiGradientDefs() {
|
|
151
|
+
return (
|
|
152
|
+
<svg aria-hidden width="0" height="0" className="absolute">
|
|
153
|
+
<defs>
|
|
154
|
+
<linearGradient id={AI_GRADIENT_ID} x1="0" y1="1" x2="1" y2="0">
|
|
155
|
+
<stop offset="0" style={{ stopColor: 'var(--brand-600)' }} />
|
|
156
|
+
<stop offset="0.5" style={{ stopColor: 'var(--violet-500)' }} />
|
|
157
|
+
<stop offset="1" style={{ stopColor: 'var(--pink-500)' }} />
|
|
158
|
+
</linearGradient>
|
|
159
|
+
</defs>
|
|
160
|
+
</svg>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Estilo que pinta um ícone ou a logo com o degradê da IA. */
|
|
165
|
+
const aiGradientFill: React.CSSProperties = {
|
|
166
|
+
fill: `url(#${AI_GRADIENT_ID})`,
|
|
167
|
+
stroke: `url(#${AI_GRADIENT_ID})`,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/** Brilho da IA em degradê, em contorno como os outros ícones, D-717. */
|
|
171
|
+
function AiSparkleIcon({ className }: { className?: string }) {
|
|
172
|
+
return (
|
|
173
|
+
<>
|
|
174
|
+
<AiGradientDefs />
|
|
175
|
+
<SparklesIcon
|
|
176
|
+
aria-hidden
|
|
177
|
+
className={className}
|
|
178
|
+
style={{ stroke: `url(#${AI_GRADIENT_ID})` }}
|
|
179
|
+
/>
|
|
180
|
+
</>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function AiBadge({
|
|
185
|
+
children = 'Gerado por IA',
|
|
186
|
+
variant = 'lime',
|
|
187
|
+
className,
|
|
188
|
+
}: {
|
|
189
|
+
children?: React.ReactNode;
|
|
190
|
+
/** Lima, a padrão, ou o degradê da IA. */
|
|
191
|
+
variant?: 'lime' | 'gradient';
|
|
192
|
+
className?: string;
|
|
193
|
+
}) {
|
|
194
|
+
return (
|
|
195
|
+
<span
|
|
196
|
+
data-slot="ai-badge"
|
|
197
|
+
data-variant={variant}
|
|
198
|
+
className={cn(
|
|
199
|
+
'inline-flex h-6 w-fit items-center gap-1 rounded-full px-2 text-body-12-semibold whitespace-nowrap',
|
|
200
|
+
// D-681: a IA tem um tratamento só, o degradê; a variação lime fica como apelido.
|
|
201
|
+
'bg-ai-gradient text-text-on-ai',
|
|
202
|
+
className,
|
|
203
|
+
)}
|
|
204
|
+
>
|
|
205
|
+
<SparklesIcon aria-hidden className="size-icon-xs" />
|
|
206
|
+
{children}
|
|
207
|
+
</span>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Botão pronto para abrir a IA: o brilho em degradê e "Perguntar à IA". Aceita tudo do Button,
|
|
213
|
+
* como `onClick`, `size` e `variant`; o texto muda pelos filhos.
|
|
214
|
+
*/
|
|
215
|
+
function AskAiButton({
|
|
216
|
+
children = 'Perguntar à IA',
|
|
217
|
+
variant = 'outline',
|
|
218
|
+
...props
|
|
219
|
+
}: React.ComponentProps<typeof Button>) {
|
|
220
|
+
return (
|
|
221
|
+
<Button
|
|
222
|
+
data-slot="ask-ai-button"
|
|
223
|
+
variant={variant}
|
|
224
|
+
{...props}
|
|
225
|
+
className={cn(variant === 'outline' && 'ai-outline', props.className)}
|
|
226
|
+
>
|
|
227
|
+
<AiSparkleIcon className="size-icon-lg" />
|
|
228
|
+
{children}
|
|
229
|
+
</Button>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
Badge,
|
|
235
|
+
CountBadge,
|
|
236
|
+
badgeVariants,
|
|
237
|
+
AiBadge,
|
|
238
|
+
AiGradientDefs,
|
|
239
|
+
AiSparkleIcon,
|
|
240
|
+
AskAiButton,
|
|
241
|
+
aiGradientFill,
|
|
242
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Bar,
|
|
5
|
+
BarChart as BarPrimitive,
|
|
6
|
+
CartesianGrid,
|
|
7
|
+
Cell,
|
|
8
|
+
LabelList,
|
|
9
|
+
ReferenceLine,
|
|
10
|
+
XAxis,
|
|
11
|
+
YAxis,
|
|
12
|
+
} from 'recharts';
|
|
13
|
+
import {
|
|
14
|
+
AXIS,
|
|
15
|
+
type ChartDatum,
|
|
16
|
+
type ChartSeries,
|
|
17
|
+
ChartContainer,
|
|
18
|
+
ChartLegend,
|
|
19
|
+
ChartTooltip,
|
|
20
|
+
formatNumber,
|
|
21
|
+
seriesConfig,
|
|
22
|
+
} from './chart';
|
|
23
|
+
import { cn } from '../lib/utils';
|
|
24
|
+
|
|
25
|
+
// Gráfico de barras pronto (D-156): pedidos por canal, vendas por mês, saldo do dia. Em pé ou
|
|
26
|
+
// deitado, várias séries lado a lado ou empilhadas, com o valor na ponta e uma barra em destaque.
|
|
27
|
+
// Valor negativo ganha a cor de perda automaticamente na série única. Canto de 4px na ponta.
|
|
28
|
+
|
|
29
|
+
function BarChart({
|
|
30
|
+
data,
|
|
31
|
+
index,
|
|
32
|
+
series,
|
|
33
|
+
layout = 'vertical',
|
|
34
|
+
stack = false,
|
|
35
|
+
labels = false,
|
|
36
|
+
highlight,
|
|
37
|
+
yAxis = true,
|
|
38
|
+
format = formatNumber,
|
|
39
|
+
className,
|
|
40
|
+
}: {
|
|
41
|
+
data: ChartDatum[];
|
|
42
|
+
/** Campo das categorias, como "mes" ou "canal". */
|
|
43
|
+
index: string;
|
|
44
|
+
series: ChartSeries[];
|
|
45
|
+
/** "vertical": barras em pé; "horizontal": deitadas, para nomes longos. */
|
|
46
|
+
layout?: 'vertical' | 'horizontal';
|
|
47
|
+
stack?: boolean;
|
|
48
|
+
/** Valor escrito na ponta de cada barra. Use com poucas barras. */
|
|
49
|
+
labels?: boolean;
|
|
50
|
+
/** Categoria em destaque; as outras ficam mais claras. */
|
|
51
|
+
highlight?: string;
|
|
52
|
+
yAxis?: boolean;
|
|
53
|
+
format?: (value: unknown) => string;
|
|
54
|
+
className?: string;
|
|
55
|
+
}) {
|
|
56
|
+
const config = seriesConfig(series);
|
|
57
|
+
const horizontal = layout === 'horizontal';
|
|
58
|
+
const single = series.length === 1 ? series[0]! : null;
|
|
59
|
+
const hasNegative = single && data.some((d) => Number(d[single.key]) < 0);
|
|
60
|
+
const last = series.length - 1;
|
|
61
|
+
// Ponta arredondada só na barra de cima da pilha; a base fica reta, no eixo.
|
|
62
|
+
const radius = (i: number): [number, number, number, number] =>
|
|
63
|
+
stack && i !== last ? [0, 0, 0, 0] : horizontal ? [0, 4, 4, 0] : [4, 4, 0, 0];
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<ChartContainer config={config} className={cn('aspect-auto h-64', className)}>
|
|
67
|
+
{(hidden) => (
|
|
68
|
+
<BarPrimitive
|
|
69
|
+
data={data}
|
|
70
|
+
layout={horizontal ? 'vertical' : 'horizontal'}
|
|
71
|
+
barGap={2}
|
|
72
|
+
barCategoryGap={series.length > 1 && !stack ? '20%' : '28%'}
|
|
73
|
+
margin={{
|
|
74
|
+
top: labels ? 20 : 8,
|
|
75
|
+
right: labels && horizontal ? 48 : 8,
|
|
76
|
+
left: 0,
|
|
77
|
+
bottom: 0,
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
80
|
+
<CartesianGrid vertical={horizontal} horizontal={!horizontal} />
|
|
81
|
+
{horizontal ? (
|
|
82
|
+
<>
|
|
83
|
+
<XAxis type="number" {...AXIS} hide={!yAxis} tickFormatter={(v) => format(v)} />
|
|
84
|
+
<YAxis type="category" dataKey={index} {...AXIS} width="auto" />
|
|
85
|
+
</>
|
|
86
|
+
) : (
|
|
87
|
+
<>
|
|
88
|
+
<XAxis dataKey={index} {...AXIS} minTickGap={8} />
|
|
89
|
+
{yAxis && <YAxis {...AXIS} width="auto" tickFormatter={(v) => format(v)} />}
|
|
90
|
+
</>
|
|
91
|
+
)}
|
|
92
|
+
{hasNegative && (
|
|
93
|
+
<ReferenceLine {...(horizontal ? { x: 0 } : { y: 0 })} stroke="var(--border-strong)" />
|
|
94
|
+
)}
|
|
95
|
+
<ChartTooltip formatValue={format} />
|
|
96
|
+
{series.length > 1 && <ChartLegend />}
|
|
97
|
+
{series.map((s, i) => (
|
|
98
|
+
<Bar
|
|
99
|
+
key={s.key}
|
|
100
|
+
dataKey={s.key}
|
|
101
|
+
hide={hidden.has(s.key)}
|
|
102
|
+
stackId={stack ? 'a' : undefined}
|
|
103
|
+
fill={`var(--color-${s.key})`}
|
|
104
|
+
radius={radius(i)}
|
|
105
|
+
maxBarSize={48}
|
|
106
|
+
stroke="var(--card)"
|
|
107
|
+
strokeWidth={stack ? 1 : 0}
|
|
108
|
+
>
|
|
109
|
+
{(hasNegative || highlight) &&
|
|
110
|
+
data.map((d) => {
|
|
111
|
+
const negative = hasNegative && Number(d[s.key]) < 0;
|
|
112
|
+
const dim = highlight !== undefined && d[index] !== highlight;
|
|
113
|
+
return (
|
|
114
|
+
<Cell
|
|
115
|
+
key={String(d[index])}
|
|
116
|
+
fill={negative ? 'var(--chart-3)' : `var(--color-${s.key})`}
|
|
117
|
+
fillOpacity={dim ? 0.35 : 1}
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
})}
|
|
121
|
+
{labels && (!stack || i === last) && (
|
|
122
|
+
<LabelList
|
|
123
|
+
dataKey={s.key}
|
|
124
|
+
position={horizontal ? 'right' : 'top'}
|
|
125
|
+
offset={6}
|
|
126
|
+
formatter={(v: unknown) => format(v)}
|
|
127
|
+
className="fill-foreground text-body-12-semibold"
|
|
128
|
+
/>
|
|
129
|
+
)}
|
|
130
|
+
</Bar>
|
|
131
|
+
))}
|
|
132
|
+
</BarPrimitive>
|
|
133
|
+
)}
|
|
134
|
+
</ChartContainer>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { BarChart };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ChevronRightIcon } from 'lucide-react';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import { cn } from '../lib/utils';
|
|
4
|
+
import { Link } from './link';
|
|
5
|
+
import { Progress } from './progress';
|
|
6
|
+
|
|
7
|
+
// Lista com barra (D-340): cada linha com o nome, o valor e uma barra do tamanho dele perto do
|
|
8
|
+
// maior, como para onde foi o gasto de IA ou por que o agente passou para a equipe. A linha pode
|
|
9
|
+
// levar a outra tela, inteira clicável e com a setinha à direita, e ter ações embaixo, como Ver
|
|
10
|
+
// conversas e Ajustar.
|
|
11
|
+
|
|
12
|
+
export type BarListItem = {
|
|
13
|
+
id: string;
|
|
14
|
+
label: ReactNode;
|
|
15
|
+
value: number;
|
|
16
|
+
/** O valor escrito, como "R$ 18,00" ou "18 vezes". Sem ele, o número. */
|
|
17
|
+
display?: ReactNode;
|
|
18
|
+
/** Leva a outra tela, pelo nome. */
|
|
19
|
+
href?: string;
|
|
20
|
+
/** Ações embaixo da barra. */
|
|
21
|
+
actions?: ReactNode;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function BarList({
|
|
25
|
+
items,
|
|
26
|
+
empty,
|
|
27
|
+
className,
|
|
28
|
+
'aria-label': ariaLabel,
|
|
29
|
+
}: {
|
|
30
|
+
items: BarListItem[];
|
|
31
|
+
/** Sem itens, como "Nada neste mês". */
|
|
32
|
+
empty?: ReactNode;
|
|
33
|
+
className?: string;
|
|
34
|
+
'aria-label'?: string;
|
|
35
|
+
}) {
|
|
36
|
+
const max = Math.max(1, ...items.map((i) => i.value));
|
|
37
|
+
const hasLinks = items.some((i) => i.href);
|
|
38
|
+
if (items.length === 0)
|
|
39
|
+
return empty ? <p className="text-body-13 text-muted-foreground">{empty}</p> : null;
|
|
40
|
+
return (
|
|
41
|
+
<ul
|
|
42
|
+
data-slot="bar-list"
|
|
43
|
+
aria-label={ariaLabel}
|
|
44
|
+
className={cn('grid', hasLinks ? 'gap-2' : 'gap-4', className)}
|
|
45
|
+
>
|
|
46
|
+
{items.map((i) => (
|
|
47
|
+
<li
|
|
48
|
+
key={i.id}
|
|
49
|
+
className={cn(
|
|
50
|
+
'grid gap-2',
|
|
51
|
+
// Com link, a linha inteira é clicável: o link cobre a linha e as ações ficam por cima.
|
|
52
|
+
i.href &&
|
|
53
|
+
'relative -mx-2 rounded-control px-2 py-2 transition-colors hover:bg-hover has-focus-visible:focus-ring',
|
|
54
|
+
)}
|
|
55
|
+
>
|
|
56
|
+
<div className="flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1">
|
|
57
|
+
{i.href ? (
|
|
58
|
+
<Link
|
|
59
|
+
href={i.href}
|
|
60
|
+
className="text-body-13-medium outline-none after:absolute after:inset-0 after:rounded-control"
|
|
61
|
+
>
|
|
62
|
+
{i.label}
|
|
63
|
+
</Link>
|
|
64
|
+
) : (
|
|
65
|
+
<span className="text-body-13-medium">{i.label}</span>
|
|
66
|
+
)}
|
|
67
|
+
<span className="flex items-center gap-1 text-body-13 text-muted-foreground tabular-nums">
|
|
68
|
+
{i.display ?? i.value.toLocaleString('pt-BR')}
|
|
69
|
+
{i.href && <ChevronRightIcon aria-hidden className="size-icon-sm self-center" />}
|
|
70
|
+
</span>
|
|
71
|
+
</div>
|
|
72
|
+
<Progress
|
|
73
|
+
value={i.value}
|
|
74
|
+
max={max}
|
|
75
|
+
className="pointer-events-none"
|
|
76
|
+
aria-label={typeof i.label === 'string' ? i.label : undefined}
|
|
77
|
+
/>
|
|
78
|
+
{i.actions && <div className="relative flex flex-wrap gap-3">{i.actions}</div>}
|
|
79
|
+
</li>
|
|
80
|
+
))}
|
|
81
|
+
</ul>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { BarList };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { BRAND_ICONS, type BrandIcon as BrandIconData } from '../brand/icons';
|
|
3
|
+
import { cn } from '../lib/utils';
|
|
4
|
+
|
|
5
|
+
// Logo de uma plataforma externa (Google, Meta, WhatsApp...), na cor da marca. Marca preta segue a
|
|
6
|
+
// cor do texto, então fica branca no modo escuro. Marca de mais de uma cor, como os Correios, desenha
|
|
7
|
+
// cada parte na sua cor; em `monochrome`, todas seguem a cor do texto, e o fundo da logo, como o
|
|
8
|
+
// quadrado rosa do Jev, some.
|
|
9
|
+
|
|
10
|
+
export type BrandName = keyof typeof BRAND_ICONS;
|
|
11
|
+
|
|
12
|
+
export function BrandIcon({
|
|
13
|
+
brand,
|
|
14
|
+
monochrome = false,
|
|
15
|
+
label,
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
}: Omit<React.ComponentProps<'svg'>, 'children'> & {
|
|
19
|
+
brand: BrandName;
|
|
20
|
+
/** Na cor do texto em vez da cor da marca. */
|
|
21
|
+
monochrome?: boolean;
|
|
22
|
+
/** Nome lido pelo leitor de tela; sem ele, o ícone é só decoração. */
|
|
23
|
+
label?: string;
|
|
24
|
+
className?: string;
|
|
25
|
+
}) {
|
|
26
|
+
const icon: BrandIconData | undefined = BRAND_ICONS[brand];
|
|
27
|
+
if (!icon) return null;
|
|
28
|
+
return (
|
|
29
|
+
<svg
|
|
30
|
+
data-slot="brand-icon"
|
|
31
|
+
viewBox="0 0 24 24"
|
|
32
|
+
className={cn('size-4 shrink-0', className)}
|
|
33
|
+
fill={monochrome || icon.layers ? 'currentColor' : (icon.color ?? 'currentColor')}
|
|
34
|
+
role={label ? 'img' : undefined}
|
|
35
|
+
aria-label={label}
|
|
36
|
+
aria-hidden={label ? undefined : true}
|
|
37
|
+
{...props}
|
|
38
|
+
>
|
|
39
|
+
{icon.layers ? (
|
|
40
|
+
icon.layers
|
|
41
|
+
.filter((layer) => !(monochrome && layer.tile))
|
|
42
|
+
.map((layer, i) => (
|
|
43
|
+
<path key={i} d={layer.path} fill={monochrome ? undefined : layer.color} />
|
|
44
|
+
))
|
|
45
|
+
) : (
|
|
46
|
+
<path d={icon.path} />
|
|
47
|
+
)}
|
|
48
|
+
</svg>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { BRAND_ICONS };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChevronRightIcon, HouseIcon } from 'lucide-react';
|
|
3
|
+
import { cn } from '../lib/utils';
|
|
4
|
+
|
|
5
|
+
import { Link, type LinkProps } from './link';
|
|
6
|
+
|
|
7
|
+
// Caminho até a página atual: "Pedidos › #1042". O último item é a página aberta e não é link.
|
|
8
|
+
|
|
9
|
+
function Breadcrumb({ ...props }: React.ComponentProps<'nav'>) {
|
|
10
|
+
return <nav aria-label="Caminho" data-slot="breadcrumb" {...props} />;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>) {
|
|
14
|
+
return (
|
|
15
|
+
<ol
|
|
16
|
+
data-slot="breadcrumb-list"
|
|
17
|
+
className={cn(
|
|
18
|
+
'flex flex-wrap items-center gap-1.5 text-body-13 break-words text-muted-foreground',
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function BreadcrumbItem({ className, ...props }: React.ComponentProps<'li'>) {
|
|
27
|
+
return (
|
|
28
|
+
<li
|
|
29
|
+
data-slot="breadcrumb-item"
|
|
30
|
+
className={cn('inline-flex items-center gap-1.5', className)}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function BreadcrumbLink({ className, ...props }: LinkProps) {
|
|
37
|
+
return (
|
|
38
|
+
<Link
|
|
39
|
+
data-slot="breadcrumb-link"
|
|
40
|
+
className={cn(
|
|
41
|
+
'rounded-control transition-colors outline-none hover:text-foreground focus-visible:focus-ring',
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>) {
|
|
50
|
+
return (
|
|
51
|
+
<span
|
|
52
|
+
data-slot="breadcrumb-page"
|
|
53
|
+
aria-current="page"
|
|
54
|
+
className={cn('text-body-13-medium text-foreground', className)}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* O primeiro nível do caminho, sempre a casinha, levando ao Início do produto (D-382). Vem antes
|
|
62
|
+
* do primeiro separador.
|
|
63
|
+
*/
|
|
64
|
+
function BreadcrumbHome({ href, label = 'Início' }: { href: string; label?: string }) {
|
|
65
|
+
return (
|
|
66
|
+
<BreadcrumbItem>
|
|
67
|
+
<BreadcrumbLink href={href} aria-label={label} title={label} className="inline-flex">
|
|
68
|
+
<HouseIcon className="size-icon-lg" />
|
|
69
|
+
</BreadcrumbLink>
|
|
70
|
+
</BreadcrumbItem>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<'li'>) {
|
|
75
|
+
return (
|
|
76
|
+
<li
|
|
77
|
+
data-slot="breadcrumb-separator"
|
|
78
|
+
role="presentation"
|
|
79
|
+
aria-hidden="true"
|
|
80
|
+
className={cn('[&>svg]:size-icon-sm', className)}
|
|
81
|
+
{...props}
|
|
82
|
+
>
|
|
83
|
+
{children ?? <ChevronRightIcon aria-hidden />}
|
|
84
|
+
</li>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
Breadcrumb,
|
|
90
|
+
BreadcrumbList,
|
|
91
|
+
BreadcrumbItem,
|
|
92
|
+
BreadcrumbHome,
|
|
93
|
+
BreadcrumbLink,
|
|
94
|
+
BreadcrumbPage,
|
|
95
|
+
BreadcrumbSeparator,
|
|
96
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { cn } from '../lib/utils';
|
|
3
|
+
|
|
4
|
+
// tokens-ok-ligacao: só estrutura: junta os Button que o app passa.
|
|
5
|
+
|
|
6
|
+
// Botões que andam juntos, como "Salvar" e a seta com mais opções. Ficam colados, sem espaço nem
|
|
7
|
+
// separador; só as pontas ficam arredondadas.
|
|
8
|
+
function ButtonGroup({
|
|
9
|
+
className,
|
|
10
|
+
orientation = 'horizontal',
|
|
11
|
+
...props
|
|
12
|
+
}: React.ComponentProps<'div'> & { orientation?: 'horizontal' | 'vertical' }) {
|
|
13
|
+
return (
|
|
14
|
+
<div
|
|
15
|
+
role="group"
|
|
16
|
+
data-slot="button-group"
|
|
17
|
+
data-orientation={orientation}
|
|
18
|
+
className={cn(
|
|
19
|
+
'flex w-fit items-stretch *:bg-clip-border *:focus-visible:relative *:focus-visible:z-10',
|
|
20
|
+
'data-[orientation=horizontal]:*:not-first:-ml-px data-[orientation=horizontal]:*:not-first:rounded-l-none data-[orientation=horizontal]:*:not-last:rounded-r-none',
|
|
21
|
+
'data-[orientation=vertical]:flex-col data-[orientation=vertical]:*:not-first:-mt-px data-[orientation=vertical]:*:not-first:rounded-t-none data-[orientation=vertical]:*:not-last:rounded-b-none',
|
|
22
|
+
className,
|
|
23
|
+
)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { ButtonGroup };
|