@hanzo/ui 5.3.35 → 5.3.36
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/bin/create-registry.js +0 -0
- package/bin/npx-registry-mcp.js +0 -0
- package/bin/registry-mcp-wrapper.sh +0 -0
- package/bin/registry-mcp.js +0 -0
- package/bin/start-mcp-server.sh +0 -0
- package/bin/test-mcp.sh +0 -0
- package/dist/3d/button.js +1 -297
- package/dist/3d/button.mjs +1 -272
- package/dist/3d/card.js +1 -233
- package/dist/3d/card.mjs +1 -206
- package/dist/3d/carousel.js +1 -370
- package/dist/3d/carousel.mjs +1 -343
- package/dist/3d/grid.js +1 -361
- package/dist/3d/grid.mjs +1 -336
- package/dist/3d/index.js +1 -1517
- package/dist/3d/index.mjs +1 -1471
- package/dist/3d/marquee.js +1 -351
- package/dist/3d/marquee.mjs +1 -326
- package/dist/3d/pin.js +1 -45
- package/dist/3d/pin.mjs +1 -23
- package/dist/accordion.js +1 -79
- package/dist/accordion.mjs +1 -54
- package/dist/alert-dialog.js +1 -224
- package/dist/alert-dialog.mjs +1 -191
- package/dist/alert.js +1 -97
- package/dist/alert.mjs +1 -91
- package/dist/animation/animated-background.js +1 -423
- package/dist/animation/animated-background.mjs +1 -417
- package/dist/animation/animated-beam.js +1 -118
- package/dist/animation/animated-beam.mjs +1 -96
- package/dist/animation/animated-cursor.js +1 -274
- package/dist/animation/animated-cursor.mjs +1 -269
- package/dist/animation/animated-icon.js +2 -356
- package/dist/animation/animated-icon.mjs +2 -350
- package/dist/animation/animated-list.js +1 -338
- package/dist/animation/animated-list.mjs +1 -332
- package/dist/animation/animated-number.js +1 -282
- package/dist/animation/animated-number.mjs +1 -276
- package/dist/animation/animated-testimonials.js +1 -96
- package/dist/animation/animated-testimonials.mjs +1 -74
- package/dist/animation/animated-tooltip.js +1 -66
- package/dist/animation/animated-tooltip.mjs +1 -44
- package/dist/animation/apple-cards-carousel.js +1 -307
- package/dist/animation/apple-cards-carousel.mjs +1 -284
- package/dist/animation/apple-hello-effect.js +1 -59
- package/dist/animation/apple-hello-effect.mjs +1 -37
- package/dist/animation/index.js +2 -1951
- package/dist/animation/index.mjs +2 -1920
- package/dist/avatar.js +1 -70
- package/dist/avatar.mjs +1 -46
- package/dist/badge.js +1 -60
- package/dist/badge.mjs +1 -54
- package/dist/blocks/index.js +2 -1684
- package/dist/blocks/index.mjs +2 -1645
- package/dist/breadcrumb.js +1 -106
- package/dist/breadcrumb.mjs +1 -98
- package/dist/calendar-ext/index.js +1 -207
- package/dist/calendar-ext/index.mjs +1 -169
- package/dist/calendar.js +1 -193
- package/dist/calendar.mjs +1 -168
- package/dist/carousel.js +1 -282
- package/dist/carousel.mjs +1 -253
- package/dist/charts/index.js +6 -5840
- package/dist/charts/index.mjs +6 -5749
- package/dist/checkbox.js +1 -59
- package/dist/checkbox.mjs +1 -34
- package/dist/code/block.js +2 -225
- package/dist/code/block.mjs +2 -202
- package/dist/code/compare.js +5 -444
- package/dist/code/compare.mjs +5 -421
- package/dist/code/diff.js +12 -429
- package/dist/code/diff.mjs +11 -405
- package/dist/code/editor.js +1 -242
- package/dist/code/editor.mjs +1 -217
- package/dist/code/explorer.js +1 -290
- package/dist/code/explorer.mjs +1 -267
- package/dist/code/index.js +26 -2514
- package/dist/code/index.mjs +24 -2471
- package/dist/code/preview.js +6 -363
- package/dist/code/preview.mjs +6 -340
- package/dist/code/snippet.js +2 -273
- package/dist/code/snippet.mjs +2 -249
- package/dist/code/tabs.js +1 -74
- package/dist/code/tabs.mjs +1 -52
- package/dist/code/terminal.js +3 -436
- package/dist/code/terminal.mjs +3 -413
- package/dist/collapsible.js +1 -32
- package/dist/collapsible.mjs +1 -8
- package/dist/command.js +1 -282
- package/dist/command.mjs +1 -251
- package/dist/context-menu.js +1 -206
- package/dist/context-menu.mjs +1 -170
- package/dist/desktop/hooks.js +1 -223
- package/dist/desktop/hooks.mjs +1 -198
- package/dist/desktop/index.js +1 -685
- package/dist/desktop/index.mjs +1 -657
- package/dist/desktop/spotlight.js +1 -260
- package/dist/desktop/spotlight.mjs +1 -235
- package/dist/desktop/window.js +1 -273
- package/dist/desktop/window.mjs +1 -247
- package/dist/device/index.js +1 -2
- package/dist/device/index.mjs +0 -1
- package/dist/dialog.js +1 -245
- package/dist/dialog.mjs +1 -213
- package/dist/dock/basic.js +1 -173
- package/dist/dock/basic.mjs +1 -150
- package/dist/dock/index.js +1 -647
- package/dist/dock/index.mjs +1 -620
- package/dist/dock/limelight-nav.js +1 -314
- package/dist/dock/limelight-nav.mjs +1 -293
- package/dist/dock/macos.js +1 -140
- package/dist/dock/macos.mjs +1 -117
- package/dist/dock/menu.js +1 -69
- package/dist/dock/menu.mjs +1 -47
- package/dist/dock/message.js +1 -148
- package/dist/dock/message.mjs +1 -126
- package/dist/drawer.js +1 -114
- package/dist/drawer.mjs +1 -102
- package/dist/dropdown-menu.js +1 -201
- package/dist/dropdown-menu.mjs +1 -165
- package/dist/finance/AdvancedChart.js +2 -47
- package/dist/finance/AdvancedChart.mjs +2 -45
- package/dist/finance/CompanyProfile.js +2 -47
- package/dist/finance/CompanyProfile.mjs +2 -45
- package/dist/finance/CryptoScreener.js +2 -44
- package/dist/finance/CryptoScreener.mjs +2 -42
- package/dist/finance/Financials.js +2 -51
- package/dist/finance/Financials.mjs +2 -49
- package/dist/finance/ForexScreener.js +2 -45
- package/dist/finance/ForexScreener.mjs +2 -43
- package/dist/finance/MarketOverview.js +2 -103
- package/dist/finance/MarketOverview.mjs +2 -101
- package/dist/finance/NewsTimeline.js +2 -43
- package/dist/finance/NewsTimeline.mjs +2 -41
- package/dist/finance/OrderEntry.js +1 -130
- package/dist/finance/OrderEntry.mjs +1 -128
- package/dist/finance/OrdersHistory.js +1 -63
- package/dist/finance/OrdersHistory.mjs +1 -61
- package/dist/finance/PositionsList.js +1 -79
- package/dist/finance/PositionsList.mjs +1 -77
- package/dist/finance/StockScreener.js +2 -45
- package/dist/finance/StockScreener.mjs +2 -43
- package/dist/finance/SymbolInfo.js +2 -45
- package/dist/finance/SymbolInfo.mjs +2 -43
- package/dist/finance/TechnicalAnalysis.js +2 -53
- package/dist/finance/TechnicalAnalysis.mjs +2 -51
- package/dist/finance/TickerTape.js +2 -55
- package/dist/finance/TickerTape.mjs +2 -53
- package/dist/finance/TradingPanel.js +1 -190
- package/dist/finance/TradingPanel.mjs +1 -188
- package/dist/finance/index.js +2 -929
- package/dist/finance/index.mjs +2 -913
- package/dist/form/index.js +1 -153
- package/dist/form/index.mjs +1 -123
- package/dist/form.js +1 -171
- package/dist/form.mjs +1 -141
- package/dist/hover-card.js +1 -57
- package/dist/hover-card.mjs +1 -33
- package/dist/index.js +192 -9618
- package/dist/index.mjs +192 -9202
- package/dist/input-otp.js +1 -78
- package/dist/input-otp.mjs +1 -53
- package/dist/kanban/index.js +1 -593
- package/dist/kanban/index.mjs +1 -571
- package/dist/lib/utils.js +1 -28
- package/dist/lib/utils.mjs +1 -24
- package/dist/mermaid/index.js +1 -280
- package/dist/mermaid/index.mjs +1 -253
- package/dist/navigation/index.js +1 -97
- package/dist/navigation/index.mjs +1 -78
- package/dist/navigation-menu.js +1 -148
- package/dist/navigation-menu.mjs +1 -115
- package/dist/pattern/grid-pattern.js +3 -325
- package/dist/pattern/grid-pattern.mjs +3 -302
- package/dist/pattern/index.js +3 -325
- package/dist/pattern/index.mjs +3 -302
- package/dist/popover.js +1 -62
- package/dist/popover.mjs +1 -36
- package/dist/progress.js +1 -61
- package/dist/progress.mjs +1 -36
- package/dist/project/gantt.js +1 -64
- package/dist/project/gantt.mjs +1 -42
- package/dist/project/index.js +1 -635
- package/dist/project/index.mjs +1 -610
- package/dist/project/kanban.js +1 -596
- package/dist/project/kanban.mjs +1 -571
- package/dist/project/list.js +1 -34
- package/dist/project/list.mjs +1 -11
- package/dist/radio-group.js +1 -67
- package/dist/radio-group.mjs +1 -44
- package/dist/resizable.js +1 -71
- package/dist/resizable.mjs +1 -47
- package/dist/scroll-area.js +1 -88
- package/dist/scroll-area.mjs +1 -65
- package/dist/select.js +1 -139
- package/dist/select.mjs +1 -110
- package/dist/separator.js +1 -58
- package/dist/separator.mjs +1 -33
- package/dist/sheet.js +1 -147
- package/dist/sheet.mjs +1 -116
- package/dist/skeleton.js +1 -31
- package/dist/skeleton.mjs +1 -26
- package/dist/slider.js +1 -98
- package/dist/slider.mjs +1 -72
- package/dist/sonner.js +1 -33
- package/dist/sonner.mjs +1 -28
- package/dist/spline/index.js +1 -210
- package/dist/spline/index.mjs +1 -201
- package/dist/spline/media-stack.js +1 -192
- package/dist/spline/media-stack.mjs +1 -184
- package/dist/spline/player.js +1 -36
- package/dist/spline/player.mjs +1 -30
- package/dist/switch.js +1 -61
- package/dist/switch.mjs +1 -36
- package/dist/table.js +1 -109
- package/dist/table.mjs +1 -100
- package/dist/tabs.js +1 -127
- package/dist/tabs.mjs +1 -101
- package/dist/tailwind/index.mjs +1 -2011
- package/dist/textarea.js +1 -77
- package/dist/textarea.mjs +1 -55
- package/dist/toggle-group.js +1 -117
- package/dist/toggle-group.mjs +1 -92
- package/dist/toggle.js +1 -70
- package/dist/toggle.mjs +1 -47
- package/dist/tooltip.js +1 -66
- package/dist/tooltip.mjs +1 -39
- package/dist/types/index.mjs +1 -51
- package/dist/ui/announcement.js +1 -133
- package/dist/ui/announcement.mjs +1 -111
- package/dist/ui/avatar-group.js +1 -87
- package/dist/ui/avatar-group.mjs +1 -64
- package/dist/ui/banner.js +1 -84
- package/dist/ui/banner.mjs +1 -61
- package/dist/ui/cursor.js +1 -77
- package/dist/ui/cursor.mjs +1 -55
- package/dist/ui/index.js +1 -494
- package/dist/ui/index.mjs +1 -461
- package/dist/ui/marquee.js +1 -73
- package/dist/ui/marquee.mjs +1 -51
- package/dist/ui/pill.js +1 -84
- package/dist/ui/pill.mjs +1 -61
- package/dist/ui/spinner.js +1 -27
- package/dist/ui/spinner.mjs +1 -25
- package/dist/ui/tags.js +1 -116
- package/dist/ui/tags.mjs +1 -94
- package/dist/ui/ticker.js +1 -72
- package/dist/ui/ticker.mjs +1 -50
- package/dist/util/index.mjs +1 -404
- package/package.json +28 -27
- package/dist/primitives/index.js +0 -9619
- package/dist/primitives/index.mjs +0 -9203
- package/dist/primitives-export.js +0 -9619
- package/dist/primitives-export.mjs +0 -9203
package/dist/desktop/hooks.mjs
CHANGED
|
@@ -1,199 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
function windowReducer(state, action) {
|
|
7
|
-
switch (action.type) {
|
|
8
|
-
case "OPEN":
|
|
9
|
-
return {
|
|
10
|
-
windows: { ...state.windows, [action.id]: true },
|
|
11
|
-
activeWindow: action.id
|
|
12
|
-
};
|
|
13
|
-
case "CLOSE":
|
|
14
|
-
return {
|
|
15
|
-
windows: { ...state.windows, [action.id]: false },
|
|
16
|
-
activeWindow: state.activeWindow === action.id ? null : state.activeWindow
|
|
17
|
-
};
|
|
18
|
-
case "TOGGLE":
|
|
19
|
-
const isOpen = state.windows[action.id];
|
|
20
|
-
return {
|
|
21
|
-
windows: { ...state.windows, [action.id]: !isOpen },
|
|
22
|
-
activeWindow: !isOpen ? action.id : state.activeWindow === action.id ? null : state.activeWindow
|
|
23
|
-
};
|
|
24
|
-
case "CLOSE_ALL":
|
|
25
|
-
return {
|
|
26
|
-
windows: Object.keys(state.windows).reduce((acc, key) => {
|
|
27
|
-
acc[key] = false;
|
|
28
|
-
return acc;
|
|
29
|
-
}, {}),
|
|
30
|
-
activeWindow: null
|
|
31
|
-
};
|
|
32
|
-
case "SET_ACTIVE":
|
|
33
|
-
return { ...state, activeWindow: action.id };
|
|
34
|
-
default:
|
|
35
|
-
return state;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
__name(windowReducer, "windowReducer");
|
|
39
|
-
function useWindowManager(initialWindows = []) {
|
|
40
|
-
const initialState = {
|
|
41
|
-
windows: initialWindows.reduce((acc, id) => {
|
|
42
|
-
acc[id] = false;
|
|
43
|
-
return acc;
|
|
44
|
-
}, {}),
|
|
45
|
-
activeWindow: null
|
|
46
|
-
};
|
|
47
|
-
const [state, dispatch] = React.useReducer(windowReducer, initialState);
|
|
48
|
-
const openWindows = React.useMemo(() => {
|
|
49
|
-
return Object.entries(state.windows).filter(([_, isOpen2]) => isOpen2).map(([id]) => id);
|
|
50
|
-
}, [state.windows]);
|
|
51
|
-
const openWindow = React.useCallback((id) => {
|
|
52
|
-
dispatch({ type: "OPEN", id });
|
|
53
|
-
}, []);
|
|
54
|
-
const closeWindow = React.useCallback((id) => {
|
|
55
|
-
dispatch({ type: "CLOSE", id });
|
|
56
|
-
}, []);
|
|
57
|
-
const toggleWindow = React.useCallback((id) => {
|
|
58
|
-
dispatch({ type: "TOGGLE", id });
|
|
59
|
-
}, []);
|
|
60
|
-
const focusWindow = React.useCallback((id) => {
|
|
61
|
-
dispatch({ type: "SET_ACTIVE", id });
|
|
62
|
-
}, []);
|
|
63
|
-
const closeAllWindows = React.useCallback(() => {
|
|
64
|
-
dispatch({ type: "CLOSE_ALL" });
|
|
65
|
-
}, []);
|
|
66
|
-
const isOpen = React.useCallback((id) => {
|
|
67
|
-
return state.windows[id] ?? false;
|
|
68
|
-
}, [state.windows]);
|
|
69
|
-
return {
|
|
70
|
-
windows: state.windows,
|
|
71
|
-
activeWindow: state.activeWindow,
|
|
72
|
-
openWindows,
|
|
73
|
-
openWindow,
|
|
74
|
-
closeWindow,
|
|
75
|
-
toggleWindow,
|
|
76
|
-
focusWindow,
|
|
77
|
-
closeAllWindows,
|
|
78
|
-
isOpen
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
__name(useWindowManager, "useWindowManager");
|
|
82
|
-
var defaultSettings = {
|
|
83
|
-
theme: "default",
|
|
84
|
-
colorScheme: "dark",
|
|
85
|
-
backgroundImage: void 0,
|
|
86
|
-
backgroundColor: void 0,
|
|
87
|
-
dockPosition: "bottom",
|
|
88
|
-
dockSize: 64,
|
|
89
|
-
dockMagnification: true,
|
|
90
|
-
dockAutoHide: false,
|
|
91
|
-
windowTransparency: 20,
|
|
92
|
-
fontSize: "medium",
|
|
93
|
-
reducedMotion: false
|
|
94
|
-
};
|
|
95
|
-
var STORAGE_KEY = "desktop-settings";
|
|
96
|
-
function loadSettings() {
|
|
97
|
-
if (typeof window === "undefined") return defaultSettings;
|
|
98
|
-
try {
|
|
99
|
-
const stored = localStorage.getItem(STORAGE_KEY);
|
|
100
|
-
if (stored) {
|
|
101
|
-
return { ...defaultSettings, ...JSON.parse(stored) };
|
|
102
|
-
}
|
|
103
|
-
} catch {
|
|
104
|
-
}
|
|
105
|
-
return defaultSettings;
|
|
106
|
-
}
|
|
107
|
-
__name(loadSettings, "loadSettings");
|
|
108
|
-
function saveSettings(settings) {
|
|
109
|
-
if (typeof window === "undefined") return;
|
|
110
|
-
try {
|
|
111
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(settings));
|
|
112
|
-
} catch {
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
__name(saveSettings, "saveSettings");
|
|
116
|
-
function useDesktopSettings() {
|
|
117
|
-
const [settings, setSettings] = React.useState(loadSettings);
|
|
118
|
-
React.useEffect(() => {
|
|
119
|
-
saveSettings(settings);
|
|
120
|
-
}, [settings]);
|
|
121
|
-
const updateSetting = /* @__PURE__ */ __name((key, value) => {
|
|
122
|
-
setSettings((prev) => ({ ...prev, [key]: value }));
|
|
123
|
-
}, "updateSetting");
|
|
124
|
-
return {
|
|
125
|
-
...settings,
|
|
126
|
-
setTheme: /* @__PURE__ */ __name((theme) => updateSetting("theme", theme), "setTheme"),
|
|
127
|
-
setColorScheme: /* @__PURE__ */ __name((scheme) => updateSetting("colorScheme", scheme), "setColorScheme"),
|
|
128
|
-
setBackgroundImage: /* @__PURE__ */ __name((url) => updateSetting("backgroundImage", url), "setBackgroundImage"),
|
|
129
|
-
setBackgroundColor: /* @__PURE__ */ __name((color) => updateSetting("backgroundColor", color), "setBackgroundColor"),
|
|
130
|
-
setDockPosition: /* @__PURE__ */ __name((position) => updateSetting("dockPosition", position), "setDockPosition"),
|
|
131
|
-
setDockSize: /* @__PURE__ */ __name((size) => updateSetting("dockSize", size), "setDockSize"),
|
|
132
|
-
setDockMagnification: /* @__PURE__ */ __name((enabled) => updateSetting("dockMagnification", enabled), "setDockMagnification"),
|
|
133
|
-
setDockAutoHide: /* @__PURE__ */ __name((enabled) => updateSetting("dockAutoHide", enabled), "setDockAutoHide"),
|
|
134
|
-
setWindowTransparency: /* @__PURE__ */ __name((value) => updateSetting("windowTransparency", value), "setWindowTransparency"),
|
|
135
|
-
setFontSize: /* @__PURE__ */ __name((size) => updateSetting("fontSize", size), "setFontSize"),
|
|
136
|
-
setReducedMotion: /* @__PURE__ */ __name((enabled) => updateSetting("reducedMotion", enabled), "setReducedMotion"),
|
|
137
|
-
toggleDarkMode: /* @__PURE__ */ __name(() => {
|
|
138
|
-
setSettings((prev) => ({
|
|
139
|
-
...prev,
|
|
140
|
-
colorScheme: prev.colorScheme === "dark" ? "light" : "dark"
|
|
141
|
-
}));
|
|
142
|
-
}, "toggleDarkMode"),
|
|
143
|
-
resetToDefaults: /* @__PURE__ */ __name(() => setSettings(defaultSettings), "resetToDefaults")
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
__name(useDesktopSettings, "useDesktopSettings");
|
|
147
|
-
function useOverlayManager() {
|
|
148
|
-
const [overlays, setOverlays] = React.useState({
|
|
149
|
-
spotlight: false,
|
|
150
|
-
contextMenu: false,
|
|
151
|
-
modal: false,
|
|
152
|
-
drawer: false
|
|
153
|
-
});
|
|
154
|
-
const isOpen = React.useCallback((id) => overlays[id] ?? false, [overlays]);
|
|
155
|
-
const open = React.useCallback((id) => {
|
|
156
|
-
setOverlays((prev) => ({ ...prev, [id]: true }));
|
|
157
|
-
}, []);
|
|
158
|
-
const close = React.useCallback((id) => {
|
|
159
|
-
setOverlays((prev) => ({ ...prev, [id]: false }));
|
|
160
|
-
}, []);
|
|
161
|
-
const toggle = React.useCallback((id) => {
|
|
162
|
-
setOverlays((prev) => ({ ...prev, [id]: !prev[id] }));
|
|
163
|
-
}, []);
|
|
164
|
-
const closeAll = React.useCallback(() => {
|
|
165
|
-
setOverlays(
|
|
166
|
-
(prev) => Object.keys(prev).reduce((acc, key) => {
|
|
167
|
-
acc[key] = false;
|
|
168
|
-
return acc;
|
|
169
|
-
}, {})
|
|
170
|
-
);
|
|
171
|
-
}, []);
|
|
172
|
-
return { overlays, isOpen, open, close, toggle, closeAll };
|
|
173
|
-
}
|
|
174
|
-
__name(useOverlayManager, "useOverlayManager");
|
|
175
|
-
function useKeyboardShortcuts(shortcuts) {
|
|
176
|
-
React.useEffect(() => {
|
|
177
|
-
const handleKeyDown = /* @__PURE__ */ __name((e) => {
|
|
178
|
-
for (const shortcut of shortcuts) {
|
|
179
|
-
const metaMatch = shortcut.meta ? e.metaKey || e.ctrlKey : !e.metaKey;
|
|
180
|
-
const ctrlMatch = shortcut.ctrl ? e.ctrlKey : true;
|
|
181
|
-
const altMatch = shortcut.alt ? e.altKey : !e.altKey;
|
|
182
|
-
const shiftMatch = shortcut.shift ? e.shiftKey : !e.shiftKey;
|
|
183
|
-
const keyMatch = e.key.toLowerCase() === shortcut.key.toLowerCase();
|
|
184
|
-
if (keyMatch && metaMatch && ctrlMatch && altMatch && shiftMatch) {
|
|
185
|
-
if (shortcut.preventDefault !== false) {
|
|
186
|
-
e.preventDefault();
|
|
187
|
-
}
|
|
188
|
-
shortcut.action();
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}, "handleKeyDown");
|
|
193
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
194
|
-
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
195
|
-
}, [shortcuts]);
|
|
196
|
-
}
|
|
197
|
-
__name(useKeyboardShortcuts, "useKeyboardShortcuts");
|
|
198
|
-
|
|
199
|
-
export { useDesktopSettings, useKeyboardShortcuts, useOverlayManager, useWindowManager };
|
|
2
|
+
import*as d from'react';var S=Object.defineProperty;var i=(t,n)=>S(t,"name",{value:n,configurable:true});function W(t,n){switch(n.type){case "OPEN":return {windows:{...t.windows,[n.id]:true},activeWindow:n.id};case "CLOSE":return {windows:{...t.windows,[n.id]:false},activeWindow:t.activeWindow===n.id?null:t.activeWindow};case "TOGGLE":let o=t.windows[n.id];return {windows:{...t.windows,[n.id]:!o},activeWindow:o?t.activeWindow===n.id?null:t.activeWindow:n.id};case "CLOSE_ALL":return {windows:Object.keys(t.windows).reduce((e,c)=>(e[c]=false,e),{}),activeWindow:null};case "SET_ACTIVE":return {...t,activeWindow:n.id};default:return t}}i(W,"windowReducer");function m(t=[]){let n={windows:t.reduce((a,f)=>(a[f]=false,a),{}),activeWindow:null},[o,e]=d.useReducer(W,n),c=d.useMemo(()=>Object.entries(o.windows).filter(([a,f])=>f).map(([a])=>a),[o.windows]),l=d.useCallback(a=>{e({type:"OPEN",id:a});},[]),w=d.useCallback(a=>{e({type:"CLOSE",id:a});},[]),s=d.useCallback(a=>{e({type:"TOGGLE",id:a});},[]),r=d.useCallback(a=>{e({type:"SET_ACTIVE",id:a});},[]),g=d.useCallback(()=>{e({type:"CLOSE_ALL"});},[]),p=d.useCallback(a=>o.windows[a]??false,[o.windows]);return {windows:o.windows,activeWindow:o.activeWindow,openWindows:c,openWindow:l,closeWindow:w,toggleWindow:s,focusWindow:r,closeAllWindows:g,isOpen:p}}i(m,"useWindowManager");var u={theme:"default",colorScheme:"dark",backgroundImage:void 0,backgroundColor:void 0,dockPosition:"bottom",dockSize:64,dockMagnification:true,dockAutoHide:false,windowTransparency:20,fontSize:"medium",reducedMotion:false},k="desktop-settings";function y(){if(typeof window>"u")return u;try{let t=localStorage.getItem(k);if(t)return {...u,...JSON.parse(t)}}catch{}return u}i(y,"loadSettings");function v(t){if(!(typeof window>"u"))try{localStorage.setItem(k,JSON.stringify(t));}catch{}}i(v,"saveSettings");function h(){let[t,n]=d.useState(y);d.useEffect(()=>{v(t);},[t]);let o=i((e,c)=>{n(l=>({...l,[e]:c}));},"updateSetting");return {...t,setTheme:i(e=>o("theme",e),"setTheme"),setColorScheme:i(e=>o("colorScheme",e),"setColorScheme"),setBackgroundImage:i(e=>o("backgroundImage",e),"setBackgroundImage"),setBackgroundColor:i(e=>o("backgroundColor",e),"setBackgroundColor"),setDockPosition:i(e=>o("dockPosition",e),"setDockPosition"),setDockSize:i(e=>o("dockSize",e),"setDockSize"),setDockMagnification:i(e=>o("dockMagnification",e),"setDockMagnification"),setDockAutoHide:i(e=>o("dockAutoHide",e),"setDockAutoHide"),setWindowTransparency:i(e=>o("windowTransparency",e),"setWindowTransparency"),setFontSize:i(e=>o("fontSize",e),"setFontSize"),setReducedMotion:i(e=>o("reducedMotion",e),"setReducedMotion"),toggleDarkMode:i(()=>{n(e=>({...e,colorScheme:e.colorScheme==="dark"?"light":"dark"}));},"toggleDarkMode"),resetToDefaults:i(()=>n(u),"resetToDefaults")}}i(h,"useDesktopSettings");function C(){let[t,n]=d.useState({spotlight:false,contextMenu:false,modal:false,drawer:false}),o=d.useCallback(s=>t[s]??false,[t]),e=d.useCallback(s=>{n(r=>({...r,[s]:true}));},[]),c=d.useCallback(s=>{n(r=>({...r,[s]:false}));},[]),l=d.useCallback(s=>{n(r=>({...r,[s]:!r[s]}));},[]),w=d.useCallback(()=>{n(s=>Object.keys(s).reduce((r,g)=>(r[g]=false,r),{}));},[]);return {overlays:t,isOpen:o,open:e,close:c,toggle:l,closeAll:w}}i(C,"useOverlayManager");function M(t){d.useEffect(()=>{let n=i(o=>{for(let e of t){let c=e.meta?o.metaKey||o.ctrlKey:!o.metaKey,l=e.ctrl?o.ctrlKey:true,w=e.alt?o.altKey:!o.altKey,s=e.shift?o.shiftKey:!o.shiftKey;if(o.key.toLowerCase()===e.key.toLowerCase()&&c&&l&&w&&s){e.preventDefault!==false&&o.preventDefault(),e.action();return}}},"handleKeyDown");return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]);}i(M,"useKeyboardShortcuts");export{h as useDesktopSettings,M as useKeyboardShortcuts,C as useOverlayManager,m as useWindowManager};
|