@deephaven/js-plugin-ag-grid 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +48 -0
  2. package/dist/AgGridDhTheme.d.ts +9 -0
  3. package/dist/AgGridDhTheme.d.ts.map +1 -0
  4. package/dist/AgGridDhTheme.js +41 -0
  5. package/dist/AgGridDhTheme.js.map +1 -0
  6. package/dist/AgGridPlugin.d.ts +5 -0
  7. package/dist/AgGridPlugin.d.ts.map +1 -0
  8. package/dist/AgGridPlugin.js +16 -0
  9. package/dist/AgGridPlugin.js.map +1 -0
  10. package/dist/AgGridView.d.ts +16 -0
  11. package/dist/AgGridView.d.ts.map +1 -0
  12. package/dist/AgGridView.js +86 -0
  13. package/dist/AgGridView.js.map +1 -0
  14. package/dist/AgGridWidget.d.ts +10 -0
  15. package/dist/AgGridWidget.d.ts.map +1 -0
  16. package/dist/AgGridWidget.js +69 -0
  17. package/dist/AgGridWidget.js.map +1 -0
  18. package/dist/bundle/index.js +60710 -0
  19. package/dist/datasources/DeephavenViewportDatasource.d.ts +66 -0
  20. package/dist/datasources/DeephavenViewportDatasource.d.ts.map +1 -0
  21. package/dist/datasources/DeephavenViewportDatasource.js +225 -0
  22. package/dist/datasources/DeephavenViewportDatasource.js.map +1 -0
  23. package/dist/datasources/index.d.ts +2 -0
  24. package/dist/datasources/index.d.ts.map +1 -0
  25. package/dist/datasources/index.js +2 -0
  26. package/dist/datasources/index.js.map +1 -0
  27. package/dist/index.d.ts +6 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +6 -84928
  30. package/dist/index.js.map +1 -0
  31. package/dist/renderers/TreeCellRenderer.d.ts +9 -0
  32. package/dist/renderers/TreeCellRenderer.d.ts.map +1 -0
  33. package/dist/renderers/TreeCellRenderer.js +35 -0
  34. package/dist/renderers/TreeCellRenderer.js.map +1 -0
  35. package/dist/renderers/index.d.ts +2 -0
  36. package/dist/renderers/index.d.ts.map +1 -0
  37. package/dist/renderers/index.js +2 -0
  38. package/dist/renderers/index.js.map +1 -0
  39. package/dist/utils/AgGridAggUtils.d.ts +23 -0
  40. package/dist/utils/AgGridAggUtils.d.ts.map +1 -0
  41. package/dist/utils/AgGridAggUtils.js +53 -0
  42. package/dist/utils/AgGridAggUtils.js.map +1 -0
  43. package/dist/utils/AgGridColors.d.ts +20 -0
  44. package/dist/utils/AgGridColors.d.ts.map +1 -0
  45. package/dist/utils/AgGridColors.js +26 -0
  46. package/dist/utils/AgGridColors.js.map +1 -0
  47. package/dist/utils/AgGridFilterUtils.d.ts +22 -0
  48. package/dist/utils/AgGridFilterUtils.d.ts.map +1 -0
  49. package/dist/utils/AgGridFilterUtils.js +202 -0
  50. package/dist/utils/AgGridFilterUtils.js.map +1 -0
  51. package/dist/utils/AgGridFormatter.d.ts +12 -0
  52. package/dist/utils/AgGridFormatter.d.ts.map +1 -0
  53. package/dist/utils/AgGridFormatter.js +64 -0
  54. package/dist/utils/AgGridFormatter.js.map +1 -0
  55. package/dist/utils/AgGridSortUtils.d.ts +20 -0
  56. package/dist/utils/AgGridSortUtils.d.ts.map +1 -0
  57. package/dist/utils/AgGridSortUtils.js +45 -0
  58. package/dist/utils/AgGridSortUtils.js.map +1 -0
  59. package/dist/utils/AgGridTableUtils.d.ts +22 -0
  60. package/dist/utils/AgGridTableUtils.d.ts.map +1 -0
  61. package/dist/utils/AgGridTableUtils.js +75 -0
  62. package/dist/utils/AgGridTableUtils.js.map +1 -0
  63. package/dist/utils/index.d.ts +7 -0
  64. package/dist/utils/index.d.ts.map +1 -0
  65. package/dist/utils/index.js +7 -0
  66. package/dist/utils/index.js.map +1 -0
  67. package/package.json +28 -9
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Deephaven JS Plugin for AG Grid
2
+
3
+ This package can be used to display Deephaven tables using [AG Grid](https://www.ag-grid.com/). It is currently in a beta state.
4
+
5
+ ## Usage
6
+
7
+ Import the DeephavenViewportDatasource and use it with your AG Grid view. For example, in React:
8
+
9
+ ```tsx
10
+ import React, { useEffect, useRef } from 'react';
11
+ import { AgGridReact } from 'ag-grid-react';
12
+ import type { dh as DhType } from '@deephaven/jsapi-types';
13
+ import { DeephavenViewportDatasource } from '@deephaven/js-plugin-ag-grid';
14
+
15
+ function DeephavenAgGridComponent({
16
+ dh,
17
+ table,
18
+ }: {
19
+ dh: typeof DhType;
20
+ table: DhType.Table;
21
+ }) {
22
+ const datasource = useMemo(
23
+ () => new DeephavenViewportDatasource(dh, table),
24
+ [dh, table]
25
+ );
26
+ return (
27
+ <AgGridReact
28
+ onGridReady={({ api }) => {
29
+ // Set the API in the Grid when the grid is ready
30
+ datasource.setGridApi(api);
31
+ }}
32
+ rowModelType="viewport"
33
+ viewportDatasource={datasource}
34
+ // other AG Grid properties
35
+ />
36
+ );
37
+ }
38
+ ```
39
+
40
+ ## Details
41
+
42
+ The `DeephavenViewportDatasource` class is designed to work with AG Grid's viewport row model. It fetches data from a Deephaven table and provides it to the grid as needed. The datasource handles the logic for fetching rows based on the current viewport, which is defined by the first and last row indices.
43
+
44
+ The [`DeephavenViewportDatasource` listens to the grid's events](./src/datasources/DeephavenViewportDatasource.ts#115) to determine when to update the filters, sorts, aggregations, and groupings in the Deephaven table. Functions in the [utils](./src/utils/) map the Grid's state to operations that can be applied to the Deephaven Table object, which then applies the operation on the server side.
45
+
46
+ - [AgGridFilterUtils](./src/utils/AgGridFilterUtils.ts): Utility functions for mapping AG Grid filter models to Deephaven table operations.
47
+ - [AgGridSortUtils](./src/utils/AgGridSortUtils.ts): Utility functions for mapping AG Grid sort models to Deephaven table operations.
48
+ - [AgGridAggUtils](./src/utils/AgGridAggUtils.ts): Utility functions for mapping AG Grid aggregation and grouping models to Deephaven table operations.
@@ -0,0 +1,9 @@
1
+ import type { CheckboxStyleParams, InputStyleParams, TabStyleParams } from '@ag-grid-community/theming';
2
+ import type { CoreParams } from '@ag-grid-community/theming/dist/types/src/styles/core/core-css';
3
+ type GridDensity = 'compact' | 'regular' | 'spacious';
4
+ export default class AgGridDhTheme {
5
+ static getThemeParams(gridDensity?: GridDensity): Partial<CoreParams & CheckboxStyleParams & TabStyleParams & InputStyleParams>;
6
+ private static getDensityDependentParams;
7
+ }
8
+ export {};
9
+ //# sourceMappingURL=AgGridDhTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgGridDhTheme.d.ts","sourceRoot":"","sources":["../src/AgGridDhTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gEAAgE,CAAC;AAGjG,KAAK,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AAEtD,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,MAAM,CAAC,cAAc,CACnB,WAAW,GAAE,WAAuB,GACnC,OAAO,CACR,UAAU,GAAG,mBAAmB,GAAG,cAAc,GAAG,gBAAgB,CACrE;IAqCD,OAAO,CAAC,MAAM,CAAC,yBAAyB;CA0BzC"}
@@ -0,0 +1,41 @@
1
+ import { AgGridThemeColors } from './utils/AgGridColors';
2
+ export default class AgGridDhTheme {
3
+ static getThemeParams(gridDensity = 'regular') {
4
+ return Object.assign({
5
+ /* Header */
6
+ headerBackgroundColor: AgGridThemeColors.headerBackgroundColor, headerTextColor: AgGridThemeColors.headerTextColor, headerColumnResizeHandleColor: AgGridThemeColors.headerColumnResizeHandleColor, headerFontFamily: 'var(--font-family-sans-serif)', headerFontSize: '12px', headerFontWeight: 600, headerHeight: 30,
7
+ /* Row */
8
+ backgroundColor: AgGridThemeColors.backgroundColor, oddRowBackgroundColor: AgGridThemeColors.oddRowBackgroundColor, rowHoverColor: AgGridThemeColors.rowHoverColor, rowBorder: false,
9
+ /* Selection */
10
+ selectedRowBackgroundColor: AgGridThemeColors.selectedRowBackgroundColor,
11
+ /* Text */
12
+ textColor: AgGridThemeColors.textColor, fontFamily: 'var(--font-family-sans-serif)', fontSize: 14,
13
+ /* Menu */
14
+ menuBackgroundColor: AgGridThemeColors.menuBackgroundColor, menuTextColor: AgGridThemeColors.menuTextColor,
15
+ /* Misc */
16
+ accentColor: AgGridThemeColors.accentColor }, this.getDensityDependentParams(gridDensity));
17
+ }
18
+ static getDensityDependentParams(gridDensity) {
19
+ switch (gridDensity) {
20
+ case 'compact':
21
+ return {
22
+ rowHeight: 16,
23
+ spacing: 5,
24
+ dataFontSize: 11,
25
+ };
26
+ case 'regular':
27
+ return {
28
+ rowHeight: 19,
29
+ spacing: 5,
30
+ dataFontSize: 12,
31
+ };
32
+ case 'spacious':
33
+ return {
34
+ rowHeight: 28,
35
+ spacing: 7,
36
+ dataFontSize: 12,
37
+ };
38
+ }
39
+ }
40
+ }
41
+ //# sourceMappingURL=AgGridDhTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgGridDhTheme.js","sourceRoot":"","sources":["../src/AgGridDhTheme.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIzD,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,MAAM,CAAC,cAAc,CACnB,cAA2B,SAAS;QAIpC;YACE,YAAY;YACZ,qBAAqB,EAAE,iBAAiB,CAAC,qBAAqB,EAC9D,eAAe,EAAE,iBAAiB,CAAC,eAAe,EAClD,6BAA6B,EAC3B,iBAAiB,CAAC,6BAA6B,EACjD,gBAAgB,EAAE,+BAA+B,EACjD,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,GAAG,EACrB,YAAY,EAAE,EAAE;YAEhB,SAAS;YACT,eAAe,EAAE,iBAAiB,CAAC,eAAe,EAClD,qBAAqB,EAAE,iBAAiB,CAAC,qBAAqB,EAC9D,aAAa,EAAE,iBAAiB,CAAC,aAAa,EAC9C,SAAS,EAAE,KAAK;YAEhB,eAAe;YACf,0BAA0B,EAAE,iBAAiB,CAAC,0BAA0B;YAExE,UAAU;YACV,SAAS,EAAE,iBAAiB,CAAC,SAAS,EACtC,UAAU,EAAE,+BAA+B,EAC3C,QAAQ,EAAE,EAAE;YAEZ,UAAU;YACV,mBAAmB,EAAE,iBAAiB,CAAC,mBAAmB,EAC1D,aAAa,EAAE,iBAAiB,CAAC,aAAa;YAE9C,UAAU;YACV,WAAW,EAAE,iBAAiB,CAAC,WAAW,IAEvC,IAAI,CAAC,yBAAyB,CAAC,WAAW,CAAC,EAC9C;IACJ,CAAC;IAEO,MAAM,CAAC,yBAAyB,CACtC,WAAwB;QAIxB,QAAQ,WAAW,EAAE;YACnB,KAAK,SAAS;gBACZ,OAAO;oBACL,SAAS,EAAE,EAAE;oBACb,OAAO,EAAE,CAAC;oBACV,YAAY,EAAE,EAAE;iBACjB,CAAC;YACJ,KAAK,SAAS;gBACZ,OAAO;oBACL,SAAS,EAAE,EAAE;oBACb,OAAO,EAAE,CAAC;oBACV,YAAY,EAAE,EAAE;iBACjB,CAAC;YACJ,KAAK,UAAU;gBACb,OAAO;oBACL,SAAS,EAAE,EAAE;oBACb,OAAO,EAAE,CAAC;oBACV,YAAY,EAAE,EAAE;iBACjB,CAAC;SACL;IACH,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ import { type WidgetPlugin } from '@deephaven/plugin';
2
+ import type { dh } from '@deephaven/jsapi-types';
3
+ export declare const AgGridPlugin: WidgetPlugin<dh.Widget>;
4
+ export default AgGridPlugin;
5
+ //# sourceMappingURL=AgGridPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgGridPlugin.d.ts","sourceRoot":"","sources":["../src/AgGridPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAc,MAAM,mBAAmB,CAAC;AAElE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAMjD,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,EAAE,CAAC,MAAM,CAOhD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,16 @@
1
+ var _a;
2
+ import { PluginType } from '@deephaven/plugin';
3
+ import { vsTable } from '@deephaven/icons';
4
+ import { LicenseManager } from '@ag-grid-enterprise/core';
5
+ import { AgGridWidget } from './AgGridWidget';
6
+ LicenseManager.setLicenseKey((_a = import.meta.env.VITE_AG_GRID_LICENSE_KEY) !== null && _a !== void 0 ? _a : '');
7
+ export const AgGridPlugin = {
8
+ name: '@deephaven/js-plugin-ag-grid',
9
+ type: PluginType.WIDGET_PLUGIN,
10
+ supportedTypes: 'deephaven.ag_grid.AgGrid',
11
+ component: AgGridWidget,
12
+ icon: vsTable,
13
+ title: 'AG Grid',
14
+ };
15
+ export default AgGridPlugin;
16
+ //# sourceMappingURL=AgGridPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgGridPlugin.js","sourceRoot":"","sources":["../src/AgGridPlugin.ts"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,cAAc,CAAC,aAAa,CAAC,MAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,mCAAI,EAAE,CAAC,CAAC;AAE7E,MAAM,CAAC,MAAM,YAAY,GAA4B;IACnD,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE,UAAU,CAAC,aAAa;IAC9B,cAAc,EAAE,0BAA0B;IAC1C,SAAS,EAAE,YAAY;IACvB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,SAAS;CACjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import type { dh as DhType } from '@deephaven/jsapi-types';
3
+ import { WorkspaceSettings } from '@deephaven/redux';
4
+ import { AgGridReactProps } from '@ag-grid-community/react';
5
+ type AgGridViewProps = {
6
+ table: DhType.Table | DhType.TreeTable;
7
+ settings?: WorkspaceSettings;
8
+ agGridProps?: AgGridReactProps;
9
+ };
10
+ /**
11
+ * AgGrid view that uses the Server-Side Row Model and a Deephaven table as a data source to display
12
+ * in AG Grid, with support for value formatting, sorting, and basic filtering operations.
13
+ */
14
+ export declare function AgGridView({ table, settings, agGridProps, }: AgGridViewProps): JSX.Element | null;
15
+ export default AgGridView;
16
+ //# sourceMappingURL=AgGridView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgGridView.d.ts","sourceRoot":"","sources":["../src/AgGridView.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AASrD,OAAO,EAEL,gBAAgB,EAEjB,MAAM,0BAA0B,CAAC;AAOlC,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC;IACvC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC,CAAC;AAIF;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,WAAW,GACZ,EAAE,eAAe,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAqHtC;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,86 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useApi } from '@deephaven/jsapi-bootstrap';
3
+ import Log from '@deephaven/log';
4
+ import { createFormatterFromSettings } from '@deephaven/jsapi-utils';
5
+ import { AgGridReact, } from '@ag-grid-community/react';
6
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
7
+ import { getColumnDefs } from './utils/AgGridTableUtils';
8
+ import AgGridFormatter from './utils/AgGridFormatter';
9
+ import TreeCellRenderer from './renderers/TreeCellRenderer';
10
+ import DeephavenViewportDatasource from './datasources/DeephavenViewportDatasource';
11
+ const log = Log.module('@deephaven/js-plugin-ag-grid/AgGridView');
12
+ /**
13
+ * AgGrid view that uses the Server-Side Row Model and a Deephaven table as a data source to display
14
+ * in AG Grid, with support for value formatting, sorting, and basic filtering operations.
15
+ */
16
+ export function AgGridView({ table, settings, agGridProps, }) {
17
+ const dh = useApi();
18
+ const gridApiRef = useRef(null);
19
+ const [isVisible, setIsVisible] = useState(false);
20
+ const [isFirstDataRendered, setIsFirstDataRendered] = useState(false);
21
+ const [isColumnsSized, setIsColumnsSized] = useState(false);
22
+ log.debug('AgGridView rendering', table, table === null || table === void 0 ? void 0 : table.columns);
23
+ /** Map from Deephaven Table Columns to AG Grid ColDefs */
24
+ const colDefs = useMemo(() => getColumnDefs(table), [table]);
25
+ /** Create the ViewportDatasource to pass in to AG Grid based on the Deephaven Table */
26
+ const datasource = useMemo(() => new DeephavenViewportDatasource(dh, table), [dh, table]);
27
+ // Create the formatter used to format cell values, currently just a
28
+ // wrapper around jsapi-utils Formatter, but more functionality could be added.
29
+ const formatter = useMemo(() => new AgGridFormatter(createFormatterFromSettings(dh, settings)), [dh, settings]);
30
+ const treeCellRenderer = useMemo(() => function customTreeCellRenderer(props) {
31
+ return (_jsx(TreeCellRenderer
32
+ // eslint-disable-next-line react/jsx-props-no-spreading
33
+ , Object.assign({}, props, { datasource: datasource })));
34
+ }, [datasource]);
35
+ const autoGroupColumnDef = useMemo(() => ({
36
+ cellRenderer: treeCellRenderer,
37
+ }), [treeCellRenderer]);
38
+ const sideBar = useMemo(() => ({
39
+ toolPanels: [
40
+ {
41
+ id: 'columns',
42
+ labelDefault: 'Columns',
43
+ labelKey: 'columns',
44
+ iconKey: 'columns',
45
+ toolPanel: 'agColumnsToolPanel',
46
+ },
47
+ ],
48
+ }), []);
49
+ // Workaround to auto-size columns based on their contents, as ag-grid ignores virtual columns
50
+ // that are not visible in the viewport
51
+ const autoSizeAllColumns = () => {
52
+ const gridApi = gridApiRef.current;
53
+ if (!gridApi)
54
+ return;
55
+ gridApi.sizeColumnsToFit();
56
+ const columns = gridApi.getColumns();
57
+ if (!columns)
58
+ return;
59
+ const allColumnIds = columns.map(col => col.getColId());
60
+ gridApi.autoSizeColumns(allColumnIds);
61
+ };
62
+ const handleGridReady = useCallback((event) => {
63
+ log.debug('handleGridReady', event);
64
+ datasource.setGridApi(event.api);
65
+ gridApiRef.current = event.api;
66
+ }, [datasource]);
67
+ const handleFirstDataRendered = (event) => {
68
+ log.debug('handleFirstDataRendered', event);
69
+ setIsFirstDataRendered(true);
70
+ };
71
+ const handleGridSizeChanged = (event) => {
72
+ log.debug('handleGridSizeChanged', event);
73
+ setIsVisible(event.clientHeight > 0 && event.clientWidth > 0);
74
+ };
75
+ useEffect(() => {
76
+ if (isVisible && isFirstDataRendered && !isColumnsSized) {
77
+ setIsColumnsSized(true);
78
+ autoSizeAllColumns();
79
+ }
80
+ }, [isVisible, isFirstDataRendered, isColumnsSized]);
81
+ return (_jsx(AgGridReact
82
+ // eslint-disable-next-line react/jsx-props-no-spreading
83
+ , Object.assign({}, agGridProps, { onGridReady: handleGridReady, onFirstDataRendered: handleFirstDataRendered, onGridSizeChanged: handleGridSizeChanged, autoGroupColumnDef: autoGroupColumnDef, columnDefs: colDefs, dataTypeDefinitions: formatter.cellDataTypeDefinitions, viewportDatasource: datasource, rowModelType: "viewport", sideBar: sideBar })));
84
+ }
85
+ export default AgGridView;
86
+ //# sourceMappingURL=AgGridView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgGridView.js","sourceRoot":"","sources":["../src/AgGridView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,GAAG,MAAM,gBAAgB,CAAC;AAEjC,OAAO,EAAE,2BAA2B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EAAE,UAAU,EAC9B,YAAY,EAAC,UAAU,EACvB,OAAO,EAAE,OAAO,IAChB,CACH,CAAC;AACJ,CAAC;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import type { dh as DhType } from '@deephaven/jsapi-types';
3
+ import { type WidgetComponentProps } from '@deephaven/plugin';
4
+ /**
5
+ * Fetches an AgGrid widget from the server and fetches the underlying table provided by the widget.
6
+ * Then passes the table to AgGridView to display the table in an AG Grid.
7
+ */
8
+ export declare function AgGridWidget(props: WidgetComponentProps<DhType.Widget>): JSX.Element;
9
+ export default AgGridWidget;
10
+ //# sourceMappingURL=AgGridWidget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgGridWidget.d.ts","sourceRoot":"","sources":["../src/AgGridWidget.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAgB9D;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,oBAAoB,CAAC,MAAM,CAAC,MAAM,CAAC,GACzC,GAAG,CAAC,OAAO,CAwEb;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useState } from 'react';
3
+ import { LoadingOverlay } from '@deephaven/components';
4
+ import { useApi } from '@deephaven/jsapi-bootstrap';
5
+ import Log from '@deephaven/log';
6
+ import { getSettings } from '@deephaven/redux';
7
+ import { useSelector } from 'react-redux';
8
+ import { themeQuartz } from '@ag-grid-community/theming';
9
+ import { ViewportRowModelModule } from '@ag-grid-enterprise/viewport-row-model';
10
+ import { ColumnsToolPanelModule } from '@ag-grid-enterprise/column-tool-panel';
11
+ import { RowGroupingModule } from '@ag-grid-enterprise/row-grouping';
12
+ import AgGridView from './AgGridView';
13
+ import AgGridDhTheme from './AgGridDhTheme';
14
+ import customStyles from './AgGridCustomStyles.css?inline';
15
+ const log = Log.module('@deephaven/js-plugin-ag-grid/AgGridView');
16
+ /**
17
+ * Fetches an AgGrid widget from the server and fetches the underlying table provided by the widget.
18
+ * Then passes the table to AgGridView to display the table in an AG Grid.
19
+ */
20
+ export function AgGridWidget(props) {
21
+ const dh = useApi();
22
+ const settings = useSelector((getSettings));
23
+ const { fetch } = props;
24
+ const [table, setTable] = useState();
25
+ const gridDensity = settings === null || settings === void 0 ? void 0 : settings.gridDensity;
26
+ const themeParams = useMemo(() => AgGridDhTheme.getThemeParams(gridDensity), [gridDensity]);
27
+ const theme = useMemo(() => themeQuartz.withParams(themeParams), [themeParams]);
28
+ const agGridProps = useMemo(() => ({
29
+ modules: [
30
+ RowGroupingModule,
31
+ ViewportRowModelModule,
32
+ ColumnsToolPanelModule,
33
+ ],
34
+ defaultColDef: {
35
+ filterParams: {
36
+ buttons: ['reset', 'apply'],
37
+ },
38
+ },
39
+ rowSelection: {
40
+ mode: 'multiRow',
41
+ checkboxes: false,
42
+ headerCheckbox: false,
43
+ enableClickSelection: true,
44
+ },
45
+ suppressCellFocus: true,
46
+ theme,
47
+ rowHeight: themeParams.rowHeight,
48
+ }), [theme, themeParams]);
49
+ /** First we load the widget object. This is the object that is sent from the server in AgGridMessageStream. */
50
+ useEffect(() => {
51
+ let cancelled = false;
52
+ async function init() {
53
+ log.debug('Fetching widget');
54
+ const widget = await fetch();
55
+ const newTable = (await widget.exportedObjects[0].fetch());
56
+ if (!cancelled) {
57
+ log.info('AgGridView loaded table', newTable);
58
+ setTable(newTable);
59
+ }
60
+ }
61
+ init();
62
+ return () => {
63
+ cancelled = true;
64
+ };
65
+ }, [dh, fetch]);
66
+ return table != null ? (_jsxs("div", Object.assign({ className: "ui-table-container" }, { children: [_jsx("style", { children: customStyles }), _jsx(AgGridView, { table: table, settings: settings, agGridProps: agGridProps })] }))) : (_jsx(LoadingOverlay, {}));
67
+ }
68
+ export default AgGridWidget;
69
+ //# sourceMappingURL=AgGridWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgGridWidget.js","sourceRoot":"","sources":["../src/AgGridWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,GAAG,MAAM,gBAAgB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAa,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,YAAY,MAAM,iCAAiC,CAAC;AAE3D,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,yCAAyC,CAAC,CAAC;AAElE;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,KAA0C;IAE1C,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IACpB,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAA,WAAsB,CAAA,CAAC,CAAC;IACrD,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACxB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAgB,CAAC;IAEnD,MAAM,WAAW,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,CAAC;IA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