@eifi1/ui-kit 0.31.1 → 0.32.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 (565) hide show
  1. package/README.md +51 -28
  2. package/dist/account/delete-account-setting.d.ts +8 -3
  3. package/dist/admin/admin-action-confirm.d.ts +8 -3
  4. package/dist/admin/admin-action-log.d.ts +1 -1
  5. package/dist/admin/admin-action-log.js +4 -2
  6. package/dist/admin/admin-action-log.js.map +1 -1
  7. package/dist/admin/invitations-panel.d.ts +8 -3
  8. package/dist/admin/invitations-panel.js +29 -26
  9. package/dist/admin/invitations-panel.js.map +1 -1
  10. package/dist/admin/reviewer-scope-editor.d.ts +8 -3
  11. package/dist/admin/role-select.d.ts +10 -5
  12. package/dist/admin/transfer-ownership-dialog.d.ts +8 -3
  13. package/dist/admin/user-roster.d.ts +10 -5
  14. package/dist/admin/user-roster.js +8 -47
  15. package/dist/admin/user-roster.js.map +1 -1
  16. package/dist/auth/auth-errors.d.ts +43 -8
  17. package/dist/auth/auth-errors.js +24 -1
  18. package/dist/auth/auth-errors.js.map +1 -1
  19. package/dist/auth/register-form.d.ts +8 -3
  20. package/dist/billing/billing-banner.d.ts +184 -0
  21. package/dist/billing/billing-banner.js +98 -0
  22. package/dist/billing/billing-banner.js.map +1 -0
  23. package/dist/billing/billing-labels.d.ts +100 -0
  24. package/dist/billing/billing-labels.js +76 -0
  25. package/dist/billing/billing-labels.js.map +1 -0
  26. package/dist/billing/billing-lock.d.ts +158 -0
  27. package/dist/billing/billing-lock.js +17 -0
  28. package/dist/billing/billing-lock.js.map +1 -0
  29. package/dist/billing/billing-standing.d.ts +149 -0
  30. package/dist/billing/billing-standing.js +28 -0
  31. package/dist/billing/billing-standing.js.map +1 -0
  32. package/dist/billing/plan-card.d.ts +248 -0
  33. package/dist/billing/plan-card.js +248 -0
  34. package/dist/billing/plan-card.js.map +1 -0
  35. package/dist/billing/plan-limit-notice.d.ts +156 -0
  36. package/dist/billing/plan-limit-notice.js +76 -0
  37. package/dist/billing/plan-limit-notice.js.map +1 -0
  38. package/dist/billing/plan-limit.d.ts +34 -0
  39. package/dist/billing/plan-limit.js +20 -0
  40. package/dist/billing/plan-limit.js.map +1 -0
  41. package/dist/billing/plan-price.d.ts +61 -0
  42. package/dist/billing/plan-price.js +45 -0
  43. package/dist/billing/plan-price.js.map +1 -0
  44. package/dist/billing/subscription-actions.d.ts +133 -0
  45. package/dist/billing/subscription-actions.js +28 -0
  46. package/dist/billing/subscription-actions.js.map +1 -0
  47. package/dist/billing/subscription-status-chip.d.ts +149 -0
  48. package/dist/billing/subscription-status-chip.js +48 -0
  49. package/dist/billing/subscription-status-chip.js.map +1 -0
  50. package/dist/chart.d.ts +9 -3
  51. package/dist/chart.js.map +1 -1
  52. package/dist/components/account-chips.d.ts +16 -4
  53. package/dist/components/account-chips.js +21 -3
  54. package/dist/components/account-chips.js.map +1 -1
  55. package/dist/components/alert-banner.d.ts +6 -1
  56. package/dist/components/alert-banner.js +5 -4
  57. package/dist/components/alert-banner.js.map +1 -1
  58. package/dist/components/amount-input.d.ts +8 -3
  59. package/dist/components/amount-input.js +5 -5
  60. package/dist/components/amount-input.js.map +1 -1
  61. package/dist/components/appearance-labels.d.ts +38 -0
  62. package/dist/components/appearance-labels.js +19 -0
  63. package/dist/components/appearance-labels.js.map +1 -0
  64. package/dist/components/autocomplete.js +2 -2
  65. package/dist/components/autocomplete.js.map +1 -1
  66. package/dist/components/breadcrumbs.js +3 -2
  67. package/dist/components/breadcrumbs.js.map +1 -1
  68. package/dist/components/bulk-action-bar.d.ts +2 -2
  69. package/dist/components/bulk-action-bar.js +7 -12
  70. package/dist/components/bulk-action-bar.js.map +1 -1
  71. package/dist/components/button-group.d.ts +8 -3
  72. package/dist/components/button-group.js +7 -1
  73. package/dist/components/button-group.js.map +1 -1
  74. package/dist/components/calculator.d.ts +8 -3
  75. package/dist/components/calculator.js +4 -3
  76. package/dist/components/calculator.js.map +1 -1
  77. package/dist/components/calendar-heatmap.js +5 -5
  78. package/dist/components/calendar-heatmap.js.map +1 -1
  79. package/dist/components/chart-height.d.ts +23 -0
  80. package/dist/components/chart-height.js +15 -0
  81. package/dist/components/chart-height.js.map +1 -0
  82. package/dist/components/chart-zoom.js +6 -1
  83. package/dist/components/chart-zoom.js.map +1 -1
  84. package/dist/components/checkbox-group.js +2 -2
  85. package/dist/components/checkbox-group.js.map +1 -1
  86. package/dist/components/checkbox.d.ts +10 -0
  87. package/dist/components/checkbox.js +25 -10
  88. package/dist/components/checkbox.js.map +1 -1
  89. package/dist/components/chip.d.ts +19 -3
  90. package/dist/components/chip.js +54 -23
  91. package/dist/components/chip.js.map +1 -1
  92. package/dist/components/choice-card.d.ts +1 -1
  93. package/dist/components/choice-card.js +9 -8
  94. package/dist/components/choice-card.js.map +1 -1
  95. package/dist/components/column-mapper.js +1 -1
  96. package/dist/components/column-mapper.js.map +1 -1
  97. package/dist/components/combobox-core.js +8 -7
  98. package/dist/components/combobox-core.js.map +1 -1
  99. package/dist/components/combobox.js +8 -8
  100. package/dist/components/combobox.js.map +1 -1
  101. package/dist/components/confirm-dialog.d.ts +8 -3
  102. package/dist/components/copy-button.d.ts +10 -5
  103. package/dist/components/country-select.js +1 -1
  104. package/dist/components/country-select.js.map +1 -1
  105. package/dist/components/currency-select.js +3 -3
  106. package/dist/components/currency-select.js.map +1 -1
  107. package/dist/components/danger-confirm.d.ts +8 -3
  108. package/dist/components/data-table-cells.d.ts +1 -1
  109. package/dist/components/data-table-filter-popover.d.ts +1 -1
  110. package/dist/components/data-table-filter-popover.js +4 -1
  111. package/dist/components/data-table-filter-popover.js.map +1 -1
  112. package/dist/components/data-table-filters.d.ts +1 -1
  113. package/dist/components/data-table-labels.d.ts +1 -1
  114. package/dist/components/data-table-pagination.d.ts +3 -2
  115. package/dist/components/data-table-pagination.js +15 -6
  116. package/dist/components/data-table-pagination.js.map +1 -1
  117. package/dist/components/data-table.d.ts +1 -1
  118. package/dist/components/data-table.js +123 -52
  119. package/dist/components/data-table.js.map +1 -1
  120. package/dist/components/date-picker.d.ts +1 -1
  121. package/dist/components/date-picker.js +18 -6
  122. package/dist/components/date-picker.js.map +1 -1
  123. package/dist/components/description-list.js +2 -2
  124. package/dist/components/description-list.js.map +1 -1
  125. package/dist/components/dialog-frame.js +2 -1
  126. package/dist/components/dialog-frame.js.map +1 -1
  127. package/dist/components/disclosure.js +3 -2
  128. package/dist/components/disclosure.js.map +1 -1
  129. package/dist/components/dropdown.d.ts +1 -1
  130. package/dist/components/dropdown.js +7 -1
  131. package/dist/components/dropdown.js.map +1 -1
  132. package/dist/components/facing-pair.d.ts +19 -6
  133. package/dist/components/facing-pair.js +3 -2
  134. package/dist/components/facing-pair.js.map +1 -1
  135. package/dist/components/field-parts.d.ts +102 -6
  136. package/dist/components/field-parts.js +81 -6
  137. package/dist/components/field-parts.js.map +1 -1
  138. package/dist/components/field-sync.d.ts +4 -1
  139. package/dist/components/field-sync.js +12 -2
  140. package/dist/components/field-sync.js.map +1 -1
  141. package/dist/components/field.js +2 -2
  142. package/dist/components/field.js.map +1 -1
  143. package/dist/components/file-button.d.ts +8 -3
  144. package/dist/components/file-dropzone.d.ts +8 -3
  145. package/dist/components/floating-panel.js +7 -4
  146. package/dist/components/floating-panel.js.map +1 -1
  147. package/dist/components/focus-ring.d.ts +12 -0
  148. package/dist/components/focus-ring.js +8 -0
  149. package/dist/components/focus-ring.js.map +1 -0
  150. package/dist/components/form-actions.d.ts +8 -3
  151. package/dist/components/form-actions.js +33 -19
  152. package/dist/components/form-actions.js.map +1 -1
  153. package/dist/components/full-bleed-dialog.d.ts +11 -1
  154. package/dist/components/full-bleed-dialog.js +3 -1
  155. package/dist/components/full-bleed-dialog.js.map +1 -1
  156. package/dist/components/iban-input.d.ts +8 -3
  157. package/dist/components/image-grid.js +1 -1
  158. package/dist/components/image-grid.js.map +1 -1
  159. package/dist/components/inline-edit-field.js +10 -4
  160. package/dist/components/inline-edit-field.js.map +1 -1
  161. package/dist/components/language-select.d.ts +8 -3
  162. package/dist/components/legal-page.d.ts +26 -5
  163. package/dist/components/legal-page.js +3 -1
  164. package/dist/components/legal-page.js.map +1 -1
  165. package/dist/components/legal.d.ts +8 -3
  166. package/dist/components/legal.js +2 -1
  167. package/dist/components/legal.js.map +1 -1
  168. package/dist/components/lightbox.js +24 -2
  169. package/dist/components/lightbox.js.map +1 -1
  170. package/dist/components/line-items.js +2 -1
  171. package/dist/components/line-items.js.map +1 -1
  172. package/dist/components/list.d.ts +5 -0
  173. package/dist/components/list.js +13 -9
  174. package/dist/components/list.js.map +1 -1
  175. package/dist/components/measured-grid.d.ts +3 -1
  176. package/dist/components/measured-grid.js +38 -20
  177. package/dist/components/measured-grid.js.map +1 -1
  178. package/dist/components/menu-item.js +2 -1
  179. package/dist/components/menu-item.js.map +1 -1
  180. package/dist/components/mini-calendar.js +8 -4
  181. package/dist/components/mini-calendar.js.map +1 -1
  182. package/dist/components/money-field.d.ts +8 -3
  183. package/dist/components/month-picker.js +50 -39
  184. package/dist/components/month-picker.js.map +1 -1
  185. package/dist/components/nav-pills.js +1 -1
  186. package/dist/components/nav-pills.js.map +1 -1
  187. package/dist/components/number-field.d.ts +8 -3
  188. package/dist/components/number-input.d.ts +11 -4
  189. package/dist/components/number-input.js +8 -6
  190. package/dist/components/number-input.js.map +1 -1
  191. package/dist/components/numpad-sheet.d.ts +8 -3
  192. package/dist/components/numpad-sheet.js +2 -1
  193. package/dist/components/numpad-sheet.js.map +1 -1
  194. package/dist/components/one-time-code-input.js +2 -2
  195. package/dist/components/one-time-code-input.js.map +1 -1
  196. package/dist/components/page-contents.js +2 -2
  197. package/dist/components/page-contents.js.map +1 -1
  198. package/dist/components/phone-input.d.ts +8 -3
  199. package/dist/components/phone-input.js +4 -4
  200. package/dist/components/phone-input.js.map +1 -1
  201. package/dist/components/pie-chart.d.ts +8 -2
  202. package/dist/components/pie-chart.js +11 -7
  203. package/dist/components/pie-chart.js.map +1 -1
  204. package/dist/components/popover.d.ts +9 -1
  205. package/dist/components/popover.js +8 -4
  206. package/dist/components/popover.js.map +1 -1
  207. package/dist/components/row-actions.d.ts +100 -0
  208. package/dist/components/row-actions.js +231 -0
  209. package/dist/components/row-actions.js.map +1 -0
  210. package/dist/components/scroll-area.js +1 -1
  211. package/dist/components/scroll-area.js.map +1 -1
  212. package/dist/components/search-field.js +3 -2
  213. package/dist/components/search-field.js.map +1 -1
  214. package/dist/components/series-chart-budget.d.ts +30 -7
  215. package/dist/components/series-chart-budget.js +12 -4
  216. package/dist/components/series-chart-budget.js.map +1 -1
  217. package/dist/components/series-chart-ticks.d.ts +7 -1
  218. package/dist/components/series-chart-ticks.js +6 -0
  219. package/dist/components/series-chart-ticks.js.map +1 -1
  220. package/dist/components/series-chart.d.ts +58 -28
  221. package/dist/components/series-chart.js +42 -32
  222. package/dist/components/series-chart.js.map +1 -1
  223. package/dist/components/settings-fields.d.ts +57 -8
  224. package/dist/components/settings-fields.js +39 -1
  225. package/dist/components/settings-fields.js.map +1 -1
  226. package/dist/components/share-card.d.ts +11 -6
  227. package/dist/components/share-card.js +8 -2
  228. package/dist/components/share-card.js.map +1 -1
  229. package/dist/components/sign-chip.d.ts +4 -0
  230. package/dist/components/sign-chip.js +17 -4
  231. package/dist/components/sign-chip.js.map +1 -1
  232. package/dist/components/signature-pad.d.ts +3 -1
  233. package/dist/components/signature-pad.js +8 -5
  234. package/dist/components/signature-pad.js.map +1 -1
  235. package/dist/components/slider.js +7 -6
  236. package/dist/components/slider.js.map +1 -1
  237. package/dist/components/sparkline.d.ts +5 -1
  238. package/dist/components/sparkline.js +4 -2
  239. package/dist/components/sparkline.js.map +1 -1
  240. package/dist/components/stat-tile.d.ts +17 -1
  241. package/dist/components/stat-tile.js +48 -20
  242. package/dist/components/stat-tile.js.map +1 -1
  243. package/dist/components/status-dot.d.ts +4 -0
  244. package/dist/components/status-dot.js +9 -2
  245. package/dist/components/status-dot.js.map +1 -1
  246. package/dist/components/swipeable-row.js +10 -2
  247. package/dist/components/swipeable-row.js.map +1 -1
  248. package/dist/components/switch.d.ts +21 -7
  249. package/dist/components/switch.js +24 -11
  250. package/dist/components/switch.js.map +1 -1
  251. package/dist/components/table.js +2 -2
  252. package/dist/components/table.js.map +1 -1
  253. package/dist/components/text-link.d.ts +8 -3
  254. package/dist/components/text-link.js +1 -1
  255. package/dist/components/text-link.js.map +1 -1
  256. package/dist/components/text.d.ts +7 -2
  257. package/dist/components/text.js +5 -5
  258. package/dist/components/text.js.map +1 -1
  259. package/dist/components/tile-radio.js +2 -1
  260. package/dist/components/tile-radio.js.map +1 -1
  261. package/dist/components/time-input.d.ts +8 -3
  262. package/dist/components/toast.d.ts +18 -2
  263. package/dist/components/toast.js +8 -5
  264. package/dist/components/toast.js.map +1 -1
  265. package/dist/components/toggle-group.d.ts +25 -3
  266. package/dist/components/toggle-group.js +40 -11
  267. package/dist/components/toggle-group.js.map +1 -1
  268. package/dist/components/toggle-legend.d.ts +10 -1
  269. package/dist/components/toggle-legend.js +21 -7
  270. package/dist/components/toggle-legend.js.map +1 -1
  271. package/dist/components/translation-review-editor.js +1 -1
  272. package/dist/components/translation-review-editor.js.map +1 -1
  273. package/dist/components/translation-review-parts.d.ts +4 -0
  274. package/dist/components/translation-review.d.ts +4 -0
  275. package/dist/components/translation-review.js +3 -3
  276. package/dist/components/translation-review.js.map +1 -1
  277. package/dist/components/tree-view.js +3 -2
  278. package/dist/components/tree-view.js.map +1 -1
  279. package/dist/components/treemap.d.ts +5 -2
  280. package/dist/components/treemap.js +33 -16
  281. package/dist/components/treemap.js.map +1 -1
  282. package/dist/components/ui.d.ts +8 -3
  283. package/dist/components/ui.js +207 -119
  284. package/dist/components/ui.js.map +1 -1
  285. package/dist/components/use-table-state.d.ts +1 -1
  286. package/dist/components/user-avatar.d.ts +5 -1
  287. package/dist/components/user-avatar.js +1 -1
  288. package/dist/components/user-avatar.js.map +1 -1
  289. package/dist/components/wizard-stepper.js +20 -14
  290. package/dist/components/wizard-stepper.js.map +1 -1
  291. package/dist/{data-table-labels-DUELeXpa.d.ts → data-table-labels-kpAAVi6g.d.ts} +26 -2
  292. package/dist/data-table.d.ts +1 -1
  293. package/dist/{delete-account-setting-CpIhzxxZ.d.ts → delete-account-setting-FLyJf-kZ.d.ts} +642 -60
  294. package/dist/demo/demo-banner.js +1 -0
  295. package/dist/demo/demo-banner.js.map +1 -1
  296. package/dist/feedback/feedback-attachment.d.ts +8 -3
  297. package/dist/feedback/feedback-context.d.ts +8 -3
  298. package/dist/feedback/feedback-crash.d.ts +8 -3
  299. package/dist/feedback/feedback-dialog.d.ts +8 -3
  300. package/dist/feedback/feedback-dialog.js +3 -3
  301. package/dist/feedback/feedback-dialog.js.map +1 -1
  302. package/dist/feedback/feedback-inbox.d.ts +8 -3
  303. package/dist/feedback/feedback-inbox.js +2 -2
  304. package/dist/feedback/feedback-inbox.js.map +1 -1
  305. package/dist/feedback/feedback-labels.d.ts +8 -3
  306. package/dist/feedback/feedback-menu.d.ts +9 -4
  307. package/dist/feedback/feedback-record.d.ts +8 -3
  308. package/dist/feedback/feedback-row-detail.d.ts +8 -3
  309. package/dist/feedback/feedback-status-undo.d.ts +8 -3
  310. package/dist/feedback/feedback-submit.d.ts +8 -3
  311. package/dist/feedback/feedback-swipe.d.ts +8 -3
  312. package/dist/feedback/feedback-table.d.ts +8 -3
  313. package/dist/feedback/feedback-thread.d.ts +8 -3
  314. package/dist/feedback/feedback-thread.js +3 -3
  315. package/dist/feedback/feedback-thread.js.map +1 -1
  316. package/dist/feedback.d.ts +8 -3
  317. package/dist/hooks/use-anchored-panel.d.ts +32 -3
  318. package/dist/hooks/use-anchored-panel.js +21 -3
  319. package/dist/hooks/use-anchored-panel.js.map +1 -1
  320. package/dist/hooks/use-breakpoint.d.ts +88 -0
  321. package/dist/hooks/use-breakpoint.js +50 -0
  322. package/dist/hooks/use-breakpoint.js.map +1 -0
  323. package/dist/hooks/use-file-drop.d.ts +8 -3
  324. package/dist/hooks/use-large-text.d.ts +29 -0
  325. package/dist/hooks/use-large-text.js +20 -0
  326. package/dist/hooks/use-large-text.js.map +1 -0
  327. package/dist/hooks/use-windowed-rows.d.ts +52 -8
  328. package/dist/hooks/use-windowed-rows.js +94 -5
  329. package/dist/hooks/use-windowed-rows.js.map +1 -1
  330. package/dist/i18n/defaults.d.ts +8 -3
  331. package/dist/i18n/defaults.js +8 -0
  332. package/dist/i18n/defaults.js.map +1 -1
  333. package/dist/i18n/german.d.ts +8 -3
  334. package/dist/i18n/german.js +94 -3
  335. package/dist/i18n/german.js.map +1 -1
  336. package/dist/i18n/kit-labels.d.ts +8 -3
  337. package/dist/i18n/kit-labels.js.map +1 -1
  338. package/dist/i18n/languages.d.ts +10 -5
  339. package/dist/i18n/locales/de-CH.d.ts +8 -3
  340. package/dist/i18n/locales/en.d.ts +8 -3
  341. package/dist/i18n/locales/es.d.ts +8 -3
  342. package/dist/i18n/locales/es.js +89 -3
  343. package/dist/i18n/locales/es.js.map +1 -1
  344. package/dist/i18n/locales/fr.d.ts +8 -3
  345. package/dist/i18n/locales/fr.js +91 -3
  346. package/dist/i18n/locales/fr.js.map +1 -1
  347. package/dist/i18n/locales/hu.d.ts +8 -3
  348. package/dist/i18n/locales/hu.js +91 -3
  349. package/dist/i18n/locales/hu.js.map +1 -1
  350. package/dist/i18n/locales/it.d.ts +8 -3
  351. package/dist/i18n/locales/it.js +92 -3
  352. package/dist/i18n/locales/it.js.map +1 -1
  353. package/dist/i18n/locales/zh.d.ts +8 -3
  354. package/dist/i18n/locales/zh.js +89 -3
  355. package/dist/i18n/locales/zh.js.map +1 -1
  356. package/dist/i18n/review.d.ts +8 -3
  357. package/dist/i18n/review.js +15 -1
  358. package/dist/i18n/review.js.map +1 -1
  359. package/dist/index.d.ts +27 -11
  360. package/dist/index.js +77 -4
  361. package/dist/index.js.map +1 -1
  362. package/dist/landing/landing-actions.d.ts +8 -3
  363. package/dist/landing/landing-sections.d.ts +8 -3
  364. package/dist/landing/landing-sections.js +7 -3
  365. package/dist/landing/landing-sections.js.map +1 -1
  366. package/dist/landing/public-header.d.ts +9 -4
  367. package/dist/landing/public-header.js +3 -3
  368. package/dist/landing/public-header.js.map +1 -1
  369. package/dist/landing/routing.d.ts +8 -3
  370. package/dist/lib/cn.js +3 -2
  371. package/dist/lib/cn.js.map +1 -1
  372. package/dist/rhf/fields.d.ts +8 -3
  373. package/dist/rhf/fields.js +1 -1
  374. package/dist/rhf/fields.js.map +1 -1
  375. package/dist/rhf/form.d.ts +8 -3
  376. package/dist/rhf/form.js +2 -2
  377. package/dist/rhf/form.js.map +1 -1
  378. package/dist/rhf.d.ts +8 -3
  379. package/dist/search/command-palette.d.ts +1 -1
  380. package/dist/search/command-palette.js +9 -8
  381. package/dist/search/command-palette.js.map +1 -1
  382. package/dist/settings/settings-layout.js +2 -1
  383. package/dist/settings/settings-layout.js.map +1 -1
  384. package/dist/settings/settings-section.d.ts +8 -3
  385. package/dist/settings/use-account-appearance.d.ts +92 -0
  386. package/dist/settings/use-account-appearance.js +63 -0
  387. package/dist/settings/use-account-appearance.js.map +1 -0
  388. package/dist/settings/use-settings-route.d.ts +1 -1
  389. package/dist/settings/use-settings-route.js +2 -3
  390. package/dist/settings/use-settings-route.js.map +1 -1
  391. package/dist/shell/app-shell.d.ts +12 -171
  392. package/dist/shell/app-shell.js +144 -28
  393. package/dist/shell/app-shell.js.map +1 -1
  394. package/dist/shell/auth-layout.js +1 -1
  395. package/dist/shell/auth-layout.js.map +1 -1
  396. package/dist/shell/option-switcher-menu.js +1 -1
  397. package/dist/shell/option-switcher-menu.js.map +1 -1
  398. package/dist/shell/top-bar-brand.d.ts +8 -3
  399. package/dist/shell/top-bar-brand.js +3 -1
  400. package/dist/shell/top-bar-brand.js.map +1 -1
  401. package/dist/shell/topbar-action-menu.d.ts +4 -0
  402. package/dist/shell/topbar-action-menu.js +3 -3
  403. package/dist/shell/topbar-action-menu.js.map +1 -1
  404. package/dist/shell/topbar-controls.js +4 -4
  405. package/dist/shell/topbar-controls.js.map +1 -1
  406. package/dist/shell.d.ts +9 -5
  407. package/dist/theme/contrast-tokens.d.ts +41 -0
  408. package/dist/theme/contrast-tokens.js +59 -0
  409. package/dist/theme/contrast-tokens.js.map +1 -0
  410. package/dist/theme/contrast.d.ts +110 -0
  411. package/dist/theme/contrast.js +128 -0
  412. package/dist/theme/contrast.js.map +1 -0
  413. package/dist/theme/palette-presets.d.ts +12 -1
  414. package/dist/theme/palette-presets.js +9 -4
  415. package/dist/theme/palette-presets.js.map +1 -1
  416. package/dist/theme/palette-store.js.map +1 -1
  417. package/dist/theme/text-size.d.ts +173 -0
  418. package/dist/theme/text-size.js +121 -0
  419. package/dist/theme/text-size.js.map +1 -0
  420. package/dist/wizard/stepper-nav.d.ts +8 -3
  421. package/dist/wizard/wizard-summary.js +1 -1
  422. package/dist/wizard/wizard-summary.js.map +1 -1
  423. package/dist/wizard.d.ts +8 -3
  424. package/package.json +1 -1
  425. package/src/admin/admin-action-log.tsx +6 -1
  426. package/src/admin/invitations-panel.tsx +36 -29
  427. package/src/admin/user-roster.tsx +17 -72
  428. package/src/auth/auth-errors.ts +68 -7
  429. package/src/billing/billing-banner.tsx +205 -0
  430. package/src/billing/billing-labels.ts +240 -0
  431. package/src/billing/billing-lock.ts +75 -0
  432. package/src/billing/billing-standing.ts +72 -0
  433. package/src/billing/plan-card.tsx +458 -0
  434. package/src/billing/plan-limit-notice.tsx +145 -0
  435. package/src/billing/plan-limit.ts +53 -0
  436. package/src/billing/plan-price.ts +101 -0
  437. package/src/billing/subscription-actions.tsx +76 -0
  438. package/src/billing/subscription-status-chip.tsx +95 -0
  439. package/src/chart.ts +2 -0
  440. package/src/components/account-chips.tsx +36 -10
  441. package/src/components/alert-banner.tsx +16 -7
  442. package/src/components/amount-input.tsx +5 -5
  443. package/src/components/appearance-labels.ts +47 -0
  444. package/src/components/autocomplete.tsx +2 -2
  445. package/src/components/breadcrumbs.tsx +3 -3
  446. package/src/components/bulk-action-bar.tsx +11 -14
  447. package/src/components/button-group.tsx +21 -0
  448. package/src/components/calculator.tsx +4 -3
  449. package/src/components/calendar-heatmap.tsx +5 -5
  450. package/src/components/chart-height.ts +30 -0
  451. package/src/components/chart-zoom.tsx +6 -1
  452. package/src/components/checkbox-group.tsx +2 -2
  453. package/src/components/checkbox.tsx +62 -20
  454. package/src/components/chip.tsx +139 -30
  455. package/src/components/choice-card.tsx +16 -11
  456. package/src/components/column-mapper.tsx +1 -1
  457. package/src/components/combobox-core.tsx +8 -7
  458. package/src/components/combobox.tsx +8 -8
  459. package/src/components/country-select.tsx +1 -1
  460. package/src/components/currency-select.tsx +3 -3
  461. package/src/components/data-table-filter-popover.tsx +7 -1
  462. package/src/components/data-table-pagination.tsx +60 -31
  463. package/src/components/data-table.tsx +164 -43
  464. package/src/components/date-picker.tsx +44 -10
  465. package/src/components/description-list.tsx +2 -2
  466. package/src/components/dialog-frame.tsx +2 -1
  467. package/src/components/disclosure.tsx +3 -2
  468. package/src/components/dropdown.tsx +10 -2
  469. package/src/components/facing-pair.ts +12 -5
  470. package/src/components/field-parts.tsx +190 -7
  471. package/src/components/field-sync.tsx +17 -3
  472. package/src/components/field.tsx +2 -2
  473. package/src/components/floating-panel.tsx +7 -4
  474. package/src/components/focus-ring.ts +12 -0
  475. package/src/components/form-actions.tsx +55 -18
  476. package/src/components/full-bleed-dialog.tsx +18 -4
  477. package/src/components/image-grid.tsx +1 -1
  478. package/src/components/inline-edit-field.tsx +26 -4
  479. package/src/components/legal-page.tsx +28 -2
  480. package/src/components/legal.tsx +19 -1
  481. package/src/components/lightbox.tsx +24 -2
  482. package/src/components/line-items.tsx +7 -1
  483. package/src/components/list.tsx +36 -10
  484. package/src/components/measured-grid.tsx +49 -24
  485. package/src/components/menu-item.tsx +2 -2
  486. package/src/components/mini-calendar.tsx +8 -4
  487. package/src/components/month-picker.tsx +15 -6
  488. package/src/components/nav-pills.tsx +1 -1
  489. package/src/components/number-input.tsx +14 -7
  490. package/src/components/numpad-sheet.tsx +2 -2
  491. package/src/components/one-time-code-input.tsx +2 -2
  492. package/src/components/page-contents.tsx +2 -2
  493. package/src/components/phone-input.tsx +9 -4
  494. package/src/components/pie-chart.tsx +19 -9
  495. package/src/components/popover.tsx +22 -5
  496. package/src/components/row-actions.tsx +450 -0
  497. package/src/components/scroll-area.tsx +1 -1
  498. package/src/components/search-field.tsx +4 -2
  499. package/src/components/series-chart-budget.ts +40 -8
  500. package/src/components/series-chart-ticks.ts +10 -0
  501. package/src/components/series-chart.tsx +123 -72
  502. package/src/components/settings-fields.tsx +89 -5
  503. package/src/components/share-card.tsx +31 -2
  504. package/src/components/sign-chip.tsx +28 -4
  505. package/src/components/signature-pad.tsx +13 -7
  506. package/src/components/slider.tsx +22 -9
  507. package/src/components/sparkline.tsx +11 -3
  508. package/src/components/stat-tile.tsx +70 -14
  509. package/src/components/status-dot.tsx +25 -2
  510. package/src/components/swipeable-row.tsx +10 -2
  511. package/src/components/switch.tsx +57 -23
  512. package/src/components/table.tsx +2 -2
  513. package/src/components/text-link.tsx +1 -1
  514. package/src/components/text.tsx +11 -6
  515. package/src/components/tile-radio.tsx +4 -1
  516. package/src/components/toast.tsx +27 -7
  517. package/src/components/toggle-group.tsx +115 -14
  518. package/src/components/toggle-legend.tsx +53 -8
  519. package/src/components/translation-review-editor.tsx +1 -1
  520. package/src/components/translation-review.tsx +11 -5
  521. package/src/components/tree-view.tsx +3 -2
  522. package/src/components/treemap.tsx +27 -10
  523. package/src/components/ui.tsx +353 -153
  524. package/src/components/user-avatar.tsx +1 -1
  525. package/src/components/wizard-stepper.tsx +5 -1
  526. package/src/demo/demo-banner.tsx +5 -0
  527. package/src/feedback/feedback-dialog.tsx +3 -3
  528. package/src/feedback/feedback-inbox.tsx +2 -2
  529. package/src/feedback/feedback-thread.tsx +3 -3
  530. package/src/hooks/use-anchored-panel.ts +67 -5
  531. package/src/hooks/use-breakpoint.ts +132 -0
  532. package/src/hooks/use-large-text.ts +41 -0
  533. package/src/hooks/use-windowed-rows.ts +168 -12
  534. package/src/i18n/defaults.ts +8 -0
  535. package/src/i18n/german.ts +107 -0
  536. package/src/i18n/kit-labels.tsx +12 -0
  537. package/src/i18n/locales/es.ts +98 -0
  538. package/src/i18n/locales/fr.ts +102 -0
  539. package/src/i18n/locales/hu.ts +100 -0
  540. package/src/i18n/locales/it.ts +103 -0
  541. package/src/i18n/locales/zh.ts +94 -0
  542. package/src/i18n/review.ts +14 -0
  543. package/src/index.ts +76 -6
  544. package/src/landing/landing-sections.tsx +7 -3
  545. package/src/landing/public-header.tsx +4 -4
  546. package/src/lib/cn.ts +13 -2
  547. package/src/rhf/fields.tsx +1 -1
  548. package/src/rhf/form.tsx +2 -2
  549. package/src/search/command-palette.tsx +10 -9
  550. package/src/settings/settings-layout.tsx +2 -1
  551. package/src/settings/use-account-appearance.ts +148 -0
  552. package/src/settings/use-settings-route.ts +3 -4
  553. package/src/shell/app-shell.tsx +278 -54
  554. package/src/shell/auth-layout.tsx +1 -1
  555. package/src/shell/option-switcher-menu.tsx +1 -1
  556. package/src/shell/top-bar-brand.tsx +3 -1
  557. package/src/shell/topbar-action-menu.tsx +3 -3
  558. package/src/shell/topbar-controls.tsx +4 -4
  559. package/src/theme/contrast-tokens.ts +112 -0
  560. package/src/theme/contrast.ts +225 -0
  561. package/src/theme/palette-presets.ts +24 -4
  562. package/src/theme/palette-store.ts +6 -1
  563. package/src/theme/text-size.ts +283 -0
  564. package/src/wizard/wizard-summary.tsx +4 -2
  565. package/tokens.css +158 -8
@@ -1 +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 { useKitLabels } from \"../i18n/kit-labels\";\nimport { FieldHint } from \"./ui\";\n\n/** The words a {@link DescriptionList} renders on its own behalf. */\nexport interface DescriptionListLabels {\n /** What an item with no value shows (see {@link DescriptionItemProps.placeholder}).\n * Default \"—\", an em dash. */\n empty: string;\n}\n\nexport const DEFAULT_DESCRIPTION_LIST_LABELS: DescriptionListLabels = {\n empty: \"—\",\n};\n\nexport type DescriptionListLayout = \"rows\" | \"cards\" | \"stacked\";\nexport type DescriptionListDensity = \"comfortable\" | \"compact\" | \"tight\";\n/** How many columns a `stacked` or `cards` list may use. */\nexport type DescriptionListColumns = 1 | 2 | 3 | 4 | 5 | 6;\n\ninterface ListContextValue {\n layout: DescriptionListLayout;\n numeric: boolean;\n prose: boolean;\n density: DescriptionListDensity;\n columns: DescriptionListColumns;\n placeholder?: ReactNode;\n}\n\nconst ListContext = createContext<ListContextValue>({\n layout: \"rows\",\n numeric: false,\n prose: false,\n density: \"comfortable\",\n columns: 2,\n});\n\n/**\n * `stacked` columns, by the width of the LIST (a container query on a wrapper — the\n * `<dl>` is the grid and cannot query itself). One column on a phone-narrow pane, two\n * from 20rem, then one more column each time every column would still get ~12rem.\n * The same shape as kastlan's DetailGrid (1 → 2 at `sm` → n at `md`), measured on the\n * pane rather than the viewport, so the four preview dialogs and a full-width detail\n * page can share one list. Literal strings, because Tailwind only emits what it reads.\n */\nconst STACKED_COLS: Record<DescriptionListColumns, string> = {\n 1: \"grid-cols-1\",\n 2: \"grid-cols-1 @xs:grid-cols-2\",\n 3: \"grid-cols-1 @xs:grid-cols-2 @xl:grid-cols-3\",\n 4: \"grid-cols-1 @xs:grid-cols-2 @xl:grid-cols-3 @3xl:grid-cols-4\",\n 5: \"grid-cols-1 @xs:grid-cols-2 @xl:grid-cols-3 @3xl:grid-cols-4 @5xl:grid-cols-5\",\n 6: \"grid-cols-1 @xs:grid-cols-2 @xl:grid-cols-3 @3xl:grid-cols-4 @5xl:grid-cols-5 @6xl:grid-cols-6\",\n};\n\n/** An item's span at each of those thresholds, never more columns than exist there —\n * so a span can never open an implicit column and push the grid past its pane. */\nconst STACKED_SPAN: Record<DescriptionListColumns, string> = {\n 1: \"\",\n 2: \"@xs:col-span-2\",\n 3: \"@xs:col-span-2 @xl:col-span-3\",\n 4: \"@xs:col-span-2 @xl:col-span-3 @3xl:col-span-4\",\n 5: \"@xs:col-span-2 @xl:col-span-3 @3xl:col-span-4 @5xl:col-span-5\",\n 6: \"@xs:col-span-2 @xl:col-span-3 @3xl:col-span-4 @5xl:col-span-5 @6xl:col-span-6\",\n};\n\n/** The cards grid's gap per density, as a class and as the length the column formula\n * subtracts — one table so the two cannot disagree. */\nconst CARD_GAP: Record<DescriptionListDensity, { cls: string; len: string }> = {\n comfortable: { cls: \"gap-3\", len: \"0.75rem\" },\n compact: { cls: \"gap-2\", len: \"0.5rem\" },\n tight: { cls: \"gap-1\", len: \"0.25rem\" },\n};\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 * `stacked` (0.10.0): a borderless grid, term ABOVE detail, {@link columns} wide —\n * kastlan's DetailField/DetailGrid and the label-over-value grids of its lease,\n * invoice, contact and unit preview dialogs. Items can {@link DescriptionItemProps.span}\n * several columns (a notes field across the whole row).\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. `tight` (0.10.0) is 11px\n * type on a 2px rhythm with no rules between rows — keksdose's admin metrics\n * breakdowns (metrics-panel's label-left, count-right lists), which are read as a\n * block of small print, not scanned row by row. */\n density?: DescriptionListDensity;\n /** `cards` only: the narrowest a card may get before the grid drops a column. */\n minCardWidth?: string;\n /**\n * `stacked`: how many columns the grid grows to on a wide pane (default 2), see\n * {@link STACKED_COLS}. `cards` (0.10.0): the MOST cards per row; the grid still\n * drops columns below {@link minCardWidth}. keksdose's category editor faked \"two\n * side by side\" with `minCardWidth=\"calc(50% - 0.5rem)\"`, which is `columns={2}\n * minCardWidth=\"0\"` now, without knowing the gap. Ignored by `rows`.\n */\n columns?: DescriptionListColumns;\n /**\n * The details are sentences, not values: regular weight in the secondary ink.\n * lenkbank's control explainer cards each carry a paragraph, and at the card's\n * `font-medium` primary ink a grid of paragraphs reads as a wall of headings — it\n * spelled `font-normal text-slate-700` into every item. A flag rather than a new\n * default because every other card list in the apps holds values (dates, figures,\n * counts) that are not flagged `numeric` and ARE meant to stand out; lightening them\n * all would not be an improvement. Per item: {@link DescriptionItemProps.prose}.\n */\n prose?: boolean;\n /** What an item with no value shows, for every item that does not set its own —\n * see {@link DescriptionItemProps.placeholder}. */\n placeholder?: ReactNode;\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 prose = false,\n density = \"comfortable\",\n minCardWidth = \"10rem\",\n columns,\n placeholder,\n className,\n style,\n ...rest\n}: DescriptionListProps) {\n const cards = layout === \"cards\";\n const stacked = layout === \"stacked\";\n const gap = CARD_GAP[density];\n // Cards: auto-fill at `minCardWidth`, and with `columns` a floor on the track of one\n // n-th of the row (less the gaps) — so auto-fill can never fit more than n. The\n // outer `min(100%, …)` keeps a single card from overflowing a pane narrower than\n // its minimum.\n const track =\n columns !== undefined\n ? `max(${minCardWidth}, (100% - ${columns - 1} * ${gap.len}) / ${columns})`\n : minCardWidth;\n const grid: CSSProperties | undefined = cards\n ? { gridTemplateColumns: `repeat(auto-fill, minmax(min(100%, ${track}), 1fr))` }\n : undefined;\n const ctx: ListContextValue = { layout, numeric, prose, density, columns: columns ?? 2, placeholder };\n const text = density === \"tight\" ? \"text-[11px] leading-4\" : density === \"compact\" ? \"text-xs\" : \"text-sm\";\n\n if (stacked) {\n return (\n <ListContext.Provider value={ctx}>\n {/* The container the columns are measured on — see STACKED_COLS. */}\n <div className=\"@container\">\n <dl\n {...rest}\n data-layout={layout}\n style={style}\n className={cn(\n \"grid\",\n STACKED_COLS[ctx.columns],\n density === \"tight\" ? \"gap-x-3 gap-y-1\" : density === \"compact\" ? \"gap-x-4 gap-y-2\" : \"gap-x-6 gap-y-4\",\n text,\n className,\n )}\n />\n </div>\n </ListContext.Provider>\n );\n }\n\n return (\n <ListContext.Provider value={ctx}>\n <dl\n {...rest}\n data-layout={layout}\n style={grid ? { ...grid, ...style } : style}\n className={cn(\n cards\n ? cn(\"grid\", gap.cls)\n : // Tight rows carry no rules: at a 2px rhythm a line under every row\n // turns a block of small print into a ruled table.\n cn(\"@container\", density !== \"tight\" && \"divide-y divide-[var(--border)]\"),\n text,\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 /** This detail is prose (see {@link DescriptionListProps.prose}); overrides the\n * list's setting either way. */\n prose?: boolean;\n /**\n * `stacked`: how many columns this item spans, clamped to the list's `columns` and\n * to however many the pane has room for; `\"full\"` is the whole row. kastlan's\n * DetailField `span={2}` for notes and descriptions. `cards`: only `\"full\"` applies,\n * because a card grid's column count is not known to CSS ahead of layout.\n */\n span?: number | \"full\";\n /**\n * Shown in place of a value that is not there — `children` of `null`, `undefined`,\n * `false` or `\"\"` (a `0` is a value and is shown). Default: the list's own\n * `placeholder`, else `descriptionList.empty` from the provider, else \"—\". `null`\n * shows nothing, as an empty detail did before. kastlan's DetailField put its\n * `EMPTY_VALUE` into every one of its call sites' values by hand.\n *\n * Drawn in the muted ink, so an absent value does not read as a value of \"—\".\n */\n placeholder?: ReactNode;\n}\n\nfunction isEmptyValue(node: ReactNode): boolean {\n return node === undefined || node === null || node === false || node === \"\";\n}\n\nconst ROW_PAD: Record<DescriptionListDensity, string> = {\n comfortable: \"py-2.5\",\n compact: \"py-1.5\",\n tight: \"py-px\",\n};\nconst CARD_PAD: Record<DescriptionListDensity, string> = {\n comfortable: \"px-3 py-2.5\",\n compact: \"px-2.5 py-1.5\",\n tight: \"px-2 py-1\",\n};\n\n/** One term and its detail inside a {@link DescriptionList}. */\nexport function DescriptionItem({\n term,\n children,\n hint,\n numeric: numericProp,\n prose: proseProp,\n span,\n placeholder: placeholderProp,\n detailClassName,\n className,\n ...rest\n}: DescriptionItemProps) {\n const {\n layout,\n numeric: listNumeric,\n prose: listProse,\n density,\n columns,\n placeholder: listPlaceholder,\n } = useContext(ListContext);\n const labels = useKitLabels(\"descriptionList\", DEFAULT_DESCRIPTION_LIST_LABELS);\n const empty = isEmptyValue(children);\n const placeholder =\n placeholderProp !== undefined ? placeholderProp : listPlaceholder !== undefined ? listPlaceholder : labels.empty;\n const numeric = numericProp ?? listNumeric;\n const prose = proseProp ?? listProse;\n const cards = layout === \"cards\";\n const stacked = layout === \"stacked\";\n const spanClass =\n span === \"full\"\n ? \"col-span-full\"\n : stacked && span !== undefined && span > 1\n ? STACKED_SPAN[Math.min(Math.floor(span), columns) as DescriptionListColumns]\n : undefined;\n\n const termNode = (\n <dt\n className={cn(\n \"flex min-w-0 items-center gap-1 text-[var(--text-muted)]\",\n cards && (density === \"tight\" ? \"text-[10px] uppercase tracking-wide\" : \"text-xs uppercase tracking-wide\"),\n // Stacked terms are a step smaller than the detail, as kastlan's dialogs set\n // them; in a list that is already small they stay the list's own size.\n stacked && density === \"comfortable\" && \"text-xs\",\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 // A stacked figure sits under its term, so it keeps the term's start edge.\n numeric && (stacked ? \"tabular-nums\" : \"tabular-nums text-end\"),\n (cards || stacked) && \"mt-0.5 font-medium\",\n prose && \"font-normal text-[var(--text-secondary)]\",\n detailClassName,\n )}\n >\n {empty && !isEmptyValue(placeholder) ? (\n <span data-slot=\"description-empty\" className=\"font-normal text-[var(--text-muted)]\">\n {placeholder}\n </span>\n ) : (\n children\n )}\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 spanClass,\n className,\n )}\n >\n {termNode}\n {detail}\n </div>\n );\n }\n\n if (stacked) {\n return (\n <div {...rest} className={cn(\"min-w-0\", spanClass, className)}>\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[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AAA,IACH;AAAA,EAEJ;AAEA,MAAI,SAAS;AACX,WACE,qBAAC,SAAK,GAAG,MAAM,WAAW,GAAG,WAAW,WAAW,SAAS,GACzD;AAAA;AAAA,MACA;AAAA,OACH;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":[]}
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 { useKitLabels } from \"../i18n/kit-labels\";\nimport { FieldHint } from \"./ui\";\n\n/** The words a {@link DescriptionList} renders on its own behalf. */\nexport interface DescriptionListLabels {\n /** What an item with no value shows (see {@link DescriptionItemProps.placeholder}).\n * Default \"—\", an em dash. */\n empty: string;\n}\n\nexport const DEFAULT_DESCRIPTION_LIST_LABELS: DescriptionListLabels = {\n empty: \"—\",\n};\n\nexport type DescriptionListLayout = \"rows\" | \"cards\" | \"stacked\";\nexport type DescriptionListDensity = \"comfortable\" | \"compact\" | \"tight\";\n/** How many columns a `stacked` or `cards` list may use. */\nexport type DescriptionListColumns = 1 | 2 | 3 | 4 | 5 | 6;\n\ninterface ListContextValue {\n layout: DescriptionListLayout;\n numeric: boolean;\n prose: boolean;\n density: DescriptionListDensity;\n columns: DescriptionListColumns;\n placeholder?: ReactNode;\n}\n\nconst ListContext = createContext<ListContextValue>({\n layout: \"rows\",\n numeric: false,\n prose: false,\n density: \"comfortable\",\n columns: 2,\n});\n\n/**\n * `stacked` columns, by the width of the LIST (a container query on a wrapper — the\n * `<dl>` is the grid and cannot query itself). One column on a phone-narrow pane, two\n * from 20rem, then one more column each time every column would still get ~12rem.\n * The same shape as kastlan's DetailGrid (1 → 2 at `sm` → n at `md`), measured on the\n * pane rather than the viewport, so the four preview dialogs and a full-width detail\n * page can share one list. Literal strings, because Tailwind only emits what it reads.\n */\nconst STACKED_COLS: Record<DescriptionListColumns, string> = {\n 1: \"grid-cols-1\",\n 2: \"grid-cols-1 @xs:grid-cols-2\",\n 3: \"grid-cols-1 @xs:grid-cols-2 @xl:grid-cols-3\",\n 4: \"grid-cols-1 @xs:grid-cols-2 @xl:grid-cols-3 @3xl:grid-cols-4\",\n 5: \"grid-cols-1 @xs:grid-cols-2 @xl:grid-cols-3 @3xl:grid-cols-4 @5xl:grid-cols-5\",\n 6: \"grid-cols-1 @xs:grid-cols-2 @xl:grid-cols-3 @3xl:grid-cols-4 @5xl:grid-cols-5 @6xl:grid-cols-6\",\n};\n\n/** An item's span at each of those thresholds, never more columns than exist there —\n * so a span can never open an implicit column and push the grid past its pane. */\nconst STACKED_SPAN: Record<DescriptionListColumns, string> = {\n 1: \"\",\n 2: \"@xs:col-span-2\",\n 3: \"@xs:col-span-2 @xl:col-span-3\",\n 4: \"@xs:col-span-2 @xl:col-span-3 @3xl:col-span-4\",\n 5: \"@xs:col-span-2 @xl:col-span-3 @3xl:col-span-4 @5xl:col-span-5\",\n 6: \"@xs:col-span-2 @xl:col-span-3 @3xl:col-span-4 @5xl:col-span-5 @6xl:col-span-6\",\n};\n\n/** The cards grid's gap per density, as a class and as the length the column formula\n * subtracts — one table so the two cannot disagree. */\nconst CARD_GAP: Record<DescriptionListDensity, { cls: string; len: string }> = {\n comfortable: { cls: \"gap-3\", len: \"0.75rem\" },\n compact: { cls: \"gap-2\", len: \"0.5rem\" },\n tight: { cls: \"gap-1\", len: \"0.25rem\" },\n};\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 * `stacked` (0.10.0): a borderless grid, term ABOVE detail, {@link columns} wide —\n * kastlan's DetailField/DetailGrid and the label-over-value grids of its lease,\n * invoice, contact and unit preview dialogs. Items can {@link DescriptionItemProps.span}\n * several columns (a notes field across the whole row).\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. `tight` (0.10.0) is 11px\n * type on a 2px rhythm with no rules between rows — keksdose's admin metrics\n * breakdowns (metrics-panel's label-left, count-right lists), which are read as a\n * block of small print, not scanned row by row. */\n density?: DescriptionListDensity;\n /** `cards` only: the narrowest a card may get before the grid drops a column. */\n minCardWidth?: string;\n /**\n * `stacked`: how many columns the grid grows to on a wide pane (default 2), see\n * {@link STACKED_COLS}. `cards` (0.10.0): the MOST cards per row; the grid still\n * drops columns below {@link minCardWidth}. keksdose's category editor faked \"two\n * side by side\" with `minCardWidth=\"calc(50% - 0.5rem)\"`, which is `columns={2}\n * minCardWidth=\"0\"` now, without knowing the gap. Ignored by `rows`.\n */\n columns?: DescriptionListColumns;\n /**\n * The details are sentences, not values: regular weight in the secondary ink.\n * lenkbank's control explainer cards each carry a paragraph, and at the card's\n * `font-medium` primary ink a grid of paragraphs reads as a wall of headings — it\n * spelled `font-normal text-slate-700` into every item. A flag rather than a new\n * default because every other card list in the apps holds values (dates, figures,\n * counts) that are not flagged `numeric` and ARE meant to stand out; lightening them\n * all would not be an improvement. Per item: {@link DescriptionItemProps.prose}.\n */\n prose?: boolean;\n /** What an item with no value shows, for every item that does not set its own —\n * see {@link DescriptionItemProps.placeholder}. */\n placeholder?: ReactNode;\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 prose = false,\n density = \"comfortable\",\n minCardWidth = \"10rem\",\n columns,\n placeholder,\n className,\n style,\n ...rest\n}: DescriptionListProps) {\n const cards = layout === \"cards\";\n const stacked = layout === \"stacked\";\n const gap = CARD_GAP[density];\n // Cards: auto-fill at `minCardWidth`, and with `columns` a floor on the track of one\n // n-th of the row (less the gaps) — so auto-fill can never fit more than n. The\n // outer `min(100%, …)` keeps a single card from overflowing a pane narrower than\n // its minimum.\n const track =\n columns !== undefined\n ? `max(${minCardWidth}, (100% - ${columns - 1} * ${gap.len}) / ${columns})`\n : minCardWidth;\n const grid: CSSProperties | undefined = cards\n ? { gridTemplateColumns: `repeat(auto-fill, minmax(min(100%, ${track}), 1fr))` }\n : undefined;\n const ctx: ListContextValue = { layout, numeric, prose, density, columns: columns ?? 2, placeholder };\n const text = density === \"tight\" ? \"text-caption leading-4\" : density === \"compact\" ? \"text-xs\" : \"text-sm\";\n\n if (stacked) {\n return (\n <ListContext.Provider value={ctx}>\n {/* The container the columns are measured on — see STACKED_COLS. */}\n <div className=\"@container\">\n <dl\n {...rest}\n data-layout={layout}\n style={style}\n className={cn(\n \"grid\",\n STACKED_COLS[ctx.columns],\n density === \"tight\" ? \"gap-x-3 gap-y-1\" : density === \"compact\" ? \"gap-x-4 gap-y-2\" : \"gap-x-6 gap-y-4\",\n text,\n className,\n )}\n />\n </div>\n </ListContext.Provider>\n );\n }\n\n return (\n <ListContext.Provider value={ctx}>\n <dl\n {...rest}\n data-layout={layout}\n style={grid ? { ...grid, ...style } : style}\n className={cn(\n cards\n ? cn(\"grid\", gap.cls)\n : // Tight rows carry no rules: at a 2px rhythm a line under every row\n // turns a block of small print into a ruled table.\n cn(\"@container\", density !== \"tight\" && \"divide-y divide-[var(--border)]\"),\n text,\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 /** This detail is prose (see {@link DescriptionListProps.prose}); overrides the\n * list's setting either way. */\n prose?: boolean;\n /**\n * `stacked`: how many columns this item spans, clamped to the list's `columns` and\n * to however many the pane has room for; `\"full\"` is the whole row. kastlan's\n * DetailField `span={2}` for notes and descriptions. `cards`: only `\"full\"` applies,\n * because a card grid's column count is not known to CSS ahead of layout.\n */\n span?: number | \"full\";\n /**\n * Shown in place of a value that is not there — `children` of `null`, `undefined`,\n * `false` or `\"\"` (a `0` is a value and is shown). Default: the list's own\n * `placeholder`, else `descriptionList.empty` from the provider, else \"—\". `null`\n * shows nothing, as an empty detail did before. kastlan's DetailField put its\n * `EMPTY_VALUE` into every one of its call sites' values by hand.\n *\n * Drawn in the muted ink, so an absent value does not read as a value of \"—\".\n */\n placeholder?: ReactNode;\n}\n\nfunction isEmptyValue(node: ReactNode): boolean {\n return node === undefined || node === null || node === false || node === \"\";\n}\n\nconst ROW_PAD: Record<DescriptionListDensity, string> = {\n comfortable: \"py-2.5\",\n compact: \"py-1.5\",\n tight: \"py-px\",\n};\nconst CARD_PAD: Record<DescriptionListDensity, string> = {\n comfortable: \"px-3 py-2.5\",\n compact: \"px-2.5 py-1.5\",\n tight: \"px-2 py-1\",\n};\n\n/** One term and its detail inside a {@link DescriptionList}. */\nexport function DescriptionItem({\n term,\n children,\n hint,\n numeric: numericProp,\n prose: proseProp,\n span,\n placeholder: placeholderProp,\n detailClassName,\n className,\n ...rest\n}: DescriptionItemProps) {\n const {\n layout,\n numeric: listNumeric,\n prose: listProse,\n density,\n columns,\n placeholder: listPlaceholder,\n } = useContext(ListContext);\n const labels = useKitLabels(\"descriptionList\", DEFAULT_DESCRIPTION_LIST_LABELS);\n const empty = isEmptyValue(children);\n const placeholder =\n placeholderProp !== undefined ? placeholderProp : listPlaceholder !== undefined ? listPlaceholder : labels.empty;\n const numeric = numericProp ?? listNumeric;\n const prose = proseProp ?? listProse;\n const cards = layout === \"cards\";\n const stacked = layout === \"stacked\";\n const spanClass =\n span === \"full\"\n ? \"col-span-full\"\n : stacked && span !== undefined && span > 1\n ? STACKED_SPAN[Math.min(Math.floor(span), columns) as DescriptionListColumns]\n : undefined;\n\n const termNode = (\n <dt\n className={cn(\n \"flex min-w-0 items-center gap-1 text-[var(--text-muted)]\",\n cards && (density === \"tight\" ? \"text-micro uppercase tracking-wide\" : \"text-xs uppercase tracking-wide\"),\n // Stacked terms are a step smaller than the detail, as kastlan's dialogs set\n // them; in a list that is already small they stay the list's own size.\n stacked && density === \"comfortable\" && \"text-xs\",\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 // A stacked figure sits under its term, so it keeps the term's start edge.\n numeric && (stacked ? \"tabular-nums\" : \"tabular-nums text-end\"),\n (cards || stacked) && \"mt-0.5 font-medium\",\n prose && \"font-normal text-[var(--text-secondary)]\",\n detailClassName,\n )}\n >\n {empty && !isEmptyValue(placeholder) ? (\n <span data-slot=\"description-empty\" className=\"font-normal text-[var(--text-muted)]\">\n {placeholder}\n </span>\n ) : (\n children\n )}\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 spanClass,\n className,\n )}\n >\n {termNode}\n {detail}\n </div>\n );\n }\n\n if (stacked) {\n return (\n <div {...rest} className={cn(\"min-w-0\", spanClass, className)}>\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":";AA8KU,cA4HN,YA5HM;AA9KV,SAAS,eAAe,kBAAkB;AAE1C,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AASnB,MAAM,kCAAyD;AAAA,EACpE,OAAO;AACT;AAgBA,MAAM,cAAc,cAAgC;AAAA,EAClD,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AACX,CAAC;AAUD,MAAM,eAAuD;AAAA,EAC3D,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAIA,MAAM,eAAuD;AAAA,EAC3D,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,G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AAuC;AAAA;AAAA;AAAA,QAGvE,WAAW,YAAY,iBAAiB;AAAA,MAC1C;AAAA,MAEA;AAAA,4BAAC,UAAK,WAAU,uBAAuB,gBAAK;AAAA,QAC3C,QAAQ,oBAAC,aAAU,OAAO,MAAM,MAAK,OAAM,WAAU,YAAW;AAAA;AAAA;AAAA,EACnE;AAEF,QAAM,SACJ;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA;AAAA,QAEA,YAAY,UAAU,iBAAiB;AAAA,SACtC,SAAS,YAAY;AAAA,QACtB,SAAS;AAAA,QACT;AAAA,MACF;AAAA,MAEC,mBAAS,CAAC,aAAa,WAAW,IACjC,oBAAC,UAAK,aAAU,qBAAoB,WAAU,wCAC3C,uBACH,IAEA;AAAA;AAAA,EAEJ;AAGF,MAAI,OAAO;AACT,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,WAAW;AAAA,UACT;AAAA,UACA,SAAS,OAAO;AAAA,UAChB;AAAA,UACA;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,UACA;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,MAAI,SAAS;AACX,WACE,qBAAC,SAAK,GAAG,MAAM,WAAW,GAAG,WAAW,WAAW,SAAS,GACzD;AAAA;AAAA,MACA;AAAA,OACH;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":[]}
@@ -3,6 +3,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useContext, useId } from "react";
4
4
  import { X } from "lucide-react";
5
5
  import { cn } from "../lib/cn.js";
6
+ import { FOCUS_RING } from "./focus-ring.js";
6
7
  import { Modal, ModalCloseContext } from "./modal.js";
7
8
  import { useKitLabels } from "../i18n/kit-labels.js";
8
9
  const DEFAULT_DIALOG_FRAME_LABELS = { close: "Close" };
@@ -82,7 +83,7 @@ function FrameClose({ label, onClose }) {
82
83
  type: "button",
83
84
  onClick: close,
84
85
  "aria-label": labels.close,
85
- className: "-me-1.5 -mt-1 shrink-0 rounded p-1.5 text-[var(--text-muted)] outline-none hover:bg-[var(--bg-hover)] hover:text-[var(--text-secondary)] focus-visible:ring-2 focus-visible:ring-[var(--brand)]",
86
+ className: cn("-me-1.5 -mt-1 shrink-0 rounded p-1.5 text-[var(--text-muted)] outline-none hover:bg-[var(--bg-hover)] hover:text-[var(--text-secondary)]", FOCUS_RING),
86
87
  children: /* @__PURE__ */ jsx(X, { "aria-hidden": true, className: "size-5" })
87
88
  }
88
89
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/dialog-frame.tsx"],"sourcesContent":["import { useContext, useId } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"../lib/cn\";\nimport { Modal, ModalCloseContext } from \"./modal\";\nimport type { ModalProps } from \"./modal\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\n\nexport interface DialogFrameLabels {\n /** Accessible name of the header's X, when {@link DialogFrameProps.closeButton} shows it. */\n close: string;\n}\n\nexport const DEFAULT_DIALOG_FRAME_LABELS: DialogFrameLabels = { close: \"Close\" };\n\n/**\n * `ModalProps` minus the three this component owns: the NAME (`labelledBy` — the\n * heading's id is generated inside and never reaches the caller), the content\n * (`children` is the body here, not the whole panel) and `title`, which is the dialog's\n * HEADING and a ReactNode rather than the browser's tooltip string — the collision\n * `PickerSheet` met first. Everything else, `size`, `draggable`, `fullBleed`,\n * `onKeyDown`, a `data-tour` anchor, still reaches the `Modal`.\n */\nexport interface DialogFrameProps extends Omit<ModalProps, \"labelledBy\" | \"children\" | \"title\"> {\n /** The heading, and therefore the dialog's accessible name (`aria-labelledby`). */\n title: ReactNode;\n /** The smaller line under the heading; wired to `aria-describedby`. */\n description?: ReactNode;\n /**\n * The heading's level. `h2` by default, which is what every dialog in both apps\n * writes; a prop for a page that nests its demos under a real heading.\n */\n headingAs?: \"h1\" | \"h2\" | \"h3\" | \"h4\";\n /**\n * The row under the body — buttons, in the caller's own order and variants (the two\n * apps disagree about the cancel button's variant, so the frame has no opinion on\n * it). Stays put while the body scrolls.\n *\n * A FUNCTION receives the panel's animated close: `(close) => <Button\n * onClick={close}>Cancel</Button>` lowers the panel the way Escape does, where\n * calling `onClose` directly unmounts it at once.\n */\n actions?: ReactNode | ((close: () => void) => ReactNode);\n /**\n * Controls that belong to the HEADER rather than to the actions row — an \"Edit\"\n * toggle, a status badge with a menu, a \"Copy link\" (kastlan). Rendered beside the\n * title, before the optional X; on a phone, where title and controls do not fit on\n * one line, they wrap under the title and the X keeps its corner.\n *\n * A function receives the animated close, as `actions` does.\n */\n headerActions?: ReactNode | ((close: () => void) => ReactNode);\n /**\n * Show an X in the header. Off by default: a centred dialog has a backdrop and\n * Escape, and a form dialog has a Cancel. On for a dialog that commits as it goes\n * and has no actions row, where the X is the only visible way out.\n */\n closeButton?: boolean;\n /** Default: `dialogFrame.close` from the {@link UiKitProvider}, else \"Close\". */\n closeLabel?: string;\n /** Extra classes for the scrolling body (default spacing `space-y-3`). */\n bodyClassName?: string;\n /**\n * Extra classes for the header row (default padding `px-4 pt-4 pb-3`), merged last —\n * `px-3` for a phone sheet whose body runs at `px-3`, so heading and fields share\n * one gutter.\n */\n headerClassName?: string;\n /**\n * A rule under the header, the twin of the one over the actions row — for a tall or\n * full-screen body that scrolls under a header which stays. The body then starts a\n * step below the rule instead of flush against it.\n */\n headerDivider?: boolean;\n /**\n * The body. Optional: a dialog whose title, description and actions are the whole\n * of it (a \"you have unsynced changes\" question) leaves it out, and the frame then\n * renders no body at all rather than an empty padded one.\n */\n children?: ReactNode;\n}\n\n/**\n * A {@link Modal} with the frame every caller was writing by hand: a heading, an\n * optional description, an optional X, a body that scrolls, and an actions row that\n * does not.\n *\n * 34 dialogs across the two apps framed themselves — a heading with an id invented per\n * file (and spelt three ways), four visible type sizes for one thing, ten spellings of\n * one right-aligned button row — and the package's own feedback dialog shipped with no\n * accessible name at all. This makes the name unforgettable: the heading's id comes\n * from `useId()` and goes straight to `Modal`'s `labelledBy`, so a framed dialog cannot\n * announce as just \"dialog\", and two open instances cannot share an id.\n *\n * ## It wraps, it does not change `Modal`\n *\n * `Modal` keeps `labelledBy` and every existing caller compiles untouched. What the\n * frame changes is inside the panel: the panel becomes a flex column with no padding\n * of its own, and only the BODY scrolls. The panel's `max-h-full` is still the outer\n * bound, so a tall form keeps its heading and its Save button on screen instead of\n * scrolling them away with the fields. A caller's own `className` still wins (it is\n * tailwind-merged last), which is how a full-screen phone sheet is spelt:\n * `fullBleed className=\"h-[100dvh] max-w-full rounded-none md:h-auto md:rounded-lg\"`.\n *\n * ## Kept mounted\n *\n * `open` reaches the `Modal` like every other prop, so `<DialogFrame open={open} …>`\n * replaces the `{open && <DialogFrame …/>}` gate (kastlan's `FormModal` was only\n * that gate) and gains the exit a caller-driven close otherwise skips. See\n * {@link ModalProps.open}.\n *\n * ## What it is not\n *\n * Not `FullBleedDialog`: that is the phone's full-screen editor with its own `open`,\n * Back handling and a required X, and it already draws a frame of its own. And not a\n * form: submit handling, a pending label and close-on-success stay the caller's.\n * Focus lands on the panel, as `Modal` decides — not on the first field, so opening\n * does not pop a phone's keyboard; an `autoFocus` in the body overrides that from the\n * caller's side, and should be a decision rather than a habit.\n */\nexport function DialogFrame({\n title,\n description,\n headingAs: Heading = \"h2\",\n actions,\n headerActions,\n closeButton = false,\n closeLabel,\n bodyClassName,\n headerClassName,\n headerDivider = false,\n className,\n children,\n \"aria-describedby\": describedBy,\n ...modal\n}: DialogFrameProps) {\n const titleId = useId();\n const descriptionId = useId();\n const hasDescription = description !== undefined && description !== null;\n // `false` too, so `{cond && <Body/>}` with a false `cond` means \"no body\".\n const hasBody = children !== undefined && children !== null && children !== false;\n\n return (\n <Modal\n {...modal}\n labelledBy={titleId}\n // The caller's own description (a warning inside the body, say) is ADDED to the\n // frame's, not traded for it: both are the dialog's.\n aria-describedby={[hasDescription ? descriptionId : undefined, describedBy].filter(Boolean).join(\" \") || undefined}\n // `overflow-hidden` replaces the panel's own `overflow-y-auto` (tailwind-merge\n // treats them as one group), `p-0` its `p-4`: the scroller and the padding move\n // to the body, which is the only part that should move.\n className={cn(\"flex flex-col overflow-hidden p-0\", className)}\n >\n <div\n className={cn(\n // `last:pb-4`: a frame with neither body nor actions closes on its header.\n \"flex shrink-0 items-start justify-between gap-2 px-4 pt-4 pb-3 last:pb-4\",\n headerDivider && \"border-b border-[var(--border)]\",\n headerClassName,\n )}\n >\n {/* Title and header actions share a wrapping row of their own, so it is THEY\n that wrap on a phone — the actions drop under a title that needs its 12rem —\n while the X stays outside it, pinned to the top-end corner. */}\n <div className=\"flex min-w-0 flex-1 flex-wrap items-start justify-between gap-x-3 gap-y-2\">\n <div className=\"min-w-0 grow basis-48\">\n <Heading id={titleId} className=\"text-lg font-semibold leading-snug text-[var(--text-primary)]\">\n {title}\n </Heading>\n {hasDescription && (\n <p id={descriptionId} className=\"mt-0.5 text-sm text-[var(--text-muted)]\">\n {description}\n </p>\n )}\n </div>\n {headerActions !== undefined && headerActions !== null && headerActions !== false && (\n <FrameHeaderActions actions={headerActions} onClose={modal.onClose} />\n )}\n </div>\n {closeButton && <FrameClose label={closeLabel} onClose={modal.onClose} />}\n </div>\n {hasBody && (\n <div\n className={cn(\n // `min-h-0` is what lets a flex child shrink below its content and scroll;\n // `last:pb-4` closes a frame that has no actions row under it.\n \"min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 pb-3 last:pb-4\",\n headerDivider && \"pt-3\",\n bodyClassName,\n )}\n >\n {children}\n </div>\n )}\n {actions !== undefined && actions !== null && (\n <FrameActions actions={actions} onClose={modal.onClose} divider={hasBody} />\n )}\n </Modal>\n );\n}\n\n/** The X. A component of its own so it can read the panel's animated close, which\n * only exists INSIDE the `Modal` (the frame's own body runs outside it). */\nfunction FrameClose({ label, onClose }: { label?: string; onClose: () => void }) {\n const close = useContext(ModalCloseContext) ?? onClose;\n const labels = useKitLabels(\"dialogFrame\", DEFAULT_DIALOG_FRAME_LABELS, label === undefined ? undefined : { close: label });\n return (\n <button\n type=\"button\"\n onClick={close}\n aria-label={labels.close}\n className=\"-me-1.5 -mt-1 shrink-0 rounded p-1.5 text-[var(--text-muted)] outline-none hover:bg-[var(--bg-hover)] hover:text-[var(--text-secondary)] focus-visible:ring-2 focus-visible:ring-[var(--brand)]\"\n >\n <X aria-hidden className=\"size-5\" />\n </button>\n );\n}\n\n/** The header's own controls; a component for the same reason as {@link FrameClose}. */\nfunction FrameHeaderActions({\n actions,\n onClose,\n}: {\n actions: NonNullable<DialogFrameProps[\"headerActions\"]>;\n onClose: () => void;\n}) {\n const close = useContext(ModalCloseContext) ?? onClose;\n return (\n <div data-dialog-header-actions=\"\" className=\"flex shrink-0 flex-wrap items-center gap-2\">\n {typeof actions === \"function\" ? actions(close) : actions}\n </div>\n );\n}\n\nfunction FrameActions({\n actions,\n onClose,\n divider,\n}: {\n actions: NonNullable<DialogFrameProps[\"actions\"]>;\n onClose: () => void;\n /** Off when there is no body: nothing scrolls, so there is no edge to mark, and a\n * rule straight under the description would cut the question from its answers. */\n divider: boolean;\n}) {\n const close = useContext(ModalCloseContext) ?? onClose;\n return (\n // The border marks where the scrolling stops; `flex-wrap` keeps three long\n // translated labels on a phone from pushing the row wider than the sheet.\n <div\n className={cn(\n \"flex shrink-0 flex-wrap items-center justify-end gap-2 px-4 py-3\",\n divider && \"border-t border-[var(--border)]\",\n )}\n >\n {typeof actions === \"function\" ? actions(close) : actions}\n </div>\n );\n}\n"],"mappings":";AAuKU,SACE,KADF;AAvKV,SAAS,YAAY,aAAa;AAElC,SAAS,SAAS;AAElB,SAAS,UAAU;AACnB,SAAS,OAAO,yBAAyB;AAEzC,SAAS,oBAAoB;AA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AAAA,cACjB;AAAA,YACF;AAAA,YAEC;AAAA;AAAA,QACH;AAAA,QAED,YAAY,UAAa,YAAY,QACpC,oBAAC,gBAAa,SAAkB,SAAS,MAAM,SAAS,SAAS,SAAS;AAAA;AAAA;AAAA,EAE9E;AAEJ;AAIA,SAAS,WAAW,EAAE,OAAO,QAAQ,GAA4C;AAC/E,QAAM,QAAQ,WAAW,iBAAiB,KAAK;AAC/C,QAAM,SAAS,aAAa,eAAe,6BAA6B,UAAU,SAAY,SAAY,EAAE,OAAO,MAAM,CAAC;AAC1H,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,SAAS;AAAA,MACT,cAAY,OAAO;AAAA,MACnB,WAAU;AAAA,MAEV,8BAAC,KAAE,eAAW,MAAC,WAAU,UAAS;AAAA;AAAA,EACpC;AAEJ;AAGA,SAAS,mBAAmB;AAAA,EAC1B;AAAA,EACA;AACF,GAGG;AACD,QAAM,QAAQ,WAAW,iBAAiB,KAAK;AAC/C,SACE,oBAAC,SAAI,8BAA2B,IAAG,WAAU,8CAC1C,iBAAO,YAAY,aAAa,QAAQ,KAAK,IAAI,SACpD;AAEJ;AAEA,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AACF,GAMG;AACD,QAAM,QAAQ,WAAW,iBAAiB,KAAK;AAC/C;AAAA;AAAA;AAAA,IAGE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA,WAAW;AAAA,QACb;AAAA,QAEC,iBAAO,YAAY,aAAa,QAAQ,KAAK,IAAI;AAAA;AAAA,IACpD;AAAA;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/dialog-frame.tsx"],"sourcesContent":["import { useContext, useId } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"../lib/cn\";\nimport { FOCUS_RING } from \"./focus-ring\";\nimport { Modal, ModalCloseContext } from \"./modal\";\nimport type { ModalProps } from \"./modal\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\n\nexport interface DialogFrameLabels {\n /** Accessible name of the header's X, when {@link DialogFrameProps.closeButton} shows it. */\n close: string;\n}\n\nexport const DEFAULT_DIALOG_FRAME_LABELS: DialogFrameLabels = { close: \"Close\" };\n\n/**\n * `ModalProps` minus the three this component owns: the NAME (`labelledBy` — the\n * heading's id is generated inside and never reaches the caller), the content\n * (`children` is the body here, not the whole panel) and `title`, which is the dialog's\n * HEADING and a ReactNode rather than the browser's tooltip string — the collision\n * `PickerSheet` met first. Everything else, `size`, `draggable`, `fullBleed`,\n * `onKeyDown`, a `data-tour` anchor, still reaches the `Modal`.\n */\nexport interface DialogFrameProps extends Omit<ModalProps, \"labelledBy\" | \"children\" | \"title\"> {\n /** The heading, and therefore the dialog's accessible name (`aria-labelledby`). */\n title: ReactNode;\n /** The smaller line under the heading; wired to `aria-describedby`. */\n description?: ReactNode;\n /**\n * The heading's level. `h2` by default, which is what every dialog in both apps\n * writes; a prop for a page that nests its demos under a real heading.\n */\n headingAs?: \"h1\" | \"h2\" | \"h3\" | \"h4\";\n /**\n * The row under the body — buttons, in the caller's own order and variants (the two\n * apps disagree about the cancel button's variant, so the frame has no opinion on\n * it). Stays put while the body scrolls.\n *\n * A FUNCTION receives the panel's animated close: `(close) => <Button\n * onClick={close}>Cancel</Button>` lowers the panel the way Escape does, where\n * calling `onClose` directly unmounts it at once.\n */\n actions?: ReactNode | ((close: () => void) => ReactNode);\n /**\n * Controls that belong to the HEADER rather than to the actions row — an \"Edit\"\n * toggle, a status badge with a menu, a \"Copy link\" (kastlan). Rendered beside the\n * title, before the optional X; on a phone, where title and controls do not fit on\n * one line, they wrap under the title and the X keeps its corner.\n *\n * A function receives the animated close, as `actions` does.\n */\n headerActions?: ReactNode | ((close: () => void) => ReactNode);\n /**\n * Show an X in the header. Off by default: a centred dialog has a backdrop and\n * Escape, and a form dialog has a Cancel. On for a dialog that commits as it goes\n * and has no actions row, where the X is the only visible way out.\n */\n closeButton?: boolean;\n /** Default: `dialogFrame.close` from the {@link UiKitProvider}, else \"Close\". */\n closeLabel?: string;\n /** Extra classes for the scrolling body (default spacing `space-y-3`). */\n bodyClassName?: string;\n /**\n * Extra classes for the header row (default padding `px-4 pt-4 pb-3`), merged last —\n * `px-3` for a phone sheet whose body runs at `px-3`, so heading and fields share\n * one gutter.\n */\n headerClassName?: string;\n /**\n * A rule under the header, the twin of the one over the actions row — for a tall or\n * full-screen body that scrolls under a header which stays. The body then starts a\n * step below the rule instead of flush against it.\n */\n headerDivider?: boolean;\n /**\n * The body. Optional: a dialog whose title, description and actions are the whole\n * of it (a \"you have unsynced changes\" question) leaves it out, and the frame then\n * renders no body at all rather than an empty padded one.\n */\n children?: ReactNode;\n}\n\n/**\n * A {@link Modal} with the frame every caller was writing by hand: a heading, an\n * optional description, an optional X, a body that scrolls, and an actions row that\n * does not.\n *\n * 34 dialogs across the two apps framed themselves — a heading with an id invented per\n * file (and spelt three ways), four visible type sizes for one thing, ten spellings of\n * one right-aligned button row — and the package's own feedback dialog shipped with no\n * accessible name at all. This makes the name unforgettable: the heading's id comes\n * from `useId()` and goes straight to `Modal`'s `labelledBy`, so a framed dialog cannot\n * announce as just \"dialog\", and two open instances cannot share an id.\n *\n * ## It wraps, it does not change `Modal`\n *\n * `Modal` keeps `labelledBy` and every existing caller compiles untouched. What the\n * frame changes is inside the panel: the panel becomes a flex column with no padding\n * of its own, and only the BODY scrolls. The panel's `max-h-full` is still the outer\n * bound, so a tall form keeps its heading and its Save button on screen instead of\n * scrolling them away with the fields. A caller's own `className` still wins (it is\n * tailwind-merged last), which is how a full-screen phone sheet is spelt:\n * `fullBleed className=\"h-[100dvh] max-w-full rounded-none md:h-auto md:rounded-lg\"`.\n *\n * ## Kept mounted\n *\n * `open` reaches the `Modal` like every other prop, so `<DialogFrame open={open} …>`\n * replaces the `{open && <DialogFrame …/>}` gate (kastlan's `FormModal` was only\n * that gate) and gains the exit a caller-driven close otherwise skips. See\n * {@link ModalProps.open}.\n *\n * ## What it is not\n *\n * Not `FullBleedDialog`: that is the phone's full-screen editor with its own `open`,\n * Back handling and a required X, and it already draws a frame of its own. And not a\n * form: submit handling, a pending label and close-on-success stay the caller's.\n * Focus lands on the panel, as `Modal` decides — not on the first field, so opening\n * does not pop a phone's keyboard; an `autoFocus` in the body overrides that from the\n * caller's side, and should be a decision rather than a habit.\n */\nexport function DialogFrame({\n title,\n description,\n headingAs: Heading = \"h2\",\n actions,\n headerActions,\n closeButton = false,\n closeLabel,\n bodyClassName,\n headerClassName,\n headerDivider = false,\n className,\n children,\n \"aria-describedby\": describedBy,\n ...modal\n}: DialogFrameProps) {\n const titleId = useId();\n const descriptionId = useId();\n const hasDescription = description !== undefined && description !== null;\n // `false` too, so `{cond && <Body/>}` with a false `cond` means \"no body\".\n const hasBody = children !== undefined && children !== null && children !== false;\n\n return (\n <Modal\n {...modal}\n labelledBy={titleId}\n // The caller's own description (a warning inside the body, say) is ADDED to the\n // frame's, not traded for it: both are the dialog's.\n aria-describedby={[hasDescription ? descriptionId : undefined, describedBy].filter(Boolean).join(\" \") || undefined}\n // `overflow-hidden` replaces the panel's own `overflow-y-auto` (tailwind-merge\n // treats them as one group), `p-0` its `p-4`: the scroller and the padding move\n // to the body, which is the only part that should move.\n className={cn(\"flex flex-col overflow-hidden p-0\", className)}\n >\n <div\n className={cn(\n // `last:pb-4`: a frame with neither body nor actions closes on its header.\n \"flex shrink-0 items-start justify-between gap-2 px-4 pt-4 pb-3 last:pb-4\",\n headerDivider && \"border-b border-[var(--border)]\",\n headerClassName,\n )}\n >\n {/* Title and header actions share a wrapping row of their own, so it is THEY\n that wrap on a phone — the actions drop under a title that needs its 12rem —\n while the X stays outside it, pinned to the top-end corner. */}\n <div className=\"flex min-w-0 flex-1 flex-wrap items-start justify-between gap-x-3 gap-y-2\">\n <div className=\"min-w-0 grow basis-48\">\n <Heading id={titleId} className=\"text-lg font-semibold leading-snug text-[var(--text-primary)]\">\n {title}\n </Heading>\n {hasDescription && (\n <p id={descriptionId} className=\"mt-0.5 text-sm text-[var(--text-muted)]\">\n {description}\n </p>\n )}\n </div>\n {headerActions !== undefined && headerActions !== null && headerActions !== false && (\n <FrameHeaderActions actions={headerActions} onClose={modal.onClose} />\n )}\n </div>\n {closeButton && <FrameClose label={closeLabel} onClose={modal.onClose} />}\n </div>\n {hasBody && (\n <div\n className={cn(\n // `min-h-0` is what lets a flex child shrink below its content and scroll;\n // `last:pb-4` closes a frame that has no actions row under it.\n \"min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 pb-3 last:pb-4\",\n headerDivider && \"pt-3\",\n bodyClassName,\n )}\n >\n {children}\n </div>\n )}\n {actions !== undefined && actions !== null && (\n <FrameActions actions={actions} onClose={modal.onClose} divider={hasBody} />\n )}\n </Modal>\n );\n}\n\n/** The X. A component of its own so it can read the panel's animated close, which\n * only exists INSIDE the `Modal` (the frame's own body runs outside it). */\nfunction FrameClose({ label, onClose }: { label?: string; onClose: () => void }) {\n const close = useContext(ModalCloseContext) ?? onClose;\n const labels = useKitLabels(\"dialogFrame\", DEFAULT_DIALOG_FRAME_LABELS, label === undefined ? undefined : { close: label });\n return (\n <button\n type=\"button\"\n onClick={close}\n aria-label={labels.close}\n className={cn(\"-me-1.5 -mt-1 shrink-0 rounded p-1.5 text-[var(--text-muted)] outline-none hover:bg-[var(--bg-hover)] hover:text-[var(--text-secondary)]\", FOCUS_RING)}\n >\n <X aria-hidden className=\"size-5\" />\n </button>\n );\n}\n\n/** The header's own controls; a component for the same reason as {@link FrameClose}. */\nfunction FrameHeaderActions({\n actions,\n onClose,\n}: {\n actions: NonNullable<DialogFrameProps[\"headerActions\"]>;\n onClose: () => void;\n}) {\n const close = useContext(ModalCloseContext) ?? onClose;\n return (\n <div data-dialog-header-actions=\"\" className=\"flex shrink-0 flex-wrap items-center gap-2\">\n {typeof actions === \"function\" ? actions(close) : actions}\n </div>\n );\n}\n\nfunction FrameActions({\n actions,\n onClose,\n divider,\n}: {\n actions: NonNullable<DialogFrameProps[\"actions\"]>;\n onClose: () => void;\n /** Off when there is no body: nothing scrolls, so there is no edge to mark, and a\n * rule straight under the description would cut the question from its answers. */\n divider: boolean;\n}) {\n const close = useContext(ModalCloseContext) ?? onClose;\n return (\n // The border marks where the scrolling stops; `flex-wrap` keeps three long\n // translated labels on a phone from pushing the row wider than the sheet.\n <div\n className={cn(\n \"flex shrink-0 flex-wrap items-center justify-end gap-2 px-4 py-3\",\n divider && \"border-t border-[var(--border)]\",\n )}\n >\n {typeof actions === \"function\" ? actions(close) : actions}\n </div>\n );\n}\n"],"mappings":";AAwKU,SACE,KADF;AAxKV,SAAS,YAAY,aAAa;AAElC,SAAS,SAAS;AAElB,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAC3B,SAAS,OAAO,yBAAyB;AAEzC,SAAS,oBAAoB;AAOtB,MAAM,8BAAiD,EAAE,OAAO,QAAQ;AA2GxE,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA,WAAW,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA,oBAAoB;AAAA,EACpB,GAAG;AACL,GAAqB;AACnB,QAAM,UAAU,MAAM;AACtB,QAAM,gBAAgB,MAAM;AAC5B,QAAM,iBAAiB,gBAAgB,UAAa,gBAAgB;AAEpE,QAAM,UAAU,aAAa,UAAa,aAAa,QAAQ,aAAa;AAE5E,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,YAAY;AAAA,MAGZ,oBAAkB,CAAC,iBAAiB,gBAAgB,QAAW,WAAW,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,KAAK;AAAA,MAIzG,WAAW,GAAG,qCAAqC,SAAS;AAAA,MAE5D;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,WAAW;AAAA;AAAA,cAET;AAAA,cACA,iBAAiB;AA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,KAAK,IAAI,SACpD;AAEJ;AAEA,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AACF,GAMG;AACD,QAAM,QAAQ,WAAW,iBAAiB,KAAK;AAC/C;AAAA;AAAA;AAAA,IAGE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA,WAAW;AAAA,QACb;AAAA,QAEC,iBAAO,YAAY,aAAa,QAAQ,KAAK,IAAI;AAAA;AAAA,IACpD;AAAA;AAEJ;","names":[]}
@@ -3,6 +3,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useId, useState } from "react";
4
4
  import { ChevronDown } from "lucide-react";
5
5
  import { cn } from "../lib/cn.js";
6
+ import { FOCUS_RING } from "./focus-ring.js";
6
7
  import { prefersReducedMotion } from "../hooks/use-close-transition.js";
7
8
  const COLLAPSE_MS = 200;
8
9
  function Collapse({ open, keepMounted = false, children, className, style, ...rest }) {
@@ -99,10 +100,10 @@ function Disclosure({
99
100
  // card's hover paint on the stretched area / the row, not the text box.
100
101
  cn(
101
102
  "min-w-0 flex-1 after:absolute after:inset-0 after:content-['']",
102
- "focus-visible:after:ring-2 focus-visible:after:ring-inset focus-visible:after:ring-[var(--brand)]",
103
+ "focus-visible:after:ring-[length:var(--focus-ring-width)] focus-visible:after:ring-inset focus-visible:after:ring-[var(--brand)]",
103
104
  card ? cn("after:rounded-lg", joined && "after:rounded-b-none") : !menu && "after:rounded-sm"
104
105
  )
105
- ) : "focus-visible:ring-2 focus-visible:ring-[var(--brand)]",
106
+ ) : FOCUS_RING,
106
107
  card ? cn(
107
108
  "items-center justify-between rounded-lg p-4",
108
109
  trailingBeside ? "pe-0" : "hover:bg-[var(--bg-hover)] focus-visible:ring-inset",
@@ -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// Read at the moment of closing, as `useCloseTransition` does: the setting can change\n// under a long-lived page.\nimport { prefersReducedMotion } from \"../hooks/use-close-transition\";\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/**\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 * `menu` is a row of a `HoverMenu`: the top bar's menu-item look\n * (`TOPBAR_MENU_ITEM_CLASS` — full-width, `px-3 py-2`, regular weight, square, the\n * hover wash with the text colour left alone), an INSET focus ring so the menu's\n * clipping edge cannot cut it off, the chevron at the end (`chevronPosition`\n * defaults to `end` here) and a body with no padding of its own, so the sub-list's\n * rows sit flush like the rows around them. keksdose's account menu opens its\n * language sub-list this way, and on `bare` it took four header overrides and a\n * body one to get there (account-menu.tsx).\n */\n variant?: \"card\" | \"bare\" | \"menu\";\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. A `menu` defaults to `end`, like the menu rows around it.\n *\n * `after-title` sits it right after the title's text, pointing down and turning up —\n * \"Net profit ⌄ ······ 1,234.50\", Lenkbank's result rows, where the far end of the\n * row belongs to a figure (see {@link trailingInTrigger}) and a leading chevron\n * would push every label off the column the non-expandable rows' labels start on.\n * Not a card's: its chevron keeps the end.\n */\n chevronPosition?: \"start\" | \"end\" | \"after-title\";\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 * Unless {@link trailingInTrigger} is set, which moves it INTO the button.\n */\n trailing?: ReactNode;\n /**\n * Render {@link trailing} inside the header button instead of beside it, so the\n * whole row — figure included — is one click target and the figure is part of the\n * button's accessible name: \"Net profit 1,234.50, collapsed\" rather than a button\n * called \"Net profit\" next to an unexplained number.\n *\n * Lenkbank's result rows (features/steering/results-panel.tsx) are the case: label,\n * chevron, and the value at the far end, all one `<button>`, because a result row\n * has nothing else it could mean.\n *\n * ⚠️ Only for NON-interactive content — a count, a figure, a status chip. A button\n * may not contain another interactive element; an action belongs in the default,\n * sibling `trailing`. The content is rendered in a `<span>`, so keep it phrasing\n * content too (no `div`s).\n */\n trailingInTrigger?: boolean;\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 * It is an IDREF LIST, as `aria-controls` is: several space-separated ids when what\n * folds is several elements — a budget group's category rows, each its own `<li>`,\n * siblings of this header (keksdose's budget-mobile-list joins their ids with\n * `\" \"`). It may be the EMPTY string: trigger-only mode with nothing to point at yet\n * (a group whose rows are all filtered away, rows that are not rendered while shut).\n * The header then carries no `aria-controls` at all rather than an empty one, and\n * still toggles.\n *\n * A table's leading row — keksdose's \"Upcoming\" toggle over the scheduled rows of\n * its transactions table — is this mode too: the rows it folds are the TABLE's, so\n * the disclosure is only the header, and the table renders or drops them from the\n * same state.\n *\n * ```tsx\n * <DataTable\n * rows={showFuture ? [...scheduled, ...posted] : posted}\n * leadingRow={\n * <Disclosure\n * variant=\"bare\"\n * title={upcomingLabel}\n * open={showFuture}\n * onOpenChange={setShowFuture}\n * // The scheduled rows' ids while they are rendered; \"\" while they are not.\n * controls={showFuture ? scheduled.map((tx) => `row-s${tx.id}`).join(\" \") : \"\"}\n * headerClassName=\"px-3 py-2\"\n * />\n * }\n * …\n * />\n * ```\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,\n headingAs: Heading,\n keepMounted,\n disabled,\n headerClassName,\n triggerProps,\n bodyClassName,\n trailing,\n trailingInTrigger = false,\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 menu = variant === \"menu\";\n // The card's chevron trails always; a menu row's unless asked otherwise; a bare\n // one only when asked to.\n const chevronAt = card ? \"end\" : (chevronPosition ?? (menu ? \"end\" : \"start\"));\n const chevronAtEnd = chevronAt === \"end\";\n const chevronAfterTitle = chevronAt === \"after-title\";\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 // `trailing` beside the button, which then stretches under it; inside the button,\n // the row is simply the button.\n const trailingInside = hasTrailing && trailingInTrigger;\n const trailingBeside = hasTrailing && !trailingInTrigger;\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 // `||`: an empty `controls` is trigger-only with nothing to name, not `aria-controls=\"\"`.\n aria-controls={triggerOnly ? controls || undefined : 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 trailingBeside\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\") : !menu && \"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 trailingBeside ? \"pe-0\" : \"hover:bg-[var(--bg-hover)] focus-visible:ring-inset\",\n joined && \"rounded-b-none\",\n )\n : menu\n ? // TOPBAR_MENU_ITEM_CLASS's row, spelled out rather than imported: a\n // component does not reach up into the shell. A test holds the two to\n // the same classes.\n \"items-center justify-between gap-3 px-3 py-2 text-sm text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] focus-visible:ring-inset\"\n : \"items-center rounded-sm text-sm font-medium text-[var(--text-secondary)] hover:text-[var(--text-primary)]\",\n headerClassName,\n )}\n >\n {chevronAt === \"start\" && <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 {chevronAfterTitle ? (\n // The chevron hugs the text, however long the translation: the text wraps\n // before the chevron is pushed away from it.\n <span className=\"flex items-center gap-1\">\n <span className=\"min-w-0\">{title}</span>\n <Chevron open={open} small />\n </span>\n ) : (\n <span className={cn(\"block\", card && \"text-sm font-semibold text-[var(--text-primary)]\")}>{title}</span>\n )}\n {hint !== undefined && (\n <span className=\"mt-0.5 block text-xs font-normal text-[var(--text-muted)]\">{hint}</span>\n )}\n </span>\n {/* The space is for the accessible name — \"Net profit 1,234.50\", not\n \"Net profit1,234.50\"; between flex items it renders as nothing. */}\n {trailingInside && \" \"}\n {trailingInside && (\n <span data-disclosure-trailing=\"\" className=\"flex shrink-0 items-center gap-2\">\n {trailing}\n </span>\n )}\n {chevronAtEnd && !trailingBeside && <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={trailingBeside ? \"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 {trailingBeside ? (\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\" : !menu && \"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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AAA,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":[]}
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\";\nimport { FOCUS_RING } from \"./focus-ring\";\n// Read at the moment of closing, as `useCloseTransition` does: the setting can change\n// under a long-lived page.\nimport { prefersReducedMotion } from \"../hooks/use-close-transition\";\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/**\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 * `menu` is a row of a `HoverMenu`: the top bar's menu-item look\n * (`TOPBAR_MENU_ITEM_CLASS` — full-width, `px-3 py-2`, regular weight, square, the\n * hover wash with the text colour left alone), an INSET focus ring so the menu's\n * clipping edge cannot cut it off, the chevron at the end (`chevronPosition`\n * defaults to `end` here) and a body with no padding of its own, so the sub-list's\n * rows sit flush like the rows around them. keksdose's account menu opens its\n * language sub-list this way, and on `bare` it took four header overrides and a\n * body one to get there (account-menu.tsx).\n */\n variant?: \"card\" | \"bare\" | \"menu\";\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. A `menu` defaults to `end`, like the menu rows around it.\n *\n * `after-title` sits it right after the title's text, pointing down and turning up —\n * \"Net profit ⌄ ······ 1,234.50\", Lenkbank's result rows, where the far end of the\n * row belongs to a figure (see {@link trailingInTrigger}) and a leading chevron\n * would push every label off the column the non-expandable rows' labels start on.\n * Not a card's: its chevron keeps the end.\n */\n chevronPosition?: \"start\" | \"end\" | \"after-title\";\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 * Unless {@link trailingInTrigger} is set, which moves it INTO the button.\n */\n trailing?: ReactNode;\n /**\n * Render {@link trailing} inside the header button instead of beside it, so the\n * whole row — figure included — is one click target and the figure is part of the\n * button's accessible name: \"Net profit 1,234.50, collapsed\" rather than a button\n * called \"Net profit\" next to an unexplained number.\n *\n * Lenkbank's result rows (features/steering/results-panel.tsx) are the case: label,\n * chevron, and the value at the far end, all one `<button>`, because a result row\n * has nothing else it could mean.\n *\n * ⚠️ Only for NON-interactive content — a count, a figure, a status chip. A button\n * may not contain another interactive element; an action belongs in the default,\n * sibling `trailing`. The content is rendered in a `<span>`, so keep it phrasing\n * content too (no `div`s).\n */\n trailingInTrigger?: boolean;\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 * It is an IDREF LIST, as `aria-controls` is: several space-separated ids when what\n * folds is several elements — a budget group's category rows, each its own `<li>`,\n * siblings of this header (keksdose's budget-mobile-list joins their ids with\n * `\" \"`). It may be the EMPTY string: trigger-only mode with nothing to point at yet\n * (a group whose rows are all filtered away, rows that are not rendered while shut).\n * The header then carries no `aria-controls` at all rather than an empty one, and\n * still toggles.\n *\n * A table's leading row — keksdose's \"Upcoming\" toggle over the scheduled rows of\n * its transactions table — is this mode too: the rows it folds are the TABLE's, so\n * the disclosure is only the header, and the table renders or drops them from the\n * same state.\n *\n * ```tsx\n * <DataTable\n * rows={showFuture ? [...scheduled, ...posted] : posted}\n * leadingRow={\n * <Disclosure\n * variant=\"bare\"\n * title={upcomingLabel}\n * open={showFuture}\n * onOpenChange={setShowFuture}\n * // The scheduled rows' ids while they are rendered; \"\" while they are not.\n * controls={showFuture ? scheduled.map((tx) => `row-s${tx.id}`).join(\" \") : \"\"}\n * headerClassName=\"px-3 py-2\"\n * />\n * }\n * …\n * />\n * ```\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,\n headingAs: Heading,\n keepMounted,\n disabled,\n headerClassName,\n triggerProps,\n bodyClassName,\n trailing,\n trailingInTrigger = false,\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 menu = variant === \"menu\";\n // The card's chevron trails always; a menu row's unless asked otherwise; a bare\n // one only when asked to.\n const chevronAt = card ? \"end\" : (chevronPosition ?? (menu ? \"end\" : \"start\"));\n const chevronAtEnd = chevronAt === \"end\";\n const chevronAfterTitle = chevronAt === \"after-title\";\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 // `trailing` beside the button, which then stretches under it; inside the button,\n // the row is simply the button.\n const trailingInside = hasTrailing && trailingInTrigger;\n const trailingBeside = hasTrailing && !trailingInTrigger;\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 // `||`: an empty `controls` is trigger-only with nothing to name, not `aria-controls=\"\"`.\n aria-controls={triggerOnly ? controls || undefined : 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 trailingBeside\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-[length:var(--focus-ring-width)] focus-visible:after:ring-inset focus-visible:after:ring-[var(--brand)]\",\n card ? cn(\"after:rounded-lg\", joined && \"after:rounded-b-none\") : !menu && \"after:rounded-sm\",\n )\n : FOCUS_RING,\n card\n ? cn(\n \"items-center justify-between rounded-lg p-4\",\n trailingBeside ? \"pe-0\" : \"hover:bg-[var(--bg-hover)] focus-visible:ring-inset\",\n joined && \"rounded-b-none\",\n )\n : menu\n ? // TOPBAR_MENU_ITEM_CLASS's row, spelled out rather than imported: a\n // component does not reach up into the shell. A test holds the two to\n // the same classes.\n \"items-center justify-between gap-3 px-3 py-2 text-sm text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] focus-visible:ring-inset\"\n : \"items-center rounded-sm text-sm font-medium text-[var(--text-secondary)] hover:text-[var(--text-primary)]\",\n headerClassName,\n )}\n >\n {chevronAt === \"start\" && <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 {chevronAfterTitle ? (\n // The chevron hugs the text, however long the translation: the text wraps\n // before the chevron is pushed away from it.\n <span className=\"flex items-center gap-1\">\n <span className=\"min-w-0\">{title}</span>\n <Chevron open={open} small />\n </span>\n ) : (\n <span className={cn(\"block\", card && \"text-sm font-semibold text-[var(--text-primary)]\")}>{title}</span>\n )}\n {hint !== undefined && (\n <span className=\"mt-0.5 block text-xs font-normal text-[var(--text-muted)]\">{hint}</span>\n )}\n </span>\n {/* The space is for the accessible name — \"Net profit 1,234.50\", not\n \"Net profit1,234.50\"; between flex items it renders as nothing. */}\n {trailingInside && \" \"}\n {trailingInside && (\n <span data-disclosure-trailing=\"\" className=\"flex shrink-0 items-center gap-2\">\n {trailing}\n </span>\n )}\n {chevronAtEnd && !trailingBeside && <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={trailingBeside ? \"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 {trailingBeside ? (\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\" : !menu && \"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":";AAuFM,cA+RI,YA/RJ;AAvFN,SAAS,WAAW,OAAO,gBAAgB;AAE3C,SAAS,mBAAmB;AAE5B,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAG3B,SAAS,4BAA4B;AAIrC,MAAM,cAAc;AA2Cb,SAAS,SAAS,EAAE,MAAM,cAAc,OAAO,UAAU,WAAW,OAAO,GAAG,KAAK,GAAkB;AAM1G,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,IAAI;AAC7C,MAAI,SAAS,UAAU;AACrB,gBAAY,IAAI;AAChB,iBAAa,CAAC,QAAQ,CAAC,qBAAqB,CAAC;AAAA,EAC/C;AACA,YAAU,MAAM;AACd,QAAI,CAAC,UAAW;AAChB,UAAM,QAAQ,WAAW,MAAM,aAAa,KAAK,GAAG,WAAW;AAC/D,WAAO,MAAM,aAAa,KAAK;AAAA,EACjC,GAAG,CAAC,SAAS,CAAC;AAEd,QAAM,UAAU,QAAQ,aAAa;AAErC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO,CAAC;AAAA,MACR,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MAGA,OAAO,EAAE,GAAG,OAAO,kBAAkB,OAAO,QAAQ,OAAO,YAAY,OAAO,YAAY,SAAS;AAAA,MAEnG;AAAA,QAAC;AAAA;AAAA,UACC,WAAW;AAAA,YACT;AAAA,YACA,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O,CAAC,MAAM;AAAA;AAAA;AAAA,QACtD,IAEA;AAAA,QAED,CAAC,eACA,oBAAC,YAAS,IAAI,QAAQ,MAAY,aAChC,8BAAC,SAAI,WAAW,GAAG,OAAO,wBAAwB,CAAC,QAAQ,kBAAkB,aAAa,GAAI,UAAS,GACzG;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":[]}
@@ -22,7 +22,7 @@ import { ComponentPropsWithoutRef, ReactNode, RefObject, KeyboardEvent } from 'r
22
22
  * while it is up, so the rule is the hook's rather than each caller's. `backCloses`
23
23
  * is for the ONE case where a second entry would be wrong: a caller whose panel is
24
24
  * itself a `PickerSheet`, which already registers one — both comboboxes swap shape at
25
- * {@link PHONE_QUERY}, and two entries would cost two Back presses to close one sheet.
25
+ * the phone layout (`usePhoneLayout()`), and two entries would cost two Back presses to close one sheet.
26
26
  *
27
27
  * ## One outside-click rule for the whole package
28
28
  *
@@ -7,6 +7,8 @@ import { useAnchoredPanel } from "../hooks/use-anchored-panel.js";
7
7
  import { useEscapeKey, useOutsideClick } from "../hooks/use-dismiss.js";
8
8
  import { useOverlayHistory } from "../hooks/use-overlay-history.js";
9
9
  import { cn } from "../lib/cn.js";
10
+ import { FIELD_TOUCH_TEXT } from "./ui.js";
11
+ import { FOCUS_RING } from "./focus-ring.js";
10
12
  import { useAnchorDir } from "./use-anchor-dir.js";
11
13
  function useDropdown({
12
14
  backCloses = true,
@@ -88,7 +90,11 @@ function DropdownSearchHeader({
88
90
  "aria-controls": listboxId,
89
91
  "aria-activedescendant": activeId,
90
92
  "aria-autocomplete": listboxId ? "list" : void 0,
91
- className: "w-full rounded-sm bg-transparent text-sm outline-none placeholder:text-[var(--text-placeholder)] text-[var(--text-primary)] focus-visible:ring-2 focus-visible:ring-[var(--brand)]"
93
+ className: cn(
94
+ "w-full rounded-sm bg-transparent text-sm outline-none placeholder:text-[var(--text-placeholder)] text-[var(--text-primary)]",
95
+ FOCUS_RING,
96
+ FIELD_TOUCH_TEXT
97
+ )
92
98
  }
93
99
  )
94
100
  ]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/dropdown.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport type {\n ComponentPropsWithoutRef,\n KeyboardEvent as ReactKeyboardEvent,\n ReactNode,\n RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Search } from \"lucide-react\";\nimport { useAnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { useEscapeKey, useOutsideClick } from \"../hooks/use-dismiss\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { cn } from \"../lib/cn\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\n\n/**\n * Open state + close-on-outside-click for the custom dropdowns (MultiSelect,\n * CurrencySelect, AmountInput's currency picker, Combobox). Attach `wrapperRef`\n * to the relatively-positioned container; the popover lives inside it so a click\n * anywhere else closes it.\n *\n * ## Back closes the list, not the page behind it\n *\n * Keksdose live #309 rework: *\"It shall only close it if it is prior open, and not\n * when I am seeing the dialog.\"* Round one wired {@link PickerSheet} — the shape\n * these lists take on a PHONE — into {@link useOverlayHistory}, and left the pointer\n * shape out. So on a desktop one Back press over an open list still went past it to\n * the dialog underneath: measured on his own budget, the transfer form's account list\n * was showing and Back took the entire add card, amount and all. That is the same\n * loss round one called *\"discarding an edit in progress in order to dismiss a\n * list\"*, in the other shell.\n *\n * Every dropdown built on this hook is dismissible and is the topmost thing on screen\n * while it is up, so the rule is the hook's rather than each caller's. `backCloses`\n * is for the ONE case where a second entry would be wrong: a caller whose panel is\n * itself a `PickerSheet`, which already registers one — both comboboxes swap shape at\n * {@link PHONE_QUERY}, and two entries would cost two Back presses to close one sheet.\n *\n * ## One outside-click rule for the whole package\n *\n * This hand-rolled a second document listener, on `mousedown`, months after\n * {@link useOutsideClick} — the hook the entity pickers dismiss through — was moved to\n * `pointerdown` for a reason that applies here word for word: on a touch platform\n * `mousedown` is SYNTHESISED, the browser emits it for most taps but is not obliged\n * to, and MultiSelect, CurrencySelect, GroupedPicker, AmountInput's currency picker\n * and both comboboxes all dismiss through this. Two copies of one rule is one copy\n * too many; this now delegates, so the package has a single answer to \"what is an\n * outside press\".\n *\n * `panelIsSheet` is what that delegation needs. A {@link PickerSheet} is modal and\n * fills the screen, so it has no outside — and being portalled to `<body>`, it is\n * inside neither `wrapperRef` nor `panelRef`, so a listener left running would read\n * every tap in it as a press outside and close it at finger-down. The sheet's own\n * `onMouseDown` stopPropagation guard used to hide that from this hook; it cannot\n * stop a `pointerdown`. It defaults to `!backCloses` because the two ask the same\n * question — \"is this caller's panel a sheet?\" — and the one caller that answers yes\n * already says so; they are separate props so a future caller can answer them apart.\n *\n * ## Escape, and where focus lands after it\n *\n * This hook had no Escape at all (the audit's §a11y): Back closed these lists, an\n * outside press closed them, and the one key every other dismissible surface in the\n * package answers to did nothing — so a keyboard user who opened a list had no way\n * out of it that did not also choose something. {@link useEscapeKey} is the listener\n * `Modal`, `Popover` and `useComboboxCore` already dismiss through, so the package\n * keeps one answer to \"what does Escape do\" rather than growing a fifth.\n *\n * Escape RESTORES FOCUS; an outside press does not. A press has already put focus\n * where the user pointed, and dragging it back from there would be the bug. Attach\n * `triggerRef` to the control that opens the panel and the keyboard paths — Escape,\n * Tab, a commit — hand focus back to it; leave it unattached and they simply close,\n * which is what the callers written before this get.\n */\nexport function useDropdown<T extends HTMLElement = HTMLDivElement>({\n backCloses = true,\n panelIsSheet = !backCloses,\n}: { backCloses?: boolean; panelIsSheet?: boolean } = {}) {\n const [open, setOpen] = useState(false);\n const wrapperRef = useRef<T>(null);\n // The control that opens the panel — see the note above on why only the keyboard\n // paths read it, and why attaching it is the caller's choice.\n const triggerRef = useRef<HTMLButtonElement>(null);\n // The panel, once it is PORTALLED (see {@link DropdownPanel}'s `anchorRef`): it is\n // then a child of <body> rather than of the wrapper, so \"did the click land inside\n // the wrapper\" answers no for every click on the list itself and the first option a\n // user picked closed the dropdown without picking anything.\n const panelRef = useRef<HTMLDivElement>(null);\n const close = useCallback(() => setOpen(false), []);\n // Closing unmounts whatever held focus — the search box, the row the keyboard was\n // on — and the browser then drops focus on <body>: the caret vanishes and the next\n // Tab restarts at the top of the document. Whoever closed the list with a key gets\n // it handed back to the trigger they opened it from.\n const closeToTrigger = useCallback(() => {\n setOpen(false);\n triggerRef.current?.focus();\n }, []);\n useOutsideClick([wrapperRef, panelRef], close, open && !panelIsSheet);\n useEscapeKey(closeToTrigger, open);\n // Same close path Escape and an outside click take, so a list dismissed by Back\n // cannot end up in a different state from one dismissed any other way.\n useOverlayHistory(open && backCloses, close);\n return { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger };\n}\n\n/**\n * {@link useDropdown} plus a search box: clears the query and focuses the search\n * input each time the panel opens, so typing filters immediately.\n */\nexport function useDropdownSearch<T extends HTMLElement = HTMLDivElement>() {\n const { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger } =\n useDropdown<T>();\n const [query, setQuery] = useState(\"\");\n const inputRef = useRef<HTMLInputElement>(null);\n useEffect(() => {\n if (open) {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- reset the query on open\n setQuery(\"\");\n requestAnimationFrame(() => inputRef.current?.focus());\n }\n }, [open]);\n return {\n open,\n setOpen,\n wrapperRef,\n panelRef,\n triggerRef,\n closeToTrigger,\n query,\n setQuery,\n inputRef,\n };\n}\n\n/** `onKeyDown` is the INPUT's, not the wrapper's — the list's keyboard is handled\n * where the focus is (see the note above), so the div's own handler signature is\n * omitted in favour of it. */\nexport interface DropdownSearchHeaderProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onKeyDown\"> {\n query: string;\n onQueryChange: (v: string) => void;\n inputRef: RefObject<HTMLInputElement | null>;\n placeholder?: string;\n /** The `<ul role=\"listbox\">` this box filters. */\n listboxId?: string;\n /** The id of the option the arrow keys are currently on, if any. */\n activeId?: string;\n /** Arrow/Home/End/Enter/Tab — the list's keyboard, handled where the focus is. */\n onKeyDown?: (e: ReactKeyboardEvent<HTMLInputElement>) => void;\n}\n\n/** The search row (magnifier + text input) shared by the searchable dropdowns.\n *\n * The input had `outline-none` and nothing in its place (the audit's §a11y, the same\n * finding as the numpad's keys). That mattered more here than the bare class suggests:\n * {@link useDropdownSearch} focuses this box the moment a panel opens, so the caret is\n * the ONLY evidence of where the next keystroke goes — and a caret in an empty field\n * showing a placeholder is a single blinking pixel column. The ring is what says \"this\n * list is being typed into\"; it appears whenever the field holds focus, which for a\n * text input is exactly when it is true.\n *\n * ## Why this box is a plain textbox and the TRIGGER is the combobox\n *\n * The panels this header sits in are opened by a field-shaped trigger, and that\n * trigger is what carries `role=\"combobox\"` (see {@link MultiSelect},\n * {@link EntityCombobox}). Two comboboxes for one list would be one too many — a\n * reader tabbing back to the field would meet a second one describing the same\n * choice. So this stays a textbox, which ARIA lets own `aria-activedescendant` and\n * `aria-controls` exactly as a combobox does: focus is HERE while the list is up, so\n * this is what has to say which option the arrow keys are on.\n *\n * Pass `listboxId` and the wiring appears; omit it and the box is what it always\n * was, for the callers that have no listbox to point at. */\nexport function DropdownSearchHeader({\n query,\n onQueryChange,\n inputRef,\n placeholder,\n listboxId,\n activeId,\n onKeyDown,\n \"aria-label\": ariaLabel,\n className,\n ...rest\n}: DropdownSearchHeaderProps) {\n return (\n // `rest` dresses the header row; the NAME goes on the box below it. A search\n // input whose only name is its placeholder has none the moment a character is\n // typed into it — the placeholder disappears — which is why this is worth a prop\n // at all rather than something a caller could add from outside.\n <div\n {...rest}\n className={cn(\n \"flex items-center gap-2 border-b border-[var(--border)] px-2 py-1.5\",\n className,\n )}\n >\n <Search className=\"size-4 text-[var(--text-placeholder)]\" />\n <input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={(e) => onQueryChange(e.target.value)}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n aria-label={ariaLabel}\n aria-controls={listboxId}\n aria-activedescendant={activeId}\n aria-autocomplete={listboxId ? \"list\" : undefined}\n className=\"w-full rounded-sm bg-transparent text-sm outline-none placeholder:text-[var(--text-placeholder)] text-[var(--text-primary)] focus-visible:ring-2 focus-visible:ring-[var(--brand)]\"\n />\n </div>\n );\n}\n\nexport interface DropdownPanelProps extends ComponentPropsWithoutRef<\"div\"> {\n header?: ReactNode;\n empty?: boolean;\n /** Attributes for the `<ul>` itself — how a caller whose children are options\n * gives the list its `role=\"listbox\"`, its id and `aria-multiselectable`. The\n * panel owns the scrolling and the padding, so `className` here is merged rather\n * than replaced. */\n listProps?: ComponentPropsWithoutRef<\"ul\">;\n /** The trigger to hang off. Given, the panel portals and goes `fixed`. */\n anchorRef?: RefObject<HTMLElement | null>;\n /** {@link useDropdown}'s `panelRef`, so an outside-click sees this as inside. */\n panelRef?: RefObject<HTMLDivElement | null>;\n /** Panel width in px, for the anchored form (the CSS `w-*` cannot be measured). */\n width?: number;\n /** Which of the panel's edges lines up with the trigger's, room permitting.\n * `start`/`end` follow the trigger's reading direction — `end` is the right edge\n * in a left-to-right form and the left one in a right-to-left form — and are what\n * the kit's own pickers pass; `left`/`right` stay physical. Default `end`, which\n * is the old `right` in a left-to-right page. */\n align?: \"left\" | \"right\" | \"start\" | \"end\";\n children: ReactNode;\n}\n\n/**\n * The floating popover surface for the searchable dropdowns: bordered/shadowed\n * panel, an optional `header` slot (search box, plus any actions), and a\n * scrollable `<ul>` of `children` with an \"empty\" row when nothing matches.\n *\n * ## Anchored, or merely absolute\n *\n * Without `anchorRef` the panel is `position: absolute` inside whatever relative box\n * the caller put it in, and the caller places it with `className` (`w-64`,\n * `end-0 top-full`). That is fine in a page that does not scroll around it, and\n * wrong the moment an ancestor has `overflow` — the panel is then CLIPPED by that\n * ancestor's box, with no error and no scrollbar, just a list with its side sliced\n * off. Keksdose dev#548 is what that looks like in practice: the app's own content\n * scroller starts 280px from the left, the amount field's currency picker opens\n * right-aligned and 256px wide, and in the transaction row editor its left third —\n * the search box's first letter, and every row's currency symbol — was cut away.\n *\n * With `anchorRef` the panel is PORTALLED to `<body>` and positioned `fixed` against\n * that trigger's rect, so no ancestor can clip it: the same treatment {@link Popover}\n * already gives the calculator, and the same reason. It re-aligns on scroll and\n * resize, flips above the trigger when the room is there instead (a phone keyboard\n * eats the bottom of the screen), and is clamped to the viewport's edges so a trigger\n * near either side cannot push it off-screen.\n *\n * Pass `panelRef` from {@link useDropdown} along with it: once portalled the panel is\n * no longer inside the wrapper, so the outside-click handler has to be told about it\n * or the first click on an option closes the list instead of choosing from it.\n */\nexport function DropdownPanel({\n header,\n empty,\n className,\n listProps,\n anchorRef,\n panelRef,\n width = 256,\n align = \"end\",\n children,\n style,\n ...rest\n}: DropdownPanelProps) {\n const anchored = useAnchoredPanel(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n const dir = useAnchorDir(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n const body = (\n <>\n {header}\n {/* The anchored form caps its own height against the VISIBLE viewport and lets\n this list have the rest; the absolute form keeps the fixed `max-h-64` it has\n always had, applied by the wrapper below. */}\n <ul {...listProps} className={cn(\"overflow-y-auto py-1\", listProps?.className)}>\n {children}\n {/* `presentation`, so that a caller who made this list a `listbox` does not\n end up with one child that is not an option. The em dash still reads — it\n is the row's semantics that are dropped, not its text. */}\n {empty && (\n <li role=\"presentation\" className=\"px-3 py-2 text-sm text-[var(--text-muted)]\">\n —\n </li>\n )}\n </ul>\n </>\n );\n\n if (!anchorRef) {\n return (\n <div\n {...rest}\n style={style}\n ref={panelRef}\n className={cn(\n \"absolute z-30 mt-1 rounded-md border border-[var(--border)] bg-[var(--bg-surface)] shadow-lg\",\n \"[&>ul]:max-h-64\",\n className,\n )}\n >\n {body}\n </div>\n );\n }\n\n const rect = anchored.rect;\n if (!rect) return null;\n // Clamped exactly as `Popover` clamps: the panel may leave the trigger's edge to\n // stay on screen, because a list half off the viewport is the bug this exists for.\n // The portal leaves the subtree the trigger's `dir` came from, so it is read off\n // the trigger — for the alignment here, and for the panel's own `dir` below,\n // without which a right-to-left form got a left-to-right list.\n const physical =\n align === \"start\" ? (dir === \"rtl\" ? \"right\" : \"left\") : align === \"end\" ? (dir === \"rtl\" ? \"left\" : \"right\") : align;\n const wanted = physical === \"right\" ? rect.right - width : rect.left;\n const left = Math.min(Math.max(8, wanted), window.innerWidth - width - 8);\n return createPortal(\n <div\n {...rest}\n ref={panelRef}\n dir={dir}\n // The caller's `style` is kept underneath, but the placement is measured rather\n // than chosen (dev#548: an `overflow` ancestor clipped a third of this panel\n // away), so those five values are the panel's own.\n style={{ ...style, position: \"fixed\", top: anchored.top, left, width, maxHeight: anchored.maxHeight }}\n className={cn(\n \"z-50 flex flex-col overflow-hidden rounded-md border border-[var(--border)] bg-[var(--bg-surface)] shadow-lg\",\n // The list, not the panel, is what scrolls: the search header has to stay put\n // while the options move under it.\n \"[&>ul]:min-h-0 [&>ul]:flex-1\",\n className,\n )}\n >\n {body}\n </div>,\n document.body,\n );\n}\n\n/** A ref that is always null, for the un-anchored form — hooks may not be conditional. */\nconst EMPTY_REF: RefObject<HTMLElement | null> = { current: null };\n"],"mappings":";AA6LI,SA4FA,UArFE,KAPF;AA7LJ,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAOzD,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,wBAAwB;AACjC,SAAS,cAAc,uBAAuB;AAC9C,SAAS,yBAAyB;AAClC,SAAS,UAAU;AACnB,SAAS,oBAAoB;AA4DtB,SAAS,YAAoD;AAAA,EAClE,aAAa;AAAA,EACb,eAAe,CAAC;AAClB,IAAsD,CAAC,GAAG;AACxD,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AACtC,QAA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I,GAAG,MAAM,GAAG,OAAO,aAAa,QAAQ,CAAC;AACxE,SAAO;AAAA,IACL;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,KAAK;AAAA,QACL;AAAA,QAIA,OAAO,EAAE,GAAG,OAAO,UAAU,SAAS,KAAK,SAAS,KAAK,MAAM,OAAO,WAAW,SAAS,UAAU;AAAA,QACpG,WAAW;AAAA,UACT;AAAA;AAAA;AAAA,UAGA;AAAA,UACA;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAGA,MAAM,YAA2C,EAAE,SAAS,KAAK;","names":[]}
1
+ {"version":3,"sources":["../../src/components/dropdown.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport type {\n ComponentPropsWithoutRef,\n KeyboardEvent as ReactKeyboardEvent,\n ReactNode,\n RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Search } from \"lucide-react\";\nimport { useAnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { useEscapeKey, useOutsideClick } from \"../hooks/use-dismiss\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { cn } from \"../lib/cn\";\nimport { FIELD_TOUCH_TEXT } from \"./ui\";\nimport { FOCUS_RING } from \"./focus-ring\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\n\n/**\n * Open state + close-on-outside-click for the custom dropdowns (MultiSelect,\n * CurrencySelect, AmountInput's currency picker, Combobox). Attach `wrapperRef`\n * to the relatively-positioned container; the popover lives inside it so a click\n * anywhere else closes it.\n *\n * ## Back closes the list, not the page behind it\n *\n * Keksdose live #309 rework: *\"It shall only close it if it is prior open, and not\n * when I am seeing the dialog.\"* Round one wired {@link PickerSheet} — the shape\n * these lists take on a PHONE — into {@link useOverlayHistory}, and left the pointer\n * shape out. So on a desktop one Back press over an open list still went past it to\n * the dialog underneath: measured on his own budget, the transfer form's account list\n * was showing and Back took the entire add card, amount and all. That is the same\n * loss round one called *\"discarding an edit in progress in order to dismiss a\n * list\"*, in the other shell.\n *\n * Every dropdown built on this hook is dismissible and is the topmost thing on screen\n * while it is up, so the rule is the hook's rather than each caller's. `backCloses`\n * is for the ONE case where a second entry would be wrong: a caller whose panel is\n * itself a `PickerSheet`, which already registers one — both comboboxes swap shape at\n * the phone layout (`usePhoneLayout()`), and two entries would cost two Back presses to close one sheet.\n *\n * ## One outside-click rule for the whole package\n *\n * This hand-rolled a second document listener, on `mousedown`, months after\n * {@link useOutsideClick} — the hook the entity pickers dismiss through — was moved to\n * `pointerdown` for a reason that applies here word for word: on a touch platform\n * `mousedown` is SYNTHESISED, the browser emits it for most taps but is not obliged\n * to, and MultiSelect, CurrencySelect, GroupedPicker, AmountInput's currency picker\n * and both comboboxes all dismiss through this. Two copies of one rule is one copy\n * too many; this now delegates, so the package has a single answer to \"what is an\n * outside press\".\n *\n * `panelIsSheet` is what that delegation needs. A {@link PickerSheet} is modal and\n * fills the screen, so it has no outside — and being portalled to `<body>`, it is\n * inside neither `wrapperRef` nor `panelRef`, so a listener left running would read\n * every tap in it as a press outside and close it at finger-down. The sheet's own\n * `onMouseDown` stopPropagation guard used to hide that from this hook; it cannot\n * stop a `pointerdown`. It defaults to `!backCloses` because the two ask the same\n * question — \"is this caller's panel a sheet?\" — and the one caller that answers yes\n * already says so; they are separate props so a future caller can answer them apart.\n *\n * ## Escape, and where focus lands after it\n *\n * This hook had no Escape at all (the audit's §a11y): Back closed these lists, an\n * outside press closed them, and the one key every other dismissible surface in the\n * package answers to did nothing — so a keyboard user who opened a list had no way\n * out of it that did not also choose something. {@link useEscapeKey} is the listener\n * `Modal`, `Popover` and `useComboboxCore` already dismiss through, so the package\n * keeps one answer to \"what does Escape do\" rather than growing a fifth.\n *\n * Escape RESTORES FOCUS; an outside press does not. A press has already put focus\n * where the user pointed, and dragging it back from there would be the bug. Attach\n * `triggerRef` to the control that opens the panel and the keyboard paths — Escape,\n * Tab, a commit — hand focus back to it; leave it unattached and they simply close,\n * which is what the callers written before this get.\n */\nexport function useDropdown<T extends HTMLElement = HTMLDivElement>({\n backCloses = true,\n panelIsSheet = !backCloses,\n}: { backCloses?: boolean; panelIsSheet?: boolean } = {}) {\n const [open, setOpen] = useState(false);\n const wrapperRef = useRef<T>(null);\n // The control that opens the panel — see the note above on why only the keyboard\n // paths read it, and why attaching it is the caller's choice.\n const triggerRef = useRef<HTMLButtonElement>(null);\n // The panel, once it is PORTALLED (see {@link DropdownPanel}'s `anchorRef`): it is\n // then a child of <body> rather than of the wrapper, so \"did the click land inside\n // the wrapper\" answers no for every click on the list itself and the first option a\n // user picked closed the dropdown without picking anything.\n const panelRef = useRef<HTMLDivElement>(null);\n const close = useCallback(() => setOpen(false), []);\n // Closing unmounts whatever held focus — the search box, the row the keyboard was\n // on — and the browser then drops focus on <body>: the caret vanishes and the next\n // Tab restarts at the top of the document. Whoever closed the list with a key gets\n // it handed back to the trigger they opened it from.\n const closeToTrigger = useCallback(() => {\n setOpen(false);\n triggerRef.current?.focus();\n }, []);\n useOutsideClick([wrapperRef, panelRef], close, open && !panelIsSheet);\n useEscapeKey(closeToTrigger, open);\n // Same close path Escape and an outside click take, so a list dismissed by Back\n // cannot end up in a different state from one dismissed any other way.\n useOverlayHistory(open && backCloses, close);\n return { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger };\n}\n\n/**\n * {@link useDropdown} plus a search box: clears the query and focuses the search\n * input each time the panel opens, so typing filters immediately.\n */\nexport function useDropdownSearch<T extends HTMLElement = HTMLDivElement>() {\n const { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger } =\n useDropdown<T>();\n const [query, setQuery] = useState(\"\");\n const inputRef = useRef<HTMLInputElement>(null);\n useEffect(() => {\n if (open) {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- reset the query on open\n setQuery(\"\");\n requestAnimationFrame(() => inputRef.current?.focus());\n }\n }, [open]);\n return {\n open,\n setOpen,\n wrapperRef,\n panelRef,\n triggerRef,\n closeToTrigger,\n query,\n setQuery,\n inputRef,\n };\n}\n\n/** `onKeyDown` is the INPUT's, not the wrapper's — the list's keyboard is handled\n * where the focus is (see the note above), so the div's own handler signature is\n * omitted in favour of it. */\nexport interface DropdownSearchHeaderProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onKeyDown\"> {\n query: string;\n onQueryChange: (v: string) => void;\n inputRef: RefObject<HTMLInputElement | null>;\n placeholder?: string;\n /** The `<ul role=\"listbox\">` this box filters. */\n listboxId?: string;\n /** The id of the option the arrow keys are currently on, if any. */\n activeId?: string;\n /** Arrow/Home/End/Enter/Tab — the list's keyboard, handled where the focus is. */\n onKeyDown?: (e: ReactKeyboardEvent<HTMLInputElement>) => void;\n}\n\n/** The search row (magnifier + text input) shared by the searchable dropdowns.\n *\n * The input had `outline-none` and nothing in its place (the audit's §a11y, the same\n * finding as the numpad's keys). That mattered more here than the bare class suggests:\n * {@link useDropdownSearch} focuses this box the moment a panel opens, so the caret is\n * the ONLY evidence of where the next keystroke goes — and a caret in an empty field\n * showing a placeholder is a single blinking pixel column. The ring is what says \"this\n * list is being typed into\"; it appears whenever the field holds focus, which for a\n * text input is exactly when it is true.\n *\n * ## Why this box is a plain textbox and the TRIGGER is the combobox\n *\n * The panels this header sits in are opened by a field-shaped trigger, and that\n * trigger is what carries `role=\"combobox\"` (see {@link MultiSelect},\n * {@link EntityCombobox}). Two comboboxes for one list would be one too many — a\n * reader tabbing back to the field would meet a second one describing the same\n * choice. So this stays a textbox, which ARIA lets own `aria-activedescendant` and\n * `aria-controls` exactly as a combobox does: focus is HERE while the list is up, so\n * this is what has to say which option the arrow keys are on.\n *\n * Pass `listboxId` and the wiring appears; omit it and the box is what it always\n * was, for the callers that have no listbox to point at. */\nexport function DropdownSearchHeader({\n query,\n onQueryChange,\n inputRef,\n placeholder,\n listboxId,\n activeId,\n onKeyDown,\n \"aria-label\": ariaLabel,\n className,\n ...rest\n}: DropdownSearchHeaderProps) {\n return (\n // `rest` dresses the header row; the NAME goes on the box below it. A search\n // input whose only name is its placeholder has none the moment a character is\n // typed into it — the placeholder disappears — which is why this is worth a prop\n // at all rather than something a caller could add from outside.\n <div\n {...rest}\n className={cn(\n \"flex items-center gap-2 border-b border-[var(--border)] px-2 py-1.5\",\n className,\n )}\n >\n <Search className=\"size-4 text-[var(--text-placeholder)]\" />\n <input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={(e) => onQueryChange(e.target.value)}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n aria-label={ariaLabel}\n aria-controls={listboxId}\n aria-activedescendant={activeId}\n aria-autocomplete={listboxId ? \"list\" : undefined}\n // FIELD_TOUCH_TEXT: a search box is a field — at least 16 px on touch, or iOS zooms\n // the page the moment a picker opens and focuses it (§10.1).\n className={cn(\n \"w-full rounded-sm bg-transparent text-sm outline-none placeholder:text-[var(--text-placeholder)] text-[var(--text-primary)]\",\n FOCUS_RING,\n FIELD_TOUCH_TEXT,\n )}\n />\n </div>\n );\n}\n\nexport interface DropdownPanelProps extends ComponentPropsWithoutRef<\"div\"> {\n header?: ReactNode;\n empty?: boolean;\n /** Attributes for the `<ul>` itself — how a caller whose children are options\n * gives the list its `role=\"listbox\"`, its id and `aria-multiselectable`. The\n * panel owns the scrolling and the padding, so `className` here is merged rather\n * than replaced. */\n listProps?: ComponentPropsWithoutRef<\"ul\">;\n /** The trigger to hang off. Given, the panel portals and goes `fixed`. */\n anchorRef?: RefObject<HTMLElement | null>;\n /** {@link useDropdown}'s `panelRef`, so an outside-click sees this as inside. */\n panelRef?: RefObject<HTMLDivElement | null>;\n /** Panel width in px, for the anchored form (the CSS `w-*` cannot be measured). */\n width?: number;\n /** Which of the panel's edges lines up with the trigger's, room permitting.\n * `start`/`end` follow the trigger's reading direction — `end` is the right edge\n * in a left-to-right form and the left one in a right-to-left form — and are what\n * the kit's own pickers pass; `left`/`right` stay physical. Default `end`, which\n * is the old `right` in a left-to-right page. */\n align?: \"left\" | \"right\" | \"start\" | \"end\";\n children: ReactNode;\n}\n\n/**\n * The floating popover surface for the searchable dropdowns: bordered/shadowed\n * panel, an optional `header` slot (search box, plus any actions), and a\n * scrollable `<ul>` of `children` with an \"empty\" row when nothing matches.\n *\n * ## Anchored, or merely absolute\n *\n * Without `anchorRef` the panel is `position: absolute` inside whatever relative box\n * the caller put it in, and the caller places it with `className` (`w-64`,\n * `end-0 top-full`). That is fine in a page that does not scroll around it, and\n * wrong the moment an ancestor has `overflow` — the panel is then CLIPPED by that\n * ancestor's box, with no error and no scrollbar, just a list with its side sliced\n * off. Keksdose dev#548 is what that looks like in practice: the app's own content\n * scroller starts 280px from the left, the amount field's currency picker opens\n * right-aligned and 256px wide, and in the transaction row editor its left third —\n * the search box's first letter, and every row's currency symbol — was cut away.\n *\n * With `anchorRef` the panel is PORTALLED to `<body>` and positioned `fixed` against\n * that trigger's rect, so no ancestor can clip it: the same treatment {@link Popover}\n * already gives the calculator, and the same reason. It re-aligns on scroll and\n * resize, flips above the trigger when the room is there instead (a phone keyboard\n * eats the bottom of the screen), and is clamped to the viewport's edges so a trigger\n * near either side cannot push it off-screen.\n *\n * Pass `panelRef` from {@link useDropdown} along with it: once portalled the panel is\n * no longer inside the wrapper, so the outside-click handler has to be told about it\n * or the first click on an option closes the list instead of choosing from it.\n */\nexport function DropdownPanel({\n header,\n empty,\n className,\n listProps,\n anchorRef,\n panelRef,\n width = 256,\n align = \"end\",\n children,\n style,\n ...rest\n}: DropdownPanelProps) {\n const anchored = useAnchoredPanel(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n const dir = useAnchorDir(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n const body = (\n <>\n {header}\n {/* The anchored form caps its own height against the VISIBLE viewport and lets\n this list have the rest; the absolute form keeps the fixed `max-h-64` it has\n always had, applied by the wrapper below. */}\n <ul {...listProps} className={cn(\"overflow-y-auto py-1\", listProps?.className)}>\n {children}\n {/* `presentation`, so that a caller who made this list a `listbox` does not\n end up with one child that is not an option. The em dash still reads — it\n is the row's semantics that are dropped, not its text. */}\n {empty && (\n <li role=\"presentation\" className=\"px-3 py-2 text-sm text-[var(--text-muted)]\">\n —\n </li>\n )}\n </ul>\n </>\n );\n\n if (!anchorRef) {\n return (\n <div\n {...rest}\n style={style}\n ref={panelRef}\n className={cn(\n \"absolute z-30 mt-1 rounded-md border border-[var(--border)] bg-[var(--bg-surface)] shadow-lg\",\n \"[&>ul]:max-h-64\",\n className,\n )}\n >\n {body}\n </div>\n );\n }\n\n const rect = anchored.rect;\n if (!rect) return null;\n // Clamped exactly as `Popover` clamps: the panel may leave the trigger's edge to\n // stay on screen, because a list half off the viewport is the bug this exists for.\n // The portal leaves the subtree the trigger's `dir` came from, so it is read off\n // the trigger — for the alignment here, and for the panel's own `dir` below,\n // without which a right-to-left form got a left-to-right list.\n const physical =\n align === \"start\" ? (dir === \"rtl\" ? \"right\" : \"left\") : align === \"end\" ? (dir === \"rtl\" ? \"left\" : \"right\") : align;\n const wanted = physical === \"right\" ? rect.right - width : rect.left;\n const left = Math.min(Math.max(8, wanted), window.innerWidth - width - 8);\n return createPortal(\n <div\n {...rest}\n ref={panelRef}\n dir={dir}\n // The caller's `style` is kept underneath, but the placement is measured rather\n // than chosen (dev#548: an `overflow` ancestor clipped a third of this panel\n // away), so those five values are the panel's own.\n style={{ ...style, position: \"fixed\", top: anchored.top, left, width, maxHeight: anchored.maxHeight }}\n className={cn(\n \"z-50 flex flex-col overflow-hidden rounded-md border border-[var(--border)] bg-[var(--bg-surface)] shadow-lg\",\n // The list, not the panel, is what scrolls: the search header has to stay put\n // while the options move under it.\n \"[&>ul]:min-h-0 [&>ul]:flex-1\",\n className,\n )}\n >\n {body}\n </div>,\n document.body,\n );\n}\n\n/** A ref that is always null, for the un-anchored form — hooks may not be conditional. */\nconst EMPTY_REF: RefObject<HTMLElement | null> = { current: null };\n"],"mappings":";AA+LI,SAkGA,UA3FE,KAPF;AA/LJ,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAOzD,SAAS,o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;AAAA,QACA,KAAK;AAAA,QACL,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,QAAM,OAAO,SAAS;AACtB,MAAI,CAAC,KAAM,QAAO;AAMlB,QAAM,WACJ,UAAU,UAAW,QAAQ,QAAQ,UAAU,SAAU,UAAU,QAAS,QAAQ,QAAQ,SAAS,UAAW;AAClH,QAAM,SAAS,aAAa,UAAU,KAAK,QAAQ,QAAQ,KAAK;AAChE,QAAM,OAAO,KAAK,IAAI,KAAK,IAAI,GAAG,MAAM,GAAG,OAAO,aAAa,QAAQ,CAAC;AACxE,SAAO;AAAA,IACL;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,KAAK;AAAA,QACL;AAAA,QAIA,OAAO,EAAE,GAAG,OAAO,UAAU,SAAS,KAAK,SAAS,KAAK,MAAM,OAAO,WAAW,SAAS,UAAU;AAAA,QACpG,WAAW;AAAA,UACT;AAAA;AAAA;AAAA,UAGA;AAAA,UACA;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAGA,MAAM,YAA2C,EAAE,SAAS,KAAK;","names":[]}
@@ -6,18 +6,20 @@ import './series-chart-labels.js';
6
6
  import './toggle-legend.js';
7
7
  import './series-chart-ticks.js';
8
8
  import './series-chart-budget.js';
9
- import '../delete-account-setting-CpIhzxxZ.js';
9
+ import '../delete-account-setting-FLyJf-kZ.js';
10
10
  import './tooltip.js';
11
11
  import '../hooks/use-anchored-rect.js';
12
12
  import '../lib/clipping.js';
13
- import '../data-table-labels-DUELeXpa.js';
13
+ import '../data-table-labels-kpAAVi6g.js';
14
14
  import './data-table-sort.js';
15
15
  import './swipeable-row.js';
16
16
  import './mini-calendar.js';
17
17
  import './calendar-heatmap.js';
18
18
  import './popover.js';
19
+ import '../hooks/use-breakpoint.js';
19
20
  import './chip.js';
20
21
  import 'lucide-react';
22
+ import './field-parts.js';
21
23
  import './field-sync.js';
22
24
  import '../wizard/types.js';
23
25
  import '../tour/tour.js';
@@ -85,6 +87,9 @@ import '../admin/admin-parts.js';
85
87
  import '../admin/admin-action-log.js';
86
88
  import '../settings/settings-labels.js';
87
89
  import '../demo/demo-labels.js';
90
+ import './appearance-labels.js';
91
+ import '../theme/contrast.js';
92
+ import '../theme/text-size.js';
88
93
  import './reauth-dialog.js';
89
94
  import './server-wake.js';
90
95
  import '../lib/server-wake.js';
@@ -98,14 +103,17 @@ import './sign-chip.js';
98
103
  import './column-mapper.js';
99
104
  import '../lib/column-mapping.js';
100
105
  import '../lib/table-text.js';
101
- import './field-parts.js';
106
+ import './focus-ring.js';
107
+ import './chart-height.js';
102
108
 
103
109
  /** Which chart of a facing pair. Physical, like the axes: charts do not mirror in RTL. */
104
110
  type FacingSide = "left" | "right";
105
111
  /** The two sides, in the order the columns stand. */
106
112
  declare const FACING_SIDES: readonly FacingSide[];
107
113
  /** The whole band a facing y axis occupies: its ticks, and the strip the rotated title
108
- * is drawn in — whether or not this chart is the one that spends it. */
114
+ * is drawn in — whether or not this chart is the one that spends it. In px at Normal:
115
+ * it is also the right axis' declared `width`, which the chart scales with the text
116
+ * (see {@link facingHeadingPad} for a heading's). */
109
117
  declare function facingBand(tickWidth?: number): number;
110
118
  /**
111
119
  * The y axis of one chart of a facing pair.
@@ -126,7 +134,12 @@ declare function facingAxes({ side, title, format, tickWidth, domain, color, }:
126
134
  }): SeriesChartAxis[];
127
135
  /** What a column heading is padded by to sit over the PLOT rather than the column: the
128
136
  * axis band, on the side that column's axis stands on. Physical padding on purpose —
129
- * the chart under it does not flip in RTL, so neither may the heading's offset. */
130
- declare function facingHeadingPad(side: FacingSide, tickWidth?: number): Pick<CSSProperties, "paddingLeft" | "paddingRight">;
137
+ * the chart under it does not flip in RTL, so neither may the heading's offset.
138
+ *
139
+ * `scale` is the text size's (`useTextSize().scale`): the chart draws its bands that
140
+ * many times wider from Large up (docs/text-size-harmonization.md §10.10), so a heading
141
+ * passes the same factor to stay over its plot. Both sides by the same factor, as the
142
+ * chart does. */
143
+ declare function facingHeadingPad(side: FacingSide, tickWidth?: number, scale?: number): Pick<CSSProperties, "paddingLeft" | "paddingRight">;
131
144
 
132
145
  export { FACING_SIDES, type FacingSide, facingAxes, facingBand, facingHeadingPad };
@@ -28,8 +28,9 @@ function facingAxes({
28
28
  }
29
29
  return [{ id: DEFAULT_Y_AXIS, width: tickWidth, title, format, domain, color }];
30
30
  }
31
- function facingHeadingPad(side, tickWidth = AXIS_TICK_WIDTH) {
32
- return side === "left" ? { paddingLeft: facingBand(tickWidth) } : { paddingRight: facingBand(tickWidth) };
31
+ function facingHeadingPad(side, tickWidth = AXIS_TICK_WIDTH, scale = 1) {
32
+ const band = axisBandWidth(tickWidth, true, scale);
33
+ return side === "left" ? { paddingLeft: band } : { paddingRight: band };
33
34
  }
34
35
  export {
35
36
  FACING_SIDES,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/facing-pair.ts"],"sourcesContent":["// Two series charts side by side that are MIRROR IMAGES of each other — the two sides\n// of a symmetric system, read against each other — and the arithmetic that keeps their\n// plots the same width. Lifted out of lenkbank, where four hand-assembled copies of\n// these rules had already drifted apart.\n//\n// The rules:\n// * The ticks stand on the OUTSIDE: the left chart's on its left, the right chart's on\n// its right. The two plots meet in the middle with nothing between them, and neither\n// column of numbers stands between a picture and the one it is compared with.\n// * The quantity is named ONCE, on the left chart; the right title would be the same\n// words twice.\n// * The untitled right axis still RESERVES the title's strip. Reserve only what its\n// ticks need and its plot comes out `AXIS_TITLE_STRIP` px wider than its neighbour's\n// — inside one shared x window, the same abscissa then lands on different pixels.\n// * A heading sits over the PLOT, not over the column, padded by the axis band on the\n// side that column's axis stands on.\n//\n// Only the geometry is here. The grid the pair stands in — column widths, where the\n// legend goes, the chart height — is a screen's layout, and stays with the screen.\nimport type { CSSProperties } from \"react\";\nimport { DEFAULT_Y_AXIS } from \"./chart-zoom\";\nimport { AXIS_TICK_WIDTH, axisBandWidth, type SeriesChartAxis } from \"./series-chart\";\n\n/** Which chart of a facing pair. Physical, like the axes: charts do not mirror in RTL. */\nexport type FacingSide = \"left\" | \"right\";\n\n/** The two sides, in the order the columns stand. */\nexport const FACING_SIDES: readonly FacingSide[] = [\"left\", \"right\"];\n\n/** The whole band a facing y axis occupies: its ticks, and the strip the rotated title\n * is drawn in — whether or not this chart is the one that spends it. */\nexport function facingBand(tickWidth: number = AXIS_TICK_WIDTH): number {\n return axisBandWidth(tickWidth, true);\n}\n\n/**\n * The y axis of one chart of a facing pair.\n *\n * The left one carries the row's quantity and the ticks' own width; the right one has\n * no title, stands on the right and reserves the whole band, so the two plots come out\n * the same width. Both may be pinned to one `domain` — whether they are is a statement\n * about the measurement, so it is the caller's.\n */\nexport function facingAxes({\n side,\n title,\n format,\n tickWidth = AXIS_TICK_WIDTH,\n domain,\n color,\n}: {\n side: FacingSide;\n /** The row's quantity, with its unit. Drawn on the left chart only. */\n title: string;\n format?: (value: number) => string;\n tickWidth?: number;\n domain?: [number, number];\n color?: string;\n}): SeriesChartAxis[] {\n if (side === \"right\") {\n return [\n {\n id: DEFAULT_Y_AXIS,\n orientation: \"right\",\n width: facingBand(tickWidth),\n title: \"\",\n format,\n domain,\n color,\n },\n ];\n }\n return [{ id: DEFAULT_Y_AXIS, width: tickWidth, title, format, domain, color }];\n}\n\n/** What a column heading is padded by to sit over the PLOT rather than the column: the\n * axis band, on the side that column's axis stands on. Physical padding on purpose —\n * the chart under it does not flip in RTL, so neither may the heading's offset. */\nexport function facingHeadingPad(\n side: FacingSide,\n tickWidth: number = AXIS_TICK_WIDTH,\n): Pick<CSSProperties, \"paddingLeft\" | \"paddingRight\"> {\n return side === \"left\"\n ? { paddingLeft: facingBand(tickWidth) }\n : { paddingRight: facingBand(tickWidth) };\n}\n"],"mappings":";AAoBA,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB,qBAA2C;AAM9D,MAAM,eAAsC,CAAC,QAAQ,OAAO;AAI5D,SAAS,WAAW,YAAoB,iBAAyB;AACtE,SAAO,cAAc,WAAW,IAAI;AACtC;AAUO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AACF,GAQsB;AACpB,MAAI,SAAS,SAAS;AACpB,WAAO;AAAA,MACL;AAAA,QACE,IAAI;AAAA,QACJ,aAAa;AAAA,QACb,OAAO,WAAW,SAAS;AAAA,QAC3B,OAAO;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO,CAAC,EAAE,IAAI,gBAAgB,OAAO,WAAW,OAAO,QAAQ,QAAQ,MAAM,CAAC;AAChF;AAKO,SAAS,iBACd,MACA,YAAoB,iBACiC;AACrD,SAAO,SAAS,SACZ,EAAE,aAAa,WAAW,SAAS,EAAE,IACrC,EAAE,cAAc,WAAW,SAAS,EAAE;AAC5C;","names":[]}
1
+ {"version":3,"sources":["../../src/components/facing-pair.ts"],"sourcesContent":["// Two series charts side by side that are MIRROR IMAGES of each other — the two sides\n// of a symmetric system, read against each other — and the arithmetic that keeps their\n// plots the same width. Lifted out of lenkbank, where four hand-assembled copies of\n// these rules had already drifted apart.\n//\n// The rules:\n// * The ticks stand on the OUTSIDE: the left chart's on its left, the right chart's on\n// its right. The two plots meet in the middle with nothing between them, and neither\n// column of numbers stands between a picture and the one it is compared with.\n// * The quantity is named ONCE, on the left chart; the right title would be the same\n// words twice.\n// * The untitled right axis still RESERVES the title's strip. Reserve only what its\n// ticks need and its plot comes out `AXIS_TITLE_STRIP` px wider than its neighbour's\n// — inside one shared x window, the same abscissa then lands on different pixels.\n// * A heading sits over the PLOT, not over the column, padded by the axis band on the\n// side that column's axis stands on.\n//\n// Only the geometry is here. The grid the pair stands in — column widths, where the\n// legend goes, the chart height — is a screen's layout, and stays with the screen.\nimport type { CSSProperties } from \"react\";\nimport { DEFAULT_Y_AXIS } from \"./chart-zoom\";\nimport { AXIS_TICK_WIDTH, axisBandWidth, type SeriesChartAxis } from \"./series-chart\";\n\n/** Which chart of a facing pair. Physical, like the axes: charts do not mirror in RTL. */\nexport type FacingSide = \"left\" | \"right\";\n\n/** The two sides, in the order the columns stand. */\nexport const FACING_SIDES: readonly FacingSide[] = [\"left\", \"right\"];\n\n/** The whole band a facing y axis occupies: its ticks, and the strip the rotated title\n * is drawn in — whether or not this chart is the one that spends it. In px at Normal:\n * it is also the right axis' declared `width`, which the chart scales with the text\n * (see {@link facingHeadingPad} for a heading's). */\nexport function facingBand(tickWidth: number = AXIS_TICK_WIDTH): number {\n return axisBandWidth(tickWidth, true);\n}\n\n/**\n * The y axis of one chart of a facing pair.\n *\n * The left one carries the row's quantity and the ticks' own width; the right one has\n * no title, stands on the right and reserves the whole band, so the two plots come out\n * the same width. Both may be pinned to one `domain` — whether they are is a statement\n * about the measurement, so it is the caller's.\n */\nexport function facingAxes({\n side,\n title,\n format,\n tickWidth = AXIS_TICK_WIDTH,\n domain,\n color,\n}: {\n side: FacingSide;\n /** The row's quantity, with its unit. Drawn on the left chart only. */\n title: string;\n format?: (value: number) => string;\n tickWidth?: number;\n domain?: [number, number];\n color?: string;\n}): SeriesChartAxis[] {\n if (side === \"right\") {\n return [\n {\n id: DEFAULT_Y_AXIS,\n orientation: \"right\",\n width: facingBand(tickWidth),\n title: \"\",\n format,\n domain,\n color,\n },\n ];\n }\n return [{ id: DEFAULT_Y_AXIS, width: tickWidth, title, format, domain, color }];\n}\n\n/** What a column heading is padded by to sit over the PLOT rather than the column: the\n * axis band, on the side that column's axis stands on. Physical padding on purpose —\n * the chart under it does not flip in RTL, so neither may the heading's offset.\n *\n * `scale` is the text size's (`useTextSize().scale`): the chart draws its bands that\n * many times wider from Large up (docs/text-size-harmonization.md §10.10), so a heading\n * passes the same factor to stay over its plot. Both sides by the same factor, as the\n * chart does. */\nexport function facingHeadingPad(\n side: FacingSide,\n tickWidth: number = AXIS_TICK_WIDTH,\n scale = 1,\n): Pick<CSSProperties, \"paddingLeft\" | \"paddingRight\"> {\n const band = axisBandWidth(tickWidth, true, scale);\n return side === \"left\" ? { paddingLeft: band } : { paddingRight: band };\n}\n"],"mappings":";AAoBA,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB,qBAA2C;AAM9D,MAAM,eAAsC,CAAC,QAAQ,OAAO;AAM5D,SAAS,WAAW,YAAoB,iBAAyB;AACtE,SAAO,cAAc,WAAW,IAAI;AACtC;AAUO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AACF,GAQsB;AACpB,MAAI,SAAS,SAAS;AACpB,WAAO;AAAA,MACL;AAAA,QACE,IAAI;AAAA,QACJ,aAAa;AAAA,QACb,OAAO,WAAW,SAAS;AAAA,QAC3B,OAAO;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO,CAAC,EAAE,IAAI,gBAAgB,OAAO,WAAW,OAAO,QAAQ,QAAQ,MAAM,CAAC;AAChF;AAUO,SAAS,iBACd,MACA,YAAoB,iBACpB,QAAQ,GAC6C;AACrD,QAAM,OAAO,cAAc,WAAW,MAAM,KAAK;AACjD,SAAO,SAAS,SAAS,EAAE,aAAa,KAAK,IAAI,EAAE,cAAc,KAAK;AACxE;","names":[]}