ssovee-os-web-ui 0.1.21 → 0.1.22
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 +3 -1
- package/dist/index.cjs +136 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +110 -0
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +136 -43
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -85,8 +85,10 @@ The package exports these components and types for external use:
|
|
|
85
85
|
- `Typography`
|
|
86
86
|
- `ImageWithPlaceholder`
|
|
87
87
|
- `Table` and its subcomponents
|
|
88
|
+
- `useGridClasses`
|
|
89
|
+
- `useShortcutFormatter`
|
|
88
90
|
|
|
89
|
-
|
|
91
|
+
The hooks are exported from the package entrypoint alongside the components.
|
|
90
92
|
|
|
91
93
|
## License
|
|
92
94
|
|
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,24 @@ 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;
|
|
2043
2136
|
|
|
2044
2137
|
exports.Accordion = Accordion_default;
|
|
2045
2138
|
exports.Alert = Alert_default;
|
|
@@ -2074,5 +2167,7 @@ exports.Toast = Toast_default;
|
|
|
2074
2167
|
exports.Toggle = Toggle_default;
|
|
2075
2168
|
exports.Tooltip = Tooltip_default;
|
|
2076
2169
|
exports.Typography = Typography_default;
|
|
2170
|
+
exports.useGridClasses = useGridClasses_default;
|
|
2171
|
+
exports.useShortcutFormatter = useShortcutFormatter_default;
|
|
2077
2172
|
//# sourceMappingURL=index.cjs.map
|
|
2078
2173
|
//# sourceMappingURL=index.cjs.map
|