@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { kitOf } from "./column-kits.js";
|
|
2
3
|
const DATABASE_COLUMN_TYPES = [
|
|
3
4
|
"text",
|
|
4
5
|
"number",
|
|
@@ -28,10 +29,14 @@ const DEFAULT_DATABASE_COLUMN_TYPE_LABELS = {
|
|
|
28
29
|
checkbox: "Checkbox",
|
|
29
30
|
select: "Select",
|
|
30
31
|
person: "Person",
|
|
31
|
-
|
|
32
|
+
// The same name as a `source` column: both hold a row's sources. A `document` column holds the
|
|
33
|
+
// documents; a `source` column also holds the passages cited in each.
|
|
34
|
+
document: "Sources",
|
|
32
35
|
relation: "Relation",
|
|
33
36
|
lookup: "Lookup",
|
|
34
|
-
rollup: "Rollup"
|
|
37
|
+
rollup: "Rollup",
|
|
38
|
+
label: "Labels",
|
|
39
|
+
source: "Sources"
|
|
35
40
|
};
|
|
36
41
|
const OPTION_TONES = [
|
|
37
42
|
"bg-blue-bg text-blue-text",
|
|
@@ -57,7 +62,9 @@ function cellIds(value) {
|
|
|
57
62
|
function titleOf(id, titles) {
|
|
58
63
|
return titles?.[id] ?? id;
|
|
59
64
|
}
|
|
60
|
-
function sameCellValue(a, b) {
|
|
65
|
+
function sameCellValue(a, b, type) {
|
|
66
|
+
const kit = type ? kitOf(type) : void 0;
|
|
67
|
+
if (kit) return kit.same(a, b);
|
|
61
68
|
if (Array.isArray(a) || Array.isArray(b)) {
|
|
62
69
|
const la = cellList(a);
|
|
63
70
|
const lb = cellList(b);
|
|
@@ -65,6 +72,12 @@ function sameCellValue(a, b) {
|
|
|
65
72
|
}
|
|
66
73
|
return (a ?? null) === (b ?? null);
|
|
67
74
|
}
|
|
75
|
+
const kitRow = (titles) => ({
|
|
76
|
+
id: "",
|
|
77
|
+
values: {},
|
|
78
|
+
titles
|
|
79
|
+
});
|
|
80
|
+
const kitColumn = (type) => ({ id: "", name: "", type });
|
|
68
81
|
function formatDateValue(value, locale) {
|
|
69
82
|
const day = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
70
83
|
if (day) {
|
|
@@ -95,6 +108,8 @@ const NAMED_TYPES = /* @__PURE__ */ new Set([
|
|
|
95
108
|
]);
|
|
96
109
|
function formatCell(value, type, locale, titles) {
|
|
97
110
|
if (isEmpty(value)) return "";
|
|
111
|
+
const kit = kitOf(type);
|
|
112
|
+
if (kit) return kit.format(value, kitRow(titles), kitColumn(type));
|
|
98
113
|
if ((type === "number" || type === "rollup") && typeof value === "number")
|
|
99
114
|
return formatNumberValue(value, locale);
|
|
100
115
|
if (type === "date" && typeof value === "string") return formatDateValue(value, locale);
|
|
@@ -107,6 +122,8 @@ function formatCell(value, type, locale, titles) {
|
|
|
107
122
|
}
|
|
108
123
|
function toApiValue(value, type) {
|
|
109
124
|
if (isEmpty(value)) return null;
|
|
125
|
+
const kit = kitOf(type);
|
|
126
|
+
if (kit) return kit.toApi(value);
|
|
110
127
|
if (LINK_COLUMN_TYPES.has(type)) return cellIds(value);
|
|
111
128
|
if (type === "checkbox") return Boolean(value);
|
|
112
129
|
if (type === "date" && value instanceof Date) {
|
|
@@ -123,6 +140,8 @@ function compareCells(a, b, type, titlesA, titlesB) {
|
|
|
123
140
|
const ea = isEmpty(a);
|
|
124
141
|
const eb = isEmpty(b);
|
|
125
142
|
if (ea || eb) return ea === eb ? 0 : ea ? 1 : -1;
|
|
143
|
+
const kit = kitOf(type);
|
|
144
|
+
if (kit) return kit.compare(a, b, kitRow(titlesA), kitRow(titlesB));
|
|
126
145
|
if (type === "number" || type === "checkbox" || type === "rollup") return Number(a) - Number(b);
|
|
127
146
|
const shown = NAMED_TYPES.has(type) || type === "lookup";
|
|
128
147
|
const ta = shown ? formatCell(a, type, void 0, titlesA) : String(a);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/databases/column-types.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Databases: the shapes the blocks read, and the per-type rules for showing and editing a cell.\n *\n * A database is a user-defined table (a client database, billing records). Its columns are typed:\n * `text`, `number`, `date`, `checkbox` and `select` hold a value; `person` holds a workspace member's\n * id (`usr-\u2026`); `document` and `relation` hold lists of ids (documents of the workspace, rows of the\n * target database); `lookup` (the values of a column of the related rows) and `rollup` (a number\n * measured over them) are computed by the server and never written. The server checks and\n * normalises every cell (dates arrive as ISO `YYYY-MM-DD` or a full timestamp, numbers as numbers, a\n * select as one of its options) and names every id a row refers to in the row's `titles`, so the\n * blocks only format for display and turn an editor's value into what the API takes.\n */\n\nexport type DatabaseColumnType =\n | 'text'\n | 'number'\n | 'date'\n | 'checkbox'\n | 'select'\n | 'person'\n | 'document'\n | 'relation'\n | 'lookup'\n | 'rollup'\n\n/** Every type, in the order a type picker lists them. */\nexport const DATABASE_COLUMN_TYPES: DatabaseColumnType[] = [\n 'text',\n 'number',\n 'date',\n 'checkbox',\n 'select',\n 'person',\n 'document',\n 'relation',\n 'lookup',\n 'rollup',\n]\n\n/** Types whose cells the server computes from a relation: shown, never edited. */\nexport const COMPUTED_COLUMN_TYPES: ReadonlySet<DatabaseColumnType> = new Set<DatabaseColumnType>([\n 'lookup',\n 'rollup',\n])\n\n/** Types whose cells are lists of ids (written as a list that replaces the cell's links). */\nexport const LINK_COLUMN_TYPES: ReadonlySet<DatabaseColumnType> = new Set<DatabaseColumnType>([\n 'document',\n 'relation',\n])\n\nexport const isComputedColumn = (column: Pick<DatabaseColumnView, 'type'>): boolean =>\n COMPUTED_COLUMN_TYPES.has(column.type)\n\nexport type DatabaseRollupOp = 'count' | 'sum' | 'avg' | 'min' | 'max'\n\nexport const DATABASE_ROLLUP_OPS: DatabaseRollupOp[] = ['count', 'sum', 'avg', 'min', 'max']\n\n/**\n * A relation column's target. A `two_way` column has a paired column on the target database\n * (`pair_column_id`) showing the same links from the other side; `reverse` marks the paired side.\n */\nexport interface DatabaseRelationView {\n database_id: string\n two_way?: boolean\n pair_column_id?: string | null\n reverse?: boolean\n}\n\n/** A lookup: `column` of the target database, read through this database's `relation` column. */\nexport interface DatabaseLookupView {\n relation: string\n column: string\n}\n\n/** A rollup: `op` over the rows linked through `relation` (`column`: a number column, not for count). */\nexport interface DatabaseRollupView {\n relation: string\n column?: string | null\n op?: DatabaseRollupOp\n}\n\n/** A column as the blocks read it (the API's `DatabaseColumn`). */\nexport interface DatabaseColumnView {\n id: string\n name: string\n type: DatabaseColumnType\n options?: string[] | null\n relation?: DatabaseRelationView | null\n lookup?: DatabaseLookupView | null\n rollup?: DatabaseRollupView | null\n /** Who may write it beyond the row's editors (`owners`, or `listed`: the people a person column of another\n * database lists \u2014 an approval's decision). */\n edit_by?: DatabaseEditRuleView | null\n /** Set by the host: the viewer may not write this column (its `edit_by` rule leaves them out). */\n locked?: boolean\n}\n\n/** A column's edit rule: the workspace's owners and the database's creator, or the people listed in\n * `column_id` of the database `database_id`. */\nexport interface DatabaseEditRuleView {\n kind: 'owners' | 'listed'\n database_id?: string | null\n column_id?: string | null\n}\n\n/**\n * A row as the blocks read it: cell values keyed by column id; an empty cell is absent. `titles`\n * names every person, document and related row the cells refer to (id \u2192 display name).\n */\nexport interface DatabaseRowView {\n id: string\n values: Record<string, unknown>\n titles?: Record<string, string>\n /** False: a draft only its creator sees, until submitted (shared). */\n shared?: boolean\n}\n\n/** A database as a list shows it (the API's `DatabaseRead`). */\nexport interface DatabaseSummaryView {\n id: string\n name: string\n description?: string | null\n columns: DatabaseColumnView[]\n row_count: number\n /** False for a database of another (public) workspace: read here, edited in its own workspace. */\n editable: boolean\n updated_at?: string | null\n}\n\nexport interface DatabaseColumnTypeLabels {\n text: string\n number: string\n date: string\n checkbox: string\n select: string\n person: string\n document: string\n relation: string\n lookup: string\n rollup: string\n}\n\nexport const DEFAULT_DATABASE_COLUMN_TYPE_LABELS: DatabaseColumnTypeLabels = {\n text: 'Text',\n number: 'Number',\n date: 'Date',\n checkbox: 'Checkbox',\n select: 'Select',\n person: 'Person',\n document: 'Documents',\n relation: 'Relation',\n lookup: 'Lookup',\n rollup: 'Rollup',\n}\n\n/**\n * Chip colours for select options: a stable colour per option text, so a value keeps its colour.\n * Theme tone pairs (tokens.css), so light and dark follow the host.\n */\nconst OPTION_TONES = [\n 'bg-blue-bg text-blue-text',\n 'bg-green-bg text-green-text',\n 'bg-yellow-bg text-yellow-text',\n 'bg-purple-bg text-purple-text',\n 'bg-red-bg text-red-text',\n 'bg-gray-bg text-gray-text',\n]\n\nexport function optionTone(option: string): string {\n let hash = 0\n for (const ch of option.toLowerCase()) hash = (hash * 31 + ch.charCodeAt(0)) >>> 0\n return OPTION_TONES[hash % OPTION_TONES.length]\n}\n\nconst isEmpty = (value: unknown): boolean =>\n value === null ||\n value === undefined ||\n (typeof value === 'string' && value.trim() === '') ||\n (Array.isArray(value) && value.length === 0)\n\n/** A cell as a list: a list cell as is, a single value as a list of one, an empty cell as none. */\nexport function cellList(value: unknown): unknown[] {\n if (isEmpty(value)) return []\n return Array.isArray(value) ? value.filter((v) => !isEmpty(v)) : [value]\n}\n\n/** The ids a person, document or relation cell holds. */\nexport function cellIds(value: unknown): string[] {\n return cellList(value).filter((v): v is string => typeof v === 'string')\n}\n\n/** An id's display name from the row's titles (the id itself when the server could not name it). */\nexport function titleOf(id: string, titles?: Record<string, string>): string {\n return titles?.[id] ?? id\n}\n\n/** Two cell values, as the API stores them, are the same (lists compare item by item). */\nexport function sameCellValue(a: unknown, b: unknown): boolean {\n if (Array.isArray(a) || Array.isArray(b)) {\n const la = cellList(a)\n const lb = cellList(b)\n return la.length === lb.length && la.every((v, i) => v === lb[i])\n }\n return (a ?? null) === (b ?? null)\n}\n\n/**\n * A stored date for display. A bare `YYYY-MM-DD` is a calendar day: it is shown from its own\n * components, never through a time zone (which would move it a day for viewers west of UTC).\n */\nexport function formatDateValue(value: string, locale?: string): string {\n const day = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value)\n if (day) {\n const [, y, m, d] = day\n return new Date(Date.UTC(+y, +m - 1, +d)).toLocaleDateString(locale, { timeZone: 'UTC' })\n }\n const at = new Date(value)\n return Number.isNaN(at.getTime()) ? value : at.toLocaleString(locale)\n}\n\nexport function formatNumberValue(value: number, locale?: string): string {\n return value.toLocaleString(locale, { maximumFractionDigits: 6 })\n}\n\nconst ISO_DATE = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:?\\d{2})?)?$/\n\n/**\n * One value of a lookup cell, whose type is the looked-up column's: an id reads as its title, a\n * number and an ISO date as their own column would show them.\n */\nexport function formatLookupValue(\n value: unknown,\n titles?: Record<string, string>,\n locale?: string\n): string {\n if (isEmpty(value)) return ''\n if (typeof value === 'number') return formatNumberValue(value, locale)\n if (typeof value === 'boolean') return value ? 'Yes' : 'No'\n if (typeof value === 'string') {\n if (titles?.[value] !== undefined) return titles[value]\n if (ISO_DATE.test(value)) return formatDateValue(value, locale)\n }\n return String(value)\n}\n\nconst NAMED_TYPES: ReadonlySet<DatabaseColumnType> = new Set<DatabaseColumnType>([\n 'person',\n 'document',\n 'relation',\n])\n\n/**\n * A cell as text: what a cell shows, what search and copy see. Checkboxes read as Yes/No; people,\n * documents and related rows by their titles (the row's `titles`), lists joined with commas.\n */\nexport function formatCell(\n value: unknown,\n type: DatabaseColumnType,\n locale?: string,\n titles?: Record<string, string>\n): string {\n if (isEmpty(value)) return ''\n if ((type === 'number' || type === 'rollup') && typeof value === 'number')\n return formatNumberValue(value, locale)\n if (type === 'date' && typeof value === 'string') return formatDateValue(value, locale)\n if (type === 'checkbox') return value ? 'Yes' : 'No'\n if (NAMED_TYPES.has(type))\n return cellIds(value)\n .map((id) => titleOf(id, titles))\n .join(', ')\n if (type === 'lookup')\n return cellList(value)\n .map((v) => formatLookupValue(v, titles, locale))\n .join(', ')\n return String(value)\n}\n\n/**\n * An editor's value as the API takes it. Empty becomes `null` (which empties the cell); everything\n * else goes as typed and the server checks it, so a bad value comes back as a 422 naming the column.\n * A document or relation cell goes as its list of ids (which replaces the cell's links).\n */\nexport function toApiValue(value: unknown, type: DatabaseColumnType): unknown {\n if (isEmpty(value)) return null\n if (LINK_COLUMN_TYPES.has(type)) return cellIds(value)\n if (type === 'checkbox') return Boolean(value)\n if (type === 'date' && value instanceof Date) {\n const pad = (n: number) => String(n).padStart(2, '0')\n return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}`\n }\n if (type === 'number' && typeof value === 'string') {\n const n = Number(value.replace(/,/g, ''))\n return Number.isFinite(n) ? n : value\n }\n return value\n}\n\n/**\n * Sort comparator for a column's stored values: empty cells last, then by type. People, documents,\n * related rows and lookups sort by what they show, so pass each row's titles.\n */\nexport function compareCells(\n a: unknown,\n b: unknown,\n type: DatabaseColumnType,\n titlesA?: Record<string, string>,\n titlesB?: Record<string, string>\n): number {\n const ea = isEmpty(a)\n const eb = isEmpty(b)\n if (ea || eb) return ea === eb ? 0 : ea ? 1 : -1\n if (type === 'number' || type === 'checkbox' || type === 'rollup') return Number(a) - Number(b)\n const shown = NAMED_TYPES.has(type) || type === 'lookup'\n const ta = shown ? formatCell(a, type, undefined, titlesA) : String(a)\n const tb = shown ? formatCell(b, type, undefined, titlesB) : String(b)\n return ta.localeCompare(tb, undefined, { sensitivity: 'base', numeric: true })\n}\n\n/**\n * A row's title: its first column as text (what a relation picker and a row's detail call it), or\n * `''` when that cell is empty.\n */\nexport function rowTitle(\n row: Pick<DatabaseRowView, 'values' | 'titles'>,\n columns: DatabaseColumnView[],\n locale?: string\n): string {\n const first = columns[0]\n return first ? formatCell(row.values[first.id], first.type, locale, row.titles) : ''\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * Databases: the shapes the blocks read, and the per-type rules for showing and editing a cell.\n *\n * A database is a user-defined table (a client database, billing records). Its columns are typed:\n * `text`, `number`, `date`, `checkbox` and `select` hold a value; `person` holds a workspace member's\n * id (`usr-\u2026`); `document` and `relation` hold lists of ids (documents of the workspace, rows of the\n * target database); `lookup` (the values of a column of the related rows) and `rollup` (a number\n * measured over them) are computed by the server and never written. The server checks and\n * normalises every cell (dates arrive as ISO `YYYY-MM-DD` or a full timestamp, numbers as numbers, a\n * select as one of its options) and names every id a row refers to in the row's `titles`, so the\n * blocks only format for display and turn an editor's value into what the API takes.\n */\n\nimport { kitOf } from './column-kits'\n\nexport type DatabaseColumnType =\n | 'text'\n | 'number'\n | 'date'\n | 'checkbox'\n | 'select'\n | 'person'\n | 'document'\n | 'relation'\n | 'lookup'\n | 'rollup'\n | 'label'\n | 'source'\n\n/** Every type, in the order a type picker lists them. */\nexport const DATABASE_COLUMN_TYPES: DatabaseColumnType[] = [\n 'text',\n 'number',\n 'date',\n 'checkbox',\n 'select',\n 'person',\n 'document',\n 'relation',\n 'lookup',\n 'rollup',\n]\n\n/** Types whose cells the server computes from a relation: shown, never edited. */\nexport const COMPUTED_COLUMN_TYPES: ReadonlySet<DatabaseColumnType> = new Set<DatabaseColumnType>([\n 'lookup',\n 'rollup',\n])\n\n/** Types whose cells are lists of ids (written as a list that replaces the cell's links). */\nexport const LINK_COLUMN_TYPES: ReadonlySet<DatabaseColumnType> = new Set<DatabaseColumnType>([\n 'document',\n 'relation',\n])\n\nexport const isComputedColumn = (column: Pick<DatabaseColumnView, 'type'>): boolean =>\n COMPUTED_COLUMN_TYPES.has(column.type)\n\nexport type DatabaseRollupOp = 'count' | 'sum' | 'avg' | 'min' | 'max'\n\nexport const DATABASE_ROLLUP_OPS: DatabaseRollupOp[] = ['count', 'sum', 'avg', 'min', 'max']\n\n/**\n * A relation column's target. A `two_way` column has a paired column on the target database\n * (`pair_column_id`) showing the same links from the other side; `reverse` marks the paired side.\n */\nexport interface DatabaseRelationView {\n database_id: string\n two_way?: boolean\n pair_column_id?: string | null\n reverse?: boolean\n}\n\n/** A lookup: `column` of the target database, read through this database's `relation` column. */\nexport interface DatabaseLookupView {\n relation: string\n column: string\n}\n\n/** A rollup: `op` over the rows linked through `relation` (`column`: a number column, not for count). */\nexport interface DatabaseRollupView {\n relation: string\n column?: string | null\n op?: DatabaseRollupOp\n}\n\nexport interface DatabaseCitationChunk {\n chunk_id: string\n page?: number | null\n}\n\n/** One cited document of a `source` cell, with the passages (chunks) cited in it. */\nexport interface DatabaseCitation {\n doc_ext_id: string\n version?: number | null\n chunks?: DatabaseCitationChunk[]\n}\n\n/** A column as the blocks read it (the API's `DatabaseColumn`). */\nexport interface DatabaseColumnView {\n id: string\n name: string\n type: DatabaseColumnType\n /** select: the option list; label: allowed tag kinds. */\n options?: string[] | null\n relation?: DatabaseRelationView | null\n lookup?: DatabaseLookupView | null\n rollup?: DatabaseRollupView | null\n /** Who may write it beyond the row's editors (`owners`, or `listed`: the people a person column of another\n * database lists \u2014 an approval's decision). */\n edit_by?: DatabaseEditRuleView | null\n /** Set by the host: the viewer may not write this column (its `edit_by` rule leaves them out). */\n locked?: boolean\n /** Where a cell is edited: in the grid cell, or only on the row's page. */\n editIn?: 'cell' | 'row'\n /** A date column that runs to the date in `endColumnId` (a span), in the zone of `timezoneColumnId`. */\n span?: { endColumnId: string; timezoneColumnId?: string }\n /** Set by the host: the width the column starts at, in pixels, instead of its type's. */\n width?: number\n /** Set by the host: the narrowest the column can be dragged (90 by default; with `grow`, the type's width). */\n minWidth?: number\n /**\n * Set by the host: a share of the table's free width (the grid's `flex`). The column fills the room\n * the others leave; a drag of its edge fixes its width.\n */\n grow?: number\n}\n\n/** A column's edit rule: the workspace's owners and the database's creator, or the people listed in\n * `column_id` of the database `database_id`. */\nexport interface DatabaseEditRuleView {\n kind: 'owners' | 'listed'\n database_id?: string | null\n column_id?: string | null\n}\n\n/**\n * A row as the blocks read it: cell values keyed by column id; an empty cell is absent. `titles`\n * names every person, document and related row the cells refer to (id \u2192 display name).\n */\nexport interface DatabaseRowView {\n id: string\n values: Record<string, unknown>\n titles?: Record<string, string>\n /** False: a draft only its creator sees, until submitted (shared). */\n shared?: boolean\n}\n\n/** A database as a list shows it (the API's `DatabaseRead`). */\nexport interface DatabaseSummaryView {\n id: string\n name: string\n description?: string | null\n columns: DatabaseColumnView[]\n row_count: number\n /** False for a database of another (public) workspace: read here, edited in its own workspace. */\n editable: boolean\n updated_at?: string | null\n}\n\nexport interface DatabaseColumnTypeLabels {\n text: string\n number: string\n date: string\n checkbox: string\n select: string\n person: string\n document: string\n relation: string\n lookup: string\n rollup: string\n label?: string\n source?: string\n}\n\nexport const DEFAULT_DATABASE_COLUMN_TYPE_LABELS: DatabaseColumnTypeLabels &\n Required<Pick<DatabaseColumnTypeLabels, 'label' | 'source'>> = {\n text: 'Text',\n number: 'Number',\n date: 'Date',\n checkbox: 'Checkbox',\n select: 'Select',\n person: 'Person',\n // The same name as a `source` column: both hold a row's sources. A `document` column holds the\n // documents; a `source` column also holds the passages cited in each.\n document: 'Sources',\n relation: 'Relation',\n lookup: 'Lookup',\n rollup: 'Rollup',\n label: 'Labels',\n source: 'Sources',\n}\n\n/**\n * Chip colours for select options: a stable colour per option text, so a value keeps its colour.\n * Theme tone pairs (tokens.css), so light and dark follow the host.\n */\nconst OPTION_TONES = [\n 'bg-blue-bg text-blue-text',\n 'bg-green-bg text-green-text',\n 'bg-yellow-bg text-yellow-text',\n 'bg-purple-bg text-purple-text',\n 'bg-red-bg text-red-text',\n 'bg-gray-bg text-gray-text',\n]\n\nexport function optionTone(option: string): string {\n let hash = 0\n for (const ch of option.toLowerCase()) hash = (hash * 31 + ch.charCodeAt(0)) >>> 0\n return OPTION_TONES[hash % OPTION_TONES.length]\n}\n\nconst isEmpty = (value: unknown): boolean =>\n value === null ||\n value === undefined ||\n (typeof value === 'string' && value.trim() === '') ||\n (Array.isArray(value) && value.length === 0)\n\n/** A cell as a list: a list cell as is, a single value as a list of one, an empty cell as none. */\nexport function cellList(value: unknown): unknown[] {\n if (isEmpty(value)) return []\n return Array.isArray(value) ? value.filter((v) => !isEmpty(v)) : [value]\n}\n\n/** The ids a person, document or relation cell holds. */\nexport function cellIds(value: unknown): string[] {\n return cellList(value).filter((v): v is string => typeof v === 'string')\n}\n\n/** An id's display name from the row's titles (the id itself when the server could not name it). */\nexport function titleOf(id: string, titles?: Record<string, string>): string {\n return titles?.[id] ?? id\n}\n\n/**\n * Two cell values, as the API stores them, are the same (lists compare item by item). With the\n * column's `type`, label and source cells compare by their own rules.\n */\nexport function sameCellValue(a: unknown, b: unknown, type?: DatabaseColumnType): boolean {\n const kit = type ? kitOf(type) : undefined\n if (kit) return kit.same(a, b)\n if (Array.isArray(a) || Array.isArray(b)) {\n const la = cellList(a)\n const lb = cellList(b)\n return la.length === lb.length && la.every((v, i) => v === lb[i])\n }\n return (a ?? null) === (b ?? null)\n}\n\n/** The row and column a kit's `format` and `compare` see when the caller only has titles and a type. */\nconst kitRow = (titles?: Record<string, string>): DatabaseRowView => ({\n id: '',\n values: {},\n titles,\n})\nconst kitColumn = (type: DatabaseColumnType): DatabaseColumnView => ({ id: '', name: '', type })\n\n/**\n * A stored date for display. A bare `YYYY-MM-DD` is a calendar day: it is shown from its own\n * components, never through a time zone (which would move it a day for viewers west of UTC).\n */\nexport function formatDateValue(value: string, locale?: string): string {\n const day = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value)\n if (day) {\n const [, y, m, d] = day\n return new Date(Date.UTC(+y, +m - 1, +d)).toLocaleDateString(locale, { timeZone: 'UTC' })\n }\n const at = new Date(value)\n return Number.isNaN(at.getTime()) ? value : at.toLocaleString(locale)\n}\n\nexport function formatNumberValue(value: number, locale?: string): string {\n return value.toLocaleString(locale, { maximumFractionDigits: 6 })\n}\n\nconst ISO_DATE = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:?\\d{2})?)?$/\n\n/**\n * One value of a lookup cell, whose type is the looked-up column's: an id reads as its title, a\n * number and an ISO date as their own column would show them.\n */\nexport function formatLookupValue(\n value: unknown,\n titles?: Record<string, string>,\n locale?: string\n): string {\n if (isEmpty(value)) return ''\n if (typeof value === 'number') return formatNumberValue(value, locale)\n if (typeof value === 'boolean') return value ? 'Yes' : 'No'\n if (typeof value === 'string') {\n if (titles?.[value] !== undefined) return titles[value]\n if (ISO_DATE.test(value)) return formatDateValue(value, locale)\n }\n return String(value)\n}\n\nconst NAMED_TYPES: ReadonlySet<DatabaseColumnType> = new Set<DatabaseColumnType>([\n 'person',\n 'document',\n 'relation',\n])\n\n/**\n * A cell as text: what a cell shows, what search and copy see. Checkboxes read as Yes/No; people,\n * documents and related rows by their titles (the row's `titles`), lists joined with commas.\n */\nexport function formatCell(\n value: unknown,\n type: DatabaseColumnType,\n locale?: string,\n titles?: Record<string, string>\n): string {\n if (isEmpty(value)) return ''\n const kit = kitOf(type)\n if (kit) return kit.format(value, kitRow(titles), kitColumn(type))\n if ((type === 'number' || type === 'rollup') && typeof value === 'number')\n return formatNumberValue(value, locale)\n if (type === 'date' && typeof value === 'string') return formatDateValue(value, locale)\n if (type === 'checkbox') return value ? 'Yes' : 'No'\n if (NAMED_TYPES.has(type))\n return cellIds(value)\n .map((id) => titleOf(id, titles))\n .join(', ')\n if (type === 'lookup')\n return cellList(value)\n .map((v) => formatLookupValue(v, titles, locale))\n .join(', ')\n return String(value)\n}\n\n/**\n * An editor's value as the API takes it. Empty becomes `null` (which empties the cell); everything\n * else goes as typed and the server checks it, so a bad value comes back as a 422 naming the column.\n * A document or relation cell goes as its list of ids (which replaces the cell's links).\n */\nexport function toApiValue(value: unknown, type: DatabaseColumnType): unknown {\n if (isEmpty(value)) return null\n const kit = kitOf(type)\n if (kit) return kit.toApi(value)\n if (LINK_COLUMN_TYPES.has(type)) return cellIds(value)\n if (type === 'checkbox') return Boolean(value)\n if (type === 'date' && value instanceof Date) {\n const pad = (n: number) => String(n).padStart(2, '0')\n return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}`\n }\n if (type === 'number' && typeof value === 'string') {\n const n = Number(value.replace(/,/g, ''))\n return Number.isFinite(n) ? n : value\n }\n return value\n}\n\n/**\n * Sort comparator for a column's stored values: empty cells last, then by type. People, documents,\n * related rows and lookups sort by what they show, so pass each row's titles.\n */\nexport function compareCells(\n a: unknown,\n b: unknown,\n type: DatabaseColumnType,\n titlesA?: Record<string, string>,\n titlesB?: Record<string, string>\n): number {\n const ea = isEmpty(a)\n const eb = isEmpty(b)\n if (ea || eb) return ea === eb ? 0 : ea ? 1 : -1\n const kit = kitOf(type)\n if (kit) return kit.compare(a, b, kitRow(titlesA), kitRow(titlesB))\n if (type === 'number' || type === 'checkbox' || type === 'rollup') return Number(a) - Number(b)\n const shown = NAMED_TYPES.has(type) || type === 'lookup'\n const ta = shown ? formatCell(a, type, undefined, titlesA) : String(a)\n const tb = shown ? formatCell(b, type, undefined, titlesB) : String(b)\n return ta.localeCompare(tb, undefined, { sensitivity: 'base', numeric: true })\n}\n\n/**\n * A row's title: its first column as text (what a relation picker and a row's detail call it), or\n * `''` when that cell is empty.\n */\nexport function rowTitle(\n row: Pick<DatabaseRowView, 'values' | 'titles'>,\n columns: DatabaseColumnView[],\n locale?: string\n): string {\n const first = columns[0]\n return first ? formatCell(row.values[first.id], first.type, locale, row.titles) : ''\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,20 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column definitions for a database grid, built from the database's own (user-defined) columns.
|
|
3
|
+
*
|
|
4
|
+
* Each column edits in place with the editor for its type (AG Grid's for text, number, date and
|
|
5
|
+
* checkbox; a chip list for select; a searchable picker for a person, documents and related rows); a
|
|
6
|
+
* checkbox toggles with one click, a select shows its value as a coloured chip, documents and
|
|
7
|
+
* related rows as chips named from the row's `titles`. Lookup and rollup columns are computed by the
|
|
8
|
+
* server: read-only, their header marked with a quiet "computed" sign. The header carries the type's
|
|
9
|
+
* icon and a button that opens the column's settings, and a trailing narrow column holds the "add a
|
|
10
|
+
* column" button: a Notion/Airtable-style table.
|
|
11
|
+
*
|
|
12
|
+
* Every column's `colId` is the database column id (`col-…`), so AG Grid's saved column state
|
|
13
|
+
* (order, width) survives renames.
|
|
14
|
+
*/
|
|
15
|
+
import type { ReactNode } from 'react';
|
|
1
16
|
import type { ColDef } from 'ag-grid-community';
|
|
2
17
|
import { Type } from 'lucide-react';
|
|
3
18
|
import { type DatabaseColumnType, type DatabaseColumnView, type DatabaseRowView } from './column-types';
|
|
4
19
|
import { SelectChip } from './SelectChip';
|
|
5
20
|
import { type DatabaseCellSources } from './linkCells';
|
|
21
|
+
import { type DateSpanEditorLabels } from './DateSpanEditor';
|
|
6
22
|
export { SelectChip };
|
|
7
23
|
export interface DatabaseColumnLabels {
|
|
8
24
|
addColumn: string;
|
|
9
25
|
columnSettings: (name: string) => string;
|
|
10
26
|
computed: string;
|
|
11
27
|
openRow: string;
|
|
28
|
+
dateSpanEditor: DateSpanEditorLabels;
|
|
29
|
+
/** The accessible name of a source chip in a grid cell, which opens the row. */
|
|
30
|
+
openRowFromSource: (title: string) => string;
|
|
12
31
|
}
|
|
13
32
|
export declare const DEFAULT_DATABASE_COLUMN_LABELS: DatabaseColumnLabels;
|
|
14
33
|
/** colId of the trailing "add a column" column (never a database column id). */
|
|
15
34
|
export declare const ADD_COLUMN_COL_ID = "__add_column";
|
|
16
35
|
/** colId of the leading "open the row" column (never a database column id). */
|
|
17
36
|
export declare const OPEN_ROW_COL_ID = "__open_row";
|
|
37
|
+
/** colId of the trailing row-actions column, left of the add column (never a database column id). */
|
|
38
|
+
export declare const ROW_ACTIONS_COL_ID = "__row_actions";
|
|
18
39
|
export declare const COLUMN_TYPE_ICONS: Record<DatabaseColumnType, typeof Type>;
|
|
19
40
|
export interface DatabaseColumnOptions {
|
|
20
41
|
/** No editing, no column settings, no add-column button (a database of another workspace). */
|
|
@@ -23,8 +44,14 @@ export interface DatabaseColumnOptions {
|
|
|
23
44
|
onEditColumn?: (column: DatabaseColumnView) => void;
|
|
24
45
|
/** Add a column (the trailing "+" header). */
|
|
25
46
|
onAddColumn?: () => void;
|
|
26
|
-
/** Open a row in full (a leading column of "open" buttons). */
|
|
27
|
-
onOpenRow?: (row: DatabaseRowView
|
|
47
|
+
/** Open a row in full (a leading column of "open" buttons, or a cell that edits on the row page). */
|
|
48
|
+
onOpenRow?: (row: DatabaseRowView, options?: {
|
|
49
|
+
focusColumn?: string;
|
|
50
|
+
}) => void;
|
|
51
|
+
/** Whether this cell may be edited here (AND-ed with the column's own rules and `readOnly`). */
|
|
52
|
+
isCellEditable?: (row: DatabaseRowView, column: DatabaseColumnView) => boolean;
|
|
53
|
+
/** A pinned-right column of row actions; the host draws what each row offers. */
|
|
54
|
+
renderRowActions?: (row: DatabaseRowView) => ReactNode;
|
|
28
55
|
/** Choices for person, document and relation cells, and what a document chip opens. */
|
|
29
56
|
sources?: DatabaseCellSources;
|
|
30
57
|
/** Locale for numbers and dates. */
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
CalendarDays,
|
|
6
6
|
CheckSquare,
|
|
7
7
|
ChevronDown,
|
|
8
|
-
FileText,
|
|
9
8
|
Hash,
|
|
10
9
|
Lock,
|
|
11
10
|
Maximize2,
|
|
@@ -23,18 +22,34 @@ import {
|
|
|
23
22
|
sameCellValue,
|
|
24
23
|
toApiValue
|
|
25
24
|
} from "./column-types.js";
|
|
25
|
+
import { COLUMN_KITS, kitOf } from "./column-kits.js";
|
|
26
26
|
import { SelectChip } from "./SelectChip.js";
|
|
27
27
|
import { SelectCellEditor } from "./SelectCellEditor.js";
|
|
28
28
|
import { PickCellEditor } from "./PickCellEditor.js";
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
LinkChipsCell,
|
|
31
|
+
LookupCell,
|
|
32
|
+
PersonCell,
|
|
33
|
+
labelSourceFor
|
|
34
|
+
} from "./linkCells.js";
|
|
35
|
+
import { LabelsCell } from "./LabelsCell.js";
|
|
36
|
+
import { SourcesCell } from "./SourcesCell.js";
|
|
37
|
+
import {
|
|
38
|
+
DateSpanCellEditor,
|
|
39
|
+
DEFAULT_DATE_SPAN_EDITOR_LABELS
|
|
40
|
+
} from "./DateSpanEditor.js";
|
|
41
|
+
import { formatSpan } from "../timeline/span.js";
|
|
30
42
|
const DEFAULT_DATABASE_COLUMN_LABELS = {
|
|
31
43
|
addColumn: "Add a column",
|
|
32
44
|
columnSettings: (name) => `${name} column settings`,
|
|
33
45
|
computed: "Computed from a relation (read-only)",
|
|
34
|
-
openRow: "Open row"
|
|
46
|
+
openRow: "Open row",
|
|
47
|
+
dateSpanEditor: DEFAULT_DATE_SPAN_EDITOR_LABELS,
|
|
48
|
+
openRowFromSource: (title) => `${title}: open the row`
|
|
35
49
|
};
|
|
36
50
|
const ADD_COLUMN_COL_ID = "__add_column";
|
|
37
51
|
const OPEN_ROW_COL_ID = "__open_row";
|
|
52
|
+
const ROW_ACTIONS_COL_ID = "__row_actions";
|
|
38
53
|
const COLUMN_TYPE_ICONS = {
|
|
39
54
|
text: Type,
|
|
40
55
|
number: Hash,
|
|
@@ -42,10 +57,12 @@ const COLUMN_TYPE_ICONS = {
|
|
|
42
57
|
checkbox: CheckSquare,
|
|
43
58
|
select: ChevronDown,
|
|
44
59
|
person: UserRound,
|
|
45
|
-
document:
|
|
60
|
+
document: COLUMN_KITS.source.icon,
|
|
46
61
|
relation: ArrowUpRight,
|
|
47
62
|
lookup: Search,
|
|
48
|
-
rollup: Sigma
|
|
63
|
+
rollup: Sigma,
|
|
64
|
+
label: COLUMN_KITS.label.icon,
|
|
65
|
+
source: COLUMN_KITS.source.icon
|
|
49
66
|
};
|
|
50
67
|
const WIDTHS = {
|
|
51
68
|
text: 220,
|
|
@@ -57,7 +74,9 @@ const WIDTHS = {
|
|
|
57
74
|
document: 240,
|
|
58
75
|
relation: 240,
|
|
59
76
|
lookup: 200,
|
|
60
|
-
rollup: 130
|
|
77
|
+
rollup: 130,
|
|
78
|
+
label: COLUMN_KITS.label.width,
|
|
79
|
+
source: COLUMN_KITS.source.width
|
|
61
80
|
};
|
|
62
81
|
function HeaderLabel({
|
|
63
82
|
dbColumn: column,
|
|
@@ -106,14 +125,28 @@ function columnWidth(column) {
|
|
|
106
125
|
const header = Math.round(column.name.length * 8) + 76 + (isComputedColumn(column) ? 16 : 0);
|
|
107
126
|
return Math.min(320, Math.max(WIDTHS[column.type], header));
|
|
108
127
|
}
|
|
128
|
+
const positive = (n) => typeof n === "number" && Number.isFinite(n) && n > 0 ? n : void 0;
|
|
129
|
+
function sizing(column) {
|
|
130
|
+
const grow = positive(column.grow);
|
|
131
|
+
if (grow !== void 0) {
|
|
132
|
+
return { flex: grow, minWidth: positive(column.minWidth) ?? columnWidth(column) };
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
width: positive(column.width) ?? columnWidth(column),
|
|
136
|
+
minWidth: positive(column.minWidth) ?? 90
|
|
137
|
+
};
|
|
138
|
+
}
|
|
109
139
|
function canEditColumn(column, sources) {
|
|
110
140
|
if (isComputedColumn(column) || column.locked) return false;
|
|
141
|
+
const kit = kitOf(column.type);
|
|
142
|
+
if (kit) return kit.canEditInGrid(column, sources);
|
|
111
143
|
if (column.type === "person") return Boolean(sources?.members);
|
|
112
144
|
if (column.type === "document") return Boolean(sources?.documents);
|
|
113
145
|
if (column.type === "relation") return Boolean(sources?.searchRows && column.relation);
|
|
114
146
|
return true;
|
|
115
147
|
}
|
|
116
|
-
function editorFor(column, sources) {
|
|
148
|
+
function editorFor(column, sources, dateSpanLabels) {
|
|
149
|
+
if (kitOf(column.type)) return {};
|
|
117
150
|
const pick = (params) => ({
|
|
118
151
|
cellEditor: PickCellEditor,
|
|
119
152
|
cellEditorPopup: true,
|
|
@@ -123,7 +156,15 @@ function editorFor(column, sources) {
|
|
|
123
156
|
case "number":
|
|
124
157
|
return { cellEditor: "agNumberCellEditor", cellEditorParams: { showStepperButtons: false } };
|
|
125
158
|
case "date":
|
|
126
|
-
return
|
|
159
|
+
return column.span ? {
|
|
160
|
+
cellEditor: DateSpanCellEditor,
|
|
161
|
+
cellEditorParams: {
|
|
162
|
+
endColumnId: column.span.endColumnId,
|
|
163
|
+
timezoneColumnId: column.span.timezoneColumnId,
|
|
164
|
+
labels: dateSpanLabels,
|
|
165
|
+
columnName: column.name
|
|
166
|
+
}
|
|
167
|
+
} : { cellEditor: "agDateStringCellEditor" };
|
|
127
168
|
case "checkbox":
|
|
128
169
|
return { cellEditor: "agCheckboxCellEditor" };
|
|
129
170
|
case "select":
|
|
@@ -151,7 +192,42 @@ function editorFor(column, sources) {
|
|
|
151
192
|
return { cellEditor: "agTextCellEditor" };
|
|
152
193
|
}
|
|
153
194
|
}
|
|
154
|
-
|
|
195
|
+
const EMPTY_ROW = { id: "", values: {} };
|
|
196
|
+
const asText = (v) => typeof v === "string" && v ? v : null;
|
|
197
|
+
function rendererFor(column, locale, sources, readOnly, isCellEditable, onOpenRow, l) {
|
|
198
|
+
const kit = kitOf(column.type);
|
|
199
|
+
if (kit) {
|
|
200
|
+
const valueFormatter = (p) => kit.format(p.value, p.data ?? EMPTY_ROW, column);
|
|
201
|
+
if (column.type === "label") {
|
|
202
|
+
const editableFor = (row) => !readOnly && column.editIn !== "row" && canEditColumn(column, sources) && (!row || !isCellEditable || isCellEditable(row, column));
|
|
203
|
+
return {
|
|
204
|
+
valueFormatter,
|
|
205
|
+
cellRenderer: (p) => /* @__PURE__ */ jsx(
|
|
206
|
+
LabelsCell,
|
|
207
|
+
{
|
|
208
|
+
value: p.value,
|
|
209
|
+
titles: p.data?.titles,
|
|
210
|
+
labels: labelSourceFor(sources?.labels, column),
|
|
211
|
+
onChange: editableFor(p.data) ? (ids) => p.node.setDataValue(column.id, ids) : void 0,
|
|
212
|
+
rowHeight: p.node?.rowHeight ?? void 0
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
valueFormatter,
|
|
219
|
+
cellRenderer: (p) => /* @__PURE__ */ jsx(
|
|
220
|
+
SourcesCell,
|
|
221
|
+
{
|
|
222
|
+
value: p.value,
|
|
223
|
+
titles: p.data?.titles,
|
|
224
|
+
openLabel: l.openRowFromSource,
|
|
225
|
+
onOpen: onOpenRow && p.data ? () => onOpenRow(p.data, { focusColumn: column.id }) : void 0,
|
|
226
|
+
rowHeight: p.node?.rowHeight ?? void 0
|
|
227
|
+
}
|
|
228
|
+
)
|
|
229
|
+
};
|
|
230
|
+
}
|
|
155
231
|
switch (column.type) {
|
|
156
232
|
case "checkbox":
|
|
157
233
|
return {
|
|
@@ -172,10 +248,20 @@ function rendererFor(column, locale, sources) {
|
|
|
172
248
|
cellClass: "cell-numeric text-muted-foreground",
|
|
173
249
|
valueFormatter: (p) => formatCell(p.value, "rollup", locale)
|
|
174
250
|
};
|
|
175
|
-
case "date":
|
|
251
|
+
case "date": {
|
|
252
|
+
const span = column.span;
|
|
253
|
+
if (span)
|
|
254
|
+
return {
|
|
255
|
+
valueFormatter: (p) => typeof p.value === "string" && p.value ? formatSpan(
|
|
256
|
+
p.value,
|
|
257
|
+
asText(p.data?.values[span.endColumnId]),
|
|
258
|
+
span.timezoneColumnId ? asText(p.data?.values[span.timezoneColumnId]) : null
|
|
259
|
+
) : ""
|
|
260
|
+
};
|
|
176
261
|
return {
|
|
177
262
|
valueFormatter: (p) => formatCell(p.value, "date", locale)
|
|
178
263
|
};
|
|
264
|
+
}
|
|
179
265
|
case "person":
|
|
180
266
|
return {
|
|
181
267
|
cellRenderer: (p) => /* @__PURE__ */ jsx(PersonCell, { value: p.value, titles: p.data?.titles })
|
|
@@ -198,11 +284,35 @@ function rendererFor(column, locale, sources) {
|
|
|
198
284
|
cellRenderer: (p) => /* @__PURE__ */ jsx(LookupCell, { value: p.value, titles: p.data?.titles, locale })
|
|
199
285
|
};
|
|
200
286
|
default:
|
|
201
|
-
return {};
|
|
287
|
+
return { cellClass: "database-cell-text" };
|
|
202
288
|
}
|
|
203
289
|
}
|
|
290
|
+
function setSpan(row, columnId, span, newValue) {
|
|
291
|
+
if ((typeof newValue === "string" || newValue === null) && sameCellValue(asText(newValue), row.values[columnId] ?? null)) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
const next = typeof newValue === "object" && newValue !== null ? newValue : { start: asText(newValue), end: null, timezone: null };
|
|
295
|
+
const writes = [
|
|
296
|
+
[columnId, next.start],
|
|
297
|
+
[span.endColumnId, next.end],
|
|
298
|
+
...span.timezoneColumnId ? [[span.timezoneColumnId, next.timezone]] : []
|
|
299
|
+
];
|
|
300
|
+
const changed = writes.filter(([id, v]) => !sameCellValue(v, row.values[id] ?? null));
|
|
301
|
+
if (changed.length === 0) return false;
|
|
302
|
+
row.values = { ...row.values, ...Object.fromEntries(writes) };
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
204
305
|
function createDatabaseColumns(columns, options = {}) {
|
|
205
|
-
const {
|
|
306
|
+
const {
|
|
307
|
+
readOnly,
|
|
308
|
+
onEditColumn,
|
|
309
|
+
onAddColumn,
|
|
310
|
+
onOpenRow,
|
|
311
|
+
locale,
|
|
312
|
+
sources,
|
|
313
|
+
isCellEditable,
|
|
314
|
+
renderRowActions
|
|
315
|
+
} = options;
|
|
206
316
|
const l = { ...DEFAULT_DATABASE_COLUMN_LABELS, ...options.labels };
|
|
207
317
|
const openRow = onOpenRow && columns.length > 0 ? [
|
|
208
318
|
{
|
|
@@ -239,42 +349,64 @@ function createDatabaseColumns(columns, options = {}) {
|
|
|
239
349
|
) : null
|
|
240
350
|
}
|
|
241
351
|
] : [];
|
|
242
|
-
const defs = columns.map((column) =>
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
352
|
+
const defs = columns.map((column) => {
|
|
353
|
+
const gridEditable = !readOnly && !kitOf(column.type) && column.editIn !== "row" && canEditColumn(column, sources);
|
|
354
|
+
return {
|
|
355
|
+
colId: column.id,
|
|
356
|
+
headerName: column.name,
|
|
357
|
+
...sizing(column),
|
|
358
|
+
resizable: true,
|
|
359
|
+
sortable: true,
|
|
360
|
+
editable: isCellEditable ? (p) => gridEditable && (!p.data || isCellEditable(p.data, column)) : gridEditable,
|
|
361
|
+
// The grid's own type inference must not second-guess the database's column type.
|
|
362
|
+
cellDataType: false,
|
|
363
|
+
headerComponentParams: {
|
|
364
|
+
innerHeaderComponent: HeaderLabel,
|
|
365
|
+
innerHeaderComponentParams: {
|
|
366
|
+
dbColumn: column,
|
|
367
|
+
settingsLabel: l.columnSettings(column.name),
|
|
368
|
+
computedLabel: l.computed,
|
|
369
|
+
onEdit: !readOnly && onEditColumn ? () => onEditColumn(column) : void 0
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
// An empty checkbox reads as unticked (not indeterminate).
|
|
373
|
+
valueGetter: (p) => column.type === "checkbox" ? p.data?.values[column.id] === true : p.data?.values[column.id] ?? null,
|
|
374
|
+
// Edits land in the row's values as the API would store them; the host saves them in
|
|
375
|
+
// onCellValueChanged and puts the server's normalised row back.
|
|
376
|
+
valueSetter: (p) => {
|
|
377
|
+
if (!p.data) return false;
|
|
378
|
+
const span = column.span;
|
|
379
|
+
if (span) return setSpan(p.data, column.id, span, p.newValue);
|
|
380
|
+
const next = toApiValue(p.newValue, column.type);
|
|
381
|
+
if (sameCellValue(next, p.oldValue, column.type)) return false;
|
|
382
|
+
p.data.values = { ...p.data.values, [column.id]: next };
|
|
383
|
+
return true;
|
|
384
|
+
},
|
|
385
|
+
comparator: (a, b, nodeA, nodeB) => compareCells(a, b, column.type, nodeA?.data?.titles, nodeB?.data?.titles),
|
|
386
|
+
getQuickFilterText: (p) => formatCell(p.value, column.type, locale, p.data?.titles),
|
|
387
|
+
...editorFor(column, sources, l.dateSpanEditor),
|
|
388
|
+
...rendererFor(column, locale, sources, readOnly, isCellEditable, onOpenRow, l)
|
|
389
|
+
};
|
|
390
|
+
});
|
|
277
391
|
defs.unshift(...openRow);
|
|
392
|
+
if (renderRowActions && columns.length > 0) {
|
|
393
|
+
defs.push({
|
|
394
|
+
colId: ROW_ACTIONS_COL_ID,
|
|
395
|
+
headerName: "",
|
|
396
|
+
width: 40,
|
|
397
|
+
minWidth: 40,
|
|
398
|
+
maxWidth: 40,
|
|
399
|
+
resizable: false,
|
|
400
|
+
sortable: false,
|
|
401
|
+
editable: false,
|
|
402
|
+
suppressMovable: true,
|
|
403
|
+
pinned: "right",
|
|
404
|
+
lockPinned: true,
|
|
405
|
+
cellClass: "flex items-center justify-center !px-0",
|
|
406
|
+
valueGetter: () => null,
|
|
407
|
+
cellRenderer: (p) => p.data ? renderRowActions(p.data) : null
|
|
408
|
+
});
|
|
409
|
+
}
|
|
278
410
|
if (!readOnly && onAddColumn) {
|
|
279
411
|
defs.push({
|
|
280
412
|
colId: ADD_COLUMN_COL_ID,
|
|
@@ -300,6 +432,7 @@ export {
|
|
|
300
432
|
COLUMN_TYPE_ICONS,
|
|
301
433
|
DEFAULT_DATABASE_COLUMN_LABELS,
|
|
302
434
|
OPEN_ROW_COL_ID,
|
|
435
|
+
ROW_ACTIONS_COL_ID,
|
|
303
436
|
SelectChip,
|
|
304
437
|
canEditColumn,
|
|
305
438
|
columnWidth,
|