@alepha/ui 0.32.0 → 0.34.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 (402) hide show
  1. package/dist/account/AccountConnections.js +1 -1
  2. package/dist/account/AccountConnections.js.map +1 -1
  3. package/dist/account/AccountDeleteDialog.d.ts.map +1 -1
  4. package/dist/account/AccountDeleteDialog.js +17 -17
  5. package/dist/account/AccountDeleteDialog.js.map +1 -1
  6. package/dist/account/AccountKeys.js +2 -2
  7. package/dist/account/AccountKeys.js.map +1 -1
  8. package/dist/account/AccountMfaDialog.d.ts.map +1 -1
  9. package/dist/account/AccountMfaDialog.js +19 -25
  10. package/dist/account/AccountMfaDialog.js.map +1 -1
  11. package/dist/account/AccountPasswordDialog.d.ts.map +1 -1
  12. package/dist/account/AccountPasswordDialog.js +25 -24
  13. package/dist/account/AccountPasswordDialog.js.map +1 -1
  14. package/dist/account/AccountProfile.d.ts.map +1 -1
  15. package/dist/account/AccountProfile.js +17 -24
  16. package/dist/account/AccountProfile.js.map +1 -1
  17. package/dist/account/AccountSecurity.d.ts.map +1 -1
  18. package/dist/account/AccountSecurity.js +21 -19
  19. package/dist/account/AccountSecurity.js.map +1 -1
  20. package/dist/account/AccountSessions.js +1 -1
  21. package/dist/account/AccountSessions.js.map +1 -1
  22. package/dist/account/ApiKeyCreateDialog.d.ts.map +1 -1
  23. package/dist/account/ApiKeyCreateDialog.js +8 -12
  24. package/dist/account/ApiKeyCreateDialog.js.map +1 -1
  25. package/dist/admin/AdminFiles.js +1 -1
  26. package/dist/admin/AdminFiles.js.map +1 -1
  27. package/dist/admin/AdminJobs.js +1 -1
  28. package/dist/admin/AdminJobs.js.map +1 -1
  29. package/dist/admin/AdminKeys.js +1 -1
  30. package/dist/admin/AdminKeys.js.map +1 -1
  31. package/dist/admin/AdminParameters.d.ts.map +1 -1
  32. package/dist/admin/AdminParameters.js +7 -5
  33. package/dist/admin/AdminParameters.js.map +1 -1
  34. package/dist/admin/AdminParametersTreeFooterActions.d.ts +2 -2
  35. package/dist/admin/AdminParametersTreeFooterActions.d.ts.map +1 -1
  36. package/dist/admin/AdminParametersTreeFooterActions.js.map +1 -1
  37. package/dist/admin/AdminParametersTreePane.d.ts +2 -2
  38. package/dist/admin/AdminParametersTreePane.d.ts.map +1 -1
  39. package/dist/admin/AdminParametersTreePane.js.map +1 -1
  40. package/dist/admin/AdminRouter.d.ts +1 -3
  41. package/dist/admin/AdminRouter.d.ts.map +1 -1
  42. package/dist/admin/AdminRouter.js +2 -4
  43. package/dist/admin/AdminRouter.js.map +1 -1
  44. package/dist/admin/AdminSessions.js +1 -1
  45. package/dist/admin/AdminSessions.js.map +1 -1
  46. package/dist/admin/AdminUserAvatarControl.d.ts.map +1 -1
  47. package/dist/admin/AdminUserAvatarControl.js +9 -16
  48. package/dist/admin/AdminUserAvatarControl.js.map +1 -1
  49. package/dist/admin/AdminUserDetail.js +4 -4
  50. package/dist/admin/AdminUserDetail.js.map +1 -1
  51. package/dist/admin/AdminUsers.d.ts.map +1 -1
  52. package/dist/admin/AdminUsers.js +10 -12
  53. package/dist/admin/AdminUsers.js.map +1 -1
  54. package/dist/admin/AdminUsersRolesPicker.d.ts +5 -1
  55. package/dist/admin/AdminUsersRolesPicker.d.ts.map +1 -1
  56. package/dist/admin/AdminUsersRolesPicker.js +2 -3
  57. package/dist/admin/AdminUsersRolesPicker.js.map +1 -1
  58. package/dist/admin/analytics/AdvancedSection.d.ts.map +1 -1
  59. package/dist/admin/analytics/AdvancedSection.js +7 -3
  60. package/dist/admin/analytics/AdvancedSection.js.map +1 -1
  61. package/dist/admin/analytics/AnalyticsChart.d.ts +1 -0
  62. package/dist/admin/analytics/AnalyticsChart.d.ts.map +1 -1
  63. package/dist/admin/analytics/AnalyticsChart.js +3 -1
  64. package/dist/admin/analytics/AnalyticsChart.js.map +1 -1
  65. package/dist/admin/analytics/AnalyticsChartHeader.d.ts +5 -0
  66. package/dist/admin/analytics/AnalyticsChartHeader.d.ts.map +1 -1
  67. package/dist/admin/analytics/AnalyticsChartHeader.js +7 -2
  68. package/dist/admin/analytics/AnalyticsChartHeader.js.map +1 -1
  69. package/dist/admin/analytics/AnalyticsChartLine.d.ts +5 -0
  70. package/dist/admin/analytics/AnalyticsChartLine.d.ts.map +1 -1
  71. package/dist/admin/analytics/AnalyticsChartLine.js +6 -2
  72. package/dist/admin/analytics/AnalyticsChartLine.js.map +1 -1
  73. package/dist/admin/analytics/CoarsenedBadge.d.ts +15 -0
  74. package/dist/admin/analytics/CoarsenedBadge.d.ts.map +1 -0
  75. package/dist/admin/analytics/CoarsenedBadge.js +30 -0
  76. package/dist/admin/analytics/CoarsenedBadge.js.map +1 -0
  77. package/dist/admin/analytics/CompareNote.d.ts +5 -0
  78. package/dist/admin/analytics/CompareNote.d.ts.map +1 -1
  79. package/dist/admin/analytics/CompareNote.js +5 -1
  80. package/dist/admin/analytics/CompareNote.js.map +1 -1
  81. package/dist/admin/analytics/FilterEditor.d.ts +1 -0
  82. package/dist/admin/analytics/FilterEditor.d.ts.map +1 -1
  83. package/dist/admin/analytics/FilterEditor.js +1 -0
  84. package/dist/admin/analytics/FilterEditor.js.map +1 -1
  85. package/dist/admin/analytics/GroupByChips.d.ts +17 -11
  86. package/dist/admin/analytics/GroupByChips.d.ts.map +1 -1
  87. package/dist/admin/analytics/GroupByChips.js +21 -20
  88. package/dist/admin/analytics/GroupByChips.js.map +1 -1
  89. package/dist/admin/analytics/MeasureChips.d.ts +11 -6
  90. package/dist/admin/analytics/MeasureChips.d.ts.map +1 -1
  91. package/dist/admin/analytics/MeasureChips.js +13 -16
  92. package/dist/admin/analytics/MeasureChips.js.map +1 -1
  93. package/dist/admin/analytics/QueryPanel.d.ts.map +1 -1
  94. package/dist/admin/analytics/QueryPanel.js +10 -6
  95. package/dist/admin/analytics/QueryPanel.js.map +1 -1
  96. package/dist/admin/analytics/RangeControl.d.ts +11 -7
  97. package/dist/admin/analytics/RangeControl.d.ts.map +1 -1
  98. package/dist/admin/analytics/RangeControl.js +83 -30
  99. package/dist/admin/analytics/RangeControl.js.map +1 -1
  100. package/dist/admin/analytics/ResultsPane.d.ts.map +1 -1
  101. package/dist/admin/analytics/ResultsPane.js +13 -9
  102. package/dist/admin/analytics/ResultsPane.js.map +1 -1
  103. package/dist/admin/analytics/ResultsTable.d.ts.map +1 -1
  104. package/dist/admin/analytics/ResultsTable.js +3 -3
  105. package/dist/admin/analytics/ResultsTable.js.map +1 -1
  106. package/dist/admin/analytics/TotalsCards.d.ts +2 -1
  107. package/dist/admin/analytics/TotalsCards.d.ts.map +1 -1
  108. package/dist/admin/analytics/TotalsCards.js +9 -10
  109. package/dist/admin/analytics/TotalsCards.js.map +1 -1
  110. package/dist/admin/analytics/analyticsModel.d.ts +126 -17
  111. package/dist/admin/analytics/analyticsModel.d.ts.map +1 -1
  112. package/dist/admin/analytics/analyticsModel.js +283 -48
  113. package/dist/admin/analytics/analyticsModel.js.map +1 -1
  114. package/dist/admin/analytics/analyticsTypes.d.ts +55 -4
  115. package/dist/admin/analytics/analyticsTypes.d.ts.map +1 -1
  116. package/dist/admin/analytics/chartModel.d.ts +38 -3
  117. package/dist/admin/analytics/chartModel.d.ts.map +1 -1
  118. package/dist/admin/analytics/chartModel.js +86 -16
  119. package/dist/admin/analytics/chartModel.js.map +1 -1
  120. package/dist/admin/analytics/instantRangeSchema.d.ts +8 -0
  121. package/dist/admin/analytics/instantRangeSchema.d.ts.map +1 -0
  122. package/dist/admin/analytics/instantRangeSchema.js +13 -0
  123. package/dist/admin/analytics/instantRangeSchema.js.map +1 -0
  124. package/dist/admin/analytics/useAnalyticsQuery.d.ts +13 -3
  125. package/dist/admin/analytics/useAnalyticsQuery.d.ts.map +1 -1
  126. package/dist/admin/analytics/useAnalyticsQuery.js +60 -21
  127. package/dist/admin/analytics/useAnalyticsQuery.js.map +1 -1
  128. package/dist/admin/analytics/useFilterValues.d.ts +4 -0
  129. package/dist/admin/analytics/useFilterValues.d.ts.map +1 -1
  130. package/dist/admin/analytics/useFilterValues.js +6 -6
  131. package/dist/admin/analytics/useFilterValues.js.map +1 -1
  132. package/dist/admin/useConfirmedAction.d.ts +8 -2
  133. package/dist/admin/useConfirmedAction.d.ts.map +1 -1
  134. package/dist/admin/useConfirmedAction.js +15 -4
  135. package/dist/admin/useConfirmedAction.js.map +1 -1
  136. package/dist/ai/AiChat.d.ts +30 -0
  137. package/dist/ai/AiChat.d.ts.map +1 -0
  138. package/dist/ai/AiChat.js +116 -0
  139. package/dist/ai/AiChat.js.map +1 -0
  140. package/dist/ai/AiChatConfirmCard.d.ts +17 -0
  141. package/dist/ai/AiChatConfirmCard.d.ts.map +1 -0
  142. package/dist/ai/AiChatConfirmCard.js +47 -0
  143. package/dist/ai/AiChatConfirmCard.js.map +1 -0
  144. package/dist/ai/AiChatHistory.d.ts +14 -0
  145. package/dist/ai/AiChatHistory.d.ts.map +1 -0
  146. package/dist/ai/AiChatHistory.js +40 -0
  147. package/dist/ai/AiChatHistory.js.map +1 -0
  148. package/dist/ai/AiChatMessage.d.ts +10 -0
  149. package/dist/ai/AiChatMessage.d.ts.map +1 -0
  150. package/dist/ai/AiChatMessage.js +38 -0
  151. package/dist/ai/AiChatMessage.js.map +1 -0
  152. package/dist/ai/AiFormRegistry.d.ts +37 -0
  153. package/dist/ai/AiFormRegistry.d.ts.map +1 -0
  154. package/dist/ai/AiFormRegistry.js +59 -0
  155. package/dist/ai/AiFormRegistry.js.map +1 -0
  156. package/dist/ai/aiChatMessageFormSchema.d.ts +7 -0
  157. package/dist/ai/aiChatMessageFormSchema.d.ts.map +1 -0
  158. package/dist/ai/aiChatMessageFormSchema.js +13 -0
  159. package/dist/ai/aiChatMessageFormSchema.js.map +1 -0
  160. package/dist/ai/aiContextAtom.d.ts +16 -0
  161. package/dist/ai/aiContextAtom.d.ts.map +1 -0
  162. package/dist/ai/aiContextAtom.js +25 -0
  163. package/dist/ai/aiContextAtom.js.map +1 -0
  164. package/dist/ai/index.d.ts +18 -0
  165. package/dist/ai/index.d.ts.map +1 -0
  166. package/dist/ai/index.js +10 -0
  167. package/dist/ai/useAiChat.d.ts +82 -0
  168. package/dist/ai/useAiChat.d.ts.map +1 -0
  169. package/dist/ai/useAiChat.js +256 -0
  170. package/dist/ai/useAiChat.js.map +1 -0
  171. package/dist/ai/useAiContext.d.ts +33 -0
  172. package/dist/ai/useAiContext.d.ts.map +1 -0
  173. package/dist/ai/useAiContext.js +52 -0
  174. package/dist/ai/useAiContext.js.map +1 -0
  175. package/dist/auth/AuthLogin.d.ts.map +1 -1
  176. package/dist/auth/AuthLogin.js +4 -4
  177. package/dist/auth/AuthLogin.js.map +1 -1
  178. package/dist/auth/AuthRegister.js.map +1 -1
  179. package/dist/core/Breadcrumb.js +1 -1
  180. package/dist/core/Breadcrumb.js.map +1 -1
  181. package/dist/core/Sheet.d.ts +6 -1
  182. package/dist/core/Sheet.d.ts.map +1 -1
  183. package/dist/core/Sheet.js +2 -2
  184. package/dist/core/Sheet.js.map +1 -1
  185. package/dist/core/Sidebar.d.ts +7 -1
  186. package/dist/core/Sidebar.d.ts.map +1 -1
  187. package/dist/core/Sidebar.js +22 -17
  188. package/dist/core/Sidebar.js.map +1 -1
  189. package/dist/core/index.js +2 -2
  190. package/dist/form/AutoForm.js +1 -1
  191. package/dist/form/AutoForm.js.map +1 -1
  192. package/dist/form/Control.d.ts +14 -0
  193. package/dist/form/Control.d.ts.map +1 -1
  194. package/dist/form/Control.js +10 -4
  195. package/dist/form/Control.js.map +1 -1
  196. package/dist/form/ControlArray.js +5 -5
  197. package/dist/form/ControlArray.js.map +1 -1
  198. package/dist/form/ControlDate.d.ts +11 -0
  199. package/dist/form/ControlDate.d.ts.map +1 -1
  200. package/dist/form/ControlDate.js +20 -2
  201. package/dist/form/ControlDate.js.map +1 -1
  202. package/dist/form/ControlDatePopover.d.ts +3 -0
  203. package/dist/form/ControlDatePopover.d.ts.map +1 -1
  204. package/dist/form/ControlDatePopover.js +1 -0
  205. package/dist/form/ControlDatePopover.js.map +1 -1
  206. package/dist/form/ControlMonthPopover.d.ts +25 -0
  207. package/dist/form/ControlMonthPopover.d.ts.map +1 -0
  208. package/dist/form/ControlMonthPopover.js +112 -0
  209. package/dist/form/ControlMonthPopover.js.map +1 -0
  210. package/dist/form/ControlSelect.d.ts +7 -0
  211. package/dist/form/ControlSelect.d.ts.map +1 -1
  212. package/dist/form/ControlSelect.js +39 -2
  213. package/dist/form/ControlSelect.js.map +1 -1
  214. package/dist/form/ControlUpload.d.ts +1 -1
  215. package/dist/form/ControlUpload.js.map +1 -1
  216. package/dist/i18n/fr/uiFr.d.ts.map +1 -1
  217. package/dist/i18n/fr/uiFr.js +31 -10
  218. package/dist/i18n/fr/uiFr.js.map +1 -1
  219. package/dist/organizations/MyOrganizationInvitations.js +2 -2
  220. package/dist/organizations/MyOrganizationInvitations.js.map +1 -1
  221. package/dist/organizations/OrganizationInviteDialog.js +1 -1
  222. package/dist/organizations/OrganizationInviteDialog.js.map +1 -1
  223. package/dist/organizations/OrganizationMembers.js +1 -1
  224. package/dist/organizations/OrganizationMembers.js.map +1 -1
  225. package/dist/organizations/OrganizationPendingInvitations.js +1 -1
  226. package/dist/organizations/OrganizationPendingInvitations.js.map +1 -1
  227. package/dist/organizations/OrganizationRanks.js +3 -3
  228. package/dist/organizations/OrganizationRanks.js.map +1 -1
  229. package/dist/organizations/useInviteOrganizationMember.d.ts +6 -1
  230. package/dist/organizations/useInviteOrganizationMember.d.ts.map +1 -1
  231. package/dist/organizations/useInviteOrganizationMember.js +13 -13
  232. package/dist/organizations/useInviteOrganizationMember.js.map +1 -1
  233. package/dist/organizations/useRevokeOrganizationInvitation.d.ts +7 -1
  234. package/dist/organizations/useRevokeOrganizationInvitation.d.ts.map +1 -1
  235. package/dist/organizations/useRevokeOrganizationInvitation.js +13 -2
  236. package/dist/organizations/useRevokeOrganizationInvitation.js.map +1 -1
  237. package/dist/shell/AppShellNavCollapse.d.ts +4 -0
  238. package/dist/shell/AppShellNavCollapse.d.ts.map +1 -1
  239. package/dist/shell/AppShellNavCollapse.js +1 -0
  240. package/dist/shell/AppShellNavCollapse.js.map +1 -1
  241. package/dist/shell/AppShellSidebarNavItem.d.ts.map +1 -1
  242. package/dist/shell/AppShellSidebarNavItem.js +13 -9
  243. package/dist/shell/AppShellSidebarNavItem.js.map +1 -1
  244. package/dist/shell/AppShellStatefulSidebarTrigger.d.ts.map +1 -1
  245. package/dist/shell/AppShellStatefulSidebarTrigger.js +5 -2
  246. package/dist/shell/AppShellStatefulSidebarTrigger.js.map +1 -1
  247. package/dist/shell/ButtonUser.d.ts +1 -2
  248. package/dist/shell/ButtonUser.d.ts.map +1 -1
  249. package/dist/shell/ButtonUser.js +14 -42
  250. package/dist/shell/ButtonUser.js.map +1 -1
  251. package/dist/shell/ButtonUserContent.d.ts +13 -0
  252. package/dist/shell/ButtonUserContent.d.ts.map +1 -0
  253. package/dist/shell/ButtonUserContent.js +52 -0
  254. package/dist/shell/ButtonUserContent.js.map +1 -0
  255. package/dist/shell/ButtonUserPlaceholder.d.ts +14 -0
  256. package/dist/shell/ButtonUserPlaceholder.d.ts.map +1 -0
  257. package/dist/shell/ButtonUserPlaceholder.js +17 -0
  258. package/dist/shell/ButtonUserPlaceholder.js.map +1 -0
  259. package/dist/styles.css +31 -0
  260. package/dist/table/DataTable.d.ts.map +1 -1
  261. package/dist/table/DataTable.js +3 -2
  262. package/dist/table/DataTable.js.map +1 -1
  263. package/dist/table/DataTableFilterBar.js +2 -2
  264. package/dist/table/DataTableFilterBar.js.map +1 -1
  265. package/dist/table/DataTableToolbar.d.ts +7 -3
  266. package/dist/table/DataTableToolbar.d.ts.map +1 -1
  267. package/dist/table/DataTableToolbar.js +7 -3
  268. package/dist/table/DataTableToolbar.js.map +1 -1
  269. package/dist/table/dataTableBaseProps.d.ts +18 -1
  270. package/dist/table/dataTableBaseProps.d.ts.map +1 -1
  271. package/dist/table/dataTableTypes.d.ts +3 -3
  272. package/dist/table/dataTableTypes.d.ts.map +1 -1
  273. package/dist/table/useDataTableData.d.ts.map +1 -1
  274. package/dist/table/useDataTableData.js +3 -1
  275. package/dist/table/useDataTableData.js.map +1 -1
  276. package/dist/table/useDataTableRefresh.js +2 -2
  277. package/dist/table/useDataTableRefresh.js.map +1 -1
  278. package/dist/table/useDataTableSummary.d.ts.map +1 -1
  279. package/dist/table/useDataTableSummary.js +2 -1
  280. package/dist/table/useDataTableSummary.js.map +1 -1
  281. package/docs/packages-alepha-ui-account.md +29 -0
  282. package/docs/packages-alepha-ui-admin.md +35 -0
  283. package/docs/packages-alepha-ui-ai.md +29 -0
  284. package/docs/packages-alepha-ui-auth.md +23 -0
  285. package/docs/packages-alepha-ui-calendar.md +24 -0
  286. package/docs/packages-alepha-ui-chart.md +23 -0
  287. package/docs/packages-alepha-ui-command.md +24 -0
  288. package/docs/packages-alepha-ui-core.md +40 -0
  289. package/docs/packages-alepha-ui-form.md +29 -0
  290. package/docs/packages-alepha-ui-i18n-fr.md +31 -0
  291. package/docs/packages-alepha-ui-markdown.md +27 -0
  292. package/docs/packages-alepha-ui-organizations.md +20 -0
  293. package/docs/packages-alepha-ui-otp.md +22 -0
  294. package/docs/packages-alepha-ui-overview.md +337 -0
  295. package/docs/packages-alepha-ui-resizable.md +22 -0
  296. package/docs/packages-alepha-ui-settings.md +23 -0
  297. package/docs/packages-alepha-ui-shell.md +41 -0
  298. package/docs/packages-alepha-ui-table.md +37 -0
  299. package/docs/packages-alepha-ui-tree.md +31 -0
  300. package/package.json +18 -8
  301. package/src/account/AccountConnections.tsx +1 -1
  302. package/src/account/AccountDeleteDialog.tsx +25 -31
  303. package/src/account/AccountKeys.tsx +2 -2
  304. package/src/account/AccountMfaDialog.tsx +33 -27
  305. package/src/account/AccountPasswordDialog.tsx +36 -39
  306. package/src/account/AccountProfile.tsx +29 -43
  307. package/src/account/AccountSecurity.tsx +57 -64
  308. package/src/account/AccountSessions.tsx +1 -1
  309. package/src/account/ApiKeyCreateDialog.tsx +12 -20
  310. package/src/account/__tests__/AccountRouter.spec.ts +2 -1
  311. package/src/admin/AdminFiles.tsx +1 -1
  312. package/src/admin/AdminJobs.tsx +1 -1
  313. package/src/admin/AdminKeys.tsx +1 -1
  314. package/src/admin/AdminParameters.tsx +7 -5
  315. package/src/admin/AdminParametersTreeFooterActions.tsx +2 -2
  316. package/src/admin/AdminParametersTreePane.tsx +2 -2
  317. package/src/admin/AdminRouter.tsx +2 -4
  318. package/src/admin/AdminSessions.tsx +1 -1
  319. package/src/admin/AdminUserAvatarControl.tsx +17 -22
  320. package/src/admin/AdminUserDetail.tsx +4 -4
  321. package/src/admin/AdminUsers.tsx +10 -12
  322. package/src/admin/AdminUsersRolesPicker.tsx +11 -4
  323. package/src/admin/__tests__/AdminRouter.spec.ts +3 -2
  324. package/src/admin/analytics/AdvancedSection.tsx +39 -30
  325. package/src/admin/analytics/AnalyticsChart.tsx +7 -1
  326. package/src/admin/analytics/AnalyticsChartHeader.tsx +22 -7
  327. package/src/admin/analytics/AnalyticsChartLine.tsx +15 -2
  328. package/src/admin/analytics/CoarsenedBadge.tsx +38 -0
  329. package/src/admin/analytics/CompareNote.tsx +16 -5
  330. package/src/admin/analytics/FilterEditor.tsx +2 -0
  331. package/src/admin/analytics/GroupByChips.tsx +40 -27
  332. package/src/admin/analytics/MeasureChips.tsx +19 -11
  333. package/src/admin/analytics/QueryPanel.tsx +11 -6
  334. package/src/admin/analytics/RangeControl.tsx +91 -27
  335. package/src/admin/analytics/ResultsPane.tsx +20 -6
  336. package/src/admin/analytics/ResultsTable.tsx +9 -5
  337. package/src/admin/analytics/TotalsCards.tsx +24 -11
  338. package/src/admin/analytics/analyticsModel.spec.ts +167 -36
  339. package/src/admin/analytics/analyticsModel.ts +358 -49
  340. package/src/admin/analytics/analyticsTypes.ts +56 -4
  341. package/src/admin/analytics/chartModel.ts +139 -20
  342. package/src/admin/analytics/instantRangeSchema.ts +9 -0
  343. package/src/admin/analytics/useAnalyticsQuery.ts +98 -35
  344. package/src/admin/analytics/useFilterValues.ts +16 -5
  345. package/src/admin/useConfirmedAction.tsx +24 -10
  346. package/src/ai/AiChat.tsx +151 -0
  347. package/src/ai/AiChatConfirmCard.tsx +64 -0
  348. package/src/ai/AiChatHistory.tsx +60 -0
  349. package/src/ai/AiChatMessage.tsx +57 -0
  350. package/src/ai/AiFormRegistry.ts +78 -0
  351. package/src/ai/__tests__/AiChat.browser.spec.tsx +391 -0
  352. package/src/ai/aiChatMessageFormSchema.ts +8 -0
  353. package/src/ai/aiContextAtom.ts +23 -0
  354. package/src/ai/index.ts +18 -0
  355. package/src/ai/useAiChat.ts +343 -0
  356. package/src/ai/useAiContext.ts +74 -0
  357. package/src/auth/AuthLogin.tsx +10 -9
  358. package/src/auth/AuthRegister.tsx +2 -2
  359. package/src/core/Breadcrumb.tsx +1 -1
  360. package/src/core/Sheet.tsx +9 -2
  361. package/src/core/Sidebar.tsx +45 -22
  362. package/src/form/AutoForm.tsx +1 -1
  363. package/src/form/Control.tsx +27 -2
  364. package/src/form/ControlArray.tsx +5 -5
  365. package/src/form/ControlDate.tsx +37 -2
  366. package/src/form/ControlDatePopover.tsx +4 -1
  367. package/src/form/ControlMonthPopover.tsx +169 -0
  368. package/src/form/ControlSelect.tsx +64 -2
  369. package/src/form/ControlUpload.tsx +1 -1
  370. package/src/form/__tests__/ControlArrayChildChange.browser.spec.tsx +1 -1
  371. package/src/form/__tests__/ControlChoices.browser.spec.tsx +130 -0
  372. package/src/i18n/fr/uiFr.ts +36 -11
  373. package/src/organizations/MyOrganizationInvitations.tsx +2 -2
  374. package/src/organizations/OrganizationInviteDialog.tsx +1 -1
  375. package/src/organizations/OrganizationMembers.tsx +1 -1
  376. package/src/organizations/OrganizationPendingInvitations.tsx +1 -1
  377. package/src/organizations/OrganizationRanks.tsx +3 -3
  378. package/src/organizations/useInviteOrganizationMember.ts +22 -15
  379. package/src/organizations/useRevokeOrganizationInvitation.ts +23 -4
  380. package/src/shell/AppShellNavCollapse.tsx +5 -0
  381. package/src/shell/AppShellSidebarNavItem.tsx +23 -10
  382. package/src/shell/AppShellStatefulSidebarTrigger.tsx +10 -2
  383. package/src/shell/ButtonUser.tsx +14 -79
  384. package/src/shell/ButtonUserContent.tsx +92 -0
  385. package/src/shell/ButtonUserPlaceholder.tsx +25 -0
  386. package/src/shell/__tests__/ActionErrorToaster.browser.spec.tsx +1 -1
  387. package/src/shell/__tests__/ActionErrorToasterHandled.browser.spec.tsx +1 -2
  388. package/src/shell/__tests__/AppShell.pageCache.spec.tsx +67 -0
  389. package/src/shell/__tests__/AppShellDirection.browser.spec.tsx +95 -0
  390. package/src/styles.css +31 -0
  391. package/src/table/DataTable.tsx +3 -1
  392. package/src/table/DataTableFilterBar.tsx +2 -2
  393. package/src/table/DataTableToolbar.tsx +18 -3
  394. package/src/table/__tests__/DataTableFilterDateRange.browser.spec.tsx +1 -1
  395. package/src/table/__tests__/DataTableLeading.browser.spec.tsx +130 -0
  396. package/src/table/__tests__/DataTableQuerySeed.browser.spec.tsx +1 -1
  397. package/src/table/__tests__/DataTableShareFilters.browser.spec.tsx +1 -1
  398. package/src/table/dataTableBaseProps.ts +18 -1
  399. package/src/table/dataTableTypes.ts +3 -3
  400. package/src/table/useDataTableData.ts +2 -0
  401. package/src/table/useDataTableRefresh.ts +3 -3
  402. package/src/table/useDataTableSummary.ts +2 -1
@@ -47,6 +47,7 @@ const ControlDatePopover = (props) => {
47
47
  children: [/* @__PURE__ */ jsxs("div", {
48
48
  className: TRIGGER_WRAPPER_CLASSES,
49
49
  children: [/* @__PURE__ */ jsxs(PopoverTrigger, {
50
+ ...props.triggerProps,
50
51
  id: props.id,
51
52
  "data-slot": "date-trigger",
52
53
  disabled: props.disabled,
@@ -1 +1 @@
1
- {"version":3,"file":"ControlDatePopover.js","names":["CalendarIcon","ChevronDownIcon"],"sources":["../../src/form/ControlDatePopover.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { useI18n } from \"alepha/react/i18n\";\nimport {\n Calendar as CalendarIcon,\n ChevronDown as ChevronDownIcon,\n} from \"lucide-react\";\nimport { useState } from \"react\";\nimport type { DayPickerProps } from \"react-day-picker\";\n\nimport { LazyCalendar, preloadCalendar } from \"../calendar/LazyCalendar.tsx\";\nimport { Input } from \"../core/Input.tsx\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../core/Popover.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport { DATE_ONLY, formatDateOnly, parseDateOnly } from \"./dateOnly.ts\";\nimport {\n ControlClearButton,\n TRIGGER_CLASSES,\n TRIGGER_SIZES,\n TRIGGER_WRAPPER_CLASSES,\n} from \"./fieldTrigger.tsx\";\n\nexport interface ControlDatePopoverProps {\n id?: string;\n value?: string;\n withTime: boolean;\n disabled?: boolean;\n clearable?: boolean;\n captionLayout?: DayPickerProps[\"captionLayout\"];\n startMonth?: Date;\n endMonth?: Date;\n onChange: (value: string | undefined) => void;\n}\n\nexport const ControlDatePopover = (props: ControlDatePopoverProps) => {\n const { tr, l } = useI18n();\n const [open, setOpen] = useState(false);\n const date = props.value\n ? !props.withTime && DATE_ONLY.test(props.value)\n ? parseDateOnly(props.value)\n : new Date(props.value)\n : undefined;\n\n // In the page's language, never the browser's. `toLocaleString()` with no\n // locale followed the browser, so an English browser on a French page\n // printed 9/10/2026 for the 10th of September, and the server, which has no\n // browser, rendered yet another shape before hydration (#Q2392). The\n // runtime's time zone is unchanged: `Intl` still formats in it.\n const formatted = date\n ? props.withTime\n ? l(date, {\n date: {\n year: \"numeric\",\n month: \"numeric\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"2-digit\",\n },\n })\n : l(date)\n : \"\";\n\n const handleDate = (d: Date | undefined) => {\n if (!d) {\n props.onChange(undefined);\n return;\n }\n if (props.withTime) {\n props.onChange(d.toISOString());\n } else {\n props.onChange(formatDateOnly(d));\n setOpen(false);\n }\n };\n\n const handleTime = (timeStr: string) => {\n if (!date) return;\n const [h, m] = timeStr.split(\":\").map(Number);\n const next = new Date(date);\n next.setHours(h ?? 0, m ?? 0, 0, 0);\n props.onChange(next.toISOString());\n };\n\n const timeValue =\n date && props.withTime\n ? `${String(date.getHours()).padStart(2, \"0\")}:${String(date.getMinutes()).padStart(2, \"0\")}`\n : \"\";\n\n const showClear = Boolean(props.clearable && date && !props.disabled);\n const size = TRIGGER_SIZES.default;\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n {/* The kit's field trigger, and the kit's clear button positioned on it\n - `control-base/field-trigger`, the same two a select draws. The\n clear sits BESIDE the trigger rather than inside it: a button nested\n in a button is invalid, and Base UI's popover trigger would swallow\n its click anyway. */}\n <div className={TRIGGER_WRAPPER_CLASSES}>\n <PopoverTrigger\n id={props.id}\n // A FIELD trigger, not a button, and the distinction is load\n // bearing: `styles.css` gives the `--border-hover` border to a\n // list of `data-slot`s, and this one was not on it, so the date\n // control was the only field in the kit that did not darken its\n // border under the pointer.\n //\n // ⚠️ It used to render `Button variant=\"outline\"` and then undo\n // the button-ness of it in four overrides - the border token, the\n // hover fill, the open-state fill, the placeholder colour - which\n // is a fair description of why it still did not look like the\n // selects beside it (feedback #2197). The shared trigger is a\n // field to begin with, so there is nothing left to undo.\n data-slot=\"date-trigger\"\n disabled={props.disabled}\n // The calendar is a chunk of its own (`LazyCalendar`). Asking for it\n // as the pointer arrives or focus lands means the click that opens\n // the popover usually finds it already downloaded.\n onPointerEnter={preloadCalendar}\n onFocus={preloadCalendar}\n className={cn(\n TRIGGER_CLASSES,\n size.trigger,\n size.chevron,\n // Muted means \"nothing picked yet\", exactly as on a select. With\n // a value the text is already `foreground`, so this only matters\n // while empty.\n !date && \"text-muted-foreground\",\n )}\n >\n {/* The room for the clear button - see `clearGap` in TRIGGER_SIZES\n for why it is a margin here and not padding on the trigger, and\n `ControlSelectCombobox` for `trigger-label`. */}\n <span\n data-slot=\"trigger-label\"\n className={cn(\n \"flex min-w-0 items-center gap-2\",\n showClear && size.clearGap,\n )}\n >\n {/*\n Muted whatever the field holds, matching `InputGroupAddon`, which\n paints every other leading icon in the kit `text-muted-foreground`\n on the container.\n\n Without the class this icon simply inherits the trigger's `color`,\n which the control swaps between muted and foreground to grey the\n PLACEHOLDER - so the icon brightened when a date was picked. That\n looked deliberate and was not: an icon says what kind of field this\n is, which does not change when you fill it, and the text beside it\n already carries filled-versus-empty.\n */}\n <CalendarIcon\n className={cn(\"text-muted-foreground shrink-0\", size.icon)}\n />\n <span className=\"truncate\">\n {formatted ||\n tr(\"controlDate.placeholder\", { default: \"Pick a date\" })}\n </span>\n </span>\n {/* Same trailing caret a select trigger carries, for the same\n reason: this opens a popover, and without it the control reads\n as a text field that happens to have a calendar glyph. */}\n <ChevronDownIcon className=\"text-muted-foreground pointer-events-none size-4 shrink-0\" />\n </PopoverTrigger>\n {showClear && (\n <ControlClearButton onClick={() => props.onChange(undefined)} />\n )}\n </div>\n <PopoverContent className=\"w-auto p-0\" align=\"start\">\n <LazyCalendar\n mode=\"single\"\n selected={date}\n onSelect={handleDate}\n captionLayout={props.captionLayout}\n startMonth={props.startMonth}\n endMonth={props.endMonth}\n />\n {props.withTime && (\n <div className=\"border-t p-3\">\n <Input\n type=\"time\"\n value={timeValue}\n onChange={(e) => handleTime(e.target.value)}\n />\n </div>\n )}\n </PopoverContent>\n </Popover>\n );\n};\n"],"mappings":";;;;;;;;;;;AAoCA,MAAa,sBAAsB,UAAmC;CACpE,MAAM,EAAE,IAAI,MAAM,QAAQ;CAC1B,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CACtC,MAAM,OAAO,MAAM,QACf,CAAC,MAAM,YAAY,UAAU,KAAK,MAAM,KAAK,IAC3C,cAAc,MAAM,KAAK,IACzB,IAAI,KAAK,MAAM,KAAK,IACtB,KAAA;CAOJ,MAAM,YAAY,OACd,MAAM,WACJ,EAAE,MAAM,EACN,MAAM;EACJ,MAAM;EACN,OAAO;EACP,KAAK;EACL,MAAM;EACN,QAAQ;CACV,EACF,CAAC,IACD,EAAE,IAAI,IACR;CAEJ,MAAM,cAAc,MAAwB;EAC1C,IAAI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ACC,aAAD,EAAiB,WAAU,4DAA6D,CAAA,CAC1E;GACf,CAAA,GAAA,aACC,oBAAC,oBAAD,EAAoB,eAAe,MAAM,SAAS,KAAA,CAAS,EAAI,CAAA,CAE9D;EACL,CAAA,GAAA,qBAAC,gBAAD;GAAgB,WAAU;GAAa,OAAM;GAA7C,UAAA,CACE,oBAAC,cAAD;IACE,MAAK;IACL,UAAU;IACV,UAAU;IACV,eAAe,MAAM;IACrB,YAAY,MAAM;IAClB,UAAU,MAAM;GACjB,CAAA,GACA,MAAM,YACL,oBAAC,OAAD;IAAK,WAAU;IACb,UAAA,oBAAC,OAAD;KACE,MAAK;KACL,OAAO;KACP,WAAW,MAAM,WAAW,EAAE,OAAO,KAAK;IAC3C,CAAA;GACE,CAAA,CAEO;EACT,CAAA,CAAA;;AAEb"}
1
+ {"version":3,"file":"ControlDatePopover.js","names":["CalendarIcon","ChevronDownIcon"],"sources":["../../src/form/ControlDatePopover.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { useI18n } from \"alepha/react/i18n\";\nimport {\n Calendar as CalendarIcon,\n ChevronDown as ChevronDownIcon,\n} from \"lucide-react\";\nimport { type HTMLAttributes, useState } from \"react\";\nimport type { DayPickerProps } from \"react-day-picker\";\n\nimport { LazyCalendar, preloadCalendar } from \"../calendar/LazyCalendar.tsx\";\nimport { Input } from \"../core/Input.tsx\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../core/Popover.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport { DATE_ONLY, formatDateOnly, parseDateOnly } from \"./dateOnly.ts\";\nimport {\n ControlClearButton,\n TRIGGER_CLASSES,\n TRIGGER_SIZES,\n TRIGGER_WRAPPER_CLASSES,\n} from \"./fieldTrigger.tsx\";\n\nexport interface ControlDatePopoverProps {\n id?: string;\n value?: string;\n withTime: boolean;\n disabled?: boolean;\n clearable?: boolean;\n captionLayout?: DayPickerProps[\"captionLayout\"];\n startMonth?: Date;\n endMonth?: Date;\n /** Forwarded to the trigger: an `aria-label`, a `data-testid`. */\n triggerProps?: HTMLAttributes<HTMLElement>;\n onChange: (value: string | undefined) => void;\n}\n\nexport const ControlDatePopover = (props: ControlDatePopoverProps) => {\n const { tr, l } = useI18n();\n const [open, setOpen] = useState(false);\n const date = props.value\n ? !props.withTime && DATE_ONLY.test(props.value)\n ? parseDateOnly(props.value)\n : new Date(props.value)\n : undefined;\n\n // In the page's language, never the browser's. `toLocaleString()` with no\n // locale followed the browser, so an English browser on a French page\n // printed 9/10/2026 for the 10th of September, and the server, which has no\n // browser, rendered yet another shape before hydration (#Q2392). The\n // runtime's time zone is unchanged: `Intl` still formats in it.\n const formatted = date\n ? props.withTime\n ? l(date, {\n date: {\n year: \"numeric\",\n month: \"numeric\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"2-digit\",\n },\n })\n : l(date)\n : \"\";\n\n const handleDate = (d: Date | undefined) => {\n if (!d) {\n props.onChange(undefined);\n return;\n }\n if (props.withTime) {\n props.onChange(d.toISOString());\n } else {\n props.onChange(formatDateOnly(d));\n setOpen(false);\n }\n };\n\n const handleTime = (timeStr: string) => {\n if (!date) return;\n const [h, m] = timeStr.split(\":\").map(Number);\n const next = new Date(date);\n next.setHours(h ?? 0, m ?? 0, 0, 0);\n props.onChange(next.toISOString());\n };\n\n const timeValue =\n date && props.withTime\n ? `${String(date.getHours()).padStart(2, \"0\")}:${String(date.getMinutes()).padStart(2, \"0\")}`\n : \"\";\n\n const showClear = Boolean(props.clearable && date && !props.disabled);\n const size = TRIGGER_SIZES.default;\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n {/* The kit's field trigger, and the kit's clear button positioned on it\n - `control-base/field-trigger`, the same two a select draws. The\n clear sits BESIDE the trigger rather than inside it: a button nested\n in a button is invalid, and Base UI's popover trigger would swallow\n its click anyway. */}\n <div className={TRIGGER_WRAPPER_CLASSES}>\n <PopoverTrigger\n {...props.triggerProps}\n id={props.id}\n // A FIELD trigger, not a button, and the distinction is load\n // bearing: `styles.css` gives the `--border-hover` border to a\n // list of `data-slot`s, and this one was not on it, so the date\n // control was the only field in the kit that did not darken its\n // border under the pointer.\n //\n // ⚠️ It used to render `Button variant=\"outline\"` and then undo\n // the button-ness of it in four overrides - the border token, the\n // hover fill, the open-state fill, the placeholder colour - which\n // is a fair description of why it still did not look like the\n // selects beside it (feedback #2197). The shared trigger is a\n // field to begin with, so there is nothing left to undo.\n data-slot=\"date-trigger\"\n disabled={props.disabled}\n // The calendar is a chunk of its own (`LazyCalendar`). Asking for it\n // as the pointer arrives or focus lands means the click that opens\n // the popover usually finds it already downloaded.\n onPointerEnter={preloadCalendar}\n onFocus={preloadCalendar}\n className={cn(\n TRIGGER_CLASSES,\n size.trigger,\n size.chevron,\n // Muted means \"nothing picked yet\", exactly as on a select. With\n // a value the text is already `foreground`, so this only matters\n // while empty.\n !date && \"text-muted-foreground\",\n )}\n >\n {/* The room for the clear button - see `clearGap` in TRIGGER_SIZES\n for why it is a margin here and not padding on the trigger, and\n `ControlSelectCombobox` for `trigger-label`. */}\n <span\n data-slot=\"trigger-label\"\n className={cn(\n \"flex min-w-0 items-center gap-2\",\n showClear && size.clearGap,\n )}\n >\n {/*\n Muted whatever the field holds, matching `InputGroupAddon`, which\n paints every other leading icon in the kit `text-muted-foreground`\n on the container.\n\n Without the class this icon simply inherits the trigger's `color`,\n which the control swaps between muted and foreground to grey the\n PLACEHOLDER - so the icon brightened when a date was picked. That\n looked deliberate and was not: an icon says what kind of field this\n is, which does not change when you fill it, and the text beside it\n already carries filled-versus-empty.\n */}\n <CalendarIcon\n className={cn(\"text-muted-foreground shrink-0\", size.icon)}\n />\n <span className=\"truncate\">\n {formatted ||\n tr(\"controlDate.placeholder\", { default: \"Pick a date\" })}\n </span>\n </span>\n {/* Same trailing caret a select trigger carries, for the same\n reason: this opens a popover, and without it the control reads\n as a text field that happens to have a calendar glyph. */}\n <ChevronDownIcon className=\"text-muted-foreground pointer-events-none size-4 shrink-0\" />\n </PopoverTrigger>\n {showClear && (\n <ControlClearButton onClick={() => props.onChange(undefined)} />\n )}\n </div>\n <PopoverContent className=\"w-auto p-0\" align=\"start\">\n <LazyCalendar\n mode=\"single\"\n selected={date}\n onSelect={handleDate}\n captionLayout={props.captionLayout}\n startMonth={props.startMonth}\n endMonth={props.endMonth}\n />\n {props.withTime && (\n <div className=\"border-t p-3\">\n <Input\n type=\"time\"\n value={timeValue}\n onChange={(e) => handleTime(e.target.value)}\n />\n </div>\n )}\n </PopoverContent>\n </Popover>\n );\n};\n"],"mappings":";;;;;;;;;;;AAsCA,MAAa,sBAAsB,UAAmC;CACpE,MAAM,EAAE,IAAI,MAAM,QAAQ;CAC1B,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CACtC,MAAM,OAAO,MAAM,QACf,CAAC,MAAM,YAAY,UAAU,KAAK,MAAM,KAAK,IAC3C,cAAc,MAAM,KAAK,IACzB,IAAI,KAAK,MAAM,KAAK,IACtB,KAAA;CAOJ,MAAM,YAAY,OACd,MAAM,WACJ,EAAE,MAAM,EACN,MAAM;EACJ,MAAM;EACN,OAAO;EACP,KAAK;EACL,MAAM;EACN,QAAQ;CACV,EACF,CAAC,IACD,EAAE,IAAI,IACR;CAEJ,MAAM,cAAc,MAAwB;EAC1C,IAAI,CAAC,GAAG;GACN,MAAM,SAAS,KAAA,CAAS;GACxB;EACF;EACA,IAAI,MAAM,UACR,MAAM,SAAS,EAAE,YAAY,CAAC;OACzB;GACL,MAAM,SAAS,eAAe,CAAC,CAAC;GAChC,QAAQ,KAAK;EACf;CACF;CAEA,MAAM,cAAc,YAAoB;EACtC,IAAI,CAAC,MAAM;EACX,MAAM,CAAC,GAAG,KAAK,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;EAC5C,MAAM,OAAO,IAAI,KAAK,IAAI;EAC1B,KAAK,SAAS,KAAK,GAAG,KAAK,GAAG,GAAG,CAAC;EAClC,MAAM,SAAS,KAAK,YAAY,CAAC;CACnC;CAEA,MAAM,YACJ,QA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AE,OAAO,KAAK;IAC3C,CAAA;GACE,CAAA,CAEO;EACT,CAAA,CAAA;;AAEb"}
@@ -0,0 +1,25 @@
1
+ import * as React from "react";
2
+ import { type HTMLAttributes } from "react";
3
+ export interface ControlMonthPopoverProps {
4
+ id?: string;
5
+ value?: string;
6
+ disabled?: boolean;
7
+ clearable?: boolean;
8
+ /** First selectable month, `YYYY-MM`. */
9
+ min?: string;
10
+ /** Last selectable month, `YYYY-MM`. */
11
+ max?: string;
12
+ /** Forwarded to the trigger: an `aria-label`, a `data-testid`. */
13
+ triggerProps?: HTMLAttributes<HTMLElement>;
14
+ onChange: (value: string | undefined) => void;
15
+ }
16
+ /**
17
+ * The month picker: the kit's field trigger, then a year with its twelve
18
+ * months. For a period that is a whole month (a report, an invoice), where a
19
+ * day picker would ask for a day nobody means.
20
+ *
21
+ * The value is `YYYY-MM`, so a schema reads it as a plain string and a
22
+ * server parses it without a time zone.
23
+ */
24
+ export declare const ControlMonthPopover: (props: ControlMonthPopoverProps) => React.JSX.Element;
25
+ //# sourceMappingURL=ControlMonthPopover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ControlMonthPopover.d.ts","sourceRoot":"","sources":["../../src/form/ControlMonthPopover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,EAAE,KAAK,cAAc,EAAY,MAAM,OAAO,CAAC;AAiBtD,MAAM,WAAW,wBAAwB;IACvC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,YAAY,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;IAC3C,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAC/C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,UAAW,wBAAwB,sBAsHlE,CAAC"}
@@ -0,0 +1,112 @@
1
+ import { cn } from "../core/utils.js";
2
+ import { Button } from "../core/Button.js";
3
+ import { Popover, PopoverContent, PopoverTrigger } from "../core/Popover.js";
4
+ import { ControlClearButton, TRIGGER_CLASSES, TRIGGER_SIZES, TRIGGER_WRAPPER_CLASSES } from "./fieldTrigger.js";
5
+ import { useI18n } from "alepha/react/i18n";
6
+ import { CalendarDays, ChevronDown, ChevronLeft, ChevronRight } from "lucide-react";
7
+ import { useState } from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ //#region src/form/ControlMonthPopover.tsx
10
+ /**
11
+ * A month as a form holds it: `YYYY-MM`, the value of `<input type="month">`.
12
+ */
13
+ const MONTH = /^(\d{4})-(\d{2})$/;
14
+ /**
15
+ * The month picker: the kit's field trigger, then a year with its twelve
16
+ * months. For a period that is a whole month (a report, an invoice), where a
17
+ * day picker would ask for a day nobody means.
18
+ *
19
+ * The value is `YYYY-MM`, so a schema reads it as a plain string and a
20
+ * server parses it without a time zone.
21
+ */
22
+ const ControlMonthPopover = (props) => {
23
+ const { tr, l, lang } = useI18n();
24
+ const [open, setOpen] = useState(false);
25
+ const match = props.value ? MONTH.exec(props.value) : null;
26
+ const year = match ? Number(match[1]) : void 0;
27
+ const month = match ? Number(match[2]) : void 0;
28
+ const [shownYear, setShownYear] = useState(() => year ?? (/* @__PURE__ */ new Date()).getFullYear());
29
+ const key = (y, m) => `${String(y).padStart(4, "0")}-${String(m).padStart(2, "0")}`;
30
+ const outOfRange = (value) => props.min !== void 0 && value < props.min || props.max !== void 0 && value > props.max;
31
+ const formatted = year !== void 0 && month !== void 0 ? l(new Date(year, month - 1, 1), { date: {
32
+ year: "numeric",
33
+ month: "long"
34
+ } }) : "";
35
+ const monthName = (m) => new Date(2e3, m - 1, 1).toLocaleString(lang, { month: "short" });
36
+ const showClear = Boolean(props.clearable && match && !props.disabled);
37
+ const size = TRIGGER_SIZES.default;
38
+ return /* @__PURE__ */ jsxs(Popover, {
39
+ open,
40
+ onOpenChange: (next) => {
41
+ if (next && year !== void 0) setShownYear(year);
42
+ setOpen(next);
43
+ },
44
+ children: [/* @__PURE__ */ jsxs("div", {
45
+ className: TRIGGER_WRAPPER_CLASSES,
46
+ children: [/* @__PURE__ */ jsxs(PopoverTrigger, {
47
+ ...props.triggerProps,
48
+ id: props.id,
49
+ "data-slot": "date-trigger",
50
+ disabled: props.disabled,
51
+ className: cn(TRIGGER_CLASSES, size.trigger, size.chevron, !match && "text-muted-foreground"),
52
+ children: [/* @__PURE__ */ jsxs("span", {
53
+ "data-slot": "trigger-label",
54
+ className: cn("flex min-w-0 items-center gap-2", showClear && size.clearGap),
55
+ children: [/* @__PURE__ */ jsx(CalendarDays, { className: cn("text-muted-foreground shrink-0", size.icon) }), /* @__PURE__ */ jsx("span", {
56
+ className: "truncate",
57
+ children: formatted || tr("controlMonth.placeholder", { default: "Pick a month" })
58
+ })]
59
+ }), /* @__PURE__ */ jsx(ChevronDown, { className: "text-muted-foreground pointer-events-none size-4 shrink-0" })]
60
+ }), showClear && /* @__PURE__ */ jsx(ControlClearButton, { onClick: () => props.onChange(void 0) })]
61
+ }), /* @__PURE__ */ jsxs(PopoverContent, {
62
+ className: "w-64 p-2",
63
+ align: "start",
64
+ children: [/* @__PURE__ */ jsxs("div", {
65
+ className: "mb-2 flex items-center justify-between",
66
+ children: [
67
+ /* @__PURE__ */ jsx(Button, {
68
+ variant: "minimal",
69
+ size: "icon-sm",
70
+ "aria-label": tr("controlMonth.previousYear", { default: "Previous year" }),
71
+ onClick: () => setShownYear((it) => it - 1),
72
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "rtl:-scale-x-100" })
73
+ }),
74
+ /* @__PURE__ */ jsx("span", {
75
+ className: "text-sm font-medium tabular-nums",
76
+ children: shownYear
77
+ }),
78
+ /* @__PURE__ */ jsx(Button, {
79
+ variant: "minimal",
80
+ size: "icon-sm",
81
+ "aria-label": tr("controlMonth.nextYear", { default: "Next year" }),
82
+ onClick: () => setShownYear((it) => it + 1),
83
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "rtl:-scale-x-100" })
84
+ })
85
+ ]
86
+ }), /* @__PURE__ */ jsx("div", {
87
+ className: "grid grid-cols-3 gap-1",
88
+ children: Array.from({ length: 12 }, (_, i) => i + 1).map((m) => {
89
+ const value = key(shownYear, m);
90
+ const selected = year === shownYear && month === m;
91
+ return /* @__PURE__ */ jsx(Button, {
92
+ variant: selected ? "solid" : "minimal",
93
+ intent: selected ? "primary" : "none",
94
+ size: "sm",
95
+ "data-value": value,
96
+ "aria-pressed": selected,
97
+ disabled: outOfRange(value),
98
+ onClick: () => {
99
+ props.onChange(value);
100
+ setOpen(false);
101
+ },
102
+ children: monthName(m)
103
+ }, m);
104
+ })
105
+ })]
106
+ })]
107
+ });
108
+ };
109
+ //#endregion
110
+ export { ControlMonthPopover };
111
+
112
+ //# sourceMappingURL=ControlMonthPopover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ControlMonthPopover.js","names":["CalendarIcon","ChevronDownIcon"],"sources":["../../src/form/ControlMonthPopover.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { useI18n } from \"alepha/react/i18n\";\nimport {\n CalendarDays as CalendarIcon,\n ChevronDown as ChevronDownIcon,\n ChevronLeft,\n ChevronRight,\n} from \"lucide-react\";\nimport { type HTMLAttributes, useState } from \"react\";\n\nimport { Button } from \"../core/Button.tsx\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../core/Popover.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport {\n ControlClearButton,\n TRIGGER_CLASSES,\n TRIGGER_SIZES,\n TRIGGER_WRAPPER_CLASSES,\n} from \"./fieldTrigger.tsx\";\n\n/**\n * A month as a form holds it: `YYYY-MM`, the value of `<input type=\"month\">`.\n */\nconst MONTH = /^(\\d{4})-(\\d{2})$/;\n\nexport interface ControlMonthPopoverProps {\n id?: string;\n value?: string;\n disabled?: boolean;\n clearable?: boolean;\n /** First selectable month, `YYYY-MM`. */\n min?: string;\n /** Last selectable month, `YYYY-MM`. */\n max?: string;\n /** Forwarded to the trigger: an `aria-label`, a `data-testid`. */\n triggerProps?: HTMLAttributes<HTMLElement>;\n onChange: (value: string | undefined) => void;\n}\n\n/**\n * The month picker: the kit's field trigger, then a year with its twelve\n * months. For a period that is a whole month (a report, an invoice), where a\n * day picker would ask for a day nobody means.\n *\n * The value is `YYYY-MM`, so a schema reads it as a plain string and a\n * server parses it without a time zone.\n */\nexport const ControlMonthPopover = (props: ControlMonthPopoverProps) => {\n const { tr, l, lang } = useI18n();\n const [open, setOpen] = useState(false);\n const match = props.value ? MONTH.exec(props.value) : null;\n const year = match ? Number(match[1]) : undefined;\n const month = match ? Number(match[2]) : undefined;\n const [shownYear, setShownYear] = useState(\n () => year ?? new Date().getFullYear(),\n );\n\n const key = (y: number, m: number) =>\n `${String(y).padStart(4, \"0\")}-${String(m).padStart(2, \"0\")}`;\n const outOfRange = (value: string) =>\n (props.min !== undefined && value < props.min) ||\n (props.max !== undefined && value > props.max);\n\n const formatted =\n year !== undefined && month !== undefined\n ? l(new Date(year, month - 1, 1), {\n date: { year: \"numeric\", month: \"long\" },\n })\n : \"\";\n const monthName = (m: number) =>\n new Date(2000, m - 1, 1).toLocaleString(lang, { month: \"short\" });\n\n const showClear = Boolean(props.clearable && match && !props.disabled);\n const size = TRIGGER_SIZES.default;\n\n return (\n <Popover\n open={open}\n onOpenChange={(next) => {\n if (next && year !== undefined) setShownYear(year);\n setOpen(next);\n }}\n >\n <div className={TRIGGER_WRAPPER_CLASSES}>\n <PopoverTrigger\n {...props.triggerProps}\n id={props.id}\n data-slot=\"date-trigger\"\n disabled={props.disabled}\n className={cn(\n TRIGGER_CLASSES,\n size.trigger,\n size.chevron,\n !match && \"text-muted-foreground\",\n )}\n >\n <span\n data-slot=\"trigger-label\"\n className={cn(\n \"flex min-w-0 items-center gap-2\",\n showClear && size.clearGap,\n )}\n >\n <CalendarIcon\n className={cn(\"text-muted-foreground shrink-0\", size.icon)}\n />\n <span className=\"truncate\">\n {formatted ||\n tr(\"controlMonth.placeholder\", { default: \"Pick a month\" })}\n </span>\n </span>\n <ChevronDownIcon className=\"text-muted-foreground pointer-events-none size-4 shrink-0\" />\n </PopoverTrigger>\n {showClear && (\n <ControlClearButton onClick={() => props.onChange(undefined)} />\n )}\n </div>\n <PopoverContent className=\"w-64 p-2\" align=\"start\">\n <div className=\"mb-2 flex items-center justify-between\">\n <Button\n variant=\"minimal\"\n size=\"icon-sm\"\n aria-label={tr(\"controlMonth.previousYear\", {\n default: \"Previous year\",\n })}\n onClick={() => setShownYear((it) => it - 1)}\n >\n <ChevronLeft className=\"rtl:-scale-x-100\" />\n </Button>\n <span className=\"text-sm font-medium tabular-nums\">{shownYear}</span>\n <Button\n variant=\"minimal\"\n size=\"icon-sm\"\n aria-label={tr(\"controlMonth.nextYear\", { default: \"Next year\" })}\n onClick={() => setShownYear((it) => it + 1)}\n >\n <ChevronRight className=\"rtl:-scale-x-100\" />\n </Button>\n </div>\n <div className=\"grid grid-cols-3 gap-1\">\n {Array.from({ length: 12 }, (_, i) => i + 1).map((m) => {\n const value = key(shownYear, m);\n const selected = year === shownYear && month === m;\n return (\n <Button\n key={m}\n variant={selected ? \"solid\" : \"minimal\"}\n intent={selected ? \"primary\" : \"none\"}\n size=\"sm\"\n data-value={value}\n aria-pressed={selected}\n disabled={outOfRange(value)}\n onClick={() => {\n props.onChange(value);\n setOpen(false);\n }}\n >\n {monthName(m)}\n </Button>\n );\n })}\n </div>\n </PopoverContent>\n </Popover>\n );\n};\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,QAAQ;;;;;;;;;AAwBd,MAAa,uBAAuB,UAAoC;CACtE,MAAM,EAAE,IAAI,GAAG,SAAS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W,UAAU;MAC9B,QAAQ,WAAW,YAAY;MAC/B,MAAK;MACL,cAAY;MACZ,gBAAc;MACd,UAAU,WAAW,KAAK;MAC1B,eAAe;OACb,MAAM,SAAS,KAAK;OACpB,QAAQ,KAAK;MACf;MAEC,UAAA,UAAU,CAAC;KACN,GAbD,CAaC;IAEZ,CAAC;GACE,CAAA,CACS;EACT,CAAA,CAAA;;AAEb"}
@@ -22,6 +22,13 @@ export interface ControlSelectProps {
22
22
  * Render as a `<Segmented>` control (best for 2–4 options).
23
23
  */
24
24
  segmented?: boolean;
25
+ /**
26
+ * Render a multi-choice field (an array schema) as a group of checkboxes,
27
+ * every option visible: for a handful of fixed choices (days of the week,
28
+ * device types), where a select would hide what is ticked. Each checkbox
29
+ * is named by its option's label and carries `data-value`.
30
+ */
31
+ checkboxes?: boolean;
25
32
  /**
26
33
  * Force the search input on. Kept as the historical name for
27
34
  * `searchable: true` — every select is a combobox now, the flag only
@@ -1 +1 @@
1
- {"version":3,"file":"ControlSelect.d.ts","sourceRoot":"","sources":["../../src/form/ControlSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EACL,KAAK,cAAc,EAIpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,KAAK,SAAS,EAA6B,MAAM,OAAO,CAAC;AAKlE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,KAAK,EAAE,cAAc,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAC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EG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;;;;;OAUG;IACH,YAAY,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;IAC3C;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,aAAa,UAAW,kBAAkB,6BAuQtD,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB,MAAM,GACN;IACE,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAIN;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { Checkbox } from "../core/Checkbox.js";
1
2
  import { FormField } from "./FormField.js";
2
3
  import { Segmented } from "../core/Segmented.js";
3
4
  import { optValue } from "./controlSelectOptions.js";
@@ -82,6 +83,42 @@ const ControlSelect = (props) => {
82
83
  fullWidth: true
83
84
  })
84
85
  });
86
+ if (props.checkboxes && isArray) {
87
+ const ticked = Array.isArray(value) ? value.map(String) : [];
88
+ return /* @__PURE__ */ jsx(FormField, {
89
+ id: meta.id,
90
+ label: meta.label,
91
+ description: meta.description,
92
+ error: meta.error,
93
+ required: meta.required,
94
+ children: /* @__PURE__ */ jsx("div", {
95
+ role: "group",
96
+ "aria-label": meta.label || void 0,
97
+ ...props.triggerProps,
98
+ id: meta.id,
99
+ className: "flex flex-wrap gap-x-4 gap-y-2 py-1",
100
+ children: data.map((o) => {
101
+ const optionValue = optValue(o);
102
+ const optionId = `${meta.id}-${optionValue}`;
103
+ return /* @__PURE__ */ jsxs("label", {
104
+ htmlFor: optionId,
105
+ className: "flex items-center gap-2 text-sm",
106
+ children: [/* @__PURE__ */ jsx(Checkbox, {
107
+ id: optionId,
108
+ "data-value": optionValue,
109
+ disabled: props.disabled || typeof o !== "string" && o.disabled,
110
+ checked: ticked.includes(optionValue),
111
+ onCheckedChange: (checked) => {
112
+ const next = checked ? [...ticked, optionValue] : ticked.filter((it) => it !== optionValue);
113
+ const ordered = data.map(optValue).filter((it) => next.includes(it));
114
+ setValue(ordered.map(coerce));
115
+ }
116
+ }), segmentedLabel(o)]
117
+ }, optionValue);
118
+ })
119
+ })
120
+ });
121
+ }
85
122
  const clearLabel = props.clearLabel ?? tr("controlSelect.none", { default: "None" });
86
123
  const searchable = props.searchable ?? (props.combobox || mode === "long" || Boolean(props.createNewEntry) || data.length > SEARCH_THRESHOLD);
87
124
  return /* @__PURE__ */ jsx(FormField, {
@@ -100,7 +137,7 @@ const ControlSelect = (props) => {
100
137
  value,
101
138
  onChange: (v) => setValue(v),
102
139
  coerce,
103
- onSearch: mode === "long" ? search.run : void 0,
140
+ onSearch: mode === "long" ? (text) => search.run(text) : void 0,
104
141
  createNewEntry: props.createNewEntry,
105
142
  icon: props.icon,
106
143
  triggerClassName: props.triggerClassName,
@@ -187,7 +224,7 @@ const useAsyncLoader = (loader, threshold, debounceMs, defaultValue) => {
187
224
  mode,
188
225
  search: useAction({
189
226
  debounce: debounceMs,
190
- handler: async (text) => {
227
+ handler: async (_ctx, text) => {
191
228
  if (!loader || mode !== "long") return;
192
229
  if (cache.current.has(text)) {
193
230
  setData(cache.current.get(text));
@@ -1 +1 @@
1
- {"version":3,"file":"ControlSelect.js","names":[],"sources":["../../src/form/ControlSelect.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport type { Async } from \"alepha\";\nimport { useAction } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport type { HTMLAttributes } from \"react\";\nimport { type ReactNode, useMemo, useRef, useState } from \"react\";\n\nimport { Segmented } from \"../core/Segmented.tsx\";\nimport { ControlSelectCombobox } from \"./ControlSelectCombobox.tsx\";\nimport { optValue } from \"./controlSelectOptions.ts\";\nimport type { ControlTriggerSize } from \"./fieldTrigger.tsx\";\nimport { FormField } from \"./FormField.tsx\";\nimport type { IconComponent } from \"./iconHint.tsx\";\n\nexport interface ControlSelectProps {\n /**\n * Bound `InputField` from `useForm`. Single or multi value depending on schema.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the input.\n */\n description?: string;\n /**\n * Render as a `<Segmented>` control (best for 2–4 options).\n */\n segmented?: boolean;\n /**\n * Force the search input on. Kept as the historical name for\n * `searchable: true` — every select is a combobox now, the flag only\n * decides whether it carries a search field.\n */\n combobox?: boolean;\n /**\n * Whether the dropdown carries a search input. Defaults to \"auto\": on for a\n * long-mode `loader` (the rows are not all here), when `createNewEntry` is\n * set (typing IS how an entry is made), and for lists longer than\n * `SEARCH_THRESHOLD`. Set explicitly to search a short list or to drop the\n * search field from a long one.\n *\n * Multi-select obeys the same rule as everything else; it used to force the\n * field on because its chips box doubled as the search input.\n */\n searchable?: boolean;\n /**\n * Async option loader. Triggers long-mode (server-side search) above `loaderThreshold` options.\n */\n loader?: (search: string, resolve?: string[]) => Async<SelectOption[]>;\n /**\n * Option count above which `loader` is invoked on every search instead of once. Defaults to 100.\n */\n loaderThreshold?: number;\n /**\n * Debounce in ms applied to search queries when calling `loader` in long mode.\n */\n loaderDebounce?: number;\n /**\n * Disable the control.\n */\n disabled?: boolean;\n /**\n * Inline option list (overrides schema `enum`). Accepts either a static\n * array or an async function `(query) => SelectOption[]`. The async form\n * is mapped to a long-mode loader.\n */\n items?:\n | SelectOption[]\n | ((query: string) => SelectOption[] | Promise<SelectOption[]>);\n /**\n * Allow the user to add a new option by typing. When `true`, the typed\n * query becomes the value (and label) of a freshly created entry. When a\n * function, the function builds the option from the query.\n *\n * - For multi-select fields: each entry is appended to the value array.\n * - For single fields: behaves like a regular text input with a dropdown\n * suggesting existing options.\n */\n createNewEntry?: boolean | ((query: string) => Exclude<SelectOption, string>);\n /**\n * When true, the dropdown gets a synthetic \"none\" row at the top that\n * resets the field to `undefined`. Useful for optional filter chips\n * (e.g. an admin-table status filter) where the user needs an explicit\n * \"no filter\" option — Base UI's `Select` reserves empty-string values\n * as its internal no-selection sentinel, so a regular `<SelectItem\n * value=\"\">` can't be picked. With `clearable`, ControlSelect uses an\n * internal sentinel and translates it to `undefined` in `onChange`.\n *\n * Currently honored by the static-short `Select` and the searchable\n * Combobox render paths. Ignored by `segmented` (use a real segment\n * for \"all\" there).\n */\n clearable?: boolean;\n /**\n * Label rendered for the \"clear\" row injected by `clearable`. Also\n * used as the trigger placeholder when the field is empty. Defaults to\n * `\"None\"`. Localize at the call site (e.g. `\"All types\"`,\n * `\"All status\"`).\n */\n clearLabel?: string;\n /**\n * Trigger text for a multi-select whose selection is too long to name, e.g.\n * `(n) => \\`${n} status\\``. One selection always shows the value itself, so\n * this is only ever asked for two or more past `maxTriggerLength`. Defaults\n * to `\"{n} values\"`.\n */\n countLabel?: (count: number) => string;\n /**\n * The longest joined text, in characters, a multi-select trigger names its\n * selection with (\"Draft, Ready\") before it collapses to `countLabel`.\n * Defaults to 20, which suits a filter chip; a full-width form field has\n * room for more.\n */\n maxTriggerLength?: number;\n /**\n * Trigger text when nothing is selected, e.g. \"Pick an epic…\". Defaults to\n * the `clearLabel` on a `clearable` or multi field (where empty IS a\n * meaningful state to name), and to \"Select…\" otherwise.\n *\n * Set it when the empty trigger has a job to do - a picker whose whole\n * purpose is the choice it prompts for reads as a dead \"Select…\" without\n * it, which is why the surfaces that needed one stayed on the raw `Select`.\n */\n placeholder?: string;\n /**\n * Extra className applied to the visible trigger: the combobox button or\n * the segmented control, whichever this field renders. Useful for sizing\n * filter chips (`\"w-40\"`, `\"w-72\"`, etc.) without wrapping the whole\n * `FormField` in an extra div.\n */\n triggerClassName?: string;\n /**\n * Trigger height and type scale. Defaults to `default`.\n */\n size?: ControlSelectSize;\n /**\n * Render the trigger borderless and transparent, so it reads as the row it\n * sits on rather than as a form field.\n */\n minimal?: boolean;\n /**\n * Extra attributes for whichever trigger this field renders, forwarded from\n * `Control`'s `inputProps`.\n *\n * The accessible name usually lives here, because a filter is routinely\n * rendered with `label=\"\"` next to its own heading: with no `<label>` to\n * borrow a name from, a `role=combobox` button or a radiogroup has no name\n * at all. That is both an a11y hole and unaddressable from a\n * test, and it was silent, since `Control` accepted `inputProps` and then\n * dropped it on every select-shaped branch.\n */\n triggerProps?: HTMLAttributes<HTMLElement>;\n /**\n * Leading icon rendered on the left of the trigger, matching the\n * text-input controls. Resolved by the parent `Control` from its `icon`\n * prop, falling back to the list glyph like a text input falls back to\n * its schema hint; `icon={null}` on the `Control` removes it, and a\n * `minimal` trigger gets none by default.\n */\n icon?: IconComponent;\n /**\n * Drawn at the top of the popup, above the options - for a setting that\n * changes what the choice MEANS rather than what is chosen, such as a\n * filter's \"is / is not\".\n *\n * ⚠️ Only the combobox shape has a popup, so a segmented or radio rendering\n * of the same field draws nothing for it.\n */\n popupHeader?: ReactNode;\n /**\n * Drawn on the trigger just before the selected label, after the icon: the\n * short word that keeps a qualified value from reading as a plain one\n * (\"not Active\"). Absent while nothing is selected, because a qualifier on\n * a placeholder has nothing to qualify.\n */\n triggerPrefix?: ReactNode;\n /**\n * Extra className on the popup, merged over its own.\n *\n * The popup is sized from its trigger by default (`--anchor-width`), and it\n * keeps following that width while open. A trigger whose text changes as\n * the reader picks - a `triggerPrefix` appearing, \"2 values\" replacing a\n * name - therefore resizes the popup under their cursor. `w-max` with a\n * floor (`w-max min-w-48`) sizes it from its own content instead.\n */\n popupClassName?: string;\n}\n\nexport const ControlSelect = (props: ControlSelectProps) => {\n const { tr } = useI18n();\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const isArray = meta.isArray;\n const isNumeric = meta.type === \"number\" || meta.type === \"integer\";\n const isBoolean = meta.type === \"boolean\";\n\n // Normalize items prop: array → static; function → loader\n const itemsArray = Array.isArray(props.items)\n ? (props.items as SelectOption[])\n : undefined;\n const itemsLoader =\n typeof props.items === \"function\"\n ? (props.items as (q: string) => Async<SelectOption[]>)\n : undefined;\n\n const enumValues =\n itemsArray ?? (meta.enum as SelectOption[] | undefined) ?? [];\n\n const effectiveLoader = props.loader ?? itemsLoader;\n\n const {\n data: asyncData,\n loading,\n mode,\n search,\n } = useAsyncLoader(\n effectiveLoader,\n props.loaderThreshold ?? 100,\n props.loaderDebounce ?? 300,\n props.input.initialValue,\n );\n\n // Labels and `disabled` flags are part of the identity: keying on the\n // joined values alone collided (`[\"ab\",\"c\"]` vs `[\"a\",\"bc\"]`) and kept a\n // stale list when only the labels changed.\n //\n // ⚠️ `icon` is EXCLUDED, and it has to be. It is a `ReactNode`, and a\n // rendered element holds a fiber that points back at its DOM node, so\n // `JSON.stringify` on the raw option threw \"Converting circular structure\n // to JSON\" - a documented prop that crashed the component the first time\n // anyone used it (#Q2049). Two lists that differ only by icon share a key,\n // which is right: the key exists to notice a changed VALUE or LABEL.\n const enumKey = JSON.stringify(\n enumValues.map((option) =>\n typeof option === \"string\"\n ? option\n : {\n value: option.value,\n label: option.label,\n description: option.description,\n tag: option.tag,\n disabled: option.disabled,\n },\n ),\n );\n const min = meta.constraints.minimum;\n const max = meta.constraints.maximum;\n // Derived, not stored: this is a pure function of the schema. As state\n // filled in by an effect, the first paint of every boolean or ranged select\n // was an EMPTY list, corrected one render later.\n const staticData = useMemo<SelectOption[]>(() => {\n if (effectiveLoader) return [];\n if (isBoolean && enumValues.length === 0) {\n return [\n { value: \"true\", label: tr(\"controlSelect.yes\", { default: \"Yes\" }) },\n { value: \"false\", label: tr(\"controlSelect.no\", { default: \"No\" }) },\n ];\n }\n if (\n isNumeric &&\n enumValues.length === 0 &&\n typeof min === \"number\" &&\n typeof max === \"number\" &&\n max - min <= 20\n ) {\n const range: SelectOption[] = [];\n for (let i = min; i <= max; i++) range.push(String(i));\n return range;\n }\n return enumValues;\n }, [effectiveLoader, enumKey, isBoolean, isNumeric, min, max, tr]);\n\n const data = effectiveLoader ? asyncData : staticData;\n\n if (!props.input?.props) return null;\n\n const coerce = (raw: string): unknown => {\n if (isNumeric) return Number(raw);\n if (isBoolean) return raw === \"true\";\n return raw;\n };\n\n if (props.segmented) {\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n {/* `triggerProps` is deliberately NOT spread here. `Segmented`\n redeclares two attributes that `HTMLAttributes` also has, with\n narrower types (`defaultValue` is string-only, `onChange` takes a\n value rather than an event), so a blanket spread neither typechecks\n nor is safe. A segmented field also renders every option as visible\n text, so it is the one branch that is not nameless without a label.\n Name it with `label` if it needs one. */}\n <Segmented\n value={value != null ? String(value) : undefined}\n onChange={(v) => setValue(coerce(v))}\n disabled={props.disabled}\n options={data.slice(0, 10).map((o) => ({\n value: optValue(o),\n label: segmentedLabel(o),\n }))}\n fullWidth\n />\n </FormField>\n );\n }\n\n const clearLabel =\n props.clearLabel ?? tr(\"controlSelect.none\", { default: \"None\" });\n\n // One control for every list. The option count decides whether the popup\n // carries a search field — it no longer decides which primitive renders.\n // The native `Select` path this replaced silently dropped `description`,\n // `tag`, per-option `disabled` and `deselectable`, and styled its trigger\n // differently, purely because a list happened to be short.\n // A search field is offered only when scanning the list by eye stops being\n // realistic: a server-driven list (whose rows are not all here), one past\n // `SEARCH_THRESHOLD`, or one where typing is how a new entry is made.\n //\n // Multi-select used to force it on unconditionally, because the chips box\n // WAS the search input and there was no other way to open the popup. The\n // trigger is a button now, so multi obeys the same rule as everything else\n // and a four-row status filter no longer opens onto a search field.\n const searchable =\n props.searchable ??\n (props.combobox ||\n mode === \"long\" ||\n Boolean(props.createNewEntry) ||\n data.length > SEARCH_THRESHOLD);\n\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <ControlSelectCombobox\n id={meta.id}\n data={data}\n loading={loading}\n multi={isArray}\n searchable={searchable}\n disabled={props.disabled}\n value={value}\n onChange={(v) => setValue(v)}\n coerce={coerce}\n onSearch={mode === \"long\" ? search.run : undefined}\n createNewEntry={props.createNewEntry}\n icon={props.icon}\n // Used to be dropped on this path, so a filter chip sized `w-40` lost\n // its width as soon as its list crossed the threshold.\n triggerClassName={props.triggerClassName}\n triggerProps={props.triggerProps}\n size={props.size}\n minimal={props.minimal}\n // `clearable` used to reach this path as a placeholder and nothing\n // else, so a filter chip that had switched to the combobox (>20\n // options) could be set but never put back to \"All …\".\n clearable={props.clearable}\n clearLabel={clearLabel}\n countLabel={props.countLabel}\n maxTriggerLength={props.maxTriggerLength}\n popupHeader={props.popupHeader}\n triggerPrefix={props.triggerPrefix}\n popupClassName={props.popupClassName}\n // An optional field must also be able to go back to empty without a\n // dedicated row: Base UI never emits `null`, so re-pressing the\n // selected row deselects (see `handleSingle` in\n // `ControlSelectCombobox.tsx`). A required field keeps its value —\n // clearing it would only produce a validation error the user cannot\n // see yet.\n deselectable={props.clearable || !meta.required}\n // Multi shows this muted when nothing is picked, so it reaches the\n // trigger whether or not the field is `clearable` — a multi-select\n // has no clear ROW (it clears by deselecting), and without this its\n // empty trigger fell back to a bare \"Select…\".\n placeholder={\n props.placeholder ??\n (props.clearable || isArray ? clearLabel : undefined)\n }\n />\n </FormField>\n );\n};\n\nexport type SelectOption =\n | string\n | {\n value: string;\n label: string;\n /**\n * Optional secondary line shown under the label in the dropdown.\n */\n description?: string;\n /**\n * Optional small badge rendered next to the label.\n */\n tag?: string;\n /**\n * Optional icon/element rendered before the label, in both the\n * dropdown row and (for single-select) the trigger when selected.\n */\n icon?: ReactNode;\n /**\n * When true, the row is non-interactive — can't be selected if\n * not selected, can't be deselected if selected. Useful for\n * default/mandatory entries (e.g. the base \"user\" role).\n */\n disabled?: boolean;\n };\n\ntype LoaderMode = \"static\" | \"short\" | \"long\";\n\n/**\n * How tall and how loud a select trigger is.\n *\n * The kit's own scale, kept under this name because `Control` and a long tail\n * of callers already spell it `size=\"xs\"` on a select. The table behind it,\n * and the trigger box it sizes, are `control-base/field-trigger`'s - shared\n * with the two calendar controls, which used to draw a button instead.\n */\nexport type ControlSelectSize = ControlTriggerSize;\n\n/**\n * Static option count above which the dropdown grows a search input. Below it\n * the very same combobox renders without one — the threshold decides whether\n * you can type, never which control you get.\n */\n// Past this many rows, scanning by eye stops being realistic and the popup\n// grows a search field. Raised 20 -> 50 with the multi-select rework: the old\n// value put a search box on lists a reader takes in at a glance.\nconst SEARCH_THRESHOLD = 50;\n\n/**\n * Friendly label for plain string options: \"optional\" → \"Optional\",\n * \"in_progress\" → \"In Progress\". Custom `{ value, label }` items pass through\n * untouched.\n */\nconst titlecase = (s: string) =>\n s.replace(/[_-]+/g, \" \").replace(/\\b\\w/g, (c) => c.toUpperCase());\n/**\n * What one segment shows.\n *\n * ⚠️ The option's `icon` is rendered HERE rather than dropped, which is what\n * this path did until #Q2049. `SegmentedOption.label` is a `ReactNode`, so\n * there was never a reason for it: an option list carrying icons for the\n * dropdown carried them for the segments too, and dropping them silently\n * made a caller choose between two shapes for one list.\n */\nconst segmentedLabel = (o: SelectOption): ReactNode => {\n if (typeof o === \"string\") {\n return titlecase(o);\n }\n if (!o.icon) {\n return o.label;\n }\n return (\n <span className=\"inline-flex items-center gap-1.5\">\n {o.icon}\n {o.label}\n </span>\n );\n};\n\nconst useAsyncLoader = (\n loader: ControlSelectProps[\"loader\"],\n threshold: number,\n debounceMs: number,\n defaultValue: unknown,\n) => {\n const [data, setData] = useState<SelectOption[]>([]);\n const [loading, setLoading] = useState(false);\n const [mode, setMode] = useState<LoaderMode>(\"static\");\n const cache = useRef(new Map<string, SelectOption[]>());\n\n useAction(\n {\n // `id`, not `name`: `id` is what useAction threads into its\n // react:action:* events. `name` was accepted and never read, so this\n // identifier reached nothing.\n id: \"select:loader:init\",\n runOnInit: true,\n handler: async () => {\n if (!loader) {\n setMode(\"static\");\n return;\n }\n setLoading(true);\n try {\n const result = await loader(\"\");\n const isShort = result.length <= threshold;\n setMode(isShort ? \"short\" : \"long\");\n cache.current.set(\"\", result);\n setData(result);\n\n // Coercion at a boundary: the value is a form/route/chart primitive whose\n // declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n if (!isShort && defaultValue != null && String(defaultValue) !== \"\") {\n // Coercion at a boundary: the value is a form/route/chart primitive whose\n // declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n const resolved = await loader(\"\", [String(defaultValue)]);\n if (resolved.length > 0) {\n setData((prev) => {\n const existing = new Set(prev.map(optValue));\n const fresh = resolved.filter(\n (r) => !existing.has(optValue(r)),\n );\n return [...prev, ...fresh];\n });\n }\n }\n } finally {\n setLoading(false);\n }\n },\n },\n [loader, threshold],\n );\n\n const search = useAction<[string]>(\n {\n debounce: debounceMs,\n handler: async (text) => {\n if (!loader || mode !== \"long\") return;\n if (cache.current.has(text)) {\n setData(cache.current.get(text)!);\n return;\n }\n setLoading(true);\n try {\n const result = await loader(text);\n cache.current.set(text, result);\n setData(result);\n } finally {\n setLoading(false);\n }\n },\n },\n [loader, mode, debounceMs],\n );\n\n return { data, loading, mode, search };\n};\n"],"mappings":";;;;;;;;;;AAwMA,MAAa,iBAAiB,UAA8B;CAC1D,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MA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YAAY,CAAC,CAAC;KACxD,IAAI,SAAS,SAAS,GACpB,SAAS,SAAS;MAChB,MAAM,WAAW,IAAI,IAAI,KAAK,IAAI,QAAQ,CAAC;MAC3C,MAAM,QAAQ,SAAS,QACpB,MAAM,CAAC,SAAS,IAAI,SAAS,CAAC,CAAC,CAClC;MACA,OAAO,CAAC,GAAG,MAAM,GAAG,KAAK;KAC3B,CAAC;IAEL;GACF,UAAU;IACR,WAAW,KAAK;GAClB;EACF;CACF,GACA,CAAC,QAAQ,SAAS,CACpB;CAwBA,OAAO;EAAE;EAAM;EAAS;EAAM,QAtBf,UACb;GACE,UAAU;GACV,SAAS,OAAO,SAAS;IACvB,IAAI,CAAC,UAAU,SAAS,QAAQ;IAChC,IAAI,MAAM,QAAQ,IAAI,IAAI,GAAG;KAC3B,QAAQ,MAAM,QAAQ,IAAI,IAAI,CAAE;KAChC;IACF;IACA,WAAW,IAAI;IACf,IAAI;KACF,MAAM,SAAS,MAAM,OAAO,IAAI;KAChC,MAAM,QAAQ,IAAI,MAAM,MAAM;KAC9B,QAAQ,MAAM;IAChB,UAAU;KACR,WAAW,KAAK;IAClB;GACF;EACF,GACA;GAAC;GAAQ;GAAM;EAAU,CAGQ;CAAE;AACvC"}
1
+ {"version":3,"file":"ControlSelect.js","names":[],"sources":["../../src/form/ControlSelect.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport type { Async } from \"alepha\";\nimport { useAction } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport type { HTMLAttributes } from \"react\";\nimport { type ReactNode, useMemo, useRef, useState } from \"react\";\n\nimport { Checkbox } from \"../core/Checkbox.tsx\";\nimport { Segmented } from \"../core/Segmented.tsx\";\nimport { ControlSelectCombobox } from \"./ControlSelectCombobox.tsx\";\nimport { optValue } from \"./controlSelectOptions.ts\";\nimport type { ControlTriggerSize } from \"./fieldTrigger.tsx\";\nimport { FormField } from \"./FormField.tsx\";\nimport type { IconComponent } from \"./iconHint.tsx\";\n\nexport interface ControlSelectProps {\n /**\n * Bound `InputField` from `useForm`. Single or multi value depending on schema.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the input.\n */\n description?: string;\n /**\n * Render as a `<Segmented>` control (best for 2–4 options).\n */\n segmented?: boolean;\n /**\n * Render a multi-choice field (an array schema) as a group of checkboxes,\n * every option visible: for a handful of fixed choices (days of the week,\n * device types), where a select would hide what is ticked. Each checkbox\n * is named by its option's label and carries `data-value`.\n */\n checkboxes?: boolean;\n /**\n * Force the search input on. Kept as the historical name for\n * `searchable: true` — every select is a combobox now, the flag only\n * decides whether it carries a search field.\n */\n combobox?: boolean;\n /**\n * Whether the dropdown carries a search input. Defaults to \"auto\": on for a\n * long-mode `loader` (the rows are not all here), when `createNewEntry` is\n * set (typing IS how an entry is made), and for lists longer than\n * `SEARCH_THRESHOLD`. Set explicitly to search a short list or to drop the\n * search field from a long one.\n *\n * Multi-select obeys the same rule as everything else; it used to force the\n * field on because its chips box doubled as the search input.\n */\n searchable?: boolean;\n /**\n * Async option loader. Triggers long-mode (server-side search) above `loaderThreshold` options.\n */\n loader?: (search: string, resolve?: string[]) => Async<SelectOption[]>;\n /**\n * Option count above which `loader` is invoked on every search instead of once. Defaults to 100.\n */\n loaderThreshold?: number;\n /**\n * Debounce in ms applied to search queries when calling `loader` in long mode.\n */\n loaderDebounce?: number;\n /**\n * Disable the control.\n */\n disabled?: boolean;\n /**\n * Inline option list (overrides schema `enum`). Accepts either a static\n * array or an async function `(query) => SelectOption[]`. The async form\n * is mapped to a long-mode loader.\n */\n items?:\n | SelectOption[]\n | ((query: string) => SelectOption[] | Promise<SelectOption[]>);\n /**\n * Allow the user to add a new option by typing. When `true`, the typed\n * query becomes the value (and label) of a freshly created entry. When a\n * function, the function builds the option from the query.\n *\n * - For multi-select fields: each entry is appended to the value array.\n * - For single fields: behaves like a regular text input with a dropdown\n * suggesting existing options.\n */\n createNewEntry?: boolean | ((query: string) => Exclude<SelectOption, string>);\n /**\n * When true, the dropdown gets a synthetic \"none\" row at the top that\n * resets the field to `undefined`. Useful for optional filter chips\n * (e.g. an admin-table status filter) where the user needs an explicit\n * \"no filter\" option — Base UI's `Select` reserves empty-string values\n * as its internal no-selection sentinel, so a regular `<SelectItem\n * value=\"\">` can't be picked. With `clearable`, ControlSelect uses an\n * internal sentinel and translates it to `undefined` in `onChange`.\n *\n * Currently honored by the static-short `Select` and the searchable\n * Combobox render paths. Ignored by `segmented` (use a real segment\n * for \"all\" there).\n */\n clearable?: boolean;\n /**\n * Label rendered for the \"clear\" row injected by `clearable`. Also\n * used as the trigger placeholder when the field is empty. Defaults to\n * `\"None\"`. Localize at the call site (e.g. `\"All types\"`,\n * `\"All status\"`).\n */\n clearLabel?: string;\n /**\n * Trigger text for a multi-select whose selection is too long to name, e.g.\n * `(n) => \\`${n} status\\``. One selection always shows the value itself, so\n * this is only ever asked for two or more past `maxTriggerLength`. Defaults\n * to `\"{n} values\"`.\n */\n countLabel?: (count: number) => string;\n /**\n * The longest joined text, in characters, a multi-select trigger names its\n * selection with (\"Draft, Ready\") before it collapses to `countLabel`.\n * Defaults to 20, which suits a filter chip; a full-width form field has\n * room for more.\n */\n maxTriggerLength?: number;\n /**\n * Trigger text when nothing is selected, e.g. \"Pick an epic…\". Defaults to\n * the `clearLabel` on a `clearable` or multi field (where empty IS a\n * meaningful state to name), and to \"Select…\" otherwise.\n *\n * Set it when the empty trigger has a job to do - a picker whose whole\n * purpose is the choice it prompts for reads as a dead \"Select…\" without\n * it, which is why the surfaces that needed one stayed on the raw `Select`.\n */\n placeholder?: string;\n /**\n * Extra className applied to the visible trigger: the combobox button or\n * the segmented control, whichever this field renders. Useful for sizing\n * filter chips (`\"w-40\"`, `\"w-72\"`, etc.) without wrapping the whole\n * `FormField` in an extra div.\n */\n triggerClassName?: string;\n /**\n * Trigger height and type scale. Defaults to `default`.\n */\n size?: ControlSelectSize;\n /**\n * Render the trigger borderless and transparent, so it reads as the row it\n * sits on rather than as a form field.\n */\n minimal?: boolean;\n /**\n * Extra attributes for whichever trigger this field renders, forwarded from\n * `Control`'s `inputProps`.\n *\n * The accessible name usually lives here, because a filter is routinely\n * rendered with `label=\"\"` next to its own heading: with no `<label>` to\n * borrow a name from, a `role=combobox` button or a radiogroup has no name\n * at all. That is both an a11y hole and unaddressable from a\n * test, and it was silent, since `Control` accepted `inputProps` and then\n * dropped it on every select-shaped branch.\n */\n triggerProps?: HTMLAttributes<HTMLElement>;\n /**\n * Leading icon rendered on the left of the trigger, matching the\n * text-input controls. Resolved by the parent `Control` from its `icon`\n * prop, falling back to the list glyph like a text input falls back to\n * its schema hint; `icon={null}` on the `Control` removes it, and a\n * `minimal` trigger gets none by default.\n */\n icon?: IconComponent;\n /**\n * Drawn at the top of the popup, above the options - for a setting that\n * changes what the choice MEANS rather than what is chosen, such as a\n * filter's \"is / is not\".\n *\n * ⚠️ Only the combobox shape has a popup, so a segmented or radio rendering\n * of the same field draws nothing for it.\n */\n popupHeader?: ReactNode;\n /**\n * Drawn on the trigger just before the selected label, after the icon: the\n * short word that keeps a qualified value from reading as a plain one\n * (\"not Active\"). Absent while nothing is selected, because a qualifier on\n * a placeholder has nothing to qualify.\n */\n triggerPrefix?: ReactNode;\n /**\n * Extra className on the popup, merged over its own.\n *\n * The popup is sized from its trigger by default (`--anchor-width`), and it\n * keeps following that width while open. A trigger whose text changes as\n * the reader picks - a `triggerPrefix` appearing, \"2 values\" replacing a\n * name - therefore resizes the popup under their cursor. `w-max` with a\n * floor (`w-max min-w-48`) sizes it from its own content instead.\n */\n popupClassName?: string;\n}\n\nexport const ControlSelect = (props: ControlSelectProps) => {\n const { tr } = useI18n();\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n\n const meta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const isArray = meta.isArray;\n const isNumeric = meta.type === \"number\" || meta.type === \"integer\";\n const isBoolean = meta.type === \"boolean\";\n\n // Normalize items prop: array → static; function → loader\n const itemsArray = Array.isArray(props.items)\n ? (props.items as SelectOption[])\n : undefined;\n const itemsLoader =\n typeof props.items === \"function\"\n ? (props.items as (q: string) => Async<SelectOption[]>)\n : undefined;\n\n const enumValues =\n itemsArray ?? (meta.enum as SelectOption[] | undefined) ?? [];\n\n const effectiveLoader = props.loader ?? itemsLoader;\n\n const {\n data: asyncData,\n loading,\n mode,\n search,\n } = useAsyncLoader(\n effectiveLoader,\n props.loaderThreshold ?? 100,\n props.loaderDebounce ?? 300,\n props.input.initialValue,\n );\n\n // Labels and `disabled` flags are part of the identity: keying on the\n // joined values alone collided (`[\"ab\",\"c\"]` vs `[\"a\",\"bc\"]`) and kept a\n // stale list when only the labels changed.\n //\n // ⚠️ `icon` is EXCLUDED, and it has to be. It is a `ReactNode`, and a\n // rendered element holds a fiber that points back at its DOM node, so\n // `JSON.stringify` on the raw option threw \"Converting circular structure\n // to JSON\" - a documented prop that crashed the component the first time\n // anyone used it (#Q2049). Two lists that differ only by icon share a key,\n // which is right: the key exists to notice a changed VALUE or LABEL.\n const enumKey = JSON.stringify(\n enumValues.map((option) =>\n typeof option === \"string\"\n ? option\n : {\n value: option.value,\n label: option.label,\n description: option.description,\n tag: option.tag,\n disabled: option.disabled,\n },\n ),\n );\n const min = meta.constraints.minimum;\n const max = meta.constraints.maximum;\n // Derived, not stored: this is a pure function of the schema. As state\n // filled in by an effect, the first paint of every boolean or ranged select\n // was an EMPTY list, corrected one render later.\n const staticData = useMemo<SelectOption[]>(() => {\n if (effectiveLoader) return [];\n if (isBoolean && enumValues.length === 0) {\n return [\n { value: \"true\", label: tr(\"controlSelect.yes\", { default: \"Yes\" }) },\n { value: \"false\", label: tr(\"controlSelect.no\", { default: \"No\" }) },\n ];\n }\n if (\n isNumeric &&\n enumValues.length === 0 &&\n typeof min === \"number\" &&\n typeof max === \"number\" &&\n max - min <= 20\n ) {\n const range: SelectOption[] = [];\n for (let i = min; i <= max; i++) range.push(String(i));\n return range;\n }\n return enumValues;\n }, [effectiveLoader, enumKey, isBoolean, isNumeric, min, max, tr]);\n\n const data = effectiveLoader ? asyncData : staticData;\n\n if (!props.input?.props) return null;\n\n const coerce = (raw: string): unknown => {\n if (isNumeric) return Number(raw);\n if (isBoolean) return raw === \"true\";\n return raw;\n };\n\n if (props.segmented) {\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n {/* `triggerProps` is deliberately NOT spread here. `Segmented`\n redeclares two attributes that `HTMLAttributes` also has, with\n narrower types (`defaultValue` is string-only, `onChange` takes a\n value rather than an event), so a blanket spread neither typechecks\n nor is safe. A segmented field also renders every option as visible\n text, so it is the one branch that is not nameless without a label.\n Name it with `label` if it needs one. */}\n <Segmented\n value={value != null ? String(value) : undefined}\n onChange={(v) => setValue(coerce(v))}\n disabled={props.disabled}\n options={data.slice(0, 10).map((o) => ({\n value: optValue(o),\n label: segmentedLabel(o),\n }))}\n fullWidth\n />\n </FormField>\n );\n }\n\n if (props.checkboxes && isArray) {\n const ticked = Array.isArray(value) ? (value as unknown[]).map(String) : [];\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div\n role=\"group\"\n aria-label={meta.label || undefined}\n {...props.triggerProps}\n id={meta.id}\n className=\"flex flex-wrap gap-x-4 gap-y-2 py-1\"\n >\n {data.map((o) => {\n const optionValue = optValue(o);\n const optionId = `${meta.id}-${optionValue}`;\n return (\n <label\n key={optionValue}\n htmlFor={optionId}\n className=\"flex items-center gap-2 text-sm\"\n >\n <Checkbox\n // An explicit id: Base UI would mint one with `useId`.\n id={optionId}\n data-value={optionValue}\n disabled={\n props.disabled || (typeof o !== \"string\" && o.disabled)\n }\n checked={ticked.includes(optionValue)}\n onCheckedChange={(checked) => {\n const next = checked\n ? [...ticked, optionValue]\n : ticked.filter((it) => it !== optionValue);\n // In the options' order, whatever order they were ticked.\n const ordered = data\n .map(optValue)\n .filter((it) => next.includes(it));\n setValue(ordered.map(coerce));\n }}\n />\n {segmentedLabel(o)}\n </label>\n );\n })}\n </div>\n </FormField>\n );\n }\n\n const clearLabel =\n props.clearLabel ?? tr(\"controlSelect.none\", { default: \"None\" });\n\n // One control for every list. The option count decides whether the popup\n // carries a search field — it no longer decides which primitive renders.\n // The native `Select` path this replaced silently dropped `description`,\n // `tag`, per-option `disabled` and `deselectable`, and styled its trigger\n // differently, purely because a list happened to be short.\n // A search field is offered only when scanning the list by eye stops being\n // realistic: a server-driven list (whose rows are not all here), one past\n // `SEARCH_THRESHOLD`, or one where typing is how a new entry is made.\n //\n // Multi-select used to force it on unconditionally, because the chips box\n // WAS the search input and there was no other way to open the popup. The\n // trigger is a button now, so multi obeys the same rule as everything else\n // and a four-row status filter no longer opens onto a search field.\n const searchable =\n props.searchable ??\n (props.combobox ||\n mode === \"long\" ||\n Boolean(props.createNewEntry) ||\n data.length > SEARCH_THRESHOLD);\n\n return (\n <FormField\n id={meta.id}\n label={meta.label}\n description={meta.description}\n error={meta.error}\n required={meta.required}\n >\n <ControlSelectCombobox\n id={meta.id}\n data={data}\n loading={loading}\n multi={isArray}\n searchable={searchable}\n disabled={props.disabled}\n value={value}\n onChange={(v) => setValue(v)}\n coerce={coerce}\n onSearch={mode === \"long\" ? (text) => search.run(text) : undefined}\n createNewEntry={props.createNewEntry}\n icon={props.icon}\n // Used to be dropped on this path, so a filter chip sized `w-40` lost\n // its width as soon as its list crossed the threshold.\n triggerClassName={props.triggerClassName}\n triggerProps={props.triggerProps}\n size={props.size}\n minimal={props.minimal}\n // `clearable` used to reach this path as a placeholder and nothing\n // else, so a filter chip that had switched to the combobox (>20\n // options) could be set but never put back to \"All …\".\n clearable={props.clearable}\n clearLabel={clearLabel}\n countLabel={props.countLabel}\n maxTriggerLength={props.maxTriggerLength}\n popupHeader={props.popupHeader}\n triggerPrefix={props.triggerPrefix}\n popupClassName={props.popupClassName}\n // An optional field must also be able to go back to empty without a\n // dedicated row: Base UI never emits `null`, so re-pressing the\n // selected row deselects (see `handleSingle` in\n // `ControlSelectCombobox.tsx`). A required field keeps its value —\n // clearing it would only produce a validation error the user cannot\n // see yet.\n deselectable={props.clearable || !meta.required}\n // Multi shows this muted when nothing is picked, so it reaches the\n // trigger whether or not the field is `clearable` — a multi-select\n // has no clear ROW (it clears by deselecting), and without this its\n // empty trigger fell back to a bare \"Select…\".\n placeholder={\n props.placeholder ??\n (props.clearable || isArray ? clearLabel : undefined)\n }\n />\n </FormField>\n );\n};\n\nexport type SelectOption =\n | string\n | {\n value: string;\n label: string;\n /**\n * Optional secondary line shown under the label in the dropdown.\n */\n description?: string;\n /**\n * Optional small badge rendered next to the label.\n */\n tag?: string;\n /**\n * Optional icon/element rendered before the label, in both the\n * dropdown row and (for single-select) the trigger when selected.\n */\n icon?: ReactNode;\n /**\n * When true, the row is non-interactive — can't be selected if\n * not selected, can't be deselected if selected. Useful for\n * default/mandatory entries (e.g. the base \"user\" role).\n */\n disabled?: boolean;\n };\n\ntype LoaderMode = \"static\" | \"short\" | \"long\";\n\n/**\n * How tall and how loud a select trigger is.\n *\n * The kit's own scale, kept under this name because `Control` and a long tail\n * of callers already spell it `size=\"xs\"` on a select. The table behind it,\n * and the trigger box it sizes, are `control-base/field-trigger`'s - shared\n * with the two calendar controls, which used to draw a button instead.\n */\nexport type ControlSelectSize = ControlTriggerSize;\n\n/**\n * Static option count above which the dropdown grows a search input. Below it\n * the very same combobox renders without one — the threshold decides whether\n * you can type, never which control you get.\n */\n// Past this many rows, scanning by eye stops being realistic and the popup\n// grows a search field. Raised 20 -> 50 with the multi-select rework: the old\n// value put a search box on lists a reader takes in at a glance.\nconst SEARCH_THRESHOLD = 50;\n\n/**\n * Friendly label for plain string options: \"optional\" → \"Optional\",\n * \"in_progress\" → \"In Progress\". Custom `{ value, label }` items pass through\n * untouched.\n */\nconst titlecase = (s: string) =>\n s.replace(/[_-]+/g, \" \").replace(/\\b\\w/g, (c) => c.toUpperCase());\n/**\n * What one segment shows.\n *\n * ⚠️ The option's `icon` is rendered HERE rather than dropped, which is what\n * this path did until #Q2049. `SegmentedOption.label` is a `ReactNode`, so\n * there was never a reason for it: an option list carrying icons for the\n * dropdown carried them for the segments too, and dropping them silently\n * made a caller choose between two shapes for one list.\n */\nconst segmentedLabel = (o: SelectOption): ReactNode => {\n if (typeof o === \"string\") {\n return titlecase(o);\n }\n if (!o.icon) {\n return o.label;\n }\n return (\n <span className=\"inline-flex items-center gap-1.5\">\n {o.icon}\n {o.label}\n </span>\n );\n};\n\nconst useAsyncLoader = (\n loader: ControlSelectProps[\"loader\"],\n threshold: number,\n debounceMs: number,\n defaultValue: unknown,\n) => {\n const [data, setData] = useState<SelectOption[]>([]);\n const [loading, setLoading] = useState(false);\n const [mode, setMode] = useState<LoaderMode>(\"static\");\n const cache = useRef(new Map<string, SelectOption[]>());\n\n useAction(\n {\n // `id`, not `name`: `id` is what useAction threads into its\n // react:action:* events. `name` was accepted and never read, so this\n // identifier reached nothing.\n id: \"select:loader:init\",\n runOnInit: true,\n handler: async () => {\n if (!loader) {\n setMode(\"static\");\n return;\n }\n setLoading(true);\n try {\n const result = await loader(\"\");\n const isShort = result.length <= threshold;\n setMode(isShort ? \"short\" : \"long\");\n cache.current.set(\"\", result);\n setData(result);\n\n // Coercion at a boundary: the value is a form/route/chart primitive whose\n // declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n if (!isShort && defaultValue != null && String(defaultValue) !== \"\") {\n // Coercion at a boundary: the value is a form/route/chart primitive whose\n // declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n const resolved = await loader(\"\", [String(defaultValue)]);\n if (resolved.length > 0) {\n setData((prev) => {\n const existing = new Set(prev.map(optValue));\n const fresh = resolved.filter(\n (r) => !existing.has(optValue(r)),\n );\n return [...prev, ...fresh];\n });\n }\n }\n } finally {\n setLoading(false);\n }\n },\n },\n [loader, threshold],\n );\n\n const search = useAction<[string]>(\n {\n debounce: debounceMs,\n handler: async (_ctx, text) => {\n if (!loader || mode !== \"long\") return;\n if (cache.current.has(text)) {\n setData(cache.current.get(text)!);\n return;\n }\n setLoading(true);\n try {\n const result = await loader(text);\n cache.current.set(text, result);\n setData(result);\n } finally {\n setLoading(false);\n }\n },\n },\n [loader, mode, debounceMs],\n );\n\n return { data, loading, mode, search };\n};\n"],"mappings":";;;;;;;;;;;AAgNA,MAAa,iBAAiB,UAA8B;CAC1D,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CAEnD,MAAM,OAAO,WAAW,MAAM,OAAO;EACnC,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO,KAAK;CACd,CAAC;CAED,MAAM,UAAU,KAAK;CACrB,MAAM,YAAY,KAAK,SAAS,YAAY,KAAK,SAAS;CAC1D,MAAM,YAAY,KAAK,SAAS;CAGhC,MAAM,aAAa,MAAM,QAAQ,MAAM,KAAK,IACvC,MAAM,QACP,KAAA;CACJ,MAAM,cACJ,OAAO,MAAM,UAAU,aAClB,MAAM,QACP,KAAA;CAEN,MAAM,aACJ,cAAe,KAAK,QAAuC,CAAC;CAE9D,MAAM,kBAAkB,MAAM,UAAU;CAExC,MAAM,EACJ,MAAM,WACN,SACA,MACA,WACE,eACF,iBACA,MAAM,mBAAmB,KACzB,MAAM,kBAAkB,KACxB,MAAM,MAAM,YACd;CAYA,MAAM,UAAU,KAAK,UACnB,WAAW,KAAK,WACd,OAAO,WAAW,WACd,SACA;EACE,OAAO,OAAO;EACd,OAAO,OAAO;EACd,aAAa,OAAO;EACpB,KAAK,OAAO;EACZ,UAAU,OAAO;CACnB,CACN,CACF;CACA,MAAM,MAAM,KAAK,YAAY;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AAU;IACjC,QAAQ,UAAU,UAAU,MAAM;IAClC,MAAM,QAAQ,IAAI,IAAI,MAAM;IAC5B,QAAQ,MAAM;IAKd,IAAI,CAAC,WAAW,gBAAgB,QAAQ,OAAO,YAAY,MAAM,IAAI;KAInE,MAAM,WAAW,MAAM,OAAO,IAAI,CAAC,OAAO,YAAY,CAAC,CAAC;KACxD,IAAI,SAAS,SAAS,GACpB,SAAS,SAAS;MAChB,MAAM,WAAW,IAAI,IAAI,KAAK,IAAI,QAAQ,CAAC;MAC3C,MAAM,QAAQ,SAAS,QACpB,MAAM,CAAC,SAAS,IAAI,SAAS,CAAC,CAAC,CAClC;MACA,OAAO,CAAC,GAAG,MAAM,GAAG,KAAK;KAC3B,CAAC;IAEL;GACF,UAAU;IACR,WAAW,KAAK;GAClB;EACF;CACF,GACA,CAAC,QAAQ,SAAS,CACpB;CAwBA,OAAO;EAAE;EAAM;EAAS;EAAM,QAtBf,UACb;GACE,UAAU;GACV,SAAS,OAAO,MAAM,SAAS;IAC7B,IAAI,CAAC,UAAU,SAAS,QAAQ;IAChC,IAAI,MAAM,QAAQ,IAAI,IAAI,GAAG;KAC3B,QAAQ,MAAM,QAAQ,IAAI,IAAI,CAAE;KAChC;IACF;IACA,WAAW,IAAI;IACf,IAAI;KACF,MAAM,SAAS,MAAM,OAAO,IAAI;KAChC,MAAM,QAAQ,IAAI,MAAM,MAAM;KAC9B,QAAQ,MAAM;IAChB,UAAU;KACR,WAAW,KAAK;IAClB;GACF;EACF,GACA;GAAC;GAAQ;GAAM;EAAU,CAGQ;CAAE;AACvC"}
@@ -40,7 +40,7 @@ export interface ControlUploadProps {
40
40
  * image the decoder chokes on is uploaded as-is, and the storage's own
41
41
  * `maxSize` remains what actually bounds it. That trade is deliberate — a
42
42
  * server-side codec able to close the gap costs more bundle than the case is
43
- * worth on an edge runtime, and encodes worse (see `files:beforeUpload` in
43
+ * worth on an edge runtime, and encodes worse (see `files:upload:before` in
44
44
  * `alepha/api/files` for where it would attach if you want it anyway).
45
45
  *
46
46
  * @example { maxWidth: 256 }
@@ -1 +1 @@
1
- {"version":3,"file":"ControlUpload.js","names":["FileIcon"],"sources":["../../src/form/ControlUpload.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport type { FileController } from \"alepha/api/files\";\nimport { useClient } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { File as FileIcon, Loader2, Upload, X } from \"lucide-react\";\nimport {\n type ChangeEvent,\n type DragEvent,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\n\nimport { Button } from \"../core/Button.tsx\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from \"../core/Dialog.tsx\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"../core/Tooltip.tsx\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { formatBytes } from \"../core/utils.ts\";\nimport { ControlUploadItemThumb } from \"./ControlUploadItemThumb.tsx\";\nimport { FormField } from \"./FormField.tsx\";\nimport { type ResizeImageOptions, resizeImage } from \"./resizeImage.ts\";\n\nexport interface ControlUploadProps {\n /**\n * Bound `InputField` from `useForm`. Stores the uploaded file ID(s).\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the dropzone.\n */\n description?: string;\n /**\n * Multi-file mode. The form value becomes an `Array<string>` of file\n * IDs. Single mode (default) stores a bare UUID string.\n */\n multi?: boolean;\n /**\n * HTML `accept` filter on the file picker (e.g. `\"image/*\"`,\n * `\".pdf,.docx\"`).\n */\n accept?: string;\n /**\n * Max size per file (bytes). Files over the limit are rejected.\n */\n maxSize?: number;\n /**\n * Downscale images to these bounds before uploading.\n *\n * Set it wherever the result is rendered small — the bytes never leave the\n * machine, so it speeds up the upload as well as every later fetch. Applied\n * before {@link maxSize}, so a photo that would have been rejected for being\n * too large is resized and accepted instead.\n *\n * Best-effort by design: a browser without `OffscreenCanvas`, an SVG, or an\n * image the decoder chokes on is uploaded as-is, and the storage's own\n * `maxSize` remains what actually bounds it. That trade is deliberate — a\n * server-side codec able to close the gap costs more bundle than the case is\n * worth on an edge runtime, and encodes worse (see `files:beforeUpload` in\n * `alepha/api/files` for where it would attach if you want it anyway).\n *\n * @example { maxWidth: 256 }\n */\n image?: ResizeImageOptions;\n /**\n * Bucket name passed to the upload endpoint.\n */\n bucket?: string;\n /**\n * Disable the dropzone.\n */\n disabled?: boolean;\n}\n\n/**\n * File upload control. Wraps `FileController.uploadFile`, stores the\n * resulting file ID(s) in the form, and renders a thumbnail preview for\n * images and a chip-style summary for everything else.\n *\n * Single-file: form value is a uuid string.\n * Multi-file: form value is an array of uuid strings.\n */\nexport const ControlUpload = (props: ControlUploadProps) => {\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n const client = useClient<FileController>();\n const { tr } = useI18n();\n const toast = useToast();\n const inputId = useId();\n const fileInputRef = useRef<HTMLInputElement>(null);\n const [uploading, setUploading] = useState(false);\n const [progress, setProgress] = useState(0);\n const [meta, setMeta] = useState<Map<string, UploadedFileMeta>>(new Map());\n const [dragOver, setDragOver] = useState(false);\n const [previewId, setPreviewId] = useState<string | null>(null);\n\n /**\n * Backfill `meta` for ids that arrived from form state (e.g. after a page\n * reload) so the renderer can show a thumbnail / chip instead of the raw\n * uuid. We can't infer the real mime type without an extra request, so we\n * fall back to a stub entry pointing at `/api/files/:id` and let the\n * `<img>` `onError` swap to the generic file chip.\n */\n useEffect(() => {\n const ids: string[] = props.multi\n ? Array.isArray(value)\n ? (value as string[])\n : []\n : value\n ? [value as string]\n : [];\n // Reconciles a cache of per-file metadata against the ids the field now\n // holds, and the entries it keeps were filled in by the upload requests this\n // same effect issues. It is the cache for an external system, not derived\n // state; the updater already no-ops when nothing changed.\n // oxlint-disable-next-line react/set-state-in-effect -- reconciles a cache for an external system, see the comment above\n setMeta((current) => {\n let changed = false;\n const next = new Map(current);\n for (const id of ids) {\n if (!next.has(id)) {\n next.set(id, {\n id,\n name: id,\n previewUrl: `/api/files/${id}`,\n });\n changed = true;\n }\n }\n return changed ? next : current;\n });\n }, [Array.isArray(value) ? value.join(\",\") : value, props.multi]);\n\n if (!props.input?.props) return null;\n\n const fieldMeta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const ids: string[] = props.multi\n ? Array.isArray(value)\n ? (value as string[])\n : []\n : value\n ? [value as string]\n : [];\n\n const handleFiles = async (files: FileList) => {\n if (!files.length) return;\n if (!props.multi && files.length > 1) {\n toast.error(\n tr(\"controlUpload.singleOnly\", { default: \"Only one file allowed\" }),\n );\n return;\n }\n\n setUploading(true);\n setProgress(0);\n const next = new Map(meta);\n const newIds: string[] = [];\n\n try {\n for (let i = 0; i < files.length; i++) {\n // Ahead of the size check on purpose: a 4 MB photo destined for a 32px\n // avatar should become a few kilobytes, not an error.\n const file = props.image\n ? await resizeImage(files[i], props.image)\n : files[i];\n\n if (props.maxSize && file.size > props.maxSize) {\n toast.error(\n tr(\"controlUpload.tooBig\", {\n default: `${file.name} exceeds ${formatBytes(props.maxSize)}`,\n args: [file.name, formatBytes(props.maxSize)],\n }),\n );\n continue;\n }\n\n const resource = await client.uploadFile({\n body: { file },\n query: props.bucket ? { bucket: props.bucket } : ({} as never),\n });\n\n const previewUrl = file.type.startsWith(\"image/\")\n ? URL.createObjectURL(file)\n : undefined;\n\n next.set(resource.id, {\n id: resource.id,\n name: resource.name ?? file.name,\n mimeType: resource.mimeType ?? file.type,\n size: resource.size ?? file.size,\n previewUrl,\n });\n newIds.push(resource.id);\n setProgress(Math.round(((i + 1) / files.length) * 100));\n }\n\n setMeta(next);\n if (props.multi) {\n setValue([...ids, ...newIds]);\n } else if (newIds[0]) {\n setValue(newIds[0]);\n }\n if (newIds.length) {\n toast.success(\n newIds.length === 1\n ? tr(\"controlUpload.uploadedOne\", { default: \"File uploaded\" })\n : tr(\"controlUpload.uploadedMany\", {\n default: `${newIds.length} files uploaded`,\n args: [String(newIds.length)],\n }),\n );\n }\n } catch (e) {\n const msg = (e as Error).message;\n toast.error(\n tr(\"controlUpload.failed\", {\n default: `Upload failed: ${msg}`,\n args: [msg],\n }),\n );\n } finally {\n setUploading(false);\n setProgress(0);\n if (fileInputRef.current) fileInputRef.current.value = \"\";\n }\n };\n\n const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files) void handleFiles(e.target.files);\n };\n\n const handleDrop = (e: DragEvent) => {\n e.preventDefault();\n setDragOver(false);\n if (props.disabled) return;\n if (e.dataTransfer.files) void handleFiles(e.dataTransfer.files);\n };\n\n const removeOne = (id: string) => {\n const next = new Map(meta);\n const item = next.get(id);\n if (item?.previewUrl) URL.revokeObjectURL(item.previewUrl);\n next.delete(id);\n setMeta(next);\n\n if (props.multi) {\n setValue(ids.filter((it) => it !== id));\n } else {\n setValue(undefined);\n }\n };\n\n const renderItem = (id: string) => {\n const item = meta.get(id);\n const acceptsImage = (props.accept ?? \"\").includes(\"image\");\n const mimeIsImage = item?.mimeType?.startsWith(\"image/\");\n const isImage =\n mimeIsImage || (acceptsImage && !!item?.previewUrl && !item?.mimeType);\n\n const canClear = !props.disabled && !fieldMeta.required;\n\n return (\n <div\n key={id}\n className={`border-border dark:bg-input/30 relative flex h-9 cursor-zoom-in items-center rounded-md border bg-transparent pl-1 ${canClear ? \"pr-9\" : \"pr-2\"}`}\n onClick={() => setPreviewId(id)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n setPreviewId(id);\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {isImage && item?.previewUrl ? (\n <ControlUploadItemThumb url={item.previewUrl} alt={item.name ?? id} />\n ) : (\n <div className=\"bg-muted text-muted-foreground flex size-7 shrink-0 items-center justify-center rounded\">\n <FileIcon className=\"size-4\" />\n </div>\n )}\n {canClear && (\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n removeOne(id);\n }}\n aria-label={tr(\"controlUpload.remove\", { default: \"Remove\" })}\n className=\"text-muted-foreground hover:text-foreground absolute top-1/2 right-2 -translate-y-1/2 p-1\"\n >\n <X className=\"size-3.5\" />\n </button>\n )}\n </div>\n );\n };\n\n const previewItem = previewId ? meta.get(previewId) : undefined;\n const previewIsImage = previewItem\n ? previewItem.mimeType?.startsWith(\"image/\") ||\n ((props.accept ?? \"\").includes(\"image\") &&\n !!previewItem.previewUrl &&\n !previewItem.mimeType)\n : false;\n const previewHasName =\n !!previewItem?.name && previewItem.name !== previewItem.id;\n\n const dragDropHint =\n tr(\"controlUpload.dragDrop\", { default: \"Upload or drag and drop here\" }) +\n (props.maxSize\n ? ` · ${tr(\"controlUpload.max\", {\n default: `max ${formatBytes(props.maxSize)}`,\n args: [formatBytes(props.maxSize)],\n })}`\n : \"\");\n\n const dropZone = (\n <Tooltip>\n <TooltipTrigger\n render={\n <Button\n type=\"button\"\n variant=\"outlined\"\n size=\"sm\"\n disabled={props.disabled || uploading}\n onClick={() => fileInputRef.current?.click()}\n onDragOver={(e) => {\n e.preventDefault();\n setDragOver(true);\n }}\n onDragLeave={() => setDragOver(false)}\n onDrop={handleDrop}\n className={dragOver ? \"border-primary bg-primary/5\" : \"\"}\n />\n }\n >\n {uploading ? (\n <>\n <Loader2 className=\"mr-1 size-4 animate-spin\" />\n {tr(\"controlUpload.uploading\", { default: \"Uploading…\" })}\n </>\n ) : (\n <>\n <Upload className=\"mr-1 size-4\" />\n {props.multi\n ? tr(\"controlUpload.chooseFiles\", { default: \"Choose files\" })\n : tr(\"controlUpload.chooseFile\", { default: \"Choose a file\" })}\n </>\n )}\n </TooltipTrigger>\n <TooltipContent>{dragDropHint}</TooltipContent>\n </Tooltip>\n );\n\n return (\n <FormField\n id={inputId}\n label={fieldMeta.label}\n description={fieldMeta.description}\n error={fieldMeta.error}\n required={fieldMeta.required}\n >\n <input\n ref={fileInputRef}\n type=\"file\"\n id={inputId}\n name={props.input.props.name}\n className=\"hidden\"\n accept={props.accept}\n multiple={props.multi}\n disabled={props.disabled}\n onChange={handleInputChange}\n />\n\n <div className=\"flex flex-col gap-2\">\n {ids.length > 0 && (\n <div className=\"flex flex-col gap-2\">{ids.map(renderItem)}</div>\n )}\n {(props.multi || ids.length === 0) && dropZone}\n {uploading && (\n <div className=\"bg-muted h-1 w-full overflow-hidden rounded\">\n <div\n className=\"bg-primary h-full transition-all\"\n style={{ width: `${progress}%` }}\n />\n </div>\n )}\n </div>\n\n <Dialog\n open={previewId !== null}\n onOpenChange={(o) => !o && setPreviewId(null)}\n >\n <DialogContent className=\"w-fit max-w-fit p-0\">\n <DialogHeader className=\"sr-only\">\n <DialogTitle>\n {previewHasName\n ? previewItem?.name\n : tr(\"controlUpload.savedFile\", { default: \"Saved file\" })}\n </DialogTitle>\n <DialogDescription>\n {previewItem?.mimeType ?? \"uploaded\"}\n </DialogDescription>\n </DialogHeader>\n <div className=\"p-4\">\n {previewIsImage && previewItem?.previewUrl ? (\n <img\n src={previewItem.previewUrl}\n alt={previewItem.name ?? \"\"}\n className=\"size-72 rounded object-contain\"\n />\n ) : (\n <div className=\"bg-muted text-muted-foreground flex size-72 items-center justify-center rounded\">\n <FileIcon className=\"size-16\" />\n </div>\n )}\n </div>\n {(previewHasName || previewItem?.mimeType) && (\n <div className=\"bg-muted/30 flex flex-col gap-0 border-t px-4 py-2\">\n {previewHasName && (\n <span className=\"truncate text-sm font-medium\">\n {previewItem?.name}\n </span>\n )}\n {previewItem?.mimeType && (\n <span className=\"text-muted-foreground truncate text-xs\">\n {previewItem.mimeType}\n </span>\n )}\n </div>\n )}\n </DialogContent>\n </Dialog>\n </FormField>\n );\n};\n\ninterface UploadedFileMeta {\n id: string;\n name: string;\n mimeType?: string;\n size?: number;\n /**\n * Object URL for image preview, when applicable.\n */\n previewUrl?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqGA,MAAa,iBAAiB,UAA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,cAAc;IACpB,eAAe,MAAM,CAAC,KAAK,aAAa,IAAI;IAE5C,UAAA,qBAAC,eAAD;KAAe,WAAU;KAAzB,UAAA;MACE,qBAAC,cAAD;OAAc,WAAU;OAAxB,UAAA,CACE,oBAAC,aAAD,EAAA,UACG,iBACG,aAAa,OACb,GAAG,2BAA2B,EAAE,SAAS,aAAa,CAAC,EAChD,CAAA,GACb,oBAAC,mBAAD,EAAA,UACG,aAAa,YAAY,WACT,CAAA,CACP;;MACd,oBAAC,OAAD;OAAK,WAAU;OACZ,UAAA,kBAAkB,aAAa,aAC9B,oBAAC,OAAD;QACE,KAAK,YAAY;QACjB,KAAK,YAAY,QAAQ;QACzB,WAAU;OACX,CAAA,IAED,oBAAC,OAAD;QAAK,WAAU;QACb,UAAA,oBAACA,MAAD,EAAU,WAAU,UAAW,CAAA;OAC5B,CAAA;MAEJ,CAAA;OACH,kBAAkB,aAAa,aAC/B,qBAAC,OAAD;OAAK,WAAU;OAAf,UAAA,CACG,kBACC,oBAAC,QAAD;QAAM,WAAU;QACb,UAAA,aAAa;OACV,CAAA,GAEP,aAAa,YACZ,oBAAC,QAAD;QAAM,WAAU;QACb,UAAA,YAAY;OACT,CAAA,CAEL;;KAEM;;GACT,CAAA;EACC;;AAEf"}
1
+ {"version":3,"file":"ControlUpload.js","names":["FileIcon"],"sources":["../../src/form/ControlUpload.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport type { FileController } from \"alepha/api/files\";\nimport { useClient } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { File as FileIcon, Loader2, Upload, X } from \"lucide-react\";\nimport {\n type ChangeEvent,\n type DragEvent,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\n\nimport { Button } from \"../core/Button.tsx\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogHeader,\n DialogTitle,\n} from \"../core/Dialog.tsx\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"../core/Tooltip.tsx\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { formatBytes } from \"../core/utils.ts\";\nimport { ControlUploadItemThumb } from \"./ControlUploadItemThumb.tsx\";\nimport { FormField } from \"./FormField.tsx\";\nimport { type ResizeImageOptions, resizeImage } from \"./resizeImage.ts\";\n\nexport interface ControlUploadProps {\n /**\n * Bound `InputField` from `useForm`. Stores the uploaded file ID(s).\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title`.\n */\n label?: string;\n /**\n * Helper text shown below the dropzone.\n */\n description?: string;\n /**\n * Multi-file mode. The form value becomes an `Array<string>` of file\n * IDs. Single mode (default) stores a bare UUID string.\n */\n multi?: boolean;\n /**\n * HTML `accept` filter on the file picker (e.g. `\"image/*\"`,\n * `\".pdf,.docx\"`).\n */\n accept?: string;\n /**\n * Max size per file (bytes). Files over the limit are rejected.\n */\n maxSize?: number;\n /**\n * Downscale images to these bounds before uploading.\n *\n * Set it wherever the result is rendered small — the bytes never leave the\n * machine, so it speeds up the upload as well as every later fetch. Applied\n * before {@link maxSize}, so a photo that would have been rejected for being\n * too large is resized and accepted instead.\n *\n * Best-effort by design: a browser without `OffscreenCanvas`, an SVG, or an\n * image the decoder chokes on is uploaded as-is, and the storage's own\n * `maxSize` remains what actually bounds it. That trade is deliberate — a\n * server-side codec able to close the gap costs more bundle than the case is\n * worth on an edge runtime, and encodes worse (see `files:upload:before` in\n * `alepha/api/files` for where it would attach if you want it anyway).\n *\n * @example { maxWidth: 256 }\n */\n image?: ResizeImageOptions;\n /**\n * Bucket name passed to the upload endpoint.\n */\n bucket?: string;\n /**\n * Disable the dropzone.\n */\n disabled?: boolean;\n}\n\n/**\n * File upload control. Wraps `FileController.uploadFile`, stores the\n * resulting file ID(s) in the form, and renders a thumbnail preview for\n * images and a chip-style summary for everything else.\n *\n * Single-file: form value is a uuid string.\n * Multi-file: form value is an array of uuid strings.\n */\nexport const ControlUpload = (props: ControlUploadProps) => {\n const form = useFormState(props.input, [\"error\"]);\n const [value, setValue] = useFieldValue(props.input);\n const client = useClient<FileController>();\n const { tr } = useI18n();\n const toast = useToast();\n const inputId = useId();\n const fileInputRef = useRef<HTMLInputElement>(null);\n const [uploading, setUploading] = useState(false);\n const [progress, setProgress] = useState(0);\n const [meta, setMeta] = useState<Map<string, UploadedFileMeta>>(new Map());\n const [dragOver, setDragOver] = useState(false);\n const [previewId, setPreviewId] = useState<string | null>(null);\n\n /**\n * Backfill `meta` for ids that arrived from form state (e.g. after a page\n * reload) so the renderer can show a thumbnail / chip instead of the raw\n * uuid. We can't infer the real mime type without an extra request, so we\n * fall back to a stub entry pointing at `/api/files/:id` and let the\n * `<img>` `onError` swap to the generic file chip.\n */\n useEffect(() => {\n const ids: string[] = props.multi\n ? Array.isArray(value)\n ? (value as string[])\n : []\n : value\n ? [value as string]\n : [];\n // Reconciles a cache of per-file metadata against the ids the field now\n // holds, and the entries it keeps were filled in by the upload requests this\n // same effect issues. It is the cache for an external system, not derived\n // state; the updater already no-ops when nothing changed.\n // oxlint-disable-next-line react/set-state-in-effect -- reconciles a cache for an external system, see the comment above\n setMeta((current) => {\n let changed = false;\n const next = new Map(current);\n for (const id of ids) {\n if (!next.has(id)) {\n next.set(id, {\n id,\n name: id,\n previewUrl: `/api/files/${id}`,\n });\n changed = true;\n }\n }\n return changed ? next : current;\n });\n }, [Array.isArray(value) ? value.join(\",\") : value, props.multi]);\n\n if (!props.input?.props) return null;\n\n const fieldMeta = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n\n const ids: string[] = props.multi\n ? Array.isArray(value)\n ? (value as string[])\n : []\n : value\n ? [value as string]\n : [];\n\n const handleFiles = async (files: FileList) => {\n if (!files.length) return;\n if (!props.multi && files.length > 1) {\n toast.error(\n tr(\"controlUpload.singleOnly\", { default: \"Only one file allowed\" }),\n );\n return;\n }\n\n setUploading(true);\n setProgress(0);\n const next = new Map(meta);\n const newIds: string[] = [];\n\n try {\n for (let i = 0; i < files.length; i++) {\n // Ahead of the size check on purpose: a 4 MB photo destined for a 32px\n // avatar should become a few kilobytes, not an error.\n const file = props.image\n ? await resizeImage(files[i], props.image)\n : files[i];\n\n if (props.maxSize && file.size > props.maxSize) {\n toast.error(\n tr(\"controlUpload.tooBig\", {\n default: `${file.name} exceeds ${formatBytes(props.maxSize)}`,\n args: [file.name, formatBytes(props.maxSize)],\n }),\n );\n continue;\n }\n\n const resource = await client.uploadFile({\n body: { file },\n query: props.bucket ? { bucket: props.bucket } : ({} as never),\n });\n\n const previewUrl = file.type.startsWith(\"image/\")\n ? URL.createObjectURL(file)\n : undefined;\n\n next.set(resource.id, {\n id: resource.id,\n name: resource.name ?? file.name,\n mimeType: resource.mimeType ?? file.type,\n size: resource.size ?? file.size,\n previewUrl,\n });\n newIds.push(resource.id);\n setProgress(Math.round(((i + 1) / files.length) * 100));\n }\n\n setMeta(next);\n if (props.multi) {\n setValue([...ids, ...newIds]);\n } else if (newIds[0]) {\n setValue(newIds[0]);\n }\n if (newIds.length) {\n toast.success(\n newIds.length === 1\n ? tr(\"controlUpload.uploadedOne\", { default: \"File uploaded\" })\n : tr(\"controlUpload.uploadedMany\", {\n default: `${newIds.length} files uploaded`,\n args: [String(newIds.length)],\n }),\n );\n }\n } catch (e) {\n const msg = (e as Error).message;\n toast.error(\n tr(\"controlUpload.failed\", {\n default: `Upload failed: ${msg}`,\n args: [msg],\n }),\n );\n } finally {\n setUploading(false);\n setProgress(0);\n if (fileInputRef.current) fileInputRef.current.value = \"\";\n }\n };\n\n const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files) void handleFiles(e.target.files);\n };\n\n const handleDrop = (e: DragEvent) => {\n e.preventDefault();\n setDragOver(false);\n if (props.disabled) return;\n if (e.dataTransfer.files) void handleFiles(e.dataTransfer.files);\n };\n\n const removeOne = (id: string) => {\n const next = new Map(meta);\n const item = next.get(id);\n if (item?.previewUrl) URL.revokeObjectURL(item.previewUrl);\n next.delete(id);\n setMeta(next);\n\n if (props.multi) {\n setValue(ids.filter((it) => it !== id));\n } else {\n setValue(undefined);\n }\n };\n\n const renderItem = (id: string) => {\n const item = meta.get(id);\n const acceptsImage = (props.accept ?? \"\").includes(\"image\");\n const mimeIsImage = item?.mimeType?.startsWith(\"image/\");\n const isImage =\n mimeIsImage || (acceptsImage && !!item?.previewUrl && !item?.mimeType);\n\n const canClear = !props.disabled && !fieldMeta.required;\n\n return (\n <div\n key={id}\n className={`border-border dark:bg-input/30 relative flex h-9 cursor-zoom-in items-center rounded-md border bg-transparent pl-1 ${canClear ? \"pr-9\" : \"pr-2\"}`}\n onClick={() => setPreviewId(id)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n setPreviewId(id);\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {isImage && item?.previewUrl ? (\n <ControlUploadItemThumb url={item.previewUrl} alt={item.name ?? id} />\n ) : (\n <div className=\"bg-muted text-muted-foreground flex size-7 shrink-0 items-center justify-center rounded\">\n <FileIcon className=\"size-4\" />\n </div>\n )}\n {canClear && (\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation();\n removeOne(id);\n }}\n aria-label={tr(\"controlUpload.remove\", { default: \"Remove\" })}\n className=\"text-muted-foreground hover:text-foreground absolute top-1/2 right-2 -translate-y-1/2 p-1\"\n >\n <X className=\"size-3.5\" />\n </button>\n )}\n </div>\n );\n };\n\n const previewItem = previewId ? meta.get(previewId) : undefined;\n const previewIsImage = previewItem\n ? previewItem.mimeType?.startsWith(\"image/\") ||\n ((props.accept ?? \"\").includes(\"image\") &&\n !!previewItem.previewUrl &&\n !previewItem.mimeType)\n : false;\n const previewHasName =\n !!previewItem?.name && previewItem.name !== previewItem.id;\n\n const dragDropHint =\n tr(\"controlUpload.dragDrop\", { default: \"Upload or drag and drop here\" }) +\n (props.maxSize\n ? ` · ${tr(\"controlUpload.max\", {\n default: `max ${formatBytes(props.maxSize)}`,\n args: [formatBytes(props.maxSize)],\n })}`\n : \"\");\n\n const dropZone = (\n <Tooltip>\n <TooltipTrigger\n render={\n <Button\n type=\"button\"\n variant=\"outlined\"\n size=\"sm\"\n disabled={props.disabled || uploading}\n onClick={() => fileInputRef.current?.click()}\n onDragOver={(e) => {\n e.preventDefault();\n setDragOver(true);\n }}\n onDragLeave={() => setDragOver(false)}\n onDrop={handleDrop}\n className={dragOver ? \"border-primary bg-primary/5\" : \"\"}\n />\n }\n >\n {uploading ? (\n <>\n <Loader2 className=\"mr-1 size-4 animate-spin\" />\n {tr(\"controlUpload.uploading\", { default: \"Uploading…\" })}\n </>\n ) : (\n <>\n <Upload className=\"mr-1 size-4\" />\n {props.multi\n ? tr(\"controlUpload.chooseFiles\", { default: \"Choose files\" })\n : tr(\"controlUpload.chooseFile\", { default: \"Choose a file\" })}\n </>\n )}\n </TooltipTrigger>\n <TooltipContent>{dragDropHint}</TooltipContent>\n </Tooltip>\n );\n\n return (\n <FormField\n id={inputId}\n label={fieldMeta.label}\n description={fieldMeta.description}\n error={fieldMeta.error}\n required={fieldMeta.required}\n >\n <input\n ref={fileInputRef}\n type=\"file\"\n id={inputId}\n name={props.input.props.name}\n className=\"hidden\"\n accept={props.accept}\n multiple={props.multi}\n disabled={props.disabled}\n onChange={handleInputChange}\n />\n\n <div className=\"flex flex-col gap-2\">\n {ids.length > 0 && (\n <div className=\"flex flex-col gap-2\">{ids.map(renderItem)}</div>\n )}\n {(props.multi || ids.length === 0) && dropZone}\n {uploading && (\n <div className=\"bg-muted h-1 w-full overflow-hidden rounded\">\n <div\n className=\"bg-primary h-full transition-all\"\n style={{ width: `${progress}%` }}\n />\n </div>\n )}\n </div>\n\n <Dialog\n open={previewId !== null}\n onOpenChange={(o) => !o && setPreviewId(null)}\n >\n <DialogContent className=\"w-fit max-w-fit p-0\">\n <DialogHeader className=\"sr-only\">\n <DialogTitle>\n {previewHasName\n ? previewItem?.name\n : tr(\"controlUpload.savedFile\", { default: \"Saved file\" })}\n </DialogTitle>\n <DialogDescription>\n {previewItem?.mimeType ?? \"uploaded\"}\n </DialogDescription>\n </DialogHeader>\n <div className=\"p-4\">\n {previewIsImage && previewItem?.previewUrl ? (\n <img\n src={previewItem.previewUrl}\n alt={previewItem.name ?? \"\"}\n className=\"size-72 rounded object-contain\"\n />\n ) : (\n <div className=\"bg-muted text-muted-foreground flex size-72 items-center justify-center rounded\">\n <FileIcon className=\"size-16\" />\n </div>\n )}\n </div>\n {(previewHasName || previewItem?.mimeType) && (\n <div className=\"bg-muted/30 flex flex-col gap-0 border-t px-4 py-2\">\n {previewHasName && (\n <span className=\"truncate text-sm font-medium\">\n {previewItem?.name}\n </span>\n )}\n {previewItem?.mimeType && (\n <span className=\"text-muted-foreground truncate text-xs\">\n {previewItem.mimeType}\n </span>\n )}\n </div>\n )}\n </DialogContent>\n </Dialog>\n </FormField>\n );\n};\n\ninterface UploadedFileMeta {\n id: string;\n name: string;\n mimeType?: string;\n size?: number;\n /**\n * Object URL for image preview, when applicable.\n */\n previewUrl?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqGA,MAAa,iBAAiB,UAA8B;CAC1D,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,OAAO,CAAC;CAChD,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CACnD,MAAM,SAAS,UAA0B;CACzC,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,QAAQ,SAAS;CACvB,MAAM,UAAU,MAAM;CACtB,MAAM,eAAe,OAAyB,IAAI;CAClD,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,UAAU,eAAe,SAAS,CAAC;CAC1C,MAAM,CAAC,MAAM,WAAW,yBAAwC,IAAI,IAAI,CAAC;CACzE,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,CAAC,WAAW,gBAAgB,SAAwB,IAAI;;;;;;;;CAS9D,gBAAgB;EACd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U,UAAW,CAAA;OAC5B,CAAA;MAEJ,CAAA;OACH,kBAAkB,aAAa,aAC/B,qBAAC,OAAD;OAAK,WAAU;OAAf,UAAA,CACG,kBACC,oBAAC,QAAD;QAAM,WAAU;QACb,UAAA,aAAa;OACV,CAAA,GAEP,aAAa,YACZ,oBAAC,QAAD;QAAM,WAAU;QACb,UAAA,YAAY;OACT,CAAA,CAEL;;KAEM;;GACT,CAAA;EACC;;AAEf"}
@@ -1 +1 @@
1
- {"version":3,"file":"uiFr.d.ts","sourceRoot":"","sources":["../../../src/i18n/fr/uiFr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA8rCvC,CAAC"}
1
+ {"version":3,"file":"uiFr.d.ts","sourceRoot":"","sources":["../../../src/i18n/fr/uiFr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAutCvC,CAAC"}