@redsift/table 11.0.0-alpha.2 → 11.0.0-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
@@ -156,6 +156,8 @@ interface StatefulDataGridProps extends DataGridProps {
156
156
  };
157
157
  /** Pinned custom columns. */
158
158
  pinnedCustomColumns?: Required<GridPinnedColumns>;
159
+ /** Local Storage version, to upgrade when we want to force a clean out. */
160
+ localStorageVersion?: number;
159
161
  }
160
162
 
161
163
  declare const StatefulDataGrid: Comp<StatefulDataGridProps, HTMLDivElement>;
package/index.js CHANGED
@@ -18081,7 +18081,7 @@ const listOperators = ['containsAnyOf', 'endsWithAnyOf', 'isAnyOf', 'isNotAnyOf'
18081
18081
  const isValueValid = (value, field, columns, operator) => {
18082
18082
  var _column$type;
18083
18083
  // every field accepts undefined as value for default
18084
- if (value === undefined) {
18084
+ if (value === undefined || value === '') {
18085
18085
  return true;
18086
18086
  }
18087
18087
 
@@ -18139,7 +18139,7 @@ const getFilterModelFromString = (searchString, columns) => {
18139
18139
  let logicOperator = GridLogicOperator.And;
18140
18140
  const searchParams = new URLSearchParams();
18141
18141
  for (const [key, value] of new URLSearchParams(searchString)) {
18142
- if (key.startsWith('_') && !['_logicOperator', '_sortColumn', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_columnVisibility'].includes(key)) {
18142
+ if (key.startsWith('_') && !['_logicOperator', '_sortColumn', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_columnVisibility', '_pagination'].includes(key)) {
18143
18143
  searchParams.set(key, value);
18144
18144
  }
18145
18145
  if (key === '_logicOperator') {
@@ -26126,7 +26126,6 @@ const useTableStates = (id, version, customDefaults) => {
26126
26126
  };
26127
26127
  };
26128
26128
 
26129
- const DATAGRID_VERSION = 1;
26130
26129
  const useStatefulTable = props => {
26131
26130
  const {
26132
26131
  // density = 'standard',
@@ -26143,7 +26142,7 @@ const useStatefulTable = props => {
26143
26142
  right: []
26144
26143
  },
26145
26144
  useRouter,
26146
- version = DATAGRID_VERSION
26145
+ localStorageVersion = 1
26147
26146
  } = props;
26148
26147
  const {
26149
26148
  search,
@@ -26171,10 +26170,10 @@ const useStatefulTable = props => {
26171
26170
  setPinnedColumns,
26172
26171
  dimensionModel,
26173
26172
  setDimensionModel
26174
- } = useTableStates(id, version, customDefaults);
26173
+ } = useTableStates(id, localStorageVersion, customDefaults);
26175
26174
 
26176
26175
  // clearing up old version keys, triggering only on first render
26177
- useEffect(() => clearPreviousVersionStorage(id, version), [id, version]);
26176
+ useEffect(() => clearPreviousVersionStorage(id, localStorageVersion), [id, localStorageVersion]);
26178
26177
  const onColumnDimensionChange = useCallback(_ref => {
26179
26178
  let {
26180
26179
  newWidth,
@@ -26206,16 +26205,18 @@ const useStatefulTable = props => {
26206
26205
  column.width = dimensionModel[column.field] || column.width || 100;
26207
26206
  return column;
26208
26207
  }), [propsColumns, dimensionModel]);
26208
+ /** Add resetPage method to apiRef. */
26209
+ apiRef.current.resetPage = () => {
26210
+ apiRef.current.setPage(0);
26211
+ };
26209
26212
  return {
26210
26213
  apiRef,
26211
26214
  columns,
26212
26215
  onFilterModelChange: (model, details) => {
26213
26216
  const filterModel = _objectSpread2(_objectSpread2({}, model), {}, {
26214
26217
  items: model.items.map(item => {
26215
- if (!item.type) {
26216
- const column = apiRef.current.getColumn(item.field);
26217
- item.type = column.type || 'string';
26218
- }
26218
+ const column = apiRef.current.getColumn(item.field);
26219
+ item.type = column.type || 'string';
26219
26220
  return item;
26220
26221
  })
26221
26222
  });
@@ -26286,7 +26287,7 @@ const useStatefulTable = props => {
26286
26287
  };
26287
26288
  };
26288
26289
 
26289
- const _excluded$1 = ["apiRef", "autoHeight", "className", "columns", "slots", "slotProps", "filterModel", "columnVisibilityModel", "pinnedColumns", "sortModel", "paginationModel", "height", "hideToolbar", "initialState", "isRowSelectable", "license", "onFilterModelChange", "rowSelectionModel", "onColumnWidthChange", "onPaginationModelChange", "onRowSelectionModelChange", "onColumnVisibilityModelChange", "onPinnedColumnsChange", "onSortModelChange", "pagination", "paginationPlacement", "paginationProps", "pinnedCustomColumns", "rows", "pageSizeOptions", "sx", "theme", "useRouter", "paginationMode", "rowCount"];
26290
+ const _excluded$1 = ["apiRef", "autoHeight", "className", "columns", "slots", "slotProps", "filterModel", "columnVisibilityModel", "pinnedColumns", "sortModel", "paginationModel", "height", "hideToolbar", "initialState", "isRowSelectable", "license", "localStorageVersion", "onFilterModelChange", "rowSelectionModel", "onColumnWidthChange", "onPaginationModelChange", "onRowSelectionModelChange", "onColumnVisibilityModelChange", "onPinnedColumnsChange", "onSortModelChange", "pagination", "paginationPlacement", "paginationProps", "pinnedCustomColumns", "rows", "pageSizeOptions", "sx", "theme", "useRouter", "paginationMode", "rowCount"];
26290
26291
  const COMPONENT_NAME$1 = 'DataGrid';
26291
26292
  const CLASSNAME$1 = 'redsift-datagrid';
26292
26293
  const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
@@ -26308,6 +26309,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
26308
26309
  initialState,
26309
26310
  isRowSelectable,
26310
26311
  license = process.env.MUI_LICENSE_KEY,
26312
+ localStorageVersion,
26311
26313
  onFilterModelChange: propsOnFilterModelChange,
26312
26314
  rowSelectionModel: propsSelectionModel,
26313
26315
  onColumnWidthChange: propsOnColumnWidthChange,
@@ -26377,7 +26379,8 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
26377
26379
  onPinnedColumnsChange: controlledOnPinnedColumnsChange,
26378
26380
  onSortModelChange: controlledOnSortModelChange,
26379
26381
  pinnedCustomColumns,
26380
- useRouter: useRouter
26382
+ useRouter: useRouter,
26383
+ localStorageVersion
26381
26384
  });
26382
26385
  const [rowSelectionModel, setRowSelectionModel] = useState(propsSelectionModel !== null && propsSelectionModel !== void 0 ? propsSelectionModel : []);
26383
26386
  useEffect(() => {