@arbidocs/blocks 0.5.182 → 0.5.184
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/README.md +30 -0
- package/dist/{ClippingPdfViewer-D5BYHEAH.cjs → ClippingPdfViewer-Z6L5DZW5.cjs} +4 -4
- package/dist/{ClippingPdfViewer-D5BYHEAH.cjs.map → ClippingPdfViewer-Z6L5DZW5.cjs.map} +1 -1
- package/dist/{ConnectedCallDock-C5UPUMMJ.cjs → ConnectedCallDock-CF7KF5KM.cjs} +6 -6
- package/dist/{ConnectedCallDock-C5UPUMMJ.cjs.map → ConnectedCallDock-CF7KF5KM.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-SEMH4DSA.cjs → ConnectedCallRoom-NQOE2RYD.cjs} +6 -6
- package/dist/{ConnectedCallRoom-SEMH4DSA.cjs.map → ConnectedCallRoom-NQOE2RYD.cjs.map} +1 -1
- package/dist/{ConnectedNativeDocxComparison-3MRTTNR2.cjs → ConnectedNativeDocxComparison-2YMF257D.cjs} +12 -11
- package/dist/{ConnectedNativeDocxComparison-3MRTTNR2.cjs.map → ConnectedNativeDocxComparison-2YMF257D.cjs.map} +1 -1
- package/dist/ConnectedPresentation-LNDESKYE.cjs +1 -1
- package/dist/{ConnectedSlidesTab-LEA5OW75.cjs → ConnectedSlidesTab-SYDDGJWM.cjs} +3 -3
- package/dist/{ConnectedSlidesTab-LEA5OW75.cjs.map → ConnectedSlidesTab-SYDDGJWM.cjs.map} +1 -1
- package/dist/{ConnectedStreamedWordArtifact-HNTS6HS4.cjs → ConnectedStreamedWordArtifact-3K5WTQMZ.cjs} +12 -11
- package/dist/{ConnectedStreamedWordArtifact-HNTS6HS4.cjs.map → ConnectedStreamedWordArtifact-3K5WTQMZ.cjs.map} +1 -1
- package/dist/{DocumentReviewCard-RPHIQZ2Y.cjs → DocumentReviewCard-3NNHDWG3.cjs} +17 -15
- package/dist/DocumentReviewCard-3NNHDWG3.cjs.map +1 -0
- package/dist/{FilesViewerDialog-PZ5H435S.cjs → FilesViewerDialog-OKLWGMIO.cjs} +23 -21
- package/dist/FilesViewerDialog-OKLWGMIO.cjs.map +1 -0
- package/dist/{NativeDocxEditor-T7FSMKG3.cjs → NativeDocxEditor-JJQJEYQD.cjs} +8 -7
- package/dist/{NativeDocxEditor-T7FSMKG3.cjs.map → NativeDocxEditor-JJQJEYQD.cjs.map} +1 -1
- package/dist/{WorkspaceTableView-QT63XYII.cjs → WorkspaceTableView-LGDLG3TX.cjs} +8 -8
- package/dist/{WorkspaceTableView-QT63XYII.cjs.map → WorkspaceTableView-LGDLG3TX.cjs.map} +1 -1
- package/dist/agents/index.cjs +164 -164
- package/dist/{ai-XIT4MY3S.cjs → ai-CTJWECJ5.cjs} +14 -14
- package/dist/ai-CTJWECJ5.cjs.map +1 -0
- package/dist/calls/index.cjs +24 -24
- package/dist/chat/index.cjs +30 -30
- package/dist/{chunk-GLFMRQBT.cjs → chunk-3J4R2QFL.cjs} +5 -5
- package/dist/{chunk-GLFMRQBT.cjs.map → chunk-3J4R2QFL.cjs.map} +1 -1
- package/dist/{chunk-DDWLMYRO.cjs → chunk-4XKROAMO.cjs} +8 -3
- package/dist/chunk-4XKROAMO.cjs.map +1 -0
- package/dist/{chunk-ADMNU2CR.cjs → chunk-66IOCKWS.cjs} +37 -10
- package/dist/chunk-66IOCKWS.cjs.map +1 -0
- package/dist/{chunk-L3MYUPSH.cjs → chunk-6AFAYGJW.cjs} +5 -5
- package/dist/{chunk-L3MYUPSH.cjs.map → chunk-6AFAYGJW.cjs.map} +1 -1
- package/dist/{chunk-2D5GZMSK.cjs → chunk-6RYDZ2PS.cjs} +44 -31
- package/dist/chunk-6RYDZ2PS.cjs.map +1 -0
- package/dist/chunk-76S6WTEC.cjs +39 -0
- package/dist/chunk-76S6WTEC.cjs.map +1 -0
- package/dist/{chunk-CYMAF656.cjs → chunk-7YALMXGZ.cjs} +39 -6
- package/dist/chunk-7YALMXGZ.cjs.map +1 -0
- package/dist/{chunk-TJY7XPDE.cjs → chunk-CWECDS4I.cjs} +4 -95
- package/dist/chunk-CWECDS4I.cjs.map +1 -0
- package/dist/{chunk-S4KKJX3G.cjs → chunk-E4CSBOXP.cjs} +32 -32
- package/dist/{chunk-S4KKJX3G.cjs.map → chunk-E4CSBOXP.cjs.map} +1 -1
- package/dist/{chunk-TQATDAJV.cjs → chunk-EBRD3IUG.cjs} +4 -4
- package/dist/{chunk-TQATDAJV.cjs.map → chunk-EBRD3IUG.cjs.map} +1 -1
- package/dist/{chunk-A4HOEGDI.cjs → chunk-ER55JOJV.cjs} +4 -4
- package/dist/{chunk-A4HOEGDI.cjs.map → chunk-ER55JOJV.cjs.map} +1 -1
- package/dist/{chunk-POUMLXMJ.cjs → chunk-FTSXCBUO.cjs} +6 -6
- package/dist/{chunk-POUMLXMJ.cjs.map → chunk-FTSXCBUO.cjs.map} +1 -1
- package/dist/chunk-GISMY7J7.cjs +99 -0
- package/dist/chunk-GISMY7J7.cjs.map +1 -0
- package/dist/{chunk-A7MGQMOV.cjs → chunk-H4N6BZNU.cjs} +3 -3
- package/dist/{chunk-A7MGQMOV.cjs.map → chunk-H4N6BZNU.cjs.map} +1 -1
- package/dist/{chunk-G2B2BWE5.cjs → chunk-HGQGXY5Q.cjs} +4 -4
- package/dist/{chunk-G2B2BWE5.cjs.map → chunk-HGQGXY5Q.cjs.map} +1 -1
- package/dist/{chunk-7H7KIJW2.cjs → chunk-HQ6SK34T.cjs} +3 -3
- package/dist/{chunk-7H7KIJW2.cjs.map → chunk-HQ6SK34T.cjs.map} +1 -1
- package/dist/chunk-HUAABZ2C.cjs +571 -0
- package/dist/chunk-HUAABZ2C.cjs.map +1 -0
- package/dist/{chunk-ICZSVCDT.cjs → chunk-IM6R7DRQ.cjs} +5 -5
- package/dist/{chunk-ICZSVCDT.cjs.map → chunk-IM6R7DRQ.cjs.map} +1 -1
- package/dist/{chunk-LYDSETR7.cjs → chunk-JEHGTPS2.cjs} +3 -3
- package/dist/{chunk-LYDSETR7.cjs.map → chunk-JEHGTPS2.cjs.map} +1 -1
- package/dist/{chunk-4AT2LJ2H.cjs → chunk-K2XLEOGQ.cjs} +6 -6
- package/dist/{chunk-4AT2LJ2H.cjs.map → chunk-K2XLEOGQ.cjs.map} +1 -1
- package/dist/{chunk-MWHVETKN.cjs → chunk-LIJB6XOR.cjs} +47 -7
- package/dist/chunk-LIJB6XOR.cjs.map +1 -0
- package/dist/{chunk-PJ5OQ5VB.cjs → chunk-LNYICHFJ.cjs} +23 -23
- package/dist/{chunk-PJ5OQ5VB.cjs.map → chunk-LNYICHFJ.cjs.map} +1 -1
- package/dist/{chunk-YC72ZCV4.cjs → chunk-LQ5XVFLV.cjs} +149 -92
- package/dist/chunk-LQ5XVFLV.cjs.map +1 -0
- package/dist/{chunk-UC6Z7E6C.cjs → chunk-LRBX4VIG.cjs} +4 -4
- package/dist/{chunk-UC6Z7E6C.cjs.map → chunk-LRBX4VIG.cjs.map} +1 -1
- package/dist/{chunk-I5LXJLO5.cjs → chunk-MZPBZSKS.cjs} +3 -3
- package/dist/{chunk-I5LXJLO5.cjs.map → chunk-MZPBZSKS.cjs.map} +1 -1
- package/dist/{chunk-JITYC4OS.cjs → chunk-NDRE7LD2.cjs} +17 -2
- package/dist/chunk-NDRE7LD2.cjs.map +1 -0
- package/dist/{chunk-YBDHWNFZ.cjs → chunk-OQWJXM4V.cjs} +24 -24
- package/dist/{chunk-YBDHWNFZ.cjs.map → chunk-OQWJXM4V.cjs.map} +1 -1
- package/dist/chunk-PUCYBYBY.cjs +3756 -0
- package/dist/chunk-PUCYBYBY.cjs.map +1 -0
- package/dist/{chunk-4H5DPHZ2.cjs → chunk-Q6DU3DZC.cjs} +4 -4
- package/dist/{chunk-4H5DPHZ2.cjs.map → chunk-Q6DU3DZC.cjs.map} +1 -1
- package/dist/{chunk-HX5SALXN.cjs → chunk-QCFX535U.cjs} +4 -4
- package/dist/{chunk-HX5SALXN.cjs.map → chunk-QCFX535U.cjs.map} +1 -1
- package/dist/chunk-QTGWH6Z2.cjs +18 -0
- package/dist/{chunk-TUURH4NE.cjs.map → chunk-QTGWH6Z2.cjs.map} +1 -1
- package/dist/{chunk-YHABS4UE.cjs → chunk-QYPCNB7P.cjs} +31 -31
- package/dist/{chunk-YHABS4UE.cjs.map → chunk-QYPCNB7P.cjs.map} +1 -1
- package/dist/{chunk-KULGPKLY.cjs → chunk-TBDQGSFI.cjs} +4 -4
- package/dist/{chunk-KULGPKLY.cjs.map → chunk-TBDQGSFI.cjs.map} +1 -1
- package/dist/{chunk-BQOL4XNZ.cjs → chunk-U46OGRCO.cjs} +94 -10
- package/dist/chunk-U46OGRCO.cjs.map +1 -0
- package/dist/{chunk-AWWGV5LL.cjs → chunk-UVMOUOFD.cjs} +28 -28
- package/dist/{chunk-AWWGV5LL.cjs.map → chunk-UVMOUOFD.cjs.map} +1 -1
- package/dist/{chunk-MZ7IUHQA.cjs → chunk-UXWPJ6I5.cjs} +38 -38
- package/dist/chunk-UXWPJ6I5.cjs.map +1 -0
- package/dist/chunk-V5P5MRSR.cjs +21 -0
- package/dist/chunk-V5P5MRSR.cjs.map +1 -0
- package/dist/{chunk-FUKN3PI5.cjs → chunk-VD3HI5RF.cjs} +99 -506
- package/dist/chunk-VD3HI5RF.cjs.map +1 -0
- package/dist/{chunk-6EJ7KD4U.cjs → chunk-WDL3TOMX.cjs} +6 -6
- package/dist/{chunk-6EJ7KD4U.cjs.map → chunk-WDL3TOMX.cjs.map} +1 -1
- package/dist/{chunk-6CPJ5ZOY.cjs → chunk-YM77I6V7.cjs} +3 -3
- package/dist/{chunk-6CPJ5ZOY.cjs.map → chunk-YM77I6V7.cjs.map} +1 -1
- package/dist/{chunk-JKTUL4L3.cjs → chunk-ZON25DCD.cjs} +5 -5
- package/dist/{chunk-JKTUL4L3.cjs.map → chunk-ZON25DCD.cjs.map} +1 -1
- package/dist/{chunk-DKKW7GOJ.cjs → chunk-ZVTLEBFG.cjs} +4 -4
- package/dist/{chunk-DKKW7GOJ.cjs.map → chunk-ZVTLEBFG.cjs.map} +1 -1
- package/dist/components/DetailPanel.d.ts +46 -3
- package/dist/components/DetailPanel.js +94 -10
- package/dist/components/DetailPanel.js.map +2 -2
- package/dist/connect/docx.cjs +16 -15
- package/dist/connect/docx.cjs.map +1 -1
- package/dist/connect/index.cjs +4916 -1817
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.d.ts +2 -1
- package/dist/connect/index.js +5 -1
- package/dist/connect/index.js.map +2 -2
- package/dist/connect/viewer.cjs +20 -18
- package/dist/connection/databases/ConnectedDatabasesPage.d.ts +22 -1
- package/dist/connection/databases/ConnectedDatabasesPage.js +189 -422
- package/dist/connection/databases/ConnectedDatabasesPage.js.map +2 -2
- package/dist/connection/databases/ConnectedRecentDatabases.d.ts +15 -0
- package/dist/connection/databases/ConnectedRecentDatabases.js +80 -0
- package/dist/connection/databases/ConnectedRecentDatabases.js.map +7 -0
- package/dist/connection/databases/ConnectedSourcesEditor.d.ts +4 -0
- package/dist/connection/databases/ConnectedSourcesEditor.js +126 -0
- package/dist/connection/databases/ConnectedSourcesEditor.js.map +7 -0
- package/dist/connection/databases/DatabaseViewsMenu.d.ts +8 -4
- package/dist/connection/databases/DatabaseViewsMenu.js +60 -27
- package/dist/connection/databases/DatabaseViewsMenu.js.map +2 -2
- package/dist/connection/databases/DatabaseWorkbench.d.ts +10 -0
- package/dist/connection/databases/DatabaseWorkbench.js +681 -0
- package/dist/connection/databases/DatabaseWorkbench.js.map +7 -0
- package/dist/connection/databases/databaseViewState.d.ts +12 -0
- package/dist/connection/databases/databaseViewState.js +50 -0
- package/dist/connection/databases/databaseViewState.js.map +7 -0
- package/dist/connection/databases/fixedPins.d.ts +6 -0
- package/dist/connection/databases/fixedPins.js +19 -0
- package/dist/connection/databases/fixedPins.js.map +7 -0
- package/dist/connection/databases/index.d.ts +6 -1
- package/dist/connection/databases/index.js +9 -1
- package/dist/connection/databases/index.js.map +2 -2
- package/dist/connection/databases/source.d.ts +26 -0
- package/dist/connection/databases/sourceCells.d.ts +14 -0
- package/dist/connection/databases/sourceCells.js +40 -0
- package/dist/connection/databases/sourceCells.js.map +7 -0
- package/dist/connection/databases/toRowView.d.ts +4 -0
- package/dist/connection/databases/toRowView.js +11 -0
- package/dist/connection/databases/toRowView.js.map +7 -0
- package/dist/connection/databases/useApiDatabaseSource.d.ts +11 -0
- package/dist/connection/databases/useApiDatabaseSource.js +473 -0
- package/dist/connection/databases/useApiDatabaseSource.js.map +7 -0
- package/dist/connection/databases/useApiViewStore.d.ts +5 -0
- package/dist/connection/databases/useApiViewStore.js +57 -0
- package/dist/connection/databases/useApiViewStore.js.map +7 -0
- package/dist/connection/databases/useDatabaseCellSources.d.ts +8 -1
- package/dist/connection/databases/useDatabaseCellSources.js +40 -5
- package/dist/connection/databases/useDatabaseCellSources.js.map +2 -2
- package/dist/connection/databases/useDeviceLayoutSettings.d.ts +6 -0
- package/dist/connection/databases/useDeviceLayoutSettings.js +57 -0
- package/dist/connection/databases/useDeviceLayoutSettings.js.map +7 -0
- package/dist/connection/databases/useLayoutRows.d.ts +13 -0
- package/dist/connection/databases/useLayoutRows.js +89 -0
- package/dist/connection/databases/useLayoutRows.js.map +7 -0
- package/dist/connection/databases/useSourceEntries.d.ts +6 -0
- package/dist/connection/databases/useSourceEntries.js +8 -0
- package/dist/connection/databases/useSourceEntries.js.map +7 -0
- package/dist/connection/databases/wireColumns.d.ts +17 -0
- package/dist/connection/databases/wireColumns.js +22 -0
- package/dist/connection/databases/wireColumns.js.map +7 -0
- package/dist/connection/facts/ConnectedFactsPage.d.ts +11 -1
- package/dist/connection/facts/ConnectedFactsPage.js +42 -10
- package/dist/connection/facts/ConnectedFactsPage.js.map +2 -2
- package/dist/connection/facts/FactMarkdownEditor.d.ts +19 -1
- package/dist/connection/facts/FactMarkdownEditor.js +67 -49
- package/dist/connection/facts/FactMarkdownEditor.js.map +2 -2
- package/dist/connection/facts/FactSourcesPopover.d.ts +3 -1
- package/dist/connection/facts/FactSourcesPopover.js +71 -61
- package/dist/connection/facts/FactSourcesPopover.js.map +2 -2
- package/dist/connection/facts/FactsQuickFilters.d.ts +16 -0
- package/dist/connection/facts/FactsQuickFilters.js +57 -0
- package/dist/connection/facts/FactsQuickFilters.js.map +7 -0
- package/dist/connection/facts/documentPickerGroups.d.ts +3 -0
- package/dist/connection/facts/documentPickerGroups.js +21 -0
- package/dist/connection/facts/documentPickerGroups.js.map +7 -0
- package/dist/connection/facts/factsRows.d.ts +49 -0
- package/dist/connection/facts/factsRows.js +103 -0
- package/dist/connection/facts/factsRows.js.map +7 -0
- package/dist/connection/facts/factsScope.d.ts +24 -0
- package/dist/connection/facts/factsScope.js +32 -0
- package/dist/connection/facts/factsScope.js.map +7 -0
- package/dist/connection/facts/factsSource.d.ts +12 -0
- package/dist/connection/facts/factsSource.js +1305 -0
- package/dist/connection/facts/factsSource.js.map +7 -0
- package/dist/connection/facts/useFactActions.d.ts +2 -2
- package/dist/connection/facts/useFactActions.js +4 -0
- package/dist/connection/facts/useFactActions.js.map +2 -2
- package/dist/connection/facts/useFactComposer.d.ts +8 -2
- package/dist/connection/facts/useFactComposer.js +36 -67
- package/dist/connection/facts/useFactComposer.js.map +2 -2
- package/dist/connection/facts/usePassageCollection.d.ts +21 -0
- package/dist/connection/facts/usePassageCollection.js +72 -0
- package/dist/connection/facts/usePassageCollection.js.map +7 -0
- package/dist/connection/facts/view-keys.d.ts +4 -0
- package/dist/connection/facts/view-keys.js +2 -0
- package/dist/connection/facts/view-keys.js.map +2 -2
- package/dist/connection/files/explorer/FileTiles.js +2 -2
- package/dist/connection/files/explorer/FileTiles.js.map +2 -2
- package/dist/connection/files/page/ConnectedFilesPage.js +4 -1
- package/dist/connection/files/page/ConnectedFilesPage.js.map +2 -2
- package/dist/connection/files/views/useTableViews.js +11 -3
- package/dist/connection/files/views/useTableViews.js.map +2 -2
- package/dist/connection/live-blocks/list-rows.d.ts +10 -0
- package/dist/connection/live-blocks/list-rows.js +12 -0
- package/dist/connection/live-blocks/list-rows.js.map +2 -2
- package/dist/connection/pages/TableViewBlock.js +2 -6
- package/dist/connection/pages/TableViewBlock.js.map +2 -2
- package/dist/connection/tags/ConnectedTagsPage.js +4 -1
- package/dist/connection/tags/ConnectedTagsPage.js.map +2 -2
- package/dist/connection/viewer/pdf/PdfPassageHighlights.d.ts +10 -2
- package/dist/connection/viewer/pdf/PdfPassageHighlights.js +57 -26
- package/dist/connection/viewer/pdf/PdfPassageHighlights.js.map +2 -2
- package/dist/connection/viewer/pdf/passageHighlights.d.ts +8 -0
- package/dist/connection/viewer/pdf/passageHighlights.js +15 -0
- package/dist/connection/viewer/pdf/passageHighlights.js.map +2 -2
- package/dist/connection/viewer/pdf/usePdfPassageHighlights.js +31 -5
- package/dist/connection/viewer/pdf/usePdfPassageHighlights.js.map +2 -2
- package/dist/connection/workspace-dashboard/ConnectedWorkspaceDashboard.d.ts +9 -2
- package/dist/connection/workspace-dashboard/ConnectedWorkspaceDashboard.js +16 -6
- package/dist/connection/workspace-dashboard/ConnectedWorkspaceDashboard.js.map +2 -2
- package/dist/dashboards/ConditionsEditor.d.ts +14 -1
- package/dist/dashboards/ConditionsEditor.js +45 -5
- package/dist/dashboards/ConditionsEditor.js.map +2 -2
- package/dist/dashboards/index.cjs +9 -9
- package/dist/databases/ColumnConfigFields.js +1 -1
- package/dist/databases/ColumnConfigFields.js.map +2 -2
- package/dist/databases/DatabaseColumnDialog.d.ts +6 -1
- package/dist/databases/DatabaseColumnDialog.js +44 -3
- package/dist/databases/DatabaseColumnDialog.js.map +2 -2
- package/dist/databases/DatabaseFilterMenu.d.ts +23 -1
- package/dist/databases/DatabaseFilterMenu.js +38 -7
- package/dist/databases/DatabaseFilterMenu.js.map +2 -2
- package/dist/databases/DatabaseList.d.ts +22 -1
- package/dist/databases/DatabaseList.js +44 -9
- package/dist/databases/DatabaseList.js.map +2 -2
- package/dist/databases/DatabaseRowDetail.d.ts +40 -3
- package/dist/databases/DatabaseRowDetail.js +124 -21
- package/dist/databases/DatabaseRowDetail.js.map +2 -2
- package/dist/databases/DatabaseTable.d.ts +44 -5
- package/dist/databases/DatabaseTable.js +165 -15
- package/dist/databases/DatabaseTable.js.map +2 -2
- package/dist/databases/DatabaseToolbar.d.ts +29 -3
- package/dist/databases/DatabaseToolbar.js +148 -96
- package/dist/databases/DatabaseToolbar.js.map +2 -2
- package/dist/databases/DateSpanEditor.d.ts +32 -0
- package/dist/databases/DateSpanEditor.js +155 -0
- package/dist/databases/DateSpanEditor.js.map +7 -0
- package/dist/databases/LabelChip.d.ts +6 -0
- package/dist/databases/LabelChip.js +34 -0
- package/dist/databases/LabelChip.js.map +7 -0
- package/dist/databases/LabelsCell.d.ts +13 -0
- package/dist/databases/LabelsCell.js +38 -0
- package/dist/databases/LabelsCell.js.map +7 -0
- package/dist/databases/LabelsField.d.ts +6 -0
- package/dist/databases/LabelsField.js +17 -0
- package/dist/databases/LabelsField.js.map +7 -0
- package/dist/databases/SourcesCell.d.ts +21 -0
- package/dist/databases/SourcesCell.js +106 -0
- package/dist/databases/SourcesCell.js.map +7 -0
- package/dist/databases/SourcesField.d.ts +7 -0
- package/dist/databases/SourcesField.js +36 -0
- package/dist/databases/SourcesField.js.map +7 -0
- package/dist/databases/column-kits.d.ts +28 -0
- package/dist/databases/column-kits.js +87 -0
- package/dist/databases/column-kits.js.map +7 -0
- package/dist/databases/column-types.d.ts +36 -4
- package/dist/databases/column-types.js +22 -3
- package/dist/databases/column-types.js.map +2 -2
- package/dist/databases/databaseColumns.d.ts +29 -2
- package/dist/databases/databaseColumns.js +180 -47
- package/dist/databases/databaseColumns.js.map +2 -2
- package/dist/databases/index.cjs +154 -76
- package/dist/databases/index.d.ts +12 -5
- package/dist/databases/index.js +17 -0
- package/dist/databases/index.js.map +2 -2
- package/dist/databases/layouts/DatabaseCalendar.d.ts +17 -0
- package/dist/databases/layouts/DatabaseCalendar.js +63 -0
- package/dist/databases/layouts/DatabaseCalendar.js.map +7 -0
- package/dist/databases/layouts/DatabaseGantt.d.ts +9 -0
- package/dist/databases/layouts/DatabaseGantt.js +52 -0
- package/dist/databases/layouts/DatabaseGantt.js.map +7 -0
- package/dist/databases/layouts/DatabaseLayoutSwitcher.d.ts +43 -0
- package/dist/databases/layouts/DatabaseLayoutSwitcher.js +190 -0
- package/dist/databases/layouts/DatabaseLayoutSwitcher.js.map +7 -0
- package/dist/databases/layouts/definitions.d.ts +11 -0
- package/dist/databases/layouts/definitions.js +56 -0
- package/dist/databases/layouts/definitions.js.map +7 -0
- package/dist/databases/layouts/index.d.ts +7 -0
- package/dist/databases/layouts/index.js +27 -0
- package/dist/databases/layouts/index.js.map +7 -0
- package/dist/databases/layouts/resolveLayoutSettings.d.ts +13 -0
- package/dist/databases/layouts/resolveLayoutSettings.js +47 -0
- package/dist/databases/layouts/resolveLayoutSettings.js.map +7 -0
- package/dist/databases/layouts/rowsToTimelineItems.d.ts +19 -0
- package/dist/databases/layouts/rowsToTimelineItems.js +81 -0
- package/dist/databases/layouts/rowsToTimelineItems.js.map +7 -0
- package/dist/databases/layouts/undated.d.ts +6 -0
- package/dist/databases/layouts/undated.js +10 -0
- package/dist/databases/layouts/undated.js.map +7 -0
- package/dist/databases/linkCells.d.ts +50 -1
- package/dist/databases/linkCells.js +28 -7
- package/dist/databases/linkCells.js.map +2 -2
- package/dist/databases/local-query.d.ts +7 -0
- package/dist/databases/local-query.js +89 -0
- package/dist/databases/local-query.js.map +7 -0
- package/dist/databases/source.d.ts +291 -0
- package/dist/databases/sourcesOverflow.d.ts +5 -0
- package/dist/databases/sourcesOverflow.js +10 -0
- package/dist/databases/sourcesOverflow.js.map +7 -0
- package/dist/docx/index.cjs +40 -39
- package/dist/embed/index.cjs +24 -21
- package/dist/facts/FactDateInput.d.ts +3 -1
- package/dist/facts/FactDateInput.js +110 -93
- package/dist/facts/FactDateInput.js.map +2 -2
- package/dist/facts/FactLabelsCell.d.ts +4 -0
- package/dist/facts/FactLabelsCell.js +27 -13
- package/dist/facts/FactLabelsCell.js.map +2 -2
- package/dist/facts/FactPassages.d.ts +6 -1
- package/dist/facts/FactPassages.js +6 -1
- package/dist/facts/FactPassages.js.map +2 -2
- package/dist/facts/FactsScopeEmpty.d.ts +8 -0
- package/dist/facts/FactsScopeEmpty.js +29 -0
- package/dist/facts/FactsScopeEmpty.js.map +7 -0
- package/dist/facts/FactsScopePicker.d.ts +33 -0
- package/dist/facts/FactsScopePicker.js +108 -0
- package/dist/facts/FactsScopePicker.js.map +7 -0
- package/dist/facts/index.cjs +105 -94
- package/dist/facts/index.cjs.map +1 -1
- package/dist/facts/index.d.ts +1 -0
- package/dist/facts/index.js +6 -0
- package/dist/facts/index.js.map +2 -2
- package/dist/files/ExplorerTile.d.ts +2 -2
- package/dist/files/ExplorerTile.js +3 -3
- package/dist/files/ExplorerTile.js.map +1 -1
- package/dist/files/HtmlViewerParts.js +7 -1
- package/dist/files/HtmlViewerParts.js.map +2 -2
- package/dist/files/folders/DocumentsFolderButton.d.ts +3 -1
- package/dist/files/folders/DocumentsFolderButton.js +3 -1
- package/dist/files/folders/DocumentsFolderButton.js.map +2 -2
- package/dist/files/folders/FolderTreePicker.d.ts +3 -1
- package/dist/files/folders/FolderTreePicker.js +23 -3
- package/dist/files/folders/FolderTreePicker.js.map +2 -2
- package/dist/files/index.cjs +251 -249
- package/dist/files/views/gridViews.d.ts +2 -0
- package/dist/files/views/gridViews.js.map +2 -2
- package/dist/home/index.cjs +10 -10
- package/dist/index.cjs +815 -803
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +2 -2
- package/dist/lib/pointer-hover.d.ts +11 -0
- package/dist/lib/pointer-hover.js +36 -0
- package/dist/lib/pointer-hover.js.map +7 -0
- package/dist/pages/index.cjs +36 -32
- package/dist/pages/index.cjs.map +1 -1
- package/dist/settings/TriStateChips.d.ts +24 -0
- package/dist/settings/TriStateChips.js +124 -0
- package/dist/settings/TriStateChips.js.map +7 -0
- package/dist/settings/index.cjs +137 -137
- package/dist/shell/index.cjs +1 -1
- package/dist/site/index.cjs +32 -31
- package/dist/studio/index.cjs +12 -12
- package/dist/styles.css +1 -1
- package/dist/timeline/TimelineCalendar.js +2 -1
- package/dist/timeline/TimelineCalendar.js.map +2 -2
- package/dist/timeline/TimelineGantt.d.ts +6 -1
- package/dist/timeline/TimelineGantt.js +34 -8
- package/dist/timeline/TimelineGantt.js.map +2 -2
- package/dist/timeline/index.cjs +13 -12
- package/dist/workflow-canvas/index.cjs +32 -30
- package/dist/workflow-canvas/index.cjs.map +1 -1
- package/dist/workspaces/index.cjs +5 -5
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/src/components/grid.css +23 -1
- package/dist/DocumentReviewCard-RPHIQZ2Y.cjs.map +0 -1
- package/dist/FilesViewerDialog-PZ5H435S.cjs.map +0 -1
- package/dist/ai-XIT4MY3S.cjs.map +0 -1
- package/dist/chunk-2D5GZMSK.cjs.map +0 -1
- package/dist/chunk-ADMNU2CR.cjs.map +0 -1
- package/dist/chunk-BQOL4XNZ.cjs.map +0 -1
- package/dist/chunk-CYMAF656.cjs.map +0 -1
- package/dist/chunk-DDWLMYRO.cjs.map +0 -1
- package/dist/chunk-FUKN3PI5.cjs.map +0 -1
- package/dist/chunk-JITYC4OS.cjs.map +0 -1
- package/dist/chunk-MWHVETKN.cjs.map +0 -1
- package/dist/chunk-MZ7IUHQA.cjs.map +0 -1
- package/dist/chunk-N33U2SB5.cjs +0 -982
- package/dist/chunk-N33U2SB5.cjs.map +0 -1
- package/dist/chunk-TJY7XPDE.cjs.map +0 -1
- package/dist/chunk-TUURH4NE.cjs +0 -18
- package/dist/chunk-UTYEXDJK.cjs +0 -1396
- package/dist/chunk-UTYEXDJK.cjs.map +0 -1
- package/dist/chunk-YC72ZCV4.cjs.map +0 -1
|
@@ -0,0 +1,3756 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunkHUAABZ2C_cjs = require('./chunk-HUAABZ2C.cjs');
|
|
5
|
+
var chunkGISMY7J7_cjs = require('./chunk-GISMY7J7.cjs');
|
|
6
|
+
var chunkV5P5MRSR_cjs = require('./chunk-V5P5MRSR.cjs');
|
|
7
|
+
var chunkSNUBQMIS_cjs = require('./chunk-SNUBQMIS.cjs');
|
|
8
|
+
var chunkLIJB6XOR_cjs = require('./chunk-LIJB6XOR.cjs');
|
|
9
|
+
var chunkU46OGRCO_cjs = require('./chunk-U46OGRCO.cjs');
|
|
10
|
+
var chunk66IOCKWS_cjs = require('./chunk-66IOCKWS.cjs');
|
|
11
|
+
var chunkZVEW3JBT_cjs = require('./chunk-ZVEW3JBT.cjs');
|
|
12
|
+
var chunkPPCATBOY_cjs = require('./chunk-PPCATBOY.cjs');
|
|
13
|
+
var chunkPLIF5CUV_cjs = require('./chunk-PLIF5CUV.cjs');
|
|
14
|
+
var lucideReact = require('lucide-react');
|
|
15
|
+
var ui = require('@arbidocs/react/ui');
|
|
16
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
17
|
+
var react = require('react');
|
|
18
|
+
|
|
19
|
+
var isId = (v) => typeof v === "string" && v.trim() !== "";
|
|
20
|
+
var asList = (v) => Array.isArray(v) ? v : [];
|
|
21
|
+
var labelIds = (v) => asList(v).filter(isId);
|
|
22
|
+
var citations = (v) => asList(v).filter(
|
|
23
|
+
(c) => typeof c === "object" && c !== null && isId(c.doc_ext_id)
|
|
24
|
+
);
|
|
25
|
+
var nameOf = (id, row) => row.titles?.[id] ?? id;
|
|
26
|
+
var byText = (a, b) => a.localeCompare(b, void 0, { sensitivity: "base", numeric: true });
|
|
27
|
+
var emptiesLast = (ea, eb) => ea !== eb ? ea ? 1 : -1 : ea ? 0 : void 0;
|
|
28
|
+
var labelNames = (v, row) => labelIds(v).map((id) => nameOf(id, row)).join("; ");
|
|
29
|
+
var pagesOf = (c) => {
|
|
30
|
+
const pages = [];
|
|
31
|
+
for (const chunk of c.chunks ?? [])
|
|
32
|
+
if (typeof chunk.page === "number" && !pages.includes(chunk.page)) pages.push(chunk.page);
|
|
33
|
+
return pages;
|
|
34
|
+
};
|
|
35
|
+
var sameCitation = (a, b) => {
|
|
36
|
+
if (a.doc_ext_id !== b.doc_ext_id || (a.version ?? null) !== (b.version ?? null)) return false;
|
|
37
|
+
const ca = a.chunks ?? [];
|
|
38
|
+
const cb = b.chunks ?? [];
|
|
39
|
+
return ca.length === cb.length && ca.every((c, i) => c.chunk_id === cb[i].chunk_id && (c.page ?? null) === (cb[i].page ?? null));
|
|
40
|
+
};
|
|
41
|
+
var labelKit = {
|
|
42
|
+
icon: lucideReact.Tags,
|
|
43
|
+
width: 200,
|
|
44
|
+
labelKey: "label",
|
|
45
|
+
empty: (v) => labelIds(v).length === 0,
|
|
46
|
+
same: (a, b) => {
|
|
47
|
+
const sa = new Set(labelIds(a));
|
|
48
|
+
const sb = new Set(labelIds(b));
|
|
49
|
+
return sa.size === sb.size && [...sa].every((id) => sb.has(id));
|
|
50
|
+
},
|
|
51
|
+
format: (v, row) => labelNames(v, row),
|
|
52
|
+
toApi: (v) => {
|
|
53
|
+
const ids = [...new Set(labelIds(v))];
|
|
54
|
+
return ids.length > 0 ? ids : null;
|
|
55
|
+
},
|
|
56
|
+
compare: (a, b, ra, rb) => emptiesLast(labelKit.empty(a), labelKit.empty(b)) ?? byText(labelNames(a, ra), labelNames(b, rb)),
|
|
57
|
+
filterOps: ["contains", "neq", "empty", "not_empty"],
|
|
58
|
+
filterInput: "label",
|
|
59
|
+
canEditInGrid: (_c, s) => Boolean(s?.labels)
|
|
60
|
+
};
|
|
61
|
+
var sourceKit = {
|
|
62
|
+
icon: lucideReact.BookMarked,
|
|
63
|
+
width: 240,
|
|
64
|
+
labelKey: "source",
|
|
65
|
+
empty: (v) => citations(v).length === 0,
|
|
66
|
+
same: (a, b) => {
|
|
67
|
+
const la = citations(a);
|
|
68
|
+
const lb = citations(b);
|
|
69
|
+
return la.length === lb.length && la.every((c, i) => sameCitation(c, lb[i]));
|
|
70
|
+
},
|
|
71
|
+
format: (v, row) => citations(v).map((c) => {
|
|
72
|
+
const pages = pagesOf(c);
|
|
73
|
+
const name = nameOf(c.doc_ext_id, row);
|
|
74
|
+
return pages.length > 0 ? `${name} (${pages.map((p) => `p.${p}`).join(", ")})` : name;
|
|
75
|
+
}).join("; "),
|
|
76
|
+
toApi: (v) => {
|
|
77
|
+
const kept = citations(v);
|
|
78
|
+
return kept.length > 0 ? kept : null;
|
|
79
|
+
},
|
|
80
|
+
compare: (a, b, ra, rb) => {
|
|
81
|
+
const empty = emptiesLast(sourceKit.empty(a), sourceKit.empty(b));
|
|
82
|
+
if (empty !== void 0) return empty;
|
|
83
|
+
const ca = citations(a);
|
|
84
|
+
const cb = citations(b);
|
|
85
|
+
if (ca.length !== cb.length) return ca.length - cb.length;
|
|
86
|
+
return byText(nameOf(ca[0].doc_ext_id, ra), nameOf(cb[0].doc_ext_id, rb));
|
|
87
|
+
},
|
|
88
|
+
filterOps: ["contains", "empty", "not_empty"],
|
|
89
|
+
filterInput: "document",
|
|
90
|
+
canEditInGrid: () => false
|
|
91
|
+
};
|
|
92
|
+
var COLUMN_KITS = {
|
|
93
|
+
label: labelKit,
|
|
94
|
+
source: sourceKit
|
|
95
|
+
};
|
|
96
|
+
function kitOf(type) {
|
|
97
|
+
return type === "label" || type === "source" ? COLUMN_KITS[type] : void 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// src/databases/column-types.ts
|
|
101
|
+
var DATABASE_COLUMN_TYPES = [
|
|
102
|
+
"text",
|
|
103
|
+
"number",
|
|
104
|
+
"date",
|
|
105
|
+
"checkbox",
|
|
106
|
+
"select",
|
|
107
|
+
"person",
|
|
108
|
+
"document",
|
|
109
|
+
"relation",
|
|
110
|
+
"lookup",
|
|
111
|
+
"rollup"
|
|
112
|
+
];
|
|
113
|
+
var COMPUTED_COLUMN_TYPES = /* @__PURE__ */ new Set([
|
|
114
|
+
"lookup",
|
|
115
|
+
"rollup"
|
|
116
|
+
]);
|
|
117
|
+
var LINK_COLUMN_TYPES = /* @__PURE__ */ new Set([
|
|
118
|
+
"document",
|
|
119
|
+
"relation"
|
|
120
|
+
]);
|
|
121
|
+
var isComputedColumn = (column) => COMPUTED_COLUMN_TYPES.has(column.type);
|
|
122
|
+
var DATABASE_ROLLUP_OPS = ["count", "sum", "avg", "min", "max"];
|
|
123
|
+
var DEFAULT_DATABASE_COLUMN_TYPE_LABELS = {
|
|
124
|
+
text: "Text",
|
|
125
|
+
number: "Number",
|
|
126
|
+
date: "Date",
|
|
127
|
+
checkbox: "Checkbox",
|
|
128
|
+
select: "Select",
|
|
129
|
+
person: "Person",
|
|
130
|
+
// The same name as a `source` column: both hold a row's sources. A `document` column holds the
|
|
131
|
+
// documents; a `source` column also holds the passages cited in each.
|
|
132
|
+
document: "Sources",
|
|
133
|
+
relation: "Relation",
|
|
134
|
+
lookup: "Lookup",
|
|
135
|
+
rollup: "Rollup",
|
|
136
|
+
label: "Labels",
|
|
137
|
+
source: "Sources"
|
|
138
|
+
};
|
|
139
|
+
var OPTION_TONES = [
|
|
140
|
+
"bg-blue-bg text-blue-text",
|
|
141
|
+
"bg-green-bg text-green-text",
|
|
142
|
+
"bg-yellow-bg text-yellow-text",
|
|
143
|
+
"bg-purple-bg text-purple-text",
|
|
144
|
+
"bg-red-bg text-red-text",
|
|
145
|
+
"bg-gray-bg text-gray-text"
|
|
146
|
+
];
|
|
147
|
+
function optionTone(option) {
|
|
148
|
+
let hash = 0;
|
|
149
|
+
for (const ch of option.toLowerCase()) hash = hash * 31 + ch.charCodeAt(0) >>> 0;
|
|
150
|
+
return OPTION_TONES[hash % OPTION_TONES.length];
|
|
151
|
+
}
|
|
152
|
+
var isEmpty = (value) => value === null || value === void 0 || typeof value === "string" && value.trim() === "" || Array.isArray(value) && value.length === 0;
|
|
153
|
+
function cellList(value) {
|
|
154
|
+
if (isEmpty(value)) return [];
|
|
155
|
+
return Array.isArray(value) ? value.filter((v) => !isEmpty(v)) : [value];
|
|
156
|
+
}
|
|
157
|
+
function cellIds(value) {
|
|
158
|
+
return cellList(value).filter((v) => typeof v === "string");
|
|
159
|
+
}
|
|
160
|
+
function titleOf(id, titles) {
|
|
161
|
+
return titles?.[id] ?? id;
|
|
162
|
+
}
|
|
163
|
+
function sameCellValue(a, b, type) {
|
|
164
|
+
const kit = type ? kitOf(type) : void 0;
|
|
165
|
+
if (kit) return kit.same(a, b);
|
|
166
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
167
|
+
const la = cellList(a);
|
|
168
|
+
const lb = cellList(b);
|
|
169
|
+
return la.length === lb.length && la.every((v, i) => v === lb[i]);
|
|
170
|
+
}
|
|
171
|
+
return (a ?? null) === (b ?? null);
|
|
172
|
+
}
|
|
173
|
+
var kitRow = (titles) => ({
|
|
174
|
+
id: "",
|
|
175
|
+
values: {},
|
|
176
|
+
titles
|
|
177
|
+
});
|
|
178
|
+
var kitColumn = (type) => ({ id: "", name: "", type });
|
|
179
|
+
function formatDateValue(value, locale) {
|
|
180
|
+
const day = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
181
|
+
if (day) {
|
|
182
|
+
const [, y, m, d] = day;
|
|
183
|
+
return new Date(Date.UTC(+y, +m - 1, +d)).toLocaleDateString(locale, { timeZone: "UTC" });
|
|
184
|
+
}
|
|
185
|
+
const at = new Date(value);
|
|
186
|
+
return Number.isNaN(at.getTime()) ? value : at.toLocaleString(locale);
|
|
187
|
+
}
|
|
188
|
+
function formatNumberValue(value, locale) {
|
|
189
|
+
return value.toLocaleString(locale, { maximumFractionDigits: 6 });
|
|
190
|
+
}
|
|
191
|
+
var ISO_DATE = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;
|
|
192
|
+
function formatLookupValue(value, titles, locale) {
|
|
193
|
+
if (isEmpty(value)) return "";
|
|
194
|
+
if (typeof value === "number") return formatNumberValue(value, locale);
|
|
195
|
+
if (typeof value === "boolean") return value ? "Yes" : "No";
|
|
196
|
+
if (typeof value === "string") {
|
|
197
|
+
if (titles?.[value] !== void 0) return titles[value];
|
|
198
|
+
if (ISO_DATE.test(value)) return formatDateValue(value, locale);
|
|
199
|
+
}
|
|
200
|
+
return String(value);
|
|
201
|
+
}
|
|
202
|
+
var NAMED_TYPES = /* @__PURE__ */ new Set([
|
|
203
|
+
"person",
|
|
204
|
+
"document",
|
|
205
|
+
"relation"
|
|
206
|
+
]);
|
|
207
|
+
function formatCell(value, type, locale, titles) {
|
|
208
|
+
if (isEmpty(value)) return "";
|
|
209
|
+
const kit = kitOf(type);
|
|
210
|
+
if (kit) return kit.format(value, kitRow(titles), kitColumn(type));
|
|
211
|
+
if ((type === "number" || type === "rollup") && typeof value === "number")
|
|
212
|
+
return formatNumberValue(value, locale);
|
|
213
|
+
if (type === "date" && typeof value === "string") return formatDateValue(value, locale);
|
|
214
|
+
if (type === "checkbox") return value ? "Yes" : "No";
|
|
215
|
+
if (NAMED_TYPES.has(type))
|
|
216
|
+
return cellIds(value).map((id) => titleOf(id, titles)).join(", ");
|
|
217
|
+
if (type === "lookup")
|
|
218
|
+
return cellList(value).map((v) => formatLookupValue(v, titles, locale)).join(", ");
|
|
219
|
+
return String(value);
|
|
220
|
+
}
|
|
221
|
+
function toApiValue(value, type) {
|
|
222
|
+
if (isEmpty(value)) return null;
|
|
223
|
+
const kit = kitOf(type);
|
|
224
|
+
if (kit) return kit.toApi(value);
|
|
225
|
+
if (LINK_COLUMN_TYPES.has(type)) return cellIds(value);
|
|
226
|
+
if (type === "checkbox") return Boolean(value);
|
|
227
|
+
if (type === "date" && value instanceof Date) {
|
|
228
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
229
|
+
return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}`;
|
|
230
|
+
}
|
|
231
|
+
if (type === "number" && typeof value === "string") {
|
|
232
|
+
const n = Number(value.replace(/,/g, ""));
|
|
233
|
+
return Number.isFinite(n) ? n : value;
|
|
234
|
+
}
|
|
235
|
+
return value;
|
|
236
|
+
}
|
|
237
|
+
function compareCells(a, b, type, titlesA, titlesB) {
|
|
238
|
+
const ea = isEmpty(a);
|
|
239
|
+
const eb = isEmpty(b);
|
|
240
|
+
if (ea || eb) return ea === eb ? 0 : ea ? 1 : -1;
|
|
241
|
+
const kit = kitOf(type);
|
|
242
|
+
if (kit) return kit.compare(a, b, kitRow(titlesA), kitRow(titlesB));
|
|
243
|
+
if (type === "number" || type === "checkbox" || type === "rollup") return Number(a) - Number(b);
|
|
244
|
+
const shown = NAMED_TYPES.has(type) || type === "lookup";
|
|
245
|
+
const ta = shown ? formatCell(a, type, void 0, titlesA) : String(a);
|
|
246
|
+
const tb = shown ? formatCell(b, type, void 0, titlesB) : String(b);
|
|
247
|
+
return ta.localeCompare(tb, void 0, { sensitivity: "base", numeric: true });
|
|
248
|
+
}
|
|
249
|
+
function rowTitle(row, columns, locale) {
|
|
250
|
+
const first = columns[0];
|
|
251
|
+
return first ? formatCell(row.values[first.id], first.type, locale, row.titles) : "";
|
|
252
|
+
}
|
|
253
|
+
function labelSourceFor(labels, column) {
|
|
254
|
+
if (!labels) return void 0;
|
|
255
|
+
const kinds = column.options?.length ? column.options : ["label"];
|
|
256
|
+
if (!labels.options.some((o) => o.kind)) return labels;
|
|
257
|
+
return {
|
|
258
|
+
options: labels.options.filter((o) => !o.kind || kinds.includes(o.kind)),
|
|
259
|
+
onCreate: kinds.includes("label") ? labels.onCreate : async () => void 0
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
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";
|
|
263
|
+
function initials(name) {
|
|
264
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
265
|
+
const letters = parts.length > 1 ? parts[0][0] + parts[parts.length - 1][0] : name.slice(0, 2);
|
|
266
|
+
return letters.toUpperCase();
|
|
267
|
+
}
|
|
268
|
+
function PersonChip({ name }) {
|
|
269
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex min-w-0 items-center gap-1.5 text-sm", children: [
|
|
270
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
271
|
+
"span",
|
|
272
|
+
{
|
|
273
|
+
"aria-hidden": true,
|
|
274
|
+
className: "flex size-5 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-medium text-muted-foreground",
|
|
275
|
+
children: initials(name)
|
|
276
|
+
}
|
|
277
|
+
),
|
|
278
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: name })
|
|
279
|
+
] });
|
|
280
|
+
}
|
|
281
|
+
function LinkChip({
|
|
282
|
+
label,
|
|
283
|
+
kind,
|
|
284
|
+
onOpen,
|
|
285
|
+
testId,
|
|
286
|
+
openLabel,
|
|
287
|
+
className,
|
|
288
|
+
suffix
|
|
289
|
+
}) {
|
|
290
|
+
const Icon = kind === "document" ? lucideReact.FileText : lucideReact.ArrowUpRight;
|
|
291
|
+
const full = suffix ? `${label} ${suffix}` : label;
|
|
292
|
+
const body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
293
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-3 shrink-0 text-muted-foreground", "aria-hidden": true }),
|
|
294
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: label }),
|
|
295
|
+
suffix && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 tabular-nums text-muted-foreground", "data-slot": "chip-suffix", children: ` ${suffix}` })
|
|
296
|
+
] });
|
|
297
|
+
if (!onOpen) {
|
|
298
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: ui.cn(CHIP, className), title: full, "data-testid": testId, children: body });
|
|
299
|
+
}
|
|
300
|
+
const stop = (e) => e.stopPropagation();
|
|
301
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
302
|
+
"button",
|
|
303
|
+
{
|
|
304
|
+
type: "button",
|
|
305
|
+
title: full,
|
|
306
|
+
"aria-label": openLabel,
|
|
307
|
+
"data-testid": testId,
|
|
308
|
+
onClick: (e) => {
|
|
309
|
+
e.stopPropagation();
|
|
310
|
+
onOpen();
|
|
311
|
+
},
|
|
312
|
+
onDoubleClick: stop,
|
|
313
|
+
onMouseDown: stop,
|
|
314
|
+
className: ui.cn(CHIP, "hover:bg-muted hover:underline", className),
|
|
315
|
+
children: body
|
|
316
|
+
}
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
function ChipRow({ children, wrap }) {
|
|
320
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
321
|
+
"span",
|
|
322
|
+
{
|
|
323
|
+
className: ui.cn(
|
|
324
|
+
"flex min-w-0 items-center gap-1",
|
|
325
|
+
wrap ? "flex-wrap py-0.5" : "h-full overflow-hidden"
|
|
326
|
+
),
|
|
327
|
+
children
|
|
328
|
+
}
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
function PersonCell({ value, titles }) {
|
|
332
|
+
const [id] = cellIds(value);
|
|
333
|
+
return id ? /* @__PURE__ */ jsxRuntime.jsx(PersonChip, { name: titleOf(id, titles) }) : null;
|
|
334
|
+
}
|
|
335
|
+
function LinkChipsCell({
|
|
336
|
+
value,
|
|
337
|
+
titles,
|
|
338
|
+
kind,
|
|
339
|
+
onOpenDocument,
|
|
340
|
+
wrap
|
|
341
|
+
}) {
|
|
342
|
+
const ids = cellIds(value);
|
|
343
|
+
if (ids.length === 0) return null;
|
|
344
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ChipRow, { wrap, children: ids.map((id) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
345
|
+
LinkChip,
|
|
346
|
+
{
|
|
347
|
+
label: titleOf(id, titles),
|
|
348
|
+
kind,
|
|
349
|
+
testId: `database-chip-${id}`,
|
|
350
|
+
onOpen: kind === "document" && onOpenDocument ? () => onOpenDocument(id) : void 0
|
|
351
|
+
},
|
|
352
|
+
id
|
|
353
|
+
)) });
|
|
354
|
+
}
|
|
355
|
+
function LookupCell({
|
|
356
|
+
value,
|
|
357
|
+
titles,
|
|
358
|
+
locale,
|
|
359
|
+
wrap
|
|
360
|
+
}) {
|
|
361
|
+
const values = cellList(value);
|
|
362
|
+
if (values.length === 0) return null;
|
|
363
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ChipRow, { wrap, children: values.map((v, i) => {
|
|
364
|
+
const text = formatLookupValue(v, titles, locale);
|
|
365
|
+
const key = `${i}-${text}`;
|
|
366
|
+
if (typeof v === "string" && /^doc-/.test(v))
|
|
367
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LinkChip, { label: text, kind: "document" }, key);
|
|
368
|
+
if (typeof v === "string" && /^dbr-/.test(v))
|
|
369
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LinkChip, { label: text, kind: "relation" }, key);
|
|
370
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
371
|
+
"span",
|
|
372
|
+
{
|
|
373
|
+
title: text,
|
|
374
|
+
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",
|
|
375
|
+
children: text
|
|
376
|
+
},
|
|
377
|
+
key
|
|
378
|
+
);
|
|
379
|
+
}) });
|
|
380
|
+
}
|
|
381
|
+
var MAX_SHOWN = 50;
|
|
382
|
+
var SEARCH_DEBOUNCE_MS = 200;
|
|
383
|
+
var DEFAULT_PICK_CELL_EDITOR_LABELS = {
|
|
384
|
+
searchPlaceholder: "Search\u2026",
|
|
385
|
+
noMatches: "No matches",
|
|
386
|
+
searching: "Searching\u2026",
|
|
387
|
+
clear: "Clear",
|
|
388
|
+
done: "Done",
|
|
389
|
+
remove: (label) => `Remove ${label}`
|
|
390
|
+
};
|
|
391
|
+
function useChoices(query, options, search) {
|
|
392
|
+
const [found, setFound] = react.useState([]);
|
|
393
|
+
const [loading, setLoading] = react.useState(Boolean(search));
|
|
394
|
+
react.useEffect(() => {
|
|
395
|
+
if (!search) return;
|
|
396
|
+
let live = true;
|
|
397
|
+
setLoading(true);
|
|
398
|
+
const t = setTimeout(
|
|
399
|
+
() => {
|
|
400
|
+
search(query.trim()).then((rows) => live && setFound(rows)).catch(() => live && setFound([])).finally(() => live && setLoading(false));
|
|
401
|
+
},
|
|
402
|
+
query ? SEARCH_DEBOUNCE_MS : 0
|
|
403
|
+
);
|
|
404
|
+
return () => {
|
|
405
|
+
live = false;
|
|
406
|
+
clearTimeout(t);
|
|
407
|
+
};
|
|
408
|
+
}, [query, search]);
|
|
409
|
+
const filtered = react.useMemo(() => {
|
|
410
|
+
if (search) return found.slice(0, MAX_SHOWN);
|
|
411
|
+
const q = query.trim().toLowerCase();
|
|
412
|
+
const all = options ?? [];
|
|
413
|
+
const hits = q ? all.filter(
|
|
414
|
+
(o) => o.label.toLowerCase().includes(q) || (o.description ?? "").toLowerCase().includes(q)
|
|
415
|
+
) : all;
|
|
416
|
+
return hits.slice(0, MAX_SHOWN);
|
|
417
|
+
}, [found, options, query, search]);
|
|
418
|
+
return { choices: filtered, loading: Boolean(search) && loading };
|
|
419
|
+
}
|
|
420
|
+
function PickCellEditor(props) {
|
|
421
|
+
const { value, onValueChange, stopEditing, data, kind, options, search } = props;
|
|
422
|
+
const l = { ...DEFAULT_PICK_CELL_EDITOR_LABELS, ...props.labels };
|
|
423
|
+
const multiple = kind !== "person";
|
|
424
|
+
const [chosen, setChosen] = react.useState(() => cellIds(value));
|
|
425
|
+
const [query, setQuery] = react.useState("");
|
|
426
|
+
const [active, setActive] = react.useState(0);
|
|
427
|
+
const input = react.useRef(null);
|
|
428
|
+
const { choices, loading } = useChoices(query, options, search);
|
|
429
|
+
const names = react.useRef({ ...data?.titles ?? {} });
|
|
430
|
+
for (const o of options ?? []) names.current[o.id] ??= o.label;
|
|
431
|
+
for (const o of choices) names.current[o.id] = o.label;
|
|
432
|
+
const nameOf2 = (id) => names.current[id] ?? id;
|
|
433
|
+
react.useEffect(() => input.current?.focus(), []);
|
|
434
|
+
react.useEffect(() => setActive(0), [query]);
|
|
435
|
+
const commit = (ids) => {
|
|
436
|
+
setChosen(ids);
|
|
437
|
+
if (data) {
|
|
438
|
+
const titles = { ...data.titles ?? {} };
|
|
439
|
+
for (const id of ids) titles[id] ??= nameOf2(id);
|
|
440
|
+
data.titles = titles;
|
|
441
|
+
}
|
|
442
|
+
onValueChange(multiple ? ids : ids[0] ?? null);
|
|
443
|
+
};
|
|
444
|
+
const close = () => setTimeout(() => stopEditing(), 0);
|
|
445
|
+
const toggle = (id) => {
|
|
446
|
+
if (!multiple) {
|
|
447
|
+
commit([id]);
|
|
448
|
+
close();
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
commit(chosen.includes(id) ? chosen.filter((x) => x !== id) : [...chosen, id]);
|
|
452
|
+
};
|
|
453
|
+
const onKeyDown = (e) => {
|
|
454
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
455
|
+
e.preventDefault();
|
|
456
|
+
e.stopPropagation();
|
|
457
|
+
if (choices.length === 0) return;
|
|
458
|
+
const step = e.key === "ArrowDown" ? 1 : -1;
|
|
459
|
+
setActive((i) => (i + step + choices.length) % choices.length);
|
|
460
|
+
} else if (e.key === "Enter") {
|
|
461
|
+
e.preventDefault();
|
|
462
|
+
e.stopPropagation();
|
|
463
|
+
const pick = choices[active];
|
|
464
|
+
if (pick) toggle(pick.id);
|
|
465
|
+
else if (multiple) close();
|
|
466
|
+
} else if (e.key === "Backspace" && multiple && !query && chosen.length > 0) {
|
|
467
|
+
commit(chosen.slice(0, -1));
|
|
468
|
+
} else if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home" || e.key === "End") {
|
|
469
|
+
e.stopPropagation();
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
473
|
+
"div",
|
|
474
|
+
{
|
|
475
|
+
"data-testid": "database-pick-editor",
|
|
476
|
+
className: "flex w-72 flex-col rounded-md border border-border bg-popover shadow-md",
|
|
477
|
+
children: [
|
|
478
|
+
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: [
|
|
479
|
+
/* @__PURE__ */ jsxRuntime.jsx(LinkChip, { label: nameOf2(id), kind: kind === "document" ? "document" : "relation" }),
|
|
480
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
481
|
+
"button",
|
|
482
|
+
{
|
|
483
|
+
type: "button",
|
|
484
|
+
"aria-label": l.remove(nameOf2(id)),
|
|
485
|
+
onClick: () => commit(chosen.filter((x) => x !== id)),
|
|
486
|
+
"data-testid": `database-pick-remove-${id}`,
|
|
487
|
+
className: "rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
488
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "size-3" })
|
|
489
|
+
}
|
|
490
|
+
)
|
|
491
|
+
] }, id)) }),
|
|
492
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 border-b border-border px-2", children: [
|
|
493
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": true }),
|
|
494
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
495
|
+
"input",
|
|
496
|
+
{
|
|
497
|
+
ref: input,
|
|
498
|
+
value: query,
|
|
499
|
+
placeholder: l.searchPlaceholder,
|
|
500
|
+
onChange: (e) => setQuery(e.target.value),
|
|
501
|
+
onKeyDown,
|
|
502
|
+
"data-testid": "database-pick-search",
|
|
503
|
+
className: "h-8 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
|
|
504
|
+
}
|
|
505
|
+
),
|
|
506
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-3.5 animate-spin text-muted-foreground" })
|
|
507
|
+
] }),
|
|
508
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { role: "listbox", "aria-multiselectable": multiple, className: "max-h-64 overflow-y-auto p-1", children: [
|
|
509
|
+
choices.map((o, i) => {
|
|
510
|
+
const isChosen = chosen.includes(o.id);
|
|
511
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
512
|
+
"button",
|
|
513
|
+
{
|
|
514
|
+
type: "button",
|
|
515
|
+
role: "option",
|
|
516
|
+
"aria-selected": isChosen,
|
|
517
|
+
onMouseEnter: () => setActive(i),
|
|
518
|
+
onClick: () => toggle(o.id),
|
|
519
|
+
"data-testid": `database-pick-option-${o.id}`,
|
|
520
|
+
className: ui.cn(
|
|
521
|
+
"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-sm",
|
|
522
|
+
i === active && "bg-muted"
|
|
523
|
+
),
|
|
524
|
+
children: [
|
|
525
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
526
|
+
kind === "person" ? /* @__PURE__ */ jsxRuntime.jsx(PersonChip, { name: o.label }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: o.label }),
|
|
527
|
+
o.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs text-muted-foreground", children: o.description })
|
|
528
|
+
] }),
|
|
529
|
+
isChosen && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "size-3.5 shrink-0" })
|
|
530
|
+
]
|
|
531
|
+
},
|
|
532
|
+
o.id
|
|
533
|
+
);
|
|
534
|
+
}),
|
|
535
|
+
choices.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-2 py-1.5 text-sm text-muted-foreground", children: loading ? l.searching : l.noMatches })
|
|
536
|
+
] }),
|
|
537
|
+
(multiple || chosen.length > 0) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end border-t border-border p-1", children: !multiple ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
538
|
+
"button",
|
|
539
|
+
{
|
|
540
|
+
type: "button",
|
|
541
|
+
onClick: () => {
|
|
542
|
+
commit([]);
|
|
543
|
+
close();
|
|
544
|
+
},
|
|
545
|
+
"data-testid": "database-pick-clear",
|
|
546
|
+
className: "rounded px-2 py-1 text-sm text-muted-foreground hover:bg-muted",
|
|
547
|
+
children: l.clear
|
|
548
|
+
}
|
|
549
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
550
|
+
"button",
|
|
551
|
+
{
|
|
552
|
+
type: "button",
|
|
553
|
+
onClick: close,
|
|
554
|
+
"data-testid": "database-pick-done",
|
|
555
|
+
className: "rounded px-2 py-1 text-sm font-medium hover:bg-muted",
|
|
556
|
+
children: l.done
|
|
557
|
+
}
|
|
558
|
+
) })
|
|
559
|
+
]
|
|
560
|
+
}
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
var optionTestId = (id) => `database-label-option-${id}`;
|
|
564
|
+
function LabelsCell({ value, titles, labels, onChange, rowHeight }) {
|
|
565
|
+
const ids = cellIds(value);
|
|
566
|
+
if (labels && onChange) {
|
|
567
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
568
|
+
chunkHUAABZ2C_cjs.FactLabelsCell,
|
|
569
|
+
{
|
|
570
|
+
options: labels.options,
|
|
571
|
+
selectedIds: ids,
|
|
572
|
+
onChange,
|
|
573
|
+
onCreate: labels.onCreate,
|
|
574
|
+
rowHeight,
|
|
575
|
+
compact: true,
|
|
576
|
+
testIds: { option: optionTestId }
|
|
577
|
+
}
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
if (ids.length === 0) return null;
|
|
581
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
582
|
+
"div",
|
|
583
|
+
{
|
|
584
|
+
className: rowHeight === void 0 ? "flex min-w-0 flex-wrap items-center gap-1" : "flex min-w-0 flex-wrap content-start gap-1 overflow-hidden",
|
|
585
|
+
style: rowHeight === void 0 ? void 0 : { maxHeight: chunkHUAABZ2C_cjs.labelChipsMaxHeight(rowHeight, true) },
|
|
586
|
+
title: rowHeight === void 0 ? void 0 : ids.map((id) => titleOf(id, titles)).join(", "),
|
|
587
|
+
children: ids.map((id) => /* @__PURE__ */ jsxRuntime.jsx(chunkHUAABZ2C_cjs.LabelChip, { name: titleOf(id, titles), color: ui.getEntityColor(id, "medium") }, id))
|
|
588
|
+
}
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
function LabelsField({ testId, ...cell }) {
|
|
592
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
593
|
+
"div",
|
|
594
|
+
{
|
|
595
|
+
"data-testid": testId,
|
|
596
|
+
className: "flex min-h-8 min-w-0 items-center rounded-md border border-input bg-card px-2 py-1",
|
|
597
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(LabelsCell, { ...cell, rowHeight: 160 })
|
|
598
|
+
}
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// src/databases/sourcesOverflow.ts
|
|
603
|
+
function hiddenAfterRows(tops, rows = 1) {
|
|
604
|
+
const shown = [...new Set(tops)].sort((a, b) => a - b)[rows - 1];
|
|
605
|
+
if (shown === void 0) return 0;
|
|
606
|
+
return tops.filter((top) => top > shown).length;
|
|
607
|
+
}
|
|
608
|
+
var CHIP_HEIGHT = 22;
|
|
609
|
+
var CHIP_GAP = 4;
|
|
610
|
+
var CELL_PAD_Y = 16;
|
|
611
|
+
var defaultMoreLabel = (count) => `${count} more: open the row`;
|
|
612
|
+
var citationKey = (cites, index) => {
|
|
613
|
+
const c = cites[index];
|
|
614
|
+
return `${c.doc_ext_id}:${c.version ?? ""}:${index}`;
|
|
615
|
+
};
|
|
616
|
+
var citationTestId = (cites, index) => {
|
|
617
|
+
const id = cites[index].doc_ext_id;
|
|
618
|
+
return cites.findIndex((c) => c.doc_ext_id === id) < index ? `${id}-${index}` : id;
|
|
619
|
+
};
|
|
620
|
+
function citationsOf(value) {
|
|
621
|
+
return cellList(value).filter(
|
|
622
|
+
(v) => typeof v === "object" && v !== null && typeof v.doc_ext_id === "string"
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
var MORE_CHIP = "inline-flex h-[22px] shrink-0 items-center rounded-md border border-border bg-muted/50 px-1.5 text-xs text-muted-foreground";
|
|
626
|
+
function SourcesCell({
|
|
627
|
+
value,
|
|
628
|
+
titles,
|
|
629
|
+
onOpen,
|
|
630
|
+
openLabel,
|
|
631
|
+
moreLabel = defaultMoreLabel,
|
|
632
|
+
rowHeight
|
|
633
|
+
}) {
|
|
634
|
+
const cites = citationsOf(value);
|
|
635
|
+
const chips = cites.map((c) => {
|
|
636
|
+
const count = c.chunks?.length ?? 0;
|
|
637
|
+
return { name: titleOf(c.doc_ext_id, titles), count: count > 0 ? `(${count})` : void 0 };
|
|
638
|
+
});
|
|
639
|
+
const names = chips.map((chip) => chip.count ? `${chip.name} ${chip.count}` : chip.name);
|
|
640
|
+
const rows = rowHeight === void 0 ? 1 : Math.max(1, Math.floor((rowHeight - CELL_PAD_Y + CHIP_GAP) / (CHIP_HEIGHT + CHIP_GAP)));
|
|
641
|
+
const row = react.useRef(null);
|
|
642
|
+
const [hidden, setHidden] = react.useState(0);
|
|
643
|
+
const signature = cites.map((c) => c.doc_ext_id).join("|");
|
|
644
|
+
react.useLayoutEffect(() => {
|
|
645
|
+
const el = row.current;
|
|
646
|
+
if (!el) return;
|
|
647
|
+
const measure = () => {
|
|
648
|
+
const next = hiddenAfterRows(
|
|
649
|
+
Array.from(el.children, (child) => child.offsetTop),
|
|
650
|
+
rows
|
|
651
|
+
);
|
|
652
|
+
setHidden((prev) => prev === next ? prev : next);
|
|
653
|
+
};
|
|
654
|
+
measure();
|
|
655
|
+
return chunkPPCATBOY_cjs.observeResize(el, measure);
|
|
656
|
+
}, [signature, titles, rows]);
|
|
657
|
+
if (cites.length === 0) return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "\u2013" });
|
|
658
|
+
const more = hidden > 0 ? names.slice(-hidden).join("\n") : void 0;
|
|
659
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full min-w-0 items-center gap-1", children: [
|
|
660
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
661
|
+
"div",
|
|
662
|
+
{
|
|
663
|
+
ref: row,
|
|
664
|
+
className: "flex min-w-0 flex-1 flex-wrap content-start gap-1 overflow-hidden",
|
|
665
|
+
style: { maxHeight: rows * CHIP_HEIGHT + (rows - 1) * CHIP_GAP },
|
|
666
|
+
children: cites.map((c, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
667
|
+
LinkChip,
|
|
668
|
+
{
|
|
669
|
+
kind: "document",
|
|
670
|
+
label: chips[i].name,
|
|
671
|
+
suffix: chips[i].count,
|
|
672
|
+
onOpen,
|
|
673
|
+
openLabel: onOpen && openLabel ? openLabel(names[i]) : void 0,
|
|
674
|
+
testId: `database-source-chip-${citationTestId(cites, i)}`,
|
|
675
|
+
className: "max-w-full"
|
|
676
|
+
},
|
|
677
|
+
citationKey(cites, i)
|
|
678
|
+
))
|
|
679
|
+
}
|
|
680
|
+
),
|
|
681
|
+
hidden > 0 && (onOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
682
|
+
"button",
|
|
683
|
+
{
|
|
684
|
+
type: "button",
|
|
685
|
+
title: more,
|
|
686
|
+
"aria-label": moreLabel(hidden),
|
|
687
|
+
"data-testid": "database-source-more",
|
|
688
|
+
onClick: (e) => {
|
|
689
|
+
e.stopPropagation();
|
|
690
|
+
onOpen();
|
|
691
|
+
},
|
|
692
|
+
onDoubleClick: (e) => e.stopPropagation(),
|
|
693
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
694
|
+
className: `${MORE_CHIP} hover:bg-muted`,
|
|
695
|
+
children: `+${hidden}`
|
|
696
|
+
}
|
|
697
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { title: more, "data-testid": "database-source-more", className: MORE_CHIP, children: `+${hidden}` }))
|
|
698
|
+
] });
|
|
699
|
+
}
|
|
700
|
+
var sourceTestId = (docId) => `database-source-${docId}`;
|
|
701
|
+
function SourcesField({ value, titles, onOpenDocument, testId }) {
|
|
702
|
+
const cites = citationsOf(value);
|
|
703
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": testId, className: "flex min-w-0 flex-col gap-2", children: cites.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "No sources" }) : cites.map((c, i) => {
|
|
704
|
+
const count = c.chunks?.length ?? 0;
|
|
705
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
706
|
+
chunkHUAABZ2C_cjs.FactSourceGroup,
|
|
707
|
+
{
|
|
708
|
+
docId: citationTestId(cites, i),
|
|
709
|
+
document: /* @__PURE__ */ jsxRuntime.jsx(
|
|
710
|
+
LinkChip,
|
|
711
|
+
{
|
|
712
|
+
kind: "document",
|
|
713
|
+
label: titleOf(c.doc_ext_id, titles),
|
|
714
|
+
onOpen: onOpenDocument ? () => onOpenDocument(c.doc_ext_id) : void 0
|
|
715
|
+
}
|
|
716
|
+
),
|
|
717
|
+
hasPassages: count > 0,
|
|
718
|
+
testIds: { root: sourceTestId },
|
|
719
|
+
labels: { wholeDocument: "Whole document" },
|
|
720
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "px-2 text-xs text-muted-foreground", children: count === 1 ? "1 passage" : `${count} passages` })
|
|
721
|
+
},
|
|
722
|
+
citationKey(cites, i)
|
|
723
|
+
);
|
|
724
|
+
}) });
|
|
725
|
+
}
|
|
726
|
+
function DateSpanField({ value, onCommit, idPrefix }) {
|
|
727
|
+
const baseline = chunkGISMY7J7_cjs.factDateSpanToFields(value.start, value.end, value.timezone);
|
|
728
|
+
const [draft, setDraft] = react.useState(baseline);
|
|
729
|
+
react.useEffect(
|
|
730
|
+
() => setDraft(chunkGISMY7J7_cjs.factDateSpanToFields(value.start, value.end, value.timezone)),
|
|
731
|
+
[value.start, value.end, value.timezone]
|
|
732
|
+
);
|
|
733
|
+
const cancelled = react.useRef(false);
|
|
734
|
+
const commit = () => {
|
|
735
|
+
if (cancelled.current) {
|
|
736
|
+
cancelled.current = false;
|
|
737
|
+
setDraft(baseline);
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
if (JSON.stringify(draft) === JSON.stringify(baseline)) return;
|
|
741
|
+
const span = chunkGISMY7J7_cjs.factDateFieldsToSpan(draft);
|
|
742
|
+
onCommit({ start: span.date, end: span.date_end, timezone: span.timezone });
|
|
743
|
+
};
|
|
744
|
+
return (
|
|
745
|
+
// The popover is drawn elsewhere on the page, but its keys still pass through here.
|
|
746
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
747
|
+
"div",
|
|
748
|
+
{
|
|
749
|
+
onKeyDownCapture: (e) => {
|
|
750
|
+
if (e.key === "Escape") cancelled.current = true;
|
|
751
|
+
},
|
|
752
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
753
|
+
chunkHUAABZ2C_cjs.FactDateInput,
|
|
754
|
+
{
|
|
755
|
+
value: draft,
|
|
756
|
+
onChange: setDraft,
|
|
757
|
+
idPrefix,
|
|
758
|
+
onOpenChange: (open) => {
|
|
759
|
+
if (open) cancelled.current = false;
|
|
760
|
+
else commit();
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
)
|
|
764
|
+
}
|
|
765
|
+
)
|
|
766
|
+
);
|
|
767
|
+
}
|
|
768
|
+
var TYPED_DATE = /^\d{4}(-\d{2})?(-\d{2})?$/;
|
|
769
|
+
var DEFAULT_DATE_SPAN_EDITOR_LABELS = {
|
|
770
|
+
edit: (name) => `Edit ${name}`,
|
|
771
|
+
invalid: "Enter a date as YYYY, YYYY-MM or YYYY-MM-DD.",
|
|
772
|
+
placeholder: "YYYY, YYYY-MM or YYYY-MM-DD"
|
|
773
|
+
};
|
|
774
|
+
var startText = (value, end, timezone) => {
|
|
775
|
+
const start = typeof value === "string" ? value : value?.start;
|
|
776
|
+
if (typeof start !== "string") return "";
|
|
777
|
+
return chunkGISMY7J7_cjs.factDateSpanToFields(start, end, timezone).date || start.slice(0, 10);
|
|
778
|
+
};
|
|
779
|
+
var typedTime = (typed) => Date.parse(`${typed}${"-01-01".slice(typed.length - 4)}`);
|
|
780
|
+
var textOf = (v) => typeof v === "string" && v ? v : null;
|
|
781
|
+
function DateSpanCellEditor({
|
|
782
|
+
value,
|
|
783
|
+
data,
|
|
784
|
+
endColumnId,
|
|
785
|
+
timezoneColumnId,
|
|
786
|
+
labels,
|
|
787
|
+
columnName = "",
|
|
788
|
+
onValueChange,
|
|
789
|
+
stopEditing
|
|
790
|
+
}) {
|
|
791
|
+
const l = { ...DEFAULT_DATE_SPAN_EDITOR_LABELS, ...labels };
|
|
792
|
+
const [original] = react.useState(value);
|
|
793
|
+
const [storedEnd] = react.useState(
|
|
794
|
+
() => textOf(endColumnId ? data?.values[endColumnId] : value?.end)
|
|
795
|
+
);
|
|
796
|
+
const [storedZone] = react.useState(
|
|
797
|
+
() => textOf(
|
|
798
|
+
timezoneColumnId ? data?.values[timezoneColumnId] : value?.timezone
|
|
799
|
+
)
|
|
800
|
+
);
|
|
801
|
+
const [opened] = react.useState(() => startText(value, storedEnd, storedZone));
|
|
802
|
+
const [text, setText] = react.useState(opened);
|
|
803
|
+
const [invalid, setInvalid] = react.useState(false);
|
|
804
|
+
const input = react.useRef(null);
|
|
805
|
+
react.useEffect(() => input.current?.focus(), []);
|
|
806
|
+
const spanFor = (typed) => {
|
|
807
|
+
if (!typed) return { start: null, end: null, timezone: null };
|
|
808
|
+
const keep = storedEnd !== null && typedTime(typed) <= Date.parse(storedEnd);
|
|
809
|
+
return { start: typed, end: keep ? storedEnd : null, timezone: keep ? storedZone : null };
|
|
810
|
+
};
|
|
811
|
+
const follow = (next) => {
|
|
812
|
+
const typed = next.trim();
|
|
813
|
+
if ((!typed || TYPED_DATE.test(typed)) && typed !== opened) {
|
|
814
|
+
onValueChange(spanFor(typed));
|
|
815
|
+
} else {
|
|
816
|
+
onValueChange(original);
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
const onKeyDown = (e) => {
|
|
820
|
+
if (e.key === "Escape") {
|
|
821
|
+
e.stopPropagation();
|
|
822
|
+
stopEditing(true);
|
|
823
|
+
} else if (e.key === "Enter") {
|
|
824
|
+
e.preventDefault();
|
|
825
|
+
e.stopPropagation();
|
|
826
|
+
const typed = text.trim();
|
|
827
|
+
if (typed && !TYPED_DATE.test(typed)) {
|
|
828
|
+
setInvalid(true);
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
if (typed === opened) {
|
|
832
|
+
stopEditing(true);
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
setTimeout(() => stopEditing(), 0);
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative h-full", children: [
|
|
839
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
840
|
+
ui.Input,
|
|
841
|
+
{
|
|
842
|
+
ref: input,
|
|
843
|
+
value: text,
|
|
844
|
+
"aria-label": l.edit(columnName),
|
|
845
|
+
"aria-invalid": invalid,
|
|
846
|
+
"aria-describedby": invalid ? "database-date-span-error" : void 0,
|
|
847
|
+
placeholder: l.placeholder,
|
|
848
|
+
onChange: (e) => {
|
|
849
|
+
setText(e.target.value);
|
|
850
|
+
follow(e.target.value);
|
|
851
|
+
setInvalid(false);
|
|
852
|
+
},
|
|
853
|
+
onKeyDown,
|
|
854
|
+
className: "h-full rounded-none",
|
|
855
|
+
"data-testid": "database-date-span-editor"
|
|
856
|
+
}
|
|
857
|
+
),
|
|
858
|
+
invalid && /* @__PURE__ */ jsxRuntime.jsx(
|
|
859
|
+
"p",
|
|
860
|
+
{
|
|
861
|
+
id: "database-date-span-error",
|
|
862
|
+
role: "alert",
|
|
863
|
+
className: "absolute left-0 top-full z-10 rounded-sm border bg-popover px-2 py-1 text-xs text-destructive shadow-md",
|
|
864
|
+
children: l.invalid
|
|
865
|
+
}
|
|
866
|
+
)
|
|
867
|
+
] });
|
|
868
|
+
}
|
|
869
|
+
function SelectChip({ value }) {
|
|
870
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
871
|
+
"span",
|
|
872
|
+
{
|
|
873
|
+
className: ui.cn(
|
|
874
|
+
"inline-flex max-w-full items-center truncate rounded-md px-2 py-0.5 text-xs font-medium",
|
|
875
|
+
optionTone(value)
|
|
876
|
+
),
|
|
877
|
+
children: value
|
|
878
|
+
}
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
function SelectCellEditor(props) {
|
|
882
|
+
const { value, onValueChange, stopEditing, options, clearLabel = "Clear" } = props;
|
|
883
|
+
const items = [...options, null];
|
|
884
|
+
const [active, setActive] = react.useState(() => Math.max(0, options.indexOf(String(value ?? ""))));
|
|
885
|
+
const list = react.useRef(null);
|
|
886
|
+
react.useEffect(() => list.current?.focus(), []);
|
|
887
|
+
const pick = (option) => {
|
|
888
|
+
onValueChange(option);
|
|
889
|
+
setTimeout(() => stopEditing(), 0);
|
|
890
|
+
};
|
|
891
|
+
const onKeyDown = (e) => {
|
|
892
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
893
|
+
e.preventDefault();
|
|
894
|
+
e.stopPropagation();
|
|
895
|
+
const step = e.key === "ArrowDown" ? 1 : -1;
|
|
896
|
+
setActive((i) => (i + step + items.length) % items.length);
|
|
897
|
+
} else if (e.key === "Enter") {
|
|
898
|
+
e.preventDefault();
|
|
899
|
+
e.stopPropagation();
|
|
900
|
+
pick(items[active]);
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
904
|
+
"div",
|
|
905
|
+
{
|
|
906
|
+
ref: list,
|
|
907
|
+
role: "listbox",
|
|
908
|
+
tabIndex: -1,
|
|
909
|
+
onKeyDown,
|
|
910
|
+
"data-testid": "database-select-editor",
|
|
911
|
+
className: "flex min-w-44 flex-col gap-0.5 rounded-md border border-border bg-popover p-1 shadow-md outline-none",
|
|
912
|
+
children: items.map((option, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
913
|
+
"button",
|
|
914
|
+
{
|
|
915
|
+
type: "button",
|
|
916
|
+
role: "option",
|
|
917
|
+
"aria-selected": option === value,
|
|
918
|
+
onMouseEnter: () => setActive(i),
|
|
919
|
+
onClick: () => pick(option),
|
|
920
|
+
"data-testid": option === null ? "database-select-clear" : `database-select-option-${option}`,
|
|
921
|
+
className: ui.cn(
|
|
922
|
+
"flex items-center gap-2 rounded px-2 py-1 text-left text-sm",
|
|
923
|
+
i === active && "bg-muted"
|
|
924
|
+
),
|
|
925
|
+
children: [
|
|
926
|
+
option === null ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: clearLabel }) : /* @__PURE__ */ jsxRuntime.jsx(SelectChip, { value: option }),
|
|
927
|
+
option !== null && option === value && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "ml-auto size-3.5" })
|
|
928
|
+
]
|
|
929
|
+
},
|
|
930
|
+
option ?? "__clear"
|
|
931
|
+
))
|
|
932
|
+
}
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
var DEFAULT_DATABASE_COLUMN_LABELS = {
|
|
936
|
+
addColumn: "Add a column",
|
|
937
|
+
columnSettings: (name) => `${name} column settings`,
|
|
938
|
+
computed: "Computed from a relation (read-only)",
|
|
939
|
+
openRow: "Open row",
|
|
940
|
+
dateSpanEditor: DEFAULT_DATE_SPAN_EDITOR_LABELS,
|
|
941
|
+
openRowFromSource: (title) => `${title}: open the row`
|
|
942
|
+
};
|
|
943
|
+
var ADD_COLUMN_COL_ID = "__add_column";
|
|
944
|
+
var OPEN_ROW_COL_ID = "__open_row";
|
|
945
|
+
var ROW_ACTIONS_COL_ID = "__row_actions";
|
|
946
|
+
var COLUMN_TYPE_ICONS = {
|
|
947
|
+
text: lucideReact.Type,
|
|
948
|
+
number: lucideReact.Hash,
|
|
949
|
+
date: lucideReact.CalendarDays,
|
|
950
|
+
checkbox: lucideReact.CheckSquare,
|
|
951
|
+
select: lucideReact.ChevronDown,
|
|
952
|
+
person: lucideReact.UserRound,
|
|
953
|
+
document: COLUMN_KITS.source.icon,
|
|
954
|
+
relation: lucideReact.ArrowUpRight,
|
|
955
|
+
lookup: lucideReact.Search,
|
|
956
|
+
rollup: lucideReact.Sigma,
|
|
957
|
+
label: COLUMN_KITS.label.icon,
|
|
958
|
+
source: COLUMN_KITS.source.icon
|
|
959
|
+
};
|
|
960
|
+
var WIDTHS = {
|
|
961
|
+
text: 220,
|
|
962
|
+
number: 130,
|
|
963
|
+
date: 140,
|
|
964
|
+
checkbox: 110,
|
|
965
|
+
select: 160,
|
|
966
|
+
person: 180,
|
|
967
|
+
document: 240,
|
|
968
|
+
relation: 240,
|
|
969
|
+
lookup: 200,
|
|
970
|
+
rollup: 130,
|
|
971
|
+
label: COLUMN_KITS.label.width,
|
|
972
|
+
source: COLUMN_KITS.source.width
|
|
973
|
+
};
|
|
974
|
+
function HeaderLabel({
|
|
975
|
+
dbColumn: column,
|
|
976
|
+
onEdit,
|
|
977
|
+
settingsLabel: label,
|
|
978
|
+
computedLabel
|
|
979
|
+
}) {
|
|
980
|
+
const Icon = COLUMN_TYPE_ICONS[column.type];
|
|
981
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "group/dbh flex min-w-0 items-center gap-1.5", children: [
|
|
982
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": true }),
|
|
983
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-[12.5px] font-medium", children: column.name }),
|
|
984
|
+
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 }) }),
|
|
985
|
+
onEdit && /* @__PURE__ */ jsxRuntime.jsx(
|
|
986
|
+
"button",
|
|
987
|
+
{
|
|
988
|
+
type: "button",
|
|
989
|
+
"aria-label": label,
|
|
990
|
+
title: label,
|
|
991
|
+
"data-testid": `database-column-settings-${column.id}`,
|
|
992
|
+
onClick: (e) => {
|
|
993
|
+
e.stopPropagation();
|
|
994
|
+
onEdit();
|
|
995
|
+
},
|
|
996
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
997
|
+
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",
|
|
998
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreHorizontal, { className: "size-3.5" })
|
|
999
|
+
}
|
|
1000
|
+
)
|
|
1001
|
+
] });
|
|
1002
|
+
}
|
|
1003
|
+
function AddColumnHeader({ addLabel, onAddColumn }) {
|
|
1004
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1005
|
+
"button",
|
|
1006
|
+
{
|
|
1007
|
+
type: "button",
|
|
1008
|
+
"aria-label": addLabel,
|
|
1009
|
+
title: addLabel,
|
|
1010
|
+
"data-testid": "database-add-column",
|
|
1011
|
+
onClick: onAddColumn,
|
|
1012
|
+
className: "flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
1013
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4" })
|
|
1014
|
+
}
|
|
1015
|
+
);
|
|
1016
|
+
}
|
|
1017
|
+
function columnWidth(column) {
|
|
1018
|
+
const header = Math.round(column.name.length * 8) + 76 + (isComputedColumn(column) ? 16 : 0);
|
|
1019
|
+
return Math.min(320, Math.max(WIDTHS[column.type], header));
|
|
1020
|
+
}
|
|
1021
|
+
var positive = (n) => typeof n === "number" && Number.isFinite(n) && n > 0 ? n : void 0;
|
|
1022
|
+
function sizing(column) {
|
|
1023
|
+
const grow = positive(column.grow);
|
|
1024
|
+
if (grow !== void 0) {
|
|
1025
|
+
return { flex: grow, minWidth: positive(column.minWidth) ?? columnWidth(column) };
|
|
1026
|
+
}
|
|
1027
|
+
return {
|
|
1028
|
+
width: positive(column.width) ?? columnWidth(column),
|
|
1029
|
+
minWidth: positive(column.minWidth) ?? 90
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
function canEditColumn(column, sources) {
|
|
1033
|
+
if (isComputedColumn(column) || column.locked) return false;
|
|
1034
|
+
const kit = kitOf(column.type);
|
|
1035
|
+
if (kit) return kit.canEditInGrid(column, sources);
|
|
1036
|
+
if (column.type === "person") return Boolean(sources?.members);
|
|
1037
|
+
if (column.type === "document") return Boolean(sources?.documents);
|
|
1038
|
+
if (column.type === "relation") return Boolean(sources?.searchRows && column.relation);
|
|
1039
|
+
return true;
|
|
1040
|
+
}
|
|
1041
|
+
function editorFor(column, sources, dateSpanLabels) {
|
|
1042
|
+
if (kitOf(column.type)) return {};
|
|
1043
|
+
const pick = (params) => ({
|
|
1044
|
+
cellEditor: PickCellEditor,
|
|
1045
|
+
cellEditorPopup: true,
|
|
1046
|
+
cellEditorParams: params
|
|
1047
|
+
});
|
|
1048
|
+
switch (column.type) {
|
|
1049
|
+
case "number":
|
|
1050
|
+
return { cellEditor: "agNumberCellEditor", cellEditorParams: { showStepperButtons: false } };
|
|
1051
|
+
case "date":
|
|
1052
|
+
return column.span ? {
|
|
1053
|
+
cellEditor: DateSpanCellEditor,
|
|
1054
|
+
cellEditorParams: {
|
|
1055
|
+
endColumnId: column.span.endColumnId,
|
|
1056
|
+
timezoneColumnId: column.span.timezoneColumnId,
|
|
1057
|
+
labels: dateSpanLabels,
|
|
1058
|
+
columnName: column.name
|
|
1059
|
+
}
|
|
1060
|
+
} : { cellEditor: "agDateStringCellEditor" };
|
|
1061
|
+
case "checkbox":
|
|
1062
|
+
return { cellEditor: "agCheckboxCellEditor" };
|
|
1063
|
+
case "select":
|
|
1064
|
+
return {
|
|
1065
|
+
cellEditor: SelectCellEditor,
|
|
1066
|
+
cellEditorPopup: true,
|
|
1067
|
+
cellEditorParams: { options: column.options ?? [] }
|
|
1068
|
+
};
|
|
1069
|
+
case "person":
|
|
1070
|
+
return pick({ kind: "person", options: sources?.members ?? [] });
|
|
1071
|
+
case "document":
|
|
1072
|
+
return pick({ kind: "document", options: sources?.documents ?? [] });
|
|
1073
|
+
case "relation": {
|
|
1074
|
+
const target = column.relation?.database_id;
|
|
1075
|
+
const searchRows = sources?.searchRows;
|
|
1076
|
+
return pick({
|
|
1077
|
+
kind: "relation",
|
|
1078
|
+
search: target && searchRows ? (q) => searchRows(target, q) : void 0
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
case "lookup":
|
|
1082
|
+
case "rollup":
|
|
1083
|
+
return {};
|
|
1084
|
+
default:
|
|
1085
|
+
return { cellEditor: "agTextCellEditor" };
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
var EMPTY_ROW = { id: "", values: {} };
|
|
1089
|
+
var asText = (v) => typeof v === "string" && v ? v : null;
|
|
1090
|
+
function rendererFor(column, locale, sources, readOnly, isCellEditable, onOpenRow, l) {
|
|
1091
|
+
const kit = kitOf(column.type);
|
|
1092
|
+
if (kit) {
|
|
1093
|
+
const valueFormatter = (p) => kit.format(p.value, p.data ?? EMPTY_ROW, column);
|
|
1094
|
+
if (column.type === "label") {
|
|
1095
|
+
const editableFor = (row) => !readOnly && column.editIn !== "row" && canEditColumn(column, sources) && (!row || !isCellEditable || isCellEditable(row, column));
|
|
1096
|
+
return {
|
|
1097
|
+
valueFormatter,
|
|
1098
|
+
cellRenderer: (p) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1099
|
+
LabelsCell,
|
|
1100
|
+
{
|
|
1101
|
+
value: p.value,
|
|
1102
|
+
titles: p.data?.titles,
|
|
1103
|
+
labels: labelSourceFor(sources?.labels, column),
|
|
1104
|
+
onChange: editableFor(p.data) ? (ids) => p.node.setDataValue(column.id, ids) : void 0,
|
|
1105
|
+
rowHeight: p.node?.rowHeight ?? void 0
|
|
1106
|
+
}
|
|
1107
|
+
)
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
return {
|
|
1111
|
+
valueFormatter,
|
|
1112
|
+
cellRenderer: (p) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1113
|
+
SourcesCell,
|
|
1114
|
+
{
|
|
1115
|
+
value: p.value,
|
|
1116
|
+
titles: p.data?.titles,
|
|
1117
|
+
openLabel: l.openRowFromSource,
|
|
1118
|
+
onOpen: onOpenRow && p.data ? () => onOpenRow(p.data, { focusColumn: column.id }) : void 0,
|
|
1119
|
+
rowHeight: p.node?.rowHeight ?? void 0
|
|
1120
|
+
}
|
|
1121
|
+
)
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
switch (column.type) {
|
|
1125
|
+
case "checkbox":
|
|
1126
|
+
return {
|
|
1127
|
+
cellRenderer: "agCheckboxCellRenderer",
|
|
1128
|
+
cellClass: "flex items-center justify-center"
|
|
1129
|
+
};
|
|
1130
|
+
case "select":
|
|
1131
|
+
return {
|
|
1132
|
+
cellRenderer: (p) => typeof p.value === "string" && p.value ? /* @__PURE__ */ jsxRuntime.jsx(SelectChip, { value: p.value }) : null
|
|
1133
|
+
};
|
|
1134
|
+
case "number":
|
|
1135
|
+
return {
|
|
1136
|
+
cellClass: "cell-numeric",
|
|
1137
|
+
valueFormatter: (p) => formatCell(p.value, "number", locale)
|
|
1138
|
+
};
|
|
1139
|
+
case "rollup":
|
|
1140
|
+
return {
|
|
1141
|
+
cellClass: "cell-numeric text-muted-foreground",
|
|
1142
|
+
valueFormatter: (p) => formatCell(p.value, "rollup", locale)
|
|
1143
|
+
};
|
|
1144
|
+
case "date": {
|
|
1145
|
+
const span = column.span;
|
|
1146
|
+
if (span)
|
|
1147
|
+
return {
|
|
1148
|
+
valueFormatter: (p) => typeof p.value === "string" && p.value ? chunk66IOCKWS_cjs.formatSpan(
|
|
1149
|
+
p.value,
|
|
1150
|
+
asText(p.data?.values[span.endColumnId]),
|
|
1151
|
+
span.timezoneColumnId ? asText(p.data?.values[span.timezoneColumnId]) : null
|
|
1152
|
+
) : ""
|
|
1153
|
+
};
|
|
1154
|
+
return {
|
|
1155
|
+
valueFormatter: (p) => formatCell(p.value, "date", locale)
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
case "person":
|
|
1159
|
+
return {
|
|
1160
|
+
cellRenderer: (p) => /* @__PURE__ */ jsxRuntime.jsx(PersonCell, { value: p.value, titles: p.data?.titles })
|
|
1161
|
+
};
|
|
1162
|
+
case "document":
|
|
1163
|
+
case "relation":
|
|
1164
|
+
return {
|
|
1165
|
+
cellRenderer: (p) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1166
|
+
LinkChipsCell,
|
|
1167
|
+
{
|
|
1168
|
+
value: p.value,
|
|
1169
|
+
titles: p.data?.titles,
|
|
1170
|
+
kind: column.type === "document" ? "document" : "relation",
|
|
1171
|
+
onOpenDocument: sources?.onOpenDocument
|
|
1172
|
+
}
|
|
1173
|
+
)
|
|
1174
|
+
};
|
|
1175
|
+
case "lookup":
|
|
1176
|
+
return {
|
|
1177
|
+
cellRenderer: (p) => /* @__PURE__ */ jsxRuntime.jsx(LookupCell, { value: p.value, titles: p.data?.titles, locale })
|
|
1178
|
+
};
|
|
1179
|
+
default:
|
|
1180
|
+
return { cellClass: "database-cell-text" };
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
function setSpan(row, columnId, span, newValue) {
|
|
1184
|
+
if ((typeof newValue === "string" || newValue === null) && sameCellValue(asText(newValue), row.values[columnId] ?? null)) {
|
|
1185
|
+
return false;
|
|
1186
|
+
}
|
|
1187
|
+
const next = typeof newValue === "object" && newValue !== null ? newValue : { start: asText(newValue), end: null, timezone: null };
|
|
1188
|
+
const writes = [
|
|
1189
|
+
[columnId, next.start],
|
|
1190
|
+
[span.endColumnId, next.end],
|
|
1191
|
+
...span.timezoneColumnId ? [[span.timezoneColumnId, next.timezone]] : []
|
|
1192
|
+
];
|
|
1193
|
+
const changed = writes.filter(([id, v]) => !sameCellValue(v, row.values[id] ?? null));
|
|
1194
|
+
if (changed.length === 0) return false;
|
|
1195
|
+
row.values = { ...row.values, ...Object.fromEntries(writes) };
|
|
1196
|
+
return true;
|
|
1197
|
+
}
|
|
1198
|
+
function createDatabaseColumns(columns, options = {}) {
|
|
1199
|
+
const {
|
|
1200
|
+
readOnly,
|
|
1201
|
+
onEditColumn,
|
|
1202
|
+
onAddColumn,
|
|
1203
|
+
onOpenRow,
|
|
1204
|
+
locale,
|
|
1205
|
+
sources,
|
|
1206
|
+
isCellEditable,
|
|
1207
|
+
renderRowActions
|
|
1208
|
+
} = options;
|
|
1209
|
+
const l = { ...DEFAULT_DATABASE_COLUMN_LABELS, ...options.labels };
|
|
1210
|
+
const openRow = onOpenRow && columns.length > 0 ? [
|
|
1211
|
+
{
|
|
1212
|
+
colId: OPEN_ROW_COL_ID,
|
|
1213
|
+
headerName: "",
|
|
1214
|
+
width: 40,
|
|
1215
|
+
minWidth: 40,
|
|
1216
|
+
maxWidth: 40,
|
|
1217
|
+
resizable: false,
|
|
1218
|
+
sortable: false,
|
|
1219
|
+
editable: false,
|
|
1220
|
+
suppressMovable: true,
|
|
1221
|
+
// Pinned: the button stays in view however far the table scrolls.
|
|
1222
|
+
pinned: "left",
|
|
1223
|
+
lockPinned: true,
|
|
1224
|
+
lockPosition: "left",
|
|
1225
|
+
cellClass: "flex items-center justify-center !px-0",
|
|
1226
|
+
valueGetter: () => null,
|
|
1227
|
+
cellRenderer: (p) => p.data ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1228
|
+
"button",
|
|
1229
|
+
{
|
|
1230
|
+
type: "button",
|
|
1231
|
+
"aria-label": l.openRow,
|
|
1232
|
+
title: l.openRow,
|
|
1233
|
+
"data-testid": `database-open-row-${p.data.id}`,
|
|
1234
|
+
onClick: (e) => {
|
|
1235
|
+
e.stopPropagation();
|
|
1236
|
+
if (p.data) onOpenRow(p.data);
|
|
1237
|
+
},
|
|
1238
|
+
onDoubleClick: (e) => e.stopPropagation(),
|
|
1239
|
+
className: "flex size-6 items-center justify-center rounded text-muted-foreground/70 hover:bg-muted hover:text-foreground",
|
|
1240
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize2, { className: "size-3.5" })
|
|
1241
|
+
}
|
|
1242
|
+
) : null
|
|
1243
|
+
}
|
|
1244
|
+
] : [];
|
|
1245
|
+
const defs = columns.map((column) => {
|
|
1246
|
+
const gridEditable = !readOnly && !kitOf(column.type) && column.editIn !== "row" && canEditColumn(column, sources);
|
|
1247
|
+
return {
|
|
1248
|
+
colId: column.id,
|
|
1249
|
+
headerName: column.name,
|
|
1250
|
+
...sizing(column),
|
|
1251
|
+
resizable: true,
|
|
1252
|
+
sortable: true,
|
|
1253
|
+
editable: isCellEditable ? (p) => gridEditable && (!p.data || isCellEditable(p.data, column)) : gridEditable,
|
|
1254
|
+
// The grid's own type inference must not second-guess the database's column type.
|
|
1255
|
+
cellDataType: false,
|
|
1256
|
+
headerComponentParams: {
|
|
1257
|
+
innerHeaderComponent: HeaderLabel,
|
|
1258
|
+
innerHeaderComponentParams: {
|
|
1259
|
+
dbColumn: column,
|
|
1260
|
+
settingsLabel: l.columnSettings(column.name),
|
|
1261
|
+
computedLabel: l.computed,
|
|
1262
|
+
onEdit: !readOnly && onEditColumn ? () => onEditColumn(column) : void 0
|
|
1263
|
+
}
|
|
1264
|
+
},
|
|
1265
|
+
// An empty checkbox reads as unticked (not indeterminate).
|
|
1266
|
+
valueGetter: (p) => column.type === "checkbox" ? p.data?.values[column.id] === true : p.data?.values[column.id] ?? null,
|
|
1267
|
+
// Edits land in the row's values as the API would store them; the host saves them in
|
|
1268
|
+
// onCellValueChanged and puts the server's normalised row back.
|
|
1269
|
+
valueSetter: (p) => {
|
|
1270
|
+
if (!p.data) return false;
|
|
1271
|
+
const span = column.span;
|
|
1272
|
+
if (span) return setSpan(p.data, column.id, span, p.newValue);
|
|
1273
|
+
const next = toApiValue(p.newValue, column.type);
|
|
1274
|
+
if (sameCellValue(next, p.oldValue, column.type)) return false;
|
|
1275
|
+
p.data.values = { ...p.data.values, [column.id]: next };
|
|
1276
|
+
return true;
|
|
1277
|
+
},
|
|
1278
|
+
comparator: (a, b, nodeA, nodeB) => compareCells(a, b, column.type, nodeA?.data?.titles, nodeB?.data?.titles),
|
|
1279
|
+
getQuickFilterText: (p) => formatCell(p.value, column.type, locale, p.data?.titles),
|
|
1280
|
+
...editorFor(column, sources, l.dateSpanEditor),
|
|
1281
|
+
...rendererFor(column, locale, sources, readOnly, isCellEditable, onOpenRow, l)
|
|
1282
|
+
};
|
|
1283
|
+
});
|
|
1284
|
+
defs.unshift(...openRow);
|
|
1285
|
+
if (renderRowActions && columns.length > 0) {
|
|
1286
|
+
defs.push({
|
|
1287
|
+
colId: ROW_ACTIONS_COL_ID,
|
|
1288
|
+
headerName: "",
|
|
1289
|
+
width: 40,
|
|
1290
|
+
minWidth: 40,
|
|
1291
|
+
maxWidth: 40,
|
|
1292
|
+
resizable: false,
|
|
1293
|
+
sortable: false,
|
|
1294
|
+
editable: false,
|
|
1295
|
+
suppressMovable: true,
|
|
1296
|
+
pinned: "right",
|
|
1297
|
+
lockPinned: true,
|
|
1298
|
+
cellClass: "flex items-center justify-center !px-0",
|
|
1299
|
+
valueGetter: () => null,
|
|
1300
|
+
cellRenderer: (p) => p.data ? renderRowActions(p.data) : null
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
if (!readOnly && onAddColumn) {
|
|
1304
|
+
defs.push({
|
|
1305
|
+
colId: ADD_COLUMN_COL_ID,
|
|
1306
|
+
width: 52,
|
|
1307
|
+
minWidth: 52,
|
|
1308
|
+
maxWidth: 52,
|
|
1309
|
+
resizable: false,
|
|
1310
|
+
sortable: false,
|
|
1311
|
+
editable: false,
|
|
1312
|
+
suppressMovable: true,
|
|
1313
|
+
// Pinned: on a wide table the add button stays in view instead of scrolling off the right.
|
|
1314
|
+
pinned: "right",
|
|
1315
|
+
lockPinned: true,
|
|
1316
|
+
headerComponent: AddColumnHeader,
|
|
1317
|
+
headerComponentParams: { addLabel: l.addColumn, onAddColumn },
|
|
1318
|
+
valueGetter: () => null
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
return defs;
|
|
1322
|
+
}
|
|
1323
|
+
var DEFAULT_COLUMN_CONFIG_LABELS = {
|
|
1324
|
+
relatedDatabase: "Related database",
|
|
1325
|
+
pickDatabase: "Pick a database",
|
|
1326
|
+
noDatabases: "There is no database to link to yet.",
|
|
1327
|
+
targetFixed: "The related database can\u2019t be changed once the column has been added.",
|
|
1328
|
+
thisDatabase: "this database",
|
|
1329
|
+
showOnTarget: (target) => `Show on ${target}`,
|
|
1330
|
+
showOnTargetHint: "Adds a column to the related database that lists the links back.",
|
|
1331
|
+
pairName: "Name of the column there",
|
|
1332
|
+
pairNamePlaceholder: (name) => name,
|
|
1333
|
+
pairedWith: (target) => `Shown on ${target} too (two-way).`,
|
|
1334
|
+
oneWay: "One-way: only this database shows the links.",
|
|
1335
|
+
relation: "Relation",
|
|
1336
|
+
pickRelation: "Pick a relation column",
|
|
1337
|
+
noRelations: "Add a relation column first: lookups and rollups read through one.",
|
|
1338
|
+
lookupColumn: "Column to show",
|
|
1339
|
+
pickColumn: "Pick a column",
|
|
1340
|
+
noColumns: "The related database has no column to show.",
|
|
1341
|
+
rollupOp: "Calculate",
|
|
1342
|
+
rollupColumn: "Of the number column",
|
|
1343
|
+
noNumberColumns: "The related database has no number column.",
|
|
1344
|
+
ops: { count: "Count", sum: "Sum", avg: "Average", min: "Min", max: "Max" }
|
|
1345
|
+
};
|
|
1346
|
+
function Field({ label, children, hint }) {
|
|
1347
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
1348
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: label }),
|
|
1349
|
+
children,
|
|
1350
|
+
hint && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: hint })
|
|
1351
|
+
] });
|
|
1352
|
+
}
|
|
1353
|
+
function Hint({ children, testId }) {
|
|
1354
|
+
return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", "data-testid": testId, children });
|
|
1355
|
+
}
|
|
1356
|
+
function ColumnSelect({
|
|
1357
|
+
value,
|
|
1358
|
+
onChange,
|
|
1359
|
+
columns,
|
|
1360
|
+
placeholder,
|
|
1361
|
+
testId
|
|
1362
|
+
}) {
|
|
1363
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { value: value || void 0, onValueChange: onChange, children: [
|
|
1364
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.SelectTrigger, { "data-testid": testId, children: /* @__PURE__ */ jsxRuntime.jsx(ui.SelectValue, { placeholder }) }),
|
|
1365
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.SelectContent, { children: columns.map((c) => {
|
|
1366
|
+
const Icon = COLUMN_TYPE_ICONS[c.type];
|
|
1367
|
+
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: [
|
|
1368
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-4 text-muted-foreground" }),
|
|
1369
|
+
c.name
|
|
1370
|
+
] }) }, c.id);
|
|
1371
|
+
}) })
|
|
1372
|
+
] });
|
|
1373
|
+
}
|
|
1374
|
+
function RelationFields({
|
|
1375
|
+
draft,
|
|
1376
|
+
onChange,
|
|
1377
|
+
databases,
|
|
1378
|
+
databaseId,
|
|
1379
|
+
databaseName,
|
|
1380
|
+
editing,
|
|
1381
|
+
column,
|
|
1382
|
+
labels
|
|
1383
|
+
}) {
|
|
1384
|
+
const nameOf2 = (id) => databases.find((d) => d.id === id)?.name ?? (id === databaseId ? labels.thisDatabase : id);
|
|
1385
|
+
if (editing && column?.relation) {
|
|
1386
|
+
const target2 = nameOf2(column.relation.database_id);
|
|
1387
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Field, { label: labels.relatedDatabase, hint: labels.targetFixed, children: [
|
|
1388
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", "data-testid": "database-column-relation-target", children: target2 }),
|
|
1389
|
+
/* @__PURE__ */ jsxRuntime.jsx(Hint, { children: column.relation.two_way ? labels.pairedWith(target2) : labels.oneWay })
|
|
1390
|
+
] });
|
|
1391
|
+
}
|
|
1392
|
+
if (databases.length === 0) return /* @__PURE__ */ jsxRuntime.jsx(Hint, { children: labels.noDatabases });
|
|
1393
|
+
const target = draft.database_id ? nameOf2(draft.database_id) : "";
|
|
1394
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1395
|
+
/* @__PURE__ */ jsxRuntime.jsx(Field, { label: labels.relatedDatabase, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1396
|
+
ui.Select,
|
|
1397
|
+
{
|
|
1398
|
+
value: draft.database_id || void 0,
|
|
1399
|
+
onValueChange: (v) => onChange({ ...draft, database_id: v }),
|
|
1400
|
+
children: [
|
|
1401
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.SelectTrigger, { "data-testid": "database-column-relation-database", children: /* @__PURE__ */ jsxRuntime.jsx(ui.SelectValue, { placeholder: labels.pickDatabase }) }),
|
|
1402
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.SelectContent, { children: databases.map((d) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1403
|
+
ui.SelectItem,
|
|
1404
|
+
{
|
|
1405
|
+
value: d.id,
|
|
1406
|
+
"data-testid": `database-column-relation-database-${d.id}`,
|
|
1407
|
+
children: d.id === databaseId ? `${d.name} (${labels.thisDatabase})` : d.name
|
|
1408
|
+
},
|
|
1409
|
+
d.id
|
|
1410
|
+
)) })
|
|
1411
|
+
]
|
|
1412
|
+
}
|
|
1413
|
+
) }),
|
|
1414
|
+
draft.database_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 rounded-md border border-border p-3", children: [
|
|
1415
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center justify-between gap-3 text-sm", children: [
|
|
1416
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex flex-col", children: [
|
|
1417
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: labels.showOnTarget(target) }),
|
|
1418
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: labels.showOnTargetHint })
|
|
1419
|
+
] }),
|
|
1420
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1421
|
+
ui.Switch,
|
|
1422
|
+
{
|
|
1423
|
+
checked: draft.two_way,
|
|
1424
|
+
onCheckedChange: (two_way) => onChange({ ...draft, two_way }),
|
|
1425
|
+
"data-testid": "database-column-relation-two-way"
|
|
1426
|
+
}
|
|
1427
|
+
)
|
|
1428
|
+
] }),
|
|
1429
|
+
draft.two_way && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
1430
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { htmlFor: "database-column-pair-name", children: labels.pairName }),
|
|
1431
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1432
|
+
ui.Input,
|
|
1433
|
+
{
|
|
1434
|
+
id: "database-column-pair-name",
|
|
1435
|
+
value: draft.pair_name,
|
|
1436
|
+
maxLength: 200,
|
|
1437
|
+
placeholder: labels.pairNamePlaceholder(databaseName ?? ""),
|
|
1438
|
+
onChange: (e) => onChange({ ...draft, pair_name: e.target.value }),
|
|
1439
|
+
"data-testid": "database-column-pair-name"
|
|
1440
|
+
}
|
|
1441
|
+
)
|
|
1442
|
+
] })
|
|
1443
|
+
] })
|
|
1444
|
+
] });
|
|
1445
|
+
}
|
|
1446
|
+
function relationColumnsOf(columns) {
|
|
1447
|
+
return columns.filter((c) => c.type === "relation" && c.relation);
|
|
1448
|
+
}
|
|
1449
|
+
function targetColumnsOf(relationId, columns, databases, databaseId) {
|
|
1450
|
+
const relation = columns.find((c) => c.id === relationId)?.relation;
|
|
1451
|
+
if (!relation) return [];
|
|
1452
|
+
if (relation.database_id === databaseId) return columns;
|
|
1453
|
+
return databases.find((d) => d.id === relation.database_id)?.columns ?? [];
|
|
1454
|
+
}
|
|
1455
|
+
function LookupFields({
|
|
1456
|
+
draft,
|
|
1457
|
+
onChange,
|
|
1458
|
+
columns,
|
|
1459
|
+
databases,
|
|
1460
|
+
databaseId,
|
|
1461
|
+
labels
|
|
1462
|
+
}) {
|
|
1463
|
+
const relations = relationColumnsOf(columns);
|
|
1464
|
+
if (relations.length === 0)
|
|
1465
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Hint, { testId: "database-column-no-relations", children: labels.noRelations });
|
|
1466
|
+
const shown = targetColumnsOf(draft.relation, columns, databases, databaseId).filter(
|
|
1467
|
+
(c) => !isComputedColumn(c) && c.type !== "label" && c.type !== "source"
|
|
1468
|
+
);
|
|
1469
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1470
|
+
/* @__PURE__ */ jsxRuntime.jsx(Field, { label: labels.relation, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1471
|
+
ColumnSelect,
|
|
1472
|
+
{
|
|
1473
|
+
value: draft.relation,
|
|
1474
|
+
onChange: (relation) => onChange({ relation, column: "" }),
|
|
1475
|
+
columns: relations,
|
|
1476
|
+
placeholder: labels.pickRelation,
|
|
1477
|
+
testId: "database-column-lookup-relation"
|
|
1478
|
+
}
|
|
1479
|
+
) }),
|
|
1480
|
+
draft.relation && /* @__PURE__ */ jsxRuntime.jsx(Field, { label: labels.lookupColumn, children: shown.length ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1481
|
+
ColumnSelect,
|
|
1482
|
+
{
|
|
1483
|
+
value: draft.column,
|
|
1484
|
+
onChange: (column) => onChange({ ...draft, column }),
|
|
1485
|
+
columns: shown,
|
|
1486
|
+
placeholder: labels.pickColumn,
|
|
1487
|
+
testId: "database-column-lookup-column"
|
|
1488
|
+
}
|
|
1489
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(Hint, { children: labels.noColumns }) })
|
|
1490
|
+
] });
|
|
1491
|
+
}
|
|
1492
|
+
function RollupFields({
|
|
1493
|
+
draft,
|
|
1494
|
+
onChange,
|
|
1495
|
+
columns,
|
|
1496
|
+
databases,
|
|
1497
|
+
databaseId,
|
|
1498
|
+
labels
|
|
1499
|
+
}) {
|
|
1500
|
+
const relations = relationColumnsOf(columns);
|
|
1501
|
+
if (relations.length === 0)
|
|
1502
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Hint, { testId: "database-column-no-relations", children: labels.noRelations });
|
|
1503
|
+
const numbers = targetColumnsOf(draft.relation, columns, databases, databaseId).filter(
|
|
1504
|
+
(c) => c.type === "number"
|
|
1505
|
+
);
|
|
1506
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1507
|
+
/* @__PURE__ */ jsxRuntime.jsx(Field, { label: labels.relation, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1508
|
+
ColumnSelect,
|
|
1509
|
+
{
|
|
1510
|
+
value: draft.relation,
|
|
1511
|
+
onChange: (relation) => onChange({ ...draft, relation, column: "" }),
|
|
1512
|
+
columns: relations,
|
|
1513
|
+
placeholder: labels.pickRelation,
|
|
1514
|
+
testId: "database-column-rollup-relation"
|
|
1515
|
+
}
|
|
1516
|
+
) }),
|
|
1517
|
+
draft.relation && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[8rem_1fr] gap-2", children: [
|
|
1518
|
+
/* @__PURE__ */ jsxRuntime.jsx(Field, { label: labels.rollupOp, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1519
|
+
ui.Select,
|
|
1520
|
+
{
|
|
1521
|
+
value: draft.op,
|
|
1522
|
+
onValueChange: (op) => onChange({ ...draft, op }),
|
|
1523
|
+
children: [
|
|
1524
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.SelectTrigger, { "data-testid": "database-column-rollup-op", children: /* @__PURE__ */ jsxRuntime.jsx(ui.SelectValue, {}) }),
|
|
1525
|
+
/* @__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)) })
|
|
1526
|
+
]
|
|
1527
|
+
}
|
|
1528
|
+
) }),
|
|
1529
|
+
draft.op !== "count" && /* @__PURE__ */ jsxRuntime.jsx(Field, { label: labels.rollupColumn, children: numbers.length ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1530
|
+
ColumnSelect,
|
|
1531
|
+
{
|
|
1532
|
+
value: draft.column,
|
|
1533
|
+
onChange: (column) => onChange({ ...draft, column }),
|
|
1534
|
+
columns: numbers,
|
|
1535
|
+
placeholder: labels.pickColumn,
|
|
1536
|
+
testId: "database-column-rollup-column"
|
|
1537
|
+
}
|
|
1538
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(Hint, { children: labels.noNumberColumns }) })
|
|
1539
|
+
] })
|
|
1540
|
+
] });
|
|
1541
|
+
}
|
|
1542
|
+
var DEFAULT_DATABASE_ROW_DETAIL_LABELS = {
|
|
1543
|
+
untitled: "Untitled",
|
|
1544
|
+
fields: "Fields",
|
|
1545
|
+
documents: "Linked documents",
|
|
1546
|
+
noDocuments: "No document is linked to this row.",
|
|
1547
|
+
empty: "Empty",
|
|
1548
|
+
deleteRow: "Delete row",
|
|
1549
|
+
close: "Close",
|
|
1550
|
+
computed: "Computed from a relation",
|
|
1551
|
+
draft: "Draft: only you can see it. Submit it when it is ready; once submitted it can\u2019t be taken back.",
|
|
1552
|
+
submit: "Submit",
|
|
1553
|
+
addField: "New field"
|
|
1554
|
+
};
|
|
1555
|
+
var asText2 = (v) => typeof v === "string" && v ? v : null;
|
|
1556
|
+
function DraftInput({
|
|
1557
|
+
value,
|
|
1558
|
+
type,
|
|
1559
|
+
onCommit,
|
|
1560
|
+
testId,
|
|
1561
|
+
label
|
|
1562
|
+
}) {
|
|
1563
|
+
const [draft, setDraft] = react.useState(value);
|
|
1564
|
+
react.useEffect(() => setDraft(value), [value]);
|
|
1565
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1566
|
+
ui.Input,
|
|
1567
|
+
{
|
|
1568
|
+
type,
|
|
1569
|
+
value: draft,
|
|
1570
|
+
"aria-label": label,
|
|
1571
|
+
onChange: (e) => setDraft(e.target.value),
|
|
1572
|
+
onBlur: () => draft !== value && onCommit(draft),
|
|
1573
|
+
onKeyDown: (e) => {
|
|
1574
|
+
if (e.key === "Enter") e.currentTarget.blur();
|
|
1575
|
+
if (e.key === "Escape") {
|
|
1576
|
+
setDraft(value);
|
|
1577
|
+
requestAnimationFrame(() => e.target.blur());
|
|
1578
|
+
}
|
|
1579
|
+
},
|
|
1580
|
+
className: "h-8",
|
|
1581
|
+
"data-testid": testId
|
|
1582
|
+
}
|
|
1583
|
+
);
|
|
1584
|
+
}
|
|
1585
|
+
function PopoverField({
|
|
1586
|
+
display,
|
|
1587
|
+
emptyLabel,
|
|
1588
|
+
testId,
|
|
1589
|
+
label,
|
|
1590
|
+
renderEditor,
|
|
1591
|
+
onCommit
|
|
1592
|
+
}) {
|
|
1593
|
+
const [open, setOpen] = react.useState(false);
|
|
1594
|
+
const pending = react.useRef(null);
|
|
1595
|
+
const cancelled = react.useRef(false);
|
|
1596
|
+
const close = (keep) => {
|
|
1597
|
+
setOpen(false);
|
|
1598
|
+
const change = pending.current;
|
|
1599
|
+
pending.current = null;
|
|
1600
|
+
if (change && !cancelled.current) onCommit(change.value);
|
|
1601
|
+
cancelled.current = false;
|
|
1602
|
+
};
|
|
1603
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1604
|
+
ui.Popover,
|
|
1605
|
+
{
|
|
1606
|
+
open,
|
|
1607
|
+
onOpenChange: (next) => {
|
|
1608
|
+
if (next) {
|
|
1609
|
+
pending.current = null;
|
|
1610
|
+
cancelled.current = false;
|
|
1611
|
+
setOpen(true);
|
|
1612
|
+
} else close();
|
|
1613
|
+
},
|
|
1614
|
+
children: [
|
|
1615
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1616
|
+
"div",
|
|
1617
|
+
{
|
|
1618
|
+
role: "button",
|
|
1619
|
+
tabIndex: 0,
|
|
1620
|
+
"aria-label": label,
|
|
1621
|
+
"aria-haspopup": "dialog",
|
|
1622
|
+
onKeyDown: (e) => {
|
|
1623
|
+
if (e.target === e.currentTarget && (e.key === "Enter" || e.key === " ")) {
|
|
1624
|
+
e.preventDefault();
|
|
1625
|
+
setOpen(true);
|
|
1626
|
+
}
|
|
1627
|
+
},
|
|
1628
|
+
className: "flex min-h-8 w-full min-w-0 cursor-pointer items-center rounded-md border border-input bg-transparent px-2 py-1 text-left text-sm outline-none hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-ring",
|
|
1629
|
+
"data-testid": testId,
|
|
1630
|
+
children: display ?? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: emptyLabel })
|
|
1631
|
+
}
|
|
1632
|
+
) }),
|
|
1633
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1634
|
+
ui.PopoverContent,
|
|
1635
|
+
{
|
|
1636
|
+
align: "start",
|
|
1637
|
+
className: "w-auto border-0 bg-transparent p-0 shadow-none",
|
|
1638
|
+
onEscapeKeyDown: () => {
|
|
1639
|
+
cancelled.current = true;
|
|
1640
|
+
},
|
|
1641
|
+
children: renderEditor({
|
|
1642
|
+
onValueChange: (value) => {
|
|
1643
|
+
pending.current = { value };
|
|
1644
|
+
},
|
|
1645
|
+
stopEditing: () => close()
|
|
1646
|
+
})
|
|
1647
|
+
}
|
|
1648
|
+
)
|
|
1649
|
+
]
|
|
1650
|
+
}
|
|
1651
|
+
);
|
|
1652
|
+
}
|
|
1653
|
+
function DatabaseRowDetail({
|
|
1654
|
+
row,
|
|
1655
|
+
columns,
|
|
1656
|
+
title: ownTitle,
|
|
1657
|
+
renderField,
|
|
1658
|
+
footer,
|
|
1659
|
+
onChange,
|
|
1660
|
+
sources,
|
|
1661
|
+
onDelete,
|
|
1662
|
+
isDeleting = false,
|
|
1663
|
+
onSubmit,
|
|
1664
|
+
onAddColumn,
|
|
1665
|
+
onClose,
|
|
1666
|
+
readOnly = false,
|
|
1667
|
+
locale,
|
|
1668
|
+
labels,
|
|
1669
|
+
className,
|
|
1670
|
+
testId = "database-row-detail"
|
|
1671
|
+
}) {
|
|
1672
|
+
const l = { ...DEFAULT_DATABASE_ROW_DETAIL_LABELS, ...labels };
|
|
1673
|
+
const title = ownTitle ?? (row ? rowTitle(row, columns, locale) || l.untitled : "");
|
|
1674
|
+
const commit = (column, value, extra) => {
|
|
1675
|
+
if (!row || !onChange) return;
|
|
1676
|
+
const next = toApiValue(value, column.type);
|
|
1677
|
+
const siblingsSame = !extra || Object.entries(extra).every(([id, v]) => sameCellValue(v ?? null, row.values[id] ?? null));
|
|
1678
|
+
if (sameCellValue(next, row.values[column.id], column.type) && siblingsSame) return;
|
|
1679
|
+
if (extra) onChange(row, column.id, next, extra);
|
|
1680
|
+
else onChange(row, column.id, next);
|
|
1681
|
+
};
|
|
1682
|
+
const fieldEditor = (column) => {
|
|
1683
|
+
if (!row) return null;
|
|
1684
|
+
const value = row.values[column.id];
|
|
1685
|
+
const id = `${testId}-input-${column.id}`;
|
|
1686
|
+
const editable = !readOnly && Boolean(onChange) && canEditColumn(column, sources);
|
|
1687
|
+
const span = column.type === "date" ? column.span : void 0;
|
|
1688
|
+
const display = () => {
|
|
1689
|
+
switch (column.type) {
|
|
1690
|
+
case "label":
|
|
1691
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LabelsCell, { value, titles: row.titles });
|
|
1692
|
+
case "date": {
|
|
1693
|
+
const text = span ? chunk66IOCKWS_cjs.formatSpan(
|
|
1694
|
+
typeof value === "string" ? value : null,
|
|
1695
|
+
asText2(row.values[span.endColumnId]),
|
|
1696
|
+
span.timezoneColumnId ? asText2(row.values[span.timezoneColumnId]) : null
|
|
1697
|
+
) : formatCell(value, column.type, locale, row.titles);
|
|
1698
|
+
return text ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "break-words", children: text }) : null;
|
|
1699
|
+
}
|
|
1700
|
+
case "select":
|
|
1701
|
+
return typeof value === "string" && value ? /* @__PURE__ */ jsxRuntime.jsx(SelectChip, { value }) : null;
|
|
1702
|
+
case "person":
|
|
1703
|
+
return cellIds(value).length ? /* @__PURE__ */ jsxRuntime.jsx(PersonCell, { value, titles: row.titles }) : null;
|
|
1704
|
+
case "document":
|
|
1705
|
+
case "relation":
|
|
1706
|
+
return cellIds(value).length ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1707
|
+
LinkChipsCell,
|
|
1708
|
+
{
|
|
1709
|
+
value,
|
|
1710
|
+
titles: row.titles,
|
|
1711
|
+
kind: column.type,
|
|
1712
|
+
onOpenDocument: sources?.onOpenDocument,
|
|
1713
|
+
wrap: true
|
|
1714
|
+
}
|
|
1715
|
+
) : null;
|
|
1716
|
+
case "lookup":
|
|
1717
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LookupCell, { value, titles: row.titles, locale, wrap: true });
|
|
1718
|
+
default: {
|
|
1719
|
+
const text = formatCell(value, column.type, locale, row.titles);
|
|
1720
|
+
return text ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "break-words", children: text }) : null;
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
};
|
|
1724
|
+
if (column.type === "source") {
|
|
1725
|
+
const editSources = sources?.renderSourcesEditor;
|
|
1726
|
+
if (editSources && !readOnly && onChange && !column.locked) {
|
|
1727
|
+
return editSources({
|
|
1728
|
+
testId: id,
|
|
1729
|
+
value: citationsOf(value),
|
|
1730
|
+
titles: row.titles,
|
|
1731
|
+
rowId: row.id,
|
|
1732
|
+
onChange: (next) => commit(column, next)
|
|
1733
|
+
});
|
|
1734
|
+
}
|
|
1735
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1736
|
+
SourcesField,
|
|
1737
|
+
{
|
|
1738
|
+
testId: id,
|
|
1739
|
+
value,
|
|
1740
|
+
titles: row.titles,
|
|
1741
|
+
onOpenDocument: sources?.onOpenDocument
|
|
1742
|
+
}
|
|
1743
|
+
);
|
|
1744
|
+
}
|
|
1745
|
+
if (!editable) {
|
|
1746
|
+
const shown = display();
|
|
1747
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1748
|
+
"div",
|
|
1749
|
+
{
|
|
1750
|
+
className: ui.cn(
|
|
1751
|
+
"flex min-h-8 min-w-0 items-center py-1 text-sm",
|
|
1752
|
+
isComputedColumn(column) && "text-muted-foreground"
|
|
1753
|
+
),
|
|
1754
|
+
title: isComputedColumn(column) ? l.computed : void 0,
|
|
1755
|
+
"data-testid": id,
|
|
1756
|
+
children: shown ?? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "\u2014" })
|
|
1757
|
+
}
|
|
1758
|
+
);
|
|
1759
|
+
}
|
|
1760
|
+
switch (column.type) {
|
|
1761
|
+
case "checkbox":
|
|
1762
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-h-8 items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1763
|
+
ui.Checkbox,
|
|
1764
|
+
{
|
|
1765
|
+
checked: value === true,
|
|
1766
|
+
"aria-label": column.name,
|
|
1767
|
+
onCheckedChange: (checked) => commit(column, checked === true),
|
|
1768
|
+
"data-testid": id
|
|
1769
|
+
}
|
|
1770
|
+
) });
|
|
1771
|
+
case "label":
|
|
1772
|
+
return sources?.labels ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1773
|
+
LabelsField,
|
|
1774
|
+
{
|
|
1775
|
+
testId: id,
|
|
1776
|
+
value,
|
|
1777
|
+
titles: row.titles,
|
|
1778
|
+
labels: labelSourceFor(sources.labels, column),
|
|
1779
|
+
onChange: (ids) => commit(column, ids)
|
|
1780
|
+
}
|
|
1781
|
+
) : null;
|
|
1782
|
+
case "date":
|
|
1783
|
+
if (span) {
|
|
1784
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1785
|
+
DateSpanField,
|
|
1786
|
+
{
|
|
1787
|
+
idPrefix: id,
|
|
1788
|
+
value: {
|
|
1789
|
+
start: asText2(value),
|
|
1790
|
+
end: asText2(row.values[span.endColumnId]),
|
|
1791
|
+
timezone: span.timezoneColumnId ? asText2(row.values[span.timezoneColumnId]) : null
|
|
1792
|
+
},
|
|
1793
|
+
onCommit: (v) => commit(column, v.start, {
|
|
1794
|
+
[span.endColumnId]: v.end,
|
|
1795
|
+
...span.timezoneColumnId ? { [span.timezoneColumnId]: v.timezone } : {}
|
|
1796
|
+
})
|
|
1797
|
+
}
|
|
1798
|
+
);
|
|
1799
|
+
}
|
|
1800
|
+
// falls through: a date without a span is a plain date box
|
|
1801
|
+
case "number":
|
|
1802
|
+
case "text": {
|
|
1803
|
+
const text = value == null ? "" : column.type === "date" ? String(value).slice(0, 10) : String(value);
|
|
1804
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1805
|
+
DraftInput,
|
|
1806
|
+
{
|
|
1807
|
+
value: text,
|
|
1808
|
+
type: column.type,
|
|
1809
|
+
label: column.name,
|
|
1810
|
+
onCommit: (next) => commit(column, next),
|
|
1811
|
+
testId: id
|
|
1812
|
+
}
|
|
1813
|
+
);
|
|
1814
|
+
}
|
|
1815
|
+
case "select":
|
|
1816
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1817
|
+
PopoverField,
|
|
1818
|
+
{
|
|
1819
|
+
display: display(),
|
|
1820
|
+
emptyLabel: l.empty,
|
|
1821
|
+
label: column.name,
|
|
1822
|
+
testId: id,
|
|
1823
|
+
onCommit: (next) => commit(column, next),
|
|
1824
|
+
renderEditor: (editor) => /* @__PURE__ */ jsxRuntime.jsx(SelectCellEditor, { ...editor, value, options: column.options ?? [] })
|
|
1825
|
+
}
|
|
1826
|
+
);
|
|
1827
|
+
case "person":
|
|
1828
|
+
case "document":
|
|
1829
|
+
case "relation": {
|
|
1830
|
+
const target = column.relation?.database_id;
|
|
1831
|
+
const searchRows = sources?.searchRows;
|
|
1832
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1833
|
+
PopoverField,
|
|
1834
|
+
{
|
|
1835
|
+
display: display(),
|
|
1836
|
+
emptyLabel: l.empty,
|
|
1837
|
+
label: column.name,
|
|
1838
|
+
testId: id,
|
|
1839
|
+
onCommit: (next) => commit(column, next),
|
|
1840
|
+
renderEditor: (editor) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1841
|
+
PickCellEditor,
|
|
1842
|
+
{
|
|
1843
|
+
...editor,
|
|
1844
|
+
value,
|
|
1845
|
+
data: row,
|
|
1846
|
+
kind: column.type,
|
|
1847
|
+
options: column.type === "person" ? sources?.members : column.type === "document" ? sources?.documents : void 0,
|
|
1848
|
+
search: column.type === "relation" && target && searchRows ? (q) => searchRows(target, q) : void 0
|
|
1849
|
+
}
|
|
1850
|
+
)
|
|
1851
|
+
}
|
|
1852
|
+
);
|
|
1853
|
+
}
|
|
1854
|
+
default:
|
|
1855
|
+
return null;
|
|
1856
|
+
}
|
|
1857
|
+
};
|
|
1858
|
+
const documents = /* @__PURE__ */ new Map();
|
|
1859
|
+
if (row) {
|
|
1860
|
+
for (const column of columns) {
|
|
1861
|
+
if (column.type !== "document") continue;
|
|
1862
|
+
for (const id of cellIds(row.values[column.id])) {
|
|
1863
|
+
documents.set(id, [...documents.get(id) ?? [], column.name]);
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
const openDocument = sources?.onOpenDocument;
|
|
1868
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1869
|
+
chunkU46OGRCO_cjs.DetailPanel,
|
|
1870
|
+
{
|
|
1871
|
+
title,
|
|
1872
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Rows3, { className: "size-4" }),
|
|
1873
|
+
isLoading: !row,
|
|
1874
|
+
onClose,
|
|
1875
|
+
labels: { close: l.close },
|
|
1876
|
+
className,
|
|
1877
|
+
testId,
|
|
1878
|
+
footer,
|
|
1879
|
+
actions: row && onDelete && !readOnly ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1880
|
+
ui.Button,
|
|
1881
|
+
{
|
|
1882
|
+
variant: "ghost",
|
|
1883
|
+
size: "icon",
|
|
1884
|
+
className: "size-8 text-red-text",
|
|
1885
|
+
onClick: () => onDelete(row),
|
|
1886
|
+
disabled: isDeleting,
|
|
1887
|
+
"aria-label": l.deleteRow,
|
|
1888
|
+
title: l.deleteRow,
|
|
1889
|
+
"data-testid": `${testId}-delete`,
|
|
1890
|
+
children: isDeleting ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-4 animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "size-4" })
|
|
1891
|
+
}
|
|
1892
|
+
) : void 0,
|
|
1893
|
+
children: [
|
|
1894
|
+
row && row.shared === false && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1895
|
+
"div",
|
|
1896
|
+
{
|
|
1897
|
+
className: "mx-3 mb-2 flex items-center justify-between gap-2 rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",
|
|
1898
|
+
"data-testid": `${testId}-draft`,
|
|
1899
|
+
children: [
|
|
1900
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: l.draft }),
|
|
1901
|
+
onSubmit && /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "sm", onClick: () => onSubmit(row), "data-testid": `${testId}-submit`, children: l.submit })
|
|
1902
|
+
]
|
|
1903
|
+
}
|
|
1904
|
+
),
|
|
1905
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkU46OGRCO_cjs.DetailSection, { title: l.fields, testId: `${testId}-fields`, children: [
|
|
1906
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkU46OGRCO_cjs.DetailFields, { children: columns.map((column) => {
|
|
1907
|
+
const Icon = COLUMN_TYPE_ICONS[column.type];
|
|
1908
|
+
const own = row ? renderField?.(column, row) : void 0;
|
|
1909
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1910
|
+
chunkU46OGRCO_cjs.DetailField,
|
|
1911
|
+
{
|
|
1912
|
+
label: column.name,
|
|
1913
|
+
icon: Icon ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-3.5" }) : void 0,
|
|
1914
|
+
hint: own?.hint,
|
|
1915
|
+
wide: own?.wide,
|
|
1916
|
+
testId: `${testId}-field-${column.id}`,
|
|
1917
|
+
children: own?.content !== void 0 ? own.content : fieldEditor(column)
|
|
1918
|
+
},
|
|
1919
|
+
column.id
|
|
1920
|
+
);
|
|
1921
|
+
}) }),
|
|
1922
|
+
onAddColumn && !readOnly && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1923
|
+
ui.Button,
|
|
1924
|
+
{
|
|
1925
|
+
type: "button",
|
|
1926
|
+
variant: "ghost",
|
|
1927
|
+
size: "sm",
|
|
1928
|
+
className: "mt-1 gap-1.5 text-muted-foreground",
|
|
1929
|
+
onClick: onAddColumn,
|
|
1930
|
+
"data-testid": `${testId}-add-field`,
|
|
1931
|
+
children: [
|
|
1932
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4", "aria-hidden": true }),
|
|
1933
|
+
l.addField
|
|
1934
|
+
]
|
|
1935
|
+
}
|
|
1936
|
+
)
|
|
1937
|
+
] }),
|
|
1938
|
+
columns.some((c) => c.type === "document") && /* @__PURE__ */ jsxRuntime.jsx(chunkU46OGRCO_cjs.DetailSection, { title: l.documents, count: documents.size, testId: `${testId}-documents`, children: documents.size ? /* @__PURE__ */ jsxRuntime.jsx(chunkU46OGRCO_cjs.DetailLinkList, { children: [...documents].map(([id, via]) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1939
|
+
chunkU46OGRCO_cjs.DetailLinkItem,
|
|
1940
|
+
{
|
|
1941
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "size-4" }),
|
|
1942
|
+
onClick: openDocument ? () => openDocument(id) : void 0,
|
|
1943
|
+
testId: `${testId}-doc-${id}`,
|
|
1944
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "min-w-0 flex-1", children: [
|
|
1945
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "block truncate font-medium", children: titleOf(id, row?.titles) }),
|
|
1946
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "block truncate text-xs text-muted-foreground", children: via.join(", ") })
|
|
1947
|
+
] })
|
|
1948
|
+
},
|
|
1949
|
+
id
|
|
1950
|
+
)) }) : /* @__PURE__ */ jsxRuntime.jsx(chunkU46OGRCO_cjs.DetailEmpty, { children: l.noDocuments }) })
|
|
1951
|
+
]
|
|
1952
|
+
}
|
|
1953
|
+
);
|
|
1954
|
+
}
|
|
1955
|
+
var escapeHtml = (text) => text.replace(/[&<>"']/g, (ch) => `&#${ch.charCodeAt(0)};`);
|
|
1956
|
+
var DEFAULT_DATABASE_TABLE_LABELS = {
|
|
1957
|
+
newRow: "New row",
|
|
1958
|
+
emptyTitle: "No rows yet",
|
|
1959
|
+
emptyMessage: "Add a row, or import a spreadsheet.",
|
|
1960
|
+
noColumnsTitle: "No columns yet",
|
|
1961
|
+
noColumnsMessage: "Add a column to start.",
|
|
1962
|
+
noMatches: "No rows match your search or filters."
|
|
1963
|
+
};
|
|
1964
|
+
function regrowAfterDrag(event) {
|
|
1965
|
+
if (!event.finished || event.source !== "uiColumnResized") return;
|
|
1966
|
+
const grid = event.api;
|
|
1967
|
+
if (grid.isDestroyed()) return;
|
|
1968
|
+
const dragged = new Set((event.columns ?? []).map((column) => column.getColId()));
|
|
1969
|
+
const state = (grid.getColumns() ?? []).flatMap((column) => {
|
|
1970
|
+
const flex = dragged.has(column.getColId()) ? null : column.getFlex();
|
|
1971
|
+
return flex ? [{ colId: column.getColId(), flex }] : [];
|
|
1972
|
+
});
|
|
1973
|
+
if (state.length > 0) grid.applyColumnState({ state, applyOrder: false });
|
|
1974
|
+
}
|
|
1975
|
+
function DatabaseTable({
|
|
1976
|
+
columns,
|
|
1977
|
+
rows,
|
|
1978
|
+
onCellChange,
|
|
1979
|
+
onAddRow,
|
|
1980
|
+
onAddColumn,
|
|
1981
|
+
onEditColumn,
|
|
1982
|
+
onOpenRow,
|
|
1983
|
+
isCellEditable,
|
|
1984
|
+
renderRowActions,
|
|
1985
|
+
getRowTestId,
|
|
1986
|
+
getCellTestId,
|
|
1987
|
+
testIds,
|
|
1988
|
+
sources,
|
|
1989
|
+
onSelectionChange,
|
|
1990
|
+
selected,
|
|
1991
|
+
readOnly = false,
|
|
1992
|
+
isFiltered = false,
|
|
1993
|
+
isLoading,
|
|
1994
|
+
locale,
|
|
1995
|
+
gridId,
|
|
1996
|
+
rowHeight = 38,
|
|
1997
|
+
height = "100%",
|
|
1998
|
+
labels,
|
|
1999
|
+
columnLabels,
|
|
2000
|
+
gridProps,
|
|
2001
|
+
testId,
|
|
2002
|
+
revealRowId,
|
|
2003
|
+
onRevealed,
|
|
2004
|
+
openRowId = null
|
|
2005
|
+
}) {
|
|
2006
|
+
const l = { ...DEFAULT_DATABASE_TABLE_LABELS, ...labels };
|
|
2007
|
+
const latest = react.useRef({
|
|
2008
|
+
onEditColumn,
|
|
2009
|
+
onAddColumn,
|
|
2010
|
+
onOpenRow,
|
|
2011
|
+
isCellEditable,
|
|
2012
|
+
renderRowActions,
|
|
2013
|
+
getRowTestId,
|
|
2014
|
+
getCellTestId,
|
|
2015
|
+
columns,
|
|
2016
|
+
openRowId
|
|
2017
|
+
});
|
|
2018
|
+
latest.current = {
|
|
2019
|
+
onEditColumn,
|
|
2020
|
+
onAddColumn,
|
|
2021
|
+
onOpenRow,
|
|
2022
|
+
isCellEditable,
|
|
2023
|
+
renderRowActions,
|
|
2024
|
+
getRowTestId,
|
|
2025
|
+
getCellTestId,
|
|
2026
|
+
columns,
|
|
2027
|
+
openRowId
|
|
2028
|
+
};
|
|
2029
|
+
const hasCellEditable = !!isCellEditable;
|
|
2030
|
+
const hasRowActions = !!renderRowActions;
|
|
2031
|
+
const hasEditColumn = !!onEditColumn;
|
|
2032
|
+
const hasAddColumn = !!onAddColumn;
|
|
2033
|
+
const hasOpenRow = !!onOpenRow;
|
|
2034
|
+
const editColumn = react.useMemo(
|
|
2035
|
+
() => hasEditColumn ? (column) => latest.current.onEditColumn?.(column) : void 0,
|
|
2036
|
+
[hasEditColumn]
|
|
2037
|
+
);
|
|
2038
|
+
const addColumn = react.useMemo(
|
|
2039
|
+
() => hasAddColumn ? () => latest.current.onAddColumn?.() : void 0,
|
|
2040
|
+
[hasAddColumn]
|
|
2041
|
+
);
|
|
2042
|
+
const openRow = react.useMemo(
|
|
2043
|
+
() => hasOpenRow ? (row, options) => options ? latest.current.onOpenRow?.(row, options) : latest.current.onOpenRow?.(row) : void 0,
|
|
2044
|
+
[hasOpenRow]
|
|
2045
|
+
);
|
|
2046
|
+
const cellEditable = react.useMemo(
|
|
2047
|
+
() => hasCellEditable ? (row, column) => latest.current.isCellEditable?.(row, column) ?? true : void 0,
|
|
2048
|
+
[hasCellEditable]
|
|
2049
|
+
);
|
|
2050
|
+
const rowActions = react.useMemo(
|
|
2051
|
+
() => hasRowActions ? (row) => latest.current.renderRowActions?.(row) : void 0,
|
|
2052
|
+
[hasRowActions]
|
|
2053
|
+
);
|
|
2054
|
+
const rowTestId = react.useCallback(
|
|
2055
|
+
(row) => latest.current.getRowTestId?.(row) ?? `database-row-${row.id}`,
|
|
2056
|
+
[]
|
|
2057
|
+
);
|
|
2058
|
+
const cellTestId = react.useCallback(
|
|
2059
|
+
(columnId, row) => latest.current.getCellTestId?.(columnId, row) ?? `database-cell-${row.id}-${columnId}`,
|
|
2060
|
+
[]
|
|
2061
|
+
);
|
|
2062
|
+
const latestSources = react.useRef(sources);
|
|
2063
|
+
latestSources.current = sources;
|
|
2064
|
+
const hasSources = !!sources;
|
|
2065
|
+
const hasSearchRows = !!sources?.searchRows;
|
|
2066
|
+
const hasOpenDocument = !!sources?.onOpenDocument;
|
|
2067
|
+
const hasLabels = !!sources?.labels;
|
|
2068
|
+
const members = sources?.members;
|
|
2069
|
+
const documents = sources?.documents;
|
|
2070
|
+
const labelOptions = sources?.labels?.options;
|
|
2071
|
+
const contentKey = react.useMemo(
|
|
2072
|
+
() => JSON.stringify([columns, members, documents, labelOptions]),
|
|
2073
|
+
[columns, members, documents, labelOptions]
|
|
2074
|
+
);
|
|
2075
|
+
const multiline = rowHeight >= chunkV5P5MRSR_cjs.rowHeightForLines(2);
|
|
2076
|
+
const columnDefs = react.useMemo(
|
|
2077
|
+
() => createDatabaseColumns(columns, {
|
|
2078
|
+
readOnly,
|
|
2079
|
+
onEditColumn: editColumn,
|
|
2080
|
+
onAddColumn: addColumn,
|
|
2081
|
+
onOpenRow: openRow,
|
|
2082
|
+
isCellEditable: cellEditable,
|
|
2083
|
+
renderRowActions: rowActions,
|
|
2084
|
+
sources: sources && {
|
|
2085
|
+
members: sources.members,
|
|
2086
|
+
documents: sources.documents,
|
|
2087
|
+
labels: hasLabels ? {
|
|
2088
|
+
options: sources.labels.options,
|
|
2089
|
+
onCreate: (name) => latestSources.current.labels.onCreate(name)
|
|
2090
|
+
} : void 0,
|
|
2091
|
+
searchRows: hasSearchRows ? (databaseId, q) => latestSources.current.searchRows(databaseId, q) : void 0,
|
|
2092
|
+
onOpenDocument: hasOpenDocument ? (documentId) => latestSources.current?.onOpenDocument?.(documentId) : void 0
|
|
2093
|
+
},
|
|
2094
|
+
locale,
|
|
2095
|
+
labels: columnLabels
|
|
2096
|
+
}),
|
|
2097
|
+
// `columns` and `sources` are read through `contentKey` (and the latest callbacks).
|
|
2098
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2099
|
+
[
|
|
2100
|
+
contentKey,
|
|
2101
|
+
hasSources,
|
|
2102
|
+
hasSearchRows,
|
|
2103
|
+
hasOpenDocument,
|
|
2104
|
+
hasLabels,
|
|
2105
|
+
readOnly,
|
|
2106
|
+
editColumn,
|
|
2107
|
+
addColumn,
|
|
2108
|
+
openRow,
|
|
2109
|
+
cellEditable,
|
|
2110
|
+
rowActions,
|
|
2111
|
+
locale,
|
|
2112
|
+
columnLabels
|
|
2113
|
+
]
|
|
2114
|
+
);
|
|
2115
|
+
const noColumns = columns.length === 0;
|
|
2116
|
+
const emptyState = {
|
|
2117
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Table2, { className: "size-8 text-muted-foreground" }),
|
|
2118
|
+
title: l.noColumnsTitle,
|
|
2119
|
+
message: readOnly ? void 0 : l.noColumnsMessage,
|
|
2120
|
+
action: !readOnly && onAddColumn ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Button, { onClick: onAddColumn, "data-testid": "database-empty-add-column", className: "gap-1.5", children: [
|
|
2121
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4" }),
|
|
2122
|
+
columnLabels?.addColumn ?? DEFAULT_DATABASE_COLUMN_LABELS.addColumn
|
|
2123
|
+
] }) : void 0
|
|
2124
|
+
};
|
|
2125
|
+
const noRowsText = isFiltered ? l.noMatches : readOnly ? l.emptyTitle : `${l.emptyTitle}. ${l.emptyMessage}`;
|
|
2126
|
+
const api = react.useRef(null);
|
|
2127
|
+
const knownColumns = react.useRef(null);
|
|
2128
|
+
react.useEffect(() => {
|
|
2129
|
+
const ids = new Set(columns.map((c) => c.id));
|
|
2130
|
+
const added = knownColumns.current ? columns.filter((c) => !knownColumns.current.has(c.id)) : [];
|
|
2131
|
+
knownColumns.current = ids;
|
|
2132
|
+
const last = added[added.length - 1];
|
|
2133
|
+
if (last && api.current) {
|
|
2134
|
+
const grid = api.current;
|
|
2135
|
+
setTimeout(() => grid.ensureColumnVisible(last.id, "end"), 0);
|
|
2136
|
+
}
|
|
2137
|
+
}, [columns]);
|
|
2138
|
+
const onRevealedRef = react.useRef(onRevealed);
|
|
2139
|
+
onRevealedRef.current = onRevealed;
|
|
2140
|
+
react.useEffect(() => {
|
|
2141
|
+
if (!revealRowId) return;
|
|
2142
|
+
const flash = setTimeout(() => {
|
|
2143
|
+
const grid = api.current;
|
|
2144
|
+
const node = grid?.getRowNode?.(revealRowId);
|
|
2145
|
+
if (grid && node) {
|
|
2146
|
+
grid.ensureNodeVisible(node, "middle");
|
|
2147
|
+
grid.flashCells({ rowNodes: [node] });
|
|
2148
|
+
}
|
|
2149
|
+
}, 300);
|
|
2150
|
+
const done = setTimeout(() => onRevealedRef.current?.(), 3e3);
|
|
2151
|
+
return () => {
|
|
2152
|
+
clearTimeout(flash);
|
|
2153
|
+
clearTimeout(done);
|
|
2154
|
+
};
|
|
2155
|
+
}, [revealRowId, rows.length]);
|
|
2156
|
+
const openRowOf = (row, columnId) => {
|
|
2157
|
+
if (row && latest.current.columns.find((c) => c.id === columnId)?.editIn === "row")
|
|
2158
|
+
latest.current.onOpenRow?.(row, { focusColumn: columnId });
|
|
2159
|
+
};
|
|
2160
|
+
const clickRowOf = (row, columnId) => {
|
|
2161
|
+
if (!row) return;
|
|
2162
|
+
const column = latest.current.columns.find((c) => c.id === columnId);
|
|
2163
|
+
if (!column) return;
|
|
2164
|
+
if (column.editIn === "row") return latest.current.onOpenRow?.(row, { focusColumn: columnId });
|
|
2165
|
+
const open = latest.current.openRowId;
|
|
2166
|
+
const plain = column.type !== "checkbox" && column.type !== "label" && column.type !== "source";
|
|
2167
|
+
if (open && open !== row.id && plain) latest.current.onOpenRow?.(row);
|
|
2168
|
+
};
|
|
2169
|
+
const shownOpenRow = react.useRef(null);
|
|
2170
|
+
react.useEffect(() => {
|
|
2171
|
+
const grid = api.current;
|
|
2172
|
+
const before = shownOpenRow.current;
|
|
2173
|
+
shownOpenRow.current = openRowId;
|
|
2174
|
+
if (!grid || grid.isDestroyed() || before === openRowId) return;
|
|
2175
|
+
const rowNodes = [before, openRowId].map((id) => id ? grid.getRowNode(id) : void 0).filter((node) => !!node);
|
|
2176
|
+
if (rowNodes.length) grid.redrawRows({ rowNodes });
|
|
2177
|
+
}, [openRowId]);
|
|
2178
|
+
const shownRowHeight = react.useRef(rowHeight);
|
|
2179
|
+
react.useEffect(() => {
|
|
2180
|
+
const grid = api.current;
|
|
2181
|
+
const before = shownRowHeight.current;
|
|
2182
|
+
shownRowHeight.current = rowHeight;
|
|
2183
|
+
if (before === rowHeight || !grid || grid.isDestroyed()) return;
|
|
2184
|
+
const sized = latest.current.columns.filter((c) => c.type === "label" || c.type === "source").map((c) => c.id);
|
|
2185
|
+
if (sized.length > 0) grid.refreshCells({ columns: sized, force: true });
|
|
2186
|
+
}, [rowHeight]);
|
|
2187
|
+
const handleCellValueChanged = (event) => {
|
|
2188
|
+
const columnId = event.column.getColId();
|
|
2189
|
+
if (!event.data || !onCellChange) return;
|
|
2190
|
+
const value = event.data.values[columnId] ?? null;
|
|
2191
|
+
const span = columns.find((c) => c.id === columnId)?.span;
|
|
2192
|
+
if (!span) return onCellChange(event.data, columnId, value);
|
|
2193
|
+
const extra = {
|
|
2194
|
+
[span.endColumnId]: event.data.values[span.endColumnId] ?? null
|
|
2195
|
+
};
|
|
2196
|
+
if (span.timezoneColumnId) {
|
|
2197
|
+
extra[span.timezoneColumnId] = event.data.values[span.timezoneColumnId] ?? null;
|
|
2198
|
+
}
|
|
2199
|
+
onCellChange(event.data, columnId, value, extra);
|
|
2200
|
+
};
|
|
2201
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2202
|
+
"div",
|
|
2203
|
+
{
|
|
2204
|
+
className: ui.cn(
|
|
2205
|
+
"database-table flex h-full min-h-0 flex-col",
|
|
2206
|
+
multiline && "database-table--multiline"
|
|
2207
|
+
),
|
|
2208
|
+
"data-testid": chunkPLIF5CUV_cjs.testIdOr(testId, { testId: "database-table" }),
|
|
2209
|
+
children: [
|
|
2210
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2211
|
+
chunkZVEW3JBT_cjs.GridView,
|
|
2212
|
+
{
|
|
2213
|
+
testId: testIds?.grid ?? "database-grid",
|
|
2214
|
+
items: rows,
|
|
2215
|
+
columnDefs,
|
|
2216
|
+
getItemId: (row) => row.id,
|
|
2217
|
+
getRowTestId: rowTestId,
|
|
2218
|
+
getCellTestId: cellTestId,
|
|
2219
|
+
isLoading,
|
|
2220
|
+
emptyState,
|
|
2221
|
+
showEmpty: noColumns,
|
|
2222
|
+
gridId,
|
|
2223
|
+
height,
|
|
2224
|
+
rowHeight,
|
|
2225
|
+
selection: onSelectionChange ? { mode: "multiple", selected: selected ?? [], onSelectionChange, controlled: true } : void 0,
|
|
2226
|
+
onCellValueChanged: handleCellValueChanged,
|
|
2227
|
+
...gridProps,
|
|
2228
|
+
onGridReady: (params) => {
|
|
2229
|
+
api.current = params.api;
|
|
2230
|
+
gridProps?.onGridReady?.(params);
|
|
2231
|
+
},
|
|
2232
|
+
gridOptions: {
|
|
2233
|
+
overlayNoRowsTemplate: `<span class="text-sm text-muted-foreground">${escapeHtml(noRowsText)}</span>`,
|
|
2234
|
+
singleClickEdit: false,
|
|
2235
|
+
stopEditingWhenCellsLoseFocus: true,
|
|
2236
|
+
enterNavigatesVerticallyAfterEdit: true,
|
|
2237
|
+
undoRedoCellEditing: false,
|
|
2238
|
+
rowClassRules: {
|
|
2239
|
+
"database-row-open": (p) => !!p.data && p.data.id === latest.current.openRowId
|
|
2240
|
+
},
|
|
2241
|
+
onCellClicked: (event) => clickRowOf(event.data, event.column.getColId()),
|
|
2242
|
+
onCellDoubleClicked: (event) => openRowOf(event.data, event.column.getColId()),
|
|
2243
|
+
onCellKeyDown: (event) => {
|
|
2244
|
+
if ("column" in event && event.event instanceof KeyboardEvent && event.event.key === "Enter")
|
|
2245
|
+
openRowOf(event.data, event.column.getColId());
|
|
2246
|
+
},
|
|
2247
|
+
...gridProps?.gridOptions,
|
|
2248
|
+
onColumnResized: (event) => {
|
|
2249
|
+
gridProps?.gridOptions?.onColumnResized?.(event);
|
|
2250
|
+
regrowAfterDrag(event);
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
) }),
|
|
2255
|
+
!readOnly && onAddRow && columns.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border px-2 py-1", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2256
|
+
ui.Button,
|
|
2257
|
+
{
|
|
2258
|
+
variant: "ghost",
|
|
2259
|
+
size: "sm",
|
|
2260
|
+
onClick: onAddRow,
|
|
2261
|
+
"data-testid": testIds?.addRow ?? "database-add-row",
|
|
2262
|
+
className: "gap-1.5 text-muted-foreground",
|
|
2263
|
+
children: [
|
|
2264
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4" }),
|
|
2265
|
+
l.newRow
|
|
2266
|
+
]
|
|
2267
|
+
}
|
|
2268
|
+
) })
|
|
2269
|
+
]
|
|
2270
|
+
}
|
|
2271
|
+
);
|
|
2272
|
+
}
|
|
2273
|
+
var DEFAULT_DATABASE_FILTER_MENU_LABELS = {
|
|
2274
|
+
...chunkLIJB6XOR_cjs.DEFAULT_CONDITIONS_LABELS,
|
|
2275
|
+
filterField: "Column",
|
|
2276
|
+
trigger: "Filter",
|
|
2277
|
+
active: (n) => `Filter (${n})`,
|
|
2278
|
+
clear: "Clear",
|
|
2279
|
+
conditions: (n) => n === 1 ? "1 condition" : `${n} conditions`
|
|
2280
|
+
};
|
|
2281
|
+
var toCondition = (f) => ({
|
|
2282
|
+
field: f.column,
|
|
2283
|
+
op: f.op,
|
|
2284
|
+
value: f.value
|
|
2285
|
+
});
|
|
2286
|
+
var toFilter = (c) => ({
|
|
2287
|
+
column: c.field,
|
|
2288
|
+
op: c.op,
|
|
2289
|
+
value: c.value ?? null
|
|
2290
|
+
});
|
|
2291
|
+
function completeFilters(filters) {
|
|
2292
|
+
return filters.filter(
|
|
2293
|
+
(f) => f.column && (!chunkLIJB6XOR_cjs.needsValue(f.op) || f.value !== void 0 && f.value !== null && f.value !== "")
|
|
2294
|
+
);
|
|
2295
|
+
}
|
|
2296
|
+
function DatabaseFilterMenu({
|
|
2297
|
+
columns,
|
|
2298
|
+
filters,
|
|
2299
|
+
onChange,
|
|
2300
|
+
labels,
|
|
2301
|
+
sources,
|
|
2302
|
+
extra,
|
|
2303
|
+
extraCount,
|
|
2304
|
+
onClearExtra,
|
|
2305
|
+
extraSummary
|
|
2306
|
+
}) {
|
|
2307
|
+
const l = { ...DEFAULT_DATABASE_FILTER_MENU_LABELS, ...labels };
|
|
2308
|
+
const count = filters.length + (extraCount ?? 0);
|
|
2309
|
+
const canClear = filters.length > 0 || (extraCount ?? 0) > 0 && Boolean(onClearExtra);
|
|
2310
|
+
const contentRef = react.useRef(null);
|
|
2311
|
+
const hint = extraSummary ? filters.length > 0 && l.conditions ? `${extraSummary}, ${l.conditions(filters.length)}` : extraSummary : void 0;
|
|
2312
|
+
const labelSource = sources?.labels;
|
|
2313
|
+
const documents = sources?.documents;
|
|
2314
|
+
const fields = react.useMemo(
|
|
2315
|
+
() => columns.map((c) => {
|
|
2316
|
+
const kit = kitOf(c.type);
|
|
2317
|
+
const base = { id: c.id, label: c.name, type: c.type };
|
|
2318
|
+
if (!kit) return base;
|
|
2319
|
+
const valueOptions = kit.filterInput === "label" ? labelSourceFor(labelSource, c)?.options.map((o) => ({ id: o.id, label: o.name })) : documents?.map((d) => ({ id: d.id, label: d.label }));
|
|
2320
|
+
return { ...base, ops: kit.filterOps, valueOptions };
|
|
2321
|
+
}),
|
|
2322
|
+
[columns, labelSource, documents]
|
|
2323
|
+
);
|
|
2324
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Popover, { children: [
|
|
2325
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2326
|
+
ui.Button,
|
|
2327
|
+
{
|
|
2328
|
+
variant: "ghost",
|
|
2329
|
+
size: "sm",
|
|
2330
|
+
className: ui.cn(
|
|
2331
|
+
"h-7 gap-1.5 px-2 text-sm font-normal text-muted-foreground hover:text-foreground pointer-coarse:h-11",
|
|
2332
|
+
count > 0 && "text-foreground"
|
|
2333
|
+
),
|
|
2334
|
+
title: hint,
|
|
2335
|
+
"data-testid": "database-filter-trigger",
|
|
2336
|
+
children: [
|
|
2337
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ListFilter, { className: "size-3.5" }),
|
|
2338
|
+
count ? l.active(count) : l.trigger
|
|
2339
|
+
]
|
|
2340
|
+
}
|
|
2341
|
+
) }),
|
|
2342
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2343
|
+
ui.PopoverContent,
|
|
2344
|
+
{
|
|
2345
|
+
ref: contentRef,
|
|
2346
|
+
className: "w-[min(560px,calc(100vw-32px))] p-3",
|
|
2347
|
+
align: "start",
|
|
2348
|
+
"data-testid": "database-filter-menu",
|
|
2349
|
+
children: [
|
|
2350
|
+
extra && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-3 border-b border-border pb-3", "data-testid": "database-filter-extra", children: extra }),
|
|
2351
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2352
|
+
chunkLIJB6XOR_cjs.ConditionsEditor,
|
|
2353
|
+
{
|
|
2354
|
+
fields,
|
|
2355
|
+
conditions: filters.map(toCondition),
|
|
2356
|
+
onChange: (next) => onChange(next.map(toFilter)),
|
|
2357
|
+
labels: l,
|
|
2358
|
+
testId: "database-filters"
|
|
2359
|
+
}
|
|
2360
|
+
),
|
|
2361
|
+
canClear && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2362
|
+
ui.Button,
|
|
2363
|
+
{
|
|
2364
|
+
variant: "ghost",
|
|
2365
|
+
size: "sm",
|
|
2366
|
+
className: "mt-2",
|
|
2367
|
+
onClick: () => {
|
|
2368
|
+
contentRef.current?.focus();
|
|
2369
|
+
if (filters.length > 0) onChange([]);
|
|
2370
|
+
onClearExtra?.();
|
|
2371
|
+
},
|
|
2372
|
+
"data-testid": "database-filter-clear",
|
|
2373
|
+
children: l.clear
|
|
2374
|
+
}
|
|
2375
|
+
)
|
|
2376
|
+
]
|
|
2377
|
+
}
|
|
2378
|
+
)
|
|
2379
|
+
] });
|
|
2380
|
+
}
|
|
2381
|
+
var DEFAULT_DATABASE_TOOLBAR_LABELS = {
|
|
2382
|
+
back: "All databases",
|
|
2383
|
+
rename: "Rename database",
|
|
2384
|
+
rows: (n) => `${n.toLocaleString()} row${n === 1 ? "" : "s"}`,
|
|
2385
|
+
showing: (shown, total) => `Showing ${shown.toLocaleString()} of ${total.toLocaleString()}`,
|
|
2386
|
+
search: "Search",
|
|
2387
|
+
deleteSelected: (n) => `Delete ${n} row${n === 1 ? "" : "s"}`,
|
|
2388
|
+
more: "More actions",
|
|
2389
|
+
importRows: "Import rows from a spreadsheet\u2026",
|
|
2390
|
+
exportXlsx: "Export to Excel (.xlsx)",
|
|
2391
|
+
exportCsv: "Export to CSV",
|
|
2392
|
+
chart: "Chart this",
|
|
2393
|
+
deleteDatabase: "Delete database",
|
|
2394
|
+
readOnly: "Read-only here: this database belongs to another workspace."
|
|
2395
|
+
};
|
|
2396
|
+
var ALL_EXPORT_FORMATS = ["xlsx", "csv"];
|
|
2397
|
+
var SPREADSHEET_ACCEPT = ".csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
2398
|
+
function DatabaseToolbar({
|
|
2399
|
+
name,
|
|
2400
|
+
icon: Icon = lucideReact.FileSpreadsheet,
|
|
2401
|
+
description,
|
|
2402
|
+
total,
|
|
2403
|
+
shown,
|
|
2404
|
+
search,
|
|
2405
|
+
onSearchChange,
|
|
2406
|
+
onBack,
|
|
2407
|
+
onRename,
|
|
2408
|
+
selectedCount = 0,
|
|
2409
|
+
onDeleteSelected,
|
|
2410
|
+
onImportRows,
|
|
2411
|
+
onExport,
|
|
2412
|
+
onChart,
|
|
2413
|
+
onDeleteDatabase,
|
|
2414
|
+
readOnly = false,
|
|
2415
|
+
filters,
|
|
2416
|
+
views,
|
|
2417
|
+
layoutSwitcher,
|
|
2418
|
+
layoutTools,
|
|
2419
|
+
hideControls = false,
|
|
2420
|
+
backTestId = "database-back",
|
|
2421
|
+
bulk,
|
|
2422
|
+
menuItems,
|
|
2423
|
+
status,
|
|
2424
|
+
onAddRow,
|
|
2425
|
+
addRowLabel = "New row",
|
|
2426
|
+
addRowTestId = "database-add-row",
|
|
2427
|
+
exportFormats = ALL_EXPORT_FORMATS,
|
|
2428
|
+
labels
|
|
2429
|
+
}) {
|
|
2430
|
+
const l = { ...DEFAULT_DATABASE_TOOLBAR_LABELS, ...labels };
|
|
2431
|
+
const [title, setTitle] = react.useState(name);
|
|
2432
|
+
const fileInput = react.useRef(null);
|
|
2433
|
+
react.useEffect(() => setTitle(name), [name]);
|
|
2434
|
+
const commitTitle = () => {
|
|
2435
|
+
const next = title.trim();
|
|
2436
|
+
if (next && next !== name) onRename?.(next);
|
|
2437
|
+
else setTitle(name);
|
|
2438
|
+
};
|
|
2439
|
+
const onTitleKey = (e) => {
|
|
2440
|
+
if (e.key === "Enter") e.currentTarget.blur();
|
|
2441
|
+
if (e.key === "Escape") {
|
|
2442
|
+
setTitle(name);
|
|
2443
|
+
e.currentTarget.blur();
|
|
2444
|
+
}
|
|
2445
|
+
};
|
|
2446
|
+
const onFile = (e) => {
|
|
2447
|
+
const file = e.target.files?.[0];
|
|
2448
|
+
if (file) onImportRows?.(file);
|
|
2449
|
+
e.target.value = "";
|
|
2450
|
+
};
|
|
2451
|
+
const canRename = !readOnly && Boolean(onRename);
|
|
2452
|
+
const canExport = Boolean(onExport) && exportFormats.length > 0;
|
|
2453
|
+
const hasPlainItems = canExport || Boolean(onChart) || !readOnly && Boolean(onImportRows);
|
|
2454
|
+
const hasMenu = !hideControls && Boolean(menuItems || hasPlainItems || !readOnly && Boolean(onDeleteDatabase));
|
|
2455
|
+
const showDeleteSelected = !hideControls && selectedCount > 0 && !bulk && !readOnly && Boolean(onDeleteSelected);
|
|
2456
|
+
const showAdd = !readOnly && Boolean(onAddRow);
|
|
2457
|
+
const hasStart = !hideControls || Boolean(layoutSwitcher) || Boolean(layoutTools);
|
|
2458
|
+
const hasEnd = !hideControls && (Boolean(views) || selectedCount > 0 && Boolean(bulk) || showDeleteSelected || hasMenu) || showAdd;
|
|
2459
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 px-2 pb-2 pt-1", "data-testid": "database-toolbar", children: [
|
|
2460
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
2461
|
+
onBack && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2462
|
+
ui.Button,
|
|
2463
|
+
{
|
|
2464
|
+
variant: "ghost",
|
|
2465
|
+
size: "icon",
|
|
2466
|
+
onClick: onBack,
|
|
2467
|
+
"aria-label": l.back,
|
|
2468
|
+
title: l.back,
|
|
2469
|
+
"data-testid": backTestId,
|
|
2470
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeft, { className: "size-4" })
|
|
2471
|
+
}
|
|
2472
|
+
),
|
|
2473
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2474
|
+
Icon,
|
|
2475
|
+
{
|
|
2476
|
+
className: "size-5 shrink-0 text-muted-foreground",
|
|
2477
|
+
"aria-hidden": true,
|
|
2478
|
+
"data-testid": "database-icon"
|
|
2479
|
+
}
|
|
2480
|
+
),
|
|
2481
|
+
canRename ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2482
|
+
"input",
|
|
2483
|
+
{
|
|
2484
|
+
value: title,
|
|
2485
|
+
"aria-label": l.rename,
|
|
2486
|
+
maxLength: 200,
|
|
2487
|
+
onChange: (e) => setTitle(e.target.value),
|
|
2488
|
+
onBlur: commitTitle,
|
|
2489
|
+
onKeyDown: onTitleKey,
|
|
2490
|
+
"data-testid": "database-title",
|
|
2491
|
+
className: "min-w-0 flex-1 truncate rounded-md bg-transparent px-1 text-xl font-semibold outline-none hover:bg-muted/60 focus:bg-muted/60"
|
|
2492
|
+
}
|
|
2493
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2494
|
+
"h2",
|
|
2495
|
+
{
|
|
2496
|
+
className: "min-w-0 flex-1 truncate px-1 text-xl font-semibold [font-family:inherit] tracking-normal",
|
|
2497
|
+
"data-testid": "database-title",
|
|
2498
|
+
children: name
|
|
2499
|
+
}
|
|
2500
|
+
),
|
|
2501
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 text-sm text-muted-foreground", "data-testid": "database-row-count", children: shown !== void 0 && shown < total ? l.showing(shown, total) : l.rows(total) }),
|
|
2502
|
+
status
|
|
2503
|
+
] }),
|
|
2504
|
+
description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-1 text-sm text-muted-foreground", children: description }),
|
|
2505
|
+
readOnly && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2506
|
+
"p",
|
|
2507
|
+
{
|
|
2508
|
+
className: "flex items-center gap-1.5 rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground",
|
|
2509
|
+
"data-testid": "database-read-only",
|
|
2510
|
+
children: [
|
|
2511
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: "size-3.5" }),
|
|
2512
|
+
l.readOnly
|
|
2513
|
+
]
|
|
2514
|
+
}
|
|
2515
|
+
),
|
|
2516
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-start gap-2", children: [
|
|
2517
|
+
hasStart && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2518
|
+
"div",
|
|
2519
|
+
{
|
|
2520
|
+
className: "flex min-h-9 min-w-0 flex-[1_1_24rem] flex-wrap items-center gap-2",
|
|
2521
|
+
"data-testid": "database-toolbar-start",
|
|
2522
|
+
children: [
|
|
2523
|
+
layoutSwitcher,
|
|
2524
|
+
!hideControls && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative min-w-32 max-w-48 flex-[1_1_8rem]", children: [
|
|
2525
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" }),
|
|
2526
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2527
|
+
ui.Input,
|
|
2528
|
+
{
|
|
2529
|
+
value: search,
|
|
2530
|
+
onChange: (e) => onSearchChange(e.target.value),
|
|
2531
|
+
placeholder: l.search,
|
|
2532
|
+
"aria-label": l.search,
|
|
2533
|
+
className: "h-8 pl-8",
|
|
2534
|
+
"data-testid": "database-search"
|
|
2535
|
+
}
|
|
2536
|
+
)
|
|
2537
|
+
] }),
|
|
2538
|
+
!hideControls && filters,
|
|
2539
|
+
layoutTools
|
|
2540
|
+
]
|
|
2541
|
+
}
|
|
2542
|
+
),
|
|
2543
|
+
hasEnd && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2544
|
+
"div",
|
|
2545
|
+
{
|
|
2546
|
+
className: "ml-auto flex min-h-9 shrink-0 items-center gap-2",
|
|
2547
|
+
"data-testid": "database-toolbar-end",
|
|
2548
|
+
children: [
|
|
2549
|
+
!hideControls && views,
|
|
2550
|
+
!hideControls && selectedCount > 0 && bulk,
|
|
2551
|
+
showDeleteSelected && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2552
|
+
ui.Button,
|
|
2553
|
+
{
|
|
2554
|
+
variant: "outline",
|
|
2555
|
+
size: "sm",
|
|
2556
|
+
onClick: onDeleteSelected,
|
|
2557
|
+
className: "gap-1.5 text-red-text",
|
|
2558
|
+
"data-testid": "database-delete-rows",
|
|
2559
|
+
children: [
|
|
2560
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "size-4" }),
|
|
2561
|
+
l.deleteSelected(selectedCount)
|
|
2562
|
+
]
|
|
2563
|
+
}
|
|
2564
|
+
),
|
|
2565
|
+
hasMenu && /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
2566
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2567
|
+
ui.Button,
|
|
2568
|
+
{
|
|
2569
|
+
variant: "outline",
|
|
2570
|
+
size: "icon",
|
|
2571
|
+
"aria-label": l.more,
|
|
2572
|
+
title: l.more,
|
|
2573
|
+
"data-testid": "database-menu",
|
|
2574
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreHorizontal, { className: "size-4" })
|
|
2575
|
+
}
|
|
2576
|
+
) }),
|
|
2577
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuContent, { align: "end", className: "w-64", children: [
|
|
2578
|
+
menuItems,
|
|
2579
|
+
menuItems && hasPlainItems && /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuSeparator, {}),
|
|
2580
|
+
!readOnly && onImportRows && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2581
|
+
ui.DropdownMenuItem,
|
|
2582
|
+
{
|
|
2583
|
+
onSelect: () => fileInput.current?.click(),
|
|
2584
|
+
"data-testid": "database-import-rows",
|
|
2585
|
+
children: [
|
|
2586
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { className: "size-4" }),
|
|
2587
|
+
l.importRows
|
|
2588
|
+
]
|
|
2589
|
+
}
|
|
2590
|
+
),
|
|
2591
|
+
onExport && exportFormats.includes("xlsx") && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2592
|
+
ui.DropdownMenuItem,
|
|
2593
|
+
{
|
|
2594
|
+
onSelect: () => onExport("xlsx"),
|
|
2595
|
+
"data-testid": "database-export-xlsx",
|
|
2596
|
+
children: [
|
|
2597
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Download, { className: "size-4" }),
|
|
2598
|
+
l.exportXlsx
|
|
2599
|
+
]
|
|
2600
|
+
}
|
|
2601
|
+
),
|
|
2602
|
+
onExport && exportFormats.includes("csv") && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2603
|
+
ui.DropdownMenuItem,
|
|
2604
|
+
{
|
|
2605
|
+
onSelect: () => onExport("csv"),
|
|
2606
|
+
"data-testid": "database-export-csv",
|
|
2607
|
+
children: [
|
|
2608
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Download, { className: "size-4" }),
|
|
2609
|
+
l.exportCsv
|
|
2610
|
+
]
|
|
2611
|
+
}
|
|
2612
|
+
),
|
|
2613
|
+
onChart && /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuItem, { onSelect: onChart, "data-testid": "database-chart", children: [
|
|
2614
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChartColumn, { className: "size-4" }),
|
|
2615
|
+
l.chart
|
|
2616
|
+
] }),
|
|
2617
|
+
!readOnly && onDeleteDatabase && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2618
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuSeparator, {}),
|
|
2619
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2620
|
+
ui.DropdownMenuItem,
|
|
2621
|
+
{
|
|
2622
|
+
onSelect: onDeleteDatabase,
|
|
2623
|
+
className: "text-red-text",
|
|
2624
|
+
"data-testid": "database-delete",
|
|
2625
|
+
children: [
|
|
2626
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "size-4" }),
|
|
2627
|
+
l.deleteDatabase
|
|
2628
|
+
]
|
|
2629
|
+
}
|
|
2630
|
+
)
|
|
2631
|
+
] })
|
|
2632
|
+
] })
|
|
2633
|
+
] }),
|
|
2634
|
+
showAdd && /* @__PURE__ */ jsxRuntime.jsxs(ui.Button, { onClick: onAddRow, "data-testid": addRowTestId, className: "gap-1.5", children: [
|
|
2635
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4" }),
|
|
2636
|
+
addRowLabel
|
|
2637
|
+
] })
|
|
2638
|
+
]
|
|
2639
|
+
}
|
|
2640
|
+
),
|
|
2641
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2642
|
+
"input",
|
|
2643
|
+
{
|
|
2644
|
+
ref: fileInput,
|
|
2645
|
+
type: "file",
|
|
2646
|
+
accept: SPREADSHEET_ACCEPT,
|
|
2647
|
+
className: "hidden",
|
|
2648
|
+
onChange: onFile,
|
|
2649
|
+
"data-testid": "database-import-rows-input"
|
|
2650
|
+
}
|
|
2651
|
+
)
|
|
2652
|
+
] })
|
|
2653
|
+
] });
|
|
2654
|
+
}
|
|
2655
|
+
var DEFAULT_DATABASE_COLUMN_DIALOG_LABELS = {
|
|
2656
|
+
addTitle: "Add a column",
|
|
2657
|
+
editTitle: "Column settings",
|
|
2658
|
+
addDescription: "Pick what the column holds; every cell in it is checked against its type.",
|
|
2659
|
+
editDescription: "Rename the column or change its options.",
|
|
2660
|
+
name: "Name",
|
|
2661
|
+
namePlaceholder: "e.g. Client, Reference, Fee",
|
|
2662
|
+
type: "Type",
|
|
2663
|
+
typeFixed: "A column\u2019s type can\u2019t be changed once it has been added.",
|
|
2664
|
+
options: "Options",
|
|
2665
|
+
optionPlaceholder: "Add an option and press Enter",
|
|
2666
|
+
addOption: "Add",
|
|
2667
|
+
removeOption: (option) => `Remove ${option}`,
|
|
2668
|
+
needsOptions: "A select column needs at least one option.",
|
|
2669
|
+
kinds: "Allowed kinds",
|
|
2670
|
+
needsKind: "A label column needs at least one kind.",
|
|
2671
|
+
cancel: "Cancel",
|
|
2672
|
+
add: "Add column",
|
|
2673
|
+
save: "Save",
|
|
2674
|
+
saving: "Saving\u2026",
|
|
2675
|
+
delete: "Delete column",
|
|
2676
|
+
confirmDelete: "Delete this column and every value in it?",
|
|
2677
|
+
editBy: "Who can set it",
|
|
2678
|
+
editByAnyone: "Anyone who can edit the row",
|
|
2679
|
+
editByOwners: "Workspace owners and the database\u2019s creator",
|
|
2680
|
+
editByListed: (database, column) => `The people listed in ${database} \u203A ${column}`,
|
|
2681
|
+
editByHint: "Listed people decide a request in this column (never their own): an approval. The server enforces it."
|
|
2682
|
+
};
|
|
2683
|
+
var LABEL_KINDS = [
|
|
2684
|
+
{ id: "label", name: "Label" },
|
|
2685
|
+
{ id: "annotation", name: "Annotation" },
|
|
2686
|
+
{ id: "search", name: "Search" },
|
|
2687
|
+
{ id: "issue", name: "Issue" },
|
|
2688
|
+
{ id: "person", name: "Person" },
|
|
2689
|
+
{ id: "organisation", name: "Organisation" }
|
|
2690
|
+
];
|
|
2691
|
+
var DEFAULT_KINDS = ["label"];
|
|
2692
|
+
var ALL_KINDS = LABEL_KINDS.map((k) => k.id);
|
|
2693
|
+
var NO_RELATION = { database_id: "", two_way: false, pair_name: "" };
|
|
2694
|
+
var NO_LOOKUP = { relation: "", column: "" };
|
|
2695
|
+
var NO_ROLLUP = { relation: "", column: "", op: "count" };
|
|
2696
|
+
var NO_COLUMNS = [];
|
|
2697
|
+
var NO_DATABASES = [];
|
|
2698
|
+
function configComplete(type, editing, relation, lookup, rollup) {
|
|
2699
|
+
if (type === "relation") return editing || Boolean(relation.database_id);
|
|
2700
|
+
if (type === "lookup") return Boolean(lookup.relation && lookup.column);
|
|
2701
|
+
if (type === "rollup") return Boolean(rollup.relation && (rollup.op === "count" || rollup.column));
|
|
2702
|
+
return true;
|
|
2703
|
+
}
|
|
2704
|
+
function DatabaseColumnDialog({
|
|
2705
|
+
open,
|
|
2706
|
+
onOpenChange,
|
|
2707
|
+
column,
|
|
2708
|
+
types = DATABASE_COLUMN_TYPES,
|
|
2709
|
+
databaseId,
|
|
2710
|
+
databaseName,
|
|
2711
|
+
columns = NO_COLUMNS,
|
|
2712
|
+
databases = NO_DATABASES,
|
|
2713
|
+
onSave,
|
|
2714
|
+
onDelete,
|
|
2715
|
+
isSaving = false,
|
|
2716
|
+
error,
|
|
2717
|
+
labels,
|
|
2718
|
+
typeLabels,
|
|
2719
|
+
configLabels
|
|
2720
|
+
}) {
|
|
2721
|
+
const l = { ...DEFAULT_DATABASE_COLUMN_DIALOG_LABELS, ...labels };
|
|
2722
|
+
const tl = { ...DEFAULT_DATABASE_COLUMN_TYPE_LABELS, ...typeLabels };
|
|
2723
|
+
const cl = { ...DEFAULT_COLUMN_CONFIG_LABELS, ...configLabels };
|
|
2724
|
+
const editing = Boolean(column);
|
|
2725
|
+
const [name, setName] = react.useState("");
|
|
2726
|
+
const [type, setType] = react.useState("text");
|
|
2727
|
+
const [options, setOptions] = react.useState([]);
|
|
2728
|
+
const [kinds, setKinds] = react.useState(DEFAULT_KINDS);
|
|
2729
|
+
const [optionDraft, setOptionDraft] = react.useState("");
|
|
2730
|
+
const [confirmingDelete, setConfirmingDelete] = react.useState(false);
|
|
2731
|
+
const [relation, setRelation] = react.useState(NO_RELATION);
|
|
2732
|
+
const [lookup, setLookup] = react.useState(NO_LOOKUP);
|
|
2733
|
+
const [rollup, setRollup] = react.useState(NO_ROLLUP);
|
|
2734
|
+
const [editBy, setEditBy] = react.useState("");
|
|
2735
|
+
react.useEffect(() => {
|
|
2736
|
+
if (!open) return;
|
|
2737
|
+
setName(column?.name ?? "");
|
|
2738
|
+
setType(column?.type ?? "text");
|
|
2739
|
+
setOptions(column?.options ?? []);
|
|
2740
|
+
setKinds(
|
|
2741
|
+
column?.type === "label" ? column.options?.length ? column.options : ALL_KINDS : DEFAULT_KINDS
|
|
2742
|
+
);
|
|
2743
|
+
setOptionDraft("");
|
|
2744
|
+
setConfirmingDelete(false);
|
|
2745
|
+
setRelation(NO_RELATION);
|
|
2746
|
+
setEditBy(
|
|
2747
|
+
column?.edit_by?.kind === "owners" ? "owners" : column?.edit_by?.kind === "listed" ? `listed:${column.edit_by.database_id}:${column.edit_by.column_id}` : ""
|
|
2748
|
+
);
|
|
2749
|
+
setLookup(column?.lookup ? { ...column.lookup } : NO_LOOKUP);
|
|
2750
|
+
setRollup(
|
|
2751
|
+
column?.rollup ? {
|
|
2752
|
+
relation: column.rollup.relation,
|
|
2753
|
+
column: column.rollup.column ?? "",
|
|
2754
|
+
op: column.rollup.op ?? "count"
|
|
2755
|
+
} : NO_ROLLUP
|
|
2756
|
+
);
|
|
2757
|
+
}, [open, column]);
|
|
2758
|
+
const offered = types.includes(type) ? types : [...types, type];
|
|
2759
|
+
const addOption = () => {
|
|
2760
|
+
const option = optionDraft.trim();
|
|
2761
|
+
if (option && !options.some((o) => o.toLowerCase() === option.toLowerCase())) {
|
|
2762
|
+
setOptions([...options, option]);
|
|
2763
|
+
}
|
|
2764
|
+
setOptionDraft("");
|
|
2765
|
+
};
|
|
2766
|
+
const pendingOptions = optionDraft.trim() ? [...options, optionDraft.trim()] : options;
|
|
2767
|
+
const missingOptions = type === "select" && pendingOptions.length === 0;
|
|
2768
|
+
const missingKinds = type === "label" && kinds.length === 0;
|
|
2769
|
+
const canSave = name.trim().length > 0 && !missingOptions && !missingKinds && configComplete(type, editing, relation, lookup, rollup) && !isSaving;
|
|
2770
|
+
const submit = (e) => {
|
|
2771
|
+
e.preventDefault();
|
|
2772
|
+
if (!canSave) return;
|
|
2773
|
+
const draft = {
|
|
2774
|
+
name: name.trim(),
|
|
2775
|
+
type,
|
|
2776
|
+
options: type === "select" ? Array.from(new Set(pendingOptions)) : type === "label" ? [
|
|
2777
|
+
...ALL_KINDS.filter((id) => kinds.includes(id)),
|
|
2778
|
+
// A kind the dialog does not list stays as it was stored.
|
|
2779
|
+
...kinds.filter((id) => !ALL_KINDS.includes(id))
|
|
2780
|
+
] : null
|
|
2781
|
+
};
|
|
2782
|
+
if (type === "relation" && !editing)
|
|
2783
|
+
draft.relation = {
|
|
2784
|
+
database_id: relation.database_id,
|
|
2785
|
+
two_way: relation.two_way,
|
|
2786
|
+
pair_name: relation.two_way ? relation.pair_name.trim() || null : null
|
|
2787
|
+
};
|
|
2788
|
+
const before = column?.edit_by ? column.edit_by.kind === "owners" ? "owners" : `listed:${column.edit_by.database_id}:${column.edit_by.column_id}` : "";
|
|
2789
|
+
if (editBy !== before) {
|
|
2790
|
+
const [kind, database_id, columnId] = editBy.split(":");
|
|
2791
|
+
draft.edit_by = kind === "owners" ? { kind: "owners" } : kind === "listed" ? { kind: "listed", database_id, column: columnId } : null;
|
|
2792
|
+
}
|
|
2793
|
+
if (type === "lookup") draft.lookup = { ...lookup };
|
|
2794
|
+
if (type === "rollup")
|
|
2795
|
+
draft.rollup = {
|
|
2796
|
+
relation: rollup.relation,
|
|
2797
|
+
op: rollup.op,
|
|
2798
|
+
column: rollup.op === "count" ? null : rollup.column
|
|
2799
|
+
};
|
|
2800
|
+
onSave(draft);
|
|
2801
|
+
};
|
|
2802
|
+
const onOptionKey = (e) => {
|
|
2803
|
+
if (e.key === "Enter") {
|
|
2804
|
+
e.preventDefault();
|
|
2805
|
+
addOption();
|
|
2806
|
+
}
|
|
2807
|
+
};
|
|
2808
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsx(ui.DialogContent, { className: "sm:max-w-md", "data-testid": "database-column-dialog", children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: submit, className: "flex flex-col gap-4", children: [
|
|
2809
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DialogHeader, { children: [
|
|
2810
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DialogTitle, { children: editing ? l.editTitle : l.addTitle }),
|
|
2811
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DialogDescription, { children: editing ? l.editDescription : l.addDescription })
|
|
2812
|
+
] }),
|
|
2813
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
2814
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { htmlFor: "database-column-name", children: l.name }),
|
|
2815
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2816
|
+
ui.Input,
|
|
2817
|
+
{
|
|
2818
|
+
id: "database-column-name",
|
|
2819
|
+
autoFocus: true,
|
|
2820
|
+
value: name,
|
|
2821
|
+
maxLength: 200,
|
|
2822
|
+
placeholder: l.namePlaceholder,
|
|
2823
|
+
onChange: (e) => setName(e.target.value),
|
|
2824
|
+
"data-testid": "database-column-name"
|
|
2825
|
+
}
|
|
2826
|
+
)
|
|
2827
|
+
] }),
|
|
2828
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
2829
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: l.type }),
|
|
2830
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2831
|
+
ui.Select,
|
|
2832
|
+
{
|
|
2833
|
+
value: type,
|
|
2834
|
+
onValueChange: (v) => setType(v),
|
|
2835
|
+
disabled: editing,
|
|
2836
|
+
children: [
|
|
2837
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.SelectTrigger, { "data-testid": "database-column-type", children: /* @__PURE__ */ jsxRuntime.jsx(ui.SelectValue, {}) }),
|
|
2838
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.SelectContent, { children: offered.map((t) => {
|
|
2839
|
+
const Icon = COLUMN_TYPE_ICONS[t];
|
|
2840
|
+
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: [
|
|
2841
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-4 text-muted-foreground" }),
|
|
2842
|
+
tl[t]
|
|
2843
|
+
] }) }, t);
|
|
2844
|
+
}) })
|
|
2845
|
+
]
|
|
2846
|
+
}
|
|
2847
|
+
),
|
|
2848
|
+
editing && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: l.typeFixed })
|
|
2849
|
+
] }),
|
|
2850
|
+
type === "select" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
2851
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { htmlFor: "database-column-option", children: l.options }),
|
|
2852
|
+
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: [
|
|
2853
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectChip, { value: option }),
|
|
2854
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2855
|
+
"button",
|
|
2856
|
+
{
|
|
2857
|
+
type: "button",
|
|
2858
|
+
"aria-label": l.removeOption(option),
|
|
2859
|
+
onClick: () => setOptions(options.filter((o) => o !== option)),
|
|
2860
|
+
className: "rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
2861
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "size-3" })
|
|
2862
|
+
}
|
|
2863
|
+
)
|
|
2864
|
+
] }, option)) }),
|
|
2865
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
|
|
2866
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2867
|
+
ui.Input,
|
|
2868
|
+
{
|
|
2869
|
+
id: "database-column-option",
|
|
2870
|
+
value: optionDraft,
|
|
2871
|
+
maxLength: 200,
|
|
2872
|
+
placeholder: l.optionPlaceholder,
|
|
2873
|
+
onChange: (e) => setOptionDraft(e.target.value),
|
|
2874
|
+
onKeyDown: onOptionKey,
|
|
2875
|
+
"data-testid": "database-column-option-input"
|
|
2876
|
+
}
|
|
2877
|
+
),
|
|
2878
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2879
|
+
ui.Button,
|
|
2880
|
+
{
|
|
2881
|
+
type: "button",
|
|
2882
|
+
variant: "outline",
|
|
2883
|
+
onClick: addOption,
|
|
2884
|
+
disabled: !optionDraft.trim(),
|
|
2885
|
+
children: l.addOption
|
|
2886
|
+
}
|
|
2887
|
+
)
|
|
2888
|
+
] }),
|
|
2889
|
+
missingOptions && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: l.needsOptions })
|
|
2890
|
+
] }),
|
|
2891
|
+
type === "label" && /* @__PURE__ */ jsxRuntime.jsxs("fieldset", { className: "m-0 flex min-w-0 flex-col gap-1.5 border-0 p-0", children: [
|
|
2892
|
+
/* @__PURE__ */ jsxRuntime.jsx("legend", { className: "mb-1.5 p-0 text-sm font-medium leading-none", children: l.kinds }),
|
|
2893
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 gap-1.5", "data-testid": "database-column-kinds", children: LABEL_KINDS.map((k) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
|
|
2894
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2895
|
+
ui.Checkbox,
|
|
2896
|
+
{
|
|
2897
|
+
checked: kinds.includes(k.id),
|
|
2898
|
+
onCheckedChange: (checked) => setKinds(
|
|
2899
|
+
checked === true ? [...kinds, k.id] : kinds.filter((x) => x !== k.id)
|
|
2900
|
+
),
|
|
2901
|
+
"data-testid": `database-column-kind-${k.id}`
|
|
2902
|
+
}
|
|
2903
|
+
),
|
|
2904
|
+
k.name
|
|
2905
|
+
] }, k.id)) }),
|
|
2906
|
+
missingKinds && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: l.needsKind })
|
|
2907
|
+
] }),
|
|
2908
|
+
type === "relation" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2909
|
+
RelationFields,
|
|
2910
|
+
{
|
|
2911
|
+
draft: relation,
|
|
2912
|
+
onChange: setRelation,
|
|
2913
|
+
databases,
|
|
2914
|
+
databaseId,
|
|
2915
|
+
databaseName,
|
|
2916
|
+
editing,
|
|
2917
|
+
column,
|
|
2918
|
+
labels: cl
|
|
2919
|
+
}
|
|
2920
|
+
),
|
|
2921
|
+
type === "lookup" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2922
|
+
LookupFields,
|
|
2923
|
+
{
|
|
2924
|
+
draft: lookup,
|
|
2925
|
+
onChange: setLookup,
|
|
2926
|
+
columns,
|
|
2927
|
+
databases,
|
|
2928
|
+
databaseId,
|
|
2929
|
+
labels: cl
|
|
2930
|
+
}
|
|
2931
|
+
),
|
|
2932
|
+
type === "rollup" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2933
|
+
RollupFields,
|
|
2934
|
+
{
|
|
2935
|
+
draft: rollup,
|
|
2936
|
+
onChange: setRollup,
|
|
2937
|
+
columns,
|
|
2938
|
+
databases,
|
|
2939
|
+
databaseId,
|
|
2940
|
+
labels: cl
|
|
2941
|
+
}
|
|
2942
|
+
),
|
|
2943
|
+
type !== "lookup" && type !== "rollup" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
2944
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: l.editBy }),
|
|
2945
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2946
|
+
"select",
|
|
2947
|
+
{
|
|
2948
|
+
className: "flex h-9 w-full rounded-md border border-input bg-background px-2 text-sm",
|
|
2949
|
+
value: editBy,
|
|
2950
|
+
onChange: (e) => setEditBy(e.target.value),
|
|
2951
|
+
"data-testid": "database-column-edit-by",
|
|
2952
|
+
children: [
|
|
2953
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: l.editByAnyone }),
|
|
2954
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "owners", children: l.editByOwners }),
|
|
2955
|
+
[
|
|
2956
|
+
...databaseId && !databases.some((d) => d.id === databaseId) ? [{ id: databaseId, name: databaseName ?? "", columns }] : [],
|
|
2957
|
+
...databases
|
|
2958
|
+
].flatMap(
|
|
2959
|
+
(d) => d.columns.filter((c) => c.type === "person" && c.id !== column?.id).map((c) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: `listed:${d.id}:${c.id}`, children: l.editByListed(d.name, c.name) }, `${d.id}:${c.id}`))
|
|
2960
|
+
)
|
|
2961
|
+
]
|
|
2962
|
+
}
|
|
2963
|
+
),
|
|
2964
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: l.editByHint })
|
|
2965
|
+
] }),
|
|
2966
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: "text-sm text-red-text", "data-testid": "database-column-error", children: error }),
|
|
2967
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DialogFooter, { className: "flex-row items-center gap-2 sm:justify-between", children: [
|
|
2968
|
+
editing && onDelete ? confirmingDelete ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2 text-sm", children: [
|
|
2969
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: l.confirmDelete }),
|
|
2970
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2971
|
+
ui.Button,
|
|
2972
|
+
{
|
|
2973
|
+
type: "button",
|
|
2974
|
+
variant: "destructive",
|
|
2975
|
+
size: "sm",
|
|
2976
|
+
onClick: onDelete,
|
|
2977
|
+
"data-testid": "database-column-delete-confirm",
|
|
2978
|
+
children: l.delete
|
|
2979
|
+
}
|
|
2980
|
+
)
|
|
2981
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2982
|
+
ui.Button,
|
|
2983
|
+
{
|
|
2984
|
+
type: "button",
|
|
2985
|
+
variant: "ghost",
|
|
2986
|
+
size: "sm",
|
|
2987
|
+
onClick: () => setConfirmingDelete(true),
|
|
2988
|
+
className: "gap-1.5 text-red-text",
|
|
2989
|
+
"data-testid": "database-column-delete",
|
|
2990
|
+
children: [
|
|
2991
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "size-4" }),
|
|
2992
|
+
l.delete
|
|
2993
|
+
]
|
|
2994
|
+
}
|
|
2995
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", {}),
|
|
2996
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex gap-2", children: [
|
|
2997
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), children: l.cancel }),
|
|
2998
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { type: "submit", disabled: !canSave, "data-testid": "database-column-save", children: isSaving ? l.saving : editing ? l.save : l.add })
|
|
2999
|
+
] })
|
|
3000
|
+
] })
|
|
3001
|
+
] }) }) });
|
|
3002
|
+
}
|
|
3003
|
+
var DEFAULT_DATABASE_LIST_LABELS = {
|
|
3004
|
+
title: "Databases",
|
|
3005
|
+
subtitle: "Tables your team keeps and searches \u2014 a client database, billing records, precedents.",
|
|
3006
|
+
newDatabase: "New database",
|
|
3007
|
+
importSpreadsheet: "Import spreadsheet",
|
|
3008
|
+
importing: "Importing\u2026",
|
|
3009
|
+
ownGroup: "In this workspace",
|
|
3010
|
+
sharedGroup: "Shared with everyone",
|
|
3011
|
+
readOnly: "Read-only",
|
|
3012
|
+
builtIn: "Built in",
|
|
3013
|
+
rows: (n) => `${n.toLocaleString()} row${n === 1 ? "" : "s"}`,
|
|
3014
|
+
columns: (n) => `${n} column${n === 1 ? "" : "s"}`,
|
|
3015
|
+
emptyTitle: "No databases yet",
|
|
3016
|
+
emptyMessage: "Start from a blank table, or import a spreadsheet (.xlsx or .csv) \u2014 its columns and their types come with it.",
|
|
3017
|
+
loading: "Loading databases\u2026"
|
|
3018
|
+
};
|
|
3019
|
+
var SPREADSHEET_ACCEPT2 = ".csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
3020
|
+
var CARD_CLASS = ui.cn(
|
|
3021
|
+
"flex min-h-32 flex-col gap-2 rounded-lg border border-border bg-background p-4 text-left transition-colors",
|
|
3022
|
+
"hover:border-primary/40 hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
3023
|
+
);
|
|
3024
|
+
function EntryCard({ entry, l }) {
|
|
3025
|
+
const Icon = entry.icon ?? lucideReact.FileSpreadsheet;
|
|
3026
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3027
|
+
"button",
|
|
3028
|
+
{
|
|
3029
|
+
type: "button",
|
|
3030
|
+
onClick: entry.onOpen,
|
|
3031
|
+
"data-testid": `database-card-${entry.id}`,
|
|
3032
|
+
"data-built-in": "",
|
|
3033
|
+
className: CARD_CLASS,
|
|
3034
|
+
children: [
|
|
3035
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex w-full items-start gap-2", children: [
|
|
3036
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "mt-0.5 size-5 shrink-0 text-muted-foreground", "aria-hidden": true }),
|
|
3037
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate font-medium", children: entry.name }),
|
|
3038
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex shrink-0 items-center rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground", children: l.builtIn })
|
|
3039
|
+
] }),
|
|
3040
|
+
entry.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "line-clamp-2 text-sm text-muted-foreground", children: entry.description }),
|
|
3041
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "mt-auto flex w-full flex-wrap items-center gap-3 text-xs text-muted-foreground", children: [
|
|
3042
|
+
entry.count && /* @__PURE__ */ jsxRuntime.jsx("span", { children: entry.count }),
|
|
3043
|
+
entry.views && entry.views.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-auto", "data-testid": `database-card-${entry.id}-views`, children: entry.views.join(" \xB7 ") })
|
|
3044
|
+
] })
|
|
3045
|
+
]
|
|
3046
|
+
}
|
|
3047
|
+
);
|
|
3048
|
+
}
|
|
3049
|
+
function DatabaseCard({
|
|
3050
|
+
database,
|
|
3051
|
+
onOpen,
|
|
3052
|
+
l
|
|
3053
|
+
}) {
|
|
3054
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3055
|
+
"button",
|
|
3056
|
+
{
|
|
3057
|
+
type: "button",
|
|
3058
|
+
onClick: onOpen,
|
|
3059
|
+
"data-testid": `database-card-${database.id}`,
|
|
3060
|
+
className: CARD_CLASS,
|
|
3061
|
+
children: [
|
|
3062
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex w-full items-start gap-2", children: [
|
|
3063
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileSpreadsheet, { className: "mt-0.5 size-5 shrink-0 text-muted-foreground", "aria-hidden": true }),
|
|
3064
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate font-medium", children: database.name }),
|
|
3065
|
+
!database.editable && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex shrink-0 items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground", children: [
|
|
3066
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: "size-3" }),
|
|
3067
|
+
l.readOnly
|
|
3068
|
+
] })
|
|
3069
|
+
] }),
|
|
3070
|
+
database.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "line-clamp-2 text-sm text-muted-foreground", children: database.description }),
|
|
3071
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "mt-auto flex w-full items-center gap-3 text-xs text-muted-foreground", children: [
|
|
3072
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: l.rows(database.row_count) }),
|
|
3073
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: l.columns(database.columns.length) }),
|
|
3074
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-auto flex items-center gap-1", "aria-hidden": true, children: database.columns.slice(0, 6).map((c) => {
|
|
3075
|
+
const Icon = COLUMN_TYPE_ICONS[c.type];
|
|
3076
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-3.5" }, c.id);
|
|
3077
|
+
}) })
|
|
3078
|
+
] })
|
|
3079
|
+
]
|
|
3080
|
+
}
|
|
3081
|
+
);
|
|
3082
|
+
}
|
|
3083
|
+
function DatabaseList({
|
|
3084
|
+
databases,
|
|
3085
|
+
entries = [],
|
|
3086
|
+
onOpen,
|
|
3087
|
+
onNew,
|
|
3088
|
+
onImport,
|
|
3089
|
+
isImporting = false,
|
|
3090
|
+
isLoading = false,
|
|
3091
|
+
labels
|
|
3092
|
+
}) {
|
|
3093
|
+
const l = { ...DEFAULT_DATABASE_LIST_LABELS, ...labels };
|
|
3094
|
+
const fileInput = react.useRef(null);
|
|
3095
|
+
const own = databases.filter((d) => d.editable);
|
|
3096
|
+
const shared = databases.filter((d) => !d.editable);
|
|
3097
|
+
const onFile = (e) => {
|
|
3098
|
+
const file = e.target.files?.[0];
|
|
3099
|
+
if (file) onImport?.(file);
|
|
3100
|
+
e.target.value = "";
|
|
3101
|
+
};
|
|
3102
|
+
const actions = /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex gap-2", children: [
|
|
3103
|
+
onImport && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3104
|
+
ui.Button,
|
|
3105
|
+
{
|
|
3106
|
+
variant: "outline",
|
|
3107
|
+
onClick: () => fileInput.current?.click(),
|
|
3108
|
+
disabled: isImporting,
|
|
3109
|
+
className: "gap-1.5",
|
|
3110
|
+
"data-testid": "database-import",
|
|
3111
|
+
children: [
|
|
3112
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { className: "size-4" }),
|
|
3113
|
+
isImporting ? l.importing : l.importSpreadsheet
|
|
3114
|
+
]
|
|
3115
|
+
}
|
|
3116
|
+
),
|
|
3117
|
+
onNew && /* @__PURE__ */ jsxRuntime.jsxs(ui.Button, { onClick: onNew, className: "gap-1.5", "data-testid": "database-new", children: [
|
|
3118
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4" }),
|
|
3119
|
+
l.newDatabase
|
|
3120
|
+
] })
|
|
3121
|
+
] });
|
|
3122
|
+
const grid = (children) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3", children });
|
|
3123
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6 p-2 sm:p-4", "data-testid": "database-list", children: [
|
|
3124
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [
|
|
3125
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3126
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-2xl font-semibold", children: l.title }),
|
|
3127
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: l.subtitle })
|
|
3128
|
+
] }),
|
|
3129
|
+
actions
|
|
3130
|
+
] }),
|
|
3131
|
+
isLoading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: l.loading }) : databases.length === 0 && entries.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3132
|
+
"div",
|
|
3133
|
+
{
|
|
3134
|
+
className: "flex flex-col items-center gap-2 rounded-lg border border-dashed border-border px-6 py-12 text-center",
|
|
3135
|
+
"data-testid": "database-list-empty",
|
|
3136
|
+
children: [
|
|
3137
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileSpreadsheet, { className: "size-8 text-muted-foreground" }),
|
|
3138
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-medium", children: l.emptyTitle }),
|
|
3139
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "max-w-md text-sm text-muted-foreground", children: l.emptyMessage })
|
|
3140
|
+
]
|
|
3141
|
+
}
|
|
3142
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3143
|
+
(entries.length > 0 || own.length > 0) && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "flex flex-col gap-2", children: [
|
|
3144
|
+
shared.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-sm font-medium text-muted-foreground", children: l.ownGroup }),
|
|
3145
|
+
grid(
|
|
3146
|
+
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3147
|
+
entries.map((e) => /* @__PURE__ */ jsxRuntime.jsx(EntryCard, { entry: e, l }, e.id)),
|
|
3148
|
+
own.map((d) => /* @__PURE__ */ jsxRuntime.jsx(DatabaseCard, { database: d, onOpen: () => onOpen(d), l }, d.id))
|
|
3149
|
+
] })
|
|
3150
|
+
)
|
|
3151
|
+
] }),
|
|
3152
|
+
shared.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "flex flex-col gap-2", "data-testid": "database-list-shared", children: [
|
|
3153
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-sm font-medium text-muted-foreground", children: l.sharedGroup }),
|
|
3154
|
+
grid(
|
|
3155
|
+
shared.map((d) => /* @__PURE__ */ jsxRuntime.jsx(DatabaseCard, { database: d, onOpen: () => onOpen(d), l }, d.id))
|
|
3156
|
+
)
|
|
3157
|
+
] })
|
|
3158
|
+
] }),
|
|
3159
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3160
|
+
"input",
|
|
3161
|
+
{
|
|
3162
|
+
ref: fileInput,
|
|
3163
|
+
type: "file",
|
|
3164
|
+
accept: SPREADSHEET_ACCEPT2,
|
|
3165
|
+
className: "hidden",
|
|
3166
|
+
onChange: onFile,
|
|
3167
|
+
"data-testid": "database-import-input"
|
|
3168
|
+
}
|
|
3169
|
+
)
|
|
3170
|
+
] });
|
|
3171
|
+
}
|
|
3172
|
+
var DEFAULT_NEW_DATABASE_DIALOG_LABELS = {
|
|
3173
|
+
title: "New database",
|
|
3174
|
+
description: "A table your workspace keeps: add columns of the kinds you need, then rows.",
|
|
3175
|
+
name: "Name",
|
|
3176
|
+
namePlaceholder: "e.g. Client database",
|
|
3177
|
+
about: "Description",
|
|
3178
|
+
aboutPlaceholder: "Optional: what it holds and who keeps it",
|
|
3179
|
+
cancel: "Cancel",
|
|
3180
|
+
create: "Create",
|
|
3181
|
+
creating: "Creating\u2026"
|
|
3182
|
+
};
|
|
3183
|
+
function NewDatabaseDialog({
|
|
3184
|
+
open,
|
|
3185
|
+
onOpenChange,
|
|
3186
|
+
onCreate,
|
|
3187
|
+
isCreating = false,
|
|
3188
|
+
error,
|
|
3189
|
+
labels
|
|
3190
|
+
}) {
|
|
3191
|
+
const l = { ...DEFAULT_NEW_DATABASE_DIALOG_LABELS, ...labels };
|
|
3192
|
+
const [name, setName] = react.useState("");
|
|
3193
|
+
const [about, setAbout] = react.useState("");
|
|
3194
|
+
react.useEffect(() => {
|
|
3195
|
+
if (open) {
|
|
3196
|
+
setName("");
|
|
3197
|
+
setAbout("");
|
|
3198
|
+
}
|
|
3199
|
+
}, [open]);
|
|
3200
|
+
const submit = (e) => {
|
|
3201
|
+
e.preventDefault();
|
|
3202
|
+
if (!name.trim() || isCreating) return;
|
|
3203
|
+
onCreate({ name: name.trim(), description: about.trim() || null });
|
|
3204
|
+
};
|
|
3205
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsx(ui.DialogContent, { className: "sm:max-w-md", "data-testid": "new-database-dialog", children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: submit, className: "flex flex-col gap-4", children: [
|
|
3206
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DialogHeader, { children: [
|
|
3207
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DialogTitle, { children: l.title }),
|
|
3208
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DialogDescription, { children: l.description })
|
|
3209
|
+
] }),
|
|
3210
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
3211
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { htmlFor: "new-database-name", children: l.name }),
|
|
3212
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3213
|
+
ui.Input,
|
|
3214
|
+
{
|
|
3215
|
+
id: "new-database-name",
|
|
3216
|
+
autoFocus: true,
|
|
3217
|
+
value: name,
|
|
3218
|
+
maxLength: 200,
|
|
3219
|
+
placeholder: l.namePlaceholder,
|
|
3220
|
+
onChange: (e) => setName(e.target.value),
|
|
3221
|
+
"data-testid": "new-database-name"
|
|
3222
|
+
}
|
|
3223
|
+
)
|
|
3224
|
+
] }),
|
|
3225
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
3226
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { htmlFor: "new-database-about", children: l.about }),
|
|
3227
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3228
|
+
ui.Textarea,
|
|
3229
|
+
{
|
|
3230
|
+
id: "new-database-about",
|
|
3231
|
+
value: about,
|
|
3232
|
+
maxLength: 2e3,
|
|
3233
|
+
rows: 2,
|
|
3234
|
+
placeholder: l.aboutPlaceholder,
|
|
3235
|
+
onChange: (e) => setAbout(e.target.value),
|
|
3236
|
+
"data-testid": "new-database-description"
|
|
3237
|
+
}
|
|
3238
|
+
)
|
|
3239
|
+
] }),
|
|
3240
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: "text-sm text-red-text", children: error }),
|
|
3241
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DialogFooter, { children: [
|
|
3242
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { type: "button", variant: "outline", onClick: () => onOpenChange(false), children: l.cancel }),
|
|
3243
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3244
|
+
ui.Button,
|
|
3245
|
+
{
|
|
3246
|
+
type: "submit",
|
|
3247
|
+
disabled: !name.trim() || isCreating,
|
|
3248
|
+
"data-testid": "new-database-create",
|
|
3249
|
+
children: isCreating ? l.creating : l.create
|
|
3250
|
+
}
|
|
3251
|
+
)
|
|
3252
|
+
] })
|
|
3253
|
+
] }) }) });
|
|
3254
|
+
}
|
|
3255
|
+
function isStartCandidate(column, columns) {
|
|
3256
|
+
return column.type === "date" && !columns.some((other) => other.span?.endColumnId === column.id);
|
|
3257
|
+
}
|
|
3258
|
+
function startColumns(columns) {
|
|
3259
|
+
return columns.filter((c) => isStartCandidate(c, columns));
|
|
3260
|
+
}
|
|
3261
|
+
function defaultDateColumn(columns) {
|
|
3262
|
+
const candidates = startColumns(columns);
|
|
3263
|
+
return candidates.find((c) => c.span) ?? candidates[0] ?? null;
|
|
3264
|
+
}
|
|
3265
|
+
var END_NAME = /end|until|finish|due|to$/i;
|
|
3266
|
+
function defaultEndColumn(columns, startId) {
|
|
3267
|
+
return columns.find(
|
|
3268
|
+
(c) => isStartCandidate(c, columns) && c.id !== startId && END_NAME.test(c.name)
|
|
3269
|
+
) ?? null;
|
|
3270
|
+
}
|
|
3271
|
+
var TABLE_LAYOUT = {
|
|
3272
|
+
id: "table",
|
|
3273
|
+
label: "Table",
|
|
3274
|
+
icon: lucideReact.Table2,
|
|
3275
|
+
defaults: () => ({})
|
|
3276
|
+
};
|
|
3277
|
+
var CALENDAR_LAYOUT = {
|
|
3278
|
+
id: "calendar",
|
|
3279
|
+
label: "Calendar",
|
|
3280
|
+
icon: lucideReact.CalendarRange,
|
|
3281
|
+
defaults: (columns) => {
|
|
3282
|
+
const date = defaultDateColumn(columns);
|
|
3283
|
+
return date ? { dateColumn: date.id } : null;
|
|
3284
|
+
}
|
|
3285
|
+
};
|
|
3286
|
+
var GANTT_LAYOUT = {
|
|
3287
|
+
id: "gantt",
|
|
3288
|
+
label: "Timeline",
|
|
3289
|
+
icon: lucideReact.GanttChartSquare,
|
|
3290
|
+
defaults: (columns) => {
|
|
3291
|
+
const date = defaultDateColumn(columns);
|
|
3292
|
+
if (!date) return null;
|
|
3293
|
+
return {
|
|
3294
|
+
dateColumn: date.id,
|
|
3295
|
+
endColumn: date.span ? null : defaultEndColumn(columns, date.id)?.id ?? null,
|
|
3296
|
+
colorColumn: columns.find((c) => c.type === "label")?.id ?? null
|
|
3297
|
+
};
|
|
3298
|
+
}
|
|
3299
|
+
};
|
|
3300
|
+
|
|
3301
|
+
// src/databases/layouts/rowsToTimelineItems.ts
|
|
3302
|
+
var BARE_DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
3303
|
+
function cellText(value) {
|
|
3304
|
+
const [first] = cellList(value);
|
|
3305
|
+
if (first === void 0) return void 0;
|
|
3306
|
+
if (typeof first === "string") return first.trim();
|
|
3307
|
+
return null;
|
|
3308
|
+
}
|
|
3309
|
+
function optionColor(option) {
|
|
3310
|
+
let hash = 0;
|
|
3311
|
+
for (const ch of option.toLowerCase()) hash = hash * 31 + ch.charCodeAt(0) >>> 0;
|
|
3312
|
+
return `hsl(${hash % 360} 60% 55%)`;
|
|
3313
|
+
}
|
|
3314
|
+
function colorsOf(row, column) {
|
|
3315
|
+
if (!column) return null;
|
|
3316
|
+
const value = row.values[column.id];
|
|
3317
|
+
if (column.type === "label") {
|
|
3318
|
+
const colors = cellIds(value).slice(0, 3).map((id) => ui.getEntityColor(id, "medium"));
|
|
3319
|
+
return colors.length ? colors : null;
|
|
3320
|
+
}
|
|
3321
|
+
if (column.type === "select") {
|
|
3322
|
+
const option = formatCell(value, column.type);
|
|
3323
|
+
return option ? [optionColor(option)] : null;
|
|
3324
|
+
}
|
|
3325
|
+
return null;
|
|
3326
|
+
}
|
|
3327
|
+
function rowsToTimelineItems(rows, columns, settings) {
|
|
3328
|
+
const result = { items: [], undated: [], invalid: [] };
|
|
3329
|
+
const start = columns.find((c) => c.id === settings.dateColumn);
|
|
3330
|
+
if (!start || start.type !== "date") {
|
|
3331
|
+
result.undated = [...rows];
|
|
3332
|
+
return result;
|
|
3333
|
+
}
|
|
3334
|
+
let end;
|
|
3335
|
+
if (start.span) end = columns.find((c) => c.id === start.span?.endColumnId);
|
|
3336
|
+
else if (settings.layout === "gantt") {
|
|
3337
|
+
end = settings.endColumn === null ? void 0 : columns.find((c) => c.id === settings.endColumn) ?? defaultEndColumn(columns, start.id) ?? void 0;
|
|
3338
|
+
}
|
|
3339
|
+
const title = columns.find((c) => c.id === settings.titleColumn) ?? columns[0];
|
|
3340
|
+
const color = columns.find((c) => c.id === settings.colorColumn);
|
|
3341
|
+
for (const row of rows) {
|
|
3342
|
+
const startText2 = cellText(row.values[start.id]);
|
|
3343
|
+
if (startText2 === void 0 || startText2 === "") {
|
|
3344
|
+
result.undated.push(row);
|
|
3345
|
+
continue;
|
|
3346
|
+
}
|
|
3347
|
+
const endText = end ? cellText(row.values[end.id]) : void 0;
|
|
3348
|
+
const hasEnd = endText !== void 0 && endText !== "";
|
|
3349
|
+
if (startText2 === null || !chunk66IOCKWS_cjs.parseIso(startText2) || hasEnd && !(endText && chunk66IOCKWS_cjs.parseIso(endText))) {
|
|
3350
|
+
result.invalid.push(row);
|
|
3351
|
+
continue;
|
|
3352
|
+
}
|
|
3353
|
+
let from = startText2;
|
|
3354
|
+
let to = hasEnd && endText ? endText : from;
|
|
3355
|
+
if (chunk66IOCKWS_cjs.parseIso(to) < chunk66IOCKWS_cjs.parseIso(from)) [from, to] = [to, from];
|
|
3356
|
+
if (BARE_DAY.test(to)) to = `${to}T23:59:59.000Z`;
|
|
3357
|
+
if (BARE_DAY.test(from)) from = `${from}T00:00:00.000Z`;
|
|
3358
|
+
const colors = colorsOf(row, color);
|
|
3359
|
+
result.items.push({
|
|
3360
|
+
id: row.id,
|
|
3361
|
+
label: formatCell(row.values[title?.id ?? ""], title?.type ?? "text", void 0, row.titles) || row.id,
|
|
3362
|
+
start: from,
|
|
3363
|
+
end: to,
|
|
3364
|
+
...colors ? { colors } : {},
|
|
3365
|
+
row
|
|
3366
|
+
});
|
|
3367
|
+
}
|
|
3368
|
+
return result;
|
|
3369
|
+
}
|
|
3370
|
+
var SELECTED = ["outline", "outline-2", "outline-offset-1", "outline-primary"];
|
|
3371
|
+
function DatabaseCalendar({
|
|
3372
|
+
rows,
|
|
3373
|
+
columns,
|
|
3374
|
+
settings,
|
|
3375
|
+
onOpenRow,
|
|
3376
|
+
selectedId,
|
|
3377
|
+
navigatorTotal,
|
|
3378
|
+
testId = "database-calendar",
|
|
3379
|
+
navigatorContainer,
|
|
3380
|
+
emptyMessage
|
|
3381
|
+
}) {
|
|
3382
|
+
const { items } = react.useMemo(
|
|
3383
|
+
() => rowsToTimelineItems(rows, columns, settings),
|
|
3384
|
+
[rows, columns, settings]
|
|
3385
|
+
);
|
|
3386
|
+
const rootRef = react.useRef(null);
|
|
3387
|
+
react.useEffect(() => {
|
|
3388
|
+
const root = rootRef.current;
|
|
3389
|
+
if (!root) return;
|
|
3390
|
+
const prefix = `${testId}-entry-`;
|
|
3391
|
+
for (const el of root.querySelectorAll("[data-testid]")) {
|
|
3392
|
+
const id = el.getAttribute("data-testid") ?? "";
|
|
3393
|
+
if (!id.startsWith(prefix)) continue;
|
|
3394
|
+
const selected = Boolean(selectedId) && id === `${prefix}${selectedId}`;
|
|
3395
|
+
el.classList.remove(...SELECTED);
|
|
3396
|
+
el.removeAttribute("aria-current");
|
|
3397
|
+
if (selected) {
|
|
3398
|
+
el.classList.add(...SELECTED);
|
|
3399
|
+
el.setAttribute("aria-current", "true");
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
}, [selectedId, items, testId]);
|
|
3403
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: rootRef, className: "h-full min-w-0 border-t border-border", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3404
|
+
chunk66IOCKWS_cjs.TimelineCalendar,
|
|
3405
|
+
{
|
|
3406
|
+
items,
|
|
3407
|
+
testId,
|
|
3408
|
+
maxLanes: Infinity,
|
|
3409
|
+
selectedIds: selectedId ? [selectedId] : [],
|
|
3410
|
+
onSelect: (item) => onOpenRow(item.row),
|
|
3411
|
+
navigatorContainer,
|
|
3412
|
+
navigatorTotal,
|
|
3413
|
+
emptyState: emptyMessage ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3414
|
+
"p",
|
|
3415
|
+
{
|
|
3416
|
+
className: "flex h-full items-center justify-center p-6 text-sm text-muted-foreground",
|
|
3417
|
+
"data-testid": `${testId}-empty-state`,
|
|
3418
|
+
children: emptyMessage
|
|
3419
|
+
}
|
|
3420
|
+
) : void 0
|
|
3421
|
+
}
|
|
3422
|
+
) });
|
|
3423
|
+
}
|
|
3424
|
+
function DatabaseGantt({
|
|
3425
|
+
rows,
|
|
3426
|
+
columns,
|
|
3427
|
+
settings,
|
|
3428
|
+
onOpenRow,
|
|
3429
|
+
selectedIds,
|
|
3430
|
+
navigatorTotal,
|
|
3431
|
+
testId = "database-gantt",
|
|
3432
|
+
navigatorContainer,
|
|
3433
|
+
emptyMessage,
|
|
3434
|
+
onSettingsChange,
|
|
3435
|
+
className
|
|
3436
|
+
}) {
|
|
3437
|
+
const { items } = react.useMemo(
|
|
3438
|
+
() => rowsToTimelineItems(rows, columns, settings),
|
|
3439
|
+
[rows, columns, settings]
|
|
3440
|
+
);
|
|
3441
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3442
|
+
"div",
|
|
3443
|
+
{
|
|
3444
|
+
className: "h-full min-w-0 border-t border-border [&_[data-testid$='-side-panel']]:hidden",
|
|
3445
|
+
"data-testid": testId,
|
|
3446
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3447
|
+
chunk66IOCKWS_cjs.TimelineGantt,
|
|
3448
|
+
{
|
|
3449
|
+
items,
|
|
3450
|
+
testId,
|
|
3451
|
+
className,
|
|
3452
|
+
...emptyMessage ? { emptyMessage } : {},
|
|
3453
|
+
labelWidth: settings.labelWidth,
|
|
3454
|
+
onLabelWidthChange: onSettingsChange ? (labelWidth) => onSettingsChange({ labelWidth }) : void 0,
|
|
3455
|
+
zoom: onSettingsChange ? settings.zoom ?? 1 : void 0,
|
|
3456
|
+
onZoomChange: onSettingsChange ? (zoom) => onSettingsChange({ zoom }) : void 0,
|
|
3457
|
+
selectedIds,
|
|
3458
|
+
followSelection: true,
|
|
3459
|
+
onSelect: (item) => item && onOpenRow(item.row),
|
|
3460
|
+
navigatorContainer,
|
|
3461
|
+
navigatorTotal
|
|
3462
|
+
}
|
|
3463
|
+
)
|
|
3464
|
+
}
|
|
3465
|
+
);
|
|
3466
|
+
}
|
|
3467
|
+
var DEFAULT_DATABASE_LAYOUT_LABELS = {
|
|
3468
|
+
layouts: "Layout",
|
|
3469
|
+
settings: "Layout settings",
|
|
3470
|
+
date: "Date",
|
|
3471
|
+
start: "Start",
|
|
3472
|
+
end: "End",
|
|
3473
|
+
none: "None",
|
|
3474
|
+
colour: "Colour by",
|
|
3475
|
+
title: "Title",
|
|
3476
|
+
firstColumn: "First column",
|
|
3477
|
+
table: "Table",
|
|
3478
|
+
calendar: "Calendar",
|
|
3479
|
+
timeline: "Timeline"
|
|
3480
|
+
};
|
|
3481
|
+
var NONE = "__none__";
|
|
3482
|
+
function SettingSelect({
|
|
3483
|
+
label,
|
|
3484
|
+
value,
|
|
3485
|
+
onValueChange,
|
|
3486
|
+
testId,
|
|
3487
|
+
children
|
|
3488
|
+
}) {
|
|
3489
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-3 text-sm", children: [
|
|
3490
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: label }),
|
|
3491
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { value, onValueChange, children: [
|
|
3492
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.SelectTrigger, { className: "h-8 w-44", "data-testid": testId, "aria-label": label, children: /* @__PURE__ */ jsxRuntime.jsx(ui.SelectValue, {}) }),
|
|
3493
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.SelectContent, { children })
|
|
3494
|
+
] })
|
|
3495
|
+
] });
|
|
3496
|
+
}
|
|
3497
|
+
function DatabaseLayoutSwitcher({
|
|
3498
|
+
layouts,
|
|
3499
|
+
columns,
|
|
3500
|
+
settings,
|
|
3501
|
+
onChange,
|
|
3502
|
+
testIdPrefix,
|
|
3503
|
+
className,
|
|
3504
|
+
labels,
|
|
3505
|
+
tableSettings,
|
|
3506
|
+
parts = "all"
|
|
3507
|
+
}) {
|
|
3508
|
+
const l = { ...DEFAULT_DATABASE_LAYOUT_LABELS, ...labels };
|
|
3509
|
+
const available = layouts.filter(
|
|
3510
|
+
(layout) => !layout.defaults || layout.defaults(columns) !== null
|
|
3511
|
+
);
|
|
3512
|
+
if (available.length < 2) return null;
|
|
3513
|
+
const wordFor = (layout) => layout.id === "table" ? l.table : layout.id === "calendar" ? l.calendar : layout.id === "gantt" ? l.timeline : layout.label;
|
|
3514
|
+
const options = available.map((layout) => {
|
|
3515
|
+
const Icon = layout.icon ?? lucideReact.Table2;
|
|
3516
|
+
return { value: layout.id, icon: /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "size-3.5" }), label: wordFor(layout) };
|
|
3517
|
+
});
|
|
3518
|
+
const isGantt = settings.layout === "gantt";
|
|
3519
|
+
const hasSettings = isGantt || settings.layout === "calendar";
|
|
3520
|
+
const showsTableSettings = settings.layout === "table" && Boolean(tableSettings);
|
|
3521
|
+
const showsLayouts = parts !== "tools";
|
|
3522
|
+
const showsSettings = parts !== "layouts" && (hasSettings || showsTableSettings);
|
|
3523
|
+
const showsZoom = parts !== "layouts" && isGantt;
|
|
3524
|
+
if (!showsLayouts && !showsSettings && !showsZoom) return null;
|
|
3525
|
+
const dates = startColumns(columns);
|
|
3526
|
+
const start = columns.find((c) => c.id === settings.dateColumn);
|
|
3527
|
+
const endSpan = start?.span ? columns.find((c) => c.id === start.span?.endColumnId) : void 0;
|
|
3528
|
+
const prefixBase = testIdPrefix.replace(/-layout$/, "");
|
|
3529
|
+
const set = (patch) => onChange({ ...settings, ...patch });
|
|
3530
|
+
const columnOrNull = (value) => value === NONE ? null : value;
|
|
3531
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: className ?? "flex items-center gap-1.5", children: [
|
|
3532
|
+
showsLayouts && /* @__PURE__ */ jsxRuntime.jsx("div", { role: "group", "aria-label": l.layouts, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3533
|
+
chunkSNUBQMIS_cjs.ViewToggle,
|
|
3534
|
+
{
|
|
3535
|
+
options,
|
|
3536
|
+
value: settings.layout,
|
|
3537
|
+
onChange: (value) => onChange({ ...settings, layout: value }),
|
|
3538
|
+
testIdPrefix,
|
|
3539
|
+
showLabels: false,
|
|
3540
|
+
size: "sm"
|
|
3541
|
+
}
|
|
3542
|
+
) }),
|
|
3543
|
+
showsSettings && /* @__PURE__ */ jsxRuntime.jsxs(ui.Popover, { children: [
|
|
3544
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3545
|
+
ui.Button,
|
|
3546
|
+
{
|
|
3547
|
+
variant: "ghost",
|
|
3548
|
+
size: "icon",
|
|
3549
|
+
className: "size-7 text-muted-foreground hover:text-foreground pointer-coarse:size-11",
|
|
3550
|
+
"aria-label": l.settings,
|
|
3551
|
+
"data-testid": `${testIdPrefix}-settings`,
|
|
3552
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings2, { className: "size-3.5" })
|
|
3553
|
+
}
|
|
3554
|
+
) }),
|
|
3555
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3556
|
+
ui.PopoverContent,
|
|
3557
|
+
{
|
|
3558
|
+
align: "start",
|
|
3559
|
+
className: "flex w-80 flex-col gap-2.5 p-3",
|
|
3560
|
+
"data-testid": `${testIdPrefix}-settings-menu`,
|
|
3561
|
+
children: showsTableSettings ? tableSettings : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3562
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3563
|
+
SettingSelect,
|
|
3564
|
+
{
|
|
3565
|
+
label: isGantt ? l.start : l.date,
|
|
3566
|
+
value: settings.dateColumn ?? "",
|
|
3567
|
+
onValueChange: (value) => (
|
|
3568
|
+
// A start cannot also be the end: the timeline would draw no length.
|
|
3569
|
+
set({
|
|
3570
|
+
dateColumn: value,
|
|
3571
|
+
...value === settings.endColumn ? { endColumn: null } : {}
|
|
3572
|
+
})
|
|
3573
|
+
),
|
|
3574
|
+
testId: `${testIdPrefix}-date`,
|
|
3575
|
+
children: dates.map((c) => /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: c.id, children: c.name }, c.id))
|
|
3576
|
+
}
|
|
3577
|
+
),
|
|
3578
|
+
isGantt && (endSpan ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
3579
|
+
l.end,
|
|
3580
|
+
": ",
|
|
3581
|
+
endSpan.name
|
|
3582
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3583
|
+
SettingSelect,
|
|
3584
|
+
{
|
|
3585
|
+
label: l.end,
|
|
3586
|
+
value: settings.endColumn ?? NONE,
|
|
3587
|
+
onValueChange: (value) => set({ endColumn: columnOrNull(value) }),
|
|
3588
|
+
testId: `${testIdPrefix}-end`,
|
|
3589
|
+
children: [
|
|
3590
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: NONE, children: l.none }),
|
|
3591
|
+
dates.filter((c) => c.id !== settings.dateColumn).map((c) => /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: c.id, children: c.name }, c.id))
|
|
3592
|
+
]
|
|
3593
|
+
}
|
|
3594
|
+
)),
|
|
3595
|
+
isGantt && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3596
|
+
SettingSelect,
|
|
3597
|
+
{
|
|
3598
|
+
label: l.colour,
|
|
3599
|
+
value: settings.colorColumn ?? NONE,
|
|
3600
|
+
onValueChange: (value) => set({ colorColumn: columnOrNull(value) }),
|
|
3601
|
+
testId: `${testIdPrefix}-color`,
|
|
3602
|
+
children: [
|
|
3603
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: NONE, children: l.none }),
|
|
3604
|
+
columns.filter((c) => c.type === "label" || c.type === "select").map((c) => /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: c.id, children: c.name }, c.id))
|
|
3605
|
+
]
|
|
3606
|
+
}
|
|
3607
|
+
),
|
|
3608
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3609
|
+
SettingSelect,
|
|
3610
|
+
{
|
|
3611
|
+
label: l.title,
|
|
3612
|
+
value: settings.titleColumn ?? NONE,
|
|
3613
|
+
onValueChange: (value) => set({ titleColumn: columnOrNull(value) }),
|
|
3614
|
+
testId: `${testIdPrefix}-title`,
|
|
3615
|
+
children: [
|
|
3616
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: NONE, children: l.firstColumn }),
|
|
3617
|
+
columns.map((c) => /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: c.id, children: c.name }, c.id))
|
|
3618
|
+
]
|
|
3619
|
+
}
|
|
3620
|
+
)
|
|
3621
|
+
] })
|
|
3622
|
+
}
|
|
3623
|
+
)
|
|
3624
|
+
] }),
|
|
3625
|
+
showsZoom && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3626
|
+
chunk66IOCKWS_cjs.TimelineZoomControl,
|
|
3627
|
+
{
|
|
3628
|
+
zoom: settings.zoom ?? 1,
|
|
3629
|
+
onZoomChange: (zoom) => set({ zoom }),
|
|
3630
|
+
testId: `${prefixBase}-timeline`
|
|
3631
|
+
}
|
|
3632
|
+
)
|
|
3633
|
+
] });
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
// src/databases/layouts/resolveLayoutSettings.ts
|
|
3637
|
+
var CHOSEN_KEYS = [
|
|
3638
|
+
"dateColumn",
|
|
3639
|
+
"endColumn",
|
|
3640
|
+
"colorColumn",
|
|
3641
|
+
"titleColumn",
|
|
3642
|
+
"zoom",
|
|
3643
|
+
"labelWidth"
|
|
3644
|
+
];
|
|
3645
|
+
function storedLayoutAfter(stored, resolved, next) {
|
|
3646
|
+
const out = { ...stored, layout: next.layout };
|
|
3647
|
+
for (const key of CHOSEN_KEYS) {
|
|
3648
|
+
if (next[key] === resolved[key]) continue;
|
|
3649
|
+
if (next[key] === void 0) delete out[key];
|
|
3650
|
+
else Object.assign(out, { [key]: next[key] });
|
|
3651
|
+
}
|
|
3652
|
+
return out;
|
|
3653
|
+
}
|
|
3654
|
+
function resolveLayoutSettings(stored, layouts, columns) {
|
|
3655
|
+
const device = {
|
|
3656
|
+
...stored?.zoom !== void 0 ? { zoom: stored.zoom } : {},
|
|
3657
|
+
...stored?.labelWidth !== void 0 ? { labelWidth: stored.labelWidth } : {}
|
|
3658
|
+
};
|
|
3659
|
+
const layout = stored && layouts.find((l) => l.id === stored.layout);
|
|
3660
|
+
const defaults = layout ? layout.defaults ? layout.defaults(columns) : {} : null;
|
|
3661
|
+
if (!stored || !layout || !defaults) return { layout: "table", ...device };
|
|
3662
|
+
const out = { ...defaults, ...stored };
|
|
3663
|
+
const has = (id, type) => columns.some((c) => c.id === id && (!type || c.type === type));
|
|
3664
|
+
const repair = (key, ok, fallback) => {
|
|
3665
|
+
const value = out[key];
|
|
3666
|
+
if (typeof value === "string" && !ok(value)) out[key] = fallback;
|
|
3667
|
+
};
|
|
3668
|
+
repair("dateColumn", (id) => has(id, "date"), defaults.dateColumn);
|
|
3669
|
+
repair("endColumn", (id) => has(id), defaults.endColumn);
|
|
3670
|
+
repair("colorColumn", (id) => has(id), defaults.colorColumn);
|
|
3671
|
+
repair("titleColumn", (id) => has(id), null);
|
|
3672
|
+
if (!out.dateColumn && defaults.dateColumn) out.dateColumn = defaults.dateColumn;
|
|
3673
|
+
if (out.endColumn === void 0 && defaults.endColumn !== void 0) {
|
|
3674
|
+
out.endColumn = defaults.endColumn;
|
|
3675
|
+
}
|
|
3676
|
+
return out;
|
|
3677
|
+
}
|
|
3678
|
+
|
|
3679
|
+
// src/databases/layouts/undated.ts
|
|
3680
|
+
function withUndatedFilter(filters, columnId) {
|
|
3681
|
+
if (!columnId) return filters;
|
|
3682
|
+
if (filters.some((f) => f.column === columnId && f.op === "empty")) return filters;
|
|
3683
|
+
return [...filters, { column: columnId, op: "empty" }];
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3686
|
+
exports.ADD_COLUMN_COL_ID = ADD_COLUMN_COL_ID;
|
|
3687
|
+
exports.CALENDAR_LAYOUT = CALENDAR_LAYOUT;
|
|
3688
|
+
exports.COLUMN_TYPE_ICONS = COLUMN_TYPE_ICONS;
|
|
3689
|
+
exports.COMPUTED_COLUMN_TYPES = COMPUTED_COLUMN_TYPES;
|
|
3690
|
+
exports.DATABASE_COLUMN_TYPES = DATABASE_COLUMN_TYPES;
|
|
3691
|
+
exports.DATABASE_ROLLUP_OPS = DATABASE_ROLLUP_OPS;
|
|
3692
|
+
exports.DEFAULT_COLUMN_CONFIG_LABELS = DEFAULT_COLUMN_CONFIG_LABELS;
|
|
3693
|
+
exports.DEFAULT_DATABASE_COLUMN_DIALOG_LABELS = DEFAULT_DATABASE_COLUMN_DIALOG_LABELS;
|
|
3694
|
+
exports.DEFAULT_DATABASE_COLUMN_LABELS = DEFAULT_DATABASE_COLUMN_LABELS;
|
|
3695
|
+
exports.DEFAULT_DATABASE_COLUMN_TYPE_LABELS = DEFAULT_DATABASE_COLUMN_TYPE_LABELS;
|
|
3696
|
+
exports.DEFAULT_DATABASE_FILTER_MENU_LABELS = DEFAULT_DATABASE_FILTER_MENU_LABELS;
|
|
3697
|
+
exports.DEFAULT_DATABASE_LAYOUT_LABELS = DEFAULT_DATABASE_LAYOUT_LABELS;
|
|
3698
|
+
exports.DEFAULT_DATABASE_LIST_LABELS = DEFAULT_DATABASE_LIST_LABELS;
|
|
3699
|
+
exports.DEFAULT_DATABASE_ROW_DETAIL_LABELS = DEFAULT_DATABASE_ROW_DETAIL_LABELS;
|
|
3700
|
+
exports.DEFAULT_DATABASE_TABLE_LABELS = DEFAULT_DATABASE_TABLE_LABELS;
|
|
3701
|
+
exports.DEFAULT_DATABASE_TOOLBAR_LABELS = DEFAULT_DATABASE_TOOLBAR_LABELS;
|
|
3702
|
+
exports.DEFAULT_NEW_DATABASE_DIALOG_LABELS = DEFAULT_NEW_DATABASE_DIALOG_LABELS;
|
|
3703
|
+
exports.DEFAULT_PICK_CELL_EDITOR_LABELS = DEFAULT_PICK_CELL_EDITOR_LABELS;
|
|
3704
|
+
exports.DatabaseCalendar = DatabaseCalendar;
|
|
3705
|
+
exports.DatabaseColumnDialog = DatabaseColumnDialog;
|
|
3706
|
+
exports.DatabaseFilterMenu = DatabaseFilterMenu;
|
|
3707
|
+
exports.DatabaseGantt = DatabaseGantt;
|
|
3708
|
+
exports.DatabaseLayoutSwitcher = DatabaseLayoutSwitcher;
|
|
3709
|
+
exports.DatabaseList = DatabaseList;
|
|
3710
|
+
exports.DatabaseRowDetail = DatabaseRowDetail;
|
|
3711
|
+
exports.DatabaseTable = DatabaseTable;
|
|
3712
|
+
exports.DatabaseToolbar = DatabaseToolbar;
|
|
3713
|
+
exports.DateSpanCellEditor = DateSpanCellEditor;
|
|
3714
|
+
exports.DateSpanField = DateSpanField;
|
|
3715
|
+
exports.GANTT_LAYOUT = GANTT_LAYOUT;
|
|
3716
|
+
exports.LINK_COLUMN_TYPES = LINK_COLUMN_TYPES;
|
|
3717
|
+
exports.LabelsCell = LabelsCell;
|
|
3718
|
+
exports.LabelsField = LabelsField;
|
|
3719
|
+
exports.LinkChip = LinkChip;
|
|
3720
|
+
exports.LinkChipsCell = LinkChipsCell;
|
|
3721
|
+
exports.LookupCell = LookupCell;
|
|
3722
|
+
exports.NewDatabaseDialog = NewDatabaseDialog;
|
|
3723
|
+
exports.OPEN_ROW_COL_ID = OPEN_ROW_COL_ID;
|
|
3724
|
+
exports.PersonCell = PersonCell;
|
|
3725
|
+
exports.PersonChip = PersonChip;
|
|
3726
|
+
exports.PickCellEditor = PickCellEditor;
|
|
3727
|
+
exports.ROW_ACTIONS_COL_ID = ROW_ACTIONS_COL_ID;
|
|
3728
|
+
exports.SelectCellEditor = SelectCellEditor;
|
|
3729
|
+
exports.SelectChip = SelectChip;
|
|
3730
|
+
exports.SourcesCell = SourcesCell;
|
|
3731
|
+
exports.SourcesField = SourcesField;
|
|
3732
|
+
exports.TABLE_LAYOUT = TABLE_LAYOUT;
|
|
3733
|
+
exports.canEditColumn = canEditColumn;
|
|
3734
|
+
exports.cellIds = cellIds;
|
|
3735
|
+
exports.cellList = cellList;
|
|
3736
|
+
exports.columnWidth = columnWidth;
|
|
3737
|
+
exports.compareCells = compareCells;
|
|
3738
|
+
exports.completeFilters = completeFilters;
|
|
3739
|
+
exports.createDatabaseColumns = createDatabaseColumns;
|
|
3740
|
+
exports.formatCell = formatCell;
|
|
3741
|
+
exports.formatDateValue = formatDateValue;
|
|
3742
|
+
exports.formatLookupValue = formatLookupValue;
|
|
3743
|
+
exports.formatNumberValue = formatNumberValue;
|
|
3744
|
+
exports.isComputedColumn = isComputedColumn;
|
|
3745
|
+
exports.kitOf = kitOf;
|
|
3746
|
+
exports.optionTone = optionTone;
|
|
3747
|
+
exports.resolveLayoutSettings = resolveLayoutSettings;
|
|
3748
|
+
exports.rowTitle = rowTitle;
|
|
3749
|
+
exports.rowsToTimelineItems = rowsToTimelineItems;
|
|
3750
|
+
exports.sameCellValue = sameCellValue;
|
|
3751
|
+
exports.storedLayoutAfter = storedLayoutAfter;
|
|
3752
|
+
exports.titleOf = titleOf;
|
|
3753
|
+
exports.toApiValue = toApiValue;
|
|
3754
|
+
exports.withUndatedFilter = withUndatedFilter;
|
|
3755
|
+
//# sourceMappingURL=chunk-PUCYBYBY.cjs.map
|
|
3756
|
+
//# sourceMappingURL=chunk-PUCYBYBY.cjs.map
|