@financinha/ui 0.10.1 → 0.12.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/dist/index.cjs CHANGED
@@ -2480,20 +2480,39 @@ var import_class_variance_authority7 = require("class-variance-authority");
2480
2480
  var import_radix_ui12 = require("radix-ui");
2481
2481
  var import_cn25 = require("cn");
2482
2482
  var import_jsx_runtime24 = require("react/jsx-runtime");
2483
- var itemVariants = (0, import_class_variance_authority7.cva)("group/item flex flex-wrap items-center gap-x-3 gap-y-1 text-sm", {
2483
+ var OUTLINE_DETAILS = [
2484
+ // O título do resumo em destaque: semibold, na cor do texto.
2485
+ "[&>[data-slot=item-content]>[data-slot=item-title]]:font-semibold [&>[data-slot=item-content]>[data-slot=item-title]]:text-foreground",
2486
+ // As linhas de detalhe (um ItemGroup dentro da caixa) ocupam a linha toda, abaixo de uma divisória de ponta a ponta,
2487
+ // com 8 px entre a divisória e o texto e entre o texto e a borda de baixo.
2488
+ "[&>[data-slot=item-group]]:-mx-2 [&>[data-slot=item-group]]:mt-1 [&>[data-slot=item-group]]:-mb-1 [&>[data-slot=item-group]]:basis-[calc(100%+1rem)] [&>[data-slot=item-group]]:border-t [&>[data-slot=item-group]]:border-border [&>[data-slot=item-group]]:px-2 [&>[data-slot=item-group]]:pt-1",
2489
+ // Cada linha de detalhe: 4 px em cima e embaixo, nome e valor em cinza, valor sem negrito.
2490
+ "[&>[data-slot=item-group]>[data-slot=item]]:py-1 [&>[data-slot=item-group]_[data-slot=item-title]]:text-muted-foreground [&>[data-slot=item-group]_[data-slot=item-actions]]:font-normal [&>[data-slot=item-group]_[data-slot=item-actions]]:text-muted-foreground"
2491
+ ].join(" ");
2492
+ var itemVariants = (0, import_class_variance_authority7.cva)("group/item flex flex-wrap items-center gap-y-1 text-sm", {
2484
2493
  variants: {
2485
2494
  variant: {
2486
2495
  // Solta, sem fundo: as linhas de uma lista.
2487
2496
  default: "py-2",
2488
2497
  // Bloco cinza com borda: o resumo dentro de um card ("Saldo total", "Ganho total").
2489
- subtle: "rounded-lg border border-border bg-muted px-4 py-3"
2498
+ subtle: "rounded-lg border border-border bg-muted px-4 py-3",
2499
+ // Caixa branca com borda e 8 px de espaço: o resumo dentro de um card, com o título em destaque e, se quiser,
2500
+ // as linhas de detalhe dentro dela (um ItemGroup). Não é um Card: card dentro de card continua proibido.
2501
+ outline: (0, import_cn25.cn)("rounded-lg border border-border bg-card p-2", OUTLINE_DETAILS)
2502
+ },
2503
+ size: {
2504
+ // 16 px no título e no valor.
2505
+ default: "gap-x-3",
2506
+ // 14 px no título e no valor (ItemTitle e ItemActions leem o data-size), e 8 px entre as partes: resumos densos.
2507
+ sm: "gap-x-2"
2490
2508
  }
2491
2509
  },
2492
- defaultVariants: { variant: "default" }
2510
+ defaultVariants: { variant: "default", size: "default" }
2493
2511
  });
2494
2512
  function Item({
2495
2513
  className,
2496
2514
  variant,
2515
+ size,
2497
2516
  asChild = false,
2498
2517
  ...props
2499
2518
  }) {
@@ -2503,7 +2522,8 @@ function Item({
2503
2522
  {
2504
2523
  "data-slot": "item",
2505
2524
  "data-variant": variant ?? "default",
2506
- className: (0, import_cn25.cn)(itemVariants({ variant }), className),
2525
+ "data-size": size ?? "default",
2526
+ className: (0, import_cn25.cn)(itemVariants({ variant, size }), className),
2507
2527
  ...props
2508
2528
  }
2509
2529
  );
@@ -2524,7 +2544,8 @@ function ItemGroup({
2524
2544
  );
2525
2545
  }
2526
2546
  var MEDIA_TONE = {
2527
- neutral: "bg-muted text-neutral-500",
2547
+ // Azul (apoio), como no MetricCard: o cinza fazia o ícone parecer desabilitado.
2548
+ neutral: "bg-support-50 text-support-500 dark:bg-support-800/40 dark:text-support-300",
2528
2549
  success: "bg-success-50 text-success-500 dark:bg-success-800/40 dark:text-success-300",
2529
2550
  danger: "bg-danger-50 text-danger-500 dark:bg-danger-800/40 dark:text-danger-300"
2530
2551
  };
@@ -2549,14 +2570,14 @@ function ItemMedia({
2549
2570
  );
2550
2571
  }
2551
2572
  function ItemContent({ className, ...props }) {
2552
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { "data-slot": "item-content", className: (0, import_cn25.cn)("flex min-w-24 flex-1 flex-col gap-1", className), ...props });
2573
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { "data-slot": "item-content", className: (0, import_cn25.cn)("flex min-w-16 flex-1 flex-col gap-1", className), ...props });
2553
2574
  }
2554
2575
  function ItemTitle({ className, ...props }) {
2555
2576
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2556
2577
  "div",
2557
2578
  {
2558
2579
  "data-slot": "item-title",
2559
- className: (0, import_cn25.cn)(textStyle("text1"), "flex items-center gap-2 leading-tight text-foreground group-data-[variant=subtle]/item:text-neutral-600", className),
2580
+ className: (0, import_cn25.cn)(textStyle("text1"), "flex items-center gap-2 leading-tight text-foreground group-data-[variant=subtle]/item:text-neutral-600 group-data-[size=sm]/item:text-sm group-data-[size=sm]/item:leading-5", className),
2560
2581
  ...props
2561
2582
  }
2562
2583
  );
@@ -2569,7 +2590,7 @@ function ItemActions({ className, ...props }) {
2569
2590
  "div",
2570
2591
  {
2571
2592
  "data-slot": "item-actions",
2572
- className: (0, import_cn25.cn)("ml-auto flex shrink-0 items-center gap-2 text-base font-semibold text-foreground tabular-nums", className),
2593
+ className: (0, import_cn25.cn)("ml-auto flex shrink-0 items-center gap-2 text-base font-semibold text-foreground tabular-nums group-data-[size=sm]/item:text-sm", className),
2573
2594
  ...props
2574
2595
  }
2575
2596
  );
@@ -2992,7 +3013,7 @@ var formatadores = /* @__PURE__ */ new Map();
2992
3013
  function formatador(moeda) {
2993
3014
  let f = formatadores.get(moeda);
2994
3015
  if (!f) {
2995
- f = new Intl.NumberFormat("pt-BR", { style: "currency", currency: moeda });
3016
+ f = new Intl.NumberFormat("pt-BR", { style: "currency", currency: moeda, currencyDisplay: "narrowSymbol" });
2996
3017
  formatadores.set(moeda, f);
2997
3018
  }
2998
3019
  return f;
@@ -3003,14 +3024,17 @@ var COR = {
3003
3024
  expense: "text-danger-500"
3004
3025
  };
3005
3026
  function Amount({ value, currency = "BRL", tone = "neutral", showSign = true, hidden = false, className, ...props }) {
3006
- const tipo = tone === "auto" ? value > 0 ? "income" : value < 0 ? "expense" : "neutral" : tone;
3027
+ const porSinal = value > 0 ? "income" : value < 0 ? "expense" : "neutral";
3028
+ const saldoPositivo = tone === "balance" && value > 0;
3029
+ const tipo = tone === "auto" ? porSinal : tone === "balance" ? saldoPositivo ? "neutral" : porSinal : tone;
3007
3030
  const negativo = tipo === "expense" || tipo === "neutral" && value < 0;
3008
- const sinal = tipo === "income" ? "+" : negativo ? "\u2212" : "";
3009
- const mostraSinal = sinal !== "" && (tipo === "neutral" || showSign);
3031
+ const positivo = tipo === "income" || saldoPositivo;
3032
+ const sinal = positivo ? "+" : negativo ? "\u2212" : "";
3033
+ const mostraSinal = sinal !== "" && (tipo === "neutral" && !saldoPositivo || showSign);
3010
3034
  const f = formatador(currency);
3011
3035
  const texto = f.format(Math.abs(value));
3012
3036
  const simbolo = f.formatToParts(0).find((p) => p.type === "currency")?.value ?? currency;
3013
- const falado = hidden ? "Valor oculto" : `${negativo ? "menos " : tipo === "income" && mostraSinal ? "mais " : ""}${texto}`;
3037
+ const falado = hidden ? "Valor oculto" : `${negativo ? "menos " : positivo && mostraSinal ? "mais " : ""}${texto}`;
3014
3038
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3015
3039
  "span",
3016
3040
  {
@@ -3471,7 +3495,7 @@ function MetricCard({
3471
3495
  }
3472
3496
 
3473
3497
  // src/components/patterns/insight-card.tsx
3474
- var React37 = require("react");
3498
+ var React37 = __toESM(require("react"), 1);
3475
3499
  var import_cn37 = require("cn");
3476
3500
  var import_lucide_react13 = require("lucide-react");
3477
3501
  var import_jsx_runtime36 = require("react/jsx-runtime");
@@ -3485,13 +3509,31 @@ var TITLE_TONE = {
3485
3509
  warning: "text-warning-500 dark:text-warning-300",
3486
3510
  tip: "text-primary-500 dark:text-primary-300"
3487
3511
  };
3488
- function InsightCard({ title, meta, action, divider = false, className, children, ...props }) {
3512
+ var InsightCardContext = React37.createContext({ size: "default", divided: true });
3513
+ function InsightCard({
3514
+ title,
3515
+ meta,
3516
+ action,
3517
+ divider = false,
3518
+ divided = true,
3519
+ size = "default",
3520
+ className,
3521
+ children,
3522
+ ...props
3523
+ }) {
3524
+ const sm = size === "sm";
3525
+ const contexto = React37.useMemo(() => ({ size, divided }), [size, divided]);
3489
3526
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
3490
3527
  Card,
3491
3528
  {
3492
3529
  "data-slot": "insight-card",
3530
+ "data-size": size,
3493
3531
  padding: "compact",
3494
- className: (0, import_cn37.cn)("gap-3 border-primary-200 bg-primary-50 dark:border-primary-700 dark:bg-primary-800/40", className),
3532
+ className: (0, import_cn37.cn)(
3533
+ "border-primary-200 bg-primary-50 dark:border-primary-700 dark:bg-primary-800/40",
3534
+ sm ? "gap-4" : "gap-3",
3535
+ className
3536
+ ),
3495
3537
  ...props,
3496
3538
  children: [
3497
3539
  /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
@@ -3499,12 +3541,14 @@ function InsightCard({ title, meta, action, divider = false, className, children
3499
3541
  {
3500
3542
  "data-slot": "insight-card-header",
3501
3543
  className: (0, import_cn37.cn)(
3502
- "flex items-center gap-2 px-(--card-spacing)",
3544
+ "flex gap-2 px-(--card-spacing)",
3545
+ // sm: 24 px de altura (a do botão icon-xs), alinhado ao topo, como o cabeçalho do Card compacto.
3546
+ sm ? "min-h-6 items-start" : "items-center",
3503
3547
  divider && "border-b border-inherit pb-(--card-spacing)"
3504
3548
  ),
3505
3549
  children: [
3506
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react13.SparklesIcon, { "aria-hidden": true, className: "size-5 shrink-0 text-primary-500 dark:text-primary-300" }),
3507
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { className: "text-base font-semibold text-foreground", children: [
3550
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { "aria-hidden": true, className: (0, import_cn37.cn)("flex shrink-0 items-center", sm && "h-6"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react13.SparklesIcon, { className: "size-5 text-primary-500 dark:text-primary-300" }) }),
3551
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { className: (0, import_cn37.cn)("font-semibold text-foreground", sm ? "text-sm leading-6" : "text-base"), children: [
3508
3552
  title,
3509
3553
  meta ? /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: "font-normal text-muted-foreground", children: [
3510
3554
  " \xB7 ",
@@ -3520,7 +3564,7 @@ function InsightCard({ title, meta, action, divider = false, className, children
3520
3564
  {
3521
3565
  "data-slot": "insight-card-content",
3522
3566
  className: "flex flex-col gap-3 px-(--card-spacing) text-sm leading-relaxed text-neutral-600 dark:text-neutral-300",
3523
- children
3567
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(InsightCardContext.Provider, { value: contexto, children })
3524
3568
  }
3525
3569
  )
3526
3570
  ]
@@ -3528,12 +3572,16 @@ function InsightCard({ title, meta, action, divider = false, className, children
3528
3572
  );
3529
3573
  }
3530
3574
  function InsightItem({ tone = "tip", icon, title, className, children, ...props }) {
3575
+ const { size, divided } = React37.useContext(InsightCardContext);
3576
+ const sm = size === "sm";
3531
3577
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
3532
3578
  "div",
3533
3579
  {
3534
3580
  "data-slot": "insight-item",
3535
3581
  className: (0, import_cn37.cn)(
3536
- "flex gap-3 border-b border-primary-200 pb-3 last:border-0 last:pb-0 dark:border-primary-700",
3582
+ "flex",
3583
+ sm ? "gap-2" : "gap-3",
3584
+ divided && "border-b border-primary-200 pb-3 last:border-0 last:pb-0 dark:border-primary-700",
3537
3585
  className
3538
3586
  ),
3539
3587
  ...props,
@@ -3542,12 +3590,16 @@ function InsightItem({ tone = "tip", icon, title, className, children, ...props
3542
3590
  "span",
3543
3591
  {
3544
3592
  "aria-hidden": true,
3545
- className: (0, import_cn37.cn)("flex size-10 shrink-0 items-center justify-center rounded-lg [&>svg]:size-5", ICON_TONE2[tone]),
3593
+ className: (0, import_cn37.cn)(
3594
+ "flex shrink-0 items-center justify-center",
3595
+ sm ? "size-8 rounded-md [&>svg]:size-4" : "size-10 rounded-lg [&>svg]:size-5",
3596
+ ICON_TONE2[tone]
3597
+ ),
3546
3598
  children: icon
3547
3599
  }
3548
3600
  ) : null,
3549
3601
  /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex flex-col gap-1", children: [
3550
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: (0, import_cn37.cn)("text-base font-semibold", TITLE_TONE[tone]), children: title }),
3602
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: (0, import_cn37.cn)("font-semibold", sm ? "text-sm" : "text-base", TITLE_TONE[tone]), children: title }),
3551
3603
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { children })
3552
3604
  ] })
3553
3605
  ]