@eifi1/ui-kit 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. package/README.md +57 -32
  2. package/dist/chart.d.ts +3 -1
  3. package/dist/chart.js +2 -0
  4. package/dist/chart.js.map +1 -1
  5. package/dist/components/account-settings-labels.d.ts +105 -0
  6. package/dist/components/account-settings-labels.js +81 -0
  7. package/dist/components/account-settings-labels.js.map +1 -0
  8. package/dist/components/account-settings.d.ts +36 -52
  9. package/dist/components/account-settings.js +44 -8
  10. package/dist/components/account-settings.js.map +1 -1
  11. package/dist/components/amount-input.d.ts +24 -4
  12. package/dist/components/amount-input.js +5 -2
  13. package/dist/components/amount-input.js.map +1 -1
  14. package/dist/components/authed-image.d.ts +68 -0
  15. package/dist/components/authed-image.js +117 -0
  16. package/dist/components/authed-image.js.map +1 -0
  17. package/dist/components/breadcrumbs.d.ts +2 -1
  18. package/dist/components/breadcrumbs.js +5 -2
  19. package/dist/components/breadcrumbs.js.map +1 -1
  20. package/dist/components/button-group.d.ts +51 -2
  21. package/dist/components/button-group.js +5 -1
  22. package/dist/components/button-group.js.map +1 -1
  23. package/dist/components/calculator.d.ts +15 -4
  24. package/dist/components/calendar-heatmap.d.ts +41 -3
  25. package/dist/components/calendar-heatmap.js +48 -7
  26. package/dist/components/calendar-heatmap.js.map +1 -1
  27. package/dist/components/chip.d.ts +2 -1
  28. package/dist/components/chip.js +6 -3
  29. package/dist/components/chip.js.map +1 -1
  30. package/dist/components/choice-card.d.ts +35 -3
  31. package/dist/components/choice-card.js +83 -25
  32. package/dist/components/choice-card.js.map +1 -1
  33. package/dist/components/combobox-core.js +2 -0
  34. package/dist/components/combobox-core.js.map +1 -1
  35. package/dist/components/combobox.d.ts +2 -2
  36. package/dist/components/combobox.js +31 -9
  37. package/dist/components/combobox.js.map +1 -1
  38. package/dist/components/copy-button.d.ts +51 -70
  39. package/dist/components/copy-button.js +1 -1
  40. package/dist/components/copy-button.js.map +1 -1
  41. package/dist/components/data-table-cells.d.ts +63 -0
  42. package/dist/components/data-table-cells.js +64 -0
  43. package/dist/components/data-table-cells.js.map +1 -0
  44. package/dist/components/data-table-filter-popover.d.ts +1 -1
  45. package/dist/components/data-table-filters.d.ts +1 -1
  46. package/dist/components/data-table-filters.js +31 -1
  47. package/dist/components/data-table-filters.js.map +1 -1
  48. package/dist/components/data-table-labels.d.ts +13 -0
  49. package/dist/components/data-table-labels.js +8 -1
  50. package/dist/components/data-table-labels.js.map +1 -1
  51. package/dist/components/data-table.d.ts +1 -1
  52. package/dist/components/data-table.js +102 -12
  53. package/dist/components/data-table.js.map +1 -1
  54. package/dist/components/date-picker.d.ts +3 -1
  55. package/dist/components/date-picker.js +15 -2
  56. package/dist/components/date-picker.js.map +1 -1
  57. package/dist/components/description-list.d.ts +23 -3
  58. package/dist/components/description-list.js +23 -3
  59. package/dist/components/description-list.js.map +1 -1
  60. package/dist/components/dialog-frame.d.ts +1 -0
  61. package/dist/components/entity-combobox.d.ts +1 -1
  62. package/dist/components/entity-combobox.js +18 -3
  63. package/dist/components/entity-combobox.js.map +1 -1
  64. package/dist/components/error-boundary.d.ts +92 -0
  65. package/dist/components/error-boundary.js +111 -0
  66. package/dist/components/error-boundary.js.map +1 -0
  67. package/dist/components/field.d.ts +30 -4
  68. package/dist/components/field.js +40 -17
  69. package/dist/components/field.js.map +1 -1
  70. package/dist/components/file-button.d.ts +50 -208
  71. package/dist/components/file-dropzone.d.ts +49 -2
  72. package/dist/components/floating-panel.d.ts +13 -4
  73. package/dist/components/floating-panel.js +7 -3
  74. package/dist/components/floating-panel.js.map +1 -1
  75. package/dist/components/form-actions.d.ts +53 -0
  76. package/dist/components/form-actions.js +98 -0
  77. package/dist/components/form-actions.js.map +1 -0
  78. package/dist/components/image-grid.d.ts +67 -0
  79. package/dist/components/image-grid.js +112 -0
  80. package/dist/components/image-grid.js.map +1 -0
  81. package/dist/components/lightbox.d.ts +104 -0
  82. package/dist/components/lightbox.js +229 -0
  83. package/dist/components/lightbox.js.map +1 -0
  84. package/dist/components/line-items.d.ts +114 -0
  85. package/dist/components/line-items.js +238 -0
  86. package/dist/components/line-items.js.map +1 -0
  87. package/dist/components/list.d.ts +23 -2
  88. package/dist/components/list.js +32 -13
  89. package/dist/components/list.js.map +1 -1
  90. package/dist/components/loading-state.d.ts +24 -0
  91. package/dist/components/loading-state.js +32 -0
  92. package/dist/components/loading-state.js.map +1 -0
  93. package/dist/components/menu-item.d.ts +2 -1
  94. package/dist/components/menu-item.js +5 -1
  95. package/dist/components/menu-item.js.map +1 -1
  96. package/dist/components/mini-calendar.d.ts +13 -1
  97. package/dist/components/mini-calendar.js +46 -2
  98. package/dist/components/mini-calendar.js.map +1 -1
  99. package/dist/components/modal.d.ts +20 -1
  100. package/dist/components/modal.js +26 -2
  101. package/dist/components/modal.js.map +1 -1
  102. package/dist/components/month-picker.d.ts +21 -1
  103. package/dist/components/month-picker.js +139 -26
  104. package/dist/components/month-picker.js.map +1 -1
  105. package/dist/components/multi-entity-combobox.d.ts +1 -1
  106. package/dist/components/multi-entity-combobox.js +19 -3
  107. package/dist/components/multi-entity-combobox.js.map +1 -1
  108. package/dist/components/nav-pills.d.ts +2 -1
  109. package/dist/components/nav-pills.js +5 -1
  110. package/dist/components/nav-pills.js.map +1 -1
  111. package/dist/components/number-field.d.ts +24 -5
  112. package/dist/components/number-field.js +5 -7
  113. package/dist/components/number-field.js.map +1 -1
  114. package/dist/components/number-input.d.ts +25 -5
  115. package/dist/components/number-input.js +7 -1
  116. package/dist/components/number-input.js.map +1 -1
  117. package/dist/components/numpad-sheet.d.ts +15 -4
  118. package/dist/components/passkeys-setting.d.ts +67 -0
  119. package/dist/components/passkeys-setting.js +214 -0
  120. package/dist/components/passkeys-setting.js.map +1 -0
  121. package/dist/components/picker-sheet.js +2 -1
  122. package/dist/components/picker-sheet.js.map +1 -1
  123. package/dist/components/pie-chart-labels.d.ts +20 -0
  124. package/dist/components/pie-chart-labels.js +12 -0
  125. package/dist/components/pie-chart-labels.js.map +1 -0
  126. package/dist/components/pie-chart.d.ts +101 -0
  127. package/dist/components/pie-chart.js +283 -0
  128. package/dist/components/pie-chart.js.map +1 -0
  129. package/dist/components/progress-bar.d.ts +44 -3
  130. package/dist/components/progress-bar.js +58 -22
  131. package/dist/components/progress-bar.js.map +1 -1
  132. package/dist/components/qr-code.d.ts +34 -0
  133. package/dist/components/qr-code.js +57 -0
  134. package/dist/components/qr-code.js.map +1 -0
  135. package/dist/components/search-field.d.ts +15 -3
  136. package/dist/components/search-field.js +5 -1
  137. package/dist/components/search-field.js.map +1 -1
  138. package/dist/components/settings-fields.d.ts +49 -1
  139. package/dist/components/signed-amount.d.ts +121 -0
  140. package/dist/components/signed-amount.js +152 -0
  141. package/dist/components/signed-amount.js.map +1 -0
  142. package/dist/components/skeleton.d.ts +10 -3
  143. package/dist/components/skeleton.js +12 -2
  144. package/dist/components/skeleton.js.map +1 -1
  145. package/dist/components/stat-tile.d.ts +2 -1
  146. package/dist/components/stat-tile.js +5 -2
  147. package/dist/components/stat-tile.js.map +1 -1
  148. package/dist/components/table.d.ts +39 -5
  149. package/dist/components/table.js +45 -11
  150. package/dist/components/table.js.map +1 -1
  151. package/dist/components/text-link.d.ts +176 -0
  152. package/dist/components/text-link.js +109 -0
  153. package/dist/components/text-link.js.map +1 -0
  154. package/dist/components/time-input.d.ts +49 -1
  155. package/dist/components/toggle-group.d.ts +13 -0
  156. package/dist/components/toggle-group.js +35 -6
  157. package/dist/components/toggle-group.js.map +1 -1
  158. package/dist/components/toggle-legend.d.ts +36 -3
  159. package/dist/components/toggle-legend.js +49 -0
  160. package/dist/components/toggle-legend.js.map +1 -1
  161. package/dist/components/ui.d.ts +51 -779
  162. package/dist/components/ui.js +215 -23
  163. package/dist/components/ui.js.map +1 -1
  164. package/dist/components/use-table-state.d.ts +3 -52
  165. package/dist/components/use-table-state.js +128 -30
  166. package/dist/components/use-table-state.js.map +1 -1
  167. package/dist/{data-table-filters-Dh9uF_S-.d.ts → data-table-Drun8Fk9.d.ts} +305 -61
  168. package/dist/data-table.d.ts +2 -1
  169. package/dist/data-table.js +5 -1
  170. package/dist/data-table.js.map +1 -1
  171. package/dist/feedback/feedback-dialog.d.ts +26 -3
  172. package/dist/feedback/feedback-dialog.js +16 -2
  173. package/dist/feedback/feedback-dialog.js.map +1 -1
  174. package/dist/feedback/feedback-thread.d.ts +133 -0
  175. package/dist/feedback/feedback-thread.js +237 -0
  176. package/dist/feedback/feedback-thread.js.map +1 -0
  177. package/dist/feedback.d.ts +2 -1
  178. package/dist/feedback.js +1 -0
  179. package/dist/feedback.js.map +1 -1
  180. package/dist/hooks/use-authed-src.d.ts +71 -0
  181. package/dist/hooks/use-authed-src.js +63 -0
  182. package/dist/hooks/use-authed-src.js.map +1 -0
  183. package/dist/hooks/use-file-drop.d.ts +49 -2
  184. package/dist/hooks/use-hotkey.d.ts +59 -0
  185. package/dist/hooks/use-hotkey.js +105 -0
  186. package/dist/hooks/use-hotkey.js.map +1 -0
  187. package/dist/hooks/use-search-param-state.d.ts +83 -0
  188. package/dist/hooks/use-search-param-state.js +94 -0
  189. package/dist/hooks/use-search-param-state.js.map +1 -0
  190. package/dist/i18n/defaults.d.ts +15 -4
  191. package/dist/i18n/defaults.js +31 -1
  192. package/dist/i18n/defaults.js.map +1 -1
  193. package/dist/i18n/kit-labels.d.ts +46 -312
  194. package/dist/i18n/kit-labels.js +20 -5
  195. package/dist/i18n/kit-labels.js.map +1 -1
  196. package/dist/i18n/locales/de-CH-informal.d.ts +15 -4
  197. package/dist/i18n/locales/de-CH.d.ts +15 -4
  198. package/dist/i18n/locales/de-informal.d.ts +15 -4
  199. package/dist/i18n/locales/de.d.ts +15 -4
  200. package/dist/i18n/locales/de.js +156 -3
  201. package/dist/i18n/locales/de.js.map +1 -1
  202. package/dist/i18n/locales/es.d.ts +15 -4
  203. package/dist/i18n/locales/es.js +153 -3
  204. package/dist/i18n/locales/es.js.map +1 -1
  205. package/dist/i18n/locales/fr.d.ts +15 -4
  206. package/dist/i18n/locales/fr.js +153 -3
  207. package/dist/i18n/locales/fr.js.map +1 -1
  208. package/dist/i18n/locales/hu.d.ts +15 -4
  209. package/dist/i18n/locales/hu.js +153 -3
  210. package/dist/i18n/locales/hu.js.map +1 -1
  211. package/dist/i18n/locales/it.d.ts +15 -4
  212. package/dist/i18n/locales/it.js +153 -3
  213. package/dist/i18n/locales/it.js.map +1 -1
  214. package/dist/i18n/locales/zh.d.ts +15 -4
  215. package/dist/i18n/locales/zh.js +153 -3
  216. package/dist/i18n/locales/zh.js.map +1 -1
  217. package/dist/index.d.ts +37 -17
  218. package/dist/index.js +40 -1
  219. package/dist/index.js.map +1 -1
  220. package/dist/kit-labels-v3biUF1L.d.ts +1645 -0
  221. package/dist/lib/format.d.ts +144 -0
  222. package/dist/lib/format.js +149 -0
  223. package/dist/lib/format.js.map +1 -0
  224. package/dist/lib/qr-encode.d.ts +44 -0
  225. package/dist/lib/qr-encode.js +338 -0
  226. package/dist/lib/qr-encode.js.map +1 -0
  227. package/dist/rhf/fields.d.ts +241 -0
  228. package/dist/rhf/fields.js +601 -0
  229. package/dist/rhf/fields.js.map +1 -0
  230. package/dist/rhf/form.d.ts +49 -1
  231. package/dist/rhf/line-items.d.ts +31 -0
  232. package/dist/rhf/line-items.js +59 -0
  233. package/dist/rhf/line-items.js.map +1 -0
  234. package/dist/rhf.d.ts +61 -1
  235. package/dist/rhf.js +2 -0
  236. package/dist/rhf.js.map +1 -1
  237. package/dist/shell/app-shell.d.ts +99 -2
  238. package/dist/shell/app-shell.js +58 -3
  239. package/dist/shell/app-shell.js.map +1 -1
  240. package/dist/shell/auth-layout.d.ts +74 -0
  241. package/dist/shell/auth-layout.js +97 -0
  242. package/dist/shell/auth-layout.js.map +1 -0
  243. package/dist/shell/top-bar-brand.d.ts +81 -0
  244. package/dist/shell/top-bar-brand.js +47 -0
  245. package/dist/shell/top-bar-brand.js.map +1 -0
  246. package/dist/shell/topbar-action-menu.d.ts +12 -1
  247. package/dist/shell/topbar-action-menu.js +16 -1
  248. package/dist/shell/topbar-action-menu.js.map +1 -1
  249. package/dist/shell.d.ts +56 -1
  250. package/dist/shell.js +2 -0
  251. package/dist/shell.js.map +1 -1
  252. package/dist/wizard/stepper-nav.d.ts +48 -1
  253. package/dist/wizard/wizard-context.d.ts +24 -1
  254. package/dist/wizard/wizard-context.js +19 -2
  255. package/dist/wizard/wizard-context.js.map +1 -1
  256. package/dist/wizard/wizard-step.d.ts +20 -5
  257. package/dist/wizard/wizard-step.js +16 -3
  258. package/dist/wizard/wizard-step.js.map +1 -1
  259. package/dist/wizard.d.ts +50 -3
  260. package/package.json +1 -1
  261. package/src/chart.ts +4 -0
  262. package/src/components/account-settings-labels.ts +190 -0
  263. package/src/components/account-settings.tsx +110 -63
  264. package/src/components/amount-input.tsx +13 -1
  265. package/src/components/authed-image.tsx +190 -0
  266. package/src/components/breadcrumbs.tsx +8 -2
  267. package/src/components/button-group.tsx +7 -2
  268. package/src/components/calendar-heatmap.tsx +105 -10
  269. package/src/components/chip.tsx +8 -4
  270. package/src/components/choice-card.tsx +136 -25
  271. package/src/components/combobox-core.tsx +5 -0
  272. package/src/components/combobox.tsx +31 -9
  273. package/src/components/copy-button.tsx +3 -2
  274. package/src/components/data-table-cells.tsx +119 -0
  275. package/src/components/data-table-filters.ts +77 -0
  276. package/src/components/data-table-labels.ts +23 -0
  277. package/src/components/data-table.tsx +224 -13
  278. package/src/components/date-picker.tsx +19 -3
  279. package/src/components/description-list.tsx +52 -3
  280. package/src/components/entity-combobox.tsx +18 -3
  281. package/src/components/error-boundary.tsx +216 -0
  282. package/src/components/field.tsx +56 -5
  283. package/src/components/floating-panel.tsx +20 -7
  284. package/src/components/form-actions.tsx +191 -0
  285. package/src/components/image-grid.tsx +181 -0
  286. package/src/components/lightbox.tsx +374 -0
  287. package/src/components/line-items.tsx +385 -0
  288. package/src/components/list.tsx +65 -16
  289. package/src/components/loading-state.tsx +47 -0
  290. package/src/components/menu-item.tsx +7 -2
  291. package/src/components/mini-calendar.tsx +72 -3
  292. package/src/components/modal.tsx +61 -3
  293. package/src/components/month-picker.tsx +181 -26
  294. package/src/components/multi-entity-combobox.tsx +19 -3
  295. package/src/components/nav-pills.tsx +8 -1
  296. package/src/components/number-field.tsx +15 -10
  297. package/src/components/number-input.tsx +16 -1
  298. package/src/components/passkeys-setting.tsx +331 -0
  299. package/src/components/picker-sheet.tsx +7 -1
  300. package/src/components/pie-chart-labels.ts +32 -0
  301. package/src/components/pie-chart.tsx +479 -0
  302. package/src/components/progress-bar.tsx +129 -19
  303. package/src/components/qr-code.tsx +83 -0
  304. package/src/components/search-field.tsx +20 -4
  305. package/src/components/signed-amount.tsx +286 -0
  306. package/src/components/skeleton.tsx +21 -3
  307. package/src/components/stat-tile.tsx +8 -2
  308. package/src/components/table.tsx +102 -13
  309. package/src/components/text-link.tsx +248 -0
  310. package/src/components/toggle-group.tsx +58 -10
  311. package/src/components/toggle-legend.tsx +87 -2
  312. package/src/components/ui.tsx +426 -36
  313. package/src/components/use-table-state.ts +265 -33
  314. package/src/data-table.ts +10 -0
  315. package/src/feedback/feedback-dialog.tsx +42 -3
  316. package/src/feedback/feedback-thread.tsx +434 -0
  317. package/src/feedback.ts +1 -0
  318. package/src/hooks/use-authed-src.ts +161 -0
  319. package/src/hooks/use-hotkey.ts +172 -0
  320. package/src/hooks/use-search-param-state.ts +187 -0
  321. package/src/i18n/defaults.ts +30 -0
  322. package/src/i18n/kit-labels.tsx +102 -8
  323. package/src/i18n/locales/de.ts +153 -0
  324. package/src/i18n/locales/es.ts +150 -0
  325. package/src/i18n/locales/fr.ts +153 -0
  326. package/src/i18n/locales/hu.ts +151 -0
  327. package/src/i18n/locales/it.ts +151 -0
  328. package/src/i18n/locales/zh.ts +150 -0
  329. package/src/index.ts +59 -0
  330. package/src/lib/format.ts +325 -0
  331. package/src/lib/qr-encode.ts +420 -0
  332. package/src/rhf/fields.tsx +1054 -0
  333. package/src/rhf/line-items.tsx +130 -0
  334. package/src/rhf.ts +6 -0
  335. package/src/shell/app-shell.tsx +147 -2
  336. package/src/shell/auth-layout.tsx +190 -0
  337. package/src/shell/top-bar-brand.tsx +76 -0
  338. package/src/shell/topbar-action-menu.tsx +21 -0
  339. package/src/shell.ts +2 -0
  340. package/src/wizard/wizard-context.tsx +41 -1
  341. package/src/wizard/wizard-step.tsx +43 -6
  342. package/tokens.css +12 -0
@@ -0,0 +1,130 @@
1
+ /**
2
+ * {@link LineItems} over react-hook-form's `useFieldArray`. `@eifi1/ui-kit/rhf`.
3
+ *
4
+ * ```tsx
5
+ * <RhfLineItems
6
+ * name="components"
7
+ * newItem={() => ({ type: "net_rent", amount: null, validFrom: "" })}
8
+ * minItems={1}
9
+ * columns={[
10
+ * { key: "type", header: "Type", render: ({ name, label }) => (
11
+ * <RhfSelect name={`${name}.type`} options={TYPES} aria-label={label} />
12
+ * ) },
13
+ * { key: "amount", header: "Amount", width: "8rem", align: "end", render: ({ name, label }) => (
14
+ * <RhfMoneyField name={`${name}.amount`} ariaLabel={label} />
15
+ * ) },
16
+ * ]}
17
+ * totals={{ amount: formatMoney(total) }}
18
+ * />
19
+ * ```
20
+ *
21
+ * The rows are the array's `fields` (keyed by their `id`, as react-hook-form asks),
22
+ * Add appends `newItem()`, remove is `remove(index)`, and an error on the array
23
+ * itself — the `rules` here, or a resolver's `lines: "At least two lines"` — is the
24
+ * list's `error`. Each cell's `render` gets `name`, the row's path
25
+ * (`"components.2"`), to bind its field to.
26
+ */
27
+ import type { ReactNode } from "react";
28
+ import {
29
+ useFieldArray,
30
+ useFormState,
31
+ type FieldArray,
32
+ type FieldArrayPath,
33
+ type FieldArrayWithId,
34
+ type FieldValues,
35
+ type UseFieldArrayProps,
36
+ } from "react-hook-form";
37
+ import {
38
+ LineItems,
39
+ type LineItemCellContext,
40
+ type LineItemsColumn,
41
+ type LineItemsProps,
42
+ } from "../components/line-items";
43
+
44
+ /** A cell's context, with the row's path in the form. */
45
+ export interface RhfLineItemCellContext<TItem, TArrayName extends string>
46
+ extends LineItemCellContext<TItem> {
47
+ /** The row's path: `${name}.${index}` — bind the cell's field to
48
+ * `` `${name}.amount` ``. */
49
+ name: `${TArrayName}.${number}`;
50
+ }
51
+
52
+ export interface RhfLineItemsColumn<TItem, TArrayName extends string>
53
+ extends Omit<LineItemsColumn<TItem>, "render"> {
54
+ render: (ctx: RhfLineItemCellContext<TItem, TArrayName>) => ReactNode;
55
+ }
56
+
57
+ export interface RhfLineItemsProps<
58
+ TFieldValues extends FieldValues = FieldValues,
59
+ TArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>,
60
+ TTransformed = TFieldValues,
61
+ > extends Omit<
62
+ LineItemsProps<FieldArrayWithId<TFieldValues, TArrayName, "id">>,
63
+ "items" | "columns" | "onAdd" | "onRemove" | "getKey"
64
+ > {
65
+ name: TArrayName;
66
+ /** `form.control`. Optional under `<Form {...form}>`. */
67
+ control?: UseFieldArrayProps<TFieldValues, TArrayName, "id", TTransformed>["control"];
68
+ /** `useFieldArray`'s `rules` (`minLength`, `validate` …); its message is the list's
69
+ * error. */
70
+ rules?: UseFieldArrayProps<TFieldValues, TArrayName, "id", TTransformed>["rules"];
71
+ columns: readonly RhfLineItemsColumn<FieldArrayWithId<TFieldValues, TArrayName, "id">, TArrayName>[];
72
+ /** A new row's values. Omitted: no add button. */
73
+ newItem?: () => FieldArray<TFieldValues, TArrayName>;
74
+ /** `false`: no remove buttons. Default `true`. */
75
+ removable?: boolean;
76
+ }
77
+
78
+ /** The message of an error at `path` in react-hook-form's errors tree: the array's
79
+ * own (`root`, from `rules`) or one a resolver put on the array. */
80
+ function arrayError(errors: unknown, path: string): string | undefined {
81
+ let node: unknown = errors;
82
+ for (const key of path.split(".")) {
83
+ if (node === null || typeof node !== "object") return undefined;
84
+ node = (node as Record<string, unknown>)[key];
85
+ }
86
+ if (node === null || typeof node !== "object") return undefined;
87
+ const { root, message } = node as { root?: { message?: unknown }; message?: unknown };
88
+ const text = root?.message ?? message;
89
+ return typeof text === "string" && text !== "" ? text : undefined;
90
+ }
91
+
92
+ /** {@link LineItems} bound to a field array. See the module note. */
93
+ export function RhfLineItems<
94
+ TFieldValues extends FieldValues = FieldValues,
95
+ TArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>,
96
+ TTransformed = TFieldValues,
97
+ >({
98
+ name,
99
+ control,
100
+ rules,
101
+ columns,
102
+ newItem,
103
+ removable = true,
104
+ error,
105
+ ...rest
106
+ }: RhfLineItemsProps<TFieldValues, TArrayName, TTransformed>) {
107
+ const { fields, append, remove } = useFieldArray<TFieldValues, TArrayName, "id", TTransformed>({
108
+ control,
109
+ name,
110
+ rules,
111
+ });
112
+ const { errors } = useFormState({ control, name: name as never });
113
+ const bound: LineItemsColumn<FieldArrayWithId<TFieldValues, TArrayName, "id">>[] = columns.map(
114
+ ({ render, ...column }) => ({
115
+ ...column,
116
+ render: (ctx) => render({ ...ctx, name: `${name}.${ctx.index}` as `${TArrayName}.${number}` }),
117
+ }),
118
+ );
119
+ return (
120
+ <LineItems
121
+ {...rest}
122
+ items={fields}
123
+ columns={bound}
124
+ getKey={(field) => field.id}
125
+ onAdd={newItem ? () => append(newItem()) : undefined}
126
+ onRemove={removable ? (index) => remove(index) : undefined}
127
+ error={error ?? arrayError(errors, name)}
128
+ />
129
+ );
130
+ }
package/src/rhf.ts CHANGED
@@ -9,3 +9,9 @@
9
9
  export * from "./rhf/form";
10
10
  // The react-hook-form bridge to the wizard's Next gate (useWizard lives in /wizard).
11
11
  export * from "./rhf/use-rhf-wizard-step";
12
+ // Bound fields — one line per field (RhfTextField, RhfNumberField, RhfMoneyField,
13
+ // RhfDateField, RhfTextarea, RhfSelect, RhfCheckbox, RhfCombobox, RhfTextCombobox)
14
+ // and RhfField, the shell they are built on.
15
+ export * from "./rhf/fields";
16
+ // LineItems over useFieldArray.
17
+ export * from "./rhf/line-items";
@@ -1,17 +1,19 @@
1
1
  import { createContext, useCallback, useContext, useEffect, useId, useRef, useState } from "react";
2
2
  import type { ComponentPropsWithoutRef, ReactNode } from "react";
3
3
  import { createPortal } from "react-dom";
4
- import { NavLink, matchPath, useLocation } from "react-router";
4
+ import { Link, NavLink, matchPath, useLocation } from "react-router";
5
5
  import { ChevronRight, PanelLeftClose, PanelLeftOpen } from "lucide-react";
6
6
  import type { LucideIcon } from "lucide-react";
7
7
  import { cn } from "../lib/cn";
8
8
  import { dirOf, type Direction } from "../lib/direction";
9
9
  import { readStored, writeStored } from "../lib/safe-storage";
10
10
  import { Tooltip } from "../components/tooltip";
11
+ import { pickLinkRenderer } from "../components/text-link";
11
12
  import { useAnchoredRect } from "../hooks/use-anchored-rect";
12
13
  import { useEscapeKey } from "../hooks/use-dismiss";
13
14
  import { useMediaQuery } from "../hooks/use-media-query";
14
- import { DEFAULT_APP_SHELL_LABELS, useKitLabels } from "../i18n/kit-labels";
15
+ import { DEFAULT_APP_SHELL_LABELS, useKitLabels, useKitLink } from "../i18n/kit-labels";
16
+ import type { KitLinkComponent, KitLinkProps } from "../i18n/kit-labels";
15
17
 
16
18
  export interface AppShellSubItem {
17
19
  to: string;
@@ -48,6 +50,44 @@ export interface AppShellNavItem {
48
50
  items?: AppShellSubItem[];
49
51
  }
50
52
 
53
+ /**
54
+ * One entry of the sidebar's bottom area ({@link AppShellProps.sidebarFooterItems}) —
55
+ * the version link and the legal links kastlan hand-built in `sidebarFooter`.
56
+ *
57
+ * - `link` (default): one link. Expanded it shows `icon` + `text` (default `label`),
58
+ * with `hint` as a tooltip if given; collapsed it is the icon alone, named and
59
+ * tooltipped by `label`.
60
+ * - `links`: a small group — the legal links. Expanded, a `<nav>` named `label` holding
61
+ * the links as a wrapping row of small text; collapsed, ONE icon link to `to` (default
62
+ * the first link's), named and tooltipped by `label`, since a column of icons for
63
+ * "Imprint", "Privacy" and "Terms" would say nothing an icon can.
64
+ */
65
+ export type AppShellSidebarFooterItem =
66
+ | {
67
+ kind?: "link";
68
+ key: string;
69
+ to: string;
70
+ icon: LucideIcon;
71
+ /** The link's name, and the tooltip when collapsed ("What's new · v1.4.0"). */
72
+ label: string;
73
+ /** Visible text when expanded ("Kastlan v1.4.0"). Default `label`. */
74
+ text?: ReactNode;
75
+ /** A tooltip on the expanded link ("What's new"). */
76
+ hint?: string;
77
+ /** Leaves the app: a plain `<a target="_blank" rel="noopener noreferrer">`. */
78
+ external?: boolean;
79
+ }
80
+ | {
81
+ kind: "links";
82
+ key: string;
83
+ icon: LucideIcon;
84
+ /** The group's name — its `<nav>` label, and the collapsed icon's name ("Legal"). */
85
+ label: string;
86
+ /** The collapsed icon's target. Default the first link's `to`. */
87
+ to?: string;
88
+ links: { to: string; label: string; external?: boolean }[];
89
+ };
90
+
51
91
  /**
52
92
  * Exported and `<div>`-shaped. This is the outermost element of every consuming app, so
53
93
  * there is nothing above it to hang an id, a landmark label or a `data-tour` anchor on —
@@ -66,6 +106,13 @@ export interface AppShellProps extends ComponentPropsWithoutRef<"div"> {
66
106
  /** Extra sidebar content above the collapse toggle (e.g. a version link).
67
107
  * Receives the collapsed state so it can render compact vs. full. */
68
108
  sidebarFooter?: (collapsed: boolean) => ReactNode;
109
+ /** The sidebar's bottom area as data — a version link, the legal links — drawn full
110
+ * when expanded and as icon + tooltip when collapsed. Rendered above
111
+ * `sidebarFooter`, which stays for anything the data cannot describe. */
112
+ sidebarFooterItems?: AppShellSidebarFooterItem[];
113
+ /** The router link for `sidebarFooterItems`. Default: the provider's
114
+ * `linkComponent`, else react-router's `Link`. */
115
+ renderLink?: KitLinkComponent;
69
116
  /** localStorage key for the persisted collapse state. */
70
117
  collapseStorageKey?: string;
71
118
  /** Default: `appShell.collapse` from the {@link UiKitProvider}, else English. */
@@ -201,6 +248,8 @@ export function AppShell({
201
248
  children,
202
249
  footer,
203
250
  sidebarFooter,
251
+ sidebarFooterItems,
252
+ renderLink,
204
253
  collapseStorageKey: collapseStorageKeyProp,
205
254
  collapseLabel,
206
255
  expandLabel,
@@ -296,6 +345,9 @@ export function AppShell({
296
345
  ))}
297
346
  </div>
298
347
  </nav>
348
+ {!!sidebarFooterItems?.length && (
349
+ <SidebarFooterItems items={sidebarFooterItems} collapsed={collapsed} renderLink={renderLink} />
350
+ )}
299
351
  {sidebarFooter?.(collapsed)}
300
352
  <div className="border-t border-[var(--border)] p-2">
301
353
  {collapsed ? (
@@ -397,6 +449,99 @@ export function AppShell({
397
449
  );
398
450
  }
399
451
 
452
+ const routerLink: KitLinkComponent = ({ href, ...p }) => <Link to={href} {...p} />;
453
+ const plainLink: KitLinkComponent = ({ children, ...p }) => <a {...p}>{children}</a>;
454
+
455
+ const FOOTER_ICON_LINK =
456
+ "flex min-h-8 items-center justify-center rounded-md text-[var(--text-muted)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-secondary)]";
457
+
458
+ /** Calls the link renderer as a component, so a router link's hooks are its own. */
459
+ function RenderedLink({ render, ...props }: KitLinkProps & { render: KitLinkComponent }) {
460
+ return render(props);
461
+ }
462
+
463
+ /** The sidebar's bottom area, from {@link AppShellSidebarFooterItem}s. */
464
+ function SidebarFooterItems({
465
+ items,
466
+ collapsed,
467
+ renderLink,
468
+ }: {
469
+ items: AppShellSidebarFooterItem[];
470
+ collapsed: boolean;
471
+ renderLink?: KitLinkComponent;
472
+ }) {
473
+ const kitLink = useKitLink();
474
+ const linkTo = (to: string, external: boolean | undefined, { children, ...props }: Omit<KitLinkProps, "href">) => {
475
+ // The kit's one link rule (`pickLinkRenderer`): an external `to` or an in-page
476
+ // `#anchor` is a plain `<a>` even without `external`; only `external` opens a tab.
477
+ const InApp = pickLinkRenderer(renderLink, kitLink ?? routerLink, to) ?? plainLink;
478
+ return external ? (
479
+ <a href={to} target="_blank" rel="noopener noreferrer" {...props}>
480
+ {children}
481
+ </a>
482
+ ) : (
483
+ <RenderedLink render={InApp} href={to} {...props}>
484
+ {children}
485
+ </RenderedLink>
486
+ );
487
+ };
488
+
489
+ return (
490
+ <div data-slot="sidebar-footer-items" className={cn("px-2 py-1", collapsed ? "space-y-1" : "space-y-1.5")}>
491
+ {items.map((item) => {
492
+ if (collapsed) {
493
+ const to = item.kind === "links" ? (item.to ?? item.links[0]?.to) : item.to;
494
+ if (!to) return null;
495
+ const external = item.kind === "links" ? item.links.find((l) => l.to === to)?.external : item.external;
496
+ return (
497
+ <Tooltip key={item.key} label={item.label} side="end" portal className="block">
498
+ {linkTo(to, external, {
499
+ "aria-label": item.label,
500
+ className: FOOTER_ICON_LINK,
501
+ children: <item.icon className="size-4" aria-hidden />,
502
+ })}
503
+ </Tooltip>
504
+ );
505
+ }
506
+ if (item.kind === "links") {
507
+ return (
508
+ <nav
509
+ key={item.key}
510
+ aria-label={item.label}
511
+ className="flex flex-wrap justify-center gap-x-3 gap-y-0.5 text-[11px] text-[var(--text-muted)]"
512
+ >
513
+ {item.links.map((l) => (
514
+ <span key={l.to}>
515
+ {linkTo(l.to, l.external, {
516
+ className: "rounded-sm hover:text-[var(--text-secondary)] hover:underline",
517
+ children: l.label,
518
+ })}
519
+ </span>
520
+ ))}
521
+ </nav>
522
+ );
523
+ }
524
+ const link = linkTo(item.to, item.external, {
525
+ className: cn(FOOTER_ICON_LINK, "gap-1.5 text-xs font-medium"),
526
+ children: (
527
+ <>
528
+ <item.icon className="size-3.5 shrink-0" aria-hidden />
529
+ <span className="min-w-0 truncate">{item.text ?? item.label}</span>
530
+ </>
531
+ ),
532
+ });
533
+ return item.hint ? (
534
+ <Tooltip key={item.key} label={item.hint} side="top" portal className="block">
535
+ {link}
536
+ </Tooltip>
537
+ ) : (
538
+ <div key={item.key}>{link}</div>
539
+ );
540
+ })}
541
+ </div>
542
+ );
543
+ }
544
+
400
545
  /** One cell of the phone's group bar. Marked while the group's own page OR any of its
401
546
  * pages is current — NavLink alone only knows its own `to`, which left the bar with
402
547
  * nothing marked on every sub-page (the same defect the sidebar had). */
@@ -0,0 +1,190 @@
1
+ import type { ComponentPropsWithoutRef, CSSProperties, ReactNode } from "react";
2
+ import { cn } from "../lib/cn";
3
+ import { Card } from "../components/ui";
4
+
5
+ /**
6
+ * `extends ComponentPropsWithoutRef<"div">` because this is the page's outermost element
7
+ * — the one that owns `min-h-dvh` and the safe-area padding — so there is nothing a
8
+ * consumer could wrap it in to add an id or a `data-*` hook without breaking that.
9
+ */
10
+ export interface AuthLayoutProps extends Omit<ComponentPropsWithoutRef<"div">, "title"> {
11
+ /** The brand mark (an SVG), drawn in a brand-coloured tile above the title. */
12
+ logo?: ReactNode;
13
+ /** `false` draws `logo` as it is, without the tile — for a full-colour logo image. */
14
+ logoTile?: boolean;
15
+ /** The page's `<h1>` (see `headingAs`): the product name on sign-in, "Verify email",
16
+ * "Imprint". */
17
+ title?: ReactNode;
18
+ /** The muted line under the title. */
19
+ description?: ReactNode;
20
+ /** The card's content — the form, the status, the legal text. */
21
+ children: ReactNode;
22
+ /**
23
+ * Above the header, outside the card — the legal pages' "← Back to sign in" link, or
24
+ * a notice banner. Start-aligned in both widths.
25
+ */
26
+ back?: ReactNode;
27
+ /** The top-end corner: a `LanguageMenu`. */
28
+ languageMenu?: ReactNode;
29
+ /** The top-end corner, before the language menu: a `ThemeToggle`. */
30
+ themeToggle?: ReactNode;
31
+ /** Below the card, centred — the legal links. */
32
+ footer?: ReactNode;
33
+ /** Wraps the footer in a `<nav>` with this name ("Legal"). Without it, a plain block. */
34
+ footerLabel?: string;
35
+ /**
36
+ * - `"narrow"` (default) — a `max-w-sm` card centred on the page, header centred:
37
+ * sign-in, register, verify email, two-factor.
38
+ * - `"wide"` — a `max-w-3xl` column from the top of the page, header start-aligned:
39
+ * running text (imprint, privacy, terms), which reads badly centred.
40
+ */
41
+ width?: "narrow" | "wide";
42
+ /** `false` lays the header and content on the page itself, without the card's
43
+ * surface and border — the legal pages. Default true. */
44
+ card?: boolean;
45
+ /** Extra classes for the card (or, with `card={false}`, the content column). */
46
+ cardClassName?: string;
47
+ /**
48
+ * `false` draws the content column and the footer as plain `<div>`s instead of
49
+ * `<main>` and `<footer>` — for an AuthLayout embedded in a page that already has its
50
+ * landmarks (a preview, a docs page, a dialog), where a second `<main>` would nest
51
+ * one inside the other. Default `true`: on its own route it IS the page.
52
+ */
53
+ landmark?: boolean;
54
+ /** The title's element. Default `h1` — the page's heading; an embedded layout takes
55
+ * the level of where it sits (`h2`, `h3`). */
56
+ headingAs?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
57
+ }
58
+
59
+ /** Keeps the page clear of a notch, the rounded corners and the home indicator on a
60
+ * phone in `viewport-fit=cover`; 1rem where the platform reports no inset. Physical
61
+ * left/right, because that is what `env()` reports. */
62
+ const SAFE_AREA: CSSProperties = {
63
+ paddingTop: "max(1rem, env(safe-area-inset-top, 0px))",
64
+ paddingBottom: "max(1rem, env(safe-area-inset-bottom, 0px))",
65
+ paddingLeft: "max(1rem, env(safe-area-inset-left, 0px))",
66
+ paddingRight: "max(1rem, env(safe-area-inset-right, 0px))",
67
+ };
68
+
69
+ const FOOTER_CLASS =
70
+ "flex flex-wrap justify-center gap-x-4 gap-y-1 text-xs text-[var(--text-muted)] [&_a:hover]:text-[var(--text-primary)] [&_a:hover]:underline [&_a]:rounded-sm [&_a:focus-visible]:outline-none [&_a:focus-visible]:ring-2 [&_a:focus-visible]:ring-[var(--brand)]";
71
+
72
+ /**
73
+ * The public page frame outside the app shell: sign-in, registration, email
74
+ * verification, two-factor — and, `width="wide"`, the legal pages.
75
+ *
76
+ * kastlan's login, register, verify-email and two-factor pages each repeat the same
77
+ * `min-h-screen` centring, the absolutely placed language switcher, the brand tile, the
78
+ * centred title + subtitle and an absolutely placed legal footer. Absolutely placed,
79
+ * the footer and the switcher sat ON the card on a short phone screen (a tall register
80
+ * form, or the software keyboard up); here they are rows of a column that grows with
81
+ * its content, so the page scrolls instead of overlapping.
82
+ *
83
+ * The corner controls, the `<main>` and the footer are in reading order: a screen
84
+ * reader meets the language switch first, which is where someone who cannot read the
85
+ * page's language needs it.
86
+ */
87
+ export function AuthLayout({
88
+ logo,
89
+ logoTile = true,
90
+ title,
91
+ description,
92
+ children,
93
+ back,
94
+ languageMenu,
95
+ themeToggle,
96
+ footer,
97
+ footerLabel,
98
+ width = "narrow",
99
+ card = true,
100
+ cardClassName,
101
+ landmark = true,
102
+ headingAs: Heading = "h1",
103
+ className,
104
+ style,
105
+ ...rest
106
+ }: AuthLayoutProps) {
107
+ const Main = landmark ? "main" : "div";
108
+ const Footer = landmark ? "footer" : "div";
109
+ const wide = width === "wide";
110
+ const hasCorner = languageMenu != null || themeToggle != null;
111
+ const hasHeader = logo != null || title != null || description != null;
112
+
113
+ const header = hasHeader && (
114
+ <div
115
+ data-slot="auth-layout-header"
116
+ className={cn("flex flex-col gap-1.5", wide ? "items-start text-start" : "items-center text-center")}
117
+ >
118
+ {logo != null &&
119
+ (logoTile ? (
120
+ <div className="mb-2 flex size-12 items-center justify-center rounded-lg bg-[var(--brand)] text-[var(--brand-contrast)] [&_svg]:size-6">
121
+ {logo}
122
+ </div>
123
+ ) : (
124
+ <div className="mb-2">{logo}</div>
125
+ ))}
126
+ {title != null && (
127
+ <Heading
128
+ className={cn(
129
+ "font-semibold leading-tight text-[var(--text-primary)]",
130
+ wide ? "text-2xl md:text-3xl" : "text-2xl",
131
+ )}
132
+ >
133
+ {title}
134
+ </Heading>
135
+ )}
136
+ {description != null && <p className="text-sm text-[var(--text-muted)]">{description}</p>}
137
+ </div>
138
+ );
139
+
140
+ const body = (
141
+ <>
142
+ {header}
143
+ <div className={cn(hasHeader && (wide ? "mt-6" : "mt-5"))}>{children}</div>
144
+ </>
145
+ );
146
+
147
+ return (
148
+ <div
149
+ {...rest}
150
+ data-auth-layout={width}
151
+ style={{ ...SAFE_AREA, ...style }}
152
+ className={cn("flex min-h-dvh flex-col bg-[var(--bg-page)] text-[var(--text-primary)]", className)}
153
+ >
154
+ {hasCorner && (
155
+ <div data-slot="auth-layout-corner" className="flex items-center justify-end gap-1">
156
+ {themeToggle}
157
+ {languageMenu}
158
+ </div>
159
+ )}
160
+ <Main
161
+ data-slot="auth-layout-main"
162
+ className={cn(
163
+ // `relative` contains any `sr-only` child (see AppShell's <main>).
164
+ "relative flex w-full flex-1 flex-col",
165
+ wide ? "py-6 md:py-10" : "items-center justify-center py-8",
166
+ )}
167
+ >
168
+ <div className={cn("mx-auto w-full", wide ? "max-w-3xl" : "max-w-sm")}>
169
+ {back != null && <div className="mb-4">{back}</div>}
170
+ {card ? (
171
+ <Card className={cn(wide ? "p-6 md:p-8" : "p-6", cardClassName)}>{body}</Card>
172
+ ) : (
173
+ <div className={cardClassName}>{body}</div>
174
+ )}
175
+ </div>
176
+ </Main>
177
+ {footer != null && footer !== false && (
178
+ <Footer data-slot="auth-layout-footer" className="pt-4">
179
+ {footerLabel ? (
180
+ <nav aria-label={footerLabel} className={FOOTER_CLASS}>
181
+ {footer}
182
+ </nav>
183
+ ) : (
184
+ <div className={FOOTER_CLASS}>{footer}</div>
185
+ )}
186
+ </Footer>
187
+ )}
188
+ </div>
189
+ );
190
+ }
@@ -0,0 +1,76 @@
1
+ import type { ReactNode } from "react";
2
+ import { Link as RouterLink } from "react-router";
3
+ import { cn } from "../lib/cn";
4
+ import { useKitLink } from "../i18n/kit-labels";
5
+ import { pickLinkRenderer } from "../components/text-link";
6
+ import type { KitLinkComponent, KitLinkProps } from "../i18n/kit-labels";
7
+
8
+ const routerLink: KitLinkComponent = ({ href, ...p }) => <RouterLink to={href} {...p} />;
9
+ const plainLink: KitLinkComponent = ({ children, ...p }) => <a {...p}>{children}</a>;
10
+
11
+ /** Below which width only the logo shows. The name stays in the link's accessible
12
+ * name at every width. */
13
+ const COLLAPSE = {
14
+ sm: "sr-only sm:not-sr-only sm:truncate",
15
+ md: "sr-only md:not-sr-only md:truncate",
16
+ } as const;
17
+
18
+ export interface TopBarBrandProps extends Omit<KitLinkProps, "href" | "children"> {
19
+ /** The brand mark — an SVG, sized by the caller or `h-6 w-auto` by default. */
20
+ logo: ReactNode;
21
+ /** The product name beside the logo, and the link's accessible name. */
22
+ name: ReactNode;
23
+ /** Where the brand links to. Default `/`. */
24
+ to?: string;
25
+ /** Hide the name below `sm` (default) or `md`; `false` always shows it. It is
26
+ * visually hidden, not removed, so the link keeps its name on a phone. */
27
+ collapseBelow?: "sm" | "md" | false;
28
+ /** The app's router link for this one link. Default: the provider's
29
+ * `linkComponent`, else react-router's `Link`. */
30
+ renderLink?: KitLinkComponent;
31
+ }
32
+
33
+ /**
34
+ * The top bar's home link: logo + product name, collapsing to the logo on a phone.
35
+ * Pass it as {@link TopBar}'s `brand`.
36
+ *
37
+ * kastlan's (top-bar.tsx:66) hid nothing and truncated the name instead — on a phone
38
+ * with five actions that left "Ka…" beside the logo — and needed an `aria-label`
39
+ * because the name could be cut. Here the name is `sr-only` below the breakpoint, so
40
+ * the logo is the whole visible link there and the name is still what it is called.
41
+ */
42
+ export function TopBarBrand({
43
+ logo,
44
+ name,
45
+ to = "/",
46
+ collapseBelow = "sm",
47
+ renderLink,
48
+ className,
49
+ ...rest
50
+ }: TopBarBrandProps) {
51
+ const kitLink = useKitLink();
52
+ return (
53
+ <RenderedLink
54
+ // The kit's one link rule (`pickLinkRenderer`): an external `to` or an in-page
55
+ // `#anchor` is a plain `<a>`, never the router's link.
56
+ render={pickLinkRenderer(renderLink, kitLink ?? routerLink, to) ?? plainLink}
57
+ {...rest}
58
+ href={to}
59
+ className={cn(
60
+ // `relative` contains the sr-only name.
61
+ "relative flex min-w-0 items-center gap-2 rounded-md font-semibold text-[var(--text-primary)] hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)]",
62
+ className,
63
+ )}
64
+ >
65
+ <span aria-hidden className="flex shrink-0 items-center [&_svg]:h-6 [&_svg]:w-auto">
66
+ {logo}
67
+ </span>
68
+ <span className={collapseBelow ? COLLAPSE[collapseBelow] : "truncate"}>{name}</span>
69
+ </RenderedLink>
70
+ );
71
+ }
72
+
73
+ /** Calls the link renderer as a component, so a router link's hooks are its own. */
74
+ function RenderedLink({ render, ...props }: KitLinkProps & { render: KitLinkComponent }) {
75
+ return render(props);
76
+ }
@@ -5,6 +5,8 @@ import { cn } from "../lib/cn";
5
5
  import { HoverMenu } from "../components/hover-menu";
6
6
  import { MenuItem } from "../components/menu-item";
7
7
  import type { MenuItemTone } from "../components/menu-item";
8
+ import { StatusDot } from "../components/status-dot";
9
+ import type { UserAvatarBadge } from "../components/user-avatar";
8
10
  import { TOPBAR_TRIGGER_CLASS } from "./topbar-controls";
9
11
 
10
12
  /**
@@ -125,6 +127,7 @@ function keepTabInsidePanel(e: ReactKeyboardEvent<HTMLUListElement>) {
125
127
  */
126
128
  export function TopBarActionMenu({
127
129
  icon,
130
+ iconBadge,
128
131
  trigger,
129
132
  triggerClassName,
130
133
  ariaLabel,
@@ -139,6 +142,13 @@ export function TopBarActionMenu({
139
142
  }: {
140
143
  /** The trigger's face for the usual icon button. Ignored when `trigger` is given. */
141
144
  icon?: ReactNode;
145
+ /**
146
+ * A status dot in the top-end corner of `icon` — keksdose's unread-support dot on the
147
+ * feedback trigger. Like `UserAvatar`'s `badge`, its `label` joins the trigger's name
148
+ * ("Send feedback 2 unread"), so the dot is not something only the eye is told about.
149
+ * Ignored with `trigger`: give the face its own badge there.
150
+ */
151
+ iconBadge?: UserAvatarBadge | null;
142
152
  /**
143
153
  * A face of your own for the trigger — the account menu's `UserAvatar`. It is drawn
144
154
  * INSIDE the kit's button, which keeps the wiring: `aria-haspopup`, `aria-expanded`,
@@ -190,6 +200,17 @@ export function TopBarActionMenu({
190
200
  {" "}
191
201
  {trigger({ open })}
192
202
  </button>
203
+ ) : iconBadge ? (
204
+ // Named by its content, like the custom-trigger branch, so the badge label is
205
+ // part of the name; an `aria-label` would have hidden it.
206
+ <button type="button" onClick={toggle} className={cn(TOPBAR_TRIGGER_CLASS, "relative", triggerClassName)}>
207
+ <span className="sr-only">{ariaLabel}</span>{" "}
208
+ <span aria-hidden className="relative inline-flex">
209
+ {icon}
210
+ <StatusDot ring tone={iconBadge.tone ?? "danger"} className="absolute -end-0.5 -top-0.5" />
211
+ </span>{" "}
212
+ <span className="sr-only">{iconBadge.label}</span>
213
+ </button>
193
214
  ) : (
194
215
  <button
195
216
  type="button"
package/src/shell.ts CHANGED
@@ -8,3 +8,5 @@ export * from "./shell/app-shell";
8
8
  export * from "./shell/option-switcher-menu";
9
9
  export * from "./shell/role-switcher";
10
10
  export * from "./shell/topbar-action-menu";
11
+ export * from "./shell/top-bar-brand";
12
+ export * from "./shell/auth-layout";