@arbidocs/blocks 0.5.146 → 0.5.147

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 (280) hide show
  1. package/dist/{ConnectedCallDock-JVLJEWLJ.cjs → ConnectedCallDock-6VGATAAQ.cjs} +5 -5
  2. package/dist/{ConnectedCallDock-JVLJEWLJ.cjs.map → ConnectedCallDock-6VGATAAQ.cjs.map} +1 -1
  3. package/dist/{ConnectedCallRoom-7YQRDIS3.cjs → ConnectedCallRoom-YBNERVTW.cjs} +5 -5
  4. package/dist/{ConnectedCallRoom-7YQRDIS3.cjs.map → ConnectedCallRoom-YBNERVTW.cjs.map} +1 -1
  5. package/dist/{ConnectedPresentation-JJXQBIV2.cjs → ConnectedPresentation-JZQFTC5H.cjs} +4 -4
  6. package/dist/{ConnectedPresentation-JJXQBIV2.cjs.map → ConnectedPresentation-JZQFTC5H.cjs.map} +1 -1
  7. package/dist/{DocumentReviewCard-ENCPTGJE.cjs → DocumentReviewCard-UDC4PNIS.cjs} +15 -14
  8. package/dist/DocumentReviewCard-UDC4PNIS.cjs.map +1 -0
  9. package/dist/{FilesViewerDialog-FFPW7TIK.cjs → FilesViewerDialog-D5GHWK4Y.cjs} +12 -11
  10. package/dist/FilesViewerDialog-D5GHWK4Y.cjs.map +1 -0
  11. package/dist/{WorkspaceTableView-2RH33X3U.cjs → WorkspaceTableView-2NRV4CWP.cjs} +7 -6
  12. package/dist/WorkspaceTableView-2NRV4CWP.cjs.map +1 -0
  13. package/dist/agents/index.cjs +176 -175
  14. package/dist/agents/tasks/TaskRowMenu.d.ts +1 -2
  15. package/dist/agents/tasks/TaskRowMenu.js +0 -2
  16. package/dist/agents/tasks/TaskRowMenu.js.map +2 -2
  17. package/dist/agents/tasks/TaskTable.d.ts +5 -2
  18. package/dist/agents/tasks/TaskTable.js +11 -8
  19. package/dist/agents/tasks/TaskTable.js.map +2 -2
  20. package/dist/agents/tasks/taskTableLabels.js +1 -1
  21. package/dist/agents/tasks/taskTableLabels.js.map +1 -1
  22. package/dist/{ai-YX3OAC4F.cjs → ai-VLIPYNWP.cjs} +13 -13
  23. package/dist/ai-VLIPYNWP.cjs.map +1 -0
  24. package/dist/calls/index.cjs +2 -2
  25. package/dist/chat/ChatThreads.js +1 -1
  26. package/dist/chat/ChatThreads.js.map +2 -2
  27. package/dist/chat/chat-page-types.d.ts +2 -0
  28. package/dist/chat/chat-page-types.js.map +2 -2
  29. package/dist/chat/index.cjs +25 -25
  30. package/dist/{chunk-32HVYK4Q.cjs → chunk-3VPNL4EH.cjs} +14 -13
  31. package/dist/chunk-3VPNL4EH.cjs.map +1 -0
  32. package/dist/{chunk-6TU4YLFW.cjs → chunk-5TT6J67U.cjs} +3 -3
  33. package/dist/chunk-5TT6J67U.cjs.map +1 -0
  34. package/dist/{chunk-N7AUJTU4.cjs → chunk-7AULM6LS.cjs} +5 -5
  35. package/dist/{chunk-N7AUJTU4.cjs.map → chunk-7AULM6LS.cjs.map} +1 -1
  36. package/dist/{chunk-MBXXWTKT.cjs → chunk-AYWY4MX2.cjs} +28 -28
  37. package/dist/{chunk-MBXXWTKT.cjs.map → chunk-AYWY4MX2.cjs.map} +1 -1
  38. package/dist/{chunk-P2AZ2HX7.cjs → chunk-AZQ4XIVY.cjs} +26 -26
  39. package/dist/{chunk-P2AZ2HX7.cjs.map → chunk-AZQ4XIVY.cjs.map} +1 -1
  40. package/dist/{chunk-VZKTOGZR.cjs → chunk-BLRPBEUG.cjs} +2 -2
  41. package/dist/{chunk-VZKTOGZR.cjs.map → chunk-BLRPBEUG.cjs.map} +1 -1
  42. package/dist/chunk-DKY67DA6.cjs +43 -0
  43. package/dist/chunk-DKY67DA6.cjs.map +1 -0
  44. package/dist/{chunk-N3H3YAKY.cjs → chunk-DUNXLT63.cjs} +17 -12
  45. package/dist/chunk-DUNXLT63.cjs.map +1 -0
  46. package/dist/{chunk-UOI6JJPG.cjs → chunk-EF2QQBDV.cjs} +29 -134
  47. package/dist/chunk-EF2QQBDV.cjs.map +1 -0
  48. package/dist/{chunk-3Y75LUCT.cjs → chunk-FHKBR55Q.cjs} +3 -3
  49. package/dist/{chunk-3Y75LUCT.cjs.map → chunk-FHKBR55Q.cjs.map} +1 -1
  50. package/dist/{chunk-QW6NCUR7.cjs → chunk-GAA222SK.cjs} +5 -5
  51. package/dist/{chunk-QW6NCUR7.cjs.map → chunk-GAA222SK.cjs.map} +1 -1
  52. package/dist/{chunk-LVIQWRC5.cjs → chunk-KRQCUVH7.cjs} +2 -2
  53. package/dist/chunk-KRQCUVH7.cjs.map +1 -0
  54. package/dist/{chunk-6RJXO2NF.cjs → chunk-KWV4VC74.cjs} +6 -6
  55. package/dist/{chunk-6RJXO2NF.cjs.map → chunk-KWV4VC74.cjs.map} +1 -1
  56. package/dist/{chunk-UD56Y6UA.cjs → chunk-L5Q5PDTA.cjs} +4 -4
  57. package/dist/{chunk-UD56Y6UA.cjs.map → chunk-L5Q5PDTA.cjs.map} +1 -1
  58. package/dist/{chunk-XAW22O2S.cjs → chunk-LCIMYEGX.cjs} +4 -4
  59. package/dist/{chunk-XAW22O2S.cjs.map → chunk-LCIMYEGX.cjs.map} +1 -1
  60. package/dist/{chunk-BCRB42SP.cjs → chunk-LYYJDQW6.cjs} +110 -970
  61. package/dist/chunk-LYYJDQW6.cjs.map +1 -0
  62. package/dist/{chunk-OE36OY64.cjs → chunk-LZQ2XZOC.cjs} +4 -4
  63. package/dist/{chunk-OE36OY64.cjs.map → chunk-LZQ2XZOC.cjs.map} +1 -1
  64. package/dist/{chunk-BTAT3MJP.cjs → chunk-MEWRE43W.cjs} +28 -28
  65. package/dist/{chunk-BTAT3MJP.cjs.map → chunk-MEWRE43W.cjs.map} +1 -1
  66. package/dist/chunk-MWHVETKN.cjs +151 -0
  67. package/dist/chunk-MWHVETKN.cjs.map +1 -0
  68. package/dist/{chunk-33GOYI3O.cjs → chunk-ONRUHYW3.cjs} +4 -4
  69. package/dist/{chunk-33GOYI3O.cjs.map → chunk-ONRUHYW3.cjs.map} +1 -1
  70. package/dist/{chunk-KP7BQIZL.cjs → chunk-ORGGDQKZ.cjs} +43 -40
  71. package/dist/chunk-ORGGDQKZ.cjs.map +1 -0
  72. package/dist/{chunk-N2OVF6SJ.cjs → chunk-OXPIJYRU.cjs} +65 -60
  73. package/dist/chunk-OXPIJYRU.cjs.map +1 -0
  74. package/dist/{chunk-2V5HW6T5.cjs → chunk-P5TQOSKA.cjs} +6 -6
  75. package/dist/{chunk-2V5HW6T5.cjs.map → chunk-P5TQOSKA.cjs.map} +1 -1
  76. package/dist/chunk-Q25CZLK6.cjs +958 -0
  77. package/dist/chunk-Q25CZLK6.cjs.map +1 -0
  78. package/dist/{chunk-ZPIZINH2.cjs → chunk-VLHBKF4P.cjs} +164 -98
  79. package/dist/chunk-VLHBKF4P.cjs.map +1 -0
  80. package/dist/{chunk-TG2GM7WJ.cjs → chunk-WCT6FT2K.cjs} +11 -7
  81. package/dist/chunk-WCT6FT2K.cjs.map +1 -0
  82. package/dist/{chunk-NPRNR54M.cjs → chunk-ZCVW63DF.cjs} +4 -4
  83. package/dist/{chunk-NPRNR54M.cjs.map → chunk-ZCVW63DF.cjs.map} +1 -1
  84. package/dist/collaboration/index.cjs +34 -9
  85. package/dist/collaboration/sharing/ShareControl.d.ts +15 -6
  86. package/dist/collaboration/sharing/ShareControl.js +9 -4
  87. package/dist/collaboration/sharing/ShareControl.js.map +2 -2
  88. package/dist/collaboration/sharing/index.d.ts +1 -0
  89. package/dist/collaboration/sharing/index.js +15 -1
  90. package/dist/collaboration/sharing/index.js.map +2 -2
  91. package/dist/collaboration/sharing/one-way.d.ts +41 -0
  92. package/dist/collaboration/sharing/one-way.js +39 -0
  93. package/dist/collaboration/sharing/one-way.js.map +7 -0
  94. package/dist/connect/index.cjs +4038 -3985
  95. package/dist/connect/index.cjs.map +1 -1
  96. package/dist/connect/viewer.cjs +9 -8
  97. package/dist/connection/account-cluster/ConnectedAccountCluster.js +1 -1
  98. package/dist/connection/account-cluster/ConnectedAccountCluster.js.map +1 -1
  99. package/dist/connection/agents/agentsPageParts.js +6 -2
  100. package/dist/connection/agents/agentsPageParts.js.map +2 -2
  101. package/dist/connection/command/actions.js +3 -3
  102. package/dist/connection/command/actions.js.map +2 -2
  103. package/dist/connection/conversation/ConnectedConversationSettings.js +3 -6
  104. package/dist/connection/conversation/ConnectedConversationSettings.js.map +2 -2
  105. package/dist/connection/dashboards/PanelEditor.d.ts +3 -9
  106. package/dist/connection/dashboards/PanelEditor.js +17 -124
  107. package/dist/connection/dashboards/PanelEditor.js.map +2 -2
  108. package/dist/connection/dashboards/index.d.ts +0 -1
  109. package/dist/connection/dashboards/index.js +0 -6
  110. package/dist/connection/dashboards/index.js.map +2 -2
  111. package/dist/connection/dashboards/templates.d.ts +1 -1
  112. package/dist/connection/dashboards/templates.js.map +1 -1
  113. package/dist/connection/databases/ConnectedDatabasesPage.js +46 -20
  114. package/dist/connection/databases/ConnectedDatabasesPage.js.map +2 -2
  115. package/dist/connection/databases/DatabaseViewsMenu.d.ts +5 -1
  116. package/dist/connection/databases/DatabaseViewsMenu.js +16 -21
  117. package/dist/connection/databases/DatabaseViewsMenu.js.map +2 -2
  118. package/dist/connection/files/bulk/ConnectedFilesBulkActions.d.ts +4 -3
  119. package/dist/connection/files/bulk/ConnectedFilesBulkActions.js +12 -18
  120. package/dist/connection/files/bulk/ConnectedFilesBulkActions.js.map +2 -2
  121. package/dist/connection/files/bulk/useDocumentBulkActions.d.ts +2 -3
  122. package/dist/connection/files/bulk/useDocumentBulkActions.js +6 -15
  123. package/dist/connection/files/bulk/useDocumentBulkActions.js.map +2 -2
  124. package/dist/connection/files/grid/cells.d.ts +7 -3
  125. package/dist/connection/files/grid/cells.js +8 -5
  126. package/dist/connection/files/grid/cells.js.map +2 -2
  127. package/dist/connection/files/grid/documentCellRenderers.d.ts +4 -1
  128. package/dist/connection/files/grid/documentCellRenderers.js +3 -2
  129. package/dist/connection/files/grid/documentCellRenderers.js.map +2 -2
  130. package/dist/connection/files/grid/documentColumns.d.ts +3 -3
  131. package/dist/connection/files/grid/documentColumns.js +4 -2
  132. package/dist/connection/files/grid/documentColumns.js.map +2 -2
  133. package/dist/connection/files/grid/useDocumentTable.js +10 -5
  134. package/dist/connection/files/grid/useDocumentTable.js.map +2 -2
  135. package/dist/connection/files/index.d.ts +1 -2
  136. package/dist/connection/files/index.js +4 -12
  137. package/dist/connection/files/index.js.map +2 -2
  138. package/dist/connection/files/review/useAiReviewLiveUpdates.js +13 -2
  139. package/dist/connection/files/review/useAiReviewLiveUpdates.js.map +2 -2
  140. package/dist/connection/files/views/ViewSelector.js +9 -21
  141. package/dist/connection/files/views/ViewSelector.js.map +2 -2
  142. package/dist/connection/files/views/useTableViews.d.ts +23 -15
  143. package/dist/connection/files/views/useTableViews.js +61 -35
  144. package/dist/connection/files/views/useTableViews.js.map +2 -2
  145. package/dist/connection/files/views/useViewWrites.d.ts +6 -0
  146. package/dist/connection/files/views/useViewWrites.js +64 -0
  147. package/dist/connection/files/views/useViewWrites.js.map +7 -0
  148. package/dist/connection/pages/BlockEditor.d.ts +32 -0
  149. package/dist/connection/pages/BlockEditor.js +175 -0
  150. package/dist/connection/pages/BlockEditor.js.map +7 -0
  151. package/dist/connection/pages/ConnectedPagesPage.d.ts +31 -0
  152. package/dist/connection/pages/ConnectedPagesPage.js +426 -0
  153. package/dist/connection/pages/ConnectedPagesPage.js.map +7 -0
  154. package/dist/connection/pages/DocumentBlocks.d.ts +46 -0
  155. package/dist/connection/pages/DocumentBlocks.js +200 -0
  156. package/dist/connection/pages/DocumentBlocks.js.map +7 -0
  157. package/dist/connection/pages/DocumentsPicker.d.ts +26 -0
  158. package/dist/connection/pages/DocumentsPicker.js +133 -0
  159. package/dist/connection/pages/DocumentsPicker.js.map +7 -0
  160. package/dist/connection/pages/PageBlockView.d.ts +22 -0
  161. package/dist/connection/pages/PageBlockView.js +82 -0
  162. package/dist/connection/pages/PageBlockView.js.map +7 -0
  163. package/dist/connection/pages/PageGrid.d.ts +26 -0
  164. package/dist/connection/pages/PageGrid.js +50 -0
  165. package/dist/connection/pages/PageGrid.js.map +7 -0
  166. package/dist/connection/pages/PageView.d.ts +24 -0
  167. package/dist/connection/pages/PageView.js +93 -0
  168. package/dist/connection/pages/PageView.js.map +7 -0
  169. package/dist/connection/pages/PagesList.d.ts +14 -0
  170. package/dist/connection/pages/PagesList.js +143 -0
  171. package/dist/connection/pages/PagesList.js.map +7 -0
  172. package/dist/connection/pages/TableViewBlock.d.ts +24 -0
  173. package/dist/connection/pages/TableViewBlock.js +82 -0
  174. package/dist/connection/pages/TableViewBlock.js.map +7 -0
  175. package/dist/connection/pages/ViewPicker.d.ts +21 -0
  176. package/dist/connection/pages/ViewPicker.js +56 -0
  177. package/dist/connection/pages/ViewPicker.js.map +7 -0
  178. package/dist/connection/pages/index.d.ts +9 -0
  179. package/dist/connection/pages/index.js +49 -0
  180. package/dist/connection/pages/index.js.map +7 -0
  181. package/dist/connection/pages/labels.d.ts +61 -0
  182. package/dist/connection/pages/labels.js +61 -0
  183. package/dist/connection/pages/labels.js.map +7 -0
  184. package/dist/connection/settings-page/featuresSection.js +2 -2
  185. package/dist/connection/settings-page/featuresSection.js.map +1 -1
  186. package/dist/connection/sharing/ResourceShareForm.js +1 -1
  187. package/dist/connection/sharing/ResourceShareForm.js.map +2 -2
  188. package/dist/connection/threads-page/ConnectedThreadsPage.js +10 -8
  189. package/dist/connection/threads-page/ConnectedThreadsPage.js.map +2 -2
  190. package/dist/connection/viewer/ConnectedDocumentViewer.js +11 -6
  191. package/dist/connection/viewer/ConnectedDocumentViewer.js.map +2 -2
  192. package/dist/dashboards/ConditionsEditor.d.ts +54 -0
  193. package/dist/dashboards/ConditionsEditor.js +156 -0
  194. package/dist/dashboards/ConditionsEditor.js.map +7 -0
  195. package/dist/dashboards/index.cjs +33 -521
  196. package/dist/dashboards/index.cjs.map +1 -1
  197. package/dist/dashboards/index.d.ts +3 -2
  198. package/dist/dashboards/index.js +13 -1
  199. package/dist/dashboards/index.js.map +2 -2
  200. package/dist/databases/DatabaseFilterMenu.d.ts +18 -0
  201. package/dist/databases/DatabaseFilterMenu.js +95 -0
  202. package/dist/databases/DatabaseFilterMenu.js.map +7 -0
  203. package/dist/databases/DatabaseTable.js +1 -1
  204. package/dist/databases/DatabaseTable.js.map +1 -1
  205. package/dist/databases/DatabaseToolbar.d.ts +3 -1
  206. package/dist/databases/DatabaseToolbar.js +2 -0
  207. package/dist/databases/DatabaseToolbar.js.map +2 -2
  208. package/dist/databases/index.cjs +85 -71
  209. package/dist/databases/index.d.ts +1 -0
  210. package/dist/databases/index.js +8 -0
  211. package/dist/databases/index.js.map +2 -2
  212. package/dist/embed/index.cjs +14 -13
  213. package/dist/facts/index.cjs +43 -43
  214. package/dist/files/bulk/BulkActionsBar.d.ts +8 -5
  215. package/dist/files/bulk/BulkActionsBar.js +6 -7
  216. package/dist/files/bulk/BulkActionsBar.js.map +2 -2
  217. package/dist/files/cells/DocumentNameCell.d.ts +2 -1
  218. package/dist/files/cells/DocumentNameCell.js +1 -1
  219. package/dist/files/cells/DocumentNameCell.js.map +2 -2
  220. package/dist/files/index.cjs +237 -224
  221. package/dist/files/index.d.ts +1 -1
  222. package/dist/files/index.js +0 -2
  223. package/dist/files/index.js.map +2 -2
  224. package/dist/files/permissions.d.ts +4 -3
  225. package/dist/files/permissions.js +6 -3
  226. package/dist/files/permissions.js.map +2 -2
  227. package/dist/files/views/ViewSelectorMenu.d.ts +24 -5
  228. package/dist/files/views/ViewSelectorMenu.js +78 -51
  229. package/dist/files/views/ViewSelectorMenu.js.map +2 -2
  230. package/dist/files/views/gridViews.d.ts +34 -1
  231. package/dist/files/views/gridViews.js +28 -0
  232. package/dist/files/views/gridViews.js.map +2 -2
  233. package/dist/files/views/index.d.ts +2 -2
  234. package/dist/files/views/index.js +8 -0
  235. package/dist/files/views/index.js.map +2 -2
  236. package/dist/files/views/useGridViews.d.ts +8 -4
  237. package/dist/files/views/useGridViews.js +42 -11
  238. package/dist/files/views/useGridViews.js.map +2 -2
  239. package/dist/files/visibility.d.ts +1 -16
  240. package/dist/files/visibility.js +6 -23
  241. package/dist/files/visibility.js.map +2 -2
  242. package/dist/index.cjs +454 -429
  243. package/dist/index.cjs.map +1 -1
  244. package/dist/pages/index.cjs +1363 -0
  245. package/dist/pages/index.cjs.map +1 -0
  246. package/dist/pages/index.d.ts +14 -0
  247. package/dist/pages/index.js +3 -0
  248. package/dist/pages/index.js.map +7 -0
  249. package/dist/settings/ConversationSettingsParts.d.ts +4 -6
  250. package/dist/settings/ConversationSettingsParts.js +15 -10
  251. package/dist/settings/ConversationSettingsParts.js.map +2 -2
  252. package/dist/settings/index.cjs +145 -144
  253. package/dist/studio/index.cjs +8 -7
  254. package/dist/studio/index.cjs.map +1 -1
  255. package/dist/studio/widgets.js.map +1 -1
  256. package/dist/styles.css +1 -1
  257. package/dist/workflow-canvas/index.cjs +23 -22
  258. package/dist/workflow-canvas/index.cjs.map +1 -1
  259. package/node_modules/@arbidocs/coedit/package.json +1 -1
  260. package/package.json +10 -5
  261. package/dist/DocumentReviewCard-ENCPTGJE.cjs.map +0 -1
  262. package/dist/FilesViewerDialog-FFPW7TIK.cjs.map +0 -1
  263. package/dist/WorkspaceTableView-2RH33X3U.cjs.map +0 -1
  264. package/dist/ai-YX3OAC4F.cjs.map +0 -1
  265. package/dist/chunk-32HVYK4Q.cjs.map +0 -1
  266. package/dist/chunk-6TU4YLFW.cjs.map +0 -1
  267. package/dist/chunk-BCRB42SP.cjs.map +0 -1
  268. package/dist/chunk-KP7BQIZL.cjs.map +0 -1
  269. package/dist/chunk-LVIQWRC5.cjs.map +0 -1
  270. package/dist/chunk-N2OVF6SJ.cjs.map +0 -1
  271. package/dist/chunk-N3H3YAKY.cjs.map +0 -1
  272. package/dist/chunk-TG2GM7WJ.cjs.map +0 -1
  273. package/dist/chunk-UOI6JJPG.cjs.map +0 -1
  274. package/dist/chunk-ZPIZINH2.cjs.map +0 -1
  275. package/dist/connection/dashboards/ConnectedDashboardsPage.d.ts +0 -69
  276. package/dist/connection/dashboards/ConnectedDashboardsPage.js +0 -554
  277. package/dist/connection/dashboards/ConnectedDashboardsPage.js.map +0 -7
  278. package/dist/connection/files/views/tableViews.d.ts +0 -19
  279. package/dist/connection/files/views/tableViews.js +0 -36
  280. package/dist/connection/files/views/tableViews.js.map +0 -7
@@ -1,778 +1,14 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
+ var chunkQ25CZLK6_cjs = require('./chunk-Q25CZLK6.cjs');
5
+ var chunkMWHVETKN_cjs = require('./chunk-MWHVETKN.cjs');
4
6
  var chunkBQOL4XNZ_cjs = require('./chunk-BQOL4XNZ.cjs');
5
- var chunkZVEW3JBT_cjs = require('./chunk-ZVEW3JBT.cjs');
6
- var chunkPLIF5CUV_cjs = require('./chunk-PLIF5CUV.cjs');
7
- var lucideReact = require('lucide-react');
8
7
  var ui = require('@arbidocs/react/ui');
9
8
  var jsxRuntime = require('react/jsx-runtime');
10
9
  var react = require('react');
10
+ var lucideReact = require('lucide-react');
11
11
 
12
- // src/databases/column-types.ts
13
- var DATABASE_COLUMN_TYPES = [
14
- "text",
15
- "number",
16
- "date",
17
- "checkbox",
18
- "select",
19
- "person",
20
- "document",
21
- "relation",
22
- "lookup",
23
- "rollup"
24
- ];
25
- var COMPUTED_COLUMN_TYPES = /* @__PURE__ */ new Set([
26
- "lookup",
27
- "rollup"
28
- ]);
29
- var LINK_COLUMN_TYPES = /* @__PURE__ */ new Set([
30
- "document",
31
- "relation"
32
- ]);
33
- var isComputedColumn = (column) => COMPUTED_COLUMN_TYPES.has(column.type);
34
- var DATABASE_ROLLUP_OPS = ["count", "sum", "avg", "min", "max"];
35
- var DEFAULT_DATABASE_COLUMN_TYPE_LABELS = {
36
- text: "Text",
37
- number: "Number",
38
- date: "Date",
39
- checkbox: "Checkbox",
40
- select: "Select",
41
- person: "Person",
42
- document: "Documents",
43
- relation: "Relation",
44
- lookup: "Lookup",
45
- rollup: "Rollup"
46
- };
47
- var OPTION_TONES = [
48
- "bg-blue-bg text-blue-text",
49
- "bg-green-bg text-green-text",
50
- "bg-yellow-bg text-yellow-text",
51
- "bg-purple-bg text-purple-text",
52
- "bg-red-bg text-red-text",
53
- "bg-gray-bg text-gray-text"
54
- ];
55
- function optionTone(option) {
56
- let hash = 0;
57
- for (const ch of option.toLowerCase()) hash = hash * 31 + ch.charCodeAt(0) >>> 0;
58
- return OPTION_TONES[hash % OPTION_TONES.length];
59
- }
60
- var isEmpty = (value) => value === null || value === void 0 || typeof value === "string" && value.trim() === "" || Array.isArray(value) && value.length === 0;
61
- function cellList(value) {
62
- if (isEmpty(value)) return [];
63
- return Array.isArray(value) ? value.filter((v) => !isEmpty(v)) : [value];
64
- }
65
- function cellIds(value) {
66
- return cellList(value).filter((v) => typeof v === "string");
67
- }
68
- function titleOf(id, titles) {
69
- return titles?.[id] ?? id;
70
- }
71
- function sameCellValue(a, b) {
72
- if (Array.isArray(a) || Array.isArray(b)) {
73
- const la = cellList(a);
74
- const lb = cellList(b);
75
- return la.length === lb.length && la.every((v, i) => v === lb[i]);
76
- }
77
- return (a ?? null) === (b ?? null);
78
- }
79
- function formatDateValue(value, locale) {
80
- const day = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
81
- if (day) {
82
- const [, y, m, d] = day;
83
- return new Date(Date.UTC(+y, +m - 1, +d)).toLocaleDateString(locale, { timeZone: "UTC" });
84
- }
85
- const at = new Date(value);
86
- return Number.isNaN(at.getTime()) ? value : at.toLocaleString(locale);
87
- }
88
- function formatNumberValue(value, locale) {
89
- return value.toLocaleString(locale, { maximumFractionDigits: 6 });
90
- }
91
- var ISO_DATE = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;
92
- function formatLookupValue(value, titles, locale) {
93
- if (isEmpty(value)) return "";
94
- if (typeof value === "number") return formatNumberValue(value, locale);
95
- if (typeof value === "boolean") return value ? "Yes" : "No";
96
- if (typeof value === "string") {
97
- if (titles?.[value] !== void 0) return titles[value];
98
- if (ISO_DATE.test(value)) return formatDateValue(value, locale);
99
- }
100
- return String(value);
101
- }
102
- var NAMED_TYPES = /* @__PURE__ */ new Set([
103
- "person",
104
- "document",
105
- "relation"
106
- ]);
107
- function formatCell(value, type, locale, titles) {
108
- if (isEmpty(value)) return "";
109
- if ((type === "number" || type === "rollup") && typeof value === "number")
110
- return formatNumberValue(value, locale);
111
- if (type === "date" && typeof value === "string") return formatDateValue(value, locale);
112
- if (type === "checkbox") return value ? "Yes" : "No";
113
- if (NAMED_TYPES.has(type))
114
- return cellIds(value).map((id) => titleOf(id, titles)).join(", ");
115
- if (type === "lookup")
116
- return cellList(value).map((v) => formatLookupValue(v, titles, locale)).join(", ");
117
- return String(value);
118
- }
119
- function toApiValue(value, type) {
120
- if (isEmpty(value)) return null;
121
- if (LINK_COLUMN_TYPES.has(type)) return cellIds(value);
122
- if (type === "checkbox") return Boolean(value);
123
- if (type === "date" && value instanceof Date) {
124
- const pad = (n) => String(n).padStart(2, "0");
125
- return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}`;
126
- }
127
- if (type === "number" && typeof value === "string") {
128
- const n = Number(value.replace(/,/g, ""));
129
- return Number.isFinite(n) ? n : value;
130
- }
131
- return value;
132
- }
133
- function compareCells(a, b, type, titlesA, titlesB) {
134
- const ea = isEmpty(a);
135
- const eb = isEmpty(b);
136
- if (ea || eb) return ea === eb ? 0 : ea ? 1 : -1;
137
- if (type === "number" || type === "checkbox" || type === "rollup") return Number(a) - Number(b);
138
- const shown = NAMED_TYPES.has(type) || type === "lookup";
139
- const ta = shown ? formatCell(a, type, void 0, titlesA) : String(a);
140
- const tb = shown ? formatCell(b, type, void 0, titlesB) : String(b);
141
- return ta.localeCompare(tb, void 0, { sensitivity: "base", numeric: true });
142
- }
143
- function rowTitle(row, columns, locale) {
144
- const first = columns[0];
145
- return first ? formatCell(row.values[first.id], first.type, locale, row.titles) : "";
146
- }
147
- var CHIP = "inline-flex h-[22px] min-w-0 max-w-[14rem] shrink-0 items-center gap-1 rounded-md border border-border bg-muted/50 px-1.5 text-xs text-foreground";
148
- function initials(name) {
149
- const parts = name.trim().split(/\s+/).filter(Boolean);
150
- const letters = parts.length > 1 ? parts[0][0] + parts[parts.length - 1][0] : name.slice(0, 2);
151
- return letters.toUpperCase();
152
- }
153
- function PersonChip({ name }) {
154
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex min-w-0 items-center gap-1.5 text-sm", children: [
155
- /* @__PURE__ */ jsxRuntime.jsx(
156
- "span",
157
- {
158
- "aria-hidden": true,
159
- className: "flex size-5 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-medium text-muted-foreground",
160
- children: initials(name)
161
- }
162
- ),
163
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: name })
164
- ] });
165
- }
166
- function LinkChip({
167
- label,
168
- kind,
169
- onOpen,
170
- testId
171
- }) {
172
- const Icon = kind === "document" ? lucideReact.FileText : lucideReact.ArrowUpRight;
173
- const body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
174
- /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-3 shrink-0 text-muted-foreground", "aria-hidden": true }),
175
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: label })
176
- ] });
177
- if (!onOpen) {
178
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: CHIP, title: label, "data-testid": testId, children: body });
179
- }
180
- const stop = (e) => e.stopPropagation();
181
- return /* @__PURE__ */ jsxRuntime.jsx(
182
- "button",
183
- {
184
- type: "button",
185
- title: label,
186
- "data-testid": testId,
187
- onClick: (e) => {
188
- e.stopPropagation();
189
- onOpen();
190
- },
191
- onDoubleClick: stop,
192
- onMouseDown: stop,
193
- className: ui.cn(CHIP, "hover:bg-muted hover:underline"),
194
- children: body
195
- }
196
- );
197
- }
198
- function ChipRow({ children, wrap }) {
199
- return /* @__PURE__ */ jsxRuntime.jsx(
200
- "span",
201
- {
202
- className: ui.cn(
203
- "flex min-w-0 items-center gap-1",
204
- wrap ? "flex-wrap py-0.5" : "h-full overflow-hidden"
205
- ),
206
- children
207
- }
208
- );
209
- }
210
- function PersonCell({ value, titles }) {
211
- const [id] = cellIds(value);
212
- return id ? /* @__PURE__ */ jsxRuntime.jsx(PersonChip, { name: titleOf(id, titles) }) : null;
213
- }
214
- function LinkChipsCell({
215
- value,
216
- titles,
217
- kind,
218
- onOpenDocument,
219
- wrap
220
- }) {
221
- const ids = cellIds(value);
222
- if (ids.length === 0) return null;
223
- return /* @__PURE__ */ jsxRuntime.jsx(ChipRow, { wrap, children: ids.map((id) => /* @__PURE__ */ jsxRuntime.jsx(
224
- LinkChip,
225
- {
226
- label: titleOf(id, titles),
227
- kind,
228
- testId: `database-chip-${id}`,
229
- onOpen: kind === "document" && onOpenDocument ? () => onOpenDocument(id) : void 0
230
- },
231
- id
232
- )) });
233
- }
234
- function LookupCell({
235
- value,
236
- titles,
237
- locale,
238
- wrap
239
- }) {
240
- const values = cellList(value);
241
- if (values.length === 0) return null;
242
- return /* @__PURE__ */ jsxRuntime.jsx(ChipRow, { wrap, children: values.map((v, i) => {
243
- const text = formatLookupValue(v, titles, locale);
244
- const key = `${i}-${text}`;
245
- if (typeof v === "string" && /^doc-/.test(v))
246
- return /* @__PURE__ */ jsxRuntime.jsx(LinkChip, { label: text, kind: "document" }, key);
247
- if (typeof v === "string" && /^dbr-/.test(v))
248
- return /* @__PURE__ */ jsxRuntime.jsx(LinkChip, { label: text, kind: "relation" }, key);
249
- return /* @__PURE__ */ jsxRuntime.jsx(
250
- "span",
251
- {
252
- title: text,
253
- className: "inline-flex h-[22px] min-w-0 max-w-[14rem] shrink-0 items-center truncate rounded-md bg-muted/60 px-1.5 text-xs text-foreground",
254
- children: text
255
- },
256
- key
257
- );
258
- }) });
259
- }
260
- var MAX_SHOWN = 50;
261
- var SEARCH_DEBOUNCE_MS = 200;
262
- var DEFAULT_PICK_CELL_EDITOR_LABELS = {
263
- searchPlaceholder: "Search\u2026",
264
- noMatches: "No matches",
265
- searching: "Searching\u2026",
266
- clear: "Clear",
267
- done: "Done",
268
- remove: (label) => `Remove ${label}`
269
- };
270
- function useChoices(query, options, search) {
271
- const [found, setFound] = react.useState([]);
272
- const [loading, setLoading] = react.useState(Boolean(search));
273
- react.useEffect(() => {
274
- if (!search) return;
275
- let live = true;
276
- setLoading(true);
277
- const t = setTimeout(
278
- () => {
279
- search(query.trim()).then((rows) => live && setFound(rows)).catch(() => live && setFound([])).finally(() => live && setLoading(false));
280
- },
281
- query ? SEARCH_DEBOUNCE_MS : 0
282
- );
283
- return () => {
284
- live = false;
285
- clearTimeout(t);
286
- };
287
- }, [query, search]);
288
- const filtered = react.useMemo(() => {
289
- if (search) return found.slice(0, MAX_SHOWN);
290
- const q = query.trim().toLowerCase();
291
- const all = options ?? [];
292
- const hits = q ? all.filter(
293
- (o) => o.label.toLowerCase().includes(q) || (o.description ?? "").toLowerCase().includes(q)
294
- ) : all;
295
- return hits.slice(0, MAX_SHOWN);
296
- }, [found, options, query, search]);
297
- return { choices: filtered, loading: Boolean(search) && loading };
298
- }
299
- function PickCellEditor(props) {
300
- const { value, onValueChange, stopEditing, data, kind, options, search } = props;
301
- const l = { ...DEFAULT_PICK_CELL_EDITOR_LABELS, ...props.labels };
302
- const multiple = kind !== "person";
303
- const [chosen, setChosen] = react.useState(() => cellIds(value));
304
- const [query, setQuery] = react.useState("");
305
- const [active, setActive] = react.useState(0);
306
- const input = react.useRef(null);
307
- const { choices, loading } = useChoices(query, options, search);
308
- const names = react.useRef({ ...data?.titles ?? {} });
309
- for (const o of options ?? []) names.current[o.id] ??= o.label;
310
- for (const o of choices) names.current[o.id] = o.label;
311
- const nameOf = (id) => names.current[id] ?? id;
312
- react.useEffect(() => input.current?.focus(), []);
313
- react.useEffect(() => setActive(0), [query]);
314
- const commit = (ids) => {
315
- setChosen(ids);
316
- if (data) {
317
- const titles = { ...data.titles ?? {} };
318
- for (const id of ids) titles[id] ??= nameOf(id);
319
- data.titles = titles;
320
- }
321
- onValueChange(multiple ? ids : ids[0] ?? null);
322
- };
323
- const close = () => setTimeout(() => stopEditing(), 0);
324
- const toggle = (id) => {
325
- if (!multiple) {
326
- commit([id]);
327
- close();
328
- return;
329
- }
330
- commit(chosen.includes(id) ? chosen.filter((x) => x !== id) : [...chosen, id]);
331
- };
332
- const onKeyDown = (e) => {
333
- if (e.key === "ArrowDown" || e.key === "ArrowUp") {
334
- e.preventDefault();
335
- e.stopPropagation();
336
- if (choices.length === 0) return;
337
- const step = e.key === "ArrowDown" ? 1 : -1;
338
- setActive((i) => (i + step + choices.length) % choices.length);
339
- } else if (e.key === "Enter") {
340
- e.preventDefault();
341
- e.stopPropagation();
342
- const pick = choices[active];
343
- if (pick) toggle(pick.id);
344
- else if (multiple) close();
345
- } else if (e.key === "Backspace" && multiple && !query && chosen.length > 0) {
346
- commit(chosen.slice(0, -1));
347
- } else if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home" || e.key === "End") {
348
- e.stopPropagation();
349
- }
350
- };
351
- return /* @__PURE__ */ jsxRuntime.jsxs(
352
- "div",
353
- {
354
- "data-testid": "database-pick-editor",
355
- className: "flex w-72 flex-col rounded-md border border-border bg-popover shadow-md",
356
- children: [
357
- multiple && chosen.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1 border-b border-border p-1.5", children: chosen.map((id) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex min-w-0 items-center", children: [
358
- /* @__PURE__ */ jsxRuntime.jsx(LinkChip, { label: nameOf(id), kind: kind === "document" ? "document" : "relation" }),
359
- /* @__PURE__ */ jsxRuntime.jsx(
360
- "button",
361
- {
362
- type: "button",
363
- "aria-label": l.remove(nameOf(id)),
364
- onClick: () => commit(chosen.filter((x) => x !== id)),
365
- "data-testid": `database-pick-remove-${id}`,
366
- className: "rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",
367
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "size-3" })
368
- }
369
- )
370
- ] }, id)) }),
371
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 border-b border-border px-2", children: [
372
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": true }),
373
- /* @__PURE__ */ jsxRuntime.jsx(
374
- "input",
375
- {
376
- ref: input,
377
- value: query,
378
- placeholder: l.searchPlaceholder,
379
- onChange: (e) => setQuery(e.target.value),
380
- onKeyDown,
381
- "data-testid": "database-pick-search",
382
- className: "h-8 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
383
- }
384
- ),
385
- loading && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-3.5 animate-spin text-muted-foreground" })
386
- ] }),
387
- /* @__PURE__ */ jsxRuntime.jsxs("div", { role: "listbox", "aria-multiselectable": multiple, className: "max-h-64 overflow-y-auto p-1", children: [
388
- choices.map((o, i) => {
389
- const isChosen = chosen.includes(o.id);
390
- return /* @__PURE__ */ jsxRuntime.jsxs(
391
- "button",
392
- {
393
- type: "button",
394
- role: "option",
395
- "aria-selected": isChosen,
396
- onMouseEnter: () => setActive(i),
397
- onClick: () => toggle(o.id),
398
- "data-testid": `database-pick-option-${o.id}`,
399
- className: ui.cn(
400
- "flex w-full items-center gap-2 rounded px-2 py-1 text-left text-sm",
401
- i === active && "bg-muted"
402
- ),
403
- children: [
404
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [
405
- kind === "person" ? /* @__PURE__ */ jsxRuntime.jsx(PersonChip, { name: o.label }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: o.label }),
406
- o.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs text-muted-foreground", children: o.description })
407
- ] }),
408
- isChosen && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "size-3.5 shrink-0" })
409
- ]
410
- },
411
- o.id
412
- );
413
- }),
414
- choices.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-2 py-1.5 text-sm text-muted-foreground", children: loading ? l.searching : l.noMatches })
415
- ] }),
416
- (multiple || chosen.length > 0) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end border-t border-border p-1", children: !multiple ? /* @__PURE__ */ jsxRuntime.jsx(
417
- "button",
418
- {
419
- type: "button",
420
- onClick: () => {
421
- commit([]);
422
- close();
423
- },
424
- "data-testid": "database-pick-clear",
425
- className: "rounded px-2 py-1 text-sm text-muted-foreground hover:bg-muted",
426
- children: l.clear
427
- }
428
- ) : /* @__PURE__ */ jsxRuntime.jsx(
429
- "button",
430
- {
431
- type: "button",
432
- onClick: close,
433
- "data-testid": "database-pick-done",
434
- className: "rounded px-2 py-1 text-sm font-medium hover:bg-muted",
435
- children: l.done
436
- }
437
- ) })
438
- ]
439
- }
440
- );
441
- }
442
- function SelectChip({ value }) {
443
- return /* @__PURE__ */ jsxRuntime.jsx(
444
- "span",
445
- {
446
- className: ui.cn(
447
- "inline-flex max-w-full items-center truncate rounded-md px-2 py-0.5 text-xs font-medium",
448
- optionTone(value)
449
- ),
450
- children: value
451
- }
452
- );
453
- }
454
- function SelectCellEditor(props) {
455
- const { value, onValueChange, stopEditing, options, clearLabel = "Clear" } = props;
456
- const items = [...options, null];
457
- const [active, setActive] = react.useState(() => Math.max(0, options.indexOf(String(value ?? ""))));
458
- const list = react.useRef(null);
459
- react.useEffect(() => list.current?.focus(), []);
460
- const pick = (option) => {
461
- onValueChange(option);
462
- setTimeout(() => stopEditing(), 0);
463
- };
464
- const onKeyDown = (e) => {
465
- if (e.key === "ArrowDown" || e.key === "ArrowUp") {
466
- e.preventDefault();
467
- e.stopPropagation();
468
- const step = e.key === "ArrowDown" ? 1 : -1;
469
- setActive((i) => (i + step + items.length) % items.length);
470
- } else if (e.key === "Enter") {
471
- e.preventDefault();
472
- e.stopPropagation();
473
- pick(items[active]);
474
- }
475
- };
476
- return /* @__PURE__ */ jsxRuntime.jsx(
477
- "div",
478
- {
479
- ref: list,
480
- role: "listbox",
481
- tabIndex: -1,
482
- onKeyDown,
483
- "data-testid": "database-select-editor",
484
- className: "flex min-w-44 flex-col gap-0.5 rounded-md border border-border bg-popover p-1 shadow-md outline-none",
485
- children: items.map((option, i) => /* @__PURE__ */ jsxRuntime.jsxs(
486
- "button",
487
- {
488
- type: "button",
489
- role: "option",
490
- "aria-selected": option === value,
491
- onMouseEnter: () => setActive(i),
492
- onClick: () => pick(option),
493
- "data-testid": option === null ? "database-select-clear" : `database-select-option-${option}`,
494
- className: ui.cn(
495
- "flex items-center gap-2 rounded px-2 py-1 text-left text-sm",
496
- i === active && "bg-muted"
497
- ),
498
- children: [
499
- option === null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: clearLabel }) : /* @__PURE__ */ jsxRuntime.jsx(SelectChip, { value: option }),
500
- option !== null && option === value && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "ml-auto size-3.5" })
501
- ]
502
- },
503
- option ?? "__clear"
504
- ))
505
- }
506
- );
507
- }
508
- var DEFAULT_DATABASE_COLUMN_LABELS = {
509
- addColumn: "Add a column",
510
- columnSettings: (name) => `${name} column settings`,
511
- computed: "Computed from a relation (read-only)",
512
- openRow: "Open row"
513
- };
514
- var ADD_COLUMN_COL_ID = "__add_column";
515
- var OPEN_ROW_COL_ID = "__open_row";
516
- var COLUMN_TYPE_ICONS = {
517
- text: lucideReact.Type,
518
- number: lucideReact.Hash,
519
- date: lucideReact.CalendarDays,
520
- checkbox: lucideReact.CheckSquare,
521
- select: lucideReact.ChevronDown,
522
- person: lucideReact.UserRound,
523
- document: lucideReact.FileText,
524
- relation: lucideReact.ArrowUpRight,
525
- lookup: lucideReact.Search,
526
- rollup: lucideReact.Sigma
527
- };
528
- var WIDTHS = {
529
- text: 220,
530
- number: 130,
531
- date: 140,
532
- checkbox: 110,
533
- select: 160,
534
- person: 180,
535
- document: 240,
536
- relation: 240,
537
- lookup: 200,
538
- rollup: 130
539
- };
540
- function HeaderLabel({
541
- dbColumn: column,
542
- onEdit,
543
- settingsLabel: label,
544
- computedLabel
545
- }) {
546
- const Icon = COLUMN_TYPE_ICONS[column.type];
547
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "group/dbh flex min-w-0 items-center gap-1.5", children: [
548
- /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": true }),
549
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-[12.5px] font-medium", children: column.name }),
550
- isComputedColumn(column) && /* @__PURE__ */ jsxRuntime.jsx("span", { title: computedLabel, "data-testid": `database-column-computed-${column.id}`, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Lock, { className: "size-3 shrink-0 text-muted-foreground/70", "aria-label": computedLabel }) }),
551
- onEdit && /* @__PURE__ */ jsxRuntime.jsx(
552
- "button",
553
- {
554
- type: "button",
555
- "aria-label": label,
556
- title: label,
557
- "data-testid": `database-column-settings-${column.id}`,
558
- onClick: (e) => {
559
- e.stopPropagation();
560
- onEdit();
561
- },
562
- onMouseDown: (e) => e.stopPropagation(),
563
- className: "ml-auto rounded p-0.5 text-muted-foreground opacity-0 hover:bg-muted hover:text-foreground focus-visible:opacity-100 group-hover/dbh:opacity-100",
564
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreHorizontal, { className: "size-3.5" })
565
- }
566
- )
567
- ] });
568
- }
569
- function AddColumnHeader({ addLabel, onAddColumn }) {
570
- return /* @__PURE__ */ jsxRuntime.jsx(
571
- "button",
572
- {
573
- type: "button",
574
- "aria-label": addLabel,
575
- title: addLabel,
576
- "data-testid": "database-add-column",
577
- onClick: onAddColumn,
578
- className: "flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground",
579
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4" })
580
- }
581
- );
582
- }
583
- function columnWidth(column) {
584
- const header = Math.round(column.name.length * 8) + 76 + (isComputedColumn(column) ? 16 : 0);
585
- return Math.min(320, Math.max(WIDTHS[column.type], header));
586
- }
587
- function canEditColumn(column, sources) {
588
- if (isComputedColumn(column) || column.locked) return false;
589
- if (column.type === "person") return Boolean(sources?.members);
590
- if (column.type === "document") return Boolean(sources?.documents);
591
- if (column.type === "relation") return Boolean(sources?.searchRows && column.relation);
592
- return true;
593
- }
594
- function editorFor(column, sources) {
595
- const pick = (params) => ({
596
- cellEditor: PickCellEditor,
597
- cellEditorPopup: true,
598
- cellEditorParams: params
599
- });
600
- switch (column.type) {
601
- case "number":
602
- return { cellEditor: "agNumberCellEditor", cellEditorParams: { showStepperButtons: false } };
603
- case "date":
604
- return { cellEditor: "agDateStringCellEditor" };
605
- case "checkbox":
606
- return { cellEditor: "agCheckboxCellEditor" };
607
- case "select":
608
- return {
609
- cellEditor: SelectCellEditor,
610
- cellEditorPopup: true,
611
- cellEditorParams: { options: column.options ?? [] }
612
- };
613
- case "person":
614
- return pick({ kind: "person", options: sources?.members ?? [] });
615
- case "document":
616
- return pick({ kind: "document", options: sources?.documents ?? [] });
617
- case "relation": {
618
- const target = column.relation?.database_id;
619
- const searchRows = sources?.searchRows;
620
- return pick({
621
- kind: "relation",
622
- search: target && searchRows ? (q) => searchRows(target, q) : void 0
623
- });
624
- }
625
- case "lookup":
626
- case "rollup":
627
- return {};
628
- default:
629
- return { cellEditor: "agTextCellEditor" };
630
- }
631
- }
632
- function rendererFor(column, locale, sources) {
633
- switch (column.type) {
634
- case "checkbox":
635
- return {
636
- cellRenderer: "agCheckboxCellRenderer",
637
- cellClass: "flex items-center justify-center"
638
- };
639
- case "select":
640
- return {
641
- cellRenderer: (p) => typeof p.value === "string" && p.value ? /* @__PURE__ */ jsxRuntime.jsx(SelectChip, { value: p.value }) : null
642
- };
643
- case "number":
644
- return {
645
- cellClass: "cell-numeric",
646
- valueFormatter: (p) => formatCell(p.value, "number", locale)
647
- };
648
- case "rollup":
649
- return {
650
- cellClass: "cell-numeric text-muted-foreground",
651
- valueFormatter: (p) => formatCell(p.value, "rollup", locale)
652
- };
653
- case "date":
654
- return {
655
- valueFormatter: (p) => formatCell(p.value, "date", locale)
656
- };
657
- case "person":
658
- return {
659
- cellRenderer: (p) => /* @__PURE__ */ jsxRuntime.jsx(PersonCell, { value: p.value, titles: p.data?.titles })
660
- };
661
- case "document":
662
- case "relation":
663
- return {
664
- cellRenderer: (p) => /* @__PURE__ */ jsxRuntime.jsx(
665
- LinkChipsCell,
666
- {
667
- value: p.value,
668
- titles: p.data?.titles,
669
- kind: column.type === "document" ? "document" : "relation",
670
- onOpenDocument: sources?.onOpenDocument
671
- }
672
- )
673
- };
674
- case "lookup":
675
- return {
676
- cellRenderer: (p) => /* @__PURE__ */ jsxRuntime.jsx(LookupCell, { value: p.value, titles: p.data?.titles, locale })
677
- };
678
- default:
679
- return {};
680
- }
681
- }
682
- function createDatabaseColumns(columns, options = {}) {
683
- const { readOnly, onEditColumn, onAddColumn, onOpenRow, locale, sources } = options;
684
- const l = { ...DEFAULT_DATABASE_COLUMN_LABELS, ...options.labels };
685
- const openRow = onOpenRow && columns.length > 0 ? [
686
- {
687
- colId: OPEN_ROW_COL_ID,
688
- headerName: "",
689
- width: 40,
690
- minWidth: 40,
691
- maxWidth: 40,
692
- resizable: false,
693
- sortable: false,
694
- editable: false,
695
- suppressMovable: true,
696
- // Pinned: the button stays in view however far the table scrolls.
697
- pinned: "left",
698
- lockPinned: true,
699
- lockPosition: "left",
700
- cellClass: "flex items-center justify-center !px-0",
701
- valueGetter: () => null,
702
- cellRenderer: (p) => p.data ? /* @__PURE__ */ jsxRuntime.jsx(
703
- "button",
704
- {
705
- type: "button",
706
- "aria-label": l.openRow,
707
- title: l.openRow,
708
- "data-testid": `database-open-row-${p.data.id}`,
709
- onClick: (e) => {
710
- e.stopPropagation();
711
- if (p.data) onOpenRow(p.data);
712
- },
713
- onDoubleClick: (e) => e.stopPropagation(),
714
- className: "flex size-6 items-center justify-center rounded text-muted-foreground/70 hover:bg-muted hover:text-foreground",
715
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize2, { className: "size-3.5" })
716
- }
717
- ) : null
718
- }
719
- ] : [];
720
- const defs = columns.map((column) => ({
721
- colId: column.id,
722
- headerName: column.name,
723
- width: columnWidth(column),
724
- minWidth: 90,
725
- resizable: true,
726
- sortable: true,
727
- editable: !readOnly && canEditColumn(column, sources),
728
- // The grid's own type inference must not second-guess the database's column type.
729
- cellDataType: false,
730
- headerComponentParams: {
731
- innerHeaderComponent: HeaderLabel,
732
- innerHeaderComponentParams: {
733
- dbColumn: column,
734
- settingsLabel: l.columnSettings(column.name),
735
- computedLabel: l.computed,
736
- onEdit: !readOnly && onEditColumn ? () => onEditColumn(column) : void 0
737
- }
738
- },
739
- // An empty checkbox reads as unticked (not indeterminate).
740
- valueGetter: (p) => column.type === "checkbox" ? p.data?.values[column.id] === true : p.data?.values[column.id] ?? null,
741
- // Edits land in the row's values as the API would store them; the host saves them in
742
- // onCellValueChanged and puts the server's normalised row back.
743
- valueSetter: (p) => {
744
- if (!p.data) return false;
745
- const next = toApiValue(p.newValue, column.type);
746
- if (sameCellValue(next, p.oldValue)) return false;
747
- p.data.values = { ...p.data.values, [column.id]: next };
748
- return true;
749
- },
750
- comparator: (a, b, nodeA, nodeB) => compareCells(a, b, column.type, nodeA?.data?.titles, nodeB?.data?.titles),
751
- getQuickFilterText: (p) => formatCell(p.value, column.type, locale, p.data?.titles),
752
- ...editorFor(column, sources),
753
- ...rendererFor(column, locale, sources)
754
- }));
755
- defs.unshift(...openRow);
756
- if (!readOnly && onAddColumn) {
757
- defs.push({
758
- colId: ADD_COLUMN_COL_ID,
759
- width: 52,
760
- minWidth: 52,
761
- maxWidth: 52,
762
- resizable: false,
763
- sortable: false,
764
- editable: false,
765
- suppressMovable: true,
766
- // Pinned: on a wide table the add button stays in view instead of scrolling off the right.
767
- pinned: "right",
768
- lockPinned: true,
769
- headerComponent: AddColumnHeader,
770
- headerComponentParams: { addLabel: l.addColumn, onAddColumn },
771
- valueGetter: () => null
772
- });
773
- }
774
- return defs;
775
- }
776
12
  var DEFAULT_COLUMN_CONFIG_LABELS = {
777
13
  relatedDatabase: "Related database",
778
14
  pickDatabase: "Pick a database",
@@ -816,7 +52,7 @@ function ColumnSelect({
816
52
  return /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { value: value || void 0, onValueChange: onChange, children: [
817
53
  /* @__PURE__ */ jsxRuntime.jsx(ui.SelectTrigger, { "data-testid": testId, children: /* @__PURE__ */ jsxRuntime.jsx(ui.SelectValue, { placeholder }) }),
818
54
  /* @__PURE__ */ jsxRuntime.jsx(ui.SelectContent, { children: columns.map((c) => {
819
- const Icon = COLUMN_TYPE_ICONS[c.type];
55
+ const Icon = chunkQ25CZLK6_cjs.COLUMN_TYPE_ICONS[c.type];
820
56
  return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: c.id, "data-testid": `${testId}-${c.id}`, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
821
57
  /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-4 text-muted-foreground" }),
822
58
  c.name
@@ -917,7 +153,7 @@ function LookupFields({
917
153
  if (relations.length === 0)
918
154
  return /* @__PURE__ */ jsxRuntime.jsx(Hint, { testId: "database-column-no-relations", children: labels.noRelations });
919
155
  const shown = targetColumnsOf(draft.relation, columns, databases, databaseId).filter(
920
- (c) => !isComputedColumn(c)
156
+ (c) => !chunkQ25CZLK6_cjs.isComputedColumn(c)
921
157
  );
922
158
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
923
159
  /* @__PURE__ */ jsxRuntime.jsx(Field, { label: labels.relation, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -975,7 +211,7 @@ function RollupFields({
975
211
  onValueChange: (op) => onChange({ ...draft, op }),
976
212
  children: [
977
213
  /* @__PURE__ */ jsxRuntime.jsx(ui.SelectTrigger, { "data-testid": "database-column-rollup-op", children: /* @__PURE__ */ jsxRuntime.jsx(ui.SelectValue, {}) }),
978
- /* @__PURE__ */ jsxRuntime.jsx(ui.SelectContent, { children: DATABASE_ROLLUP_OPS.map((op) => /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: op, "data-testid": `database-column-rollup-op-${op}`, children: labels.ops[op] }, op)) })
214
+ /* @__PURE__ */ jsxRuntime.jsx(ui.SelectContent, { children: chunkQ25CZLK6_cjs.DATABASE_ROLLUP_OPS.map((op) => /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: op, "data-testid": `database-column-rollup-op-${op}`, children: labels.ops[op] }, op)) })
979
215
  ]
980
216
  }
981
217
  ) }),
@@ -1116,28 +352,28 @@ function DatabaseRowDetail({
1116
352
  testId = "database-row-detail"
1117
353
  }) {
1118
354
  const l = { ...DEFAULT_DATABASE_ROW_DETAIL_LABELS, ...labels };
1119
- const title = row ? rowTitle(row, columns, locale) || l.untitled : "";
355
+ const title = row ? chunkQ25CZLK6_cjs.rowTitle(row, columns, locale) || l.untitled : "";
1120
356
  const commit = (column, value) => {
1121
357
  if (!row || !onChange) return;
1122
- const next = toApiValue(value, column.type);
1123
- if (sameCellValue(next, row.values[column.id])) return;
358
+ const next = chunkQ25CZLK6_cjs.toApiValue(value, column.type);
359
+ if (chunkQ25CZLK6_cjs.sameCellValue(next, row.values[column.id])) return;
1124
360
  onChange(row, column.id, next);
1125
361
  };
1126
362
  const fieldEditor = (column) => {
1127
363
  if (!row) return null;
1128
364
  const value = row.values[column.id];
1129
365
  const id = `${testId}-input-${column.id}`;
1130
- const editable = !readOnly && Boolean(onChange) && canEditColumn(column, sources);
366
+ const editable = !readOnly && Boolean(onChange) && chunkQ25CZLK6_cjs.canEditColumn(column, sources);
1131
367
  const display = () => {
1132
368
  switch (column.type) {
1133
369
  case "select":
1134
- return typeof value === "string" && value ? /* @__PURE__ */ jsxRuntime.jsx(SelectChip, { value }) : null;
370
+ return typeof value === "string" && value ? /* @__PURE__ */ jsxRuntime.jsx(chunkQ25CZLK6_cjs.SelectChip, { value }) : null;
1135
371
  case "person":
1136
- return cellIds(value).length ? /* @__PURE__ */ jsxRuntime.jsx(PersonCell, { value, titles: row.titles }) : null;
372
+ return chunkQ25CZLK6_cjs.cellIds(value).length ? /* @__PURE__ */ jsxRuntime.jsx(chunkQ25CZLK6_cjs.PersonCell, { value, titles: row.titles }) : null;
1137
373
  case "document":
1138
374
  case "relation":
1139
- return cellIds(value).length ? /* @__PURE__ */ jsxRuntime.jsx(
1140
- LinkChipsCell,
375
+ return chunkQ25CZLK6_cjs.cellIds(value).length ? /* @__PURE__ */ jsxRuntime.jsx(
376
+ chunkQ25CZLK6_cjs.LinkChipsCell,
1141
377
  {
1142
378
  value,
1143
379
  titles: row.titles,
@@ -1147,9 +383,9 @@ function DatabaseRowDetail({
1147
383
  }
1148
384
  ) : null;
1149
385
  case "lookup":
1150
- return /* @__PURE__ */ jsxRuntime.jsx(LookupCell, { value, titles: row.titles, locale, wrap: true });
386
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkQ25CZLK6_cjs.LookupCell, { value, titles: row.titles, locale, wrap: true });
1151
387
  default: {
1152
- const text = formatCell(value, column.type, locale, row.titles);
388
+ const text = chunkQ25CZLK6_cjs.formatCell(value, column.type, locale, row.titles);
1153
389
  return text ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "break-words", children: text }) : null;
1154
390
  }
1155
391
  }
@@ -1161,9 +397,9 @@ function DatabaseRowDetail({
1161
397
  {
1162
398
  className: ui.cn(
1163
399
  "flex min-h-8 min-w-0 items-center py-1 text-sm",
1164
- isComputedColumn(column) && "text-muted-foreground"
400
+ chunkQ25CZLK6_cjs.isComputedColumn(column) && "text-muted-foreground"
1165
401
  ),
1166
- title: isComputedColumn(column) ? l.computed : void 0,
402
+ title: chunkQ25CZLK6_cjs.isComputedColumn(column) ? l.computed : void 0,
1167
403
  "data-testid": id,
1168
404
  children: shown ?? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "\u2014" })
1169
405
  }
@@ -1204,7 +440,7 @@ function DatabaseRowDetail({
1204
440
  label: column.name,
1205
441
  testId: id,
1206
442
  onCommit: (next) => commit(column, next),
1207
- renderEditor: (editor) => /* @__PURE__ */ jsxRuntime.jsx(SelectCellEditor, { ...editor, value, options: column.options ?? [] })
443
+ renderEditor: (editor) => /* @__PURE__ */ jsxRuntime.jsx(chunkQ25CZLK6_cjs.SelectCellEditor, { ...editor, value, options: column.options ?? [] })
1208
444
  }
1209
445
  );
1210
446
  case "person":
@@ -1221,7 +457,7 @@ function DatabaseRowDetail({
1221
457
  testId: id,
1222
458
  onCommit: (next) => commit(column, next),
1223
459
  renderEditor: (editor) => /* @__PURE__ */ jsxRuntime.jsx(
1224
- PickCellEditor,
460
+ chunkQ25CZLK6_cjs.PickCellEditor,
1225
461
  {
1226
462
  ...editor,
1227
463
  value,
@@ -1242,7 +478,7 @@ function DatabaseRowDetail({
1242
478
  if (row) {
1243
479
  for (const column of columns) {
1244
480
  if (column.type !== "document") continue;
1245
- for (const id of cellIds(row.values[column.id])) {
481
+ for (const id of chunkQ25CZLK6_cjs.cellIds(row.values[column.id])) {
1246
482
  documents.set(id, [...documents.get(id) ?? [], column.name]);
1247
483
  }
1248
484
  }
@@ -1284,7 +520,7 @@ function DatabaseRowDetail({
1284
520
  }
1285
521
  ),
1286
522
  /* @__PURE__ */ jsxRuntime.jsx(chunkBQOL4XNZ_cjs.DetailSection, { title: l.fields, testId: `${testId}-fields`, children: /* @__PURE__ */ jsxRuntime.jsx(chunkBQOL4XNZ_cjs.DetailFields, { children: columns.map((column) => {
1287
- const Icon = COLUMN_TYPE_ICONS[column.type];
523
+ const Icon = chunkQ25CZLK6_cjs.COLUMN_TYPE_ICONS[column.type];
1288
524
  return /* @__PURE__ */ jsxRuntime.jsx(
1289
525
  chunkBQOL4XNZ_cjs.DetailField,
1290
526
  {
@@ -1303,7 +539,7 @@ function DatabaseRowDetail({
1303
539
  onClick: openDocument ? () => openDocument(id) : void 0,
1304
540
  testId: `${testId}-doc-${id}`,
1305
541
  children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "min-w-0 flex-1", children: [
1306
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block truncate font-medium", children: titleOf(id, row?.titles) }),
542
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block truncate font-medium", children: chunkQ25CZLK6_cjs.titleOf(id, row?.titles) }),
1307
543
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block truncate text-xs text-muted-foreground", children: via.join(", ") })
1308
544
  ] })
1309
545
  },
@@ -1313,150 +549,85 @@ function DatabaseRowDetail({
1313
549
  }
1314
550
  );
1315
551
  }
1316
- var escapeHtml = (text) => text.replace(/[&<>"']/g, (ch) => `&#${ch.charCodeAt(0)};`);
1317
- var DEFAULT_DATABASE_TABLE_LABELS = {
1318
- newRow: "New row",
1319
- emptyTitle: "No rows yet",
1320
- emptyMessage: "Add a row, or import a spreadsheet.",
1321
- noColumnsTitle: "No columns yet",
1322
- noColumnsMessage: "Add a column to start.",
1323
- noMatches: "No rows match your search."
552
+ var DEFAULT_DATABASE_FILTER_MENU_LABELS = {
553
+ ...chunkMWHVETKN_cjs.DEFAULT_CONDITIONS_LABELS,
554
+ filterField: "Column",
555
+ trigger: "Filter",
556
+ active: (n) => `Filter (${n})`,
557
+ clear: "Clear"
1324
558
  };
1325
- function DatabaseTable({
559
+ var toCondition = (f) => ({
560
+ field: f.column,
561
+ op: f.op,
562
+ value: f.value
563
+ });
564
+ var toFilter = (c) => ({
565
+ column: c.field,
566
+ op: c.op,
567
+ value: c.value ?? null
568
+ });
569
+ function completeFilters(filters) {
570
+ return filters.filter(
571
+ (f) => f.column && (!chunkMWHVETKN_cjs.needsValue(f.op) || f.value !== void 0 && f.value !== null && f.value !== "")
572
+ );
573
+ }
574
+ function DatabaseFilterMenu({
1326
575
  columns,
1327
- rows,
1328
- onCellChange,
1329
- onAddRow,
1330
- onAddColumn,
1331
- onEditColumn,
1332
- onOpenRow,
1333
- sources,
1334
- onSelectionChange,
1335
- selected,
1336
- readOnly = false,
1337
- isFiltered = false,
1338
- isLoading,
1339
- locale,
1340
- gridId,
1341
- height = "100%",
1342
- labels,
1343
- columnLabels,
1344
- gridProps,
1345
- testId
576
+ filters,
577
+ onChange,
578
+ labels
1346
579
  }) {
1347
- const l = { ...DEFAULT_DATABASE_TABLE_LABELS, ...labels };
1348
- const latest = react.useRef({ onEditColumn, onAddColumn, onOpenRow });
1349
- latest.current = { onEditColumn, onAddColumn, onOpenRow };
1350
- const hasEditColumn = !!onEditColumn;
1351
- const hasAddColumn = !!onAddColumn;
1352
- const hasOpenRow = !!onOpenRow;
1353
- const editColumn = react.useMemo(
1354
- () => hasEditColumn ? (column) => latest.current.onEditColumn?.(column) : void 0,
1355
- [hasEditColumn]
1356
- );
1357
- const addColumn = react.useMemo(
1358
- () => hasAddColumn ? () => latest.current.onAddColumn?.() : void 0,
1359
- [hasAddColumn]
1360
- );
1361
- const openRow = react.useMemo(
1362
- () => hasOpenRow ? (row) => latest.current.onOpenRow?.(row) : void 0,
1363
- [hasOpenRow]
1364
- );
1365
- const columnDefs = react.useMemo(
1366
- () => createDatabaseColumns(columns, {
1367
- readOnly,
1368
- onEditColumn: editColumn,
1369
- onAddColumn: addColumn,
1370
- onOpenRow: openRow,
1371
- sources,
1372
- locale,
1373
- labels: columnLabels
1374
- }),
1375
- [columns, readOnly, editColumn, addColumn, openRow, sources, locale, columnLabels]
1376
- );
1377
- const noColumns = columns.length === 0;
1378
- const emptyState = {
1379
- icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Table2, { className: "size-8 text-muted-foreground" }),
1380
- title: l.noColumnsTitle,
1381
- message: readOnly ? void 0 : l.noColumnsMessage,
1382
- action: !readOnly && onAddColumn ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Button, { onClick: onAddColumn, "data-testid": "database-empty-add-column", className: "gap-1.5", children: [
1383
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4" }),
1384
- columnLabels?.addColumn ?? DEFAULT_DATABASE_COLUMN_LABELS.addColumn
1385
- ] }) : void 0
1386
- };
1387
- const noRowsText = isFiltered ? l.noMatches : readOnly ? l.emptyTitle : `${l.emptyTitle}. ${l.emptyMessage}`;
1388
- const api = react.useRef(null);
1389
- const knownColumns = react.useRef(null);
1390
- react.useEffect(() => {
1391
- const ids = new Set(columns.map((c) => c.id));
1392
- const added = knownColumns.current ? columns.filter((c) => !knownColumns.current.has(c.id)) : [];
1393
- knownColumns.current = ids;
1394
- const last = added[added.length - 1];
1395
- if (last && api.current) {
1396
- const grid = api.current;
1397
- setTimeout(() => grid.ensureColumnVisible(last.id, "end"), 0);
1398
- }
1399
- }, [columns]);
1400
- const handleCellValueChanged = (event) => {
1401
- const columnId = event.column.getColId();
1402
- if (!event.data || !onCellChange) return;
1403
- onCellChange(event.data, columnId, event.data.values[columnId] ?? null);
1404
- };
1405
- return /* @__PURE__ */ jsxRuntime.jsxs(
1406
- "div",
1407
- {
1408
- className: "flex h-full min-h-0 flex-col",
1409
- "data-testid": chunkPLIF5CUV_cjs.testIdOr(testId, { testId: "database-table" }),
1410
- children: [
1411
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
1412
- chunkZVEW3JBT_cjs.GridView,
1413
- {
1414
- testId: "database-grid",
1415
- items: rows,
1416
- columnDefs,
1417
- getItemId: (row) => row.id,
1418
- getRowTestId: (row) => `database-row-${row.id}`,
1419
- getCellTestId: (colId, row) => `database-cell-${row.id}-${colId}`,
1420
- isLoading,
1421
- emptyState,
1422
- showEmpty: noColumns,
1423
- gridId,
1424
- height,
1425
- rowHeight: 38,
1426
- selection: onSelectionChange ? { mode: "multiple", selected: selected ?? [], onSelectionChange, controlled: true } : void 0,
1427
- onCellValueChanged: handleCellValueChanged,
1428
- ...gridProps,
1429
- onGridReady: (params) => {
1430
- api.current = params.api;
1431
- gridProps?.onGridReady?.(params);
1432
- },
1433
- gridOptions: {
1434
- overlayNoRowsTemplate: `<span class="text-sm text-muted-foreground">${escapeHtml(noRowsText)}</span>`,
1435
- singleClickEdit: false,
1436
- stopEditingWhenCellsLoseFocus: true,
1437
- enterNavigatesVerticallyAfterEdit: true,
1438
- undoRedoCellEditing: false,
1439
- ...gridProps?.gridOptions
580
+ const l = { ...DEFAULT_DATABASE_FILTER_MENU_LABELS, ...labels };
581
+ const fields = columns.map((c) => ({ id: c.id, label: c.name, type: c.type }));
582
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Popover, { children: [
583
+ /* @__PURE__ */ jsxRuntime.jsx(ui.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
584
+ ui.Button,
585
+ {
586
+ variant: "ghost",
587
+ size: "sm",
588
+ className: ui.cn(
589
+ "h-7 gap-1.5 px-2 text-sm font-normal text-muted-foreground hover:text-foreground pointer-coarse:h-11",
590
+ filters.length > 0 && "text-foreground"
591
+ ),
592
+ "data-testid": "database-filter-trigger",
593
+ children: [
594
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ListFilter, { className: "size-3.5" }),
595
+ filters.length ? l.active(filters.length) : l.trigger
596
+ ]
597
+ }
598
+ ) }),
599
+ /* @__PURE__ */ jsxRuntime.jsxs(
600
+ ui.PopoverContent,
601
+ {
602
+ className: "w-[min(560px,calc(100vw-32px))] p-3",
603
+ align: "start",
604
+ "data-testid": "database-filter-menu",
605
+ children: [
606
+ /* @__PURE__ */ jsxRuntime.jsx(
607
+ chunkMWHVETKN_cjs.ConditionsEditor,
608
+ {
609
+ fields,
610
+ conditions: filters.map(toCondition),
611
+ onChange: (next) => onChange(next.map(toFilter)),
612
+ labels: l,
613
+ testId: "database-filters"
1440
614
  }
1441
- }
1442
- ) }),
1443
- !readOnly && onAddRow && columns.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border px-2 py-1", children: /* @__PURE__ */ jsxRuntime.jsxs(
1444
- ui.Button,
1445
- {
1446
- variant: "ghost",
1447
- size: "sm",
1448
- onClick: onAddRow,
1449
- "data-testid": "database-add-row",
1450
- className: "gap-1.5 text-muted-foreground",
1451
- children: [
1452
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4" }),
1453
- l.newRow
1454
- ]
1455
- }
1456
- ) })
1457
- ]
1458
- }
1459
- );
615
+ ),
616
+ filters.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
617
+ ui.Button,
618
+ {
619
+ variant: "ghost",
620
+ size: "sm",
621
+ className: "mt-2",
622
+ onClick: () => onChange([]),
623
+ "data-testid": "database-filter-clear",
624
+ children: l.clear
625
+ }
626
+ )
627
+ ]
628
+ }
629
+ )
630
+ ] });
1460
631
  }
1461
632
  var DEFAULT_DATABASE_TOOLBAR_LABELS = {
1462
633
  back: "All databases",
@@ -1490,6 +661,7 @@ function DatabaseToolbar({
1490
661
  onChart,
1491
662
  onDeleteDatabase,
1492
663
  readOnly = false,
664
+ filters,
1493
665
  views,
1494
666
  labels
1495
667
  }) {
@@ -1580,6 +752,7 @@ function DatabaseToolbar({
1580
752
  }
1581
753
  )
1582
754
  ] }),
755
+ filters,
1583
756
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1" }),
1584
757
  views,
1585
758
  !readOnly && selectedCount > 0 && onDeleteSelected && /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1733,7 +906,7 @@ function DatabaseColumnDialog({
1733
906
  configLabels
1734
907
  }) {
1735
908
  const l = { ...DEFAULT_DATABASE_COLUMN_DIALOG_LABELS, ...labels };
1736
- const tl = { ...DEFAULT_DATABASE_COLUMN_TYPE_LABELS, ...typeLabels };
909
+ const tl = { ...chunkQ25CZLK6_cjs.DEFAULT_DATABASE_COLUMN_TYPE_LABELS, ...typeLabels };
1737
910
  const cl = { ...DEFAULT_COLUMN_CONFIG_LABELS, ...configLabels };
1738
911
  const editing = Boolean(column);
1739
912
  const [name, setName] = react.useState("");
@@ -1839,8 +1012,8 @@ function DatabaseColumnDialog({
1839
1012
  disabled: editing,
1840
1013
  children: [
1841
1014
  /* @__PURE__ */ jsxRuntime.jsx(ui.SelectTrigger, { "data-testid": "database-column-type", children: /* @__PURE__ */ jsxRuntime.jsx(ui.SelectValue, {}) }),
1842
- /* @__PURE__ */ jsxRuntime.jsx(ui.SelectContent, { children: DATABASE_COLUMN_TYPES.map((t) => {
1843
- const Icon = COLUMN_TYPE_ICONS[t];
1015
+ /* @__PURE__ */ jsxRuntime.jsx(ui.SelectContent, { children: chunkQ25CZLK6_cjs.DATABASE_COLUMN_TYPES.map((t) => {
1016
+ const Icon = chunkQ25CZLK6_cjs.COLUMN_TYPE_ICONS[t];
1844
1017
  return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: t, "data-testid": `database-column-type-${t}`, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
1845
1018
  /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-4 text-muted-foreground" }),
1846
1019
  tl[t]
@@ -1854,7 +1027,7 @@ function DatabaseColumnDialog({
1854
1027
  type === "select" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
1855
1028
  /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { htmlFor: "database-column-option", children: l.options }),
1856
1029
  options.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1.5", "data-testid": "database-column-options", children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-0.5", children: [
1857
- /* @__PURE__ */ jsxRuntime.jsx(SelectChip, { value: option }),
1030
+ /* @__PURE__ */ jsxRuntime.jsx(chunkQ25CZLK6_cjs.SelectChip, { value: option }),
1858
1031
  /* @__PURE__ */ jsxRuntime.jsx(
1859
1032
  "button",
1860
1033
  {
@@ -2032,7 +1205,7 @@ function DatabaseCard({
2032
1205
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: l.rows(database.row_count) }),
2033
1206
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: l.columns(database.columns.length) }),
2034
1207
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-auto flex items-center gap-1", "aria-hidden": true, children: database.columns.slice(0, 6).map((c) => {
2035
- const Icon = COLUMN_TYPE_ICONS[c.type];
1208
+ const Icon = chunkQ25CZLK6_cjs.COLUMN_TYPE_ICONS[c.type];
2036
1209
  return /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-3.5" }, c.id);
2037
1210
  }) })
2038
1211
  ] })
@@ -2205,52 +1378,19 @@ function NewDatabaseDialog({
2205
1378
  ] }) }) });
2206
1379
  }
2207
1380
 
2208
- exports.ADD_COLUMN_COL_ID = ADD_COLUMN_COL_ID;
2209
- exports.COLUMN_TYPE_ICONS = COLUMN_TYPE_ICONS;
2210
- exports.COMPUTED_COLUMN_TYPES = COMPUTED_COLUMN_TYPES;
2211
- exports.DATABASE_COLUMN_TYPES = DATABASE_COLUMN_TYPES;
2212
- exports.DATABASE_ROLLUP_OPS = DATABASE_ROLLUP_OPS;
2213
1381
  exports.DEFAULT_COLUMN_CONFIG_LABELS = DEFAULT_COLUMN_CONFIG_LABELS;
2214
1382
  exports.DEFAULT_DATABASE_COLUMN_DIALOG_LABELS = DEFAULT_DATABASE_COLUMN_DIALOG_LABELS;
2215
- exports.DEFAULT_DATABASE_COLUMN_LABELS = DEFAULT_DATABASE_COLUMN_LABELS;
2216
- exports.DEFAULT_DATABASE_COLUMN_TYPE_LABELS = DEFAULT_DATABASE_COLUMN_TYPE_LABELS;
1383
+ exports.DEFAULT_DATABASE_FILTER_MENU_LABELS = DEFAULT_DATABASE_FILTER_MENU_LABELS;
2217
1384
  exports.DEFAULT_DATABASE_LIST_LABELS = DEFAULT_DATABASE_LIST_LABELS;
2218
1385
  exports.DEFAULT_DATABASE_ROW_DETAIL_LABELS = DEFAULT_DATABASE_ROW_DETAIL_LABELS;
2219
- exports.DEFAULT_DATABASE_TABLE_LABELS = DEFAULT_DATABASE_TABLE_LABELS;
2220
1386
  exports.DEFAULT_DATABASE_TOOLBAR_LABELS = DEFAULT_DATABASE_TOOLBAR_LABELS;
2221
1387
  exports.DEFAULT_NEW_DATABASE_DIALOG_LABELS = DEFAULT_NEW_DATABASE_DIALOG_LABELS;
2222
- exports.DEFAULT_PICK_CELL_EDITOR_LABELS = DEFAULT_PICK_CELL_EDITOR_LABELS;
2223
1388
  exports.DatabaseColumnDialog = DatabaseColumnDialog;
1389
+ exports.DatabaseFilterMenu = DatabaseFilterMenu;
2224
1390
  exports.DatabaseList = DatabaseList;
2225
1391
  exports.DatabaseRowDetail = DatabaseRowDetail;
2226
- exports.DatabaseTable = DatabaseTable;
2227
1392
  exports.DatabaseToolbar = DatabaseToolbar;
2228
- exports.LINK_COLUMN_TYPES = LINK_COLUMN_TYPES;
2229
- exports.LinkChip = LinkChip;
2230
- exports.LinkChipsCell = LinkChipsCell;
2231
- exports.LookupCell = LookupCell;
2232
1393
  exports.NewDatabaseDialog = NewDatabaseDialog;
2233
- exports.OPEN_ROW_COL_ID = OPEN_ROW_COL_ID;
2234
- exports.PersonCell = PersonCell;
2235
- exports.PersonChip = PersonChip;
2236
- exports.PickCellEditor = PickCellEditor;
2237
- exports.SelectCellEditor = SelectCellEditor;
2238
- exports.SelectChip = SelectChip;
2239
- exports.canEditColumn = canEditColumn;
2240
- exports.cellIds = cellIds;
2241
- exports.cellList = cellList;
2242
- exports.columnWidth = columnWidth;
2243
- exports.compareCells = compareCells;
2244
- exports.createDatabaseColumns = createDatabaseColumns;
2245
- exports.formatCell = formatCell;
2246
- exports.formatDateValue = formatDateValue;
2247
- exports.formatLookupValue = formatLookupValue;
2248
- exports.formatNumberValue = formatNumberValue;
2249
- exports.isComputedColumn = isComputedColumn;
2250
- exports.optionTone = optionTone;
2251
- exports.rowTitle = rowTitle;
2252
- exports.sameCellValue = sameCellValue;
2253
- exports.titleOf = titleOf;
2254
- exports.toApiValue = toApiValue;
2255
- //# sourceMappingURL=chunk-BCRB42SP.cjs.map
2256
- //# sourceMappingURL=chunk-BCRB42SP.cjs.map
1394
+ exports.completeFilters = completeFilters;
1395
+ //# sourceMappingURL=chunk-LYYJDQW6.cjs.map
1396
+ //# sourceMappingURL=chunk-LYYJDQW6.cjs.map