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

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
@@ -26167,7 +26167,6 @@ const useTableStates = (id, version, customDefaults) => {
26167
26167
  };
26168
26168
  };
26169
26169
 
26170
- const DATAGRID_VERSION = 1;
26171
26170
  const useStatefulTable = props => {
26172
26171
  const {
26173
26172
  // density = 'standard',
@@ -26185,7 +26184,7 @@ const useStatefulTable = props => {
26185
26184
  right: []
26186
26185
  },
26187
26186
  useRouter,
26188
- version = DATAGRID_VERSION
26187
+ localStorageVersion = 1
26189
26188
  } = props;
26190
26189
  const {
26191
26190
  search,
@@ -26213,10 +26212,10 @@ const useStatefulTable = props => {
26213
26212
  setPinnedColumns,
26214
26213
  dimensionModel,
26215
26214
  setDimensionModel
26216
- } = useTableStates(id, version, customDefaults);
26215
+ } = useTableStates(id, localStorageVersion, customDefaults);
26217
26216
 
26218
26217
  // clearing up old version keys, triggering only on first render
26219
- useEffect(() => clearPreviousVersionStorage(id, version), [id, version]);
26218
+ useEffect(() => clearPreviousVersionStorage(id, localStorageVersion), [id, localStorageVersion]);
26220
26219
  const onColumnDimensionChange = useCallback(_ref => {
26221
26220
  let {
26222
26221
  newWidth,
@@ -26248,6 +26247,11 @@ const useStatefulTable = props => {
26248
26247
  column.width = dimensionModel[column.field] || column.width || 100;
26249
26248
  return column;
26250
26249
  }), [propsColumns, dimensionModel]);
26250
+
26251
+ /** Add resetPage method to apiRef. */
26252
+ apiRef.current.resetPage = () => {
26253
+ apiRef.current.setPage(0);
26254
+ };
26251
26255
  return {
26252
26256
  apiRef,
26253
26257
  columns,
@@ -26343,7 +26347,7 @@ const useStatefulTable = props => {
26343
26347
  };
26344
26348
  };
26345
26349
 
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"];
26350
+ 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
26351
  const COMPONENT_NAME$1 = 'DataGrid';
26348
26352
  const CLASSNAME$1 = 'redsift-datagrid';
26349
26353
  const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
@@ -26367,6 +26371,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
26367
26371
  initialState,
26368
26372
  isRowSelectable,
26369
26373
  license = process.env.MUI_LICENSE_KEY,
26374
+ localStorageVersion,
26370
26375
  onFilterModelChange: propsOnFilterModelChange,
26371
26376
  selectionModel: propsSelectionModel,
26372
26377
  onColumnWidthChange: propsOnColumnWidthChange,
@@ -26443,7 +26448,8 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
26443
26448
  onPinnedColumnsChange: controlledOnPinnedColumnsChange,
26444
26449
  onSortModelChange: controlledOnSortModelChange,
26445
26450
  pinnedCustomColumns,
26446
- useRouter: useRouter
26451
+ useRouter: useRouter,
26452
+ localStorageVersion
26447
26453
  });
26448
26454
  const [selectionModel, setSelectionModel] = useState(propsSelectionModel !== null && propsSelectionModel !== void 0 ? propsSelectionModel : []);
26449
26455
  useEffect(() => {