@cloud-ru/uikit-product-utils 8.0.0 → 8.0.2
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 +22 -0
- package/dist/cjs/utils/getAdaptive.d.ts +1 -1
- package/dist/cjs/utils/getAdaptive.js +2 -2
- package/dist/cjs/utils/getUserAgentInfo.js +2 -1
- package/dist/esm/utils/getAdaptive.d.ts +1 -1
- package/dist/esm/utils/getAdaptive.js +2 -2
- package/dist/esm/utils/getUserAgentInfo.js +2 -1
- package/package.json +2 -2
- package/src/utils/getAdaptive.ts +2 -2
- package/src/utils/getUserAgentInfo.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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
|
+
## 8.0.2 (2025-12-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **FF-7187:** add SSR safety checks for localStorage and navigator usage ([c2c7561](https://gitverse.ru/cloud-ru-tech/uikit-product/commits/c2c7561c9a2f5e3b1bd897b696b33ea309f39dfa))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## 8.0.1 (2025-11-24)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **FF-7533:** mobile layout type for small tablets ([22fc805](https://gitverse.ru/cloud-ru-tech/uikit-product/commits/22fc805273e29253c6e54f2587d121999744b1ff))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
# 8.0.0 (2025-11-24)
|
|
7
29
|
|
|
8
30
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AdaptiveQueriesTitle } from '../constants/adaptive';
|
|
2
2
|
import { LayoutType, MatchMediaGeneric } from '../types/adaptive';
|
|
3
|
-
export declare function getAdaptive({ isMobile }: MatchMediaGeneric<AdaptiveQueriesTitle>): {
|
|
3
|
+
export declare function getAdaptive({ isMobile, isTablet }: MatchMediaGeneric<AdaptiveQueriesTitle>): {
|
|
4
4
|
layoutType: LayoutType;
|
|
5
5
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAdaptive = getAdaptive;
|
|
4
4
|
const getUserAgentInfo_1 = require("./getUserAgentInfo");
|
|
5
|
-
function getAdaptive({ isMobile }) {
|
|
5
|
+
function getAdaptive({ isMobile, isTablet }) {
|
|
6
6
|
const { device } = (0, getUserAgentInfo_1.getUserAgentInfo)();
|
|
7
7
|
let layoutType;
|
|
8
8
|
switch (device.type) {
|
|
@@ -10,7 +10,7 @@ function getAdaptive({ isMobile }) {
|
|
|
10
10
|
layoutType = 'mobile';
|
|
11
11
|
break;
|
|
12
12
|
case 'tablet':
|
|
13
|
-
layoutType = 'tablet';
|
|
13
|
+
layoutType = isMobile || isTablet ? 'mobile' : 'tablet';
|
|
14
14
|
break;
|
|
15
15
|
default:
|
|
16
16
|
layoutType = isMobile ? 'desktopSmall' : 'desktop';
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUserAgentInfo = getUserAgentInfo;
|
|
4
4
|
const ua_parser_js_1 = require("ua-parser-js");
|
|
5
|
+
const utils_1 = require("@snack-uikit/utils");
|
|
5
6
|
const DEVICE_TYPE = {
|
|
6
7
|
Console: 'console',
|
|
7
8
|
Mobile: 'mobile',
|
|
@@ -14,7 +15,7 @@ const DEVICE_TYPE = {
|
|
|
14
15
|
const DEVICE_TYPES = Object.values(DEVICE_TYPE);
|
|
15
16
|
const getDeviceType = (type) => DEVICE_TYPES.find(value => value === type) || DEVICE_TYPE.Desktop;
|
|
16
17
|
function getUserAgentInfo() {
|
|
17
|
-
const parser = new ua_parser_js_1.UAParser(globalThis.navigator.userAgent);
|
|
18
|
+
const parser = new ua_parser_js_1.UAParser((0, utils_1.isBrowser)() ? globalThis.navigator.userAgent : undefined);
|
|
18
19
|
const device = parser.getDevice();
|
|
19
20
|
const browser = parser.getBrowser();
|
|
20
21
|
const os = parser.getOS();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AdaptiveQueriesTitle } from '../constants/adaptive';
|
|
2
2
|
import { LayoutType, MatchMediaGeneric } from '../types/adaptive';
|
|
3
|
-
export declare function getAdaptive({ isMobile }: MatchMediaGeneric<AdaptiveQueriesTitle>): {
|
|
3
|
+
export declare function getAdaptive({ isMobile, isTablet }: MatchMediaGeneric<AdaptiveQueriesTitle>): {
|
|
4
4
|
layoutType: LayoutType;
|
|
5
5
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getUserAgentInfo } from './getUserAgentInfo';
|
|
2
|
-
export function getAdaptive({ isMobile }) {
|
|
2
|
+
export function getAdaptive({ isMobile, isTablet }) {
|
|
3
3
|
const { device } = getUserAgentInfo();
|
|
4
4
|
let layoutType;
|
|
5
5
|
switch (device.type) {
|
|
@@ -7,7 +7,7 @@ export function getAdaptive({ isMobile }) {
|
|
|
7
7
|
layoutType = 'mobile';
|
|
8
8
|
break;
|
|
9
9
|
case 'tablet':
|
|
10
|
-
layoutType = 'tablet';
|
|
10
|
+
layoutType = isMobile || isTablet ? 'mobile' : 'tablet';
|
|
11
11
|
break;
|
|
12
12
|
default:
|
|
13
13
|
layoutType = isMobile ? 'desktopSmall' : 'desktop';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UAParser } from 'ua-parser-js';
|
|
2
|
+
import { isBrowser } from '@snack-uikit/utils';
|
|
2
3
|
const DEVICE_TYPE = {
|
|
3
4
|
Console: 'console',
|
|
4
5
|
Mobile: 'mobile',
|
|
@@ -11,7 +12,7 @@ const DEVICE_TYPE = {
|
|
|
11
12
|
const DEVICE_TYPES = Object.values(DEVICE_TYPE);
|
|
12
13
|
const getDeviceType = (type) => DEVICE_TYPES.find(value => value === type) || DEVICE_TYPE.Desktop;
|
|
13
14
|
export function getUserAgentInfo() {
|
|
14
|
-
const parser = new UAParser(globalThis.navigator.userAgent);
|
|
15
|
+
const parser = new UAParser(isBrowser() ? globalThis.navigator.userAgent : undefined);
|
|
15
16
|
const device = parser.getDevice();
|
|
16
17
|
const browser = parser.getBrowser();
|
|
17
18
|
const os = parser.getOS();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-ru/uikit-product-utils",
|
|
3
3
|
"title": "Utils",
|
|
4
|
-
"version": "8.0.
|
|
4
|
+
"version": "8.0.2",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css",
|
|
7
7
|
"*.woff",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"optional": true
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "ab61e93fe6f723c522e95a7c5540b3080de6b2de"
|
|
88
88
|
}
|
package/src/utils/getAdaptive.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AdaptiveQueriesTitle } from '../constants/adaptive';
|
|
|
2
2
|
import { LayoutType, MatchMediaGeneric } from '../types/adaptive';
|
|
3
3
|
import { getUserAgentInfo } from './getUserAgentInfo';
|
|
4
4
|
|
|
5
|
-
export function getAdaptive({ isMobile }: MatchMediaGeneric<AdaptiveQueriesTitle>) {
|
|
5
|
+
export function getAdaptive({ isMobile, isTablet }: MatchMediaGeneric<AdaptiveQueriesTitle>) {
|
|
6
6
|
const { device } = getUserAgentInfo();
|
|
7
7
|
|
|
8
8
|
let layoutType: LayoutType;
|
|
@@ -12,7 +12,7 @@ export function getAdaptive({ isMobile }: MatchMediaGeneric<AdaptiveQueriesTitle
|
|
|
12
12
|
layoutType = 'mobile';
|
|
13
13
|
break;
|
|
14
14
|
case 'tablet':
|
|
15
|
-
layoutType = 'tablet';
|
|
15
|
+
layoutType = isMobile || isTablet ? 'mobile' : 'tablet';
|
|
16
16
|
break;
|
|
17
17
|
default:
|
|
18
18
|
layoutType = isMobile ? 'desktopSmall' : 'desktop';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UAParser } from 'ua-parser-js';
|
|
2
2
|
|
|
3
|
-
import { ValueOf } from '@snack-uikit/utils';
|
|
3
|
+
import { isBrowser, ValueOf } from '@snack-uikit/utils';
|
|
4
4
|
|
|
5
5
|
const DEVICE_TYPE = {
|
|
6
6
|
Console: 'console',
|
|
@@ -20,7 +20,7 @@ const getDeviceType = (type: string | undefined): DeviceType =>
|
|
|
20
20
|
DEVICE_TYPES.find(value => value === type) || DEVICE_TYPE.Desktop;
|
|
21
21
|
|
|
22
22
|
export function getUserAgentInfo() {
|
|
23
|
-
const parser = new UAParser(globalThis.navigator.userAgent);
|
|
23
|
+
const parser = new UAParser(isBrowser() ? globalThis.navigator.userAgent : undefined);
|
|
24
24
|
const device = parser.getDevice();
|
|
25
25
|
const browser = parser.getBrowser();
|
|
26
26
|
const os = parser.getOS();
|