@snack-uikit/table 0.36.9 → 0.36.10

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.36.10 (2025-06-19)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **FF-0000:** table state control ([4059c7b](https://github.com/cloud-ru-tech/snack-uikit/commit/4059c7bb77e37cf1bb761583db960f93e0e24abb))
12
+
13
+
14
+
15
+
16
+
6
17
  ## 0.36.9 (2025-06-16)
7
18
 
8
19
 
@@ -224,13 +224,7 @@ function Table(_a) {
224
224
  globalFilterFn: enableFuzzySearch ? utils_2.fuzzyFilter : 'includesString',
225
225
  onGlobalFilterChange,
226
226
  getRowId,
227
- onRowSelectionChange: updater => {
228
- if (typeof updater === 'function') {
229
- onRowSelectionChange(updater(rowSelection));
230
- } else {
231
- onRowSelectionChange(updater);
232
- }
233
- },
227
+ onRowSelectionChange,
234
228
  enableGrouping: true,
235
229
  enableRowSelection,
236
230
  enableMultiRowSelection: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow,
@@ -2,12 +2,12 @@ import { TableProps } from '../../../types';
2
2
  type useFiltersProps<TData extends object, TFilters extends Record<string, unknown>> = Pick<TableProps<TData, TFilters>, 'columnFilters'>;
3
3
  export declare function useFilters<TData extends object, TFilters extends Record<string, unknown>>({ columnFilters, }: useFiltersProps<TData, TFilters>): {
4
4
  filter: TFilters | undefined;
5
- setFilter: import("uncontrollable").Handler;
5
+ setFilter: import("@tanstack/react-table").OnChangeFn<TFilters | undefined>;
6
6
  patchedFilter: {
7
7
  value: TFilters | undefined;
8
- onChange: import("uncontrollable").Handler;
8
+ onChange: (filter: TFilters) => void;
9
9
  visibleFilters: string[];
10
- onVisibleFiltersChange: import("uncontrollable").Handler;
10
+ onVisibleFiltersChange: import("@tanstack/react-table").OnChangeFn<string[]>;
11
11
  className?: string;
12
12
  "aria-activedescendant"?: string | undefined;
13
13
  "aria-atomic"?: (boolean | "true" | "false") | undefined;
@@ -70,6 +70,6 @@ export declare function useFilters<TData extends object, TFilters extends Record
70
70
  onOpenChange: (isOpen: boolean) => void;
71
71
  initialOpen?: boolean;
72
72
  } | undefined;
73
- setFilterVisibility: import("uncontrollable").Handler;
73
+ setFilterVisibility: import("@tanstack/react-table").OnChangeFn<string[]>;
74
74
  };
75
75
  export {};
@@ -1,5 +1,6 @@
1
- export declare function useStateControl<TState>(control: {
1
+ import { OnChangeFn } from '@tanstack/react-table';
2
+ export declare function useStateControl<TState extends object | string | number | boolean | undefined>(control: {
2
3
  initialState?: TState;
3
4
  state?: TState;
4
5
  onChange?(state: TState): void;
5
- } | undefined, defaultState: TState): readonly [TState, import("uncontrollable").Handler];
6
+ } | undefined, defaultState: TState): readonly [TState, OnChangeFn<TState>];
@@ -7,5 +7,13 @@ exports.useStateControl = useStateControl;
7
7
  const uncontrollable_1 = require("uncontrollable");
8
8
  function useStateControl(control, defaultState) {
9
9
  var _a, _b;
10
- return (0, uncontrollable_1.useUncontrolledProp)(control === null || control === void 0 ? void 0 : control.state, (_b = (_a = control === null || control === void 0 ? void 0 : control.state) !== null && _a !== void 0 ? _a : control === null || control === void 0 ? void 0 : control.initialState) !== null && _b !== void 0 ? _b : defaultState, control === null || control === void 0 ? void 0 : control.onChange);
10
+ const [state, setState] = (0, uncontrollable_1.useUncontrolledProp)(control === null || control === void 0 ? void 0 : control.state, (_b = (_a = control === null || control === void 0 ? void 0 : control.state) !== null && _a !== void 0 ? _a : control === null || control === void 0 ? void 0 : control.initialState) !== null && _b !== void 0 ? _b : defaultState, control === null || control === void 0 ? void 0 : control.onChange);
11
+ const onChangeFunction = updater => {
12
+ if (typeof updater === 'function') {
13
+ setState(updater(state));
14
+ } else {
15
+ setState(updater);
16
+ }
17
+ };
18
+ return [state, onChangeFunction];
11
19
  }
@@ -138,14 +138,7 @@ export function Table(_a) {
138
138
  globalFilterFn: enableFuzzySearch ? fuzzyFilter : 'includesString',
139
139
  onGlobalFilterChange,
140
140
  getRowId,
141
- onRowSelectionChange: updater => {
142
- if (typeof updater === 'function') {
143
- onRowSelectionChange(updater(rowSelection));
144
- }
145
- else {
146
- onRowSelectionChange(updater);
147
- }
148
- },
141
+ onRowSelectionChange,
149
142
  enableGrouping: true,
150
143
  enableRowSelection,
151
144
  enableMultiRowSelection: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow,
@@ -2,12 +2,12 @@ import { TableProps } from '../../../types';
2
2
  type useFiltersProps<TData extends object, TFilters extends Record<string, unknown>> = Pick<TableProps<TData, TFilters>, 'columnFilters'>;
3
3
  export declare function useFilters<TData extends object, TFilters extends Record<string, unknown>>({ columnFilters, }: useFiltersProps<TData, TFilters>): {
4
4
  filter: TFilters | undefined;
5
- setFilter: import("uncontrollable").Handler;
5
+ setFilter: import("@tanstack/react-table").OnChangeFn<TFilters | undefined>;
6
6
  patchedFilter: {
7
7
  value: TFilters | undefined;
8
- onChange: import("uncontrollable").Handler;
8
+ onChange: (filter: TFilters) => void;
9
9
  visibleFilters: string[];
10
- onVisibleFiltersChange: import("uncontrollable").Handler;
10
+ onVisibleFiltersChange: import("@tanstack/react-table").OnChangeFn<string[]>;
11
11
  className?: string;
12
12
  "aria-activedescendant"?: string | undefined;
13
13
  "aria-atomic"?: (boolean | "true" | "false") | undefined;
@@ -70,6 +70,6 @@ export declare function useFilters<TData extends object, TFilters extends Record
70
70
  onOpenChange: (isOpen: boolean) => void;
71
71
  initialOpen?: boolean;
72
72
  } | undefined;
73
- setFilterVisibility: import("uncontrollable").Handler;
73
+ setFilterVisibility: import("@tanstack/react-table").OnChangeFn<string[]>;
74
74
  };
75
75
  export {};
@@ -1,5 +1,6 @@
1
- export declare function useStateControl<TState>(control: {
1
+ import { OnChangeFn } from '@tanstack/react-table';
2
+ export declare function useStateControl<TState extends object | string | number | boolean | undefined>(control: {
2
3
  initialState?: TState;
3
4
  state?: TState;
4
5
  onChange?(state: TState): void;
5
- } | undefined, defaultState: TState): readonly [TState, import("uncontrollable").Handler];
6
+ } | undefined, defaultState: TState): readonly [TState, OnChangeFn<TState>];
@@ -1,5 +1,14 @@
1
1
  import { useUncontrolledProp } from 'uncontrollable';
2
2
  export function useStateControl(control, defaultState) {
3
3
  var _a, _b;
4
- return useUncontrolledProp(control === null || control === void 0 ? void 0 : control.state, (_b = (_a = control === null || control === void 0 ? void 0 : control.state) !== null && _a !== void 0 ? _a : control === null || control === void 0 ? void 0 : control.initialState) !== null && _b !== void 0 ? _b : defaultState, control === null || control === void 0 ? void 0 : control.onChange);
4
+ const [state, setState] = useUncontrolledProp(control === null || control === void 0 ? void 0 : control.state, (_b = (_a = control === null || control === void 0 ? void 0 : control.state) !== null && _a !== void 0 ? _a : control === null || control === void 0 ? void 0 : control.initialState) !== null && _b !== void 0 ? _b : defaultState, control === null || control === void 0 ? void 0 : control.onChange);
5
+ const onChangeFunction = updater => {
6
+ if (typeof updater === 'function') {
7
+ setState(updater(state));
8
+ }
9
+ else {
10
+ setState(updater);
11
+ }
12
+ };
13
+ return [state, onChangeFunction];
5
14
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Table",
7
- "version": "0.36.9",
7
+ "version": "0.36.10",
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": "4898ffc6db1c53aa9998f54b1e41741b80cb01cd"
69
+ "gitHead": "11b356cdf85866c119c6abef219fc7394828c55e"
70
70
  }
@@ -257,13 +257,7 @@ export function Table<TData extends object, TFilters extends FiltersState = Reco
257
257
  onGlobalFilterChange,
258
258
 
259
259
  getRowId,
260
- onRowSelectionChange: updater => {
261
- if (typeof updater === 'function') {
262
- onRowSelectionChange(updater(rowSelection));
263
- } else {
264
- onRowSelectionChange(updater);
265
- }
266
- },
260
+ onRowSelectionChange,
267
261
  enableGrouping: true,
268
262
  enableRowSelection,
269
263
  enableMultiRowSelection: rowSelectionProp?.multiRow,
@@ -45,7 +45,7 @@ export function useFilters<TData extends object, TFilters extends Record<string,
45
45
  onOpenChange: setAreColumnFiltersOpen,
46
46
  ...columnFilters,
47
47
  value: filter,
48
- onChange: setFilter,
48
+ onChange: setFilter as (filter: TFilters) => void,
49
49
  visibleFilters: filterVisibility,
50
50
  onVisibleFiltersChange: setFilterVisibility,
51
51
  };
@@ -1,12 +1,23 @@
1
+ import { OnChangeFn } from '@tanstack/react-table';
1
2
  import { useUncontrolledProp } from 'uncontrollable';
2
3
 
3
- export function useStateControl<TState>(
4
+ export function useStateControl<TState extends object | string | number | boolean | undefined>(
4
5
  control: { initialState?: TState; state?: TState; onChange?(state: TState): void } | undefined,
5
6
  defaultState: TState,
6
7
  ) {
7
- return useUncontrolledProp<TState>(
8
+ const [state, setState] = useUncontrolledProp<TState>(
8
9
  control?.state,
9
10
  control?.state ?? control?.initialState ?? defaultState,
10
11
  control?.onChange,
11
12
  );
13
+
14
+ const onChangeFunction: OnChangeFn<TState> = updater => {
15
+ if (typeof updater === 'function') {
16
+ setState(updater(state));
17
+ } else {
18
+ setState(updater);
19
+ }
20
+ };
21
+
22
+ return [state, onChangeFunction] as const;
12
23
  }