@arbidocs/blocks 0.5.146 → 0.5.148
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.
- package/dist/{ConnectedCallDock-JVLJEWLJ.cjs → ConnectedCallDock-6VGATAAQ.cjs} +5 -5
- package/dist/{ConnectedCallDock-JVLJEWLJ.cjs.map → ConnectedCallDock-6VGATAAQ.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-7YQRDIS3.cjs → ConnectedCallRoom-YBNERVTW.cjs} +5 -5
- package/dist/{ConnectedCallRoom-7YQRDIS3.cjs.map → ConnectedCallRoom-YBNERVTW.cjs.map} +1 -1
- package/dist/{ConnectedPresentation-JJXQBIV2.cjs → ConnectedPresentation-JZQFTC5H.cjs} +4 -4
- package/dist/{ConnectedPresentation-JJXQBIV2.cjs.map → ConnectedPresentation-JZQFTC5H.cjs.map} +1 -1
- package/dist/{DocumentReviewCard-ENCPTGJE.cjs → DocumentReviewCard-UDC4PNIS.cjs} +15 -14
- package/dist/DocumentReviewCard-UDC4PNIS.cjs.map +1 -0
- package/dist/{FilesViewerDialog-FFPW7TIK.cjs → FilesViewerDialog-D5GHWK4Y.cjs} +12 -11
- package/dist/FilesViewerDialog-D5GHWK4Y.cjs.map +1 -0
- package/dist/{WorkspaceTableView-2RH33X3U.cjs → WorkspaceTableView-2NRV4CWP.cjs} +7 -6
- package/dist/WorkspaceTableView-2NRV4CWP.cjs.map +1 -0
- package/dist/agents/index.cjs +176 -175
- package/dist/agents/tasks/TaskRowMenu.d.ts +1 -2
- package/dist/agents/tasks/TaskRowMenu.js +0 -2
- package/dist/agents/tasks/TaskRowMenu.js.map +2 -2
- package/dist/agents/tasks/TaskTable.d.ts +5 -2
- package/dist/agents/tasks/TaskTable.js +11 -8
- package/dist/agents/tasks/TaskTable.js.map +2 -2
- package/dist/agents/tasks/taskTableLabels.js +1 -1
- package/dist/agents/tasks/taskTableLabels.js.map +1 -1
- package/dist/{ai-YX3OAC4F.cjs → ai-VLIPYNWP.cjs} +13 -13
- package/dist/ai-VLIPYNWP.cjs.map +1 -0
- package/dist/calls/index.cjs +2 -2
- package/dist/chat/ChatThreads.js +1 -1
- package/dist/chat/ChatThreads.js.map +2 -2
- package/dist/chat/chat-page-types.d.ts +2 -0
- package/dist/chat/chat-page-types.js.map +2 -2
- package/dist/chat/index.cjs +25 -25
- package/dist/{chunk-32HVYK4Q.cjs → chunk-3VPNL4EH.cjs} +14 -13
- package/dist/chunk-3VPNL4EH.cjs.map +1 -0
- package/dist/{chunk-6TU4YLFW.cjs → chunk-5TT6J67U.cjs} +3 -3
- package/dist/chunk-5TT6J67U.cjs.map +1 -0
- package/dist/{chunk-N7AUJTU4.cjs → chunk-7AULM6LS.cjs} +5 -5
- package/dist/{chunk-N7AUJTU4.cjs.map → chunk-7AULM6LS.cjs.map} +1 -1
- package/dist/{chunk-MBXXWTKT.cjs → chunk-AYWY4MX2.cjs} +28 -28
- package/dist/{chunk-MBXXWTKT.cjs.map → chunk-AYWY4MX2.cjs.map} +1 -1
- package/dist/{chunk-P2AZ2HX7.cjs → chunk-AZQ4XIVY.cjs} +26 -26
- package/dist/{chunk-P2AZ2HX7.cjs.map → chunk-AZQ4XIVY.cjs.map} +1 -1
- package/dist/{chunk-VZKTOGZR.cjs → chunk-BLRPBEUG.cjs} +2 -2
- package/dist/{chunk-VZKTOGZR.cjs.map → chunk-BLRPBEUG.cjs.map} +1 -1
- package/dist/chunk-DKY67DA6.cjs +43 -0
- package/dist/chunk-DKY67DA6.cjs.map +1 -0
- package/dist/{chunk-N3H3YAKY.cjs → chunk-DUNXLT63.cjs} +17 -12
- package/dist/chunk-DUNXLT63.cjs.map +1 -0
- package/dist/{chunk-UOI6JJPG.cjs → chunk-EF2QQBDV.cjs} +29 -134
- package/dist/chunk-EF2QQBDV.cjs.map +1 -0
- package/dist/{chunk-3Y75LUCT.cjs → chunk-FHKBR55Q.cjs} +3 -3
- package/dist/{chunk-3Y75LUCT.cjs.map → chunk-FHKBR55Q.cjs.map} +1 -1
- package/dist/{chunk-QW6NCUR7.cjs → chunk-GAA222SK.cjs} +5 -5
- package/dist/{chunk-QW6NCUR7.cjs.map → chunk-GAA222SK.cjs.map} +1 -1
- package/dist/{chunk-LVIQWRC5.cjs → chunk-KRQCUVH7.cjs} +2 -2
- package/dist/chunk-KRQCUVH7.cjs.map +1 -0
- package/dist/{chunk-6RJXO2NF.cjs → chunk-KWV4VC74.cjs} +6 -6
- package/dist/{chunk-6RJXO2NF.cjs.map → chunk-KWV4VC74.cjs.map} +1 -1
- package/dist/{chunk-UD56Y6UA.cjs → chunk-L5Q5PDTA.cjs} +4 -4
- package/dist/{chunk-UD56Y6UA.cjs.map → chunk-L5Q5PDTA.cjs.map} +1 -1
- package/dist/{chunk-XAW22O2S.cjs → chunk-LCIMYEGX.cjs} +4 -4
- package/dist/{chunk-XAW22O2S.cjs.map → chunk-LCIMYEGX.cjs.map} +1 -1
- package/dist/{chunk-BCRB42SP.cjs → chunk-LYYJDQW6.cjs} +110 -970
- package/dist/chunk-LYYJDQW6.cjs.map +1 -0
- package/dist/{chunk-OE36OY64.cjs → chunk-LZQ2XZOC.cjs} +4 -4
- package/dist/{chunk-OE36OY64.cjs.map → chunk-LZQ2XZOC.cjs.map} +1 -1
- package/dist/{chunk-BTAT3MJP.cjs → chunk-MEWRE43W.cjs} +28 -28
- package/dist/{chunk-BTAT3MJP.cjs.map → chunk-MEWRE43W.cjs.map} +1 -1
- package/dist/chunk-MWHVETKN.cjs +151 -0
- package/dist/chunk-MWHVETKN.cjs.map +1 -0
- package/dist/{chunk-33GOYI3O.cjs → chunk-ONRUHYW3.cjs} +4 -4
- package/dist/{chunk-33GOYI3O.cjs.map → chunk-ONRUHYW3.cjs.map} +1 -1
- package/dist/{chunk-KP7BQIZL.cjs → chunk-ORGGDQKZ.cjs} +43 -40
- package/dist/chunk-ORGGDQKZ.cjs.map +1 -0
- package/dist/{chunk-N2OVF6SJ.cjs → chunk-OXPIJYRU.cjs} +65 -60
- package/dist/chunk-OXPIJYRU.cjs.map +1 -0
- package/dist/{chunk-2V5HW6T5.cjs → chunk-P5TQOSKA.cjs} +6 -6
- package/dist/{chunk-2V5HW6T5.cjs.map → chunk-P5TQOSKA.cjs.map} +1 -1
- package/dist/chunk-Q25CZLK6.cjs +958 -0
- package/dist/chunk-Q25CZLK6.cjs.map +1 -0
- package/dist/{chunk-ZPIZINH2.cjs → chunk-VLHBKF4P.cjs} +164 -98
- package/dist/chunk-VLHBKF4P.cjs.map +1 -0
- package/dist/{chunk-TG2GM7WJ.cjs → chunk-WCT6FT2K.cjs} +11 -7
- package/dist/chunk-WCT6FT2K.cjs.map +1 -0
- package/dist/{chunk-NPRNR54M.cjs → chunk-ZCVW63DF.cjs} +4 -4
- package/dist/{chunk-NPRNR54M.cjs.map → chunk-ZCVW63DF.cjs.map} +1 -1
- package/dist/collaboration/index.cjs +34 -9
- package/dist/collaboration/sharing/ShareControl.d.ts +15 -6
- package/dist/collaboration/sharing/ShareControl.js +9 -4
- package/dist/collaboration/sharing/ShareControl.js.map +2 -2
- package/dist/collaboration/sharing/index.d.ts +1 -0
- package/dist/collaboration/sharing/index.js +15 -1
- package/dist/collaboration/sharing/index.js.map +2 -2
- package/dist/collaboration/sharing/one-way.d.ts +41 -0
- package/dist/collaboration/sharing/one-way.js +39 -0
- package/dist/collaboration/sharing/one-way.js.map +7 -0
- package/dist/connect/index.cjs +4037 -3984
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/viewer.cjs +9 -8
- package/dist/connection/account-cluster/ConnectedAccountCluster.js +1 -1
- package/dist/connection/account-cluster/ConnectedAccountCluster.js.map +1 -1
- package/dist/connection/agents/agentsPageParts.js +6 -2
- package/dist/connection/agents/agentsPageParts.js.map +2 -2
- package/dist/connection/command/actions.js +3 -3
- package/dist/connection/command/actions.js.map +2 -2
- package/dist/connection/conversation/ConnectedConversationSettings.js +3 -6
- package/dist/connection/conversation/ConnectedConversationSettings.js.map +2 -2
- package/dist/connection/dashboards/PanelEditor.d.ts +3 -9
- package/dist/connection/dashboards/PanelEditor.js +17 -124
- package/dist/connection/dashboards/PanelEditor.js.map +2 -2
- package/dist/connection/dashboards/index.d.ts +0 -1
- package/dist/connection/dashboards/index.js +0 -6
- package/dist/connection/dashboards/index.js.map +2 -2
- package/dist/connection/dashboards/templates.d.ts +1 -1
- package/dist/connection/dashboards/templates.js.map +1 -1
- package/dist/connection/databases/ConnectedDatabasesPage.js +46 -20
- package/dist/connection/databases/ConnectedDatabasesPage.js.map +2 -2
- package/dist/connection/databases/DatabaseViewsMenu.d.ts +5 -1
- package/dist/connection/databases/DatabaseViewsMenu.js +16 -21
- package/dist/connection/databases/DatabaseViewsMenu.js.map +2 -2
- package/dist/connection/files/bulk/ConnectedFilesBulkActions.d.ts +4 -3
- package/dist/connection/files/bulk/ConnectedFilesBulkActions.js +12 -18
- package/dist/connection/files/bulk/ConnectedFilesBulkActions.js.map +2 -2
- package/dist/connection/files/bulk/useDocumentBulkActions.d.ts +2 -3
- package/dist/connection/files/bulk/useDocumentBulkActions.js +6 -15
- package/dist/connection/files/bulk/useDocumentBulkActions.js.map +2 -2
- package/dist/connection/files/grid/cells.d.ts +7 -3
- package/dist/connection/files/grid/cells.js +8 -5
- package/dist/connection/files/grid/cells.js.map +2 -2
- package/dist/connection/files/grid/documentCellRenderers.d.ts +4 -1
- package/dist/connection/files/grid/documentCellRenderers.js +3 -2
- package/dist/connection/files/grid/documentCellRenderers.js.map +2 -2
- package/dist/connection/files/grid/documentColumns.d.ts +3 -3
- package/dist/connection/files/grid/documentColumns.js +4 -2
- package/dist/connection/files/grid/documentColumns.js.map +2 -2
- package/dist/connection/files/grid/useDocumentTable.js +10 -5
- package/dist/connection/files/grid/useDocumentTable.js.map +2 -2
- package/dist/connection/files/index.d.ts +1 -2
- package/dist/connection/files/index.js +4 -12
- package/dist/connection/files/index.js.map +2 -2
- package/dist/connection/files/review/useAiReviewLiveUpdates.js +13 -2
- package/dist/connection/files/review/useAiReviewLiveUpdates.js.map +2 -2
- package/dist/connection/files/views/ViewSelector.js +9 -21
- package/dist/connection/files/views/ViewSelector.js.map +2 -2
- package/dist/connection/files/views/useTableViews.d.ts +23 -15
- package/dist/connection/files/views/useTableViews.js +61 -35
- package/dist/connection/files/views/useTableViews.js.map +2 -2
- package/dist/connection/files/views/useViewWrites.d.ts +6 -0
- package/dist/connection/files/views/useViewWrites.js +64 -0
- package/dist/connection/files/views/useViewWrites.js.map +7 -0
- package/dist/connection/pages/BlockEditor.d.ts +32 -0
- package/dist/connection/pages/BlockEditor.js +175 -0
- package/dist/connection/pages/BlockEditor.js.map +7 -0
- package/dist/connection/pages/ConnectedPagesPage.d.ts +31 -0
- package/dist/connection/pages/ConnectedPagesPage.js +426 -0
- package/dist/connection/pages/ConnectedPagesPage.js.map +7 -0
- package/dist/connection/pages/DocumentBlocks.d.ts +46 -0
- package/dist/connection/pages/DocumentBlocks.js +200 -0
- package/dist/connection/pages/DocumentBlocks.js.map +7 -0
- package/dist/connection/pages/DocumentsPicker.d.ts +26 -0
- package/dist/connection/pages/DocumentsPicker.js +133 -0
- package/dist/connection/pages/DocumentsPicker.js.map +7 -0
- package/dist/connection/pages/PageBlockView.d.ts +22 -0
- package/dist/connection/pages/PageBlockView.js +82 -0
- package/dist/connection/pages/PageBlockView.js.map +7 -0
- package/dist/connection/pages/PageGrid.d.ts +26 -0
- package/dist/connection/pages/PageGrid.js +50 -0
- package/dist/connection/pages/PageGrid.js.map +7 -0
- package/dist/connection/pages/PageView.d.ts +24 -0
- package/dist/connection/pages/PageView.js +93 -0
- package/dist/connection/pages/PageView.js.map +7 -0
- package/dist/connection/pages/PagesList.d.ts +14 -0
- package/dist/connection/pages/PagesList.js +143 -0
- package/dist/connection/pages/PagesList.js.map +7 -0
- package/dist/connection/pages/TableViewBlock.d.ts +24 -0
- package/dist/connection/pages/TableViewBlock.js +82 -0
- package/dist/connection/pages/TableViewBlock.js.map +7 -0
- package/dist/connection/pages/ViewPicker.d.ts +21 -0
- package/dist/connection/pages/ViewPicker.js +56 -0
- package/dist/connection/pages/ViewPicker.js.map +7 -0
- package/dist/connection/pages/index.d.ts +9 -0
- package/dist/connection/pages/index.js +49 -0
- package/dist/connection/pages/index.js.map +7 -0
- package/dist/connection/pages/labels.d.ts +61 -0
- package/dist/connection/pages/labels.js +61 -0
- package/dist/connection/pages/labels.js.map +7 -0
- package/dist/connection/settings-page/featuresSection.js +2 -2
- package/dist/connection/settings-page/featuresSection.js.map +1 -1
- package/dist/connection/sharing/ResourceShareForm.js +1 -1
- package/dist/connection/sharing/ResourceShareForm.js.map +2 -2
- package/dist/connection/threads-page/ConnectedThreadsPage.js +10 -8
- package/dist/connection/threads-page/ConnectedThreadsPage.js.map +2 -2
- package/dist/connection/viewer/ConnectedDocumentViewer.js +11 -6
- package/dist/connection/viewer/ConnectedDocumentViewer.js.map +2 -2
- package/dist/dashboards/ConditionsEditor.d.ts +54 -0
- package/dist/dashboards/ConditionsEditor.js +156 -0
- package/dist/dashboards/ConditionsEditor.js.map +7 -0
- package/dist/dashboards/index.cjs +33 -521
- package/dist/dashboards/index.cjs.map +1 -1
- package/dist/dashboards/index.d.ts +3 -2
- package/dist/dashboards/index.js +13 -1
- package/dist/dashboards/index.js.map +2 -2
- package/dist/databases/DatabaseFilterMenu.d.ts +18 -0
- package/dist/databases/DatabaseFilterMenu.js +95 -0
- package/dist/databases/DatabaseFilterMenu.js.map +7 -0
- package/dist/databases/DatabaseTable.js +1 -1
- package/dist/databases/DatabaseTable.js.map +1 -1
- package/dist/databases/DatabaseToolbar.d.ts +3 -1
- package/dist/databases/DatabaseToolbar.js +2 -0
- package/dist/databases/DatabaseToolbar.js.map +2 -2
- package/dist/databases/index.cjs +85 -71
- package/dist/databases/index.d.ts +1 -0
- package/dist/databases/index.js +8 -0
- package/dist/databases/index.js.map +2 -2
- package/dist/embed/index.cjs +14 -13
- package/dist/facts/index.cjs +43 -43
- package/dist/files/bulk/BulkActionsBar.d.ts +8 -5
- package/dist/files/bulk/BulkActionsBar.js +6 -7
- package/dist/files/bulk/BulkActionsBar.js.map +2 -2
- package/dist/files/cells/DocumentNameCell.d.ts +2 -1
- package/dist/files/cells/DocumentNameCell.js +1 -1
- package/dist/files/cells/DocumentNameCell.js.map +2 -2
- package/dist/files/index.cjs +237 -224
- package/dist/files/index.d.ts +1 -1
- package/dist/files/index.js +0 -2
- package/dist/files/index.js.map +2 -2
- package/dist/files/permissions.d.ts +4 -3
- package/dist/files/permissions.js +6 -3
- package/dist/files/permissions.js.map +2 -2
- package/dist/files/views/ViewSelectorMenu.d.ts +24 -5
- package/dist/files/views/ViewSelectorMenu.js +78 -51
- package/dist/files/views/ViewSelectorMenu.js.map +2 -2
- package/dist/files/views/gridViews.d.ts +34 -1
- package/dist/files/views/gridViews.js +28 -0
- package/dist/files/views/gridViews.js.map +2 -2
- package/dist/files/views/index.d.ts +2 -2
- package/dist/files/views/index.js +8 -0
- package/dist/files/views/index.js.map +2 -2
- package/dist/files/views/useGridViews.d.ts +8 -4
- package/dist/files/views/useGridViews.js +42 -11
- package/dist/files/views/useGridViews.js.map +2 -2
- package/dist/files/visibility.d.ts +1 -16
- package/dist/files/visibility.js +6 -23
- package/dist/files/visibility.js.map +2 -2
- package/dist/index.cjs +453 -428
- package/dist/index.cjs.map +1 -1
- package/dist/pages/index.cjs +1363 -0
- package/dist/pages/index.cjs.map +1 -0
- package/dist/pages/index.d.ts +14 -0
- package/dist/pages/index.js +3 -0
- package/dist/pages/index.js.map +7 -0
- package/dist/settings/ConversationSettingsParts.d.ts +4 -6
- package/dist/settings/ConversationSettingsParts.js +15 -10
- package/dist/settings/ConversationSettingsParts.js.map +2 -2
- package/dist/settings/index.cjs +145 -144
- package/dist/studio/index.cjs +8 -7
- package/dist/studio/index.cjs.map +1 -1
- package/dist/studio/widgets.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/workflow-canvas/index.cjs +23 -22
- package/dist/workflow-canvas/index.cjs.map +1 -1
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +10 -5
- package/dist/DocumentReviewCard-ENCPTGJE.cjs.map +0 -1
- package/dist/FilesViewerDialog-FFPW7TIK.cjs.map +0 -1
- package/dist/WorkspaceTableView-2RH33X3U.cjs.map +0 -1
- package/dist/ai-YX3OAC4F.cjs.map +0 -1
- package/dist/chunk-32HVYK4Q.cjs.map +0 -1
- package/dist/chunk-6TU4YLFW.cjs.map +0 -1
- package/dist/chunk-BCRB42SP.cjs.map +0 -1
- package/dist/chunk-KP7BQIZL.cjs.map +0 -1
- package/dist/chunk-LVIQWRC5.cjs.map +0 -1
- package/dist/chunk-N2OVF6SJ.cjs.map +0 -1
- package/dist/chunk-N3H3YAKY.cjs.map +0 -1
- package/dist/chunk-TG2GM7WJ.cjs.map +0 -1
- package/dist/chunk-UOI6JJPG.cjs.map +0 -1
- package/dist/chunk-ZPIZINH2.cjs.map +0 -1
- package/dist/connection/dashboards/ConnectedDashboardsPage.d.ts +0 -69
- package/dist/connection/dashboards/ConnectedDashboardsPage.js +0 -554
- package/dist/connection/dashboards/ConnectedDashboardsPage.js.map +0 -7
- package/dist/connection/files/views/tableViews.d.ts +0 -19
- package/dist/connection/files/views/tableViews.js +0 -36
- package/dist/connection/files/views/tableViews.js.map +0 -7
|
@@ -0,0 +1,958 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunkZVEW3JBT_cjs = require('./chunk-ZVEW3JBT.cjs');
|
|
5
|
+
var chunkPLIF5CUV_cjs = require('./chunk-PLIF5CUV.cjs');
|
|
6
|
+
var lucideReact = require('lucide-react');
|
|
7
|
+
var ui = require('@arbidocs/react/ui');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
var react = require('react');
|
|
10
|
+
|
|
11
|
+
// src/databases/column-types.ts
|
|
12
|
+
var DATABASE_COLUMN_TYPES = [
|
|
13
|
+
"text",
|
|
14
|
+
"number",
|
|
15
|
+
"date",
|
|
16
|
+
"checkbox",
|
|
17
|
+
"select",
|
|
18
|
+
"person",
|
|
19
|
+
"document",
|
|
20
|
+
"relation",
|
|
21
|
+
"lookup",
|
|
22
|
+
"rollup"
|
|
23
|
+
];
|
|
24
|
+
var COMPUTED_COLUMN_TYPES = /* @__PURE__ */ new Set([
|
|
25
|
+
"lookup",
|
|
26
|
+
"rollup"
|
|
27
|
+
]);
|
|
28
|
+
var LINK_COLUMN_TYPES = /* @__PURE__ */ new Set([
|
|
29
|
+
"document",
|
|
30
|
+
"relation"
|
|
31
|
+
]);
|
|
32
|
+
var isComputedColumn = (column) => COMPUTED_COLUMN_TYPES.has(column.type);
|
|
33
|
+
var DATABASE_ROLLUP_OPS = ["count", "sum", "avg", "min", "max"];
|
|
34
|
+
var DEFAULT_DATABASE_COLUMN_TYPE_LABELS = {
|
|
35
|
+
text: "Text",
|
|
36
|
+
number: "Number",
|
|
37
|
+
date: "Date",
|
|
38
|
+
checkbox: "Checkbox",
|
|
39
|
+
select: "Select",
|
|
40
|
+
person: "Person",
|
|
41
|
+
document: "Documents",
|
|
42
|
+
relation: "Relation",
|
|
43
|
+
lookup: "Lookup",
|
|
44
|
+
rollup: "Rollup"
|
|
45
|
+
};
|
|
46
|
+
var OPTION_TONES = [
|
|
47
|
+
"bg-blue-bg text-blue-text",
|
|
48
|
+
"bg-green-bg text-green-text",
|
|
49
|
+
"bg-yellow-bg text-yellow-text",
|
|
50
|
+
"bg-purple-bg text-purple-text",
|
|
51
|
+
"bg-red-bg text-red-text",
|
|
52
|
+
"bg-gray-bg text-gray-text"
|
|
53
|
+
];
|
|
54
|
+
function optionTone(option) {
|
|
55
|
+
let hash = 0;
|
|
56
|
+
for (const ch of option.toLowerCase()) hash = hash * 31 + ch.charCodeAt(0) >>> 0;
|
|
57
|
+
return OPTION_TONES[hash % OPTION_TONES.length];
|
|
58
|
+
}
|
|
59
|
+
var isEmpty = (value) => value === null || value === void 0 || typeof value === "string" && value.trim() === "" || Array.isArray(value) && value.length === 0;
|
|
60
|
+
function cellList(value) {
|
|
61
|
+
if (isEmpty(value)) return [];
|
|
62
|
+
return Array.isArray(value) ? value.filter((v) => !isEmpty(v)) : [value];
|
|
63
|
+
}
|
|
64
|
+
function cellIds(value) {
|
|
65
|
+
return cellList(value).filter((v) => typeof v === "string");
|
|
66
|
+
}
|
|
67
|
+
function titleOf(id, titles) {
|
|
68
|
+
return titles?.[id] ?? id;
|
|
69
|
+
}
|
|
70
|
+
function sameCellValue(a, b) {
|
|
71
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
72
|
+
const la = cellList(a);
|
|
73
|
+
const lb = cellList(b);
|
|
74
|
+
return la.length === lb.length && la.every((v, i) => v === lb[i]);
|
|
75
|
+
}
|
|
76
|
+
return (a ?? null) === (b ?? null);
|
|
77
|
+
}
|
|
78
|
+
function formatDateValue(value, locale) {
|
|
79
|
+
const day = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
80
|
+
if (day) {
|
|
81
|
+
const [, y, m, d] = day;
|
|
82
|
+
return new Date(Date.UTC(+y, +m - 1, +d)).toLocaleDateString(locale, { timeZone: "UTC" });
|
|
83
|
+
}
|
|
84
|
+
const at = new Date(value);
|
|
85
|
+
return Number.isNaN(at.getTime()) ? value : at.toLocaleString(locale);
|
|
86
|
+
}
|
|
87
|
+
function formatNumberValue(value, locale) {
|
|
88
|
+
return value.toLocaleString(locale, { maximumFractionDigits: 6 });
|
|
89
|
+
}
|
|
90
|
+
var ISO_DATE = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;
|
|
91
|
+
function formatLookupValue(value, titles, locale) {
|
|
92
|
+
if (isEmpty(value)) return "";
|
|
93
|
+
if (typeof value === "number") return formatNumberValue(value, locale);
|
|
94
|
+
if (typeof value === "boolean") return value ? "Yes" : "No";
|
|
95
|
+
if (typeof value === "string") {
|
|
96
|
+
if (titles?.[value] !== void 0) return titles[value];
|
|
97
|
+
if (ISO_DATE.test(value)) return formatDateValue(value, locale);
|
|
98
|
+
}
|
|
99
|
+
return String(value);
|
|
100
|
+
}
|
|
101
|
+
var NAMED_TYPES = /* @__PURE__ */ new Set([
|
|
102
|
+
"person",
|
|
103
|
+
"document",
|
|
104
|
+
"relation"
|
|
105
|
+
]);
|
|
106
|
+
function formatCell(value, type, locale, titles) {
|
|
107
|
+
if (isEmpty(value)) return "";
|
|
108
|
+
if ((type === "number" || type === "rollup") && typeof value === "number")
|
|
109
|
+
return formatNumberValue(value, locale);
|
|
110
|
+
if (type === "date" && typeof value === "string") return formatDateValue(value, locale);
|
|
111
|
+
if (type === "checkbox") return value ? "Yes" : "No";
|
|
112
|
+
if (NAMED_TYPES.has(type))
|
|
113
|
+
return cellIds(value).map((id) => titleOf(id, titles)).join(", ");
|
|
114
|
+
if (type === "lookup")
|
|
115
|
+
return cellList(value).map((v) => formatLookupValue(v, titles, locale)).join(", ");
|
|
116
|
+
return String(value);
|
|
117
|
+
}
|
|
118
|
+
function toApiValue(value, type) {
|
|
119
|
+
if (isEmpty(value)) return null;
|
|
120
|
+
if (LINK_COLUMN_TYPES.has(type)) return cellIds(value);
|
|
121
|
+
if (type === "checkbox") return Boolean(value);
|
|
122
|
+
if (type === "date" && value instanceof Date) {
|
|
123
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
124
|
+
return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}`;
|
|
125
|
+
}
|
|
126
|
+
if (type === "number" && typeof value === "string") {
|
|
127
|
+
const n = Number(value.replace(/,/g, ""));
|
|
128
|
+
return Number.isFinite(n) ? n : value;
|
|
129
|
+
}
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
132
|
+
function compareCells(a, b, type, titlesA, titlesB) {
|
|
133
|
+
const ea = isEmpty(a);
|
|
134
|
+
const eb = isEmpty(b);
|
|
135
|
+
if (ea || eb) return ea === eb ? 0 : ea ? 1 : -1;
|
|
136
|
+
if (type === "number" || type === "checkbox" || type === "rollup") return Number(a) - Number(b);
|
|
137
|
+
const shown = NAMED_TYPES.has(type) || type === "lookup";
|
|
138
|
+
const ta = shown ? formatCell(a, type, void 0, titlesA) : String(a);
|
|
139
|
+
const tb = shown ? formatCell(b, type, void 0, titlesB) : String(b);
|
|
140
|
+
return ta.localeCompare(tb, void 0, { sensitivity: "base", numeric: true });
|
|
141
|
+
}
|
|
142
|
+
function rowTitle(row, columns, locale) {
|
|
143
|
+
const first = columns[0];
|
|
144
|
+
return first ? formatCell(row.values[first.id], first.type, locale, row.titles) : "";
|
|
145
|
+
}
|
|
146
|
+
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";
|
|
147
|
+
function initials(name) {
|
|
148
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
149
|
+
const letters = parts.length > 1 ? parts[0][0] + parts[parts.length - 1][0] : name.slice(0, 2);
|
|
150
|
+
return letters.toUpperCase();
|
|
151
|
+
}
|
|
152
|
+
function PersonChip({ name }) {
|
|
153
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex min-w-0 items-center gap-1.5 text-sm", children: [
|
|
154
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
155
|
+
"span",
|
|
156
|
+
{
|
|
157
|
+
"aria-hidden": true,
|
|
158
|
+
className: "flex size-5 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-medium text-muted-foreground",
|
|
159
|
+
children: initials(name)
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: name })
|
|
163
|
+
] });
|
|
164
|
+
}
|
|
165
|
+
function LinkChip({
|
|
166
|
+
label,
|
|
167
|
+
kind,
|
|
168
|
+
onOpen,
|
|
169
|
+
testId
|
|
170
|
+
}) {
|
|
171
|
+
const Icon = kind === "document" ? lucideReact.FileText : lucideReact.ArrowUpRight;
|
|
172
|
+
const body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
173
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-3 shrink-0 text-muted-foreground", "aria-hidden": true }),
|
|
174
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: label })
|
|
175
|
+
] });
|
|
176
|
+
if (!onOpen) {
|
|
177
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: CHIP, title: label, "data-testid": testId, children: body });
|
|
178
|
+
}
|
|
179
|
+
const stop = (e) => e.stopPropagation();
|
|
180
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
181
|
+
"button",
|
|
182
|
+
{
|
|
183
|
+
type: "button",
|
|
184
|
+
title: label,
|
|
185
|
+
"data-testid": testId,
|
|
186
|
+
onClick: (e) => {
|
|
187
|
+
e.stopPropagation();
|
|
188
|
+
onOpen();
|
|
189
|
+
},
|
|
190
|
+
onDoubleClick: stop,
|
|
191
|
+
onMouseDown: stop,
|
|
192
|
+
className: ui.cn(CHIP, "hover:bg-muted hover:underline"),
|
|
193
|
+
children: body
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
function ChipRow({ children, wrap }) {
|
|
198
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
199
|
+
"span",
|
|
200
|
+
{
|
|
201
|
+
className: ui.cn(
|
|
202
|
+
"flex min-w-0 items-center gap-1",
|
|
203
|
+
wrap ? "flex-wrap py-0.5" : "h-full overflow-hidden"
|
|
204
|
+
),
|
|
205
|
+
children
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
function PersonCell({ value, titles }) {
|
|
210
|
+
const [id] = cellIds(value);
|
|
211
|
+
return id ? /* @__PURE__ */ jsxRuntime.jsx(PersonChip, { name: titleOf(id, titles) }) : null;
|
|
212
|
+
}
|
|
213
|
+
function LinkChipsCell({
|
|
214
|
+
value,
|
|
215
|
+
titles,
|
|
216
|
+
kind,
|
|
217
|
+
onOpenDocument,
|
|
218
|
+
wrap
|
|
219
|
+
}) {
|
|
220
|
+
const ids = cellIds(value);
|
|
221
|
+
if (ids.length === 0) return null;
|
|
222
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ChipRow, { wrap, children: ids.map((id) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
223
|
+
LinkChip,
|
|
224
|
+
{
|
|
225
|
+
label: titleOf(id, titles),
|
|
226
|
+
kind,
|
|
227
|
+
testId: `database-chip-${id}`,
|
|
228
|
+
onOpen: kind === "document" && onOpenDocument ? () => onOpenDocument(id) : void 0
|
|
229
|
+
},
|
|
230
|
+
id
|
|
231
|
+
)) });
|
|
232
|
+
}
|
|
233
|
+
function LookupCell({
|
|
234
|
+
value,
|
|
235
|
+
titles,
|
|
236
|
+
locale,
|
|
237
|
+
wrap
|
|
238
|
+
}) {
|
|
239
|
+
const values = cellList(value);
|
|
240
|
+
if (values.length === 0) return null;
|
|
241
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ChipRow, { wrap, children: values.map((v, i) => {
|
|
242
|
+
const text = formatLookupValue(v, titles, locale);
|
|
243
|
+
const key = `${i}-${text}`;
|
|
244
|
+
if (typeof v === "string" && /^doc-/.test(v))
|
|
245
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LinkChip, { label: text, kind: "document" }, key);
|
|
246
|
+
if (typeof v === "string" && /^dbr-/.test(v))
|
|
247
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LinkChip, { label: text, kind: "relation" }, key);
|
|
248
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
249
|
+
"span",
|
|
250
|
+
{
|
|
251
|
+
title: text,
|
|
252
|
+
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",
|
|
253
|
+
children: text
|
|
254
|
+
},
|
|
255
|
+
key
|
|
256
|
+
);
|
|
257
|
+
}) });
|
|
258
|
+
}
|
|
259
|
+
var MAX_SHOWN = 50;
|
|
260
|
+
var SEARCH_DEBOUNCE_MS = 200;
|
|
261
|
+
var DEFAULT_PICK_CELL_EDITOR_LABELS = {
|
|
262
|
+
searchPlaceholder: "Search\u2026",
|
|
263
|
+
noMatches: "No matches",
|
|
264
|
+
searching: "Searching\u2026",
|
|
265
|
+
clear: "Clear",
|
|
266
|
+
done: "Done",
|
|
267
|
+
remove: (label) => `Remove ${label}`
|
|
268
|
+
};
|
|
269
|
+
function useChoices(query, options, search) {
|
|
270
|
+
const [found, setFound] = react.useState([]);
|
|
271
|
+
const [loading, setLoading] = react.useState(Boolean(search));
|
|
272
|
+
react.useEffect(() => {
|
|
273
|
+
if (!search) return;
|
|
274
|
+
let live = true;
|
|
275
|
+
setLoading(true);
|
|
276
|
+
const t = setTimeout(
|
|
277
|
+
() => {
|
|
278
|
+
search(query.trim()).then((rows) => live && setFound(rows)).catch(() => live && setFound([])).finally(() => live && setLoading(false));
|
|
279
|
+
},
|
|
280
|
+
query ? SEARCH_DEBOUNCE_MS : 0
|
|
281
|
+
);
|
|
282
|
+
return () => {
|
|
283
|
+
live = false;
|
|
284
|
+
clearTimeout(t);
|
|
285
|
+
};
|
|
286
|
+
}, [query, search]);
|
|
287
|
+
const filtered = react.useMemo(() => {
|
|
288
|
+
if (search) return found.slice(0, MAX_SHOWN);
|
|
289
|
+
const q = query.trim().toLowerCase();
|
|
290
|
+
const all = options ?? [];
|
|
291
|
+
const hits = q ? all.filter(
|
|
292
|
+
(o) => o.label.toLowerCase().includes(q) || (o.description ?? "").toLowerCase().includes(q)
|
|
293
|
+
) : all;
|
|
294
|
+
return hits.slice(0, MAX_SHOWN);
|
|
295
|
+
}, [found, options, query, search]);
|
|
296
|
+
return { choices: filtered, loading: Boolean(search) && loading };
|
|
297
|
+
}
|
|
298
|
+
function PickCellEditor(props) {
|
|
299
|
+
const { value, onValueChange, stopEditing, data, kind, options, search } = props;
|
|
300
|
+
const l = { ...DEFAULT_PICK_CELL_EDITOR_LABELS, ...props.labels };
|
|
301
|
+
const multiple = kind !== "person";
|
|
302
|
+
const [chosen, setChosen] = react.useState(() => cellIds(value));
|
|
303
|
+
const [query, setQuery] = react.useState("");
|
|
304
|
+
const [active, setActive] = react.useState(0);
|
|
305
|
+
const input = react.useRef(null);
|
|
306
|
+
const { choices, loading } = useChoices(query, options, search);
|
|
307
|
+
const names = react.useRef({ ...data?.titles ?? {} });
|
|
308
|
+
for (const o of options ?? []) names.current[o.id] ??= o.label;
|
|
309
|
+
for (const o of choices) names.current[o.id] = o.label;
|
|
310
|
+
const nameOf = (id) => names.current[id] ?? id;
|
|
311
|
+
react.useEffect(() => input.current?.focus(), []);
|
|
312
|
+
react.useEffect(() => setActive(0), [query]);
|
|
313
|
+
const commit = (ids) => {
|
|
314
|
+
setChosen(ids);
|
|
315
|
+
if (data) {
|
|
316
|
+
const titles = { ...data.titles ?? {} };
|
|
317
|
+
for (const id of ids) titles[id] ??= nameOf(id);
|
|
318
|
+
data.titles = titles;
|
|
319
|
+
}
|
|
320
|
+
onValueChange(multiple ? ids : ids[0] ?? null);
|
|
321
|
+
};
|
|
322
|
+
const close = () => setTimeout(() => stopEditing(), 0);
|
|
323
|
+
const toggle = (id) => {
|
|
324
|
+
if (!multiple) {
|
|
325
|
+
commit([id]);
|
|
326
|
+
close();
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
commit(chosen.includes(id) ? chosen.filter((x) => x !== id) : [...chosen, id]);
|
|
330
|
+
};
|
|
331
|
+
const onKeyDown = (e) => {
|
|
332
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
333
|
+
e.preventDefault();
|
|
334
|
+
e.stopPropagation();
|
|
335
|
+
if (choices.length === 0) return;
|
|
336
|
+
const step = e.key === "ArrowDown" ? 1 : -1;
|
|
337
|
+
setActive((i) => (i + step + choices.length) % choices.length);
|
|
338
|
+
} else if (e.key === "Enter") {
|
|
339
|
+
e.preventDefault();
|
|
340
|
+
e.stopPropagation();
|
|
341
|
+
const pick = choices[active];
|
|
342
|
+
if (pick) toggle(pick.id);
|
|
343
|
+
else if (multiple) close();
|
|
344
|
+
} else if (e.key === "Backspace" && multiple && !query && chosen.length > 0) {
|
|
345
|
+
commit(chosen.slice(0, -1));
|
|
346
|
+
} else if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home" || e.key === "End") {
|
|
347
|
+
e.stopPropagation();
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
351
|
+
"div",
|
|
352
|
+
{
|
|
353
|
+
"data-testid": "database-pick-editor",
|
|
354
|
+
className: "flex w-72 flex-col rounded-md border border-border bg-popover shadow-md",
|
|
355
|
+
children: [
|
|
356
|
+
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: [
|
|
357
|
+
/* @__PURE__ */ jsxRuntime.jsx(LinkChip, { label: nameOf(id), kind: kind === "document" ? "document" : "relation" }),
|
|
358
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
359
|
+
"button",
|
|
360
|
+
{
|
|
361
|
+
type: "button",
|
|
362
|
+
"aria-label": l.remove(nameOf(id)),
|
|
363
|
+
onClick: () => commit(chosen.filter((x) => x !== id)),
|
|
364
|
+
"data-testid": `database-pick-remove-${id}`,
|
|
365
|
+
className: "rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
366
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "size-3" })
|
|
367
|
+
}
|
|
368
|
+
)
|
|
369
|
+
] }, id)) }),
|
|
370
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 border-b border-border px-2", children: [
|
|
371
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": true }),
|
|
372
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
373
|
+
"input",
|
|
374
|
+
{
|
|
375
|
+
ref: input,
|
|
376
|
+
value: query,
|
|
377
|
+
placeholder: l.searchPlaceholder,
|
|
378
|
+
onChange: (e) => setQuery(e.target.value),
|
|
379
|
+
onKeyDown,
|
|
380
|
+
"data-testid": "database-pick-search",
|
|
381
|
+
className: "h-8 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
|
|
382
|
+
}
|
|
383
|
+
),
|
|
384
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-3.5 animate-spin text-muted-foreground" })
|
|
385
|
+
] }),
|
|
386
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { role: "listbox", "aria-multiselectable": multiple, className: "max-h-64 overflow-y-auto p-1", children: [
|
|
387
|
+
choices.map((o, i) => {
|
|
388
|
+
const isChosen = chosen.includes(o.id);
|
|
389
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
390
|
+
"button",
|
|
391
|
+
{
|
|
392
|
+
type: "button",
|
|
393
|
+
role: "option",
|
|
394
|
+
"aria-selected": isChosen,
|
|
395
|
+
onMouseEnter: () => setActive(i),
|
|
396
|
+
onClick: () => toggle(o.id),
|
|
397
|
+
"data-testid": `database-pick-option-${o.id}`,
|
|
398
|
+
className: ui.cn(
|
|
399
|
+
"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-sm",
|
|
400
|
+
i === active && "bg-muted"
|
|
401
|
+
),
|
|
402
|
+
children: [
|
|
403
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
404
|
+
kind === "person" ? /* @__PURE__ */ jsxRuntime.jsx(PersonChip, { name: o.label }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: o.label }),
|
|
405
|
+
o.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs text-muted-foreground", children: o.description })
|
|
406
|
+
] }),
|
|
407
|
+
isChosen && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "size-3.5 shrink-0" })
|
|
408
|
+
]
|
|
409
|
+
},
|
|
410
|
+
o.id
|
|
411
|
+
);
|
|
412
|
+
}),
|
|
413
|
+
choices.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-2 py-1.5 text-sm text-muted-foreground", children: loading ? l.searching : l.noMatches })
|
|
414
|
+
] }),
|
|
415
|
+
(multiple || chosen.length > 0) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end border-t border-border p-1", children: !multiple ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
416
|
+
"button",
|
|
417
|
+
{
|
|
418
|
+
type: "button",
|
|
419
|
+
onClick: () => {
|
|
420
|
+
commit([]);
|
|
421
|
+
close();
|
|
422
|
+
},
|
|
423
|
+
"data-testid": "database-pick-clear",
|
|
424
|
+
className: "rounded px-2 py-1 text-sm text-muted-foreground hover:bg-muted",
|
|
425
|
+
children: l.clear
|
|
426
|
+
}
|
|
427
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
428
|
+
"button",
|
|
429
|
+
{
|
|
430
|
+
type: "button",
|
|
431
|
+
onClick: close,
|
|
432
|
+
"data-testid": "database-pick-done",
|
|
433
|
+
className: "rounded px-2 py-1 text-sm font-medium hover:bg-muted",
|
|
434
|
+
children: l.done
|
|
435
|
+
}
|
|
436
|
+
) })
|
|
437
|
+
]
|
|
438
|
+
}
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
function SelectChip({ value }) {
|
|
442
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
443
|
+
"span",
|
|
444
|
+
{
|
|
445
|
+
className: ui.cn(
|
|
446
|
+
"inline-flex max-w-full items-center truncate rounded-md px-2 py-0.5 text-xs font-medium",
|
|
447
|
+
optionTone(value)
|
|
448
|
+
),
|
|
449
|
+
children: value
|
|
450
|
+
}
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
function SelectCellEditor(props) {
|
|
454
|
+
const { value, onValueChange, stopEditing, options, clearLabel = "Clear" } = props;
|
|
455
|
+
const items = [...options, null];
|
|
456
|
+
const [active, setActive] = react.useState(() => Math.max(0, options.indexOf(String(value ?? ""))));
|
|
457
|
+
const list = react.useRef(null);
|
|
458
|
+
react.useEffect(() => list.current?.focus(), []);
|
|
459
|
+
const pick = (option) => {
|
|
460
|
+
onValueChange(option);
|
|
461
|
+
setTimeout(() => stopEditing(), 0);
|
|
462
|
+
};
|
|
463
|
+
const onKeyDown = (e) => {
|
|
464
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
465
|
+
e.preventDefault();
|
|
466
|
+
e.stopPropagation();
|
|
467
|
+
const step = e.key === "ArrowDown" ? 1 : -1;
|
|
468
|
+
setActive((i) => (i + step + items.length) % items.length);
|
|
469
|
+
} else if (e.key === "Enter") {
|
|
470
|
+
e.preventDefault();
|
|
471
|
+
e.stopPropagation();
|
|
472
|
+
pick(items[active]);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
476
|
+
"div",
|
|
477
|
+
{
|
|
478
|
+
ref: list,
|
|
479
|
+
role: "listbox",
|
|
480
|
+
tabIndex: -1,
|
|
481
|
+
onKeyDown,
|
|
482
|
+
"data-testid": "database-select-editor",
|
|
483
|
+
className: "flex min-w-44 flex-col gap-0.5 rounded-md border border-border bg-popover p-1 shadow-md outline-none",
|
|
484
|
+
children: items.map((option, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
485
|
+
"button",
|
|
486
|
+
{
|
|
487
|
+
type: "button",
|
|
488
|
+
role: "option",
|
|
489
|
+
"aria-selected": option === value,
|
|
490
|
+
onMouseEnter: () => setActive(i),
|
|
491
|
+
onClick: () => pick(option),
|
|
492
|
+
"data-testid": option === null ? "database-select-clear" : `database-select-option-${option}`,
|
|
493
|
+
className: ui.cn(
|
|
494
|
+
"flex items-center gap-2 rounded px-2 py-1 text-left text-sm",
|
|
495
|
+
i === active && "bg-muted"
|
|
496
|
+
),
|
|
497
|
+
children: [
|
|
498
|
+
option === null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: clearLabel }) : /* @__PURE__ */ jsxRuntime.jsx(SelectChip, { value: option }),
|
|
499
|
+
option !== null && option === value && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "ml-auto size-3.5" })
|
|
500
|
+
]
|
|
501
|
+
},
|
|
502
|
+
option ?? "__clear"
|
|
503
|
+
))
|
|
504
|
+
}
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
var DEFAULT_DATABASE_COLUMN_LABELS = {
|
|
508
|
+
addColumn: "Add a column",
|
|
509
|
+
columnSettings: (name) => `${name} column settings`,
|
|
510
|
+
computed: "Computed from a relation (read-only)",
|
|
511
|
+
openRow: "Open row"
|
|
512
|
+
};
|
|
513
|
+
var ADD_COLUMN_COL_ID = "__add_column";
|
|
514
|
+
var OPEN_ROW_COL_ID = "__open_row";
|
|
515
|
+
var COLUMN_TYPE_ICONS = {
|
|
516
|
+
text: lucideReact.Type,
|
|
517
|
+
number: lucideReact.Hash,
|
|
518
|
+
date: lucideReact.CalendarDays,
|
|
519
|
+
checkbox: lucideReact.CheckSquare,
|
|
520
|
+
select: lucideReact.ChevronDown,
|
|
521
|
+
person: lucideReact.UserRound,
|
|
522
|
+
document: lucideReact.FileText,
|
|
523
|
+
relation: lucideReact.ArrowUpRight,
|
|
524
|
+
lookup: lucideReact.Search,
|
|
525
|
+
rollup: lucideReact.Sigma
|
|
526
|
+
};
|
|
527
|
+
var WIDTHS = {
|
|
528
|
+
text: 220,
|
|
529
|
+
number: 130,
|
|
530
|
+
date: 140,
|
|
531
|
+
checkbox: 110,
|
|
532
|
+
select: 160,
|
|
533
|
+
person: 180,
|
|
534
|
+
document: 240,
|
|
535
|
+
relation: 240,
|
|
536
|
+
lookup: 200,
|
|
537
|
+
rollup: 130
|
|
538
|
+
};
|
|
539
|
+
function HeaderLabel({
|
|
540
|
+
dbColumn: column,
|
|
541
|
+
onEdit,
|
|
542
|
+
settingsLabel: label,
|
|
543
|
+
computedLabel
|
|
544
|
+
}) {
|
|
545
|
+
const Icon = COLUMN_TYPE_ICONS[column.type];
|
|
546
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "group/dbh flex min-w-0 items-center gap-1.5", children: [
|
|
547
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": true }),
|
|
548
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-[12.5px] font-medium", children: column.name }),
|
|
549
|
+
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 }) }),
|
|
550
|
+
onEdit && /* @__PURE__ */ jsxRuntime.jsx(
|
|
551
|
+
"button",
|
|
552
|
+
{
|
|
553
|
+
type: "button",
|
|
554
|
+
"aria-label": label,
|
|
555
|
+
title: label,
|
|
556
|
+
"data-testid": `database-column-settings-${column.id}`,
|
|
557
|
+
onClick: (e) => {
|
|
558
|
+
e.stopPropagation();
|
|
559
|
+
onEdit();
|
|
560
|
+
},
|
|
561
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
562
|
+
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",
|
|
563
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreHorizontal, { className: "size-3.5" })
|
|
564
|
+
}
|
|
565
|
+
)
|
|
566
|
+
] });
|
|
567
|
+
}
|
|
568
|
+
function AddColumnHeader({ addLabel, onAddColumn }) {
|
|
569
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
570
|
+
"button",
|
|
571
|
+
{
|
|
572
|
+
type: "button",
|
|
573
|
+
"aria-label": addLabel,
|
|
574
|
+
title: addLabel,
|
|
575
|
+
"data-testid": "database-add-column",
|
|
576
|
+
onClick: onAddColumn,
|
|
577
|
+
className: "flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
578
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4" })
|
|
579
|
+
}
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
function columnWidth(column) {
|
|
583
|
+
const header = Math.round(column.name.length * 8) + 76 + (isComputedColumn(column) ? 16 : 0);
|
|
584
|
+
return Math.min(320, Math.max(WIDTHS[column.type], header));
|
|
585
|
+
}
|
|
586
|
+
function canEditColumn(column, sources) {
|
|
587
|
+
if (isComputedColumn(column) || column.locked) return false;
|
|
588
|
+
if (column.type === "person") return Boolean(sources?.members);
|
|
589
|
+
if (column.type === "document") return Boolean(sources?.documents);
|
|
590
|
+
if (column.type === "relation") return Boolean(sources?.searchRows && column.relation);
|
|
591
|
+
return true;
|
|
592
|
+
}
|
|
593
|
+
function editorFor(column, sources) {
|
|
594
|
+
const pick = (params) => ({
|
|
595
|
+
cellEditor: PickCellEditor,
|
|
596
|
+
cellEditorPopup: true,
|
|
597
|
+
cellEditorParams: params
|
|
598
|
+
});
|
|
599
|
+
switch (column.type) {
|
|
600
|
+
case "number":
|
|
601
|
+
return { cellEditor: "agNumberCellEditor", cellEditorParams: { showStepperButtons: false } };
|
|
602
|
+
case "date":
|
|
603
|
+
return { cellEditor: "agDateStringCellEditor" };
|
|
604
|
+
case "checkbox":
|
|
605
|
+
return { cellEditor: "agCheckboxCellEditor" };
|
|
606
|
+
case "select":
|
|
607
|
+
return {
|
|
608
|
+
cellEditor: SelectCellEditor,
|
|
609
|
+
cellEditorPopup: true,
|
|
610
|
+
cellEditorParams: { options: column.options ?? [] }
|
|
611
|
+
};
|
|
612
|
+
case "person":
|
|
613
|
+
return pick({ kind: "person", options: sources?.members ?? [] });
|
|
614
|
+
case "document":
|
|
615
|
+
return pick({ kind: "document", options: sources?.documents ?? [] });
|
|
616
|
+
case "relation": {
|
|
617
|
+
const target = column.relation?.database_id;
|
|
618
|
+
const searchRows = sources?.searchRows;
|
|
619
|
+
return pick({
|
|
620
|
+
kind: "relation",
|
|
621
|
+
search: target && searchRows ? (q) => searchRows(target, q) : void 0
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
case "lookup":
|
|
625
|
+
case "rollup":
|
|
626
|
+
return {};
|
|
627
|
+
default:
|
|
628
|
+
return { cellEditor: "agTextCellEditor" };
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
function rendererFor(column, locale, sources) {
|
|
632
|
+
switch (column.type) {
|
|
633
|
+
case "checkbox":
|
|
634
|
+
return {
|
|
635
|
+
cellRenderer: "agCheckboxCellRenderer",
|
|
636
|
+
cellClass: "flex items-center justify-center"
|
|
637
|
+
};
|
|
638
|
+
case "select":
|
|
639
|
+
return {
|
|
640
|
+
cellRenderer: (p) => typeof p.value === "string" && p.value ? /* @__PURE__ */ jsxRuntime.jsx(SelectChip, { value: p.value }) : null
|
|
641
|
+
};
|
|
642
|
+
case "number":
|
|
643
|
+
return {
|
|
644
|
+
cellClass: "cell-numeric",
|
|
645
|
+
valueFormatter: (p) => formatCell(p.value, "number", locale)
|
|
646
|
+
};
|
|
647
|
+
case "rollup":
|
|
648
|
+
return {
|
|
649
|
+
cellClass: "cell-numeric text-muted-foreground",
|
|
650
|
+
valueFormatter: (p) => formatCell(p.value, "rollup", locale)
|
|
651
|
+
};
|
|
652
|
+
case "date":
|
|
653
|
+
return {
|
|
654
|
+
valueFormatter: (p) => formatCell(p.value, "date", locale)
|
|
655
|
+
};
|
|
656
|
+
case "person":
|
|
657
|
+
return {
|
|
658
|
+
cellRenderer: (p) => /* @__PURE__ */ jsxRuntime.jsx(PersonCell, { value: p.value, titles: p.data?.titles })
|
|
659
|
+
};
|
|
660
|
+
case "document":
|
|
661
|
+
case "relation":
|
|
662
|
+
return {
|
|
663
|
+
cellRenderer: (p) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
664
|
+
LinkChipsCell,
|
|
665
|
+
{
|
|
666
|
+
value: p.value,
|
|
667
|
+
titles: p.data?.titles,
|
|
668
|
+
kind: column.type === "document" ? "document" : "relation",
|
|
669
|
+
onOpenDocument: sources?.onOpenDocument
|
|
670
|
+
}
|
|
671
|
+
)
|
|
672
|
+
};
|
|
673
|
+
case "lookup":
|
|
674
|
+
return {
|
|
675
|
+
cellRenderer: (p) => /* @__PURE__ */ jsxRuntime.jsx(LookupCell, { value: p.value, titles: p.data?.titles, locale })
|
|
676
|
+
};
|
|
677
|
+
default:
|
|
678
|
+
return {};
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function createDatabaseColumns(columns, options = {}) {
|
|
682
|
+
const { readOnly, onEditColumn, onAddColumn, onOpenRow, locale, sources } = options;
|
|
683
|
+
const l = { ...DEFAULT_DATABASE_COLUMN_LABELS, ...options.labels };
|
|
684
|
+
const openRow = onOpenRow && columns.length > 0 ? [
|
|
685
|
+
{
|
|
686
|
+
colId: OPEN_ROW_COL_ID,
|
|
687
|
+
headerName: "",
|
|
688
|
+
width: 40,
|
|
689
|
+
minWidth: 40,
|
|
690
|
+
maxWidth: 40,
|
|
691
|
+
resizable: false,
|
|
692
|
+
sortable: false,
|
|
693
|
+
editable: false,
|
|
694
|
+
suppressMovable: true,
|
|
695
|
+
// Pinned: the button stays in view however far the table scrolls.
|
|
696
|
+
pinned: "left",
|
|
697
|
+
lockPinned: true,
|
|
698
|
+
lockPosition: "left",
|
|
699
|
+
cellClass: "flex items-center justify-center !px-0",
|
|
700
|
+
valueGetter: () => null,
|
|
701
|
+
cellRenderer: (p) => p.data ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
702
|
+
"button",
|
|
703
|
+
{
|
|
704
|
+
type: "button",
|
|
705
|
+
"aria-label": l.openRow,
|
|
706
|
+
title: l.openRow,
|
|
707
|
+
"data-testid": `database-open-row-${p.data.id}`,
|
|
708
|
+
onClick: (e) => {
|
|
709
|
+
e.stopPropagation();
|
|
710
|
+
if (p.data) onOpenRow(p.data);
|
|
711
|
+
},
|
|
712
|
+
onDoubleClick: (e) => e.stopPropagation(),
|
|
713
|
+
className: "flex size-6 items-center justify-center rounded text-muted-foreground/70 hover:bg-muted hover:text-foreground",
|
|
714
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize2, { className: "size-3.5" })
|
|
715
|
+
}
|
|
716
|
+
) : null
|
|
717
|
+
}
|
|
718
|
+
] : [];
|
|
719
|
+
const defs = columns.map((column) => ({
|
|
720
|
+
colId: column.id,
|
|
721
|
+
headerName: column.name,
|
|
722
|
+
width: columnWidth(column),
|
|
723
|
+
minWidth: 90,
|
|
724
|
+
resizable: true,
|
|
725
|
+
sortable: true,
|
|
726
|
+
editable: !readOnly && canEditColumn(column, sources),
|
|
727
|
+
// The grid's own type inference must not second-guess the database's column type.
|
|
728
|
+
cellDataType: false,
|
|
729
|
+
headerComponentParams: {
|
|
730
|
+
innerHeaderComponent: HeaderLabel,
|
|
731
|
+
innerHeaderComponentParams: {
|
|
732
|
+
dbColumn: column,
|
|
733
|
+
settingsLabel: l.columnSettings(column.name),
|
|
734
|
+
computedLabel: l.computed,
|
|
735
|
+
onEdit: !readOnly && onEditColumn ? () => onEditColumn(column) : void 0
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
// An empty checkbox reads as unticked (not indeterminate).
|
|
739
|
+
valueGetter: (p) => column.type === "checkbox" ? p.data?.values[column.id] === true : p.data?.values[column.id] ?? null,
|
|
740
|
+
// Edits land in the row's values as the API would store them; the host saves them in
|
|
741
|
+
// onCellValueChanged and puts the server's normalised row back.
|
|
742
|
+
valueSetter: (p) => {
|
|
743
|
+
if (!p.data) return false;
|
|
744
|
+
const next = toApiValue(p.newValue, column.type);
|
|
745
|
+
if (sameCellValue(next, p.oldValue)) return false;
|
|
746
|
+
p.data.values = { ...p.data.values, [column.id]: next };
|
|
747
|
+
return true;
|
|
748
|
+
},
|
|
749
|
+
comparator: (a, b, nodeA, nodeB) => compareCells(a, b, column.type, nodeA?.data?.titles, nodeB?.data?.titles),
|
|
750
|
+
getQuickFilterText: (p) => formatCell(p.value, column.type, locale, p.data?.titles),
|
|
751
|
+
...editorFor(column, sources),
|
|
752
|
+
...rendererFor(column, locale, sources)
|
|
753
|
+
}));
|
|
754
|
+
defs.unshift(...openRow);
|
|
755
|
+
if (!readOnly && onAddColumn) {
|
|
756
|
+
defs.push({
|
|
757
|
+
colId: ADD_COLUMN_COL_ID,
|
|
758
|
+
width: 52,
|
|
759
|
+
minWidth: 52,
|
|
760
|
+
maxWidth: 52,
|
|
761
|
+
resizable: false,
|
|
762
|
+
sortable: false,
|
|
763
|
+
editable: false,
|
|
764
|
+
suppressMovable: true,
|
|
765
|
+
// Pinned: on a wide table the add button stays in view instead of scrolling off the right.
|
|
766
|
+
pinned: "right",
|
|
767
|
+
lockPinned: true,
|
|
768
|
+
headerComponent: AddColumnHeader,
|
|
769
|
+
headerComponentParams: { addLabel: l.addColumn, onAddColumn },
|
|
770
|
+
valueGetter: () => null
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
return defs;
|
|
774
|
+
}
|
|
775
|
+
var escapeHtml = (text) => text.replace(/[&<>"']/g, (ch) => `&#${ch.charCodeAt(0)};`);
|
|
776
|
+
var DEFAULT_DATABASE_TABLE_LABELS = {
|
|
777
|
+
newRow: "New row",
|
|
778
|
+
emptyTitle: "No rows yet",
|
|
779
|
+
emptyMessage: "Add a row, or import a spreadsheet.",
|
|
780
|
+
noColumnsTitle: "No columns yet",
|
|
781
|
+
noColumnsMessage: "Add a column to start.",
|
|
782
|
+
noMatches: "No rows match your search or filters."
|
|
783
|
+
};
|
|
784
|
+
function DatabaseTable({
|
|
785
|
+
columns,
|
|
786
|
+
rows,
|
|
787
|
+
onCellChange,
|
|
788
|
+
onAddRow,
|
|
789
|
+
onAddColumn,
|
|
790
|
+
onEditColumn,
|
|
791
|
+
onOpenRow,
|
|
792
|
+
sources,
|
|
793
|
+
onSelectionChange,
|
|
794
|
+
selected,
|
|
795
|
+
readOnly = false,
|
|
796
|
+
isFiltered = false,
|
|
797
|
+
isLoading,
|
|
798
|
+
locale,
|
|
799
|
+
gridId,
|
|
800
|
+
height = "100%",
|
|
801
|
+
labels,
|
|
802
|
+
columnLabels,
|
|
803
|
+
gridProps,
|
|
804
|
+
testId
|
|
805
|
+
}) {
|
|
806
|
+
const l = { ...DEFAULT_DATABASE_TABLE_LABELS, ...labels };
|
|
807
|
+
const latest = react.useRef({ onEditColumn, onAddColumn, onOpenRow });
|
|
808
|
+
latest.current = { onEditColumn, onAddColumn, onOpenRow };
|
|
809
|
+
const hasEditColumn = !!onEditColumn;
|
|
810
|
+
const hasAddColumn = !!onAddColumn;
|
|
811
|
+
const hasOpenRow = !!onOpenRow;
|
|
812
|
+
const editColumn = react.useMemo(
|
|
813
|
+
() => hasEditColumn ? (column) => latest.current.onEditColumn?.(column) : void 0,
|
|
814
|
+
[hasEditColumn]
|
|
815
|
+
);
|
|
816
|
+
const addColumn = react.useMemo(
|
|
817
|
+
() => hasAddColumn ? () => latest.current.onAddColumn?.() : void 0,
|
|
818
|
+
[hasAddColumn]
|
|
819
|
+
);
|
|
820
|
+
const openRow = react.useMemo(
|
|
821
|
+
() => hasOpenRow ? (row) => latest.current.onOpenRow?.(row) : void 0,
|
|
822
|
+
[hasOpenRow]
|
|
823
|
+
);
|
|
824
|
+
const columnDefs = react.useMemo(
|
|
825
|
+
() => createDatabaseColumns(columns, {
|
|
826
|
+
readOnly,
|
|
827
|
+
onEditColumn: editColumn,
|
|
828
|
+
onAddColumn: addColumn,
|
|
829
|
+
onOpenRow: openRow,
|
|
830
|
+
sources,
|
|
831
|
+
locale,
|
|
832
|
+
labels: columnLabels
|
|
833
|
+
}),
|
|
834
|
+
[columns, readOnly, editColumn, addColumn, openRow, sources, locale, columnLabels]
|
|
835
|
+
);
|
|
836
|
+
const noColumns = columns.length === 0;
|
|
837
|
+
const emptyState = {
|
|
838
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Table2, { className: "size-8 text-muted-foreground" }),
|
|
839
|
+
title: l.noColumnsTitle,
|
|
840
|
+
message: readOnly ? void 0 : l.noColumnsMessage,
|
|
841
|
+
action: !readOnly && onAddColumn ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Button, { onClick: onAddColumn, "data-testid": "database-empty-add-column", className: "gap-1.5", children: [
|
|
842
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4" }),
|
|
843
|
+
columnLabels?.addColumn ?? DEFAULT_DATABASE_COLUMN_LABELS.addColumn
|
|
844
|
+
] }) : void 0
|
|
845
|
+
};
|
|
846
|
+
const noRowsText = isFiltered ? l.noMatches : readOnly ? l.emptyTitle : `${l.emptyTitle}. ${l.emptyMessage}`;
|
|
847
|
+
const api = react.useRef(null);
|
|
848
|
+
const knownColumns = react.useRef(null);
|
|
849
|
+
react.useEffect(() => {
|
|
850
|
+
const ids = new Set(columns.map((c) => c.id));
|
|
851
|
+
const added = knownColumns.current ? columns.filter((c) => !knownColumns.current.has(c.id)) : [];
|
|
852
|
+
knownColumns.current = ids;
|
|
853
|
+
const last = added[added.length - 1];
|
|
854
|
+
if (last && api.current) {
|
|
855
|
+
const grid = api.current;
|
|
856
|
+
setTimeout(() => grid.ensureColumnVisible(last.id, "end"), 0);
|
|
857
|
+
}
|
|
858
|
+
}, [columns]);
|
|
859
|
+
const handleCellValueChanged = (event) => {
|
|
860
|
+
const columnId = event.column.getColId();
|
|
861
|
+
if (!event.data || !onCellChange) return;
|
|
862
|
+
onCellChange(event.data, columnId, event.data.values[columnId] ?? null);
|
|
863
|
+
};
|
|
864
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
865
|
+
"div",
|
|
866
|
+
{
|
|
867
|
+
className: "flex h-full min-h-0 flex-col",
|
|
868
|
+
"data-testid": chunkPLIF5CUV_cjs.testIdOr(testId, { testId: "database-table" }),
|
|
869
|
+
children: [
|
|
870
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
871
|
+
chunkZVEW3JBT_cjs.GridView,
|
|
872
|
+
{
|
|
873
|
+
testId: "database-grid",
|
|
874
|
+
items: rows,
|
|
875
|
+
columnDefs,
|
|
876
|
+
getItemId: (row) => row.id,
|
|
877
|
+
getRowTestId: (row) => `database-row-${row.id}`,
|
|
878
|
+
getCellTestId: (colId, row) => `database-cell-${row.id}-${colId}`,
|
|
879
|
+
isLoading,
|
|
880
|
+
emptyState,
|
|
881
|
+
showEmpty: noColumns,
|
|
882
|
+
gridId,
|
|
883
|
+
height,
|
|
884
|
+
rowHeight: 38,
|
|
885
|
+
selection: onSelectionChange ? { mode: "multiple", selected: selected ?? [], onSelectionChange, controlled: true } : void 0,
|
|
886
|
+
onCellValueChanged: handleCellValueChanged,
|
|
887
|
+
...gridProps,
|
|
888
|
+
onGridReady: (params) => {
|
|
889
|
+
api.current = params.api;
|
|
890
|
+
gridProps?.onGridReady?.(params);
|
|
891
|
+
},
|
|
892
|
+
gridOptions: {
|
|
893
|
+
overlayNoRowsTemplate: `<span class="text-sm text-muted-foreground">${escapeHtml(noRowsText)}</span>`,
|
|
894
|
+
singleClickEdit: false,
|
|
895
|
+
stopEditingWhenCellsLoseFocus: true,
|
|
896
|
+
enterNavigatesVerticallyAfterEdit: true,
|
|
897
|
+
undoRedoCellEditing: false,
|
|
898
|
+
...gridProps?.gridOptions
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
) }),
|
|
902
|
+
!readOnly && onAddRow && columns.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border px-2 py-1", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
903
|
+
ui.Button,
|
|
904
|
+
{
|
|
905
|
+
variant: "ghost",
|
|
906
|
+
size: "sm",
|
|
907
|
+
onClick: onAddRow,
|
|
908
|
+
"data-testid": "database-add-row",
|
|
909
|
+
className: "gap-1.5 text-muted-foreground",
|
|
910
|
+
children: [
|
|
911
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4" }),
|
|
912
|
+
l.newRow
|
|
913
|
+
]
|
|
914
|
+
}
|
|
915
|
+
) })
|
|
916
|
+
]
|
|
917
|
+
}
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
exports.ADD_COLUMN_COL_ID = ADD_COLUMN_COL_ID;
|
|
922
|
+
exports.COLUMN_TYPE_ICONS = COLUMN_TYPE_ICONS;
|
|
923
|
+
exports.COMPUTED_COLUMN_TYPES = COMPUTED_COLUMN_TYPES;
|
|
924
|
+
exports.DATABASE_COLUMN_TYPES = DATABASE_COLUMN_TYPES;
|
|
925
|
+
exports.DATABASE_ROLLUP_OPS = DATABASE_ROLLUP_OPS;
|
|
926
|
+
exports.DEFAULT_DATABASE_COLUMN_LABELS = DEFAULT_DATABASE_COLUMN_LABELS;
|
|
927
|
+
exports.DEFAULT_DATABASE_COLUMN_TYPE_LABELS = DEFAULT_DATABASE_COLUMN_TYPE_LABELS;
|
|
928
|
+
exports.DEFAULT_DATABASE_TABLE_LABELS = DEFAULT_DATABASE_TABLE_LABELS;
|
|
929
|
+
exports.DEFAULT_PICK_CELL_EDITOR_LABELS = DEFAULT_PICK_CELL_EDITOR_LABELS;
|
|
930
|
+
exports.DatabaseTable = DatabaseTable;
|
|
931
|
+
exports.LINK_COLUMN_TYPES = LINK_COLUMN_TYPES;
|
|
932
|
+
exports.LinkChip = LinkChip;
|
|
933
|
+
exports.LinkChipsCell = LinkChipsCell;
|
|
934
|
+
exports.LookupCell = LookupCell;
|
|
935
|
+
exports.OPEN_ROW_COL_ID = OPEN_ROW_COL_ID;
|
|
936
|
+
exports.PersonCell = PersonCell;
|
|
937
|
+
exports.PersonChip = PersonChip;
|
|
938
|
+
exports.PickCellEditor = PickCellEditor;
|
|
939
|
+
exports.SelectCellEditor = SelectCellEditor;
|
|
940
|
+
exports.SelectChip = SelectChip;
|
|
941
|
+
exports.canEditColumn = canEditColumn;
|
|
942
|
+
exports.cellIds = cellIds;
|
|
943
|
+
exports.cellList = cellList;
|
|
944
|
+
exports.columnWidth = columnWidth;
|
|
945
|
+
exports.compareCells = compareCells;
|
|
946
|
+
exports.createDatabaseColumns = createDatabaseColumns;
|
|
947
|
+
exports.formatCell = formatCell;
|
|
948
|
+
exports.formatDateValue = formatDateValue;
|
|
949
|
+
exports.formatLookupValue = formatLookupValue;
|
|
950
|
+
exports.formatNumberValue = formatNumberValue;
|
|
951
|
+
exports.isComputedColumn = isComputedColumn;
|
|
952
|
+
exports.optionTone = optionTone;
|
|
953
|
+
exports.rowTitle = rowTitle;
|
|
954
|
+
exports.sameCellValue = sameCellValue;
|
|
955
|
+
exports.titleOf = titleOf;
|
|
956
|
+
exports.toApiValue = toApiValue;
|
|
957
|
+
//# sourceMappingURL=chunk-Q25CZLK6.cjs.map
|
|
958
|
+
//# sourceMappingURL=chunk-Q25CZLK6.cjs.map
|