@deephaven/js-plugin-ag-grid
Version:
Deephaven AG Grid plugin
27 lines • 1.57 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { useMemo } from 'react';
import { useApi } from '@deephaven/jsapi-bootstrap';
import { getSettings } from '@deephaven/redux';
import { themeQuartz } from 'ag-grid-community';
import { useSelector } from 'react-redux';
import AgGridView from './AgGridView';
import { AgGridDhTheme, getDefaultProps } from '../utils';
import useWidgetFetch from '../hooks/useWidgetFetch';
import LoadingOverlay from './LoadingOverlay';
/**
* Fetches an AgGrid widget from the server and fetches the underlying table provided by the widget.
* Then passes the table to AgGridView to display the table in an AG Grid.
*/
export function AgGridWidget(props) {
const dh = useApi();
const settings = useSelector((getSettings));
const { fetch } = props;
const gridDensity = settings === null || settings === void 0 ? void 0 : settings.gridDensity;
const themeParams = useMemo(() => AgGridDhTheme.getThemeParams(gridDensity), [gridDensity]);
const theme = useMemo(() => themeQuartz.withParams(themeParams), [themeParams]);
const agGridProps = useMemo(() => (Object.assign(Object.assign({}, getDefaultProps()), { theme, rowHeight: themeParams.rowHeight })), [theme, themeParams]);
const table = useWidgetFetch(dh, fetch);
return table != null ? (_jsx("div", { className: "ui-table-container widget-container", children: _jsx(AgGridView, { table: table, settings: settings, agGridProps: agGridProps }) })) : (_jsx(LoadingOverlay, {}));
}
export default AgGridWidget;
//# sourceMappingURL=AgGridWidget.js.map