@eifi1/ui-kit 0.52.0 → 0.54.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 (290) hide show
  1. package/README.md +52 -59
  2. package/dist/account/delete-account-setting.d.ts +3 -2
  3. package/dist/account/delete-account-setting.js.map +1 -1
  4. package/dist/auth/auth-errors.d.ts +36 -0
  5. package/dist/auth/auth-errors.js +20 -0
  6. package/dist/auth/auth-errors.js.map +1 -1
  7. package/dist/billing/cancel-subscription.d.ts +5 -14
  8. package/dist/billing/cancel-subscription.js +1 -3
  9. package/dist/billing/cancel-subscription.js.map +1 -1
  10. package/dist/billing/plan-card.d.ts +5 -13
  11. package/dist/billing/plan-card.js +3 -11
  12. package/dist/billing/plan-card.js.map +1 -1
  13. package/dist/billing/plan-switch.d.ts +5 -14
  14. package/dist/billing/plan-switch.js +1 -3
  15. package/dist/billing/plan-switch.js.map +1 -1
  16. package/dist/chart.d.ts +3 -14
  17. package/dist/chart.js +64 -11
  18. package/dist/chart.js.map +1 -1
  19. package/dist/components/amount-input.d.ts +2 -1
  20. package/dist/components/amount-input.js.map +1 -1
  21. package/dist/components/calendar-heatmap.js +4 -2
  22. package/dist/components/calendar-heatmap.js.map +1 -1
  23. package/dist/components/currency-option-list.d.ts +2 -1
  24. package/dist/components/currency-option-list.js +10 -3
  25. package/dist/components/currency-option-list.js.map +1 -1
  26. package/dist/components/currency-select.d.ts +3 -1
  27. package/dist/components/currency-select.js.map +1 -1
  28. package/dist/components/danger-confirm.d.ts +22 -1
  29. package/dist/components/danger-confirm.js +50 -28
  30. package/dist/components/danger-confirm.js.map +1 -1
  31. package/dist/components/data-table-filter-popover.d.ts +2 -1
  32. package/dist/components/data-table-filter-popover.js +3 -2
  33. package/dist/components/data-table-filter-popover.js.map +1 -1
  34. package/dist/components/data-table-filters.d.ts +33 -3
  35. package/dist/components/data-table-filters.js +6 -4
  36. package/dist/components/data-table-filters.js.map +1 -1
  37. package/dist/components/date-field.d.ts +1 -1
  38. package/dist/components/date-field.js.map +1 -1
  39. package/dist/components/date-picker.d.ts +1 -1
  40. package/dist/components/date-picker.js.map +1 -1
  41. package/dist/components/date-range-picker.d.ts +4 -17
  42. package/dist/components/date-range-picker.js +2 -2
  43. package/dist/components/date-range-picker.js.map +1 -1
  44. package/dist/components/dialog-frame.d.ts +3 -1
  45. package/dist/components/dialog-frame.js +6 -2
  46. package/dist/components/dialog-frame.js.map +1 -1
  47. package/dist/components/mini-calendar.js +3 -2
  48. package/dist/components/mini-calendar.js.map +1 -1
  49. package/dist/components/modal.d.ts +27 -0
  50. package/dist/components/modal.js +5 -3
  51. package/dist/components/modal.js.map +1 -1
  52. package/dist/components/nav-pills.d.ts +1 -1
  53. package/dist/components/nav-pills.js.map +1 -1
  54. package/dist/components/number-input.js.map +1 -1
  55. package/dist/components/series-chart-axes.d.ts +1 -1
  56. package/dist/components/series-chart-axes.js.map +1 -1
  57. package/dist/components/series-chart.d.ts +64 -19
  58. package/dist/components/series-chart.js +2 -1
  59. package/dist/components/series-chart.js.map +1 -1
  60. package/dist/components/stat-tile.d.ts +21 -2
  61. package/dist/components/stat-tile.js +4 -2
  62. package/dist/components/stat-tile.js.map +1 -1
  63. package/dist/components/treemap-labels.d.ts +6 -1
  64. package/dist/components/treemap-labels.js +2 -2
  65. package/dist/components/treemap-labels.js.map +1 -1
  66. package/dist/components/treemap.d.ts +29 -4
  67. package/dist/components/treemap.js +22 -9
  68. package/dist/components/treemap.js.map +1 -1
  69. package/dist/currencies.d.ts +16 -2
  70. package/dist/currencies.js +2 -1
  71. package/dist/currencies.js.map +1 -1
  72. package/dist/data-table.d.ts +1 -6
  73. package/dist/data-table.js +1 -9
  74. package/dist/data-table.js.map +1 -1
  75. package/dist/demo/demo-countdown.d.ts +0 -5
  76. package/dist/demo/demo-countdown.js +0 -4
  77. package/dist/demo/demo-countdown.js.map +1 -1
  78. package/dist/eslint/index.js +1 -1
  79. package/dist/feedback/feedback-context-labels.js +2 -1
  80. package/dist/feedback/feedback-context-labels.js.map +1 -1
  81. package/dist/feedback/feedback-context.d.ts +19 -3
  82. package/dist/feedback/feedback-context.js +12 -1
  83. package/dist/feedback/feedback-context.js.map +1 -1
  84. package/dist/feedback/feedback-diagnostics.d.ts +17 -0
  85. package/dist/feedback/feedback-diagnostics.js +27 -0
  86. package/dist/feedback/feedback-diagnostics.js.map +1 -0
  87. package/dist/feedback/feedback-dialog.d.ts +10 -0
  88. package/dist/feedback/feedback-dialog.js +6 -4
  89. package/dist/feedback/feedback-dialog.js.map +1 -1
  90. package/dist/feedback/feedback-mutation.d.ts +11 -23
  91. package/dist/feedback/feedback-mutation.js +1 -9
  92. package/dist/feedback/feedback-mutation.js.map +1 -1
  93. package/dist/feedback/feedback-public-list.d.ts +1 -6
  94. package/dist/feedback/feedback-public-list.js +1 -2
  95. package/dist/feedback/feedback-public-list.js.map +1 -1
  96. package/dist/feedback/feedback-record.d.ts +5 -0
  97. package/dist/feedback/feedback-record.js.map +1 -1
  98. package/dist/feedback/feedback-row-detail-labels.js +1 -8
  99. package/dist/feedback/feedback-row-detail-labels.js.map +1 -1
  100. package/dist/feedback/feedback-row-detail.d.ts +6 -50
  101. package/dist/feedback/feedback-row-detail.js +3 -8
  102. package/dist/feedback/feedback-row-detail.js.map +1 -1
  103. package/dist/feedback/feedback-status-undo.d.ts +3 -19
  104. package/dist/feedback/feedback-status-undo.js.map +1 -1
  105. package/dist/feedback/feedback-submit-dialog.d.ts +5 -1
  106. package/dist/feedback/feedback-submit-dialog.js +15 -3
  107. package/dist/feedback/feedback-submit-dialog.js.map +1 -1
  108. package/dist/feedback/feedback-submit.d.ts +30 -2
  109. package/dist/feedback/feedback-submit.js +5 -2
  110. package/dist/feedback/feedback-submit.js.map +1 -1
  111. package/dist/feedback/feedback-thread.d.ts +0 -9
  112. package/dist/feedback/feedback-thread.js.map +1 -1
  113. package/dist/feedback.d.ts +6 -40
  114. package/dist/feedback.js +88 -46
  115. package/dist/feedback.js.map +1 -1
  116. package/dist/hooks/use-hotkey.js +11 -1
  117. package/dist/hooks/use-hotkey.js.map +1 -1
  118. package/dist/i18n/defaults.js +0 -4
  119. package/dist/i18n/defaults.js.map +1 -1
  120. package/dist/i18n/german.js +5 -20
  121. package/dist/i18n/german.js.map +1 -1
  122. package/dist/i18n/kit-labels.d.ts +5 -14
  123. package/dist/i18n/kit-labels.js.map +1 -1
  124. package/dist/i18n/locales/en.js +5 -31
  125. package/dist/i18n/locales/en.js.map +3 -3
  126. package/dist/i18n/locales/es.js +5 -20
  127. package/dist/i18n/locales/es.js.map +1 -1
  128. package/dist/i18n/locales/fr.js +5 -20
  129. package/dist/i18n/locales/fr.js.map +1 -1
  130. package/dist/i18n/locales/hu.js +5 -20
  131. package/dist/i18n/locales/hu.js.map +1 -1
  132. package/dist/i18n/locales/it.js +5 -21
  133. package/dist/i18n/locales/it.js.map +1 -1
  134. package/dist/i18n/locales/zh.js +5 -20
  135. package/dist/i18n/locales/zh.js.map +1 -1
  136. package/dist/i18n/review.js +9 -4
  137. package/dist/i18n/review.js.map +1 -1
  138. package/dist/i18n/shared-labels.js +0 -1
  139. package/dist/i18n/shared-labels.js.map +1 -1
  140. package/dist/index.d.ts +18 -67
  141. package/dist/index.js +28 -103
  142. package/dist/index.js.map +1 -1
  143. package/dist/lib/dates.d.ts +7 -1
  144. package/dist/lib/dates.js +8 -1
  145. package/dist/lib/dates.js.map +1 -1
  146. package/dist/lib/format.d.ts +37 -2
  147. package/dist/lib/format.js +25 -1
  148. package/dist/lib/format.js.map +1 -1
  149. package/dist/lib/intl-cache.d.ts +4 -2
  150. package/dist/lib/intl-cache.js.map +1 -1
  151. package/dist/lib/translation-review.d.ts +26 -0
  152. package/dist/lib/translation-review.js +14 -0
  153. package/dist/lib/translation-review.js.map +1 -1
  154. package/dist/rhf/fields.d.ts +2 -2
  155. package/dist/rhf/fields.js.map +1 -1
  156. package/dist/search/search-index.d.ts +0 -6
  157. package/dist/search/search-index.js +0 -4
  158. package/dist/search/search-index.js.map +1 -1
  159. package/dist/search.d.ts +1 -8
  160. package/dist/search.js +2 -7
  161. package/dist/search.js.map +1 -1
  162. package/dist/shell/account-menu-language.d.ts +7 -21
  163. package/dist/shell/account-menu-language.js +1 -3
  164. package/dist/shell/account-menu-language.js.map +1 -1
  165. package/dist/shell/account-menu-text-size.d.ts +9 -23
  166. package/dist/shell/account-menu-text-size.js +2 -3
  167. package/dist/shell/account-menu-text-size.js.map +1 -1
  168. package/dist/shell/app-shell.d.ts +0 -10
  169. package/dist/shell/app-shell.js +1 -7
  170. package/dist/shell/app-shell.js.map +1 -1
  171. package/dist/shell/company-switcher.d.ts +1 -1
  172. package/dist/shell/company-switcher.js.map +1 -1
  173. package/dist/shell/dev-menu.d.ts +1 -1
  174. package/dist/shell/dev-menu.js.map +1 -1
  175. package/dist/shell/top-bar-parts-labels.d.ts +1 -1
  176. package/dist/shell/top-bar-parts-labels.js.map +1 -1
  177. package/dist/shell.d.ts +7 -29
  178. package/dist/shell.js +12 -42
  179. package/dist/shell.js.map +1 -1
  180. package/dist/sync.d.ts +2 -6
  181. package/dist/sync.js +2 -15
  182. package/dist/sync.js.map +1 -1
  183. package/dist/theme/chart-palette.d.ts +0 -5
  184. package/dist/theme/chart-palette.js +0 -2
  185. package/dist/theme/chart-palette.js.map +1 -1
  186. package/package.json +1 -1
  187. package/src/account/delete-account-setting.tsx +3 -2
  188. package/src/auth/auth-errors.ts +69 -0
  189. package/src/billing/cancel-subscription.tsx +5 -16
  190. package/src/billing/plan-card.tsx +7 -24
  191. package/src/billing/plan-switch.tsx +5 -16
  192. package/src/chart.ts +62 -13
  193. package/src/components/amount-input.tsx +2 -1
  194. package/src/components/calendar-heatmap.tsx +8 -2
  195. package/src/components/currency-option-list.tsx +12 -4
  196. package/src/components/currency-select.tsx +3 -1
  197. package/src/components/danger-confirm.tsx +80 -27
  198. package/src/components/data-table-filter-popover.tsx +19 -11
  199. package/src/components/data-table-filters.ts +36 -8
  200. package/src/components/date-field.tsx +1 -1
  201. package/src/components/date-picker.tsx +0 -1
  202. package/src/components/date-range-picker.tsx +6 -22
  203. package/src/components/dialog-frame.tsx +12 -4
  204. package/src/components/mini-calendar.tsx +5 -2
  205. package/src/components/modal.tsx +36 -7
  206. package/src/components/nav-pills.tsx +1 -1
  207. package/src/components/number-input.tsx +4 -3
  208. package/src/components/series-chart-axes.ts +6 -1
  209. package/src/components/series-chart.tsx +78 -21
  210. package/src/components/stat-tile.tsx +32 -3
  211. package/src/components/treemap-labels.ts +11 -3
  212. package/src/components/treemap.tsx +65 -12
  213. package/src/currencies.ts +23 -3
  214. package/src/data-table.ts +1 -11
  215. package/src/demo/demo-countdown.ts +3 -8
  216. package/src/feedback/feedback-context-labels.ts +1 -0
  217. package/src/feedback/feedback-context.tsx +34 -2
  218. package/src/feedback/feedback-diagnostics.tsx +41 -0
  219. package/src/feedback/feedback-dialog.tsx +16 -4
  220. package/src/feedback/feedback-mutation.ts +12 -33
  221. package/src/feedback/feedback-public-list.tsx +1 -7
  222. package/src/feedback/feedback-record.ts +5 -0
  223. package/src/feedback/feedback-row-detail-labels.ts +1 -8
  224. package/src/feedback/feedback-row-detail.tsx +21 -58
  225. package/src/feedback/feedback-status-undo.ts +4 -18
  226. package/src/feedback/feedback-submit-dialog.tsx +15 -2
  227. package/src/feedback/feedback-submit.tsx +36 -3
  228. package/src/feedback/feedback-thread.tsx +0 -10
  229. package/src/feedback.ts +89 -48
  230. package/src/hooks/use-hotkey.ts +24 -1
  231. package/src/i18n/defaults.ts +0 -4
  232. package/src/i18n/german.ts +4 -19
  233. package/src/i18n/kit-labels.tsx +5 -14
  234. package/src/i18n/locales/es.ts +4 -19
  235. package/src/i18n/locales/fr.ts +4 -19
  236. package/src/i18n/locales/hu.ts +4 -19
  237. package/src/i18n/locales/it.ts +4 -20
  238. package/src/i18n/locales/zh.ts +4 -19
  239. package/src/i18n/review.ts +9 -4
  240. package/src/i18n/shared-labels.ts +0 -1
  241. package/src/index.ts +44 -114
  242. package/src/lib/dates.ts +24 -2
  243. package/src/lib/format.ts +66 -3
  244. package/src/lib/intl-cache.ts +4 -2
  245. package/src/lib/translation-review.ts +52 -0
  246. package/src/rhf/fields.tsx +2 -2
  247. package/src/search/search-index.ts +0 -15
  248. package/src/search.ts +8 -8
  249. package/src/shell/account-menu-language.tsx +7 -27
  250. package/src/shell/account-menu-text-size.tsx +13 -32
  251. package/src/shell/app-shell.tsx +0 -13
  252. package/src/shell/company-switcher.tsx +1 -1
  253. package/src/shell/dev-menu.tsx +1 -1
  254. package/src/shell/top-bar-parts-labels.ts +1 -1
  255. package/src/shell.ts +17 -44
  256. package/src/sync.ts +2 -15
  257. package/src/theme/chart-palette.ts +0 -2
  258. package/tokens.css +4 -4
  259. package/dist/billing/dialog-close.d.ts +0 -29
  260. package/dist/billing/dialog-close.js +0 -8
  261. package/dist/billing/dialog-close.js.map +0 -1
  262. package/dist/components/field-sync-labels.d.ts +0 -3
  263. package/dist/components/field-sync-labels.js +0 -12
  264. package/dist/components/field-sync-labels.js.map +0 -1
  265. package/dist/components/field-sync.d.ts +0 -186
  266. package/dist/components/field-sync.js +0 -269
  267. package/dist/components/field-sync.js.map +0 -1
  268. package/dist/components/section-nav.d.ts +0 -44
  269. package/dist/components/section-nav.js +0 -33
  270. package/dist/components/section-nav.js.map +0 -1
  271. package/dist/components/sign-chip-labels.d.ts +0 -3
  272. package/dist/components/sign-chip-labels.js +0 -11
  273. package/dist/components/sign-chip-labels.js.map +0 -1
  274. package/dist/components/sign-chip.d.ts +0 -77
  275. package/dist/components/sign-chip.js +0 -47
  276. package/dist/components/sign-chip.js.map +0 -1
  277. package/dist/lib/isin.d.ts +0 -38
  278. package/dist/lib/isin.js +0 -36
  279. package/dist/lib/isin.js.map +0 -1
  280. package/dist/shell/role-switcher.d.ts +0 -28
  281. package/dist/shell/role-switcher.js +0 -31
  282. package/dist/shell/role-switcher.js.map +0 -1
  283. package/src/billing/dialog-close.ts +0 -34
  284. package/src/components/field-sync-labels.ts +0 -14
  285. package/src/components/field-sync.tsx +0 -504
  286. package/src/components/section-nav.tsx +0 -72
  287. package/src/components/sign-chip-labels.ts +0 -13
  288. package/src/components/sign-chip.tsx +0 -133
  289. package/src/lib/isin.ts +0 -72
  290. package/src/shell/role-switcher.tsx +0 -53
@@ -186,8 +186,27 @@ export interface StatTileProps extends Omit<ComponentPropsWithRef<"div">, "child
186
186
  /** Anything below the rest — a progress bar, a link row. */
187
187
  footer?: ReactNode;
188
188
  /** Tag every figure `data-private`, so the host's demo-mode rule blurs it — the
189
- * same attribute `Tooltip redact` and the chart tooltip's value cell carry. */
189
+ * same attribute `Tooltip redact` and the chart tooltip's value cell carry.
190
+ * The figures are the tile's own: value, delta, projection, sub-values and the
191
+ * trend. The `description` and `footer` are the app's nodes and stay readable;
192
+ * see {@link StatTileProps.descriptionSensitive} for the ones that carry an amount. */
190
193
  sensitive?: boolean;
194
+ /**
195
+ * Tag the `description` line `data-private` too, as `sensitive` tags the figures.
196
+ * For a description that names an amount: keksdose's tax reserve tile states its
197
+ * basis there ("…applied to €42,000"), and its report KpiCard puts a `hintSensitive`
198
+ * hint there — both tag their own `<span data-private>` today
199
+ * (reports/tabs/tax-tab.tsx, reports/charts/kpi-card.tsx). Separate from
200
+ * `sensitive`, so a description of words ("Last 12 months") on a money tile stays
201
+ * readable in demo mode. keksdose audit follow-up, 2026-11-01.
202
+ */
203
+ descriptionSensitive?: boolean;
204
+ /**
205
+ * Tag the `footer` `data-private`, as `sensitive` tags the figures — for a footer
206
+ * that carries an amount: keksdose's tax reserve tile's shortfall line ("Set aside
207
+ * €1,200 more…"), which it tags by hand. keksdose audit follow-up, 2026-11-01.
208
+ */
209
+ footerSensitive?: boolean;
191
210
  /** Skeleton in place of the value; delta, sub-values and trend are withheld. */
192
211
  loading?: boolean;
193
212
  /** `"sm"` for dense grids (a metrics wall); `"md"` the default KPI. */
@@ -227,7 +246,7 @@ export interface StatTileProps extends Omit<ComponentPropsWithRef<"div">, "child
227
246
  * the hint sits above the overlay and stays its own tab stop. The link's name is the
228
247
  * label, and it is described by the value and the delta.
229
248
  */
230
- export 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): import("react").JSX.Element;
249
+ export 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, descriptionSensitive, footerSensitive, loading, size, variant, href, renderLink, onClick, labels, className, ...rest }: StatTileProps): import("react").JSX.Element;
231
250
  export interface StatTileGridProps extends ComponentPropsWithRef<"div"> {
232
251
  /** The narrowest a tile may get before the grid drops a column. The default fits
233
252
  * two tiles on a 320px phone. */
@@ -69,6 +69,8 @@ function StatTile({
69
69
  icon,
70
70
  footer,
71
71
  sensitive = false,
72
+ descriptionSensitive = false,
73
+ footerSensitive = false,
72
74
  loading = false,
73
75
  size = "md",
74
76
  variant = "card",
@@ -232,14 +234,14 @@ function StatTile({
232
234
  ) : /* @__PURE__ */ jsx("div", { className: "mt-1", children: headline }),
233
235
  !large && !loading && projections.length > 0 && /* @__PURE__ */ jsx("dl", { className: "mt-0.5 space-y-0.5", children: projections.map((p, i) => /* @__PURE__ */ jsx(FigureRow, { figure: p, tileTone: tone, show, priv }, i)) }),
234
236
  deltaNode,
235
- description != null && /* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-muted", children: description }),
237
+ description != null && /* @__PURE__ */ jsx("div", { "data-private": descriptionSensitive ? "" : void 0, className: "mt-1 text-xs text-muted", children: description }),
236
238
  !large && graphic && /* @__PURE__ */ jsx("div", { className: "mt-2", children: graphic }),
237
239
  !loading && (large && projections.length > 0 || subValues && subValues.length > 0) && /* @__PURE__ */ jsxs("dl", { "data-slot": "stat-tile-figures", className: cn("mt-1.5", large ? "space-y-1.5" : "space-y-0.5"), children: [
238
240
  large && projections.map((p, i) => /* @__PURE__ */ jsx(FigureRow, { figure: p, tileTone: tone, show, priv, stacked: true }, `projection-${i}`)),
239
241
  subValues?.map((sv, i) => /* @__PURE__ */ jsx(FigureRow, { figure: sv, tileTone: tone, show, priv, stacked: large }, i))
240
242
  ] }),
241
243
  large && graphic && /* @__PURE__ */ jsx("div", { "data-slot": "stat-tile-graphic", className: "mt-2", children: graphic }),
242
- footer != null && /* @__PURE__ */ jsx("div", { className: "mt-2", children: footer })
244
+ footer != null && /* @__PURE__ */ jsx("div", { "data-private": footerSensitive ? "" : void 0, className: "mt-2", children: footer })
243
245
  ]
244
246
  }
245
247
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/stat-tile.tsx"],"sourcesContent":["import { createContext, useContext, useId, useLayoutEffect, useState } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactElement, ReactNode } from \"react\";\nimport { ArrowDown, ArrowUp, Minus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\n// The sparkline's name: the label's text (lib since 0.36, which a field's `help` \"?\" shares).\nimport { plainText } from \"../lib/plain-text\";\nimport { useKitLabels, useKitLink, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { pickLinkRenderer, RenderedKitLink } from \"./text-link\";\nimport { Card } from \"./card\";\nimport { FieldHint } from \"./field-parts\";\nimport { useInlineFacts, useLargeText } from \"../hooks/use-large-text\";\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\";\nimport { DEFAULT_STAT_TILE_LABELS } from \"./stat-tile-labels\";\nimport { formatWithMinus } from \"../lib/minus\";\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\n// Defined in ./stat-tile-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_STAT_TILE_LABELS };\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\" | \"brand\" | \"income\" | \"expense\" | \"net\" | \"signed\" | \"success\" | \"warning\" | \"danger\" | \"info\";\n\nconst TONE_CLASS: Record<Exclude<StatTileTone, \"signed\">, string> = {\n neutral: \"text-primary\",\n brand: \"text-brand\",\n income: \"text-money-income\",\n expense: \"text-money-expense\",\n net: \"text-money-net\",\n success: \"text-success\",\n warning: \"text-warning\",\n danger: \"text-danger\",\n info: \"text-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\n/**\n * A `div`'s props, `ref` included since 0.35 (round 0.35 R4, the follow-up to API-2): they\n * ride on to the {@link Card} that is the tile, so the ref is the tile's own `<div>` — the\n * one to scroll into view or measure. `ComponentPropsWithoutRef` only kept it out of the\n * type; at runtime `{...rest}` already carried it there.\n */\nexport interface StatTileProps extends Omit<ComponentPropsWithRef<\"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 *\n * 0.32 (docs/text-size-harmonization.md §4 \"No fact only in a tooltip\"): at Large\n * and Extra large, and on a touch screen, the words are shown under the label\n * instead of behind the \"?\". */\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 * Ignored at Large and Extra large (0.32, §4): nothing truncates there, and the full\n * label would otherwise be a fact only in a tooltip.\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 * 0.51: or several, in order (keksdose #633). Its figure tiles carry two forward rows,\n * \"Committed <date>\" (today plus what is scheduled) and \"Projected <date>\" (that plus the\n * usual variable money), both of which belong with the headline and neither with the\n * history below. The tile draws what it is given; which rows to give is the app's rule\n * (keksdose shows both on every tile, live #455, even where Committed equals the figure\n * so far).\n */\n projection?: StatTileSubValue | readonly StatTileSubValue[];\n /**\n * Smaller figures under the headline, label left and figure right.\n *\n * At Large and Extra large (0.32, §4 \"StatTile shows its one big number; the sparkline\n * and sub-values move below\"): the tile leads with the headline and its delta, and the\n * projection, these rows and the sparkline follow beneath the description, each row's\n * label over its figure — a 2-up tile at 150 % is 120 px of text wide, and a label\n * beside a figure there squeezed both.\n */\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?: LabelOverride<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 // §4: at Large the one big number leads and the rest follows below it; the label\n // never truncates; on touch or at Large the hint is words, not a \"?\".\n const large = useLargeText();\n const inlineHint = useInlineFacts() && !!hint;\n if (large) truncateLabel = false;\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 // One projection or several (0.51), as a list either way.\n const projections: readonly StatTileSubValue[] =\n projection === undefined ? [] : isFigureList(projection) ? projection : [projection];\n\n const fmt =\n format ??\n ((n: number) =>\n // U+2212 for a negative headline (0.49, KIT-1).\n formatWithMinus(\n numberFormatter(kitLocale, {\n ...(currency ? { style: \"currency\", currency } : null),\n ...(compact ? { notation: \"compact\" } : null),\n ...numberFormat,\n }),\n n,\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 // The kit's focus frame (0.32, §5), on the overlay — `FOCUS_RING`'s classes cannot\n // carry the `after:`, so its width is spelt out.\n \"focus-visible:outline-none focus-visible:after:ring-focus focus-visible:after:ring-inset focus-visible:after:ring-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-muted\";\n if (goodDirection && dir !== \"flat\") {\n const good = dir === goodDirection;\n spoken = good ? text.better(spoken) : text.worse(spoken);\n deltaTone = good ? \"text-success\" : \"text-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\n id={deltaId}\n data-private={priv}\n className={cn(\"inline-flex items-center gap-0.5 font-medium\", deltaTone)}\n >\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-muted\">{d.label}</span>}\n </div>\n );\n }\n\n // ── Headline ──\n const valueClass = cn(\"whitespace-nowrap font-semibold tabular-nums\", VALUE_TEXT[size], toneClass(tone, value));\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 && !large && \"ms-auto\")}>\n {show(value)}\n {unit != null && <span className=\"ms-1 text-[0.7em] font-medium text-muted\">{unit}</span>}\n </span>\n ) : (\n <span id={valueId} className={cn(\"relative\", valueClass, \"text-muted\")}>\n <span aria-hidden>—</span>\n <span className=\"sr-only\">{text.noValue}</span>\n </span>\n );\n\n const graphic = loading\n ? null\n : (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-strong hover: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-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 && !inlineHint && <FieldHint label={hint} side=\"top\" className=\"relative z-10 shrink-0\" />}\n </div>\n {icon != null && (\n <span aria-hidden className=\"shrink-0 text-muted [&_svg]:size-4\">\n {icon}\n </span>\n )}\n </div>\n\n {inlineHint && (\n // §4: the hint as words under the label — the same muted type as `description`,\n // in the reading case of a sentence rather than the label's capitals.\n <p data-slot=\"stat-tile-hint\" className=\"mt-0.5 text-xs text-muted\">\n {hint}\n </p>\n )}\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. At\n // Large the period goes over the figure, which then has the tile's width.\n <div className={cn(\"mt-1 flex items-baseline gap-x-1.5\", large ? \"flex-col items-start\" : \"flex-wrap\")}>\n <span className=\"shrink-0 text-xs uppercase tracking-wide text-muted\">{valueLabel}</span>\n {headline}\n </div>\n ) : (\n <div className=\"mt-1\">{headline}</div>\n )}\n\n {/* At Large the delta and description follow the figure at once, and the\n projection moves down with the other figures (see `subValues`). */}\n {!large && !loading && projections.length > 0 && (\n <dl className=\"mt-0.5 space-y-0.5\">\n {projections.map((p, i) => (\n <FigureRow key={i} figure={p} tileTone={tone} show={show} priv={priv} />\n ))}\n </dl>\n )}\n\n {deltaNode}\n {description != null && <div className=\"mt-1 text-xs text-muted\">{description}</div>}\n {!large && graphic && <div className=\"mt-2\">{graphic}</div>}\n\n {!loading && ((large && projections.length > 0) || (subValues && subValues.length > 0)) && (\n <dl data-slot=\"stat-tile-figures\" className={cn(\"mt-1.5\", large ? \"space-y-1.5\" : \"space-y-0.5\")}>\n {large &&\n projections.map((p, i) => (\n <FigureRow key={`projection-${i}`} figure={p} tileTone={tone} show={show} priv={priv} stacked />\n ))}\n {subValues?.map((sv, i) => (\n <FigureRow key={i} figure={sv} tileTone={tone} show={show} priv={priv} stacked={large} />\n ))}\n </dl>\n )}\n\n {large && graphic && (\n <div data-slot=\"stat-tile-graphic\" className=\"mt-2\">\n {graphic}\n </div>\n )}\n\n {footer != null && <div className=\"mt-2\">{footer}</div>}\n </Card>\n );\n}\n\n/** `Array.isArray` narrows a readonly array to `any[]`; this keeps the element type. */\nfunction isFigureList(p: StatTileSubValue | readonly StatTileSubValue[]): p is readonly StatTileSubValue[] {\n return Array.isArray(p);\n}\n\n/** One label/value row of a `<dl>`: a sub-value, or a projection. */\nfunction FigureRow({\n figure,\n tileTone,\n show,\n priv,\n stacked = false,\n}: {\n figure: StatTileSubValue;\n tileTone: StatTileTone;\n show: (v: ReactNode) => ReactNode;\n priv: \"\" | undefined;\n /** The label over the figure (Large, §4) instead of beside it. */\n stacked?: boolean;\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 //\n // 0.49: between WORDS only. `overflow-wrap:anywhere` (with `min-w-0`) cut a single\n // word at any letter — \"PROJECT|ED\" in a 160px KPI tile at 360px. The label now keeps\n // a flex item's own floor, its longest word; only a word that cannot share the line\n // with the figure sends the figure to the next line, still end-aligned. `break-word`\n // is the last resort for a word wider than the whole tile, and does not lower that\n // floor the way `anywhere` did.\n return (\n <div\n className={cn(\n \"flex text-xs tabular-nums text-muted\",\n stacked ? \"flex-col items-start\" : \"flex-wrap items-baseline gap-x-2\",\n )}\n >\n <dt className=\"max-w-full uppercase tracking-wide [overflow-wrap:break-word]\">{figure.label}</dt>\n <dd\n data-private={priv}\n className={cn(\n \"shrink-0 whitespace-nowrap\",\n !stacked && \"ms-auto\",\n svTone && [toneClass(svTone, figure.value), \"opacity-75\"],\n )}\n >\n {show(figure.value)}\n </dd>\n </div>\n );\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 ComponentPropsWithRef<\"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?: LabelOverride<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":";AAuYM,cAoCE,YApCF;AAvYN,SAAS,eAAe,YAAY,OAAO,iBAAiB,gBAAgB;AAE5E,SAAS,WAAW,SAAS,aAAa;AAC1C,SAAS,UAAU;AAEnB,SAAS,iBAAiB;AAC1B,SAAS,cAAc,YAAY,oBAAwC;AAC3E,SAAS,kBAAkB,uBAAuB;AAClD,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB,oBAAoB;AAC7C,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AAIxB,SAAS,sBAAsB;AAC/B,SAAS,gCAAgC;AACzC,SAAS,uBAAuB;AAsChC,MAAM,aAA8D;AAAA,EAClE,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AACR;AAEA,SAAS,UAAU,MAAoB,OAAwB;AAC7D,MAAI,SAAS,SAAU,QAAO,WAAW,IAAI;AAC7C,MAAI,OAAO,UAAU,YAAY,UAAU,EAAG,QAAO,WAAW;AAChE,SAAO,QAAQ,IAAI,WAAW,UAAU,WAAW;AACrD;A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;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":[]}
1
+ {"version":3,"sources":["../../src/components/stat-tile.tsx"],"sourcesContent":["import { createContext, useContext, useId, useLayoutEffect, useState } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactElement, ReactNode } from \"react\";\nimport { ArrowDown, ArrowUp, Minus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\n// The sparkline's name: the label's text (lib since 0.36, which a field's `help` \"?\" shares).\nimport { plainText } from \"../lib/plain-text\";\nimport { useKitLabels, useKitLink, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { pickLinkRenderer, RenderedKitLink } from \"./text-link\";\nimport { Card } from \"./card\";\nimport { FieldHint } from \"./field-parts\";\nimport { useInlineFacts, useLargeText } from \"../hooks/use-large-text\";\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\";\nimport { DEFAULT_STAT_TILE_LABELS } from \"./stat-tile-labels\";\nimport { formatWithMinus } from \"../lib/minus\";\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\n// Defined in ./stat-tile-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_STAT_TILE_LABELS };\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\" | \"brand\" | \"income\" | \"expense\" | \"net\" | \"signed\" | \"success\" | \"warning\" | \"danger\" | \"info\";\n\nconst TONE_CLASS: Record<Exclude<StatTileTone, \"signed\">, string> = {\n neutral: \"text-primary\",\n brand: \"text-brand\",\n income: \"text-money-income\",\n expense: \"text-money-expense\",\n net: \"text-money-net\",\n success: \"text-success\",\n warning: \"text-warning\",\n danger: \"text-danger\",\n info: \"text-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\n/**\n * A `div`'s props, `ref` included since 0.35 (round 0.35 R4, the follow-up to API-2): they\n * ride on to the {@link Card} that is the tile, so the ref is the tile's own `<div>` — the\n * one to scroll into view or measure. `ComponentPropsWithoutRef` only kept it out of the\n * type; at runtime `{...rest}` already carried it there.\n */\nexport interface StatTileProps extends Omit<ComponentPropsWithRef<\"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 *\n * 0.32 (docs/text-size-harmonization.md §4 \"No fact only in a tooltip\"): at Large\n * and Extra large, and on a touch screen, the words are shown under the label\n * instead of behind the \"?\". */\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 * Ignored at Large and Extra large (0.32, §4): nothing truncates there, and the full\n * label would otherwise be a fact only in a tooltip.\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 * 0.51: or several, in order (keksdose #633). Its figure tiles carry two forward rows,\n * \"Committed <date>\" (today plus what is scheduled) and \"Projected <date>\" (that plus the\n * usual variable money), both of which belong with the headline and neither with the\n * history below. The tile draws what it is given; which rows to give is the app's rule\n * (keksdose shows both on every tile, live #455, even where Committed equals the figure\n * so far).\n */\n projection?: StatTileSubValue | readonly StatTileSubValue[];\n /**\n * Smaller figures under the headline, label left and figure right.\n *\n * At Large and Extra large (0.32, §4 \"StatTile shows its one big number; the sparkline\n * and sub-values move below\"): the tile leads with the headline and its delta, and the\n * projection, these rows and the sparkline follow beneath the description, each row's\n * label over its figure — a 2-up tile at 150 % is 120 px of text wide, and a label\n * beside a figure there squeezed both.\n */\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 * The figures are the tile's own: value, delta, projection, sub-values and the\n * trend. The `description` and `footer` are the app's nodes and stay readable;\n * see {@link StatTileProps.descriptionSensitive} for the ones that carry an amount. */\n sensitive?: boolean;\n /**\n * Tag the `description` line `data-private` too, as `sensitive` tags the figures.\n * For a description that names an amount: keksdose's tax reserve tile states its\n * basis there (\"…applied to €42,000\"), and its report KpiCard puts a `hintSensitive`\n * hint there — both tag their own `<span data-private>` today\n * (reports/tabs/tax-tab.tsx, reports/charts/kpi-card.tsx). Separate from\n * `sensitive`, so a description of words (\"Last 12 months\") on a money tile stays\n * readable in demo mode. keksdose audit follow-up, 2026-11-01.\n */\n descriptionSensitive?: boolean;\n /**\n * Tag the `footer` `data-private`, as `sensitive` tags the figures — for a footer\n * that carries an amount: keksdose's tax reserve tile's shortfall line (\"Set aside\n * €1,200 more…\"), which it tags by hand. keksdose audit follow-up, 2026-11-01.\n */\n footerSensitive?: 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?: LabelOverride<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 descriptionSensitive = false,\n footerSensitive = 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 // §4: at Large the one big number leads and the rest follows below it; the label\n // never truncates; on touch or at Large the hint is words, not a \"?\".\n const large = useLargeText();\n const inlineHint = useInlineFacts() && !!hint;\n if (large) truncateLabel = false;\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 // One projection or several (0.51), as a list either way.\n const projections: readonly StatTileSubValue[] =\n projection === undefined ? [] : isFigureList(projection) ? projection : [projection];\n\n const fmt =\n format ??\n ((n: number) =>\n // U+2212 for a negative headline (0.49, KIT-1).\n formatWithMinus(\n numberFormatter(kitLocale, {\n ...(currency ? { style: \"currency\", currency } : null),\n ...(compact ? { notation: \"compact\" } : null),\n ...numberFormat,\n }),\n n,\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 // The kit's focus frame (0.32, §5), on the overlay — `FOCUS_RING`'s classes cannot\n // carry the `after:`, so its width is spelt out.\n \"focus-visible:outline-none focus-visible:after:ring-focus focus-visible:after:ring-inset focus-visible:after:ring-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-muted\";\n if (goodDirection && dir !== \"flat\") {\n const good = dir === goodDirection;\n spoken = good ? text.better(spoken) : text.worse(spoken);\n deltaTone = good ? \"text-success\" : \"text-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\n id={deltaId}\n data-private={priv}\n className={cn(\"inline-flex items-center gap-0.5 font-medium\", deltaTone)}\n >\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-muted\">{d.label}</span>}\n </div>\n );\n }\n\n // ── Headline ──\n const valueClass = cn(\"whitespace-nowrap font-semibold tabular-nums\", VALUE_TEXT[size], toneClass(tone, value));\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 && !large && \"ms-auto\")}>\n {show(value)}\n {unit != null && <span className=\"ms-1 text-[0.7em] font-medium text-muted\">{unit}</span>}\n </span>\n ) : (\n <span id={valueId} className={cn(\"relative\", valueClass, \"text-muted\")}>\n <span aria-hidden>—</span>\n <span className=\"sr-only\">{text.noValue}</span>\n </span>\n );\n\n const graphic = loading\n ? null\n : (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-strong hover: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-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 && !inlineHint && <FieldHint label={hint} side=\"top\" className=\"relative z-10 shrink-0\" />}\n </div>\n {icon != null && (\n <span aria-hidden className=\"shrink-0 text-muted [&_svg]:size-4\">\n {icon}\n </span>\n )}\n </div>\n\n {inlineHint && (\n // §4: the hint as words under the label — the same muted type as `description`,\n // in the reading case of a sentence rather than the label's capitals.\n <p data-slot=\"stat-tile-hint\" className=\"mt-0.5 text-xs text-muted\">\n {hint}\n </p>\n )}\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. At\n // Large the period goes over the figure, which then has the tile's width.\n <div className={cn(\"mt-1 flex items-baseline gap-x-1.5\", large ? \"flex-col items-start\" : \"flex-wrap\")}>\n <span className=\"shrink-0 text-xs uppercase tracking-wide text-muted\">{valueLabel}</span>\n {headline}\n </div>\n ) : (\n <div className=\"mt-1\">{headline}</div>\n )}\n\n {/* At Large the delta and description follow the figure at once, and the\n projection moves down with the other figures (see `subValues`). */}\n {!large && !loading && projections.length > 0 && (\n <dl className=\"mt-0.5 space-y-0.5\">\n {projections.map((p, i) => (\n <FigureRow key={i} figure={p} tileTone={tone} show={show} priv={priv} />\n ))}\n </dl>\n )}\n\n {deltaNode}\n {description != null && (\n <div data-private={descriptionSensitive ? \"\" : undefined} className=\"mt-1 text-xs text-muted\">\n {description}\n </div>\n )}\n {!large && graphic && <div className=\"mt-2\">{graphic}</div>}\n\n {!loading && ((large && projections.length > 0) || (subValues && subValues.length > 0)) && (\n <dl data-slot=\"stat-tile-figures\" className={cn(\"mt-1.5\", large ? \"space-y-1.5\" : \"space-y-0.5\")}>\n {large &&\n projections.map((p, i) => (\n <FigureRow key={`projection-${i}`} figure={p} tileTone={tone} show={show} priv={priv} stacked />\n ))}\n {subValues?.map((sv, i) => (\n <FigureRow key={i} figure={sv} tileTone={tone} show={show} priv={priv} stacked={large} />\n ))}\n </dl>\n )}\n\n {large && graphic && (\n <div data-slot=\"stat-tile-graphic\" className=\"mt-2\">\n {graphic}\n </div>\n )}\n\n {footer != null && (\n <div data-private={footerSensitive ? \"\" : undefined} className=\"mt-2\">\n {footer}\n </div>\n )}\n </Card>\n );\n}\n\n/** `Array.isArray` narrows a readonly array to `any[]`; this keeps the element type. */\nfunction isFigureList(p: StatTileSubValue | readonly StatTileSubValue[]): p is readonly StatTileSubValue[] {\n return Array.isArray(p);\n}\n\n/** One label/value row of a `<dl>`: a sub-value, or a projection. */\nfunction FigureRow({\n figure,\n tileTone,\n show,\n priv,\n stacked = false,\n}: {\n figure: StatTileSubValue;\n tileTone: StatTileTone;\n show: (v: ReactNode) => ReactNode;\n priv: \"\" | undefined;\n /** The label over the figure (Large, §4) instead of beside it. */\n stacked?: boolean;\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 //\n // 0.49: between WORDS only. `overflow-wrap:anywhere` (with `min-w-0`) cut a single\n // word at any letter — \"PROJECT|ED\" in a 160px KPI tile at 360px. The label now keeps\n // a flex item's own floor, its longest word; only a word that cannot share the line\n // with the figure sends the figure to the next line, still end-aligned. `break-word`\n // is the last resort for a word wider than the whole tile, and does not lower that\n // floor the way `anywhere` did.\n return (\n <div\n className={cn(\n \"flex text-xs tabular-nums text-muted\",\n stacked ? \"flex-col items-start\" : \"flex-wrap items-baseline gap-x-2\",\n )}\n >\n <dt className=\"max-w-full uppercase tracking-wide [overflow-wrap:break-word]\">{figure.label}</dt>\n <dd\n data-private={priv}\n className={cn(\n \"shrink-0 whitespace-nowrap\",\n !stacked && \"ms-auto\",\n svTone && [toneClass(svTone, figure.value), \"opacity-75\"],\n )}\n >\n {show(figure.value)}\n </dd>\n </div>\n );\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 ComponentPropsWithRef<\"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?: LabelOverride<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":";AA4ZM,cAoCE,YApCF;AA5ZN,SAAS,eAAe,YAAY,OAAO,iBAAiB,gBAAgB;AAE5E,SAAS,WAAW,SAAS,aAAa;AAC1C,SAAS,UAAU;AAEnB,SAAS,iBAAiB;AAC1B,SAAS,cAAc,YAAY,oBAAwC;AAC3E,SAAS,kBAAkB,uBAAuB;AAClD,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB,oBAAoB;AAC7C,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AAIxB,SAAS,sBAAsB;AAC/B,SAAS,gCAAgC;AACzC,SAAS,uBAAuB;AAsChC,MAAM,aAA8D;AAAA,EAClE,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AACR;AAEA,SAAS,UAAU,MAAoB,OAAwB;AAC7D,MAAI,SAAS,SAAU,QAAO,WAAW,IAAI;AAC7C,MAAI,OAAO,UAAU,YAAY,UAAU,EAAG,QAAO,WAAW;AAChE,SAAO,QAAQ,IAAI,WAAW,UAAU,WAAW;AACrD;AA8MA,MAAM,aAAa,oBAAI,IAA+B;AACtD,SAAS,gBAAgB,QAA4B,SAAsD;AACzG,QAAM,MAAM,GAAG,UAAU,EAAE,IAAI,KAAK,UAAU,OAAO,CAAC;AACtD,MAAI,IAAI,WAAW,IAAI,GAAG;AAC1B,MAAI,CAAC,GAAG;AACN,QAAI,IAAI,KAAK,aAAa,QAAQ,OAAO;AACzC,eAAW,IAAI,KAAK,CAAC;AAAA,EACvB;AACA,SAAO;AACT;AAMA,MAAM,aAAa;AAAA,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AM,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":[]}
@@ -5,13 +5,18 @@ export interface TreemapLabels {
5
5
  * `valueFormatter` when that returns text, else as the number in the provider's
6
6
  * locale; `share` is the tile's share of what is drawn, already a formatted percent
7
7
  * ("60 %" in German, "60%" in English) — the function only arranges them.
8
+ *
9
+ * `share` is `""` when the map's `shareInValue` says the formatter's text already holds
10
+ * it (0.53): leave out whatever frames it, as every catalogue drops its " (share)" —
11
+ * "Migros: CHF 412.30 · 12%", not "… · 12% ()".
8
12
  */
9
13
  tile: (name: string, value: string, share: string) => string;
10
14
  /**
11
15
  * A group's accessible name (0.52, `TreemapNode.children`): its frame is a stop of the
12
16
  * map's keyboard before its tiles, so a reader hears the group and its total once, on the
13
17
  * way in. `value` and `share` as for {@link TreemapLabels.tile}, of the group's tiles
14
- * together; the word "group" tells it from a tile of the same shape.
18
+ * together, the share `""` under `shareInValue` as there; the word "group" tells it from
19
+ * a tile of the same shape.
15
20
  */
16
21
  group: (name: string, value: string, share: string) => string;
17
22
  /**
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  const DEFAULT_TREEMAP_LABELS = {
3
- tile: (name, value, share) => `${name}: ${value} (${share})`,
4
- group: (name, value, share) => `${name}, group: ${value} (${share})`,
3
+ tile: (name, value, share) => `${name}: ${value}${share ? ` (${share})` : ""}`,
4
+ group: (name, value, share) => `${name}, group: ${value}${share ? ` (${share})` : ""}`,
5
5
  inGroup: (name, group) => `${name}, in ${group}`
6
6
  };
7
7
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/treemap-labels.ts"],"sourcesContent":["// All user-facing strings for `Treemap`, as the `treemap` namespace of\n// `<UiKitProvider labels>`, and per map the `labels` prop over that (0.52, refactor audit\n// 2026-10-30, DSP-5).\n//\n// A module of its own, with no recharts in it, for the reason `pie-chart-labels` is one:\n// the label registry (src/i18n) imports the defaults, and must not pull the chart\n// library in behind them.\n\nexport interface TreemapLabels {\n /**\n * One tile's accessible name — what a screen reader says for a tile, clickable or\n * not, since its area is nothing it can say. `value` arrives through the map's\n * `valueFormatter` when that returns text, else as the number in the provider's\n * locale; `share` is the tile's share of what is drawn, already a formatted percent\n * (\"60 %\" in German, \"60%\" in English) — the function only arranges them.\n */\n tile: (name: string, value: string, share: string) => string;\n /**\n * A group's accessible name (0.52, `TreemapNode.children`): its frame is a stop of the\n * map's keyboard before its tiles, so a reader hears the group and its total once, on the\n * way in. `value` and `share` as for {@link TreemapLabels.tile}, of the group's tiles\n * together; the word \"group\" tells it from a tile of the same shape.\n */\n group: (name: string, value: string, share: string) => string;\n /**\n * A name inside a group: `name` is the tile's (or a nested group's) own, from\n * {@link TreemapLabels.tile} or {@link TreemapLabels.group}, and `group` the name of the\n * group round it — applied once per group, the innermost first, so a tile two levels deep\n * reads \"Rent: 1,050 (40%), in Housing, in Fixed costs\". In the name rather than said once\n * by the frame, because Home, End and a click land on a tile without passing its frame.\n */\n inGroup: (name: string, group: string) => string;\n}\n\nexport const DEFAULT_TREEMAP_LABELS: TreemapLabels = {\n tile: (name, value, share) => `${name}: ${value} (${share})`,\n group: (name, value, share) => `${name}, group: ${value} (${share})`,\n inGroup: (name, group) => `${name}, in ${group}`,\n};\n"],"mappings":";AAkCO,MAAM,yBAAwC;AAAA,EACnD,MAAM,CAAC,MAAM,OAAO,UAAU,GAAG,IAAI,KAAK,KAAK,KAAK,KAAK;AAAA,EACzD,OAAO,CAAC,MAAM,OAAO,UAAU,GAAG,IAAI,YAAY,KAAK,KAAK,KAAK;AAAA,EACjE,SAAS,CAAC,MAAM,UAAU,GAAG,IAAI,QAAQ,KAAK;AAChD;","names":[]}
1
+ {"version":3,"sources":["../../src/components/treemap-labels.ts"],"sourcesContent":["// All user-facing strings for `Treemap`, as the `treemap` namespace of\n// `<UiKitProvider labels>`, and per map the `labels` prop over that (0.52, refactor audit\n// 2026-10-30, DSP-5).\n//\n// A module of its own, with no recharts in it, for the reason `pie-chart-labels` is one:\n// the label registry (src/i18n) imports the defaults, and must not pull the chart\n// library in behind them.\n\nexport interface TreemapLabels {\n /**\n * One tile's accessible name — what a screen reader says for a tile, clickable or\n * not, since its area is nothing it can say. `value` arrives through the map's\n * `valueFormatter` when that returns text, else as the number in the provider's\n * locale; `share` is the tile's share of what is drawn, already a formatted percent\n * (\"60 %\" in German, \"60%\" in English) — the function only arranges them.\n *\n * `share` is `\"\"` when the map's `shareInValue` says the formatter's text already holds\n * it (0.53): leave out whatever frames it, as every catalogue drops its \" (share)\" —\n * \"Migros: CHF 412.30 · 12%\", not \"… · 12% ()\".\n */\n tile: (name: string, value: string, share: string) => string;\n /**\n * A group's accessible name (0.52, `TreemapNode.children`): its frame is a stop of the\n * map's keyboard before its tiles, so a reader hears the group and its total once, on the\n * way in. `value` and `share` as for {@link TreemapLabels.tile}, of the group's tiles\n * together, the share `\"\"` under `shareInValue` as there; the word \"group\" tells it from\n * a tile of the same shape.\n */\n group: (name: string, value: string, share: string) => string;\n /**\n * A name inside a group: `name` is the tile's (or a nested group's) own, from\n * {@link TreemapLabels.tile} or {@link TreemapLabels.group}, and `group` the name of the\n * group round it — applied once per group, the innermost first, so a tile two levels deep\n * reads \"Rent: 1,050 (40%), in Housing, in Fixed costs\". In the name rather than said once\n * by the frame, because Home, End and a click land on a tile without passing its frame.\n */\n inGroup: (name: string, group: string) => string;\n}\n\n// The share in brackets only when there is one: `\"\"` under the map's `shareInValue` (0.53,\n// keksdose after 0.52), which the catalogues in src/i18n/locales follow, each in its own\n// typography.\nexport const DEFAULT_TREEMAP_LABELS: TreemapLabels = {\n tile: (name, value, share) => `${name}: ${value}${share ? ` (${share})` : \"\"}`,\n group: (name, value, share) => `${name}, group: ${value}${share ? ` (${share})` : \"\"}`,\n inGroup: (name, group) => `${name}, in ${group}`,\n};\n"],"mappings":";AA0CO,MAAM,yBAAwC;AAAA,EACnD,MAAM,CAAC,MAAM,OAAO,UAAU,GAAG,IAAI,KAAK,KAAK,GAAG,QAAQ,KAAK,KAAK,MAAM,EAAE;AAAA,EAC5E,OAAO,CAAC,MAAM,OAAO,UAAU,GAAG,IAAI,YAAY,KAAK,GAAG,QAAQ,KAAK,KAAK,MAAM,EAAE;AAAA,EACpF,SAAS,CAAC,MAAM,UAAU,GAAG,IAAI,QAAQ,KAAK;AAChD;","names":[]}
@@ -94,13 +94,26 @@ export interface TreemapProps extends Omit<ComponentPropsWithoutRef<"div">, "chi
94
94
  * A tile's and a group's accessible name (`labels.tile`, `labels.group`, 0.52) says the
95
95
  * value too, asked of the formatter as the tooltip asks it, share and all, and its text
96
96
  * is used; markup is said as the bare number. The name says the share itself, so a
97
- * formatter that writes it into its text has it said twice.
97
+ * formatter that writes it into its text has it said twice — say so with
98
+ * {@link TreemapProps.shareInValue}.
98
99
  *
99
100
  * Default: the bare number through `Intl.NumberFormat` in the provider's locale (0.52,
100
101
  * DOC-10: before, the runtime's). A host with a currency passes this — the kit knows
101
102
  * none.
102
103
  */
103
104
  valueFormatter?: (value: number, share: number | undefined) => ReactNode;
105
+ /**
106
+ * The `valueFormatter`'s text already says the share ("CHF 412.30 · 12%"), so a tile's
107
+ * and a group's accessible name leave their own " (12%)" out (0.53, keksdose after 0.52):
108
+ * the map hands `labels.tile` and `labels.group` the share as `""`, and every catalogue's
109
+ * template drops it there, in its own typography. Before, the only way out was to replace
110
+ * both templates, and with them the kit's seven catalogues. The tooltip is the same either
111
+ * way: it prints what the formatter prints. A formatter whose value is markup is said as
112
+ * the bare number, so its share is then not said at all.
113
+ *
114
+ * Default `false`: the name says the share.
115
+ */
116
+ shareInValue?: boolean;
104
117
  /**
105
118
  * What the map SHOWS, in a sentence — "Rent is three fifths of the month." — the
106
119
  * figure's accessible description (0.52, DSP-5). Not drawn; a caption the eye should
@@ -150,8 +163,18 @@ export interface TreemapProps extends Omit<ComponentPropsWithoutRef<"div">, "chi
150
163
  * Every tile is tagged as a whole too, clickable or not (0.52): its accessible name
151
164
  * (`labels.tile`) says the name and the value, in an attribute a host's redaction
152
165
  * reaches only through the tag.
166
+ *
167
+ * - `true`: every node — the tiles, and a group's frame (its `<g>` and its band's name)
168
+ * and tooltip bubble too.
169
+ * - `"tiles"` (0.53, keksdose after 0.52): the tiles as `true` tags them, and no group —
170
+ * for groups that are public names over private ones, as chains (Migros, Coop) over
171
+ * the shops a user paid. Its frame's band, its frame and its bubble's name are
172
+ * untagged, and so is the frame's accessible name (`labels.group`), which says the
173
+ * group's TOTAL: use it only where the groups' names and totals are not the private
174
+ * part. The bubble's value cell is tagged whatever this says, as in every chart.
175
+ * A tile's name still says its group's (`labels.inGroup`), under the tile's tag.
153
176
  */
154
- redactNames?: boolean;
177
+ redactNames?: boolean | "tiles";
155
178
  /**
156
179
  * A second, smaller line under a tile's label — one extra figure per node that the
157
180
  * name cannot carry (a year-on-year `+12%`, `new`). Return `undefined` for a node
@@ -242,7 +265,9 @@ export interface TreemapCellProps {
242
265
  /** Filled in by recharts for a GROUP: the nodes laid out inside it. A cell with
243
266
  * children draws a frame, not a tile (0.52). */
244
267
  children?: readonly object[] | null;
245
- redactNames?: boolean;
268
+ /** See {@link TreemapProps.redactNames}: `"tiles"` tags a cell with no `children`, and
269
+ * leaves a group's frame and band untagged (0.53). */
270
+ redactNames?: boolean | "tiles";
246
271
  nodeNote?: (id: string) => string | undefined;
247
272
  /** The page's reading direction, which `Treemap` reads off its own root. In `rtl`
248
273
  * the label stands in the tile's top RIGHT corner and is shaped right-to-left, so a
@@ -289,4 +314,4 @@ export declare function TreemapCell(props: TreemapCellProps): import("react").JS
289
314
  *
290
315
  * Needs `recharts`, like everything behind `@eifi1/ui-kit/chart`.
291
316
  */
292
- export declare function Treemap({ data, valueFormatter, height, onNodeClick, onGroupClick, redactNames, nodeNote, maxTiles, colors, edges, description, labels: labelsProp, style, ...rest }: TreemapProps): import("react").JSX.Element | null;
317
+ export declare function Treemap({ data, valueFormatter, height, onNodeClick, onGroupClick, redactNames, shareInValue, nodeNote, maxTiles, colors, edges, description, labels: labelsProp, style, ...rest }: TreemapProps): import("react").JSX.Element | null;
@@ -141,6 +141,7 @@ function Tile({
141
141
  const activate = id != null && click ? () => groups && groups.length > 0 ? click(id, name ?? "", groups) : click(id, name ?? "") : void 0;
142
142
  const roving = path != null && keys ? keys : void 0;
143
143
  const focusable = roving !== void 0 || activate !== void 0;
144
+ const redact = redactNames === true || redactNames === "tiles" && !group;
144
145
  const onKeyDown = focusable ? (e) => {
145
146
  if (roving?.move(path, e)) {
146
147
  e.preventDefault();
@@ -161,7 +162,7 @@ function Tile({
161
162
  role: activate ? "button" : roving ? "img" : void 0,
162
163
  tabIndex: roving ? -1 : activate ? 0 : void 0,
163
164
  "aria-label": focusable ? roving?.name(path) ?? name : void 0,
164
- "data-private": focusable && redactNames ? "" : void 0,
165
+ "data-private": focusable && redact ? "" : void 0,
165
166
  "data-group": group ? "" : void 0,
166
167
  cursor: activate ? "pointer" : void 0,
167
168
  className: focusable ? "outline-none [&:focus-visible>rect]:stroke-[var(--brand)]" : void 0,
@@ -197,7 +198,7 @@ function Tile({
197
198
  label != null && /* @__PURE__ */ jsx(
198
199
  "text",
199
200
  {
200
- "data-private": redactNames ? "" : void 0,
201
+ "data-private": redact ? "" : void 0,
201
202
  x: textX,
202
203
  y: py + (group ? 14 : 15) * scale,
203
204
  direction: dir,
@@ -228,8 +229,13 @@ function Tile({
228
229
  );
229
230
  }
230
231
  const TREEMAP_CONFIG = {};
231
- function RedactedTooltipContent(props) {
232
- return /* @__PURE__ */ jsx("div", { "data-private": true, children: /* @__PURE__ */ jsx(ChartTooltipContent, { ...props }) });
232
+ function RedactedTooltipContent({
233
+ groups = true,
234
+ ...props
235
+ }) {
236
+ const children = props.payload?.[0]?.payload?.children;
237
+ const group = Array.isArray(children) && children.length > 0;
238
+ return /* @__PURE__ */ jsx("div", { "data-private": groups || !group ? true : void 0, children: /* @__PURE__ */ jsx(ChartTooltipContent, { ...props }) });
233
239
  }
234
240
  function createAnchor() {
235
241
  let at = null;
@@ -321,6 +327,7 @@ function Treemap({
321
327
  onNodeClick,
322
328
  onGroupClick,
323
329
  redactNames = false,
330
+ shareInValue = false,
324
331
  nodeNote,
325
332
  maxTiles,
326
333
  colors,
@@ -430,15 +437,16 @@ function Treemap({
430
437
  return typeof out === "string" || typeof out === "number" ? String(out) : formatWithMinus(numberFormat, v);
431
438
  };
432
439
  const groupName = new Map(order.filter((n) => n.children).map((n) => [n.path, n.name]));
440
+ const shareOf = (v) => shareInValue ? "" : shareText(total > 0 ? v / total : 0);
433
441
  return new Map(
434
442
  order.map((n) => {
435
443
  const say = n.children ? labels.group : labels.tile;
436
- const own = say(n.name, valueText(n.size), shareText(total > 0 ? n.size / total : 0));
444
+ const own = say(n.name, valueText(n.size), shareOf(n.size));
437
445
  const named = n.groups.map((g, i) => groupName.get(pathOf(n.groups.slice(0, i), g)) ?? g).reduceRight((acc, group) => labels.inGroup(acc, group), own);
438
446
  return [n.path, named];
439
447
  })
440
448
  );
441
- }, [order, labels, format, numberFormat, shareText, total]);
449
+ }, [order, labels, format, numberFormat, shareText, shareInValue, total]);
442
450
  const keys = useMemo(
443
451
  () => ({ name: (path) => names.get(path), onFocus, register, move }),
444
452
  [names, onFocus, register, move]
@@ -447,7 +455,6 @@ function Treemap({
447
455
  () => ({ tokens: tokenHex, edgeFor, edges: edgesInForce, keys, layout, hover: anchor.set }),
448
456
  [tokenHex, edgeFor, edgesInForce, keys, layout, anchor]
449
457
  );
450
- const Content = redactNames ? RedactedTooltipContent : ChartTooltipContent;
451
458
  const cell = useMemo(
452
459
  () => /* @__PURE__ */ jsx(
453
460
  TreemapCell,
@@ -462,8 +469,14 @@ function Treemap({
462
469
  [onNodeClick, onGroupClick, redactNames, nodeNote, dir]
463
470
  );
464
471
  const tooltip = useMemo(
465
- () => /* @__PURE__ */ jsx(TreemapTooltip, { content: /* @__PURE__ */ jsx(Content, { hideLabel: true, valueFormatter: format }), anchor }),
466
- [Content, format, anchor]
472
+ () => /* @__PURE__ */ jsx(
473
+ TreemapTooltip,
474
+ {
475
+ content: redactNames ? /* @__PURE__ */ jsx(RedactedTooltipContent, { hideLabel: true, valueFormatter: format, groups: redactNames === true }) : /* @__PURE__ */ jsx(ChartTooltipContent, { hideLabel: true, valueFormatter: format }),
476
+ anchor
477
+ }
478
+ ),
479
+ [redactNames, format, anchor]
467
480
  );
468
481
  if (nodes.length === 0) return null;
469
482
  const box = chartHeightProps(height);