@financinha/ui 0.10.1 → 0.11.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.d.cts CHANGED
@@ -349,7 +349,7 @@ type BankAvatarProps = Omit<React$1.ComponentProps<"span">, "children"> & {
349
349
  */
350
350
  declare function BankAvatar({ name, src, initials, color, textColor, size, status, statusLabel, owner, ownerLabel, className, ...props }: BankAvatarProps): React$1.JSX.Element;
351
351
 
352
- type AmountTone = "neutral" | "income" | "expense" | "auto";
352
+ type AmountTone = "neutral" | "income" | "expense" | "auto" | "balance";
353
353
  type AmountProps = Omit<React$1.ComponentProps<"span">, "children"> & {
354
354
  /** O valor, na moeda de `currency`. Pode ser negativo. */
355
355
  value: number;
@@ -361,6 +361,8 @@ type AmountProps = Omit<React$1.ComponentProps<"span">, "children"> & {
361
361
  * - `income`: ganho. Verde, com "+".
362
362
  * - `expense`: despesa. Vermelho, com "−".
363
363
  * - `auto`: pelo sinal do valor. Positivo é ganho, negativo é despesa, zero é neutro.
364
+ * - `balance`: um saldo que pode ficar positivo ou negativo, como o saldo livre. Positivo com "+" na cor
365
+ * do texto (é um total, não um ganho); negativo vermelho, com "−"; zero sem sinal.
364
366
  */
365
367
  tone?: AmountTone;
366
368
  /** Mostra "+" ou "−" no ganho e na despesa. Padrão: sim. */
@@ -369,7 +371,7 @@ type AmountProps = Omit<React$1.ComponentProps<"span">, "children"> & {
369
371
  hidden?: boolean;
370
372
  };
371
373
  /**
372
- * financinha: valor em dinheiro, sempre no mesmo formato ("R$ 1.234,56", "US$ 1.234,56"), com
374
+ * financinha: valor em dinheiro, sempre no mesmo formato ("R$ 1.234,56", "$ 1.234,56"), com
373
375
  * algarismos de largura igual para alinhar em colunas. O tamanho e o peso vêm do texto em volta
374
376
  * (use `className`).
375
377
  */
@@ -527,9 +529,10 @@ declare function CardContent({ className, flush, ...props }: React$1.ComponentPr
527
529
  declare function CardFooter({ className, ...props }: React$1.ComponentProps<"div">): React$1.JSX.Element;
528
530
 
529
531
  declare const itemVariants: (props?: ({
530
- variant?: "default" | "subtle" | null | undefined;
532
+ variant?: "default" | "outline" | "subtle" | null | undefined;
533
+ size?: "default" | "sm" | null | undefined;
531
534
  } & class_variance_authority_types.ClassProp) | undefined) => string;
532
- declare function Item({ className, variant, asChild, ...props }: React$1.ComponentProps<"div"> & VariantProps<typeof itemVariants> & {
535
+ declare function Item({ className, variant, size, asChild, ...props }: React$1.ComponentProps<"div"> & VariantProps<typeof itemVariants> & {
533
536
  asChild?: boolean;
534
537
  }): React$1.JSX.Element;
535
538
  /** Uma lista de `Item`. Com `divided`, uma linha entre eles (como Fixo e Variável). */
@@ -537,7 +540,7 @@ declare function ItemGroup({ className, divided, ...props }: React$1.ComponentPr
537
540
  divided?: boolean;
538
541
  }): React$1.JSX.Element;
539
542
  declare const MEDIA_TONE: {
540
- readonly neutral: "bg-muted text-neutral-500";
543
+ readonly neutral: "bg-support-50 text-support-500 dark:bg-support-800/40 dark:text-support-300";
541
544
  readonly success: "bg-success-50 text-success-500 dark:bg-success-800/40 dark:text-success-300";
542
545
  readonly danger: "bg-danger-50 text-danger-500 dark:bg-danger-800/40 dark:text-danger-300";
543
546
  };
package/dist/index.d.ts CHANGED
@@ -349,7 +349,7 @@ type BankAvatarProps = Omit<React$1.ComponentProps<"span">, "children"> & {
349
349
  */
350
350
  declare function BankAvatar({ name, src, initials, color, textColor, size, status, statusLabel, owner, ownerLabel, className, ...props }: BankAvatarProps): React$1.JSX.Element;
351
351
 
352
- type AmountTone = "neutral" | "income" | "expense" | "auto";
352
+ type AmountTone = "neutral" | "income" | "expense" | "auto" | "balance";
353
353
  type AmountProps = Omit<React$1.ComponentProps<"span">, "children"> & {
354
354
  /** O valor, na moeda de `currency`. Pode ser negativo. */
355
355
  value: number;
@@ -361,6 +361,8 @@ type AmountProps = Omit<React$1.ComponentProps<"span">, "children"> & {
361
361
  * - `income`: ganho. Verde, com "+".
362
362
  * - `expense`: despesa. Vermelho, com "−".
363
363
  * - `auto`: pelo sinal do valor. Positivo é ganho, negativo é despesa, zero é neutro.
364
+ * - `balance`: um saldo que pode ficar positivo ou negativo, como o saldo livre. Positivo com "+" na cor
365
+ * do texto (é um total, não um ganho); negativo vermelho, com "−"; zero sem sinal.
364
366
  */
365
367
  tone?: AmountTone;
366
368
  /** Mostra "+" ou "−" no ganho e na despesa. Padrão: sim. */
@@ -369,7 +371,7 @@ type AmountProps = Omit<React$1.ComponentProps<"span">, "children"> & {
369
371
  hidden?: boolean;
370
372
  };
371
373
  /**
372
- * financinha: valor em dinheiro, sempre no mesmo formato ("R$ 1.234,56", "US$ 1.234,56"), com
374
+ * financinha: valor em dinheiro, sempre no mesmo formato ("R$ 1.234,56", "$ 1.234,56"), com
373
375
  * algarismos de largura igual para alinhar em colunas. O tamanho e o peso vêm do texto em volta
374
376
  * (use `className`).
375
377
  */
@@ -527,9 +529,10 @@ declare function CardContent({ className, flush, ...props }: React$1.ComponentPr
527
529
  declare function CardFooter({ className, ...props }: React$1.ComponentProps<"div">): React$1.JSX.Element;
528
530
 
529
531
  declare const itemVariants: (props?: ({
530
- variant?: "default" | "subtle" | null | undefined;
532
+ variant?: "default" | "outline" | "subtle" | null | undefined;
533
+ size?: "default" | "sm" | null | undefined;
531
534
  } & class_variance_authority_types.ClassProp) | undefined) => string;
532
- declare function Item({ className, variant, asChild, ...props }: React$1.ComponentProps<"div"> & VariantProps<typeof itemVariants> & {
535
+ declare function Item({ className, variant, size, asChild, ...props }: React$1.ComponentProps<"div"> & VariantProps<typeof itemVariants> & {
533
536
  asChild?: boolean;
534
537
  }): React$1.JSX.Element;
535
538
  /** Uma lista de `Item`. Com `divided`, uma linha entre eles (como Fixo e Variável). */
@@ -537,7 +540,7 @@ declare function ItemGroup({ className, divided, ...props }: React$1.ComponentPr
537
540
  divided?: boolean;
538
541
  }): React$1.JSX.Element;
539
542
  declare const MEDIA_TONE: {
540
- readonly neutral: "bg-muted text-neutral-500";
543
+ readonly neutral: "bg-support-50 text-support-500 dark:bg-support-800/40 dark:text-support-300";
541
544
  readonly success: "bg-success-50 text-success-500 dark:bg-success-800/40 dark:text-success-300";
542
545
  readonly danger: "bg-danger-50 text-danger-500 dark:bg-danger-800/40 dark:text-danger-300";
543
546
  };
package/dist/index.js CHANGED
@@ -2217,20 +2217,39 @@ import { cva as cva6 } from "class-variance-authority";
2217
2217
  import { Slot as Slot3 } from "radix-ui";
2218
2218
  import { cn as cn25 } from "cn";
2219
2219
  import { jsx as jsx24 } from "react/jsx-runtime";
2220
- var itemVariants = cva6("group/item flex flex-wrap items-center gap-x-3 gap-y-1 text-sm", {
2220
+ var OUTLINE_DETAILS = [
2221
+ // O título do resumo em destaque: semibold, na cor do texto.
2222
+ "[&>[data-slot=item-content]>[data-slot=item-title]]:font-semibold [&>[data-slot=item-content]>[data-slot=item-title]]:text-foreground",
2223
+ // As linhas de detalhe (um ItemGroup dentro da caixa) ocupam a linha toda, abaixo de uma divisória de ponta a ponta,
2224
+ // com 8 px entre a divisória e o texto e entre o texto e a borda de baixo.
2225
+ "[&>[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",
2226
+ // Cada linha de detalhe: 4 px em cima e embaixo, nome e valor em cinza, valor sem negrito.
2227
+ "[&>[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"
2228
+ ].join(" ");
2229
+ var itemVariants = cva6("group/item flex flex-wrap items-center gap-y-1 text-sm", {
2221
2230
  variants: {
2222
2231
  variant: {
2223
2232
  // Solta, sem fundo: as linhas de uma lista.
2224
2233
  default: "py-2",
2225
2234
  // Bloco cinza com borda: o resumo dentro de um card ("Saldo total", "Ganho total").
2226
- subtle: "rounded-lg border border-border bg-muted px-4 py-3"
2235
+ subtle: "rounded-lg border border-border bg-muted px-4 py-3",
2236
+ // 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,
2237
+ // as linhas de detalhe dentro dela (um ItemGroup). Não é um Card: card dentro de card continua proibido.
2238
+ outline: cn25("rounded-lg border border-border bg-card p-2", OUTLINE_DETAILS)
2239
+ },
2240
+ size: {
2241
+ // 16 px no título e no valor.
2242
+ default: "gap-x-3",
2243
+ // 14 px no título e no valor (ItemTitle e ItemActions leem o data-size), e 8 px entre as partes: resumos densos.
2244
+ sm: "gap-x-2"
2227
2245
  }
2228
2246
  },
2229
- defaultVariants: { variant: "default" }
2247
+ defaultVariants: { variant: "default", size: "default" }
2230
2248
  });
2231
2249
  function Item({
2232
2250
  className,
2233
2251
  variant,
2252
+ size,
2234
2253
  asChild = false,
2235
2254
  ...props
2236
2255
  }) {
@@ -2240,7 +2259,8 @@ function Item({
2240
2259
  {
2241
2260
  "data-slot": "item",
2242
2261
  "data-variant": variant ?? "default",
2243
- className: cn25(itemVariants({ variant }), className),
2262
+ "data-size": size ?? "default",
2263
+ className: cn25(itemVariants({ variant, size }), className),
2244
2264
  ...props
2245
2265
  }
2246
2266
  );
@@ -2261,7 +2281,8 @@ function ItemGroup({
2261
2281
  );
2262
2282
  }
2263
2283
  var MEDIA_TONE = {
2264
- neutral: "bg-muted text-neutral-500",
2284
+ // Azul (apoio), como no MetricCard: o cinza fazia o ícone parecer desabilitado.
2285
+ neutral: "bg-support-50 text-support-500 dark:bg-support-800/40 dark:text-support-300",
2265
2286
  success: "bg-success-50 text-success-500 dark:bg-success-800/40 dark:text-success-300",
2266
2287
  danger: "bg-danger-50 text-danger-500 dark:bg-danger-800/40 dark:text-danger-300"
2267
2288
  };
@@ -2286,14 +2307,14 @@ function ItemMedia({
2286
2307
  );
2287
2308
  }
2288
2309
  function ItemContent({ className, ...props }) {
2289
- return /* @__PURE__ */ jsx24("div", { "data-slot": "item-content", className: cn25("flex min-w-24 flex-1 flex-col gap-1", className), ...props });
2310
+ return /* @__PURE__ */ jsx24("div", { "data-slot": "item-content", className: cn25("flex min-w-16 flex-1 flex-col gap-1", className), ...props });
2290
2311
  }
2291
2312
  function ItemTitle({ className, ...props }) {
2292
2313
  return /* @__PURE__ */ jsx24(
2293
2314
  "div",
2294
2315
  {
2295
2316
  "data-slot": "item-title",
2296
- className: cn25(textStyle("text1"), "flex items-center gap-2 leading-tight text-foreground group-data-[variant=subtle]/item:text-neutral-600", className),
2317
+ className: cn25(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),
2297
2318
  ...props
2298
2319
  }
2299
2320
  );
@@ -2306,7 +2327,7 @@ function ItemActions({ className, ...props }) {
2306
2327
  "div",
2307
2328
  {
2308
2329
  "data-slot": "item-actions",
2309
- className: cn25("ml-auto flex shrink-0 items-center gap-2 text-base font-semibold text-foreground tabular-nums", className),
2330
+ className: cn25("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),
2310
2331
  ...props
2311
2332
  }
2312
2333
  );
@@ -2729,7 +2750,7 @@ var formatadores = /* @__PURE__ */ new Map();
2729
2750
  function formatador(moeda) {
2730
2751
  let f = formatadores.get(moeda);
2731
2752
  if (!f) {
2732
- f = new Intl.NumberFormat("pt-BR", { style: "currency", currency: moeda });
2753
+ f = new Intl.NumberFormat("pt-BR", { style: "currency", currency: moeda, currencyDisplay: "narrowSymbol" });
2733
2754
  formatadores.set(moeda, f);
2734
2755
  }
2735
2756
  return f;
@@ -2740,14 +2761,17 @@ var COR = {
2740
2761
  expense: "text-danger-500"
2741
2762
  };
2742
2763
  function Amount({ value, currency = "BRL", tone = "neutral", showSign = true, hidden = false, className, ...props }) {
2743
- const tipo = tone === "auto" ? value > 0 ? "income" : value < 0 ? "expense" : "neutral" : tone;
2764
+ const porSinal = value > 0 ? "income" : value < 0 ? "expense" : "neutral";
2765
+ const saldoPositivo = tone === "balance" && value > 0;
2766
+ const tipo = tone === "auto" ? porSinal : tone === "balance" ? saldoPositivo ? "neutral" : porSinal : tone;
2744
2767
  const negativo = tipo === "expense" || tipo === "neutral" && value < 0;
2745
- const sinal = tipo === "income" ? "+" : negativo ? "\u2212" : "";
2746
- const mostraSinal = sinal !== "" && (tipo === "neutral" || showSign);
2768
+ const positivo = tipo === "income" || saldoPositivo;
2769
+ const sinal = positivo ? "+" : negativo ? "\u2212" : "";
2770
+ const mostraSinal = sinal !== "" && (tipo === "neutral" && !saldoPositivo || showSign);
2747
2771
  const f = formatador(currency);
2748
2772
  const texto = f.format(Math.abs(value));
2749
2773
  const simbolo = f.formatToParts(0).find((p) => p.type === "currency")?.value ?? currency;
2750
- const falado = hidden ? "Valor oculto" : `${negativo ? "menos " : tipo === "income" && mostraSinal ? "mais " : ""}${texto}`;
2774
+ const falado = hidden ? "Valor oculto" : `${negativo ? "menos " : positivo && mostraSinal ? "mais " : ""}${texto}`;
2751
2775
  return /* @__PURE__ */ jsxs13(
2752
2776
  "span",
2753
2777
  {