@alepha/ui 0.39.0 → 0.41.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 (761) hide show
  1. package/README.md +4 -2
  2. package/dist/account/AccountConnections.js +1 -1
  3. package/dist/account/AccountConnectionsView.js +4 -4
  4. package/dist/account/AccountDeleteDialog.d.ts.map +1 -1
  5. package/dist/account/AccountDeleteDialog.js +5 -4
  6. package/dist/account/AccountDeleteDialog.js.map +1 -1
  7. package/dist/account/AccountDialog.js +4 -4
  8. package/dist/account/AccountDisplay.js +4 -4
  9. package/dist/account/AccountKeys.js +1 -1
  10. package/dist/account/AccountKeysView.js +5 -5
  11. package/dist/account/AccountMfaDialog.js +4 -4
  12. package/dist/account/AccountPasskeyProofDialog.js +2 -2
  13. package/dist/account/AccountPasskeyRow.js +3 -3
  14. package/dist/account/AccountPasskeys.js +4 -4
  15. package/dist/account/AccountPasswordDialog.js +4 -4
  16. package/dist/account/AccountPasswordDialog.js.map +1 -1
  17. package/dist/account/AccountPasswordGuard.js +2 -2
  18. package/dist/account/AccountProfile.js +1 -1
  19. package/dist/account/AccountProfileView.d.ts.map +1 -1
  20. package/dist/account/AccountProfileView.js +8 -7
  21. package/dist/account/AccountProfileView.js.map +1 -1
  22. package/dist/account/AccountRecoveryCodes.js +2 -2
  23. package/dist/account/AccountRecoveryCodesDialog.js +1 -1
  24. package/dist/account/AccountSecurity.js +1 -1
  25. package/dist/account/AccountSecurityView.js +5 -5
  26. package/dist/account/AccountSessions.js +1 -1
  27. package/dist/account/AccountSessionsView.js +4 -4
  28. package/dist/account/ApiKeyCreateDialog.js +7 -6
  29. package/dist/account/ApiKeyCreateDialog.js.map +1 -1
  30. package/dist/account/ApiKeyScopeMatrix.js +2 -2
  31. package/dist/account/ApiKeyStatusBadge.js +1 -1
  32. package/dist/admin/$pageAdmin.js +1 -1
  33. package/dist/admin/AdminAi.d.ts +12 -0
  34. package/dist/admin/AdminAi.d.ts.map +1 -0
  35. package/dist/admin/AdminAi.js +173 -0
  36. package/dist/admin/AdminAi.js.map +1 -0
  37. package/dist/admin/AdminAiDailyChart.d.ts +16 -0
  38. package/dist/admin/AdminAiDailyChart.d.ts.map +1 -0
  39. package/dist/admin/AdminAiDailyChart.js +87 -0
  40. package/dist/admin/AdminAiDailyChart.js.map +1 -0
  41. package/dist/admin/AdminAiUsageTable.d.ts +33 -0
  42. package/dist/admin/AdminAiUsageTable.d.ts.map +1 -0
  43. package/dist/admin/AdminAiUsageTable.js +77 -0
  44. package/dist/admin/AdminAiUsageTable.js.map +1 -0
  45. package/dist/admin/AdminAnalytics.js +3 -3
  46. package/dist/admin/AdminAudits.js +7 -7
  47. package/dist/admin/AdminBrand.js +2 -2
  48. package/dist/admin/AdminConnectedTile.js +1 -1
  49. package/dist/admin/AdminDashboard.js +3 -3
  50. package/dist/admin/AdminFailedAuditsTile.js +3 -3
  51. package/dist/admin/AdminFiles.d.ts.map +1 -1
  52. package/dist/admin/AdminFiles.js +8 -8
  53. package/dist/admin/AdminFiles.js.map +1 -1
  54. package/dist/admin/AdminFilesUsage.js +2 -2
  55. package/dist/admin/AdminFilesUsageCard.js +2 -2
  56. package/dist/admin/AdminJobDetail.js +7 -7
  57. package/dist/admin/AdminJobDetailAside.js +3 -3
  58. package/dist/admin/AdminJobDetailExecutions.js +6 -6
  59. package/dist/admin/AdminJobExecutionLogs.js +1 -1
  60. package/dist/admin/AdminJobExecutionSheet.d.ts.map +1 -1
  61. package/dist/admin/AdminJobExecutionSheet.js +12 -5
  62. package/dist/admin/AdminJobExecutionSheet.js.map +1 -1
  63. package/dist/admin/AdminJobExecutionSteps.js +1 -1
  64. package/dist/admin/AdminJobs.js +7 -7
  65. package/dist/admin/AdminJobsTypeIcon.js +1 -1
  66. package/dist/admin/AdminKeys.js +6 -6
  67. package/dist/admin/AdminKeysTokenDialog.js +4 -4
  68. package/dist/admin/AdminLayout.js +5 -5
  69. package/dist/admin/AdminNotifications.js +6 -6
  70. package/dist/admin/AdminNotificationsDetail.js +2 -2
  71. package/dist/admin/AdminNotificationsDetailTabs.js +3 -3
  72. package/dist/admin/AdminNotificationsPreviewBody.js +1 -1
  73. package/dist/admin/AdminNotificationsPreviewTab.js +1 -1
  74. package/dist/admin/AdminParameters.d.ts.map +1 -1
  75. package/dist/admin/AdminParameters.js +10 -8
  76. package/dist/admin/AdminParameters.js.map +1 -1
  77. package/dist/admin/AdminParametersEditorForm.d.ts +5 -0
  78. package/dist/admin/AdminParametersEditorForm.d.ts.map +1 -1
  79. package/dist/admin/AdminParametersEditorForm.js +8 -6
  80. package/dist/admin/AdminParametersEditorForm.js.map +1 -1
  81. package/dist/admin/AdminParametersEditorPane.d.ts +5 -0
  82. package/dist/admin/AdminParametersEditorPane.d.ts.map +1 -1
  83. package/dist/admin/AdminParametersEditorPane.js +7 -6
  84. package/dist/admin/AdminParametersEditorPane.js.map +1 -1
  85. package/dist/admin/AdminParametersHistoryPane.js +5 -5
  86. package/dist/admin/AdminParametersTreeFooterActions.js +3 -3
  87. package/dist/admin/AdminParametersTreeNodeView.js +5 -5
  88. package/dist/admin/AdminParametersTreeNodeView.js.map +1 -1
  89. package/dist/admin/AdminParametersTreePane.js +4 -4
  90. package/dist/admin/AdminPayments.js +4 -4
  91. package/dist/admin/AdminRouter.d.ts +12 -5
  92. package/dist/admin/AdminRouter.d.ts.map +1 -1
  93. package/dist/admin/AdminRouter.js +39 -10
  94. package/dist/admin/AdminRouter.js.map +1 -1
  95. package/dist/admin/AdminRouterOptions.js +1 -1
  96. package/dist/admin/AdminSessions.js +6 -6
  97. package/dist/admin/AdminStatTile.js +6 -6
  98. package/dist/admin/AdminStatTile.js.map +1 -1
  99. package/dist/admin/AdminStatTileDeltaChip.js +1 -1
  100. package/dist/admin/AdminUserAvatarControl.js +5 -5
  101. package/dist/admin/AdminUserCell.js +3 -3
  102. package/dist/admin/AdminUserDetail.js +10 -10
  103. package/dist/admin/AdminUserDetailAuditsTab.js +3 -3
  104. package/dist/admin/AdminUserDetailIdentityAside.js +4 -4
  105. package/dist/admin/AdminUserDetailOverviewTab.js +3 -3
  106. package/dist/admin/AdminUserDetailPasskeys.js +3 -3
  107. package/dist/admin/AdminUserDetailPasswordDialog.js +4 -4
  108. package/dist/admin/AdminUserDetailSecurityTab.js +4 -4
  109. package/dist/admin/AdminUserDetailSessionsTab.js +3 -3
  110. package/dist/admin/AdminUsers.js +10 -10
  111. package/dist/admin/AdminUsers.js.map +1 -1
  112. package/dist/admin/AdminUsersCreateDialog.js +5 -5
  113. package/dist/admin/AdminUsersRolesPicker.js +2 -2
  114. package/dist/admin/AdminUsersStatusBadge.js +1 -1
  115. package/dist/admin/AdminUsersTile.js +2 -2
  116. package/dist/admin/AdminWebhookDeliveries.js +6 -6
  117. package/dist/admin/AdminWebhookDeliveryDialog.js +5 -5
  118. package/dist/admin/AdminWebhookDetail.js +6 -6
  119. package/dist/admin/AdminWebhookDetailAside.js +3 -3
  120. package/dist/admin/AdminWebhookDetailOverview.js +6 -6
  121. package/dist/admin/AdminWebhooks.js +7 -7
  122. package/dist/admin/AdminWebhooksCreateDialog.js +6 -6
  123. package/dist/admin/AdminWebhooksSecretDialog.js +4 -4
  124. package/dist/admin/AdminWebhooksStatusBadge.js +3 -3
  125. package/dist/admin/ParameterDiffDialog.js +3 -3
  126. package/dist/admin/ParameterHistoryItem.js +5 -5
  127. package/dist/admin/ParameterJsonDialog.js +4 -4
  128. package/dist/admin/ParameterSaveDialog.js +5 -5
  129. package/dist/admin/adminAiMoney.d.ts +10 -0
  130. package/dist/admin/adminAiMoney.d.ts.map +1 -0
  131. package/dist/admin/adminAiMoney.js +21 -0
  132. package/dist/admin/adminAiMoney.js.map +1 -0
  133. package/dist/admin/adminParametersTree.d.ts +23 -2
  134. package/dist/admin/adminParametersTree.d.ts.map +1 -1
  135. package/dist/admin/adminParametersTree.js +36 -3
  136. package/dist/admin/adminParametersTree.js.map +1 -1
  137. package/dist/admin/analytics/AdvancedSection.js +3 -3
  138. package/dist/admin/analytics/AnalyticsChartBars.js +1 -1
  139. package/dist/admin/analytics/AnalyticsChartDonut.js +1 -1
  140. package/dist/admin/analytics/AnalyticsChartHeader.js +1 -1
  141. package/dist/admin/analytics/CoarsenedBadge.js +1 -1
  142. package/dist/admin/analytics/CompareNote.js +1 -1
  143. package/dist/admin/analytics/DatasetSelect.js +4 -4
  144. package/dist/admin/analytics/FilterEditor.js +3 -3
  145. package/dist/admin/analytics/FilterValuePicker.js +3 -3
  146. package/dist/admin/analytics/GroupByChips.js +1 -1
  147. package/dist/admin/analytics/MeasureChips.js +1 -1
  148. package/dist/admin/analytics/QueryPanel.js +1 -1
  149. package/dist/admin/analytics/RangeControl.js +3 -3
  150. package/dist/admin/analytics/RequestDialog.js +3 -3
  151. package/dist/admin/analytics/RequestDialog.js.map +1 -1
  152. package/dist/admin/analytics/ResultsPane.js +3 -3
  153. package/dist/admin/analytics/ResultsTable.d.ts.map +1 -1
  154. package/dist/admin/analytics/ResultsTable.js +3 -3
  155. package/dist/admin/analytics/ResultsTable.js.map +1 -1
  156. package/dist/admin/analytics/RunFooter.js +2 -2
  157. package/dist/admin/analytics/SamplingBadge.js +1 -1
  158. package/dist/admin/analytics/ToggleChip.js +1 -1
  159. package/dist/admin/analytics/TotalsCards.js +1 -1
  160. package/dist/admin/analytics/TruncationBanner.js +2 -2
  161. package/dist/admin/analytics/analyticsModel.d.ts +3 -1
  162. package/dist/admin/analytics/analyticsModel.d.ts.map +1 -1
  163. package/dist/admin/analytics/analyticsModel.js +13 -5
  164. package/dist/admin/analytics/analyticsModel.js.map +1 -1
  165. package/dist/admin/analytics/analyticsTypes.d.ts +1 -1
  166. package/dist/admin/analytics/analyticsTypes.d.ts.map +1 -1
  167. package/dist/admin/analytics/chartModel.d.ts.map +1 -1
  168. package/dist/admin/analytics/chartModel.js +2 -2
  169. package/dist/admin/analytics/chartModel.js.map +1 -1
  170. package/dist/admin/analytics/useAnalyticsQuery.js +2 -2
  171. package/dist/admin/analytics/useFilterValues.js +1 -1
  172. package/dist/admin/useAdminDetailTrail.js +2 -2
  173. package/dist/admin/useConfirmedAction.js +2 -2
  174. package/dist/ai/AiChat.d.ts +37 -5
  175. package/dist/ai/AiChat.d.ts.map +1 -1
  176. package/dist/ai/AiChat.js +107 -18
  177. package/dist/ai/AiChat.js.map +1 -1
  178. package/dist/ai/AiChatComposer.d.ts +9 -0
  179. package/dist/ai/AiChatComposer.d.ts.map +1 -1
  180. package/dist/ai/AiChatComposer.js +9 -4
  181. package/dist/ai/AiChatComposer.js.map +1 -1
  182. package/dist/ai/AiChatConfirmCard.d.ts +2 -2
  183. package/dist/ai/AiChatConfirmCard.d.ts.map +1 -1
  184. package/dist/ai/AiChatConfirmCard.js +20 -6
  185. package/dist/ai/AiChatConfirmCard.js.map +1 -1
  186. package/dist/ai/AiChatDock.js +3 -3
  187. package/dist/ai/AiChatEmpty.d.ts +5 -0
  188. package/dist/ai/AiChatEmpty.d.ts.map +1 -1
  189. package/dist/ai/AiChatEmpty.js +26 -30
  190. package/dist/ai/AiChatEmpty.js.map +1 -1
  191. package/dist/ai/AiChatFloat.d.ts +43 -0
  192. package/dist/ai/AiChatFloat.d.ts.map +1 -0
  193. package/dist/ai/AiChatFloat.js +66 -0
  194. package/dist/ai/AiChatFloat.js.map +1 -0
  195. package/dist/ai/AiChatHeaderButton.d.ts +14 -0
  196. package/dist/ai/AiChatHeaderButton.d.ts.map +1 -0
  197. package/dist/ai/AiChatHeaderButton.js +21 -0
  198. package/dist/ai/AiChatHeaderButton.js.map +1 -0
  199. package/dist/ai/AiChatHistory.d.ts.map +1 -1
  200. package/dist/ai/AiChatHistory.js +8 -6
  201. package/dist/ai/AiChatHistory.js.map +1 -1
  202. package/dist/ai/AiChatLauncher.d.ts +5 -0
  203. package/dist/ai/AiChatLauncher.d.ts.map +1 -1
  204. package/dist/ai/AiChatLauncher.js +3 -3
  205. package/dist/ai/AiChatLauncher.js.map +1 -1
  206. package/dist/ai/AiChatMessage.d.ts +6 -0
  207. package/dist/ai/AiChatMessage.d.ts.map +1 -1
  208. package/dist/ai/AiChatMessage.js +5 -5
  209. package/dist/ai/AiChatMessage.js.map +1 -1
  210. package/dist/ai/AiChatPanel.d.ts +65 -5
  211. package/dist/ai/AiChatPanel.d.ts.map +1 -1
  212. package/dist/ai/AiChatPanel.js +87 -41
  213. package/dist/ai/AiChatPanel.js.map +1 -1
  214. package/dist/ai/AiChatToolStepDetails.d.ts +14 -0
  215. package/dist/ai/AiChatToolStepDetails.d.ts.map +1 -0
  216. package/dist/ai/AiChatToolStepDetails.js +34 -0
  217. package/dist/ai/AiChatToolStepDetails.js.map +1 -0
  218. package/dist/ai/AiChatToolTrace.d.ts +63 -0
  219. package/dist/ai/AiChatToolTrace.d.ts.map +1 -0
  220. package/dist/ai/AiChatToolTrace.js +118 -0
  221. package/dist/ai/AiChatToolTrace.js.map +1 -0
  222. package/dist/ai/aiChatMotion.d.ts +24 -0
  223. package/dist/ai/aiChatMotion.d.ts.map +1 -0
  224. package/dist/ai/aiChatMotion.js +67 -0
  225. package/dist/ai/aiChatMotion.js.map +1 -0
  226. package/dist/ai/index.d.ts +6 -2
  227. package/dist/ai/index.d.ts.map +1 -1
  228. package/dist/ai/index.js +5 -1
  229. package/dist/ai/useAiChat.d.ts +11 -0
  230. package/dist/ai/useAiChat.d.ts.map +1 -1
  231. package/dist/ai/useAiChat.js +6 -4
  232. package/dist/ai/useAiChat.js.map +1 -1
  233. package/dist/ai/useAiChatFloatDrag.d.ts +23 -0
  234. package/dist/ai/useAiChatFloatDrag.d.ts.map +1 -0
  235. package/dist/ai/useAiChatFloatDrag.js +87 -0
  236. package/dist/ai/useAiChatFloatDrag.js.map +1 -0
  237. package/dist/ai/useAiContext.js +2 -2
  238. package/dist/auth/AuthLogin.d.ts.map +1 -1
  239. package/dist/auth/AuthLogin.js +18 -10
  240. package/dist/auth/AuthLogin.js.map +1 -1
  241. package/dist/auth/AuthLoginSlots.d.ts +53 -0
  242. package/dist/auth/AuthLoginSlots.d.ts.map +1 -0
  243. package/dist/auth/AuthLoginSlots.js +39 -0
  244. package/dist/auth/AuthLoginSlots.js.map +1 -0
  245. package/dist/auth/AuthMfaStep.js +7 -7
  246. package/dist/auth/AuthPasskeyAutofill.js +1 -1
  247. package/dist/auth/AuthRegister.js +9 -9
  248. package/dist/auth/AuthRegisterFormPhase.js +4 -4
  249. package/dist/auth/AuthRegisterPasswordRules.js +2 -2
  250. package/dist/auth/AuthResetPassword.js +10 -10
  251. package/dist/auth/AuthRouter.js +2 -2
  252. package/dist/auth/AuthVerifyEmail.js +2 -2
  253. package/dist/auth/AuthVerifyEmailStateful.js +3 -3
  254. package/dist/auth/AuthVerifyEmailView.js +4 -4
  255. package/dist/auth/TurnstileWidget.js +1 -1
  256. package/dist/auth/index.d.ts +1 -0
  257. package/dist/auth/index.d.ts.map +1 -1
  258. package/dist/auth/index.js +2 -1
  259. package/dist/auth/usePasskey.js +1 -1
  260. package/dist/calendar/Calendar.js +4 -4
  261. package/dist/chart/Chart.js +2 -2
  262. package/dist/command/Command.js +4 -4
  263. package/dist/core/Alert.js +2 -2
  264. package/dist/core/AlertDialog.js +2 -2
  265. package/dist/core/Avatar.js +2 -2
  266. package/dist/core/Badge.js +2 -2
  267. package/dist/core/BrandIcon.js +1 -1
  268. package/dist/core/Breadcrumb.js +3 -3
  269. package/dist/core/Button.d.ts.map +1 -1
  270. package/dist/core/Button.js +22 -6
  271. package/dist/core/Button.js.map +1 -1
  272. package/dist/core/ButtonGroup.js +2 -2
  273. package/dist/core/Card.js +1 -1
  274. package/dist/core/Checkbox.js +2 -2
  275. package/dist/core/Collapsible.js +2 -2
  276. package/dist/core/Combobox.d.ts.map +1 -1
  277. package/dist/core/Combobox.js +4 -4
  278. package/dist/core/Combobox.js.map +1 -1
  279. package/dist/core/ContextMenu.js +2 -2
  280. package/dist/core/Dialog.d.ts.map +1 -1
  281. package/dist/core/Dialog.js +4 -4
  282. package/dist/core/Dialog.js.map +1 -1
  283. package/dist/core/DirectionProvider.js +1 -1
  284. package/dist/core/Drawer.js +3 -3
  285. package/dist/core/DropdownMenu.js +2 -2
  286. package/dist/core/Empty.js +1 -1
  287. package/dist/core/HoverCard.js +1 -1
  288. package/dist/core/Input.js +2 -2
  289. package/dist/core/InputGroup.js +2 -2
  290. package/dist/core/Label.js +1 -1
  291. package/dist/core/Menubar.js +4 -4
  292. package/dist/core/PageOutline.d.ts +9 -1
  293. package/dist/core/PageOutline.d.ts.map +1 -1
  294. package/dist/core/PageOutline.js +25 -6
  295. package/dist/core/PageOutline.js.map +1 -1
  296. package/dist/core/Pagination.js +2 -2
  297. package/dist/core/PaneRail.js +1 -1
  298. package/dist/core/Popover.js +2 -2
  299. package/dist/core/Progress.js +1 -1
  300. package/dist/core/Segmented.d.ts +11 -1
  301. package/dist/core/Segmented.d.ts.map +1 -1
  302. package/dist/core/Segmented.js +8 -5
  303. package/dist/core/Segmented.js.map +1 -1
  304. package/dist/core/Separator.js +1 -1
  305. package/dist/core/Sheet.js +3 -3
  306. package/dist/core/Sidebar.js +7 -7
  307. package/dist/core/Slider.js +3 -3
  308. package/dist/core/Spinner.js +1 -1
  309. package/dist/core/Stepper.js +1 -1
  310. package/dist/core/Switch.js +1 -1
  311. package/dist/core/Table.js +1 -1
  312. package/dist/core/Textarea.js +1 -1
  313. package/dist/core/TimeAgo.d.ts +12 -5
  314. package/dist/core/TimeAgo.d.ts.map +1 -1
  315. package/dist/core/TimeAgo.js +18 -7
  316. package/dist/core/TimeAgo.js.map +1 -1
  317. package/dist/core/Toaster.js +2 -2
  318. package/dist/core/Tooltip.js +1 -1
  319. package/dist/core/UserAvatar.js +3 -3
  320. package/dist/core/index.d.ts +0 -1
  321. package/dist/core/index.d.ts.map +1 -1
  322. package/dist/core/index.js +1 -2
  323. package/dist/core/useDialog.js +5 -5
  324. package/dist/core/useUndoable.js +1 -1
  325. package/dist/form/AutoForm.js +6 -6
  326. package/dist/form/AutoFormBottomBar.js +4 -4
  327. package/dist/form/AutoFormErrorPopover.js +4 -4
  328. package/dist/form/AutoFormGroupBlock.js +3 -3
  329. package/dist/form/AutoFormGroupGridField.js +2 -2
  330. package/dist/form/Control.d.ts +4 -0
  331. package/dist/form/Control.d.ts.map +1 -1
  332. package/dist/form/Control.js +9 -8
  333. package/dist/form/Control.js.map +1 -1
  334. package/dist/form/ControlArray.js +7 -7
  335. package/dist/form/ControlDate.js +6 -6
  336. package/dist/form/ControlDatePopover.js +4 -4
  337. package/dist/form/ControlDateRange.js +5 -5
  338. package/dist/form/ControlMonthPopover.js +4 -4
  339. package/dist/form/ControlNumber.js +3 -3
  340. package/dist/form/ControlObject.js +7 -7
  341. package/dist/form/ControlPassword.js +3 -3
  342. package/dist/form/ControlSelect.d.ts +12 -0
  343. package/dist/form/ControlSelect.d.ts.map +1 -1
  344. package/dist/form/ControlSelect.js +13 -7
  345. package/dist/form/ControlSelect.js.map +1 -1
  346. package/dist/form/ControlSelectCombobox.js +4 -4
  347. package/dist/form/ControlUpload.d.ts.map +1 -1
  348. package/dist/form/ControlUpload.js +11 -10
  349. package/dist/form/ControlUpload.js.map +1 -1
  350. package/dist/form/ControlUploadItemThumb.js +1 -1
  351. package/dist/form/FormField.js +2 -2
  352. package/dist/form/FormFieldDescriptionTip.js +1 -1
  353. package/dist/form/fieldTrigger.js +3 -3
  354. package/dist/form/iconHint.js +1 -1
  355. package/dist/form/useFieldErrorText.js +1 -1
  356. package/dist/i18n/en/index.d.ts +22 -0
  357. package/dist/i18n/en/index.d.ts.map +1 -0
  358. package/dist/i18n/en/index.js +1 -0
  359. package/dist/i18n/en/uiEn.d.ts +37 -0
  360. package/dist/i18n/en/uiEn.d.ts.map +1 -0
  361. package/dist/i18n/en/uiEn.js +1497 -0
  362. package/dist/i18n/en/uiEn.js.map +1 -0
  363. package/dist/i18n/fr/uiFr.d.ts +3 -2
  364. package/dist/i18n/fr/uiFr.d.ts.map +1 -1
  365. package/dist/i18n/fr/uiFr.js +38 -4
  366. package/dist/i18n/fr/uiFr.js.map +1 -1
  367. package/dist/markdown/MarkdownView.d.ts +23 -0
  368. package/dist/markdown/MarkdownView.d.ts.map +1 -1
  369. package/dist/markdown/MarkdownView.js +29 -10
  370. package/dist/markdown/MarkdownView.js.map +1 -1
  371. package/dist/markdown/diagram/DiagramLabel.js +1 -1
  372. package/dist/markdown/diagram/FlowchartDiagram.js +2 -2
  373. package/dist/markdown/diagram/FlowchartDiagramCluster.js +2 -2
  374. package/dist/markdown/diagram/FlowchartDiagramEdge.js +1 -1
  375. package/dist/markdown/diagram/FlowchartDiagramNode.js +1 -1
  376. package/dist/markdown/diagram/MermaidFence.js +2 -2
  377. package/dist/markdown/diagram/SequenceDiagram.js +2 -2
  378. package/dist/markdown/diagram/SequenceDiagramFragment.js +2 -2
  379. package/dist/markdown/diagram/SequenceDiagramMessage.js +1 -1
  380. package/dist/markdown/diagram/SequenceDiagramNote.js +1 -1
  381. package/dist/markdown/diagram/SequenceDiagramParticipant.js +2 -2
  382. package/dist/markdown/diagram/SequenceDiagramParticipantActor.js +2 -2
  383. package/dist/markdown/diagram/layoutFlowchart.js +1 -1
  384. package/dist/markdown/highlightLines.d.ts +27 -0
  385. package/dist/markdown/highlightLines.d.ts.map +1 -0
  386. package/dist/markdown/highlightLines.js +91 -0
  387. package/dist/markdown/highlightLines.js.map +1 -0
  388. package/dist/markdown/index.d.ts +5 -2
  389. package/dist/markdown/index.d.ts.map +1 -1
  390. package/dist/markdown/index.js +2 -1
  391. package/dist/organizations/MyOrganizationInvitations.d.ts.map +1 -1
  392. package/dist/organizations/MyOrganizationInvitations.js +13 -5
  393. package/dist/organizations/MyOrganizationInvitations.js.map +1 -1
  394. package/dist/organizations/MyOrganizations.d.ts.map +1 -1
  395. package/dist/organizations/MyOrganizations.js +15 -5
  396. package/dist/organizations/MyOrganizations.js.map +1 -1
  397. package/dist/organizations/OrganizationInviteDialog.js +6 -6
  398. package/dist/organizations/OrganizationInviteDialog.js.map +1 -1
  399. package/dist/organizations/OrganizationMemberRankPicker.js +5 -5
  400. package/dist/organizations/OrganizationMembers.d.ts.map +1 -1
  401. package/dist/organizations/OrganizationMembers.js +12 -6
  402. package/dist/organizations/OrganizationMembers.js.map +1 -1
  403. package/dist/organizations/OrganizationPendingInvitations.d.ts.map +1 -1
  404. package/dist/organizations/OrganizationPendingInvitations.js +9 -4
  405. package/dist/organizations/OrganizationPendingInvitations.js.map +1 -1
  406. package/dist/organizations/OrganizationRankColumnHeader.js +2 -2
  407. package/dist/organizations/OrganizationRanks.d.ts.map +1 -1
  408. package/dist/organizations/OrganizationRanks.js +7 -5
  409. package/dist/organizations/OrganizationRanks.js.map +1 -1
  410. package/dist/organizations/OrganizationTransferOwnershipDialog.js +5 -5
  411. package/dist/organizations/OrganizationTransferOwnershipDialog.js.map +1 -1
  412. package/dist/organizations/useInviteOrganizationMember.js +1 -1
  413. package/dist/organizations/useRevokeOrganizationInvitation.js +2 -2
  414. package/dist/otp/InputOTP.js +2 -2
  415. package/dist/resizable/Resizable.js +1 -1
  416. package/dist/settings/$settingsDialog.js +1 -1
  417. package/dist/settings/$settingsSection.js +1 -1
  418. package/dist/settings/SettingsDangerSection.js +1 -1
  419. package/dist/settings/SettingsDialog.js +6 -6
  420. package/dist/settings/SettingsDialogHost.js +3 -3
  421. package/dist/settings/SettingsDialogs.js +2 -2
  422. package/dist/settings/useSettingsDialog.js +2 -2
  423. package/dist/shell/ActionErrorToaster.js +2 -2
  424. package/dist/shell/AppActions.js +1 -1
  425. package/dist/shell/AppShell.js +4 -4
  426. package/dist/shell/AppShellNavCollapse.js +1 -1
  427. package/dist/shell/AppShellNavDropdownItems.js +5 -5
  428. package/dist/shell/AppShellNavDropdownItems.js.map +1 -1
  429. package/dist/shell/AppShellSidebarNavItem.js +7 -7
  430. package/dist/shell/AppShellSidebarNavItem.js.map +1 -1
  431. package/dist/shell/AppShellStatefulSidebarTrigger.js +4 -4
  432. package/dist/shell/ButtonDark.js +3 -3
  433. package/dist/shell/ButtonInbox.d.ts +8 -0
  434. package/dist/shell/ButtonInbox.d.ts.map +1 -1
  435. package/dist/shell/ButtonInbox.js +8 -6
  436. package/dist/shell/ButtonInbox.js.map +1 -1
  437. package/dist/shell/ButtonLanguage.js +4 -4
  438. package/dist/shell/ButtonSettings.js +5 -5
  439. package/dist/shell/ButtonSettingsColorModeMenu.js +2 -2
  440. package/dist/shell/ButtonSettingsLanguageMenu.js +3 -3
  441. package/dist/shell/ButtonSettingsThemeMenu.js +4 -4
  442. package/dist/shell/ButtonSettingsVisionMenuItem.js +2 -2
  443. package/dist/shell/ButtonTheme.js +5 -5
  444. package/dist/shell/ButtonUser.js +1 -1
  445. package/dist/shell/ButtonUserAccountMenuItem.js +3 -3
  446. package/dist/shell/ButtonUserAdminMenuItem.js +4 -4
  447. package/dist/shell/ButtonUserAdminMenuItem.js.map +1 -1
  448. package/dist/shell/ButtonUserContent.js +5 -5
  449. package/dist/shell/ButtonUserDefaultMenu.js +2 -2
  450. package/dist/shell/ButtonUserLogoutMenuItem.js +2 -2
  451. package/dist/shell/ButtonVision.js +3 -3
  452. package/dist/shell/DetailAside.js +4 -4
  453. package/dist/shell/DetailLayout.d.ts +3 -1
  454. package/dist/shell/DetailLayout.d.ts.map +1 -1
  455. package/dist/shell/DetailLayout.js +29 -17
  456. package/dist/shell/DetailLayout.js.map +1 -1
  457. package/dist/shell/DetailLayoutTabMenu.d.ts +19 -0
  458. package/dist/shell/DetailLayoutTabMenu.d.ts.map +1 -0
  459. package/dist/shell/DetailLayoutTabMenu.js +65 -0
  460. package/dist/shell/DetailLayoutTabMenu.js.map +1 -0
  461. package/dist/shell/NavShell.js +2 -2
  462. package/dist/shell/PlateFolderTabs.js +1 -1
  463. package/dist/shell/PlateLayout.d.ts.map +1 -1
  464. package/dist/shell/PlateLayout.js +2 -2
  465. package/dist/shell/PlateLayout.js.map +1 -1
  466. package/dist/shell/PlateTabBar.js +1 -1
  467. package/dist/shell/SidebarBackHeader.js +3 -3
  468. package/dist/shell/SidebarBackHeader.js.map +1 -1
  469. package/dist/shell/SidebarNavAutoClose.js +1 -1
  470. package/dist/shell/Spotlight.js +3 -3
  471. package/dist/shell/useDetailTab.js +1 -1
  472. package/dist/shell/useNavBreadcrumbs.js +3 -3
  473. package/dist/shell/useNavCrumbs.js +1 -1
  474. package/dist/shell/useNavEntries.js +3 -3
  475. package/dist/shell/useNavTree.js +1 -1
  476. package/dist/sortable/index.d.ts +17 -0
  477. package/dist/sortable/index.d.ts.map +1 -0
  478. package/dist/sortable/index.js +4 -0
  479. package/dist/sortable/useSortableItem.d.ts +32 -0
  480. package/dist/sortable/useSortableItem.d.ts.map +1 -0
  481. package/dist/sortable/useSortableItem.js +35 -0
  482. package/dist/sortable/useSortableItem.js.map +1 -0
  483. package/dist/sortable/useSortableList.d.ts +85 -0
  484. package/dist/sortable/useSortableList.d.ts.map +1 -0
  485. package/dist/sortable/useSortableList.js +125 -0
  486. package/dist/sortable/useSortableList.js.map +1 -0
  487. package/dist/styles.css +43 -0
  488. package/dist/swagger/SwaggerAccessBadge.js +1 -1
  489. package/dist/swagger/SwaggerAlephaMeta.js +1 -1
  490. package/dist/swagger/SwaggerCredentials.js +3 -3
  491. package/dist/swagger/SwaggerExplorer.js +5 -5
  492. package/dist/swagger/SwaggerNav.js +2 -2
  493. package/dist/swagger/SwaggerOperationView.js +2 -2
  494. package/dist/swagger/SwaggerResponseView.js +2 -2
  495. package/dist/swagger/SwaggerResponses.js +1 -1
  496. package/dist/swagger/SwaggerSchemaView.js +1 -1
  497. package/dist/swagger/SwaggerTryIt.js +2 -2
  498. package/dist/swagger/SwaggerTryItForm.js +3 -3
  499. package/dist/swagger/useSwaggerAccess.js +2 -2
  500. package/dist/table/DataTable.d.ts.map +1 -1
  501. package/dist/table/DataTable.js +53 -15
  502. package/dist/table/DataTable.js.map +1 -1
  503. package/dist/table/DataTableBody.d.ts +10 -0
  504. package/dist/table/DataTableBody.d.ts.map +1 -1
  505. package/dist/table/DataTableBody.js +32 -10
  506. package/dist/table/DataTableBody.js.map +1 -1
  507. package/dist/table/DataTableBulkBar.d.ts.map +1 -1
  508. package/dist/table/DataTableBulkBar.js +5 -4
  509. package/dist/table/DataTableBulkBar.js.map +1 -1
  510. package/dist/table/DataTableBulkMenu.js +2 -2
  511. package/dist/table/DataTableColumnPicker.js +3 -3
  512. package/dist/table/DataTableCompactPager.js +2 -2
  513. package/dist/table/DataTableFilterAdd.js +2 -2
  514. package/dist/table/DataTableFilterBar.js +2 -2
  515. package/dist/table/DataTableFilterControl.js +2 -2
  516. package/dist/table/DataTableFilterDialog.js +3 -3
  517. package/dist/table/DataTableFilterMenu.js +2 -2
  518. package/dist/table/DataTableFooter.d.ts +5 -1
  519. package/dist/table/DataTableFooter.d.ts.map +1 -1
  520. package/dist/table/DataTableFooter.js +27 -23
  521. package/dist/table/DataTableFooter.js.map +1 -1
  522. package/dist/table/DataTableGroupRow.js +1 -1
  523. package/dist/table/DataTableHeaderFilter.js +3 -3
  524. package/dist/table/DataTableHeaderPopup.js +3 -3
  525. package/dist/table/DataTableHeaderPopupChevron.js +1 -1
  526. package/dist/table/DataTableHeaderPopupFilter.js +1 -1
  527. package/dist/table/DataTableHeaderPopupList.js +1 -1
  528. package/dist/table/DataTableHeaderPopupRange.js +3 -3
  529. package/dist/table/DataTableHeaderRow.js +3 -3
  530. package/dist/table/DataTableHelpButton.js +2 -2
  531. package/dist/table/DataTableKeyHints.d.ts +11 -0
  532. package/dist/table/DataTableKeyHints.d.ts.map +1 -0
  533. package/dist/table/DataTableKeyHints.js +23 -0
  534. package/dist/table/DataTableKeyHints.js.map +1 -0
  535. package/dist/table/DataTablePresetRail.js +4 -4
  536. package/dist/table/DataTableRowActionGroupItem.d.ts +23 -0
  537. package/dist/table/DataTableRowActionGroupItem.d.ts.map +1 -0
  538. package/dist/table/DataTableRowActionGroupItem.js +38 -0
  539. package/dist/table/DataTableRowActionGroupItem.js.map +1 -0
  540. package/dist/table/DataTableRowActionItem.d.ts.map +1 -1
  541. package/dist/table/DataTableRowActionItem.js +15 -2
  542. package/dist/table/DataTableRowActionItem.js.map +1 -1
  543. package/dist/table/DataTableRowActionPrimary.d.ts +20 -0
  544. package/dist/table/DataTableRowActionPrimary.d.ts.map +1 -0
  545. package/dist/table/DataTableRowActionPrimary.js +42 -0
  546. package/dist/table/DataTableRowActionPrimary.js.map +1 -0
  547. package/dist/table/DataTableRowActionsInline.d.ts +3 -2
  548. package/dist/table/DataTableRowActionsInline.d.ts.map +1 -1
  549. package/dist/table/DataTableRowActionsInline.js +35 -23
  550. package/dist/table/DataTableRowActionsInline.js.map +1 -1
  551. package/dist/table/DataTableRowActionsMenu.d.ts +3 -2
  552. package/dist/table/DataTableRowActionsMenu.d.ts.map +1 -1
  553. package/dist/table/DataTableRowActionsMenu.js +14 -16
  554. package/dist/table/DataTableRowActionsMenu.js.map +1 -1
  555. package/dist/table/DataTableSortMenuButton.d.ts +15 -0
  556. package/dist/table/DataTableSortMenuButton.d.ts.map +1 -0
  557. package/dist/table/DataTableSortMenuButton.js +62 -0
  558. package/dist/table/DataTableSortMenuButton.js.map +1 -0
  559. package/dist/table/DataTableSummaryPanel.js +2 -2
  560. package/dist/table/DataTableToolbar.d.ts +4 -0
  561. package/dist/table/DataTableToolbar.d.ts.map +1 -1
  562. package/dist/table/DataTableToolbar.js +8 -2
  563. package/dist/table/DataTableToolbar.js.map +1 -1
  564. package/dist/table/PermissionMatrixGroupRows.js +1 -1
  565. package/dist/table/dataTableBaseProps.d.ts +93 -3
  566. package/dist/table/dataTableBaseProps.d.ts.map +1 -1
  567. package/dist/table/dataTableFilterFields.js +1 -1
  568. package/dist/table/dataTablePersistence.d.ts +53 -11
  569. package/dist/table/dataTablePersistence.d.ts.map +1 -1
  570. package/dist/table/dataTablePersistence.js +66 -29
  571. package/dist/table/dataTablePersistence.js.map +1 -1
  572. package/dist/table/dataTablePriority.d.ts +16 -0
  573. package/dist/table/dataTablePriority.d.ts.map +1 -0
  574. package/dist/table/dataTablePriority.js +31 -0
  575. package/dist/table/dataTablePriority.js.map +1 -0
  576. package/dist/table/dataTableTypes.d.ts +155 -3
  577. package/dist/table/dataTableTypes.d.ts.map +1 -1
  578. package/dist/table/index.d.ts +10 -2
  579. package/dist/table/index.d.ts.map +1 -1
  580. package/dist/table/index.js +3 -1
  581. package/dist/table/useDataTableColumns.d.ts.map +1 -1
  582. package/dist/table/useDataTableColumns.js +5 -5
  583. package/dist/table/useDataTableColumns.js.map +1 -1
  584. package/dist/table/useDataTableData.d.ts +1 -0
  585. package/dist/table/useDataTableData.d.ts.map +1 -1
  586. package/dist/table/useDataTableData.js +10 -9
  587. package/dist/table/useDataTableData.js.map +1 -1
  588. package/dist/table/useDataTableFilterForm.d.ts.map +1 -1
  589. package/dist/table/useDataTableFilterForm.js +9 -5
  590. package/dist/table/useDataTableFilterForm.js.map +1 -1
  591. package/dist/table/useDataTableFilterModel.d.ts +1 -0
  592. package/dist/table/useDataTableFilterModel.d.ts.map +1 -1
  593. package/dist/table/useDataTableFilterModel.js +4 -4
  594. package/dist/table/useDataTableFilterVisibility.d.ts +5 -0
  595. package/dist/table/useDataTableFilterVisibility.d.ts.map +1 -1
  596. package/dist/table/useDataTableFilterVisibility.js +17 -9
  597. package/dist/table/useDataTableFilterVisibility.js.map +1 -1
  598. package/dist/table/useDataTableKeyboard.d.ts +58 -0
  599. package/dist/table/useDataTableKeyboard.d.ts.map +1 -0
  600. package/dist/table/useDataTableKeyboard.js +157 -0
  601. package/dist/table/useDataTableKeyboard.js.map +1 -0
  602. package/dist/table/useDataTableRefresh.d.ts.map +1 -1
  603. package/dist/table/useDataTableRefresh.js +4 -3
  604. package/dist/table/useDataTableRefresh.js.map +1 -1
  605. package/dist/table/useDataTableSummary.d.ts +5 -0
  606. package/dist/table/useDataTableSummary.d.ts.map +1 -1
  607. package/dist/table/useDataTableSummary.js +7 -7
  608. package/dist/table/useDataTableSummary.js.map +1 -1
  609. package/dist/table/useDataTableWake.js +1 -1
  610. package/dist/table/useElementWidth.d.ts +10 -0
  611. package/dist/table/useElementWidth.d.ts.map +1 -0
  612. package/dist/table/useElementWidth.js +29 -0
  613. package/dist/table/useElementWidth.js.map +1 -0
  614. package/dist/tree/TreeView.js +1 -1
  615. package/dist/tree/TreeViewRow.d.ts.map +1 -1
  616. package/dist/tree/TreeViewRow.js +3 -3
  617. package/dist/tree/TreeViewRow.js.map +1 -1
  618. package/docs/packages-alepha-ui-ai.md +4 -3
  619. package/docs/packages-alepha-ui-i18n-en.md +35 -0
  620. package/docs/packages-alepha-ui-markdown.md +3 -1
  621. package/docs/packages-alepha-ui-overview.md +4 -2
  622. package/docs/packages-alepha-ui-sortable.md +34 -0
  623. package/docs/packages-alepha-ui-table.md +7 -1
  624. package/package.json +28 -10
  625. package/src/account/AccountDeleteDialog.tsx +2 -1
  626. package/src/account/AccountPasswordDialog.tsx +1 -1
  627. package/src/account/AccountProfileView.tsx +2 -1
  628. package/src/account/ApiKeyCreateDialog.tsx +1 -1
  629. package/src/account/__tests__/AccountProfile.browser.spec.tsx +21 -5
  630. package/src/admin/AdminAi.tsx +231 -0
  631. package/src/admin/AdminAiDailyChart.tsx +93 -0
  632. package/src/admin/AdminAiUsageTable.tsx +115 -0
  633. package/src/admin/AdminFiles.tsx +4 -6
  634. package/src/admin/AdminJobExecutionSheet.tsx +9 -0
  635. package/src/admin/AdminParameters.tsx +13 -2
  636. package/src/admin/AdminParametersEditorForm.tsx +9 -4
  637. package/src/admin/AdminParametersEditorPane.tsx +6 -0
  638. package/src/admin/AdminParametersTreeNodeView.tsx +1 -1
  639. package/src/admin/AdminRouter.tsx +31 -5
  640. package/src/admin/__tests__/AdminAiDailyChart.browser.spec.tsx +57 -0
  641. package/src/admin/__tests__/AdminRouter.spec.ts +5 -2
  642. package/src/admin/adminAiMoney.ts +20 -0
  643. package/src/admin/adminParametersTree.spec.ts +132 -0
  644. package/src/admin/adminParametersTree.ts +54 -2
  645. package/src/admin/analytics/RequestDialog.tsx +1 -1
  646. package/src/admin/analytics/ResultsTable.tsx +3 -1
  647. package/src/admin/analytics/analyticsModel.spec.ts +61 -2
  648. package/src/admin/analytics/analyticsModel.ts +29 -14
  649. package/src/admin/analytics/analyticsTypes.ts +1 -1
  650. package/src/admin/analytics/chartModel.ts +6 -2
  651. package/src/ai/AiChat.tsx +182 -20
  652. package/src/ai/AiChatComposer.tsx +26 -2
  653. package/src/ai/AiChatConfirmCard.tsx +22 -5
  654. package/src/ai/AiChatEmpty.tsx +24 -11
  655. package/src/ai/AiChatFloat.tsx +136 -0
  656. package/src/ai/AiChatHeaderButton.tsx +36 -0
  657. package/src/ai/AiChatHistory.tsx +22 -12
  658. package/src/ai/AiChatLauncher.tsx +6 -1
  659. package/src/ai/AiChatMessage.tsx +18 -3
  660. package/src/ai/AiChatPanel.tsx +236 -74
  661. package/src/ai/AiChatToolStepDetails.tsx +42 -0
  662. package/src/ai/AiChatToolTrace.tsx +213 -0
  663. package/src/ai/__tests__/AiChat.browser.spec.tsx +771 -4
  664. package/src/ai/aiChatMotion.ts +86 -0
  665. package/src/ai/index.ts +6 -2
  666. package/src/ai/useAiChat.ts +13 -0
  667. package/src/ai/useAiChatFloatDrag.ts +131 -0
  668. package/src/auth/AuthLogin.tsx +26 -1
  669. package/src/auth/AuthLoginSlots.ts +55 -0
  670. package/src/auth/__tests__/AuthLoginSlots.browser.spec.tsx +93 -0
  671. package/src/auth/index.ts +1 -0
  672. package/src/core/Button.tsx +26 -1
  673. package/src/core/Combobox.tsx +3 -1
  674. package/src/core/Dialog.tsx +13 -2
  675. package/src/core/PageOutline.tsx +28 -4
  676. package/src/core/Segmented.tsx +27 -5
  677. package/src/core/TimeAgo.browser.spec.tsx +49 -4
  678. package/src/core/TimeAgo.tsx +19 -8
  679. package/src/core/__tests__/Button.browser.spec.tsx +57 -0
  680. package/src/core/__tests__/CoreA11y.browser.spec.tsx +1 -10
  681. package/src/core/__tests__/PageOutline.browser.spec.tsx +20 -0
  682. package/src/core/__tests__/Segmented.browser.spec.tsx +59 -1
  683. package/src/core/__tests__/Textarea.browser.spec.tsx +1 -0
  684. package/src/core/__tests__/primitiveSlots.spec.ts +0 -1
  685. package/src/core/index.ts +0 -11
  686. package/src/form/Control.tsx +5 -0
  687. package/src/form/ControlSelect.tsx +31 -3
  688. package/src/form/ControlUpload.tsx +11 -16
  689. package/src/form/__tests__/ControlChoices.browser.spec.tsx +42 -0
  690. package/src/form/__tests__/ControlSelectLongLabelDialog.browser.spec.tsx +105 -0
  691. package/src/form/__tests__/ControlUpload.browser.spec.tsx +24 -0
  692. package/src/i18n/en/__tests__/uiEn.spec.ts +110 -0
  693. package/src/i18n/en/index.ts +22 -0
  694. package/src/i18n/en/uiEn.ts +1678 -0
  695. package/src/i18n/fr/uiFr.ts +40 -4
  696. package/src/markdown/MarkdownView.tsx +51 -6
  697. package/src/markdown/__tests__/MarkdownViewLink.browser.spec.tsx +33 -0
  698. package/src/markdown/__tests__/highlightLines.spec.ts +45 -0
  699. package/src/markdown/highlightLines.ts +120 -0
  700. package/src/markdown/index.ts +14 -2
  701. package/src/organizations/MyOrganizationInvitations.tsx +11 -2
  702. package/src/organizations/MyOrganizations.tsx +24 -3
  703. package/src/organizations/OrganizationInviteDialog.tsx +1 -1
  704. package/src/organizations/OrganizationMembers.tsx +10 -1
  705. package/src/organizations/OrganizationPendingInvitations.tsx +6 -0
  706. package/src/organizations/OrganizationRanks.tsx +2 -0
  707. package/src/organizations/OrganizationTransferOwnershipDialog.tsx +1 -1
  708. package/src/organizations/__tests__/MyOrganizations.browser.spec.tsx +2 -1
  709. package/src/shell/ButtonInbox.tsx +11 -1
  710. package/src/shell/DetailLayout.tsx +27 -5
  711. package/src/shell/DetailLayoutTabMenu.tsx +89 -0
  712. package/src/shell/PlateLayout.tsx +18 -9
  713. package/src/shell/__tests__/ButtonInbox.browser.spec.tsx +40 -0
  714. package/src/shell/__tests__/DetailLayout.browser.spec.tsx +36 -1
  715. package/src/shell/__tests__/PlateLayout.browser.spec.tsx +19 -2
  716. package/src/sortable/__tests__/useSortableList.browser.spec.tsx +157 -0
  717. package/src/sortable/index.ts +22 -0
  718. package/src/sortable/useSortableItem.ts +65 -0
  719. package/src/sortable/useSortableList.ts +231 -0
  720. package/src/styles.css +43 -0
  721. package/src/table/DataTable.tsx +73 -7
  722. package/src/table/DataTableBody.tsx +48 -6
  723. package/src/table/DataTableBulkBar.tsx +3 -6
  724. package/src/table/DataTableFooter.tsx +6 -1
  725. package/src/table/DataTableKeyHints.tsx +40 -0
  726. package/src/table/DataTableRowActionGroupItem.tsx +75 -0
  727. package/src/table/DataTableRowActionItem.tsx +6 -0
  728. package/src/table/DataTableRowActionPrimary.tsx +52 -0
  729. package/src/table/DataTableRowActionsInline.tsx +19 -3
  730. package/src/table/DataTableRowActionsMenu.tsx +33 -49
  731. package/src/table/DataTableSortMenuButton.tsx +105 -0
  732. package/src/table/DataTableToolbar.tsx +9 -0
  733. package/src/table/__tests__/DataTableColumnPriority.browser.spec.tsx +147 -0
  734. package/src/table/__tests__/DataTableDenseHeader.browser.spec.tsx +92 -0
  735. package/src/table/__tests__/DataTableKeyboard.browser.spec.tsx +216 -0
  736. package/src/table/__tests__/DataTablePersistenceStorage.browser.spec.tsx +204 -0
  737. package/src/table/__tests__/DataTableRowActionGroup.browser.spec.tsx +118 -1
  738. package/src/table/__tests__/DataTableRowActionPrimary.browser.spec.tsx +126 -0
  739. package/src/table/__tests__/DataTableSortMenu.browser.spec.tsx +126 -0
  740. package/src/table/__tests__/DataTableStaticLoading.browser.spec.tsx +80 -0
  741. package/src/table/dataTableBaseProps.ts +94 -2
  742. package/src/table/dataTablePersistence.ts +118 -32
  743. package/src/table/dataTablePriority.ts +34 -0
  744. package/src/table/dataTableTypes.ts +159 -3
  745. package/src/table/index.ts +19 -1
  746. package/src/table/useDataTableColumns.ts +9 -4
  747. package/src/table/useDataTableData.ts +13 -4
  748. package/src/table/useDataTableFilterForm.ts +6 -2
  749. package/src/table/useDataTableFilterVisibility.ts +20 -7
  750. package/src/table/useDataTableKeyboard.ts +231 -0
  751. package/src/table/useDataTableRefresh.ts +4 -2
  752. package/src/table/useDataTableSummary.ts +25 -8
  753. package/src/table/useElementWidth.ts +35 -0
  754. package/src/tree/TreeViewRow.tsx +4 -12
  755. package/src/tree/__tests__/TreeView.browser.spec.tsx +27 -12
  756. package/dist/core/Tabs.d.ts +0 -15
  757. package/dist/core/Tabs.d.ts.map +0 -1
  758. package/dist/core/Tabs.js +0 -50
  759. package/dist/core/Tabs.js.map +0 -1
  760. package/src/core/Tabs.tsx +0 -86
  761. package/src/core/__tests__/Tabs.browser.spec.tsx +0 -23
@@ -1 +1 @@
1
- {"version":3,"file":"useDataTableData.js","names":[],"sources":["../../src/table/useDataTableData.ts"],"sourcesContent":["import { type Alepha, type Page, type ZObject, z } from \"alepha\";\nimport { ActionErrorPolicy } from \"alepha/react\";\nimport { type FormModel, useForm } from \"alepha/react/form\";\nimport {\n type Dispatch,\n type SetStateAction,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport type { DataTableBaseProps } from \"./dataTableBaseProps.ts\";\nimport { dataTableFilterOperatorKey } from \"./dataTableFilterFields.ts\";\nimport { persistedSort, writePersisted } from \"./dataTablePersistence.ts\";\nimport type {\n DataTableFilterFields,\n DataTableSource,\n ColumnDef,\n SortState,\n} from \"./dataTableTypes.ts\";\nimport { paginateLocal } from \"./paginateLocal.ts\";\n\nexport interface UseDataTableDataOptions<T> {\n props: DataTableBaseProps<T, DataTableFilterFields> &\n DataTableSource<T, DataTableFilterFields>;\n /**\n * The page size and its setter. The state is declared in `DataTable`,\n * first of all its hooks; this hook changes it from the footer's picker.\n */\n size: number;\n setSize: Dispatch<SetStateAction<number>>;\n /**\n * The key the sort is persisted under, or `undefined` when the table does\n * not store it.\n */\n sortKey: string | undefined;\n form: FormModel<ZObject> | undefined;\n alepha: Alepha;\n}\n\n/**\n * The rows `DataTable` renders and the state that picks them: the page, the\n * page-size picker, the sort, and either the fetched page or the static one\n * derived from `data`.\n *\n * The setters are returned alongside the values because the refresh wiring\n * and the scope change in `DataTable` write the same state.\n */\nexport const useDataTableData = <T>(options: UseDataTableDataOptions<T>) => {\n const { props, size, setSize, sortKey, form, alepha } = options;\n\n // -- Paging / sort / data --------------------------------------------------\n\n const [page, setPage] = useState(0);\n\n /**\n * Change the page size and go back to the first page.\n *\n * The reset is the whole point: raising the size while on page 5 can put\n * the reader past the last page, which renders an empty table with no\n * visible cause. Persisted so the choice survives a reload, alongside the\n * filters, sort and columns this table already remembers.\n */\n const changeSize = (next: number) => {\n setSize(next);\n setPage(0);\n if (props.persistenceKey) {\n writePersisted(props.persistenceKey, \"size\", next);\n }\n };\n\n /**\n * The footer's page-size picker, as a form of one field.\n *\n * `Control` is form-bound and this picker is not part of any form, which is\n * why the footer stayed on a raw `<Select>` long after everything else here\n * moved. One field is the whole cost of joining, and it buys the picker the\n * same trigger, popup and keyboard handling as every other select in the\n * table. `keepDirty: false` so the re-seed below actually re-seeds: `size`\n * can move without the picker (a persisted value on mount), and a kept\n * \"edit\" would pin the trigger to a page size the table is not using.\n */\n const sizeForm = useForm({\n schema: z.object({ size: z.number() }),\n initialValues: { size },\n keepDirty: false,\n handler: async () => {},\n onChange: (_key, next) => changeSize(next as number),\n });\n\n const [sort, setSort] = useState<SortState | null>(() =>\n persistedSort(sortKey, props.defaultSort),\n );\n const [fetchedData, setData] = useState<T[]>([]);\n const [fetchedMeta, setMeta] = useState<Page<T>[\"page\"] | null>(null);\n // The filters the fetched rows answer, read when their request left: by\n // the time it answers, `form.currentValues` holds what the reader is\n // typing now. Read by the cells through `rowFilters`.\n const [fetchedFilters, setFetchedFilters] = useState<\n Record<string, unknown> | undefined\n >(undefined);\n const [loading, setLoading] = useState(false);\n // The id of the request whose rows are on screen. Optimistic overlays\n // (`useOptimisticRows`) wait for a request that left after the server\n // accepted their write before they let go of a row.\n const [loadedRequestId, setLoadedRequestId] = useState(0);\n const [refreshKey, setRefreshKey] = useState(0);\n const [isRefreshing, setIsRefreshing] = useState(false);\n\n // Alepha's pagination parser reads \"field\" as asc and \"-field\" as desc.\n // Multiple comma-separated entries are multi-column sort, so we must\n // NOT use `field,direction` syntax: that would treat \"asc\"/\"desc\" as\n // a second column name and 500 on the backend.\n const sortParam = sort\n ? sort.direction === \"desc\"\n ? `-${sort.field}`\n : sort.field\n : undefined;\n\n // Hold the latest `fetch` in a ref so it is NOT a dependency of `load`.\n // Callers pass `fetch` inline (a new function every render), and a fetcher\n // that writes a store atom the caller also subscribes to would otherwise\n // self-trigger: load → atom write → caller re-render → new `fetch` → new\n // `load` → effect re-runs → infinite loop. The ref keeps the newest closure\n // available while `load` only re-runs on actual inputs (page/size/sort/…).\n const fetchRef = useRef(props.fetch);\n fetchRef.current = props.fetch;\n\n // The newest request, so an older one that answers late cannot put its\n // rows back (#Q2517). A project switch, a filter keystroke or a refresh\n // each start one; only the last may write, and it aborts the one before.\n const latestRequest = useRef<\n { id: number; abort: AbortController } | undefined\n >(undefined);\n\n const load = useCallback(async () => {\n // Static mode owns no request. Bail before touching `loading` too, so a\n // table fed an array never flashes the skeleton over rows it already has.\n const fetcher = fetchRef.current;\n if (!fetcher) return;\n latestRequest.current?.abort.abort();\n const request = {\n id: (latestRequest.current?.id ?? 0) + 1,\n abort: new AbortController(),\n };\n latestRequest.current = request;\n const isLatest = () => latestRequest.current === request;\n setLoading(true);\n const sent = form ? { ...form.currentValues } : undefined;\n try {\n const res = await fetcher({\n page,\n size,\n sort: sortParam,\n filters: form?.currentValues,\n signal: request.abort.signal,\n });\n if (!isLatest()) return;\n setData(res.content);\n setMeta(res.page);\n setFetchedFilters(sent);\n setLoadedRequestId(request.id);\n } catch (error) {\n // A superseded request's failure (its own abort included) is nobody's\n // news: a newer one is already answering.\n if (!isLatest()) return;\n // Surface read failures through the same `react:action:error` channel\n // that useAction/useQuery use, so a mounted <ActionErrorToaster /> toasts\n // them. Keep the previous rows on screen rather than blanking the table.\n void alepha.events.emit(\"react:action:error\", {\n type: \"custom\",\n id: \"data-table:load\",\n error: error as Error,\n handled: ActionErrorPolicy.isHandled(error),\n });\n } finally {\n // Only the newest request clears `loading`: an older one finishing\n // first used to hide the spinner while the table still waited.\n if (isLatest()) {\n setLoading(false);\n }\n }\n }, [page, size, sortParam, refreshKey, form, alepha]);\n\n useEffect(() => {\n void load();\n }, [load]);\n\n /**\n * Static mode's equivalent of `load`: derived, not stored.\n *\n * Deliberately NOT routed through `load`: putting `props.data` in that\n * effect's dependencies reproduces the exact loop `fetchRef` exists to\n * prevent (load → setData → re-render → new inline array → new load).\n * Computed synchronously there is no state to go stale, an inline\n * `data={rows.filter(…)}` is safe, and a changed array is on screen in\n * the same render.\n */\n const staticPage = useMemo(() => {\n if (!props.data) return null;\n const sortValues: Record<string, (item: T) => unknown> = {};\n for (const [key, column] of Object.entries(props.columns)) {\n if (column.sortValue) {\n sortValues[column.sortKey ?? key] = column.sortValue;\n }\n }\n // The preset operators, which the static match applies; a custom list is\n // the caller's `filter`.\n const operators: Record<string, string> = {};\n for (const [key, field] of Object.entries(props.filters?.fields ?? {})) {\n const operatorKey = dataTableFilterOperatorKey(key, field);\n if (operatorKey && typeof field.operators === \"string\") {\n operators[key] = operatorKey;\n }\n }\n // `pagination={false}`: one page holding every row.\n const unpaged = props.pagination === false;\n return paginateLocal(props.data, {\n page: unpaged ? 0 : page,\n size: unpaged ? Math.max(props.data.length, 1) : size,\n sort: sortParam,\n sortValues,\n filters: form?.currentValues,\n operators,\n filter: props.filter,\n group: props.groupBy\n ? { key: props.groupBy.key, order: props.groupBy.order }\n : undefined,\n });\n // `refreshKey` is what the filter-form subscriptions bump, so it is how\n // a filter change reaches this memo: `form` keeps its identity while\n // its values change, and `currentValues` is read inside.\n }, [\n props.data,\n props.columns,\n props.filter,\n props.filters?.fields,\n props.pagination,\n props.groupBy,\n page,\n size,\n sortParam,\n refreshKey,\n form,\n ]);\n\n const data = staticPage ? staticPage.content : fetchedData;\n const meta = staticPage ? staticPage.page : fetchedMeta;\n // Static rows are derived in this render from the current values, so those\n // ARE the filters they answer.\n const rowFilters = staticPage ? form?.currentValues : fetchedFilters;\n // Each group's rows over every page, for its header's count.\n const groupCounts = staticPage?.groupCounts;\n\n /**\n * Rows vanish under the reader in static mode: the caller detaches one and\n * the page they are on stops existing. Nothing fetches, so nothing else\n * would notice, and the table would sit on an empty page with no visible\n * cause. Fetch mode has the same hole, but there the server round-trip\n * needed to see it makes this the wrong place to close it.\n */\n if (staticPage) {\n const totalPages = staticPage.page.totalPages ?? 0;\n if (page > 0 && page > totalPages - 1) {\n // Guarded on `page`, so it settles in one pass and does not need an\n // effect: the clamp lands before the rows render against a page that no\n // longer exists.\n setPage(Math.max(0, totalPages - 1));\n }\n }\n\n // -- Sort ------------------------------------------------------------------\n\n /**\n * Apply a sort the reader chose, store it and report it.\n *\n * Stored here, on the reader's act, never on mount: a mount effect stamped\n * `defaultSort` into storage for everyone who merely opened the table, so a\n * later change of it never reached them (the rule the column writes in\n * `useDataTableColumns` follow too). The callback runs outside a `setSort`\n * updater, which StrictMode runs twice.\n */\n const applySort = (next: SortState | null) => {\n setSort(next);\n if (sortKey) {\n writePersisted(sortKey, \"sort\", next);\n }\n props.onSortChange?.(next);\n };\n\n const toggleSort = (col: string, def: ColumnDef<T>) => {\n if (!def.sortable) return;\n const field = def.sortKey ?? col;\n applySort(\n !sort || sort.field !== field\n ? { field, direction: \"asc\" }\n : sort.direction === \"asc\"\n ? { field, direction: \"desc\" }\n : null,\n );\n };\n\n /**\n * Sort in a named direction, or clear it.\n *\n * The header cycles; the menu states. Both write the same state, so a\n * column sorted from the menu shows the header's own arrow.\n */\n const setSortTo = (\n col: string,\n def: ColumnDef<T>,\n direction: \"asc\" | \"desc\" | null,\n ) => {\n if (!def.sortable) return;\n const field = def.sortKey ?? col;\n applySort(direction ? { field, direction } : null);\n };\n\n /**\n * The id the newest request carries, or the one the next will exceed.\n */\n const lastRequestId = useCallback(() => latestRequest.current?.id ?? 0, []);\n\n return {\n page,\n setPage,\n loadedRequestId,\n lastRequestId,\n isStatic: Boolean(props.data),\n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B,UAAU,YAAY;GAAE;GAAO;EAAU,IAAI,IAAI;CACnD;CAOA,OAAO;EACL;EACA;EACA;EACA,eANoB,kBAAkB,cAAc,SAAS,MAAM,GAAG,CAAC,CAM3D;EACZ,UAAU,QAAQ,MAAM,IAAI;EAC5B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"useDataTableData.js","names":[],"sources":["../../src/table/useDataTableData.ts"],"sourcesContent":["import { type Alepha, type Page, type ZObject, z } from \"alepha\";\nimport { ActionErrorPolicy } from \"alepha/react\";\nimport { type FormModel, useForm } from \"alepha/react/form\";\nimport {\n type Dispatch,\n type SetStateAction,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport type { DataTableBaseProps } from \"./dataTableBaseProps.ts\";\nimport { dataTableFilterOperatorKey } from \"./dataTableFilterFields.ts\";\nimport { persistedSort, writePersisted } from \"./dataTablePersistence.ts\";\nimport type {\n DataTableFilterFields,\n DataTableSource,\n ColumnDef,\n SortState,\n} from \"./dataTableTypes.ts\";\nimport { paginateLocal } from \"./paginateLocal.ts\";\n\nexport interface UseDataTableDataOptions<T> {\n props: DataTableBaseProps<T, DataTableFilterFields> &\n DataTableSource<T, DataTableFilterFields>;\n /**\n * The page size and its setter. The state is declared in `DataTable`,\n * first of all its hooks; this hook changes it from the footer's picker.\n */\n size: number;\n setSize: Dispatch<SetStateAction<number>>;\n /**\n * The key the sort is persisted under, or `undefined` when the table does\n * not store it.\n */\n sortKey: string | undefined;\n form: FormModel<ZObject> | undefined;\n alepha: Alepha;\n}\n\n/**\n * The rows `DataTable` renders and the state that picks them: the page, the\n * page-size picker, the sort, and either the fetched page or the static one\n * derived from `data`.\n *\n * The setters are returned alongside the values because the refresh wiring\n * and the scope change in `DataTable` write the same state.\n */\nexport const useDataTableData = <T>(options: UseDataTableDataOptions<T>) => {\n const { props, size, setSize, sortKey, form, alepha } = options;\n\n // -- Paging / sort / data --------------------------------------------------\n\n const [page, setPage] = useState(0);\n\n /**\n * Change the page size and go back to the first page.\n *\n * The reset is the whole point: raising the size while on page 5 can put\n * the reader past the last page, which renders an empty table with no\n * visible cause. Persisted so the choice survives a reload, alongside the\n * filters, sort and columns this table already remembers.\n */\n const changeSize = (next: number) => {\n setSize(next);\n setPage(0);\n if (props.persistenceKey) {\n writePersisted(\n props.persistenceKey,\n \"size\",\n next,\n props.persistenceStorage,\n );\n }\n };\n\n /**\n * The footer's page-size picker, as a form of one field.\n *\n * `Control` is form-bound and this picker is not part of any form, which is\n * why the footer stayed on a raw `<Select>` long after everything else here\n * moved. One field is the whole cost of joining, and it buys the picker the\n * same trigger, popup and keyboard handling as every other select in the\n * table. `keepDirty: false` so the re-seed below actually re-seeds: `size`\n * can move without the picker (a persisted value on mount), and a kept\n * \"edit\" would pin the trigger to a page size the table is not using.\n */\n const sizeForm = useForm({\n schema: z.object({ size: z.number() }),\n initialValues: { size },\n keepDirty: false,\n handler: async () => {},\n onChange: (_key, next) => changeSize(next as number),\n });\n\n const [sort, setSort] = useState<SortState | null>(() =>\n persistedSort(sortKey, props.defaultSort, props.persistenceStorage),\n );\n const [fetchedData, setData] = useState<T[]>([]);\n const [fetchedMeta, setMeta] = useState<Page<T>[\"page\"] | null>(null);\n // The filters the fetched rows answer, read when their request left: by\n // the time it answers, `form.currentValues` holds what the reader is\n // typing now. Read by the cells through `rowFilters`.\n const [fetchedFilters, setFetchedFilters] = useState<\n Record<string, unknown> | undefined\n >(undefined);\n const [loading, setLoading] = useState(false);\n // The id of the request whose rows are on screen. Optimistic overlays\n // (`useOptimisticRows`) wait for a request that left after the server\n // accepted their write before they let go of a row.\n const [loadedRequestId, setLoadedRequestId] = useState(0);\n const [refreshKey, setRefreshKey] = useState(0);\n const [isRefreshing, setIsRefreshing] = useState(false);\n\n // Alepha's pagination parser reads \"field\" as asc and \"-field\" as desc.\n // Multiple comma-separated entries are multi-column sort, so we must\n // NOT use `field,direction` syntax: that would treat \"asc\"/\"desc\" as\n // a second column name and 500 on the backend.\n const sortParam = sort\n ? sort.direction === \"desc\"\n ? `-${sort.field}`\n : sort.field\n : undefined;\n\n // Hold the latest `fetch` in a ref so it is NOT a dependency of `load`.\n // Callers pass `fetch` inline (a new function every render), and a fetcher\n // that writes a store atom the caller also subscribes to would otherwise\n // self-trigger: load → atom write → caller re-render → new `fetch` → new\n // `load` → effect re-runs → infinite loop. The ref keeps the newest closure\n // available while `load` only re-runs on actual inputs (page/size/sort/…).\n const fetchRef = useRef(props.fetch);\n fetchRef.current = props.fetch;\n\n // The newest request, so an older one that answers late cannot put its\n // rows back (#Q2517). A project switch, a filter keystroke or a refresh\n // each start one; only the last may write, and it aborts the one before.\n const latestRequest = useRef<\n { id: number; abort: AbortController } | undefined\n >(undefined);\n\n const load = useCallback(async () => {\n // Static mode owns no request. Bail before touching `loading` too, so a\n // table fed an array never flashes the skeleton over rows it already has.\n const fetcher = fetchRef.current;\n if (!fetcher) return;\n latestRequest.current?.abort.abort();\n const request = {\n id: (latestRequest.current?.id ?? 0) + 1,\n abort: new AbortController(),\n };\n latestRequest.current = request;\n const isLatest = () => latestRequest.current === request;\n setLoading(true);\n const sent = form ? { ...form.currentValues } : undefined;\n try {\n const res = await fetcher({\n page,\n size,\n sort: sortParam,\n filters: form?.currentValues,\n signal: request.abort.signal,\n });\n if (!isLatest()) return;\n setData(res.content);\n setMeta(res.page);\n setFetchedFilters(sent);\n setLoadedRequestId(request.id);\n } catch (error) {\n // A superseded request's failure (its own abort included) is nobody's\n // news: a newer one is already answering.\n if (!isLatest()) return;\n // Surface read failures through the same `react:action:error` channel\n // that useAction/useQuery use, so a mounted <ActionErrorToaster /> toasts\n // them. Keep the previous rows on screen rather than blanking the table.\n void alepha.events.emit(\"react:action:error\", {\n type: \"custom\",\n id: \"data-table:load\",\n error: error as Error,\n handled: ActionErrorPolicy.isHandled(error),\n });\n } finally {\n // Only the newest request clears `loading`: an older one finishing\n // first used to hide the spinner while the table still waited.\n if (isLatest()) {\n setLoading(false);\n }\n }\n }, [page, size, sortParam, refreshKey, form, alepha]);\n\n useEffect(() => {\n void load();\n }, [load]);\n\n /**\n * Static mode's equivalent of `load`: derived, not stored.\n *\n * Deliberately NOT routed through `load`: putting `props.data` in that\n * effect's dependencies reproduces the exact loop `fetchRef` exists to\n * prevent (load → setData → re-render → new inline array → new load).\n * Computed synchronously there is no state to go stale, an inline\n * `data={rows.filter(…)}` is safe, and a changed array is on screen in\n * the same render.\n */\n const staticPage = useMemo(() => {\n if (!props.data) return null;\n const sortValues: Record<string, (item: T) => unknown> = {};\n for (const [key, column] of Object.entries(props.columns)) {\n if (column.sortValue) {\n sortValues[column.sortKey ?? key] = column.sortValue;\n }\n }\n // The preset operators, which the static match applies; a custom list is\n // the caller's `filter`.\n const operators: Record<string, string> = {};\n for (const [key, field] of Object.entries(props.filters?.fields ?? {})) {\n const operatorKey = dataTableFilterOperatorKey(key, field);\n if (operatorKey && typeof field.operators === \"string\") {\n operators[key] = operatorKey;\n }\n }\n // `pagination={false}`: one page holding every row.\n const unpaged = props.pagination === false;\n return paginateLocal(props.data, {\n page: unpaged ? 0 : page,\n size: unpaged ? Math.max(props.data.length, 1) : size,\n sort: sortParam,\n sortValues,\n filters: form?.currentValues,\n operators,\n filter: props.filter,\n group: props.groupBy\n ? { key: props.groupBy.key, order: props.groupBy.order }\n : undefined,\n });\n // `refreshKey` is what the filter-form subscriptions bump, so it is how\n // a filter change reaches this memo: `form` keeps its identity while\n // its values change, and `currentValues` is read inside.\n }, [\n props.data,\n props.columns,\n props.filter,\n props.filters?.fields,\n props.pagination,\n props.groupBy,\n page,\n size,\n sortParam,\n refreshKey,\n form,\n ]);\n\n const data = staticPage ? staticPage.content : fetchedData;\n const meta = staticPage ? staticPage.page : fetchedMeta;\n // Static rows are derived in this render from the current values, so those\n // ARE the filters they answer.\n const rowFilters = staticPage ? form?.currentValues : fetchedFilters;\n // Each group's rows over every page, for its header's count.\n const groupCounts = staticPage?.groupCounts;\n\n /**\n * Rows vanish under the reader in static mode: the caller detaches one and\n * the page they are on stops existing. Nothing fetches, so nothing else\n * would notice, and the table would sit on an empty page with no visible\n * cause. Fetch mode has the same hole, but there the server round-trip\n * needed to see it makes this the wrong place to close it.\n */\n if (staticPage) {\n const totalPages = staticPage.page.totalPages ?? 0;\n if (page > 0 && page > totalPages - 1) {\n // Guarded on `page`, so it settles in one pass and does not need an\n // effect: the clamp lands before the rows render against a page that no\n // longer exists.\n setPage(Math.max(0, totalPages - 1));\n }\n }\n\n // -- Sort ------------------------------------------------------------------\n\n /**\n * Apply a sort the reader chose, store it and report it.\n *\n * Stored here, on the reader's act, never on mount: a mount effect stamped\n * `defaultSort` into storage for everyone who merely opened the table, so a\n * later change of it never reached them (the rule the column writes in\n * `useDataTableColumns` follow too). The callback runs outside a `setSort`\n * updater, which StrictMode runs twice.\n */\n const applySort = (next: SortState | null) => {\n setSort(next);\n if (sortKey) {\n writePersisted(sortKey, \"sort\", next, props.persistenceStorage);\n }\n props.onSortChange?.(next);\n };\n\n const toggleSort = (col: string, def: ColumnDef<T>) => {\n if (!def.sortable) return;\n const field = def.sortKey ?? col;\n applySort(\n !sort || sort.field !== field\n ? { field, direction: \"asc\" }\n : sort.direction === \"asc\"\n ? { field, direction: \"desc\" }\n : null,\n );\n };\n\n /**\n * Sort in a named direction, or clear it.\n *\n * The header cycles; the menu states. Both write the same state, so a\n * column sorted from the menu shows the header's own arrow.\n */\n const setSortTo = (\n col: string,\n def: ColumnDef<T>,\n direction: \"asc\" | \"desc\" | null,\n ) => {\n if (!def.sortable) return;\n const field = def.sortKey ?? col;\n applySort(direction ? { field, direction } : null);\n };\n\n /**\n * The id the newest request carries, or the one the next will exceed.\n */\n const lastRequestId = useCallback(() => latestRequest.current?.id ?? 0, []);\n\n return {\n page,\n setPage,\n loadedRequestId,\n lastRequestId,\n isStatic: Boolean(props.data),\n sizeForm,\n sort,\n setSort,\n data,\n meta,\n rowFilters,\n groupCounts,\n // Static mode's rows are the caller's: whether they are still on their\n // way is the caller's to say (`loading`), and the body then draws its\n // skeleton rather than an empty state.\n loading: staticPage ? Boolean(props.loading) : loading,\n refreshKey,\n setRefreshKey,\n isRefreshing,\n setIsRefreshing,\n toggleSort,\n setSortTo,\n applySort,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAkDA,MAAa,oBAAuB,YAAwC;CAC1E,MAAM,EAAE,OAAO,MAAM,SAAS,SAAS,MAAM,WAAW;CAIxD,MAAM,CAAC,MAAM,WAAW,SAAS,CAAC;;;;;;;;;CAUlC,MAAM,cAAc,SAAiB;EACnC,QAAQ,IAAI;EACZ,QAAQ,CAAC;EACT,IAAI,MAAM,gBACR,eACE,MAAM,gBACN,QACA,MACA,MAAM,kBACR;CAEJ;;;;;;;;;;;;CAaA,MAAM,WAAW,QAAQ;EACvB,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;EACrC,eAAe,EAAE,KAAK;EACtB,WAAW;EACX,SAAS,YAAY,CAAC;EACtB,WAAW,MAAM,SAAS,WAAW,IAAc;CACrD,CAAC;CAED,MAAM,CAAC,MAAM,WAAW,eACtB,cAAc,SAAS,MAAM,aAAa,MAAM,kBAAkB,CACpE;CACA,MAAM,CAAC,aAAa,WAAW,SAAc,CAAC,CAAC;CAC/C,MAAM,CAAC,aAAa,WAAW,SAAiC,IAAI;CAIpE,MAAM,CAAC,gBAAgB,qBAAqB,SAE1C,KAAA,CAAS;CACX,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAI5C,MAAM,CAAC,iBAAiB,sBAAsB,SAAS,CAAC;CACxD,MAAM,CAAC,YAAY,iBAAiB,SAAS,CAAC;CAC9C,MAAM,CAAC,cAAc,mBAAmB,SAAS,KAAK;CAMtD,MAAM,YAAY,OACd,KAAK,cAAc,SACjB,IAAI,KAAK,UACT,KAAK,QACP,KAAA;CAQJ,MAAM,WAAW,OAAO,MAAM,KAAK;CACnC,SAAS,UAAU,MAAM;CA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ACJ,KACA,KACA,cACG;EACH,IAAI,CAAC,IAAI,UAAU;EACnB,MAAM,QAAQ,IAAI,WAAW;EAC7B,UAAU,YAAY;GAAE;GAAO;EAAU,IAAI,IAAI;CACnD;CAOA,OAAO;EACL;EACA;EACA;EACA,eANoB,kBAAkB,cAAc,SAAS,MAAM,GAAG,CAAC,CAM3D;EACZ,UAAU,QAAQ,MAAM,IAAI;EAC5B;EACA;EACA;EACA;EACA;EACA;EACA;EAIA,SAAS,aAAa,QAAQ,MAAM,OAAO,IAAI;EAC/C;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDataTableFilterForm.d.ts","sourceRoot":"","sources":["../../src/table/useDataTableFilterForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAK,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,mBAAmB,CAAC;AAG5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAiBlE,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAK7B,MAAM,WAAW,6BAA6B,CAAC,CAAC;IAC9C,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,qBAAqB,CAAC,GACjD,eAAe,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;IAC5C;;;OAGG;IACH,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IACf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC3C;;OAEG;IACH,IAAI,EAAE,MAAM,E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C;IACrC,UAAU,EAAE,yBAAyB,GAAG,SAAS,CAAC;CAiJnD,CAAC"}
@@ -1,11 +1,11 @@
1
+ import { z } from "alepha";
2
+ import { useForm } from "alepha/react/form";
3
+ import { useEffect, useMemo, useRef } from "react";
1
4
  import { buildDataTableFilterSchema, dataTableFilterKeys, dataTableFilterMode, dataTableFilterOperatorKey, dataTableKeptFilterKeys } from "./dataTableFilterFields.js";
2
5
  import { readPersisted, reconcilePersistedFilters } from "./dataTablePersistence.js";
3
6
  import { isEmptyFilterValue } from "./dataTablePresets.js";
4
7
  import { DATA_TABLE_FILTERS_QUERY_KEY, DATA_TABLE_NO_STORED_FILTERS } from "./dataTableQueryKeys.js";
5
8
  import { queryToFilters } from "./queryFilters.js";
6
- import { useEffect, useMemo, useRef } from "react";
7
- import { z } from "alepha";
8
- import { useForm } from "alepha/react/form";
9
9
  // src/table/useDataTableFilterForm.ts
10
10
  const EMPTY_FILTERS_SCHEMA = z.object({});
11
11
  /**
@@ -51,8 +51,12 @@ const useDataTableFilterForm = (options) => {
51
51
  });
52
52
  const persistedFilterValues = useMemo(() => {
53
53
  if (!filtersKey || !definition) return void 0;
54
- return reconcilePersistedFilters(definition.schema, readPersisted(filtersKey, "filters"));
55
- }, [filtersKey, definition]);
54
+ return reconcilePersistedFilters(definition.schema, readPersisted(filtersKey, "filters", props.persistenceStorage));
55
+ }, [
56
+ filtersKey,
57
+ definition,
58
+ props.persistenceStorage
59
+ ]);
56
60
  /**
57
61
  * Filter values the URL carries, when the caller opted in with `fromQuery`.
58
62
  *
@@ -1 +1 @@
1
- {"version":3,"file":"useDataTableFilterForm.js","names":[],"sources":["../../src/table/useDataTableFilterForm.ts"],"sourcesContent":["import { type Alepha, type ZObject, z } from \"alepha\";\nimport { type FormModel, useForm } from \"alepha/react/form\";\nimport { useEffect, useMemo, useRef } from \"react\";\n\nimport type { DataTableBaseProps } from \"./dataTableBaseProps.ts\";\nimport {\n dataTableFilterKeys,\n dataTableKeptFilterKeys,\n dataTableFilterMode,\n dataTableFilterOperatorKey,\n buildDataTableFilterSchema,\n} from \"./dataTableFilterFields.ts\";\nimport {\n readPersisted,\n reconcilePersistedFilters,\n} from \"./dataTablePersistence.ts\";\nimport { isEmptyFilterValue } from \"./dataTablePresets.ts\";\nimport {\n DATA_TABLE_FILTERS_QUERY_KEY,\n DATA_TABLE_NO_STORED_FILTERS,\n} from \"./dataTableQueryKeys.ts\";\nimport type {\n DataTableFilterFields,\n DataTableFilterMode,\n DataTableSource,\n} from \"./dataTableTypes.ts\";\nimport { queryToFilters } from \"./queryFilters.ts\";\n\nconst EMPTY_FILTERS_SCHEMA = z.object({}) as ZObject;\n\nexport interface UseDataTableFilterFormOptions<T> {\n props: DataTableBaseProps<T, DataTableFilterFields> &\n DataTableSource<T, DataTableFilterFields>;\n /**\n * The key the filter values are persisted under, or `undefined` when the\n * table does not store them.\n */\n filtersKey: string | undefined;\n alepha: Alepha;\n}\n\n/**\n * What a table's filters are, as read at mount: the schema its form is built\n * on, every key a filter value is stored under, and the mode each field\n * starts in.\n */\nexport interface DataTableFilterDefinition {\n schema: ZObject;\n /**\n * Every filter key, operator keys included, in declaration order. See\n * `dataTableFilterKeys`.\n */\n keys: string[];\n /**\n * The mode of each field, keyed by field.\n */\n modes: Record<string, DataTableFilterMode>;\n /**\n * The keys a preset leaves alone. See `dataTableKeptFilterKeys`.\n */\n kept: string[];\n}\n\n/**\n * The filter form `DataTable` reads its filter values from, and the\n * definition it was built from. Both are `undefined` without `filters`.\n */\nexport const useDataTableFilterForm = <T>(\n options: UseDataTableFilterFormOptions<T>,\n): {\n form: FormModel<ZObject> | undefined;\n definition: DataTableFilterDefinition | undefined;\n} => {\n const { props, filtersKey, alepha } = options;\n\n /**\n * The schema, the keys and the modes, read ONCE.\n *\n * `useForm` captures its schema at mount and persistence and `fromQuery`\n * are read at mount, so a key set that moved later would be a filter the\n * form cannot hold.\n */\n const definition = useMemo<DataTableFilterDefinition | undefined>(() => {\n const fields = props.filters?.fields;\n if (!fields) return undefined;\n const modes: Record<string, DataTableFilterMode> = {};\n for (const [key, field] of Object.entries(fields)) {\n modes[key] = dataTableFilterMode(field);\n }\n return {\n schema: buildDataTableFilterSchema(fields),\n keys: dataTableFilterKeys(fields),\n modes,\n kept: dataTableKeptFilterKeys(fields),\n };\n }, []);\n\n /**\n * A key set that changed after mount does nothing: the form, persistence\n * and the URL all read the one taken at mount. Silence would leave a filter\n * that never filters, so development says so, once. A field that has\n * nothing to offer yet sets `hidden` instead of dropping its key.\n */\n const warnedKeys = useRef(false);\n useEffect(() => {\n const fields = props.filters?.fields;\n if (!fields || !definition || warnedKeys.current) return;\n if (alepha.isProduction()) return;\n const keys = dataTableFilterKeys(fields);\n if (keys.join(\",\") === definition.keys.join(\",\")) return;\n warnedKeys.current = true;\n console.warn(\n `DataTable: the filter fields changed after mount (${definition.keys.join(\", \")} -> ${keys.join(\", \")}). ` +\n \"The key set is read once; set `hidden` on a field instead of dropping its key, or change the table's `key` to remount it.\",\n );\n });\n\n // Read persisted filter values synchronously so they reach useForm's\n // first invocation. Reading inside an effect would be too late:\n // useForm captures `initialValues` only once via useMemo.\n const persistedFilterValues = useMemo(() => {\n if (!filtersKey || !definition) return undefined;\n return reconcilePersistedFilters(\n definition.schema,\n readPersisted<Record<string, any>>(filtersKey, \"filters\"),\n );\n }, [filtersKey, definition]);\n\n /**\n * Filter values the URL carries, when the caller opted in with `fromQuery`.\n *\n * Read from the store rather than through `useRouterState`, on purpose:\n * this is a one-shot read at mount, so the subscription would only buy a\n * re-render of the whole table on navigations it must not react to anyway.\n * A missing store (a table mounted with no router at all) reads as no\n * query, not as a crash.\n *\n * An allowlist that names a field brings its operator key with it: a link\n * carrying `?status=done&statusOp=not`, read without the operator, would\n * select the very rows it excluded.\n */\n const routerQuery = useMemo(() => {\n if (!props.filters?.fromQuery || !definition) return undefined;\n return (\n alepha.store.get(\"alepha.react.router.state\") as\n | { query?: Record<string, any> }\n | undefined\n )?.query;\n }, []);\n\n /**\n * `?filters=none` (`DATA_TABLE_NO_STORED_FILTERS`): the link's filters are\n * the whole filter even when it carries none. A drill-through to an\n * unfiltered list (a dashboard's \"every user\" tile) has no filter of its\n * own to replace the stored ones with, so without this the reader's\n * filters from last week would narrow the list the link promised. Read\n * only when the table opted into `fromQuery`, like every other param.\n */\n const ignoreStored =\n routerQuery?.[DATA_TABLE_FILTERS_QUERY_KEY] ===\n DATA_TABLE_NO_STORED_FILTERS;\n\n const queryFilterValues = useMemo(() => {\n const fromQuery = props.filters?.fromQuery;\n if (!fromQuery || !definition) return undefined;\n const query = routerQuery;\n if (!query) return undefined;\n let keys: readonly string[] = definition.keys;\n const fields = props.filters?.fields;\n if (Array.isArray(fromQuery) && fields) {\n keys = fromQuery.flatMap((key) => {\n const field = fields[key];\n const operatorKey = field\n ? dataTableFilterOperatorKey(key, field)\n : undefined;\n return operatorKey && !fromQuery.includes(operatorKey)\n ? [key, operatorKey]\n : [key];\n });\n }\n return queryToFilters(alepha, definition.schema, query, keys);\n }, []);\n\n const mergedFilterInitialValues = useMemo<Record<string, any>>(\n () => ({\n ...props.filters?.initialValues,\n // A link that carries filters REPLACES the stored choice rather than\n // adding to it: a drill-through or a preset's values arriving by URL\n // mean those rows, and a filter the reader set last week kept on top\n // of them would silently narrow the list the link promised.\n ...(ignoreStored || hasQueryFilters(queryFilterValues)\n ? {}\n : persistedFilterValues),\n ...queryFilterValues,\n // Last: an explicit `seedValues` is the caller deciding for a case of\n // its own, and outranks what the URL happened to carry.\n ...props.filters?.seedValues,\n }),\n [],\n );\n\n // Always call useForm to keep hook order stable. When the caller\n // doesn't pass `filters`, the form has an empty schema and is unused.\n const internalForm = useForm({\n schema: definition?.schema ?? EMPTY_FILTERS_SCHEMA,\n initialValues: mergedFilterInitialValues,\n handler: async () => {\n // No-op: the table subscribes to `form:submit:success` to refetch.\n },\n });\n\n return { form: definition ? internalForm : undefined, definition };\n};\n\nconst hasQueryFilters = (values: Record<string, unknown> | undefined) =>\n Boolean(values) &&\n Object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AG,CAAC,CAAC;;;;;;;;;CAUL,MAAM,eACJ,cAAc,kCACd;CAEF,MAAM,oBAAoB,cAAc;EACtC,MAAM,YAAY,MAAM,SAAS;EACjC,IAAI,CAAC,aAAa,CAAC,YAAY,OAAO,KAAA;EACtC,MAAM,QAAQ;EACd,IAAI,CAAC,OAAO,OAAO,KAAA;EACnB,IAAI,OAA0B,WAAW;EACzC,MAAM,SAAS,MAAM,SAAS;EAC9B,IAAI,MAAM,QAAQ,SAAS,KAAK,QAC9B,OAAO,UAAU,SAAS,QAAQ;GAChC,MAAM,QAAQ,OAAO;GACrB,MAAM,cAAc,QAChB,2BAA2B,KAAK,KAAK,IACrC,KAAA;GACJ,OAAO,eAAe,CAAC,UAAU,SAAS,WAAW,IACjD,CAAC,KAAK,WAAW,IACjB,CAAC,GAAG;EACV,CAAC;EAEH,OAAO,eAAe,QAAQ,WAAW,QAAQ,OAAO,IAAI;CAC9D,GAAG,CAAC,CAAC;CAEL,MAAM,4BAA4B,eACzB;EACL,GAAG,MAAM,SAAS;EAKlB,GAAI,gBAAgB,gBAAgB,iBAAiB,IACjD,CAAC,IACD;EACJ,GAAG;EAGH,GAAG,MAAM,SAAS;CACpB,IACA,CAAC,CACH;CAIA,MAAM,eAAe,QAAQ;EAC3B,QAAQ,YAAY,UAAU;EAC9B,eAAe;EACf,SAAS,YAAY,CAErB;CACF,CAAC;CAED,OAAO;EAAE,MAAM,aAAa,eAAe,KAAA;EAAW;CAAW;AACnE;AAEA,MAAM,mBAAmB,WACvB,QAAQ,MAAM,KACd,OAAO,OAAO,MAAiC,CAAC,CAAC,MAC9C,UAAU,CAAC,mBAAmB,KAAK,CACtC"}
1
+ {"version":3,"file":"useDataTableFilterForm.js","names":[],"sources":["../../src/table/useDataTableFilterForm.ts"],"sourcesContent":["import { type Alepha, type ZObject, z } from \"alepha\";\nimport { type FormModel, useForm } from \"alepha/react/form\";\nimport { useEffect, useMemo, useRef } from \"react\";\n\nimport type { DataTableBaseProps } from \"./dataTableBaseProps.ts\";\nimport {\n dataTableFilterKeys,\n dataTableKeptFilterKeys,\n dataTableFilterMode,\n dataTableFilterOperatorKey,\n buildDataTableFilterSchema,\n} from \"./dataTableFilterFields.ts\";\nimport {\n readPersisted,\n reconcilePersistedFilters,\n} from \"./dataTablePersistence.ts\";\nimport { isEmptyFilterValue } from \"./dataTablePresets.ts\";\nimport {\n DATA_TABLE_FILTERS_QUERY_KEY,\n DATA_TABLE_NO_STORED_FILTERS,\n} from \"./dataTableQueryKeys.ts\";\nimport type {\n DataTableFilterFields,\n DataTableFilterMode,\n DataTableSource,\n} from \"./dataTableTypes.ts\";\nimport { queryToFilters } from \"./queryFilters.ts\";\n\nconst EMPTY_FILTERS_SCHEMA = z.object({}) as ZObject;\n\nexport interface UseDataTableFilterFormOptions<T> {\n props: DataTableBaseProps<T, DataTableFilterFields> &\n DataTableSource<T, DataTableFilterFields>;\n /**\n * The key the filter values are persisted under, or `undefined` when the\n * table does not store them.\n */\n filtersKey: string | undefined;\n alepha: Alepha;\n}\n\n/**\n * What a table's filters are, as read at mount: the schema its form is built\n * on, every key a filter value is stored under, and the mode each field\n * starts in.\n */\nexport interface DataTableFilterDefinition {\n schema: ZObject;\n /**\n * Every filter key, operator keys included, in declaration order. See\n * `dataTableFilterKeys`.\n */\n keys: string[];\n /**\n * The mode of each field, keyed by field.\n */\n modes: Record<string, DataTableFilterMode>;\n /**\n * The keys a preset leaves alone. See `dataTableKeptFilterKeys`.\n */\n kept: string[];\n}\n\n/**\n * The filter form `DataTable` reads its filter values from, and the\n * definition it was built from. Both are `undefined` without `filters`.\n */\nexport const useDataTableFilterForm = <T>(\n options: UseDataTableFilterFormOptions<T>,\n): {\n form: FormModel<ZObject> | undefined;\n definition: DataTableFilterDefinition | undefined;\n} => {\n const { props, filtersKey, alepha } = options;\n\n /**\n * The schema, the keys and the modes, read ONCE.\n *\n * `useForm` captures its schema at mount and persistence and `fromQuery`\n * are read at mount, so a key set that moved later would be a filter the\n * form cannot hold.\n */\n const definition = useMemo<DataTableFilterDefinition | undefined>(() => {\n const fields = props.filters?.fields;\n if (!fields) return undefined;\n const modes: Record<string, DataTableFilterMode> = {};\n for (const [key, field] of Object.entries(fields)) {\n modes[key] = dataTableFilterMode(field);\n }\n return {\n schema: buildDataTableFilterSchema(fields),\n keys: dataTableFilterKeys(fields),\n modes,\n kept: dataTableKeptFilterKeys(fields),\n };\n }, []);\n\n /**\n * A key set that changed after mount does nothing: the form, persistence\n * and the URL all read the one taken at mount. Silence would leave a filter\n * that never filters, so development says so, once. A field that has\n * nothing to offer yet sets `hidden` instead of dropping its key.\n */\n const warnedKeys = useRef(false);\n useEffect(() => {\n const fields = props.filters?.fields;\n if (!fields || !definition || warnedKeys.current) return;\n if (alepha.isProduction()) return;\n const keys = dataTableFilterKeys(fields);\n if (keys.join(\",\") === definition.keys.join(\",\")) return;\n warnedKeys.current = true;\n console.warn(\n `DataTable: the filter fields changed after mount (${definition.keys.join(\", \")} -> ${keys.join(\", \")}). ` +\n \"The key set is read once; set `hidden` on a field instead of dropping its key, or change the table's `key` to remount it.\",\n );\n });\n\n // Read persisted filter values synchronously so they reach useForm's\n // first invocation. Reading inside an effect would be too late:\n // useForm captures `initialValues` only once via useMemo.\n const persistedFilterValues = useMemo(() => {\n if (!filtersKey || !definition) return undefined;\n return reconcilePersistedFilters(\n definition.schema,\n readPersisted<Record<string, any>>(\n filtersKey,\n \"filters\",\n props.persistenceStorage,\n ),\n );\n }, [filtersKey, definition, props.persistenceStorage]);\n\n /**\n * Filter values the URL carries, when the caller opted in with `fromQuery`.\n *\n * Read from the store rather than through `useRouterState`, on purpose:\n * this is a one-shot read at mount, so the subscription would only buy a\n * re-render of the whole table on navigations it must not react to anyway.\n * A missing store (a table mounted with no router at all) reads as no\n * query, not as a crash.\n *\n * An allowlist that names a field brings its operator key with it: a link\n * carrying `?status=done&statusOp=not`, read without the operator, would\n * select the very rows it excluded.\n */\n const routerQuery = useMemo(() => {\n if (!props.filters?.fromQuery || !definition) return undefined;\n return (\n alepha.store.get(\"alepha.react.router.state\") as\n | { query?: Record<string, any> }\n | undefined\n )?.query;\n }, []);\n\n /**\n * `?filters=none` (`DATA_TABLE_NO_STORED_FILTERS`): the link's filters are\n * the whole filter even when it carries none. A drill-through to an\n * unfiltered list (a dashboard's \"every user\" tile) has no filter of its\n * own to replace the stored ones with, so without this the reader's\n * filters from last week would narrow the list the link promised. Read\n * only when the table opted into `fromQuery`, like every other param.\n */\n const ignoreStored =\n routerQuery?.[DATA_TABLE_FILTERS_QUERY_KEY] ===\n DATA_TABLE_NO_STORED_FILTERS;\n\n const queryFilterValues = useMemo(() => {\n const fromQuery = props.filters?.fromQuery;\n if (!fromQuery || !definition) return undefined;\n const query = routerQuery;\n if (!query) return undefined;\n let keys: readonly string[] = definition.keys;\n const fields = props.filters?.fields;\n if (Array.isArray(fromQuery) && fields) {\n keys = fromQuery.flatMap((key) => {\n const field = fields[key];\n const operatorKey = field\n ? dataTableFilterOperatorKey(key, field)\n : undefined;\n return operatorKey && !fromQuery.includes(operatorKey)\n ? [key, operatorKey]\n : [key];\n });\n }\n return queryToFilters(alepha, definition.schema, query, keys);\n }, []);\n\n const mergedFilterInitialValues = useMemo<Record<string, any>>(\n () => ({\n ...props.filters?.initialValues,\n // A link that carries filters REPLACES the stored choice rather than\n // adding to it: a drill-through or a preset's values arriving by URL\n // mean those rows, and a filter the reader set last week kept on top\n // of them would silently narrow the list the link promised.\n ...(ignoreStored || hasQueryFilters(queryFilterValues)\n ? {}\n : persistedFilterValues),\n ...queryFilterValues,\n // Last: an explicit `seedValues` is the caller deciding for a case of\n // its own, and outranks what the URL happened to carry.\n ...props.filters?.seedValues,\n }),\n [],\n );\n\n // Always call useForm to keep hook order stable. When the caller\n // doesn't pass `filters`, the form has an empty schema and is unused.\n const internalForm = useForm({\n schema: definition?.schema ?? EMPTY_FILTERS_SCHEMA,\n initialValues: mergedFilterInitialValues,\n handler: async () => {\n // No-op: the table subscribes to `form:submit:success` to refetch.\n },\n });\n\n return { form: definition ? internalForm : undefined, definition };\n};\n\nconst hasQueryFilters = (values: Record<string, unknown> | undefined) =>\n Boolean(values) &&\n Object.values(values as Record<string, unknown>).some(\n (value) => !isEmptyFilterValue(value),\n );\n"],"mappings":";;;;;;;;;AA4BA,MAAM,uBAAuB,EAAE,OAAO,CAAC,CAAC;;;;;AAuCxC,MAAa,0BACX,YAIG;CACH,MAAM,EAAE,OAAO,YAAY,WAAW;;;;;;;;CAStC,MAAM,aAAa,cAAqD;EACtE,MAAM,SAAS,MAAM,SAAS;EAC9B,IAAI,CAAC,QAAQ,OAAO,KAAA;EACpB,MAAM,QAA6C,CAAC;EACpD,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,GAC9C,MAAM,OAAO,oBAAoB,KAAK;EAExC,OAAO;GACL,QAAQ,2BAA2B,MAAM;GACzC,MAAM,oBAAoB,MAAM;GAChC;GACA,MAAM,wBAAwB,MAAM;EACtC;CACF,GAAG,CAAC,CAAC;;;;;;;CAQL,MAAM,aAAa,OAAO,KAAK;CAC/B,gBAAgB;EACd,MAAM,SAAS,MAAM,SAAS;EAC9B,IAAI,CAAC,UAAU,CAAC,cAAc,WAAW,SAAS;EAClD,IAAI,OAAO,aAAa,GAAG;EAC3B,MAAM,OAAO,oBAAoB,MAAM;EACvC,IAAI,KAAK,KAAK,GAAG,MAAM,WAAW,KAAK,KAAK,GAAG,GAAG;EAClD,WAAW,UAAU;EACrB,QAAQ,KACN,qDAAqD,WAAW,KAAK,KAAK,IAAI,EAAE,MAAM,KAAK,KAAK,IAAI,EAAE,iIAExG;CACF,CAAC;CAKD,MAAM,wBAAwB,cAAc;EAC1C,IAAI,CAAC,cAAc,CAAC,YAAY,OAAO,KAAA;EACvC,OAAO,0BACL,WAAW,QACX,cACE,YACA,WACA,MAAM,kBACR,CACF;CACF,GAAG;EAAC;EAAY;EAAY,MAAM;CAAkB,CAAC;;;;;;;;;;;;;;CAerD,MAAM,cAAc,cAAc;EAChC,I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ean;
57
57
  segmented?: boolean;
58
+ segmentedVariant?: "subtle" | "solid";
58
59
  checkboxes?: boolean;
59
60
  slider?: boolean;
60
61
  object?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"useDataTableFilterModel.d.ts","sourceRoot":"","sources":["../../src/table/useDataTableFilterModel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAMnF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,SAAU,SAAS,CAAC,OAAO,CAAC;;;aAMrD,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;;oBAGV,uBAAuB,KAAG,mBAAmB;iBAKhD,MAAM,KAAG,OAAO;mBAMd,uBAAuB,KAAG,OAAO;sBAG9B,uBAAuB;2BAPlB,uBAAuB;yBAW5C,uBAAuB,KAC7B,6BAA6B,EAAE,GAAG,SAAS;wBAkCnB,uBAAuB;qBAsCzC,uBAAuB,KAC7B,YAAY,EAAE,GAAG,SAAS;oBAaN,uBAAuB,KAAG,sBAAsB;2BAkBzC,uBAAuB;qBAO7B,uBAAuB;oBAQxB,uBAAuB;wBAYnB,uBAAuB;4BAWnB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAKtB,KAAK;;;;;;;;;CAwCtC,CAAC;AAEF;;GAEG;AACH,MAAM,MAA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@@ -1,10 +1,10 @@
1
- import { DATA_TABLE_FILTER_OPERATORS, DataTableFilterOperator } from "./DataTableFilterOperator.js";
2
- import { isEmptyFilterValue } from "./dataTablePresets.js";
1
+ import { z } from "alepha";
2
+ import { useFormValues } from "alepha/react/form";
3
3
  import { useI18n } from "alepha/react/i18n";
4
4
  import { Calendar, List, Search, Type } from "lucide-react";
5
+ import { DATA_TABLE_FILTER_OPERATORS, DataTableFilterOperator } from "./DataTableFilterOperator.js";
6
+ import { isEmptyFilterValue } from "./dataTablePresets.js";
5
7
  import { jsx } from "react/jsx-runtime";
6
- import { z } from "alepha";
7
- import { useFormValues } from "alepha/react/form";
8
8
  // src/table/useDataTableFilterModel.tsx
9
9
  /**
10
10
  * What one filter of `filters.fields` IS, read off the table's filter form:
@@ -1,3 +1,4 @@
1
+ import { type DataTablePersistenceStorage } from "./dataTablePersistence.ts";
1
2
  import type { DataTableFilterDefinition } from "./useDataTableFilterForm.ts";
2
3
  export interface UseDataTableFilterVisibilityOptions {
3
4
  /**
@@ -12,6 +13,10 @@ export interface UseDataTableFilterVisibilityOptions {
12
13
  * they put on the bar with it.
13
14
  */
14
15
  filtersKey: string | undefined;
16
+ /**
17
+ * Where `filtersKey` is stored, `localStorage` when absent.
18
+ */
19
+ persistenceStorage?: DataTablePersistenceStorage;
15
20
  }
16
21
  /**
17
22
  * Which filters are on the bar: the table's state, not the bar's, because
@@ -1 +1 @@
1
- {"version":3,"file":"useDataTableFilterVisibility.d.ts","sourceRoot":"","sources":["../../src/table/useDataTableFilterVisibility.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAE7E,MAAM,WAAW,mCAAmC;IAClD;;;OAGG;IACH,UAAU,EAAE,yBAAyB,GAAG,SAAS,CAAC;IAClD;;;;;OAKG;IACH,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAID;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,YAC9B,mCAAmC;;qBAYnC,MAAM,EAAE,OAAO,OAAO;;uBA6BvB,MAAM,GAAG,SAAS;;CAiB3B,CAAC"}
1
+ {"version":3,"file":"useDataTableFilterVisibility.d.ts","sourceRoot":"","sources":["../../src/table/useDataTableFilterVisibility.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,2BAA2B,EAKjC,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAE7E,MAAM,WAAW,mCAAmC;IAClD;;;OAGG;IACH,UAAU,EAAE,yBAAyB,GAAG,SAAS,CAAC;IAClD;;;;;OAKG;IACH,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B;;OAEG;IACH,kBAAkB,CAAC,EAAE,2BAA2B,CAAC;CAClD;AAID;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,YAC9B,mCAAmC;;qBAYnC,MAAM,EAAE,OAAO,OAAO;;uBAqCvB,MAAM,GAAG,SAAS;;CAiB3B,CAAC"}
@@ -1,5 +1,5 @@
1
- import { declaredShownFilters, filterVisibilityChange, persistedShownFilters, writePersisted } from "./dataTablePersistence.js";
2
1
  import { useCallback, useMemo, useState } from "react";
2
+ import { declaredShownFilters, filterVisibilityChange, persistedShownFilters, writePersisted } from "./dataTablePersistence.js";
3
3
  // src/table/useDataTableFilterVisibility.ts
4
4
  const NO_MODES = {};
5
5
  /**
@@ -13,23 +13,31 @@ const NO_MODES = {};
13
13
  * reader choosing anything, and `setShown` with `act: false` stores nothing.
14
14
  */
15
15
  const useDataTableFilterVisibility = (options) => {
16
- const { definition, filtersKey } = options;
16
+ const { definition, filtersKey, persistenceStorage } = options;
17
17
  const modes = definition?.modes ?? NO_MODES;
18
- const [shown, setShownState] = useState(() => persistedShownFilters(filtersKey, modes));
18
+ const [shown, setShownState] = useState(() => persistedShownFilters(filtersKey, modes, persistenceStorage));
19
19
  const declared = useMemo(() => declaredShownFilters(modes), [modes]);
20
20
  return {
21
21
  shown,
22
22
  setShown: useCallback((next, act) => {
23
23
  setShownState(next);
24
- if (act && filtersKey) writePersisted(filtersKey, "filterVisibility", filterVisibilityChange(next, modes));
25
- }, [filtersKey, modes]),
24
+ if (act && filtersKey) writePersisted(filtersKey, "filterVisibility", filterVisibilityChange(next, modes), persistenceStorage);
25
+ }, [
26
+ filtersKey,
27
+ modes,
28
+ persistenceStorage
29
+ ]),
26
30
  resetShown: useCallback(() => {
27
31
  setShownState(declared);
28
- if (filtersKey) writePersisted(filtersKey, "filterVisibility", void 0);
29
- }, [declared, filtersKey]),
32
+ if (filtersKey) writePersisted(filtersKey, "filterVisibility", void 0, persistenceStorage);
33
+ }, [
34
+ declared,
35
+ filtersKey,
36
+ persistenceStorage
37
+ ]),
30
38
  rereadShown: useCallback((key) => {
31
- setShownState(persistedShownFilters(key, modes));
32
- }, [modes]),
39
+ setShownState(persistedShownFilters(key, modes, persistenceStorage));
40
+ }, [modes, persistenceStorage]),
33
41
  differsFromDeclaration: shown.length !== declared.length || declared.some((key) => !shown.includes(key))
34
42
  };
35
43
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useDataTableFilterVisibility.js","names":[],"sources":["../../src/table/useDataTableFilterVisibility.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from \"react\";\n\nimport {\n declaredShownFilters,\n filterVisibilityChange,\n persistedShownFilters,\n writePersisted,\n} from \"./dataTablePersistence.ts\";\nimport type { DataTableFilterDefinition } from \"./useDataTableFilterForm.ts\";\n\nexport interface UseDataTableFilterVisibilityOptions {\n /**\n * What the table's filters are, as read at mount. `undefined` without\n * `filters`.\n */\n definition: DataTableFilterDefinition | undefined;\n /**\n * The key the filters facet is persisted under, or `undefined` when the\n * table does not store it. The shown filters sit behind the same facet as\n * the values: a table that forgets what the reader filtered by forgets what\n * they put on the bar with it.\n */\n filtersKey: string | undefined;\n}\n\nconst NO_MODES = {};\n\n/**\n * Which filters are on the bar: the table's state, not the bar's, because\n * three things write it - the bar (add, remove), Reset filters, and\n * persistence.\n *\n * Stored under `persistenceKey` as `filterVisibility`, and written on the\n * reader's acts only, never on mount: the rule every other persisted facet\n * follows. A filter that joined the bar because it holds a value is not the\n * reader choosing anything, and `setShown` with `act: false` stores nothing.\n */\nexport const useDataTableFilterVisibility = (\n options: UseDataTableFilterVisibilityOptions,\n) => {\n const { definition, filtersKey } = options;\n const modes = definition?.modes ?? NO_MODES;\n\n const [shown, setShownState] = useState<string[]>(() =>\n persistedShownFilters(filtersKey, modes),\n );\n\n const declared = useMemo(() => declaredShownFilters(modes), [modes]);\n\n const setShown = useCallback(\n (next: string[], act: boolean) => {\n setShownState(next);\n if (act && filtersKey) {\n writePersisted(\n filtersKey,\n \"filterVisibility\",\n filterVisibilityChange(next, modes),\n );\n }\n },\n [filtersKey, modes],\n );\n\n /**\n * Back to the declaration: every optional filter off, every default one\n * on, and nothing stored.\n */\n const resetShown = useCallback(() => {\n setShownState(declared);\n if (filtersKey) writePersisted(filtersKey, \"filterVisibility\", undefined);\n }, [declared, filtersKey]);\n\n /**\n * Re-read for a scope that just changed under a mounted table. Called from\n * `DataTable`'s render-time scope block, with the other facets, and for\n * the same reason: an effect would leave the incoming project showing the\n * bar of the one just left.\n */\n const rereadShown = useCallback(\n (key: string | undefined) => {\n setShownState(persistedShownFilters(key, modes));\n },\n [modes],\n );\n\n /**\n * Whether the bar is somewhere Reset would move it from: an optional\n * filter added, or a default one removed. Order alone is not a difference:\n * the bar draws the filters in the order they joined it, and the same set\n * in another order is not worth a Reset.\n */\n const differsFromDeclaration =\n shown.length !== declared.length ||\n declared.some((key) => !shown.includes(key));\n\n return { shown, setShown, resetShown, rereadShown, differsFromDeclaration };\n};\n"],"mappings":";;;AAyBA,MAAM,WAAW,CAAC;;;;;;;;;;;AAYlB,MAAa,gCACX,YACG;CACH,MAAM,EAAE,YAAY,eAAe;CACnC,MAAM,QAAQ,YAAY,SAAS;CAEnC,MAAM,CAAC,OAAO,iBAAiB,eAC7B,sBAAsB,YAAY,KAAK,CACzC;CAEA,MAAM,WAAW,cAAc,qBAAqB,KAAK,GAAG,CAAC,KAAK,CAAC;CAgDnE,OAAO;EAAE;EAAO,UA9CC,aACd,MAAgB,QAAiB;GAChC,cAAc,IAAI;GAClB,IAAI,OAAO,YACT,eACE,YACA,oBACA,uBAAuB,MAAM,KAAK,CACpC;EAEJ,GACA,CAAC,YAAY,KAAK,CAmCG;EAAG,YA5BP,kBAAkB;GACnC,cAAc,QAAQ;GACtB,IAAI,YAAY,eAAe,YAAY,oBAAoB,KAAA,CAAS;EAC1E,GAAG,CAAC,UAAU,UAAU,CAyBW;EAAG,aAjBlB,aACjB,QAA4B;GAC3B,cAAc,sBAAsB,KAAK,KAAK,CAAC;EACjD,GACA,CAAC,KAAK,CAawC;EAAG,wBAHjD,MAAM,WAAW,SAAS,UAC1B,SAAS,MAAM,QAAQ,CAAC,MAAM,SAAS,GAAG,CAAC;CAE6B;AAC5E"}
1
+ {"version":3,"file":"useDataTableFilterVisibility.js","names":[],"sources":["../../src/table/useDataTableFilterVisibility.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from \"react\";\n\nimport {\n type DataTablePersistenceStorage,\n declaredShownFilters,\n filterVisibilityChange,\n persistedShownFilters,\n writePersisted,\n} from \"./dataTablePersistence.ts\";\nimport type { DataTableFilterDefinition } from \"./useDataTableFilterForm.ts\";\n\nexport interface UseDataTableFilterVisibilityOptions {\n /**\n * What the table's filters are, as read at mount. `undefined` without\n * `filters`.\n */\n definition: DataTableFilterDefinition | undefined;\n /**\n * The key the filters facet is persisted under, or `undefined` when the\n * table does not store it. The shown filters sit behind the same facet as\n * the values: a table that forgets what the reader filtered by forgets what\n * they put on the bar with it.\n */\n filtersKey: string | undefined;\n /**\n * Where `filtersKey` is stored, `localStorage` when absent.\n */\n persistenceStorage?: DataTablePersistenceStorage;\n}\n\nconst NO_MODES = {};\n\n/**\n * Which filters are on the bar: the table's state, not the bar's, because\n * three things write it - the bar (add, remove), Reset filters, and\n * persistence.\n *\n * Stored under `persistenceKey` as `filterVisibility`, and written on the\n * reader's acts only, never on mount: the rule every other persisted facet\n * follows. A filter that joined the bar because it holds a value is not the\n * reader choosing anything, and `setShown` with `act: false` stores nothing.\n */\nexport const useDataTableFilterVisibility = (\n options: UseDataTableFilterVisibilityOptions,\n) => {\n const { definition, filtersKey, persistenceStorage } = options;\n const modes = definition?.modes ?? NO_MODES;\n\n const [shown, setShownState] = useState<string[]>(() =>\n persistedShownFilters(filtersKey, modes, persistenceStorage),\n );\n\n const declared = useMemo(() => declaredShownFilters(modes), [modes]);\n\n const setShown = useCallback(\n (next: string[], act: boolean) => {\n setShownState(next);\n if (act && filtersKey) {\n writePersisted(\n filtersKey,\n \"filterVisibility\",\n filterVisibilityChange(next, modes),\n persistenceStorage,\n );\n }\n },\n [filtersKey, modes, persistenceStorage],\n );\n\n /**\n * Back to the declaration: every optional filter off, every default one\n * on, and nothing stored.\n */\n const resetShown = useCallback(() => {\n setShownState(declared);\n if (filtersKey) {\n writePersisted(\n filtersKey,\n \"filterVisibility\",\n undefined,\n persistenceStorage,\n );\n }\n }, [declared, filtersKey, persistenceStorage]);\n\n /**\n * Re-read for a scope that just changed under a mounted table. Called from\n * `DataTable`'s render-time scope block, with the other facets, and for\n * the same reason: an effect would leave the incoming project showing the\n * bar of the one just left.\n */\n const rereadShown = useCallback(\n (key: string | undefined) => {\n setShownState(persistedShownFilters(key, modes, persistenceStorage));\n },\n [modes, persistenceStorage],\n );\n\n /**\n * Whether the bar is somewhere Reset would move it from: an optional\n * filter added, or a default one removed. Order alone is not a difference:\n * the bar draws the filters in the order they joined it, and the same set\n * in another order is not worth a Reset.\n */\n const differsFromDeclaration =\n shown.length !== declared.length ||\n declared.some((key) => !shown.includes(key));\n\n return { shown, setShown, resetShown, rereadShown, differsFromDeclaration };\n};\n"],"mappings":";;;AA8BA,MAAM,WAAW,CAAC;;;;;;;;;;;AAYlB,MAAa,gCACX,YACG;CACH,MAAM,EAAE,YAAY,YAAY,uBAAuB;CACvD,MAAM,QAAQ,YAAY,SAAS;CAEnC,MAAM,CAAC,OAAO,iBAAiB,eAC7B,sBAAsB,YAAY,OAAO,kBAAkB,CAC7D;CAEA,MAAM,WAAW,cAAc,qBAAqB,KAAK,GAAG,CAAC,KAAK,CAAC;CAwDnE,OAAO;EAAE;EAAO,UAtDC,aACd,MAAgB,QAAiB;GAChC,cAAc,IAAI;GAClB,IAAI,OAAO,YACT,eACE,YACA,oBACA,uBAAuB,MAAM,KAAK,GAClC,kBACF;EAEJ,GACA;GAAC;GAAY;GAAO;EAAkB,CA0CjB;EAAG,YAnCP,kBAAkB;GACnC,cAAc,QAAQ;GACtB,IAAI,YACF,eACE,YACA,oBACA,KAAA,GACA,kBACF;EAEJ,GAAG;GAAC;GAAU;GAAY;EAAkB,CAyBT;EAAG,aAjBlB,aACjB,QAA4B;GAC3B,cAAc,sBAAsB,KAAK,OAAO,kBAAkB,CAAC;EACrE,GACA,CAAC,OAAO,kBAAkB,CAaoB;EAAG,wBAHjD,MAAM,WAAW,SAAS,UAC1B,SAAS,MAAM,QAAQ,CAAC,MAAM,SAAS,GAAG,CAAC;CAE6B;AAC5E"}
@@ -0,0 +1,58 @@
1
+ import { type RefObject } from "react";
2
+ import type { DataTableKeyboard } from "./dataTableTypes.ts";
3
+ export interface UseDataTableKeyboardOptions<T> {
4
+ /**
5
+ * The table's `keyboard` prop. Off when absent or `false`.
6
+ */
7
+ keyboard: boolean | DataTableKeyboard<T> | undefined;
8
+ /**
9
+ * The table's root, where the rows are found in the order they are drawn
10
+ * (groups and folded groups included).
11
+ */
12
+ root: RefObject<HTMLElement | null>;
13
+ data: T[];
14
+ /**
15
+ * One key per row of `data`, index for index.
16
+ */
17
+ rowKeys: string[];
18
+ /**
19
+ * The table's `onRowClick`, what Enter calls.
20
+ */
21
+ onRowClick?: (item: T) => void;
22
+ /**
23
+ * Whether the rows have checkboxes, which X ticks.
24
+ */
25
+ canSelect: boolean;
26
+ toggleRow: (item: T) => void;
27
+ }
28
+ export interface DataTableKeyHint {
29
+ /**
30
+ * The keys, as the hint draws them.
31
+ */
32
+ keys: string[];
33
+ /**
34
+ * What they do.
35
+ */
36
+ label: string;
37
+ }
38
+ /**
39
+ * The keyboard row focus of a `DataTable` (its `keyboard` prop): the focused
40
+ * row's key, the setter a row click uses, and the hints the footer lists.
41
+ *
42
+ * The keys listen on the document, since a list page is read without a
43
+ * focused element: the reader opens the page and presses J.
44
+ */
45
+ export declare const useDataTableKeyboard: <T>(options: UseDataTableKeyboardOptions<T>) => {
46
+ enabled: boolean;
47
+ focusedKey: string | undefined;
48
+ focusedItem: T | undefined;
49
+ /**
50
+ * Moves the focus to a row, as a click on it does.
51
+ */
52
+ focusRow: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
53
+ /**
54
+ * The hints the footer lists, or `undefined` when they are off.
55
+ */
56
+ hints: DataTableKeyHint[] | undefined;
57
+ };
58
+ //# sourceMappingURL=useDataTableKeyboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataTableKeyboard.d.ts","sourceRoot":"","sources":["../../src/table/useDataTableKeyboard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAwC,MAAM,OAAO,CAAC;AAE7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,WAAW,2BAA2B,CAAC,CAAC;IAC5C;;OAEG;IACH,QAAQ,EAAE,OAAO,GAAG,iBAAiB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACrD;;;OAGG;IACH,IAAI,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACpC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC/B;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IACf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,WAC3B,2BAA2B,CAAC,CAAC,CAAC;;;;IA4HrC;;OAEG;;IAEH;;OAEG;;CAGN,CAAC"}
@@ -0,0 +1,157 @@
1
+ import { useI18n } from "alepha/react/i18n";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
+ // src/table/useDataTableKeyboard.ts
4
+ /**
5
+ * The keyboard row focus of a `DataTable` (its `keyboard` prop): the focused
6
+ * row's key, the setter a row click uses, and the hints the footer lists.
7
+ *
8
+ * The keys listen on the document, since a list page is read without a
9
+ * focused element: the reader opens the page and presses J.
10
+ */
11
+ const useDataTableKeyboard = (options) => {
12
+ const { tr } = useI18n();
13
+ const enabled = Boolean(options.keyboard);
14
+ const config = typeof options.keyboard === "object" ? options.keyboard : {};
15
+ const [focused, setFocused] = useState(void 0);
16
+ const index = focused === void 0 ? -1 : options.rowKeys.indexOf(focused);
17
+ const focusedKey = enabled && index >= 0 ? focused : void 0;
18
+ const focusedItem = index >= 0 ? options.data[index] : void 0;
19
+ const latest = useRef({
20
+ options,
21
+ config,
22
+ focusedKey,
23
+ focusedItem
24
+ });
25
+ latest.current = {
26
+ options,
27
+ config,
28
+ focusedKey,
29
+ focusedItem
30
+ };
31
+ useEffect(() => {
32
+ if (!enabled) return;
33
+ const onKeyDown = (event) => {
34
+ if (event.defaultPrevented) return;
35
+ if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return;
36
+ if (isTypingTarget(event.target)) return;
37
+ const { options, config, focusedKey, focusedItem } = latest.current;
38
+ const key = event.key.length === 1 ? event.key.toLowerCase() : event.key;
39
+ const move = (delta) => {
40
+ const keys = drawnRowKeys(options.root.current);
41
+ if (keys.length === 0) return;
42
+ const at = focusedKey === void 0 ? -1 : keys.indexOf(focusedKey);
43
+ const next = at < 0 ? 0 : Math.min(keys.length - 1, Math.max(0, at + delta));
44
+ event.preventDefault();
45
+ setFocused(keys[next]);
46
+ };
47
+ if (key === "j" || key === "ArrowDown") return move(1);
48
+ if (key === "k" || key === "ArrowUp") return move(-1);
49
+ if (focusedItem === void 0 || focusedKey === void 0) return;
50
+ if (key === "Enter") {
51
+ if (isControl(event.target)) return;
52
+ if (options.onRowClick) {
53
+ event.preventDefault();
54
+ options.onRowClick(focusedItem);
55
+ return;
56
+ }
57
+ const link = rowElement(options.root.current, focusedKey)?.querySelector("a[href]");
58
+ if (link) {
59
+ event.preventDefault();
60
+ link.click();
61
+ }
62
+ return;
63
+ }
64
+ if (key === "x") {
65
+ if (!options.canSelect) return;
66
+ event.preventDefault();
67
+ options.toggleRow(focusedItem);
68
+ return;
69
+ }
70
+ const binding = config.keys?.find((candidate) => candidate.key.toLowerCase() === key.toLowerCase());
71
+ if (binding) {
72
+ event.preventDefault();
73
+ binding.onKey(focusedItem);
74
+ }
75
+ };
76
+ document.addEventListener("keydown", onKeyDown);
77
+ return () => document.removeEventListener("keydown", onKeyDown);
78
+ }, [enabled]);
79
+ useEffect(() => {
80
+ if (focusedKey === void 0) return;
81
+ rowElement(options.root.current, focusedKey)?.scrollIntoView?.({ block: "nearest" });
82
+ }, [focusedKey, options.root]);
83
+ const reported = useRef(void 0);
84
+ useEffect(() => {
85
+ if (reported.current === focusedKey) return;
86
+ reported.current = focusedKey;
87
+ latest.current.config.onFocusChange?.(latest.current.focusedItem);
88
+ }, [focusedKey]);
89
+ const bindings = config.keys;
90
+ const canSelect = options.canSelect;
91
+ const hints = useMemo(() => {
92
+ const list = [{
93
+ keys: ["J", "K"],
94
+ label: String(tr("dataTable.keys.move", { default: "Move" }))
95
+ }, {
96
+ keys: ["Enter"],
97
+ label: String(tr("dataTable.keys.open", { default: "Open" }))
98
+ }];
99
+ if (canSelect) list.push({
100
+ keys: ["X"],
101
+ label: String(tr("dataTable.keys.select", { default: "Select" }))
102
+ });
103
+ for (const binding of bindings ?? []) list.push({
104
+ keys: [hintKey(binding.key)],
105
+ label: binding.label
106
+ });
107
+ return list;
108
+ }, [
109
+ bindings,
110
+ canSelect,
111
+ tr
112
+ ]);
113
+ return {
114
+ enabled,
115
+ focusedKey,
116
+ focusedItem,
117
+ /**
118
+ * Moves the focus to a row, as a click on it does.
119
+ */
120
+ focusRow: setFocused,
121
+ /**
122
+ * The hints the footer lists, or `undefined` when they are off.
123
+ */
124
+ hints: enabled && config.hints !== false ? hints : void 0
125
+ };
126
+ };
127
+ /**
128
+ * The key as a hint draws it: a letter in capitals, a named key as named.
129
+ */
130
+ const hintKey = (key) => key.length === 1 ? key.toUpperCase() : key;
131
+ /**
132
+ * The keys of the rows on screen, in the order they are drawn, without the
133
+ * rows an optimistic remove is taking off.
134
+ */
135
+ const drawnRowKeys = (root) => root ? Array.from(root.querySelectorAll("tbody tr[data-row-key]:not([data-leaving])")).map((row) => row.dataset.rowKey ?? "") : [];
136
+ const rowElement = (root, key) => root ? Array.from(root.querySelectorAll("tbody tr[data-row-key]")).find((row) => row.dataset.rowKey === key) ?? null : null;
137
+ /**
138
+ * Whether a key press belongs to what has the focus: a field being typed
139
+ * in, or an open menu, listbox or dialog moving its own selection.
140
+ */
141
+ const isTypingTarget = (target) => {
142
+ if (!(target instanceof HTMLElement)) return false;
143
+ if ([
144
+ "INPUT",
145
+ "TEXTAREA",
146
+ "SELECT"
147
+ ].includes(target.tagName)) return true;
148
+ if (target.isContentEditable) return true;
149
+ return target.closest("[contenteditable=\"\"], [contenteditable=\"true\"], [role=\"menu\"], [role=\"listbox\"], [role=\"dialog\"], [role=\"alertdialog\"], [role=\"combobox\"]") !== null;
150
+ };
151
+ /**
152
+ * Whether the target is a control Enter activates by itself.
153
+ */
154
+ const isControl = (target) => target instanceof HTMLElement && target.closest("button, a[href], [role=\"button\"]") !== null;
155
+ export { useDataTableKeyboard };
156
+
157
+ //# sourceMappingURL=useDataTableKeyboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataTableKeyboard.js","names":[],"sources":["../../src/table/useDataTableKeyboard.ts"],"sourcesContent":["import { useI18n } from \"alepha/react/i18n\";\nimport { type RefObject, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport type { DataTableKeyboard } from \"./dataTableTypes.ts\";\n\nexport interface UseDataTableKeyboardOptions<T> {\n /**\n * The table's `keyboard` prop. Off when absent or `false`.\n */\n keyboard: boolean | DataTableKeyboard<T> | undefined;\n /**\n * The table's root, where the rows are found in the order they are drawn\n * (groups and folded groups included).\n */\n root: RefObject<HTMLElement | null>;\n data: T[];\n /**\n * One key per row of `data`, index for index.\n */\n rowKeys: string[];\n /**\n * The table's `onRowClick`, what Enter calls.\n */\n onRowClick?: (item: T) => void;\n /**\n * Whether the rows have checkboxes, which X ticks.\n */\n canSelect: boolean;\n toggleRow: (item: T) => void;\n}\n\nexport interface DataTableKeyHint {\n /**\n * The keys, as the hint draws them.\n */\n keys: string[];\n /**\n * What they do.\n */\n label: string;\n}\n\n/**\n * The keyboard row focus of a `DataTable` (its `keyboard` prop): the focused\n * row's key, the setter a row click uses, and the hints the footer lists.\n *\n * The keys listen on the document, since a list page is read without a\n * focused element: the reader opens the page and presses J.\n */\nexport const useDataTableKeyboard = <T>(\n options: UseDataTableKeyboardOptions<T>,\n) => {\n const { tr } = useI18n();\n const enabled = Boolean(options.keyboard);\n const config: DataTableKeyboard<T> =\n typeof options.keyboard === \"object\" ? options.keyboard : {};\n const [focused, setFocused] = useState<string | undefined>(undefined);\n\n // A key whose row went away (a new page, a filter, a delete) is no focus.\n const index = focused === undefined ? -1 : options.rowKeys.indexOf(focused);\n const focusedKey = enabled && index >= 0 ? focused : undefined;\n const focusedItem = index >= 0 ? options.data[index] : undefined;\n\n // Everything the listener reads, current at every key press without\n // subscribing again on each render.\n const latest = useRef({ options, config, focusedKey, focusedItem });\n latest.current = { options, config, focusedKey, focusedItem };\n\n useEffect(() => {\n if (!enabled) return;\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.defaultPrevented) return;\n if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) {\n return;\n }\n if (isTypingTarget(event.target)) return;\n const { options, config, focusedKey, focusedItem } = latest.current;\n const key = event.key.length === 1 ? event.key.toLowerCase() : event.key;\n\n const move = (delta: 1 | -1) => {\n const keys = drawnRowKeys(options.root.current);\n if (keys.length === 0) return;\n const at = focusedKey === undefined ? -1 : keys.indexOf(focusedKey);\n const next =\n at < 0 ? 0 : Math.min(keys.length - 1, Math.max(0, at + delta));\n event.preventDefault();\n setFocused(keys[next]);\n };\n\n if (key === \"j\" || key === \"ArrowDown\") return move(1);\n if (key === \"k\" || key === \"ArrowUp\") return move(-1);\n if (focusedItem === undefined || focusedKey === undefined) return;\n\n if (key === \"Enter\") {\n // Enter on a focused button or link is that control's own.\n if (isControl(event.target)) return;\n if (options.onRowClick) {\n event.preventDefault();\n options.onRowClick(focusedItem);\n return;\n }\n const link = rowElement(\n options.root.current,\n focusedKey,\n )?.querySelector<HTMLElement>(\"a[href]\");\n if (link) {\n event.preventDefault();\n link.click();\n }\n return;\n }\n if (key === \"x\") {\n if (!options.canSelect) return;\n event.preventDefault();\n options.toggleRow(focusedItem);\n return;\n }\n const binding = config.keys?.find(\n (candidate) => candidate.key.toLowerCase() === key.toLowerCase(),\n );\n if (binding) {\n event.preventDefault();\n binding.onKey(focusedItem);\n }\n };\n document.addEventListener(\"keydown\", onKeyDown);\n return () => document.removeEventListener(\"keydown\", onKeyDown);\n }, [enabled]);\n\n // The focused row stays on screen as it moves.\n useEffect(() => {\n if (focusedKey === undefined) return;\n rowElement(options.root.current, focusedKey)?.scrollIntoView?.({\n block: \"nearest\",\n });\n }, [focusedKey, options.root]);\n\n // Reported on a change only, not on mount.\n const reported = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (reported.current === focusedKey) return;\n reported.current = focusedKey;\n latest.current.config.onFocusChange?.(latest.current.focusedItem);\n }, [focusedKey]);\n\n const bindings = config.keys;\n const canSelect = options.canSelect;\n const hints = useMemo((): DataTableKeyHint[] => {\n const list: DataTableKeyHint[] = [\n {\n keys: [\"J\", \"K\"],\n label: String(tr(\"dataTable.keys.move\", { default: \"Move\" })),\n },\n {\n keys: [\"Enter\"],\n label: String(tr(\"dataTable.keys.open\", { default: \"Open\" })),\n },\n ];\n if (canSelect) {\n list.push({\n keys: [\"X\"],\n label: String(tr(\"dataTable.keys.select\", { default: \"Select\" })),\n });\n }\n for (const binding of bindings ?? []) {\n list.push({ keys: [hintKey(binding.key)], label: binding.label });\n }\n return list;\n }, [bindings, canSelect, tr]);\n\n return {\n enabled,\n focusedKey,\n focusedItem,\n /**\n * Moves the focus to a row, as a click on it does.\n */\n focusRow: setFocused,\n /**\n * The hints the footer lists, or `undefined` when they are off.\n */\n hints: enabled && config.hints !== false ? hints : undefined,\n };\n};\n\n/**\n * The key as a hint draws it: a letter in capitals, a named key as named.\n */\nconst hintKey = (key: string) => (key.length === 1 ? key.toUpperCase() : key);\n\n/**\n * The keys of the rows on screen, in the order they are drawn, without the\n * rows an optimistic remove is taking off.\n */\nconst drawnRowKeys = (root: HTMLElement | null): string[] =>\n root\n ? Array.from(\n root.querySelectorAll<HTMLElement>(\n \"tbody tr[data-row-key]:not([data-leaving])\",\n ),\n ).map((row) => row.dataset.rowKey ?? \"\")\n : [];\n\nconst rowElement = (root: HTMLElement | null, key: string) =>\n root\n ? (Array.from(\n root.querySelectorAll<HTMLElement>(\"tbody tr[data-row-key]\"),\n ).find((row) => row.dataset.rowKey === key) ?? null)\n : null;\n\n/**\n * Whether a key press belongs to what has the focus: a field being typed\n * in, or an open menu, listbox or dialog moving its own selection.\n */\nconst isTypingTarget = (target: EventTarget | null): boolean => {\n if (!(target instanceof HTMLElement)) return false;\n if ([\"INPUT\", \"TEXTAREA\", \"SELECT\"].includes(target.tagName)) return true;\n if (target.isContentEditable) return true;\n return (\n target.closest(\n '[contenteditable=\"\"], [contenteditable=\"true\"], [role=\"menu\"], [role=\"listbox\"], [role=\"dialog\"], [role=\"alertdialog\"], [role=\"combobox\"]',\n ) !== null\n );\n};\n\n/**\n * Whether the target is a control Enter activates by itself.\n */\nconst isControl = (target: EventTarget | null): boolean =>\n target instanceof HTMLElement &&\n target.closest('button, a[href], [role=\"button\"]') !== null;\n"],"mappings":";;;;;;;;;;AAiDA,MAAa,wBACX,YACG;CACH,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,UAAU,QAAQ,QAAQ,QAAQ;CACxC,MAAM,SACJ,OAAO,QAAQ,aAAa,WAAW,QAAQ,WAAW,CAAC;CAC7D,MAAM,CAAC,SAAS,cAAc,SAA6B,KAAA,CAAS;CAGpE,MAAM,QAAQ,YAAY,KAAA,IAAY,KAAK,QAAQ,QAAQ,QAAQ,OAAO;CAC1E,MAAM,aAAa,WAAW,SAAS,IAAI,UAAU,KAAA;CACrD,MAAM,cAAc,SAAS,IAAI,QAAQ,KAAK,SAAS,KAAA;CAIvD,MAAM,SAAS,OAAO;EAAE;EAAS;EAAQ;EAAY;CAAY,CAAC;CAClE,OAAO,UAAU;EAAE;EAAS;EAAQ;EAAY;CAAY;CAE5D,gBAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,aAAa,UAAyB;GAC1C,IAAI,MAAM,kBAAkB;GAC5B,IAAI,MAAM,WAAW,MAAM,WAAW,MAAM,UAAU,MAAM,UAC1D;GAEF,IAAI,eAAe,MAAM,MAAM,GAAG;GAClC,MAAM,EAAE,SAAS,QAAQ,YAAY,gBAAgB,OAAO;GAC5D,MAAM,MAAM,MAAM,IAAI,WAAW,IAAI,MAAM,IAAI,YAAY,IAAI,MAAM;GAErE,MAAM,QAAQ,UAAkB;IAC9B,MAAM,OAAO,aAAa,QAAQ,KAAK,OAAO;IAC9C,IAAI,KAAK,WAAW,GAAG;IACvB,MAAM,KAAK,eAAe,KAAA,IAAY,KAAK,KAAK,QAA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AAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,aAAa,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,eAAe,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;CACpD;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,WAC1B,0BAA0B,CAAC,CAAC,CAAC;;;;;;;CAuLvC,CAAC"}
@@ -1,6 +1,6 @@
1
+ import { useCallback, useEffect, useRef } from "react";
1
2
  import { writePersisted } from "./dataTablePersistence.js";
2
3
  import { cleanFilterValues, shareFiltersUrl } from "./queryFilters.js";
3
- import { useCallback, useEffect, useRef } from "react";
4
4
  // src/table/useDataTableRefresh.ts
5
5
  /**
6
6
  * What makes `DataTable` fetch again, and the filter actions that sit
@@ -110,7 +110,7 @@ const useDataTableRefresh = (options) => {
110
110
  useEffect(() => {
111
111
  if (!filtersKey || !form || !props.filters) return;
112
112
  const writeFilters = () => {
113
- writePersisted(filtersKey, "filters", cleanFilterValues(form.currentValues ?? {}));
113
+ writePersisted(filtersKey, "filters", cleanFilterValues(form.currentValues ?? {}), props.persistenceStorage);
114
114
  };
115
115
  const unsubs = [alepha.events.on("form:changed", (event) => {
116
116
  if (event.id !== form.id) return;
@@ -126,7 +126,8 @@ const useDataTableRefresh = (options) => {
126
126
  alepha,
127
127
  form,
128
128
  props.filters,
129
- filtersKey
129
+ filtersKey,
130
+ props.persistenceStorage
130
131
  ]);
131
132
  useEffect(() => {
132
133
  if (!props.pollMs) return;