@redsift/table 11.0.0-muiv5-alpha.3 → 11.0.0-muiv5

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/index.d.ts CHANGED
@@ -157,6 +157,21 @@ type StyledDataGridProps = {
157
157
 
158
158
  declare const DataGrid: Comp<DataGridProps, HTMLDivElement>;
159
159
 
160
+ interface StatefulDataGridProps extends DataGridProps {
161
+ /** Hook returning pathname, search params and a method to update query params. */
162
+ useRouter: () => {
163
+ pathname: string;
164
+ search: string;
165
+ historyReplace: (newSearch: string) => void;
166
+ };
167
+ /** Pinned custom columns. */
168
+ pinnedCustomColumns?: Required<GridPinnedColumns>;
169
+ /** Local Storage version, to upgrade when we want to force a clean out. */
170
+ localStorageVersion?: number;
171
+ }
172
+
173
+ declare const StatefulDataGrid: Comp<StatefulDataGridProps, HTMLDivElement>;
174
+
160
175
  interface ExtendedGridPaginationModel {
161
176
  page: number;
162
177
  pageSize: number;
@@ -319,19 +334,6 @@ type ServerSideControlledPaginationProps = {
319
334
  declare const onServerSideSelectionStatusChange: (newSelectionModel: GridSelectionModel, apiRef: React.MutableRefObject<GridApiPro>, selectionStatus: React.MutableRefObject<SelectionStatus>, isRowSelectable: ((params: GridRowParams<any>) => boolean) | undefined, page: number, pageSize: number) => void;
320
335
  declare const ServerSideControlledPagination: React.FC<ServerSideControlledPaginationProps>;
321
336
 
322
- interface StatefulDataGridProps extends DataGridProps {
323
- /** Hook returning pathname, search params and a method to update query params. */
324
- useRouter: () => {
325
- pathname: string;
326
- search: string;
327
- historyReplace: (newSearch: string) => void;
328
- };
329
- /** Pinned custom columns. */
330
- pinnedCustomColumns?: Required<GridPinnedColumns>;
331
- }
332
-
333
- declare const StatefulDataGrid: Comp<StatefulDataGridProps, HTMLDivElement>;
334
-
335
337
  interface TextCellProps extends ComponentProps<'div'> {
336
338
  /** Including Badge Component. */
337
339
  badge?: ReactNode;
package/index.js CHANGED
@@ -25807,7 +25807,7 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
25807
25807
  onPinnedColumnsChange: propsOnPinnedColumnsChange,
25808
25808
  onSortModelChange: propsOnSortModelChange,
25809
25809
  selectionModel: propsSelectionModel,
25810
- onSelectionModelChange,
25810
+ onSelectionModelChange: propsOnSelectionModelChange,
25811
25811
  page: propsPage,
25812
25812
  pageSize: propsPageSize,
25813
25813
  pagination,
@@ -25860,6 +25860,13 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
25860
25860
  useEffect(() => {
25861
25861
  setSelectionModel(propsSelectionModel !== null && propsSelectionModel !== void 0 ? propsSelectionModel : []);
25862
25862
  }, [propsSelectionModel]);
25863
+ const onSelectionModelChange = (selectionModel, details) => {
25864
+ if (propsOnSelectionModelChange) {
25865
+ propsOnSelectionModelChange(selectionModel, details);
25866
+ } else {
25867
+ setSelectionModel(selectionModel);
25868
+ }
25869
+ };
25863
25870
  const selectionStatus = useRef({
25864
25871
  type: 'none',
25865
25872
  numberOfSelectedRows: 0,
@@ -26167,7 +26174,6 @@ const useTableStates = (id, version, customDefaults) => {
26167
26174
  };
26168
26175
  };
26169
26176
 
26170
- const DATAGRID_VERSION = 1;
26171
26177
  const useStatefulTable = props => {
26172
26178
  const {
26173
26179
  // density = 'standard',
@@ -26185,7 +26191,7 @@ const useStatefulTable = props => {
26185
26191
  right: []
26186
26192
  },
26187
26193
  useRouter,
26188
- version = DATAGRID_VERSION
26194
+ localStorageVersion = 1
26189
26195
  } = props;
26190
26196
  const {
26191
26197
  search,
@@ -26213,10 +26219,10 @@ const useStatefulTable = props => {
26213
26219
  setPinnedColumns,
26214
26220
  dimensionModel,
26215
26221
  setDimensionModel
26216
- } = useTableStates(id, version, customDefaults);
26222
+ } = useTableStates(id, localStorageVersion, customDefaults);
26217
26223
 
26218
26224
  // clearing up old version keys, triggering only on first render
26219
- useEffect(() => clearPreviousVersionStorage(id, version), [id, version]);
26225
+ useEffect(() => clearPreviousVersionStorage(id, localStorageVersion), [id, localStorageVersion]);
26220
26226
  const onColumnDimensionChange = useCallback(_ref => {
26221
26227
  let {
26222
26228
  newWidth,
@@ -26248,6 +26254,11 @@ const useStatefulTable = props => {
26248
26254
  column.width = dimensionModel[column.field] || column.width || 100;
26249
26255
  return column;
26250
26256
  }), [propsColumns, dimensionModel]);
26257
+
26258
+ /** Add resetPage method to apiRef. */
26259
+ apiRef.current.resetPage = () => {
26260
+ apiRef.current.setPage(0);
26261
+ };
26251
26262
  return {
26252
26263
  apiRef,
26253
26264
  columns,
@@ -26343,7 +26354,7 @@ const useStatefulTable = props => {
26343
26354
  };
26344
26355
  };
26345
26356
 
26346
- const _excluded$1 = ["apiRef", "autoHeight", "className", "columns", "columnTypes", "components", "componentsProps", "filterModel", "columnVisibilityModel", "pinnedColumns", "sortModel", "page", "pageSize", "height", "hideToolbar", "initialState", "isRowSelectable", "license", "onFilterModelChange", "selectionModel", "onColumnWidthChange", "onPageChange", "onPageSizeChange", "onSelectionModelChange", "onColumnVisibilityModelChange", "onPinnedColumnsChange", "onSortModelChange", "pagination", "paginationPlacement", "paginationProps", "pinnedCustomColumns", "rows", "rowsPerPageOptions", "sx", "theme", "useRouter", "paginationMode", "rowCount"];
26357
+ const _excluded$1 = ["apiRef", "autoHeight", "className", "columns", "columnTypes", "components", "componentsProps", "filterModel", "columnVisibilityModel", "pinnedColumns", "sortModel", "page", "pageSize", "height", "hideToolbar", "initialState", "isRowSelectable", "license", "localStorageVersion", "onFilterModelChange", "selectionModel", "onColumnWidthChange", "onPageChange", "onPageSizeChange", "onSelectionModelChange", "onColumnVisibilityModelChange", "onPinnedColumnsChange", "onSortModelChange", "pagination", "paginationPlacement", "paginationProps", "pinnedCustomColumns", "rows", "rowsPerPageOptions", "sx", "theme", "useRouter", "paginationMode", "rowCount"];
26347
26358
  const COMPONENT_NAME$1 = 'DataGrid';
26348
26359
  const CLASSNAME$1 = 'redsift-datagrid';
26349
26360
  const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
@@ -26367,6 +26378,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
26367
26378
  initialState,
26368
26379
  isRowSelectable,
26369
26380
  license = process.env.MUI_LICENSE_KEY,
26381
+ localStorageVersion,
26370
26382
  onFilterModelChange: propsOnFilterModelChange,
26371
26383
  selectionModel: propsSelectionModel,
26372
26384
  onColumnWidthChange: propsOnColumnWidthChange,
@@ -26443,7 +26455,8 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
26443
26455
  onPinnedColumnsChange: controlledOnPinnedColumnsChange,
26444
26456
  onSortModelChange: controlledOnSortModelChange,
26445
26457
  pinnedCustomColumns,
26446
- useRouter: useRouter
26458
+ useRouter: useRouter,
26459
+ localStorageVersion
26447
26460
  });
26448
26461
  const [selectionModel, setSelectionModel] = useState(propsSelectionModel !== null && propsSelectionModel !== void 0 ? propsSelectionModel : []);
26449
26462
  useEffect(() => {