@alepha/ui 0.35.0 → 0.36.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 (264) hide show
  1. package/README.md +54 -1
  2. package/dist/account/AccountBrand.d.ts +10 -3
  3. package/dist/account/AccountBrand.d.ts.map +1 -1
  4. package/dist/account/AccountBrand.js +12 -6
  5. package/dist/account/AccountBrand.js.map +1 -1
  6. package/dist/account/AccountLayout.d.ts.map +1 -1
  7. package/dist/account/AccountLayout.js +1 -1
  8. package/dist/account/AccountLayout.js.map +1 -1
  9. package/dist/admin/AdminUserDetail.d.ts +3 -3
  10. package/dist/admin/AdminUserDetail.js +3 -3
  11. package/dist/admin/AdminUserDetail.js.map +1 -1
  12. package/dist/ai/AiChat.d.ts +36 -6
  13. package/dist/ai/AiChat.d.ts.map +1 -1
  14. package/dist/ai/AiChat.js +101 -63
  15. package/dist/ai/AiChat.js.map +1 -1
  16. package/dist/ai/AiChatComposer.d.ts +22 -0
  17. package/dist/ai/AiChatComposer.d.ts.map +1 -0
  18. package/dist/ai/AiChatComposer.js +75 -0
  19. package/dist/ai/AiChatComposer.js.map +1 -0
  20. package/dist/ai/AiChatConfirmCard.d.ts +5 -2
  21. package/dist/ai/AiChatConfirmCard.d.ts.map +1 -1
  22. package/dist/ai/AiChatConfirmCard.js +7 -6
  23. package/dist/ai/AiChatConfirmCard.js.map +1 -1
  24. package/dist/ai/AiChatConfirmFields.d.ts +9 -0
  25. package/dist/ai/AiChatConfirmFields.d.ts.map +1 -0
  26. package/dist/ai/AiChatConfirmFields.js +45 -0
  27. package/dist/ai/AiChatConfirmFields.js.map +1 -0
  28. package/dist/ai/AiChatEmpty.d.ts +26 -0
  29. package/dist/ai/AiChatEmpty.d.ts.map +1 -0
  30. package/dist/ai/AiChatEmpty.js +47 -0
  31. package/dist/ai/AiChatEmpty.js.map +1 -0
  32. package/dist/ai/AiChatHistory.d.ts +3 -2
  33. package/dist/ai/AiChatHistory.d.ts.map +1 -1
  34. package/dist/ai/AiChatHistory.js +51 -22
  35. package/dist/ai/AiChatHistory.js.map +1 -1
  36. package/dist/ai/AiChatMessage.d.ts +14 -0
  37. package/dist/ai/AiChatMessage.d.ts.map +1 -1
  38. package/dist/ai/AiChatMessage.js +20 -12
  39. package/dist/ai/AiChatMessage.js.map +1 -1
  40. package/dist/ai/index.d.ts +3 -0
  41. package/dist/ai/index.d.ts.map +1 -1
  42. package/dist/ai/index.js +4 -1
  43. package/dist/ai/useAiChat.d.ts +4 -0
  44. package/dist/ai/useAiChat.d.ts.map +1 -1
  45. package/dist/ai/useAiChat.js +15 -1
  46. package/dist/ai/useAiChat.js.map +1 -1
  47. package/dist/core/Sidebar.js +2 -2
  48. package/dist/core/Sidebar.js.map +1 -1
  49. package/dist/core/index.d.ts +1 -0
  50. package/dist/core/index.d.ts.map +1 -1
  51. package/dist/core/index.js +2 -1
  52. package/dist/core/useToast.d.ts +22 -1
  53. package/dist/core/useToast.d.ts.map +1 -1
  54. package/dist/core/useToast.js +4 -1
  55. package/dist/core/useToast.js.map +1 -1
  56. package/dist/core/useUndoable.d.ts +93 -0
  57. package/dist/core/useUndoable.d.ts.map +1 -0
  58. package/dist/core/useUndoable.js +172 -0
  59. package/dist/core/useUndoable.js.map +1 -0
  60. package/dist/i18n/fr/uiFr.d.ts.map +1 -1
  61. package/dist/i18n/fr/uiFr.js +50 -1
  62. package/dist/i18n/fr/uiFr.js.map +1 -1
  63. package/dist/markdown/MarkdownView.d.ts +15 -0
  64. package/dist/markdown/MarkdownView.d.ts.map +1 -1
  65. package/dist/markdown/MarkdownView.js +4 -1
  66. package/dist/markdown/MarkdownView.js.map +1 -1
  67. package/dist/organizations/useInviteOrganizationMember.d.ts +2 -2
  68. package/dist/organizations/useInviteOrganizationMember.js.map +1 -1
  69. package/dist/shell/AppShellSidebarNavItem.d.ts.map +1 -1
  70. package/dist/shell/AppShellSidebarNavItem.js +25 -2
  71. package/dist/shell/AppShellSidebarNavItem.js.map +1 -1
  72. package/dist/shell/PlateTabBar.d.ts.map +1 -1
  73. package/dist/shell/PlateTabBar.js +2 -2
  74. package/dist/shell/PlateTabBar.js.map +1 -1
  75. package/dist/shell/SidebarBackHeader.d.ts +35 -0
  76. package/dist/shell/SidebarBackHeader.d.ts.map +1 -0
  77. package/dist/shell/SidebarBackHeader.js +34 -0
  78. package/dist/shell/SidebarBackHeader.js.map +1 -0
  79. package/dist/shell/appShellNav.d.ts +30 -0
  80. package/dist/shell/appShellNav.d.ts.map +1 -1
  81. package/dist/shell/appShellNav.js.map +1 -1
  82. package/dist/shell/index.d.ts +2 -1
  83. package/dist/shell/index.d.ts.map +1 -1
  84. package/dist/shell/index.js +2 -1
  85. package/dist/swagger/$uiSwagger.d.ts +75 -0
  86. package/dist/swagger/$uiSwagger.d.ts.map +1 -0
  87. package/dist/swagger/$uiSwagger.js +51 -0
  88. package/dist/swagger/$uiSwagger.js.map +1 -0
  89. package/dist/swagger/OpenApiSpec.d.ts +113 -0
  90. package/dist/swagger/OpenApiSpec.d.ts.map +1 -0
  91. package/dist/swagger/OpenApiSpec.js +186 -0
  92. package/dist/swagger/OpenApiSpec.js.map +1 -0
  93. package/dist/swagger/SwaggerAccessBadge.d.ts +16 -0
  94. package/dist/swagger/SwaggerAccessBadge.d.ts.map +1 -0
  95. package/dist/swagger/SwaggerAccessBadge.js +40 -0
  96. package/dist/swagger/SwaggerAccessBadge.js.map +1 -0
  97. package/dist/swagger/SwaggerAlephaMeta.d.ts +11 -0
  98. package/dist/swagger/SwaggerAlephaMeta.d.ts.map +1 -0
  99. package/dist/swagger/SwaggerAlephaMeta.js +103 -0
  100. package/dist/swagger/SwaggerAlephaMeta.js.map +1 -0
  101. package/dist/swagger/SwaggerCredentials.d.ts +11 -0
  102. package/dist/swagger/SwaggerCredentials.d.ts.map +1 -0
  103. package/dist/swagger/SwaggerCredentials.js +35 -0
  104. package/dist/swagger/SwaggerCredentials.js.map +1 -0
  105. package/dist/swagger/SwaggerExplorer.d.ts +31 -0
  106. package/dist/swagger/SwaggerExplorer.d.ts.map +1 -0
  107. package/dist/swagger/SwaggerExplorer.js +156 -0
  108. package/dist/swagger/SwaggerExplorer.js.map +1 -0
  109. package/dist/swagger/SwaggerMethodBadge.d.ts +10 -0
  110. package/dist/swagger/SwaggerMethodBadge.d.ts.map +1 -0
  111. package/dist/swagger/SwaggerMethodBadge.js +27 -0
  112. package/dist/swagger/SwaggerMethodBadge.js.map +1 -0
  113. package/dist/swagger/SwaggerNav.d.ts +16 -0
  114. package/dist/swagger/SwaggerNav.d.ts.map +1 -0
  115. package/dist/swagger/SwaggerNav.js +63 -0
  116. package/dist/swagger/SwaggerNav.js.map +1 -0
  117. package/dist/swagger/SwaggerOperationView.d.ts +22 -0
  118. package/dist/swagger/SwaggerOperationView.d.ts.map +1 -0
  119. package/dist/swagger/SwaggerOperationView.js +89 -0
  120. package/dist/swagger/SwaggerOperationView.js.map +1 -0
  121. package/dist/swagger/SwaggerParameters.d.ts +11 -0
  122. package/dist/swagger/SwaggerParameters.d.ts.map +1 -0
  123. package/dist/swagger/SwaggerParameters.js +80 -0
  124. package/dist/swagger/SwaggerParameters.js.map +1 -0
  125. package/dist/swagger/SwaggerRequestBuilder.d.ts +83 -0
  126. package/dist/swagger/SwaggerRequestBuilder.d.ts.map +1 -0
  127. package/dist/swagger/SwaggerRequestBuilder.js +231 -0
  128. package/dist/swagger/SwaggerRequestBuilder.js.map +1 -0
  129. package/dist/swagger/SwaggerResponseView.d.ts +25 -0
  130. package/dist/swagger/SwaggerResponseView.d.ts.map +1 -0
  131. package/dist/swagger/SwaggerResponseView.js +94 -0
  132. package/dist/swagger/SwaggerResponseView.js.map +1 -0
  133. package/dist/swagger/SwaggerResponses.d.ts +12 -0
  134. package/dist/swagger/SwaggerResponses.d.ts.map +1 -0
  135. package/dist/swagger/SwaggerResponses.js +75 -0
  136. package/dist/swagger/SwaggerResponses.js.map +1 -0
  137. package/dist/swagger/SwaggerSchemaView.d.ts +19 -0
  138. package/dist/swagger/SwaggerSchemaView.d.ts.map +1 -0
  139. package/dist/swagger/SwaggerSchemaView.js +98 -0
  140. package/dist/swagger/SwaggerSchemaView.js.map +1 -0
  141. package/dist/swagger/SwaggerSection.d.ts +14 -0
  142. package/dist/swagger/SwaggerSection.d.ts.map +1 -0
  143. package/dist/swagger/SwaggerSection.js +23 -0
  144. package/dist/swagger/SwaggerSection.js.map +1 -0
  145. package/dist/swagger/SwaggerTryIt.d.ts +31 -0
  146. package/dist/swagger/SwaggerTryIt.d.ts.map +1 -0
  147. package/dist/swagger/SwaggerTryIt.js +68 -0
  148. package/dist/swagger/SwaggerTryIt.js.map +1 -0
  149. package/dist/swagger/SwaggerTryItForm.d.ts +20 -0
  150. package/dist/swagger/SwaggerTryItForm.d.ts.map +1 -0
  151. package/dist/swagger/SwaggerTryItForm.js +52 -0
  152. package/dist/swagger/SwaggerTryItForm.js.map +1 -0
  153. package/dist/swagger/index.d.ts +29 -0
  154. package/dist/swagger/index.d.ts.map +1 -0
  155. package/dist/swagger/index.js +18 -0
  156. package/dist/swagger/useSwaggerAccess.d.ts +24 -0
  157. package/dist/swagger/useSwaggerAccess.d.ts.map +1 -0
  158. package/dist/swagger/useSwaggerAccess.js +33 -0
  159. package/dist/swagger/useSwaggerAccess.js.map +1 -0
  160. package/dist/table/DataTable.d.ts.map +1 -1
  161. package/dist/table/DataTable.js +50 -13
  162. package/dist/table/DataTable.js.map +1 -1
  163. package/dist/table/DataTableBody.d.ts +18 -1
  164. package/dist/table/DataTableBody.d.ts.map +1 -1
  165. package/dist/table/DataTableBody.js +83 -58
  166. package/dist/table/DataTableBody.js.map +1 -1
  167. package/dist/table/DataTableRowActionsInline.d.ts +17 -0
  168. package/dist/table/DataTableRowActionsInline.d.ts.map +1 -0
  169. package/dist/table/DataTableRowActionsInline.js +45 -0
  170. package/dist/table/DataTableRowActionsInline.js.map +1 -0
  171. package/dist/table/PermissionMatrix.d.ts +4 -4
  172. package/dist/table/PermissionMatrix.js +2 -2
  173. package/dist/table/PermissionMatrix.js.map +1 -1
  174. package/dist/table/dataTableBaseProps.d.ts +31 -0
  175. package/dist/table/dataTableBaseProps.d.ts.map +1 -1
  176. package/dist/table/dataTableTypes.d.ts +16 -2
  177. package/dist/table/dataTableTypes.d.ts.map +1 -1
  178. package/dist/table/useDataTableData.d.ts +3 -0
  179. package/dist/table/useDataTableData.d.ts.map +1 -1
  180. package/dist/table/useDataTableData.js +9 -2
  181. package/dist/table/useDataTableData.js.map +1 -1
  182. package/dist/table/useDataTableRefresh.d.ts +1 -0
  183. package/dist/table/useDataTableRefresh.d.ts.map +1 -1
  184. package/dist/table/useDataTableRefresh.js +13 -1
  185. package/dist/table/useDataTableRefresh.js.map +1 -1
  186. package/dist/table/useOptimisticRows.d.ts +64 -0
  187. package/dist/table/useOptimisticRows.d.ts.map +1 -0
  188. package/dist/table/useOptimisticRows.js +185 -0
  189. package/dist/table/useOptimisticRows.js.map +1 -0
  190. package/dist/table/useRowMotion.d.ts +27 -0
  191. package/dist/table/useRowMotion.d.ts.map +1 -0
  192. package/dist/table/useRowMotion.js +112 -0
  193. package/dist/table/useRowMotion.js.map +1 -0
  194. package/docs/packages-alepha-ui-core.md +1 -0
  195. package/docs/packages-alepha-ui-overview.md +53 -1
  196. package/docs/packages-alepha-ui-swagger.md +35 -0
  197. package/package.json +11 -3
  198. package/src/account/AccountBrand.tsx +25 -6
  199. package/src/account/AccountLayout.tsx +5 -1
  200. package/src/admin/AdminUserDetail.tsx +3 -3
  201. package/src/admin/__tests__/AdminUserDetail.spec.ts +2 -2
  202. package/src/ai/AiChat.tsx +160 -82
  203. package/src/ai/AiChatComposer.tsx +117 -0
  204. package/src/ai/AiChatConfirmCard.tsx +7 -5
  205. package/src/ai/AiChatConfirmFields.tsx +65 -0
  206. package/src/ai/AiChatEmpty.tsx +73 -0
  207. package/src/ai/AiChatHistory.tsx +64 -28
  208. package/src/ai/AiChatMessage.tsx +41 -14
  209. package/src/ai/__tests__/AiChat.browser.spec.tsx +146 -5
  210. package/src/ai/index.ts +3 -0
  211. package/src/ai/useAiChat.ts +18 -0
  212. package/src/core/Sidebar.tsx +2 -2
  213. package/src/core/__tests__/useUndoable.browser.spec.tsx +201 -0
  214. package/src/core/index.ts +7 -0
  215. package/src/core/useToast.tsx +30 -2
  216. package/src/core/useUndoable.tsx +285 -0
  217. package/src/form/__tests__/ControlChoices.browser.spec.tsx +2 -1
  218. package/src/i18n/fr/uiFr.ts +52 -0
  219. package/src/markdown/MarkdownView.tsx +27 -9
  220. package/src/organizations/useInviteOrganizationMember.ts +2 -2
  221. package/src/shell/AppShellSidebarNavItem.tsx +51 -1
  222. package/src/shell/PlateTabBar.tsx +8 -2
  223. package/src/shell/SidebarBackHeader.tsx +58 -0
  224. package/src/shell/appShellNav.tsx +31 -0
  225. package/src/shell/index.ts +5 -1
  226. package/src/swagger/$uiSwagger.tsx +95 -0
  227. package/src/swagger/OpenApiSpec.ts +300 -0
  228. package/src/swagger/SwaggerAccessBadge.tsx +64 -0
  229. package/src/swagger/SwaggerAlephaMeta.tsx +141 -0
  230. package/src/swagger/SwaggerCredentials.tsx +44 -0
  231. package/src/swagger/SwaggerExplorer.tsx +208 -0
  232. package/src/swagger/SwaggerMethodBadge.tsx +32 -0
  233. package/src/swagger/SwaggerNav.tsx +92 -0
  234. package/src/swagger/SwaggerOperationView.tsx +102 -0
  235. package/src/swagger/SwaggerParameters.tsx +74 -0
  236. package/src/swagger/SwaggerRequestBuilder.ts +331 -0
  237. package/src/swagger/SwaggerResponseView.tsx +107 -0
  238. package/src/swagger/SwaggerResponses.tsx +83 -0
  239. package/src/swagger/SwaggerSchemaView.tsx +134 -0
  240. package/src/swagger/SwaggerSection.tsx +29 -0
  241. package/src/swagger/SwaggerTryIt.tsx +95 -0
  242. package/src/swagger/SwaggerTryItForm.tsx +87 -0
  243. package/src/swagger/__tests__/$uiSwagger.spec.ts +52 -0
  244. package/src/swagger/__tests__/OpenApiSpec.spec.ts +139 -0
  245. package/src/swagger/__tests__/SwaggerAccess.browser.spec.tsx +124 -0
  246. package/src/swagger/__tests__/SwaggerOperationView.browser.spec.tsx +194 -0
  247. package/src/swagger/__tests__/SwaggerRequestBuilder.spec.ts +250 -0
  248. package/src/swagger/index.ts +75 -0
  249. package/src/swagger/useSwaggerAccess.ts +59 -0
  250. package/src/table/DataTable.tsx +85 -34
  251. package/src/table/DataTableBody.tsx +51 -7
  252. package/src/table/DataTableRowActionsInline.tsx +80 -0
  253. package/src/table/PermissionMatrix.tsx +4 -4
  254. package/src/table/__tests__/DataTableEmptyState.browser.spec.tsx +1 -1
  255. package/src/table/__tests__/DataTableListMode.browser.spec.tsx +174 -0
  256. package/src/table/__tests__/DataTableOptimistic.browser.spec.tsx +173 -0
  257. package/src/table/__tests__/PermissionMatrix.browser.spec.tsx +2 -2
  258. package/src/table/__tests__/queryFilters.spec.ts +10 -12
  259. package/src/table/dataTableBaseProps.ts +31 -0
  260. package/src/table/dataTableTypes.ts +16 -2
  261. package/src/table/useDataTableData.ts +18 -2
  262. package/src/table/useDataTableRefresh.ts +26 -2
  263. package/src/table/useOptimisticRows.ts +265 -0
  264. package/src/table/useRowMotion.ts +152 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/swagger/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,WAAW,EACX,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,qBAAqB,EACrB,KAAK,mBAAmB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,KAAK,qBAAqB,EAC1B,mBAAmB,EACnB,KAAK,wBAAwB,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,GAC/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,aAAa,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { $uiSwagger } from "./$uiSwagger.js";
2
+ import { OpenApiSpec } from "./OpenApiSpec.js";
3
+ import { SwaggerAccessBadge } from "./SwaggerAccessBadge.js";
4
+ import { SwaggerAlephaMeta } from "./SwaggerAlephaMeta.js";
5
+ import { SwaggerCredentials } from "./SwaggerCredentials.js";
6
+ import { SwaggerExplorer } from "./SwaggerExplorer.js";
7
+ import { SwaggerMethodBadge } from "./SwaggerMethodBadge.js";
8
+ import { SwaggerNav } from "./SwaggerNav.js";
9
+ import { SwaggerRequestBuilder } from "./SwaggerRequestBuilder.js";
10
+ import { SwaggerResponseView } from "./SwaggerResponseView.js";
11
+ import { SwaggerTryIt } from "./SwaggerTryIt.js";
12
+ import { SwaggerTryItForm } from "./SwaggerTryItForm.js";
13
+ import { SwaggerOperationView } from "./SwaggerOperationView.js";
14
+ import { SwaggerParameters } from "./SwaggerParameters.js";
15
+ import { SwaggerResponses } from "./SwaggerResponses.js";
16
+ import { SwaggerSchemaView } from "./SwaggerSchemaView.js";
17
+ import { useSwaggerAccess } from "./useSwaggerAccess.js";
18
+ export { $uiSwagger, OpenApiSpec, SwaggerAccessBadge, SwaggerAlephaMeta, SwaggerCredentials, SwaggerExplorer, SwaggerMethodBadge, SwaggerNav, SwaggerOperationView, SwaggerParameters, SwaggerRequestBuilder, SwaggerResponseView, SwaggerResponses, SwaggerSchemaView, SwaggerTryIt, SwaggerTryItForm, useSwaggerAccess };
@@ -0,0 +1,24 @@
1
+ import type { OpenApiSpec, SwaggerEntry } from "./OpenApiSpec.ts";
2
+ /**
3
+ * Whether the viewer may call an operation:
4
+ *
5
+ * - `open`: no gate;
6
+ * - `anonymous`: gated, and nobody is signed in;
7
+ * - `allowed` / `denied`: gated, and the signed-in user's action registry
8
+ * (`/api/_links`, built per user) does or does not list it;
9
+ * - `unknown`: gated and signed in, with no registry to ask (the app does not
10
+ * use `alepha/server/links`, or the operation is not an `$action`).
11
+ */
12
+ export type SwaggerAccess = "open" | "anonymous" | "allowed" | "denied" | "unknown";
13
+ /**
14
+ * Answers {@link SwaggerAccess} for each operation, against the current user.
15
+ *
16
+ * Read from what the page already has, never a request per operation: the
17
+ * signed-in user is `currentUserAtom`, and what they may call is the action
18
+ * registry `LinkProvider` holds, the one `useAuth().has()` reads. The
19
+ * registry lists only the actions the user's permissions reach, so an action
20
+ * present in it is one they may call. A UI affordance, not a decision: the
21
+ * server's `$secure` still answers every request.
22
+ */
23
+ export declare const useSwaggerAccess: (spec: OpenApiSpec | undefined) => ((entry: SwaggerEntry) => SwaggerAccess);
24
+ //# sourceMappingURL=useSwaggerAccess.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSwaggerAccess.d.ts","sourceRoot":"","sources":["../../src/swagger/useSwaggerAccess.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAElE;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,WAAW,GACX,SAAS,GACT,QAAQ,GACR,SAAS,CAAC;AAEd;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,SACrB,WAAW,GAAG,SAAS,KAC5B,CAAC,CAAC,KAAK,EAAE,YAAY,KAAK,aAAa,CAsBzC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { currentUserAtom } from "alepha/security";
2
+ import { LinkProvider } from "alepha/server/links";
3
+ import { useCallback } from "react";
4
+ import { useAlepha, useStore } from "alepha/react";
5
+ // src/swagger/useSwaggerAccess.ts
6
+ /**
7
+ * Answers {@link SwaggerAccess} for each operation, against the current user.
8
+ *
9
+ * Read from what the page already has, never a request per operation: the
10
+ * signed-in user is `currentUserAtom`, and what they may call is the action
11
+ * registry `LinkProvider` holds, the one `useAuth().has()` reads. The
12
+ * registry lists only the actions the user's permissions reach, so an action
13
+ * present in it is one they may call. A UI affordance, not a decision: the
14
+ * server's `$secure` still answers every request.
15
+ */
16
+ const useSwaggerAccess = (spec) => {
17
+ const alepha = useAlepha();
18
+ const [user] = useStore(currentUserAtom);
19
+ return useCallback((entry) => {
20
+ if (!spec || !spec.isSecured(entry.operation)) return "open";
21
+ if (!user) return "anonymous";
22
+ const name = spec.metadata(entry.operation).action?.name;
23
+ if (!name || !alepha.has(LinkProvider)) return "unknown";
24
+ return alepha.inject(LinkProvider).can(name) ? "allowed" : "denied";
25
+ }, [
26
+ alepha,
27
+ spec,
28
+ user
29
+ ]);
30
+ };
31
+ export { useSwaggerAccess };
32
+
33
+ //# sourceMappingURL=useSwaggerAccess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSwaggerAccess.js","names":[],"sources":["../../src/swagger/useSwaggerAccess.ts"],"sourcesContent":["import { useAlepha, useStore } from \"alepha/react\";\nimport { currentUserAtom } from \"alepha/security\";\nimport { LinkProvider } from \"alepha/server/links\";\nimport { useCallback } from \"react\";\n\nimport type { OpenApiSpec, SwaggerEntry } from \"./OpenApiSpec.ts\";\n\n/**\n * Whether the viewer may call an operation:\n *\n * - `open`: no gate;\n * - `anonymous`: gated, and nobody is signed in;\n * - `allowed` / `denied`: gated, and the signed-in user's action registry\n * (`/api/_links`, built per user) does or does not list it;\n * - `unknown`: gated and signed in, with no registry to ask (the app does not\n * use `alepha/server/links`, or the operation is not an `$action`).\n */\nexport type SwaggerAccess =\n | \"open\"\n | \"anonymous\"\n | \"allowed\"\n | \"denied\"\n | \"unknown\";\n\n/**\n * Answers {@link SwaggerAccess} for each operation, against the current user.\n *\n * Read from what the page already has, never a request per operation: the\n * signed-in user is `currentUserAtom`, and what they may call is the action\n * registry `LinkProvider` holds, the one `useAuth().has()` reads. The\n * registry lists only the actions the user's permissions reach, so an action\n * present in it is one they may call. A UI affordance, not a decision: the\n * server's `$secure` still answers every request.\n */\nexport const useSwaggerAccess = (\n spec: OpenApiSpec | undefined,\n): ((entry: SwaggerEntry) => SwaggerAccess) => {\n const alepha = useAlepha();\n const [user] = useStore(currentUserAtom);\n\n return useCallback(\n (entry: SwaggerEntry): SwaggerAccess => {\n if (!spec || !spec.isSecured(entry.operation)) {\n return \"open\";\n }\n if (!user) {\n return \"anonymous\";\n }\n const name = spec.metadata(entry.operation).action?.name;\n // Injecting LinkProvider in an app without its module would register\n // that module after start, which the container refuses.\n if (!name || !alepha.has(LinkProvider)) {\n return \"unknown\";\n }\n return alepha.inject(LinkProvider).can(name) ? \"allowed\" : \"denied\";\n },\n [alepha, spec, user],\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAkCA,MAAa,oBACX,SAC6C;CAC7C,MAAM,SAAS,UAAU;CACzB,MAAM,CAAC,QAAQ,SAAS,eAAe;CAEvC,OAAO,aACJ,UAAuC;EACtC,IAAI,CAAC,QAAQ,CAAC,KAAK,UAAU,MAAM,SAAS,GAC1C,OAAO;EAET,IAAI,CAAC,MACH,OAAO;EAET,MAAM,OAAO,KAAK,SAAS,MAAM,SAAS,CAAC,CAAC,QAAQ;EAGpD,IAAI,CAAC,QAAQ,CAAC,OAAO,IAAI,YAAY,GACnC,OAAO;EAET,OAAO,OAAO,OAAO,YAAY,CAAC,CAAC,IAAI,IAAI,IAAI,YAAY;CAC7D,GACA;EAAC;EAAQ;EAAM;CAAI,CACrB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../src/table/DataTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAelE,OAAO,KAAK,EAEV,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EAIhB,MAAM,qBAAqB,CAAC;AAU7B,MAAM,MAAM,cAAc,CACxB,CAAC,EACD,CAAC,SAAS,qBAAqB,GAAG,uBAAuB,IACvD,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAErD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,GACpB,CAAC,EACD,KAAK,CAAC,CAAC,SAAS,qBAAqB,GAAG,uBAAuB,SAExD,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,sBAqjB5B,CAAC"}
1
+ {"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../src/table/DataTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAelE,OAAO,KAAK,EAEV,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EAIhB,MAAM,qBAAqB,CAAC;AAW7B,MAAM,MAAM,cAAc,CACxB,CAAC,EACD,CAAC,SAAS,qBAAqB,GAAG,uBAAuB,IACvD,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAErD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,GACpB,CAAC,EACD,KAAK,CAAC,CAAC,SAAS,qBAAqB,GAAG,uBAAuB,SAExD,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,sBAumB5B,CAAC"}
@@ -18,6 +18,7 @@ import { useDataTableFilterForm } from "./useDataTableFilterForm.js";
18
18
  import { useDataTableFilterVisibility } from "./useDataTableFilterVisibility.js";
19
19
  import { useDataTableRefresh } from "./useDataTableRefresh.js";
20
20
  import { useDataTableSummary } from "./useDataTableSummary.js";
21
+ import { useOptimisticRows } from "./useOptimisticRows.js";
21
22
  import { useTableSelection } from "./useTableSelection.js";
22
23
  import { useI18n } from "alepha/react/i18n";
23
24
  import { useCallback, useMemo, useRef, useState } from "react";
@@ -82,7 +83,7 @@ const DataTable = (props) => {
82
83
  definition: filterDefinition,
83
84
  filtersKey
84
85
  });
85
- const { page, setPage, sizeForm, sort, setSort, data, meta, rowFilters, loading, refreshKey, setRefreshKey, isRefreshing, setIsRefreshing, toggleSort, setSortTo } = useDataTableData({
86
+ const { page, setPage, sizeForm, sort, setSort, data: serverData, meta, rowFilters, loading, loadedRequestId, lastRequestId, isStatic, refreshKey, setRefreshKey, isRefreshing, setIsRefreshing, toggleSort, setSortTo } = useDataTableData({
86
87
  props: untyped,
87
88
  size,
88
89
  setSize,
@@ -90,7 +91,7 @@ const DataTable = (props) => {
90
91
  form,
91
92
  alepha
92
93
  });
93
- const { refresh, handleRefreshClick, resetFilters, canShare, shareFilters } = useDataTableRefresh({
94
+ const { refresh, reload, handleRefreshClick, resetFilters, canShare, shareFilters } = useDataTableRefresh({
94
95
  props: untyped,
95
96
  form,
96
97
  filterKeys: filterDefinition?.keys ?? [],
@@ -121,15 +122,33 @@ const DataTable = (props) => {
121
122
  * Selection was broken by the same thing - `selection.has(rowKey(item))`
122
123
  * compared against a key generated one render earlier, so it never matched.
123
124
  */
124
- const rowKeys = useMemo(() => data.map((item, index) => {
125
+ /**
126
+ * A row's key from the row alone, so a row redrawn by an optimistic patch
127
+ * (a new object) keeps the key of the one it replaces.
128
+ */
129
+ const keyOf = useCallback((item, index) => {
125
130
  if (props.rowKey) return props.rowKey(item);
126
131
  const id = item?.id;
127
132
  return id != null ? String(id) : `page-${page}-row-${index}`;
128
- }), [
129
- data,
130
- page,
131
- props.rowKey
132
- ]);
133
+ }, [page, props.rowKey]);
134
+ const serverRowKeys = useMemo(() => serverData.map((item, index) => keyOf(item, index)), [serverData, keyOf]);
135
+ const serverKeyByItem = useMemo(() => {
136
+ const map = /* @__PURE__ */ new Map();
137
+ serverData.forEach((item, index) => map.set(item, serverRowKeys[index]));
138
+ return map;
139
+ }, [serverData, serverRowKeys]);
140
+ const overlayKey = useCallback((item) => serverKeyByItem.get(item) ?? keyOf(item, -1), [serverKeyByItem, keyOf]);
141
+ const overlay = useOptimisticRows({
142
+ data: serverData,
143
+ rowKeys: serverRowKeys,
144
+ rowKey: overlayKey,
145
+ loadedRequestId,
146
+ lastRequestId,
147
+ reload,
148
+ isStatic
149
+ });
150
+ const data = overlay.data;
151
+ const rowKeys = overlay.rowKeys;
133
152
  /**
134
153
  * Selection asks for a key by item, not by index. Every item it can ask
135
154
  * about is one of `data`'s, so a lookup keyed on identity covers it without
@@ -201,12 +220,26 @@ const DataTable = (props) => {
201
220
  const hasRowActions = Boolean(props.rowActions);
202
221
  const rowCtx = useMemo(() => ({
203
222
  refresh,
204
- clearSelection
205
- }), [refresh, clearSelection]);
223
+ reload,
224
+ clearSelection,
225
+ optimistic: overlay.optimistic
226
+ }), [
227
+ refresh,
228
+ reload,
229
+ clearSelection,
230
+ overlay.optimistic
231
+ ]);
206
232
  const bulkCtx = useMemo(() => ({
207
233
  refresh,
208
- clearSelection
209
- }), [refresh, clearSelection]);
234
+ reload,
235
+ clearSelection,
236
+ optimistic: overlay.optimistic
237
+ }), [
238
+ refresh,
239
+ reload,
240
+ clearSelection,
241
+ overlay.optimistic
242
+ ]);
210
243
  /**
211
244
  * How many filters currently narrow the list — a count rather than the
212
245
  * boolean this used to be, because on a phone the bar is behind a button
@@ -243,7 +276,7 @@ const DataTable = (props) => {
243
276
  const flatTop = props.flat && "rounded-none border-x-0 border-t-0";
244
277
  const flatRows = props.flat && "rounded-none border-x-0 border-t-0 border-b-0";
245
278
  const flatBottom = props.flat && "rounded-none border-x-0 border-b-0";
246
- const showFooter = (props.pageSizes ?? PAGE_SIZES).length > 0 || Boolean(meta?.totalPages && meta.totalPages > 1);
279
+ const showFooter = !(props.pagination === false && Boolean(props.data)) && ((props.pageSizes ?? PAGE_SIZES).length > 0 || Boolean(meta?.totalPages && meta.totalPages > 1));
247
280
  const showColumnPicker = !props.hideColumnPicker && allColumnKeys.length > 0;
248
281
  const showActionsMenu = !props.hideActionsMenu;
249
282
  return /* @__PURE__ */ jsx(ClientOnly, { children: /* @__PURE__ */ jsxs("div", {
@@ -324,6 +357,8 @@ const DataTable = (props) => {
324
357
  data,
325
358
  cellContext,
326
359
  rowKeys,
360
+ leaving: overlay.leaving,
361
+ flash: overlay.flash,
327
362
  loading,
328
363
  visibleCols,
329
364
  hasCheckbox,
@@ -333,6 +368,8 @@ const DataTable = (props) => {
333
368
  toggleRow,
334
369
  rowCtx,
335
370
  rowActions: props.rowActions,
371
+ rowActionsDisplay: props.rowActionsDisplay,
372
+ striped: props.striped,
336
373
  onRowClick: props.onRowClick,
337
374
  onRowHover: props.onRowHover,
338
375
  empty: props.empty,
@@ -1 +1 @@
1
- {"version":3,"file":"DataTable.js","names":[],"sources":["../../src/table/DataTable.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { ClientOnly, useAlepha } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\n\nimport { Table, TableHeader } from \"../core/Table.tsx\";\nimport { useIsMobile } from \"../core/useIsMobile.ts\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport type { DataTableBaseProps } from \"./dataTableBaseProps.ts\";\nimport { DataTableBody } from \"./DataTableBody.tsx\";\nimport { DataTableBulkBar } from \"./DataTableBulkBar.tsx\";\nimport { DATA_TABLE_CELL_PADDING } from \"./dataTableCellPadding.ts\";\nimport { DataTableFooter, PAGE_SIZES } from \"./DataTableFooter.tsx\";\nimport { DataTableHeaderRow } from \"./DataTableHeaderRow.tsx\";\nimport {\n persistedColumns,\n persistedOrder,\n persistedSize,\n persistedSort,\n} from \"./dataTablePersistence.ts\";\nimport { DATA_TABLE_SQUARE_RIGHT } from \"./dataTableSquareRight.ts\";\nimport { DataTableSummaryPanel } from \"./DataTableSummaryPanel.tsx\";\nimport { DataTableToolbar } from \"./DataTableToolbar.tsx\";\nimport type {\n DataTableCellContext,\n DataTableFilterFields,\n DataTableNoFilterFields,\n DataTableSource,\n BulkActionContext,\n ColumnDef,\n RowActionContext,\n} from \"./dataTableTypes.ts\";\nimport { cleanFilterValues } from \"./queryFilters.ts\";\nimport { useDataTableColumns } from \"./useDataTableColumns.ts\";\nimport { useDataTableData } from \"./useDataTableData.ts\";\nimport { useDataTableFilterForm } from \"./useDataTableFilterForm.ts\";\nimport { useDataTableFilterVisibility } from \"./useDataTableFilterVisibility.ts\";\nimport { useDataTableRefresh } from \"./useDataTableRefresh.ts\";\nimport { useDataTableSummary } from \"./useDataTableSummary.ts\";\nimport { useTableSelection } from \"./useTableSelection.ts\";\n\nexport type DataTableProps<\n T,\n F extends DataTableFilterFields = DataTableNoFilterFields,\n> = DataTableBaseProps<T, F> & DataTableSource<T, F>;\n\n/**\n * A data table: server-side or static rows, sorting, filters, row and bulk\n * actions, persisted preferences.\n *\n * `T` is the row. `F` is the type of `filters.fields`, written as\n * `typeof filterFields` beside the row type, which is what types `fetch`'s\n * filters, the `data` predicate, `initialValues`, `seedValues` and\n * `fromQuery`. It defaults to no filters at all, so a table given `fields`\n * without it does not compile.\n */\nexport const DataTable = <\n T,\n const F extends DataTableFilterFields = DataTableNoFilterFields,\n>(\n props: DataTableProps<T, F>,\n) => {\n /**\n * The props, with their filters read untyped. The parts below enumerate\n * filter keys at runtime and never read one by name, so the type of `F` is\n * the call site's business and one cast here keeps it out of every hook.\n */\n const untyped = props as unknown as DataTableProps<T, DataTableFilterFields>;\n\n /**\n * `persistenceKey`, once per facet.\n *\n * A facet that is off gets `undefined`, which is the same value every\n * persistence helper here already treats as \"do not store\" - so turning one\n * off takes the branch a table with no key has always taken, rather than a\n * new one. That is what keeps the default behaviour of `persistenceKey`\n * exactly as it was: with `persist` absent, all three of these ARE\n * `props.persistenceKey`.\n *\n * Primitives, so they go straight into the dependency arrays and `useState`\n * initializers below without giving any of them a new identity per render.\n */\n const filtersKey =\n props.persist?.filters === false ? undefined : props.persistenceKey;\n const columnsKey =\n props.persist?.columns === false ? undefined : props.persistenceKey;\n const sortKey =\n props.persist?.sort === false ? undefined : props.persistenceKey;\n // `pageSizes={[]}` hides the picker, and with it the reader's say in the\n // size: a size stored while the picker was still there must not outlive\n // it, or a reader who once chose 50 is stuck at 50 with no control left to\n // change it. The call site's `defaultSize` is the size, full stop.\n const sizeKey =\n props.pageSizes?.length === 0 ? undefined : props.persistenceKey;\n\n // State, not a constant. It was `props.defaultSize ?? 20` read once, so a\n // reader had no way to see more rows than the call site had decided for\n // them. Already in `load`'s dependency array, so changing it refetches.\n const [size, setSize] = useState<number>(() =>\n persistedSize(sizeKey, props.defaultSize),\n );\n const alepha = useAlepha();\n const { tr } = useI18n();\n const toast = useToast();\n /**\n * The whole of the phone layout, and deliberately one switch rather than a\n * scattering of `max-md:` classes: the filter controls have to be rendered\n * in exactly ONE of the two places (see `DataTableFilterDialog`), which\n * CSS cannot express. Everything else below the breakpoint follows the same\n * flag so the two halves of the layout cannot disagree.\n *\n * Safe against hydration because the whole table sits inside `ClientOnly`,\n * and `useIsMobile` reads the same `MediaQueryList` it subscribes to.\n */\n const isMobile = useIsMobile();\n\n const { form, definition: filterDefinition } = useDataTableFilterForm({\n props: untyped,\n filtersKey,\n alepha,\n });\n\n const filterVisibility = useDataTableFilterVisibility({\n definition: filterDefinition,\n filtersKey,\n });\n\n const {\n page,\n setPage,\n sizeForm,\n sort,\n setSort,\n data,\n meta,\n rowFilters,\n loading,\n refreshKey,\n setRefreshKey,\n isRefreshing,\n setIsRefreshing,\n toggleSort,\n setSortTo,\n } = useDataTableData({\n props: untyped,\n size,\n setSize,\n sortKey,\n form,\n alepha,\n });\n\n const { refresh, handleRefreshClick, resetFilters, canShare, shareFilters } =\n useDataTableRefresh({\n props: untyped,\n form,\n filterKeys: filterDefinition?.keys ?? [],\n resetShownFilters: filterVisibility.resetShown,\n filtersKey,\n alepha,\n toast,\n tr,\n setPage,\n setRefreshKey,\n setIsRefreshing,\n });\n\n const summary = useDataTableSummary({\n summary: untyped.summary,\n persistenceKey: props.persistenceKey,\n refreshKey,\n form,\n alepha,\n });\n\n // -- Row identity ----------------------------------------------------------\n\n /**\n * A row's key, in order of preference: the caller's `rowKey`, the row's own\n * `id`, then where the row sits.\n *\n * The last one used to be `Math.random()`, which is not an identity at all.\n * Every render produced a new key, so React saw every id-less row as a new\n * row and remounted it: focus in an inline input was lost the moment\n * anything else re-rendered, and the list re-animated on every keystroke.\n * Selection was broken by the same thing - `selection.has(rowKey(item))`\n * compared against a key generated one render earlier, so it never matched.\n */\n const rowKeys = useMemo(\n () =>\n data.map((item, index) => {\n if (props.rowKey) return props.rowKey(item);\n const id = (item as { id?: unknown })?.id;\n // Coercion at a boundary: the value is a form/route/chart primitive\n // whose declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n return id != null ? String(id) : `page-${page}-row-${index}`;\n }),\n [data, page, props.rowKey],\n );\n\n /**\n * Selection asks for a key by item, not by index. Every item it can ask\n * about is one of `data`'s, so a lookup keyed on identity covers it without\n * an O(n) scan per call.\n */\n const rowKeyByItem = useMemo(() => {\n const map = new Map<T, string>();\n data.forEach((item, index) => map.set(item, rowKeys[index]));\n return map;\n }, [data, rowKeys]);\n\n const rowKey = useCallback(\n (item: T): string => rowKeyByItem.get(item) ?? \"\",\n [rowKeyByItem],\n );\n\n // -- Selection -------------------------------------------------------------\n\n const {\n selection,\n selectedItems,\n allSelected,\n someSelected,\n toggleRow,\n toggleAll,\n clearSelection,\n } = useTableSelection(data, rowKey);\n\n // The bulk actions offered for THIS selection: an action's `visible`\n // predicate reads the selected rows. Computed once, here, so the pill's\n // contents and the pill's own presence come from the same list.\n const visibleBulkActions = useMemo(\n () =>\n (props.bulkActions ?? []).filter(\n (action) => action.visible?.(selectedItems) ?? true,\n ),\n [props.bulkActions, selectedItems],\n );\n\n const {\n allColumnKeys,\n visibleColumns,\n setVisibleColumns,\n orderedKeys,\n setColumnOrder,\n moveColumn,\n reorderColumn,\n toggleColumn,\n orderAnnouncement,\n } = useDataTableColumns({ props: untyped, columnsKey, tr });\n\n /**\n * ⚠️ A changed `persistenceKey` is a changed SCOPE, and this is where that\n * is handled.\n *\n * Every caller encodes its scope in that key - `lor.activity.${project.id}`,\n * `lor.epics.${project.id}` - so switching project changes it. Nothing acted\n * on that before, and `load` re-runs only on `[page, size, sortParam,\n * refreshKey, form, alepha]`, none of which a project switch touches. The\n * router does not remount on a param-only navigation either, so the table\n * kept serving the PREVIOUS project's rows under the new project's name\n * (feedback #2096).\n *\n * `refreshKey` is bumped rather than relying on the re-read: two projects\n * can share a stored sort and size, and then no dependency of `load` would\n * change and nothing would refetch. That equality is the bug's whole\n * mechanism, so the refetch cannot be a side effect of the values moving.\n *\n * ⚠️ Adjusted during RENDER, not in an effect, and that is load-bearing.\n * The sort effect (`useDataTableData`) and the column writes\n * (`useDataTableColumns`) are keyed on `persistenceKey` too, so on the\n * render where it changes they would fire in the same flush and write the\n * OUTGOING scope's state under the INCOMING key - silently\n * overwriting the project you just opened with the one you just left. React\n * re-renders before committing this, so by the time those effects run the\n * state is already the new scope's and they write back what was just read.\n *\n * ⚠️ `props.fetch` is still NOT a dependency of `load`. That is the loop\n * `fetchRef` exists to prevent, and several callers write a store atom from\n * inside their fetcher.\n *\n * Filter VALUES are deliberately not reset here: `useForm` captures its\n * `initialValues` once, so resetting them is form surgery rather than a\n * state assignment. They are also not clobbered - the filter-persist effect\n * writes only on `form:changed` / `form:submit:success`, never on mount - so\n * the stored filters of the project you left stay its own.\n */\n const scopeRef = useRef(props.persistenceKey);\n if (scopeRef.current !== props.persistenceKey) {\n scopeRef.current = props.persistenceKey;\n setPage(0);\n setSize(persistedSize(sizeKey, props.defaultSize));\n setSort(persistedSort(sortKey, props.defaultSort));\n setVisibleColumns(persistedColumns(columnsKey, props.columns));\n // Same render pass as the rest, and for the identical reason: the effects\n // keyed on `persistenceKey` fire in one flush, so an order left behind\n // here would be written back under the INCOMING key.\n setColumnOrder(persistedOrder(columnsKey, props.columns));\n // Which filters are on the bar is the scope's too, and read here for the\n // same reason: the project just opened must not show the bar of the one\n // just left.\n filterVisibility.rereadShown(filtersKey);\n // The panel's open state is the scope's like the size is, and its cards\n // are the scope's figures: they go now, and the bump below refetches.\n summary.resetScope(props.persistenceKey);\n setRefreshKey((k) => k + 1);\n }\n\n // -- Render ---------------------------------------------------------------\n\n // The reader's order, not the declaration's.\n const cols = orderedKeys.map((key) => [key, props.columns[key]!]) as Array<\n [string, ColumnDef<T>]\n >;\n const visibleCols = cols.filter(([key]) => visibleColumns.has(key));\n const hasCheckbox = Boolean(props.bulkActions?.length);\n const hasRowActions = Boolean(props.rowActions);\n\n const rowCtx: RowActionContext = useMemo(\n () => ({ refresh, clearSelection }),\n [refresh, clearSelection],\n );\n const bulkCtx: BulkActionContext = useMemo(\n () => ({ refresh, clearSelection }),\n [refresh, clearSelection],\n );\n\n /**\n * How many filters currently narrow the list — a count rather than the\n * boolean this used to be, because on a phone the bar is behind a button\n * and the trigger's badge is the only thing that says the table is\n * filtered at all.\n */\n const activeFilterCount = useMemo(() => {\n if (!props.filters || !form) return 0;\n return Object.keys(cleanFilterValues(form.currentValues ?? {})).length;\n }, [props.filters, form, refreshKey]);\n const hasActiveFilters = activeFilterCount > 0;\n\n // What every cell is told beside its row: the search the rows on screen\n // answer, from the first `preset: \"search\"` field holding one.\n const searchKey = Object.entries(props.filters?.fields ?? {}).find(\n ([, field]) => field.preset === \"search\",\n )?.[0];\n const rowSearch = searchKey ? rowFilters?.[searchKey] : undefined;\n const cellContext: DataTableCellContext = {\n search:\n typeof rowSearch === \"string\" && rowSearch.trim() !== \"\"\n ? rowSearch.trim()\n : undefined,\n };\n /**\n * Whether Reset filters would change anything: a value set, or a bar that\n * is not the one the table declares. Not the count alone, or a reader who\n * removed a default filter would have no way to bring it back.\n */\n const canResetFilters =\n hasActiveFilters || filterVisibility.differsFromDeclaration;\n\n // The empty state is showing, as opposed to the skeleton that also renders\n // on `data.length === 0`. Read by the `<Table>` height as well as the body,\n // so the two cannot disagree.\n const isEmptyState = !loading && data.length === 0;\n\n // A node that draws nothing is no help and no content: the `?` and the\n // band would open on an empty card. Decided here, once, and handed down\n // as `undefined` when it is empty.\n const hasHelp =\n props.help != null && props.help !== false && props.help !== \"\";\n const showToolbar =\n Boolean(props.filters) ||\n Boolean(props.leading) ||\n Boolean(props.toolbar) ||\n Boolean(props.actions?.length) ||\n hasHelp ||\n !props.hideColumnPicker ||\n !props.hideActionsMenu;\n // Drawn while a first fetch is out (its placeholders), and after that only\n // with something in it: a summary with no card and no content is no band.\n // A function is called on every render, which only builds its element: the\n // panel mounts it while open, and the counter is what tells it to reload.\n const rawSummaryContent = props.summary?.content;\n const summaryContent =\n typeof rawSummaryContent === \"function\"\n ? rawSummaryContent({ refreshKey })\n : rawSummaryContent;\n const hasSummaryContent =\n summaryContent != null && summaryContent !== false && summaryContent !== \"\";\n const showSummary =\n Boolean(props.summary) &&\n (summary.cards === undefined ||\n summary.cards.length > 0 ||\n hasSummaryContent);\n const cellPadding = DATA_TABLE_CELL_PADDING[props.cellPadding ?? \"normal\"];\n const squareRight = props.squareRight\n ? DATA_TABLE_SQUARE_RIGHT[`${props.squareRight}`]\n : undefined;\n // `flat` drops the outer frame and keeps the lines between the bands: the\n // toolbar keeps its bottom border, the footer its top one, and the rows\n // lose the sides. Applied after `squareRight`, which has nothing left to\n // square once the corners are gone.\n const flatTop = props.flat && \"rounded-none border-x-0 border-t-0\";\n const flatRows =\n props.flat && \"rounded-none border-x-0 border-t-0 border-b-0\";\n const flatBottom = props.flat && \"rounded-none border-x-0 border-b-0\";\n // The footer holds two controls, the size picker and the page links, and\n // the count beside them. A table that hid the picker (`pageSizes={[]}`)\n // and fits on one page has neither, and \"Page 1 of 1\" alone is a bar\n // saying nothing, so it goes. The links' condition is the footer's own.\n const showFooter =\n (props.pageSizes ?? PAGE_SIZES).length > 0 ||\n Boolean(meta?.totalPages && meta.totalPages > 1);\n const showColumnPicker = !props.hideColumnPicker && allColumnKeys.length > 0;\n const showActionsMenu = !props.hideActionsMenu;\n\n return (\n <ClientOnly>\n <div className={cn(\"flex flex-col gap-2\", props.className)}>\n {props.header && (\n <div className=\"flex items-center gap-2\">\n <div className=\"min-w-0 flex-1\">{props.header}</div>\n </div>\n )}\n\n {/*\n The summary opens the frame when it is there, so it takes the top\n corners `squareRight` squares, and whatever follows it (the filter\n bar, or the rows when there is none) joins under it the way the rows\n join the filter bar: flattened top, no top border, `-mt-2` against\n the wrapper's gap. The panel's own bottom border is the line\n between them.\n */}\n {showSummary && (\n <DataTableSummaryPanel\n title={\n props.summary?.title ??\n tr(\"dataTable.summary\", { default: \"Summary\" })\n }\n open={summary.open}\n onOpenChange={summary.setOpen}\n cards={summary.cards}\n loading={summary.loading}\n content={hasSummaryContent ? summaryContent : undefined}\n className={cn(squareRight?.top, flatTop, props.chromeClassName)}\n />\n )}\n\n {showToolbar && (\n <DataTableToolbar<T>\n columns={props.columns}\n filters={untyped.filters}\n form={form}\n filterDefinition={filterDefinition}\n shownFilters={filterVisibility.shown}\n onShownFiltersChange={filterVisibility.setShown}\n canResetFilters={canResetFilters}\n leading={props.leading}\n toolbar={props.toolbar}\n actions={props.actions}\n help={hasHelp ? props.help : undefined}\n isMobile={isMobile}\n showColumnPicker={showColumnPicker}\n showActionsMenu={showActionsMenu}\n activeFilterCount={activeFilterCount}\n canShare={canShare}\n resetFilters={resetFilters}\n shareFilters={shareFilters}\n orderedKeys={orderedKeys}\n visibleColumns={visibleColumns}\n toggleColumn={toggleColumn}\n reorderColumn={reorderColumn}\n isRefreshing={isRefreshing}\n handleRefreshClick={handleRefreshClick}\n className={cn(\n showSummary\n ? \"-mt-2 rounded-t-none border-t-0\"\n : squareRight?.top,\n flatTop,\n props.chromeClassName,\n )}\n />\n )}\n\n {hasCheckbox && selection.size > 0 && visibleBulkActions.length > 0 && (\n <DataTableBulkBar<T>\n selection={selection}\n selectedItems={selectedItems}\n visibleBulkActions={visibleBulkActions}\n bulkCtx={bulkCtx}\n clearSelection={clearSelection}\n />\n )}\n\n {/*\n The toolbar, the rows and the footer are one panel: each facing edge\n is flattened and its border dropped so no double line appears, and\n `-mt-2` cancels the wrapper's `gap-2`. The footer half follows\n `showFooter`, which is true for every table that keeps its size\n picker: gating the footer on `meta` alone would pop the bar in and\n flip this bottom border on every load, since `meta` starts null and\n only fills after the fetch. Only a table that hid the picker can\n lose it, and then the rows close the panel themselves.\n */}\n <div\n className={cn(\n \"flex min-h-0 flex-1 flex-col overflow-auto rounded-md border\",\n (showToolbar || showSummary) && \"-mt-2 rounded-t-none border-t-0\",\n showFooter ? \"rounded-b-none border-b-0\" : squareRight?.bottom,\n flatRows,\n // With no toolbar and no summary the rows open the table, so\n // their top-right corner is the one `squareRight` squares.\n !showToolbar && !showSummary && squareRight?.top,\n // `<Table>` wraps the table in a container div whose classes it\n // hardcodes, and only this table needs that container to grow,\n // so the one class it needs is set from out here instead.\n //\n // `grow`, NOT `flex-1`: `flex-1` sets the basis to 0, and in the\n // ordinary case this wrapper has no height of its own, so a 0\n // basis with nothing to grow into collapses the table to nothing.\n // `grow` keeps the content basis and only spends space that is\n // actually free, which is the full-height case.\n \"[&>[data-slot=table-container]]:grow\",\n )}\n >\n {/* `h-full` ONLY while the empty state is what is in the body.\n It is what lets that one row take the height the scroller grew\n into, so `align-middle` can centre the state in it.\n\n ⚠️ Never unconditionally. A CSS table given a height larger\n than its content does not leave the surplus at the bottom, it\n DISTRIBUTES IT ACROSS THE ROWS - so an unconditional `h-full`\n silently turns a short table into a tall one: Lore's Apps page,\n two rows in a full-height pane, rendered them 239px each. No\n unit test sees it (jsdom computes no layout) and it is invisible\n on a table long enough to fill its own container, which is why\n it reached e2e rather than review. */}\n <Table className={cn(isEmptyState && \"h-full\")}>\n {/* `bg-muted`, fully opaque, NOT the base header's `bg-muted/50`:\n this header is sticky, so anything translucent lets the rows\n scroll visibly through the column labels. Same tint, no\n transparency.\n\n Two inset lines, not one. The bottom is the divider against the\n first row; the top is the `--bevel` highlight, which is what\n gives the band its thickness. Inset shadows rather than borders\n because a border on a sticky `<thead>` is dropped by the\n collapsed table border model, and because the two lines have to\n sit INSIDE the header's own height: it is pinned at `top-0`\n against a scrolling body, so anything painted outside it is\n painted over. */}\n <TableHeader\n className={cn(\n // ⚠️ `[&_tr]:border-b-0` or the bottom rule is drawn TWICE: `TableHeader`\n // gives its rows a `border-b`, and the inset shadow above draws\n // the same line, so the band closed with 2px where it opens with\n // 1px. The inset one wins because it is what survives the sticky\n // header being painted over.\n \"bg-muted sticky top-0 z-10 shadow-[inset_0_1px_0_0_var(--bevel),inset_0_-1px_0_0_var(--border)] [&_tr]:border-b-0\",\n props.chromeClassName,\n )}\n >\n <DataTableHeaderRow<T>\n headClassName={cellPadding.head}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n allSelected={allSelected}\n someSelected={someSelected}\n toggleAll={toggleAll}\n sort={sort}\n toggleSort={toggleSort}\n setSortTo={setSortTo}\n moveColumn={moveColumn}\n toggleColumn={toggleColumn}\n />\n </TableHeader>\n <DataTableBody<T>\n cellClassName={cellPadding.cell}\n data={data}\n cellContext={cellContext}\n rowKeys={rowKeys}\n loading={loading}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n hasActiveFilters={hasActiveFilters}\n selection={selection}\n toggleRow={toggleRow}\n rowCtx={rowCtx}\n rowActions={props.rowActions}\n onRowClick={props.onRowClick}\n onRowHover={props.onRowHover}\n empty={props.empty}\n emptyMessage={props.emptyMessage}\n emptyState={props.emptyState}\n noMatchState={props.noMatchState}\n />\n </Table>\n </div>\n\n {/* A move is otherwise silent: nothing about a reordered table is\n spoken, and the visual change is the only feedback. Outside the\n table so it is not read as a cell. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {orderAnnouncement}\n </span>\n\n {showFooter && (\n <DataTableFooter\n pageSizes={props.pageSizes}\n sizeForm={sizeForm}\n meta={meta}\n isMobile={isMobile}\n setPage={setPage}\n className={cn(\n squareRight?.bottom,\n flatBottom,\n props.chromeClassName,\n )}\n />\n )}\n </div>\n </ClientOnly>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAa,aAIX,UACG;;;;;;CAMH,MAAM,UAAU;;;;;;;;;;;;;;CAehB,MAAM,aACJ,MAAM,SAAS,YAAY,QAAQ,KAAA,IAAY,MAAM;CACvD,MAAM,aACJ,MAAM,SAAS,YAAY,QAAQ,KAAA,IAAY,MAAM;CACvD,MAAM,UACJ,MAAM,SAAS,SAAS,QAAQ,KAAA,IAAY,MAAM;CAKpD,MAAM,UACJ,MAAM,WAAW,WAAW,IAAI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OAAD;KAAO,WAAW,GAAG,gBAAgB,QAAQ;KAA7C,UAAA,CAcE,oBAAC,aAAD;MACE,WAAW,GAMT,qHACA,MAAM,eACR;MAEA,UAAA,oBAAC,oBAAD;OACE,eAAe,YAAY;OACd;OACA;OACE;OACF;OACC;OACH;OACL;OACM;OACD;OACC;OACE;MACf,CAAA;KACU,CAAA,GACb,oBAAC,eAAD;MACE,eAAe,YAAY;MACrB;MACO;MACJ;MACA;MACI;MACA;MACE;MACG;MACP;MACA;MACH;MACR,YAAY,MAAM;MAClB,YAAY,MAAM;MAClB,YAAY,MAAM;MAClB,OAAO,MAAM;MACb,cAAc,MAAM;MACpB,YAAY,MAAM;MAClB,cAAc,MAAM;KACrB,CAAA,CACI;;GACJ,CAAA;GAKL,oBAAC,QAAD;IAAM,aAAU;IAAS,WAAU;IAChC,UAAA;GACG,CAAA;GAEL,cACC,oBAAC,iBAAD;IACE,WAAW,MAAM;IACP;IACJ;IACI;IACD;IACT,WAAW,GACT,aAAa,QACb,YACA,MAAM,eACR;GACD,CAAA;EAEA;CACK,CAAA,EAAA,CAAA;AAEhB"}
1
+ {"version":3,"file":"DataTable.js","names":[],"sources":["../../src/table/DataTable.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { ClientOnly, useAlepha } from \"alepha/react\";\nimport { useI18n } from \"alepha/react/i18n\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\n\nimport { Table, TableHeader } from \"../core/Table.tsx\";\nimport { useIsMobile } from \"../core/useIsMobile.ts\";\nimport { useToast } from \"../core/useToast.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport type { DataTableBaseProps } from \"./dataTableBaseProps.ts\";\nimport { DataTableBody } from \"./DataTableBody.tsx\";\nimport { DataTableBulkBar } from \"./DataTableBulkBar.tsx\";\nimport { DATA_TABLE_CELL_PADDING } from \"./dataTableCellPadding.ts\";\nimport { DataTableFooter, PAGE_SIZES } from \"./DataTableFooter.tsx\";\nimport { DataTableHeaderRow } from \"./DataTableHeaderRow.tsx\";\nimport {\n persistedColumns,\n persistedOrder,\n persistedSize,\n persistedSort,\n} from \"./dataTablePersistence.ts\";\nimport { DATA_TABLE_SQUARE_RIGHT } from \"./dataTableSquareRight.ts\";\nimport { DataTableSummaryPanel } from \"./DataTableSummaryPanel.tsx\";\nimport { DataTableToolbar } from \"./DataTableToolbar.tsx\";\nimport type {\n DataTableCellContext,\n DataTableFilterFields,\n DataTableNoFilterFields,\n DataTableSource,\n BulkActionContext,\n ColumnDef,\n RowActionContext,\n} from \"./dataTableTypes.ts\";\nimport { cleanFilterValues } from \"./queryFilters.ts\";\nimport { useDataTableColumns } from \"./useDataTableColumns.ts\";\nimport { useDataTableData } from \"./useDataTableData.ts\";\nimport { useDataTableFilterForm } from \"./useDataTableFilterForm.ts\";\nimport { useDataTableFilterVisibility } from \"./useDataTableFilterVisibility.ts\";\nimport { useDataTableRefresh } from \"./useDataTableRefresh.ts\";\nimport { useDataTableSummary } from \"./useDataTableSummary.ts\";\nimport { useOptimisticRows } from \"./useOptimisticRows.ts\";\nimport { useTableSelection } from \"./useTableSelection.ts\";\n\nexport type DataTableProps<\n T,\n F extends DataTableFilterFields = DataTableNoFilterFields,\n> = DataTableBaseProps<T, F> & DataTableSource<T, F>;\n\n/**\n * A data table: server-side or static rows, sorting, filters, row and bulk\n * actions, persisted preferences.\n *\n * `T` is the row. `F` is the type of `filters.fields`, written as\n * `typeof filterFields` beside the row type, which is what types `fetch`'s\n * filters, the `data` predicate, `initialValues`, `seedValues` and\n * `fromQuery`. It defaults to no filters at all, so a table given `fields`\n * without it does not compile.\n */\nexport const DataTable = <\n T,\n const F extends DataTableFilterFields = DataTableNoFilterFields,\n>(\n props: DataTableProps<T, F>,\n) => {\n /**\n * The props, with their filters read untyped. The parts below enumerate\n * filter keys at runtime and never read one by name, so the type of `F` is\n * the call site's business and one cast here keeps it out of every hook.\n */\n const untyped = props as unknown as DataTableProps<T, DataTableFilterFields>;\n\n /**\n * `persistenceKey`, once per facet.\n *\n * A facet that is off gets `undefined`, which is the same value every\n * persistence helper here already treats as \"do not store\" - so turning one\n * off takes the branch a table with no key has always taken, rather than a\n * new one. That is what keeps the default behaviour of `persistenceKey`\n * exactly as it was: with `persist` absent, all three of these ARE\n * `props.persistenceKey`.\n *\n * Primitives, so they go straight into the dependency arrays and `useState`\n * initializers below without giving any of them a new identity per render.\n */\n const filtersKey =\n props.persist?.filters === false ? undefined : props.persistenceKey;\n const columnsKey =\n props.persist?.columns === false ? undefined : props.persistenceKey;\n const sortKey =\n props.persist?.sort === false ? undefined : props.persistenceKey;\n // `pageSizes={[]}` hides the picker, and with it the reader's say in the\n // size: a size stored while the picker was still there must not outlive\n // it, or a reader who once chose 50 is stuck at 50 with no control left to\n // change it. The call site's `defaultSize` is the size, full stop.\n const sizeKey =\n props.pageSizes?.length === 0 ? undefined : props.persistenceKey;\n\n // State, not a constant. It was `props.defaultSize ?? 20` read once, so a\n // reader had no way to see more rows than the call site had decided for\n // them. Already in `load`'s dependency array, so changing it refetches.\n const [size, setSize] = useState<number>(() =>\n persistedSize(sizeKey, props.defaultSize),\n );\n const alepha = useAlepha();\n const { tr } = useI18n();\n const toast = useToast();\n /**\n * The whole of the phone layout, and deliberately one switch rather than a\n * scattering of `max-md:` classes: the filter controls have to be rendered\n * in exactly ONE of the two places (see `DataTableFilterDialog`), which\n * CSS cannot express. Everything else below the breakpoint follows the same\n * flag so the two halves of the layout cannot disagree.\n *\n * Safe against hydration because the whole table sits inside `ClientOnly`,\n * and `useIsMobile` reads the same `MediaQueryList` it subscribes to.\n */\n const isMobile = useIsMobile();\n\n const { form, definition: filterDefinition } = useDataTableFilterForm({\n props: untyped,\n filtersKey,\n alepha,\n });\n\n const filterVisibility = useDataTableFilterVisibility({\n definition: filterDefinition,\n filtersKey,\n });\n\n const {\n page,\n setPage,\n sizeForm,\n sort,\n setSort,\n data: serverData,\n meta,\n rowFilters,\n loading,\n loadedRequestId,\n lastRequestId,\n isStatic,\n refreshKey,\n setRefreshKey,\n isRefreshing,\n setIsRefreshing,\n toggleSort,\n setSortTo,\n } = useDataTableData({\n props: untyped,\n size,\n setSize,\n sortKey,\n form,\n alepha,\n });\n\n const {\n refresh,\n reload,\n handleRefreshClick,\n resetFilters,\n canShare,\n shareFilters,\n } = useDataTableRefresh({\n props: untyped,\n form,\n filterKeys: filterDefinition?.keys ?? [],\n resetShownFilters: filterVisibility.resetShown,\n filtersKey,\n alepha,\n toast,\n tr,\n setPage,\n setRefreshKey,\n setIsRefreshing,\n });\n\n const summary = useDataTableSummary({\n summary: untyped.summary,\n persistenceKey: props.persistenceKey,\n refreshKey,\n form,\n alepha,\n });\n\n // -- Row identity ----------------------------------------------------------\n\n /**\n * A row's key, in order of preference: the caller's `rowKey`, the row's own\n * `id`, then where the row sits.\n *\n * The last one used to be `Math.random()`, which is not an identity at all.\n * Every render produced a new key, so React saw every id-less row as a new\n * row and remounted it: focus in an inline input was lost the moment\n * anything else re-rendered, and the list re-animated on every keystroke.\n * Selection was broken by the same thing - `selection.has(rowKey(item))`\n * compared against a key generated one render earlier, so it never matched.\n */\n /**\n * A row's key from the row alone, so a row redrawn by an optimistic patch\n * (a new object) keeps the key of the one it replaces.\n */\n const keyOf = useCallback(\n (item: T, index: number): string => {\n if (props.rowKey) return props.rowKey(item);\n const id = (item as { id?: unknown })?.id;\n // Coercion at a boundary: the value is a form/route/chart primitive\n // whose declared type is wider than what can reach here.\n // oxlint-disable-next-line typescript/no-base-to-string -- a coercion at a boundary, see the comment above\n return id != null ? String(id) : `page-${page}-row-${index}`;\n },\n [page, props.rowKey],\n );\n\n const serverRowKeys = useMemo(\n () => serverData.map((item, index) => keyOf(item, index)),\n [serverData, keyOf],\n );\n\n // -- Optimistic overlay ----------------------------------------------------\n\n const serverKeyByItem = useMemo(() => {\n const map = new Map<T, string>();\n serverData.forEach((item, index) => map.set(item, serverRowKeys[index]));\n return map;\n }, [serverData, serverRowKeys]);\n\n const overlayKey = useCallback(\n (item: T) => serverKeyByItem.get(item) ?? keyOf(item, -1),\n [serverKeyByItem, keyOf],\n );\n\n const overlay = useOptimisticRows<T>({\n data: serverData,\n rowKeys: serverRowKeys,\n rowKey: overlayKey,\n loadedRequestId,\n lastRequestId,\n reload,\n isStatic,\n });\n const data = overlay.data;\n const rowKeys = overlay.rowKeys;\n\n /**\n * Selection asks for a key by item, not by index. Every item it can ask\n * about is one of `data`'s, so a lookup keyed on identity covers it without\n * an O(n) scan per call.\n */\n const rowKeyByItem = useMemo(() => {\n const map = new Map<T, string>();\n data.forEach((item, index) => map.set(item, rowKeys[index]));\n return map;\n }, [data, rowKeys]);\n\n const rowKey = useCallback(\n (item: T): string => rowKeyByItem.get(item) ?? \"\",\n [rowKeyByItem],\n );\n\n // -- Selection -------------------------------------------------------------\n\n const {\n selection,\n selectedItems,\n allSelected,\n someSelected,\n toggleRow,\n toggleAll,\n clearSelection,\n } = useTableSelection(data, rowKey);\n\n // The bulk actions offered for THIS selection: an action's `visible`\n // predicate reads the selected rows. Computed once, here, so the pill's\n // contents and the pill's own presence come from the same list.\n const visibleBulkActions = useMemo(\n () =>\n (props.bulkActions ?? []).filter(\n (action) => action.visible?.(selectedItems) ?? true,\n ),\n [props.bulkActions, selectedItems],\n );\n\n const {\n allColumnKeys,\n visibleColumns,\n setVisibleColumns,\n orderedKeys,\n setColumnOrder,\n moveColumn,\n reorderColumn,\n toggleColumn,\n orderAnnouncement,\n } = useDataTableColumns({ props: untyped, columnsKey, tr });\n\n /**\n * ⚠️ A changed `persistenceKey` is a changed SCOPE, and this is where that\n * is handled.\n *\n * Every caller encodes its scope in that key - `lor.activity.${project.id}`,\n * `lor.epics.${project.id}` - so switching project changes it. Nothing acted\n * on that before, and `load` re-runs only on `[page, size, sortParam,\n * refreshKey, form, alepha]`, none of which a project switch touches. The\n * router does not remount on a param-only navigation either, so the table\n * kept serving the PREVIOUS project's rows under the new project's name\n * (feedback #2096).\n *\n * `refreshKey` is bumped rather than relying on the re-read: two projects\n * can share a stored sort and size, and then no dependency of `load` would\n * change and nothing would refetch. That equality is the bug's whole\n * mechanism, so the refetch cannot be a side effect of the values moving.\n *\n * ⚠️ Adjusted during RENDER, not in an effect, and that is load-bearing.\n * The sort effect (`useDataTableData`) and the column writes\n * (`useDataTableColumns`) are keyed on `persistenceKey` too, so on the\n * render where it changes they would fire in the same flush and write the\n * OUTGOING scope's state under the INCOMING key - silently\n * overwriting the project you just opened with the one you just left. React\n * re-renders before committing this, so by the time those effects run the\n * state is already the new scope's and they write back what was just read.\n *\n * ⚠️ `props.fetch` is still NOT a dependency of `load`. That is the loop\n * `fetchRef` exists to prevent, and several callers write a store atom from\n * inside their fetcher.\n *\n * Filter VALUES are deliberately not reset here: `useForm` captures its\n * `initialValues` once, so resetting them is form surgery rather than a\n * state assignment. They are also not clobbered - the filter-persist effect\n * writes only on `form:changed` / `form:submit:success`, never on mount - so\n * the stored filters of the project you left stay its own.\n */\n const scopeRef = useRef(props.persistenceKey);\n if (scopeRef.current !== props.persistenceKey) {\n scopeRef.current = props.persistenceKey;\n setPage(0);\n setSize(persistedSize(sizeKey, props.defaultSize));\n setSort(persistedSort(sortKey, props.defaultSort));\n setVisibleColumns(persistedColumns(columnsKey, props.columns));\n // Same render pass as the rest, and for the identical reason: the effects\n // keyed on `persistenceKey` fire in one flush, so an order left behind\n // here would be written back under the INCOMING key.\n setColumnOrder(persistedOrder(columnsKey, props.columns));\n // Which filters are on the bar is the scope's too, and read here for the\n // same reason: the project just opened must not show the bar of the one\n // just left.\n filterVisibility.rereadShown(filtersKey);\n // The panel's open state is the scope's like the size is, and its cards\n // are the scope's figures: they go now, and the bump below refetches.\n summary.resetScope(props.persistenceKey);\n setRefreshKey((k) => k + 1);\n }\n\n // -- Render ---------------------------------------------------------------\n\n // The reader's order, not the declaration's.\n const cols = orderedKeys.map((key) => [key, props.columns[key]!]) as Array<\n [string, ColumnDef<T>]\n >;\n const visibleCols = cols.filter(([key]) => visibleColumns.has(key));\n const hasCheckbox = Boolean(props.bulkActions?.length);\n const hasRowActions = Boolean(props.rowActions);\n\n const rowCtx: RowActionContext<T> = useMemo(\n () => ({ refresh, reload, clearSelection, optimistic: overlay.optimistic }),\n [refresh, reload, clearSelection, overlay.optimistic],\n );\n const bulkCtx: BulkActionContext<T> = useMemo(\n () => ({ refresh, reload, clearSelection, optimistic: overlay.optimistic }),\n [refresh, reload, clearSelection, overlay.optimistic],\n );\n\n /**\n * How many filters currently narrow the list — a count rather than the\n * boolean this used to be, because on a phone the bar is behind a button\n * and the trigger's badge is the only thing that says the table is\n * filtered at all.\n */\n const activeFilterCount = useMemo(() => {\n if (!props.filters || !form) return 0;\n return Object.keys(cleanFilterValues(form.currentValues ?? {})).length;\n }, [props.filters, form, refreshKey]);\n const hasActiveFilters = activeFilterCount > 0;\n\n // What every cell is told beside its row: the search the rows on screen\n // answer, from the first `preset: \"search\"` field holding one.\n const searchKey = Object.entries(props.filters?.fields ?? {}).find(\n ([, field]) => field.preset === \"search\",\n )?.[0];\n const rowSearch = searchKey ? rowFilters?.[searchKey] : undefined;\n const cellContext: DataTableCellContext = {\n search:\n typeof rowSearch === \"string\" && rowSearch.trim() !== \"\"\n ? rowSearch.trim()\n : undefined,\n };\n /**\n * Whether Reset filters would change anything: a value set, or a bar that\n * is not the one the table declares. Not the count alone, or a reader who\n * removed a default filter would have no way to bring it back.\n */\n const canResetFilters =\n hasActiveFilters || filterVisibility.differsFromDeclaration;\n\n // The empty state is showing, as opposed to the skeleton that also renders\n // on `data.length === 0`. Read by the `<Table>` height as well as the body,\n // so the two cannot disagree.\n const isEmptyState = !loading && data.length === 0;\n\n // A node that draws nothing is no help and no content: the `?` and the\n // band would open on an empty card. Decided here, once, and handed down\n // as `undefined` when it is empty.\n const hasHelp =\n props.help != null && props.help !== false && props.help !== \"\";\n const showToolbar =\n Boolean(props.filters) ||\n Boolean(props.leading) ||\n Boolean(props.toolbar) ||\n Boolean(props.actions?.length) ||\n hasHelp ||\n !props.hideColumnPicker ||\n !props.hideActionsMenu;\n // Drawn while a first fetch is out (its placeholders), and after that only\n // with something in it: a summary with no card and no content is no band.\n // A function is called on every render, which only builds its element: the\n // panel mounts it while open, and the counter is what tells it to reload.\n const rawSummaryContent = props.summary?.content;\n const summaryContent =\n typeof rawSummaryContent === \"function\"\n ? rawSummaryContent({ refreshKey })\n : rawSummaryContent;\n const hasSummaryContent =\n summaryContent != null && summaryContent !== false && summaryContent !== \"\";\n const showSummary =\n Boolean(props.summary) &&\n (summary.cards === undefined ||\n summary.cards.length > 0 ||\n hasSummaryContent);\n const cellPadding = DATA_TABLE_CELL_PADDING[props.cellPadding ?? \"normal\"];\n const squareRight = props.squareRight\n ? DATA_TABLE_SQUARE_RIGHT[`${props.squareRight}`]\n : undefined;\n // `flat` drops the outer frame and keeps the lines between the bands: the\n // toolbar keeps its bottom border, the footer its top one, and the rows\n // lose the sides. Applied after `squareRight`, which has nothing left to\n // square once the corners are gone.\n const flatTop = props.flat && \"rounded-none border-x-0 border-t-0\";\n const flatRows =\n props.flat && \"rounded-none border-x-0 border-t-0 border-b-0\";\n const flatBottom = props.flat && \"rounded-none border-x-0 border-b-0\";\n // The footer holds two controls, the size picker and the page links, and\n // the count beside them. A table that hid the picker (`pageSizes={[]}`)\n // and fits on one page has neither, and \"Page 1 of 1\" alone is a bar\n // saying nothing, so it goes. The links' condition is the footer's own.\n // `pagination={false}` holds for static rows only: a fetched table is\n // paged by the server, and hiding its pager would hide rows.\n const unpaged = props.pagination === false && Boolean(props.data);\n const showFooter =\n !unpaged &&\n ((props.pageSizes ?? PAGE_SIZES).length > 0 ||\n Boolean(meta?.totalPages && meta.totalPages > 1));\n const showColumnPicker = !props.hideColumnPicker && allColumnKeys.length > 0;\n const showActionsMenu = !props.hideActionsMenu;\n\n return (\n <ClientOnly>\n <div className={cn(\"flex flex-col gap-2\", props.className)}>\n {props.header && (\n <div className=\"flex items-center gap-2\">\n <div className=\"min-w-0 flex-1\">{props.header}</div>\n </div>\n )}\n\n {/*\n The summary opens the frame when it is there, so it takes the top\n corners `squareRight` squares, and whatever follows it (the filter\n bar, or the rows when there is none) joins under it the way the rows\n join the filter bar: flattened top, no top border, `-mt-2` against\n the wrapper's gap. The panel's own bottom border is the line\n between them.\n */}\n {showSummary && (\n <DataTableSummaryPanel\n title={\n props.summary?.title ??\n tr(\"dataTable.summary\", { default: \"Summary\" })\n }\n open={summary.open}\n onOpenChange={summary.setOpen}\n cards={summary.cards}\n loading={summary.loading}\n content={hasSummaryContent ? summaryContent : undefined}\n className={cn(squareRight?.top, flatTop, props.chromeClassName)}\n />\n )}\n\n {showToolbar && (\n <DataTableToolbar<T>\n columns={props.columns}\n filters={untyped.filters}\n form={form}\n filterDefinition={filterDefinition}\n shownFilters={filterVisibility.shown}\n onShownFiltersChange={filterVisibility.setShown}\n canResetFilters={canResetFilters}\n leading={props.leading}\n toolbar={props.toolbar}\n actions={props.actions}\n help={hasHelp ? props.help : undefined}\n isMobile={isMobile}\n showColumnPicker={showColumnPicker}\n showActionsMenu={showActionsMenu}\n activeFilterCount={activeFilterCount}\n canShare={canShare}\n resetFilters={resetFilters}\n shareFilters={shareFilters}\n orderedKeys={orderedKeys}\n visibleColumns={visibleColumns}\n toggleColumn={toggleColumn}\n reorderColumn={reorderColumn}\n isRefreshing={isRefreshing}\n handleRefreshClick={handleRefreshClick}\n className={cn(\n showSummary\n ? \"-mt-2 rounded-t-none border-t-0\"\n : squareRight?.top,\n flatTop,\n props.chromeClassName,\n )}\n />\n )}\n\n {hasCheckbox && selection.size > 0 && visibleBulkActions.length > 0 && (\n <DataTableBulkBar<T>\n selection={selection}\n selectedItems={selectedItems}\n visibleBulkActions={visibleBulkActions}\n bulkCtx={bulkCtx}\n clearSelection={clearSelection}\n />\n )}\n\n {/*\n The toolbar, the rows and the footer are one panel: each facing edge\n is flattened and its border dropped so no double line appears, and\n `-mt-2` cancels the wrapper's `gap-2`. The footer half follows\n `showFooter`, which is true for every table that keeps its size\n picker: gating the footer on `meta` alone would pop the bar in and\n flip this bottom border on every load, since `meta` starts null and\n only fills after the fetch. Only a table that hid the picker can\n lose it, and then the rows close the panel themselves.\n */}\n <div\n className={cn(\n \"flex min-h-0 flex-1 flex-col overflow-auto rounded-md border\",\n (showToolbar || showSummary) && \"-mt-2 rounded-t-none border-t-0\",\n showFooter ? \"rounded-b-none border-b-0\" : squareRight?.bottom,\n flatRows,\n // With no toolbar and no summary the rows open the table, so\n // their top-right corner is the one `squareRight` squares.\n !showToolbar && !showSummary && squareRight?.top,\n // `<Table>` wraps the table in a container div whose classes it\n // hardcodes, and only this table needs that container to grow,\n // so the one class it needs is set from out here instead.\n //\n // `grow`, NOT `flex-1`: `flex-1` sets the basis to 0, and in the\n // ordinary case this wrapper has no height of its own, so a 0\n // basis with nothing to grow into collapses the table to nothing.\n // `grow` keeps the content basis and only spends space that is\n // actually free, which is the full-height case.\n \"[&>[data-slot=table-container]]:grow\",\n )}\n >\n {/* `h-full` ONLY while the empty state is what is in the body.\n It is what lets that one row take the height the scroller grew\n into, so `align-middle` can centre the state in it.\n\n ⚠️ Never unconditionally. A CSS table given a height larger\n than its content does not leave the surplus at the bottom, it\n DISTRIBUTES IT ACROSS THE ROWS - so an unconditional `h-full`\n silently turns a short table into a tall one: Lore's Apps page,\n two rows in a full-height pane, rendered them 239px each. No\n unit test sees it (jsdom computes no layout) and it is invisible\n on a table long enough to fill its own container, which is why\n it reached e2e rather than review. */}\n <Table className={cn(isEmptyState && \"h-full\")}>\n {/* `bg-muted`, fully opaque, NOT the base header's `bg-muted/50`:\n this header is sticky, so anything translucent lets the rows\n scroll visibly through the column labels. Same tint, no\n transparency.\n\n Two inset lines, not one. The bottom is the divider against the\n first row; the top is the `--bevel` highlight, which is what\n gives the band its thickness. Inset shadows rather than borders\n because a border on a sticky `<thead>` is dropped by the\n collapsed table border model, and because the two lines have to\n sit INSIDE the header's own height: it is pinned at `top-0`\n against a scrolling body, so anything painted outside it is\n painted over. */}\n <TableHeader\n className={cn(\n // ⚠️ `[&_tr]:border-b-0` or the bottom rule is drawn TWICE: `TableHeader`\n // gives its rows a `border-b`, and the inset shadow above draws\n // the same line, so the band closed with 2px where it opens with\n // 1px. The inset one wins because it is what survives the sticky\n // header being painted over.\n \"bg-muted sticky top-0 z-10 shadow-[inset_0_1px_0_0_var(--bevel),inset_0_-1px_0_0_var(--border)] [&_tr]:border-b-0\",\n props.chromeClassName,\n )}\n >\n <DataTableHeaderRow<T>\n headClassName={cellPadding.head}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n allSelected={allSelected}\n someSelected={someSelected}\n toggleAll={toggleAll}\n sort={sort}\n toggleSort={toggleSort}\n setSortTo={setSortTo}\n moveColumn={moveColumn}\n toggleColumn={toggleColumn}\n />\n </TableHeader>\n <DataTableBody<T>\n cellClassName={cellPadding.cell}\n data={data}\n cellContext={cellContext}\n rowKeys={rowKeys}\n leaving={overlay.leaving}\n flash={overlay.flash}\n loading={loading}\n visibleCols={visibleCols}\n hasCheckbox={hasCheckbox}\n hasRowActions={hasRowActions}\n hasActiveFilters={hasActiveFilters}\n selection={selection}\n toggleRow={toggleRow}\n rowCtx={rowCtx}\n rowActions={props.rowActions}\n rowActionsDisplay={props.rowActionsDisplay}\n striped={props.striped}\n onRowClick={props.onRowClick}\n onRowHover={props.onRowHover}\n empty={props.empty}\n emptyMessage={props.emptyMessage}\n emptyState={props.emptyState}\n noMatchState={props.noMatchState}\n />\n </Table>\n </div>\n\n {/* A move is otherwise silent: nothing about a reordered table is\n spoken, and the visual change is the only feedback. Outside the\n table so it is not read as a cell. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {orderAnnouncement}\n </span>\n\n {showFooter && (\n <DataTableFooter\n pageSizes={props.pageSizes}\n sizeForm={sizeForm}\n meta={meta}\n isMobile={isMobile}\n setPage={setPage}\n className={cn(\n squareRight?.bottom,\n flatBottom,\n props.chromeClassName,\n )}\n />\n )}\n </div>\n </ClientOnly>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;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AY;MACrB;MACO;MACJ;MACT,SAAS,QAAQ;MACjB,OAAO,QAAQ;MACN;MACI;MACA;MACE;MACG;MACP;MACA;MACH;MACR,YAAY,MAAM;MAClB,mBAAmB,MAAM;MACzB,SAAS,MAAM;MACf,YAAY,MAAM;MAClB,YAAY,MAAM;MAClB,OAAO,MAAM;MACb,cAAc,MAAM;MACpB,YAAY,MAAM;MAClB,cAAc,MAAM;KACrB,CAAA,CACI;;GACJ,CAAA;GAKL,oBAAC,QAAD;IAAM,aAAU;IAAS,WAAU;IAChC,UAAA;GACG,CAAA;GAEL,cACC,oBAAC,iBAAD;IACE,WAAW,MAAM;IACP;IACJ;IACI;IACD;IACT,WAAW,GACT,aAAa,QACb,YACA,MAAM,eACR;GACD,CAAA;EAEA;CACK,CAAA,EAAA,CAAA;AAEhB"}
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from "react";
1
+ import { type ReactNode } from "react";
2
2
  import type { DataTableCellContext, DataTableEmptyState, ColumnDef, RowActionContext, RowActionEntry } from "./dataTableTypes.ts";
3
3
  export interface DataTableBodyProps<T> {
4
4
  /**
@@ -11,6 +11,15 @@ export interface DataTableBodyProps<T> {
11
11
  * One key per row of `data`, index for index.
12
12
  */
13
13
  rowKeys: string[];
14
+ /**
15
+ * Rows an optimistic remove is taking off: drawn, inert, playing their
16
+ * exit.
17
+ */
18
+ leaving?: ReadonlySet<string>;
19
+ /**
20
+ * Rows an optimistic patch just redrew, flashed once.
21
+ */
22
+ flash?: Set<string>;
14
23
  loading: boolean;
15
24
  /**
16
25
  * The visible columns, in the reader's order.
@@ -31,6 +40,14 @@ export interface DataTableBodyProps<T> {
31
40
  toggleRow: (item: T) => void;
32
41
  rowCtx: RowActionContext;
33
42
  rowActions?: (item: T) => RowActionEntry<T>[];
43
+ /**
44
+ * The table's `rowActionsDisplay`.
45
+ */
46
+ rowActionsDisplay?: "menu" | "inline";
47
+ /**
48
+ * The table's `striped`.
49
+ */
50
+ striped?: boolean;
34
51
  onRowClick?: (item: T) => void;
35
52
  onRowHover?: (item: T | undefined) => void;
36
53
  empty?: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"DataTableBody.d.ts","sourceRoot":"","sources":["../../src/table/DataTableBody.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,EACT,gBAAgB,EAChB,cAAc,EACf,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C;;OAEG;IACH,WAAW,EAAE,oBAAoB,CAAC;IAClC,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAClC,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7B,MAAM,EAAE,gBAAgB,CAAC;IACzB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,MAA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AAK,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IACtC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACpC;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAU,kBAAkB,CAAC,CAAC,CAAC,gCA6L7D,CAAC"}
@@ -1,10 +1,13 @@
1
1
  import { Checkbox } from "../core/Checkbox.js";
2
2
  import { TableBody, TableCell, TableRow } from "../core/Table.js";
3
3
  import { cn } from "../core/utils.js";
4
+ import { DataTableRowActionsInline } from "./DataTableRowActionsInline.js";
4
5
  import { DataTableRowActionsMenu } from "./DataTableRowActionsMenu.js";
5
6
  import { DataTableSkeletonRows } from "./DataTableSkeletonRows.js";
7
+ import { useRowMotion } from "./useRowMotion.js";
6
8
  import { useI18n } from "alepha/react/i18n";
7
9
  import { Inbox, SearchX } from "lucide-react";
10
+ import { useRef } from "react";
8
11
  import { jsx, jsxs } from "react/jsx-runtime";
9
12
  // src/table/DataTableBody.tsx
10
13
  /**
@@ -14,74 +17,96 @@ import { jsx, jsxs } from "react/jsx-runtime";
14
17
  const DataTableBody = (props) => {
15
18
  const { data, rowKeys, loading, visibleCols, hasCheckbox, hasRowActions, hasActiveFilters, selection, toggleRow, rowCtx } = props;
16
19
  const { tr } = useI18n();
20
+ const bodyRef = useRef(null);
21
+ const leaving = props.leaving ?? NO_KEYS;
22
+ useRowMotion({
23
+ body: bodyRef,
24
+ rowKeys,
25
+ leaving,
26
+ flash: props.flash ?? NO_FLASH
27
+ });
17
28
  const emptyOverride = (hasActiveFilters ? props.noMatchState : props.emptyState) ?? {};
18
29
  const EmptyIcon = emptyOverride.icon ?? (hasActiveFilters ? SearchX : Inbox);
19
30
  const emptyTitle = emptyOverride.title ?? props.emptyMessage ?? String(hasActiveFilters ? tr("dataTable.noMatchTitle", { default: "No match" }) : tr("dataTable.emptyTitle", { default: "No items" }));
20
31
  const emptyAction = emptyOverride.action;
21
32
  const emptyDescription = emptyOverride.description ?? (props.emptyMessage ? void 0 : String(hasActiveFilters ? tr("dataTable.noMatchDescription", { default: "Try adjusting or clearing the filters." }) : tr("dataTable.emptyDescription", { default: "Nothing here yet." })));
22
- return /* @__PURE__ */ jsx(TableBody, { children: loading && data.length === 0 ? /* @__PURE__ */ jsx(DataTableSkeletonRows, {
23
- cellClassName: props.cellClassName,
24
- rows: 5,
25
- cols: visibleCols.length + (hasCheckbox ? 1 : 0) + (hasRowActions ? 1 : 0)
26
- }) : data.length === 0 ? /* @__PURE__ */ jsx(TableRow, {
27
- className: "hover:bg-transparent",
28
- children: /* @__PURE__ */ jsx(TableCell, {
29
- colSpan: visibleCols.length + (hasCheckbox ? 1 : 0) + (hasRowActions ? 1 : 0),
30
- className: "h-full p-0 whitespace-normal",
31
- children: props.empty ?? /* @__PURE__ */ jsxs("div", {
32
- className: "flex flex-col items-center justify-center gap-2 px-6 py-12 text-center",
33
+ return /* @__PURE__ */ jsx(TableBody, {
34
+ ref: bodyRef,
35
+ children: loading && data.length === 0 ? /* @__PURE__ */ jsx(DataTableSkeletonRows, {
36
+ cellClassName: props.cellClassName,
37
+ rows: 5,
38
+ cols: visibleCols.length + (hasCheckbox ? 1 : 0) + (hasRowActions ? 1 : 0)
39
+ }) : data.length === 0 ? /* @__PURE__ */ jsx(TableRow, {
40
+ className: "hover:bg-transparent",
41
+ children: /* @__PURE__ */ jsx(TableCell, {
42
+ colSpan: visibleCols.length + (hasCheckbox ? 1 : 0) + (hasRowActions ? 1 : 0),
43
+ className: "h-full p-0 whitespace-normal",
44
+ children: props.empty ?? /* @__PURE__ */ jsxs("div", {
45
+ className: "flex flex-col items-center justify-center gap-2 px-6 py-12 text-center",
46
+ children: [
47
+ /* @__PURE__ */ jsx(EmptyIcon, { className: "text-muted-foreground size-8 opacity-40" }),
48
+ /* @__PURE__ */ jsx("p", {
49
+ className: "text-foreground text-sm font-medium",
50
+ children: emptyTitle
51
+ }),
52
+ emptyDescription ? /* @__PURE__ */ jsx("p", {
53
+ className: "text-muted-foreground max-w-xs text-sm text-balance",
54
+ children: emptyDescription
55
+ }) : null,
56
+ emptyAction ? /* @__PURE__ */ jsx("div", {
57
+ className: "pt-2",
58
+ children: emptyAction
59
+ }) : null
60
+ ]
61
+ })
62
+ })
63
+ }) : data.map((item, rowIndex) => {
64
+ const key = rowKeys[rowIndex];
65
+ const isSelected = selection.has(key);
66
+ const isLeaving = leaving.has(key);
67
+ return /* @__PURE__ */ jsxs(TableRow, {
68
+ "data-row-key": key,
69
+ "data-leaving": isLeaving || void 0,
70
+ "aria-hidden": isLeaving || void 0,
71
+ inert: isLeaving || void 0,
72
+ onClick: () => props.onRowClick?.(item),
73
+ onMouseEnter: () => props.onRowHover?.(item),
74
+ onMouseLeave: () => props.onRowHover?.(void 0),
75
+ className: cn(props.onRowClick && "cursor-pointer", props.striped && "even:bg-muted/40", isSelected && "bg-muted/30"),
33
76
  children: [
34
- /* @__PURE__ */ jsx(EmptyIcon, { className: "text-muted-foreground size-8 opacity-40" }),
35
- /* @__PURE__ */ jsx("p", {
36
- className: "text-foreground text-sm font-medium",
37
- children: emptyTitle
77
+ hasCheckbox && /* @__PURE__ */ jsx(TableCell, {
78
+ className: props.cellClassName,
79
+ onClick: (e) => e.stopPropagation(),
80
+ children: /* @__PURE__ */ jsx(Checkbox, {
81
+ checked: isSelected,
82
+ onCheckedChange: () => toggleRow(item),
83
+ "aria-label": tr("dataTable.selectRow", { default: "Select row" })
84
+ })
38
85
  }),
39
- emptyDescription ? /* @__PURE__ */ jsx("p", {
40
- className: "text-muted-foreground max-w-xs text-sm text-balance",
41
- children: emptyDescription
42
- }) : null,
43
- emptyAction ? /* @__PURE__ */ jsx("div", {
44
- className: "pt-2",
45
- children: emptyAction
46
- }) : null
86
+ visibleCols.map(([key, def]) => /* @__PURE__ */ jsx(TableCell, {
87
+ className: cn(props.cellClassName, def.className, def.align === "right" && "text-right", def.align === "center" && "text-center"),
88
+ children: def.cell(item, props.cellContext)
89
+ }, key)),
90
+ hasRowActions && /* @__PURE__ */ jsx(TableCell, {
91
+ className: cn(props.cellClassName, "text-right"),
92
+ onClick: (e) => e.stopPropagation(),
93
+ children: props.rowActionsDisplay === "inline" ? /* @__PURE__ */ jsx(DataTableRowActionsInline, {
94
+ actions: props.rowActions(item),
95
+ item,
96
+ ctx: rowCtx
97
+ }) : /* @__PURE__ */ jsx(DataTableRowActionsMenu, {
98
+ actions: props.rowActions(item),
99
+ item,
100
+ ctx: rowCtx
101
+ })
102
+ })
47
103
  ]
48
- })
104
+ }, key);
49
105
  })
50
- }) : data.map((item, rowIndex) => {
51
- const key = rowKeys[rowIndex];
52
- const isSelected = selection.has(key);
53
- return /* @__PURE__ */ jsxs(TableRow, {
54
- onClick: () => props.onRowClick?.(item),
55
- onMouseEnter: () => props.onRowHover?.(item),
56
- onMouseLeave: () => props.onRowHover?.(void 0),
57
- className: cn(props.onRowClick && "cursor-pointer", isSelected && "bg-muted/30"),
58
- children: [
59
- hasCheckbox && /* @__PURE__ */ jsx(TableCell, {
60
- className: props.cellClassName,
61
- onClick: (e) => e.stopPropagation(),
62
- children: /* @__PURE__ */ jsx(Checkbox, {
63
- checked: isSelected,
64
- onCheckedChange: () => toggleRow(item),
65
- "aria-label": tr("dataTable.selectRow", { default: "Select row" })
66
- })
67
- }),
68
- visibleCols.map(([key, def]) => /* @__PURE__ */ jsx(TableCell, {
69
- className: cn(props.cellClassName, def.className, def.align === "right" && "text-right", def.align === "center" && "text-center"),
70
- children: def.cell(item, props.cellContext)
71
- }, key)),
72
- hasRowActions && /* @__PURE__ */ jsx(TableCell, {
73
- className: cn(props.cellClassName, "text-right"),
74
- onClick: (e) => e.stopPropagation(),
75
- children: /* @__PURE__ */ jsx(DataTableRowActionsMenu, {
76
- actions: props.rowActions(item),
77
- item,
78
- ctx: rowCtx
79
- })
80
- })
81
- ]
82
- }, key);
83
- }) });
106
+ });
84
107
  };
108
+ const NO_KEYS = /* @__PURE__ */ new Set();
109
+ const NO_FLASH = /* @__PURE__ */ new Set();
85
110
  export { DataTableBody };
86
111
 
87
112
  //# sourceMappingURL=DataTableBody.js.map