@snack-uikit/table 0.37.5 → 0.37.6

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 0.37.6 (2025-09-11)
7
+
8
+
9
+ ### Dependencies
10
+
11
+ * **FF-7214:** up eslint ssr plugin ([2fbc38b](https://github.com/cloud-ru-tech/snack-uikit/commit/2fbc38b0dc78d953f638c8ddd5b20620c826178d))
12
+
13
+
14
+
15
+
16
+
6
17
  ## 0.37.5 (2025-09-10)
7
18
 
8
19
  ### Only dependencies have been changed
package/README.md CHANGED
@@ -109,6 +109,8 @@ const columnDefinitions: ColumnDefinition<TableData>[] = [
109
109
  ### Props
110
110
  | name | type | default value | description |
111
111
  |------|------|---------------|-------------|
112
+ | search | `string` | - | |
113
+ | filter | `FiltersState` | - | |
112
114
  | pagination | `PaginationState \| PaginationParams` | - | |
113
115
  | sorting | `SortingState` | - | |
114
116
  ## Table
@@ -8,6 +8,7 @@ const core_1 = require("@dnd-kit/core");
8
8
  const modifiers_1 = require("@dnd-kit/modifiers");
9
9
  const sortable_1 = require("@dnd-kit/sortable");
10
10
  const react_1 = require("react");
11
+ const utils_1 = require("@snack-uikit/utils");
11
12
  const prepareInitialState_1 = require("./utils/prepareInitialState");
12
13
  const draggingOptions = {
13
14
  activationConstraint: {
@@ -28,7 +29,7 @@ function useColumnOrderByDrag(_ref) {
28
29
  } else {
29
30
  updatedOrder = value;
30
31
  }
31
- if (savedState === null || savedState === void 0 ? void 0 : savedState.columnSettings) {
32
+ if ((savedState === null || savedState === void 0 ? void 0 : savedState.columnSettings) && (0, utils_1.isBrowser)()) {
32
33
  localStorage.setItem((0, prepareInitialState_1.getLocalStorageColumnOrderKey)(savedState.id), JSON.stringify(updatedOrder));
33
34
  }
34
35
  setColumnOrderState(updatedOrder);
@@ -5,14 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getLocalStorageColumnOrderKey = void 0;
7
7
  exports.prepareInitialState = prepareInitialState;
8
- const utils_1 = require("../../../utils");
8
+ const utils_1 = require("@snack-uikit/utils");
9
+ const utils_2 = require("../../../utils");
9
10
  const getLocalStorageColumnOrderKey = id => `${id}_columnOrder`;
10
11
  exports.getLocalStorageColumnOrderKey = getLocalStorageColumnOrderKey;
11
12
  function prepareInitialState(tableColumns, savedState) {
12
- const columnOrder = tableColumns.filter(column => column.pinned !== 'left' && column.pinned !== 'right').map(utils_1.getColumnIdentifier);
13
- if (savedState === null || savedState === void 0 ? void 0 : savedState.columnSettings) {
13
+ const columnOrder = tableColumns.filter(column => column.pinned !== 'left' && column.pinned !== 'right').map(utils_2.getColumnIdentifier);
14
+ if ((savedState === null || savedState === void 0 ? void 0 : savedState.columnSettings) && (0, utils_1.isBrowser)()) {
14
15
  const persistState = JSON.parse(localStorage.getItem((0, exports.getLocalStorageColumnOrderKey)(savedState.id)) || 'null');
15
- const persistValue = (0, utils_1.isEveryArrayItemString)(persistState) ? persistState : null;
16
+ const persistValue = (0, utils_2.isEveryArrayItemString)(persistState) ? persistState : null;
16
17
  if (persistValue !== null) {
17
18
  return [...persistValue, ...columnOrder.filter(column => !(persistValue === null || persistValue === void 0 ? void 0 : persistValue.includes(column)))];
18
19
  }
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useColumnSettings = useColumnSettings;
7
7
  const react_1 = require("react");
8
8
  const locale_1 = require("@snack-uikit/locale");
9
- const utils_1 = require("../../utils");
10
- const utils_2 = require("./utils");
9
+ const utils_1 = require("@snack-uikit/utils");
10
+ const utils_2 = require("../../utils");
11
+ const utils_3 = require("./utils");
11
12
  function useColumnSettings(_ref) {
12
13
  let {
13
14
  columnDefinitions,
@@ -22,10 +23,10 @@ function useColumnSettings(_ref) {
22
23
  t
23
24
  } = (0, locale_1.useLocale)('Table');
24
25
  const localStorageKey = `${savedState === null || savedState === void 0 ? void 0 : savedState.id}_columnSettings`;
25
- const configurableColumns = (0, react_1.useMemo)(() => columnDefinitions.filter(utils_2.isColumnVisibilityConfigurable), [columnDefinitions]);
26
- const [enabledColumns, setEnabledColumns] = (0, react_1.useState)(() => (0, utils_2.getEnabledColumnsInitialState)(configurableColumns, savedState, localStorageKey));
26
+ const configurableColumns = (0, react_1.useMemo)(() => columnDefinitions.filter(utils_3.isColumnVisibilityConfigurable), [columnDefinitions]);
27
+ const [enabledColumns, setEnabledColumns] = (0, react_1.useState)(() => (0, utils_3.getEnabledColumnsInitialState)(configurableColumns, savedState, localStorageKey));
27
28
  const setEnabledColumnsOuter = (0, react_1.useCallback)(value => {
28
- if (savedState === null || savedState === void 0 ? void 0 : savedState.columnSettings) {
29
+ if ((savedState === null || savedState === void 0 ? void 0 : savedState.columnSettings) && (0, utils_1.isBrowser)()) {
29
30
  localStorage.setItem(localStorageKey, JSON.stringify(value));
30
31
  }
31
32
  setEnabledColumns(value);
@@ -36,21 +37,21 @@ function useColumnSettings(_ref) {
36
37
  return columnDefinitions;
37
38
  }
38
39
  return columnDefinitions.filter(colDef => {
39
- if ((0, utils_2.isFilterableColumn)(colDef)) {
40
- return enabledColumns.includes((0, utils_1.getColumnIdentifier)(colDef));
40
+ if ((0, utils_3.isFilterableColumn)(colDef)) {
41
+ return enabledColumns.includes((0, utils_2.getColumnIdentifier)(colDef));
41
42
  }
42
43
  return true;
43
44
  });
44
45
  }, [columnDefinitions, enabledColumns, areColumnsSettingsEnabled]);
45
46
  const enableSelection = Boolean(rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.enable);
46
- const enabledTableColumns = (0, react_1.useMemo)(() => (0, utils_1.getTableColumnsDefinitions)({
47
+ const enabledTableColumns = (0, react_1.useMemo)(() => (0, utils_2.getTableColumnsDefinitions)({
47
48
  columnDefinitions: enabledColumnsDefinitions,
48
49
  enableSelection,
49
50
  enableSelectPinned,
50
51
  expanding
51
52
  }), [enableSelectPinned, enableSelection, enabledColumnsDefinitions, expanding]);
52
53
  const areAllColumnsEnabled = enabledColumns.length === configurableColumns.length;
53
- const getColumnsSettings = (0, react_1.useCallback)(columnOrder => (0, utils_2.prepareColumnsSettings)({
54
+ const getColumnsSettings = (0, react_1.useCallback)(columnOrder => (0, utils_3.prepareColumnsSettings)({
54
55
  pinnedGroups,
55
56
  columnOrder,
56
57
  areAllColumnsEnabled,
@@ -4,19 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getEnabledColumnsInitialState = getEnabledColumnsInitialState;
7
- const utils_1 = require("../../../utils");
7
+ const utils_1 = require("@snack-uikit/utils");
8
+ const utils_2 = require("../../../utils");
8
9
  const isColumnEnabledInitially_1 = require("./isColumnEnabledInitially");
9
10
  function getSettingsFromLocalStorage(localStorageKey) {
10
- const localStorageState = JSON.parse(localStorage.getItem(localStorageKey) || 'null');
11
- return (0, utils_1.isEveryArrayItemString)(localStorageState) ? localStorageState : null;
11
+ if ((0, utils_1.isBrowser)()) {
12
+ const localStorageState = JSON.parse(localStorage.getItem(localStorageKey) || 'null');
13
+ return (0, utils_2.isEveryArrayItemString)(localStorageState) ? localStorageState : null;
14
+ }
15
+ return null;
12
16
  }
13
17
  function getEnabledColumnsInitialState(configurableColumns, savedState, localStorageKey) {
14
18
  const localStorageSettings = getSettingsFromLocalStorage(localStorageKey);
15
19
  return configurableColumns.filter(colDef => {
16
- const columnIdentifier = (0, utils_1.getColumnIdentifier)(colDef);
20
+ const columnIdentifier = (0, utils_2.getColumnIdentifier)(colDef);
17
21
  if (localStorageSettings && (savedState === null || savedState === void 0 ? void 0 : savedState.columnSettings)) {
18
22
  return Boolean(localStorageSettings.find(columnKey => columnKey === columnIdentifier));
19
23
  }
20
24
  return (0, isColumnEnabledInitially_1.isColumnEnabledInitially)(colDef);
21
- }).map(utils_1.getColumnIdentifier);
25
+ }).map(utils_2.getColumnIdentifier);
22
26
  }
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getInitColumnSizeFromLocalStorage = getInitColumnSizeFromLocalStorage;
7
7
  exports.saveStateToLocalStorage = saveStateToLocalStorage;
8
+ const utils_1 = require("@snack-uikit/utils");
8
9
  const RESIZED_KEY = 'RESIZED_COLUMN_KEY';
9
10
  function getInitColumnSizeFromLocalStorage(_ref) {
10
11
  let {
@@ -12,11 +13,13 @@ function getInitColumnSizeFromLocalStorage(_ref) {
12
13
  columnId
13
14
  } = _ref;
14
15
  var _a;
15
- const savedStateFromStorage = JSON.parse(localStorage.getItem(id || '') || 'null');
16
- if (!savedStateFromStorage) {
17
- return;
16
+ if ((0, utils_1.isBrowser)()) {
17
+ const savedStateFromStorage = JSON.parse(localStorage.getItem(id || '') || 'null');
18
+ if (!savedStateFromStorage) {
19
+ return;
20
+ }
21
+ return (_a = savedStateFromStorage.resizeState) === null || _a === void 0 ? void 0 : _a[`${RESIZED_KEY}-${columnId}`];
18
22
  }
19
- return (_a = savedStateFromStorage.resizeState) === null || _a === void 0 ? void 0 : _a[`${RESIZED_KEY}-${columnId}`];
20
23
  }
21
24
  function saveStateToLocalStorage(_ref2) {
22
25
  let {
@@ -24,10 +27,12 @@ function saveStateToLocalStorage(_ref2) {
24
27
  columnId,
25
28
  size
26
29
  } = _ref2;
27
- const savedStateFromStorage = JSON.parse(localStorage.getItem(id) || 'null');
28
- const newResizeState = (savedStateFromStorage === null || savedStateFromStorage === void 0 ? void 0 : savedStateFromStorage.resizeState) || {};
29
- newResizeState[`${RESIZED_KEY}-${columnId}`] = size;
30
- localStorage.setItem(id, JSON.stringify(Object.assign(Object.assign({}, savedStateFromStorage || {}), {
31
- resizeState: newResizeState
32
- })));
30
+ if ((0, utils_1.isBrowser)()) {
31
+ const savedStateFromStorage = JSON.parse(localStorage.getItem(id) || 'null');
32
+ const newResizeState = (savedStateFromStorage === null || savedStateFromStorage === void 0 ? void 0 : savedStateFromStorage.resizeState) || {};
33
+ newResizeState[`${RESIZED_KEY}-${columnId}`] = size;
34
+ localStorage.setItem(id, JSON.stringify(Object.assign(Object.assign({}, savedStateFromStorage || {}), {
35
+ resizeState: newResizeState
36
+ })));
37
+ }
33
38
  }
@@ -2,6 +2,7 @@ import { closestCenter, KeyboardSensor, MouseSensor, TouchSensor, useSensor, use
2
2
  import { restrictToHorizontalAxis } from '@dnd-kit/modifiers';
3
3
  import { arrayMove } from '@dnd-kit/sortable';
4
4
  import { useCallback, useMemo, useState } from 'react';
5
+ import { isBrowser } from '@snack-uikit/utils';
5
6
  import { getLocalStorageColumnOrderKey, prepareInitialState } from './utils/prepareInitialState';
6
7
  const draggingOptions = {
7
8
  activationConstraint: {
@@ -18,7 +19,7 @@ export function useColumnOrderByDrag({ tableColumns, savedState, columnSettings,
18
19
  else {
19
20
  updatedOrder = value;
20
21
  }
21
- if (savedState === null || savedState === void 0 ? void 0 : savedState.columnSettings) {
22
+ if ((savedState === null || savedState === void 0 ? void 0 : savedState.columnSettings) && isBrowser()) {
22
23
  localStorage.setItem(getLocalStorageColumnOrderKey(savedState.id), JSON.stringify(updatedOrder));
23
24
  }
24
25
  setColumnOrderState(updatedOrder);
@@ -1,10 +1,11 @@
1
+ import { isBrowser } from '@snack-uikit/utils';
1
2
  import { getColumnIdentifier, isEveryArrayItemString } from '../../../utils';
2
3
  export const getLocalStorageColumnOrderKey = (id) => `${id}_columnOrder`;
3
4
  export function prepareInitialState(tableColumns, savedState) {
4
5
  const columnOrder = tableColumns
5
6
  .filter(column => column.pinned !== 'left' && column.pinned !== 'right')
6
7
  .map(getColumnIdentifier);
7
- if (savedState === null || savedState === void 0 ? void 0 : savedState.columnSettings) {
8
+ if ((savedState === null || savedState === void 0 ? void 0 : savedState.columnSettings) && isBrowser()) {
8
9
  const persistState = JSON.parse(localStorage.getItem(getLocalStorageColumnOrderKey(savedState.id)) || 'null');
9
10
  const persistValue = isEveryArrayItemString(persistState) ? persistState : null;
10
11
  if (persistValue !== null) {
@@ -1,5 +1,6 @@
1
1
  import { useCallback, useMemo, useState } from 'react';
2
2
  import { useLocale } from '@snack-uikit/locale';
3
+ import { isBrowser } from '@snack-uikit/utils';
3
4
  import { getColumnIdentifier, getTableColumnsDefinitions } from '../../utils';
4
5
  import { getEnabledColumnsInitialState, isColumnVisibilityConfigurable, isFilterableColumn, prepareColumnsSettings, } from './utils';
5
6
  export function useColumnSettings({ columnDefinitions, columnsSettings, pinnedGroups, savedState, rowSelection, enableSelectPinned, expanding, }) {
@@ -8,7 +9,7 @@ export function useColumnSettings({ columnDefinitions, columnsSettings, pinnedGr
8
9
  const configurableColumns = useMemo(() => columnDefinitions.filter(isColumnVisibilityConfigurable), [columnDefinitions]);
9
10
  const [enabledColumns, setEnabledColumns] = useState(() => getEnabledColumnsInitialState(configurableColumns, savedState, localStorageKey));
10
11
  const setEnabledColumnsOuter = useCallback((value) => {
11
- if (savedState === null || savedState === void 0 ? void 0 : savedState.columnSettings) {
12
+ if ((savedState === null || savedState === void 0 ? void 0 : savedState.columnSettings) && isBrowser()) {
12
13
  localStorage.setItem(localStorageKey, JSON.stringify(value));
13
14
  }
14
15
  setEnabledColumns(value);
@@ -1,8 +1,12 @@
1
+ import { isBrowser } from '@snack-uikit/utils';
1
2
  import { getColumnIdentifier, isEveryArrayItemString } from '../../../utils';
2
3
  import { isColumnEnabledInitially } from './isColumnEnabledInitially';
3
4
  function getSettingsFromLocalStorage(localStorageKey) {
4
- const localStorageState = JSON.parse(localStorage.getItem(localStorageKey) || 'null');
5
- return isEveryArrayItemString(localStorageState) ? localStorageState : null;
5
+ if (isBrowser()) {
6
+ const localStorageState = JSON.parse(localStorage.getItem(localStorageKey) || 'null');
7
+ return isEveryArrayItemString(localStorageState) ? localStorageState : null;
8
+ }
9
+ return null;
6
10
  }
7
11
  export function getEnabledColumnsInitialState(configurableColumns, savedState, localStorageKey) {
8
12
  const localStorageSettings = getSettingsFromLocalStorage(localStorageKey);
@@ -1,15 +1,20 @@
1
+ import { isBrowser } from '@snack-uikit/utils';
1
2
  const RESIZED_KEY = 'RESIZED_COLUMN_KEY';
2
3
  export function getInitColumnSizeFromLocalStorage({ id, columnId, }) {
3
4
  var _a;
4
- const savedStateFromStorage = JSON.parse(localStorage.getItem(id || '') || 'null');
5
- if (!savedStateFromStorage) {
6
- return;
5
+ if (isBrowser()) {
6
+ const savedStateFromStorage = JSON.parse(localStorage.getItem(id || '') || 'null');
7
+ if (!savedStateFromStorage) {
8
+ return;
9
+ }
10
+ return (_a = savedStateFromStorage.resizeState) === null || _a === void 0 ? void 0 : _a[`${RESIZED_KEY}-${columnId}`];
7
11
  }
8
- return (_a = savedStateFromStorage.resizeState) === null || _a === void 0 ? void 0 : _a[`${RESIZED_KEY}-${columnId}`];
9
12
  }
10
13
  export function saveStateToLocalStorage({ id, columnId, size }) {
11
- const savedStateFromStorage = JSON.parse(localStorage.getItem(id) || 'null');
12
- const newResizeState = (savedStateFromStorage === null || savedStateFromStorage === void 0 ? void 0 : savedStateFromStorage.resizeState) || {};
13
- newResizeState[`${RESIZED_KEY}-${columnId}`] = size;
14
- localStorage.setItem(id, JSON.stringify(Object.assign(Object.assign({}, (savedStateFromStorage || {})), { resizeState: newResizeState })));
14
+ if (isBrowser()) {
15
+ const savedStateFromStorage = JSON.parse(localStorage.getItem(id) || 'null');
16
+ const newResizeState = (savedStateFromStorage === null || savedStateFromStorage === void 0 ? void 0 : savedStateFromStorage.resizeState) || {};
17
+ newResizeState[`${RESIZED_KEY}-${columnId}`] = size;
18
+ localStorage.setItem(id, JSON.stringify(Object.assign(Object.assign({}, (savedStateFromStorage || {})), { resizeState: newResizeState })));
19
+ }
15
20
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Table",
7
- "version": "0.37.5",
7
+ "version": "0.37.6",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -66,5 +66,5 @@
66
66
  "peerDependencies": {
67
67
  "@snack-uikit/locale": "*"
68
68
  },
69
- "gitHead": "52e8255973ff9c525da7463937b674772dd0f710"
69
+ "gitHead": "2e88e675144c48f37ba65d9cdf8cc04da7ebda8e"
70
70
  }
@@ -13,6 +13,8 @@ import { restrictToHorizontalAxis } from '@dnd-kit/modifiers';
13
13
  import { arrayMove } from '@dnd-kit/sortable';
14
14
  import { Dispatch, SetStateAction, useCallback, useMemo, useState } from 'react';
15
15
 
16
+ import { isBrowser } from '@snack-uikit/utils';
17
+
16
18
  import { ColumnDefinition } from '../../../../types';
17
19
  import { TableProps } from '../../../types';
18
20
  import { getLocalStorageColumnOrderKey, prepareInitialState } from './utils/prepareInitialState';
@@ -46,7 +48,7 @@ export function useColumnOrderByDrag<TData extends object>({
46
48
  updatedOrder = value;
47
49
  }
48
50
 
49
- if (savedState?.columnSettings) {
51
+ if (savedState?.columnSettings && isBrowser()) {
50
52
  localStorage.setItem(getLocalStorageColumnOrderKey(savedState.id), JSON.stringify(updatedOrder));
51
53
  }
52
54
 
@@ -1,3 +1,5 @@
1
+ import { isBrowser } from '@snack-uikit/utils';
2
+
1
3
  import { ColumnDefinition } from '../../../../../types';
2
4
  import { TableProps } from '../../../../types';
3
5
  import { getColumnIdentifier, isEveryArrayItemString } from '../../../utils';
@@ -12,7 +14,7 @@ export function prepareInitialState<TData extends object>(
12
14
  .filter(column => column.pinned !== 'left' && column.pinned !== 'right')
13
15
  .map(getColumnIdentifier);
14
16
 
15
- if (savedState?.columnSettings) {
17
+ if (savedState?.columnSettings && isBrowser()) {
16
18
  const persistState = JSON.parse(localStorage.getItem(getLocalStorageColumnOrderKey(savedState.id)) || 'null');
17
19
  const persistValue: string[] | null = isEveryArrayItemString(persistState) ? persistState : null;
18
20
 
@@ -1,6 +1,7 @@
1
1
  import { useCallback, useMemo, useState } from 'react';
2
2
 
3
3
  import { useLocale } from '@snack-uikit/locale';
4
+ import { isBrowser } from '@snack-uikit/utils';
4
5
 
5
6
  import { TableProps } from '../../../types';
6
7
  import { getColumnIdentifier, getTableColumnsDefinitions, PinnedGroupsState } from '../../utils';
@@ -41,7 +42,7 @@ export function useColumnSettings<TData extends object, TFilters extends Record<
41
42
 
42
43
  const setEnabledColumnsOuter = useCallback(
43
44
  (value: string[]) => {
44
- if (savedState?.columnSettings) {
45
+ if (savedState?.columnSettings && isBrowser()) {
45
46
  localStorage.setItem(localStorageKey, JSON.stringify(value));
46
47
  }
47
48
 
@@ -1,11 +1,17 @@
1
+ import { isBrowser } from '@snack-uikit/utils';
2
+
1
3
  import { ColumnDefinition } from '../../../../../types';
2
4
  import { TableProps } from '../../../../types';
3
5
  import { getColumnIdentifier, isEveryArrayItemString } from '../../../utils';
4
6
  import { isColumnEnabledInitially } from './isColumnEnabledInitially';
5
7
 
6
8
  function getSettingsFromLocalStorage(localStorageKey: string): string[] | null {
7
- const localStorageState = JSON.parse(localStorage.getItem(localStorageKey) || 'null');
8
- return isEveryArrayItemString(localStorageState) ? localStorageState : null;
9
+ if (isBrowser()) {
10
+ const localStorageState = JSON.parse(localStorage.getItem(localStorageKey) || 'null');
11
+ return isEveryArrayItemString(localStorageState) ? localStorageState : null;
12
+ }
13
+
14
+ return null;
9
15
  }
10
16
 
11
17
  export function getEnabledColumnsInitialState<TData extends object, TFilters extends Record<string, unknown>>(
@@ -1,3 +1,5 @@
1
+ import { isBrowser } from '@snack-uikit/utils';
2
+
1
3
  const RESIZED_KEY = 'RESIZED_COLUMN_KEY';
2
4
 
3
5
  type SavedState = {
@@ -13,13 +15,15 @@ export function getInitColumnSizeFromLocalStorage({
13
15
  id,
14
16
  columnId,
15
17
  }: GetSavedStateFromLocalStorageProps): string | undefined {
16
- const savedStateFromStorage: SavedState | null = JSON.parse(localStorage.getItem(id || '') || 'null');
18
+ if (isBrowser()) {
19
+ const savedStateFromStorage: SavedState | null = JSON.parse(localStorage.getItem(id || '') || 'null');
17
20
 
18
- if (!savedStateFromStorage) {
19
- return;
20
- }
21
+ if (!savedStateFromStorage) {
22
+ return;
23
+ }
21
24
 
22
- return savedStateFromStorage.resizeState?.[`${RESIZED_KEY}-${columnId}`];
25
+ return savedStateFromStorage.resizeState?.[`${RESIZED_KEY}-${columnId}`];
26
+ }
23
27
  }
24
28
 
25
29
  type SaveStateToLocalStorageProps = {
@@ -29,10 +33,12 @@ type SaveStateToLocalStorageProps = {
29
33
  };
30
34
 
31
35
  export function saveStateToLocalStorage({ id, columnId, size }: SaveStateToLocalStorageProps) {
32
- const savedStateFromStorage: SavedState | null = JSON.parse(localStorage.getItem(id) || 'null');
36
+ if (isBrowser()) {
37
+ const savedStateFromStorage: SavedState | null = JSON.parse(localStorage.getItem(id) || 'null');
33
38
 
34
- const newResizeState: Record<string, string> = savedStateFromStorage?.resizeState || {};
35
- newResizeState[`${RESIZED_KEY}-${columnId}`] = size;
39
+ const newResizeState: Record<string, string> = savedStateFromStorage?.resizeState || {};
40
+ newResizeState[`${RESIZED_KEY}-${columnId}`] = size;
36
41
 
37
- localStorage.setItem(id, JSON.stringify({ ...(savedStateFromStorage || {}), resizeState: newResizeState }));
42
+ localStorage.setItem(id, JSON.stringify({ ...(savedStateFromStorage || {}), resizeState: newResizeState }));
43
+ }
38
44
  }