@cloud-ru/uikit-product-mobile-toolbar 3.0.1 → 4.0.0

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,25 @@
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
+ # 4.0.0 (2026-10-15)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+
12
+ * **CORESERV-12174:** remove double url-encoding of mobile toolbar persisted state ([cb69518](https://github.com/cloud-ru-tech/uikit-product/commit/cb69518dbf30bf30c553beec5a350828c8133420))
13
+
14
+
15
+
16
+
17
+ ## 3.0.2 (2026-10-09)
18
+
19
+ **Note:** Version bump only for package @cloud-ru/uikit-product-mobile-toolbar
20
+
21
+
22
+
23
+
24
+
6
25
  ## 3.0.1 (2026-09-29)
7
26
 
8
27
  **Note:** Version bump only for package @cloud-ru/uikit-product-mobile-toolbar
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const __1 = require("..");
5
+ const BASE_URL = 'https://example.com/table';
6
+ const QUERY_KEY = 'state';
7
+ const writeStateToUrl = (state) => {
8
+ const url = new URL(BASE_URL);
9
+ url.searchParams.set(QUERY_KEY, (0, __1.defaultSerializer)(state));
10
+ return url;
11
+ };
12
+ const readStateFromUrl = (href) => { var _a; return (0, __1.defaultParser)((_a = new URL(href).searchParams.get(QUERY_KEY)) !== null && _a !== void 0 ? _a : ''); };
13
+ const paginationState = {
14
+ pagination: { limit: 25, offset: 0 },
15
+ search: '',
16
+ filter: {},
17
+ };
18
+ const roundTripCases = [
19
+ { name: 'pagination', state: paginationState },
20
+ {
21
+ name: 'ordering',
22
+ state: {
23
+ ordering: [
24
+ { field: 'name', direction: '-' },
25
+ { field: 'status', direction: '+' },
26
+ ],
27
+ search: '',
28
+ filter: {},
29
+ },
30
+ },
31
+ {
32
+ name: 'filter with in and eq conditions',
33
+ state: { search: '', filter: { status: ['active', 'inactive'], type: 'http' } },
34
+ },
35
+ { name: 'cyrillic search with space', state: { search: 'точка москва', filter: {} } },
36
+ { name: 'search with plus, space and hash', state: { search: 'a+b #1', filter: {} } },
37
+ { name: 'search with percent sign', state: { search: '100%', filter: {} } },
38
+ { name: 'search with percent-encoded-like sequence', state: { search: 'a%41b', filter: {} } },
39
+ ];
40
+ (0, vitest_1.describe)('persisted toolbar state in query param', () => {
41
+ roundTripCases.forEach(({ name, state }) => {
42
+ (0, vitest_1.it)(`should restore ${name} from url`, () => {
43
+ const url = writeStateToUrl(state);
44
+ (0, vitest_1.expect)(readStateFromUrl(url.href)).toEqual(state);
45
+ });
46
+ });
47
+ roundTripCases
48
+ .filter(({ state }) => { var _a; return !((_a = state.search) === null || _a === void 0 ? void 0 : _a.includes('%')); })
49
+ .forEach(({ name, state }) => {
50
+ (0, vitest_1.it)(`should not double-encode ${name} in url`, () => {
51
+ const url = writeStateToUrl(state);
52
+ (0, vitest_1.expect)(url.search).not.toContain('%25');
53
+ });
54
+ });
55
+ (0, vitest_1.it)('should encode pagination once', () => {
56
+ const url = writeStateToUrl(paginationState);
57
+ (0, vitest_1.expect)(url.search).toBe('?state=limit%3D25%26offset%3D0');
58
+ });
59
+ (0, vitest_1.it)('should encode literal percent sign in search exactly once', () => {
60
+ const url = writeStateToUrl({ search: '100%', filter: {} });
61
+ (0, vitest_1.expect)(url.search.match(/%25/g)).toHaveLength(1);
62
+ (0, vitest_1.expect)(readStateFromUrl(url.href).search).toBe('100%');
63
+ });
64
+ (0, vitest_1.it)('should truncate search containing ampersand and equals sign', () => {
65
+ const url = writeStateToUrl({ search: 'a&b=c', filter: {} });
66
+ (0, vitest_1.expect)(readStateFromUrl(url.href).search).toBe('a');
67
+ });
68
+ });
@@ -25,7 +25,7 @@ const mapFilterFromPayload = (value) => {
25
25
  };
26
26
  const defaultParser = (value) => {
27
27
  var _a, _b;
28
- const parsed = (0, ft_request_payload_transform_1.parseQueryParamsString)(value);
28
+ const parsed = (0, ft_request_payload_transform_1.parseQueryParamsString)(value, { decode: false });
29
29
  return {
30
30
  pagination: parsed === null || parsed === void 0 ? void 0 : parsed.pagination,
31
31
  ordering: parsed === null || parsed === void 0 ? void 0 : parsed.ordering,
@@ -8,4 +8,5 @@ export declare const formatFilterStateToRequestPayload: <T extends FiltersState>
8
8
  encode?: boolean;
9
9
  }): string;
10
10
  };
11
+ /** Возвращает сырую строку: URL-кодированием занимается `URLSearchParams.set` в источнике query-параметров */
11
12
  export declare const defaultSerializer: <T extends FiltersState>(value: PersistedFilterState<T>) => string;
@@ -41,5 +41,6 @@ const formatFilterStateToRequestPayload = (value) => {
41
41
  });
42
42
  };
43
43
  exports.formatFilterStateToRequestPayload = formatFilterStateToRequestPayload;
44
- const defaultSerializer = (value) => (0, exports.formatFilterStateToRequestPayload)(value).toString();
44
+ /** Возвращает сырую строку: URL-кодированием занимается `URLSearchParams.set` в источнике query-параметров */
45
+ const defaultSerializer = (value) => (0, exports.formatFilterStateToRequestPayload)(value).toString({ encode: false });
45
46
  exports.defaultSerializer = defaultSerializer;
@@ -0,0 +1,66 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { defaultParser, defaultSerializer } from '..';
3
+ const BASE_URL = 'https://example.com/table';
4
+ const QUERY_KEY = 'state';
5
+ const writeStateToUrl = (state) => {
6
+ const url = new URL(BASE_URL);
7
+ url.searchParams.set(QUERY_KEY, defaultSerializer(state));
8
+ return url;
9
+ };
10
+ const readStateFromUrl = (href) => { var _a; return defaultParser((_a = new URL(href).searchParams.get(QUERY_KEY)) !== null && _a !== void 0 ? _a : ''); };
11
+ const paginationState = {
12
+ pagination: { limit: 25, offset: 0 },
13
+ search: '',
14
+ filter: {},
15
+ };
16
+ const roundTripCases = [
17
+ { name: 'pagination', state: paginationState },
18
+ {
19
+ name: 'ordering',
20
+ state: {
21
+ ordering: [
22
+ { field: 'name', direction: '-' },
23
+ { field: 'status', direction: '+' },
24
+ ],
25
+ search: '',
26
+ filter: {},
27
+ },
28
+ },
29
+ {
30
+ name: 'filter with in and eq conditions',
31
+ state: { search: '', filter: { status: ['active', 'inactive'], type: 'http' } },
32
+ },
33
+ { name: 'cyrillic search with space', state: { search: 'точка москва', filter: {} } },
34
+ { name: 'search with plus, space and hash', state: { search: 'a+b #1', filter: {} } },
35
+ { name: 'search with percent sign', state: { search: '100%', filter: {} } },
36
+ { name: 'search with percent-encoded-like sequence', state: { search: 'a%41b', filter: {} } },
37
+ ];
38
+ describe('persisted toolbar state in query param', () => {
39
+ roundTripCases.forEach(({ name, state }) => {
40
+ it(`should restore ${name} from url`, () => {
41
+ const url = writeStateToUrl(state);
42
+ expect(readStateFromUrl(url.href)).toEqual(state);
43
+ });
44
+ });
45
+ roundTripCases
46
+ .filter(({ state }) => { var _a; return !((_a = state.search) === null || _a === void 0 ? void 0 : _a.includes('%')); })
47
+ .forEach(({ name, state }) => {
48
+ it(`should not double-encode ${name} in url`, () => {
49
+ const url = writeStateToUrl(state);
50
+ expect(url.search).not.toContain('%25');
51
+ });
52
+ });
53
+ it('should encode pagination once', () => {
54
+ const url = writeStateToUrl(paginationState);
55
+ expect(url.search).toBe('?state=limit%3D25%26offset%3D0');
56
+ });
57
+ it('should encode literal percent sign in search exactly once', () => {
58
+ const url = writeStateToUrl({ search: '100%', filter: {} });
59
+ expect(url.search.match(/%25/g)).toHaveLength(1);
60
+ expect(readStateFromUrl(url.href).search).toBe('100%');
61
+ });
62
+ it('should truncate search containing ampersand and equals sign', () => {
63
+ const url = writeStateToUrl({ search: 'a&b=c', filter: {} });
64
+ expect(readStateFromUrl(url.href).search).toBe('a');
65
+ });
66
+ });
@@ -22,7 +22,7 @@ const mapFilterFromPayload = (value) => {
22
22
  };
23
23
  export const defaultParser = (value) => {
24
24
  var _a, _b;
25
- const parsed = parseQueryParamsString(value);
25
+ const parsed = parseQueryParamsString(value, { decode: false });
26
26
  return {
27
27
  pagination: parsed === null || parsed === void 0 ? void 0 : parsed.pagination,
28
28
  ordering: parsed === null || parsed === void 0 ? void 0 : parsed.ordering,
@@ -8,4 +8,5 @@ export declare const formatFilterStateToRequestPayload: <T extends FiltersState>
8
8
  encode?: boolean;
9
9
  }): string;
10
10
  };
11
+ /** Возвращает сырую строку: URL-кодированием занимается `URLSearchParams.set` в источнике query-параметров */
11
12
  export declare const defaultSerializer: <T extends FiltersState>(value: PersistedFilterState<T>) => string;
@@ -37,4 +37,5 @@ export const formatFilterStateToRequestPayload = (value) => {
37
37
  filter: mapFilterToPayload(value === null || value === void 0 ? void 0 : value.filter),
38
38
  });
39
39
  };
40
- export const defaultSerializer = (value) => formatFilterStateToRequestPayload(value).toString();
40
+ /** Возвращает сырую строку: URL-кодированием занимается `URLSearchParams.set` в источнике query-параметров */
41
+ export const defaultSerializer = (value) => formatFilterStateToRequestPayload(value).toString({ encode: false });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloud-ru/uikit-product-mobile-toolbar",
3
3
  "title": "Mobile Toolbar",
4
- "version": "3.0.1",
4
+ "version": "4.0.0",
5
5
  "sideEffects": [
6
6
  "*.css",
7
7
  "*.woff",
@@ -35,21 +35,21 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@cloud-ru/ft-request-payload-transform": "^0.3.0",
38
+ "@cloud-ru/ft-request-payload-transform": "^0.5.0",
39
39
  "@snack-uikit/button": "^1.0.1",
40
40
  "@snack-uikit/chips": "^1.0.1",
41
41
  "@snack-uikit/counter": "^1.0.1",
42
42
  "@snack-uikit/search-private": "^1.0.1",
43
43
  "@snack-uikit/tag": "^1.0.1",
44
44
  "@snack-uikit/toggles": "^1.0.1",
45
- "@snack-uikit/toolbar": "^1.0.1",
45
+ "@snack-uikit/toolbar": "^2.0.0",
46
46
  "@snack-uikit/utils": "^5.0.0",
47
47
  "classnames": "^2.5.1",
48
48
  "uncontrollable": "^8.0.4",
49
- "@cloud-ru/uikit-product-icons": "^19.1.0",
50
- "@cloud-ru/uikit-product-mobile-dropdown": "^3.0.1",
51
- "@cloud-ru/uikit-product-mobile-chips": "^3.0.1",
52
- "@cloud-ru/uikit-product-mobile-tooltip": "^2.0.1",
49
+ "@cloud-ru/uikit-product-icons": "^19.2.0",
50
+ "@cloud-ru/uikit-product-mobile-chips": "^3.0.2",
51
+ "@cloud-ru/uikit-product-mobile-dropdown": "^3.0.2",
52
+ "@cloud-ru/uikit-product-mobile-tooltip": "^2.0.2",
53
53
  "@cloud-ru/uikit-product-utils": "^10.0.0"
54
54
  },
55
55
  "peerDependencies": {
@@ -0,0 +1,85 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { FiltersState } from '@snack-uikit/chips';
4
+
5
+ import { PersistedFilterState } from '../../../../types';
6
+ import { defaultParser, defaultSerializer } from '..';
7
+
8
+ const BASE_URL = 'https://example.com/table';
9
+ const QUERY_KEY = 'state';
10
+
11
+ const writeStateToUrl = (state: PersistedFilterState<FiltersState>) => {
12
+ const url = new URL(BASE_URL);
13
+ url.searchParams.set(QUERY_KEY, defaultSerializer(state));
14
+ return url;
15
+ };
16
+
17
+ const readStateFromUrl = (href: string) => defaultParser(new URL(href).searchParams.get(QUERY_KEY) ?? '');
18
+
19
+ const paginationState: PersistedFilterState<FiltersState> = {
20
+ pagination: { limit: 25, offset: 0 },
21
+ search: '',
22
+ filter: {},
23
+ };
24
+
25
+ const roundTripCases: { name: string; state: PersistedFilterState<FiltersState> }[] = [
26
+ { name: 'pagination', state: paginationState },
27
+ {
28
+ name: 'ordering',
29
+ state: {
30
+ ordering: [
31
+ { field: 'name', direction: '-' },
32
+ { field: 'status', direction: '+' },
33
+ ],
34
+ search: '',
35
+ filter: {},
36
+ },
37
+ },
38
+ {
39
+ name: 'filter with in and eq conditions',
40
+ state: { search: '', filter: { status: ['active', 'inactive'], type: 'http' } },
41
+ },
42
+ { name: 'cyrillic search with space', state: { search: 'точка москва', filter: {} } },
43
+ { name: 'search with plus, space and hash', state: { search: 'a+b #1', filter: {} } },
44
+ { name: 'search with percent sign', state: { search: '100%', filter: {} } },
45
+ { name: 'search with percent-encoded-like sequence', state: { search: 'a%41b', filter: {} } },
46
+ ];
47
+
48
+ describe('persisted toolbar state in query param', () => {
49
+ roundTripCases.forEach(({ name, state }) => {
50
+ it(`should restore ${name} from url`, () => {
51
+ const url = writeStateToUrl(state);
52
+
53
+ expect(readStateFromUrl(url.href)).toEqual(state);
54
+ });
55
+ });
56
+
57
+ roundTripCases
58
+ .filter(({ state }) => !state.search?.includes('%'))
59
+ .forEach(({ name, state }) => {
60
+ it(`should not double-encode ${name} in url`, () => {
61
+ const url = writeStateToUrl(state);
62
+
63
+ expect(url.search).not.toContain('%25');
64
+ });
65
+ });
66
+
67
+ it('should encode pagination once', () => {
68
+ const url = writeStateToUrl(paginationState);
69
+
70
+ expect(url.search).toBe('?state=limit%3D25%26offset%3D0');
71
+ });
72
+
73
+ it('should encode literal percent sign in search exactly once', () => {
74
+ const url = writeStateToUrl({ search: '100%', filter: {} });
75
+
76
+ expect(url.search.match(/%25/g)).toHaveLength(1);
77
+ expect(readStateFromUrl(url.href).search).toBe('100%');
78
+ });
79
+
80
+ it('should truncate search containing ampersand and equals sign', () => {
81
+ const url = writeStateToUrl({ search: 'a&b=c', filter: {} });
82
+
83
+ expect(readStateFromUrl(url.href).search).toBe('a');
84
+ });
85
+ });
@@ -35,7 +35,7 @@ const mapFilterFromPayload = <TFilters extends FiltersState = Record<string, unk
35
35
  };
36
36
 
37
37
  export const defaultParser = <T extends FiltersState>(value: string): PersistedFilterState<T> => {
38
- const parsed = parseQueryParamsString(value);
38
+ const parsed = parseQueryParamsString(value, { decode: false });
39
39
 
40
40
  return {
41
41
  pagination: parsed?.pagination,
@@ -49,5 +49,6 @@ export const formatFilterStateToRequestPayload = <T extends FiltersState>(value?
49
49
  filter: mapFilterToPayload(value?.filter),
50
50
  });
51
51
 
52
+ /** Возвращает сырую строку: URL-кодированием занимается `URLSearchParams.set` в источнике query-параметров */
52
53
  export const defaultSerializer = <T extends FiltersState>(value: PersistedFilterState<T>) =>
53
- formatFilterStateToRequestPayload(value).toString();
54
+ formatFilterStateToRequestPayload(value).toString({ encode: false });