@arbidocs/blocks 0.5.182 → 0.5.183

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 (378) hide show
  1. package/README.md +30 -0
  2. package/dist/{ClippingPdfViewer-D5BYHEAH.cjs → ClippingPdfViewer-Z6L5DZW5.cjs} +4 -4
  3. package/dist/{ClippingPdfViewer-D5BYHEAH.cjs.map → ClippingPdfViewer-Z6L5DZW5.cjs.map} +1 -1
  4. package/dist/{ConnectedCallDock-C5UPUMMJ.cjs → ConnectedCallDock-CF7KF5KM.cjs} +6 -6
  5. package/dist/{ConnectedCallDock-C5UPUMMJ.cjs.map → ConnectedCallDock-CF7KF5KM.cjs.map} +1 -1
  6. package/dist/{ConnectedCallRoom-SEMH4DSA.cjs → ConnectedCallRoom-NQOE2RYD.cjs} +6 -6
  7. package/dist/{ConnectedCallRoom-SEMH4DSA.cjs.map → ConnectedCallRoom-NQOE2RYD.cjs.map} +1 -1
  8. package/dist/{ConnectedNativeDocxComparison-3MRTTNR2.cjs → ConnectedNativeDocxComparison-3KTHPCMT.cjs} +11 -10
  9. package/dist/{ConnectedNativeDocxComparison-3MRTTNR2.cjs.map → ConnectedNativeDocxComparison-3KTHPCMT.cjs.map} +1 -1
  10. package/dist/ConnectedPresentation-LNDESKYE.cjs +1 -1
  11. package/dist/{ConnectedSlidesTab-LEA5OW75.cjs → ConnectedSlidesTab-SYDDGJWM.cjs} +3 -3
  12. package/dist/{ConnectedSlidesTab-LEA5OW75.cjs.map → ConnectedSlidesTab-SYDDGJWM.cjs.map} +1 -1
  13. package/dist/{ConnectedStreamedWordArtifact-HNTS6HS4.cjs → ConnectedStreamedWordArtifact-LUM6WE7F.cjs} +11 -10
  14. package/dist/{ConnectedStreamedWordArtifact-HNTS6HS4.cjs.map → ConnectedStreamedWordArtifact-LUM6WE7F.cjs.map} +1 -1
  15. package/dist/{DocumentReviewCard-RPHIQZ2Y.cjs → DocumentReviewCard-NKCKBY3P.cjs} +15 -13
  16. package/dist/DocumentReviewCard-NKCKBY3P.cjs.map +1 -0
  17. package/dist/{FilesViewerDialog-PZ5H435S.cjs → FilesViewerDialog-T4SOKUKO.cjs} +14 -12
  18. package/dist/FilesViewerDialog-T4SOKUKO.cjs.map +1 -0
  19. package/dist/{NativeDocxEditor-T7FSMKG3.cjs → NativeDocxEditor-JJQJEYQD.cjs} +8 -7
  20. package/dist/{NativeDocxEditor-T7FSMKG3.cjs.map → NativeDocxEditor-JJQJEYQD.cjs.map} +1 -1
  21. package/dist/WorkspaceTableView-QT63XYII.cjs +1 -1
  22. package/dist/agents/index.cjs +1 -1
  23. package/dist/{ai-XIT4MY3S.cjs → ai-CTJWECJ5.cjs} +14 -14
  24. package/dist/ai-CTJWECJ5.cjs.map +1 -0
  25. package/dist/calls/index.cjs +3 -3
  26. package/dist/chat/index.cjs +26 -26
  27. package/dist/{chunk-4AT2LJ2H.cjs → chunk-3YPVXIFF.cjs} +6 -6
  28. package/dist/{chunk-4AT2LJ2H.cjs.map → chunk-3YPVXIFF.cjs.map} +1 -1
  29. package/dist/{chunk-GLFMRQBT.cjs → chunk-4TCOUQMC.cjs} +4 -4
  30. package/dist/{chunk-GLFMRQBT.cjs.map → chunk-4TCOUQMC.cjs.map} +1 -1
  31. package/dist/{chunk-DDWLMYRO.cjs → chunk-4XKROAMO.cjs} +8 -3
  32. package/dist/chunk-4XKROAMO.cjs.map +1 -0
  33. package/dist/{chunk-AWWGV5LL.cjs → chunk-6VIS6B3O.cjs} +28 -28
  34. package/dist/{chunk-AWWGV5LL.cjs.map → chunk-6VIS6B3O.cjs.map} +1 -1
  35. package/dist/chunk-76S6WTEC.cjs +39 -0
  36. package/dist/chunk-76S6WTEC.cjs.map +1 -0
  37. package/dist/{chunk-MZ7IUHQA.cjs → chunk-7ARRFRQR.cjs} +38 -38
  38. package/dist/chunk-7ARRFRQR.cjs.map +1 -0
  39. package/dist/{chunk-CYMAF656.cjs → chunk-7QZXHSQX.cjs} +18 -5
  40. package/dist/chunk-7QZXHSQX.cjs.map +1 -0
  41. package/dist/chunk-AZP4ABNL.cjs +18 -0
  42. package/dist/{chunk-TUURH4NE.cjs.map → chunk-AZP4ABNL.cjs.map} +1 -1
  43. package/dist/{chunk-TJY7XPDE.cjs → chunk-CWECDS4I.cjs} +4 -95
  44. package/dist/chunk-CWECDS4I.cjs.map +1 -0
  45. package/dist/{chunk-YC72ZCV4.cjs → chunk-DWUWPF2A.cjs} +147 -90
  46. package/dist/chunk-DWUWPF2A.cjs.map +1 -0
  47. package/dist/{chunk-POUMLXMJ.cjs → chunk-FTSXCBUO.cjs} +6 -6
  48. package/dist/{chunk-POUMLXMJ.cjs.map → chunk-FTSXCBUO.cjs.map} +1 -1
  49. package/dist/chunk-GISMY7J7.cjs +99 -0
  50. package/dist/chunk-GISMY7J7.cjs.map +1 -0
  51. package/dist/chunk-GXJW5EK5.cjs +102 -0
  52. package/dist/chunk-GXJW5EK5.cjs.map +1 -0
  53. package/dist/{chunk-HX5SALXN.cjs → chunk-H3C5BY2H.cjs} +4 -4
  54. package/dist/{chunk-HX5SALXN.cjs.map → chunk-H3C5BY2H.cjs.map} +1 -1
  55. package/dist/{chunk-G2B2BWE5.cjs → chunk-HGQGXY5Q.cjs} +4 -4
  56. package/dist/{chunk-G2B2BWE5.cjs.map → chunk-HGQGXY5Q.cjs.map} +1 -1
  57. package/dist/{chunk-7H7KIJW2.cjs → chunk-HQ6SK34T.cjs} +3 -3
  58. package/dist/{chunk-7H7KIJW2.cjs.map → chunk-HQ6SK34T.cjs.map} +1 -1
  59. package/dist/{chunk-YHABS4UE.cjs → chunk-HYULUR6E.cjs} +12 -12
  60. package/dist/{chunk-YHABS4UE.cjs.map → chunk-HYULUR6E.cjs.map} +1 -1
  61. package/dist/chunk-I24N4OSB.cjs +57 -0
  62. package/dist/chunk-I24N4OSB.cjs.map +1 -0
  63. package/dist/{chunk-TQATDAJV.cjs → chunk-J4X3LYGC.cjs} +4 -4
  64. package/dist/{chunk-TQATDAJV.cjs.map → chunk-J4X3LYGC.cjs.map} +1 -1
  65. package/dist/chunk-KHZEFLQC.cjs +524 -0
  66. package/dist/chunk-KHZEFLQC.cjs.map +1 -0
  67. package/dist/{chunk-DKKW7GOJ.cjs → chunk-LIAC6O7W.cjs} +4 -4
  68. package/dist/{chunk-DKKW7GOJ.cjs.map → chunk-LIAC6O7W.cjs.map} +1 -1
  69. package/dist/{chunk-MWHVETKN.cjs → chunk-LIJB6XOR.cjs} +47 -7
  70. package/dist/chunk-LIJB6XOR.cjs.map +1 -0
  71. package/dist/{chunk-PJ5OQ5VB.cjs → chunk-LNYICHFJ.cjs} +23 -23
  72. package/dist/{chunk-PJ5OQ5VB.cjs.map → chunk-LNYICHFJ.cjs.map} +1 -1
  73. package/dist/{chunk-UC6Z7E6C.cjs → chunk-LRBX4VIG.cjs} +4 -4
  74. package/dist/{chunk-UC6Z7E6C.cjs.map → chunk-LRBX4VIG.cjs.map} +1 -1
  75. package/dist/{chunk-JITYC4OS.cjs → chunk-NDRE7LD2.cjs} +17 -2
  76. package/dist/chunk-NDRE7LD2.cjs.map +1 -0
  77. package/dist/{chunk-FUKN3PI5.cjs → chunk-NGT3P5ZG.cjs} +100 -506
  78. package/dist/chunk-NGT3P5ZG.cjs.map +1 -0
  79. package/dist/{chunk-2D5GZMSK.cjs → chunk-SFAAOEQE.cjs} +43 -30
  80. package/dist/chunk-SFAAOEQE.cjs.map +1 -0
  81. package/dist/{chunk-KULGPKLY.cjs → chunk-TBDQGSFI.cjs} +4 -4
  82. package/dist/{chunk-KULGPKLY.cjs.map → chunk-TBDQGSFI.cjs.map} +1 -1
  83. package/dist/{chunk-BQOL4XNZ.cjs → chunk-U46OGRCO.cjs} +94 -10
  84. package/dist/chunk-U46OGRCO.cjs.map +1 -0
  85. package/dist/{chunk-UTYEXDJK.cjs → chunk-UFDUDQYT.cjs} +887 -168
  86. package/dist/chunk-UFDUDQYT.cjs.map +1 -0
  87. package/dist/chunk-V5P5MRSR.cjs +21 -0
  88. package/dist/chunk-V5P5MRSR.cjs.map +1 -0
  89. package/dist/{chunk-N33U2SB5.cjs → chunk-VBD4RJOL.cjs} +730 -72
  90. package/dist/chunk-VBD4RJOL.cjs.map +1 -0
  91. package/dist/{chunk-ADMNU2CR.cjs → chunk-W5UGKUV7.cjs} +66 -132
  92. package/dist/chunk-W5UGKUV7.cjs.map +1 -0
  93. package/dist/{chunk-6EJ7KD4U.cjs → chunk-WDL3TOMX.cjs} +6 -6
  94. package/dist/{chunk-6EJ7KD4U.cjs.map → chunk-WDL3TOMX.cjs.map} +1 -1
  95. package/dist/{chunk-S4KKJX3G.cjs → chunk-WIQDXRRB.cjs} +12 -12
  96. package/dist/{chunk-S4KKJX3G.cjs.map → chunk-WIQDXRRB.cjs.map} +1 -1
  97. package/dist/{chunk-6CPJ5ZOY.cjs → chunk-YM77I6V7.cjs} +3 -3
  98. package/dist/{chunk-6CPJ5ZOY.cjs.map → chunk-YM77I6V7.cjs.map} +1 -1
  99. package/dist/{chunk-ICZSVCDT.cjs → chunk-YYMCN76N.cjs} +5 -5
  100. package/dist/{chunk-ICZSVCDT.cjs.map → chunk-YYMCN76N.cjs.map} +1 -1
  101. package/dist/{chunk-JKTUL4L3.cjs → chunk-ZON25DCD.cjs} +5 -5
  102. package/dist/{chunk-JKTUL4L3.cjs.map → chunk-ZON25DCD.cjs.map} +1 -1
  103. package/dist/{chunk-YBDHWNFZ.cjs → chunk-ZTLPUUZB.cjs} +20 -20
  104. package/dist/{chunk-YBDHWNFZ.cjs.map → chunk-ZTLPUUZB.cjs.map} +1 -1
  105. package/dist/components/DetailPanel.d.ts +46 -3
  106. package/dist/components/DetailPanel.js +94 -10
  107. package/dist/components/DetailPanel.js.map +2 -2
  108. package/dist/connect/docx.cjs +15 -14
  109. package/dist/connect/docx.cjs.map +1 -1
  110. package/dist/connect/index.cjs +4478 -1585
  111. package/dist/connect/index.cjs.map +1 -1
  112. package/dist/connect/index.d.ts +2 -1
  113. package/dist/connect/index.js +5 -1
  114. package/dist/connect/index.js.map +2 -2
  115. package/dist/connect/viewer.cjs +12 -10
  116. package/dist/connection/databases/ConnectedDatabasesPage.d.ts +22 -1
  117. package/dist/connection/databases/ConnectedDatabasesPage.js +189 -422
  118. package/dist/connection/databases/ConnectedDatabasesPage.js.map +2 -2
  119. package/dist/connection/databases/ConnectedRecentDatabases.d.ts +15 -0
  120. package/dist/connection/databases/ConnectedRecentDatabases.js +80 -0
  121. package/dist/connection/databases/ConnectedRecentDatabases.js.map +7 -0
  122. package/dist/connection/databases/DatabaseViewsMenu.d.ts +8 -4
  123. package/dist/connection/databases/DatabaseViewsMenu.js +60 -27
  124. package/dist/connection/databases/DatabaseViewsMenu.js.map +2 -2
  125. package/dist/connection/databases/DatabaseWorkbench.d.ts +10 -0
  126. package/dist/connection/databases/DatabaseWorkbench.js +681 -0
  127. package/dist/connection/databases/DatabaseWorkbench.js.map +7 -0
  128. package/dist/connection/databases/databaseViewState.d.ts +12 -0
  129. package/dist/connection/databases/databaseViewState.js +50 -0
  130. package/dist/connection/databases/databaseViewState.js.map +7 -0
  131. package/dist/connection/databases/fixedPins.d.ts +6 -0
  132. package/dist/connection/databases/fixedPins.js +19 -0
  133. package/dist/connection/databases/fixedPins.js.map +7 -0
  134. package/dist/connection/databases/index.d.ts +6 -1
  135. package/dist/connection/databases/index.js +9 -1
  136. package/dist/connection/databases/index.js.map +2 -2
  137. package/dist/connection/databases/source.d.ts +26 -0
  138. package/dist/connection/databases/toRowView.d.ts +4 -0
  139. package/dist/connection/databases/toRowView.js +11 -0
  140. package/dist/connection/databases/toRowView.js.map +7 -0
  141. package/dist/connection/databases/useApiDatabaseSource.d.ts +11 -0
  142. package/dist/connection/databases/useApiDatabaseSource.js +449 -0
  143. package/dist/connection/databases/useApiDatabaseSource.js.map +7 -0
  144. package/dist/connection/databases/useApiViewStore.d.ts +5 -0
  145. package/dist/connection/databases/useApiViewStore.js +57 -0
  146. package/dist/connection/databases/useApiViewStore.js.map +7 -0
  147. package/dist/connection/databases/useDeviceLayoutSettings.d.ts +6 -0
  148. package/dist/connection/databases/useDeviceLayoutSettings.js +57 -0
  149. package/dist/connection/databases/useDeviceLayoutSettings.js.map +7 -0
  150. package/dist/connection/databases/useLayoutRows.d.ts +13 -0
  151. package/dist/connection/databases/useLayoutRows.js +89 -0
  152. package/dist/connection/databases/useLayoutRows.js.map +7 -0
  153. package/dist/connection/databases/useSourceEntries.d.ts +6 -0
  154. package/dist/connection/databases/useSourceEntries.js +8 -0
  155. package/dist/connection/databases/useSourceEntries.js.map +7 -0
  156. package/dist/connection/facts/ConnectedFactsPage.d.ts +11 -1
  157. package/dist/connection/facts/ConnectedFactsPage.js +42 -10
  158. package/dist/connection/facts/ConnectedFactsPage.js.map +2 -2
  159. package/dist/connection/facts/FactMarkdownEditor.d.ts +19 -1
  160. package/dist/connection/facts/FactMarkdownEditor.js +67 -49
  161. package/dist/connection/facts/FactMarkdownEditor.js.map +2 -2
  162. package/dist/connection/facts/FactSourcesPopover.d.ts +3 -1
  163. package/dist/connection/facts/FactSourcesPopover.js +71 -61
  164. package/dist/connection/facts/FactSourcesPopover.js.map +2 -2
  165. package/dist/connection/facts/FactsQuickFilters.d.ts +16 -0
  166. package/dist/connection/facts/FactsQuickFilters.js +57 -0
  167. package/dist/connection/facts/FactsQuickFilters.js.map +7 -0
  168. package/dist/connection/facts/factsRows.d.ts +49 -0
  169. package/dist/connection/facts/factsRows.js +103 -0
  170. package/dist/connection/facts/factsRows.js.map +7 -0
  171. package/dist/connection/facts/factsScope.d.ts +24 -0
  172. package/dist/connection/facts/factsScope.js +32 -0
  173. package/dist/connection/facts/factsScope.js.map +7 -0
  174. package/dist/connection/facts/factsSource.d.ts +12 -0
  175. package/dist/connection/facts/factsSource.js +1320 -0
  176. package/dist/connection/facts/factsSource.js.map +7 -0
  177. package/dist/connection/facts/useFactActions.d.ts +2 -2
  178. package/dist/connection/facts/useFactActions.js +4 -0
  179. package/dist/connection/facts/useFactActions.js.map +2 -2
  180. package/dist/connection/facts/useFactComposer.d.ts +8 -2
  181. package/dist/connection/facts/useFactComposer.js +31 -8
  182. package/dist/connection/facts/useFactComposer.js.map +2 -2
  183. package/dist/connection/facts/view-keys.d.ts +4 -0
  184. package/dist/connection/facts/view-keys.js +2 -0
  185. package/dist/connection/facts/view-keys.js.map +2 -2
  186. package/dist/connection/files/explorer/FileTiles.js +2 -2
  187. package/dist/connection/files/explorer/FileTiles.js.map +2 -2
  188. package/dist/connection/files/page/ConnectedFilesPage.js +4 -1
  189. package/dist/connection/files/page/ConnectedFilesPage.js.map +2 -2
  190. package/dist/connection/files/views/useTableViews.js +11 -3
  191. package/dist/connection/files/views/useTableViews.js.map +2 -2
  192. package/dist/connection/live-blocks/list-rows.d.ts +10 -0
  193. package/dist/connection/live-blocks/list-rows.js +12 -0
  194. package/dist/connection/live-blocks/list-rows.js.map +2 -2
  195. package/dist/connection/viewer/pdf/PdfPassageHighlights.d.ts +10 -2
  196. package/dist/connection/viewer/pdf/PdfPassageHighlights.js +57 -26
  197. package/dist/connection/viewer/pdf/PdfPassageHighlights.js.map +2 -2
  198. package/dist/connection/viewer/pdf/passageHighlights.d.ts +8 -0
  199. package/dist/connection/viewer/pdf/passageHighlights.js +15 -0
  200. package/dist/connection/viewer/pdf/passageHighlights.js.map +2 -2
  201. package/dist/connection/viewer/pdf/usePdfPassageHighlights.js +31 -5
  202. package/dist/connection/viewer/pdf/usePdfPassageHighlights.js.map +2 -2
  203. package/dist/connection/workspace-dashboard/ConnectedWorkspaceDashboard.d.ts +9 -2
  204. package/dist/connection/workspace-dashboard/ConnectedWorkspaceDashboard.js +16 -6
  205. package/dist/connection/workspace-dashboard/ConnectedWorkspaceDashboard.js.map +2 -2
  206. package/dist/dashboards/ConditionsEditor.d.ts +14 -1
  207. package/dist/dashboards/ConditionsEditor.js +45 -5
  208. package/dist/dashboards/ConditionsEditor.js.map +2 -2
  209. package/dist/dashboards/index.cjs +9 -9
  210. package/dist/databases/ColumnConfigFields.js +1 -1
  211. package/dist/databases/ColumnConfigFields.js.map +2 -2
  212. package/dist/databases/DatabaseColumnDialog.d.ts +6 -1
  213. package/dist/databases/DatabaseColumnDialog.js +44 -3
  214. package/dist/databases/DatabaseColumnDialog.js.map +2 -2
  215. package/dist/databases/DatabaseFilterMenu.d.ts +23 -1
  216. package/dist/databases/DatabaseFilterMenu.js +37 -7
  217. package/dist/databases/DatabaseFilterMenu.js.map +2 -2
  218. package/dist/databases/DatabaseList.d.ts +22 -1
  219. package/dist/databases/DatabaseList.js +44 -9
  220. package/dist/databases/DatabaseList.js.map +2 -2
  221. package/dist/databases/DatabaseRowDetail.d.ts +40 -3
  222. package/dist/databases/DatabaseRowDetail.js +107 -20
  223. package/dist/databases/DatabaseRowDetail.js.map +2 -2
  224. package/dist/databases/DatabaseTable.d.ts +44 -5
  225. package/dist/databases/DatabaseTable.js +165 -15
  226. package/dist/databases/DatabaseTable.js.map +2 -2
  227. package/dist/databases/DatabaseToolbar.d.ts +29 -3
  228. package/dist/databases/DatabaseToolbar.js +148 -96
  229. package/dist/databases/DatabaseToolbar.js.map +2 -2
  230. package/dist/databases/DateSpanEditor.d.ts +32 -0
  231. package/dist/databases/DateSpanEditor.js +155 -0
  232. package/dist/databases/DateSpanEditor.js.map +7 -0
  233. package/dist/databases/LabelChip.d.ts +6 -0
  234. package/dist/databases/LabelChip.js +34 -0
  235. package/dist/databases/LabelChip.js.map +7 -0
  236. package/dist/databases/LabelsCell.d.ts +13 -0
  237. package/dist/databases/LabelsCell.js +38 -0
  238. package/dist/databases/LabelsCell.js.map +7 -0
  239. package/dist/databases/LabelsField.d.ts +6 -0
  240. package/dist/databases/LabelsField.js +17 -0
  241. package/dist/databases/LabelsField.js.map +7 -0
  242. package/dist/databases/SourcesCell.d.ts +21 -0
  243. package/dist/databases/SourcesCell.js +106 -0
  244. package/dist/databases/SourcesCell.js.map +7 -0
  245. package/dist/databases/SourcesField.d.ts +7 -0
  246. package/dist/databases/SourcesField.js +36 -0
  247. package/dist/databases/SourcesField.js.map +7 -0
  248. package/dist/databases/column-kits.d.ts +28 -0
  249. package/dist/databases/column-kits.js +87 -0
  250. package/dist/databases/column-kits.js.map +7 -0
  251. package/dist/databases/column-types.d.ts +36 -4
  252. package/dist/databases/column-types.js +22 -3
  253. package/dist/databases/column-types.js.map +2 -2
  254. package/dist/databases/databaseColumns.d.ts +29 -2
  255. package/dist/databases/databaseColumns.js +174 -46
  256. package/dist/databases/databaseColumns.js.map +2 -2
  257. package/dist/databases/index.cjs +135 -54
  258. package/dist/databases/index.d.ts +12 -5
  259. package/dist/databases/index.js +17 -0
  260. package/dist/databases/index.js.map +2 -2
  261. package/dist/databases/layouts/DatabaseCalendar.d.ts +17 -0
  262. package/dist/databases/layouts/DatabaseCalendar.js +63 -0
  263. package/dist/databases/layouts/DatabaseCalendar.js.map +7 -0
  264. package/dist/databases/layouts/DatabaseGantt.d.ts +9 -0
  265. package/dist/databases/layouts/DatabaseGantt.js +52 -0
  266. package/dist/databases/layouts/DatabaseGantt.js.map +7 -0
  267. package/dist/databases/layouts/DatabaseLayoutSwitcher.d.ts +43 -0
  268. package/dist/databases/layouts/DatabaseLayoutSwitcher.js +190 -0
  269. package/dist/databases/layouts/DatabaseLayoutSwitcher.js.map +7 -0
  270. package/dist/databases/layouts/definitions.d.ts +11 -0
  271. package/dist/databases/layouts/definitions.js +56 -0
  272. package/dist/databases/layouts/definitions.js.map +7 -0
  273. package/dist/databases/layouts/index.d.ts +7 -0
  274. package/dist/databases/layouts/index.js +27 -0
  275. package/dist/databases/layouts/index.js.map +7 -0
  276. package/dist/databases/layouts/resolveLayoutSettings.d.ts +13 -0
  277. package/dist/databases/layouts/resolveLayoutSettings.js +47 -0
  278. package/dist/databases/layouts/resolveLayoutSettings.js.map +7 -0
  279. package/dist/databases/layouts/rowsToTimelineItems.d.ts +19 -0
  280. package/dist/databases/layouts/rowsToTimelineItems.js +81 -0
  281. package/dist/databases/layouts/rowsToTimelineItems.js.map +7 -0
  282. package/dist/databases/layouts/undated.d.ts +6 -0
  283. package/dist/databases/layouts/undated.js +10 -0
  284. package/dist/databases/layouts/undated.js.map +7 -0
  285. package/dist/databases/linkCells.d.ts +14 -1
  286. package/dist/databases/linkCells.js +11 -5
  287. package/dist/databases/linkCells.js.map +2 -2
  288. package/dist/databases/local-query.d.ts +7 -0
  289. package/dist/databases/local-query.js +89 -0
  290. package/dist/databases/local-query.js.map +7 -0
  291. package/dist/databases/source.d.ts +291 -0
  292. package/dist/databases/sourcesOverflow.d.ts +5 -0
  293. package/dist/databases/sourcesOverflow.js +10 -0
  294. package/dist/databases/sourcesOverflow.js.map +7 -0
  295. package/dist/docx/index.cjs +40 -39
  296. package/dist/embed/index.cjs +17 -14
  297. package/dist/facts/FactDateInput.d.ts +3 -1
  298. package/dist/facts/FactDateInput.js +110 -93
  299. package/dist/facts/FactDateInput.js.map +2 -2
  300. package/dist/facts/FactLabelsCell.d.ts +4 -0
  301. package/dist/facts/FactLabelsCell.js +27 -13
  302. package/dist/facts/FactLabelsCell.js.map +2 -2
  303. package/dist/facts/FactPassages.d.ts +6 -1
  304. package/dist/facts/FactPassages.js +6 -1
  305. package/dist/facts/FactPassages.js.map +2 -2
  306. package/dist/facts/FactsScopeEmpty.d.ts +8 -0
  307. package/dist/facts/FactsScopeEmpty.js +29 -0
  308. package/dist/facts/FactsScopeEmpty.js.map +7 -0
  309. package/dist/facts/FactsScopePicker.d.ts +33 -0
  310. package/dist/facts/FactsScopePicker.js +108 -0
  311. package/dist/facts/FactsScopePicker.js.map +7 -0
  312. package/dist/facts/index.cjs +107 -94
  313. package/dist/facts/index.cjs.map +1 -1
  314. package/dist/facts/index.d.ts +1 -0
  315. package/dist/facts/index.js +6 -0
  316. package/dist/facts/index.js.map +2 -2
  317. package/dist/files/ExplorerTile.d.ts +2 -2
  318. package/dist/files/ExplorerTile.js +3 -3
  319. package/dist/files/ExplorerTile.js.map +1 -1
  320. package/dist/files/HtmlViewerParts.js +7 -1
  321. package/dist/files/HtmlViewerParts.js.map +2 -2
  322. package/dist/files/folders/DocumentsFolderButton.d.ts +3 -1
  323. package/dist/files/folders/DocumentsFolderButton.js +3 -1
  324. package/dist/files/folders/DocumentsFolderButton.js.map +2 -2
  325. package/dist/files/folders/FolderTreePicker.d.ts +3 -1
  326. package/dist/files/folders/FolderTreePicker.js +23 -3
  327. package/dist/files/folders/FolderTreePicker.js.map +2 -2
  328. package/dist/files/index.cjs +250 -248
  329. package/dist/files/views/gridViews.d.ts +2 -0
  330. package/dist/files/views/gridViews.js.map +2 -2
  331. package/dist/home/index.cjs +1 -1
  332. package/dist/index.cjs +139 -126
  333. package/dist/index.cjs.map +1 -1
  334. package/dist/index.d.ts +1 -1
  335. package/dist/index.js +7 -1
  336. package/dist/index.js.map +2 -2
  337. package/dist/lib/pointer-hover.d.ts +11 -0
  338. package/dist/lib/pointer-hover.js +36 -0
  339. package/dist/lib/pointer-hover.js.map +7 -0
  340. package/dist/pages/index.cjs +33 -28
  341. package/dist/pages/index.cjs.map +1 -1
  342. package/dist/settings/TriStateChips.d.ts +24 -0
  343. package/dist/settings/TriStateChips.js +124 -0
  344. package/dist/settings/TriStateChips.js.map +7 -0
  345. package/dist/settings/index.cjs +1 -1
  346. package/dist/shell/index.cjs +1 -1
  347. package/dist/site/index.cjs +33 -31
  348. package/dist/studio/index.cjs +12 -11
  349. package/dist/studio/index.cjs.map +1 -1
  350. package/dist/styles.css +1 -1
  351. package/dist/timeline/TimelineCalendar.js +2 -1
  352. package/dist/timeline/TimelineCalendar.js.map +2 -2
  353. package/dist/timeline/TimelineGantt.d.ts +6 -1
  354. package/dist/timeline/TimelineGantt.js +34 -8
  355. package/dist/timeline/TimelineGantt.js.map +2 -2
  356. package/dist/timeline/index.cjs +14 -12
  357. package/dist/workflow-canvas/index.cjs +22 -20
  358. package/dist/workflow-canvas/index.cjs.map +1 -1
  359. package/node_modules/@arbidocs/coedit/package.json +1 -1
  360. package/package.json +5 -5
  361. package/src/components/grid.css +23 -1
  362. package/dist/DocumentReviewCard-RPHIQZ2Y.cjs.map +0 -1
  363. package/dist/FilesViewerDialog-PZ5H435S.cjs.map +0 -1
  364. package/dist/ai-XIT4MY3S.cjs.map +0 -1
  365. package/dist/chunk-2D5GZMSK.cjs.map +0 -1
  366. package/dist/chunk-ADMNU2CR.cjs.map +0 -1
  367. package/dist/chunk-BQOL4XNZ.cjs.map +0 -1
  368. package/dist/chunk-CYMAF656.cjs.map +0 -1
  369. package/dist/chunk-DDWLMYRO.cjs.map +0 -1
  370. package/dist/chunk-FUKN3PI5.cjs.map +0 -1
  371. package/dist/chunk-JITYC4OS.cjs.map +0 -1
  372. package/dist/chunk-MWHVETKN.cjs.map +0 -1
  373. package/dist/chunk-MZ7IUHQA.cjs.map +0 -1
  374. package/dist/chunk-N33U2SB5.cjs.map +0 -1
  375. package/dist/chunk-TJY7XPDE.cjs.map +0 -1
  376. package/dist/chunk-TUURH4NE.cjs +0 -18
  377. package/dist/chunk-UTYEXDJK.cjs.map +0 -1
  378. package/dist/chunk-YC72ZCV4.cjs.map +0 -1
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { kitOf } from "./column-kits.js";
2
3
  const DATABASE_COLUMN_TYPES = [
3
4
  "text",
4
5
  "number",
@@ -28,10 +29,14 @@ const DEFAULT_DATABASE_COLUMN_TYPE_LABELS = {
28
29
  checkbox: "Checkbox",
29
30
  select: "Select",
30
31
  person: "Person",
31
- document: "Documents",
32
+ // The same name as a `source` column: both hold a row's sources. A `document` column holds the
33
+ // documents; a `source` column also holds the passages cited in each.
34
+ document: "Sources",
32
35
  relation: "Relation",
33
36
  lookup: "Lookup",
34
- rollup: "Rollup"
37
+ rollup: "Rollup",
38
+ label: "Labels",
39
+ source: "Sources"
35
40
  };
36
41
  const OPTION_TONES = [
37
42
  "bg-blue-bg text-blue-text",
@@ -57,7 +62,9 @@ function cellIds(value) {
57
62
  function titleOf(id, titles) {
58
63
  return titles?.[id] ?? id;
59
64
  }
60
- function sameCellValue(a, b) {
65
+ function sameCellValue(a, b, type) {
66
+ const kit = type ? kitOf(type) : void 0;
67
+ if (kit) return kit.same(a, b);
61
68
  if (Array.isArray(a) || Array.isArray(b)) {
62
69
  const la = cellList(a);
63
70
  const lb = cellList(b);
@@ -65,6 +72,12 @@ function sameCellValue(a, b) {
65
72
  }
66
73
  return (a ?? null) === (b ?? null);
67
74
  }
75
+ const kitRow = (titles) => ({
76
+ id: "",
77
+ values: {},
78
+ titles
79
+ });
80
+ const kitColumn = (type) => ({ id: "", name: "", type });
68
81
  function formatDateValue(value, locale) {
69
82
  const day = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
70
83
  if (day) {
@@ -95,6 +108,8 @@ const NAMED_TYPES = /* @__PURE__ */ new Set([
95
108
  ]);
96
109
  function formatCell(value, type, locale, titles) {
97
110
  if (isEmpty(value)) return "";
111
+ const kit = kitOf(type);
112
+ if (kit) return kit.format(value, kitRow(titles), kitColumn(type));
98
113
  if ((type === "number" || type === "rollup") && typeof value === "number")
99
114
  return formatNumberValue(value, locale);
100
115
  if (type === "date" && typeof value === "string") return formatDateValue(value, locale);
@@ -107,6 +122,8 @@ function formatCell(value, type, locale, titles) {
107
122
  }
108
123
  function toApiValue(value, type) {
109
124
  if (isEmpty(value)) return null;
125
+ const kit = kitOf(type);
126
+ if (kit) return kit.toApi(value);
110
127
  if (LINK_COLUMN_TYPES.has(type)) return cellIds(value);
111
128
  if (type === "checkbox") return Boolean(value);
112
129
  if (type === "date" && value instanceof Date) {
@@ -123,6 +140,8 @@ function compareCells(a, b, type, titlesA, titlesB) {
123
140
  const ea = isEmpty(a);
124
141
  const eb = isEmpty(b);
125
142
  if (ea || eb) return ea === eb ? 0 : ea ? 1 : -1;
143
+ const kit = kitOf(type);
144
+ if (kit) return kit.compare(a, b, kitRow(titlesA), kitRow(titlesB));
126
145
  if (type === "number" || type === "checkbox" || type === "rollup") return Number(a) - Number(b);
127
146
  const shown = NAMED_TYPES.has(type) || type === "lookup";
128
147
  const ta = shown ? formatCell(a, type, void 0, titlesA) : String(a);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/databases/column-types.ts"],
4
- "sourcesContent": ["/**\n * Databases: the shapes the blocks read, and the per-type rules for showing and editing a cell.\n *\n * A database is a user-defined table (a client database, billing records). Its columns are typed:\n * `text`, `number`, `date`, `checkbox` and `select` hold a value; `person` holds a workspace member's\n * id (`usr-\u2026`); `document` and `relation` hold lists of ids (documents of the workspace, rows of the\n * target database); `lookup` (the values of a column of the related rows) and `rollup` (a number\n * measured over them) are computed by the server and never written. The server checks and\n * normalises every cell (dates arrive as ISO `YYYY-MM-DD` or a full timestamp, numbers as numbers, a\n * select as one of its options) and names every id a row refers to in the row's `titles`, so the\n * blocks only format for display and turn an editor's value into what the API takes.\n */\n\nexport type DatabaseColumnType =\n | 'text'\n | 'number'\n | 'date'\n | 'checkbox'\n | 'select'\n | 'person'\n | 'document'\n | 'relation'\n | 'lookup'\n | 'rollup'\n\n/** Every type, in the order a type picker lists them. */\nexport const DATABASE_COLUMN_TYPES: DatabaseColumnType[] = [\n 'text',\n 'number',\n 'date',\n 'checkbox',\n 'select',\n 'person',\n 'document',\n 'relation',\n 'lookup',\n 'rollup',\n]\n\n/** Types whose cells the server computes from a relation: shown, never edited. */\nexport const COMPUTED_COLUMN_TYPES: ReadonlySet<DatabaseColumnType> = new Set<DatabaseColumnType>([\n 'lookup',\n 'rollup',\n])\n\n/** Types whose cells are lists of ids (written as a list that replaces the cell's links). */\nexport const LINK_COLUMN_TYPES: ReadonlySet<DatabaseColumnType> = new Set<DatabaseColumnType>([\n 'document',\n 'relation',\n])\n\nexport const isComputedColumn = (column: Pick<DatabaseColumnView, 'type'>): boolean =>\n COMPUTED_COLUMN_TYPES.has(column.type)\n\nexport type DatabaseRollupOp = 'count' | 'sum' | 'avg' | 'min' | 'max'\n\nexport const DATABASE_ROLLUP_OPS: DatabaseRollupOp[] = ['count', 'sum', 'avg', 'min', 'max']\n\n/**\n * A relation column's target. A `two_way` column has a paired column on the target database\n * (`pair_column_id`) showing the same links from the other side; `reverse` marks the paired side.\n */\nexport interface DatabaseRelationView {\n database_id: string\n two_way?: boolean\n pair_column_id?: string | null\n reverse?: boolean\n}\n\n/** A lookup: `column` of the target database, read through this database's `relation` column. */\nexport interface DatabaseLookupView {\n relation: string\n column: string\n}\n\n/** A rollup: `op` over the rows linked through `relation` (`column`: a number column, not for count). */\nexport interface DatabaseRollupView {\n relation: string\n column?: string | null\n op?: DatabaseRollupOp\n}\n\n/** A column as the blocks read it (the API's `DatabaseColumn`). */\nexport interface DatabaseColumnView {\n id: string\n name: string\n type: DatabaseColumnType\n options?: string[] | null\n relation?: DatabaseRelationView | null\n lookup?: DatabaseLookupView | null\n rollup?: DatabaseRollupView | null\n /** Who may write it beyond the row's editors (`owners`, or `listed`: the people a person column of another\n * database lists \u2014 an approval's decision). */\n edit_by?: DatabaseEditRuleView | null\n /** Set by the host: the viewer may not write this column (its `edit_by` rule leaves them out). */\n locked?: boolean\n}\n\n/** A column's edit rule: the workspace's owners and the database's creator, or the people listed in\n * `column_id` of the database `database_id`. */\nexport interface DatabaseEditRuleView {\n kind: 'owners' | 'listed'\n database_id?: string | null\n column_id?: string | null\n}\n\n/**\n * A row as the blocks read it: cell values keyed by column id; an empty cell is absent. `titles`\n * names every person, document and related row the cells refer to (id \u2192 display name).\n */\nexport interface DatabaseRowView {\n id: string\n values: Record<string, unknown>\n titles?: Record<string, string>\n /** False: a draft only its creator sees, until submitted (shared). */\n shared?: boolean\n}\n\n/** A database as a list shows it (the API's `DatabaseRead`). */\nexport interface DatabaseSummaryView {\n id: string\n name: string\n description?: string | null\n columns: DatabaseColumnView[]\n row_count: number\n /** False for a database of another (public) workspace: read here, edited in its own workspace. */\n editable: boolean\n updated_at?: string | null\n}\n\nexport interface DatabaseColumnTypeLabels {\n text: string\n number: string\n date: string\n checkbox: string\n select: string\n person: string\n document: string\n relation: string\n lookup: string\n rollup: string\n}\n\nexport const DEFAULT_DATABASE_COLUMN_TYPE_LABELS: DatabaseColumnTypeLabels = {\n text: 'Text',\n number: 'Number',\n date: 'Date',\n checkbox: 'Checkbox',\n select: 'Select',\n person: 'Person',\n document: 'Documents',\n relation: 'Relation',\n lookup: 'Lookup',\n rollup: 'Rollup',\n}\n\n/**\n * Chip colours for select options: a stable colour per option text, so a value keeps its colour.\n * Theme tone pairs (tokens.css), so light and dark follow the host.\n */\nconst OPTION_TONES = [\n 'bg-blue-bg text-blue-text',\n 'bg-green-bg text-green-text',\n 'bg-yellow-bg text-yellow-text',\n 'bg-purple-bg text-purple-text',\n 'bg-red-bg text-red-text',\n 'bg-gray-bg text-gray-text',\n]\n\nexport function optionTone(option: string): string {\n let hash = 0\n for (const ch of option.toLowerCase()) hash = (hash * 31 + ch.charCodeAt(0)) >>> 0\n return OPTION_TONES[hash % OPTION_TONES.length]\n}\n\nconst isEmpty = (value: unknown): boolean =>\n value === null ||\n value === undefined ||\n (typeof value === 'string' && value.trim() === '') ||\n (Array.isArray(value) && value.length === 0)\n\n/** A cell as a list: a list cell as is, a single value as a list of one, an empty cell as none. */\nexport function cellList(value: unknown): unknown[] {\n if (isEmpty(value)) return []\n return Array.isArray(value) ? value.filter((v) => !isEmpty(v)) : [value]\n}\n\n/** The ids a person, document or relation cell holds. */\nexport function cellIds(value: unknown): string[] {\n return cellList(value).filter((v): v is string => typeof v === 'string')\n}\n\n/** An id's display name from the row's titles (the id itself when the server could not name it). */\nexport function titleOf(id: string, titles?: Record<string, string>): string {\n return titles?.[id] ?? id\n}\n\n/** Two cell values, as the API stores them, are the same (lists compare item by item). */\nexport function sameCellValue(a: unknown, b: unknown): boolean {\n if (Array.isArray(a) || Array.isArray(b)) {\n const la = cellList(a)\n const lb = cellList(b)\n return la.length === lb.length && la.every((v, i) => v === lb[i])\n }\n return (a ?? null) === (b ?? null)\n}\n\n/**\n * A stored date for display. A bare `YYYY-MM-DD` is a calendar day: it is shown from its own\n * components, never through a time zone (which would move it a day for viewers west of UTC).\n */\nexport function formatDateValue(value: string, locale?: string): string {\n const day = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value)\n if (day) {\n const [, y, m, d] = day\n return new Date(Date.UTC(+y, +m - 1, +d)).toLocaleDateString(locale, { timeZone: 'UTC' })\n }\n const at = new Date(value)\n return Number.isNaN(at.getTime()) ? value : at.toLocaleString(locale)\n}\n\nexport function formatNumberValue(value: number, locale?: string): string {\n return value.toLocaleString(locale, { maximumFractionDigits: 6 })\n}\n\nconst ISO_DATE = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:?\\d{2})?)?$/\n\n/**\n * One value of a lookup cell, whose type is the looked-up column's: an id reads as its title, a\n * number and an ISO date as their own column would show them.\n */\nexport function formatLookupValue(\n value: unknown,\n titles?: Record<string, string>,\n locale?: string\n): string {\n if (isEmpty(value)) return ''\n if (typeof value === 'number') return formatNumberValue(value, locale)\n if (typeof value === 'boolean') return value ? 'Yes' : 'No'\n if (typeof value === 'string') {\n if (titles?.[value] !== undefined) return titles[value]\n if (ISO_DATE.test(value)) return formatDateValue(value, locale)\n }\n return String(value)\n}\n\nconst NAMED_TYPES: ReadonlySet<DatabaseColumnType> = new Set<DatabaseColumnType>([\n 'person',\n 'document',\n 'relation',\n])\n\n/**\n * A cell as text: what a cell shows, what search and copy see. Checkboxes read as Yes/No; people,\n * documents and related rows by their titles (the row's `titles`), lists joined with commas.\n */\nexport function formatCell(\n value: unknown,\n type: DatabaseColumnType,\n locale?: string,\n titles?: Record<string, string>\n): string {\n if (isEmpty(value)) return ''\n if ((type === 'number' || type === 'rollup') && typeof value === 'number')\n return formatNumberValue(value, locale)\n if (type === 'date' && typeof value === 'string') return formatDateValue(value, locale)\n if (type === 'checkbox') return value ? 'Yes' : 'No'\n if (NAMED_TYPES.has(type))\n return cellIds(value)\n .map((id) => titleOf(id, titles))\n .join(', ')\n if (type === 'lookup')\n return cellList(value)\n .map((v) => formatLookupValue(v, titles, locale))\n .join(', ')\n return String(value)\n}\n\n/**\n * An editor's value as the API takes it. Empty becomes `null` (which empties the cell); everything\n * else goes as typed and the server checks it, so a bad value comes back as a 422 naming the column.\n * A document or relation cell goes as its list of ids (which replaces the cell's links).\n */\nexport function toApiValue(value: unknown, type: DatabaseColumnType): unknown {\n if (isEmpty(value)) return null\n if (LINK_COLUMN_TYPES.has(type)) return cellIds(value)\n if (type === 'checkbox') return Boolean(value)\n if (type === 'date' && value instanceof Date) {\n const pad = (n: number) => String(n).padStart(2, '0')\n return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}`\n }\n if (type === 'number' && typeof value === 'string') {\n const n = Number(value.replace(/,/g, ''))\n return Number.isFinite(n) ? n : value\n }\n return value\n}\n\n/**\n * Sort comparator for a column's stored values: empty cells last, then by type. People, documents,\n * related rows and lookups sort by what they show, so pass each row's titles.\n */\nexport function compareCells(\n a: unknown,\n b: unknown,\n type: DatabaseColumnType,\n titlesA?: Record<string, string>,\n titlesB?: Record<string, string>\n): number {\n const ea = isEmpty(a)\n const eb = isEmpty(b)\n if (ea || eb) return ea === eb ? 0 : ea ? 1 : -1\n if (type === 'number' || type === 'checkbox' || type === 'rollup') return Number(a) - Number(b)\n const shown = NAMED_TYPES.has(type) || type === 'lookup'\n const ta = shown ? formatCell(a, type, undefined, titlesA) : String(a)\n const tb = shown ? formatCell(b, type, undefined, titlesB) : String(b)\n return ta.localeCompare(tb, undefined, { sensitivity: 'base', numeric: true })\n}\n\n/**\n * A row's title: its first column as text (what a relation picker and a row's detail call it), or\n * `''` when that cell is empty.\n */\nexport function rowTitle(\n row: Pick<DatabaseRowView, 'values' | 'titles'>,\n columns: DatabaseColumnView[],\n locale?: string\n): string {\n const first = columns[0]\n return first ? formatCell(row.values[first.id], first.type, locale, row.titles) : ''\n}\n"],
5
- "mappings": ";AA0BO,MAAM,wBAA8C;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAC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AACpB,QAAM,KAAK,QAAQ,CAAC;AACpB,MAAI,MAAM,GAAI,QAAO,OAAO,KAAK,IAAI,KAAK,IAAI;AAC9C,MAAI,SAAS,YAAY,SAAS,cAAc,SAAS,SAAU,QAAO,OAAO,CAAC,IAAI,OAAO,CAAC;AAC9F,QAAM,QAAQ,YAAY,IAAI,IAAI,KAAK,SAAS;AAChD,QAAM,KAAK,QAAQ,WAAW,GAAG,MAAM,QAAW,OAAO,IAAI,OAAO,CAAC;AACrE,QAAM,KAAK,QAAQ,WAAW,GAAG,MAAM,QAAW,OAAO,IAAI,OAAO,CAAC;AACrE,SAAO,GAAG,cAAc,IAAI,QAAW,EAAE,aAAa,QAAQ,SAAS,KAAK,CAAC;AAC/E;AAMO,SAAS,SACd,KACA,SACA,QACQ;AACR,QAAM,QAAQ,QAAQ,CAAC;AACvB,SAAO,QAAQ,WAAW,IAAI,OAAO,MAAM,EAAE,GAAG,MAAM,MAAM,QAAQ,IAAI,MAAM,IAAI;AACpF;",
4
+ "sourcesContent": ["/**\n * Databases: the shapes the blocks read, and the per-type rules for showing and editing a cell.\n *\n * A database is a user-defined table (a client database, billing records). Its columns are typed:\n * `text`, `number`, `date`, `checkbox` and `select` hold a value; `person` holds a workspace member's\n * id (`usr-\u2026`); `document` and `relation` hold lists of ids (documents of the workspace, rows of the\n * target database); `lookup` (the values of a column of the related rows) and `rollup` (a number\n * measured over them) are computed by the server and never written. The server checks and\n * normalises every cell (dates arrive as ISO `YYYY-MM-DD` or a full timestamp, numbers as numbers, a\n * select as one of its options) and names every id a row refers to in the row's `titles`, so the\n * blocks only format for display and turn an editor's value into what the API takes.\n */\n\nimport { kitOf } from './column-kits'\n\nexport type DatabaseColumnType =\n | 'text'\n | 'number'\n | 'date'\n | 'checkbox'\n | 'select'\n | 'person'\n | 'document'\n | 'relation'\n | 'lookup'\n | 'rollup'\n | 'label'\n | 'source'\n\n/** Every type, in the order a type picker lists them. */\nexport const DATABASE_COLUMN_TYPES: DatabaseColumnType[] = [\n 'text',\n 'number',\n 'date',\n 'checkbox',\n 'select',\n 'person',\n 'document',\n 'relation',\n 'lookup',\n 'rollup',\n]\n\n/** Types whose cells the server computes from a relation: shown, never edited. */\nexport const COMPUTED_COLUMN_TYPES: ReadonlySet<DatabaseColumnType> = new Set<DatabaseColumnType>([\n 'lookup',\n 'rollup',\n])\n\n/** Types whose cells are lists of ids (written as a list that replaces the cell's links). */\nexport const LINK_COLUMN_TYPES: ReadonlySet<DatabaseColumnType> = new Set<DatabaseColumnType>([\n 'document',\n 'relation',\n])\n\nexport const isComputedColumn = (column: Pick<DatabaseColumnView, 'type'>): boolean =>\n COMPUTED_COLUMN_TYPES.has(column.type)\n\nexport type DatabaseRollupOp = 'count' | 'sum' | 'avg' | 'min' | 'max'\n\nexport const DATABASE_ROLLUP_OPS: DatabaseRollupOp[] = ['count', 'sum', 'avg', 'min', 'max']\n\n/**\n * A relation column's target. A `two_way` column has a paired column on the target database\n * (`pair_column_id`) showing the same links from the other side; `reverse` marks the paired side.\n */\nexport interface DatabaseRelationView {\n database_id: string\n two_way?: boolean\n pair_column_id?: string | null\n reverse?: boolean\n}\n\n/** A lookup: `column` of the target database, read through this database's `relation` column. */\nexport interface DatabaseLookupView {\n relation: string\n column: string\n}\n\n/** A rollup: `op` over the rows linked through `relation` (`column`: a number column, not for count). */\nexport interface DatabaseRollupView {\n relation: string\n column?: string | null\n op?: DatabaseRollupOp\n}\n\nexport interface DatabaseCitationChunk {\n chunk_id: string\n page?: number | null\n}\n\n/** One cited document of a `source` cell, with the passages (chunks) cited in it. */\nexport interface DatabaseCitation {\n doc_ext_id: string\n version?: number | null\n chunks?: DatabaseCitationChunk[]\n}\n\n/** A column as the blocks read it (the API's `DatabaseColumn`). */\nexport interface DatabaseColumnView {\n id: string\n name: string\n type: DatabaseColumnType\n /** select: the option list; label: allowed tag kinds. */\n options?: string[] | null\n relation?: DatabaseRelationView | null\n lookup?: DatabaseLookupView | null\n rollup?: DatabaseRollupView | null\n /** Who may write it beyond the row's editors (`owners`, or `listed`: the people a person column of another\n * database lists \u2014 an approval's decision). */\n edit_by?: DatabaseEditRuleView | null\n /** Set by the host: the viewer may not write this column (its `edit_by` rule leaves them out). */\n locked?: boolean\n /** Where a cell is edited: in the grid cell, or only on the row's page. */\n editIn?: 'cell' | 'row'\n /** A date column that runs to the date in `endColumnId` (a span), in the zone of `timezoneColumnId`. */\n span?: { endColumnId: string; timezoneColumnId?: string }\n /** Set by the host: the width the column starts at, in pixels, instead of its type's. */\n width?: number\n /** Set by the host: the narrowest the column can be dragged (90 by default; with `grow`, the type's width). */\n minWidth?: number\n /**\n * Set by the host: a share of the table's free width (the grid's `flex`). The column fills the room\n * the others leave; a drag of its edge fixes its width.\n */\n grow?: number\n}\n\n/** A column's edit rule: the workspace's owners and the database's creator, or the people listed in\n * `column_id` of the database `database_id`. */\nexport interface DatabaseEditRuleView {\n kind: 'owners' | 'listed'\n database_id?: string | null\n column_id?: string | null\n}\n\n/**\n * A row as the blocks read it: cell values keyed by column id; an empty cell is absent. `titles`\n * names every person, document and related row the cells refer to (id \u2192 display name).\n */\nexport interface DatabaseRowView {\n id: string\n values: Record<string, unknown>\n titles?: Record<string, string>\n /** False: a draft only its creator sees, until submitted (shared). */\n shared?: boolean\n}\n\n/** A database as a list shows it (the API's `DatabaseRead`). */\nexport interface DatabaseSummaryView {\n id: string\n name: string\n description?: string | null\n columns: DatabaseColumnView[]\n row_count: number\n /** False for a database of another (public) workspace: read here, edited in its own workspace. */\n editable: boolean\n updated_at?: string | null\n}\n\nexport interface DatabaseColumnTypeLabels {\n text: string\n number: string\n date: string\n checkbox: string\n select: string\n person: string\n document: string\n relation: string\n lookup: string\n rollup: string\n label?: string\n source?: string\n}\n\nexport const DEFAULT_DATABASE_COLUMN_TYPE_LABELS: DatabaseColumnTypeLabels &\n Required<Pick<DatabaseColumnTypeLabels, 'label' | 'source'>> = {\n text: 'Text',\n number: 'Number',\n date: 'Date',\n checkbox: 'Checkbox',\n select: 'Select',\n person: 'Person',\n // The same name as a `source` column: both hold a row's sources. A `document` column holds the\n // documents; a `source` column also holds the passages cited in each.\n document: 'Sources',\n relation: 'Relation',\n lookup: 'Lookup',\n rollup: 'Rollup',\n label: 'Labels',\n source: 'Sources',\n}\n\n/**\n * Chip colours for select options: a stable colour per option text, so a value keeps its colour.\n * Theme tone pairs (tokens.css), so light and dark follow the host.\n */\nconst OPTION_TONES = [\n 'bg-blue-bg text-blue-text',\n 'bg-green-bg text-green-text',\n 'bg-yellow-bg text-yellow-text',\n 'bg-purple-bg text-purple-text',\n 'bg-red-bg text-red-text',\n 'bg-gray-bg text-gray-text',\n]\n\nexport function optionTone(option: string): string {\n let hash = 0\n for (const ch of option.toLowerCase()) hash = (hash * 31 + ch.charCodeAt(0)) >>> 0\n return OPTION_TONES[hash % OPTION_TONES.length]\n}\n\nconst isEmpty = (value: unknown): boolean =>\n value === null ||\n value === undefined ||\n (typeof value === 'string' && value.trim() === '') ||\n (Array.isArray(value) && value.length === 0)\n\n/** A cell as a list: a list cell as is, a single value as a list of one, an empty cell as none. */\nexport function cellList(value: unknown): unknown[] {\n if (isEmpty(value)) return []\n return Array.isArray(value) ? value.filter((v) => !isEmpty(v)) : [value]\n}\n\n/** The ids a person, document or relation cell holds. */\nexport function cellIds(value: unknown): string[] {\n return cellList(value).filter((v): v is string => typeof v === 'string')\n}\n\n/** An id's display name from the row's titles (the id itself when the server could not name it). */\nexport function titleOf(id: string, titles?: Record<string, string>): string {\n return titles?.[id] ?? id\n}\n\n/**\n * Two cell values, as the API stores them, are the same (lists compare item by item). With the\n * column's `type`, label and source cells compare by their own rules.\n */\nexport function sameCellValue(a: unknown, b: unknown, type?: DatabaseColumnType): boolean {\n const kit = type ? kitOf(type) : undefined\n if (kit) return kit.same(a, b)\n if (Array.isArray(a) || Array.isArray(b)) {\n const la = cellList(a)\n const lb = cellList(b)\n return la.length === lb.length && la.every((v, i) => v === lb[i])\n }\n return (a ?? null) === (b ?? null)\n}\n\n/** The row and column a kit's `format` and `compare` see when the caller only has titles and a type. */\nconst kitRow = (titles?: Record<string, string>): DatabaseRowView => ({\n id: '',\n values: {},\n titles,\n})\nconst kitColumn = (type: DatabaseColumnType): DatabaseColumnView => ({ id: '', name: '', type })\n\n/**\n * A stored date for display. A bare `YYYY-MM-DD` is a calendar day: it is shown from its own\n * components, never through a time zone (which would move it a day for viewers west of UTC).\n */\nexport function formatDateValue(value: string, locale?: string): string {\n const day = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value)\n if (day) {\n const [, y, m, d] = day\n return new Date(Date.UTC(+y, +m - 1, +d)).toLocaleDateString(locale, { timeZone: 'UTC' })\n }\n const at = new Date(value)\n return Number.isNaN(at.getTime()) ? value : at.toLocaleString(locale)\n}\n\nexport function formatNumberValue(value: number, locale?: string): string {\n return value.toLocaleString(locale, { maximumFractionDigits: 6 })\n}\n\nconst ISO_DATE = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:?\\d{2})?)?$/\n\n/**\n * One value of a lookup cell, whose type is the looked-up column's: an id reads as its title, a\n * number and an ISO date as their own column would show them.\n */\nexport function formatLookupValue(\n value: unknown,\n titles?: Record<string, string>,\n locale?: string\n): string {\n if (isEmpty(value)) return ''\n if (typeof value === 'number') return formatNumberValue(value, locale)\n if (typeof value === 'boolean') return value ? 'Yes' : 'No'\n if (typeof value === 'string') {\n if (titles?.[value] !== undefined) return titles[value]\n if (ISO_DATE.test(value)) return formatDateValue(value, locale)\n }\n return String(value)\n}\n\nconst NAMED_TYPES: ReadonlySet<DatabaseColumnType> = new Set<DatabaseColumnType>([\n 'person',\n 'document',\n 'relation',\n])\n\n/**\n * A cell as text: what a cell shows, what search and copy see. Checkboxes read as Yes/No; people,\n * documents and related rows by their titles (the row's `titles`), lists joined with commas.\n */\nexport function formatCell(\n value: unknown,\n type: DatabaseColumnType,\n locale?: string,\n titles?: Record<string, string>\n): string {\n if (isEmpty(value)) return ''\n const kit = kitOf(type)\n if (kit) return kit.format(value, kitRow(titles), kitColumn(type))\n if ((type === 'number' || type === 'rollup') && typeof value === 'number')\n return formatNumberValue(value, locale)\n if (type === 'date' && typeof value === 'string') return formatDateValue(value, locale)\n if (type === 'checkbox') return value ? 'Yes' : 'No'\n if (NAMED_TYPES.has(type))\n return cellIds(value)\n .map((id) => titleOf(id, titles))\n .join(', ')\n if (type === 'lookup')\n return cellList(value)\n .map((v) => formatLookupValue(v, titles, locale))\n .join(', ')\n return String(value)\n}\n\n/**\n * An editor's value as the API takes it. Empty becomes `null` (which empties the cell); everything\n * else goes as typed and the server checks it, so a bad value comes back as a 422 naming the column.\n * A document or relation cell goes as its list of ids (which replaces the cell's links).\n */\nexport function toApiValue(value: unknown, type: DatabaseColumnType): unknown {\n if (isEmpty(value)) return null\n const kit = kitOf(type)\n if (kit) return kit.toApi(value)\n if (LINK_COLUMN_TYPES.has(type)) return cellIds(value)\n if (type === 'checkbox') return Boolean(value)\n if (type === 'date' && value instanceof Date) {\n const pad = (n: number) => String(n).padStart(2, '0')\n return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}`\n }\n if (type === 'number' && typeof value === 'string') {\n const n = Number(value.replace(/,/g, ''))\n return Number.isFinite(n) ? n : value\n }\n return value\n}\n\n/**\n * Sort comparator for a column's stored values: empty cells last, then by type. People, documents,\n * related rows and lookups sort by what they show, so pass each row's titles.\n */\nexport function compareCells(\n a: unknown,\n b: unknown,\n type: DatabaseColumnType,\n titlesA?: Record<string, string>,\n titlesB?: Record<string, string>\n): number {\n const ea = isEmpty(a)\n const eb = isEmpty(b)\n if (ea || eb) return ea === eb ? 0 : ea ? 1 : -1\n const kit = kitOf(type)\n if (kit) return kit.compare(a, b, kitRow(titlesA), kitRow(titlesB))\n if (type === 'number' || type === 'checkbox' || type === 'rollup') return Number(a) - Number(b)\n const shown = NAMED_TYPES.has(type) || type === 'lookup'\n const ta = shown ? formatCell(a, type, undefined, titlesA) : String(a)\n const tb = shown ? formatCell(b, type, undefined, titlesB) : String(b)\n return ta.localeCompare(tb, undefined, { sensitivity: 'base', numeric: true })\n}\n\n/**\n * A row's title: its first column as text (what a relation picker and a row's detail call it), or\n * `''` when that cell is empty.\n */\nexport function rowTitle(\n row: Pick<DatabaseRowView, 'values' | 'titles'>,\n columns: DatabaseColumnView[],\n locale?: string\n): string {\n const first = columns[0]\n return first ? formatCell(row.values[first.id], first.type, locale, row.titles) : ''\n}\n"],
5
+ "mappings": ";AAaA,SAAS,aAAa;AAiBf,MAAM,wBAA8C;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,MAAM,wBAAyD,oBAAI,IAAwB;AAAA,EAChG;AAAA,EACA;AACF,CAAC;AAGM,MAAM,oBAAqD,oBAAI,IAAwB;AAAA,EAC5F;AAAA,EACA;AACF,CAAC;AAEM,MAAM,mBAAmB,CAAC,WAC/B,sBAAsB,IAAI,OAAO,IAAI;AAIhC,MAAM,sBAA0C,CAAC,SAAS,OAAO,OAAO,OAAO,KAAK;AAmHpF,MAAM,sCACoD;AAAA,EAC/D,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA;AAAA;AAAA,EAGR,UAAU;AAAA,EACV,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AACV;AAMA,MAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,SAAS,WAAW,QAAwB;AACjD,MAAI,OAAO;AACX,aAAW,MAAM,OAAO,YAAY,EAAG,QAAQ,OAAO,KAAK,GAAG,WAAW,CAAC,MAAO;AACjF,SAAO,aAAa,OAAO,aAAa,MAAM;AAChD;AAEA,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ChD,QAAM,KAAK,QAAQ,WAAW,GAAG,MAAM,QAAW,OAAO,IAAI,OAAO,CAAC;AACrE,QAAM,KAAK,QAAQ,WAAW,GAAG,MAAM,QAAW,OAAO,IAAI,OAAO,CAAC;AACrE,SAAO,GAAG,cAAc,IAAI,QAAW,EAAE,aAAa,QAAQ,SAAS,KAAK,CAAC;AAC/E;AAMO,SAAS,SACd,KACA,SACA,QACQ;AACR,QAAM,QAAQ,QAAQ,CAAC;AACvB,SAAO,QAAQ,WAAW,IAAI,OAAO,MAAM,EAAE,GAAG,MAAM,MAAM,QAAQ,IAAI,MAAM,IAAI;AACpF;",
6
6
  "names": []
7
7
  }
@@ -1,20 +1,41 @@
1
+ /**
2
+ * Column definitions for a database grid, built from the database's own (user-defined) columns.
3
+ *
4
+ * Each column edits in place with the editor for its type (AG Grid's for text, number, date and
5
+ * checkbox; a chip list for select; a searchable picker for a person, documents and related rows); a
6
+ * checkbox toggles with one click, a select shows its value as a coloured chip, documents and
7
+ * related rows as chips named from the row's `titles`. Lookup and rollup columns are computed by the
8
+ * server: read-only, their header marked with a quiet "computed" sign. The header carries the type's
9
+ * icon and a button that opens the column's settings, and a trailing narrow column holds the "add a
10
+ * column" button: a Notion/Airtable-style table.
11
+ *
12
+ * Every column's `colId` is the database column id (`col-…`), so AG Grid's saved column state
13
+ * (order, width) survives renames.
14
+ */
15
+ import type { ReactNode } from 'react';
1
16
  import type { ColDef } from 'ag-grid-community';
2
17
  import { Type } from 'lucide-react';
3
18
  import { type DatabaseColumnType, type DatabaseColumnView, type DatabaseRowView } from './column-types';
4
19
  import { SelectChip } from './SelectChip';
5
20
  import { type DatabaseCellSources } from './linkCells';
21
+ import { type DateSpanEditorLabels } from './DateSpanEditor';
6
22
  export { SelectChip };
7
23
  export interface DatabaseColumnLabels {
8
24
  addColumn: string;
9
25
  columnSettings: (name: string) => string;
10
26
  computed: string;
11
27
  openRow: string;
28
+ dateSpanEditor: DateSpanEditorLabels;
29
+ /** The accessible name of a source chip in a grid cell, which opens the row. */
30
+ openRowFromSource: (title: string) => string;
12
31
  }
13
32
  export declare const DEFAULT_DATABASE_COLUMN_LABELS: DatabaseColumnLabels;
14
33
  /** colId of the trailing "add a column" column (never a database column id). */
15
34
  export declare const ADD_COLUMN_COL_ID = "__add_column";
16
35
  /** colId of the leading "open the row" column (never a database column id). */
17
36
  export declare const OPEN_ROW_COL_ID = "__open_row";
37
+ /** colId of the trailing row-actions column, left of the add column (never a database column id). */
38
+ export declare const ROW_ACTIONS_COL_ID = "__row_actions";
18
39
  export declare const COLUMN_TYPE_ICONS: Record<DatabaseColumnType, typeof Type>;
19
40
  export interface DatabaseColumnOptions {
20
41
  /** No editing, no column settings, no add-column button (a database of another workspace). */
@@ -23,8 +44,14 @@ export interface DatabaseColumnOptions {
23
44
  onEditColumn?: (column: DatabaseColumnView) => void;
24
45
  /** Add a column (the trailing "+" header). */
25
46
  onAddColumn?: () => void;
26
- /** Open a row in full (a leading column of "open" buttons). */
27
- onOpenRow?: (row: DatabaseRowView) => void;
47
+ /** Open a row in full (a leading column of "open" buttons, or a cell that edits on the row page). */
48
+ onOpenRow?: (row: DatabaseRowView, options?: {
49
+ focusColumn?: string;
50
+ }) => void;
51
+ /** Whether this cell may be edited here (AND-ed with the column's own rules and `readOnly`). */
52
+ isCellEditable?: (row: DatabaseRowView, column: DatabaseColumnView) => boolean;
53
+ /** A pinned-right column of row actions; the host draws what each row offers. */
54
+ renderRowActions?: (row: DatabaseRowView) => ReactNode;
28
55
  /** Choices for person, document and relation cells, and what a document chip opens. */
29
56
  sources?: DatabaseCellSources;
30
57
  /** Locale for numbers and dates. */
@@ -5,7 +5,6 @@ import {
5
5
  CalendarDays,
6
6
  CheckSquare,
7
7
  ChevronDown,
8
- FileText,
9
8
  Hash,
10
9
  Lock,
11
10
  Maximize2,
@@ -23,18 +22,29 @@ import {
23
22
  sameCellValue,
24
23
  toApiValue
25
24
  } from "./column-types.js";
25
+ import { COLUMN_KITS, kitOf } from "./column-kits.js";
26
26
  import { SelectChip } from "./SelectChip.js";
27
27
  import { SelectCellEditor } from "./SelectCellEditor.js";
28
28
  import { PickCellEditor } from "./PickCellEditor.js";
29
29
  import { LinkChipsCell, LookupCell, PersonCell } from "./linkCells.js";
30
+ import { LabelsCell } from "./LabelsCell.js";
31
+ import { SourcesCell } from "./SourcesCell.js";
32
+ import {
33
+ DateSpanCellEditor,
34
+ DEFAULT_DATE_SPAN_EDITOR_LABELS
35
+ } from "./DateSpanEditor.js";
36
+ import { formatSpan } from "../timeline/span.js";
30
37
  const DEFAULT_DATABASE_COLUMN_LABELS = {
31
38
  addColumn: "Add a column",
32
39
  columnSettings: (name) => `${name} column settings`,
33
40
  computed: "Computed from a relation (read-only)",
34
- openRow: "Open row"
41
+ openRow: "Open row",
42
+ dateSpanEditor: DEFAULT_DATE_SPAN_EDITOR_LABELS,
43
+ openRowFromSource: (title) => `${title}: open the row`
35
44
  };
36
45
  const ADD_COLUMN_COL_ID = "__add_column";
37
46
  const OPEN_ROW_COL_ID = "__open_row";
47
+ const ROW_ACTIONS_COL_ID = "__row_actions";
38
48
  const COLUMN_TYPE_ICONS = {
39
49
  text: Type,
40
50
  number: Hash,
@@ -42,10 +52,12 @@ const COLUMN_TYPE_ICONS = {
42
52
  checkbox: CheckSquare,
43
53
  select: ChevronDown,
44
54
  person: UserRound,
45
- document: FileText,
55
+ document: COLUMN_KITS.source.icon,
46
56
  relation: ArrowUpRight,
47
57
  lookup: Search,
48
- rollup: Sigma
58
+ rollup: Sigma,
59
+ label: COLUMN_KITS.label.icon,
60
+ source: COLUMN_KITS.source.icon
49
61
  };
50
62
  const WIDTHS = {
51
63
  text: 220,
@@ -57,7 +69,9 @@ const WIDTHS = {
57
69
  document: 240,
58
70
  relation: 240,
59
71
  lookup: 200,
60
- rollup: 130
72
+ rollup: 130,
73
+ label: COLUMN_KITS.label.width,
74
+ source: COLUMN_KITS.source.width
61
75
  };
62
76
  function HeaderLabel({
63
77
  dbColumn: column,
@@ -106,14 +120,28 @@ function columnWidth(column) {
106
120
  const header = Math.round(column.name.length * 8) + 76 + (isComputedColumn(column) ? 16 : 0);
107
121
  return Math.min(320, Math.max(WIDTHS[column.type], header));
108
122
  }
123
+ const positive = (n) => typeof n === "number" && Number.isFinite(n) && n > 0 ? n : void 0;
124
+ function sizing(column) {
125
+ const grow = positive(column.grow);
126
+ if (grow !== void 0) {
127
+ return { flex: grow, minWidth: positive(column.minWidth) ?? columnWidth(column) };
128
+ }
129
+ return {
130
+ width: positive(column.width) ?? columnWidth(column),
131
+ minWidth: positive(column.minWidth) ?? 90
132
+ };
133
+ }
109
134
  function canEditColumn(column, sources) {
110
135
  if (isComputedColumn(column) || column.locked) return false;
136
+ const kit = kitOf(column.type);
137
+ if (kit) return kit.canEditInGrid(column, sources);
111
138
  if (column.type === "person") return Boolean(sources?.members);
112
139
  if (column.type === "document") return Boolean(sources?.documents);
113
140
  if (column.type === "relation") return Boolean(sources?.searchRows && column.relation);
114
141
  return true;
115
142
  }
116
- function editorFor(column, sources) {
143
+ function editorFor(column, sources, dateSpanLabels) {
144
+ if (kitOf(column.type)) return {};
117
145
  const pick = (params) => ({
118
146
  cellEditor: PickCellEditor,
119
147
  cellEditorPopup: true,
@@ -123,7 +151,15 @@ function editorFor(column, sources) {
123
151
  case "number":
124
152
  return { cellEditor: "agNumberCellEditor", cellEditorParams: { showStepperButtons: false } };
125
153
  case "date":
126
- return { cellEditor: "agDateStringCellEditor" };
154
+ return column.span ? {
155
+ cellEditor: DateSpanCellEditor,
156
+ cellEditorParams: {
157
+ endColumnId: column.span.endColumnId,
158
+ timezoneColumnId: column.span.timezoneColumnId,
159
+ labels: dateSpanLabels,
160
+ columnName: column.name
161
+ }
162
+ } : { cellEditor: "agDateStringCellEditor" };
127
163
  case "checkbox":
128
164
  return { cellEditor: "agCheckboxCellEditor" };
129
165
  case "select":
@@ -151,7 +187,42 @@ function editorFor(column, sources) {
151
187
  return { cellEditor: "agTextCellEditor" };
152
188
  }
153
189
  }
154
- function rendererFor(column, locale, sources) {
190
+ const EMPTY_ROW = { id: "", values: {} };
191
+ const asText = (v) => typeof v === "string" && v ? v : null;
192
+ function rendererFor(column, locale, sources, readOnly, isCellEditable, onOpenRow, l) {
193
+ const kit = kitOf(column.type);
194
+ if (kit) {
195
+ const valueFormatter = (p) => kit.format(p.value, p.data ?? EMPTY_ROW, column);
196
+ if (column.type === "label") {
197
+ const editableFor = (row) => !readOnly && column.editIn !== "row" && canEditColumn(column, sources) && (!row || !isCellEditable || isCellEditable(row, column));
198
+ return {
199
+ valueFormatter,
200
+ cellRenderer: (p) => /* @__PURE__ */ jsx(
201
+ LabelsCell,
202
+ {
203
+ value: p.value,
204
+ titles: p.data?.titles,
205
+ labels: sources?.labels,
206
+ onChange: editableFor(p.data) ? (ids) => p.node.setDataValue(column.id, ids) : void 0,
207
+ rowHeight: p.node?.rowHeight ?? void 0
208
+ }
209
+ )
210
+ };
211
+ }
212
+ return {
213
+ valueFormatter,
214
+ cellRenderer: (p) => /* @__PURE__ */ jsx(
215
+ SourcesCell,
216
+ {
217
+ value: p.value,
218
+ titles: p.data?.titles,
219
+ openLabel: l.openRowFromSource,
220
+ onOpen: onOpenRow && p.data ? () => onOpenRow(p.data, { focusColumn: column.id }) : void 0,
221
+ rowHeight: p.node?.rowHeight ?? void 0
222
+ }
223
+ )
224
+ };
225
+ }
155
226
  switch (column.type) {
156
227
  case "checkbox":
157
228
  return {
@@ -172,10 +243,20 @@ function rendererFor(column, locale, sources) {
172
243
  cellClass: "cell-numeric text-muted-foreground",
173
244
  valueFormatter: (p) => formatCell(p.value, "rollup", locale)
174
245
  };
175
- case "date":
246
+ case "date": {
247
+ const span = column.span;
248
+ if (span)
249
+ return {
250
+ valueFormatter: (p) => typeof p.value === "string" && p.value ? formatSpan(
251
+ p.value,
252
+ asText(p.data?.values[span.endColumnId]),
253
+ span.timezoneColumnId ? asText(p.data?.values[span.timezoneColumnId]) : null
254
+ ) : ""
255
+ };
176
256
  return {
177
257
  valueFormatter: (p) => formatCell(p.value, "date", locale)
178
258
  };
259
+ }
179
260
  case "person":
180
261
  return {
181
262
  cellRenderer: (p) => /* @__PURE__ */ jsx(PersonCell, { value: p.value, titles: p.data?.titles })
@@ -198,11 +279,35 @@ function rendererFor(column, locale, sources) {
198
279
  cellRenderer: (p) => /* @__PURE__ */ jsx(LookupCell, { value: p.value, titles: p.data?.titles, locale })
199
280
  };
200
281
  default:
201
- return {};
282
+ return { cellClass: "database-cell-text" };
283
+ }
284
+ }
285
+ function setSpan(row, columnId, span, newValue) {
286
+ if ((typeof newValue === "string" || newValue === null) && sameCellValue(asText(newValue), row.values[columnId] ?? null)) {
287
+ return false;
202
288
  }
289
+ const next = typeof newValue === "object" && newValue !== null ? newValue : { start: asText(newValue), end: null, timezone: null };
290
+ const writes = [
291
+ [columnId, next.start],
292
+ [span.endColumnId, next.end],
293
+ ...span.timezoneColumnId ? [[span.timezoneColumnId, next.timezone]] : []
294
+ ];
295
+ const changed = writes.filter(([id, v]) => !sameCellValue(v, row.values[id] ?? null));
296
+ if (changed.length === 0) return false;
297
+ row.values = { ...row.values, ...Object.fromEntries(writes) };
298
+ return true;
203
299
  }
204
300
  function createDatabaseColumns(columns, options = {}) {
205
- const { readOnly, onEditColumn, onAddColumn, onOpenRow, locale, sources } = options;
301
+ const {
302
+ readOnly,
303
+ onEditColumn,
304
+ onAddColumn,
305
+ onOpenRow,
306
+ locale,
307
+ sources,
308
+ isCellEditable,
309
+ renderRowActions
310
+ } = options;
206
311
  const l = { ...DEFAULT_DATABASE_COLUMN_LABELS, ...options.labels };
207
312
  const openRow = onOpenRow && columns.length > 0 ? [
208
313
  {
@@ -239,42 +344,64 @@ function createDatabaseColumns(columns, options = {}) {
239
344
  ) : null
240
345
  }
241
346
  ] : [];
242
- const defs = columns.map((column) => ({
243
- colId: column.id,
244
- headerName: column.name,
245
- width: columnWidth(column),
246
- minWidth: 90,
247
- resizable: true,
248
- sortable: true,
249
- editable: !readOnly && canEditColumn(column, sources),
250
- // The grid's own type inference must not second-guess the database's column type.
251
- cellDataType: false,
252
- headerComponentParams: {
253
- innerHeaderComponent: HeaderLabel,
254
- innerHeaderComponentParams: {
255
- dbColumn: column,
256
- settingsLabel: l.columnSettings(column.name),
257
- computedLabel: l.computed,
258
- onEdit: !readOnly && onEditColumn ? () => onEditColumn(column) : void 0
259
- }
260
- },
261
- // An empty checkbox reads as unticked (not indeterminate).
262
- valueGetter: (p) => column.type === "checkbox" ? p.data?.values[column.id] === true : p.data?.values[column.id] ?? null,
263
- // Edits land in the row's values as the API would store them; the host saves them in
264
- // onCellValueChanged and puts the server's normalised row back.
265
- valueSetter: (p) => {
266
- if (!p.data) return false;
267
- const next = toApiValue(p.newValue, column.type);
268
- if (sameCellValue(next, p.oldValue)) return false;
269
- p.data.values = { ...p.data.values, [column.id]: next };
270
- return true;
271
- },
272
- comparator: (a, b, nodeA, nodeB) => compareCells(a, b, column.type, nodeA?.data?.titles, nodeB?.data?.titles),
273
- getQuickFilterText: (p) => formatCell(p.value, column.type, locale, p.data?.titles),
274
- ...editorFor(column, sources),
275
- ...rendererFor(column, locale, sources)
276
- }));
347
+ const defs = columns.map((column) => {
348
+ const gridEditable = !readOnly && !kitOf(column.type) && column.editIn !== "row" && canEditColumn(column, sources);
349
+ return {
350
+ colId: column.id,
351
+ headerName: column.name,
352
+ ...sizing(column),
353
+ resizable: true,
354
+ sortable: true,
355
+ editable: isCellEditable ? (p) => gridEditable && (!p.data || isCellEditable(p.data, column)) : gridEditable,
356
+ // The grid's own type inference must not second-guess the database's column type.
357
+ cellDataType: false,
358
+ headerComponentParams: {
359
+ innerHeaderComponent: HeaderLabel,
360
+ innerHeaderComponentParams: {
361
+ dbColumn: column,
362
+ settingsLabel: l.columnSettings(column.name),
363
+ computedLabel: l.computed,
364
+ onEdit: !readOnly && onEditColumn ? () => onEditColumn(column) : void 0
365
+ }
366
+ },
367
+ // An empty checkbox reads as unticked (not indeterminate).
368
+ valueGetter: (p) => column.type === "checkbox" ? p.data?.values[column.id] === true : p.data?.values[column.id] ?? null,
369
+ // Edits land in the row's values as the API would store them; the host saves them in
370
+ // onCellValueChanged and puts the server's normalised row back.
371
+ valueSetter: (p) => {
372
+ if (!p.data) return false;
373
+ const span = column.span;
374
+ if (span) return setSpan(p.data, column.id, span, p.newValue);
375
+ const next = toApiValue(p.newValue, column.type);
376
+ if (sameCellValue(next, p.oldValue, column.type)) return false;
377
+ p.data.values = { ...p.data.values, [column.id]: next };
378
+ return true;
379
+ },
380
+ comparator: (a, b, nodeA, nodeB) => compareCells(a, b, column.type, nodeA?.data?.titles, nodeB?.data?.titles),
381
+ getQuickFilterText: (p) => formatCell(p.value, column.type, locale, p.data?.titles),
382
+ ...editorFor(column, sources, l.dateSpanEditor),
383
+ ...rendererFor(column, locale, sources, readOnly, isCellEditable, onOpenRow, l)
384
+ };
385
+ });
277
386
  defs.unshift(...openRow);
387
+ if (renderRowActions && columns.length > 0) {
388
+ defs.push({
389
+ colId: ROW_ACTIONS_COL_ID,
390
+ headerName: "",
391
+ width: 40,
392
+ minWidth: 40,
393
+ maxWidth: 40,
394
+ resizable: false,
395
+ sortable: false,
396
+ editable: false,
397
+ suppressMovable: true,
398
+ pinned: "right",
399
+ lockPinned: true,
400
+ cellClass: "flex items-center justify-center !px-0",
401
+ valueGetter: () => null,
402
+ cellRenderer: (p) => p.data ? renderRowActions(p.data) : null
403
+ });
404
+ }
278
405
  if (!readOnly && onAddColumn) {
279
406
  defs.push({
280
407
  colId: ADD_COLUMN_COL_ID,
@@ -300,6 +427,7 @@ export {
300
427
  COLUMN_TYPE_ICONS,
301
428
  DEFAULT_DATABASE_COLUMN_LABELS,
302
429
  OPEN_ROW_COL_ID,
430
+ ROW_ACTIONS_COL_ID,
303
431
  SelectChip,
304
432
  canEditColumn,
305
433
  columnWidth,