@eifi1/ui-kit 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (397) hide show
  1. package/README.md +59 -34
  2. package/dist/chart.d.ts +3 -1
  3. package/dist/chart.js +2 -0
  4. package/dist/chart.js.map +1 -1
  5. package/dist/components/account-settings-labels.d.ts +105 -0
  6. package/dist/components/account-settings-labels.js +81 -0
  7. package/dist/components/account-settings-labels.js.map +1 -0
  8. package/dist/components/account-settings.d.ts +36 -52
  9. package/dist/components/account-settings.js +44 -8
  10. package/dist/components/account-settings.js.map +1 -1
  11. package/dist/components/amount-input.d.ts +40 -4
  12. package/dist/components/amount-input.js +50 -12
  13. package/dist/components/amount-input.js.map +1 -1
  14. package/dist/components/authed-image.d.ts +68 -0
  15. package/dist/components/authed-image.js +117 -0
  16. package/dist/components/authed-image.js.map +1 -0
  17. package/dist/components/breadcrumbs.d.ts +2 -1
  18. package/dist/components/breadcrumbs.js +5 -2
  19. package/dist/components/breadcrumbs.js.map +1 -1
  20. package/dist/components/bulk-action-bar.d.ts +10 -2
  21. package/dist/components/bulk-action-bar.js.map +1 -1
  22. package/dist/components/button-group.d.ts +51 -2
  23. package/dist/components/button-group.js +5 -1
  24. package/dist/components/button-group.js.map +1 -1
  25. package/dist/components/calculator.d.ts +15 -4
  26. package/dist/components/calendar-heatmap.d.ts +41 -3
  27. package/dist/components/calendar-heatmap.js +48 -7
  28. package/dist/components/calendar-heatmap.js.map +1 -1
  29. package/dist/components/chart.js +14 -8
  30. package/dist/components/chart.js.map +1 -1
  31. package/dist/components/chip.d.ts +2 -1
  32. package/dist/components/chip.js +26 -18
  33. package/dist/components/chip.js.map +1 -1
  34. package/dist/components/choice-card.d.ts +35 -3
  35. package/dist/components/choice-card.js +83 -25
  36. package/dist/components/choice-card.js.map +1 -1
  37. package/dist/components/combobox-core.d.ts +3 -1
  38. package/dist/components/combobox-core.js +18 -5
  39. package/dist/components/combobox-core.js.map +1 -1
  40. package/dist/components/combobox.d.ts +2 -2
  41. package/dist/components/combobox.js +31 -9
  42. package/dist/components/combobox.js.map +1 -1
  43. package/dist/components/copy-button.d.ts +51 -70
  44. package/dist/components/copy-button.js +1 -1
  45. package/dist/components/copy-button.js.map +1 -1
  46. package/dist/components/data-table-cells.d.ts +63 -0
  47. package/dist/components/data-table-cells.js +64 -0
  48. package/dist/components/data-table-cells.js.map +1 -0
  49. package/dist/components/data-table-filter-popover.d.ts +1 -1
  50. package/dist/components/data-table-filter-popover.js +8 -1
  51. package/dist/components/data-table-filter-popover.js.map +1 -1
  52. package/dist/components/data-table-filters.d.ts +1 -1
  53. package/dist/components/data-table-filters.js +31 -1
  54. package/dist/components/data-table-filters.js.map +1 -1
  55. package/dist/components/data-table-labels.d.ts +13 -0
  56. package/dist/components/data-table-labels.js +8 -1
  57. package/dist/components/data-table-labels.js.map +1 -1
  58. package/dist/components/data-table.d.ts +1 -1
  59. package/dist/components/data-table.js +125 -27
  60. package/dist/components/data-table.js.map +1 -1
  61. package/dist/components/date-picker.d.ts +3 -1
  62. package/dist/components/date-picker.js +15 -2
  63. package/dist/components/date-picker.js.map +1 -1
  64. package/dist/components/description-list.d.ts +23 -3
  65. package/dist/components/description-list.js +23 -3
  66. package/dist/components/description-list.js.map +1 -1
  67. package/dist/components/dialog-frame.d.ts +1 -0
  68. package/dist/components/entity-combobox.d.ts +1 -1
  69. package/dist/components/entity-combobox.js +40 -20
  70. package/dist/components/entity-combobox.js.map +1 -1
  71. package/dist/components/error-boundary.d.ts +281 -0
  72. package/dist/components/error-boundary.js +302 -0
  73. package/dist/components/error-boundary.js.map +1 -0
  74. package/dist/components/field-sync.js +90 -83
  75. package/dist/components/field-sync.js.map +1 -1
  76. package/dist/components/field.d.ts +30 -4
  77. package/dist/components/field.js +40 -17
  78. package/dist/components/field.js.map +1 -1
  79. package/dist/components/file-button.d.ts +50 -208
  80. package/dist/components/file-dropzone.d.ts +49 -2
  81. package/dist/components/floating-panel.d.ts +13 -4
  82. package/dist/components/floating-panel.js +7 -3
  83. package/dist/components/floating-panel.js.map +1 -1
  84. package/dist/components/form-actions.d.ts +53 -0
  85. package/dist/components/form-actions.js +98 -0
  86. package/dist/components/form-actions.js.map +1 -0
  87. package/dist/components/full-bleed-dialog.js +4 -0
  88. package/dist/components/full-bleed-dialog.js.map +1 -1
  89. package/dist/components/hover-menu.js +64 -56
  90. package/dist/components/hover-menu.js.map +1 -1
  91. package/dist/components/image-grid.d.ts +67 -0
  92. package/dist/components/image-grid.js +112 -0
  93. package/dist/components/image-grid.js.map +1 -0
  94. package/dist/components/lightbox.d.ts +104 -0
  95. package/dist/components/lightbox.js +229 -0
  96. package/dist/components/lightbox.js.map +1 -0
  97. package/dist/components/line-items.d.ts +114 -0
  98. package/dist/components/line-items.js +238 -0
  99. package/dist/components/line-items.js.map +1 -0
  100. package/dist/components/list.d.ts +37 -4
  101. package/dist/components/list.js +35 -14
  102. package/dist/components/list.js.map +1 -1
  103. package/dist/components/loading-state.d.ts +24 -0
  104. package/dist/components/loading-state.js +32 -0
  105. package/dist/components/loading-state.js.map +1 -0
  106. package/dist/components/menu-item.d.ts +2 -1
  107. package/dist/components/menu-item.js +5 -1
  108. package/dist/components/menu-item.js.map +1 -1
  109. package/dist/components/mini-calendar.d.ts +13 -1
  110. package/dist/components/mini-calendar.js +46 -2
  111. package/dist/components/mini-calendar.js.map +1 -1
  112. package/dist/components/modal.d.ts +20 -1
  113. package/dist/components/modal.js +26 -2
  114. package/dist/components/modal.js.map +1 -1
  115. package/dist/components/month-picker.d.ts +21 -1
  116. package/dist/components/month-picker.js +139 -26
  117. package/dist/components/month-picker.js.map +1 -1
  118. package/dist/components/multi-entity-combobox.d.ts +1 -1
  119. package/dist/components/multi-entity-combobox.js +42 -20
  120. package/dist/components/multi-entity-combobox.js.map +1 -1
  121. package/dist/components/nav-pills.d.ts +2 -1
  122. package/dist/components/nav-pills.js +5 -1
  123. package/dist/components/nav-pills.js.map +1 -1
  124. package/dist/components/number-field.d.ts +24 -5
  125. package/dist/components/number-field.js +5 -7
  126. package/dist/components/number-field.js.map +1 -1
  127. package/dist/components/number-input.d.ts +25 -5
  128. package/dist/components/number-input.js +7 -1
  129. package/dist/components/number-input.js.map +1 -1
  130. package/dist/components/numpad-sheet.d.ts +20 -5
  131. package/dist/components/numpad-sheet.js +3 -2
  132. package/dist/components/numpad-sheet.js.map +1 -1
  133. package/dist/components/page-header.d.ts +35 -6
  134. package/dist/components/page-header.js +7 -1
  135. package/dist/components/page-header.js.map +1 -1
  136. package/dist/components/passkeys-setting.d.ts +67 -0
  137. package/dist/components/passkeys-setting.js +214 -0
  138. package/dist/components/passkeys-setting.js.map +1 -0
  139. package/dist/components/picker-sheet.js +5 -1
  140. package/dist/components/picker-sheet.js.map +1 -1
  141. package/dist/components/pie-chart-labels.d.ts +20 -0
  142. package/dist/components/pie-chart-labels.js +12 -0
  143. package/dist/components/pie-chart-labels.js.map +1 -0
  144. package/dist/components/pie-chart.d.ts +101 -0
  145. package/dist/components/pie-chart.js +283 -0
  146. package/dist/components/pie-chart.js.map +1 -0
  147. package/dist/components/popover.js +3 -0
  148. package/dist/components/popover.js.map +1 -1
  149. package/dist/components/progress-bar.d.ts +44 -3
  150. package/dist/components/progress-bar.js +58 -22
  151. package/dist/components/progress-bar.js.map +1 -1
  152. package/dist/components/qr-code.d.ts +34 -0
  153. package/dist/components/qr-code.js +57 -0
  154. package/dist/components/qr-code.js.map +1 -0
  155. package/dist/components/search-field.d.ts +15 -3
  156. package/dist/components/search-field.js +5 -1
  157. package/dist/components/search-field.js.map +1 -1
  158. package/dist/components/settings-fields.d.ts +49 -1
  159. package/dist/components/signed-amount.d.ts +122 -0
  160. package/dist/components/signed-amount.js +152 -0
  161. package/dist/components/signed-amount.js.map +1 -0
  162. package/dist/components/skeleton.d.ts +10 -3
  163. package/dist/components/skeleton.js +12 -2
  164. package/dist/components/skeleton.js.map +1 -1
  165. package/dist/components/stat-tile.d.ts +2 -1
  166. package/dist/components/stat-tile.js +6 -3
  167. package/dist/components/stat-tile.js.map +1 -1
  168. package/dist/components/swipeable-row.js +4 -3
  169. package/dist/components/swipeable-row.js.map +1 -1
  170. package/dist/components/table.d.ts +39 -5
  171. package/dist/components/table.js +45 -11
  172. package/dist/components/table.js.map +1 -1
  173. package/dist/components/text-link.d.ts +238 -0
  174. package/dist/components/text-link.js +144 -0
  175. package/dist/components/text-link.js.map +1 -0
  176. package/dist/components/text.d.ts +26 -2
  177. package/dist/components/text.js +16 -2
  178. package/dist/components/text.js.map +1 -1
  179. package/dist/components/time-input.d.ts +49 -1
  180. package/dist/components/toggle-group.d.ts +35 -0
  181. package/dist/components/toggle-group.js +43 -14
  182. package/dist/components/toggle-group.js.map +1 -1
  183. package/dist/components/toggle-legend.d.ts +53 -3
  184. package/dist/components/toggle-legend.js +54 -1
  185. package/dist/components/toggle-legend.js.map +1 -1
  186. package/dist/components/tooltip.d.ts +51 -1
  187. package/dist/components/tooltip.js +59 -35
  188. package/dist/components/tooltip.js.map +1 -1
  189. package/dist/components/ui.d.ts +51 -779
  190. package/dist/components/ui.js +364 -34
  191. package/dist/components/ui.js.map +1 -1
  192. package/dist/components/use-table-state.d.ts +3 -52
  193. package/dist/components/use-table-state.js +128 -30
  194. package/dist/components/use-table-state.js.map +1 -1
  195. package/dist/{data-table-filters-Dh9uF_S-.d.ts → data-table-Drun8Fk9.d.ts} +305 -61
  196. package/dist/data-table.d.ts +2 -1
  197. package/dist/data-table.js +5 -1
  198. package/dist/data-table.js.map +1 -1
  199. package/dist/feedback/feedback-attachment.js +4 -6
  200. package/dist/feedback/feedback-attachment.js.map +1 -1
  201. package/dist/feedback/feedback-dialog.d.ts +26 -3
  202. package/dist/feedback/feedback-dialog.js +21 -5
  203. package/dist/feedback/feedback-dialog.js.map +1 -1
  204. package/dist/feedback/feedback-inbox.js +86 -75
  205. package/dist/feedback/feedback-inbox.js.map +1 -1
  206. package/dist/feedback/feedback-thread.d.ts +173 -0
  207. package/dist/feedback/feedback-thread.js +264 -0
  208. package/dist/feedback/feedback-thread.js.map +1 -0
  209. package/dist/feedback.d.ts +2 -1
  210. package/dist/feedback.js +1 -0
  211. package/dist/feedback.js.map +1 -1
  212. package/dist/hooks/use-authed-src.d.ts +71 -0
  213. package/dist/hooks/use-authed-src.js +63 -0
  214. package/dist/hooks/use-authed-src.js.map +1 -0
  215. package/dist/hooks/use-file-drop.d.ts +49 -2
  216. package/dist/hooks/use-hotkey.d.ts +59 -0
  217. package/dist/hooks/use-hotkey.js +105 -0
  218. package/dist/hooks/use-hotkey.js.map +1 -0
  219. package/dist/hooks/use-search-param-state.d.ts +83 -0
  220. package/dist/hooks/use-search-param-state.js +94 -0
  221. package/dist/hooks/use-search-param-state.js.map +1 -0
  222. package/dist/i18n/defaults.d.ts +15 -4
  223. package/dist/i18n/defaults.js +31 -1
  224. package/dist/i18n/defaults.js.map +1 -1
  225. package/dist/i18n/kit-labels.d.ts +46 -312
  226. package/dist/i18n/kit-labels.js +20 -5
  227. package/dist/i18n/kit-labels.js.map +1 -1
  228. package/dist/i18n/locales/de-CH-informal.d.ts +15 -4
  229. package/dist/i18n/locales/de-CH.d.ts +15 -4
  230. package/dist/i18n/locales/de-informal.d.ts +15 -4
  231. package/dist/i18n/locales/de.d.ts +15 -4
  232. package/dist/i18n/locales/de.js +164 -3
  233. package/dist/i18n/locales/de.js.map +1 -1
  234. package/dist/i18n/locales/es.d.ts +15 -4
  235. package/dist/i18n/locales/es.js +161 -3
  236. package/dist/i18n/locales/es.js.map +1 -1
  237. package/dist/i18n/locales/fr.d.ts +15 -4
  238. package/dist/i18n/locales/fr.js +161 -3
  239. package/dist/i18n/locales/fr.js.map +1 -1
  240. package/dist/i18n/locales/hu.d.ts +15 -4
  241. package/dist/i18n/locales/hu.js +161 -3
  242. package/dist/i18n/locales/hu.js.map +1 -1
  243. package/dist/i18n/locales/it.d.ts +15 -4
  244. package/dist/i18n/locales/it.js +161 -3
  245. package/dist/i18n/locales/it.js.map +1 -1
  246. package/dist/i18n/locales/zh.d.ts +15 -4
  247. package/dist/i18n/locales/zh.js +161 -3
  248. package/dist/i18n/locales/zh.js.map +1 -1
  249. package/dist/index.d.ts +39 -19
  250. package/dist/index.js +40 -1
  251. package/dist/index.js.map +1 -1
  252. package/dist/kit-labels-Mz8zZHIF.d.ts +1744 -0
  253. package/dist/lib/format.d.ts +162 -0
  254. package/dist/lib/format.js +151 -0
  255. package/dist/lib/format.js.map +1 -0
  256. package/dist/lib/qr-encode.d.ts +44 -0
  257. package/dist/lib/qr-encode.js +338 -0
  258. package/dist/lib/qr-encode.js.map +1 -0
  259. package/dist/rhf/fields.d.ts +283 -0
  260. package/dist/rhf/fields.js +631 -0
  261. package/dist/rhf/fields.js.map +1 -0
  262. package/dist/rhf/form.d.ts +49 -1
  263. package/dist/rhf/line-items.d.ts +31 -0
  264. package/dist/rhf/line-items.js +59 -0
  265. package/dist/rhf/line-items.js.map +1 -0
  266. package/dist/rhf.d.ts +61 -1
  267. package/dist/rhf.js +2 -0
  268. package/dist/rhf.js.map +1 -1
  269. package/dist/search/command-palette.js +20 -14
  270. package/dist/search/command-palette.js.map +1 -1
  271. package/dist/shell/app-shell.d.ts +99 -2
  272. package/dist/shell/app-shell.js +120 -57
  273. package/dist/shell/app-shell.js.map +1 -1
  274. package/dist/shell/auth-layout.d.ts +74 -0
  275. package/dist/shell/auth-layout.js +97 -0
  276. package/dist/shell/auth-layout.js.map +1 -0
  277. package/dist/shell/top-bar-brand.d.ts +81 -0
  278. package/dist/shell/top-bar-brand.js +47 -0
  279. package/dist/shell/top-bar-brand.js.map +1 -0
  280. package/dist/shell/topbar-action-menu.d.ts +21 -4
  281. package/dist/shell/topbar-action-menu.js +18 -2
  282. package/dist/shell/topbar-action-menu.js.map +1 -1
  283. package/dist/shell.d.ts +56 -1
  284. package/dist/shell.js +2 -0
  285. package/dist/shell.js.map +1 -1
  286. package/dist/tour/tour.js +10 -4
  287. package/dist/tour/tour.js.map +1 -1
  288. package/dist/wizard/stepper-nav.d.ts +48 -1
  289. package/dist/wizard/use-wizard.js +4 -2
  290. package/dist/wizard/use-wizard.js.map +1 -1
  291. package/dist/wizard/wizard-context.d.ts +24 -1
  292. package/dist/wizard/wizard-context.js +19 -2
  293. package/dist/wizard/wizard-context.js.map +1 -1
  294. package/dist/wizard/wizard-step.d.ts +30 -5
  295. package/dist/wizard/wizard-step.js +34 -3
  296. package/dist/wizard/wizard-step.js.map +1 -1
  297. package/dist/wizard.d.ts +50 -3
  298. package/package.json +6 -6
  299. package/src/chart.ts +4 -0
  300. package/src/components/account-settings-labels.ts +190 -0
  301. package/src/components/account-settings.tsx +110 -63
  302. package/src/components/amount-input.tsx +109 -10
  303. package/src/components/authed-image.tsx +190 -0
  304. package/src/components/breadcrumbs.tsx +8 -2
  305. package/src/components/bulk-action-bar.tsx +16 -3
  306. package/src/components/button-group.tsx +7 -2
  307. package/src/components/calendar-heatmap.tsx +105 -10
  308. package/src/components/chart.tsx +19 -8
  309. package/src/components/chip.tsx +14 -4
  310. package/src/components/choice-card.tsx +136 -25
  311. package/src/components/combobox-core.tsx +33 -9
  312. package/src/components/combobox.tsx +33 -9
  313. package/src/components/copy-button.tsx +3 -2
  314. package/src/components/data-table-cells.tsx +119 -0
  315. package/src/components/data-table-filter-popover.tsx +13 -5
  316. package/src/components/data-table-filters.ts +77 -0
  317. package/src/components/data-table-labels.ts +23 -0
  318. package/src/components/data-table.tsx +230 -13
  319. package/src/components/date-picker.tsx +19 -3
  320. package/src/components/description-list.tsx +52 -3
  321. package/src/components/entity-combobox.tsx +25 -7
  322. package/src/components/error-boundary.tsx +640 -0
  323. package/src/components/field-sync.tsx +48 -40
  324. package/src/components/field.tsx +56 -5
  325. package/src/components/floating-panel.tsx +20 -7
  326. package/src/components/form-actions.tsx +191 -0
  327. package/src/components/full-bleed-dialog.tsx +4 -0
  328. package/src/components/hover-menu.tsx +26 -17
  329. package/src/components/image-grid.tsx +181 -0
  330. package/src/components/lightbox.tsx +374 -0
  331. package/src/components/line-items.tsx +385 -0
  332. package/src/components/list.tsx +82 -19
  333. package/src/components/loading-state.tsx +47 -0
  334. package/src/components/menu-item.tsx +7 -2
  335. package/src/components/mini-calendar.tsx +72 -3
  336. package/src/components/modal.tsx +65 -3
  337. package/src/components/month-picker.tsx +181 -26
  338. package/src/components/multi-entity-combobox.tsx +27 -7
  339. package/src/components/nav-pills.tsx +8 -1
  340. package/src/components/number-field.tsx +15 -10
  341. package/src/components/number-input.tsx +17 -1
  342. package/src/components/numpad-sheet.tsx +6 -1
  343. package/src/components/page-header.tsx +42 -5
  344. package/src/components/passkeys-setting.tsx +331 -0
  345. package/src/components/picker-sheet.tsx +10 -1
  346. package/src/components/pie-chart-labels.ts +32 -0
  347. package/src/components/pie-chart.tsx +479 -0
  348. package/src/components/popover.tsx +3 -0
  349. package/src/components/progress-bar.tsx +129 -19
  350. package/src/components/qr-code.tsx +83 -0
  351. package/src/components/search-field.tsx +20 -4
  352. package/src/components/signed-amount.tsx +295 -0
  353. package/src/components/skeleton.tsx +21 -3
  354. package/src/components/stat-tile.tsx +11 -3
  355. package/src/components/swipeable-row.tsx +7 -7
  356. package/src/components/table.tsx +102 -13
  357. package/src/components/text-link.tsx +356 -0
  358. package/src/components/text.tsx +46 -2
  359. package/src/components/toggle-group.tsx +93 -20
  360. package/src/components/toggle-legend.tsx +108 -2
  361. package/src/components/tooltip.tsx +79 -8
  362. package/src/components/ui.tsx +707 -49
  363. package/src/components/use-table-state.ts +265 -33
  364. package/src/data-table.ts +10 -0
  365. package/src/feedback/feedback-attachment.tsx +10 -7
  366. package/src/feedback/feedback-dialog.tsx +49 -7
  367. package/src/feedback/feedback-inbox.tsx +7 -0
  368. package/src/feedback/feedback-thread.tsx +510 -0
  369. package/src/feedback.ts +1 -0
  370. package/src/hooks/use-authed-src.ts +161 -0
  371. package/src/hooks/use-hotkey.ts +172 -0
  372. package/src/hooks/use-search-param-state.ts +187 -0
  373. package/src/i18n/defaults.ts +30 -0
  374. package/src/i18n/kit-labels.tsx +118 -8
  375. package/src/i18n/locales/de.ts +161 -0
  376. package/src/i18n/locales/es.ts +158 -0
  377. package/src/i18n/locales/fr.ts +161 -0
  378. package/src/i18n/locales/hu.ts +159 -0
  379. package/src/i18n/locales/it.ts +159 -0
  380. package/src/i18n/locales/zh.ts +158 -0
  381. package/src/index.ts +59 -0
  382. package/src/lib/format.ts +348 -0
  383. package/src/lib/qr-encode.ts +420 -0
  384. package/src/rhf/fields.tsx +1135 -0
  385. package/src/rhf/line-items.tsx +130 -0
  386. package/src/rhf.ts +6 -0
  387. package/src/search/command-palette.tsx +29 -19
  388. package/src/shell/app-shell.tsx +153 -3
  389. package/src/shell/auth-layout.tsx +190 -0
  390. package/src/shell/top-bar-brand.tsx +76 -0
  391. package/src/shell/topbar-action-menu.tsx +32 -4
  392. package/src/shell.ts +2 -0
  393. package/src/tour/tour.tsx +16 -5
  394. package/src/wizard/use-wizard.ts +8 -4
  395. package/src/wizard/wizard-context.tsx +41 -1
  396. package/src/wizard/wizard-step.tsx +75 -6
  397. package/tokens.css +12 -0
@@ -0,0 +1,173 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, Ref } from 'react';
3
+ import { FeedbackNoteAttachment } from './feedback-inbox.js';
4
+ import { FeedbackAttachmentLabels } from './feedback-dialog.js';
5
+ import 'lucide-react';
6
+
7
+ /**
8
+ * The conversation under a report: who said what, when, with what attached — and the
9
+ * box to answer in.
10
+ *
11
+ * Both apps had written it by hand. kastlan's feedback page grew a comment list of
12
+ * bordered boxes with `slate-*` literals (feedback-page.tsx, "keksdose left this
13
+ * unbuilt"), and keksdose built the same thing a second time for support
14
+ * (support-thread.tsx) with sides, bubbles and a composer that clears only what it
15
+ * sent. This is that second one, generalised: the kit owns the look and the
16
+ * behaviour, the app owns the data, the upload and every word it does not share.
17
+ *
18
+ * **Own vs other** is the caller's per message (`own`), not a comparison the kit makes
19
+ * against a user id: whose message sits at the END side depends on who is reading,
20
+ * and only the app knows that (keksdose's support thread labelled a member's question
21
+ * "Du" in the admin panel the first time round, by reading the wrong field).
22
+ *
23
+ * **Redaction.** A thread is somebody's words about their own data — exactly what a
24
+ * host's demo / screen-share mode blurs. Bodies, authors and attachments carry
25
+ * `data-private` (the attribute `Tooltip redact` and `StatTile sensitive` use) unless
26
+ * `redact={false}`.
27
+ *
28
+ * **RTL.** Sides are logical — `justify-end` is the reading end, and the bubble's
29
+ * tucked corner is `rounded-ee` / `rounded-es` — and each body is `dir="auto"`, so a
30
+ * Hebrew reply in an English thread (or the reverse) lays out as its own language.
31
+ */
32
+ /** The `feedbackThread` namespace of `<UiKitProvider labels>`. */
33
+ interface FeedbackThreadLabels {
34
+ /** Accessible name of the message list. */
35
+ thread: string;
36
+ empty: string;
37
+ loading: string;
38
+ /** Author line of an `own` message that has no `author` of its own. */
39
+ you: string;
40
+ /** The badge beside a `staff` author. */
41
+ staff: string;
42
+ /** Accessible name of a message's attachment list. */
43
+ attachments: string;
44
+ }
45
+ declare const DEFAULT_FEEDBACK_THREAD_LABELS: FeedbackThreadLabels;
46
+ /** The `feedbackComposer` namespace of `<UiKitProvider labels>`. The attach buttons'
47
+ * words are `feedbackAttachment`'s, shared with the dialog and the note editor. */
48
+ interface FeedbackComposerLabels {
49
+ /** Accessible name of the text box. */
50
+ field: string;
51
+ placeholder: string;
52
+ send: string;
53
+ /** The shortcut line, given the platform's modifier ("Ctrl" or "⌘"). */
54
+ sendHint: (modifier: string) => string;
55
+ }
56
+ declare const DEFAULT_FEEDBACK_COMPOSER_LABELS: FeedbackComposerLabels;
57
+ interface FeedbackThreadAttachment {
58
+ id?: string | number;
59
+ name: string;
60
+ /** Where to open it. Left out, the attachment is listed by name only. */
61
+ url?: string;
62
+ /** MIME type; an `image/*` with a `url` is shown as a thumbnail. */
63
+ type?: string;
64
+ /** Bytes, shown beside a non-image. */
65
+ size?: number;
66
+ }
67
+ interface FeedbackThreadMessage {
68
+ id: string | number;
69
+ /** Who wrote it. Left out on an `own` message, it reads "You". */
70
+ author?: ReactNode;
71
+ /** A `Date`, an ISO string or epoch ms. */
72
+ createdAt: Date | string | number;
73
+ body: string;
74
+ attachments?: readonly FeedbackThreadAttachment[];
75
+ /** Written by whoever is reading: sits at the end side, in the brand tint. */
76
+ own?: boolean;
77
+ /** Written by the team rather than a user: gets the "Staff" badge. */
78
+ staff?: boolean;
79
+ }
80
+ interface FeedbackThreadProps {
81
+ messages: readonly FeedbackThreadMessage[];
82
+ loading?: boolean;
83
+ /** Replaces the default "No comments yet". */
84
+ empty?: ReactNode;
85
+ /**
86
+ * Draw one attachment yourself — for files behind auth, which a plain `<img src>`
87
+ * cannot fetch (kastlan's `AuthedImage`), or a lightbox. The default is a thumbnail
88
+ * link for an image with a `url`, a file link otherwise.
89
+ */
90
+ renderAttachment?: (attachment: FeedbackThreadAttachment, message: FeedbackThreadMessage) => ReactNode;
91
+ /** Tag bodies, authors and attachments `data-private`. Default true. */
92
+ redact?: boolean;
93
+ /** "Now" for the relative times — pin it in tests and stories. Default: the clock. */
94
+ now?: Date | number;
95
+ /** Overrides the provider's locale for the times. */
96
+ locale?: string;
97
+ labels?: Partial<FeedbackThreadLabels>;
98
+ className?: string;
99
+ }
100
+ declare function FeedbackThread({ messages, loading, empty, renderAttachment, redact, now, locale: localeProp, labels: labelsProp, className, }: FeedbackThreadProps): react.JSX.Element;
101
+ /** What the composer's attach control takes — {@link FeedbackNoteAttachment} with the
102
+ * labels optional, since the field reads `feedbackAttachment` from the provider. */
103
+ type FeedbackComposerAttachment = Omit<FeedbackNoteAttachment, "labels"> & {
104
+ labels?: Partial<FeedbackAttachmentLabels>;
105
+ };
106
+ interface FeedbackComposerProps {
107
+ /**
108
+ * Send the comment. Return the promise: the box clears when it RESOLVES, and only of
109
+ * what was sent — text typed while it was in flight stays. A rejection keeps
110
+ * everything for a retry (surface the error yourself; the composer stays quiet).
111
+ */
112
+ onSend: (body: string, attachment: File | null) => void | Promise<unknown>;
113
+ /** The send is in flight: a spinner on the button and no second send. */
114
+ pending?: boolean;
115
+ /** Offer one picture with the comment (file, paste or `onCaptureScreenshot`).
116
+ * `true` for the defaults. Left out, the composer is text only. */
117
+ attachment?: boolean | FeedbackComposerAttachment;
118
+ /** Rendered INSTEAD of the composer — the thread is closed, or read-only for this
119
+ * reader. */
120
+ disabledReason?: ReactNode;
121
+ rows?: number;
122
+ /**
123
+ * The box's hint, over the `placeholder` label — keksdose F9: an admin answering a
124
+ * support ticket is asked something else ("Reply to Anna…") than a member adding to
125
+ * their own report, and one provider-wide label cannot say both.
126
+ */
127
+ placeholder?: string;
128
+ /**
129
+ * The draft, controlled — for a host that keeps it itself (saves it per ticket,
130
+ * prefills a template). Left out, the composer keeps its own. Either way a send
131
+ * that resolves clears only what was sent: controlled, that is an
132
+ * `onValueChange("")` the host receives like any keystroke, and only if the draft
133
+ * is still the one that went out.
134
+ */
135
+ value?: string;
136
+ /** Every change to the draft — typing, {@link FeedbackComposerHandle.insertText}, the
137
+ * clear after a send. Required to change a controlled `value`. */
138
+ onValueChange?: (value: string) => void;
139
+ /** {@link FeedbackComposerHandle}: put text into the draft from outside (canned-reply
140
+ * chips) or focus the box. */
141
+ ref?: Ref<FeedbackComposerHandle>;
142
+ labels?: Partial<FeedbackComposerLabels>;
143
+ className?: string;
144
+ }
145
+ /**
146
+ * What a {@link FeedbackComposer} `ref` holds.
147
+ *
148
+ * keksdose F9: the support admin answers the same five questions all day and wants
149
+ * chips above the box ("Thanks, fixed in the next release") that drop their text in
150
+ * where the caret is. A controlled `value` alone cannot do that well — the host sees
151
+ * the string, not the caret, so it could only append — so the composer, which owns
152
+ * the textarea, does the splice.
153
+ */
154
+ interface FeedbackComposerHandle {
155
+ /**
156
+ * Insert `text` at the caret, replacing any selection (the caret the box last had:
157
+ * a click on a chip blurs it, and the selection survives the blur), then focus the
158
+ * box with the caret after the inserted text so the reply can go on. Nothing is
159
+ * added around it — put a space or a newline in `text` if the reply needs one. A
160
+ * no-op while `disabledReason` replaces the box.
161
+ */
162
+ insertText: (text: string) => void;
163
+ focus: () => void;
164
+ }
165
+ /**
166
+ * The answer box under a {@link FeedbackThread}: a textarea, an optional picture,
167
+ * and Send — Ctrl/⌘+Enter sends, the shortcut the report dialog and the note editor
168
+ * use, so the habit carries across the feature. Plain Enter is a new line: feedback is
169
+ * written in paragraphs, unlike a chat.
170
+ */
171
+ declare function FeedbackComposer({ onSend, pending, attachment, disabledReason, rows, placeholder, value, onValueChange, ref, labels: labelsProp, className, }: FeedbackComposerProps): react.JSX.Element;
172
+
173
+ export { DEFAULT_FEEDBACK_COMPOSER_LABELS, DEFAULT_FEEDBACK_THREAD_LABELS, FeedbackComposer, type FeedbackComposerAttachment, type FeedbackComposerHandle, type FeedbackComposerLabels, type FeedbackComposerProps, FeedbackThread, type FeedbackThreadAttachment, type FeedbackThreadLabels, type FeedbackThreadMessage, type FeedbackThreadProps };
@@ -0,0 +1,264 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useImperativeHandle, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
4
+ import { Paperclip, Send } from "lucide-react";
5
+ import { cn } from "../lib/cn.js";
6
+ import { formatRelativeTime } from "../lib/format.js";
7
+ import { Button, EmptyState, Spinner, Textarea } from "../components/ui.js";
8
+ import { Skeleton } from "../components/skeleton.js";
9
+ import { Tooltip } from "../components/tooltip.js";
10
+ import { useKitFileLabels, useKitLabels, useKitLocale } from "../i18n/kit-labels.js";
11
+ import { FeedbackAttachmentField } from "./feedback-attachment.js";
12
+ const DEFAULT_FEEDBACK_THREAD_LABELS = {
13
+ thread: "Comments",
14
+ empty: "No comments yet",
15
+ loading: "Loading comments\u2026",
16
+ you: "You",
17
+ staff: "Staff",
18
+ attachments: "Attachments"
19
+ };
20
+ const DEFAULT_FEEDBACK_COMPOSER_LABELS = {
21
+ field: "Write a comment",
22
+ placeholder: "Write a comment\u2026",
23
+ send: "Send",
24
+ sendHint: (modifier) => `${modifier} + Enter to send`
25
+ };
26
+ function FeedbackThread({
27
+ messages,
28
+ loading = false,
29
+ empty,
30
+ renderAttachment,
31
+ redact = true,
32
+ now,
33
+ locale: localeProp,
34
+ labels: labelsProp,
35
+ className
36
+ }) {
37
+ const labels = useKitLabels("feedbackThread", DEFAULT_FEEDBACK_THREAD_LABELS, labelsProp);
38
+ const locale = useKitLocale(localeProp);
39
+ const file = useKitFileLabels();
40
+ const priv = redact ? "" : void 0;
41
+ const clock = useMinuteClock(now === void 0);
42
+ const reference = now === void 0 ? clock : +now;
43
+ if (loading && messages.length === 0) {
44
+ return /* @__PURE__ */ jsx(Skeleton, { lines: 3, label: labels.loading, className });
45
+ }
46
+ if (messages.length === 0) {
47
+ return /* @__PURE__ */ jsx(
48
+ EmptyState,
49
+ {
50
+ variant: "inline",
51
+ size: "sm",
52
+ title: empty ?? labels.empty,
53
+ className: cn("justify-start", className)
54
+ }
55
+ );
56
+ }
57
+ return /* @__PURE__ */ jsx("ol", { "aria-label": labels.thread, "aria-busy": loading || void 0, className: cn("space-y-3", className), children: messages.map((message) => {
58
+ const date = toDate(message.createdAt);
59
+ const author = message.author ?? (message.own ? labels.you : null);
60
+ const attachments = message.attachments ?? [];
61
+ return /* @__PURE__ */ jsx(
62
+ "li",
63
+ {
64
+ className: cn("flex", message.own ? "justify-end" : "justify-start"),
65
+ "data-own": message.own ? "" : void 0,
66
+ children: /* @__PURE__ */ jsxs(
67
+ "article",
68
+ {
69
+ className: cn(
70
+ "max-w-[85%] min-w-0 rounded-lg px-3 py-2 text-sm",
71
+ message.own ? "rounded-ee-sm bg-[var(--brand-bg)]" : "rounded-es-sm bg-[var(--bg-surface-2)]"
72
+ ),
73
+ children: [
74
+ /* @__PURE__ */ jsxs("header", { className: "mb-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-[var(--text-muted)]", children: [
75
+ author != null && /* @__PURE__ */ jsx("span", { "data-private": priv, className: "font-medium text-[var(--text-secondary)]", children: author }),
76
+ message.staff && /* @__PURE__ */ jsx("span", { className: "rounded border border-[var(--border)] bg-[var(--bg-surface)] px-1 text-[10px] font-medium uppercase tracking-wide text-[var(--text-secondary)]", children: labels.staff }),
77
+ date && // The kit's Tooltip, not a native title: one tooltip look app-wide
78
+ // (keksdose F0 / dev#523).
79
+ /* @__PURE__ */ jsx(Tooltip, { label: new Intl.DateTimeFormat(locale, { dateStyle: "full", timeStyle: "short" }).format(date), children: /* @__PURE__ */ jsx("time", { dateTime: date.toISOString(), className: "tabular-nums", children: formatRelativeTime(date, {
80
+ now: reference,
81
+ locale,
82
+ // Past the kit's day steps it is a date: "2 weeks ago" makes
83
+ // the reader do arithmetic the date already did.
84
+ absoluteAfterDays: 6.5
85
+ }) }) })
86
+ ] }),
87
+ message.body && /* @__PURE__ */ jsx(
88
+ "p",
89
+ {
90
+ "data-private": priv,
91
+ dir: "auto",
92
+ className: "whitespace-pre-wrap break-words text-start text-[var(--text-primary)]",
93
+ children: message.body
94
+ }
95
+ ),
96
+ attachments.length > 0 && /* @__PURE__ */ jsx("ul", { "aria-label": labels.attachments, "data-private": priv, className: "mt-2 flex flex-wrap gap-2", children: attachments.map((attachment, index) => /* @__PURE__ */ jsx("li", { className: "min-w-0", children: renderAttachment ? renderAttachment(attachment, message) : /* @__PURE__ */ jsx(DefaultAttachment, { attachment, size: file.size }) }, attachment.id ?? `${index}-${attachment.name}`)) })
97
+ ]
98
+ }
99
+ )
100
+ },
101
+ message.id
102
+ );
103
+ }) });
104
+ }
105
+ function DefaultAttachment({
106
+ attachment,
107
+ size
108
+ }) {
109
+ const { name, url, type } = attachment;
110
+ if (url && type?.startsWith("image/")) {
111
+ return /* @__PURE__ */ jsx("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: "block", children: /* @__PURE__ */ jsx(
112
+ "img",
113
+ {
114
+ src: url,
115
+ alt: name,
116
+ loading: "lazy",
117
+ className: "h-20 w-20 rounded border border-[var(--border)] object-cover"
118
+ }
119
+ ) });
120
+ }
121
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
122
+ /* @__PURE__ */ jsx(Paperclip, { className: "size-3.5 shrink-0", "aria-hidden": true }),
123
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: name }),
124
+ attachment.size !== void 0 && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-[var(--text-muted)]", children: size(attachment.size) })
125
+ ] });
126
+ const chip = "inline-flex max-w-full items-center gap-1 rounded border border-[var(--border)] bg-[var(--bg-surface)] px-2 py-1 text-xs text-[var(--text-secondary)]";
127
+ return url ? /* @__PURE__ */ jsx("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: cn(chip, "hover:bg-[var(--bg-hover)]"), children: content }) : /* @__PURE__ */ jsx("span", { className: chip, children: content });
128
+ }
129
+ function useMinuteClock(active) {
130
+ const [time, setTime] = useState(() => Date.now());
131
+ useEffect(() => {
132
+ if (!active) return;
133
+ const id = setInterval(() => setTime(Date.now()), 6e4);
134
+ return () => clearInterval(id);
135
+ }, [active]);
136
+ return time;
137
+ }
138
+ function toDate(value) {
139
+ const date = value instanceof Date ? value : new Date(value);
140
+ return Number.isNaN(date.getTime()) ? null : date;
141
+ }
142
+ const noSubscribe = () => () => {
143
+ };
144
+ const isApple = () => typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent);
145
+ function FeedbackComposer({
146
+ onSend,
147
+ pending = false,
148
+ attachment,
149
+ disabledReason,
150
+ rows = 3,
151
+ placeholder,
152
+ value,
153
+ onValueChange,
154
+ ref,
155
+ labels: labelsProp,
156
+ className
157
+ }) {
158
+ const labels = useKitLabels("feedbackComposer", DEFAULT_FEEDBACK_COMPOSER_LABELS, labelsProp);
159
+ const [ownDraft, setOwnDraft] = useState("");
160
+ const controlled = value !== void 0;
161
+ const draft = controlled ? value : ownDraft;
162
+ const [file, setFile] = useState(null);
163
+ const root = useRef(null);
164
+ const box = useRef(null);
165
+ const latest = useRef(draft);
166
+ useLayoutEffect(() => {
167
+ latest.current = draft;
168
+ });
169
+ const caret = useRef(null);
170
+ useLayoutEffect(() => {
171
+ const el = box.current;
172
+ if (caret.current === null || !el) return;
173
+ el.focus();
174
+ el.setSelectionRange(caret.current, caret.current);
175
+ caret.current = null;
176
+ });
177
+ const setDraft = (next) => {
178
+ latest.current = next;
179
+ if (!controlled) setOwnDraft(next);
180
+ onValueChange?.(next);
181
+ };
182
+ useImperativeHandle(ref, () => ({
183
+ insertText: (text) => {
184
+ const el = box.current;
185
+ if (!el) return;
186
+ const current = latest.current;
187
+ const pending2 = caret.current;
188
+ const start = Math.min(pending2 ?? el.selectionStart ?? current.length, current.length);
189
+ const end = pending2 ?? Math.max(start, Math.min(el.selectionEnd ?? start, current.length));
190
+ caret.current = start + text.length;
191
+ setDraft(current.slice(0, start) + text + current.slice(end));
192
+ },
193
+ focus: () => box.current?.focus()
194
+ }));
195
+ const modifier = useSyncExternalStore(
196
+ noSubscribe,
197
+ () => isApple() ? "\u2318" : "Ctrl",
198
+ () => "Ctrl"
199
+ );
200
+ if (disabledReason != null && disabledReason !== false) {
201
+ return /* @__PURE__ */ jsx("p", { className: cn("text-xs text-[var(--text-muted)]", className), children: disabledReason });
202
+ }
203
+ const canSend = draft.trim().length > 0 && !pending;
204
+ const send = () => {
205
+ if (!canSend) return;
206
+ const sentDraft = draft;
207
+ const sentFile = file;
208
+ Promise.resolve(onSend(draft.trim(), file)).then(() => {
209
+ if (latest.current === sentDraft) setDraft("");
210
+ setFile((current) => current === sentFile ? null : current);
211
+ }).catch(() => {
212
+ });
213
+ };
214
+ const config = attachment === true ? {} : attachment || null;
215
+ return /* @__PURE__ */ jsxs("div", { ref: root, className: cn("space-y-2", className), children: [
216
+ /* @__PURE__ */ jsx(
217
+ Textarea,
218
+ {
219
+ rows,
220
+ dir: "auto",
221
+ "aria-label": labels.field,
222
+ ref: box,
223
+ placeholder: placeholder ?? labels.placeholder,
224
+ value: draft,
225
+ onChange: (event) => setDraft(event.target.value),
226
+ onKeyDown: (event) => {
227
+ if ((event.ctrlKey || event.metaKey) && event.key === "Enter") {
228
+ event.preventDefault();
229
+ send();
230
+ }
231
+ }
232
+ }
233
+ ),
234
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-end justify-between gap-2", children: [
235
+ config ? /* @__PURE__ */ jsx(
236
+ FeedbackAttachmentField,
237
+ {
238
+ value: file,
239
+ onChange: setFile,
240
+ labels: config.labels,
241
+ accept: config.accept,
242
+ maxBytes: config.maxBytes,
243
+ onError: config.onError,
244
+ onCaptureScreenshot: config.onCaptureScreenshot,
245
+ pasteFrom: root
246
+ }
247
+ ) : /* @__PURE__ */ jsx("span", {}),
248
+ /* @__PURE__ */ jsxs("div", { className: "ms-auto flex items-center gap-2", children: [
249
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-[var(--text-placeholder)]", children: labels.sendHint(modifier) }),
250
+ /* @__PURE__ */ jsxs(Button, { onClick: send, disabled: !canSend, "aria-busy": pending || void 0, children: [
251
+ pending ? /* @__PURE__ */ jsx(Spinner, { label: null, className: "size-4" }) : /* @__PURE__ */ jsx(Send, { className: "size-4 rtl:-scale-x-100", "aria-hidden": true }),
252
+ labels.send
253
+ ] })
254
+ ] })
255
+ ] })
256
+ ] });
257
+ }
258
+ export {
259
+ DEFAULT_FEEDBACK_COMPOSER_LABELS,
260
+ DEFAULT_FEEDBACK_THREAD_LABELS,
261
+ FeedbackComposer,
262
+ FeedbackThread
263
+ };
264
+ //# sourceMappingURL=feedback-thread.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/feedback/feedback-thread.tsx"],"sourcesContent":["import { useEffect, useImperativeHandle, useLayoutEffect, useRef, useState, useSyncExternalStore } from \"react\";\nimport type { ReactNode, Ref } from \"react\";\nimport { Paperclip, Send } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { formatRelativeTime } from \"../lib/format\";\nimport { Button, EmptyState, Spinner, Textarea } from \"../components/ui\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { useKitFileLabels, useKitLabels, useKitLocale } from \"../i18n/kit-labels\";\nimport { FeedbackAttachmentField } from \"./feedback-attachment\";\nimport type { FeedbackNoteAttachment } from \"./feedback-inbox\";\nimport type { FeedbackAttachmentLabels } from \"./feedback-dialog\";\n\n/**\n * The conversation under a report: who said what, when, with what attached — and the\n * box to answer in.\n *\n * Both apps had written it by hand. kastlan's feedback page grew a comment list of\n * bordered boxes with `slate-*` literals (feedback-page.tsx, \"keksdose left this\n * unbuilt\"), and keksdose built the same thing a second time for support\n * (support-thread.tsx) with sides, bubbles and a composer that clears only what it\n * sent. This is that second one, generalised: the kit owns the look and the\n * behaviour, the app owns the data, the upload and every word it does not share.\n *\n * **Own vs other** is the caller's per message (`own`), not a comparison the kit makes\n * against a user id: whose message sits at the END side depends on who is reading,\n * and only the app knows that (keksdose's support thread labelled a member's question\n * \"Du\" in the admin panel the first time round, by reading the wrong field).\n *\n * **Redaction.** A thread is somebody's words about their own data — exactly what a\n * host's demo / screen-share mode blurs. Bodies, authors and attachments carry\n * `data-private` (the attribute `Tooltip redact` and `StatTile sensitive` use) unless\n * `redact={false}`.\n *\n * **RTL.** Sides are logical — `justify-end` is the reading end, and the bubble's\n * tucked corner is `rounded-ee` / `rounded-es` — and each body is `dir=\"auto\"`, so a\n * Hebrew reply in an English thread (or the reverse) lays out as its own language.\n */\n\n/* ── Labels ───────────────────────────────────────────────────────────────── */\n\n/** The `feedbackThread` namespace of `<UiKitProvider labels>`. */\nexport interface FeedbackThreadLabels {\n /** Accessible name of the message list. */\n thread: string;\n empty: string;\n loading: string;\n /** Author line of an `own` message that has no `author` of its own. */\n you: string;\n /** The badge beside a `staff` author. */\n staff: string;\n /** Accessible name of a message's attachment list. */\n attachments: string;\n}\n\nexport const DEFAULT_FEEDBACK_THREAD_LABELS: FeedbackThreadLabels = {\n thread: \"Comments\",\n empty: \"No comments yet\",\n loading: \"Loading comments…\",\n you: \"You\",\n staff: \"Staff\",\n attachments: \"Attachments\",\n};\n\n/** The `feedbackComposer` namespace of `<UiKitProvider labels>`. The attach buttons'\n * words are `feedbackAttachment`'s, shared with the dialog and the note editor. */\nexport interface FeedbackComposerLabels {\n /** Accessible name of the text box. */\n field: string;\n placeholder: string;\n send: string;\n /** The shortcut line, given the platform's modifier (\"Ctrl\" or \"⌘\"). */\n sendHint: (modifier: string) => string;\n}\n\nexport const DEFAULT_FEEDBACK_COMPOSER_LABELS: FeedbackComposerLabels = {\n field: \"Write a comment\",\n placeholder: \"Write a comment…\",\n send: \"Send\",\n sendHint: (modifier) => `${modifier} + Enter to send`,\n};\n\n/* ── Thread ───────────────────────────────────────────────────────────────── */\n\nexport interface FeedbackThreadAttachment {\n id?: string | number;\n name: string;\n /** Where to open it. Left out, the attachment is listed by name only. */\n url?: string;\n /** MIME type; an `image/*` with a `url` is shown as a thumbnail. */\n type?: string;\n /** Bytes, shown beside a non-image. */\n size?: number;\n}\n\nexport interface FeedbackThreadMessage {\n id: string | number;\n /** Who wrote it. Left out on an `own` message, it reads \"You\". */\n author?: ReactNode;\n /** A `Date`, an ISO string or epoch ms. */\n createdAt: Date | string | number;\n body: string;\n attachments?: readonly FeedbackThreadAttachment[];\n /** Written by whoever is reading: sits at the end side, in the brand tint. */\n own?: boolean;\n /** Written by the team rather than a user: gets the \"Staff\" badge. */\n staff?: boolean;\n}\n\nexport interface FeedbackThreadProps {\n messages: readonly FeedbackThreadMessage[];\n loading?: boolean;\n /** Replaces the default \"No comments yet\". */\n empty?: ReactNode;\n /**\n * Draw one attachment yourself — for files behind auth, which a plain `<img src>`\n * cannot fetch (kastlan's `AuthedImage`), or a lightbox. The default is a thumbnail\n * link for an image with a `url`, a file link otherwise.\n */\n renderAttachment?: (attachment: FeedbackThreadAttachment, message: FeedbackThreadMessage) => ReactNode;\n /** Tag bodies, authors and attachments `data-private`. Default true. */\n redact?: boolean;\n /** \"Now\" for the relative times — pin it in tests and stories. Default: the clock. */\n now?: Date | number;\n /** Overrides the provider's locale for the times. */\n locale?: string;\n labels?: Partial<FeedbackThreadLabels>;\n className?: string;\n}\n\nexport function FeedbackThread({\n messages,\n loading = false,\n empty,\n renderAttachment,\n redact = true,\n now,\n locale: localeProp,\n labels: labelsProp,\n className,\n}: FeedbackThreadProps) {\n const labels = useKitLabels(\"feedbackThread\", DEFAULT_FEEDBACK_THREAD_LABELS, labelsProp);\n const locale = useKitLocale(localeProp);\n const file = useKitFileLabels();\n const priv = redact ? \"\" : undefined;\n const clock = useMinuteClock(now === undefined);\n const reference = now === undefined ? clock : +now;\n\n if (loading && messages.length === 0) {\n return <Skeleton lines={3} label={labels.loading} className={className} />;\n }\n if (messages.length === 0) {\n return (\n <EmptyState\n variant=\"inline\"\n size=\"sm\"\n title={empty ?? labels.empty}\n className={cn(\"justify-start\", className)}\n />\n );\n }\n\n return (\n <ol aria-label={labels.thread} aria-busy={loading || undefined} className={cn(\"space-y-3\", className)}>\n {messages.map((message) => {\n const date = toDate(message.createdAt);\n const author = message.author ?? (message.own ? labels.you : null);\n const attachments = message.attachments ?? [];\n return (\n <li\n key={message.id}\n className={cn(\"flex\", message.own ? \"justify-end\" : \"justify-start\")}\n data-own={message.own ? \"\" : undefined}\n >\n <article\n className={cn(\n \"max-w-[85%] min-w-0 rounded-lg px-3 py-2 text-sm\",\n message.own\n ? \"rounded-ee-sm bg-[var(--brand-bg)]\"\n : \"rounded-es-sm bg-[var(--bg-surface-2)]\",\n )}\n >\n <header className=\"mb-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-[var(--text-muted)]\">\n {author != null && (\n <span data-private={priv} className=\"font-medium text-[var(--text-secondary)]\">\n {author}\n </span>\n )}\n {message.staff && (\n <span className=\"rounded border border-[var(--border)] bg-[var(--bg-surface)] px-1 text-[10px] font-medium uppercase tracking-wide text-[var(--text-secondary)]\">\n {labels.staff}\n </span>\n )}\n {date && (\n // The kit's Tooltip, not a native title: one tooltip look app-wide\n // (keksdose F0 / dev#523).\n <Tooltip label={new Intl.DateTimeFormat(locale, { dateStyle: \"full\", timeStyle: \"short\" }).format(date)}>\n <time dateTime={date.toISOString()} className=\"tabular-nums\">\n {formatRelativeTime(date, {\n now: reference,\n locale,\n // Past the kit's day steps it is a date: \"2 weeks ago\" makes\n // the reader do arithmetic the date already did.\n absoluteAfterDays: 6.5,\n })}\n </time>\n </Tooltip>\n )}\n </header>\n {message.body && (\n <p\n data-private={priv}\n dir=\"auto\"\n className=\"whitespace-pre-wrap break-words text-start text-[var(--text-primary)]\"\n >\n {message.body}\n </p>\n )}\n {attachments.length > 0 && (\n <ul aria-label={labels.attachments} data-private={priv} className=\"mt-2 flex flex-wrap gap-2\">\n {attachments.map((attachment, index) => (\n <li key={attachment.id ?? `${index}-${attachment.name}`} className=\"min-w-0\">\n {renderAttachment ? (\n renderAttachment(attachment, message)\n ) : (\n <DefaultAttachment attachment={attachment} size={file.size} />\n )}\n </li>\n ))}\n </ul>\n )}\n </article>\n </li>\n );\n })}\n </ol>\n );\n}\n\nfunction DefaultAttachment({\n attachment,\n size,\n}: {\n attachment: FeedbackThreadAttachment;\n size: (bytes: number) => string;\n}) {\n const { name, url, type } = attachment;\n if (url && type?.startsWith(\"image/\")) {\n return (\n <a href={url} target=\"_blank\" rel=\"noopener noreferrer\" className=\"block\">\n <img\n src={url}\n alt={name}\n loading=\"lazy\"\n className=\"h-20 w-20 rounded border border-[var(--border)] object-cover\"\n />\n </a>\n );\n }\n const content = (\n <>\n <Paperclip className=\"size-3.5 shrink-0\" aria-hidden />\n <span className=\"truncate\">{name}</span>\n {attachment.size !== undefined && (\n <span className=\"shrink-0 text-[var(--text-muted)]\">{size(attachment.size)}</span>\n )}\n </>\n );\n const chip =\n \"inline-flex max-w-full items-center gap-1 rounded border border-[var(--border)] bg-[var(--bg-surface)] px-2 py-1 text-xs text-[var(--text-secondary)]\";\n return url ? (\n <a href={url} target=\"_blank\" rel=\"noopener noreferrer\" className={cn(chip, \"hover:bg-[var(--bg-hover)]\")}>\n {content}\n </a>\n ) : (\n <span className={chip}>{content}</span>\n );\n}\n\n/** The time, refreshed once a minute while `active`, so \"2 minutes ago\" does not stay\n * \"just now\" on a page left open. Read in state rather than in render, which must be\n * pure. */\nfunction useMinuteClock(active: boolean): number {\n const [time, setTime] = useState(() => Date.now());\n useEffect(() => {\n if (!active) return;\n const id = setInterval(() => setTime(Date.now()), 60_000);\n return () => clearInterval(id);\n }, [active]);\n return time;\n}\n\nfunction toDate(value: Date | string | number): Date | null {\n const date = value instanceof Date ? value : new Date(value);\n return Number.isNaN(date.getTime()) ? null : date;\n}\n\n/* ── Composer ─────────────────────────────────────────────────────────────── */\n\n/** What the composer's attach control takes — {@link FeedbackNoteAttachment} with the\n * labels optional, since the field reads `feedbackAttachment` from the provider. */\nexport type FeedbackComposerAttachment = Omit<FeedbackNoteAttachment, \"labels\"> & {\n labels?: Partial<FeedbackAttachmentLabels>;\n};\n\nexport interface FeedbackComposerProps {\n /**\n * Send the comment. Return the promise: the box clears when it RESOLVES, and only of\n * what was sent — text typed while it was in flight stays. A rejection keeps\n * everything for a retry (surface the error yourself; the composer stays quiet).\n */\n onSend: (body: string, attachment: File | null) => void | Promise<unknown>;\n /** The send is in flight: a spinner on the button and no second send. */\n pending?: boolean;\n /** Offer one picture with the comment (file, paste or `onCaptureScreenshot`).\n * `true` for the defaults. Left out, the composer is text only. */\n attachment?: boolean | FeedbackComposerAttachment;\n /** Rendered INSTEAD of the composer — the thread is closed, or read-only for this\n * reader. */\n disabledReason?: ReactNode;\n rows?: number;\n /**\n * The box's hint, over the `placeholder` label — keksdose F9: an admin answering a\n * support ticket is asked something else (\"Reply to Anna…\") than a member adding to\n * their own report, and one provider-wide label cannot say both.\n */\n placeholder?: string;\n /**\n * The draft, controlled — for a host that keeps it itself (saves it per ticket,\n * prefills a template). Left out, the composer keeps its own. Either way a send\n * that resolves clears only what was sent: controlled, that is an\n * `onValueChange(\"\")` the host receives like any keystroke, and only if the draft\n * is still the one that went out.\n */\n value?: string;\n /** Every change to the draft — typing, {@link FeedbackComposerHandle.insertText}, the\n * clear after a send. Required to change a controlled `value`. */\n onValueChange?: (value: string) => void;\n /** {@link FeedbackComposerHandle}: put text into the draft from outside (canned-reply\n * chips) or focus the box. */\n ref?: Ref<FeedbackComposerHandle>;\n labels?: Partial<FeedbackComposerLabels>;\n className?: string;\n}\n\n/**\n * What a {@link FeedbackComposer} `ref` holds.\n *\n * keksdose F9: the support admin answers the same five questions all day and wants\n * chips above the box (\"Thanks, fixed in the next release\") that drop their text in\n * where the caret is. A controlled `value` alone cannot do that well — the host sees\n * the string, not the caret, so it could only append — so the composer, which owns\n * the textarea, does the splice.\n */\nexport interface FeedbackComposerHandle {\n /**\n * Insert `text` at the caret, replacing any selection (the caret the box last had:\n * a click on a chip blurs it, and the selection survives the blur), then focus the\n * box with the caret after the inserted text so the reply can go on. Nothing is\n * added around it — put a space or a newline in `text` if the reply needs one. A\n * no-op while `disabledReason` replaces the box.\n */\n insertText: (text: string) => void;\n focus: () => void;\n}\n\nconst noSubscribe = () => () => {};\nconst isApple = () =>\n typeof navigator !== \"undefined\" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent);\n\n/**\n * The answer box under a {@link FeedbackThread}: a textarea, an optional picture,\n * and Send — Ctrl/⌘+Enter sends, the shortcut the report dialog and the note editor\n * use, so the habit carries across the feature. Plain Enter is a new line: feedback is\n * written in paragraphs, unlike a chat.\n */\nexport function FeedbackComposer({\n onSend,\n pending = false,\n attachment,\n disabledReason,\n rows = 3,\n placeholder,\n value,\n onValueChange,\n ref,\n labels: labelsProp,\n className,\n}: FeedbackComposerProps) {\n const labels = useKitLabels(\"feedbackComposer\", DEFAULT_FEEDBACK_COMPOSER_LABELS, labelsProp);\n const [ownDraft, setOwnDraft] = useState(\"\");\n const controlled = value !== undefined;\n const draft = controlled ? value : ownDraft;\n const [file, setFile] = useState<File | null>(null);\n const root = useRef<HTMLDivElement>(null);\n const box = useRef<HTMLTextAreaElement>(null);\n // The draft as of the last commit. The send's `.then` and `insertText` run after\n // renders their closure did not see — text typed while the send was in flight, a\n // second chip clicked before the first one's render — and must not act on a stale\n // string (for a controlled draft there is no updater function to lean on).\n const latest = useRef(draft);\n useLayoutEffect(() => {\n latest.current = draft;\n });\n // Where the caret goes once an inserted text has rendered.\n const caret = useRef<number | null>(null);\n useLayoutEffect(() => {\n const el = box.current;\n if (caret.current === null || !el) return;\n el.focus();\n el.setSelectionRange(caret.current, caret.current);\n caret.current = null;\n });\n\n const setDraft = (next: string) => {\n latest.current = next;\n if (!controlled) setOwnDraft(next);\n onValueChange?.(next);\n };\n\n useImperativeHandle(ref, () => ({\n insertText: (text) => {\n const el = box.current;\n if (!el) return;\n const current = latest.current;\n // A second insert before the first has rendered goes after the first, not at the\n // textarea's not-yet-moved caret. Otherwise the textarea's selection, which may\n // be past the end of a controlled value the host has just shortened: clamp it.\n const pending = caret.current;\n const start = Math.min(pending ?? el.selectionStart ?? current.length, current.length);\n const end = pending ?? Math.max(start, Math.min(el.selectionEnd ?? start, current.length));\n caret.current = start + text.length;\n setDraft(current.slice(0, start) + text + current.slice(end));\n },\n focus: () => box.current?.focus(),\n }));\n // The server snapshot is \"Ctrl\"; the client corrects it after hydration.\n const modifier = useSyncExternalStore(\n noSubscribe,\n () => (isApple() ? \"⌘\" : \"Ctrl\"),\n () => \"Ctrl\",\n );\n\n if (disabledReason != null && disabledReason !== false) {\n return <p className={cn(\"text-xs text-[var(--text-muted)]\", className)}>{disabledReason}</p>;\n }\n\n const canSend = draft.trim().length > 0 && !pending;\n const send = () => {\n if (!canSend) return;\n const sentDraft = draft;\n const sentFile = file;\n Promise.resolve(onSend(draft.trim(), file))\n .then(() => {\n if (latest.current === sentDraft) setDraft(\"\");\n setFile((current) => (current === sentFile ? null : current));\n })\n .catch(() => {});\n };\n\n const config = attachment === true ? {} : attachment || null;\n\n return (\n <div ref={root} className={cn(\"space-y-2\", className)}>\n <Textarea\n rows={rows}\n dir=\"auto\"\n aria-label={labels.field}\n ref={box}\n placeholder={placeholder ?? labels.placeholder}\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={(event) => {\n if ((event.ctrlKey || event.metaKey) && event.key === \"Enter\") {\n event.preventDefault();\n send();\n }\n }}\n />\n <div className=\"flex flex-wrap items-end justify-between gap-2\">\n {config ? (\n <FeedbackAttachmentField\n value={file}\n onChange={setFile}\n labels={config.labels}\n accept={config.accept}\n maxBytes={config.maxBytes}\n onError={config.onError}\n onCaptureScreenshot={config.onCaptureScreenshot}\n // The box is this field's sibling; a paste in it bubbles to `root`.\n pasteFrom={root}\n />\n ) : (\n <span />\n )}\n <div className=\"ms-auto flex items-center gap-2\">\n <span className=\"text-xs text-[var(--text-placeholder)]\">{labels.sendHint(modifier)}</span>\n <Button onClick={send} disabled={!canSend} aria-busy={pending || undefined}>\n {pending ? (\n <Spinner label={null} className=\"size-4\" />\n ) : (\n <Send className=\"size-4 rtl:-scale-x-100\" aria-hidden />\n )}\n {labels.send}\n </Button>\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";AAqJW,SA+GP,UA/GO,KAiCG,YAjCH;AArJX,SAAS,WAAW,qBAAqB,iBAAiB,QAAQ,UAAU,4BAA4B;AAExG,SAAS,WAAW,YAAY;AAChC,SAAS,UAAU;AACnB,SAAS,0BAA0B;AACnC,SAAS,QAAQ,YAAY,SAAS,gBAAgB;AACtD,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,kBAAkB,cAAc,oBAAoB;AAC7D,SAAS,+BAA+B;AA8CjC,MAAM,iCAAuD;AAAA,EAClE,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AAAA,EACT,KAAK;AAAA,EACL,OAAO;AAAA,EACP,aAAa;AACf;AAaO,MAAM,mCAA2D;AAAA,EACtE,OAAO;AAAA,EACP,aAAa;AAAA,EACb,MAAM;AAAA,EACN,UAAU,CAAC,aAAa,GAAG,QAAQ;AACrC;AAkDO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EAC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,UAAO,SAAS,MAAM,UAAU,CAAC,SAAS,aAAW,WAAW,QAC9D;AAAA,oBACC,oBAAC,WAAQ,OAAO,MAAM,WAAU,UAAS,IAEzC,oBAAC,QAAK,WAAU,2BAA0B,eAAW,MAAC;AAAA,UAEvD,OAAO;AAAA,WACV;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAEJ;","names":["pending"]}
@@ -1,5 +1,6 @@
1
1
  export { DEFAULT_ATTACHMENT_ACCEPT, DEFAULT_FEEDBACK_ATTACHMENT_LABELS, DEFAULT_MAX_ATTACHMENT_BYTES, FeedbackAttachmentField, FeedbackAttachmentFieldLabels, pastedName } from './feedback/feedback-attachment.js';
2
- export { FeedbackAttachmentLabels, FeedbackCategoryOption, FeedbackDialog, FeedbackDialogLabels, FeedbackSubmission } from './feedback/feedback-dialog.js';
2
+ export { DEFAULT_FEEDBACK_DIALOG_LABELS, FeedbackAttachmentLabels, FeedbackCategoryOption, FeedbackDialog, FeedbackDialogLabels, FeedbackDialogTextLabels, FeedbackSubmission } from './feedback/feedback-dialog.js';
3
3
  export { FEEDBACK_CATEGORY_META, FEEDBACK_CATEGORY_ORDER, FEEDBACK_STATUS_META, FEEDBACK_STATUS_ORDER, FeedbackCategory, FeedbackCategoryBadge, FeedbackDetail, FeedbackDetailSection, FeedbackNoteAttachment, FeedbackNoteEditor, FeedbackProse, FeedbackStatus, FeedbackStatusBadge, FeedbackStatusTransitions, feedbackCategoryRank, nextFeedbackStatus, selectableFeedbackStatuses, visibleFeedbackStatuses } from './feedback/feedback-inbox.js';
4
+ export { DEFAULT_FEEDBACK_COMPOSER_LABELS, DEFAULT_FEEDBACK_THREAD_LABELS, FeedbackComposer, FeedbackComposerAttachment, FeedbackComposerHandle, FeedbackComposerLabels, FeedbackComposerProps, FeedbackThread, FeedbackThreadAttachment, FeedbackThreadLabels, FeedbackThreadMessage, FeedbackThreadProps } from './feedback/feedback-thread.js';
4
5
  import 'react';
5
6
  import 'lucide-react';
package/dist/feedback.js CHANGED
@@ -2,4 +2,5 @@
2
2
  export * from "./feedback/feedback-attachment.js";
3
3
  export * from "./feedback/feedback-dialog.js";
4
4
  export * from "./feedback/feedback-inbox.js";
5
+ export * from "./feedback/feedback-thread.js";
5
6
  //# sourceMappingURL=feedback.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/feedback.ts"],"sourcesContent":["// `@eifi1/ui-kit/feedback` — the report form and the parts an inbox is built from.\n//\n// A re-slicing of the main barrel, not a new API. The kit owns the status vocabulary,\n// the transition policy and the look; each app still wires its own API, columns,\n// strings and permissions — see the note at the top of feedback/feedback-inbox.tsx.\nexport * from \"./feedback/feedback-attachment\";\nexport * from \"./feedback/feedback-dialog\";\nexport * from \"./feedback/feedback-inbox\";\n"],"mappings":";AAKA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/feedback.ts"],"sourcesContent":["// `@eifi1/ui-kit/feedback` — the report form and the parts an inbox is built from.\n//\n// A re-slicing of the main barrel, not a new API. The kit owns the status vocabulary,\n// the transition policy and the look; each app still wires its own API, columns,\n// strings and permissions — see the note at the top of feedback/feedback-inbox.tsx.\nexport * from \"./feedback/feedback-attachment\";\nexport * from \"./feedback/feedback-dialog\";\nexport * from \"./feedback/feedback-inbox\";\nexport * from \"./feedback/feedback-thread\";\n"],"mappings":";AAKA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Fetch a file with the app's own credentials and hand back an object URL for it.
3
+ *
4
+ * A plain `<img src="/api/v1/…">` cannot carry a Bearer token, so the browser gets a
5
+ * 401 and the image — and any "open it" link built on the same path — fails. Both apps
6
+ * solved this once each, by hand: kastlan's `shared/components/authed-image.tsx` (ported
7
+ * from keksdose) and its `useDocumentBlobUrl` for floor plans. This is that code, once,
8
+ * with the two things neither copy did: a loading/error state a caller can render, and
9
+ * an abort when the URL changes mid-flight (a stale response used to overwrite the new
10
+ * one's object URL — and leak the old one, since nothing revoked it).
11
+ *
12
+ * The kit does no auth of its own: the caller hands over a {@link AuthedFetcher} — its
13
+ * axios client, its `fetch` with the header — and the kit only manages the blob's life:
14
+ *
15
+ * - created when the bytes arrive,
16
+ * - revoked when the URL changes, the fetcher reports an error, or the component
17
+ * unmounts — so a long gallery session does not accumulate blobs,
18
+ * - never exposed as a token-bearing URL: the object URL is `blob:` and local.
19
+ */
20
+ /**
21
+ * The app's authenticated GET. Resolve to the file's bytes: a `Blob` (axios with
22
+ * `responseType: "blob"`), or a `Response` (plain `fetch`), whose `ok` is checked here.
23
+ *
24
+ * Honour `signal` if you can — a thumbnail scrolled past, or a lightbox paged on, then
25
+ * stops downloading. Ignoring it is safe; the result of a superseded call is discarded
26
+ * either way.
27
+ */
28
+ type AuthedFetcher = (url: string, init: {
29
+ signal: AbortSignal;
30
+ }) => Promise<Blob | Response>;
31
+ /** `idle`: no URL. `loading`: the fetch is in flight. `ready`: `src` is usable.
32
+ * `error`: the fetch failed (see `error`). */
33
+ type AuthedSrcStatus = "idle" | "loading" | "ready" | "error";
34
+ interface UseAuthedSrcOptions {
35
+ /**
36
+ * How to fetch. Left out (or `null`), the URL is used as it is — `src` is the URL and
37
+ * the status `ready` at once — so a component that takes an OPTIONAL fetcher (the
38
+ * image grid, the lightbox) has one code path for public and protected images.
39
+ */
40
+ fetcher?: AuthedFetcher | null;
41
+ /** `false` holds the fetch — a lightbox slide that is not on screen. Default `true`. */
42
+ enabled?: boolean;
43
+ }
44
+ interface UseAuthedSrcResult {
45
+ /** The object URL (or, without a fetcher, the URL itself); `null` until ready. */
46
+ src: string | null;
47
+ status: AuthedSrcStatus;
48
+ /** What the fetcher threw, when `status` is `error`. */
49
+ error: unknown;
50
+ /** The blob's MIME type, once fetched (`""` when the server sent none). `undefined`
51
+ * without a fetcher — nothing was fetched to ask. Lets a caller that does not know
52
+ * whether a URL is an image or a PDF find out. */
53
+ type: string | undefined;
54
+ /** Fetch again — after an `error`, or to pick up a changed file at the same URL. */
55
+ retry: () => void;
56
+ }
57
+ /**
58
+ * `useAuthedSrc(url, { fetcher })` — see the module note.
59
+ *
60
+ * ```tsx
61
+ * const fetcher: AuthedFetcher = (url, { signal }) =>
62
+ * apiClient.get(url, { responseType: "blob", signal }).then((r) => r.data);
63
+ * const { src, status } = useAuthedSrc(photo.file_path, { fetcher });
64
+ * ```
65
+ *
66
+ * The fetcher is read through a ref, so an inline arrow does not refetch on every
67
+ * render; a change of `url` (or `retry`) does.
68
+ */
69
+ declare function useAuthedSrc(url: string | null | undefined, { fetcher, enabled }?: UseAuthedSrcOptions): UseAuthedSrcResult;
70
+
71
+ export { type AuthedFetcher, type AuthedSrcStatus, type UseAuthedSrcOptions, type UseAuthedSrcResult, useAuthedSrc };
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ async function toBlob(res) {
4
+ if (typeof Response !== "undefined" && res instanceof Response) {
5
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
6
+ return res.blob();
7
+ }
8
+ return res;
9
+ }
10
+ function useAuthedSrc(url, { fetcher, enabled = true } = {}) {
11
+ const fetcherRef = useRef(fetcher);
12
+ useEffect(() => {
13
+ fetcherRef.current = fetcher;
14
+ });
15
+ const hasFetcher = !!fetcher;
16
+ const [attempt, setAttempt] = useState(0);
17
+ const key = url && enabled && hasFetcher ? `${attempt}|${url}` : null;
18
+ const [state, setState] = useState({
19
+ key: null,
20
+ src: null,
21
+ status: "idle",
22
+ error: void 0,
23
+ type: void 0
24
+ });
25
+ useEffect(() => {
26
+ const fetchFn = fetcherRef.current;
27
+ if (!key || !url || !fetchFn) return;
28
+ const controller = new AbortController();
29
+ let created = null;
30
+ let active = true;
31
+ let settled = false;
32
+ fetchFn(url, { signal: controller.signal }).then(toBlob).then((blob) => {
33
+ settled = true;
34
+ if (!active) return;
35
+ created = URL.createObjectURL(blob);
36
+ setState({ key, src: created, status: "ready", error: void 0, type: blob.type });
37
+ }).catch((error) => {
38
+ settled = true;
39
+ if (!active) return;
40
+ setState({ key, src: null, status: "error", error, type: void 0 });
41
+ });
42
+ return () => {
43
+ active = false;
44
+ if (!settled) controller.abort();
45
+ if (created) URL.revokeObjectURL(created);
46
+ };
47
+ }, [key, url]);
48
+ const retry = useCallback(() => setAttempt((n) => n + 1), []);
49
+ if (!url || !enabled) {
50
+ return { src: null, status: "idle", error: void 0, type: void 0, retry };
51
+ }
52
+ if (!hasFetcher) {
53
+ return { src: url, status: "ready", error: void 0, type: void 0, retry };
54
+ }
55
+ if (state.key !== key) {
56
+ return { src: null, status: "loading", error: void 0, type: void 0, retry };
57
+ }
58
+ return { src: state.src, status: state.status, error: state.error, type: state.type, retry };
59
+ }
60
+ export {
61
+ useAuthedSrc
62
+ };
63
+ //# sourceMappingURL=use-authed-src.js.map