@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.
- 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,224 @@
|
|
|
1
|
+
import { ArrowDownIcon, ArrowRightIcon } from 'lucide-react';
|
|
2
|
+
import { cn } from '../lib/utils';
|
|
3
|
+
import { Badge } from './badge';
|
|
4
|
+
|
|
5
|
+
// tokens-ok-ligacao: desenho próprio do funil, com as cores do tema; não usa o Recharts.
|
|
6
|
+
|
|
7
|
+
// Funil (D-156): quantos passam de uma etapa para a outra, como visitas, carrinho, pagamento e
|
|
8
|
+
// pedido pago, ou contatos, conversas, propostas e vendas no CRM. Três formas, pela prop variant:
|
|
9
|
+
// - "bars": uma barra por etapa, com quanto da etapa anterior chegou ali à direita;
|
|
10
|
+
// - "vertical": o funil clássico, de cima para baixo, com a passagem entre as etapas;
|
|
11
|
+
// - "horizontal": da esquerda para a direita, numa faixa que afina de etapa em etapa.
|
|
12
|
+
|
|
13
|
+
export type FunnelStep = { label: string; value: number };
|
|
14
|
+
|
|
15
|
+
type FunnelProps = {
|
|
16
|
+
steps: FunnelStep[];
|
|
17
|
+
format: (value: number) => string;
|
|
18
|
+
color: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const percent = (n: number) => `${n.toLocaleString('pt-BR', { maximumFractionDigits: 1 })}%`;
|
|
22
|
+
// Cada etapa um pouco mais clara que a anterior, na mesma cor.
|
|
23
|
+
const shade = (i: number) => Math.max(0.35, 1 - i * 0.14);
|
|
24
|
+
|
|
25
|
+
function FunnelBars({ steps, format, color }: FunnelProps) {
|
|
26
|
+
const first = steps[0]?.value || 1;
|
|
27
|
+
return (
|
|
28
|
+
<ol className="grid gap-2">
|
|
29
|
+
{steps.map((s, i) => {
|
|
30
|
+
const prev = i > 0 ? steps[i - 1]!.value : null;
|
|
31
|
+
const pass = prev ? (s.value / prev) * 100 : null;
|
|
32
|
+
return (
|
|
33
|
+
// No celular, nome e porcentagem em cima e a barra inteira embaixo: lado a lado, a
|
|
34
|
+
// trilha ficava com poucos pixels. No escuro, a trilha sobe um tom para aparecer.
|
|
35
|
+
<li
|
|
36
|
+
key={s.label}
|
|
37
|
+
className="grid grid-cols-[1fr_auto] items-center gap-x-3 gap-y-1.5 sm:grid-cols-[8rem_1fr_4.5rem] sm:gap-3"
|
|
38
|
+
>
|
|
39
|
+
<span className="truncate text-body-13-medium">{s.label}</span>
|
|
40
|
+
<span className="relative col-span-2 h-8 overflow-hidden rounded-inner bg-muted max-sm:order-last sm:col-span-1 dark:bg-surface-strong">
|
|
41
|
+
<span
|
|
42
|
+
className="absolute inset-y-0 left-0 rounded-inner"
|
|
43
|
+
style={{
|
|
44
|
+
width: `${Math.max(2, (s.value / first) * 100)}%`,
|
|
45
|
+
background: color,
|
|
46
|
+
opacity: 1 - i * 0.12,
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
<span className="relative flex h-full items-center px-2 text-body-12-semibold text-foreground">
|
|
50
|
+
<span className="rounded bg-card/85 px-1.5 tabular-nums">{format(s.value)}</span>
|
|
51
|
+
</span>
|
|
52
|
+
</span>
|
|
53
|
+
<span className="text-right text-body-13 text-muted-foreground tabular-nums">
|
|
54
|
+
{pass === null ? '100%' : percent(pass)}
|
|
55
|
+
</span>
|
|
56
|
+
</li>
|
|
57
|
+
);
|
|
58
|
+
})}
|
|
59
|
+
</ol>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Largura da etapa no funil clássico: proporcional ao número, mas nunca abaixo de 28% da boca,
|
|
64
|
+
// para a última etapa continuar visível.
|
|
65
|
+
const funnelWidth = (v: number, first: number) => 28 + 72 * (v / first);
|
|
66
|
+
|
|
67
|
+
function FunnelVertical({ steps, format, color }: FunnelProps) {
|
|
68
|
+
const first = steps[0]?.value || 1;
|
|
69
|
+
return (
|
|
70
|
+
<ol className="grid max-w-xl grid-cols-[minmax(4.5rem,16rem)_minmax(6.5rem,10rem)_auto] gap-x-4 gap-y-1">
|
|
71
|
+
{steps.map((s, i) => {
|
|
72
|
+
const top = funnelWidth(s.value, first);
|
|
73
|
+
const next = steps[i + 1];
|
|
74
|
+
const bottom = next ? funnelWidth(next.value, first) : top * 0.82;
|
|
75
|
+
// O recorte afina da largura de cima para a de baixo, centralizado.
|
|
76
|
+
const inset = ((top - bottom) / 2 / top) * 100;
|
|
77
|
+
const prev = i > 0 ? steps[i - 1]!.value : null;
|
|
78
|
+
return (
|
|
79
|
+
<li key={s.label} className="col-span-3 grid grid-cols-subgrid items-center">
|
|
80
|
+
<span className="flex h-14 justify-center">
|
|
81
|
+
<span
|
|
82
|
+
aria-hidden
|
|
83
|
+
className="h-full"
|
|
84
|
+
style={{
|
|
85
|
+
width: `${top}%`,
|
|
86
|
+
background: color,
|
|
87
|
+
opacity: shade(i),
|
|
88
|
+
clipPath: `polygon(0 0, 100% 0, ${100 - inset}% 100%, ${inset}% 100%)`,
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
</span>
|
|
92
|
+
<span className="grid min-w-0">
|
|
93
|
+
<span className="truncate text-body-13 text-muted-foreground">{s.label}</span>
|
|
94
|
+
<span className="text-stat-sm tabular-nums">{format(s.value)}</span>
|
|
95
|
+
</span>
|
|
96
|
+
{/* Passagem da etapa anterior para esta, na divisa entre as duas. */}
|
|
97
|
+
<span className="relative min-w-16 self-stretch">
|
|
98
|
+
{prev !== null && (
|
|
99
|
+
<Badge
|
|
100
|
+
variant="secondary"
|
|
101
|
+
size="sm"
|
|
102
|
+
className="absolute top-0 left-0 -translate-y-1/2 gap-0.5"
|
|
103
|
+
>
|
|
104
|
+
<ArrowDownIcon aria-hidden />
|
|
105
|
+
{percent(prev ? (s.value / prev) * 100 : 0)}
|
|
106
|
+
</Badge>
|
|
107
|
+
)}
|
|
108
|
+
</span>
|
|
109
|
+
</li>
|
|
110
|
+
);
|
|
111
|
+
})}
|
|
112
|
+
</ol>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function FunnelHorizontal({ steps, format, color }: FunnelProps) {
|
|
117
|
+
const first = steps[0]?.value || 1;
|
|
118
|
+
const n = steps.length;
|
|
119
|
+
// Altura da faixa em cada etapa, em porcentagem da área: proporcional, com um mínimo visível.
|
|
120
|
+
const h = steps.map((s) => Math.max(6, (s.value / first) * 100));
|
|
121
|
+
const top = (i: number) => (100 - h[i]!) / 2;
|
|
122
|
+
const bottom = (i: number) => (100 + h[i]!) / 2;
|
|
123
|
+
// Cada etapa ocupa 100 unidades: fica reta até 55 e faz a curva até a altura da seguinte.
|
|
124
|
+
const segment = (i: number) => {
|
|
125
|
+
const x0 = i * 100;
|
|
126
|
+
const j = i + 1 < n ? i + 1 : i;
|
|
127
|
+
const flat = x0 + 55;
|
|
128
|
+
const x1 = x0 + 100;
|
|
129
|
+
const mid = (flat + x1) / 2;
|
|
130
|
+
return [
|
|
131
|
+
`M${x0},${top(i)}`,
|
|
132
|
+
`L${flat},${top(i)}`,
|
|
133
|
+
`C${mid},${top(i)} ${mid},${top(j)} ${x1},${top(j)}`,
|
|
134
|
+
`L${x1},${bottom(j)}`,
|
|
135
|
+
`C${mid},${bottom(j)} ${mid},${bottom(i)} ${flat},${bottom(i)}`,
|
|
136
|
+
`L${x0},${bottom(i)}`,
|
|
137
|
+
'Z',
|
|
138
|
+
].join(' ');
|
|
139
|
+
};
|
|
140
|
+
return (
|
|
141
|
+
// Abaixo de 480px a faixa rola de lado, com a borda esmaecida dizendo que há mais etapas.
|
|
142
|
+
<div className="overflow-x-auto scroll-fade-x [--scroll-fade-size:--spacing(6)] not-supports-[animation-timeline:scroll()]:[--scroll-fade-size:0px]">
|
|
143
|
+
<div className="grid min-w-120 gap-3">
|
|
144
|
+
<ol className="grid" style={{ gridTemplateColumns: `repeat(${n}, minmax(0, 1fr))` }}>
|
|
145
|
+
{steps.map((s, i) => {
|
|
146
|
+
const prev = i > 0 ? steps[i - 1]!.value : null;
|
|
147
|
+
return (
|
|
148
|
+
<li
|
|
149
|
+
key={s.label}
|
|
150
|
+
className="grid min-w-0 content-start gap-0.5 border-l px-2.5 first:border-l-0 first:pl-0"
|
|
151
|
+
>
|
|
152
|
+
<span className="truncate text-body-13 text-muted-foreground">{s.label}</span>
|
|
153
|
+
<span className="text-stat-sm tabular-nums">{format(s.value)}</span>
|
|
154
|
+
{/* Quanto da etapa anterior chegou aqui. */}
|
|
155
|
+
<Badge variant="secondary" size="sm" className="mt-1 gap-0.5">
|
|
156
|
+
{prev !== null && <ArrowRightIcon aria-hidden />}
|
|
157
|
+
{prev === null ? '100%' : percent(prev ? (s.value / prev) * 100 : 0)}
|
|
158
|
+
</Badge>
|
|
159
|
+
</li>
|
|
160
|
+
);
|
|
161
|
+
})}
|
|
162
|
+
</ol>
|
|
163
|
+
<svg
|
|
164
|
+
aria-hidden
|
|
165
|
+
viewBox={`0 0 ${n * 100} 100`}
|
|
166
|
+
preserveAspectRatio="none"
|
|
167
|
+
className="h-36 w-full"
|
|
168
|
+
>
|
|
169
|
+
{steps.map((s, i) => (
|
|
170
|
+
<path key={s.label} d={segment(i)} fill={color} fillOpacity={shade(i)} />
|
|
171
|
+
))}
|
|
172
|
+
{steps.slice(1).map((s, i) => (
|
|
173
|
+
<line
|
|
174
|
+
key={s.label}
|
|
175
|
+
x1={(i + 1) * 100}
|
|
176
|
+
x2={(i + 1) * 100}
|
|
177
|
+
y1={0}
|
|
178
|
+
y2={100}
|
|
179
|
+
stroke="var(--card)"
|
|
180
|
+
strokeWidth={2}
|
|
181
|
+
vectorEffect="non-scaling-stroke"
|
|
182
|
+
/>
|
|
183
|
+
))}
|
|
184
|
+
</svg>
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function FunnelChart({
|
|
191
|
+
steps,
|
|
192
|
+
variant = 'bars',
|
|
193
|
+
format = (v) => v.toLocaleString('pt-BR'),
|
|
194
|
+
color = 'var(--chart-1)',
|
|
195
|
+
className,
|
|
196
|
+
}: {
|
|
197
|
+
steps: FunnelStep[];
|
|
198
|
+
/** "bars": barras; "vertical": funil clássico; "horizontal": faixa da esquerda para a direita. */
|
|
199
|
+
variant?: 'bars' | 'vertical' | 'horizontal';
|
|
200
|
+
format?: (value: number) => string;
|
|
201
|
+
color?: string;
|
|
202
|
+
className?: string;
|
|
203
|
+
}) {
|
|
204
|
+
const props = { steps, format, color };
|
|
205
|
+
return (
|
|
206
|
+
<div
|
|
207
|
+
data-slot="funnel-chart"
|
|
208
|
+
data-variant={variant}
|
|
209
|
+
role="figure"
|
|
210
|
+
aria-label={`Funil: ${steps.map((s) => `${s.label} ${format(s.value)}`).join(', ')}`}
|
|
211
|
+
className={cn('w-full', className)}
|
|
212
|
+
>
|
|
213
|
+
{variant === 'vertical' ? (
|
|
214
|
+
<FunnelVertical {...props} />
|
|
215
|
+
) : variant === 'horizontal' ? (
|
|
216
|
+
<FunnelHorizontal {...props} />
|
|
217
|
+
) : (
|
|
218
|
+
<FunnelBars {...props} />
|
|
219
|
+
)}
|
|
220
|
+
</div>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export { FunnelChart };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { cn } from '../lib/utils';
|
|
2
|
+
|
|
3
|
+
// tokens-ok-ligacao: desenho próprio da meia-rosca, com as cores do tema; não usa o Recharts.
|
|
4
|
+
|
|
5
|
+
// Meia-rosca, D-731: uma taxa ou uma meta atingida, como a taxa de ganho ou a cota do mês. O arco
|
|
6
|
+
// preenchido mostra a parte; o resto fica no tom da trilha. Com `rest`, o resto ganha cor e
|
|
7
|
+
// legenda, como ganhos contra perdidos. O número fica no centro, embaixo do arco.
|
|
8
|
+
|
|
9
|
+
function arc(from: number, to: number, r: number) {
|
|
10
|
+
// Ângulos de 0 a 1, da esquerda para a direita, por cima.
|
|
11
|
+
const a0 = Math.PI * (1 - from);
|
|
12
|
+
const a1 = Math.PI * (1 - to);
|
|
13
|
+
const x0 = 50 + r * Math.cos(a0);
|
|
14
|
+
const y0 = 50 - r * Math.sin(a0);
|
|
15
|
+
const x1 = 50 + r * Math.cos(a1);
|
|
16
|
+
const y1 = 50 - r * Math.sin(a1);
|
|
17
|
+
return `M ${x0} ${y0} A ${r} ${r} 0 0 1 ${x1} ${y1}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function GaugeChart({
|
|
21
|
+
value,
|
|
22
|
+
max = 100,
|
|
23
|
+
centerValue,
|
|
24
|
+
centerLabel,
|
|
25
|
+
label,
|
|
26
|
+
rest,
|
|
27
|
+
color = 'var(--chart-1)',
|
|
28
|
+
restColor = 'var(--chart-3)',
|
|
29
|
+
className,
|
|
30
|
+
}: {
|
|
31
|
+
/** A parte, como 37 ganhos. */
|
|
32
|
+
value: number;
|
|
33
|
+
/** O todo, como 59 decididos. Padrão 100, para porcentagem. */
|
|
34
|
+
max?: number;
|
|
35
|
+
/** No centro, como "63%". Sem ele, a porcentagem. */
|
|
36
|
+
centerValue?: string;
|
|
37
|
+
/** Embaixo do número, como "dos negócios decididos". */
|
|
38
|
+
centerLabel?: string;
|
|
39
|
+
/** Nome da parte na legenda, como "Ganhos". */
|
|
40
|
+
label?: string;
|
|
41
|
+
/** Nome do resto na legenda, como "Perdidos". Com ele, o resto ganha cor. */
|
|
42
|
+
rest?: string;
|
|
43
|
+
color?: string;
|
|
44
|
+
restColor?: string;
|
|
45
|
+
className?: string;
|
|
46
|
+
}) {
|
|
47
|
+
const share = max > 0 ? Math.min(1, Math.max(0, value / max)) : 0;
|
|
48
|
+
const pct = `${Math.round(share * 100)}%`;
|
|
49
|
+
const gap = share > 0 && share < 1 ? 0.012 : 0;
|
|
50
|
+
return (
|
|
51
|
+
<figure
|
|
52
|
+
data-slot="gauge-chart"
|
|
53
|
+
className={cn('grid justify-items-center gap-3', className)}
|
|
54
|
+
aria-label={`${label ?? 'Valor'}: ${centerValue ?? pct}`}
|
|
55
|
+
>
|
|
56
|
+
<div className="relative w-full max-w-64">
|
|
57
|
+
<svg viewBox="0 0 100 54" className="w-full" aria-hidden>
|
|
58
|
+
<path
|
|
59
|
+
d={arc(0, 1, 40)}
|
|
60
|
+
fill="none"
|
|
61
|
+
stroke="var(--muted)"
|
|
62
|
+
strokeWidth={12}
|
|
63
|
+
strokeLinecap="round"
|
|
64
|
+
/>
|
|
65
|
+
{rest && share < 1 && (
|
|
66
|
+
<path
|
|
67
|
+
d={arc(share + gap, 1, 40)}
|
|
68
|
+
fill="none"
|
|
69
|
+
stroke={restColor}
|
|
70
|
+
strokeWidth={12}
|
|
71
|
+
strokeLinecap="round"
|
|
72
|
+
/>
|
|
73
|
+
)}
|
|
74
|
+
{share > 0 && (
|
|
75
|
+
<path
|
|
76
|
+
d={arc(0, share - gap, 40)}
|
|
77
|
+
fill="none"
|
|
78
|
+
stroke={color}
|
|
79
|
+
strokeWidth={12}
|
|
80
|
+
strokeLinecap="round"
|
|
81
|
+
/>
|
|
82
|
+
)}
|
|
83
|
+
</svg>
|
|
84
|
+
<figcaption className="absolute inset-x-0 bottom-0 grid justify-items-center">
|
|
85
|
+
<span className="text-stat tabular-nums">{centerValue ?? pct}</span>
|
|
86
|
+
{centerLabel && <span className="text-body-12 text-muted-foreground">{centerLabel}</span>}
|
|
87
|
+
</figcaption>
|
|
88
|
+
</div>
|
|
89
|
+
{(label || rest) && (
|
|
90
|
+
<div className="flex flex-wrap justify-center gap-x-4 gap-y-1 text-body-12 text-muted-foreground">
|
|
91
|
+
{label && (
|
|
92
|
+
<span className="flex items-center gap-1.5">
|
|
93
|
+
<span className="size-2 rounded-full" style={{ background: color }} />
|
|
94
|
+
{label} · {value.toLocaleString('pt-BR')}
|
|
95
|
+
</span>
|
|
96
|
+
)}
|
|
97
|
+
{rest && (
|
|
98
|
+
<span className="flex items-center gap-1.5">
|
|
99
|
+
<span className="size-2 rounded-full" style={{ background: restColor }} />
|
|
100
|
+
{rest} · {(max - value).toLocaleString('pt-BR')}
|
|
101
|
+
</span>
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
104
|
+
)}
|
|
105
|
+
</figure>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { GaugeChart };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from './tooltip';
|
|
2
|
+
import { cn } from '../lib/utils';
|
|
3
|
+
|
|
4
|
+
// Mapa de calor (D-156): quando as coisas acontecem, como pedidos ou mensagens por hora e dia da
|
|
5
|
+
// semana. Um tom só, do claro ao escuro: quanto mais escuro, mais movimento. Cada casa mostra o
|
|
6
|
+
// valor ao passar o mouse, e a legenda embaixo diz o que cada tom quer dizer.
|
|
7
|
+
|
|
8
|
+
const STEPS = [0, 18, 36, 58, 80, 100];
|
|
9
|
+
|
|
10
|
+
function Heatmap({
|
|
11
|
+
rows,
|
|
12
|
+
columns,
|
|
13
|
+
values,
|
|
14
|
+
format = (v) => v.toLocaleString('pt-BR'),
|
|
15
|
+
color = 'var(--chart-1)',
|
|
16
|
+
columnStep = 1,
|
|
17
|
+
className,
|
|
18
|
+
'aria-label': ariaLabel,
|
|
19
|
+
}: {
|
|
20
|
+
/** Nomes das linhas, como os dias da semana. */
|
|
21
|
+
rows: string[];
|
|
22
|
+
/** Nomes das colunas, como as horas. */
|
|
23
|
+
columns: string[];
|
|
24
|
+
/** Valores: uma lista por linha, na ordem das colunas. */
|
|
25
|
+
values: number[][];
|
|
26
|
+
format?: (value: number) => string;
|
|
27
|
+
color?: string;
|
|
28
|
+
/** Mostra o nome de uma coluna a cada N, como de 3 em 3 horas. */
|
|
29
|
+
columnStep?: number;
|
|
30
|
+
className?: string;
|
|
31
|
+
'aria-label': string;
|
|
32
|
+
}) {
|
|
33
|
+
const max = Math.max(1, ...values.flat());
|
|
34
|
+
const level = (v: number) => (v <= 0 ? 0 : Math.min(5, Math.ceil((v / max) * 5)));
|
|
35
|
+
// O tom zero vem da classe `empty`, que sobe um passo no escuro para não sumir no cartão.
|
|
36
|
+
const fill = (lv: number) =>
|
|
37
|
+
lv === 0 ? undefined : `color-mix(in oklch, ${color} ${STEPS[lv]}%, var(--card))`;
|
|
38
|
+
const empty = 'bg-muted dark:bg-surface-strong';
|
|
39
|
+
return (
|
|
40
|
+
<figure data-slot="heatmap" aria-label={ariaLabel} className={cn('grid gap-3', className)}>
|
|
41
|
+
<div
|
|
42
|
+
className="grid gap-[3px]"
|
|
43
|
+
style={{ gridTemplateColumns: `auto repeat(${columns.length}, minmax(0, 1fr))` }}
|
|
44
|
+
>
|
|
45
|
+
{rows.map((r, ri) => (
|
|
46
|
+
<div key={r} className="contents">
|
|
47
|
+
<span className="pr-2 text-body-12 text-muted-foreground">{r}</span>
|
|
48
|
+
{columns.map((c, ci) => {
|
|
49
|
+
const v = values[ri]?.[ci] ?? 0;
|
|
50
|
+
return (
|
|
51
|
+
<Tooltip key={c}>
|
|
52
|
+
<TooltipTrigger
|
|
53
|
+
render={
|
|
54
|
+
<span
|
|
55
|
+
aria-label={`${r}, ${c}: ${format(v)}`}
|
|
56
|
+
// Sem altura mínima: no celular, ela passava da coluna e colava nas vizinhas.
|
|
57
|
+
className={cn(
|
|
58
|
+
// tokens-ok: célula do mapa de calor, menor que o menor canto da escala.
|
|
59
|
+
'aspect-square rounded-[3px] outline-none hover:ring-2 hover:ring-foreground/40',
|
|
60
|
+
level(v) === 0 && empty,
|
|
61
|
+
)}
|
|
62
|
+
style={{ background: fill(level(v)) }}
|
|
63
|
+
/>
|
|
64
|
+
}
|
|
65
|
+
/>
|
|
66
|
+
<TooltipContent>
|
|
67
|
+
{r}, {c}: {format(v)}
|
|
68
|
+
</TooltipContent>
|
|
69
|
+
</Tooltip>
|
|
70
|
+
);
|
|
71
|
+
})}
|
|
72
|
+
</div>
|
|
73
|
+
))}
|
|
74
|
+
<span />
|
|
75
|
+
{columns.map((c, ci) => (
|
|
76
|
+
// No celular, mostra um rótulo sim e outro não, para os nomes das colunas não se
|
|
77
|
+
// encostarem.
|
|
78
|
+
<span
|
|
79
|
+
key={c}
|
|
80
|
+
className={cn(
|
|
81
|
+
'text-center text-body-12 whitespace-nowrap text-muted-foreground tabular-nums',
|
|
82
|
+
(ci / columnStep) % 2 === 1 && 'max-sm:invisible',
|
|
83
|
+
)}
|
|
84
|
+
>
|
|
85
|
+
{ci % columnStep === 0 ? c : ''}
|
|
86
|
+
</span>
|
|
87
|
+
))}
|
|
88
|
+
</div>
|
|
89
|
+
<figcaption className="flex items-center justify-end gap-1.5 text-body-12 text-muted-foreground">
|
|
90
|
+
Menos
|
|
91
|
+
{[0, 1, 2, 3, 4, 5].map((lv) => (
|
|
92
|
+
<span
|
|
93
|
+
key={lv}
|
|
94
|
+
// tokens-ok: amostra da legenda do mapa de calor
|
|
95
|
+
className={cn('size-3 rounded-[3px]', lv === 0 && empty)}
|
|
96
|
+
style={{ background: fill(lv) }}
|
|
97
|
+
/>
|
|
98
|
+
))}
|
|
99
|
+
Mais
|
|
100
|
+
</figcaption>
|
|
101
|
+
</figure>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { Heatmap };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { PreviewCard as PreviewCardPrimitive } from '@base-ui/react/preview-card';
|
|
4
|
+
import { cn } from '../lib/utils';
|
|
5
|
+
|
|
6
|
+
// Cartão que aparece ao passar o mouse num nome ou link, como o resumo de um cliente numa lista de
|
|
7
|
+
// pedidos: mostra mais sem abrir outra tela (D-309). Só para conteúdo extra; nada de ação que só
|
|
8
|
+
// exista ali, porque no celular não há mouse.
|
|
9
|
+
|
|
10
|
+
function HoverCard({ ...props }: PreviewCardPrimitive.Root.Props) {
|
|
11
|
+
return <PreviewCardPrimitive.Root data-slot="hover-card" {...props} />;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function HoverCardTrigger({ ...props }: PreviewCardPrimitive.Trigger.Props) {
|
|
15
|
+
return <PreviewCardPrimitive.Trigger data-slot="hover-card-trigger" {...props} />;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function HoverCardContent({
|
|
19
|
+
className,
|
|
20
|
+
side = 'bottom',
|
|
21
|
+
sideOffset = 6,
|
|
22
|
+
align = 'start',
|
|
23
|
+
...props
|
|
24
|
+
}: PreviewCardPrimitive.Popup.Props &
|
|
25
|
+
Pick<PreviewCardPrimitive.Positioner.Props, 'side' | 'sideOffset' | 'align'>) {
|
|
26
|
+
return (
|
|
27
|
+
<PreviewCardPrimitive.Portal>
|
|
28
|
+
<PreviewCardPrimitive.Positioner
|
|
29
|
+
side={side}
|
|
30
|
+
sideOffset={sideOffset}
|
|
31
|
+
align={align}
|
|
32
|
+
className="isolate z-50"
|
|
33
|
+
>
|
|
34
|
+
<PreviewCardPrimitive.Popup
|
|
35
|
+
data-slot="hover-card-content"
|
|
36
|
+
className={cn(
|
|
37
|
+
'z-50 w-72 max-w-(--available-width) origin-(--transform-origin) rounded-menu bg-popover p-4 text-body-13 text-popover-foreground shadow-menu ring-1 ring-border outline-hidden duration-(--duration-fast) 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',
|
|
38
|
+
className,
|
|
39
|
+
)}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
</PreviewCardPrimitive.Positioner>
|
|
43
|
+
</PreviewCardPrimitive.Portal>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { HoverCard, HoverCardTrigger, HoverCardContent };
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ChevronLeftIcon, ChevronRightIcon, DownloadIcon, XIcon } from 'lucide-react';
|
|
4
|
+
import { type KeyboardEvent, type ReactElement, useRef, useState } from 'react';
|
|
5
|
+
import { Button } from './button';
|
|
6
|
+
import { Dialog, DialogClose, DialogContent, DialogTitle, DialogTrigger } from './dialog';
|
|
7
|
+
import { cn } from '../lib/utils';
|
|
8
|
+
|
|
9
|
+
// Visualizador de fotos por cima da tela, como o do WhatsApp: fundo escuro, a foto inteira cabendo
|
|
10
|
+
// na tela sem deformar, o nome em cima, Baixar e Fechar. Com mais de uma foto, setas para passar,
|
|
11
|
+
// as setas do teclado e o arrastar do dedo no celular. Esc fecha. Montado sobre o Dialog.
|
|
12
|
+
|
|
13
|
+
export type ImageViewerImage = {
|
|
14
|
+
src: string;
|
|
15
|
+
/** Descrição da foto para o leitor de tela. */
|
|
16
|
+
alt?: string;
|
|
17
|
+
/** Nome do arquivo ou legenda, mostrado no alto. */
|
|
18
|
+
caption?: string;
|
|
19
|
+
/** Nome do arquivo ao baixar. */
|
|
20
|
+
downloadName?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const BAR_BUTTON =
|
|
24
|
+
'text-shell-foreground hover:bg-shell-hover hover:text-shell-foreground dark:hover:bg-shell-hover';
|
|
25
|
+
|
|
26
|
+
function ImageViewer({
|
|
27
|
+
images,
|
|
28
|
+
open: openProp,
|
|
29
|
+
defaultOpen = false,
|
|
30
|
+
onOpenChange,
|
|
31
|
+
index: indexProp,
|
|
32
|
+
defaultIndex = 0,
|
|
33
|
+
onIndexChange,
|
|
34
|
+
trigger,
|
|
35
|
+
}: {
|
|
36
|
+
images: ImageViewerImage[];
|
|
37
|
+
open?: boolean;
|
|
38
|
+
defaultOpen?: boolean;
|
|
39
|
+
onOpenChange?: (open: boolean) => void;
|
|
40
|
+
/** Foto aberta, contando do zero. */
|
|
41
|
+
index?: number;
|
|
42
|
+
defaultIndex?: number;
|
|
43
|
+
onIndexChange?: (index: number) => void;
|
|
44
|
+
/** O que abre o visualizador ao clicar, como a miniatura da foto. */
|
|
45
|
+
trigger?: ReactElement;
|
|
46
|
+
}) {
|
|
47
|
+
const [openState, setOpenState] = useState(defaultOpen);
|
|
48
|
+
const [indexState, setIndexState] = useState(defaultIndex);
|
|
49
|
+
const open = openProp ?? openState;
|
|
50
|
+
const total = images.length;
|
|
51
|
+
const index = Math.min(Math.max(indexProp ?? indexState, 0), Math.max(total - 1, 0));
|
|
52
|
+
const image = images[index];
|
|
53
|
+
const many = total > 1;
|
|
54
|
+
const swipe = useRef<number | null>(null);
|
|
55
|
+
|
|
56
|
+
function setOpen(next: boolean) {
|
|
57
|
+
setOpenState(next);
|
|
58
|
+
onOpenChange?.(next);
|
|
59
|
+
}
|
|
60
|
+
function go(step: number) {
|
|
61
|
+
if (!many) return;
|
|
62
|
+
const next = (index + step + total) % total;
|
|
63
|
+
setIndexState(next);
|
|
64
|
+
onIndexChange?.(next);
|
|
65
|
+
}
|
|
66
|
+
function onKeyDown(e: KeyboardEvent) {
|
|
67
|
+
if (e.key === 'ArrowLeft') {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
go(-1);
|
|
70
|
+
} else if (e.key === 'ArrowRight') {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
go(1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const title = image?.caption ?? image?.alt ?? 'Foto';
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
80
|
+
{trigger && <DialogTrigger render={trigger} />}
|
|
81
|
+
<DialogContent
|
|
82
|
+
showCloseButton={false}
|
|
83
|
+
data-slot="image-viewer"
|
|
84
|
+
onKeyDown={onKeyDown}
|
|
85
|
+
className="top-0 left-0 flex h-dvh w-full max-w-none translate-x-0 translate-y-0 flex-col gap-0 rounded-none bg-shell/95 p-0 text-shell-foreground shadow-none ring-0 data-[size=default]:sm:max-w-none"
|
|
86
|
+
>
|
|
87
|
+
<div className="flex items-center gap-2 px-4 py-3">
|
|
88
|
+
<div className="grid min-w-0 flex-1">
|
|
89
|
+
<DialogTitle className="truncate text-body-14-medium">{title}</DialogTitle>
|
|
90
|
+
{many && (
|
|
91
|
+
<span className="text-body-12 text-shell-muted tabular-nums">
|
|
92
|
+
{index + 1} de {total}
|
|
93
|
+
</span>
|
|
94
|
+
)}
|
|
95
|
+
</div>
|
|
96
|
+
{image && (
|
|
97
|
+
<Button
|
|
98
|
+
variant="ghost"
|
|
99
|
+
size="icon"
|
|
100
|
+
aria-label="Baixar foto"
|
|
101
|
+
className={BAR_BUTTON}
|
|
102
|
+
render={<a href={image.src} download={image.downloadName ?? ''} />}
|
|
103
|
+
>
|
|
104
|
+
<DownloadIcon />
|
|
105
|
+
</Button>
|
|
106
|
+
)}
|
|
107
|
+
<DialogClose
|
|
108
|
+
render={
|
|
109
|
+
<Button variant="ghost" size="icon" aria-label="Fechar" className={BAR_BUTTON} />
|
|
110
|
+
}
|
|
111
|
+
>
|
|
112
|
+
<XIcon />
|
|
113
|
+
</DialogClose>
|
|
114
|
+
</div>
|
|
115
|
+
<div
|
|
116
|
+
className="relative flex min-h-0 flex-1 touch-pan-y items-center justify-center px-4 pb-4 sm:px-16"
|
|
117
|
+
onClick={(e) => {
|
|
118
|
+
if (e.target === e.currentTarget) setOpen(false);
|
|
119
|
+
}}
|
|
120
|
+
onPointerDown={(e) => {
|
|
121
|
+
swipe.current = e.pointerType === 'touch' ? e.clientX : null;
|
|
122
|
+
}}
|
|
123
|
+
onPointerUp={(e) => {
|
|
124
|
+
if (swipe.current === null) return;
|
|
125
|
+
const dx = e.clientX - swipe.current;
|
|
126
|
+
swipe.current = null;
|
|
127
|
+
if (Math.abs(dx) > 48) go(dx < 0 ? 1 : -1);
|
|
128
|
+
}}
|
|
129
|
+
>
|
|
130
|
+
{image && (
|
|
131
|
+
<img
|
|
132
|
+
key={image.src}
|
|
133
|
+
src={image.src}
|
|
134
|
+
alt={image.alt ?? title}
|
|
135
|
+
draggable={false}
|
|
136
|
+
className="max-h-full max-w-full rounded-inner object-contain select-none"
|
|
137
|
+
/>
|
|
138
|
+
)}
|
|
139
|
+
{many && (
|
|
140
|
+
<>
|
|
141
|
+
<NavButton side="left" onClick={() => go(-1)} />
|
|
142
|
+
<NavButton side="right" onClick={() => go(1)} />
|
|
143
|
+
</>
|
|
144
|
+
)}
|
|
145
|
+
</div>
|
|
146
|
+
</DialogContent>
|
|
147
|
+
</Dialog>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function NavButton({ side, onClick }: { side: 'left' | 'right'; onClick: () => void }) {
|
|
152
|
+
const Icon = side === 'left' ? ChevronLeftIcon : ChevronRightIcon;
|
|
153
|
+
// A posição fica num invólucro, porque o botão já se move um pouco ao ser apertado.
|
|
154
|
+
return (
|
|
155
|
+
<span
|
|
156
|
+
className={cn(
|
|
157
|
+
'absolute top-1/2 -translate-y-1/2',
|
|
158
|
+
side === 'left' ? 'left-2 sm:left-4' : 'right-2 sm:right-4',
|
|
159
|
+
)}
|
|
160
|
+
>
|
|
161
|
+
<Button
|
|
162
|
+
variant="ghost"
|
|
163
|
+
size="icon-lg"
|
|
164
|
+
aria-label={side === 'left' ? 'Foto anterior' : 'Próxima foto'}
|
|
165
|
+
onClick={onClick}
|
|
166
|
+
className={cn('rounded-full bg-shell-surface', BAR_BUTTON)}
|
|
167
|
+
>
|
|
168
|
+
<Icon />
|
|
169
|
+
</Button>
|
|
170
|
+
</span>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export { ImageViewer };
|