@geneui/components 3.0.0-next-cbf1483-19022025 → 3.0.0-next-ed7bf62-05032025
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/hooks/index.d.ts +1 -0
- package/hooks/useDeviceInfo/index.d.ts +1 -0
- package/hooks/useDeviceInfo/useDeviceInfo.d.ts +13 -0
- package/index.d.ts +1 -0
- package/index.js +48 -2
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
package/hooks/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { default as useDebounce } from "./useDebounceCallback";
|
|
|
2
2
|
export { default as useEllipsisDetection } from "./useEllipsisDetection";
|
|
3
3
|
export { default as useScrollLock } from "./useScrollLock";
|
|
4
4
|
export { default as useWindowSize } from "./useWindowSize";
|
|
5
|
+
export { default as useDeviceInfo } from "./useDeviceInfo";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./useDeviceInfo";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OS } from "@types";
|
|
2
|
+
interface IDeviceInfo {
|
|
3
|
+
isMobile: boolean;
|
|
4
|
+
isDesktop: boolean;
|
|
5
|
+
os: OS;
|
|
6
|
+
isWindows: boolean;
|
|
7
|
+
isMacOS: boolean;
|
|
8
|
+
isLinux: boolean;
|
|
9
|
+
isAndroid: boolean;
|
|
10
|
+
isIOS: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const useDeviceInfo: () => IDeviceInfo;
|
|
13
|
+
export default useDeviceInfo;
|
package/index.d.ts
CHANGED
|
@@ -21,3 +21,4 @@ export { default as useDebounce } from "./hooks/useDebounceCallback";
|
|
|
21
21
|
export { default as useEllipsisDetection } from "./hooks/useEllipsisDetection";
|
|
22
22
|
export { default as useScrollLock } from "./hooks/useScrollLock";
|
|
23
23
|
export { default as useWindowSize } from "./hooks/useWindowSize";
|
|
24
|
+
export { default as useDeviceInfo } from "./hooks/useDeviceInfo";
|
package/index.js
CHANGED
|
@@ -19,7 +19,7 @@ export { Key, KeyValue, Value } from './KeyValue.js';
|
|
|
19
19
|
export { GeneUIDesignSystemContext, default as GeneUIProvider } from './GeneUIProvider.js';
|
|
20
20
|
export { u as useDebounce } from './useDebounceCallback-999deae7.js';
|
|
21
21
|
export { u as useEllipsisDetection } from './useEllipsisDetection-e545ae62.js';
|
|
22
|
-
import { useState, useEffect } from 'react';
|
|
22
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
23
23
|
import './index-ce02421b.js';
|
|
24
24
|
import './ArrowLeft-b88e2ba8.js';
|
|
25
25
|
import './style-inject.es-746bb8ed.js';
|
|
@@ -47,4 +47,50 @@ const useWindowSize = () => {
|
|
|
47
47
|
return windowSize;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
// Map of OS detection patterns
|
|
51
|
+
const osPatterns = [
|
|
52
|
+
["Windows", /\b(windows nt|win)\b/i],
|
|
53
|
+
["iOS", /\b(iPhone|iPad|iPod).*?OS \d+/i],
|
|
54
|
+
["Android", /\bandroid\b/i],
|
|
55
|
+
["macOS", /\b(mac os|macintosh)\b(?!.*(?:iphone|ipad|ipod))/i],
|
|
56
|
+
["Linux", /\blinux\b/i]
|
|
57
|
+
];
|
|
58
|
+
const useDeviceInfo = () => {
|
|
59
|
+
return useMemo(() => {
|
|
60
|
+
var _a;
|
|
61
|
+
if (typeof navigator === "undefined") {
|
|
62
|
+
return {
|
|
63
|
+
isMobile: false,
|
|
64
|
+
isDesktop: false,
|
|
65
|
+
os: "Unknown",
|
|
66
|
+
isWindows: false,
|
|
67
|
+
isMacOS: false,
|
|
68
|
+
isLinux: false,
|
|
69
|
+
isAndroid: false,
|
|
70
|
+
isIOS: false
|
|
71
|
+
}; // Safe for SSR
|
|
72
|
+
}
|
|
73
|
+
const userAgent = (_a = navigator.userAgent) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
74
|
+
// Find the first matching OS using destructuring
|
|
75
|
+
const [detectedOS = "Unknown"] = osPatterns.find(([, pattern]) => pattern.test(userAgent)) || [];
|
|
76
|
+
const isWindows = detectedOS === "Windows";
|
|
77
|
+
const isMacOS = detectedOS === "macOS";
|
|
78
|
+
const isLinux = detectedOS === "Linux";
|
|
79
|
+
const isAndroid = detectedOS === "Android";
|
|
80
|
+
const isIOS = detectedOS === "iOS";
|
|
81
|
+
const isMobile = isAndroid || isIOS;
|
|
82
|
+
const isDesktop = isWindows || isMacOS || isLinux;
|
|
83
|
+
return {
|
|
84
|
+
isMobile,
|
|
85
|
+
isDesktop,
|
|
86
|
+
os: detectedOS,
|
|
87
|
+
isWindows,
|
|
88
|
+
isMacOS,
|
|
89
|
+
isLinux,
|
|
90
|
+
isAndroid,
|
|
91
|
+
isIOS
|
|
92
|
+
};
|
|
93
|
+
}, []);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export { useDeviceInfo, useWindowSize };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geneui/components",
|
|
3
3
|
"description": "The Gene UI components library designed for BI tools",
|
|
4
|
-
"version": "3.0.0-next-
|
|
4
|
+
"version": "3.0.0-next-ed7bf62-05032025",
|
|
5
5
|
"author": "SoftConstruct",
|
|
6
6
|
"homepage": "https://github.com/softconstruct/gene-ui-components#readme",
|
|
7
7
|
"repository": {
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type OS = "iOS" | "Android" | "Windows" | "macOS" | "Linux" | "Unknown";
|