Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 34 additions & 20 deletions src/lib/components/AgGrid.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
import LazyLoader from '../LazyLoader';
import React, {lazy, Suspense, useState, useCallback, useEffect} from 'react';
import {AllCommunityModule, ModuleRegistry} from 'ag-grid-community';
import {pick} from 'ramda';

// Register all community features
ModuleRegistry.registerModules([AllCommunityModule]);
Expand All @@ -13,6 +14,25 @@ function getGrid(enable) {
return enable ? RealAgGridEnterprise : RealAgGrid;
}

export const defaultProps = {
className: '',
resetColumnState: false,
exportDataAsCsv: false,
selectAll: false,
deselectAll: false,
enableEnterpriseModules: false,
updateColumnState: false,
persisted_props: ['selectedRows'],
persistence_type: 'local',
suppressDragLeaveHidesColumns: true,
dangerously_allow_code: false,
rowModelType: 'clientSide',
dashGridOptions: {},
filterModel: {},
paginationGoTo: null,
selectedRows: [],
};

/**
* Dash interface to AG Grid, a powerful tabular data component.
*/
Expand Down Expand Up @@ -49,31 +69,26 @@ function DashAgGrid(props) {

return (
<Suspense fallback={null}>
<RealComponent parentState={state} {...props} />
<RealComponent parentState={state} {...defaultProps} {...props} />
</Suspense>
);
}

const REACT_VERSION_DASH2_COMPAT = 18.3;
if (
parseFloat(React.version.substring(0, React.version.lastIndexOf('.'))) <
REACT_VERSION_DASH2_COMPAT
) {
DashAgGrid.defaultProps = defaultProps;
} else {
DashAgGrid.dashPersistence = pick(
['persisted_props', 'persistence_type'],
defaultProps
);
}

DashAgGrid.dashRenderType = true;

DashAgGrid.defaultProps = {
className: '',
resetColumnState: false,
exportDataAsCsv: false,
selectAll: false,
deselectAll: false,
enableEnterpriseModules: false,
updateColumnState: false,
persisted_props: ['selectedRows'],
persistence_type: 'local',
suppressDragLeaveHidesColumns: true,
dangerously_allow_code: false,
rowModelType: 'clientSide',
dashGridOptions: {},
filterModel: {},
paginationGoTo: null,
selectedRows: [],
};
DashAgGrid.propTypes = {
/********************************
* DASH PROPS
Expand Down Expand Up @@ -755,7 +770,6 @@ DashAgGrid.propTypes = {
};

export const propTypes = DashAgGrid.propTypes;
export const defaultProps = DashAgGrid.defaultProps;

export default DashAgGrid;

Expand Down
8 changes: 1 addition & 7 deletions src/lib/fragments/AgGrid.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ import {
assoc,
assocPath,
} from 'ramda';
import {
propTypes as _propTypes,
defaultProps as _defaultProps,
apiGetters,
} from '../components/AgGrid.react';
import {propTypes as _propTypes, apiGetters} from '../components/AgGrid.react';
import {
COLUMN_DANGEROUS_FUNCTIONS,
COLUMN_MAYBE_FUNCTIONS,
Expand Down Expand Up @@ -1617,11 +1613,9 @@ export function DashAgGrid(props) {
);
}

DashAgGrid.defaultProps = _defaultProps;
DashAgGrid.propTypes = {parentState: PropTypes.any, ..._propTypes};

export const propTypes = DashAgGrid.propTypes;
export const defaultProps = DashAgGrid.defaultProps;

var dagfuncs = (window.dash_ag_grid = window.dash_ag_grid || {});
dagfuncs.useGridFilter = useGridFilter;
Expand Down
3 changes: 3 additions & 0 deletions src/lib/utils/propCategories.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ export const PASSTHRU_PROPS = ['rowData'];
*/
export const PROPS_NOT_FOR_AG_GRID = [
'children',
'dashRenderType',
'licenseKey',
'setProps',
'loading_state',
'enableEnterpriseModules',
Expand Down Expand Up @@ -356,6 +358,7 @@ export const PROPS_NOT_FOR_AG_GRID = [
'scrollTo',
'eventListeners',
'eventData',
'paginationInfo',
];

/**
Expand Down