@eifi1/ui-kit 0.15.4 → 0.16.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.
Files changed (160) hide show
  1. package/README.md +20 -15
  2. package/dist/chart.d.ts +3 -4
  3. package/dist/components/alert-banner.js +1 -1
  4. package/dist/components/alert-banner.js.map +1 -1
  5. package/dist/components/amount-input.d.ts +13 -4
  6. package/dist/components/amount-input.js +166 -157
  7. package/dist/components/amount-input.js.map +1 -1
  8. package/dist/components/authed-image.d.ts +14 -3
  9. package/dist/components/authed-image.js +32 -23
  10. package/dist/components/authed-image.js.map +1 -1
  11. package/dist/components/button-group.d.ts +3 -4
  12. package/dist/components/calculator.d.ts +3 -4
  13. package/dist/components/checkbox.js +1 -1
  14. package/dist/components/checkbox.js.map +1 -1
  15. package/dist/components/choice-card.js +1 -1
  16. package/dist/components/choice-card.js.map +1 -1
  17. package/dist/components/copy-button.d.ts +3 -4
  18. package/dist/components/error-boundary.js +1 -1
  19. package/dist/components/error-boundary.js.map +1 -1
  20. package/dist/components/facing-pair.d.ts +3 -4
  21. package/dist/components/file-button.d.ts +3 -4
  22. package/dist/components/file-button.js +64 -31
  23. package/dist/components/file-button.js.map +1 -1
  24. package/dist/components/file-dropzone.d.ts +3 -4
  25. package/dist/components/file-dropzone.js +1 -1
  26. package/dist/components/file-dropzone.js.map +1 -1
  27. package/dist/components/form-actions.d.ts +4 -5
  28. package/dist/components/form-actions.js +18 -6
  29. package/dist/components/form-actions.js.map +1 -1
  30. package/dist/components/line-items.d.ts +53 -2
  31. package/dist/components/line-items.js +73 -7
  32. package/dist/components/line-items.js.map +1 -1
  33. package/dist/components/list.d.ts +99 -5
  34. package/dist/components/list.js +103 -38
  35. package/dist/components/list.js.map +1 -1
  36. package/dist/components/loading-state.d.ts +19 -3
  37. package/dist/components/loading-state.js +14 -3
  38. package/dist/components/loading-state.js.map +1 -1
  39. package/dist/components/money-field.d.ts +3 -4
  40. package/dist/components/number-field.d.ts +3 -4
  41. package/dist/components/number-input.d.ts +3 -4
  42. package/dist/components/number-input.js +4 -2
  43. package/dist/components/number-input.js.map +1 -1
  44. package/dist/components/numpad-sheet.d.ts +3 -4
  45. package/dist/components/passkeys-setting.d.ts +30 -10
  46. package/dist/components/passkeys-setting.js +19 -11
  47. package/dist/components/passkeys-setting.js.map +1 -1
  48. package/dist/components/progress-bar.d.ts +12 -3
  49. package/dist/components/progress-bar.js +21 -11
  50. package/dist/components/progress-bar.js.map +1 -1
  51. package/dist/components/series-chart.d.ts +3 -4
  52. package/dist/components/settings-fields.d.ts +3 -4
  53. package/dist/components/signed-amount.d.ts +28 -4
  54. package/dist/components/signed-amount.js +17 -8
  55. package/dist/components/signed-amount.js.map +1 -1
  56. package/dist/components/stat-tile.d.ts +31 -2
  57. package/dist/components/stat-tile.js +37 -6
  58. package/dist/components/stat-tile.js.map +1 -1
  59. package/dist/components/status-dot.d.ts +4 -1
  60. package/dist/components/status-dot.js +20 -1
  61. package/dist/components/status-dot.js.map +1 -1
  62. package/dist/components/swatch-picker.d.ts +3 -1
  63. package/dist/components/swatch-picker.js.map +1 -1
  64. package/dist/components/table.d.ts +18 -13
  65. package/dist/components/table.js +20 -5
  66. package/dist/components/table.js.map +1 -1
  67. package/dist/components/text-link.d.ts +3 -4
  68. package/dist/components/time-input.d.ts +3 -4
  69. package/dist/components/toggle-legend.d.ts +12 -1
  70. package/dist/components/toggle-legend.js +6 -2
  71. package/dist/components/toggle-legend.js.map +1 -1
  72. package/dist/components/ui.d.ts +3 -4
  73. package/dist/components/ui.js +156 -52
  74. package/dist/components/ui.js.map +1 -1
  75. package/dist/feedback/feedback-attachment.d.ts +2 -82
  76. package/dist/feedback/feedback-attachment.js +285 -55
  77. package/dist/feedback/feedback-attachment.js.map +1 -1
  78. package/dist/feedback/feedback-dialog.d.ts +2 -105
  79. package/dist/feedback/feedback-dialog.js +57 -25
  80. package/dist/feedback/feedback-dialog.js.map +1 -1
  81. package/dist/feedback/feedback-inbox.d.ts +1 -1
  82. package/dist/feedback/feedback-thread.d.ts +2 -2
  83. package/dist/feedback-attachment-WFiXJ8We.d.ts +302 -0
  84. package/dist/feedback.d.ts +1 -2
  85. package/dist/hooks/use-file-drop.d.ts +3 -4
  86. package/dist/i18n/defaults.d.ts +3 -4
  87. package/dist/i18n/kit-labels.d.ts +2 -3
  88. package/dist/i18n/locales/de-CH-informal.d.ts +3 -4
  89. package/dist/i18n/locales/de-CH.d.ts +3 -4
  90. package/dist/i18n/locales/de-informal.d.ts +3 -4
  91. package/dist/i18n/locales/de.d.ts +3 -4
  92. package/dist/i18n/locales/de.js +5 -1
  93. package/dist/i18n/locales/de.js.map +1 -1
  94. package/dist/i18n/locales/es.d.ts +3 -4
  95. package/dist/i18n/locales/es.js +5 -1
  96. package/dist/i18n/locales/es.js.map +1 -1
  97. package/dist/i18n/locales/fr.d.ts +3 -4
  98. package/dist/i18n/locales/fr.js +5 -1
  99. package/dist/i18n/locales/fr.js.map +1 -1
  100. package/dist/i18n/locales/hu.d.ts +3 -4
  101. package/dist/i18n/locales/hu.js +5 -1
  102. package/dist/i18n/locales/hu.js.map +1 -1
  103. package/dist/i18n/locales/it.d.ts +3 -4
  104. package/dist/i18n/locales/it.js +5 -1
  105. package/dist/i18n/locales/it.js.map +1 -1
  106. package/dist/i18n/locales/zh.d.ts +3 -4
  107. package/dist/i18n/locales/zh.js +5 -1
  108. package/dist/i18n/locales/zh.js.map +1 -1
  109. package/dist/index.d.ts +10 -11
  110. package/dist/{kit-labels-CnnBd-2N.d.ts → kit-labels-DE--LmCk.d.ts} +154 -14
  111. package/dist/lib/format.d.ts +18 -3
  112. package/dist/lib/format.js +2 -1
  113. package/dist/lib/format.js.map +1 -1
  114. package/dist/rhf/fields.d.ts +3 -4
  115. package/dist/rhf/form.d.ts +3 -4
  116. package/dist/rhf/line-items.js.map +1 -1
  117. package/dist/rhf.d.ts +3 -4
  118. package/dist/shell/app-shell.d.ts +3 -4
  119. package/dist/shell/top-bar-brand.d.ts +3 -4
  120. package/dist/shell.d.ts +3 -4
  121. package/dist/theme/palette-derive.d.ts +3 -0
  122. package/dist/theme/palette-derive.js +7 -0
  123. package/dist/theme/palette-derive.js.map +1 -1
  124. package/dist/wizard/stepper-nav.d.ts +3 -4
  125. package/dist/wizard.d.ts +3 -4
  126. package/package.json +4 -2
  127. package/src/components/alert-banner.tsx +1 -1
  128. package/src/components/amount-input.tsx +47 -16
  129. package/src/components/authed-image.tsx +20 -2
  130. package/src/components/checkbox.tsx +1 -1
  131. package/src/components/choice-card.tsx +1 -1
  132. package/src/components/error-boundary.tsx +1 -1
  133. package/src/components/file-button.tsx +77 -27
  134. package/src/components/file-dropzone.tsx +1 -1
  135. package/src/components/form-actions.tsx +86 -8
  136. package/src/components/line-items.tsx +131 -14
  137. package/src/components/list.tsx +240 -50
  138. package/src/components/loading-state.tsx +35 -4
  139. package/src/components/number-input.tsx +18 -2
  140. package/src/components/passkeys-setting.tsx +45 -18
  141. package/src/components/progress-bar.tsx +46 -21
  142. package/src/components/signed-amount.tsx +47 -8
  143. package/src/components/stat-tile.tsx +76 -6
  144. package/src/components/status-dot.tsx +31 -0
  145. package/src/components/swatch-picker.tsx +3 -1
  146. package/src/components/table.tsx +42 -15
  147. package/src/components/toggle-legend.tsx +21 -4
  148. package/src/components/ui.tsx +280 -70
  149. package/src/feedback/feedback-attachment.tsx +472 -96
  150. package/src/feedback/feedback-dialog.tsx +162 -50
  151. package/src/i18n/locales/de.ts +4 -0
  152. package/src/i18n/locales/es.ts +4 -0
  153. package/src/i18n/locales/fr.ts +4 -0
  154. package/src/i18n/locales/hu.ts +4 -0
  155. package/src/i18n/locales/it.ts +4 -0
  156. package/src/i18n/locales/zh.ts +4 -0
  157. package/src/lib/format.ts +24 -3
  158. package/src/rhf/line-items.tsx +6 -0
  159. package/src/theme/palette-derive.ts +10 -0
  160. package/tokens.css +9 -1
@@ -36,13 +36,18 @@ function useMagnitudeFormatter({ currency, unit, compact, digits, format, locale
36
36
  return formatNumber(magnitude, { locale: kitLocale, compact, digits });
37
37
  };
38
38
  }
39
- function directionOf(value) {
40
- return value > 0 ? "up" : value < 0 ? "down" : "flat";
39
+ function directionOf(value, flatWithin = 0) {
40
+ if (Math.abs(value) <= Math.max(0, flatWithin)) return "flat";
41
+ return value > 0 ? "up" : "down";
41
42
  }
42
- function signedToneClass(tone, dir, goodDirection) {
43
+ function verdictClass(good, palette) {
44
+ if (palette === "money") return good ? TEXT_TONE.income : TEXT_TONE.expense;
45
+ return good ? TEXT_TONE.success : TEXT_TONE.danger;
46
+ }
47
+ function signedToneClass(tone, dir, goodDirection, palette) {
43
48
  if (tone === "verdict" || goodDirection && tone === "signed") {
44
49
  if (dir === "flat" || !goodDirection) return TEXT_TONE.muted;
45
- return dir === goodDirection ? TEXT_TONE.success : TEXT_TONE.danger;
50
+ return verdictClass(dir === goodDirection, palette);
46
51
  }
47
52
  if (tone === "signed") return dir === "flat" ? TEXT_TONE.muted : dir === "up" ? TEXT_TONE.income : TEXT_TONE.expense;
48
53
  if (tone === "neutral") return "";
@@ -59,6 +64,8 @@ function SignedAmount({
59
64
  locale,
60
65
  tone = "signed",
61
66
  goodDirection,
67
+ palette = "status",
68
+ flatWithin,
62
69
  showPlus = true,
63
70
  arrow = false,
64
71
  sensitive = false,
@@ -69,7 +76,7 @@ function SignedAmount({
69
76
  const text = useKitLabels("signedAmount", DEFAULT_SIGNED_AMOUNT_LABELS, labels);
70
77
  const fmt = useMagnitudeFormatter({ currency, unit, compact, digits, format, locale });
71
78
  const finite = Number.isFinite(value);
72
- const dir = finite ? directionOf(value) : "flat";
79
+ const dir = finite ? directionOf(value, flatWithin) : "flat";
73
80
  const amount = finite ? fmt(Math.abs(value)) : "\u2014";
74
81
  const sign = dir === "up" ? showPlus ? "+" : "" : dir === "down" ? "\u2212" : "";
75
82
  const spoken = dir === "up" ? text.positive(amount) : dir === "down" ? text.negative(amount) : amount;
@@ -82,7 +89,7 @@ function SignedAmount({
82
89
  "data-direction": dir,
83
90
  className: cn(
84
91
  "relative inline-flex items-center gap-0.5 whitespace-nowrap tabular-nums",
85
- signedToneClass(tone, dir, goodDirection),
92
+ signedToneClass(tone, dir, goodDirection, palette),
86
93
  className
87
94
  ),
88
95
  children: [
@@ -105,6 +112,8 @@ function Delta({
105
112
  format,
106
113
  locale,
107
114
  goodDirection,
115
+ palette = "status",
116
+ flatWithin,
108
117
  label,
109
118
  arrow = true,
110
119
  sensitive = false,
@@ -116,14 +125,14 @@ function Delta({
116
125
  const fmt = useMagnitudeFormatter({ currency, unit, compact, digits, format, locale });
117
126
  if (!Number.isFinite(value)) return null;
118
127
  const amount = fmt(Math.abs(value));
119
- const dir = directionOf(value);
128
+ const dir = directionOf(value, flatWithin);
120
129
  const Icon = ARROW[dir];
121
130
  let spoken = dir === "up" ? text.increase(amount) : dir === "down" ? text.decrease(amount) : text.unchanged;
122
131
  let tone = TEXT_TONE.muted;
123
132
  if (goodDirection && dir !== "flat") {
124
133
  const good = dir === goodDirection;
125
134
  spoken = good ? text.better(spoken) : text.worse(spoken);
126
- tone = good ? TEXT_TONE.success : TEXT_TONE.danger;
135
+ tone = verdictClass(good, palette);
127
136
  }
128
137
  return /* @__PURE__ */ jsxs(
129
138
  "span",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/signed-amount.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { ArrowDown, ArrowUp, Minus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { formatMoney, formatNumber, formatPercent } from \"../lib/format\";\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { DEFAULT_STAT_TILE_LABELS } from \"./stat-tile\";\nimport type { StatTileLabels } from \"./stat-tile\";\n\n/**\n * The text colours a figure can carry, token-backed — `StatTile`'s tones, as a class\n * any span can take.\n *\n * - `default` — the primary text colour. `muted` — the secondary, quiet one.\n * - `income` / `expense` / `net` — the money trio (CVD-safe teal / amber / violet).\n * - `success` / `warning` / `danger` / `info` — a verdict: a rent rise is the tenant's\n * bad news (kastlan lease-columns), a vote \"for\" is green (meeting-agenda-tab).\n * - `brand` — the app's accent.\n *\n * Colour is never the only carrier: pair a verdict with an arrow, a word, or a sign.\n */\nexport type TextTone =\n | \"default\"\n | \"muted\"\n | \"brand\"\n | \"income\"\n | \"expense\"\n | \"net\"\n | \"success\"\n | \"warning\"\n | \"danger\"\n | \"info\";\n\nconst TEXT_TONE: Record<TextTone, string> = {\n default: \"text-[var(--text-primary)]\",\n muted: \"text-[var(--text-muted)]\",\n brand: \"text-[var(--brand)]\",\n income: \"text-[var(--money-income)]\",\n expense: \"text-[var(--money-expense)]\",\n net: \"text-[var(--money-net)]\",\n success: \"text-[var(--success)]\",\n warning: \"text-[var(--warning)]\",\n danger: \"text-[var(--danger)]\",\n info: \"text-[var(--info)]\",\n};\n\n/**\n * The class that colours text in `tone` — for the spans kastlan colours by hand with\n * `text-[var(--danger)]` / `text-emerald-600` (settlement-table, changelog-page,\n * meeting-agenda-tab), so the palette they draw from is the kit's tokens.\n */\nexport function toneTextClass(tone: TextTone): string {\n return TEXT_TONE[tone];\n}\n\nexport interface ToneProps extends ComponentPropsWithoutRef<\"span\"> {\n tone: TextTone;\n}\n\n/** A `<span>` in a {@link TextTone} — `<Tone tone=\"success\">{votesFor}</Tone>`. */\nexport function Tone({ tone, className, ...rest }: ToneProps) {\n return <span {...rest} className={cn(TEXT_TONE[tone], className)} />;\n}\n\n/* ── Signed amounts ──────────────────────────────────────────────────────── */\n\n/** Which way is +1: `up` for a figure where more is good news (income, savings),\n * `down` where less is (a rent the tenant pays, a cost). */\nexport type GoodDirection = \"up\" | \"down\";\n\n/**\n * How a signed figure is coloured:\n * - `signed` (default) — money read by its own sign: above zero `income`, below zero\n * `expense`, zero muted. A balance, a net.\n * - `income` / `expense` / `neutral` — one colour whatever the sign (`neutral` is the\n * text's own colour).\n * - `verdict` — the change judged by {@link SignedAmountProps.goodDirection}: good\n * news `success`, bad news `danger`, zero muted. Setting `goodDirection` implies it.\n */\nexport type SignedAmountTone = \"signed\" | \"income\" | \"expense\" | \"neutral\" | \"verdict\";\n\n/** What a signed figure says to a screen reader, whose readers disagree about a\n * leading \"+\" (most skip it) and a \"−\" (some read \"dash\", some nothing). */\nexport interface SignedAmountLabels {\n /** A figure above zero. `amount` is formatted and unsigned. */\n positive: (amount: string) => string;\n /** A figure below zero. `amount` is formatted and unsigned. */\n negative: (amount: string) => string;\n}\n\nexport const DEFAULT_SIGNED_AMOUNT_LABELS: SignedAmountLabels = {\n positive: (amount) => `plus ${amount}`,\n negative: (amount) => `minus ${amount}`,\n};\n\ninterface SignedFormatProps {\n /** ISO 4217 code: format as money. */\n currency?: string;\n /** `\"percent\"` reads `value` as a RATIO (`0.12` → 12 %), as `StatTile`'s delta does. */\n unit?: \"value\" | \"percent\";\n /** Compact notation: 12 400 → \"12K\". */\n compact?: boolean;\n /** Fraction digits, as `formatNumber`'s `digits`. */\n digits?: number | { min?: number; max?: number };\n /** Formats the UNSIGNED magnitude, replacing the `Intl` default outright. The sign\n * is the component's. */\n format?: (magnitude: number) => string;\n locale?: string;\n}\n\nfunction useMagnitudeFormatter({ currency, unit, compact, digits, format, locale }: SignedFormatProps) {\n const kitLocale = useKitLocale(locale);\n return (magnitude: number): string => {\n if (format) return format(magnitude);\n if (unit === \"percent\") return formatPercent(magnitude, { locale: kitLocale, compact, digits });\n if (currency) return formatMoney(magnitude, currency, { locale: kitLocale, compact, digits });\n return formatNumber(magnitude, { locale: kitLocale, compact, digits });\n };\n}\n\nfunction directionOf(value: number): \"up\" | \"down\" | \"flat\" {\n return value > 0 ? \"up\" : value < 0 ? \"down\" : \"flat\";\n}\n\nfunction signedToneClass(\n tone: SignedAmountTone,\n dir: \"up\" | \"down\" | \"flat\",\n goodDirection: GoodDirection | undefined,\n): string {\n if (tone === \"verdict\" || (goodDirection && tone === \"signed\")) {\n if (dir === \"flat\" || !goodDirection) return TEXT_TONE.muted;\n return dir === goodDirection ? TEXT_TONE.success : TEXT_TONE.danger;\n }\n if (tone === \"signed\") return dir === \"flat\" ? TEXT_TONE.muted : dir === \"up\" ? TEXT_TONE.income : TEXT_TONE.expense;\n if (tone === \"neutral\") return \"\";\n return TEXT_TONE[tone];\n}\n\nconst ARROW = { up: ArrowUp, down: ArrowDown, flat: Minus } as const;\n\nexport interface SignedAmountProps\n extends SignedFormatProps,\n Omit<ComponentPropsWithoutRef<\"span\">, \"children\"> {\n value: number;\n /** See {@link SignedAmountTone}. Default `signed`, or `verdict` with `goodDirection`. */\n tone?: SignedAmountTone;\n /** Which way is good news — colours by verdict (`success` / `danger`). */\n goodDirection?: GoodDirection;\n /** Print \"+\" before a positive figure (default `true`). A negative always shows its\n * minus; zero shows neither. */\n showPlus?: boolean;\n /** An arrow before the figure (up / down / a dash at zero) — so the direction does not\n * ride on colour alone. Decorative; the words say the same. */\n arrow?: boolean;\n /** Tag the figure `data-private`, for the host's demo-mode blur. */\n sensitive?: boolean;\n labels?: Partial<SignedAmountLabels>;\n}\n\n/**\n * A figure with a sign that matters: a balance, a rent change, a net.\n *\n * kastlan writes it by hand in five places — `{change > 0 ? \"+\" : \"\"}{formatCurrency(\n * change)}` in a span coloured by a ternary (lease-columns:190, settlement-table:58,\n * the tenancy `formatPct`) — and each picks its own colours for the same verdict.\n *\n * The visible figure (sign, digits, arrow) is hidden from assistive tech and spoken as\n * words instead (\"plus CHF 50.00\" / \"minus CHF 50.00\", `signedAmount.*`): a \"+\" is\n * skipped by most screen readers, and `Intl`'s \"−\" is read as \"dash\" or not at all.\n */\nexport function SignedAmount({\n value,\n currency,\n unit,\n compact,\n digits,\n format,\n locale,\n tone = \"signed\",\n goodDirection,\n showPlus = true,\n arrow = false,\n sensitive = false,\n labels,\n className,\n ...rest\n}: SignedAmountProps) {\n const text = useKitLabels(\"signedAmount\", DEFAULT_SIGNED_AMOUNT_LABELS, labels);\n const fmt = useMagnitudeFormatter({ currency, unit, compact, digits, format, locale });\n const finite = Number.isFinite(value);\n const dir = finite ? directionOf(value) : \"flat\";\n const amount = finite ? fmt(Math.abs(value)) : \"—\";\n // U+2212, the typographic minus: the same width as \"+\", so a column of signed figures\n // lines up under `tabular-nums`.\n const sign = dir === \"up\" ? (showPlus ? \"+\" : \"\") : dir === \"down\" ? \"−\" : \"\";\n const spoken = dir === \"up\" ? text.positive(amount) : dir === \"down\" ? text.negative(amount) : amount;\n const Icon = ARROW[dir];\n return (\n <span\n {...rest}\n data-private={sensitive ? \"\" : undefined}\n data-direction={dir}\n className={cn(\n \"relative inline-flex items-center gap-0.5 whitespace-nowrap tabular-nums\",\n signedToneClass(tone, dir, goodDirection),\n className,\n )}\n >\n {arrow && <Icon aria-hidden className=\"size-[1em] shrink-0\" />}\n <span aria-hidden>\n {sign}\n {amount}\n </span>\n <span className=\"sr-only\">{spoken}</span>\n </span>\n );\n}\n\nexport interface DeltaProps extends SignedFormatProps, Omit<ComponentPropsWithoutRef<\"span\">, \"children\"> {\n /** The change. Above zero is \"up\". */\n value: number;\n /** Which way is good news. Unset, the change is stated and not judged (muted); set,\n * it is coloured `success` / `danger` and its sentence says \"(better)\" / \"(worse)\". */\n goodDirection?: GoodDirection;\n /** What it is measured against, after it: \"vs last month\". */\n label?: ReactNode;\n /** Hide the arrow (shown by default, as on a StatTile). At zero the arrow is a flat\n * dash BESIDE the figure (\"– 0.00 %\"), never in place of it. */\n arrow?: boolean;\n sensitive?: boolean;\n /** The `statTile` namespace's direction words — a delta says the same as a tile's. */\n labels?: Partial<Pick<StatTileLabels, \"increase\" | \"decrease\" | \"unchanged\" | \"better\" | \"worse\">>;\n}\n\n/**\n * `StatTile`'s delta on its own: an arrow, the unsigned magnitude, and a sentence for\n * screen readers (\"Up 12% (worse)\"), coloured only when `goodDirection` judges it —\n * users up and cost up are the same arrow until someone says which is good.\n *\n * For a change shown outside a tile: kastlan's rent-change column\n * (lease-columns:219, a \"+1.25%\" chip), the breakdown rows of the rent calculator\n * (breakdown-row:5, a trend icon coloured by hand).\n */\nexport function Delta({\n value,\n currency,\n unit,\n compact,\n digits,\n format,\n locale,\n goodDirection,\n label,\n arrow = true,\n sensitive = false,\n labels,\n className,\n ...rest\n}: DeltaProps) {\n const text = useKitLabels(\"statTile\", DEFAULT_STAT_TILE_LABELS, labels);\n const fmt = useMagnitudeFormatter({ currency, unit, compact, digits, format, locale });\n if (!Number.isFinite(value)) return null;\n const amount = fmt(Math.abs(value));\n const dir = directionOf(value);\n const Icon = ARROW[dir];\n let spoken = dir === \"up\" ? text.increase(amount) : dir === \"down\" ? text.decrease(amount) : text.unchanged;\n let tone = TEXT_TONE.muted;\n if (goodDirection && dir !== \"flat\") {\n const good = dir === goodDirection;\n spoken = good ? text.better(spoken) : text.worse(spoken);\n tone = good ? TEXT_TONE.success : TEXT_TONE.danger;\n }\n return (\n <span\n {...rest}\n data-direction={dir}\n className={cn(\"relative inline-flex flex-wrap items-center gap-x-1.5 tabular-nums\", className)}\n >\n <span data-private={sensitive ? \"\" : undefined} className={cn(\"inline-flex items-center gap-0.5 font-medium\", tone)}>\n {arrow && <Icon className=\"size-[1em] shrink-0\" aria-hidden />}\n {/* The figure at zero too, beside the flat dash (kastlan feedback #48). Before\n this a flat delta with an arrow drew the dash ALONE, as a StatTile does — so\n a rent-change column that printed \"0.00 %\" for an unchanged lease showed a\n bare \"–\" in its place, and a bare dash is what a table prints for a MISSING\n value: \"unchanged\" and \"not known\" looked the same. The Minus icon is the\n neutral indicator, the muted tone the neutral colour, and the figure says\n how much (none) in the column's own digits. A value that is missing never\n reaches here — a non-finite one renders nothing, above. Visible change for\n every `<Delta value={0}>` with the default arrow: \"–\" became \"– 0 %\". */}\n <span aria-hidden>{amount}</span>\n <span className=\"sr-only\">{spoken}</span>\n </span>\n {label != null && <span className=\"text-[var(--text-muted)]\">{label}</span>}\n </span>\n );\n}\n"],"mappings":";AA4DS,cAoJH,YApJG;AA3DT,SAAS,WAAW,SAAS,aAAa;AAC1C,SAAS,UAAU;AACnB,SAAS,aAAa,cAAc,qBAAqB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4BAA4B,iBAAM;AAAA;AAAA;AAAA,EACtE;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/signed-amount.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { ArrowDown, ArrowUp, Minus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { formatMoney, formatNumber, formatPercent } from \"../lib/format\";\nimport { useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { DEFAULT_STAT_TILE_LABELS } from \"./stat-tile\";\nimport type { StatTileLabels } from \"./stat-tile\";\n\n/**\n * The text colours a figure can carry, token-backed — `StatTile`'s tones, as a class\n * any span can take.\n *\n * - `default` — the primary text colour. `muted` — the secondary, quiet one.\n * - `income` / `expense` / `net` — the money trio (CVD-safe teal / amber / violet).\n * - `success` / `warning` / `danger` / `info` — a verdict: a rent rise is the tenant's\n * bad news (kastlan lease-columns), a vote \"for\" is green (meeting-agenda-tab).\n * - `brand` — the app's accent.\n *\n * Colour is never the only carrier: pair a verdict with an arrow, a word, or a sign.\n */\nexport type TextTone =\n | \"default\"\n | \"muted\"\n | \"brand\"\n | \"income\"\n | \"expense\"\n | \"net\"\n | \"success\"\n | \"warning\"\n | \"danger\"\n | \"info\";\n\nconst TEXT_TONE: Record<TextTone, string> = {\n default: \"text-[var(--text-primary)]\",\n muted: \"text-[var(--text-muted)]\",\n brand: \"text-[var(--brand)]\",\n income: \"text-[var(--money-income)]\",\n expense: \"text-[var(--money-expense)]\",\n net: \"text-[var(--money-net)]\",\n success: \"text-[var(--success)]\",\n warning: \"text-[var(--warning)]\",\n danger: \"text-[var(--danger)]\",\n info: \"text-[var(--info)]\",\n};\n\n/**\n * The class that colours text in `tone` — for the spans kastlan colours by hand with\n * `text-[var(--danger)]` / `text-emerald-600` (settlement-table, changelog-page,\n * meeting-agenda-tab), so the palette they draw from is the kit's tokens.\n */\nexport function toneTextClass(tone: TextTone): string {\n return TEXT_TONE[tone];\n}\n\nexport interface ToneProps extends ComponentPropsWithoutRef<\"span\"> {\n tone: TextTone;\n}\n\n/** A `<span>` in a {@link TextTone} — `<Tone tone=\"success\">{votesFor}</Tone>`. */\nexport function Tone({ tone, className, ...rest }: ToneProps) {\n return <span {...rest} className={cn(TEXT_TONE[tone], className)} />;\n}\n\n/* ── Signed amounts ──────────────────────────────────────────────────────── */\n\n/** Which way is +1: `up` for a figure where more is good news (income, savings),\n * `down` where less is (a rent the tenant pays, a cost). */\nexport type GoodDirection = \"up\" | \"down\";\n\n/**\n * How a signed figure is coloured:\n * - `signed` (default) — money read by its own sign: above zero `income`, below zero\n * `expense`, zero muted. A balance, a net.\n * - `income` / `expense` / `neutral` — one colour whatever the sign (`neutral` is the\n * text's own colour).\n * - `verdict` — the change judged by {@link SignedAmountProps.goodDirection}: good\n * news `success`, bad news `danger`, zero muted. Setting `goodDirection` implies it.\n */\nexport type SignedAmountTone = \"signed\" | \"income\" | \"expense\" | \"neutral\" | \"verdict\";\n\n/**\n * The colours a VERDICT is painted in (`goodDirection` set, or `tone=\"verdict\"`):\n * - `status` (default) — `success` / `danger`: good news, bad news.\n * - `money` — `income` / `expense` (the `.text-money-pos` / `.text-money-neg` pair):\n * the app's ONE money palette (keksdose dev#434). A grocery price going UP is money\n * going out, so with `goodDirection=\"down\"` it wears the expense colour every other\n * outflow in the app wears — not a red that says \"error\". keksdose coloured its\n * three price-change sites by hand for want of this.\n */\nexport type VerdictPalette = \"status\" | \"money\";\n\n/** What a signed figure says to a screen reader, whose readers disagree about a\n * leading \"+\" (most skip it) and a \"−\" (some read \"dash\", some nothing). */\nexport interface SignedAmountLabels {\n /** A figure above zero. `amount` is formatted and unsigned. */\n positive: (amount: string) => string;\n /** A figure below zero. `amount` is formatted and unsigned. */\n negative: (amount: string) => string;\n}\n\nexport const DEFAULT_SIGNED_AMOUNT_LABELS: SignedAmountLabels = {\n positive: (amount) => `plus ${amount}`,\n negative: (amount) => `minus ${amount}`,\n};\n\ninterface SignedFormatProps {\n /** ISO 4217 code: format as money. */\n currency?: string;\n /** `\"percent\"` reads `value` as a RATIO (`0.12` → 12 %), as `StatTile`'s delta does. */\n unit?: \"value\" | \"percent\";\n /** Compact notation: 12 400 → \"12K\". */\n compact?: boolean;\n /** Fraction digits, as `formatNumber`'s `digits`. */\n digits?: number | { min?: number; max?: number };\n /** Formats the UNSIGNED magnitude, replacing the `Intl` default outright. The sign\n * is the component's. */\n format?: (magnitude: number) => string;\n locale?: string;\n}\n\nfunction useMagnitudeFormatter({ currency, unit, compact, digits, format, locale }: SignedFormatProps) {\n const kitLocale = useKitLocale(locale);\n return (magnitude: number): string => {\n if (format) return format(magnitude);\n if (unit === \"percent\") return formatPercent(magnitude, { locale: kitLocale, compact, digits });\n if (currency) return formatMoney(magnitude, currency, { locale: kitLocale, compact, digits });\n return formatNumber(magnitude, { locale: kitLocale, compact, digits });\n };\n}\n\n/** `flatWithin` widens \"no change\" from exactly zero to a band round it: a price that\n * moved by a fraction of a cent, a ratio that rounds to \"0.0 %\", is not a rise, and an\n * arrow and a colour for it claim one. Inclusive — `|value| ≤ flatWithin` is flat. */\nfunction directionOf(value: number, flatWithin = 0): \"up\" | \"down\" | \"flat\" {\n if (Math.abs(value) <= Math.max(0, flatWithin)) return \"flat\";\n return value > 0 ? \"up\" : \"down\";\n}\n\nfunction verdictClass(good: boolean, palette: VerdictPalette): string {\n if (palette === \"money\") return good ? TEXT_TONE.income : TEXT_TONE.expense;\n return good ? TEXT_TONE.success : TEXT_TONE.danger;\n}\n\nfunction signedToneClass(\n tone: SignedAmountTone,\n dir: \"up\" | \"down\" | \"flat\",\n goodDirection: GoodDirection | undefined,\n palette: VerdictPalette,\n): string {\n if (tone === \"verdict\" || (goodDirection && tone === \"signed\")) {\n if (dir === \"flat\" || !goodDirection) return TEXT_TONE.muted;\n return verdictClass(dir === goodDirection, palette);\n }\n if (tone === \"signed\") return dir === \"flat\" ? TEXT_TONE.muted : dir === \"up\" ? TEXT_TONE.income : TEXT_TONE.expense;\n if (tone === \"neutral\") return \"\";\n return TEXT_TONE[tone];\n}\n\nconst ARROW = { up: ArrowUp, down: ArrowDown, flat: Minus } as const;\n\nexport interface SignedAmountProps\n extends SignedFormatProps,\n Omit<ComponentPropsWithoutRef<\"span\">, \"children\"> {\n value: number;\n /** See {@link SignedAmountTone}. Default `signed`, or `verdict` with `goodDirection`. */\n tone?: SignedAmountTone;\n /** Which way is good news — colours by verdict (`success` / `danger`, or the money\n * pair with `palette=\"money\"`). */\n goodDirection?: GoodDirection;\n /** See {@link VerdictPalette}. Default `status`. Only a verdict reads it. */\n palette?: VerdictPalette;\n /** A magnitude up to which the figure counts as NO change: no sign, no arrow but the\n * flat dash, muted, spoken without \"plus\"/\"minus\" (inclusive; default 0). The digits\n * still print `|value|` — use a band below the display precision, where they round\n * to zero anyway (`flatWithin={0.005}` at two digits). */\n flatWithin?: number;\n /** Print \"+\" before a positive figure (default `true`). A negative always shows its\n * minus; zero shows neither. */\n showPlus?: boolean;\n /** An arrow before the figure (up / down / a dash at zero) — so the direction does not\n * ride on colour alone. Decorative; the words say the same. */\n arrow?: boolean;\n /** Tag the figure `data-private`, for the host's demo-mode blur. */\n sensitive?: boolean;\n labels?: Partial<SignedAmountLabels>;\n}\n\n/**\n * A figure with a sign that matters: a balance, a rent change, a net.\n *\n * kastlan writes it by hand in five places — `{change > 0 ? \"+\" : \"\"}{formatCurrency(\n * change)}` in a span coloured by a ternary (lease-columns:190, settlement-table:58,\n * the tenancy `formatPct`) — and each picks its own colours for the same verdict.\n *\n * The visible figure (sign, digits, arrow) is hidden from assistive tech and spoken as\n * words instead (\"plus CHF 50.00\" / \"minus CHF 50.00\", `signedAmount.*`): a \"+\" is\n * skipped by most screen readers, and `Intl`'s \"−\" is read as \"dash\" or not at all.\n */\nexport function SignedAmount({\n value,\n currency,\n unit,\n compact,\n digits,\n format,\n locale,\n tone = \"signed\",\n goodDirection,\n palette = \"status\",\n flatWithin,\n showPlus = true,\n arrow = false,\n sensitive = false,\n labels,\n className,\n ...rest\n}: SignedAmountProps) {\n const text = useKitLabels(\"signedAmount\", DEFAULT_SIGNED_AMOUNT_LABELS, labels);\n const fmt = useMagnitudeFormatter({ currency, unit, compact, digits, format, locale });\n const finite = Number.isFinite(value);\n const dir = finite ? directionOf(value, flatWithin) : \"flat\";\n const amount = finite ? fmt(Math.abs(value)) : \"—\";\n // U+2212, the typographic minus: the same width as \"+\", so a column of signed figures\n // lines up under `tabular-nums`.\n const sign = dir === \"up\" ? (showPlus ? \"+\" : \"\") : dir === \"down\" ? \"−\" : \"\";\n const spoken = dir === \"up\" ? text.positive(amount) : dir === \"down\" ? text.negative(amount) : amount;\n const Icon = ARROW[dir];\n return (\n <span\n {...rest}\n data-private={sensitive ? \"\" : undefined}\n data-direction={dir}\n className={cn(\n \"relative inline-flex items-center gap-0.5 whitespace-nowrap tabular-nums\",\n signedToneClass(tone, dir, goodDirection, palette),\n className,\n )}\n >\n {arrow && <Icon aria-hidden className=\"size-[1em] shrink-0\" />}\n <span aria-hidden>\n {sign}\n {amount}\n </span>\n <span className=\"sr-only\">{spoken}</span>\n </span>\n );\n}\n\nexport interface DeltaProps extends SignedFormatProps, Omit<ComponentPropsWithoutRef<\"span\">, \"children\"> {\n /** The change. Above zero is \"up\". */\n value: number;\n /** Which way is good news. Unset, the change is stated and not judged (muted); set,\n * it is coloured `success` / `danger` and its sentence says \"(better)\" / \"(worse)\". */\n goodDirection?: GoodDirection;\n /** See {@link VerdictPalette}: `money` paints good news `income` and bad news\n * `expense` instead of `success` / `danger`. Default `status`. */\n palette?: VerdictPalette;\n /** See {@link SignedAmountProps.flatWithin}: up to this magnitude the change is\n * \"unchanged\" — flat dash, muted, no verdict. Default 0. */\n flatWithin?: number;\n /** What it is measured against, after it: \"vs last month\". */\n label?: ReactNode;\n /** Hide the arrow (shown by default, as on a StatTile). At zero the arrow is a flat\n * dash BESIDE the figure (\"– 0.00 %\"), never in place of it. */\n arrow?: boolean;\n sensitive?: boolean;\n /** The `statTile` namespace's direction words — a delta says the same as a tile's. */\n labels?: Partial<Pick<StatTileLabels, \"increase\" | \"decrease\" | \"unchanged\" | \"better\" | \"worse\">>;\n}\n\n/**\n * `StatTile`'s delta on its own: an arrow, the unsigned magnitude, and a sentence for\n * screen readers (\"Up 12% (worse)\"), coloured only when `goodDirection` judges it —\n * users up and cost up are the same arrow until someone says which is good.\n *\n * For a change shown outside a tile: kastlan's rent-change column\n * (lease-columns:219, a \"+1.25%\" chip), the breakdown rows of the rent calculator\n * (breakdown-row:5, a trend icon coloured by hand).\n */\nexport function Delta({\n value,\n currency,\n unit,\n compact,\n digits,\n format,\n locale,\n goodDirection,\n palette = \"status\",\n flatWithin,\n label,\n arrow = true,\n sensitive = false,\n labels,\n className,\n ...rest\n}: DeltaProps) {\n const text = useKitLabels(\"statTile\", DEFAULT_STAT_TILE_LABELS, labels);\n const fmt = useMagnitudeFormatter({ currency, unit, compact, digits, format, locale });\n if (!Number.isFinite(value)) return null;\n const amount = fmt(Math.abs(value));\n const dir = directionOf(value, flatWithin);\n const Icon = ARROW[dir];\n let spoken = dir === \"up\" ? text.increase(amount) : dir === \"down\" ? text.decrease(amount) : text.unchanged;\n let tone = TEXT_TONE.muted;\n if (goodDirection && dir !== \"flat\") {\n const good = dir === goodDirection;\n spoken = good ? text.better(spoken) : text.worse(spoken);\n tone = verdictClass(good, palette);\n }\n return (\n <span\n {...rest}\n data-direction={dir}\n className={cn(\"relative inline-flex flex-wrap items-center gap-x-1.5 tabular-nums\", className)}\n >\n <span data-private={sensitive ? \"\" : undefined} className={cn(\"inline-flex items-center gap-0.5 font-medium\", tone)}>\n {arrow && <Icon className=\"size-[1em] shrink-0\" aria-hidden />}\n {/* The figure at zero too, beside the flat dash (kastlan feedback #48). Before\n this a flat delta with an arrow drew the dash ALONE, as a StatTile does — so\n a rent-change column that printed \"0.00 %\" for an unchanged lease showed a\n bare \"–\" in its place, and a bare dash is what a table prints for a MISSING\n value: \"unchanged\" and \"not known\" looked the same. The Minus icon is the\n neutral indicator, the muted tone the neutral colour, and the figure says\n how much (none) in the column's own digits. A value that is missing never\n reaches here — a non-finite one renders nothing, above. Visible change for\n every `<Delta value={0}>` with the default arrow: \"–\" became \"– 0 %\". */}\n <span aria-hidden>{amount}</span>\n <span className=\"sr-only\">{spoken}</span>\n </span>\n {label != null && <span className=\"text-[var(--text-muted)]\">{label}</span>}\n </span>\n );\n}\n"],"mappings":";AA4DS,cAmLH,YAnLG;AA3DT,SAAS,WAAW,SAAS,aAAa;AAC1C,SAAS,UAAU;AACnB,SAAS,aAAa,cAAc,qBAAqB;AACzD,SAAS,cAAc,oBAAoB;AAC3C,SAAS,gCAAgC;AA2BzC,MAAM,YAAsC;AAAA,EAC1C,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AACR;AAOO,SAAS,cAAc,MAAwB;AACpD,SAAO,UAAU,IAAI;AACvB;AAOO,SAAS,KAAK,EAAE,MAAM,WAAW,GAAG,KAAK,GAAc;AAC5D,SAAO,oBAAC,UAAM,GAAG,MAAM,WAAW,GAAG,UAAU,IAAI,GAAG,SAAS,GAAG;AACpE;AAuCO,MAAM,+BAAmD;AAAA,EAC9D,UAAU,CAAC,WAAW,QAAQ,MAAM;AAAA,EACpC,UAAU,CAAC,WAAW,SAAS,MAAM;AACvC;AAiBA,SAAS,sBAAsB,EAAE,UAAU,MAAM,SAAS,QAAQ,QAAQ,OAAO,GAAsB;AACrG,QAAM,YAAY,aAAa,MAAM;AACrC,SAAO,CAAC,cAA8B;AACpC,QAAI,OAAQ,QAAO,OAAO,SAAS;AACnC,QAAI,SAAS,UAAW,QAAO,cAAc,WAAW,EAAE,QAAQ,WAAW,SAAS,OAAO,CAAC;AAC9F,QAAI,SAAU,QAAO,YAAY,WAAW,UAAU,EAAE,QAAQ,WAAW,SAAS,OAAO,CAAC;AAC5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M,IAAI,KAAK;AAClG,MAAI,OAAO,UAAU;AACrB,MAAI,iBAAiB,QAAQ,QAAQ;AACnC,UAAM,OAAO,QAAQ;AACrB,aAAS,OAAO,KAAK,OAAO,MAAM,IAAI,KAAK,MAAM,MAAM;AACvD,WAAO,aAAa,MAAM,OAAO;AAAA,EACnC;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,kBAAgB;AAAA,MAChB,WAAW,GAAG,sEAAsE,SAAS;AAAA,MAE7F;AAAA,6BAAC,UAAK,gBAAc,YAAY,KAAK,QAAW,WAAW,GAAG,gDAAgD,IAAI,GAC/G;AAAA,mBAAS,oBAAC,QAAK,WAAU,uBAAsB,eAAW,MAAC;AAAA,UAU5D,oBAAC,UAAK,eAAW,MAAE,kBAAO;AAAA,UAC1B,oBAAC,UAAK,WAAU,WAAW,kBAAO;AAAA,WACpC;AAAA,QACC,SAAS,QAAQ,oBAAC,UAAK,WAAU,4BAA4B,iBAAM;AAAA;AAAA;AAAA,EACtE;AAEJ;","names":[]}
@@ -163,6 +163,16 @@ interface StatTileProps extends Omit<ComponentPropsWithoutRef<"div">, "children"
163
163
  loading?: boolean;
164
164
  /** `"sm"` for dense grids (a metrics wall); `"md"` the default KPI. */
165
165
  size?: "sm" | "md";
166
+ /**
167
+ * The tile's frame. `"card"` (default) is the bordered, shadowed card on the page.
168
+ * `"inset"` is a tile INSIDE a card: {@link Card}'s `inset` — the raised
169
+ * `--bg-surface-2`, a small radius, no border or shadow, since the card round it
170
+ * already has them. `"plain"` drops the frame altogether — no fill and no padding —
171
+ * for figures set straight into a card's content (a summary row under a card title),
172
+ * where any box would be a box in a box. keksdose wrote both by hand over the card
173
+ * tile (`border-0 shadow-none bg-transparent p-0`) for its tiles inside a card.
174
+ */
175
+ variant?: "card" | "inset" | "plain";
166
176
  /** Makes the tile a link. See {@link renderLink} for a router. */
167
177
  href?: string;
168
178
  /** Renders the link for `href` — pass your router's `<Link>` here, since a plain
@@ -188,11 +198,30 @@ interface StatTileProps extends Omit<ComponentPropsWithoutRef<"div">, "children"
188
198
  * the hint sits above the overlay and stays its own tab stop. The link's name is the
189
199
  * label, and it is described by the value and the delta.
190
200
  */
191
- declare function StatTile({ label, value, currency, compact, numberFormat, format, locale, unit, valueLabel, tone, delta, goodDirection, hint, truncateLabel, name, description, projection, subValues, trend, sparkline, icon, footer, sensitive, loading, size, href, renderLink, onClick, labels, className, ...rest }: StatTileProps): react.JSX.Element;
201
+ declare function StatTile({ label, value, currency, compact, numberFormat, format, locale, unit, valueLabel, tone, delta, goodDirection, hint, truncateLabel, name, description, projection, subValues, trend, sparkline, icon, footer, sensitive, loading, size, variant, href, renderLink, onClick, labels, className, ...rest }: StatTileProps): react.JSX.Element;
192
202
  interface StatTileGridProps extends ComponentPropsWithoutRef<"div"> {
193
203
  /** The narrowest a tile may get before the grid drops a column. The default fits
194
204
  * two tiles on a 320px phone. */
195
205
  minTileWidth?: string;
206
+ /**
207
+ * Let a row that is not full stretch its tiles across the whole width. Default
208
+ * `true` (CSS `auto-fit`): one or two tiles fill the row, as they always have.
209
+ * `false` (`auto-fill`): the empty columns are kept, so every tile is the width of
210
+ * a column whatever the count — a lone "Balance" tile in a card stays tile-sized
211
+ * instead of becoming a banner the width of the card, and the tiles of a short row
212
+ * line up with the columns of a full one above it.
213
+ */
214
+ stretch?: boolean;
215
+ /**
216
+ * Every tile in the grid is loading: each shows its skeleton (as with its own
217
+ * `loading`), and the grid says "Loading…" ONCE, in a polite status region, instead
218
+ * of each tile carrying its own sr-only "Loading…" — a wall of eight tiles was read
219
+ * as eight "Loading…"s in a row. The grid is `aria-busy` meanwhile. A tile's own
220
+ * `loading` inside a grid that is not loading still speaks for itself.
221
+ */
222
+ loading?: boolean;
223
+ /** The grid's one sentence — `loading` from {@link StatTileLabels}. */
224
+ labels?: Partial<Pick<StatTileLabels, "loading">>;
196
225
  }
197
226
  /**
198
227
  * The row of tiles every dashboard in the three apps lays out by hand, each with its
@@ -201,6 +230,6 @@ interface StatTileGridProps extends ComponentPropsWithoutRef<"div"> {
201
230
  * the band where the sidebar was open. This fits as many columns as `minTileWidth`
202
231
  * allows in the space the grid actually has, and needs no breakpoint at all.
203
232
  */
204
- declare function StatTileGrid({ minTileWidth, className, style, ...rest }: StatTileGridProps): react.JSX.Element;
233
+ declare function StatTileGrid({ minTileWidth, stretch, loading, labels, className, style, children, ...rest }: StatTileGridProps): react.JSX.Element;
205
234
 
206
235
  export { DEFAULT_STAT_TILE_LABELS, StatTile, type StatTileDelta, StatTileGrid, type StatTileGridProps, type StatTileLabels, type StatTileLinkProps, type StatTileProps, type StatTileSubValue, type StatTileTone };
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { isValidElement, useId, useLayoutEffect, useState } from "react";
3
+ import { createContext, isValidElement, useContext, useId, useLayoutEffect, useState } from "react";
4
4
  import { ArrowDown, ArrowUp, Minus } from "lucide-react";
5
5
  import { cn } from "../lib/cn.js";
6
6
  import { useKitLabels, useKitLink, useKitLocale } from "../i18n/kit-labels.js";
@@ -75,6 +75,7 @@ function StatTile({
75
75
  sensitive = false,
76
76
  loading = false,
77
77
  size = "md",
78
+ variant = "card",
78
79
  href,
79
80
  renderLink,
80
81
  onClick,
@@ -83,6 +84,8 @@ function StatTile({
83
84
  ...rest
84
85
  }) {
85
86
  const text = useKitLabels("statTile", DEFAULT_STAT_TILE_LABELS, labels);
87
+ const gridLoading = useContext(StatTileGridLoadingContext);
88
+ loading = loading || gridLoading;
86
89
  const kitLink = useKitLink();
87
90
  const [labelEl, setLabelEl] = useState(null);
88
91
  const labelCut = useIsTruncated(truncateLabel ? labelEl : null);
@@ -151,7 +154,7 @@ function StatTile({
151
154
  );
152
155
  const headline = loading ? /* @__PURE__ */ jsxs("span", { id: valueId, className: "relative block py-0.5", children: [
153
156
  /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cn(SKELETON_CLASS, "block h-6 w-24 max-w-full") }),
154
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: text.loading })
157
+ !gridLoading && /* @__PURE__ */ jsx("span", { className: "sr-only", children: text.loading })
155
158
  ] }) : hasValue ? /* @__PURE__ */ jsxs("span", { id: valueId, "data-private": priv, className: cn(valueClass, valueLabel != null && "ms-auto"), children: [
156
159
  show(value),
157
160
  unit != null && /* @__PURE__ */ jsx("span", { className: "ms-1 text-[0.7em] font-medium text-[var(--text-muted)]", children: unit })
@@ -176,13 +179,18 @@ function StatTile({
176
179
  Card,
177
180
  {
178
181
  ...rest,
182
+ variant: variant === "card" ? "default" : "inset",
183
+ "data-variant": variant === "card" ? void 0 : variant,
179
184
  "aria-busy": loading || void 0,
180
185
  className: cn(
181
186
  // @container: the headline sizes read the tile's width. relative: the stretched
182
187
  // link's overlay. overflow-hidden: at pathological widths a figure clips inside
183
188
  // the border instead of painting over the neighbouring tile.
184
189
  "@container relative flex min-w-0 flex-col overflow-hidden",
185
- PADDING[size],
190
+ // `plain` is the inset card with its fill and padding taken away — the figures
191
+ // align with the content edge of the card they sit in. (Not `p-0` over the
192
+ // padding: the padding's `sm:p-4` would still win from `sm` up.)
193
+ variant === "plain" ? "rounded-none bg-transparent p-0" : PADDING[size],
186
194
  interactive && "transition-colors hover:border-[var(--border-strong)] hover:bg-[var(--bg-hover)]",
187
195
  className
188
196
  ),
@@ -259,11 +267,34 @@ function useIsTruncated(el) {
259
267
  }, [el]);
260
268
  return cut;
261
269
  }
262
- function StatTileGrid({ minTileWidth = "9rem", className, style, ...rest }) {
270
+ const StatTileGridLoadingContext = createContext(false);
271
+ function StatTileGrid({
272
+ minTileWidth = "9rem",
273
+ stretch = true,
274
+ loading = false,
275
+ labels,
276
+ className,
277
+ style,
278
+ children,
279
+ ...rest
280
+ }) {
281
+ const text = useKitLabels("statTile", DEFAULT_STAT_TILE_LABELS, labels);
263
282
  const columns = {
264
- gridTemplateColumns: `repeat(auto-fit, minmax(min(100%, ${minTileWidth}), 1fr))`
283
+ gridTemplateColumns: `repeat(${stretch ? "auto-fit" : "auto-fill"}, minmax(min(100%, ${minTileWidth}), 1fr))`
265
284
  };
266
- return /* @__PURE__ */ jsx("div", { ...rest, className: cn("grid gap-3", className), style: { ...columns, ...style } });
285
+ return /* @__PURE__ */ jsxs(
286
+ "div",
287
+ {
288
+ ...rest,
289
+ "aria-busy": loading || rest["aria-busy"] || void 0,
290
+ className: cn("relative grid gap-3", className),
291
+ style: { ...columns, ...style },
292
+ children: [
293
+ /* @__PURE__ */ jsx("span", { role: "status", className: "sr-only", children: loading ? text.loading : "" }),
294
+ /* @__PURE__ */ jsx(StatTileGridLoadingContext.Provider, { value: loading, children })
295
+ ]
296
+ }
297
+ );
267
298
  }
268
299
  export {
269
300
  DEFAULT_STAT_TILE_LABELS,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/stat-tile.tsx"],"sourcesContent":["import { isValidElement, useId, useLayoutEffect, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, CSSProperties, ReactElement, ReactNode } from \"react\";\nimport { ArrowDown, ArrowUp, Minus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels, useKitLink, useKitLocale } from \"../i18n/kit-labels\";\nimport { pickLinkRenderer, RenderedKitLink } from \"./text-link\";\nimport { Card, FieldHint } from \"./ui\";\nimport { Sparkline } from \"./sparkline\";\nimport { Tooltip } from \"./tooltip\";\n// The kit's one placeholder look, so a loading tile and the Skeleton list beside it\n// shimmer as one surface — and both stop under `prefers-reduced-motion`, which this\n// tile's private copy of the string did not.\nimport { SKELETON_CLASS } from \"./skeleton\";\n\n/**\n * The words a stat tile speaks. The delta's arrow is an icon, and an icon is not a\n * sentence: a screen reader gets the direction (and, under `goodDirection`, the\n * verdict) as words, and a sighted reader who cannot tell the two delta colours apart\n * still has the arrow — neither judgement rides on colour alone.\n */\nexport interface StatTileLabels {\n /** The delta, rising. `amount` is already formatted and unsigned. */\n increase: (amount: string) => string;\n decrease: (amount: string) => string;\n unchanged: string;\n /** Wraps the direction sentence when `goodDirection` says the change is good. */\n better: (change: string) => string;\n worse: (change: string) => string;\n /** Spoken in place of a missing value (the tile shows a dash). */\n noValue: string;\n /** Spoken while `loading`. */\n loading: string;\n}\n\nexport const DEFAULT_STAT_TILE_LABELS: StatTileLabels = {\n increase: (amount) => `Up ${amount}`,\n decrease: (amount) => `Down ${amount}`,\n unchanged: \"No change\",\n better: (change) => `${change} (better)`,\n worse: (change) => `${change} (worse)`,\n noValue: \"No data\",\n loading: \"Loading…\",\n};\n\n/**\n * What colours a figure. Token-backed like everything else in the kit.\n *\n * - `income` / `expense` / `net` — the money trio (teal / amber / violet, CVD-safe).\n * - `signed` — a money figure read by its own sign: above zero `income`, below zero\n * `expense`, exactly zero neutral (a zero balance is neither news). Needs a NUMBER\n * value; a pre-formatted string cannot be read and stays neutral.\n * - `success` / `warning` / `danger` / `info` — a threshold verdict (\"phase margin\n * below 30°\"). Say it in the hint or description as well; colour alone is not one.\n */\nexport type StatTileTone =\n | \"neutral\"\n | \"brand\"\n | \"income\"\n | \"expense\"\n | \"net\"\n | \"signed\"\n | \"success\"\n | \"warning\"\n | \"danger\"\n | \"info\";\n\nconst TONE_CLASS: Record<Exclude<StatTileTone, \"signed\">, string> = {\n neutral: \"text-[var(--text-primary)]\",\n brand: \"text-[var(--brand)]\",\n income: \"text-[var(--money-income)]\",\n expense: \"text-[var(--money-expense)]\",\n net: \"text-[var(--money-net)]\",\n success: \"text-[var(--success)]\",\n warning: \"text-[var(--warning)]\",\n danger: \"text-[var(--danger)]\",\n info: \"text-[var(--info)]\",\n};\n\nfunction toneClass(tone: StatTileTone, value: unknown): string {\n if (tone !== \"signed\") return TONE_CLASS[tone];\n if (typeof value !== \"number\" || value === 0) return TONE_CLASS.neutral;\n return value < 0 ? TONE_CLASS.expense : TONE_CLASS.income;\n}\n\n/** A change since the previous period. A bare number is shorthand for `{ value }`. */\nexport interface StatTileDelta {\n /** Signed: above zero is \"up\". */\n value: number;\n /** `\"value\"` (default) formats it like the headline — same currency, same\n * notation. `\"percent\"` reads it as a RATIO: `0.12` is shown as 12 %. */\n unit?: \"value\" | \"percent\";\n /** What it is measured against, shown after it: \"vs last month\". */\n label?: ReactNode;\n}\n\n/** A smaller figure under the headline — a prior period, a projection, a split. */\nexport interface StatTileSubValue {\n label: ReactNode;\n /** A number is formatted like the headline; anything else is rendered as given. */\n value: ReactNode;\n /** Defaults to the tile's own `tone`, read per figure (so a `signed` tile shows a\n * teal September above an amber August). Sub-values are always the muted weight\n * of their tone: they are history, and must not outshout the figure above them.\n *\n * `\"none\"` leaves the figure untinted — the row's own muted text, like its label —\n * even on a toned tile: keksdose's report KpiCard (reports/charts/kpi-card.tsx),\n * whose `negative` convention tints only a figure below zero and leaves the rest\n * plain. (`\"neutral\"` is not that: it is the headline's full text colour, at the\n * sub-value's 75 %.) */\n tone?: StatTileTone | \"none\";\n}\n\n/** What {@link StatTileProps.renderLink} is handed. Spread it onto your router's\n * link: the class is what stretches the link over the whole tile. */\nexport interface StatTileLinkProps {\n href: string;\n className: string;\n \"aria-describedby\": string;\n children: ReactNode;\n}\n\nexport interface StatTileProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\" | \"onClick\"> {\n /** What is measured. Also the tile's accessible name when it is a link/button. */\n label: ReactNode;\n /**\n * The headline. A number is formatted with `Intl.NumberFormat` in the kit's locale\n * (see `currency`, `compact`, `numberFormat`, `format`); a string or element is\n * rendered as given. `null`/`undefined` shows a dash and says \"No data\".\n */\n value?: ReactNode;\n /** ISO 4217 code — formats a number value (and a `\"value\"` delta, and numeric\n * sub-values) as money. */\n currency?: string;\n /** Compact notation: 12 400 → \"12K\". */\n compact?: boolean;\n /** Any further `Intl.NumberFormat` options, merged over the two above. */\n numberFormat?: Intl.NumberFormatOptions;\n /** Formats every NUMBER the tile shows, replacing the `Intl` default outright. */\n format?: (value: number) => string;\n locale?: string;\n /** A short unit after the value that `Intl` has no name for: \"ms\", \"dB\", \"Hz\". */\n unit?: ReactNode;\n /** The period the headline belongs to, shown to its left (\"SEP\"). */\n valueLabel?: ReactNode;\n tone?: StatTileTone;\n delta?: number | StatTileDelta;\n /** Which way is good news. Unset, the delta is stated and not judged (users up and\n * cost up are the same arrow); set, it is coloured and its sentence says so. */\n goodDirection?: \"up\" | \"down\";\n /** The explanation behind a \"?\" beside the label (a {@link FieldHint}) — hidden\n * until asked for, so it is for what a reader MIGHT want to know (\"excludes\n * transfers between your own accounts\"). For a line everyone should read, use\n * {@link StatTileProps.description} instead. */\n hint?: string;\n /**\n * Keep the label to ONE line, cut with an ellipsis, and show the whole of it in a\n * {@link Tooltip} on hover and focus — but only while it is actually cut, so a\n * label that fits shows no bubble repeating itself. keksdose's admin MetricTile\n * wall: twenty tiles whose German labels (\"Aktive Abonnements (30 Tage)\") wrapped\n * onto two or three lines and pushed each tile's figure to a different height.\n *\n * The label element keeps the FULL text — the ellipsis is paint — so it is still\n * the tile's accessible name (and the stretched link's, on a link tile) exactly as\n * without this. Off by default: a wrapping label is what every existing tile does,\n * and a tile standing alone has room to.\n *\n * This is the tooltip: pass the label as a plain STRING rather than wrapping it in\n * your own `<Tooltip>` for the full text (keksdose's admin metrics-panel.tsx:134\n * does, from before this prop). A wrapped label shows a bubble even when nothing is\n * cut, and nests its trigger inside this one's.\n */\n truncateLabel?: boolean;\n /**\n * The tile's name as plain text, for the places that need a string rather than a\n * node — today the {@link StatTileProps.trend} sparkline's accessible name. Only\n * needed when `label` is not a string AND its text cannot be read from it: a label\n * element's text children are found on their own (a `<Tooltip label=\"…\">Spend\n * </Tooltip>` label still names its sparkline \"Spend\"), an icon or a formatted\n * message component's are not.\n */\n name?: string;\n /** A visible line under the value: \"Last 12 months\", \"3 estates / 9 buildings\" —\n * always shown, so it is for what every reader needs. An explanation only some\n * will want belongs in {@link StatTileProps.hint}, the \"?\" beside the label. */\n description?: ReactNode;\n /**\n * One figure that belongs WITH the headline rather than under it: keksdose's\n * \"Projected €1,850\" under a to-date \"€420\" (KpiCard, feedback #51), which it\n * currently smuggles into `description` with hand-set margins so the prior-month\n * sub-values do not come between the two. It is drawn directly under the value\n * (before the delta, the description and the sparkline) as a sub-value row, with\n * only a hair of space above it.\n *\n * A slot of its own rather than a placement switch for `subValues`: the history\n * rows (last month, last year) should stay at the bottom where they are, and moving\n * the whole list up to bring one row with it would put them between the headline\n * and its delta. Same shape as a sub-value, so the `tone` rules are the same.\n * Withheld while `loading`, like the sub-values.\n */\n projection?: StatTileSubValue;\n subValues?: StatTileSubValue[];\n /** Shorthand for a fluid {@link Sparkline} named after the tile and speaking in\n * the tile's number format. The name is the label's text; see\n * {@link StatTileProps.name} for a label that has none. */\n trend?: ReadonlyArray<number | null | undefined>;\n /** A custom sparkline (or any small graphic) in the same place. Wins over `trend`. */\n sparkline?: ReactNode;\n /** A decorative icon at the top end of the tile. */\n icon?: ReactNode;\n /** Anything below the rest — a progress bar, a link row. */\n footer?: ReactNode;\n /** Tag every figure `data-private`, so the host's demo-mode rule blurs it — the\n * same attribute `Tooltip redact` and the chart tooltip's value cell carry. */\n sensitive?: boolean;\n /** Skeleton in place of the value; delta, sub-values and trend are withheld. */\n loading?: boolean;\n /** `\"sm\"` for dense grids (a metrics wall); `\"md\"` the default KPI. */\n size?: \"sm\" | \"md\";\n /** Makes the tile a link. See {@link renderLink} for a router. */\n href?: string;\n /** Renders the link for `href` — pass your router's `<Link>` here, since a plain\n * `<a>` reloads a single-page app. Default: the `<UiKitProvider linkComponent>`\n * (for an in-app `href`), then `<a>`. */\n renderLink?: (props: StatTileLinkProps) => ReactElement;\n /** Makes the tile a button (ignored when `href` is given). */\n onClick?: () => void;\n labels?: Partial<StatTileLabels>;\n}\n\n// One formatter per option set: a metrics wall is twenty of these.\nconst formatters = new Map<string, Intl.NumberFormat>();\nfunction numberFormatter(locale: string | undefined, options: Intl.NumberFormatOptions): Intl.NumberFormat {\n const key = `${locale ?? \"\"}|${JSON.stringify(options)}`;\n let f = formatters.get(key);\n if (!f) {\n f = new Intl.NumberFormat(locale, options);\n formatters.set(key, f);\n }\n return f;\n}\n\n// The headline sizes are keyed on the TILE's width (it is a @container), not the\n// viewport: a grid beside a sidebar makes tiles narrowest exactly where a viewport\n// breakpoint would hand them the larger font. `sm` is keksdose's compact headline,\n// sized so a worst-case \"CHF 123,456.78\" still fits a 320px phone's 2-up tiles.\nconst VALUE_TEXT = {\n md: \"text-xl @[13rem]:text-2xl\",\n sm: \"text-xs @[8.5rem]:text-sm @[13rem]:text-base\",\n} as const;\nconst PADDING = { md: \"p-3 sm:p-4\", sm: \"px-2.5 py-2\" } as const;\n\n/**\n * The KPI card: a label, one number, and optionally how it moved, what it is made of\n * and which way it has been going.\n *\n * Replaces keksdose's `KpiCard` and admin `Tile`, lenkbank's metrics tiles and\n * kastlan's `KpiCard` — the same card four times, with four answers to the same\n * questions (how a currency is formatted, whether a delta is judged, what happens to\n * the figures in demo mode).\n *\n * Interactive tiles use a STRETCHED link: the label is the `<a>`/`<button>`, and its\n * `::after` covers the card. Making the card itself the link would nest the hint's\n * `<button>` inside it, which is invalid HTML and an unreachable control; this way\n * the hint sits above the overlay and stays its own tab stop. The link's name is the\n * label, and it is described by the value and the delta.\n */\nexport function StatTile({\n label,\n value,\n currency,\n compact = false,\n numberFormat,\n format,\n locale,\n unit,\n valueLabel,\n tone = \"neutral\",\n delta,\n goodDirection,\n hint,\n truncateLabel = false,\n name,\n description,\n projection,\n subValues,\n trend,\n sparkline,\n icon,\n footer,\n sensitive = false,\n loading = false,\n size = \"md\",\n href,\n renderLink,\n onClick,\n labels,\n className,\n ...rest\n}: StatTileProps) {\n const text = useKitLabels(\"statTile\", DEFAULT_STAT_TILE_LABELS, labels);\n const kitLink = useKitLink();\n const [labelEl, setLabelEl] = useState<HTMLElement | null>(null);\n const labelCut = useIsTruncated(truncateLabel ? labelEl : null);\n const kitLocale = useKitLocale(locale);\n const id = useId();\n const valueId = `${id}-value`;\n const deltaId = `${id}-delta`;\n const priv = sensitive ? \"\" : undefined;\n\n const fmt =\n format ??\n ((n: number) =>\n numberFormatter(kitLocale, {\n ...(currency ? { style: \"currency\", currency } : null),\n ...(compact ? { notation: \"compact\" } : null),\n ...numberFormat,\n }).format(n));\n const show = (v: ReactNode) => (typeof v === \"number\" ? fmt(v) : v);\n\n const d = typeof delta === \"number\" ? { value: delta } : delta;\n const hasValue = value !== null && value !== undefined && value !== \"\";\n const labelText = name ?? plainText(label);\n\n // ── The label, which is also the link/button when the tile is interactive ──\n const stretched = cn(\n \"text-start uppercase tracking-wide\",\n \"after:absolute after:inset-0 after:rounded-lg after:content-['']\",\n \"focus-visible:outline-none focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-[var(--brand)]\",\n );\n const describedBy = d ? `${valueId} ${deltaId}` : valueId;\n let labelNode: ReactNode = label;\n if (href !== undefined) {\n const linkProps: StatTileLinkProps = {\n href,\n className: stretched,\n \"aria-describedby\": describedBy,\n children: label,\n };\n const kit = pickLinkRenderer<StatTileLinkProps>(undefined, kitLink, href);\n labelNode = renderLink ? (\n renderLink(linkProps)\n ) : kit ? (\n <RenderedKitLink render={kit} props={linkProps} />\n ) : (\n <a href={href} className={stretched} aria-describedby={describedBy}>\n {label}\n </a>\n );\n } else if (onClick) {\n labelNode = (\n <button type=\"button\" onClick={onClick} aria-describedby={describedBy} className={stretched}>\n {label}\n </button>\n );\n }\n const interactive = href !== undefined || onClick !== undefined;\n\n // ── Delta ──\n let deltaNode: ReactNode = null;\n if (d && !loading && Number.isFinite(d.value)) {\n const magnitude = Math.abs(d.value);\n const amount =\n d.unit === \"percent\"\n ? numberFormatter(kitLocale, { style: \"percent\", maximumFractionDigits: 1 }).format(magnitude)\n : fmt(magnitude);\n const dir = d.value > 0 ? \"up\" : d.value < 0 ? \"down\" : \"flat\";\n const Icon = dir === \"up\" ? ArrowUp : dir === \"down\" ? ArrowDown : Minus;\n let spoken = dir === \"up\" ? text.increase(amount) : dir === \"down\" ? text.decrease(amount) : text.unchanged;\n let deltaTone = \"text-[var(--text-muted)]\";\n if (goodDirection && dir !== \"flat\") {\n const good = dir === goodDirection;\n spoken = good ? text.better(spoken) : text.worse(spoken);\n deltaTone = good ? \"text-[var(--success)]\" : \"text-[var(--danger)]\";\n }\n deltaNode = (\n // `relative`: the containing block for the sr-only sentence (see the\n // sr-only-containment test for what an escaped one does to the page).\n <div className=\"relative mt-1 flex flex-wrap items-center gap-x-1.5 text-xs tabular-nums\">\n <span id={deltaId} data-private={priv} className={cn(\"inline-flex items-center gap-0.5 font-medium\", deltaTone)}>\n <Icon className=\"size-3 shrink-0\" aria-hidden />\n {/* The figure at zero too, like Delta (kastlan 48): \"0 %\" says the change was\n measured; a bare dash reads like a missing value. */}\n <span aria-hidden>{amount}</span>\n <span className=\"sr-only\">{spoken}</span>\n </span>\n {d.label != null && <span className=\"text-[var(--text-muted)]\">{d.label}</span>}\n </div>\n );\n }\n\n // ── Headline ──\n const valueClass = cn(\n \"whitespace-nowrap font-semibold tabular-nums\",\n VALUE_TEXT[size],\n toneClass(tone, value),\n );\n const headline = loading ? (\n <span id={valueId} className=\"relative block py-0.5\">\n <span aria-hidden className={cn(SKELETON_CLASS, \"block h-6 w-24 max-w-full\")} />\n <span className=\"sr-only\">{text.loading}</span>\n </span>\n ) : hasValue ? (\n <span id={valueId} data-private={priv} className={cn(valueClass, valueLabel != null && \"ms-auto\")}>\n {show(value)}\n {unit != null && (\n <span className=\"ms-1 text-[0.7em] font-medium text-[var(--text-muted)]\">{unit}</span>\n )}\n </span>\n ) : (\n <span id={valueId} className={cn(\"relative\", valueClass, \"text-[var(--text-muted)]\")}>\n <span aria-hidden>—</span>\n <span className=\"sr-only\">{text.noValue}</span>\n </span>\n );\n\n const graphic =\n loading ? null : sparkline ??\n (trend && (\n <Sparkline\n data={trend}\n fluid\n height={size === \"sm\" ? 20 : 28}\n label={labelText}\n formatValue={fmt}\n locale={kitLocale}\n tone={tone === \"signed\" ? \"signed\" : tone === \"neutral\" ? \"chart\" : tone}\n data-private={priv}\n />\n ));\n\n return (\n <Card\n {...rest}\n aria-busy={loading || undefined}\n className={cn(\n // @container: the headline sizes read the tile's width. relative: the stretched\n // link's overlay. overflow-hidden: at pathological widths a figure clips inside\n // the border instead of painting over the neighbouring tile.\n \"@container relative flex min-w-0 flex-col overflow-hidden\",\n PADDING[size],\n interactive && \"transition-colors hover:border-[var(--border-strong)] hover:bg-[var(--bg-hover)]\",\n className,\n )}\n >\n <div className=\"flex items-start gap-2\">\n <div className=\"flex min-w-0 flex-1 items-center gap-1 break-words text-xs uppercase tracking-wide text-[var(--text-muted)]\">\n {truncateLabel && labelCut ? (\n // Portalled: the tile is `overflow-hidden`, and a bubble inside it would be\n // clipped by the very box whose edge cut the label.\n <Tooltip label={label} side=\"top\" portal className=\"flex min-w-0\">\n <span ref={setLabelEl} className=\"block min-w-0 truncate\">\n {labelNode}\n </span>\n </Tooltip>\n ) : (\n <span ref={setLabelEl} className={cn(\"min-w-0\", truncateLabel && \"block truncate\")}>\n {labelNode}\n </span>\n )}\n {/* Above the stretched link's overlay, so it stays hoverable and focusable. */}\n {hint && <FieldHint label={hint} side=\"top\" className=\"relative z-10 shrink-0\" />}\n </div>\n {icon != null && (\n <span aria-hidden className=\"shrink-0 text-[var(--text-muted)] [&_svg]:size-4\">\n {icon}\n </span>\n )}\n </div>\n\n {valueLabel != null ? (\n // Period-left / value-right, matching the sub-rows below it. flex-wrap lets a\n // too-long amount drop to its own end-aligned line instead of overflowing.\n <div className=\"mt-1 flex flex-wrap items-baseline gap-x-1.5\">\n <span className=\"shrink-0 text-xs uppercase tracking-wide text-[var(--text-muted)]\">{valueLabel}</span>\n {headline}\n </div>\n ) : (\n <div className=\"mt-1\">{headline}</div>\n )}\n\n {!loading && projection && (\n <dl className=\"mt-0.5\">\n <FigureRow figure={projection} tileTone={tone} show={show} priv={priv} />\n </dl>\n )}\n\n {deltaNode}\n {description != null && <div className=\"mt-1 text-xs text-[var(--text-muted)]\">{description}</div>}\n {graphic && <div className=\"mt-2\">{graphic}</div>}\n\n {!loading && subValues && subValues.length > 0 && (\n <dl className=\"mt-1.5 space-y-0.5\">\n {subValues.map((sv, i) => (\n <FigureRow key={i} figure={sv} tileTone={tone} show={show} priv={priv} />\n ))}\n </dl>\n )}\n\n {footer != null && <div className=\"mt-2\">{footer}</div>}\n </Card>\n );\n}\n\n/** One label/value row of a `<dl>`: a sub-value, or the projection. */\nfunction FigureRow({\n figure,\n tileTone,\n show,\n priv,\n}: {\n figure: StatTileSubValue;\n tileTone: StatTileTone;\n show: (v: ReactNode) => ReactNode;\n priv: \"\" | undefined;\n}) {\n const own = figure.tone ?? (tileTone === \"neutral\" ? undefined : tileTone);\n const svTone = own === \"none\" ? undefined : own;\n // The LABEL gives way, never the figure. This row used to wrap, so on a narrow tile a\n // long label (\"AUG (SIGNED)\") dropped its amount onto a line of its own while the\n // next row stayed on one — two layouts in one list, and a figure no longer beside\n // the period it belongs to. Now the label breaks within itself and the amount stays\n // on the label's first line, end-aligned like every other row.\n return (\n <div className=\"flex items-baseline gap-x-2 text-xs tabular-nums text-[var(--text-muted)]\">\n <dt className=\"min-w-0 uppercase tracking-wide [overflow-wrap:anywhere]\">{figure.label}</dt>\n <dd\n data-private={priv}\n className={cn(\"ms-auto shrink-0 whitespace-nowrap\", svTone && [toneClass(svTone, figure.value), \"opacity-75\"])}\n >\n {show(figure.value)}\n </dd>\n </div>\n );\n}\n\n/**\n * The text of a label node, for the sparkline's name: a string or number as is, an\n * element by its children, recursively. A `<Tooltip label=\"…\">Spend</Tooltip>` label\n * yields \"Spend\" — the text the reader sees, not the bubble's. `undefined` when there\n * is no text to find (an icon), so the sparkline falls back to its unnamed summary.\n */\nfunction plainText(node: ReactNode): string | undefined {\n const walk = (n: ReactNode): string => {\n if (typeof n === \"string\" || typeof n === \"number\") return String(n);\n if (Array.isArray(n)) return n.map(walk).join(\"\");\n if (isValidElement<{ children?: ReactNode }>(n)) return walk(n.props.children);\n return \"\";\n };\n const text = walk(node).replace(/\\s+/g, \" \").trim();\n return text === \"\" ? undefined : text;\n}\n\n/**\n * Whether `el`'s text is wider than its box — i.e. whether `truncate` is cutting it.\n * Re-measured whenever the box resizes (a grid reflowing, a translation loading), not\n * only on mount. Keyed on the ELEMENT (a callback ref), because wrapping the label in\n * its tooltip remounts it, and an observer on the old node would watch nothing.\n */\nfunction useIsTruncated(el: HTMLElement | null): boolean {\n const [cut, setCut] = useState(false);\n useLayoutEffect(() => {\n // No reset while there is no node: between the unwrapped label unmounting and the\n // wrapped one mounting there is none, and a reset there would unwrap it again.\n if (!el) return;\n const measure = () => setCut(el.scrollWidth > el.clientWidth);\n measure();\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(measure);\n observer.observe(el);\n return () => observer.disconnect();\n }, [el]);\n return cut;\n}\n\nexport interface StatTileGridProps extends ComponentPropsWithoutRef<\"div\"> {\n /** The narrowest a tile may get before the grid drops a column. The default fits\n * two tiles on a 320px phone. */\n minTileWidth?: string;\n}\n\n/**\n * The row of tiles every dashboard in the three apps lays out by hand, each with its\n * own breakpoint ladder (`grid-cols-2 md:grid-cols-4 min-[2400px]:grid-cols-8` …).\n * Those ladders read the VIEWPORT and so ignored the sidebar: 6-up tiles at 155px in\n * the band where the sidebar was open. This fits as many columns as `minTileWidth`\n * allows in the space the grid actually has, and needs no breakpoint at all.\n */\nexport function StatTileGrid({ minTileWidth = \"9rem\", className, style, ...rest }: StatTileGridProps) {\n const columns: CSSProperties = {\n gridTemplateColumns: `repeat(auto-fit, minmax(min(100%, ${minTileWidth}), 1fr))`,\n };\n return <div {...rest} className={cn(\"grid gap-3\", className)} style={{ ...columns, ...style }} />;\n}\n"],"mappings":";AAuVM,cAoCE,YApCF;AAvVN,SAAS,gBAAgB,OAAO,iBAAiB,gBAAgB;AAEjE,SAAS,WAAW,SAAS,aAAa;AAC1C,SAAS,UAAU;AACnB,SAAS,cAAc,YAAY,oBAAoB;AACvD,SAAS,kBAAkB,uBAAuB;AAClD,SAAS,MAAM,iBAAiB;AAChC,SAAS,iBAAiB;AAC1B,SAAS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xE;AACA,SAAO,oBAAC,SAAK,GAAG,MAAM,WAAW,GAAG,cAAc,SAAS,GAAG,OAAO,EAAE,GAAG,SAAS,GAAG,MAAM,GAAG;AACjG;","names":[]}
1
+ {"version":3,"sources":["../../src/components/stat-tile.tsx"],"sourcesContent":["import { createContext, isValidElement, useContext, useId, useLayoutEffect, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, CSSProperties, ReactElement, ReactNode } from \"react\";\nimport { ArrowDown, ArrowUp, Minus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels, useKitLink, useKitLocale } from \"../i18n/kit-labels\";\nimport { pickLinkRenderer, RenderedKitLink } from \"./text-link\";\nimport { Card, FieldHint } from \"./ui\";\nimport { Sparkline } from \"./sparkline\";\nimport { Tooltip } from \"./tooltip\";\n// The kit's one placeholder look, so a loading tile and the Skeleton list beside it\n// shimmer as one surface — and both stop under `prefers-reduced-motion`, which this\n// tile's private copy of the string did not.\nimport { SKELETON_CLASS } from \"./skeleton\";\n\n/**\n * The words a stat tile speaks. The delta's arrow is an icon, and an icon is not a\n * sentence: a screen reader gets the direction (and, under `goodDirection`, the\n * verdict) as words, and a sighted reader who cannot tell the two delta colours apart\n * still has the arrow — neither judgement rides on colour alone.\n */\nexport interface StatTileLabels {\n /** The delta, rising. `amount` is already formatted and unsigned. */\n increase: (amount: string) => string;\n decrease: (amount: string) => string;\n unchanged: string;\n /** Wraps the direction sentence when `goodDirection` says the change is good. */\n better: (change: string) => string;\n worse: (change: string) => string;\n /** Spoken in place of a missing value (the tile shows a dash). */\n noValue: string;\n /** Spoken while `loading`. */\n loading: string;\n}\n\nexport const DEFAULT_STAT_TILE_LABELS: StatTileLabels = {\n increase: (amount) => `Up ${amount}`,\n decrease: (amount) => `Down ${amount}`,\n unchanged: \"No change\",\n better: (change) => `${change} (better)`,\n worse: (change) => `${change} (worse)`,\n noValue: \"No data\",\n loading: \"Loading…\",\n};\n\n/**\n * What colours a figure. Token-backed like everything else in the kit.\n *\n * - `income` / `expense` / `net` — the money trio (teal / amber / violet, CVD-safe).\n * - `signed` — a money figure read by its own sign: above zero `income`, below zero\n * `expense`, exactly zero neutral (a zero balance is neither news). Needs a NUMBER\n * value; a pre-formatted string cannot be read and stays neutral.\n * - `success` / `warning` / `danger` / `info` — a threshold verdict (\"phase margin\n * below 30°\"). Say it in the hint or description as well; colour alone is not one.\n */\nexport type StatTileTone =\n | \"neutral\"\n | \"brand\"\n | \"income\"\n | \"expense\"\n | \"net\"\n | \"signed\"\n | \"success\"\n | \"warning\"\n | \"danger\"\n | \"info\";\n\nconst TONE_CLASS: Record<Exclude<StatTileTone, \"signed\">, string> = {\n neutral: \"text-[var(--text-primary)]\",\n brand: \"text-[var(--brand)]\",\n income: \"text-[var(--money-income)]\",\n expense: \"text-[var(--money-expense)]\",\n net: \"text-[var(--money-net)]\",\n success: \"text-[var(--success)]\",\n warning: \"text-[var(--warning)]\",\n danger: \"text-[var(--danger)]\",\n info: \"text-[var(--info)]\",\n};\n\nfunction toneClass(tone: StatTileTone, value: unknown): string {\n if (tone !== \"signed\") return TONE_CLASS[tone];\n if (typeof value !== \"number\" || value === 0) return TONE_CLASS.neutral;\n return value < 0 ? TONE_CLASS.expense : TONE_CLASS.income;\n}\n\n/** A change since the previous period. A bare number is shorthand for `{ value }`. */\nexport interface StatTileDelta {\n /** Signed: above zero is \"up\". */\n value: number;\n /** `\"value\"` (default) formats it like the headline — same currency, same\n * notation. `\"percent\"` reads it as a RATIO: `0.12` is shown as 12 %. */\n unit?: \"value\" | \"percent\";\n /** What it is measured against, shown after it: \"vs last month\". */\n label?: ReactNode;\n}\n\n/** A smaller figure under the headline — a prior period, a projection, a split. */\nexport interface StatTileSubValue {\n label: ReactNode;\n /** A number is formatted like the headline; anything else is rendered as given. */\n value: ReactNode;\n /** Defaults to the tile's own `tone`, read per figure (so a `signed` tile shows a\n * teal September above an amber August). Sub-values are always the muted weight\n * of their tone: they are history, and must not outshout the figure above them.\n *\n * `\"none\"` leaves the figure untinted — the row's own muted text, like its label —\n * even on a toned tile: keksdose's report KpiCard (reports/charts/kpi-card.tsx),\n * whose `negative` convention tints only a figure below zero and leaves the rest\n * plain. (`\"neutral\"` is not that: it is the headline's full text colour, at the\n * sub-value's 75 %.) */\n tone?: StatTileTone | \"none\";\n}\n\n/** What {@link StatTileProps.renderLink} is handed. Spread it onto your router's\n * link: the class is what stretches the link over the whole tile. */\nexport interface StatTileLinkProps {\n href: string;\n className: string;\n \"aria-describedby\": string;\n children: ReactNode;\n}\n\nexport interface StatTileProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\" | \"onClick\"> {\n /** What is measured. Also the tile's accessible name when it is a link/button. */\n label: ReactNode;\n /**\n * The headline. A number is formatted with `Intl.NumberFormat` in the kit's locale\n * (see `currency`, `compact`, `numberFormat`, `format`); a string or element is\n * rendered as given. `null`/`undefined` shows a dash and says \"No data\".\n */\n value?: ReactNode;\n /** ISO 4217 code — formats a number value (and a `\"value\"` delta, and numeric\n * sub-values) as money. */\n currency?: string;\n /** Compact notation: 12 400 → \"12K\". */\n compact?: boolean;\n /** Any further `Intl.NumberFormat` options, merged over the two above. */\n numberFormat?: Intl.NumberFormatOptions;\n /** Formats every NUMBER the tile shows, replacing the `Intl` default outright. */\n format?: (value: number) => string;\n locale?: string;\n /** A short unit after the value that `Intl` has no name for: \"ms\", \"dB\", \"Hz\". */\n unit?: ReactNode;\n /** The period the headline belongs to, shown to its left (\"SEP\"). */\n valueLabel?: ReactNode;\n tone?: StatTileTone;\n delta?: number | StatTileDelta;\n /** Which way is good news. Unset, the delta is stated and not judged (users up and\n * cost up are the same arrow); set, it is coloured and its sentence says so. */\n goodDirection?: \"up\" | \"down\";\n /** The explanation behind a \"?\" beside the label (a {@link FieldHint}) — hidden\n * until asked for, so it is for what a reader MIGHT want to know (\"excludes\n * transfers between your own accounts\"). For a line everyone should read, use\n * {@link StatTileProps.description} instead. */\n hint?: string;\n /**\n * Keep the label to ONE line, cut with an ellipsis, and show the whole of it in a\n * {@link Tooltip} on hover and focus — but only while it is actually cut, so a\n * label that fits shows no bubble repeating itself. keksdose's admin MetricTile\n * wall: twenty tiles whose German labels (\"Aktive Abonnements (30 Tage)\") wrapped\n * onto two or three lines and pushed each tile's figure to a different height.\n *\n * The label element keeps the FULL text — the ellipsis is paint — so it is still\n * the tile's accessible name (and the stretched link's, on a link tile) exactly as\n * without this. Off by default: a wrapping label is what every existing tile does,\n * and a tile standing alone has room to.\n *\n * This is the tooltip: pass the label as a plain STRING rather than wrapping it in\n * your own `<Tooltip>` for the full text (keksdose's admin metrics-panel.tsx:134\n * does, from before this prop). A wrapped label shows a bubble even when nothing is\n * cut, and nests its trigger inside this one's.\n */\n truncateLabel?: boolean;\n /**\n * The tile's name as plain text, for the places that need a string rather than a\n * node — today the {@link StatTileProps.trend} sparkline's accessible name. Only\n * needed when `label` is not a string AND its text cannot be read from it: a label\n * element's text children are found on their own (a `<Tooltip label=\"…\">Spend\n * </Tooltip>` label still names its sparkline \"Spend\"), an icon or a formatted\n * message component's are not.\n */\n name?: string;\n /** A visible line under the value: \"Last 12 months\", \"3 estates / 9 buildings\" —\n * always shown, so it is for what every reader needs. An explanation only some\n * will want belongs in {@link StatTileProps.hint}, the \"?\" beside the label. */\n description?: ReactNode;\n /**\n * One figure that belongs WITH the headline rather than under it: keksdose's\n * \"Projected €1,850\" under a to-date \"€420\" (KpiCard, feedback #51), which it\n * currently smuggles into `description` with hand-set margins so the prior-month\n * sub-values do not come between the two. It is drawn directly under the value\n * (before the delta, the description and the sparkline) as a sub-value row, with\n * only a hair of space above it.\n *\n * A slot of its own rather than a placement switch for `subValues`: the history\n * rows (last month, last year) should stay at the bottom where they are, and moving\n * the whole list up to bring one row with it would put them between the headline\n * and its delta. Same shape as a sub-value, so the `tone` rules are the same.\n * Withheld while `loading`, like the sub-values.\n */\n projection?: StatTileSubValue;\n subValues?: StatTileSubValue[];\n /** Shorthand for a fluid {@link Sparkline} named after the tile and speaking in\n * the tile's number format. The name is the label's text; see\n * {@link StatTileProps.name} for a label that has none. */\n trend?: ReadonlyArray<number | null | undefined>;\n /** A custom sparkline (or any small graphic) in the same place. Wins over `trend`. */\n sparkline?: ReactNode;\n /** A decorative icon at the top end of the tile. */\n icon?: ReactNode;\n /** Anything below the rest — a progress bar, a link row. */\n footer?: ReactNode;\n /** Tag every figure `data-private`, so the host's demo-mode rule blurs it — the\n * same attribute `Tooltip redact` and the chart tooltip's value cell carry. */\n sensitive?: boolean;\n /** Skeleton in place of the value; delta, sub-values and trend are withheld. */\n loading?: boolean;\n /** `\"sm\"` for dense grids (a metrics wall); `\"md\"` the default KPI. */\n size?: \"sm\" | \"md\";\n /**\n * The tile's frame. `\"card\"` (default) is the bordered, shadowed card on the page.\n * `\"inset\"` is a tile INSIDE a card: {@link Card}'s `inset` — the raised\n * `--bg-surface-2`, a small radius, no border or shadow, since the card round it\n * already has them. `\"plain\"` drops the frame altogether — no fill and no padding —\n * for figures set straight into a card's content (a summary row under a card title),\n * where any box would be a box in a box. keksdose wrote both by hand over the card\n * tile (`border-0 shadow-none bg-transparent p-0`) for its tiles inside a card.\n */\n variant?: \"card\" | \"inset\" | \"plain\";\n /** Makes the tile a link. See {@link renderLink} for a router. */\n href?: string;\n /** Renders the link for `href` — pass your router's `<Link>` here, since a plain\n * `<a>` reloads a single-page app. Default: the `<UiKitProvider linkComponent>`\n * (for an in-app `href`), then `<a>`. */\n renderLink?: (props: StatTileLinkProps) => ReactElement;\n /** Makes the tile a button (ignored when `href` is given). */\n onClick?: () => void;\n labels?: Partial<StatTileLabels>;\n}\n\n// One formatter per option set: a metrics wall is twenty of these.\nconst formatters = new Map<string, Intl.NumberFormat>();\nfunction numberFormatter(locale: string | undefined, options: Intl.NumberFormatOptions): Intl.NumberFormat {\n const key = `${locale ?? \"\"}|${JSON.stringify(options)}`;\n let f = formatters.get(key);\n if (!f) {\n f = new Intl.NumberFormat(locale, options);\n formatters.set(key, f);\n }\n return f;\n}\n\n// The headline sizes are keyed on the TILE's width (it is a @container), not the\n// viewport: a grid beside a sidebar makes tiles narrowest exactly where a viewport\n// breakpoint would hand them the larger font. `sm` is keksdose's compact headline,\n// sized so a worst-case \"CHF 123,456.78\" still fits a 320px phone's 2-up tiles.\nconst VALUE_TEXT = {\n md: \"text-xl @[13rem]:text-2xl\",\n sm: \"text-xs @[8.5rem]:text-sm @[13rem]:text-base\",\n} as const;\nconst PADDING = { md: \"p-3 sm:p-4\", sm: \"px-2.5 py-2\" } as const;\n\n/**\n * The KPI card: a label, one number, and optionally how it moved, what it is made of\n * and which way it has been going.\n *\n * Replaces keksdose's `KpiCard` and admin `Tile`, lenkbank's metrics tiles and\n * kastlan's `KpiCard` — the same card four times, with four answers to the same\n * questions (how a currency is formatted, whether a delta is judged, what happens to\n * the figures in demo mode).\n *\n * Interactive tiles use a STRETCHED link: the label is the `<a>`/`<button>`, and its\n * `::after` covers the card. Making the card itself the link would nest the hint's\n * `<button>` inside it, which is invalid HTML and an unreachable control; this way\n * the hint sits above the overlay and stays its own tab stop. The link's name is the\n * label, and it is described by the value and the delta.\n */\nexport function StatTile({\n label,\n value,\n currency,\n compact = false,\n numberFormat,\n format,\n locale,\n unit,\n valueLabel,\n tone = \"neutral\",\n delta,\n goodDirection,\n hint,\n truncateLabel = false,\n name,\n description,\n projection,\n subValues,\n trend,\n sparkline,\n icon,\n footer,\n sensitive = false,\n loading = false,\n size = \"md\",\n variant = \"card\",\n href,\n renderLink,\n onClick,\n labels,\n className,\n ...rest\n}: StatTileProps) {\n const text = useKitLabels(\"statTile\", DEFAULT_STAT_TILE_LABELS, labels);\n // A loading StatTileGrid puts every tile in it into the loading state and says\n // \"Loading…\" ONCE for all of them; the tile then keeps its own sentence to itself\n // (see StatTileGrid's `loading`).\n const gridLoading = useContext(StatTileGridLoadingContext);\n loading = loading || gridLoading;\n const kitLink = useKitLink();\n const [labelEl, setLabelEl] = useState<HTMLElement | null>(null);\n const labelCut = useIsTruncated(truncateLabel ? labelEl : null);\n const kitLocale = useKitLocale(locale);\n const id = useId();\n const valueId = `${id}-value`;\n const deltaId = `${id}-delta`;\n const priv = sensitive ? \"\" : undefined;\n\n const fmt =\n format ??\n ((n: number) =>\n numberFormatter(kitLocale, {\n ...(currency ? { style: \"currency\", currency } : null),\n ...(compact ? { notation: \"compact\" } : null),\n ...numberFormat,\n }).format(n));\n const show = (v: ReactNode) => (typeof v === \"number\" ? fmt(v) : v);\n\n const d = typeof delta === \"number\" ? { value: delta } : delta;\n const hasValue = value !== null && value !== undefined && value !== \"\";\n const labelText = name ?? plainText(label);\n\n // ── The label, which is also the link/button when the tile is interactive ──\n const stretched = cn(\n \"text-start uppercase tracking-wide\",\n \"after:absolute after:inset-0 after:rounded-lg after:content-['']\",\n \"focus-visible:outline-none focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-[var(--brand)]\",\n );\n const describedBy = d ? `${valueId} ${deltaId}` : valueId;\n let labelNode: ReactNode = label;\n if (href !== undefined) {\n const linkProps: StatTileLinkProps = {\n href,\n className: stretched,\n \"aria-describedby\": describedBy,\n children: label,\n };\n const kit = pickLinkRenderer<StatTileLinkProps>(undefined, kitLink, href);\n labelNode = renderLink ? (\n renderLink(linkProps)\n ) : kit ? (\n <RenderedKitLink render={kit} props={linkProps} />\n ) : (\n <a href={href} className={stretched} aria-describedby={describedBy}>\n {label}\n </a>\n );\n } else if (onClick) {\n labelNode = (\n <button type=\"button\" onClick={onClick} aria-describedby={describedBy} className={stretched}>\n {label}\n </button>\n );\n }\n const interactive = href !== undefined || onClick !== undefined;\n\n // ── Delta ──\n let deltaNode: ReactNode = null;\n if (d && !loading && Number.isFinite(d.value)) {\n const magnitude = Math.abs(d.value);\n const amount =\n d.unit === \"percent\"\n ? numberFormatter(kitLocale, { style: \"percent\", maximumFractionDigits: 1 }).format(magnitude)\n : fmt(magnitude);\n const dir = d.value > 0 ? \"up\" : d.value < 0 ? \"down\" : \"flat\";\n const Icon = dir === \"up\" ? ArrowUp : dir === \"down\" ? ArrowDown : Minus;\n let spoken = dir === \"up\" ? text.increase(amount) : dir === \"down\" ? text.decrease(amount) : text.unchanged;\n let deltaTone = \"text-[var(--text-muted)]\";\n if (goodDirection && dir !== \"flat\") {\n const good = dir === goodDirection;\n spoken = good ? text.better(spoken) : text.worse(spoken);\n deltaTone = good ? \"text-[var(--success)]\" : \"text-[var(--danger)]\";\n }\n deltaNode = (\n // `relative`: the containing block for the sr-only sentence (see the\n // sr-only-containment test for what an escaped one does to the page).\n <div className=\"relative mt-1 flex flex-wrap items-center gap-x-1.5 text-xs tabular-nums\">\n <span id={deltaId} data-private={priv} className={cn(\"inline-flex items-center gap-0.5 font-medium\", deltaTone)}>\n <Icon className=\"size-3 shrink-0\" aria-hidden />\n {/* The figure at zero too, like Delta (kastlan 48): \"0 %\" says the change was\n measured; a bare dash reads like a missing value. */}\n <span aria-hidden>{amount}</span>\n <span className=\"sr-only\">{spoken}</span>\n </span>\n {d.label != null && <span className=\"text-[var(--text-muted)]\">{d.label}</span>}\n </div>\n );\n }\n\n // ── Headline ──\n const valueClass = cn(\n \"whitespace-nowrap font-semibold tabular-nums\",\n VALUE_TEXT[size],\n toneClass(tone, value),\n );\n const headline = loading ? (\n <span id={valueId} className=\"relative block py-0.5\">\n <span aria-hidden className={cn(SKELETON_CLASS, \"block h-6 w-24 max-w-full\")} />\n {!gridLoading && <span className=\"sr-only\">{text.loading}</span>}\n </span>\n ) : hasValue ? (\n <span id={valueId} data-private={priv} className={cn(valueClass, valueLabel != null && \"ms-auto\")}>\n {show(value)}\n {unit != null && (\n <span className=\"ms-1 text-[0.7em] font-medium text-[var(--text-muted)]\">{unit}</span>\n )}\n </span>\n ) : (\n <span id={valueId} className={cn(\"relative\", valueClass, \"text-[var(--text-muted)]\")}>\n <span aria-hidden>—</span>\n <span className=\"sr-only\">{text.noValue}</span>\n </span>\n );\n\n const graphic =\n loading ? null : sparkline ??\n (trend && (\n <Sparkline\n data={trend}\n fluid\n height={size === \"sm\" ? 20 : 28}\n label={labelText}\n formatValue={fmt}\n locale={kitLocale}\n tone={tone === \"signed\" ? \"signed\" : tone === \"neutral\" ? \"chart\" : tone}\n data-private={priv}\n />\n ));\n\n return (\n <Card\n {...rest}\n variant={variant === \"card\" ? \"default\" : \"inset\"}\n data-variant={variant === \"card\" ? undefined : variant}\n aria-busy={loading || undefined}\n className={cn(\n // @container: the headline sizes read the tile's width. relative: the stretched\n // link's overlay. overflow-hidden: at pathological widths a figure clips inside\n // the border instead of painting over the neighbouring tile.\n \"@container relative flex min-w-0 flex-col overflow-hidden\",\n // `plain` is the inset card with its fill and padding taken away — the figures\n // align with the content edge of the card they sit in. (Not `p-0` over the\n // padding: the padding's `sm:p-4` would still win from `sm` up.)\n variant === \"plain\" ? \"rounded-none bg-transparent p-0\" : PADDING[size],\n interactive && \"transition-colors hover:border-[var(--border-strong)] hover:bg-[var(--bg-hover)]\",\n className,\n )}\n >\n <div className=\"flex items-start gap-2\">\n <div className=\"flex min-w-0 flex-1 items-center gap-1 break-words text-xs uppercase tracking-wide text-[var(--text-muted)]\">\n {truncateLabel && labelCut ? (\n // Portalled: the tile is `overflow-hidden`, and a bubble inside it would be\n // clipped by the very box whose edge cut the label.\n <Tooltip label={label} side=\"top\" portal className=\"flex min-w-0\">\n <span ref={setLabelEl} className=\"block min-w-0 truncate\">\n {labelNode}\n </span>\n </Tooltip>\n ) : (\n <span ref={setLabelEl} className={cn(\"min-w-0\", truncateLabel && \"block truncate\")}>\n {labelNode}\n </span>\n )}\n {/* Above the stretched link's overlay, so it stays hoverable and focusable. */}\n {hint && <FieldHint label={hint} side=\"top\" className=\"relative z-10 shrink-0\" />}\n </div>\n {icon != null && (\n <span aria-hidden className=\"shrink-0 text-[var(--text-muted)] [&_svg]:size-4\">\n {icon}\n </span>\n )}\n </div>\n\n {valueLabel != null ? (\n // Period-left / value-right, matching the sub-rows below it. flex-wrap lets a\n // too-long amount drop to its own end-aligned line instead of overflowing.\n <div className=\"mt-1 flex flex-wrap items-baseline gap-x-1.5\">\n <span className=\"shrink-0 text-xs uppercase tracking-wide text-[var(--text-muted)]\">{valueLabel}</span>\n {headline}\n </div>\n ) : (\n <div className=\"mt-1\">{headline}</div>\n )}\n\n {!loading && projection && (\n <dl className=\"mt-0.5\">\n <FigureRow figure={projection} tileTone={tone} show={show} priv={priv} />\n </dl>\n )}\n\n {deltaNode}\n {description != null && <div className=\"mt-1 text-xs text-[var(--text-muted)]\">{description}</div>}\n {graphic && <div className=\"mt-2\">{graphic}</div>}\n\n {!loading && subValues && subValues.length > 0 && (\n <dl className=\"mt-1.5 space-y-0.5\">\n {subValues.map((sv, i) => (\n <FigureRow key={i} figure={sv} tileTone={tone} show={show} priv={priv} />\n ))}\n </dl>\n )}\n\n {footer != null && <div className=\"mt-2\">{footer}</div>}\n </Card>\n );\n}\n\n/** One label/value row of a `<dl>`: a sub-value, or the projection. */\nfunction FigureRow({\n figure,\n tileTone,\n show,\n priv,\n}: {\n figure: StatTileSubValue;\n tileTone: StatTileTone;\n show: (v: ReactNode) => ReactNode;\n priv: \"\" | undefined;\n}) {\n const own = figure.tone ?? (tileTone === \"neutral\" ? undefined : tileTone);\n const svTone = own === \"none\" ? undefined : own;\n // The LABEL gives way, never the figure. This row used to wrap, so on a narrow tile a\n // long label (\"AUG (SIGNED)\") dropped its amount onto a line of its own while the\n // next row stayed on one — two layouts in one list, and a figure no longer beside\n // the period it belongs to. Now the label breaks within itself and the amount stays\n // on the label's first line, end-aligned like every other row.\n return (\n <div className=\"flex items-baseline gap-x-2 text-xs tabular-nums text-[var(--text-muted)]\">\n <dt className=\"min-w-0 uppercase tracking-wide [overflow-wrap:anywhere]\">{figure.label}</dt>\n <dd\n data-private={priv}\n className={cn(\"ms-auto shrink-0 whitespace-nowrap\", svTone && [toneClass(svTone, figure.value), \"opacity-75\"])}\n >\n {show(figure.value)}\n </dd>\n </div>\n );\n}\n\n/**\n * The text of a label node, for the sparkline's name: a string or number as is, an\n * element by its children, recursively. A `<Tooltip label=\"…\">Spend</Tooltip>` label\n * yields \"Spend\" — the text the reader sees, not the bubble's. `undefined` when there\n * is no text to find (an icon), so the sparkline falls back to its unnamed summary.\n */\nfunction plainText(node: ReactNode): string | undefined {\n const walk = (n: ReactNode): string => {\n if (typeof n === \"string\" || typeof n === \"number\") return String(n);\n if (Array.isArray(n)) return n.map(walk).join(\"\");\n if (isValidElement<{ children?: ReactNode }>(n)) return walk(n.props.children);\n return \"\";\n };\n const text = walk(node).replace(/\\s+/g, \" \").trim();\n return text === \"\" ? undefined : text;\n}\n\n/**\n * Whether `el`'s text is wider than its box — i.e. whether `truncate` is cutting it.\n * Re-measured whenever the box resizes (a grid reflowing, a translation loading), not\n * only on mount. Keyed on the ELEMENT (a callback ref), because wrapping the label in\n * its tooltip remounts it, and an observer on the old node would watch nothing.\n */\nfunction useIsTruncated(el: HTMLElement | null): boolean {\n const [cut, setCut] = useState(false);\n useLayoutEffect(() => {\n // No reset while there is no node: between the unwrapped label unmounting and the\n // wrapped one mounting there is none, and a reset there would unwrap it again.\n if (!el) return;\n const measure = () => setCut(el.scrollWidth > el.clientWidth);\n measure();\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(measure);\n observer.observe(el);\n return () => observer.disconnect();\n }, [el]);\n return cut;\n}\n\nexport interface StatTileGridProps extends ComponentPropsWithoutRef<\"div\"> {\n /** The narrowest a tile may get before the grid drops a column. The default fits\n * two tiles on a 320px phone. */\n minTileWidth?: string;\n /**\n * Let a row that is not full stretch its tiles across the whole width. Default\n * `true` (CSS `auto-fit`): one or two tiles fill the row, as they always have.\n * `false` (`auto-fill`): the empty columns are kept, so every tile is the width of\n * a column whatever the count — a lone \"Balance\" tile in a card stays tile-sized\n * instead of becoming a banner the width of the card, and the tiles of a short row\n * line up with the columns of a full one above it.\n */\n stretch?: boolean;\n /**\n * Every tile in the grid is loading: each shows its skeleton (as with its own\n * `loading`), and the grid says \"Loading…\" ONCE, in a polite status region, instead\n * of each tile carrying its own sr-only \"Loading…\" — a wall of eight tiles was read\n * as eight \"Loading…\"s in a row. The grid is `aria-busy` meanwhile. A tile's own\n * `loading` inside a grid that is not loading still speaks for itself.\n */\n loading?: boolean;\n /** The grid's one sentence — `loading` from {@link StatTileLabels}. */\n labels?: Partial<Pick<StatTileLabels, \"loading\">>;\n}\n\n/** Set by a loading {@link StatTileGrid}; read by each tile in it. */\nconst StatTileGridLoadingContext = createContext(false);\n\n/**\n * The row of tiles every dashboard in the three apps lays out by hand, each with its\n * own breakpoint ladder (`grid-cols-2 md:grid-cols-4 min-[2400px]:grid-cols-8` …).\n * Those ladders read the VIEWPORT and so ignored the sidebar: 6-up tiles at 155px in\n * the band where the sidebar was open. This fits as many columns as `minTileWidth`\n * allows in the space the grid actually has, and needs no breakpoint at all.\n */\nexport function StatTileGrid({\n minTileWidth = \"9rem\",\n stretch = true,\n loading = false,\n labels,\n className,\n style,\n children,\n ...rest\n}: StatTileGridProps) {\n const text = useKitLabels(\"statTile\", DEFAULT_STAT_TILE_LABELS, labels);\n const columns: CSSProperties = {\n gridTemplateColumns: `repeat(${stretch ? \"auto-fit\" : \"auto-fill\"}, minmax(min(100%, ${minTileWidth}), 1fr))`,\n };\n return (\n <div\n {...rest}\n aria-busy={loading || rest[\"aria-busy\"] || undefined}\n // `relative`: the containing block for the sr-only status, which is absolutely\n // positioned and so also takes no grid cell.\n className={cn(\"relative grid gap-3\", className)}\n style={{ ...columns, ...style }}\n >\n {/* Always mounted, filled while loading: a live region announces a CHANGE of\n its content, so one that appeared already holding the sentence might say\n nothing. */}\n <span role=\"status\" className=\"sr-only\">\n {loading ? text.loading : \"\"}\n </span>\n <StatTileGridLoadingContext.Provider value={loading}>{children}</StatTileGridLoadingContext.Provider>\n </div>\n );\n}\n"],"mappings":";AAuWM,cAoCE,YApCF;AAvWN,SAAS,eAAe,gBAAgB,YAAY,OAAO,iBAAiB,gBAAgB;AAE5F,SAAS,WAAW,SAAS,aAAa;AAC1C,SAAS,UAAU;AACnB,SAAS,cAAc,YAAY,oBAAoB;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AAa;AAC3C,UAAM,WAAW,IAAI,eAAe,OAAO;AAC3C,aAAS,QAAQ,EAAE;AACnB,WAAO,MAAM,SAAS,WAAW;AAAA,EACnC,GAAG,CAAC,EAAE,CAAC;AACP,SAAO;AACT;AA4BA,MAAM,6BAA6B,cAAc,KAAK;AAS/C,SAAS,aAAa;AAAA,EAC3B,eAAe;AAAA,EACf,UAAU;AAAA,EACV,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAsB;AACpB,QAAM,OAAO,aAAa,YAAY,0BAA0B,MAAM;AACtE,QAAM,UAAyB;AAAA,IAC7B,qBAAqB,UAAU,UAAU,aAAa,WAAW,sBAAsB,YAAY;AAAA,EACrG;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,aAAW,WAAW,KAAK,WAAW,KAAK;AAAA,MAG3C,WAAW,GAAG,uBAAuB,SAAS;AAAA,MAC9C,OAAO,EAAE,GAAG,SAAS,GAAG,MAAM;AAAA,MAK9B;AAAA,4BAAC,UAAK,MAAK,UAAS,WAAU,WAC3B,oBAAU,KAAK,UAAU,IAC5B;AAAA,QACA,oBAAC,2BAA2B,UAA3B,EAAoC,OAAO,SAAU,UAAS;AAAA;AAAA;AAAA,EACjE;AAEJ;","names":[]}
@@ -16,6 +16,9 @@ type StatusDotTone = ProgressBarTone | ChipHue;
16
16
  /** `sm` 8px (keksdose's unread dot on the support trigger), `md` 10px (the avatar's
17
17
  * unread dot), `lg` 12px (kastlan's occupancy legend swatch). */
18
18
  type StatusDotSize = "sm" | "md" | "lg";
19
+ /** The CSS colour a {@link StatusDot} of `tone` is filled with — `statusDotColor("teal")`
20
+ * is `"var(--hue-teal)"`. See the table above for when to reach for it. */
21
+ declare function statusDotColor(tone: StatusDotTone): string;
19
22
  interface StatusDotProps extends Omit<ComponentPropsWithoutRef<"span">, "children"> {
20
23
  tone?: StatusDotTone;
21
24
  size?: StatusDotSize;
@@ -50,4 +53,4 @@ interface StatusDotProps extends Omit<ComponentPropsWithoutRef<"span">, "childre
50
53
  */
51
54
  declare function StatusDot({ tone, size, label, ring, className, dotClassName, "aria-label": ariaLabel, ...rest }: StatusDotProps): react.JSX.Element;
52
55
 
53
- export { StatusDot, type StatusDotProps, type StatusDotSize, type StatusDotTone };
56
+ export { StatusDot, type StatusDotProps, type StatusDotSize, type StatusDotTone, statusDotColor };
@@ -16,6 +16,24 @@ const FILL = {
16
16
  teal: "bg-[var(--hue-teal)]",
17
17
  orange: "bg-[var(--hue-orange)]"
18
18
  };
19
+ const COLOR = {
20
+ brand: "var(--brand)",
21
+ neutral: "var(--text-muted)",
22
+ success: "var(--success)",
23
+ warning: "var(--warning)",
24
+ danger: "var(--danger)",
25
+ info: "var(--info)",
26
+ income: "var(--money-income)",
27
+ expense: "var(--money-expense)",
28
+ blue: "var(--hue-blue)",
29
+ indigo: "var(--hue-indigo)",
30
+ purple: "var(--hue-purple)",
31
+ teal: "var(--hue-teal)",
32
+ orange: "var(--hue-orange)"
33
+ };
34
+ function statusDotColor(tone) {
35
+ return COLOR[tone];
36
+ }
19
37
  const SIZE = { sm: "size-2", md: "size-2.5", lg: "size-3" };
20
38
  function StatusDot({
21
39
  tone = "neutral",
@@ -52,6 +70,7 @@ function StatusDot({
52
70
  );
53
71
  }
54
72
  export {
55
- StatusDot
73
+ StatusDot,
74
+ statusDotColor
56
75
  };
57
76
  //# sourceMappingURL=status-dot.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/status-dot.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport type { ProgressBarTone } from \"./progress-bar\";\nimport type { ChipHue } from \"./chip\";\n\n/**\n * The tones are `ProgressBar`'s, name for name — which are `Chip`'s, less nothing — so a\n * dot in a legend, the bar it explains and the badge beside it can be given the same\n * word and agree. The money pair is here for the same reason it is there: a legend\n * swatch for income is money, not \"success\". Chip's categorical hues are here too\n * (0.11): a unit-status dot in a combobox (kastlan lease-unit-step.tsx:35, \"rented\"\n * is blue) must match the Chip that states the same status elsewhere.\n */\nexport type StatusDotTone = ProgressBarTone | ChipHue;\n\n/** `sm` 8px (keksdose's unread dot on the support trigger), `md` 10px (the avatar's\n * unread dot), `lg` 12px (kastlan's occupancy legend swatch). */\nexport type StatusDotSize = \"sm\" | \"md\" | \"lg\";\n\nconst FILL: Record<StatusDotTone, string> = {\n brand: \"bg-[var(--brand)]\",\n neutral: \"bg-[var(--text-muted)]\",\n success: \"bg-[var(--success)]\",\n warning: \"bg-[var(--warning)]\",\n danger: \"bg-[var(--danger)]\",\n info: \"bg-[var(--info)]\",\n income: \"bg-[var(--money-income)]\",\n expense: \"bg-[var(--money-expense)]\",\n blue: \"bg-[var(--hue-blue)]\",\n indigo: \"bg-[var(--hue-indigo)]\",\n purple: \"bg-[var(--hue-purple)]\",\n teal: \"bg-[var(--hue-teal)]\",\n orange: \"bg-[var(--hue-orange)]\",\n};\n\nconst SIZE: Record<StatusDotSize, string> = { sm: \"size-2\", md: \"size-2.5\", lg: \"size-3\" };\n\nexport interface StatusDotProps extends Omit<ComponentPropsWithoutRef<\"span\">, \"children\"> {\n tone?: StatusDotTone;\n size?: StatusDotSize;\n /**\n * Visible text beside the dot — a legend entry (\"Rented\") or a status (\"Online\"). It\n * is also what a screen reader reads: the dot itself is decorative whenever there is\n * a label.\n *\n * Without a label the dot is hidden from assistive technology, because a coloured\n * circle says nothing to someone who cannot see it. Say the state where it IS read —\n * keksdose's avatar trigger puts \"3 unread\" in its own `aria-label` — or give the dot\n * an `aria-label` of its own, which makes it an image with that name.\n */\n label?: ReactNode;\n /**\n * A ring in the surface colour round the dot, so a dot laid over the corner of an\n * icon or an avatar reads as a separate mark and not a smudge (keksdose top-bar.tsx\n * :152, account-menu.tsx ~385, both hand-drawing `ring-2 ring-white\n * dark:ring-slate-900`). Position it with `className` (`absolute -end-0.5 -top-0.5`).\n */\n ring?: boolean;\n /** Extra classes for the dot itself; `className` goes on the outer element. */\n dotClassName?: string;\n}\n\n/**\n * A small token-coloured dot, with an optional label.\n *\n * kastlan's reporting dashboard (dashboard-tab.tsx:79) paints its occupancy legend\n * with raw `bg-green-500` / `bg-red-500` / `bg-yellow-500`, which ignores the palette\n * and the dark theme; keksdose draws two unread dots by hand in `rose-500`. Both are\n * this.\n */\nexport function StatusDot({\n tone = \"neutral\",\n size = \"sm\",\n label,\n ring = false,\n className,\n dotClassName,\n \"aria-label\": ariaLabel,\n ...rest\n}: StatusDotProps) {\n const dot = (\n <span\n className={cn(\n \"inline-block shrink-0 rounded-full\",\n SIZE[size],\n FILL[tone],\n ring && \"ring-2 ring-[var(--bg-surface)]\",\n label == null && className,\n dotClassName,\n )}\n {...(label == null\n ? ariaLabel\n ? { role: \"img\", \"aria-label\": ariaLabel, ...rest }\n : { \"aria-hidden\": true, ...rest }\n : { \"aria-hidden\": true })}\n />\n );\n if (label == null) return dot;\n return (\n // No `aria-label` here: the visible label is the text, and a name on a role-less\n // span is one ARIA forbids and screen readers ignore.\n <span {...rest} className={cn(\"inline-flex min-w-0 items-center gap-1.5 text-sm\", className)}>\n {dot}\n <span className=\"min-w-0 truncate\">{label}</span>\n </span>\n );\n}\n"],"mappings":";AAiFI,cAoBA,YApBA;AAhFJ,SAAS,UAAU;AAkBnB,MAAM,OAAsC;AAAA,EAC1C,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AACV;AAEA,MAAM,OAAsC,EAAE,IAAI,UAAU,IAAI,YAAY,IAAI,SAAS;AAmClF,SAAS,UAAU;AAAA,EACxB,OAAO;AAAA,EACP,OAAO;AAAA,EACP;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,GAAG;AACL,GAAmB;AACjB,QAAM,MACJ;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,KAAK,IAAI;AAAA,QACT,KAAK,IAAI;AAAA,QACT,QAAQ;AAAA,QACR,SAAS,QAAQ;AAAA,QACjB;AAAA,MACF;AAAA,MACC,GAAI,SAAS,OACV,YACE,EAAE,MAAM,OAAO,cAAc,WAAW,GAAG,KAAK,IAChD,EAAE,eAAe,MAAM,GAAG,KAAK,IACjC,EAAE,eAAe,KAAK;AAAA;AAAA,EAC5B;AAEF,MAAI,SAAS,KAAM,QAAO;AAC1B;AAAA;AAAA;AAAA,IAGE,qBAAC,UAAM,GAAG,MAAM,WAAW,GAAG,oDAAoD,SAAS,GACxF;AAAA;AAAA,MACD,oBAAC,UAAK,WAAU,oBAAoB,iBAAM;AAAA,OAC5C;AAAA;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/status-dot.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport type { ProgressBarTone } from \"./progress-bar\";\nimport type { ChipHue } from \"./chip\";\n\n/**\n * The tones are `ProgressBar`'s, name for name — which are `Chip`'s, less nothing — so a\n * dot in a legend, the bar it explains and the badge beside it can be given the same\n * word and agree. The money pair is here for the same reason it is there: a legend\n * swatch for income is money, not \"success\". Chip's categorical hues are here too\n * (0.11): a unit-status dot in a combobox (kastlan lease-unit-step.tsx:35, \"rented\"\n * is blue) must match the Chip that states the same status elsewhere.\n */\nexport type StatusDotTone = ProgressBarTone | ChipHue;\n\n/** `sm` 8px (keksdose's unread dot on the support trigger), `md` 10px (the avatar's\n * unread dot), `lg` 12px (kastlan's occupancy legend swatch). */\nexport type StatusDotSize = \"sm\" | \"md\" | \"lg\";\n\nconst FILL: Record<StatusDotTone, string> = {\n brand: \"bg-[var(--brand)]\",\n neutral: \"bg-[var(--text-muted)]\",\n success: \"bg-[var(--success)]\",\n warning: \"bg-[var(--warning)]\",\n danger: \"bg-[var(--danger)]\",\n info: \"bg-[var(--info)]\",\n income: \"bg-[var(--money-income)]\",\n expense: \"bg-[var(--money-expense)]\",\n blue: \"bg-[var(--hue-blue)]\",\n indigo: \"bg-[var(--hue-indigo)]\",\n purple: \"bg-[var(--hue-purple)]\",\n teal: \"bg-[var(--hue-teal)]\",\n orange: \"bg-[var(--hue-orange)]\",\n};\n\n/**\n * The colour of each tone as a CSS value — the same `var(--…)` the dot's class paints\n * with. For a mark the kit does not draw: a `SwatchPicker` option (`color`), a chart\n * series, an inline `style`. keksdose's category picker spelled `var(--hue-teal)` out by\n * hand to match the dot beside the category name; a renamed token would have parted\n * them silently. (The class table above stays literal: Tailwind finds classes by\n * reading the source, so `bg-[${…}]` would never be generated. A test keeps the two\n * tables agreeing.)\n */\nconst COLOR: Record<StatusDotTone, string> = {\n brand: \"var(--brand)\",\n neutral: \"var(--text-muted)\",\n success: \"var(--success)\",\n warning: \"var(--warning)\",\n danger: \"var(--danger)\",\n info: \"var(--info)\",\n income: \"var(--money-income)\",\n expense: \"var(--money-expense)\",\n blue: \"var(--hue-blue)\",\n indigo: \"var(--hue-indigo)\",\n purple: \"var(--hue-purple)\",\n teal: \"var(--hue-teal)\",\n orange: \"var(--hue-orange)\",\n};\n\n/** The CSS colour a {@link StatusDot} of `tone` is filled with — `statusDotColor(\"teal\")`\n * is `\"var(--hue-teal)\"`. See the table above for when to reach for it. */\nexport function statusDotColor(tone: StatusDotTone): string {\n return COLOR[tone];\n}\n\nconst SIZE: Record<StatusDotSize, string> = { sm: \"size-2\", md: \"size-2.5\", lg: \"size-3\" };\n\nexport interface StatusDotProps extends Omit<ComponentPropsWithoutRef<\"span\">, \"children\"> {\n tone?: StatusDotTone;\n size?: StatusDotSize;\n /**\n * Visible text beside the dot — a legend entry (\"Rented\") or a status (\"Online\"). It\n * is also what a screen reader reads: the dot itself is decorative whenever there is\n * a label.\n *\n * Without a label the dot is hidden from assistive technology, because a coloured\n * circle says nothing to someone who cannot see it. Say the state where it IS read —\n * keksdose's avatar trigger puts \"3 unread\" in its own `aria-label` — or give the dot\n * an `aria-label` of its own, which makes it an image with that name.\n */\n label?: ReactNode;\n /**\n * A ring in the surface colour round the dot, so a dot laid over the corner of an\n * icon or an avatar reads as a separate mark and not a smudge (keksdose top-bar.tsx\n * :152, account-menu.tsx ~385, both hand-drawing `ring-2 ring-white\n * dark:ring-slate-900`). Position it with `className` (`absolute -end-0.5 -top-0.5`).\n */\n ring?: boolean;\n /** Extra classes for the dot itself; `className` goes on the outer element. */\n dotClassName?: string;\n}\n\n/**\n * A small token-coloured dot, with an optional label.\n *\n * kastlan's reporting dashboard (dashboard-tab.tsx:79) paints its occupancy legend\n * with raw `bg-green-500` / `bg-red-500` / `bg-yellow-500`, which ignores the palette\n * and the dark theme; keksdose draws two unread dots by hand in `rose-500`. Both are\n * this.\n */\nexport function StatusDot({\n tone = \"neutral\",\n size = \"sm\",\n label,\n ring = false,\n className,\n dotClassName,\n \"aria-label\": ariaLabel,\n ...rest\n}: StatusDotProps) {\n const dot = (\n <span\n className={cn(\n \"inline-block shrink-0 rounded-full\",\n SIZE[size],\n FILL[tone],\n ring && \"ring-2 ring-[var(--bg-surface)]\",\n label == null && className,\n dotClassName,\n )}\n {...(label == null\n ? ariaLabel\n ? { role: \"img\", \"aria-label\": ariaLabel, ...rest }\n : { \"aria-hidden\": true, ...rest }\n : { \"aria-hidden\": true })}\n />\n );\n if (label == null) return dot;\n return (\n // No `aria-label` here: the visible label is the text, and a name on a role-less\n // span is one ARIA forbids and screen readers ignore.\n <span {...rest} className={cn(\"inline-flex min-w-0 items-center gap-1.5 text-sm\", className)}>\n {dot}\n <span className=\"min-w-0 truncate\">{label}</span>\n </span>\n );\n}\n"],"mappings":";AAgHI,cAoBA,YApBA;AA/GJ,SAAS,UAAU;AAkBnB,MAAM,OAAsC;AAAA,EAC1C,OAAO;AAAA,EACP,SAAS;AAAA,EACT,S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[]}
@@ -13,7 +13,9 @@ interface SwatchOption<T extends string> {
13
13
  value: T;
14
14
  /** Any CSS colour — a token (`var(--chart-3)`), a hex, an `oklch()`. Painted as an
15
15
  * inline background, so it does not have to be a class the kit's CSS knows.
16
- * Leave it out when `swatchClassName` paints the dot instead. */
16
+ * Leave it out when `swatchClassName` paints the dot instead. For a colour that
17
+ * must match a `StatusDot` / `Chip` hue elsewhere, `statusDotColor("teal")` rather
18
+ * than `"var(--hue-teal)"` written out — one table, so the two cannot drift. */
17
19
  color?: string;
18
20
  /** The colour's name, in the user's language. Shown in the bubble and read out;
19
21
  * required, because a swatch with no name is a colour only some people can read. */