@datarecce/ui 0.1.29 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{RecceCheckContext-fAKHgsGz.js → RecceCheckContext-DPpu9nG5.js} +2 -2
- package/dist/{RecceCheckContext-fAKHgsGz.js.map → RecceCheckContext-DPpu9nG5.js.map} +1 -1
- package/dist/{RecceCheckContext-PT4-g1bW.mjs → RecceCheckContext-bXdfQLGG.mjs} +2 -2
- package/dist/{RecceCheckContext-PT4-g1bW.mjs.map → RecceCheckContext-bXdfQLGG.mjs.map} +1 -1
- package/dist/api.d.mts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +4 -3
- package/dist/api.mjs +4 -3
- package/dist/{components-B9F5oJbK.js → components-B-YxuuPz.js} +66 -65
- package/dist/{components-B9F5oJbK.js.map → components-B-YxuuPz.js.map} +1 -1
- package/dist/{components-D2DRqJsz.css → components-BeAjVBV3.css} +1 -1
- package/dist/{components-D2DRqJsz.css.map → components-BeAjVBV3.css.map} +1 -1
- package/dist/{components-gDC1ucjo.mjs → components-DCOI1YlQ.mjs} +8 -7
- package/dist/{components-gDC1ucjo.mjs.map → components-DCOI1YlQ.mjs.map} +1 -1
- package/dist/{components-dVXbmdqd.css → components-iUxcqtUB.css} +1 -1
- package/dist/{components-dVXbmdqd.css.map → components-iUxcqtUB.css.map} +1 -1
- package/dist/components.d.mts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +6 -5
- package/dist/components.mjs +6 -5
- package/dist/{hooks-C2jUJ9EN.js → hooks-B9hsc1oD.js} +3 -3
- package/dist/{hooks-C2jUJ9EN.js.map → hooks-B9hsc1oD.js.map} +1 -1
- package/dist/{hooks-4hRUjy9Q.mjs → hooks-DjBNmTdh.mjs} +3 -3
- package/dist/{hooks-4hRUjy9Q.mjs.map → hooks-DjBNmTdh.mjs.map} +1 -1
- package/dist/hooks.d.mts +1 -1
- package/dist/hooks.d.ts +1 -1
- package/dist/hooks.js +5 -4
- package/dist/hooks.mjs +5 -4
- package/dist/{html2canvas-pro.esm-BR5xeFe-.mjs → html2canvas-pro.esm-BInzOtWO.mjs} +1 -1
- package/dist/{html2canvas-pro.esm-BR5xeFe-.mjs.map → html2canvas-pro.esm-BInzOtWO.mjs.map} +1 -1
- package/dist/{html2canvas-pro.esm-CVOsBdk0.js → html2canvas-pro.esm-WJxOmKlq.js} +1 -1
- package/dist/{html2canvas-pro.esm-CVOsBdk0.js.map → html2canvas-pro.esm-WJxOmKlq.js.map} +1 -1
- package/dist/{index-Bv5R8iLo.d.mts → index-B9lSPJTi.d.ts} +192 -12
- package/dist/index-B9lSPJTi.d.ts.map +1 -0
- package/dist/{index-CUtFlKOo.d.ts → index-IIXVIoOL.d.mts} +262 -78
- package/dist/index-IIXVIoOL.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -8
- package/dist/index.mjs.map +1 -1
- package/dist/mui-theme-B2wm_cvZ.js +732 -0
- package/dist/mui-theme-B2wm_cvZ.js.map +1 -0
- package/dist/mui-theme-CUhybmBq.mjs +696 -0
- package/dist/mui-theme-CUhybmBq.mjs.map +1 -0
- package/dist/{state-CELzQ0tM.mjs → state-B9yzhuKs.mjs} +5 -694
- package/dist/state-B9yzhuKs.mjs.map +1 -0
- package/dist/{state-eEsMhIy4.css → state-DOUPNifc.css} +1 -1
- package/dist/{state-eEsMhIy4.css.map → state-DOUPNifc.css.map} +1 -1
- package/dist/{state-CemiRRon.js → state-lPCQsWy5.js} +24 -737
- package/dist/state-lPCQsWy5.js.map +1 -0
- package/dist/styles.css +4 -0
- package/dist/theme.d.mts +3 -0
- package/dist/theme.d.ts +3 -0
- package/dist/theme.js +9 -0
- package/dist/theme.mjs +4 -0
- package/dist/{tooltipMessage-CrXjOmVM.mjs → tooltipMessage-B--I3p1V.mjs} +1 -1
- package/dist/{tooltipMessage-CrXjOmVM.mjs.map → tooltipMessage-B--I3p1V.mjs.map} +1 -1
- package/dist/{tooltipMessage-Dbi1kkfi.js → tooltipMessage-DosF13kZ.js} +1 -1
- package/dist/{tooltipMessage-Dbi1kkfi.js.map → tooltipMessage-DosF13kZ.js.map} +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +2 -2
- package/dist/types.mjs +2 -2
- package/dist/{urls-D7PrPolY.mjs → urls-B1Ymdoz-.mjs} +1 -1
- package/dist/{urls-D7PrPolY.mjs.map → urls-B1Ymdoz-.mjs.map} +1 -1
- package/dist/{urls-SazAekCZ.js → urls-C4eAc82S.js} +1 -1
- package/dist/{urls-SazAekCZ.js.map → urls-C4eAc82S.js.map} +1 -1
- package/dist/{version-bWg7XwOu.js → version-Dh8sZhvs.js} +2 -2
- package/dist/{version-bWg7XwOu.js.map → version-Dh8sZhvs.js.map} +1 -1
- package/dist/{version-paZ9esBk.mjs → version-OnOKzBeQ.mjs} +2 -2
- package/dist/{version-paZ9esBk.mjs.map → version-OnOKzBeQ.mjs.map} +1 -1
- package/package.json +9 -2
- package/recce-source/.editorconfig +26 -0
- package/recce-source/.flake8 +37 -0
- package/recce-source/.github/ISSUE_TEMPLATE/bug_report.yml +67 -0
- package/recce-source/.github/ISSUE_TEMPLATE/custom.md +10 -0
- package/recce-source/.github/ISSUE_TEMPLATE/feature_request.yml +42 -0
- package/recce-source/.github/PULL_REQUEST_TEMPLATE.md +21 -0
- package/recce-source/.github/copilot-instructions.md +331 -0
- package/recce-source/.github/instructions/backend-instructions.md +541 -0
- package/recce-source/.github/instructions/frontend-instructions.md +317 -0
- package/recce-source/.github/workflows/build-statics.yaml +72 -0
- package/recce-source/.github/workflows/bump.yaml +48 -0
- package/recce-source/.github/workflows/integration-tests-cloud.yaml +92 -0
- package/recce-source/.github/workflows/integration-tests-sqlmesh.yaml +33 -0
- package/recce-source/.github/workflows/integration-tests.yaml +52 -0
- package/recce-source/.github/workflows/nightly.yaml +246 -0
- package/recce-source/.github/workflows/release.yaml +196 -0
- package/recce-source/.github/workflows/tests-js.yaml +58 -0
- package/recce-source/.github/workflows/tests-python.yaml +128 -0
- package/recce-source/.pre-commit-config.yaml +26 -0
- package/recce-source/CLAUDE.md +483 -0
- package/recce-source/CODE_OF_CONDUCT.md +128 -0
- package/recce-source/CONTRIBUTING.md +107 -0
- package/recce-source/LICENSE +201 -0
- package/recce-source/Makefile +126 -0
- package/recce-source/README.md +182 -0
- package/recce-source/RECCE_CLOUD.md +81 -0
- package/recce-source/SECURITY.md +25 -0
- package/recce-source/docs/PACKAGING.md +340 -0
- package/recce-source/docs/README.md +1 -0
- package/recce-source/integration_tests/dbt/dbt_project.yml +26 -0
- package/recce-source/integration_tests/dbt/models/customers.sql +69 -0
- package/recce-source/integration_tests/dbt/models/docs.md +14 -0
- package/recce-source/integration_tests/dbt/models/orders.sql +56 -0
- package/recce-source/integration_tests/dbt/models/schema.yml +82 -0
- package/recce-source/integration_tests/dbt/models/staging/schema.yml +31 -0
- package/recce-source/integration_tests/dbt/models/staging/stg_customers.sql +22 -0
- package/recce-source/integration_tests/dbt/models/staging/stg_orders.sql +23 -0
- package/recce-source/integration_tests/dbt/models/staging/stg_payments.sql +25 -0
- package/recce-source/integration_tests/dbt/packages.yml +7 -0
- package/recce-source/integration_tests/dbt/profiles.yml +8 -0
- package/recce-source/integration_tests/dbt/seeds/raw_customers.csv +101 -0
- package/recce-source/integration_tests/dbt/seeds/raw_orders.csv +100 -0
- package/recce-source/integration_tests/dbt/seeds/raw_payments.csv +114 -0
- package/recce-source/integration_tests/dbt/seeds/raw_statuses.csv +5 -0
- package/recce-source/integration_tests/dbt/smoke_test.sh +72 -0
- package/recce-source/integration_tests/dbt/smoke_test_cloud.sh +71 -0
- package/recce-source/integration_tests/sqlmesh/__init__.py +0 -0
- package/recce-source/integration_tests/sqlmesh/audits/assert_item_price_above_zero.sql +9 -0
- package/recce-source/integration_tests/sqlmesh/audits/items.sql +7 -0
- package/recce-source/integration_tests/sqlmesh/audits/order_items.sql +7 -0
- package/recce-source/integration_tests/sqlmesh/config.py +171 -0
- package/recce-source/integration_tests/sqlmesh/helper.py +20 -0
- package/recce-source/integration_tests/sqlmesh/hooks/__init__.py +0 -0
- package/recce-source/integration_tests/sqlmesh/macros/__init__.py +0 -0
- package/recce-source/integration_tests/sqlmesh/macros/macros.py +8 -0
- package/recce-source/integration_tests/sqlmesh/macros/macros.sql +8 -0
- package/recce-source/integration_tests/sqlmesh/macros/utils.py +11 -0
- package/recce-source/integration_tests/sqlmesh/metrics/metrics.sql +25 -0
- package/recce-source/integration_tests/sqlmesh/models/customer_revenue_by_day.sql +41 -0
- package/recce-source/integration_tests/sqlmesh/models/customer_revenue_lifetime.sql +60 -0
- package/recce-source/integration_tests/sqlmesh/models/customers.sql +32 -0
- package/recce-source/integration_tests/sqlmesh/models/items.py +95 -0
- package/recce-source/integration_tests/sqlmesh/models/marketing.sql +15 -0
- package/recce-source/integration_tests/sqlmesh/models/order_items.py +95 -0
- package/recce-source/integration_tests/sqlmesh/models/orders.py +70 -0
- package/recce-source/integration_tests/sqlmesh/models/raw_marketing.py +62 -0
- package/recce-source/integration_tests/sqlmesh/models/top_waiters.sql +23 -0
- package/recce-source/integration_tests/sqlmesh/models/waiter_as_customer_by_day.sql +29 -0
- package/recce-source/integration_tests/sqlmesh/models/waiter_names.sql +10 -0
- package/recce-source/integration_tests/sqlmesh/models/waiter_revenue_by_day.sql +29 -0
- package/recce-source/integration_tests/sqlmesh/models/waiters.py +62 -0
- package/recce-source/integration_tests/sqlmesh/prep_env.sh +16 -0
- package/recce-source/integration_tests/sqlmesh/schema.yaml +5 -0
- package/recce-source/integration_tests/sqlmesh/seeds/waiter_names.csv +11 -0
- package/recce-source/integration_tests/sqlmesh/test_server.sh +29 -0
- package/recce-source/integration_tests/sqlmesh/tests/test_customer_revenue_by_day.yaml +63 -0
- package/recce-source/integration_tests/sqlmesh/tests/test_order_items.yaml +72 -0
- package/recce-source/js/.editorconfig +27 -0
- package/recce-source/js/.env.development +5 -0
- package/recce-source/js/.husky/pre-commit +29 -0
- package/recce-source/js/.nvmrc +1 -0
- package/recce-source/js/README.md +39 -0
- package/recce-source/js/app/(mainComponents)/DisplayModeToggle.tsx +65 -0
- package/recce-source/js/app/(mainComponents)/NavBar.tsx +228 -0
- package/recce-source/js/app/(mainComponents)/RecceVersionBadge.tsx +107 -0
- package/recce-source/js/app/(mainComponents)/TopBar.tsx +252 -0
- package/recce-source/js/app/@lineage/default.tsx +20 -0
- package/recce-source/js/app/@lineage/page.tsx +14 -0
- package/recce-source/js/app/MainLayout.tsx +170 -0
- package/recce-source/js/app/Providers.tsx +49 -0
- package/recce-source/js/app/checks/page.tsx +296 -0
- package/recce-source/js/app/error.tsx +93 -0
- package/recce-source/js/app/favicon.ico +0 -0
- package/recce-source/js/app/global-error.tsx +115 -0
- package/recce-source/js/app/global.css +82 -0
- package/recce-source/js/app/layout.tsx +48 -0
- package/recce-source/js/app/lineage/page.tsx +15 -0
- package/recce-source/js/app/page.tsx +12 -0
- package/recce-source/js/app/query/page.tsx +8 -0
- package/recce-source/js/biome.json +313 -0
- package/recce-source/js/jest.config.js +34 -0
- package/recce-source/js/jest.globals.d.ts +32 -0
- package/recce-source/js/jest.setup.js +91 -0
- package/recce-source/js/next.config.js +16 -0
- package/recce-source/js/package-lock.json +13843 -0
- package/recce-source/js/package.json +123 -0
- package/recce-source/js/pnpm-lock.yaml +9235 -0
- package/recce-source/js/pnpm-workspace.yaml +6 -0
- package/recce-source/js/postcss.config.js +5 -0
- package/recce-source/js/public/auth_callback.html +68 -0
- package/recce-source/js/public/imgs/feedback/thumbs-down.png +0 -0
- package/recce-source/js/public/imgs/feedback/thumbs-up.png +0 -0
- package/recce-source/js/public/imgs/reload-image.svg +4 -0
- package/recce-source/js/public/logo/recce-logo-white.png +0 -0
- package/recce-source/js/src/components/AuthModal/AuthModal.tsx +202 -0
- package/recce-source/js/src/components/app/AvatarDropdown.tsx +159 -0
- package/recce-source/js/src/components/app/EnvInfo.tsx +357 -0
- package/recce-source/js/src/components/app/Filename.tsx +388 -0
- package/recce-source/js/src/components/app/SetupConnectionPopover.tsx +91 -0
- package/recce-source/js/src/components/app/StateExporter.tsx +57 -0
- package/recce-source/js/src/components/app/StateImporter.tsx +198 -0
- package/recce-source/js/src/components/app/StateSharing.tsx +145 -0
- package/recce-source/js/src/components/app/StateSynchronizer.tsx +205 -0
- package/recce-source/js/src/components/charts/HistogramChart.tsx +291 -0
- package/recce-source/js/src/components/charts/SquareIcon.tsx +51 -0
- package/recce-source/js/src/components/charts/TopKSummaryList.tsx +457 -0
- package/recce-source/js/src/components/charts/chartTheme.ts +74 -0
- package/recce-source/js/src/components/check/CheckBreadcrumb.tsx +97 -0
- package/recce-source/js/src/components/check/CheckDescription.tsx +134 -0
- package/recce-source/js/src/components/check/CheckDetail.tsx +797 -0
- package/recce-source/js/src/components/check/CheckEmptyState.tsx +84 -0
- package/recce-source/js/src/components/check/CheckList.tsx +320 -0
- package/recce-source/js/src/components/check/LineageDiffView.tsx +32 -0
- package/recce-source/js/src/components/check/PresetCheckTemplateView.tsx +48 -0
- package/recce-source/js/src/components/check/SchemaDiffView.tsx +290 -0
- package/recce-source/js/src/components/check/check.ts +25 -0
- package/recce-source/js/src/components/check/timeline/CheckTimeline.tsx +163 -0
- package/recce-source/js/src/components/check/timeline/CommentInput.tsx +84 -0
- package/recce-source/js/src/components/check/timeline/TimelineEvent.tsx +468 -0
- package/recce-source/js/src/components/check/timeline/index.ts +12 -0
- package/recce-source/js/src/components/check/utils.ts +12 -0
- package/recce-source/js/src/components/data-grid/ScreenshotDataGrid.tsx +333 -0
- package/recce-source/js/src/components/data-grid/agGridStyles.css +55 -0
- package/recce-source/js/src/components/data-grid/agGridTheme.ts +43 -0
- package/recce-source/js/src/components/editor/CodeEditor.tsx +107 -0
- package/recce-source/js/src/components/editor/DiffEditor.tsx +162 -0
- package/recce-source/js/src/components/editor/index.ts +12 -0
- package/recce-source/js/src/components/errorboundary/ErrorBoundary.tsx +87 -0
- package/recce-source/js/src/components/histogram/HistogramDiffForm.tsx +147 -0
- package/recce-source/js/src/components/histogram/HistogramDiffResultView.tsx +63 -0
- package/recce-source/js/src/components/icons/index.tsx +142 -0
- package/recce-source/js/src/components/lineage/ActionControl.tsx +63 -0
- package/recce-source/js/src/components/lineage/ActionTag.tsx +141 -0
- package/recce-source/js/src/components/lineage/ChangeStatusLegend.tsx +46 -0
- package/recce-source/js/src/components/lineage/ColumnLevelLineageControl.tsx +327 -0
- package/recce-source/js/src/components/lineage/ColumnLevelLineageLegend.tsx +57 -0
- package/recce-source/js/src/components/lineage/GraphColumnNode.tsx +199 -0
- package/recce-source/js/src/components/lineage/GraphEdge.tsx +59 -0
- package/recce-source/js/src/components/lineage/GraphNode.tsx +555 -0
- package/recce-source/js/src/components/lineage/LineagePage.tsx +10 -0
- package/recce-source/js/src/components/lineage/LineageView.tsx +1384 -0
- package/recce-source/js/src/components/lineage/LineageViewContext.tsx +86 -0
- package/recce-source/js/src/components/lineage/LineageViewContextMenu.tsx +637 -0
- package/recce-source/js/src/components/lineage/LineageViewNotification.tsx +64 -0
- package/recce-source/js/src/components/lineage/LineageViewTopBar.tsx +596 -0
- package/recce-source/js/src/components/lineage/NodeSqlView.tsx +136 -0
- package/recce-source/js/src/components/lineage/NodeTag.tsx +278 -0
- package/recce-source/js/src/components/lineage/NodeView.tsx +642 -0
- package/recce-source/js/src/components/lineage/SandboxView.tsx +436 -0
- package/recce-source/js/src/components/lineage/ServerDisconnectedModalContent.tsx +105 -0
- package/recce-source/js/src/components/lineage/SetupConnectionBanner.tsx +52 -0
- package/recce-source/js/src/components/lineage/SingleEnvironmentQueryView.tsx +152 -0
- package/recce-source/js/src/components/lineage/graph.test.ts +31 -0
- package/recce-source/js/src/components/lineage/graph.ts +58 -0
- package/recce-source/js/src/components/lineage/lineage.test.ts +169 -0
- package/recce-source/js/src/components/lineage/lineage.ts +521 -0
- package/recce-source/js/src/components/lineage/styles.css +42 -0
- package/recce-source/js/src/components/lineage/styles.tsx +165 -0
- package/recce-source/js/src/components/lineage/useMultiNodesAction.ts +352 -0
- package/recce-source/js/src/components/lineage/useValueDiffAlertDialog.tsx +108 -0
- package/recce-source/js/src/components/onboarding-guide/Notification.tsx +62 -0
- package/recce-source/js/src/components/profile/ProfileDiffForm.tsx +134 -0
- package/recce-source/js/src/components/profile/ProfileDiffResultView.tsx +245 -0
- package/recce-source/js/src/components/query/ChangedOnlyCheckbox.tsx +29 -0
- package/recce-source/js/src/components/query/DiffText.tsx +120 -0
- package/recce-source/js/src/components/query/QueryDiffResultView.tsx +470 -0
- package/recce-source/js/src/components/query/QueryForm.tsx +80 -0
- package/recce-source/js/src/components/query/QueryPage.tsx +282 -0
- package/recce-source/js/src/components/query/QueryResultView.tsx +180 -0
- package/recce-source/js/src/components/query/SetupConnectionGuide.tsx +57 -0
- package/recce-source/js/src/components/query/SqlEditor.tsx +245 -0
- package/recce-source/js/src/components/query/ToggleSwitch.tsx +84 -0
- package/recce-source/js/src/components/query/styles.css +21 -0
- package/recce-source/js/src/components/routing/DirectUrlAccess.test.tsx +428 -0
- package/recce-source/js/src/components/routing/LineageStatePreservation.test.tsx +311 -0
- package/recce-source/js/src/components/routing/Navigation.test.tsx +256 -0
- package/recce-source/js/src/components/rowcount/RowCountDiffResultView.tsx +109 -0
- package/recce-source/js/src/components/rowcount/delta.ts +11 -0
- package/recce-source/js/src/components/run/RunList.tsx +303 -0
- package/recce-source/js/src/components/run/RunModal.tsx +191 -0
- package/recce-source/js/src/components/run/RunPage.tsx +26 -0
- package/recce-source/js/src/components/run/RunResultPane.tsx +454 -0
- package/recce-source/js/src/components/run/RunStatusAndDate.tsx +106 -0
- package/recce-source/js/src/components/run/RunToolbar.tsx +70 -0
- package/recce-source/js/src/components/run/RunView.tsx +196 -0
- package/recce-source/js/src/components/run/registry.ts +214 -0
- package/recce-source/js/src/components/run/types.ts +14 -0
- package/recce-source/js/src/components/schema/ColumnNameCell.test.tsx +169 -0
- package/recce-source/js/src/components/schema/ColumnNameCell.tsx +198 -0
- package/recce-source/js/src/components/schema/SchemaView.tsx +337 -0
- package/recce-source/js/src/components/schema/schemaDiff.ts +32 -0
- package/recce-source/js/src/components/schema/style.css +134 -0
- package/recce-source/js/src/components/screenshot/ScreenshotBox.tsx +39 -0
- package/recce-source/js/src/components/shared/HistoryToggle.tsx +35 -0
- package/recce-source/js/src/components/split/Split.tsx +40 -0
- package/recce-source/js/src/components/split/styles.css +24 -0
- package/recce-source/js/src/components/summary/ChangeSummary.tsx +264 -0
- package/recce-source/js/src/components/summary/SchemaSummary.tsx +123 -0
- package/recce-source/js/src/components/summary/SummaryView.tsx +29 -0
- package/recce-source/js/src/components/timeout/IdleTimeoutBadge.tsx +48 -0
- package/recce-source/js/src/components/top-k/TopKDiffForm.tsx +58 -0
- package/recce-source/js/src/components/top-k/TopKDiffResultView.tsx +73 -0
- package/recce-source/js/src/components/ui/dataGrid/DataFrameColumnGroupHeader.tsx +228 -0
- package/recce-source/js/src/components/ui/dataGrid/DataFrameColumnHeader.tsx +113 -0
- package/recce-source/js/src/components/ui/dataGrid/defaultRenderCell.tsx +72 -0
- package/recce-source/js/src/components/ui/dataGrid/index.ts +23 -0
- package/recce-source/js/src/components/ui/dataGrid/inlineRenderCell.test.tsx +607 -0
- package/recce-source/js/src/components/ui/dataGrid/inlineRenderCell.tsx +211 -0
- package/recce-source/js/src/components/ui/dataGrid/schemaCells.test.tsx +452 -0
- package/recce-source/js/src/components/ui/dataGrid/schemaCells.tsx +142 -0
- package/recce-source/js/src/components/ui/dataGrid/valueDiffCells.test.tsx +178 -0
- package/recce-source/js/src/components/ui/dataGrid/valueDiffCells.tsx +275 -0
- package/recce-source/js/src/components/ui/markdown/ExternalLinkConfirmDialog.tsx +134 -0
- package/recce-source/js/src/components/ui/markdown/MarkdownContent.tsx +364 -0
- package/recce-source/js/src/components/ui/mui/index.ts +13 -0
- package/recce-source/js/src/components/ui/mui-provider.tsx +67 -0
- package/recce-source/js/src/components/ui/mui-theme.ts +1039 -0
- package/recce-source/js/src/components/ui/mui-utils.ts +113 -0
- package/recce-source/js/src/components/ui/toaster.tsx +288 -0
- package/recce-source/js/src/components/valuediff/ValueDiffDetailResultView.tsx +217 -0
- package/recce-source/js/src/components/valuediff/ValueDiffForm.tsx +246 -0
- package/recce-source/js/src/components/valuediff/ValueDiffResultView.tsx +82 -0
- package/recce-source/js/src/components/valuediff/shared.ts +33 -0
- package/recce-source/js/src/constants/tooltipMessage.ts +3 -0
- package/recce-source/js/src/constants/urls.ts +1 -0
- package/recce-source/js/src/lib/UrlHash.ts +12 -0
- package/recce-source/js/src/lib/api/adhocQuery.ts +70 -0
- package/recce-source/js/src/lib/api/axiosClient.ts +9 -0
- package/recce-source/js/src/lib/api/cacheKeys.ts +13 -0
- package/recce-source/js/src/lib/api/checkEvents.ts +252 -0
- package/recce-source/js/src/lib/api/checks.ts +129 -0
- package/recce-source/js/src/lib/api/cll.ts +53 -0
- package/recce-source/js/src/lib/api/connectToCloud.ts +13 -0
- package/recce-source/js/src/lib/api/flag.ts +37 -0
- package/recce-source/js/src/lib/api/info.ts +198 -0
- package/recce-source/js/src/lib/api/instanceInfo.ts +25 -0
- package/recce-source/js/src/lib/api/keepAlive.ts +108 -0
- package/recce-source/js/src/lib/api/lineagecheck.ts +35 -0
- package/recce-source/js/src/lib/api/localStorageKeys.ts +7 -0
- package/recce-source/js/src/lib/api/models.ts +59 -0
- package/recce-source/js/src/lib/api/profile.ts +65 -0
- package/recce-source/js/src/lib/api/rowcount.ts +19 -0
- package/recce-source/js/src/lib/api/runs.ts +174 -0
- package/recce-source/js/src/lib/api/schemacheck.ts +31 -0
- package/recce-source/js/src/lib/api/select.ts +25 -0
- package/recce-source/js/src/lib/api/sessionStorageKeys.ts +8 -0
- package/recce-source/js/src/lib/api/state.ts +117 -0
- package/recce-source/js/src/lib/api/track.ts +281 -0
- package/recce-source/js/src/lib/api/types.ts +284 -0
- package/recce-source/js/src/lib/api/user.ts +42 -0
- package/recce-source/js/src/lib/api/valuediff.ts +46 -0
- package/recce-source/js/src/lib/api/version.ts +40 -0
- package/recce-source/js/src/lib/const.ts +9 -0
- package/recce-source/js/src/lib/dataGrid/crossFunctionConsistency.test.ts +626 -0
- package/recce-source/js/src/lib/dataGrid/dataGridFactory.test.ts +2140 -0
- package/recce-source/js/src/lib/dataGrid/dataGridFactory.ts +397 -0
- package/recce-source/js/src/lib/dataGrid/generators/rowCountUtils.test.ts +132 -0
- package/recce-source/js/src/lib/dataGrid/generators/rowCountUtils.ts +126 -0
- package/recce-source/js/src/lib/dataGrid/generators/toDataDiffGrid.test.ts +1627 -0
- package/recce-source/js/src/lib/dataGrid/generators/toDataDiffGrid.ts +140 -0
- package/recce-source/js/src/lib/dataGrid/generators/toDataGrid.ts +67 -0
- package/recce-source/js/src/lib/dataGrid/generators/toRowCountDataGrid.test.ts +142 -0
- package/recce-source/js/src/lib/dataGrid/generators/toRowCountDataGrid.ts +71 -0
- package/recce-source/js/src/lib/dataGrid/generators/toRowCountDiffDataGrid.test.ts +258 -0
- package/recce-source/js/src/lib/dataGrid/generators/toRowCountDiffDataGrid.ts +153 -0
- package/recce-source/js/src/lib/dataGrid/generators/toSchemaDataGrid.test.ts +951 -0
- package/recce-source/js/src/lib/dataGrid/generators/toSchemaDataGrid.ts +221 -0
- package/recce-source/js/src/lib/dataGrid/generators/toValueDataGrid.test.ts +395 -0
- package/recce-source/js/src/lib/dataGrid/generators/toValueDataGrid.ts +184 -0
- package/recce-source/js/src/lib/dataGrid/generators/toValueDiffGrid.test.ts +884 -0
- package/recce-source/js/src/lib/dataGrid/generators/toValueDiffGrid.ts +113 -0
- package/recce-source/js/src/lib/dataGrid/index.ts +51 -0
- package/recce-source/js/src/lib/dataGrid/propertyBased.test.ts +858 -0
- package/recce-source/js/src/lib/dataGrid/shared/columnBuilders.test.ts +482 -0
- package/recce-source/js/src/lib/dataGrid/shared/columnBuilders.ts +345 -0
- package/recce-source/js/src/lib/dataGrid/shared/dataTypeEdgeCases.test.ts +698 -0
- package/recce-source/js/src/lib/dataGrid/shared/diffColumnBuilder.test.tsx +820 -0
- package/recce-source/js/src/lib/dataGrid/shared/diffColumnBuilder.tsx +277 -0
- package/recce-source/js/src/lib/dataGrid/shared/gridUtils.test.ts +785 -0
- package/recce-source/js/src/lib/dataGrid/shared/gridUtils.ts +370 -0
- package/recce-source/js/src/lib/dataGrid/shared/index.ts +81 -0
- package/recce-source/js/src/lib/dataGrid/shared/rowBuilders.test.ts +909 -0
- package/recce-source/js/src/lib/dataGrid/shared/rowBuilders.ts +325 -0
- package/recce-source/js/src/lib/dataGrid/shared/simpleColumnBuilder.tsx +240 -0
- package/recce-source/js/src/lib/dataGrid/shared/toDiffColumn.test.tsx +719 -0
- package/recce-source/js/src/lib/dataGrid/shared/toDiffColumn.tsx +231 -0
- package/recce-source/js/src/lib/dataGrid/shared/validation.test.ts +559 -0
- package/recce-source/js/src/lib/dataGrid/shared/validation.ts +367 -0
- package/recce-source/js/src/lib/dataGrid/warehouseNamingConventions.test.ts +1117 -0
- package/recce-source/js/src/lib/formatSelect.ts +50 -0
- package/recce-source/js/src/lib/hooks/ApiConfigContext.tsx +181 -0
- package/recce-source/js/src/lib/hooks/IdleTimeoutContext.tsx +177 -0
- package/recce-source/js/src/lib/hooks/LineageGraphContext.tsx +512 -0
- package/recce-source/js/src/lib/hooks/RecceActionContext.tsx +269 -0
- package/recce-source/js/src/lib/hooks/RecceCheckContext.tsx +33 -0
- package/recce-source/js/src/lib/hooks/RecceContextProvider.tsx +54 -0
- package/recce-source/js/src/lib/hooks/RecceInstanceContext.tsx +129 -0
- package/recce-source/js/src/lib/hooks/RecceQueryContext.tsx +98 -0
- package/recce-source/js/src/lib/hooks/RecceShareStateContext.tsx +59 -0
- package/recce-source/js/src/lib/hooks/ScreenShot.tsx +399 -0
- package/recce-source/js/src/lib/hooks/useAppRouter.test.ts +211 -0
- package/recce-source/js/src/lib/hooks/useAppRouter.ts +200 -0
- package/recce-source/js/src/lib/hooks/useCheckEvents.ts +99 -0
- package/recce-source/js/src/lib/hooks/useCheckToast.tsx +14 -0
- package/recce-source/js/src/lib/hooks/useClipBoardToast.tsx +27 -0
- package/recce-source/js/src/lib/hooks/useCountdownToast.tsx +102 -0
- package/recce-source/js/src/lib/hooks/useFeedbackCollectionToast.tsx +130 -0
- package/recce-source/js/src/lib/hooks/useGuideToast.tsx +45 -0
- package/recce-source/js/src/lib/hooks/useIdleDetection.tsx +185 -0
- package/recce-source/js/src/lib/hooks/useModelColumns.tsx +113 -0
- package/recce-source/js/src/lib/hooks/useRecceInstanceInfo.tsx +13 -0
- package/recce-source/js/src/lib/hooks/useRecceServerFlag.tsx +13 -0
- package/recce-source/js/src/lib/hooks/useRun.tsx +89 -0
- package/recce-source/js/src/lib/hooks/useThemeColors.ts +115 -0
- package/recce-source/js/src/lib/mergeKeys.test.ts +89 -0
- package/recce-source/js/src/lib/mergeKeys.ts +86 -0
- package/recce-source/js/src/lib/result/ResultErrorFallback.tsx +9 -0
- package/recce-source/js/src/lib/utils/formatTime.ts +84 -0
- package/recce-source/js/src/lib/utils/urls.ts +16 -0
- package/recce-source/js/src/utils/DropdownValuesInput.tsx +297 -0
- package/recce-source/js/src/utils/formatters.tsx +237 -0
- package/recce-source/js/src/utils/transforms.ts +81 -0
- package/recce-source/js/tsconfig.json +47 -0
- package/recce-source/macros/README.md +8 -0
- package/recce-source/macros/recce_athena.sql +73 -0
- package/recce-source/pyproject.toml +109 -0
- package/recce-source/recce/VERSION +1 -0
- package/recce-source/recce/__init__.py +84 -0
- package/recce-source/recce/adapter/__init__.py +0 -0
- package/recce-source/recce/adapter/base.py +109 -0
- package/recce-source/recce/adapter/dbt_adapter/__init__.py +1699 -0
- package/recce-source/recce/adapter/dbt_adapter/dbt_version.py +42 -0
- package/recce-source/recce/adapter/sqlmesh_adapter.py +141 -0
- package/recce-source/recce/apis/__init__.py +0 -0
- package/recce-source/recce/apis/check_api.py +203 -0
- package/recce-source/recce/apis/check_events_api.py +353 -0
- package/recce-source/recce/apis/check_func.py +130 -0
- package/recce-source/recce/apis/run_api.py +130 -0
- package/recce-source/recce/apis/run_func.py +258 -0
- package/recce-source/recce/artifact.py +266 -0
- package/recce-source/recce/cli.py +1846 -0
- package/recce-source/recce/config.py +127 -0
- package/recce-source/recce/connect_to_cloud.py +138 -0
- package/recce-source/recce/core.py +334 -0
- package/recce-source/recce/diff.py +26 -0
- package/recce-source/recce/event/CONFIG +1 -0
- package/recce-source/recce/event/SENTRY_DNS +1 -0
- package/recce-source/recce/event/__init__.py +304 -0
- package/recce-source/recce/event/collector.py +184 -0
- package/recce-source/recce/event/track.py +158 -0
- package/recce-source/recce/exceptions.py +21 -0
- package/recce-source/recce/git.py +77 -0
- package/recce-source/recce/github.py +222 -0
- package/recce-source/recce/mcp_server.py +861 -0
- package/recce-source/recce/models/__init__.py +6 -0
- package/recce-source/recce/models/check.py +473 -0
- package/recce-source/recce/models/run.py +46 -0
- package/recce-source/recce/models/types.py +218 -0
- package/recce-source/recce/pull_request.py +124 -0
- package/recce-source/recce/run.py +390 -0
- package/recce-source/recce/server.py +877 -0
- package/recce-source/recce/state/__init__.py +31 -0
- package/recce-source/recce/state/cloud.py +644 -0
- package/recce-source/recce/state/const.py +26 -0
- package/recce-source/recce/state/local.py +56 -0
- package/recce-source/recce/state/state.py +119 -0
- package/recce-source/recce/state/state_loader.py +174 -0
- package/recce-source/recce/summary.py +575 -0
- package/recce-source/recce/tasks/__init__.py +23 -0
- package/recce-source/recce/tasks/core.py +134 -0
- package/recce-source/recce/tasks/dataframe.py +170 -0
- package/recce-source/recce/tasks/histogram.py +433 -0
- package/recce-source/recce/tasks/lineage.py +19 -0
- package/recce-source/recce/tasks/profile.py +298 -0
- package/recce-source/recce/tasks/query.py +450 -0
- package/recce-source/recce/tasks/rowcount.py +277 -0
- package/recce-source/recce/tasks/schema.py +65 -0
- package/recce-source/recce/tasks/top_k.py +172 -0
- package/recce-source/recce/tasks/utils.py +147 -0
- package/recce-source/recce/tasks/valuediff.py +497 -0
- package/recce-source/recce/util/__init__.py +4 -0
- package/recce-source/recce/util/api_token.py +80 -0
- package/recce-source/recce/util/breaking.py +330 -0
- package/recce-source/recce/util/cache.py +25 -0
- package/recce-source/recce/util/cll.py +355 -0
- package/recce-source/recce/util/cloud/__init__.py +15 -0
- package/recce-source/recce/util/cloud/base.py +115 -0
- package/recce-source/recce/util/cloud/check_events.py +190 -0
- package/recce-source/recce/util/cloud/checks.py +242 -0
- package/recce-source/recce/util/io.py +120 -0
- package/recce-source/recce/util/lineage.py +83 -0
- package/recce-source/recce/util/logger.py +25 -0
- package/recce-source/recce/util/onboarding_state.py +45 -0
- package/recce-source/recce/util/perf_tracking.py +85 -0
- package/recce-source/recce/util/pydantic_model.py +22 -0
- package/recce-source/recce/util/recce_cloud.py +454 -0
- package/recce-source/recce/util/singleton.py +18 -0
- package/recce-source/recce/util/startup_perf.py +121 -0
- package/recce-source/recce/yaml/__init__.py +58 -0
- package/recce-source/recce_cloud/README.md +780 -0
- package/recce-source/recce_cloud/VERSION +1 -0
- package/recce-source/recce_cloud/__init__.py +24 -0
- package/recce-source/recce_cloud/api/__init__.py +17 -0
- package/recce-source/recce_cloud/api/base.py +132 -0
- package/recce-source/recce_cloud/api/client.py +186 -0
- package/recce-source/recce_cloud/api/exceptions.py +26 -0
- package/recce-source/recce_cloud/api/factory.py +63 -0
- package/recce-source/recce_cloud/api/github.py +106 -0
- package/recce-source/recce_cloud/api/gitlab.py +111 -0
- package/recce-source/recce_cloud/artifact.py +57 -0
- package/recce-source/recce_cloud/ci_providers/__init__.py +9 -0
- package/recce-source/recce_cloud/ci_providers/base.py +82 -0
- package/recce-source/recce_cloud/ci_providers/detector.py +147 -0
- package/recce-source/recce_cloud/ci_providers/github_actions.py +136 -0
- package/recce-source/recce_cloud/ci_providers/gitlab_ci.py +130 -0
- package/recce-source/recce_cloud/cli.py +434 -0
- package/recce-source/recce_cloud/download.py +230 -0
- package/recce-source/recce_cloud/hatch_build.py +20 -0
- package/recce-source/recce_cloud/pyproject.toml +49 -0
- package/recce-source/recce_cloud/upload.py +214 -0
- package/recce-source/test.py +0 -0
- package/recce-source/tests/__init__.py +0 -0
- package/recce-source/tests/adapter/__init__.py +0 -0
- package/recce-source/tests/adapter/dbt_adapter/__init__.py +0 -0
- package/recce-source/tests/adapter/dbt_adapter/conftest.py +17 -0
- package/recce-source/tests/adapter/dbt_adapter/dbt_test_helper.py +298 -0
- package/recce-source/tests/adapter/dbt_adapter/test_dbt_adapter.py +25 -0
- package/recce-source/tests/adapter/dbt_adapter/test_dbt_cll.py +717 -0
- package/recce-source/tests/adapter/dbt_adapter/test_proj/dbt_project.yml +4 -0
- package/recce-source/tests/adapter/dbt_adapter/test_proj/manifest.json +1 -0
- package/recce-source/tests/adapter/dbt_adapter/test_proj/package-lock.yml +8 -0
- package/recce-source/tests/adapter/dbt_adapter/test_proj/packages.yml +7 -0
- package/recce-source/tests/adapter/dbt_adapter/test_proj/profiles.yml +6 -0
- package/recce-source/tests/adapter/dbt_adapter/test_selector.py +205 -0
- package/recce-source/tests/apis/__init__.py +0 -0
- package/recce-source/tests/apis/row_count_diff.json +59 -0
- package/recce-source/tests/apis/test_check_events_api.py +615 -0
- package/recce-source/tests/apis/test_run_func.py +433 -0
- package/recce-source/tests/catalog.json +527 -0
- package/recce-source/tests/data/manifest/base/catalog.json +1 -0
- package/recce-source/tests/data/manifest/base/manifest.json +1 -0
- package/recce-source/tests/data/manifest/pr2/catalog.json +1 -0
- package/recce-source/tests/data/manifest/pr2/manifest.json +1 -0
- package/recce-source/tests/manifest.json +10655 -0
- package/recce-source/tests/models/__init__.py +0 -0
- package/recce-source/tests/models/test_check.py +731 -0
- package/recce-source/tests/models/test_run_models.py +295 -0
- package/recce-source/tests/recce_cloud/__init__.py +0 -0
- package/recce-source/tests/recce_cloud/test_ci_providers.py +351 -0
- package/recce-source/tests/recce_cloud/test_cli.py +735 -0
- package/recce-source/tests/recce_cloud/test_client.py +379 -0
- package/recce-source/tests/recce_cloud/test_platform_clients.py +483 -0
- package/recce-source/tests/recce_state.json +1 -0
- package/recce-source/tests/state/test_cloud.py +719 -0
- package/recce-source/tests/state/test_local.py +164 -0
- package/recce-source/tests/state/test_state_loader.py +211 -0
- package/recce-source/tests/tasks/__init__.py +0 -0
- package/recce-source/tests/tasks/conftest.py +4 -0
- package/recce-source/tests/tasks/test_histogram.py +129 -0
- package/recce-source/tests/tasks/test_lineage.py +55 -0
- package/recce-source/tests/tasks/test_preset_checks.py +64 -0
- package/recce-source/tests/tasks/test_profile.py +397 -0
- package/recce-source/tests/tasks/test_query.py +528 -0
- package/recce-source/tests/tasks/test_row_count.py +133 -0
- package/recce-source/tests/tasks/test_schema.py +122 -0
- package/recce-source/tests/tasks/test_top_k.py +77 -0
- package/recce-source/tests/tasks/test_utils.py +439 -0
- package/recce-source/tests/tasks/test_valuediff.py +361 -0
- package/recce-source/tests/test_cli.py +236 -0
- package/recce-source/tests/test_cli_mcp_optional.py +45 -0
- package/recce-source/tests/test_cloud_listing_cli.py +324 -0
- package/recce-source/tests/test_config.py +43 -0
- package/recce-source/tests/test_connect_to_cloud.py +82 -0
- package/recce-source/tests/test_core.py +174 -0
- package/recce-source/tests/test_dbt.py +36 -0
- package/recce-source/tests/test_mcp_server.py +505 -0
- package/recce-source/tests/test_pull_request.py +130 -0
- package/recce-source/tests/test_server.py +202 -0
- package/recce-source/tests/test_server_lifespan.py +138 -0
- package/recce-source/tests/test_summary.py +73 -0
- package/recce-source/tests/util/__init__.py +0 -0
- package/recce-source/tests/util/cloud/__init__.py +0 -0
- package/recce-source/tests/util/cloud/test_check_events.py +255 -0
- package/recce-source/tests/util/cloud/test_checks.py +204 -0
- package/recce-source/tests/util/test_api_token.py +119 -0
- package/recce-source/tests/util/test_breaking.py +1427 -0
- package/recce-source/tests/util/test_cll.py +706 -0
- package/recce-source/tests/util/test_lineage.py +122 -0
- package/recce-source/tests/util/test_onboarding_state.py +84 -0
- package/recce-source/tests/util/test_recce_cloud.py +231 -0
- package/recce-source/tox.ini +40 -0
- package/recce-source/uv.lock +3928 -0
- package/src/api/index.ts +32 -0
- package/src/components/index.ts +154 -0
- package/src/global.d.ts +14 -0
- package/src/hooks/index.ts +56 -0
- package/src/index.ts +17 -0
- package/src/lib/hooks/RouteConfigContext.ts +139 -0
- package/src/lib/hooks/useAppRouter.ts +240 -0
- package/src/mui-augmentation.d.ts +139 -0
- package/src/theme/index.ts +13 -0
- package/src/theme.ts +23 -0
- package/src/types/index.ts +23 -0
- package/dist/index-Bv5R8iLo.d.mts.map +0 -1
- package/dist/index-CUtFlKOo.d.ts.map +0 -1
- package/dist/state-CELzQ0tM.mjs.map +0 -1
- package/dist/state-CemiRRon.js.map +0 -1
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file ScreenshotDataGrid.tsx
|
|
3
|
+
* @description AG Grid wrapper component for Recce data grids
|
|
4
|
+
*
|
|
5
|
+
* This component wraps the AG Grid and provides a consistent interface
|
|
6
|
+
* for all data grid views in the application. It handles:
|
|
7
|
+
* - Theme switching (light/dark)
|
|
8
|
+
* - PII tracking safety classes
|
|
9
|
+
* - Default grid configurations
|
|
10
|
+
* - Backward compatibility with existing column/row data formats
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
"use client";
|
|
14
|
+
|
|
15
|
+
import Box from "@mui/material/Box";
|
|
16
|
+
import { useTheme } from "@mui/material/styles";
|
|
17
|
+
import Typography from "@mui/material/Typography";
|
|
18
|
+
import type {
|
|
19
|
+
ColDef,
|
|
20
|
+
ColGroupDef,
|
|
21
|
+
GetRowIdParams,
|
|
22
|
+
GridReadyEvent,
|
|
23
|
+
} from "ag-grid-community";
|
|
24
|
+
import { AllCommunityModule, ModuleRegistry } from "ag-grid-community";
|
|
25
|
+
import { AgGridReact, type AgGridReactProps } from "ag-grid-react";
|
|
26
|
+
import "./agGridStyles.css";
|
|
27
|
+
import React, {
|
|
28
|
+
type CSSProperties,
|
|
29
|
+
forwardRef,
|
|
30
|
+
type Ref,
|
|
31
|
+
useImperativeHandle,
|
|
32
|
+
useMemo,
|
|
33
|
+
useRef,
|
|
34
|
+
} from "react";
|
|
35
|
+
import { RowObjectType } from "@/lib/api/types";
|
|
36
|
+
import { recceGridThemeDark, recceGridThemeLight } from "./agGridTheme";
|
|
37
|
+
|
|
38
|
+
// Register AG Grid modules once
|
|
39
|
+
ModuleRegistry.registerModules([AllCommunityModule]);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Handle type for accessing AG Grid API and DOM element (for screenshots)
|
|
43
|
+
*/
|
|
44
|
+
export interface DataGridHandle {
|
|
45
|
+
api: GridReadyEvent["api"] | null;
|
|
46
|
+
/** DOM element for screenshot functionality */
|
|
47
|
+
element: HTMLElement | null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Props for ScreenshotDataGrid component
|
|
52
|
+
*
|
|
53
|
+
* Supports both new AG Grid style props (columnDefs/rowData) and
|
|
54
|
+
* legacy react-data-grid style props (columns/rows) for backward compatibility
|
|
55
|
+
*/
|
|
56
|
+
export interface ScreenshotDataGridProps<TData = RowObjectType>
|
|
57
|
+
extends Omit<AgGridReactProps<TData>, "theme" | "rowClass"> {
|
|
58
|
+
/** Container style */
|
|
59
|
+
style?: CSSProperties;
|
|
60
|
+
/** Additional CSS class for container */
|
|
61
|
+
className?: string;
|
|
62
|
+
/** Empty state renderer (legacy) */
|
|
63
|
+
renderers?: {
|
|
64
|
+
noRowsFallback?: React.ReactNode;
|
|
65
|
+
};
|
|
66
|
+
/** Legacy: Column definitions (maps to columnDefs) */
|
|
67
|
+
columns?: (ColDef<TData> | ColGroupDef<TData>)[];
|
|
68
|
+
/** Legacy: Row data (maps to rowData) */
|
|
69
|
+
rows?: TData[];
|
|
70
|
+
/** Legacy: Default column options (maps to defaultColDef) */
|
|
71
|
+
defaultColumnOptions?: ColDef<TData>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Empty rows renderer component
|
|
76
|
+
*/
|
|
77
|
+
interface EmptyRowsRendererProps {
|
|
78
|
+
emptyMessage?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function EmptyRowsRenderer({ emptyMessage }: EmptyRowsRendererProps) {
|
|
82
|
+
return (
|
|
83
|
+
<Box
|
|
84
|
+
sx={{
|
|
85
|
+
display: "flex",
|
|
86
|
+
height: "35px",
|
|
87
|
+
alignItems: "center",
|
|
88
|
+
justifyContent: "center",
|
|
89
|
+
bgcolor: "grey.100",
|
|
90
|
+
textAlign: "center",
|
|
91
|
+
gridColumn: "1/-1",
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
<Typography sx={{ fontWeight: 600 }}>
|
|
95
|
+
{emptyMessage ?? "No rows"}
|
|
96
|
+
</Typography>
|
|
97
|
+
</Box>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* AG Grid wrapper component for Recce (Screenshot-capable)
|
|
103
|
+
*
|
|
104
|
+
* @description Provides a themed AG Grid with default configurations:
|
|
105
|
+
* - Automatic light/dark theme switching
|
|
106
|
+
* - Row hover highlighting disabled by default
|
|
107
|
+
* - Cell focus suppressed for cleaner UX
|
|
108
|
+
* - PII-safe tracking class applied to all rows
|
|
109
|
+
*
|
|
110
|
+
* Backward compatible with react-data-grid API:
|
|
111
|
+
* - `columns` prop maps to `columnDefs`
|
|
112
|
+
* - `rows` prop maps to `rowData`
|
|
113
|
+
* - `defaultColumnOptions` maps to `defaultColDef`
|
|
114
|
+
* - `renderers.noRowsFallback` maps to `noRowsOverlayComponent`
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```tsx
|
|
118
|
+
* // New AG Grid style
|
|
119
|
+
* <ScreenshotDataGrid
|
|
120
|
+
* columnDefs={columns}
|
|
121
|
+
* rowData={rows}
|
|
122
|
+
* style={{ height: '400px' }}
|
|
123
|
+
* />
|
|
124
|
+
*
|
|
125
|
+
* // Legacy react-data-grid style
|
|
126
|
+
* <ScreenshotDataGrid
|
|
127
|
+
* columns={columns}
|
|
128
|
+
* rows={rows}
|
|
129
|
+
* renderers={{ noRowsFallback: <EmptyRowsRenderer /> }}
|
|
130
|
+
* />
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
function _ScreenshotDataGrid<TData = RowObjectType>(
|
|
134
|
+
{
|
|
135
|
+
style,
|
|
136
|
+
className,
|
|
137
|
+
columnDefs,
|
|
138
|
+
rowData,
|
|
139
|
+
columns,
|
|
140
|
+
rows,
|
|
141
|
+
getRowId,
|
|
142
|
+
rowHeight = 32,
|
|
143
|
+
headerHeight = 36,
|
|
144
|
+
defaultColDef,
|
|
145
|
+
defaultColumnOptions,
|
|
146
|
+
renderers,
|
|
147
|
+
...props
|
|
148
|
+
}: ScreenshotDataGridProps<TData>,
|
|
149
|
+
ref: Ref<DataGridHandle>,
|
|
150
|
+
) {
|
|
151
|
+
// Container ref for screenshot functionality
|
|
152
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
153
|
+
// AG Grid API ref
|
|
154
|
+
const gridApiRef = useRef<GridReadyEvent["api"] | null>(null);
|
|
155
|
+
|
|
156
|
+
// Expose both API and DOM element through ref
|
|
157
|
+
useImperativeHandle(
|
|
158
|
+
ref,
|
|
159
|
+
() => ({
|
|
160
|
+
api: gridApiRef.current,
|
|
161
|
+
element: containerRef.current,
|
|
162
|
+
}),
|
|
163
|
+
[],
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
// Get MUI theme to determine dark/light mode
|
|
167
|
+
const muiTheme = useTheme();
|
|
168
|
+
|
|
169
|
+
// Select AG Grid theme based on MUI theme mode
|
|
170
|
+
const gridTheme = useMemo(
|
|
171
|
+
() =>
|
|
172
|
+
muiTheme.palette.mode === "dark"
|
|
173
|
+
? recceGridThemeDark
|
|
174
|
+
: recceGridThemeLight,
|
|
175
|
+
[muiTheme.palette.mode],
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
// Support both new and legacy props
|
|
179
|
+
const resolvedColumnDefs = columnDefs ?? columns;
|
|
180
|
+
const resolvedRowData = rowData ?? rows;
|
|
181
|
+
const resolvedDefaultColDef = defaultColDef ?? defaultColumnOptions;
|
|
182
|
+
|
|
183
|
+
// Merge default column options
|
|
184
|
+
const mergedDefaultColDef = useMemo<ColDef<TData>>(
|
|
185
|
+
() => ({
|
|
186
|
+
resizable: true,
|
|
187
|
+
suppressMovable: true,
|
|
188
|
+
...resolvedDefaultColDef,
|
|
189
|
+
}),
|
|
190
|
+
[resolvedDefaultColDef],
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
// Custom overlay component when no rows
|
|
194
|
+
const noRowsOverlayComponent = useMemo(() => {
|
|
195
|
+
if (!renderers?.noRowsFallback) return undefined;
|
|
196
|
+
return () => renderers.noRowsFallback;
|
|
197
|
+
}, [renderers?.noRowsFallback]);
|
|
198
|
+
|
|
199
|
+
// Generate row ID from __rowKey if available
|
|
200
|
+
const resolvedGetRowId = useMemo(() => {
|
|
201
|
+
if (getRowId) return getRowId;
|
|
202
|
+
return (params: GetRowIdParams<TData>) => {
|
|
203
|
+
const data = params.data as RowObjectType;
|
|
204
|
+
if (data?.__rowKey !== undefined) {
|
|
205
|
+
return String(data.__rowKey);
|
|
206
|
+
}
|
|
207
|
+
// Use rowIndex from the data or generate a random ID
|
|
208
|
+
const index = (params.data as unknown as { rowIndex?: number })?.rowIndex;
|
|
209
|
+
return String(index ?? Math.random());
|
|
210
|
+
};
|
|
211
|
+
}, [getRowId]);
|
|
212
|
+
|
|
213
|
+
// Generate a key based on pinned columns to force AG Grid to remount when pinned columns change
|
|
214
|
+
// This is necessary because AG Grid maintains internal column state that may not update
|
|
215
|
+
// when columnDefs change
|
|
216
|
+
const gridKey = useMemo(() => {
|
|
217
|
+
if (!resolvedColumnDefs) return "grid";
|
|
218
|
+
const pinnedFields = resolvedColumnDefs
|
|
219
|
+
.filter(
|
|
220
|
+
(col): col is ColDef<TData> => "field" in col && col.pinned === "left",
|
|
221
|
+
)
|
|
222
|
+
.map((col) => col.field)
|
|
223
|
+
.sort()
|
|
224
|
+
.join(",");
|
|
225
|
+
return `grid-${pinnedFields}`;
|
|
226
|
+
}, [resolvedColumnDefs]);
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<Box
|
|
230
|
+
ref={containerRef}
|
|
231
|
+
className={
|
|
232
|
+
className ? `${className} no-track-pii-safe` : "no-track-pii-safe"
|
|
233
|
+
}
|
|
234
|
+
sx={{
|
|
235
|
+
// Use flex: 1 and minHeight: 0 for proper sizing in flex containers
|
|
236
|
+
// This allows AG Grid to fill available space and scroll internally
|
|
237
|
+
flex: 1,
|
|
238
|
+
minHeight: 0,
|
|
239
|
+
width: "100%",
|
|
240
|
+
overflow: "hidden",
|
|
241
|
+
"& .ag-root-wrapper": {
|
|
242
|
+
border: "none",
|
|
243
|
+
height: "100%",
|
|
244
|
+
},
|
|
245
|
+
"& .ag-header": {
|
|
246
|
+
borderBottom: "1px solid var(--ag-border-color)",
|
|
247
|
+
},
|
|
248
|
+
"& .ag-row": {
|
|
249
|
+
borderBottom: "1px solid var(--ag-border-color)",
|
|
250
|
+
},
|
|
251
|
+
"& .ag-cell": {
|
|
252
|
+
borderRight: "1px solid var(--ag-border-color)",
|
|
253
|
+
},
|
|
254
|
+
"& .ag-header-cell": {
|
|
255
|
+
borderRight: "1px solid var(--ag-border-color)",
|
|
256
|
+
},
|
|
257
|
+
// Diff cell styling - theme-aware colors
|
|
258
|
+
"& .diff-cell-added": {
|
|
259
|
+
backgroundColor:
|
|
260
|
+
muiTheme.palette.mode === "dark"
|
|
261
|
+
? "#1a4d1a !important"
|
|
262
|
+
: "#cefece !important",
|
|
263
|
+
color: muiTheme.palette.text.primary,
|
|
264
|
+
},
|
|
265
|
+
"& .diff-cell-removed": {
|
|
266
|
+
backgroundColor:
|
|
267
|
+
muiTheme.palette.mode === "dark"
|
|
268
|
+
? "#5c1f1f !important"
|
|
269
|
+
: "#ffc5c5 !important",
|
|
270
|
+
color: muiTheme.palette.text.primary,
|
|
271
|
+
},
|
|
272
|
+
"& .diff-cell-modified": {
|
|
273
|
+
backgroundColor:
|
|
274
|
+
muiTheme.palette.mode === "dark"
|
|
275
|
+
? "#5c1f1f !important"
|
|
276
|
+
: "#ffc5c5 !important",
|
|
277
|
+
color: muiTheme.palette.text.primary,
|
|
278
|
+
},
|
|
279
|
+
// Diff header styling
|
|
280
|
+
"& .diff-header-added": {
|
|
281
|
+
backgroundColor: "#15803d !important",
|
|
282
|
+
color: "white",
|
|
283
|
+
},
|
|
284
|
+
"& .diff-header-removed": {
|
|
285
|
+
backgroundColor: "#f43f5e !important",
|
|
286
|
+
color: "white",
|
|
287
|
+
},
|
|
288
|
+
// Index column styling
|
|
289
|
+
"& .index-column": {
|
|
290
|
+
color: muiTheme.palette.text.secondary,
|
|
291
|
+
textAlign: "right",
|
|
292
|
+
},
|
|
293
|
+
// Frozen/pinned column styling
|
|
294
|
+
"& .ag-pinned-left-cols-container .ag-cell": {
|
|
295
|
+
backgroundColor:
|
|
296
|
+
muiTheme.palette.mode === "dark" ? "#2d2d2d" : "#f5f5f5",
|
|
297
|
+
},
|
|
298
|
+
}}
|
|
299
|
+
>
|
|
300
|
+
<AgGridReact<TData>
|
|
301
|
+
key={gridKey}
|
|
302
|
+
theme={gridTheme}
|
|
303
|
+
columnDefs={resolvedColumnDefs}
|
|
304
|
+
rowData={resolvedRowData}
|
|
305
|
+
getRowId={resolvedGetRowId}
|
|
306
|
+
rowHeight={rowHeight}
|
|
307
|
+
headerHeight={headerHeight}
|
|
308
|
+
defaultColDef={mergedDefaultColDef}
|
|
309
|
+
suppressCellFocus={true}
|
|
310
|
+
suppressRowHoverHighlight={false}
|
|
311
|
+
animateRows={false}
|
|
312
|
+
rowClass="no-track-pii-safe"
|
|
313
|
+
noRowsOverlayComponent={noRowsOverlayComponent}
|
|
314
|
+
onGridReady={(event) => {
|
|
315
|
+
gridApiRef.current = event.api;
|
|
316
|
+
}}
|
|
317
|
+
{...props}
|
|
318
|
+
/>
|
|
319
|
+
</Box>
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export const ScreenshotDataGrid = forwardRef(_ScreenshotDataGrid) as <
|
|
324
|
+
TData = RowObjectType,
|
|
325
|
+
>(
|
|
326
|
+
props: ScreenshotDataGridProps<TData> & { ref?: Ref<DataGridHandle> },
|
|
327
|
+
) => React.ReactNode;
|
|
328
|
+
|
|
329
|
+
// Re-export AG Grid types for convenience
|
|
330
|
+
export type { ColDef, ColGroupDef, GetRowIdParams, GridReadyEvent };
|
|
331
|
+
|
|
332
|
+
// For backward compatibility, also export as DataGridHandle
|
|
333
|
+
export type { DataGridHandle as RecceDataGridHandle };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file agGridStyles.css
|
|
3
|
+
* @description Custom AG Grid styles for Recce data grids
|
|
4
|
+
*
|
|
5
|
+
* Provides header layout customization to ensure proper flex alignment:
|
|
6
|
+
* - Header cells use flex layout with items centered vertically
|
|
7
|
+
* - Labels aligned to the left
|
|
8
|
+
* - Actions (menu, sort icons) aligned to the right
|
|
9
|
+
* - Sticky headers when scrolling vertically
|
|
10
|
+
*
|
|
11
|
+
* Uses CSS custom properties from global.css for theme-aware colors.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/* AG Grid Viewport - uses theme-aware background */
|
|
15
|
+
.ag-body-viewport,
|
|
16
|
+
.ag-center-cols-viewport {
|
|
17
|
+
background-color: var(--recce-bg-muted);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Sticky header - stays visible when scrolling vertically */
|
|
21
|
+
.ag-header {
|
|
22
|
+
position: sticky;
|
|
23
|
+
top: 0;
|
|
24
|
+
z-index: 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Header cell flex layout */
|
|
28
|
+
.ag-header-cell-comp-wrapper {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
width: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* Header label takes available space and aligns left */
|
|
35
|
+
.ag-header-cell-label {
|
|
36
|
+
flex: 1;
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* Sort icons stay with the label */
|
|
43
|
+
.ag-header-cell-label .ag-sort-indicator-container {
|
|
44
|
+
margin-left: 4px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* Actions container (menu button, etc.) aligned right */
|
|
48
|
+
.ag-header-cell-menu-button {
|
|
49
|
+
margin-left: auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Ensure header icons don't shrink */
|
|
53
|
+
.ag-header-icon {
|
|
54
|
+
flex-shrink: 0;
|
|
55
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file agGridTheme.ts
|
|
3
|
+
* @description AG Grid theme configuration for Recce data grids
|
|
4
|
+
*
|
|
5
|
+
* Provides light and dark themes that match the existing react-data-grid styling
|
|
6
|
+
* using AG Grid's themeQuartz as a base.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { themeQuartz } from "ag-grid-community";
|
|
10
|
+
|
|
11
|
+
// System font stack for headers
|
|
12
|
+
const systemFontStack =
|
|
13
|
+
'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
14
|
+
|
|
15
|
+
// Light theme matching current rdg-light styling
|
|
16
|
+
export const recceGridThemeLight = themeQuartz.withParams({
|
|
17
|
+
backgroundColor: "#ffffff",
|
|
18
|
+
headerBackgroundColor: "#f5f5f5",
|
|
19
|
+
rowHoverColor: "#ffffff",
|
|
20
|
+
borderColor: "#e0e0e0",
|
|
21
|
+
foregroundColor: "#1e1e1e",
|
|
22
|
+
fontFamily: "monospace",
|
|
23
|
+
fontSize: 13,
|
|
24
|
+
headerFontFamily: systemFontStack,
|
|
25
|
+
headerFontSize: 13,
|
|
26
|
+
headerFontWeight: 700,
|
|
27
|
+
cellHorizontalPadding: 8,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Dark theme matching current rdg-dark styling
|
|
31
|
+
export const recceGridThemeDark = themeQuartz.withParams({
|
|
32
|
+
backgroundColor: "#1e1e1e",
|
|
33
|
+
headerBackgroundColor: "#252526",
|
|
34
|
+
rowHoverColor: "#1e1e1e",
|
|
35
|
+
borderColor: "#3c3c3c",
|
|
36
|
+
foregroundColor: "#e0e0e0",
|
|
37
|
+
fontFamily: "monospace",
|
|
38
|
+
fontSize: 13,
|
|
39
|
+
headerFontFamily: systemFontStack,
|
|
40
|
+
headerFontSize: 13,
|
|
41
|
+
headerFontWeight: 700,
|
|
42
|
+
cellHorizontalPadding: 8,
|
|
43
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { PostgreSQL, sql } from "@codemirror/lang-sql";
|
|
4
|
+
import { yaml } from "@codemirror/lang-yaml";
|
|
5
|
+
import { Prec } from "@codemirror/state";
|
|
6
|
+
import { EditorView, keymap } from "@codemirror/view";
|
|
7
|
+
import { githubDark, githubLight } from "@uiw/codemirror-theme-github";
|
|
8
|
+
import CodeMirror from "@uiw/react-codemirror";
|
|
9
|
+
import { useMemo } from "react";
|
|
10
|
+
|
|
11
|
+
export type CodeEditorLanguage = "sql" | "yaml";
|
|
12
|
+
export type CodeEditorTheme = "light" | "dark";
|
|
13
|
+
|
|
14
|
+
export interface CodeEditorProps {
|
|
15
|
+
value: string;
|
|
16
|
+
onChange?: (value: string) => void;
|
|
17
|
+
language?: CodeEditorLanguage;
|
|
18
|
+
readOnly?: boolean;
|
|
19
|
+
lineNumbers?: boolean;
|
|
20
|
+
wordWrap?: boolean;
|
|
21
|
+
fontSize?: number;
|
|
22
|
+
height?: string;
|
|
23
|
+
className?: string;
|
|
24
|
+
/** Theme: "light" for githubLight, "dark" for githubDark */
|
|
25
|
+
theme?: CodeEditorTheme;
|
|
26
|
+
/** Custom keyboard shortcuts: { key: handler } */
|
|
27
|
+
keyBindings?: Array<{ key: string; run: () => boolean }>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const getLanguageExtension = (language: CodeEditorLanguage) => {
|
|
31
|
+
switch (language) {
|
|
32
|
+
case "sql":
|
|
33
|
+
return sql({ dialect: PostgreSQL });
|
|
34
|
+
case "yaml":
|
|
35
|
+
return yaml();
|
|
36
|
+
default:
|
|
37
|
+
return sql({ dialect: PostgreSQL });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export function CodeEditor({
|
|
42
|
+
value,
|
|
43
|
+
onChange,
|
|
44
|
+
language = "sql",
|
|
45
|
+
readOnly = false,
|
|
46
|
+
lineNumbers = true,
|
|
47
|
+
wordWrap = true,
|
|
48
|
+
fontSize = 14,
|
|
49
|
+
height = "100%",
|
|
50
|
+
className = "",
|
|
51
|
+
theme = "light",
|
|
52
|
+
keyBindings = [],
|
|
53
|
+
}: CodeEditorProps) {
|
|
54
|
+
const extensions = useMemo(() => {
|
|
55
|
+
const exts = [
|
|
56
|
+
getLanguageExtension(language),
|
|
57
|
+
EditorView.theme({
|
|
58
|
+
"&": { fontSize: `${fontSize}px` },
|
|
59
|
+
".cm-content": { fontFamily: "monospace" },
|
|
60
|
+
".cm-gutters": { fontFamily: "monospace" },
|
|
61
|
+
}),
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
if (wordWrap) {
|
|
65
|
+
exts.push(EditorView.lineWrapping);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Use Prec.highest to ensure custom keybindings take precedence
|
|
69
|
+
// over defaultKeymap bindings (e.g., Mod-Enter -> insertBlankLine)
|
|
70
|
+
if (keyBindings.length > 0) {
|
|
71
|
+
exts.push(Prec.highest(keymap.of(keyBindings)));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return exts;
|
|
75
|
+
}, [language, fontSize, wordWrap, keyBindings]);
|
|
76
|
+
|
|
77
|
+
const themeExtension = useMemo(() => {
|
|
78
|
+
return theme === "dark" ? githubDark : githubLight;
|
|
79
|
+
}, [theme]);
|
|
80
|
+
|
|
81
|
+
const handleChange = (val: string) => {
|
|
82
|
+
if (onChange) {
|
|
83
|
+
onChange(val);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<CodeMirror
|
|
89
|
+
value={value}
|
|
90
|
+
onChange={handleChange}
|
|
91
|
+
extensions={extensions}
|
|
92
|
+
readOnly={readOnly}
|
|
93
|
+
basicSetup={{
|
|
94
|
+
lineNumbers,
|
|
95
|
+
foldGutter: true,
|
|
96
|
+
highlightActiveLineGutter: !readOnly,
|
|
97
|
+
highlightActiveLine: !readOnly,
|
|
98
|
+
tabSize: 2,
|
|
99
|
+
}}
|
|
100
|
+
height={height}
|
|
101
|
+
className={`${className} no-track-pii-safe`}
|
|
102
|
+
theme={themeExtension}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default CodeEditor;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { PostgreSQL, sql } from "@codemirror/lang-sql";
|
|
4
|
+
import { yaml } from "@codemirror/lang-yaml";
|
|
5
|
+
import { MergeView, unifiedMergeView } from "@codemirror/merge";
|
|
6
|
+
import { EditorState, Extension, Text } from "@codemirror/state";
|
|
7
|
+
import {
|
|
8
|
+
EditorView,
|
|
9
|
+
lineNumbers as lineNumbersExtension,
|
|
10
|
+
} from "@codemirror/view";
|
|
11
|
+
import { githubDark, githubLight } from "@uiw/codemirror-theme-github";
|
|
12
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
13
|
+
|
|
14
|
+
export type DiffEditorLanguage = "sql" | "yaml";
|
|
15
|
+
export type DiffEditorTheme = "light" | "dark";
|
|
16
|
+
|
|
17
|
+
export interface DiffEditorProps {
|
|
18
|
+
original: string;
|
|
19
|
+
modified: string;
|
|
20
|
+
language?: DiffEditorLanguage;
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
lineNumbers?: boolean;
|
|
23
|
+
sideBySide?: boolean;
|
|
24
|
+
height?: string;
|
|
25
|
+
className?: string;
|
|
26
|
+
/** Theme: "light" for githubLight, "dark" for githubDark */
|
|
27
|
+
theme?: DiffEditorTheme;
|
|
28
|
+
/** Called when modified content changes (only if not readOnly) */
|
|
29
|
+
onModifiedChange?: (value: string) => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const getLanguageExtension = (language: DiffEditorLanguage) => {
|
|
33
|
+
switch (language) {
|
|
34
|
+
case "sql":
|
|
35
|
+
return sql({ dialect: PostgreSQL });
|
|
36
|
+
case "yaml":
|
|
37
|
+
return yaml();
|
|
38
|
+
default:
|
|
39
|
+
return sql({ dialect: PostgreSQL });
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const getThemeExtension = (theme: DiffEditorTheme): Extension => {
|
|
44
|
+
return theme === "dark" ? githubDark : githubLight;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export function DiffEditor({
|
|
48
|
+
original,
|
|
49
|
+
modified,
|
|
50
|
+
language = "sql",
|
|
51
|
+
readOnly = true,
|
|
52
|
+
lineNumbers = true,
|
|
53
|
+
sideBySide = true,
|
|
54
|
+
height = "100%",
|
|
55
|
+
className = "",
|
|
56
|
+
theme = "light",
|
|
57
|
+
onModifiedChange,
|
|
58
|
+
}: DiffEditorProps) {
|
|
59
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
60
|
+
const viewRef = useRef<MergeView | EditorView | null>(null);
|
|
61
|
+
|
|
62
|
+
const extensions = useMemo(() => {
|
|
63
|
+
const exts = [getLanguageExtension(language), getThemeExtension(theme)];
|
|
64
|
+
|
|
65
|
+
if (lineNumbers) {
|
|
66
|
+
exts.push(lineNumbersExtension());
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return exts;
|
|
70
|
+
}, [language, theme, lineNumbers]);
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!containerRef.current) return;
|
|
74
|
+
|
|
75
|
+
// Clean up previous instance
|
|
76
|
+
if (viewRef.current) {
|
|
77
|
+
viewRef.current.destroy();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (sideBySide) {
|
|
81
|
+
// Side-by-side mode using MergeView
|
|
82
|
+
const mergeView = new MergeView({
|
|
83
|
+
a: {
|
|
84
|
+
doc: original,
|
|
85
|
+
extensions: [
|
|
86
|
+
...extensions,
|
|
87
|
+
EditorView.editable.of(false),
|
|
88
|
+
EditorState.readOnly.of(true),
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
b: {
|
|
92
|
+
doc: modified,
|
|
93
|
+
extensions: [
|
|
94
|
+
...extensions,
|
|
95
|
+
EditorView.editable.of(!readOnly),
|
|
96
|
+
EditorState.readOnly.of(readOnly),
|
|
97
|
+
EditorView.updateListener.of((update) => {
|
|
98
|
+
if (update.docChanged && onModifiedChange) {
|
|
99
|
+
onModifiedChange(update.state.doc.toString());
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
parent: containerRef.current,
|
|
105
|
+
revertControls: !readOnly ? "a-to-b" : undefined,
|
|
106
|
+
highlightChanges: true,
|
|
107
|
+
gutter: lineNumbers,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
viewRef.current = mergeView;
|
|
111
|
+
} else {
|
|
112
|
+
// Unified/inline mode using unifiedMergeView
|
|
113
|
+
const editorView = new EditorView({
|
|
114
|
+
doc: modified,
|
|
115
|
+
extensions: [
|
|
116
|
+
...extensions,
|
|
117
|
+
unifiedMergeView({
|
|
118
|
+
original: Text.of(original.split("\n")),
|
|
119
|
+
allowInlineDiffs: true,
|
|
120
|
+
highlightChanges: true,
|
|
121
|
+
gutter: lineNumbers,
|
|
122
|
+
mergeControls: false,
|
|
123
|
+
}),
|
|
124
|
+
EditorView.editable.of(!readOnly),
|
|
125
|
+
EditorState.readOnly.of(readOnly),
|
|
126
|
+
EditorView.updateListener.of((update) => {
|
|
127
|
+
if (update.docChanged && onModifiedChange) {
|
|
128
|
+
onModifiedChange(update.state.doc.toString());
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
],
|
|
132
|
+
parent: containerRef.current,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
viewRef.current = editorView;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return () => {
|
|
139
|
+
if (viewRef.current) {
|
|
140
|
+
viewRef.current.destroy();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}, [
|
|
144
|
+
original,
|
|
145
|
+
modified,
|
|
146
|
+
extensions,
|
|
147
|
+
readOnly,
|
|
148
|
+
lineNumbers,
|
|
149
|
+
sideBySide,
|
|
150
|
+
onModifiedChange,
|
|
151
|
+
]);
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<div
|
|
155
|
+
ref={containerRef}
|
|
156
|
+
className={`${className} no-track-pii-safe`}
|
|
157
|
+
style={{ height, overflow: "auto" }}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export default DiffEditor;
|