ssovee-os-web-ui 0.1.21 → 0.1.23
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/README.md +13 -1
- package/dist/index.cjs +190 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +110 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +188 -43
- package/dist/index.js.map +1 -1
- package/dist/sdk.cjs +265 -0
- package/dist/sdk.cjs.map +1 -0
- package/dist/sdk.d.cts +24 -0
- package/dist/sdk.d.ts +24 -0
- package/dist/sdk.js +260 -0
- package/dist/sdk.js.map +1 -0
- package/package.json +11 -2
package/README.md
CHANGED
|
@@ -53,6 +53,14 @@ export function Example() {
|
|
|
53
53
|
}
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
## Hooks
|
|
57
|
+
|
|
58
|
+
Hooks are also available through the SDK-style entrypoint:
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { useGridClasses, useDeviceSupport, useSound } from "ssovee-os-web-ui/sdk";
|
|
62
|
+
```
|
|
63
|
+
|
|
56
64
|
## Public exports
|
|
57
65
|
|
|
58
66
|
The package exports these components and types for external use:
|
|
@@ -85,8 +93,12 @@ The package exports these components and types for external use:
|
|
|
85
93
|
- `Typography`
|
|
86
94
|
- `ImageWithPlaceholder`
|
|
87
95
|
- `Table` and its subcomponents
|
|
96
|
+
- `useGridClasses`
|
|
97
|
+
- `useShortcutFormatter`
|
|
98
|
+
- `useDeviceSupport`
|
|
99
|
+
- `useSound`
|
|
88
100
|
|
|
89
|
-
|
|
101
|
+
The hooks are available from the package entrypoint and from the SDK subpath.
|
|
90
102
|
|
|
91
103
|
## License
|
|
92
104
|
|
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var React20 = require('react');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var react = require('@phosphor-icons/react');
|
|
6
|
+
var uaParserJs = require('ua-parser-js');
|
|
6
7
|
|
|
7
8
|
function _interopNamespace(e) {
|
|
8
9
|
if (e && e.__esModule) return e;
|
|
@@ -1312,64 +1313,138 @@ var Tooltip = ({
|
|
|
1312
1313
|
);
|
|
1313
1314
|
};
|
|
1314
1315
|
var Tooltip_default = Tooltip;
|
|
1316
|
+
|
|
1317
|
+
// src/utils/constants.ts
|
|
1315
1318
|
var globalKeyboardShortcuts = [
|
|
1316
|
-
{
|
|
1317
|
-
|
|
1319
|
+
{
|
|
1320
|
+
command: "toggle_theme",
|
|
1321
|
+
shortcut: ["Ctrl", "Shift", "M"],
|
|
1322
|
+
usage: "Toggle between light and dark theme"
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
command: "app_switcher",
|
|
1326
|
+
shortcut: ["Ctrl", "Shift", "S"],
|
|
1327
|
+
usage: "Switch between open apps"
|
|
1328
|
+
},
|
|
1329
|
+
{
|
|
1330
|
+
command: "exit_app",
|
|
1331
|
+
shortcut: ["Ctrl", "E"],
|
|
1332
|
+
usage: "Exit or quit the application"
|
|
1333
|
+
},
|
|
1334
|
+
{
|
|
1335
|
+
command: "maximize_app",
|
|
1336
|
+
shortcut: ["Ctrl", "ArrowUp"],
|
|
1337
|
+
usage: "Maximize the application window"
|
|
1338
|
+
},
|
|
1339
|
+
{
|
|
1340
|
+
command: "minimize_app",
|
|
1341
|
+
shortcut: ["Ctrl", "ArrowDown"],
|
|
1342
|
+
usage: "Minimize the application window"
|
|
1343
|
+
},
|
|
1344
|
+
{
|
|
1345
|
+
command: "global_search",
|
|
1346
|
+
shortcut: ["Ctrl", "Shift", "K"],
|
|
1347
|
+
usage: "Open global search"
|
|
1348
|
+
},
|
|
1349
|
+
{
|
|
1350
|
+
command: "toggle_search_mode",
|
|
1351
|
+
shortcut: ["Ctrl", "Shift", "L"],
|
|
1352
|
+
usage: "Enable AI and Voice command (start/stop voice input in search)"
|
|
1353
|
+
},
|
|
1354
|
+
{
|
|
1355
|
+
command: "toggle_control_center",
|
|
1356
|
+
shortcut: ["Ctrl", "Shift", "O"],
|
|
1357
|
+
usage: "Toggle control center panel or drawer"
|
|
1358
|
+
},
|
|
1359
|
+
{
|
|
1360
|
+
command: "arrow_up",
|
|
1361
|
+
shortcut: ["ArrowUp"],
|
|
1362
|
+
usage: "Navigate up in lists, menus and options"
|
|
1363
|
+
},
|
|
1364
|
+
{
|
|
1365
|
+
command: "arrow_down",
|
|
1366
|
+
shortcut: ["ArrowDown"],
|
|
1367
|
+
usage: "Navigate down in lists, menus and options"
|
|
1368
|
+
},
|
|
1369
|
+
{
|
|
1370
|
+
command: "escape_button_action",
|
|
1371
|
+
shortcut: ["Escape"],
|
|
1372
|
+
usage: "Close or go back from any open alert, popup, search, or control center"
|
|
1373
|
+
},
|
|
1374
|
+
{
|
|
1375
|
+
command: "enter_button_action",
|
|
1376
|
+
shortcut: ["Enter"],
|
|
1377
|
+
usage: "Select or confirm the currently focused item"
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
command: "toggle_filters",
|
|
1381
|
+
shortcut: ["Ctrl", "Shift", "U"],
|
|
1382
|
+
usage: "To open or close filters of any current active app"
|
|
1383
|
+
},
|
|
1384
|
+
{
|
|
1385
|
+
command: "focus_search",
|
|
1386
|
+
shortcut: ["Ctrl", "k"],
|
|
1387
|
+
usage: "Focus on current app search"
|
|
1388
|
+
},
|
|
1389
|
+
{
|
|
1390
|
+
command: "toggle_all_apps",
|
|
1391
|
+
shortcut: ["Ctrl", "Shift", "A"],
|
|
1392
|
+
usage: "Toggle showing all available apps and plugins"
|
|
1393
|
+
}
|
|
1318
1394
|
];
|
|
1319
1395
|
var keyMap = {
|
|
1396
|
+
mac: {
|
|
1397
|
+
ctrl: "\u2318",
|
|
1398
|
+
alt: "\u2325",
|
|
1399
|
+
shift: "\u21E7",
|
|
1400
|
+
enter: "\u23CE",
|
|
1401
|
+
backspace: "\u232B",
|
|
1402
|
+
arrowup: "\u2191",
|
|
1403
|
+
arrowdown: "\u2193"
|
|
1404
|
+
},
|
|
1320
1405
|
windows: {
|
|
1321
1406
|
ctrl: "Ctrl",
|
|
1322
1407
|
alt: "Alt",
|
|
1323
1408
|
shift: "Shift",
|
|
1324
|
-
meta: "Win",
|
|
1325
|
-
escape: "Esc",
|
|
1326
1409
|
enter: "Enter",
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
ctrl: "Ctrl",
|
|
1331
|
-
alt: "\u2325",
|
|
1332
|
-
shift: "\u21E7",
|
|
1333
|
-
meta: "\u2318",
|
|
1334
|
-
escape: "Esc",
|
|
1335
|
-
enter: "Enter",
|
|
1336
|
-
k: "K"
|
|
1410
|
+
backspace: "Backspace",
|
|
1411
|
+
arrowup: "\u2191",
|
|
1412
|
+
arrowdown: "\u2193"
|
|
1337
1413
|
},
|
|
1338
1414
|
linux: {
|
|
1339
1415
|
ctrl: "Ctrl",
|
|
1340
1416
|
alt: "Alt",
|
|
1341
1417
|
shift: "Shift",
|
|
1342
|
-
meta: "Meta",
|
|
1343
|
-
escape: "Esc",
|
|
1344
1418
|
enter: "Enter",
|
|
1345
|
-
|
|
1419
|
+
backspace: "Backspace",
|
|
1420
|
+
arrowup: "\u2191",
|
|
1421
|
+
arrowdown: "\u2193"
|
|
1346
1422
|
}
|
|
1347
1423
|
};
|
|
1348
1424
|
var detectOS = () => {
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
if (
|
|
1354
|
-
|
|
1355
|
-
return "linux";
|
|
1425
|
+
const parser = new uaParserJs.UAParser();
|
|
1426
|
+
const osName = parser.getOS().name?.toLowerCase() || "";
|
|
1427
|
+
if (osName.includes("mac")) return "mac";
|
|
1428
|
+
if (osName.includes("windows")) return "windows";
|
|
1429
|
+
if (osName.includes("linux")) return "linux";
|
|
1430
|
+
return "windows";
|
|
1356
1431
|
};
|
|
1432
|
+
var normalizeKey = (key) => key.toLowerCase();
|
|
1357
1433
|
var matchShortcut = (event, shortcut, os) => {
|
|
1358
|
-
const
|
|
1359
|
-
const
|
|
1360
|
-
if (
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
if (
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
return matchesPrimaryKey && shiftMatches;
|
|
1434
|
+
const keySet = new Set(shortcut.map(normalizeKey));
|
|
1435
|
+
const pressed = [];
|
|
1436
|
+
if (os === "mac") {
|
|
1437
|
+
if (event.metaKey) pressed.push("ctrl");
|
|
1438
|
+
} else {
|
|
1439
|
+
if (event.ctrlKey) pressed.push("ctrl");
|
|
1440
|
+
}
|
|
1441
|
+
if (event.altKey) pressed.push("alt");
|
|
1442
|
+
if (event.shiftKey) pressed.push("shift");
|
|
1443
|
+
if (event.key && !["Control", "Meta", "Alt", "Shift"].includes(event.key)) {
|
|
1444
|
+
pressed.push(normalizeKey(event.key));
|
|
1445
|
+
}
|
|
1446
|
+
if (pressed.length !== shortcut.length) return false;
|
|
1447
|
+
return pressed.every((k) => keySet.has(k));
|
|
1373
1448
|
};
|
|
1374
1449
|
var useShortcutFormatter = () => {
|
|
1375
1450
|
const [os, setOS] = React20.useState("windows");
|
|
@@ -1380,7 +1455,7 @@ var useShortcutFormatter = () => {
|
|
|
1380
1455
|
React20.useEffect(() => {
|
|
1381
1456
|
const handleKeyDown = (event) => {
|
|
1382
1457
|
for (const shortcut of globalKeyboardShortcuts) {
|
|
1383
|
-
if (matchShortcut(event, shortcut.shortcut)) {
|
|
1458
|
+
if (matchShortcut(event, shortcut.shortcut, os)) {
|
|
1384
1459
|
const listeners = listenersRef.current.get(shortcut.command);
|
|
1385
1460
|
if (listeners) {
|
|
1386
1461
|
event.preventDefault();
|
|
@@ -1398,7 +1473,7 @@ var useShortcutFormatter = () => {
|
|
|
1398
1473
|
return keys.map((key) => keyMap[os][key.toLowerCase()] || key.toUpperCase()).join(" + ");
|
|
1399
1474
|
};
|
|
1400
1475
|
const getShortcutByCommand = (command) => {
|
|
1401
|
-
const found = globalKeyboardShortcuts.find((
|
|
1476
|
+
const found = globalKeyboardShortcuts.find((s) => s.command === command);
|
|
1402
1477
|
return found ? found.shortcut : [""];
|
|
1403
1478
|
};
|
|
1404
1479
|
const addShortcutListener = (command, listener) => {
|
|
@@ -2040,6 +2115,76 @@ var TableCaption = React20__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
2040
2115
|
}
|
|
2041
2116
|
));
|
|
2042
2117
|
TableCaption.displayName = "TableCaption";
|
|
2118
|
+
var useGridClasses = (windowSize, gridRules) => {
|
|
2119
|
+
const deviceType = React20.useMemo(() => {
|
|
2120
|
+
if (windowSize.width <= 640) return "mobile";
|
|
2121
|
+
if (windowSize.width <= 1024) return "tablet";
|
|
2122
|
+
return "desktop";
|
|
2123
|
+
}, [windowSize]);
|
|
2124
|
+
const gridClasses = React20.useMemo(() => {
|
|
2125
|
+
const classes = {};
|
|
2126
|
+
for (const element in gridRules) {
|
|
2127
|
+
const classRules = gridRules[element];
|
|
2128
|
+
const colSpan = classRules["col-span"][deviceType];
|
|
2129
|
+
classes[element] = `col-span-${deviceType}-${colSpan}`;
|
|
2130
|
+
}
|
|
2131
|
+
return classes;
|
|
2132
|
+
}, [deviceType, gridRules]);
|
|
2133
|
+
return { gridClasses, deviceType };
|
|
2134
|
+
};
|
|
2135
|
+
var useGridClasses_default = useGridClasses;
|
|
2136
|
+
var useDeviceSupport = () => {
|
|
2137
|
+
const [isSupported, setIsSupported] = React20.useState(true);
|
|
2138
|
+
React20.useEffect(() => {
|
|
2139
|
+
function checkSupport() {
|
|
2140
|
+
const ua = typeof window !== "undefined" ? window.navigator.userAgent : "";
|
|
2141
|
+
const width = typeof window !== "undefined" ? window.innerWidth : 1920;
|
|
2142
|
+
const height = typeof window !== "undefined" ? window.innerHeight : 1080;
|
|
2143
|
+
const isTouch = typeof window !== "undefined" ? "ontouchstart" in window : false;
|
|
2144
|
+
const isMobile = /Mobi|Android|iPhone|iPod/.test(ua) && width <= 767;
|
|
2145
|
+
const isTablet = /iPad|Tablet|Android/.test(ua) && !/Mobile/.test(ua) || isTouch && width >= 600 && width <= 1024;
|
|
2146
|
+
const isTabletPortrait = isTablet && width < height;
|
|
2147
|
+
const isTabletLandscape = isTablet && width > height && width >= 1024 && width <= 1366;
|
|
2148
|
+
const isLaptop = width >= 1024 && !isMobile && (!isTablet || isTabletLandscape);
|
|
2149
|
+
if (isMobile) {
|
|
2150
|
+
setIsSupported(false);
|
|
2151
|
+
} else if (isTabletPortrait) {
|
|
2152
|
+
setIsSupported(false);
|
|
2153
|
+
} else if (isTabletLandscape) {
|
|
2154
|
+
setIsSupported(true);
|
|
2155
|
+
} else if (isLaptop) {
|
|
2156
|
+
setIsSupported(true);
|
|
2157
|
+
} else {
|
|
2158
|
+
setIsSupported(true);
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
checkSupport();
|
|
2162
|
+
window.addEventListener("resize", checkSupport);
|
|
2163
|
+
return () => window.removeEventListener("resize", checkSupport);
|
|
2164
|
+
}, []);
|
|
2165
|
+
return isSupported;
|
|
2166
|
+
};
|
|
2167
|
+
var soundMap = {
|
|
2168
|
+
click: "/sounds/click-tone.wav",
|
|
2169
|
+
alert: "/sounds/error-tone.wav",
|
|
2170
|
+
notification: "/sounds/notification-tone.wav",
|
|
2171
|
+
error: "/sounds/error-tone.wav",
|
|
2172
|
+
success: "/sounds/success-tone.wav",
|
|
2173
|
+
swipe: "/sounds/swipe-tone.wav"
|
|
2174
|
+
};
|
|
2175
|
+
var useSound = () => {
|
|
2176
|
+
const playSound = React20.useCallback((type) => {
|
|
2177
|
+
if (typeof window === "undefined" || typeof window.Audio === "undefined") {
|
|
2178
|
+
return;
|
|
2179
|
+
}
|
|
2180
|
+
const soundSrc = soundMap[type];
|
|
2181
|
+
const audio = new window.Audio(soundSrc);
|
|
2182
|
+
audio.play().catch((err) => {
|
|
2183
|
+
console.error("Sound playback failed:", err);
|
|
2184
|
+
});
|
|
2185
|
+
}, []);
|
|
2186
|
+
return { playSound };
|
|
2187
|
+
};
|
|
2043
2188
|
|
|
2044
2189
|
exports.Accordion = Accordion_default;
|
|
2045
2190
|
exports.Alert = Alert_default;
|
|
@@ -2074,5 +2219,9 @@ exports.Toast = Toast_default;
|
|
|
2074
2219
|
exports.Toggle = Toggle_default;
|
|
2075
2220
|
exports.Tooltip = Tooltip_default;
|
|
2076
2221
|
exports.Typography = Typography_default;
|
|
2222
|
+
exports.useDeviceSupport = useDeviceSupport;
|
|
2223
|
+
exports.useGridClasses = useGridClasses_default;
|
|
2224
|
+
exports.useShortcutFormatter = useShortcutFormatter_default;
|
|
2225
|
+
exports.useSound = useSound;
|
|
2077
2226
|
//# sourceMappingURL=index.cjs.map
|
|
2078
2227
|
//# sourceMappingURL=index.cjs.map
|