@eifi1/ui-kit 0.7.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/README.md +32 -17
  2. package/dist/chart.d.ts +3 -2
  3. package/dist/components/alert-banner.d.ts +59 -10
  4. package/dist/components/alert-banner.js +114 -8
  5. package/dist/components/alert-banner.js.map +1 -1
  6. package/dist/components/amount-input.d.ts +3 -0
  7. package/dist/components/button-group.d.ts +26 -0
  8. package/dist/components/button-group.js +49 -0
  9. package/dist/components/button-group.js.map +1 -0
  10. package/dist/components/calculator.d.ts +3 -0
  11. package/dist/components/chart-zoom.d.ts +63 -14
  12. package/dist/components/chart-zoom.js +82 -16
  13. package/dist/components/chart-zoom.js.map +1 -1
  14. package/dist/components/chip.d.ts +67 -2
  15. package/dist/components/chip.js +73 -8
  16. package/dist/components/chip.js.map +1 -1
  17. package/dist/components/confirm-dialog.d.ts +120 -0
  18. package/dist/components/confirm-dialog.js +96 -0
  19. package/dist/components/confirm-dialog.js.map +1 -0
  20. package/dist/components/copy-button.d.ts +62 -0
  21. package/dist/components/copy-button.js +95 -0
  22. package/dist/components/copy-button.js.map +1 -0
  23. package/dist/components/data-table-filter-popover.d.ts +1 -1
  24. package/dist/components/data-table-filters.d.ts +1 -1
  25. package/dist/components/data-table-pagination.d.ts +5 -1
  26. package/dist/components/data-table-pagination.js +71 -58
  27. package/dist/components/data-table-pagination.js.map +1 -1
  28. package/dist/components/data-table-sort.d.ts +28 -5
  29. package/dist/components/data-table-sort.js +11 -7
  30. package/dist/components/data-table-sort.js.map +1 -1
  31. package/dist/components/data-table.d.ts +1 -1
  32. package/dist/components/data-table.js +544 -423
  33. package/dist/components/data-table.js.map +1 -1
  34. package/dist/components/date-picker.d.ts +51 -5
  35. package/dist/components/date-picker.js +152 -40
  36. package/dist/components/date-picker.js.map +1 -1
  37. package/dist/components/description-list.d.ts +60 -0
  38. package/dist/components/description-list.js +112 -0
  39. package/dist/components/description-list.js.map +1 -0
  40. package/dist/components/disclosure.d.ts +37 -2
  41. package/dist/components/disclosure.js +14 -5
  42. package/dist/components/disclosure.js.map +1 -1
  43. package/dist/components/facing-pair.d.ts +2 -0
  44. package/dist/components/file-button.d.ts +17 -1
  45. package/dist/components/file-button.js +8 -1
  46. package/dist/components/file-button.js.map +1 -1
  47. package/dist/components/file-dropzone.d.ts +54 -9
  48. package/dist/components/file-dropzone.js +100 -70
  49. package/dist/components/file-dropzone.js.map +1 -1
  50. package/dist/components/floating-panel.d.ts +107 -0
  51. package/dist/components/floating-panel.js +206 -0
  52. package/dist/components/floating-panel.js.map +1 -0
  53. package/dist/components/full-bleed-dialog.d.ts +12 -1
  54. package/dist/components/full-bleed-dialog.js +28 -5
  55. package/dist/components/full-bleed-dialog.js.map +1 -1
  56. package/dist/components/modal.d.ts +6 -2
  57. package/dist/components/modal.js +2 -1
  58. package/dist/components/modal.js.map +1 -1
  59. package/dist/components/number-field.d.ts +3 -0
  60. package/dist/components/number-input.d.ts +3 -0
  61. package/dist/components/numpad-sheet.d.ts +3 -0
  62. package/dist/components/progress-bar.d.ts +54 -0
  63. package/dist/components/progress-bar.js +94 -0
  64. package/dist/components/progress-bar.js.map +1 -0
  65. package/dist/components/scroll-area.d.ts +53 -0
  66. package/dist/components/scroll-area.js +86 -0
  67. package/dist/components/scroll-area.js.map +1 -0
  68. package/dist/components/separator.d.ts +23 -0
  69. package/dist/components/separator.js +24 -0
  70. package/dist/components/separator.js.map +1 -0
  71. package/dist/components/series-chart-ticks.d.ts +34 -1
  72. package/dist/components/series-chart-ticks.js +83 -1
  73. package/dist/components/series-chart-ticks.js.map +1 -1
  74. package/dist/components/series-chart.d.ts +314 -19
  75. package/dist/components/series-chart.js +510 -120
  76. package/dist/components/series-chart.js.map +1 -1
  77. package/dist/components/skeleton.d.ts +36 -0
  78. package/dist/components/skeleton.js +35 -0
  79. package/dist/components/skeleton.js.map +1 -0
  80. package/dist/components/stat-tile.d.ts +60 -6
  81. package/dist/components/stat-tile.js +60 -26
  82. package/dist/components/stat-tile.js.map +1 -1
  83. package/dist/components/table.d.ts +83 -0
  84. package/dist/components/table.js +166 -0
  85. package/dist/components/table.js.map +1 -0
  86. package/dist/components/toggle-legend.d.ts +3 -2
  87. package/dist/components/toggle-legend.js +1 -1
  88. package/dist/components/toggle-legend.js.map +1 -1
  89. package/dist/components/tree-view.d.ts +129 -0
  90. package/dist/components/tree-view.js +376 -0
  91. package/dist/components/tree-view.js.map +1 -0
  92. package/dist/components/treemap.d.ts +9 -2
  93. package/dist/components/treemap.js +6 -2
  94. package/dist/components/treemap.js.map +1 -1
  95. package/dist/components/ui.d.ts +94 -13
  96. package/dist/components/ui.js +111 -29
  97. package/dist/components/ui.js.map +1 -1
  98. package/dist/components/use-table-state.d.ts +1 -1
  99. package/dist/{data-table-filters-noy0Abvi.d.ts → data-table-filters-CF1PXqjQ.d.ts} +73 -3
  100. package/dist/data-table.d.ts +2 -2
  101. package/dist/data-table.js.map +1 -1
  102. package/dist/hooks/use-copy-to-clipboard.d.ts +28 -0
  103. package/dist/hooks/use-copy-to-clipboard.js +81 -0
  104. package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
  105. package/dist/hooks/use-debounce.d.ts +43 -0
  106. package/dist/hooks/use-debounce.js +56 -0
  107. package/dist/hooks/use-debounce.js.map +1 -0
  108. package/dist/hooks/use-file-drop.d.ts +72 -0
  109. package/dist/hooks/use-file-drop.js +57 -0
  110. package/dist/hooks/use-file-drop.js.map +1 -0
  111. package/dist/i18n/defaults.d.ts +3 -0
  112. package/dist/i18n/defaults.js +7 -1
  113. package/dist/i18n/defaults.js.map +1 -1
  114. package/dist/i18n/kit-labels.d.ts +15 -0
  115. package/dist/i18n/kit-labels.js +6 -2
  116. package/dist/i18n/kit-labels.js.map +1 -1
  117. package/dist/i18n/locales/de-CH-informal.d.ts +43 -0
  118. package/dist/i18n/locales/de-CH-informal.js +8 -0
  119. package/dist/i18n/locales/de-CH-informal.js.map +1 -0
  120. package/dist/i18n/locales/de-CH.d.ts +3 -0
  121. package/dist/i18n/locales/de-CH.js +1 -14
  122. package/dist/i18n/locales/de-CH.js.map +1 -1
  123. package/dist/i18n/locales/de-informal.d.ts +64 -0
  124. package/dist/i18n/locales/de-informal.js +37 -0
  125. package/dist/i18n/locales/de-informal.js.map +1 -0
  126. package/dist/i18n/locales/de.d.ts +3 -0
  127. package/dist/i18n/locales/de.js +25 -0
  128. package/dist/i18n/locales/de.js.map +1 -1
  129. package/dist/i18n/locales/es.d.ts +3 -0
  130. package/dist/i18n/locales/es.js +25 -0
  131. package/dist/i18n/locales/es.js.map +1 -1
  132. package/dist/i18n/locales/fr.d.ts +3 -0
  133. package/dist/i18n/locales/fr.js +25 -0
  134. package/dist/i18n/locales/fr.js.map +1 -1
  135. package/dist/i18n/locales/hu.d.ts +3 -0
  136. package/dist/i18n/locales/hu.js +25 -0
  137. package/dist/i18n/locales/hu.js.map +1 -1
  138. package/dist/i18n/locales/it.d.ts +3 -0
  139. package/dist/i18n/locales/it.js +25 -0
  140. package/dist/i18n/locales/it.js.map +1 -1
  141. package/dist/i18n/locales/zh.d.ts +3 -0
  142. package/dist/i18n/locales/zh.js +25 -0
  143. package/dist/i18n/locales/zh.js.map +1 -1
  144. package/dist/i18n/swiss.d.ts +13 -0
  145. package/dist/i18n/swiss.js +19 -0
  146. package/dist/i18n/swiss.js.map +1 -0
  147. package/dist/index.d.ts +25 -10
  148. package/dist/index.js +22 -0
  149. package/dist/index.js.map +1 -1
  150. package/dist/lib/dates.d.ts +37 -1
  151. package/dist/lib/dates.js +19 -0
  152. package/dist/lib/dates.js.map +1 -1
  153. package/dist/search/command-palette.d.ts +15 -1
  154. package/dist/search/command-palette.js +10 -2
  155. package/dist/search/command-palette.js.map +1 -1
  156. package/dist/wizard/stepper-nav.d.ts +35 -2
  157. package/dist/wizard/stepper-nav.js +54 -22
  158. package/dist/wizard/stepper-nav.js.map +1 -1
  159. package/dist/wizard/types.d.ts +107 -5
  160. package/dist/wizard/types.js +2 -1
  161. package/dist/wizard/types.js.map +1 -1
  162. package/dist/wizard/use-wizard.js +141 -21
  163. package/dist/wizard/use-wizard.js.map +1 -1
  164. package/dist/wizard/wizard-summary.d.ts +10 -2
  165. package/dist/wizard/wizard-summary.js +3 -1
  166. package/dist/wizard/wizard-summary.js.map +1 -1
  167. package/dist/wizard.d.ts +4 -1
  168. package/dist/wizard.js.map +1 -1
  169. package/package.json +1 -1
  170. package/src/components/alert-banner.tsx +211 -20
  171. package/src/components/button-group.tsx +75 -0
  172. package/src/components/chart-zoom.tsx +158 -20
  173. package/src/components/chip.tsx +160 -9
  174. package/src/components/confirm-dialog.tsx +242 -0
  175. package/src/components/copy-button.tsx +158 -0
  176. package/src/components/data-table-pagination.tsx +19 -6
  177. package/src/components/data-table-sort.ts +49 -10
  178. package/src/components/data-table.tsx +293 -24
  179. package/src/components/date-picker.tsx +262 -57
  180. package/src/components/description-list.tsx +174 -0
  181. package/src/components/disclosure.tsx +58 -5
  182. package/src/components/file-button.tsx +22 -2
  183. package/src/components/file-dropzone.tsx +198 -100
  184. package/src/components/floating-panel.tsx +341 -0
  185. package/src/components/full-bleed-dialog.tsx +53 -5
  186. package/src/components/modal.tsx +9 -2
  187. package/src/components/progress-bar.tsx +163 -0
  188. package/src/components/scroll-area.tsx +129 -0
  189. package/src/components/separator.tsx +37 -0
  190. package/src/components/series-chart-ticks.ts +135 -0
  191. package/src/components/series-chart.tsx +934 -67
  192. package/src/components/skeleton.tsx +65 -0
  193. package/src/components/stat-tile.tsx +160 -27
  194. package/src/components/table.tsx +263 -0
  195. package/src/components/toggle-legend.tsx +4 -3
  196. package/src/components/tree-view.tsx +589 -0
  197. package/src/components/treemap.tsx +13 -2
  198. package/src/components/ui.tsx +270 -39
  199. package/src/data-table.ts +2 -0
  200. package/src/hooks/use-copy-to-clipboard.ts +122 -0
  201. package/src/hooks/use-debounce.ts +105 -0
  202. package/src/hooks/use-file-drop.ts +123 -0
  203. package/src/i18n/defaults.ts +6 -0
  204. package/src/i18n/kit-labels.tsx +19 -0
  205. package/src/i18n/locales/de-CH-informal.ts +10 -0
  206. package/src/i18n/locales/de-CH.ts +1 -16
  207. package/src/i18n/locales/de-informal.ts +61 -0
  208. package/src/i18n/locales/de.ts +25 -0
  209. package/src/i18n/locales/es.ts +25 -0
  210. package/src/i18n/locales/fr.ts +25 -0
  211. package/src/i18n/locales/hu.ts +25 -0
  212. package/src/i18n/locales/it.ts +25 -0
  213. package/src/i18n/locales/zh.ts +25 -0
  214. package/src/i18n/swiss.ts +25 -0
  215. package/src/index.ts +29 -0
  216. package/src/lib/dates.ts +48 -0
  217. package/src/search/command-palette.tsx +29 -3
  218. package/src/wizard/stepper-nav.tsx +102 -28
  219. package/src/wizard/types.ts +106 -4
  220. package/src/wizard/use-wizard.ts +211 -31
  221. package/src/wizard/wizard-summary.tsx +24 -12
  222. package/src/wizard.ts +3 -2
@@ -0,0 +1,112 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { createContext, useContext } from "react";
4
+ import { cn } from "../lib/cn.js";
5
+ import { FieldHint } from "./ui.js";
6
+ const ListContext = createContext({ layout: "rows", numeric: false, density: "comfortable" });
7
+ function DescriptionList({
8
+ layout = "rows",
9
+ numeric = false,
10
+ density = "comfortable",
11
+ minCardWidth = "10rem",
12
+ className,
13
+ style,
14
+ ...rest
15
+ }) {
16
+ const cards = layout === "cards";
17
+ const grid = cards ? { gridTemplateColumns: `repeat(auto-fill, minmax(min(100%, ${minCardWidth}), 1fr))` } : void 0;
18
+ return /* @__PURE__ */ jsx(ListContext.Provider, { value: { layout, numeric, density }, children: /* @__PURE__ */ jsx(
19
+ "dl",
20
+ {
21
+ ...rest,
22
+ "data-layout": layout,
23
+ style: grid ? { ...grid, ...style } : style,
24
+ className: cn(
25
+ cards ? cn("grid", density === "compact" ? "gap-2" : "gap-3") : "@container divide-y divide-[var(--border)]",
26
+ density === "compact" ? "text-xs" : "text-sm",
27
+ className
28
+ )
29
+ }
30
+ ) });
31
+ }
32
+ const ROW_PAD = { comfortable: "py-2.5", compact: "py-1.5" };
33
+ const CARD_PAD = { comfortable: "px-3 py-2.5", compact: "px-2.5 py-1.5" };
34
+ function DescriptionItem({
35
+ term,
36
+ children,
37
+ hint,
38
+ numeric: numericProp,
39
+ detailClassName,
40
+ className,
41
+ ...rest
42
+ }) {
43
+ const { layout, numeric: listNumeric, density } = useContext(ListContext);
44
+ const numeric = numericProp ?? listNumeric;
45
+ const cards = layout === "cards";
46
+ const termNode = /* @__PURE__ */ jsxs(
47
+ "dt",
48
+ {
49
+ className: cn(
50
+ "flex min-w-0 items-center gap-1 text-[var(--text-muted)]",
51
+ cards && "text-xs uppercase tracking-wide"
52
+ ),
53
+ children: [
54
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 break-words", children: term }),
55
+ hint && /* @__PURE__ */ jsx(FieldHint, { label: hint, side: "top", className: "shrink-0" })
56
+ ]
57
+ }
58
+ );
59
+ const detail = /* @__PURE__ */ jsx(
60
+ "dd",
61
+ {
62
+ className: cn(
63
+ "min-w-0 break-words text-[var(--text-primary)]",
64
+ numeric && "tabular-nums text-end",
65
+ cards && "mt-0.5 font-medium",
66
+ detailClassName
67
+ ),
68
+ children
69
+ }
70
+ );
71
+ if (cards) {
72
+ return /* @__PURE__ */ jsxs(
73
+ "div",
74
+ {
75
+ ...rest,
76
+ className: cn(
77
+ "min-w-0 rounded-md border border-[var(--border)] bg-[var(--bg-surface)]",
78
+ CARD_PAD[density],
79
+ className
80
+ ),
81
+ children: [
82
+ termNode,
83
+ detail
84
+ ]
85
+ }
86
+ );
87
+ }
88
+ return /* @__PURE__ */ jsxs(
89
+ "div",
90
+ {
91
+ ...rest,
92
+ className: cn(
93
+ "grid gap-x-4 gap-y-0.5",
94
+ numeric ? (
95
+ // Never stacks: a figure is short (see DescriptionListProps.numeric).
96
+ "grid-cols-[minmax(0,1fr)_auto] items-baseline"
97
+ ) : "grid-cols-1 @sm:grid-cols-[minmax(0,1fr)_minmax(0,2fr)] @sm:items-baseline",
98
+ ROW_PAD[density],
99
+ className
100
+ ),
101
+ children: [
102
+ termNode,
103
+ detail
104
+ ]
105
+ }
106
+ );
107
+ }
108
+ export {
109
+ DescriptionItem,
110
+ DescriptionList
111
+ };
112
+ //# sourceMappingURL=description-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/description-list.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { ComponentPropsWithoutRef, CSSProperties, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { FieldHint } from \"./ui\";\n\nexport type DescriptionListLayout = \"rows\" | \"cards\";\nexport type DescriptionListDensity = \"comfortable\" | \"compact\";\n\ninterface ListContextValue {\n layout: DescriptionListLayout;\n numeric: boolean;\n density: DescriptionListDensity;\n}\n\nconst ListContext = createContext<ListContextValue>({ layout: \"rows\", numeric: false, density: \"comfortable\" });\n\nexport interface DescriptionListProps extends ComponentPropsWithoutRef<\"dl\"> {\n /**\n * `rows` (default): term beside detail, a two-column list that stacks the pair\n * when the LIST is narrower than 24rem — a container query, so a detail panel\n * beside a sidebar stacks where it is actually cramped, not where the viewport is.\n * `cards`: a grid of small bordered cards, term above body — keksdose's overview\n * figures, lenkbank's account facts.\n */\n layout?: DescriptionListLayout;\n /** Every detail is a figure: tabular digits, end-aligned. A `numeric` list of\n * rows does not stack on a phone — a figure is short, and putting it under its\n * term would double the list's height to gain no width. Per item: see\n * {@link DescriptionItemProps.numeric}. */\n numeric?: boolean;\n /** `compact` tightens the rhythm for a dense side panel. */\n density?: DescriptionListDensity;\n /** `cards` only: the narrowest a card may get before the grid drops a column. */\n minCardWidth?: string;\n}\n\n/**\n * A real `<dl>` — terms and their details, which is what keksdose's eight and\n * lenkbank's four hand-built \"label: value\" blocks were, and none of them said so.\n * As a `<dl>` a reader announces \"list, 6 items\" and pairs each term with its detail;\n * as a stack of `<div>`s it read one undifferentiated run of text.\n *\n * Composed from {@link DescriptionItem} children rather than taking an `items`\n * array. The call sites this replaces are mostly CONDITIONAL — \"IBAN, if there is\n * one\", \"closing date, once closed\" — and `{iban && <DescriptionItem …>}` reads as\n * what it means, where an array wants `.filter(Boolean)` and a cast. Children also\n * give each item its own props (a numeric figure in an otherwise textual list, a\n * `data-private` detail) with no parallel config object. A data-driven list loses\n * nothing: `items.map((i) => <DescriptionItem key={i.term} {...i} />)`.\n *\n * Each pair is wrapped in a `<div>`, which HTML permits inside a `<dl>` for exactly\n * this: styling a pair as a unit (a row, a card) without breaking the list.\n */\nexport function DescriptionList({\n layout = \"rows\",\n numeric = false,\n density = \"comfortable\",\n minCardWidth = \"10rem\",\n className,\n style,\n ...rest\n}: DescriptionListProps) {\n const cards = layout === \"cards\";\n const grid: CSSProperties | undefined = cards\n ? { gridTemplateColumns: `repeat(auto-fill, minmax(min(100%, ${minCardWidth}), 1fr))` }\n : undefined;\n return (\n <ListContext.Provider value={{ layout, numeric, density }}>\n <dl\n {...rest}\n data-layout={layout}\n style={grid ? { ...grid, ...style } : style}\n className={cn(\n cards\n ? cn(\"grid\", density === \"compact\" ? \"gap-2\" : \"gap-3\")\n : \"@container divide-y divide-[var(--border)]\",\n density === \"compact\" ? \"text-xs\" : \"text-sm\",\n className,\n )}\n />\n </ListContext.Provider>\n );\n}\n\nexport interface DescriptionItemProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** What is described: \"Opened\", \"IBAN\", \"Net rent\". */\n term: ReactNode;\n /** The description itself. */\n children?: ReactNode;\n /** The explanation behind a \"?\" beside the term (a {@link FieldHint}) — the same\n * meaning `hint` has on `StatTile` and the labelled fields. */\n hint?: string;\n /** This detail is a figure (see {@link DescriptionListProps.numeric}); overrides\n * the list's setting either way. */\n numeric?: boolean;\n /** Classes for the `<dd>`. */\n detailClassName?: string;\n}\n\nconst ROW_PAD: Record<DescriptionListDensity, string> = { comfortable: \"py-2.5\", compact: \"py-1.5\" };\nconst CARD_PAD: Record<DescriptionListDensity, string> = { comfortable: \"px-3 py-2.5\", compact: \"px-2.5 py-1.5\" };\n\n/** One term and its detail inside a {@link DescriptionList}. */\nexport function DescriptionItem({\n term,\n children,\n hint,\n numeric: numericProp,\n detailClassName,\n className,\n ...rest\n}: DescriptionItemProps) {\n const { layout, numeric: listNumeric, density } = useContext(ListContext);\n const numeric = numericProp ?? listNumeric;\n const cards = layout === \"cards\";\n\n const termNode = (\n <dt\n className={cn(\n \"flex min-w-0 items-center gap-1 text-[var(--text-muted)]\",\n cards && \"text-xs uppercase tracking-wide\",\n )}\n >\n <span className=\"min-w-0 break-words\">{term}</span>\n {hint && <FieldHint label={hint} side=\"top\" className=\"shrink-0\" />}\n </dt>\n );\n const detail = (\n <dd\n className={cn(\n \"min-w-0 break-words text-[var(--text-primary)]\",\n numeric && \"tabular-nums text-end\",\n cards && \"mt-0.5 font-medium\",\n detailClassName,\n )}\n >\n {children}\n </dd>\n );\n\n if (cards) {\n return (\n <div\n {...rest}\n className={cn(\n \"min-w-0 rounded-md border border-[var(--border)] bg-[var(--bg-surface)]\",\n CARD_PAD[density],\n className,\n )}\n >\n {termNode}\n {detail}\n </div>\n );\n }\n\n return (\n <div\n {...rest}\n className={cn(\n \"grid gap-x-4 gap-y-0.5\",\n numeric\n ? // Never stacks: a figure is short (see DescriptionListProps.numeric).\n \"grid-cols-[minmax(0,1fr)_auto] items-baseline\"\n : \"grid-cols-1 @sm:grid-cols-[minmax(0,1fr)_minmax(0,2fr)] @sm:items-baseline\",\n ROW_PAD[density],\n className,\n )}\n >\n {termNode}\n {detail}\n </div>\n );\n}\n"],"mappings":";AAoEM,cAiDF,YAjDE;AApEN,SAAS,eAAe,kBAAkB;AAE1C,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAW1B,MAAM,cAAc,cAAgC,EAAE,QAAQ,QAAQ,SAAS,OAAO,SAAS,cAAc,CAAC;AAuCvG,SAAS,gBAAgB;AAAA,EAC9B,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;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;AAGF,MAAI,OAAO;AACT,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,WAAW;AAAA,UACT;AAAA,UACA,SAAS,OAAO;AAAA,UAChB;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,UACA;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT;AAAA,QACA;AAAA;AAAA,UAEI;AAAA,YACA;AAAA,QACJ,QAAQ,OAAO;AAAA,QACf;AAAA,MACF;AAAA,MAEC;AAAA;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -42,6 +42,15 @@ interface CollapseProps extends ComponentPropsWithoutRef<"div"> {
42
42
  * it, they would hold the row open by that much.
43
43
  */
44
44
  declare function Collapse({ open, keepMounted, children, className, style, ...rest }: CollapseProps): react.JSX.Element;
45
+ /**
46
+ * What {@link DisclosureProps.triggerProps} may put on the header button: its own
47
+ * attributes and handlers, and any `data-*`. Not the ones the disclosure owns —
48
+ * `aria-expanded`, `aria-controls`, `disabled`, `onClick`, `type` and the content — nor
49
+ * `className`, which is {@link DisclosureProps.headerClassName}.
50
+ */
51
+ type DisclosureTriggerProps = Omit<ComponentPropsWithoutRef<"button">, "type" | "aria-expanded" | "aria-controls" | "disabled" | "onClick" | "children" | "className"> & {
52
+ [data: `data-${string}`]: string | number | boolean | undefined;
53
+ };
45
54
  /**
46
55
  * `title` is omitted from the div's own props because this component already owns the
47
56
  * name: here it is the header's content (and a ReactNode), not the browser's tooltip.
@@ -73,6 +82,16 @@ interface DisclosureProps extends Omit<ComponentPropsWithoutRef<"div">, "title">
73
82
  * its own surface.
74
83
  */
75
84
  variant?: "card" | "bare";
85
+ /**
86
+ * Where a `bare` disclosure draws its chevron. `start` (default) is the leading
87
+ * chevron that turns from the reading direction to down. `end` puts it at the far
88
+ * end of the row, pointing down and turning up as the card's does — keksdose's
89
+ * account menu, whose language sub-list reads "Language 🇩🇪 ⌄" with the chevron
90
+ * after the flag, like every other menu row with a sub-list. With `trailing`, the
91
+ * chevron follows it, as on a card. A `card` always has it at the end, so this is
92
+ * ignored there.
93
+ */
94
+ chevronPosition?: "start" | "end";
76
95
  /**
77
96
  * Wrap the header button in a heading of this level. The WAI-ARIA disclosure pattern
78
97
  * puts the button INSIDE the heading when the disclosure titles a section, so the
@@ -85,6 +104,22 @@ interface DisclosureProps extends Omit<ComponentPropsWithoutRef<"div">, "title">
85
104
  disabled?: boolean;
86
105
  /** Extra classes for the header button. */
87
106
  headerClassName?: string;
107
+ /**
108
+ * Attributes for the header BUTTON — the outer props go to the wrapping div — such as
109
+ * an `aria-label`, an `id` or a `data-*` test hook. A function of the open state
110
+ * when they depend on it: keksdose's budget table names each group's toggle
111
+ * "Expand group Food" / "Collapse group Food", because the visible title is only the
112
+ * group's name:
113
+ *
114
+ * ```tsx
115
+ * triggerProps={(open) => ({ "aria-label": t(open ? "collapseGroup" : "expandGroup", { name }) })}
116
+ * ```
117
+ *
118
+ * An `aria-label` REPLACES the title as the button's name, so it must still contain
119
+ * the title's words (WCAG 2.5.3, label in name). See {@link DisclosureTriggerProps}
120
+ * for what the disclosure keeps for itself.
121
+ */
122
+ triggerProps?: DisclosureTriggerProps | ((open: boolean) => DisclosureTriggerProps);
88
123
  /** Extra classes for the body's wrapper — where its padding and spacing live. */
89
124
  bodyClassName?: string;
90
125
  /**
@@ -123,6 +158,6 @@ interface DisclosureProps extends Omit<ComponentPropsWithoutRef<"div">, "title">
123
158
  * The body is unmounted while shut; see {@link CollapseProps.keepMounted} for why that
124
159
  * is the default and when to opt out.
125
160
  */
126
- declare function Disclosure({ title, hint, open: controlled, defaultOpen, onOpenChange, variant, headingAs: Heading, keepMounted, disabled, headerClassName, bodyClassName, trailing, controls, className, children, ...rest }: DisclosureProps): react.JSX.Element;
161
+ declare function Disclosure({ title, hint, open: controlled, defaultOpen, onOpenChange, variant, chevronPosition, headingAs: Heading, keepMounted, disabled, headerClassName, triggerProps, bodyClassName, trailing, controls, className, children, ...rest }: DisclosureProps): react.JSX.Element;
127
162
 
128
- export { Collapse, type CollapseProps, Disclosure, type DisclosureProps };
163
+ export { Collapse, type CollapseProps, Disclosure, type DisclosureProps, type DisclosureTriggerProps };
@@ -50,10 +50,12 @@ function Disclosure({
50
50
  defaultOpen = false,
51
51
  onOpenChange,
52
52
  variant = "card",
53
+ chevronPosition = "start",
53
54
  headingAs: Heading,
54
55
  keepMounted,
55
56
  disabled,
56
57
  headerClassName,
58
+ triggerProps,
57
59
  bodyClassName,
58
60
  trailing,
59
61
  controls,
@@ -65,6 +67,7 @@ function Disclosure({
65
67
  const open = controlled ?? own;
66
68
  const bodyId = useId();
67
69
  const card = variant === "card";
70
+ const chevronAtEnd = card || chevronPosition === "end";
68
71
  const triggerOnly = controls !== void 0;
69
72
  const joined = open && !triggerOnly;
70
73
  const hasTrailing = trailing !== void 0 && trailing !== null && trailing !== false;
@@ -73,9 +76,11 @@ function Disclosure({
73
76
  if (controlled === void 0) setOwn(next);
74
77
  onOpenChange?.(next);
75
78
  };
79
+ const extraTriggerProps = typeof triggerProps === "function" ? triggerProps(open) : triggerProps;
76
80
  const button = /* @__PURE__ */ jsxs(
77
81
  "button",
78
82
  {
83
+ ...extraTriggerProps,
79
84
  type: "button",
80
85
  "aria-expanded": open,
81
86
  "aria-controls": triggerOnly ? controls : bodyId,
@@ -102,12 +107,12 @@ function Disclosure({
102
107
  headerClassName
103
108
  ),
104
109
  children: [
105
- !card && /* @__PURE__ */ jsx(Chevron, { open, leading: true }),
110
+ !chevronAtEnd && /* @__PURE__ */ jsx(Chevron, { open, leading: true }),
106
111
  /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
107
112
  /* @__PURE__ */ jsx("span", { className: cn("block", card && "text-sm font-semibold text-[var(--text-primary)]"), children: title }),
108
113
  hint !== void 0 && /* @__PURE__ */ jsx("span", { className: "mt-0.5 block text-xs font-normal text-[var(--text-muted)]", children: hint })
109
114
  ] }),
110
- card && !hasTrailing && /* @__PURE__ */ jsx(Chevron, { open })
115
+ chevronAtEnd && !hasTrailing && /* @__PURE__ */ jsx(Chevron, { open, small: !card })
111
116
  ]
112
117
  }
113
118
  );
@@ -131,7 +136,7 @@ function Disclosure({
131
136
  children: [
132
137
  header,
133
138
  /* @__PURE__ */ jsx("div", { className: "relative flex shrink-0 items-center gap-2", children: trailing }),
134
- card && /* @__PURE__ */ jsx(Chevron, { open })
139
+ chevronAtEnd && /* @__PURE__ */ jsx(Chevron, { open, small: !card })
135
140
  ]
136
141
  }
137
142
  ) : header,
@@ -140,14 +145,18 @@ function Disclosure({
140
145
  }
141
146
  );
142
147
  }
143
- function Chevron({ open, leading = false }) {
148
+ function Chevron({
149
+ open,
150
+ leading = false,
151
+ small = leading
152
+ }) {
144
153
  return /* @__PURE__ */ jsx(
145
154
  ChevronDown,
146
155
  {
147
156
  "aria-hidden": true,
148
157
  className: cn(
149
158
  "shrink-0 text-[var(--text-muted)] transition-transform duration-200 ease-out motion-reduce:transition-none",
150
- leading ? "size-3.5" : "size-4",
159
+ small ? "size-3.5" : "size-4",
151
160
  leading ? !open && "-rotate-90 rtl:rotate-90" : open && "rotate-180"
152
161
  )
153
162
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/disclosure.tsx"],"sourcesContent":["import { useEffect, useId, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { ChevronDown } from \"lucide-react\";\n\nimport { cn } from \"../lib/cn\";\n\n/** How long the fold takes, in ms. The same number as the `duration-200` below and as\n * the unmount timer, because they are the same movement. */\nconst COLLAPSE_MS = 200;\n\n/** Read at the moment of closing, like `useCloseTransition` does: the setting can\n * change under a long-lived page, and jsdom/SSR have no `matchMedia` — where \"no\n * animation\" is also the only correct answer, since nothing is painting. */\nfunction prefersReducedMotion(): boolean {\n return (\n typeof window === \"undefined\" ||\n typeof window.matchMedia !== \"function\" ||\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n );\n}\n\n/**\n * `extends` the div's props so an `id` (what a trigger's `aria-controls` points at), a\n * `data-tour` anchor or a test id reaches the element that folds.\n */\nexport interface CollapseProps extends ComponentPropsWithoutRef<\"div\"> {\n open: boolean;\n /**\n * Keep the children mounted while shut (hidden and `inert`) instead of unmounting\n * them once the fold has finished closing.\n *\n * Off by default, and that default is a behaviour contract rather than a\n * performance note: Lenkbank's disclosure bodies FETCH, and a body that only exists\n * while open is what stops a closed card asking — without every caller carrying its\n * own `enabled: open`. On for a body whose state must outlive a close (a half-typed\n * form) or that must be found by the browser's find-in-page.\n */\n keepMounted?: boolean;\n children: ReactNode;\n}\n\n/**\n * The fold on its own: content that opens and shuts in place, animated to a height\n * nobody measured.\n *\n * THE TECHNIQUE is `AppShell`'s sidebar group's, lifted out so there is one copy of it.\n * A `grid-template-rows` transition from `0fr` to `1fr` is the one way to animate to a\n * content-sized height without measuring it — so a chart that resizes inside it, or a\n * translated line that wraps, is still exactly as tall as it needs. `visibility` rides\n * the same transition, so a shut body leaves the accessibility tree only once it has\n * finished closing; `inert` takes it out of the tab order immediately.\n *\n * THE CHILDREN are unmounted once closed (see {@link CollapseProps.keepMounted}), but\n * only once the track has finished closing: the track is what animates, so the\n * children have to survive the movement that hides them. Under reduced motion they\n * go at once — there is no movement to wait for — and the opening half is silenced by\n * `motion-reduce:transition-none`, since tokens.css only silences the overlay\n * animations by name.\n *\n * Padding and margins belong on a child: on this element, or the clipping one inside\n * it, they would hold the row open by that much.\n */\nexport function Collapse({ open, keepMounted = false, children, className, style, ...rest }: CollapseProps) {\n // Whether the children are still on their way out. Adjusted DURING render when\n // `open` flips (React's \"storing information from previous renders\"), so a close\n // under reduced motion unmounts in the same render that shut it — a test, and a\n // screen reader, see the body go on the click — and a re-open mid-fold simply\n // cancels the linger.\n const [lingering, setLingering] = useState(false);\n const [prevOpen, setPrevOpen] = useState(open);\n if (open !== prevOpen) {\n setPrevOpen(open);\n setLingering(!open && !prefersReducedMotion());\n }\n useEffect(() => {\n if (!lingering) return;\n const timer = setTimeout(() => setLingering(false), COLLAPSE_MS);\n return () => clearTimeout(timer);\n }, [lingering]);\n\n const mounted = open || lingering || keepMounted;\n\n return (\n <div\n {...rest}\n inert={!open}\n className={cn(\n \"grid transition-[grid-template-rows,visibility] duration-200 ease-out motion-reduce:transition-none\",\n className,\n )}\n // Inline rather than `grid-rows-[…]` classes: a caller's `className` must not be\n // able to pin the track open, and the two values ARE the state.\n style={{ ...style, gridTemplateRows: open ? \"1fr\" : \"0fr\", visibility: open ? \"visible\" : \"hidden\" }}\n >\n <div\n className={cn(\n \"min-h-0 overflow-hidden transition-opacity duration-200 ease-out motion-reduce:transition-none\",\n open ? \"opacity-100\" : \"opacity-0\",\n )}\n >\n {mounted && children}\n </div>\n </div>\n );\n}\n\n/**\n * `title` is omitted from the div's own props because this component already owns the\n * name: here it is the header's content (and a ReactNode), not the browser's tooltip.\n * Everything else reaches the outer element.\n */\nexport interface DisclosureProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"title\"> {\n /** What the header says. A node, so a status chip or a count can sit in it. */\n title: ReactNode;\n /** The smaller line under the title — what is inside, for a reader deciding whether\n * to open it. */\n hint?: ReactNode;\n /**\n * Who decides whether this one is open. Left out, the disclosure decides for itself,\n * which is what one standing on its own wants. Passed, the caller does — a set of\n * which one is open at a time, or an open state kept in the URL so the view can be\n * linked to. There is no accordion component: \"one open at a time\" is a few lines in\n * the caller and it usually owns a URL parameter, which is app state.\n */\n open?: boolean;\n /** Whether an UNCONTROLLED disclosure starts open. Ignored when `open` is passed. */\n defaultOpen?: boolean;\n /** Called with the next state on every toggle, controlled or not. */\n onOpenChange?: (open: boolean) => void;\n /**\n * `card` (default) draws the kit's `Card` surface round header and body, with the\n * chevron trailing the header and turning over — the \"section that opens\" of a\n * settings or analysis page. `bare` draws nothing: a leading chevron that turns\n * down, for an inline \"Show 3 hidden accounts\" inside something that already has\n * its own surface.\n */\n variant?: \"card\" | \"bare\";\n /**\n * Wrap the header button in a heading of this level. The WAI-ARIA disclosure pattern\n * puts the button INSIDE the heading when the disclosure titles a section, so the\n * page's heading outline still lists it. Off by default: an inline \"show more\" is\n * not a section.\n */\n headingAs?: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n /** See {@link CollapseProps.keepMounted}. */\n keepMounted?: boolean;\n disabled?: boolean;\n /** Extra classes for the header button. */\n headerClassName?: string;\n /** Extra classes for the body's wrapper — where its padding and spacing live. */\n bodyClassName?: string;\n /**\n * Content at the far end of the header row, beside the title: a count, a date, a\n * status chip, an action button. It is a SIBLING of the header button, never inside\n * it — a button may not contain another interactive element, and a count inside it\n * would also be read as part of the button's name. The header button still spans\n * the row under it (a stretched hit area), so clicking the empty space or the\n * card's chevron still toggles, while whatever sits in `trailing` gets its own\n * clicks. With `trailing`, the card's chevron moves after it, to the row's end.\n */\n trailing?: ReactNode;\n /**\n * Trigger-only mode: the id of an element the CALLER renders elsewhere — the hidden\n * rows of a table, a panel in another column — which this header shows and hides.\n * The header's `aria-controls` points at it and the disclosure renders no body of\n * its own (`children`, `bodyClassName` and `keepMounted` are ignored). Pair it with\n * `open` / `onOpenChange`: the caller owns the state, since the caller renders what\n * it governs.\n */\n controls?: string;\n /** The body. Not rendered in trigger-only mode ({@link DisclosureProps.controls}). */\n children?: ReactNode;\n}\n\n/**\n * A section that opens in place: a header button with `aria-expanded` and\n * `aria-controls`, and a {@link Collapse} under it.\n *\n * Both apps had written this by hand — Lenkbank as a shared `CollapsibleCard` with ten\n * importers, Keksdose three separate times (accounts, twice; the support panel) — and\n * the copies had drifted: none of Keksdose's animated, and all three swapped a\n * `ChevronRight` for a `ChevronDown` rather than turning one. Here the chevron is one\n * icon that rotates, so the change of state is one element moving rather than two\n * trading places.\n *\n * The body is unmounted while shut; see {@link CollapseProps.keepMounted} for why that\n * is the default and when to opt out.\n */\nexport function Disclosure({\n title,\n hint,\n open: controlled,\n defaultOpen = false,\n onOpenChange,\n variant = \"card\",\n headingAs: Heading,\n keepMounted,\n disabled,\n headerClassName,\n bodyClassName,\n trailing,\n controls,\n className,\n children,\n ...rest\n}: DisclosureProps) {\n const [own, setOwn] = useState(defaultOpen);\n const open = controlled ?? own;\n const bodyId = useId();\n const card = variant === \"card\";\n const triggerOnly = controls !== undefined;\n // The card's header squares its lower corners only when a body opens under it.\n const joined = open && !triggerOnly;\n const hasTrailing = trailing !== undefined && trailing !== null && trailing !== false;\n\n const toggle = () => {\n const next = !open;\n if (controlled === undefined) setOwn(next);\n onOpenChange?.(next);\n };\n\n const button = (\n <button\n type=\"button\"\n aria-expanded={open}\n aria-controls={triggerOnly ? controls : bodyId}\n disabled={disabled}\n onClick={toggle}\n data-disclosure-trigger=\"\"\n className={cn(\n \"flex w-full gap-2 text-start outline-none disabled:cursor-not-allowed disabled:opacity-50\",\n hasTrailing\n ? // Stretched over the whole header row (the row is `relative`), so the space\n // round `trailing` and the card's chevron still toggle; the ring and the\n // card's hover paint on the stretched area / the row, not the text box.\n cn(\n \"min-w-0 flex-1 after:absolute after:inset-0 after:content-['']\",\n \"focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-[var(--brand)]\",\n card ? cn(\"after:rounded-lg\", joined && \"after:rounded-b-none\") : \"after:rounded-sm\",\n )\n : \"focus-visible:ring-2 focus-visible:ring-[var(--brand)]\",\n card\n ? cn(\n \"items-center justify-between rounded-lg p-4\",\n hasTrailing ? \"pe-0\" : \"hover:bg-[var(--bg-hover)] focus-visible:ring-inset\",\n joined && \"rounded-b-none\",\n )\n : \"items-center rounded-sm text-sm font-medium text-[var(--text-secondary)] hover:text-[var(--text-primary)]\",\n headerClassName,\n )}\n >\n {!card && <Chevron open={open} leading />}\n {/* `flex-1`: the title takes the row, so whatever a caller puts at its end sits\n at the header's far edge. */}\n <span className=\"min-w-0 flex-1\">\n <span className={cn(\"block\", card && \"text-sm font-semibold text-[var(--text-primary)]\")}>{title}</span>\n {hint !== undefined && (\n <span className=\"mt-0.5 block text-xs font-normal text-[var(--text-muted)]\">{hint}</span>\n )}\n </span>\n {card && !hasTrailing && <Chevron open={open} />}\n </button>\n );\n\n // Preflight already makes h1–h6 inherit size and weight, so the heading adds\n // structure and nothing visible.\n const header = Heading ? <Heading className={hasTrailing ? \"min-w-0 flex-1\" : undefined}>{button}</Heading> : button;\n\n return (\n <div\n {...rest}\n className={cn(card && \"rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] shadow-sm\", className)}\n >\n {hasTrailing ? (\n <div\n className={cn(\n \"relative flex items-center gap-2\",\n card &&\n cn(\n \"rounded-lg pe-4 has-[[data-disclosure-trigger]:enabled:hover]:bg-[var(--bg-hover)]\",\n joined && \"rounded-b-none\",\n ),\n )}\n >\n {header}\n {/* Positioned, so it paints over the stretched button and takes its own\n clicks; the chevron is not, so a click on it lands on the button. */}\n <div className=\"relative flex shrink-0 items-center gap-2\">{trailing}</div>\n {card && <Chevron open={open} />}\n </div>\n ) : (\n header\n )}\n {!triggerOnly && (\n <Collapse id={bodyId} open={open} keepMounted={keepMounted}>\n <div className={cn(card ? \"space-y-3 px-4 pb-4\" : \"space-y-2 pt-2\", bodyClassName)}>{children}</div>\n </Collapse>\n )}\n </div>\n );\n}\n\n/**\n * One icon for both variants, turned rather than swapped. `leading` (bare) points it\n * along the reading direction while shut — right in LTR, left in RTL — and down when\n * open; trailing (card) points down while shut and up when open, which is the card\n * header's convention. Rotation, not a mirrored glyph, so RTL needs one opposite angle\n * and no `scale` composing with the turn.\n */\nfunction Chevron({ open, leading = false }: { open: boolean; leading?: boolean }) {\n return (\n <ChevronDown\n aria-hidden\n className={cn(\n \"shrink-0 text-[var(--text-muted)] transition-transform duration-200 ease-out motion-reduce:transition-none\",\n leading ? \"size-3.5\" : \"size-4\",\n leading ? !open && \"-rotate-90 rtl:rotate-90\" : open && \"rotate-180\",\n )}\n />\n );\n}\n"],"mappings":";AA8FM,cAgKA,YAhKA;AA9FN,SAAS,WAAW,OAAO,gBAAgB;AAE3C,SAA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AAQ,6EAA6E,SAAS;AAAA,MAE3G;AAAA,sBACC;AAAA,UAAC;AAAA;AAAA,YACC,WAAW;AAAA,cACT;AAAA,cACA,QACE;AAAA,gBACE;AAAA,gBACA,UAAU;AAAA,cACZ;AAAA,YACJ;AAAA,YAEC;AAAA;AAAA,cAGD,oBAAC,SAAI,WAAU,6CAA6C,oBAAS;AAAA,cACpE,QAAQ,oBAAC,WAAQ,MAAY;AAAA;AAAA;AAAA,QAChC,IAEA;AAAA,QAED,CAAC,eACA,oBAAC,YAAS,IAAI,QAAQ,MAAY,aAChC,8BAAC,SAAI,WAAW,GAAG,OAAO,wBAAwB,kBAAkB,aAAa,GAAI,UAAS,GAChG;AAAA;AAAA;AAAA,EAEJ;AAEJ;AASA,SAAS,QAAQ,EAAE,MAAM,UAAU,MAAM,GAAyC;AAChF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW;AAAA,MACX,WAAW;AAAA,QACT;AAAA,QACA,UAAU,aAAa;AAAA,QACvB,UAAU,CAAC,QAAQ,6BAA6B,QAAQ;AAAA,MAC1D;AAAA;AAAA,EACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/disclosure.tsx"],"sourcesContent":["import { useEffect, useId, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport { ChevronDown } from \"lucide-react\";\n\nimport { cn } from \"../lib/cn\";\n\n/** How long the fold takes, in ms. The same number as the `duration-200` below and as\n * the unmount timer, because they are the same movement. */\nconst COLLAPSE_MS = 200;\n\n/** Read at the moment of closing, like `useCloseTransition` does: the setting can\n * change under a long-lived page, and jsdom/SSR have no `matchMedia` — where \"no\n * animation\" is also the only correct answer, since nothing is painting. */\nfunction prefersReducedMotion(): boolean {\n return (\n typeof window === \"undefined\" ||\n typeof window.matchMedia !== \"function\" ||\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n );\n}\n\n/**\n * `extends` the div's props so an `id` (what a trigger's `aria-controls` points at), a\n * `data-tour` anchor or a test id reaches the element that folds.\n */\nexport interface CollapseProps extends ComponentPropsWithoutRef<\"div\"> {\n open: boolean;\n /**\n * Keep the children mounted while shut (hidden and `inert`) instead of unmounting\n * them once the fold has finished closing.\n *\n * Off by default, and that default is a behaviour contract rather than a\n * performance note: Lenkbank's disclosure bodies FETCH, and a body that only exists\n * while open is what stops a closed card asking — without every caller carrying its\n * own `enabled: open`. On for a body whose state must outlive a close (a half-typed\n * form) or that must be found by the browser's find-in-page.\n */\n keepMounted?: boolean;\n children: ReactNode;\n}\n\n/**\n * The fold on its own: content that opens and shuts in place, animated to a height\n * nobody measured.\n *\n * THE TECHNIQUE is `AppShell`'s sidebar group's, lifted out so there is one copy of it.\n * A `grid-template-rows` transition from `0fr` to `1fr` is the one way to animate to a\n * content-sized height without measuring it — so a chart that resizes inside it, or a\n * translated line that wraps, is still exactly as tall as it needs. `visibility` rides\n * the same transition, so a shut body leaves the accessibility tree only once it has\n * finished closing; `inert` takes it out of the tab order immediately.\n *\n * THE CHILDREN are unmounted once closed (see {@link CollapseProps.keepMounted}), but\n * only once the track has finished closing: the track is what animates, so the\n * children have to survive the movement that hides them. Under reduced motion they\n * go at once — there is no movement to wait for — and the opening half is silenced by\n * `motion-reduce:transition-none`, since tokens.css only silences the overlay\n * animations by name.\n *\n * Padding and margins belong on a child: on this element, or the clipping one inside\n * it, they would hold the row open by that much.\n */\nexport function Collapse({ open, keepMounted = false, children, className, style, ...rest }: CollapseProps) {\n // Whether the children are still on their way out. Adjusted DURING render when\n // `open` flips (React's \"storing information from previous renders\"), so a close\n // under reduced motion unmounts in the same render that shut it — a test, and a\n // screen reader, see the body go on the click — and a re-open mid-fold simply\n // cancels the linger.\n const [lingering, setLingering] = useState(false);\n const [prevOpen, setPrevOpen] = useState(open);\n if (open !== prevOpen) {\n setPrevOpen(open);\n setLingering(!open && !prefersReducedMotion());\n }\n useEffect(() => {\n if (!lingering) return;\n const timer = setTimeout(() => setLingering(false), COLLAPSE_MS);\n return () => clearTimeout(timer);\n }, [lingering]);\n\n const mounted = open || lingering || keepMounted;\n\n return (\n <div\n {...rest}\n inert={!open}\n className={cn(\n \"grid transition-[grid-template-rows,visibility] duration-200 ease-out motion-reduce:transition-none\",\n className,\n )}\n // Inline rather than `grid-rows-[…]` classes: a caller's `className` must not be\n // able to pin the track open, and the two values ARE the state.\n style={{ ...style, gridTemplateRows: open ? \"1fr\" : \"0fr\", visibility: open ? \"visible\" : \"hidden\" }}\n >\n <div\n className={cn(\n \"min-h-0 overflow-hidden transition-opacity duration-200 ease-out motion-reduce:transition-none\",\n open ? \"opacity-100\" : \"opacity-0\",\n )}\n >\n {mounted && children}\n </div>\n </div>\n );\n}\n\n/**\n * What {@link DisclosureProps.triggerProps} may put on the header button: its own\n * attributes and handlers, and any `data-*`. Not the ones the disclosure owns —\n * `aria-expanded`, `aria-controls`, `disabled`, `onClick`, `type` and the content — nor\n * `className`, which is {@link DisclosureProps.headerClassName}.\n */\nexport type DisclosureTriggerProps = Omit<\n ComponentPropsWithoutRef<\"button\">,\n \"type\" | \"aria-expanded\" | \"aria-controls\" | \"disabled\" | \"onClick\" | \"children\" | \"className\"\n> & { [data: `data-${string}`]: string | number | boolean | undefined };\n\n/**\n * `title` is omitted from the div's own props because this component already owns the\n * name: here it is the header's content (and a ReactNode), not the browser's tooltip.\n * Everything else reaches the outer element.\n */\nexport interface DisclosureProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"title\"> {\n /** What the header says. A node, so a status chip or a count can sit in it. */\n title: ReactNode;\n /** The smaller line under the title — what is inside, for a reader deciding whether\n * to open it. */\n hint?: ReactNode;\n /**\n * Who decides whether this one is open. Left out, the disclosure decides for itself,\n * which is what one standing on its own wants. Passed, the caller does — a set of\n * which one is open at a time, or an open state kept in the URL so the view can be\n * linked to. There is no accordion component: \"one open at a time\" is a few lines in\n * the caller and it usually owns a URL parameter, which is app state.\n */\n open?: boolean;\n /** Whether an UNCONTROLLED disclosure starts open. Ignored when `open` is passed. */\n defaultOpen?: boolean;\n /** Called with the next state on every toggle, controlled or not. */\n onOpenChange?: (open: boolean) => void;\n /**\n * `card` (default) draws the kit's `Card` surface round header and body, with the\n * chevron trailing the header and turning over — the \"section that opens\" of a\n * settings or analysis page. `bare` draws nothing: a leading chevron that turns\n * down, for an inline \"Show 3 hidden accounts\" inside something that already has\n * its own surface.\n */\n variant?: \"card\" | \"bare\";\n /**\n * Where a `bare` disclosure draws its chevron. `start` (default) is the leading\n * chevron that turns from the reading direction to down. `end` puts it at the far\n * end of the row, pointing down and turning up as the card's does — keksdose's\n * account menu, whose language sub-list reads \"Language 🇩🇪 ⌄\" with the chevron\n * after the flag, like every other menu row with a sub-list. With `trailing`, the\n * chevron follows it, as on a card. A `card` always has it at the end, so this is\n * ignored there.\n */\n chevronPosition?: \"start\" | \"end\";\n /**\n * Wrap the header button in a heading of this level. The WAI-ARIA disclosure pattern\n * puts the button INSIDE the heading when the disclosure titles a section, so the\n * page's heading outline still lists it. Off by default: an inline \"show more\" is\n * not a section.\n */\n headingAs?: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n /** See {@link CollapseProps.keepMounted}. */\n keepMounted?: boolean;\n disabled?: boolean;\n /** Extra classes for the header button. */\n headerClassName?: string;\n /**\n * Attributes for the header BUTTON — the outer props go to the wrapping div — such as\n * an `aria-label`, an `id` or a `data-*` test hook. A function of the open state\n * when they depend on it: keksdose's budget table names each group's toggle\n * \"Expand group Food\" / \"Collapse group Food\", because the visible title is only the\n * group's name:\n *\n * ```tsx\n * triggerProps={(open) => ({ \"aria-label\": t(open ? \"collapseGroup\" : \"expandGroup\", { name }) })}\n * ```\n *\n * An `aria-label` REPLACES the title as the button's name, so it must still contain\n * the title's words (WCAG 2.5.3, label in name). See {@link DisclosureTriggerProps}\n * for what the disclosure keeps for itself.\n */\n triggerProps?: DisclosureTriggerProps | ((open: boolean) => DisclosureTriggerProps);\n /** Extra classes for the body's wrapper — where its padding and spacing live. */\n bodyClassName?: string;\n /**\n * Content at the far end of the header row, beside the title: a count, a date, a\n * status chip, an action button. It is a SIBLING of the header button, never inside\n * it — a button may not contain another interactive element, and a count inside it\n * would also be read as part of the button's name. The header button still spans\n * the row under it (a stretched hit area), so clicking the empty space or the\n * card's chevron still toggles, while whatever sits in `trailing` gets its own\n * clicks. With `trailing`, the card's chevron moves after it, to the row's end.\n */\n trailing?: ReactNode;\n /**\n * Trigger-only mode: the id of an element the CALLER renders elsewhere — the hidden\n * rows of a table, a panel in another column — which this header shows and hides.\n * The header's `aria-controls` points at it and the disclosure renders no body of\n * its own (`children`, `bodyClassName` and `keepMounted` are ignored). Pair it with\n * `open` / `onOpenChange`: the caller owns the state, since the caller renders what\n * it governs.\n */\n controls?: string;\n /** The body. Not rendered in trigger-only mode ({@link DisclosureProps.controls}). */\n children?: ReactNode;\n}\n\n/**\n * A section that opens in place: a header button with `aria-expanded` and\n * `aria-controls`, and a {@link Collapse} under it.\n *\n * Both apps had written this by hand — Lenkbank as a shared `CollapsibleCard` with ten\n * importers, Keksdose three separate times (accounts, twice; the support panel) — and\n * the copies had drifted: none of Keksdose's animated, and all three swapped a\n * `ChevronRight` for a `ChevronDown` rather than turning one. Here the chevron is one\n * icon that rotates, so the change of state is one element moving rather than two\n * trading places.\n *\n * The body is unmounted while shut; see {@link CollapseProps.keepMounted} for why that\n * is the default and when to opt out.\n */\nexport function Disclosure({\n title,\n hint,\n open: controlled,\n defaultOpen = false,\n onOpenChange,\n variant = \"card\",\n chevronPosition = \"start\",\n headingAs: Heading,\n keepMounted,\n disabled,\n headerClassName,\n triggerProps,\n bodyClassName,\n trailing,\n controls,\n className,\n children,\n ...rest\n}: DisclosureProps) {\n const [own, setOwn] = useState(defaultOpen);\n const open = controlled ?? own;\n const bodyId = useId();\n const card = variant === \"card\";\n // The card's chevron trails always; a bare one only when asked to.\n const chevronAtEnd = card || chevronPosition === \"end\";\n const triggerOnly = controls !== undefined;\n // The card's header squares its lower corners only when a body opens under it.\n const joined = open && !triggerOnly;\n const hasTrailing = trailing !== undefined && trailing !== null && trailing !== false;\n\n const toggle = () => {\n const next = !open;\n if (controlled === undefined) setOwn(next);\n onOpenChange?.(next);\n };\n\n const extraTriggerProps = typeof triggerProps === \"function\" ? triggerProps(open) : triggerProps;\n\n const button = (\n <button\n {...extraTriggerProps}\n type=\"button\"\n aria-expanded={open}\n aria-controls={triggerOnly ? controls : bodyId}\n disabled={disabled}\n onClick={toggle}\n data-disclosure-trigger=\"\"\n className={cn(\n \"flex w-full gap-2 text-start outline-none disabled:cursor-not-allowed disabled:opacity-50\",\n hasTrailing\n ? // Stretched over the whole header row (the row is `relative`), so the space\n // round `trailing` and the card's chevron still toggle; the ring and the\n // card's hover paint on the stretched area / the row, not the text box.\n cn(\n \"min-w-0 flex-1 after:absolute after:inset-0 after:content-['']\",\n \"focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-[var(--brand)]\",\n card ? cn(\"after:rounded-lg\", joined && \"after:rounded-b-none\") : \"after:rounded-sm\",\n )\n : \"focus-visible:ring-2 focus-visible:ring-[var(--brand)]\",\n card\n ? cn(\n \"items-center justify-between rounded-lg p-4\",\n hasTrailing ? \"pe-0\" : \"hover:bg-[var(--bg-hover)] focus-visible:ring-inset\",\n joined && \"rounded-b-none\",\n )\n : \"items-center rounded-sm text-sm font-medium text-[var(--text-secondary)] hover:text-[var(--text-primary)]\",\n headerClassName,\n )}\n >\n {!chevronAtEnd && <Chevron open={open} leading />}\n {/* `flex-1`: the title takes the row, so whatever a caller puts at its end sits\n at the header's far edge. */}\n <span className=\"min-w-0 flex-1\">\n <span className={cn(\"block\", card && \"text-sm font-semibold text-[var(--text-primary)]\")}>{title}</span>\n {hint !== undefined && (\n <span className=\"mt-0.5 block text-xs font-normal text-[var(--text-muted)]\">{hint}</span>\n )}\n </span>\n {chevronAtEnd && !hasTrailing && <Chevron open={open} small={!card} />}\n </button>\n );\n\n // Preflight already makes h1–h6 inherit size and weight, so the heading adds\n // structure and nothing visible.\n const header = Heading ? <Heading className={hasTrailing ? \"min-w-0 flex-1\" : undefined}>{button}</Heading> : button;\n\n return (\n <div\n {...rest}\n className={cn(card && \"rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] shadow-sm\", className)}\n >\n {hasTrailing ? (\n <div\n className={cn(\n \"relative flex items-center gap-2\",\n card &&\n cn(\n \"rounded-lg pe-4 has-[[data-disclosure-trigger]:enabled:hover]:bg-[var(--bg-hover)]\",\n joined && \"rounded-b-none\",\n ),\n )}\n >\n {header}\n {/* Positioned, so it paints over the stretched button and takes its own\n clicks; the chevron is not, so a click on it lands on the button. */}\n <div className=\"relative flex shrink-0 items-center gap-2\">{trailing}</div>\n {chevronAtEnd && <Chevron open={open} small={!card} />}\n </div>\n ) : (\n header\n )}\n {!triggerOnly && (\n <Collapse id={bodyId} open={open} keepMounted={keepMounted}>\n <div className={cn(card ? \"space-y-3 px-4 pb-4\" : \"space-y-2 pt-2\", bodyClassName)}>{children}</div>\n </Collapse>\n )}\n </div>\n );\n}\n\n/**\n * One icon for both variants, turned rather than swapped. `leading` (bare) points it\n * along the reading direction while shut — right in LTR, left in RTL — and down when\n * open; trailing (card) points down while shut and up when open, which is the card\n * header's convention. Rotation, not a mirrored glyph, so RTL needs one opposite angle\n * and no `scale` composing with the turn.\n */\nfunction Chevron({\n open,\n leading = false,\n small = leading,\n}: {\n open: boolean;\n leading?: boolean;\n /** The bare variant's size, which a bare chevron keeps at either end of its row. */\n small?: boolean;\n}) {\n return (\n <ChevronDown\n aria-hidden\n className={cn(\n \"shrink-0 text-[var(--text-muted)] transition-transform duration-200 ease-out motion-reduce:transition-none\",\n small ? \"size-3.5\" : \"size-4\",\n leading ? !open && \"-rotate-90 rtl:rotate-90\" : open && \"rotate-180\",\n )}\n />\n );\n}\n"],"mappings":";AA8FM,cA4MA,YA5MA;AA9FN,SAAS,WAAW,OAAO,gBAAgB;AAE3C,SAAS,mBAAmB;AAE5B,SAAS,UAAU;AAInB,MAAM,cAAc;AAKpB,SAAS,uBAAgC;AACvC,S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Y,kBAAO,IAAa;AAE9G,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,QAAQ,6EAA6E,SAAS;AAAA,MAE3G;AAAA,sBACC;AAAA,UAAC;AAAA;AAAA,YACC,WAAW;AAAA,cACT;AAAA,cACA,QACE;AAAA,gBACE;AAAA,gBACA,UAAU;AAAA,cACZ;AAAA,YACJ;AAAA,YAEC;AAAA;AAAA,cAGD,oBAAC,SAAI,WAAU,6CAA6C,oBAAS;AAAA,cACpE,gBAAgB,oBAAC,WAAQ,MAAY,OAAO,CAAC,MAAM;AAAA;AAAA;AAAA,QACtD,IAEA;AAAA,QAED,CAAC,eACA,oBAAC,YAAS,IAAI,QAAQ,MAAY,aAChC,8BAAC,SAAI,WAAW,GAAG,OAAO,wBAAwB,kBAAkB,aAAa,GAAI,UAAS,GAChG;AAAA;AAAA;AAAA,EAEJ;AAEJ;AASA,SAAS,QAAQ;AAAA,EACf;AAAA,EACA,UAAU;AAAA,EACV,QAAQ;AACV,GAKG;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW;AAAA,MACX,WAAW;AAAA,QACT;AAAA,QACA,QAAQ,aAAa;AAAA,QACrB,UAAU,CAAC,QAAQ,6BAA6B,QAAQ;AAAA,MAC1D;AAAA;AAAA,EACF;AAEJ;","names":[]}
@@ -3,6 +3,8 @@ import { SeriesChartAxis } from './series-chart.js';
3
3
  import './chart-zoom.js';
4
4
  import 'recharts';
5
5
  import './series-chart-labels.js';
6
+ import './toggle-legend.js';
7
+ import './series-chart-ticks.js';
6
8
 
7
9
  /** Which chart of a facing pair. Physical, like the axes: charts do not mirror in RTL. */
8
10
  type FacingSide = "left" | "right";
@@ -60,6 +60,19 @@ interface FilePickerLabels {
60
60
  /** Spoken after a remove / clear, since the button that was pressed is gone. */
61
61
  removed: (name: string) => string;
62
62
  cleared: string;
63
+ /** The dropzone's accessible name, when the host passes no `dropLabel`. */
64
+ dropzone: string;
65
+ /** The dropzone's Browse button, when the host passes no `browseLabel`. */
66
+ browse: string;
67
+ /** What an empty single-file dropzone says (no `emptyLabel` given). */
68
+ empty: string;
69
+ /** …and an empty `multiple` one. */
70
+ emptyMultiple: string;
71
+ /** The dropzone's second line (no `hint` given). Receives `accept` as a person
72
+ * reads it (`".pdf, image/png"`), or `""` when anything goes. */
73
+ hint: (accept: string) => string;
74
+ /** What a `busy` dropzone says in place of its body ("Uploading…"). */
75
+ busy: string;
63
76
  }
64
77
  declare const DEFAULT_FILE_PICKER_LABELS: FilePickerLabels;
65
78
  type FileRejectionReason = "type" | "size" | "count" | "invalid";
@@ -81,6 +94,9 @@ interface FileRejection {
81
94
  * `model/step`: that is how `accept` has to be written for the dialog anyway.
82
95
  */
83
96
  declare function matchesAccept(file: File, accept: string | undefined): boolean;
97
+ /** @internal `" .PDF, image/png ,"` => `".pdf, image/png"` — `accept` as a person reads
98
+ * it. Also the dropzone's default hint. */
99
+ declare function formatAccept(accept: string): string;
84
100
  /** What the pickers screen a pick with. All optional; nothing set accepts everything. */
85
101
  interface FileScreenOptions {
86
102
  accept?: string;
@@ -191,4 +207,4 @@ interface FileButtonProps extends Omit<UseFilePickerOptions, "disabled">, Omit<B
191
207
  */
192
208
  declare const FileButton: react.ForwardRefExoticComponent<FileButtonProps & react.RefAttributes<HTMLButtonElement>>;
193
209
 
194
- export { DEFAULT_FILE_PICKER_LABELS, FileButton, type FileButtonProps, type FilePickHandler, type FilePickerLabels, type FileRejection, type FileRejectionReason, type FileScreenOptions, type UseFilePickerOptions, type UseFilePickerReturn, judgePick, matchesAccept, screenFiles, summariseRejections, useFilePicker };
210
+ export { DEFAULT_FILE_PICKER_LABELS, FileButton, type FileButtonProps, type FilePickHandler, type FilePickerLabels, type FileRejection, type FileRejectionReason, type FileScreenOptions, type UseFilePickerOptions, type UseFilePickerReturn, formatAccept, judgePick, matchesAccept, screenFiles, summariseRejections, useFilePicker };
@@ -17,7 +17,13 @@ const DEFAULT_FILE_PICKER_LABELS = {
17
17
  remove: (name) => `Remove \u201C${name}\u201D`,
18
18
  clearAll: "Remove all files",
19
19
  removed: (name) => `\u201C${name}\u201D removed`,
20
- cleared: "All files removed"
20
+ cleared: "All files removed",
21
+ dropzone: "File upload",
22
+ browse: "Browse",
23
+ empty: "Drop a file here",
24
+ emptyMultiple: "Drop files here",
25
+ hint: (accept) => accept ? `Accepted: ${accept}` : "Any file type",
26
+ busy: "Uploading\u2026"
21
27
  };
22
28
  function matchesAccept(file, accept) {
23
29
  const tokens = (accept ?? "").split(",").map((t) => t.trim().toLowerCase()).filter(Boolean);
@@ -255,6 +261,7 @@ FileButton.displayName = "FileButton";
255
261
  export {
256
262
  DEFAULT_FILE_PICKER_LABELS,
257
263
  FileButton,
264
+ formatAccept,
258
265
  judgePick,
259
266
  matchesAccept,
260
267
  screenFiles,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/file-button.tsx"],"sourcesContent":["import { forwardRef, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, DragEvent, ReactElement, ReactNode, Ref } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { useKitFileLabels, useKitLabels } from \"../i18n/kit-labels\";\nimport { Button, Spinner } from \"./ui\";\n\n/**\n * A button that opens the file picker — the shape all three apps kept writing by hand\n * as a `<Button>` plus a hidden `<input type=\"file\">` plus a ref between them (seven\n * copies in keksdose, two each in kastlan and lenkbank).\n *\n * Every copy had to remember the same four things, and each one forgot at least one:\n *\n * 1. **Reset the input after every pick.** A file input fires `change` only when its\n * value CHANGES, so picking the same file twice in a row — the retry after a failed\n * upload, the second photo of the same receipt — did nothing at all, which reads as\n * a broken button. `value = \"\"` after each pick; always, not per call site.\n * 2. **`type=\"button\"`.** `<Button>` does not set it, and inside a form a bare button\n * submits the form before the picker opens.\n * 3. **Check the file.** `accept` filters the DIALOG, not the result: the dialog's\n * \"All files\" switch, a drop, and a mobile share sheet all hand over whatever the\n * user chose. So `accept` is re-checked here, along with `maxSize`, `maxFiles` and\n * an optional `isValid`.\n * 4. **Say no without a toast.** A rejection is reported through `onReject`, with a\n * translated message per file, and spoken through a live region — the kit does not\n * decide how an app surfaces errors (keksdose's proposal §1 asked for exactly that).\n *\n * The part that is not a button — the hidden input, the check, the announcement — is\n * {@link useFilePicker}, for the case where the thing that opens the picker is someone\n * else's control (a card's \"Add\" action, a menu item, a second button for the camera).\n */\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string the file pickers ({@link FileButton}, `FileDropzone`) render or speak.\n * Messages are functions of the file name so a translation can put it anywhere. */\nexport interface FilePickerLabels {\n /** The file's type is not in `accept`, when no `accept` is known to name (see\n * `rejectedTypeOnly`). */\n rejectedType: (name: string) => string;\n /** The file's type is not in `accept`, naming what IS accepted: `accept`'s tokens,\n * lower-cased and joined with \", \" (`\".csv\"` => \"Only .csv files\"). Used whenever\n * `accept` is set — kastlan kept a custom `isValid` + `invalidMessage` per form only\n * to say this, and `accept` already knows it. */\n rejectedTypeOnly: (accept: string, name: string) => string;\n /** The file is larger than `maxSize`; `maxSize` arrives formatted (\"5 MB\"). */\n rejectedSize: (name: string, maxSize: string) => string;\n /** The file was one too many for `maxFiles`. */\n rejectedCount: (name: string, maxFiles: number) => string;\n /** `isValid` said no and the caller gave no `invalidMessage`. */\n rejectedInvalid: (name: string) => string;\n /** Spoken instead of the per-file message when more than one file was refused. */\n rejectedMany: (count: number) => string;\n /** Spoken (and shown, on a dropzone) when `onPick` refused the WHOLE pick.\n * Receives the number of files in it. */\n rejectedPick: (count: number) => string;\n /** Spoken after a pick the component itself echoes (the dropzone). */\n selected: (count: number, firstName: string) => string;\n /** The dropzone's remove button for one file. */\n remove: (name: string) => string;\n /** The dropzone's remove-everything button in `multiple` mode. */\n clearAll: string;\n /** Spoken after a remove / clear, since the button that was pressed is gone. */\n removed: (name: string) => string;\n cleared: string;\n}\n\nexport const DEFAULT_FILE_PICKER_LABELS: FilePickerLabels = {\n rejectedType: (name) => `“${name}” is not a supported file type`,\n rejectedTypeOnly: (accept) => `Only ${accept} files`,\n rejectedSize: (name, maxSize) => `“${name}” is larger than ${maxSize}`,\n rejectedCount: (name, maxFiles) =>\n `“${name}” was not added: at most ${maxFiles} ${maxFiles === 1 ? \"file\" : \"files\"}`,\n rejectedInvalid: (name) => `“${name}” cannot be used here`,\n rejectedMany: (count) => `${count} files were not added`,\n rejectedPick: (count) =>\n count === 1 ? \"The file was not added\" : `None of the ${count} files were added`,\n selected: (count, firstName) => (count === 1 ? `“${firstName}” selected` : `${count} files selected`),\n remove: (name) => `Remove “${name}”`,\n clearAll: \"Remove all files\",\n removed: (name) => `“${name}” removed`,\n cleared: \"All files removed\",\n};\n\n/* ── Screening ───────────────────────────────────────────────────────────── */\n\nexport type FileRejectionReason = \"type\" | \"size\" | \"count\" | \"invalid\";\n\n/** One file the picker refused, and why. `message` is already translated (see\n * {@link FilePickerLabels}, or the caller's `invalidMessage`), so a host that just\n * wants to show it can render `rejections[0].message` as is. */\nexport interface FileRejection {\n file: File;\n reason: FileRejectionReason;\n message: string;\n}\n\n/**\n * Does `file` satisfy an `accept` string, the way the browser's dialog reads it?\n * Comma-separated tokens: `.ext` (case-insensitive suffix of the name), `type/*`\n * (a MIME family) or an exact MIME type. An empty or absent `accept` takes anything.\n *\n * A file with no `type` — common for `.step`, `.dat`, anything the OS has no MIME\n * mapping for — can only match by extension, which is why lenkbank lists `.stp` AND\n * `model/step`: that is how `accept` has to be written for the dialog anyway.\n */\nexport function matchesAccept(file: File, accept: string | undefined): boolean {\n const tokens = (accept ?? \"\")\n .split(\",\")\n .map((t) => t.trim().toLowerCase())\n .filter(Boolean);\n if (tokens.length === 0) return true;\n const name = file.name.toLowerCase();\n // An EMPTY type is the browser saying \"I don't know\", not \"it's something else\": HEIC\n // photos on Windows without the codec arrive with `type === \"\"`. Refusing them\n // (0.6.0) refused iPhone photos the picker itself had just offered (keksdose). So a\n // missing type is inferred from the extension where that is unambiguous, and a file\n // whose type cannot be known at all is given the benefit of the doubt — nothing here\n // proves it does not match, and the server validates what it receives anyway.\n const type = (file.type || typeFromExtension(name) || \"\").toLowerCase();\n if (!type && !tokens.every((t) => t.startsWith(\".\"))) return true;\n return tokens.some((token) => {\n if (token.startsWith(\".\")) return name.endsWith(token);\n if (!type) return false;\n if (token.endsWith(\"/*\")) return type.startsWith(token.slice(0, -1));\n return type === token;\n });\n}\n\n/** MIME types for the extensions a browser most often leaves untyped. */\nconst EXTENSION_TYPES: Record<string, string> = {\n heic: \"image/heic\",\n heif: \"image/heif\",\n avif: \"image/avif\",\n webp: \"image/webp\",\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n png: \"image/png\",\n gif: \"image/gif\",\n pdf: \"application/pdf\",\n csv: \"text/csv\",\n txt: \"text/plain\",\n};\n\nfunction typeFromExtension(name: string): string | undefined {\n const dot = name.lastIndexOf(\".\");\n return dot === -1 ? undefined : EXTENSION_TYPES[name.slice(dot + 1)];\n}\n\n/** `\" .PDF, image/png ,\"` => `\".pdf, image/png\"` — `accept` as a person reads it. */\nfunction formatAccept(accept: string): string {\n return accept\n .split(\",\")\n .map((t) => t.trim().toLowerCase())\n .filter(Boolean)\n .join(\", \");\n}\n\n/** What the pickers screen a pick with. All optional; nothing set accepts everything. */\nexport interface FileScreenOptions {\n accept?: string;\n /** Bytes. Larger files are refused with reason `\"size\"`. */\n maxSize?: number;\n /** How many files one pick may deliver. The rest are refused with reason `\"count\"`\n * — first come, first kept. For a running cap (\"at most 5 attachments\") pass what\n * is LEFT: `maxFiles={5 - attachments.length}`. */\n maxFiles?: number;\n /** The caller's own check, after `accept` and `maxSize`. */\n isValid?: (file: File) => boolean;\n /** The message for an `isValid` refusal; `labels.rejectedInvalid` otherwise. */\n invalidMessage?: string;\n}\n\n/** @internal Split a pick into the files that pass and the ones that do not. */\nexport function screenFiles(\n files: readonly File[],\n opts: FileScreenOptions,\n labels: FilePickerLabels,\n formatSize: (bytes: number) => string,\n): { accepted: File[]; rejected: FileRejection[] } {\n const accepted: File[] = [];\n const rejected: FileRejection[] = [];\n // Name what `accept` takes (\"Only .csv files\") — unless the host translated\n // `rejectedType` but not yet `rejectedTypeOnly`: its own sentence beats an English one.\n const acceptText = opts.accept ? formatAccept(opts.accept) : \"\";\n const useOnly =\n acceptText !== \"\" &&\n (labels.rejectedTypeOnly !== DEFAULT_FILE_PICKER_LABELS.rejectedTypeOnly ||\n labels.rejectedType === DEFAULT_FILE_PICKER_LABELS.rejectedType);\n const typeMessage = (name: string) =>\n useOnly ? labels.rejectedTypeOnly(acceptText, name) : labels.rejectedType(name);\n for (const file of files) {\n let reason: FileRejectionReason | null = null;\n if (!matchesAccept(file, opts.accept)) reason = \"type\";\n else if (opts.maxSize !== undefined && file.size > opts.maxSize) reason = \"size\";\n else if (opts.isValid && !opts.isValid(file)) reason = \"invalid\";\n // Count last, and only against files that passed everything else: a refused\n // file should not use up one of the slots a good one could have had.\n else if (opts.maxFiles !== undefined && accepted.length >= opts.maxFiles) reason = \"count\";\n if (reason === null) {\n accepted.push(file);\n continue;\n }\n const message =\n reason === \"type\"\n ? typeMessage(file.name)\n : reason === \"size\"\n ? labels.rejectedSize(file.name, formatSize(opts.maxSize ?? 0))\n : reason === \"count\"\n ? labels.rejectedCount(file.name, Math.max(0, opts.maxFiles ?? 0))\n : (opts.invalidMessage ?? labels.rejectedInvalid(file.name));\n rejected.push({ file, reason, message });\n }\n return { accepted, rejected };\n}\n\n/**\n * Judges a pick as a whole — keksdose's \"refuse the pick if any file is bad\", which\n * with `onFiles` + `onReject` alone had to be rebuilt from two calls in a microtask.\n *\n * Called ONCE per pick, after screening and before `onFiles` / `onReject`, with both\n * halves (either may be empty). Return `false` to refuse the whole pick: the accepted\n * files are not delivered, `onReject` still receives what screening refused, and one\n * sentence (`labels.rejectedPick`) is spoken for the pick instead of a per-file one.\n * Return nothing to let the pick through as usual.\n *\n * ```tsx\n * onPick={(ok, bad) => bad.length === 0 || false} // all or nothing\n * ```\n */\nexport type FilePickHandler = (accepted: File[], rejected: FileRejection[]) => boolean | void;\n\n/** @internal The shared tail of both pickers: run `onPick`, and say whether the pick\n * stands. A pick with nothing accepted has nothing to refuse, so `false` there is\n * treated as no verdict and the usual per-file messages are kept. */\nexport function judgePick(\n onPick: FilePickHandler | undefined,\n accepted: File[],\n rejected: FileRejection[],\n): boolean {\n if (!onPick) return true;\n return onPick(accepted, rejected) !== false || accepted.length === 0;\n}\n\n/** One sentence for a whole batch of refusals: the file's own message for one, a\n * count for several — reading out five sentences in a row helps nobody. */\nexport function summariseRejections(rejected: readonly FileRejection[], labels: FilePickerLabels): string {\n if (rejected.length === 0) return \"\";\n if (rejected.length === 1) return rejected[0].message;\n return labels.rejectedMany(rejected.length);\n}\n\n/* ── useFilePicker ───────────────────────────────────────────────────────── */\n\nexport interface UseFilePickerOptions extends FileScreenOptions {\n /** Let one pick deliver several files. Without it a drop of several keeps the first. */\n multiple?: boolean;\n /**\n * Ask a phone for its camera instead of the file chooser: `\"environment\"` is the\n * back camera, `\"user\"` the front. A HINT — desktop browsers ignore it, and Chrome\n * drops it when `multiple` is also set (a camera cannot deliver a list), which is why\n * keksdose's camera input has no `multiple`. Pass one or the other.\n */\n capture?: boolean | \"user\" | \"environment\";\n /** The files that passed, in pick order. Never called with an empty array.\n * Optional since 0.7 for a caller that takes the pick through `onPick` alone. */\n onFiles?: (files: File[]) => void;\n /** See {@link FilePickHandler}: the whole pick at once, with the power to refuse it. */\n onPick?: FilePickHandler;\n /** The files that did not, with a translated message each. The refusals are also\n * spoken through a live region, so this is for SHOWING them, not for a11y. */\n onReject?: (rejections: FileRejection[]) => void;\n /** `open()` and `take()` do nothing while set. */\n disabled?: boolean;\n /** Per-instance overrides of the `filePicker` label namespace. */\n labels?: Partial<FilePickerLabels>;\n}\n\nexport interface UseFilePickerReturn {\n /** Open the system picker. Call it from a click handler — browsers only open a file\n * dialog in response to a user gesture. */\n open: () => void;\n /** Screen and deliver files that arrived some other way — a drop, a paste. Honours\n * `multiple` (only the first file without it) and every check. */\n take: (files: ArrayLike<File> | null | undefined) => void;\n /** The hidden input and the live region. Render it once, anywhere — it takes no\n * space and needs no positioned ancestor. */\n element: ReactElement;\n}\n\n/**\n * The headless half of {@link FileButton}: a hidden file input you can open from any\n * control, with the reset, the screening and the announcement built in.\n *\n * ```tsx\n * const picker = useFilePicker({ accept: \".pdf\", onFiles: ([f]) => upload(f) });\n * return <>{picker.element}<DetailTableCard onAdd={picker.open} … /></>;\n * ```\n */\nexport function useFilePicker({\n accept,\n multiple,\n capture,\n maxSize,\n maxFiles,\n isValid,\n invalidMessage,\n onFiles,\n onPick,\n onReject,\n disabled,\n labels: labelsProp,\n}: UseFilePickerOptions): UseFilePickerReturn {\n const inputRef = useRef<HTMLInputElement>(null);\n const labels = useKitLabels(\"filePicker\", DEFAULT_FILE_PICKER_LABELS, labelsProp);\n const fileText = useKitFileLabels();\n // Assertive: a refusal is a failure the user has to hear before they move on, and\n // it is the only thing this region ever says.\n const { announce, regionProps } = useAnnounce({ politeness: \"assertive\" });\n\n const take = (list: ArrayLike<File> | null | undefined) => {\n if (disabled || !list || list.length === 0) return;\n const all = Array.from(list);\n const files = multiple ? all : all.slice(0, 1);\n const { accepted, rejected } = screenFiles(\n files,\n // A single-file picker holds one file by definition; `maxFiles` is a multi-mode\n // cap and would only ever say \"0\" there if a caller passed it by mistake.\n { accept, maxSize, maxFiles: multiple ? maxFiles : undefined, isValid, invalidMessage },\n labels,\n fileText.size,\n );\n if (!judgePick(onPick, accepted, rejected)) {\n if (rejected.length > 0) onReject?.(rejected);\n announce(labels.rejectedPick(files.length));\n return;\n }\n if (accepted.length > 0) onFiles?.(accepted);\n if (rejected.length > 0) {\n onReject?.(rejected);\n announce(summariseRejections(rejected, labels));\n }\n };\n\n const element = (\n <>\n <input\n ref={inputRef}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n capture={capture}\n disabled={disabled}\n // `hidden` (display: none), not `sr-only`: the control a user reaches is the\n // button, and a second, nameless tab stop for the same action is noise. A\n // display:none file input still opens on `.click()` in every current browser —\n // and, unlike `sr-only`, it cannot escape to the initial containing block and\n // stretch the page (see the note in `file-dropzone.tsx`).\n className=\"hidden\"\n tabIndex={-1}\n aria-hidden\n onChange={(e) => {\n // Copy BEFORE the reset: `files` is a live view of the input's value, and\n // clearing the value empties it.\n const picked = Array.from(e.currentTarget.files ?? []);\n e.currentTarget.value = \"\";\n take(picked);\n }}\n />\n <span {...regionProps} />\n </>\n );\n\n return {\n open: () => {\n if (!disabled) inputRef.current?.click();\n },\n take,\n element,\n };\n}\n\n/* ── FileButton ──────────────────────────────────────────────────────────── */\n\ntype ButtonOwnProps = ComponentPropsWithoutRef<typeof Button>;\n\nexport interface FileButtonProps\n extends Omit<UseFilePickerOptions, \"disabled\">,\n // `onDrop` & co. stay the caller's own when `droppable` is off; `type` is fixed to\n // \"button\" (see 2. above) — a file trigger never submits a form.\n Omit<ButtonOwnProps, \"type\" | \"children\" | \"accept\" | \"capture\" | \"multiple\"> {\n /** The button's content — usually an icon and a word. It is the accessible name. */\n children: ReactNode;\n /** Busy: disabled, `aria-busy`, and a spinner before the content — for \"uploading\". */\n pending?: boolean;\n /** Also accept files dropped ON the button (lenkbank's \"drop onto the button\").\n * Off by default: a button that silently takes drops is a surprise on a page that\n * has a real drop target elsewhere. */\n droppable?: boolean;\n}\n\n/**\n * {@link useFilePicker} behind a {@link Button}: `variant` and every other button prop\n * pass through, and the ref is the `<button>` (so `ref.current.click()` opens the\n * picker from elsewhere too).\n *\n * ```tsx\n * <FileButton accept=\"image/*,application/pdf\" capture=\"environment\" variant=\"secondary\"\n * maxSize={10_000_000} onFiles={([f]) => upload(f)} onReject={([r]) => setError(r.message)}>\n * <Camera aria-hidden /> Photograph receipt\n * </FileButton>\n * ```\n */\nexport const FileButton = forwardRef<HTMLButtonElement, FileButtonProps>(function FileButton(\n {\n accept,\n multiple,\n capture,\n maxSize,\n maxFiles,\n isValid,\n invalidMessage,\n onFiles,\n onPick,\n onReject,\n labels,\n pending,\n droppable,\n disabled,\n children,\n className,\n onClick,\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop,\n ...rest\n },\n ref,\n) {\n const inert = Boolean(disabled || pending);\n const picker = useFilePicker({\n accept,\n multiple,\n capture,\n maxSize,\n maxFiles,\n isValid,\n invalidMessage,\n onFiles,\n onPick,\n onReject,\n labels,\n disabled: inert,\n });\n const [dragOver, setDragOver] = useState(false);\n\n const hasFiles = (e: DragEvent) => Array.from(e.dataTransfer?.types ?? []).includes(\"Files\");\n // Only when `droppable`: otherwise the caller's own handlers are passed untouched.\n const dropHandlers = droppable\n ? {\n onDragEnter: (e: DragEvent<HTMLButtonElement>) => {\n onDragEnter?.(e);\n if (!hasFiles(e)) return;\n e.preventDefault();\n if (!inert) setDragOver(true);\n },\n onDragOver: (e: DragEvent<HTMLButtonElement>) => {\n onDragOver?.(e);\n if (!hasFiles(e)) return;\n // Always cancel for a file drag, busy or not: an uncancelled drop makes the\n // browser NAVIGATE to the file, which loses the page.\n e.preventDefault();\n e.dataTransfer.dropEffect = inert ? \"none\" : \"copy\";\n },\n onDragLeave: (e: DragEvent<HTMLButtonElement>) => {\n onDragLeave?.(e);\n if (e.currentTarget.contains(e.relatedTarget as Node | null)) return;\n setDragOver(false);\n },\n onDrop: (e: DragEvent<HTMLButtonElement>) => {\n onDrop?.(e);\n if (!hasFiles(e)) return;\n e.preventDefault();\n setDragOver(false);\n picker.take(e.dataTransfer.files);\n },\n }\n : { onDragEnter, onDragOver, onDragLeave, onDrop };\n\n // `Button` is a plain function component; under React 19 `ref` is an ordinary prop\n // and reaches the `<button>` through its `...rest`. Its props type just does not\n // declare it, hence the widening here rather than a second button implementation.\n const refProp = { ref } as { ref?: Ref<HTMLButtonElement> };\n\n return (\n <>\n <Button\n {...rest}\n {...refProp}\n {...dropHandlers}\n type=\"button\"\n disabled={inert}\n aria-busy={pending || undefined}\n data-drag-over={dragOver || undefined}\n className={cn(\n // A live drag gets the focus ring's colour as a ring: \"let go here\", in the\n // same vocabulary the button already uses for \"you are here\".\n dragOver && \"ring-2 ring-[var(--brand)]\",\n className,\n )}\n onClick={(e) => {\n onClick?.(e);\n if (!e.defaultPrevented) picker.open();\n }}\n >\n {/* `label={null}`: the spinner is decoration here — `aria-busy` says the same\n thing on the button, and a spoken \"Loading\" would run into its name. */}\n {pending && <Spinner label={null} className=\"size-4\" />}\n {children}\n </Button>\n {picker.element}\n </>\n );\n});\nFileButton.displayName = \"FileButton\";\n"],"mappings":";AA0VI,mBACE,KADF;AA1VJ,SAAS,YAAY,QAAQ,gBAAgB;AAE7C,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB,oBAAoB;AAC/C,SAAS,QAAQ,eAAe;AA+DzB,MAAM,6BAA+C;AAAA,EAC1D,cAAc,CAAC,SAAS,SAAI,IAAI;AAAA,EAChC,kBAAkB,CAAC,WAAW,QAAQ,MAAM;AAAA,EAC5C,cAAc,CAAC,MAAM,YAAY,SAAI,IAAI,yBAAoB,OAAO;AAAA,EACpE,eAAe,CAAC,MAAM,aACpB,SAAI,IAAI,iCAA4B,QAAQ,IAAI,aAAa,IAAI,SAAS,OAAO;AAAA,EACnF,iBAAiB,CAAC,SAAS,SAAI,IAAI;AAAA,EACnC,cAAc,CAAC,UAAU,GAAG,KAAK;AAAA,EACjC,cAAc,CAAC,UACb,UAAU,IAAI,2BAA2B,eAAe,KAAK;AAAA,EAC/D,UAAU,CAAC,OAAO,cAAe,UAAU,IAAI,SAAI,SAAS,oBAAe,GAAG,KAAK;AAAA,EACnF,QAAQ,CAAC,SAAS,gBAAW,IAAI;AAAA,EACjC,UAAU;AAAA,EACV,SAAS,CAAC,SAAS,SAAI,IAAI;AAAA,EAC3B,SAAS;AACX;AAwBO,SAAS,cAAc,MAAY,QAAqC;AAC7E,QAAM,UAAU,UAAU,IACvB,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,EACjC,OAAO,OAAO;AACjB,MAAI,O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AAoC;AAC3C,eAAS,CAAC;AACV,UAAI,CAAC,SAAS,CAAC,EAAG;AAClB,QAAE,eAAe;AACjB,kBAAY,KAAK;AACjB,aAAO,KAAK,EAAE,aAAa,KAAK;AAAA,IAClC;AAAA,EACF,IACA,EAAE,aAAa,YAAY,aAAa,OAAO;AAKnD,QAAM,UAAU,EAAE,IAAI;AAEtB,SACE,iCACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAG;AAAA,QACJ,MAAK;AAAA,QACL,UAAU;AAAA,QACV,aAAW,WAAW;AAAA,QACtB,kBAAgB,YAAY;AAAA,QAC5B,WAAW;AAAA;AAAA;AAAA,UAGT,YAAY;AAAA,UACZ;AAAA,QACF;AAAA,QACA,SAAS,CAAC,MAAM;AACd,oBAAU,CAAC;AACX,cAAI,CAAC,EAAE,iBAAkB,QAAO,KAAK;AAAA,QACvC;AAAA,QAIC;AAAA,qBAAW,oBAAC,WAAQ,OAAO,MAAM,WAAU,UAAS;AAAA,UACpD;AAAA;AAAA;AAAA,IACH;AAAA,IACC,OAAO;AAAA,KACV;AAEJ,CAAC;AACD,WAAW,cAAc;","names":["FileButton"]}
1
+ {"version":3,"sources":["../../src/components/file-button.tsx"],"sourcesContent":["import { forwardRef, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, DragEvent, ReactElement, ReactNode, Ref } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { useAnnounce } from \"../hooks/use-announce\";\nimport { useKitFileLabels, useKitLabels } from \"../i18n/kit-labels\";\nimport { Button, Spinner } from \"./ui\";\n\n/**\n * A button that opens the file picker — the shape all three apps kept writing by hand\n * as a `<Button>` plus a hidden `<input type=\"file\">` plus a ref between them (seven\n * copies in keksdose, two each in kastlan and lenkbank).\n *\n * Every copy had to remember the same four things, and each one forgot at least one:\n *\n * 1. **Reset the input after every pick.** A file input fires `change` only when its\n * value CHANGES, so picking the same file twice in a row — the retry after a failed\n * upload, the second photo of the same receipt — did nothing at all, which reads as\n * a broken button. `value = \"\"` after each pick; always, not per call site.\n * 2. **`type=\"button\"`.** `<Button>` does not set it, and inside a form a bare button\n * submits the form before the picker opens.\n * 3. **Check the file.** `accept` filters the DIALOG, not the result: the dialog's\n * \"All files\" switch, a drop, and a mobile share sheet all hand over whatever the\n * user chose. So `accept` is re-checked here, along with `maxSize`, `maxFiles` and\n * an optional `isValid`.\n * 4. **Say no without a toast.** A rejection is reported through `onReject`, with a\n * translated message per file, and spoken through a live region — the kit does not\n * decide how an app surfaces errors (keksdose's proposal §1 asked for exactly that).\n *\n * The part that is not a button — the hidden input, the check, the announcement — is\n * {@link useFilePicker}, for the case where the thing that opens the picker is someone\n * else's control (a card's \"Add\" action, a menu item, a second button for the camera).\n */\n\n/* ── Labels ──────────────────────────────────────────────────────────────── */\n\n/** Every string the file pickers ({@link FileButton}, `FileDropzone`) render or speak.\n * Messages are functions of the file name so a translation can put it anywhere. */\nexport interface FilePickerLabels {\n /** The file's type is not in `accept`, when no `accept` is known to name (see\n * `rejectedTypeOnly`). */\n rejectedType: (name: string) => string;\n /** The file's type is not in `accept`, naming what IS accepted: `accept`'s tokens,\n * lower-cased and joined with \", \" (`\".csv\"` => \"Only .csv files\"). Used whenever\n * `accept` is set — kastlan kept a custom `isValid` + `invalidMessage` per form only\n * to say this, and `accept` already knows it. */\n rejectedTypeOnly: (accept: string, name: string) => string;\n /** The file is larger than `maxSize`; `maxSize` arrives formatted (\"5 MB\"). */\n rejectedSize: (name: string, maxSize: string) => string;\n /** The file was one too many for `maxFiles`. */\n rejectedCount: (name: string, maxFiles: number) => string;\n /** `isValid` said no and the caller gave no `invalidMessage`. */\n rejectedInvalid: (name: string) => string;\n /** Spoken instead of the per-file message when more than one file was refused. */\n rejectedMany: (count: number) => string;\n /** Spoken (and shown, on a dropzone) when `onPick` refused the WHOLE pick.\n * Receives the number of files in it. */\n rejectedPick: (count: number) => string;\n /** Spoken after a pick the component itself echoes (the dropzone). */\n selected: (count: number, firstName: string) => string;\n /** The dropzone's remove button for one file. */\n remove: (name: string) => string;\n /** The dropzone's remove-everything button in `multiple` mode. */\n clearAll: string;\n /** Spoken after a remove / clear, since the button that was pressed is gone. */\n removed: (name: string) => string;\n cleared: string;\n /** The dropzone's accessible name, when the host passes no `dropLabel`. */\n dropzone: string;\n /** The dropzone's Browse button, when the host passes no `browseLabel`. */\n browse: string;\n /** What an empty single-file dropzone says (no `emptyLabel` given). */\n empty: string;\n /** …and an empty `multiple` one. */\n emptyMultiple: string;\n /** The dropzone's second line (no `hint` given). Receives `accept` as a person\n * reads it (`\".pdf, image/png\"`), or `\"\"` when anything goes. */\n hint: (accept: string) => string;\n /** What a `busy` dropzone says in place of its body (\"Uploading…\"). */\n busy: string;\n}\n\nexport const DEFAULT_FILE_PICKER_LABELS: FilePickerLabels = {\n rejectedType: (name) => `“${name}” is not a supported file type`,\n rejectedTypeOnly: (accept) => `Only ${accept} files`,\n rejectedSize: (name, maxSize) => `“${name}” is larger than ${maxSize}`,\n rejectedCount: (name, maxFiles) =>\n `“${name}” was not added: at most ${maxFiles} ${maxFiles === 1 ? \"file\" : \"files\"}`,\n rejectedInvalid: (name) => `“${name}” cannot be used here`,\n rejectedMany: (count) => `${count} files were not added`,\n rejectedPick: (count) =>\n count === 1 ? \"The file was not added\" : `None of the ${count} files were added`,\n selected: (count, firstName) => (count === 1 ? `“${firstName}” selected` : `${count} files selected`),\n remove: (name) => `Remove “${name}”`,\n clearAll: \"Remove all files\",\n removed: (name) => `“${name}” removed`,\n cleared: \"All files removed\",\n dropzone: \"File upload\",\n browse: \"Browse\",\n empty: \"Drop a file here\",\n emptyMultiple: \"Drop files here\",\n hint: (accept) => (accept ? `Accepted: ${accept}` : \"Any file type\"),\n busy: \"Uploading…\",\n};\n\n/* ── Screening ───────────────────────────────────────────────────────────── */\n\nexport type FileRejectionReason = \"type\" | \"size\" | \"count\" | \"invalid\";\n\n/** One file the picker refused, and why. `message` is already translated (see\n * {@link FilePickerLabels}, or the caller's `invalidMessage`), so a host that just\n * wants to show it can render `rejections[0].message` as is. */\nexport interface FileRejection {\n file: File;\n reason: FileRejectionReason;\n message: string;\n}\n\n/**\n * Does `file` satisfy an `accept` string, the way the browser's dialog reads it?\n * Comma-separated tokens: `.ext` (case-insensitive suffix of the name), `type/*`\n * (a MIME family) or an exact MIME type. An empty or absent `accept` takes anything.\n *\n * A file with no `type` — common for `.step`, `.dat`, anything the OS has no MIME\n * mapping for — can only match by extension, which is why lenkbank lists `.stp` AND\n * `model/step`: that is how `accept` has to be written for the dialog anyway.\n */\nexport function matchesAccept(file: File, accept: string | undefined): boolean {\n const tokens = (accept ?? \"\")\n .split(\",\")\n .map((t) => t.trim().toLowerCase())\n .filter(Boolean);\n if (tokens.length === 0) return true;\n const name = file.name.toLowerCase();\n // An EMPTY type is the browser saying \"I don't know\", not \"it's something else\": HEIC\n // photos on Windows without the codec arrive with `type === \"\"`. Refusing them\n // (0.6.0) refused iPhone photos the picker itself had just offered (keksdose). So a\n // missing type is inferred from the extension where that is unambiguous, and a file\n // whose type cannot be known at all is given the benefit of the doubt — nothing here\n // proves it does not match, and the server validates what it receives anyway.\n const type = (file.type || typeFromExtension(name) || \"\").toLowerCase();\n if (!type && !tokens.every((t) => t.startsWith(\".\"))) return true;\n return tokens.some((token) => {\n if (token.startsWith(\".\")) return name.endsWith(token);\n if (!type) return false;\n if (token.endsWith(\"/*\")) return type.startsWith(token.slice(0, -1));\n return type === token;\n });\n}\n\n/** MIME types for the extensions a browser most often leaves untyped. */\nconst EXTENSION_TYPES: Record<string, string> = {\n heic: \"image/heic\",\n heif: \"image/heif\",\n avif: \"image/avif\",\n webp: \"image/webp\",\n jpg: \"image/jpeg\",\n jpeg: \"image/jpeg\",\n png: \"image/png\",\n gif: \"image/gif\",\n pdf: \"application/pdf\",\n csv: \"text/csv\",\n txt: \"text/plain\",\n};\n\nfunction typeFromExtension(name: string): string | undefined {\n const dot = name.lastIndexOf(\".\");\n return dot === -1 ? undefined : EXTENSION_TYPES[name.slice(dot + 1)];\n}\n\n/** @internal `\" .PDF, image/png ,\"` => `\".pdf, image/png\"` — `accept` as a person reads\n * it. Also the dropzone's default hint. */\nexport function formatAccept(accept: string): string {\n return accept\n .split(\",\")\n .map((t) => t.trim().toLowerCase())\n .filter(Boolean)\n .join(\", \");\n}\n\n/** What the pickers screen a pick with. All optional; nothing set accepts everything. */\nexport interface FileScreenOptions {\n accept?: string;\n /** Bytes. Larger files are refused with reason `\"size\"`. */\n maxSize?: number;\n /** How many files one pick may deliver. The rest are refused with reason `\"count\"`\n * — first come, first kept. For a running cap (\"at most 5 attachments\") pass what\n * is LEFT: `maxFiles={5 - attachments.length}`. */\n maxFiles?: number;\n /** The caller's own check, after `accept` and `maxSize`. */\n isValid?: (file: File) => boolean;\n /** The message for an `isValid` refusal; `labels.rejectedInvalid` otherwise. */\n invalidMessage?: string;\n}\n\n/** @internal Split a pick into the files that pass and the ones that do not. */\nexport function screenFiles(\n files: readonly File[],\n opts: FileScreenOptions,\n labels: FilePickerLabels,\n formatSize: (bytes: number) => string,\n): { accepted: File[]; rejected: FileRejection[] } {\n const accepted: File[] = [];\n const rejected: FileRejection[] = [];\n // Name what `accept` takes (\"Only .csv files\") — unless the host translated\n // `rejectedType` but not yet `rejectedTypeOnly`: its own sentence beats an English one.\n const acceptText = opts.accept ? formatAccept(opts.accept) : \"\";\n const useOnly =\n acceptText !== \"\" &&\n (labels.rejectedTypeOnly !== DEFAULT_FILE_PICKER_LABELS.rejectedTypeOnly ||\n labels.rejectedType === DEFAULT_FILE_PICKER_LABELS.rejectedType);\n const typeMessage = (name: string) =>\n useOnly ? labels.rejectedTypeOnly(acceptText, name) : labels.rejectedType(name);\n for (const file of files) {\n let reason: FileRejectionReason | null = null;\n if (!matchesAccept(file, opts.accept)) reason = \"type\";\n else if (opts.maxSize !== undefined && file.size > opts.maxSize) reason = \"size\";\n else if (opts.isValid && !opts.isValid(file)) reason = \"invalid\";\n // Count last, and only against files that passed everything else: a refused\n // file should not use up one of the slots a good one could have had.\n else if (opts.maxFiles !== undefined && accepted.length >= opts.maxFiles) reason = \"count\";\n if (reason === null) {\n accepted.push(file);\n continue;\n }\n const message =\n reason === \"type\"\n ? typeMessage(file.name)\n : reason === \"size\"\n ? labels.rejectedSize(file.name, formatSize(opts.maxSize ?? 0))\n : reason === \"count\"\n ? labels.rejectedCount(file.name, Math.max(0, opts.maxFiles ?? 0))\n : (opts.invalidMessage ?? labels.rejectedInvalid(file.name));\n rejected.push({ file, reason, message });\n }\n return { accepted, rejected };\n}\n\n/**\n * Judges a pick as a whole — keksdose's \"refuse the pick if any file is bad\", which\n * with `onFiles` + `onReject` alone had to be rebuilt from two calls in a microtask.\n *\n * Called ONCE per pick, after screening and before `onFiles` / `onReject`, with both\n * halves (either may be empty). Return `false` to refuse the whole pick: the accepted\n * files are not delivered, `onReject` still receives what screening refused, and one\n * sentence (`labels.rejectedPick`) is spoken for the pick instead of a per-file one.\n * Return nothing to let the pick through as usual.\n *\n * ```tsx\n * onPick={(ok, bad) => bad.length === 0 || false} // all or nothing\n * ```\n */\nexport type FilePickHandler = (accepted: File[], rejected: FileRejection[]) => boolean | void;\n\n/** @internal The shared tail of both pickers: run `onPick`, and say whether the pick\n * stands. A pick with nothing accepted has nothing to refuse, so `false` there is\n * treated as no verdict and the usual per-file messages are kept. */\nexport function judgePick(\n onPick: FilePickHandler | undefined,\n accepted: File[],\n rejected: FileRejection[],\n): boolean {\n if (!onPick) return true;\n return onPick(accepted, rejected) !== false || accepted.length === 0;\n}\n\n/** One sentence for a whole batch of refusals: the file's own message for one, a\n * count for several — reading out five sentences in a row helps nobody. */\nexport function summariseRejections(rejected: readonly FileRejection[], labels: FilePickerLabels): string {\n if (rejected.length === 0) return \"\";\n if (rejected.length === 1) return rejected[0].message;\n return labels.rejectedMany(rejected.length);\n}\n\n/* ── useFilePicker ───────────────────────────────────────────────────────── */\n\nexport interface UseFilePickerOptions extends FileScreenOptions {\n /** Let one pick deliver several files. Without it a drop of several keeps the first. */\n multiple?: boolean;\n /**\n * Ask a phone for its camera instead of the file chooser: `\"environment\"` is the\n * back camera, `\"user\"` the front. A HINT — desktop browsers ignore it, and Chrome\n * drops it when `multiple` is also set (a camera cannot deliver a list), which is why\n * keksdose's camera input has no `multiple`. Pass one or the other.\n */\n capture?: boolean | \"user\" | \"environment\";\n /** The files that passed, in pick order. Never called with an empty array.\n * Optional since 0.7 for a caller that takes the pick through `onPick` alone. */\n onFiles?: (files: File[]) => void;\n /** See {@link FilePickHandler}: the whole pick at once, with the power to refuse it. */\n onPick?: FilePickHandler;\n /** The files that did not, with a translated message each. The refusals are also\n * spoken through a live region, so this is for SHOWING them, not for a11y. */\n onReject?: (rejections: FileRejection[]) => void;\n /** `open()` and `take()` do nothing while set. */\n disabled?: boolean;\n /** Per-instance overrides of the `filePicker` label namespace. */\n labels?: Partial<FilePickerLabels>;\n}\n\nexport interface UseFilePickerReturn {\n /** Open the system picker. Call it from a click handler — browsers only open a file\n * dialog in response to a user gesture. */\n open: () => void;\n /** Screen and deliver files that arrived some other way — a drop, a paste. Honours\n * `multiple` (only the first file without it) and every check. */\n take: (files: ArrayLike<File> | null | undefined) => void;\n /** The hidden input and the live region. Render it once, anywhere — it takes no\n * space and needs no positioned ancestor. */\n element: ReactElement;\n}\n\n/**\n * The headless half of {@link FileButton}: a hidden file input you can open from any\n * control, with the reset, the screening and the announcement built in.\n *\n * ```tsx\n * const picker = useFilePicker({ accept: \".pdf\", onFiles: ([f]) => upload(f) });\n * return <>{picker.element}<DetailTableCard onAdd={picker.open} … /></>;\n * ```\n */\nexport function useFilePicker({\n accept,\n multiple,\n capture,\n maxSize,\n maxFiles,\n isValid,\n invalidMessage,\n onFiles,\n onPick,\n onReject,\n disabled,\n labels: labelsProp,\n}: UseFilePickerOptions): UseFilePickerReturn {\n const inputRef = useRef<HTMLInputElement>(null);\n const labels = useKitLabels(\"filePicker\", DEFAULT_FILE_PICKER_LABELS, labelsProp);\n const fileText = useKitFileLabels();\n // Assertive: a refusal is a failure the user has to hear before they move on, and\n // it is the only thing this region ever says.\n const { announce, regionProps } = useAnnounce({ politeness: \"assertive\" });\n\n const take = (list: ArrayLike<File> | null | undefined) => {\n if (disabled || !list || list.length === 0) return;\n const all = Array.from(list);\n const files = multiple ? all : all.slice(0, 1);\n const { accepted, rejected } = screenFiles(\n files,\n // A single-file picker holds one file by definition; `maxFiles` is a multi-mode\n // cap and would only ever say \"0\" there if a caller passed it by mistake.\n { accept, maxSize, maxFiles: multiple ? maxFiles : undefined, isValid, invalidMessage },\n labels,\n fileText.size,\n );\n if (!judgePick(onPick, accepted, rejected)) {\n if (rejected.length > 0) onReject?.(rejected);\n announce(labels.rejectedPick(files.length));\n return;\n }\n if (accepted.length > 0) onFiles?.(accepted);\n if (rejected.length > 0) {\n onReject?.(rejected);\n announce(summariseRejections(rejected, labels));\n }\n };\n\n const element = (\n <>\n <input\n ref={inputRef}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n capture={capture}\n disabled={disabled}\n // `hidden` (display: none), not `sr-only`: the control a user reaches is the\n // button, and a second, nameless tab stop for the same action is noise. A\n // display:none file input still opens on `.click()` in every current browser —\n // and, unlike `sr-only`, it cannot escape to the initial containing block and\n // stretch the page (see the note in `file-dropzone.tsx`).\n className=\"hidden\"\n tabIndex={-1}\n aria-hidden\n onChange={(e) => {\n // Copy BEFORE the reset: `files` is a live view of the input's value, and\n // clearing the value empties it.\n const picked = Array.from(e.currentTarget.files ?? []);\n e.currentTarget.value = \"\";\n take(picked);\n }}\n />\n <span {...regionProps} />\n </>\n );\n\n return {\n open: () => {\n if (!disabled) inputRef.current?.click();\n },\n take,\n element,\n };\n}\n\n/* ── FileButton ──────────────────────────────────────────────────────────── */\n\ntype ButtonOwnProps = ComponentPropsWithoutRef<typeof Button>;\n\nexport interface FileButtonProps\n extends Omit<UseFilePickerOptions, \"disabled\">,\n // `onDrop` & co. stay the caller's own when `droppable` is off; `type` is fixed to\n // \"button\" (see 2. above) — a file trigger never submits a form.\n Omit<ButtonOwnProps, \"type\" | \"children\" | \"accept\" | \"capture\" | \"multiple\"> {\n /** The button's content — usually an icon and a word. It is the accessible name. */\n children: ReactNode;\n /** Busy: disabled, `aria-busy`, and a spinner before the content — for \"uploading\". */\n pending?: boolean;\n /** Also accept files dropped ON the button (lenkbank's \"drop onto the button\").\n * Off by default: a button that silently takes drops is a surprise on a page that\n * has a real drop target elsewhere. */\n droppable?: boolean;\n}\n\n/**\n * {@link useFilePicker} behind a {@link Button}: `variant` and every other button prop\n * pass through, and the ref is the `<button>` (so `ref.current.click()` opens the\n * picker from elsewhere too).\n *\n * ```tsx\n * <FileButton accept=\"image/*,application/pdf\" capture=\"environment\" variant=\"secondary\"\n * maxSize={10_000_000} onFiles={([f]) => upload(f)} onReject={([r]) => setError(r.message)}>\n * <Camera aria-hidden /> Photograph receipt\n * </FileButton>\n * ```\n */\nexport const FileButton = forwardRef<HTMLButtonElement, FileButtonProps>(function FileButton(\n {\n accept,\n multiple,\n capture,\n maxSize,\n maxFiles,\n isValid,\n invalidMessage,\n onFiles,\n onPick,\n onReject,\n labels,\n pending,\n droppable,\n disabled,\n children,\n className,\n onClick,\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop,\n ...rest\n },\n ref,\n) {\n const inert = Boolean(disabled || pending);\n const picker = useFilePicker({\n accept,\n multiple,\n capture,\n maxSize,\n maxFiles,\n isValid,\n invalidMessage,\n onFiles,\n onPick,\n onReject,\n labels,\n disabled: inert,\n });\n const [dragOver, setDragOver] = useState(false);\n\n const hasFiles = (e: DragEvent) => Array.from(e.dataTransfer?.types ?? []).includes(\"Files\");\n // Only when `droppable`: otherwise the caller's own handlers are passed untouched.\n const dropHandlers = droppable\n ? {\n onDragEnter: (e: DragEvent<HTMLButtonElement>) => {\n onDragEnter?.(e);\n if (!hasFiles(e)) return;\n e.preventDefault();\n if (!inert) setDragOver(true);\n },\n onDragOver: (e: DragEvent<HTMLButtonElement>) => {\n onDragOver?.(e);\n if (!hasFiles(e)) return;\n // Always cancel for a file drag, busy or not: an uncancelled drop makes the\n // browser NAVIGATE to the file, which loses the page.\n e.preventDefault();\n e.dataTransfer.dropEffect = inert ? \"none\" : \"copy\";\n },\n onDragLeave: (e: DragEvent<HTMLButtonElement>) => {\n onDragLeave?.(e);\n if (e.currentTarget.contains(e.relatedTarget as Node | null)) return;\n setDragOver(false);\n },\n onDrop: (e: DragEvent<HTMLButtonElement>) => {\n onDrop?.(e);\n if (!hasFiles(e)) return;\n e.preventDefault();\n setDragOver(false);\n picker.take(e.dataTransfer.files);\n },\n }\n : { onDragEnter, onDragOver, onDragLeave, onDrop };\n\n // `Button` is a plain function component; under React 19 `ref` is an ordinary prop\n // and reaches the `<button>` through its `...rest`. Its props type just does not\n // declare it, hence the widening here rather than a second button implementation.\n const refProp = { ref } as { ref?: Ref<HTMLButtonElement> };\n\n return (\n <>\n <Button\n {...rest}\n {...refProp}\n {...dropHandlers}\n type=\"button\"\n disabled={inert}\n aria-busy={pending || undefined}\n data-drag-over={dragOver || undefined}\n className={cn(\n // A live drag gets the focus ring's colour as a ring: \"let go here\", in the\n // same vocabulary the button already uses for \"you are here\".\n dragOver && \"ring-2 ring-[var(--brand)]\",\n className,\n )}\n onClick={(e) => {\n onClick?.(e);\n if (!e.defaultPrevented) picker.open();\n }}\n >\n {/* `label={null}`: the spinner is decoration here — `aria-busy` says the same\n thing on the button, and a spoken \"Loading\" would run into its name. */}\n {pending && <Spinner label={null} className=\"size-4\" />}\n {children}\n </Button>\n {picker.element}\n </>\n );\n});\nFileButton.displayName = \"FileButton\";\n"],"mappings":";AA8WI,mBACE,KADF;AA9WJ,SAAS,YAAY,QAAQ,gBAAgB;AAE7C,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB,oBAAoB;AAC/C,SAAS,QAAQ,eAAe;AA4EzB,MAAM,6BAA+C;AAAA,EAC1D,cAAc,CAAC,SAAS,SAAI,IAAI;AAAA,EAChC,kBAAkB,CAAC,WAA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